af_inet6.c (138593) | af_inet6.c (146187) |
---|---|
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[] = | 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 138593 2004-12-08 19:18:07Z sam $"; | 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 | 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 |
60/* wrapper for KAME-special getnameinfo() */ 61#ifndef NI_WITHSCOPEID 62#define NI_WITHSCOPEID 0 63#endif 64 | |
65static struct in6_ifreq in6_ridreq; 66static struct in6_aliasreq in6_addreq = 67 { { 0 }, 68 { 0 }, 69 { 0 }, 70 { 0 }, 71 0, 72 { 0, 0, ND6_INFINITE_LIFETIME, ND6_INFINITE_LIFETIME } }; --- 158 unchanged lines hidden (view full) --- 231 index = *(u_short *)&sin->sin6_addr.s6_addr[2]; 232 *(u_short *)&sin->sin6_addr.s6_addr[2] = 0; 233 if (sin->sin6_scope_id == 0) 234 sin->sin6_scope_id = ntohs(index); 235 } 236 scopeid = sin->sin6_scope_id; 237 238 error = getnameinfo((struct sockaddr *)sin, sin->sin6_len, addr_buf, | 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, |
239 sizeof(addr_buf), NULL, 0, 240 NI_NUMERICHOST|NI_WITHSCOPEID); | 234 sizeof(addr_buf), NULL, 0, NI_NUMERICHOST); |
241 if (error != 0) 242 inet_ntop(AF_INET6, &sin->sin6_addr, addr_buf, 243 sizeof(addr_buf)); 244 printf("\tinet6 %s ", addr_buf); 245 246 if (flags & IFF_POINTOPOINT) { 247 /* note RTAX_BRD overlap with IFF_BROADCAST */ 248 sin = (struct sockaddr_in6 *)info->rti_info[RTAX_BRD]; --- 13 unchanged lines hidden (view full) --- 262 *(u_short *)&sin->sin6_addr.s6_addr[2] = 0; 263 if (sin->sin6_scope_id == 0) 264 sin->sin6_scope_id = ntohs(index); 265 } 266 267 error = getnameinfo((struct sockaddr *)sin, 268 sin->sin6_len, addr_buf, 269 sizeof(addr_buf), NULL, 0, | 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, |
270 NI_NUMERICHOST|NI_WITHSCOPEID); | 264 NI_NUMERICHOST); |
271 if (error != 0) 272 inet_ntop(AF_INET6, &sin->sin6_addr, addr_buf, 273 sizeof(addr_buf)); 274 printf("--> %s ", addr_buf); 275 } 276 } 277 278 sin = (struct sockaddr_in6 *)info->rti_info[RTAX_NETMASK]; --- 170 unchanged lines hidden (view full) --- 449 } 450} 451 452static void 453in6_status_tunnel(int s) 454{ 455 char src[NI_MAXHOST]; 456 char dst[NI_MAXHOST]; | 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]; |
457#ifdef NI_WITHSCOPEID 458 const int niflag = NI_NUMERICHOST | NI_WITHSCOPEID; 459#else 460 const int niflag = NI_NUMERICHOST; 461#endif | |
462 struct in6_ifreq in6_ifr; 463 const struct sockaddr *sa = (const struct sockaddr *) &in6_ifr.ifr_addr; 464 465 memset(&in6_ifr, 0, sizeof(in6_ifr)); 466 strncpy(in6_ifr.ifr_name, name, IFNAMSIZ); 467 468 if (ioctl(s, SIOCGIFPSRCADDR_IN6, (caddr_t)&in6_ifr) < 0) 469 return; 470 if (sa->sa_family == AF_INET6) 471 in6_fillscopeid(&in6_ifr.ifr_addr); | 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); |
472 if (getnameinfo(sa, sa->sa_len, src, sizeof(src), 0, 0, niflag) != 0) | 461 if (getnameinfo(sa, sa->sa_len, src, sizeof(src), 0, 0, 462 NI_NUMERICHOST) != 0) |
473 src[0] = '\0'; 474 475 if (ioctl(s, SIOCGIFPDSTADDR_IN6, (caddr_t)&in6_ifr) < 0) 476 return; 477 if (sa->sa_family == AF_INET6) 478 in6_fillscopeid(&in6_ifr.ifr_addr); | 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); |
479 if (getnameinfo(sa, sa->sa_len, dst, sizeof(dst), 0, 0, niflag) != 0) | 469 if (getnameinfo(sa, sa->sa_len, dst, sizeof(dst), 0, 0, 470 NI_NUMERICHOST) != 0) |
480 dst[0] = '\0'; 481 482 printf("\ttunnel inet6 %s --> %s\n", src, dst); 483} 484 485static void 486in6_set_tunnel(int s, struct addrinfo *srcres, struct addrinfo *dstres) 487{ --- 60 unchanged lines hidden --- | 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 --- |