1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#ifndef lint 31static const char rcsid[] = |
32 "$FreeBSD: head/sbin/ifconfig/af_inet6.c 146187 2005-05-13 16:31:11Z ume $"; |
33#endif /* not lint */ 34 35#include <sys/param.h> 36#include <sys/ioctl.h> 37#include <sys/socket.h> 38#include <net/if.h> 39#include <net/route.h> /* for RTX_IFA */ 40 --- 11 unchanged lines hidden (view full) --- 52#include <netinet/in_var.h> 53#include <arpa/inet.h> 54#include <netdb.h> 55 56#include <netinet6/nd6.h> /* Define ND6_INFINITE_LIFETIME */ 57 58#include "ifconfig.h" 59 |
60static struct in6_ifreq in6_ridreq; 61static struct in6_aliasreq in6_addreq = 62 { { 0 }, 63 { 0 }, 64 { 0 }, 65 { 0 }, 66 0, 67 { 0, 0, ND6_INFINITE_LIFETIME, ND6_INFINITE_LIFETIME } }; --- 158 unchanged lines hidden (view full) --- 226 index = *(u_short *)&sin->sin6_addr.s6_addr[2]; 227 *(u_short *)&sin->sin6_addr.s6_addr[2] = 0; 228 if (sin->sin6_scope_id == 0) 229 sin->sin6_scope_id = ntohs(index); 230 } 231 scopeid = sin->sin6_scope_id; 232 233 error = getnameinfo((struct sockaddr *)sin, sin->sin6_len, addr_buf, |
234 sizeof(addr_buf), NULL, 0, NI_NUMERICHOST); |
235 if (error != 0) 236 inet_ntop(AF_INET6, &sin->sin6_addr, addr_buf, 237 sizeof(addr_buf)); 238 printf("\tinet6 %s ", addr_buf); 239 240 if (flags & IFF_POINTOPOINT) { 241 /* note RTAX_BRD overlap with IFF_BROADCAST */ 242 sin = (struct sockaddr_in6 *)info->rti_info[RTAX_BRD]; --- 13 unchanged lines hidden (view full) --- 256 *(u_short *)&sin->sin6_addr.s6_addr[2] = 0; 257 if (sin->sin6_scope_id == 0) 258 sin->sin6_scope_id = ntohs(index); 259 } 260 261 error = getnameinfo((struct sockaddr *)sin, 262 sin->sin6_len, addr_buf, 263 sizeof(addr_buf), NULL, 0, |
264 NI_NUMERICHOST); |
265 if (error != 0) 266 inet_ntop(AF_INET6, &sin->sin6_addr, addr_buf, 267 sizeof(addr_buf)); 268 printf("--> %s ", addr_buf); 269 } 270 } 271 272 sin = (struct sockaddr_in6 *)info->rti_info[RTAX_NETMASK]; --- 170 unchanged lines hidden (view full) --- 443 } 444} 445 446static void 447in6_status_tunnel(int s) 448{ 449 char src[NI_MAXHOST]; 450 char dst[NI_MAXHOST]; |
451 struct in6_ifreq in6_ifr; 452 const struct sockaddr *sa = (const struct sockaddr *) &in6_ifr.ifr_addr; 453 454 memset(&in6_ifr, 0, sizeof(in6_ifr)); 455 strncpy(in6_ifr.ifr_name, name, IFNAMSIZ); 456 457 if (ioctl(s, SIOCGIFPSRCADDR_IN6, (caddr_t)&in6_ifr) < 0) 458 return; 459 if (sa->sa_family == AF_INET6) 460 in6_fillscopeid(&in6_ifr.ifr_addr); |
461 if (getnameinfo(sa, sa->sa_len, src, sizeof(src), 0, 0, 462 NI_NUMERICHOST) != 0) |
463 src[0] = '\0'; 464 465 if (ioctl(s, SIOCGIFPDSTADDR_IN6, (caddr_t)&in6_ifr) < 0) 466 return; 467 if (sa->sa_family == AF_INET6) 468 in6_fillscopeid(&in6_ifr.ifr_addr); |
469 if (getnameinfo(sa, sa->sa_len, dst, sizeof(dst), 0, 0, 470 NI_NUMERICHOST) != 0) |
471 dst[0] = '\0'; 472 473 printf("\ttunnel inet6 %s --> %s\n", src, dst); 474} 475 476static void 477in6_set_tunnel(int s, struct addrinfo *srcres, struct addrinfo *dstres) 478{ --- 60 unchanged lines hidden --- |