af_inet6.c (288305) | af_inet6.c (299873) |
---|---|
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 288305 2015-09-27 07:51:18Z ngie $"; | 32 "$FreeBSD: head/sbin/ifconfig/af_inet6.c 299873 2016-05-16 00:25:24Z truckman $"; |
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 40#include <err.h> --- 138 unchanged lines hidden (view full) --- 179 clock_gettime(CLOCK_MONOTONIC_FAST, &now); 180 181 memset(&null_sin, 0, sizeof(null_sin)); 182 183 sin = (struct sockaddr_in6 *)ifa->ifa_addr; 184 if (sin == NULL) 185 return; 186 | 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 40#include <err.h> --- 138 unchanged lines hidden (view full) --- 179 clock_gettime(CLOCK_MONOTONIC_FAST, &now); 180 181 memset(&null_sin, 0, sizeof(null_sin)); 182 183 sin = (struct sockaddr_in6 *)ifa->ifa_addr; 184 if (sin == NULL) 185 return; 186 |
187 strncpy(ifr6.ifr_name, ifr.ifr_name, sizeof(ifr.ifr_name)); | 187 strlcpy(ifr6.ifr_name, ifr.ifr_name, sizeof(ifr.ifr_name)); |
188 if ((s6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { 189 warn("socket(AF_INET6,SOCK_DGRAM)"); 190 return; 191 } 192 ifr6.ifr_addr = *sin; 193 if (ioctl(s6, SIOCGIFAFLAG_IN6, &ifr6) < 0) { 194 warn("ioctl(SIOCGIFAFLAG_IN6)"); 195 close(s6); --- 222 unchanged lines hidden (view full) --- 418in6_status_tunnel(int s) 419{ 420 char src[NI_MAXHOST]; 421 char dst[NI_MAXHOST]; 422 struct in6_ifreq in6_ifr; 423 const struct sockaddr *sa = (const struct sockaddr *) &in6_ifr.ifr_addr; 424 425 memset(&in6_ifr, 0, sizeof(in6_ifr)); | 188 if ((s6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { 189 warn("socket(AF_INET6,SOCK_DGRAM)"); 190 return; 191 } 192 ifr6.ifr_addr = *sin; 193 if (ioctl(s6, SIOCGIFAFLAG_IN6, &ifr6) < 0) { 194 warn("ioctl(SIOCGIFAFLAG_IN6)"); 195 close(s6); --- 222 unchanged lines hidden (view full) --- 418in6_status_tunnel(int s) 419{ 420 char src[NI_MAXHOST]; 421 char dst[NI_MAXHOST]; 422 struct in6_ifreq in6_ifr; 423 const struct sockaddr *sa = (const struct sockaddr *) &in6_ifr.ifr_addr; 424 425 memset(&in6_ifr, 0, sizeof(in6_ifr)); |
426 strncpy(in6_ifr.ifr_name, name, IFNAMSIZ); | 426 strlcpy(in6_ifr.ifr_name, name, sizeof(in6_ifr.ifr_name)); |
427 428 if (ioctl(s, SIOCGIFPSRCADDR_IN6, (caddr_t)&in6_ifr) < 0) 429 return; 430 if (sa->sa_family != AF_INET6) 431 return; 432 if (getnameinfo(sa, sa->sa_len, src, sizeof(src), 0, 0, 433 NI_NUMERICHOST) != 0) 434 src[0] = '\0'; --- 10 unchanged lines hidden (view full) --- 445} 446 447static void 448in6_set_tunnel(int s, struct addrinfo *srcres, struct addrinfo *dstres) 449{ 450 struct in6_aliasreq in6_addreq; 451 452 memset(&in6_addreq, 0, sizeof(in6_addreq)); | 427 428 if (ioctl(s, SIOCGIFPSRCADDR_IN6, (caddr_t)&in6_ifr) < 0) 429 return; 430 if (sa->sa_family != AF_INET6) 431 return; 432 if (getnameinfo(sa, sa->sa_len, src, sizeof(src), 0, 0, 433 NI_NUMERICHOST) != 0) 434 src[0] = '\0'; --- 10 unchanged lines hidden (view full) --- 445} 446 447static void 448in6_set_tunnel(int s, struct addrinfo *srcres, struct addrinfo *dstres) 449{ 450 struct in6_aliasreq in6_addreq; 451 452 memset(&in6_addreq, 0, sizeof(in6_addreq)); |
453 strncpy(in6_addreq.ifra_name, name, IFNAMSIZ); | 453 strlcpy(in6_addreq.ifra_name, name, sizeof(in6_addreq.ifra_name)); |
454 memcpy(&in6_addreq.ifra_addr, srcres->ai_addr, srcres->ai_addr->sa_len); 455 memcpy(&in6_addreq.ifra_dstaddr, dstres->ai_addr, 456 dstres->ai_addr->sa_len); 457 458 if (ioctl(s, SIOCSIFPHYADDR_IN6, &in6_addreq) < 0) 459 warn("SIOCSIFPHYADDR_IN6"); 460} 461 --- 74 unchanged lines hidden --- | 454 memcpy(&in6_addreq.ifra_addr, srcres->ai_addr, srcres->ai_addr->sa_len); 455 memcpy(&in6_addreq.ifra_dstaddr, dstres->ai_addr, 456 dstres->ai_addr->sa_len); 457 458 if (ioctl(s, SIOCSIFPHYADDR_IN6, &in6_addreq) < 0) 459 warn("SIOCSIFPHYADDR_IN6"); 460} 461 --- 74 unchanged lines hidden --- |