ipv6cp.c (102500) | ipv6cp.c (102558) |
---|---|
1/*- 2 * Copyright (c) 2001 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) 2001 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/ipv6cp.c 102500 2002-08-27 20:11:58Z brian $ | 26 * $FreeBSD: head/usr.sbin/ppp/ipv6cp.c 102558 2002-08-29 02:44:58Z brian $ |
27 */ 28 29#include <sys/param.h> 30#include <netinet/in_systm.h> 31#include <netinet/in.h> 32#include <netinet/ip.h> 33#include <sys/socket.h> 34#include <net/route.h> 35#include <net/if.h> | 27 */ 28 29#include <sys/param.h> 30#include <netinet/in_systm.h> 31#include <netinet/in.h> 32#include <netinet/ip.h> 33#include <sys/socket.h> 34#include <net/route.h> 35#include <net/if.h> |
36#include <net/if_types.h> 37#include <net/if_dl.h> |
|
36#include <sys/un.h> 37 38#include <stdarg.h> 39#include <stdio.h> 40#include <stdlib.h> 41#include <string.h> 42#include <termios.h> | 38#include <sys/un.h> 39 40#include <stdarg.h> 41#include <stdio.h> 42#include <stdlib.h> 43#include <string.h> 44#include <termios.h> |
45#include <ifaddrs.h> |
|
43 44#include "layer.h" 45#include "defs.h" 46#include "mbuf.h" 47#include "timer.h" 48#include "fsm.h" 49#include "iplist.h" 50#include "throughput.h" --- 47 unchanged lines hidden (view full) --- 98 ipv6cp_SendConfigReq, 99 ipv6cp_SentTerminateReq, 100 ipv6cp_SendTerminateAck, 101 ipv6cp_DecodeConfig, 102 fsm_NullRecvResetReq, 103 fsm_NullRecvResetAck 104}; 105 | 46 47#include "layer.h" 48#include "defs.h" 49#include "mbuf.h" 50#include "timer.h" 51#include "fsm.h" 52#include "iplist.h" 53#include "throughput.h" --- 47 unchanged lines hidden (view full) --- 101 ipv6cp_SendConfigReq, 102 ipv6cp_SentTerminateReq, 103 ipv6cp_SendTerminateAck, 104 ipv6cp_DecodeConfig, 105 fsm_NullRecvResetReq, 106 fsm_NullRecvResetAck 107}; 108 |
106static u_int32_t 107GenerateToken(void) | 109static void 110SetInterfaceID(u_char *ifid, int userandom) |
108{ | 111{ |
109 /* Generate random number which will be used as negotiation token */ 110 randinit(); | 112 struct ifaddrs *ifa, *ifap = NULL; 113 struct sockaddr_dl *sdl; 114 const u_long i32_max = 0xffffffff; 115 u_long r1, r2; |
111 | 116 |
112 return random() + 1; | 117 /* configure an interface ID based on Section 4.1 of RFC 2472 */ 118 memset(ifid, 0, IPV6CP_IFIDLEN); 119 120 /* 121 * 1) If an IEEE global identifier (EUI-48 or EUI-64) is 122 * available anywhere on the node, it should be used to construct 123 * the tentative Interface-Identifier due to its uniqueness 124 * properties. 125 */ 126 if (userandom) 127 goto randomid; 128 if (getifaddrs(&ifap) < 0) 129 goto randomid; 130 131 for (ifa = ifap; ifa; ifa = ifa->ifa_next) { 132 char *cp; 133 134 if (ifa->ifa_addr->sa_family != AF_LINK) 135 continue; 136 137 sdl = (struct sockaddr_dl *)ifa->ifa_addr; 138 if (sdl->sdl_alen < 6) 139 continue; 140 /* we're only interested in IEEE hardware addresses */ 141 switch(sdl->sdl_type) { 142 case IFT_ETHER: 143 case IFT_FDDI: 144 /* XXX need more cases? */ 145 break; 146 default: 147 continue; 148 } 149 150 cp = (char *)(sdl->sdl_data + sdl->sdl_nlen); 151 ifid[0] = cp[0]; 152 ifid[0] ^= 0x02; /* reverse the u/l bit*/ 153 ifid[1] = cp[1]; 154 ifid[2] = cp[2]; 155 ifid[3] = 0xff; 156 ifid[4] = 0xfe; 157 ifid[5] = cp[3]; 158 ifid[6] = cp[4]; 159 ifid[7] = cp[5]; 160 161 freeifaddrs(ifap); 162 return; 163 } 164 165 freeifaddrs(ifap); 166 167 /* 168 * 2) If an IEEE global identifier is not available a different source 169 * of uniqueness should be used. 170 * XXX: we skip this case. 171 */ 172 173 /* 174 * 3) If a good source of uniqueness cannot be found, it is 175 * recommended that a random number be generated. In this case the 176 * "u" bit of the interface identifier MUST be set to zero (0). 177 */ 178 randomid: 179 randinit(); 180 r1 = (((u_long)random()) % i32_max) + 1; 181 r2 = (((u_long)random()) % i32_max) + 1; 182 memcpy(ifid, &r1, sizeof(r1)); 183 memcpy(ifid + 4, &r2, sizeof(r2)); 184 ifid[0] &= 0xfd; 185 return; |
113} 114 115static int | 186} 187 188static int |
116ipcp_SetIPv6address(struct ipv6cp *ipv6cp, u_int32_t mytok, u_int32_t histok) | 189ipcp_SetIPv6address(struct ipv6cp *ipv6cp, u_char *myifid, u_char *hisifid) |
117{ 118 struct bundle *bundle = ipv6cp->fsm.bundle; 119 struct in6_addr myaddr, hisaddr; 120 struct ncprange myrange; 121 struct sockaddr_storage ssdst, ssgw, ssmask; 122 struct sockaddr *sadst, *sagw, *samask; 123 124 sadst = (struct sockaddr *)&ssdst; 125 sagw = (struct sockaddr *)&ssgw; 126 samask = (struct sockaddr *)&ssmask; 127 128 memset(&myaddr, '\0', sizeof myaddr); 129 memset(&hisaddr, '\0', sizeof hisaddr); 130 131 myaddr.s6_addr[0] = 0xfe; 132 myaddr.s6_addr[1] = 0x80; | 190{ 191 struct bundle *bundle = ipv6cp->fsm.bundle; 192 struct in6_addr myaddr, hisaddr; 193 struct ncprange myrange; 194 struct sockaddr_storage ssdst, ssgw, ssmask; 195 struct sockaddr *sadst, *sagw, *samask; 196 197 sadst = (struct sockaddr *)&ssdst; 198 sagw = (struct sockaddr *)&ssgw; 199 samask = (struct sockaddr *)&ssmask; 200 201 memset(&myaddr, '\0', sizeof myaddr); 202 memset(&hisaddr, '\0', sizeof hisaddr); 203 204 myaddr.s6_addr[0] = 0xfe; 205 myaddr.s6_addr[1] = 0x80; |
133 *(u_int32_t *)(myaddr.s6_addr + 12) = htonl(mytok); | 206 memcpy(&myaddr.s6_addr[8], myifid, IPV6CP_IFIDLEN); 207#if 0 208 myaddr.s6_addr[8] |= 0x02; /* set 'universal' bit */ 209#endif |
134 135 hisaddr.s6_addr[0] = 0xfe; 136 hisaddr.s6_addr[1] = 0x80; | 210 211 hisaddr.s6_addr[0] = 0xfe; 212 hisaddr.s6_addr[1] = 0x80; |
137 *(u_int32_t *)(hisaddr.s6_addr + 12) = htonl(histok); | 213 memcpy(&hisaddr.s6_addr[8], hisifid, IPV6CP_IFIDLEN); 214#if 0 215 hisaddr.s6_addr[8] |= 0x02; /* set 'universal' bit */ 216#endif |
138 139 ncpaddr_setip6(&ipv6cp->myaddr, &myaddr); 140 ncpaddr_setip6(&ipv6cp->hisaddr, &hisaddr); 141 ncprange_sethost(&myrange, &ipv6cp->myaddr); 142 143 if (!iface_Add(bundle->iface, &bundle->ncp, &myrange, &ipv6cp->hisaddr, 144 IFACE_ADD_FIRST|IFACE_FORCE_ADD|IFACE_SYSTEM)) 145 return 0; --- 33 unchanged lines hidden (view full) --- 179 180 fsm_Init(&ipv6cp->fsm, "IPV6CP", PROTO_IPV6CP, 1, IPV6CP_MAXCODE, LogIPV6CP, 181 bundle, l, parent, &ipv6cp_Callbacks, timer_names); 182 183 ipv6cp->cfg.fsm.timeout = DEF_FSMRETRY; 184 ipv6cp->cfg.fsm.maxreq = DEF_FSMTRIES; 185 ipv6cp->cfg.fsm.maxtrm = DEF_FSMTRIES; 186 | 217 218 ncpaddr_setip6(&ipv6cp->myaddr, &myaddr); 219 ncpaddr_setip6(&ipv6cp->hisaddr, &hisaddr); 220 ncprange_sethost(&myrange, &ipv6cp->myaddr); 221 222 if (!iface_Add(bundle->iface, &bundle->ncp, &myrange, &ipv6cp->hisaddr, 223 IFACE_ADD_FIRST|IFACE_FORCE_ADD|IFACE_SYSTEM)) 224 return 0; --- 33 unchanged lines hidden (view full) --- 258 259 fsm_Init(&ipv6cp->fsm, "IPV6CP", PROTO_IPV6CP, 1, IPV6CP_MAXCODE, LogIPV6CP, 260 bundle, l, parent, &ipv6cp_Callbacks, timer_names); 261 262 ipv6cp->cfg.fsm.timeout = DEF_FSMRETRY; 263 ipv6cp->cfg.fsm.maxreq = DEF_FSMTRIES; 264 ipv6cp->cfg.fsm.maxtrm = DEF_FSMTRIES; 265 |
187 ipv6cp->my_token = GenerateToken(); 188 while ((ipv6cp->peer_token = GenerateToken()) == ipv6cp->my_token) 189 ; | 266 SetInterfaceID(ipv6cp->my_ifid, 0); 267 do { 268 SetInterfaceID(ipv6cp->his_ifid, 1); 269 } while (memcmp(ipv6cp->his_ifid, ipv6cp->my_ifid, IPV6CP_IFIDLEN) == 0); |
190 191 if (probe.ipv6_available) { 192 n = 100; 193 while (n && | 270 271 if (probe.ipv6_available) { 272 n = 100; 273 while (n && |
194 !ipcp_SetIPv6address(ipv6cp, ipv6cp->my_token, ipv6cp->peer_token)) { 195 n--; 196 while (n && (ipv6cp->my_token = GenerateToken()) == ipv6cp->peer_token) 197 n--; | 274 !ipcp_SetIPv6address(ipv6cp, ipv6cp->my_ifid, ipv6cp->his_ifid)) { 275 do { 276 n--; 277 SetInterfaceID(ipv6cp->my_ifid, 1); 278 } while (n 279 && memcmp(ipv6cp->his_ifid, ipv6cp->my_ifid, IPV6CP_IFIDLEN) == 0); |
198 } 199 } 200 201 throughput_init(&ipv6cp->throughput, SAMPLE_PERIOD); 202 memset(ipv6cp->Queue, '\0', sizeof ipv6cp->Queue); 203 ipv6cp_Setup(ipv6cp); 204} 205 --- 82 unchanged lines hidden (view full) --- 288void 289ipv6cp_IfaceAddrDeleted(struct ipv6cp *ipv6cp, const struct iface_addr *addr) 290{ 291} 292 293int 294ipv6cp_InterfaceUp(struct ipv6cp *ipv6cp) 295{ | 280 } 281 } 282 283 throughput_init(&ipv6cp->throughput, SAMPLE_PERIOD); 284 memset(ipv6cp->Queue, '\0', sizeof ipv6cp->Queue); 285 ipv6cp_Setup(ipv6cp); 286} 287 --- 82 unchanged lines hidden (view full) --- 370void 371ipv6cp_IfaceAddrDeleted(struct ipv6cp *ipv6cp, const struct iface_addr *addr) 372{ 373} 374 375int 376ipv6cp_InterfaceUp(struct ipv6cp *ipv6cp) 377{ |
296 if (!ipcp_SetIPv6address(ipv6cp, ipv6cp->my_token, ipv6cp->peer_token)) { | 378 if (!ipcp_SetIPv6address(ipv6cp, ipv6cp->my_ifid, ipv6cp->his_ifid)) { |
297 log_Printf(LogERROR, "ipv6cp_InterfaceUp: unable to set ipv6 address\n"); 298 return 0; 299 } 300 301 if (!iface_SetFlags(ipv6cp->fsm.bundle->iface->name, IFF_UP)) { 302 log_Printf(LogERROR, "ipv6cp_InterfaceUp: Can't set the IFF_UP" 303 " flag on %s\n", ipv6cp->fsm.bundle->iface->name); 304 return 0; --- 145 unchanged lines hidden (view full) --- 450} 451 452static void 453ipv6cp_SendConfigReq(struct fsm *fp) 454{ 455 /* Send config REQ please */ 456 struct physical *p = link2physical(fp->link); 457 struct ipv6cp *ipv6cp = fsm2ipv6cp(fp); | 379 log_Printf(LogERROR, "ipv6cp_InterfaceUp: unable to set ipv6 address\n"); 380 return 0; 381 } 382 383 if (!iface_SetFlags(ipv6cp->fsm.bundle->iface->name, IFF_UP)) { 384 log_Printf(LogERROR, "ipv6cp_InterfaceUp: Can't set the IFF_UP" 385 " flag on %s\n", ipv6cp->fsm.bundle->iface->name); 386 return 0; --- 145 unchanged lines hidden (view full) --- 532} 533 534static void 535ipv6cp_SendConfigReq(struct fsm *fp) 536{ 537 /* Send config REQ please */ 538 struct physical *p = link2physical(fp->link); 539 struct ipv6cp *ipv6cp = fsm2ipv6cp(fp); |
458 u_char buff[6]; | 540 u_char buff[IPV6CP_IFIDLEN+2]; |
459 struct fsm_opt *o; 460 461 o = (struct fsm_opt *)buff; 462 463 if ((p && !physical_IsSync(p)) || !REJECTED(ipv6cp, TY_TOKEN)) { | 541 struct fsm_opt *o; 542 543 o = (struct fsm_opt *)buff; 544 545 if ((p && !physical_IsSync(p)) || !REJECTED(ipv6cp, TY_TOKEN)) { |
464 memcpy(o->data, &ipv6cp->my_token, 4); 465 INC_FSM_OPT(TY_TOKEN, 6, o); | 546 memcpy(o->data, ipv6cp->my_ifid, IPV6CP_IFIDLEN); 547 INC_FSM_OPT(TY_TOKEN, IPV6CP_IFIDLEN + 2, o); |
466 } 467 468 fsm_Output(fp, CODE_CONFIGREQ, fp->reqid, buff, (u_char *)o - buff, 469 MB_IPV6CPOUT); 470} 471 472static void 473ipv6cp_SentTerminateReq(struct fsm *fp) --- 6 unchanged lines hidden (view full) --- 480{ 481 /* Send Term ACK please */ 482 fsm_Output(fp, CODE_TERMACK, id, NULL, 0, MB_IPV6CPOUT); 483} 484 485static const char * 486protoname(int proto) 487{ | 548 } 549 550 fsm_Output(fp, CODE_CONFIGREQ, fp->reqid, buff, (u_char *)o - buff, 551 MB_IPV6CPOUT); 552} 553 554static void 555ipv6cp_SentTerminateReq(struct fsm *fp) --- 6 unchanged lines hidden (view full) --- 562{ 563 /* Send Term ACK please */ 564 fsm_Output(fp, CODE_TERMACK, id, NULL, 0, MB_IPV6CPOUT); 565} 566 567static const char * 568protoname(int proto) 569{ |
488 static const char *cftypes[] = { "TOKEN", "COMPPROTO" }; | 570 static const char *cftypes[] = { "IFACEID", "COMPPROTO" }; |
489 490 if (proto > 0 && proto <= sizeof cftypes / sizeof *cftypes) 491 return cftypes[proto - 1]; 492 493 return NumStr(proto, NULL, 0); 494} 495 496static void | 571 572 if (proto > 0 && proto <= sizeof cftypes / sizeof *cftypes) 573 return cftypes[proto - 1]; 574 575 return NumStr(proto, NULL, 0); 576} 577 578static void |
497ipv6cp_ValidateToken(struct ipv6cp *ipv6cp, u_int32_t token, 498 struct fsm_decode *dec) | 579ipv6cp_ValidateInterfaceID(struct ipv6cp *ipv6cp, u_char *ifid, 580 struct fsm_decode *dec) |
499{ 500 struct fsm_opt opt; | 581{ 582 struct fsm_opt opt; |
583 u_char zero[IPV6CP_IFIDLEN]; |
|
501 | 584 |
502 if (token != 0 && token != ipv6cp->my_token) 503 ipv6cp->peer_token = token; | 585 memset(zero, 0, IPV6CP_IFIDLEN); |
504 | 586 |
587 if (memcmp(ifid, zero, IPV6CP_IFIDLEN) != 0 588 && memcmp(ifid, ipv6cp->my_ifid, IPV6CP_IFIDLEN) != 0) 589 memcpy(ipv6cp->his_ifid, ifid, IPV6CP_IFIDLEN); 590 |
|
505 opt.hdr.id = TY_TOKEN; | 591 opt.hdr.id = TY_TOKEN; |
506 opt.hdr.len = 6; 507 memcpy(opt.data, &ipv6cp->peer_token, 4); 508 if (token == ipv6cp->peer_token) | 592 opt.hdr.len = IPV6CP_IFIDLEN + 2; 593 memcpy(opt.data, &ipv6cp->his_ifid, IPV6CP_IFIDLEN); 594 if (memcmp(ifid, ipv6cp->his_ifid, IPV6CP_IFIDLEN) == 0) |
509 fsm_ack(dec, &opt); 510 else 511 fsm_nak(dec, &opt); 512} 513 514static void 515ipv6cp_DecodeConfig(struct fsm *fp, u_char *cp, u_char *end, int mode_type, 516 struct fsm_decode *dec) 517{ 518 /* Deal with incoming PROTO_IPV6CP */ 519 struct ipv6cp *ipv6cp = fsm2ipv6cp(fp); 520 int n; 521 char tbuff[100]; | 595 fsm_ack(dec, &opt); 596 else 597 fsm_nak(dec, &opt); 598} 599 600static void 601ipv6cp_DecodeConfig(struct fsm *fp, u_char *cp, u_char *end, int mode_type, 602 struct fsm_decode *dec) 603{ 604 /* Deal with incoming PROTO_IPV6CP */ 605 struct ipv6cp *ipv6cp = fsm2ipv6cp(fp); 606 int n; 607 char tbuff[100]; |
522 u_int32_t token; | 608 u_char ifid[IPV6CP_IFIDLEN], zero[IPV6CP_IFIDLEN]; |
523 struct fsm_opt *opt; 524 | 609 struct fsm_opt *opt; 610 |
611 memset(zero, 0, IPV6CP_IFIDLEN); 612 |
|
525 while (end - cp >= sizeof(opt->hdr)) { 526 if ((opt = fsm_readopt(&cp)) == NULL) 527 break; 528 529 snprintf(tbuff, sizeof tbuff, " %s[%d]", protoname(opt->hdr.id), 530 opt->hdr.len); 531 532 switch (opt->hdr.id) { 533 case TY_TOKEN: | 613 while (end - cp >= sizeof(opt->hdr)) { 614 if ((opt = fsm_readopt(&cp)) == NULL) 615 break; 616 617 snprintf(tbuff, sizeof tbuff, " %s[%d]", protoname(opt->hdr.id), 618 opt->hdr.len); 619 620 switch (opt->hdr.id) { 621 case TY_TOKEN: |
534 memcpy(&token, opt->data, 4); 535 log_Printf(LogIPV6CP, "%s 0x%08lx\n", tbuff, (unsigned long)token); | 622 memcpy(ifid, opt->data, IPV6CP_IFIDLEN); 623 log_Printf(LogIPV6CP, "%s 0x%02x%02x%02x%02x%02x%02x%02x%02x\n", tbuff, 624 ifid[0], ifid[1], ifid[2], ifid[3], ifid[4], ifid[5], ifid[6], ifid[7]); |
536 537 switch (mode_type) { 538 case MODE_REQ: 539 ipv6cp->peer_tokenreq = 1; | 625 626 switch (mode_type) { 627 case MODE_REQ: 628 ipv6cp->peer_tokenreq = 1; |
540 ipv6cp_ValidateToken(ipv6cp, token, dec); | 629 ipv6cp_ValidateInterfaceID(ipv6cp, ifid, dec); |
541 break; 542 543 case MODE_NAK: | 630 break; 631 632 case MODE_NAK: |
544 if (token == 0) { | 633 if (memcmp(ifid, zero, IPV6CP_IFIDLEN) == 0) { |
545 log_Printf(log_IsKept(LogIPV6CP) ? LogIPV6CP : LogPHASE, | 634 log_Printf(log_IsKept(LogIPV6CP) ? LogIPV6CP : LogPHASE, |
546 "0x00000000: Unacceptable token!\n"); | 635 "0x0000000000000000: Unacceptable IntefaceID!\n"); |
547 fsm_Close(&ipv6cp->fsm); | 636 fsm_Close(&ipv6cp->fsm); |
548 } else if (token == ipv6cp->peer_token) | 637 } else if (memcmp(ifid, ipv6cp->his_ifid, IPV6CP_IFIDLEN) == 0) { |
549 log_Printf(log_IsKept(LogIPV6CP) ? LogIPV6CP : LogPHASE, | 638 log_Printf(log_IsKept(LogIPV6CP) ? LogIPV6CP : LogPHASE, |
550 "0x%08lx: Unacceptable token!\n", (unsigned long)token); 551 else if (token != ipv6cp->my_token) { | 639 "0x%02x%02x%02x%02x%02x%02x%02x%02x: " 640 "Unacceptable IntefaceID!\n", 641 ifid[0], ifid[1], ifid[2], ifid[3], 642 ifid[4], ifid[5], ifid[6], ifid[7]); 643 } else if (memcmp(ifid, ipv6cp->my_ifid, IPV6CP_IFIDLEN) != 0) { |
552 n = 100; | 644 n = 100; |
553 while (n && !ipcp_SetIPv6address(ipv6cp, token, ipv6cp->peer_token)) { 554 n--; 555 while (n && (token = GenerateToken()) == ipv6cp->peer_token) 556 n--; 557 } | 645 while (n && !ipcp_SetIPv6address(ipv6cp, ifid, ipv6cp->his_ifid)) { 646 do { 647 n--; 648 SetInterfaceID(ifid, 1); 649 } while (n && memcmp(ifid, ipv6cp->his_ifid, IPV6CP_IFIDLEN) == 0); 650 } |
558 559 if (n == 0) { 560 log_Printf(log_IsKept(LogIPV6CP) ? LogIPV6CP : LogPHASE, | 651 652 if (n == 0) { 653 log_Printf(log_IsKept(LogIPV6CP) ? LogIPV6CP : LogPHASE, |
561 "0x00000000: Unacceptable token!\n"); | 654 "0x0000000000000000: Unacceptable IntefaceID!\n"); |
562 fsm_Close(&ipv6cp->fsm); 563 } else { | 655 fsm_Close(&ipv6cp->fsm); 656 } else { |
564 log_Printf(LogIPV6CP, "%s changing token: 0x%08lx --> 0x%08lx\n", 565 tbuff, (unsigned long)ipv6cp->my_token, 566 (unsigned long)token); 567 ipv6cp->my_token = token; | 657 log_Printf(LogIPV6CP, "%s changing IntefaceID: " 658 "0x%02x%02x%02x%02x%02x%02x%02x%02x " 659 "--> 0x%02x%02x%02x%02x%02x%02x%02x%02x\n", tbuff, 660 ipv6cp->my_ifid[0], ipv6cp->my_ifid[1], 661 ipv6cp->my_ifid[2], ipv6cp->my_ifid[3], 662 ipv6cp->my_ifid[4], ipv6cp->my_ifid[5], 663 ipv6cp->my_ifid[6], ipv6cp->my_ifid[7], 664 ifid[0], ifid[1], ifid[2], ifid[3], 665 ifid[4], ifid[5], ifid[6], ifid[7]); 666 memcpy(ipv6cp->my_ifid, ifid, IPV6CP_IFIDLEN); |
568 bundle_AdjustFilters(fp->bundle, &ipv6cp->myaddr, NULL); 569 } 570 } 571 break; 572 573 case MODE_REJ: 574 ipv6cp->his_reject |= (1 << opt->hdr.id); 575 break; --- 16 unchanged lines hidden (view full) --- 592 * Pretend the peer has requested a TOKEN. 593 * We do this to ensure that we only send one NAK if the only 594 * reason for the NAK is because the peer isn't sending a 595 * TY_TOKEN REQ. This stops us from repeatedly trying to tell 596 * the peer that we have to have an IP address on their end. 597 */ 598 ipv6cp->peer_tokenreq = 1; 599 } | 667 bundle_AdjustFilters(fp->bundle, &ipv6cp->myaddr, NULL); 668 } 669 } 670 break; 671 672 case MODE_REJ: 673 ipv6cp->his_reject |= (1 << opt->hdr.id); 674 break; --- 16 unchanged lines hidden (view full) --- 691 * Pretend the peer has requested a TOKEN. 692 * We do this to ensure that we only send one NAK if the only 693 * reason for the NAK is because the peer isn't sending a 694 * TY_TOKEN REQ. This stops us from repeatedly trying to tell 695 * the peer that we have to have an IP address on their end. 696 */ 697 ipv6cp->peer_tokenreq = 1; 698 } |
600 ipv6cp_ValidateToken(ipv6cp, 0, dec); | 699 memset(ifid, 0, IPV6CP_IFIDLEN); 700 ipv6cp_ValidateInterfaceID(ipv6cp, ifid, dec); |
601 } 602 fsm_opt_normalise(dec); 603 } 604} 605#endif | 701 } 702 fsm_opt_normalise(dec); 703 } 704} 705#endif |