iface.c (102574) | iface.c (113067) |
---|---|
1/*- 2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 3 * 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 --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 3 * 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 --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/usr.sbin/ppp/iface.c 102574 2002-08-29 12:52:28Z sobomax $ | 26 * $FreeBSD: head/usr.sbin/ppp/iface.c 113067 2003-04-04 11:09:08Z ume $ |
27 */ 28 29#include <sys/param.h> 30#include <sys/socket.h> 31#include <netinet/in.h> 32#include <net/if.h> 33#include <net/if_dl.h> 34#ifdef __FreeBSD__ --- 43 unchanged lines hidden (view full) --- 78#include "radius.h" 79#endif 80#include "ipv6cp.h" 81#include "ncp.h" 82#include "bundle.h" 83#include "prompt.h" 84#include "iface.h" 85 | 27 */ 28 29#include <sys/param.h> 30#include <sys/socket.h> 31#include <netinet/in.h> 32#include <net/if.h> 33#include <net/if_dl.h> 34#ifdef __FreeBSD__ --- 43 unchanged lines hidden (view full) --- 78#include "radius.h" 79#endif 80#include "ipv6cp.h" 81#include "ncp.h" 82#include "bundle.h" 83#include "prompt.h" 84#include "iface.h" 85 |
86#define IN6MASK128 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ 87 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}} 88static const struct in6_addr in6mask128 = IN6MASK128; |
|
86 | 89 |
90 |
|
87struct iface * 88iface_Create(const char *name) 89{ 90 int mib[6], maxtries, err; 91 size_t needed, namelen; 92 char *buf, *ptr, *end; 93 struct if_msghdr *ifm; 94 struct ifa_msghdr *ifam; --- 233 unchanged lines hidden (view full) --- 328 case AF_INET6: 329 memset(&ifra6, '\0', sizeof ifra6); 330 strncpy(ifra6.ifra_name, name, sizeof ifra6.ifra_name - 1); 331 332 memcpy(&ifra6.ifra_addr, &ssme, sizeof ifra6.ifra_addr); 333 memcpy(&ifra6.ifra_prefixmask, &ssmsk, sizeof ifra6.ifra_prefixmask); 334 if (ncpaddr_family(&addr->peer) == AF_UNSPEC) 335 ifra6.ifra_dstaddr.sin6_family = AF_UNSPEC; | 91struct iface * 92iface_Create(const char *name) 93{ 94 int mib[6], maxtries, err; 95 size_t needed, namelen; 96 char *buf, *ptr, *end; 97 struct if_msghdr *ifm; 98 struct ifa_msghdr *ifam; --- 233 unchanged lines hidden (view full) --- 332 case AF_INET6: 333 memset(&ifra6, '\0', sizeof ifra6); 334 strncpy(ifra6.ifra_name, name, sizeof ifra6.ifra_name - 1); 335 336 memcpy(&ifra6.ifra_addr, &ssme, sizeof ifra6.ifra_addr); 337 memcpy(&ifra6.ifra_prefixmask, &ssmsk, sizeof ifra6.ifra_prefixmask); 338 if (ncpaddr_family(&addr->peer) == AF_UNSPEC) 339 ifra6.ifra_dstaddr.sin6_family = AF_UNSPEC; |
336 else | 340 else if (memcmp(&((struct sockaddr_in6 *)&ssmsk)->sin6_addr, &in6mask128, 341 sizeof in6mask128) == 0) |
337 memcpy(&ifra6.ifra_dstaddr, &sspeer, sizeof ifra6.ifra_dstaddr); 338 ifra6.ifra_lifetime.ia6t_vltime = ND6_INFINITE_LIFETIME; 339 ifra6.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME; 340 341 res = ID0ioctl(s, SIOCAIFADDR_IN6, &ifra6); 342 break; 343#endif 344 } --- 76 unchanged lines hidden (view full) --- 421 close(s6); 422 } 423} 424 425int 426iface_Add(struct iface *iface, struct ncp *ncp, const struct ncprange *ifa, 427 const struct ncpaddr *peer, int how) 428{ | 342 memcpy(&ifra6.ifra_dstaddr, &sspeer, sizeof ifra6.ifra_dstaddr); 343 ifra6.ifra_lifetime.ia6t_vltime = ND6_INFINITE_LIFETIME; 344 ifra6.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME; 345 346 res = ID0ioctl(s, SIOCAIFADDR_IN6, &ifra6); 347 break; 348#endif 349 } --- 76 unchanged lines hidden (view full) --- 426 close(s6); 427 } 428} 429 430int 431iface_Add(struct iface *iface, struct ncp *ncp, const struct ncprange *ifa, 432 const struct ncpaddr *peer, int how) 433{ |
429 int af, n, removed, s, width; | 434 int af, n, removed, s; |
430 struct ncpaddr ncplocal; 431 struct iface_addr *addr, newaddr; 432 433 af = ncprange_family(ifa); 434 if ((s = ID0socket(af, SOCK_DGRAM, 0)) == -1) { 435 log_Printf(LogERROR, "iface_Add: socket(): %s\n", strerror(errno)); 436 return 0; 437 } --- 9 unchanged lines hidden (view full) --- 447 } 448 449 if (ncprange_equal(&iface->addr[n].ifa, ifa) && 450 ncpaddr_equal(&iface->addr[n].peer, peer)) { 451 close(s); 452 return 1; /* Already there */ 453 } 454 | 435 struct ncpaddr ncplocal; 436 struct iface_addr *addr, newaddr; 437 438 af = ncprange_family(ifa); 439 if ((s = ID0socket(af, SOCK_DGRAM, 0)) == -1) { 440 log_Printf(LogERROR, "iface_Add: socket(): %s\n", strerror(errno)); 441 return 0; 442 } --- 9 unchanged lines hidden (view full) --- 452 } 453 454 if (ncprange_equal(&iface->addr[n].ifa, ifa) && 455 ncpaddr_equal(&iface->addr[n].peer, peer)) { 456 close(s); 457 return 1; /* Already there */ 458 } 459 |
455 width = 456#ifndef NOINET6 457 (af == AF_INET6) ? 128 : 458#endif 459 32; | |
460 removed = iface_addr_Zap(iface->name, iface->addr + n, s); 461 if (removed) 462 ncp_IfaceAddrDeleted(ncp, iface->addr + n); 463 ncprange_copy(&iface->addr[n].ifa, ifa); 464 ncpaddr_copy(&iface->addr[n].peer, peer); 465 if (!iface_addr_Add(iface->name, iface->addr + n, s)) { 466 if (removed) { 467 bcopy(iface->addr + n + 1, iface->addr + n, --- 252 unchanged lines hidden --- | 460 removed = iface_addr_Zap(iface->name, iface->addr + n, s); 461 if (removed) 462 ncp_IfaceAddrDeleted(ncp, iface->addr + n); 463 ncprange_copy(&iface->addr[n].ifa, ifa); 464 ncpaddr_copy(&iface->addr[n].peer, peer); 465 if (!iface_addr_Add(iface->name, iface->addr + n, s)) { 466 if (removed) { 467 bcopy(iface->addr + n + 1, iface->addr + n, --- 252 unchanged lines hidden --- |