2 * Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
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
26 * $FreeBSD: src/usr.sbin/ppp/ipv6cp.c,v 1.8.2.4 2003/04/29 16:04:41 ume Exp $
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>
36 #include <net/if_types.h>
37 #include <net/if_dl.h>
53 #include "throughput.h"
54 #include "slcompress.h"
63 #include "descriptor.h"
84 #define IN6ADDR_LINKLOCAL_MCAST_INIT \
85 {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
86 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
87 static const struct in6_addr in6addr_linklocal_mcast =
88 IN6ADDR_LINKLOCAL_MCAST_INIT;
90 static int ipv6cp_LayerUp(struct fsm *);
91 static void ipv6cp_LayerDown(struct fsm *);
92 static void ipv6cp_LayerStart(struct fsm *);
93 static void ipv6cp_LayerFinish(struct fsm *);
94 static void ipv6cp_InitRestartCounter(struct fsm *, int);
95 static void ipv6cp_SendConfigReq(struct fsm *);
96 static void ipv6cp_SentTerminateReq(struct fsm *);
97 static void ipv6cp_SendTerminateAck(struct fsm *, u_char);
98 static void ipv6cp_DecodeConfig(struct fsm *, u_char *, u_char *, int,
101 static struct fsm_callbacks ipv6cp_Callbacks = {
106 ipv6cp_InitRestartCounter,
107 ipv6cp_SendConfigReq,
108 ipv6cp_SentTerminateReq,
109 ipv6cp_SendTerminateAck,
111 fsm_NullRecvResetReq,
116 SetInterfaceID(u_char *ifid, int userandom)
118 struct ifaddrs *ifa, *ifap = NULL;
119 struct sockaddr_dl *sdl;
120 const u_long i32_max = 0xffffffff;
123 /* configure an interface ID based on Section 4.1 of RFC 2472 */
124 memset(ifid, 0, IPV6CP_IFIDLEN);
127 * 1) If an IEEE global identifier (EUI-48 or EUI-64) is
128 * available anywhere on the node, it should be used to construct
129 * the tentative Interface-Identifier due to its uniqueness
134 if (getifaddrs(&ifap) < 0)
137 for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
140 if (ifa->ifa_addr->sa_family != AF_LINK)
143 sdl = (struct sockaddr_dl *)ifa->ifa_addr;
144 if (sdl->sdl_alen < 6)
146 /* we're only interested in IEEE hardware addresses */
147 switch(sdl->sdl_type) {
150 /* XXX need more cases? */
156 cp = (char *)(sdl->sdl_data + sdl->sdl_nlen);
158 ifid[0] ^= 0x02; /* reverse the u/l bit*/
174 * 2) If an IEEE global identifier is not available a different source
175 * of uniqueness should be used.
176 * XXX: we skip this case.
180 * 3) If a good source of uniqueness cannot be found, it is
181 * recommended that a random number be generated. In this case the
182 * "u" bit of the interface identifier MUST be set to zero (0).
186 r1 = (((u_long)random()) % i32_max) + 1;
187 r2 = (((u_long)random()) % i32_max) + 1;
188 memcpy(ifid, &r1, sizeof(r1));
189 memcpy(ifid + 4, &r2, sizeof(r2));
195 ipcp_SetIPv6address(struct ipv6cp *ipv6cp, u_char *myifid, u_char *hisifid)
197 struct bundle *bundle = ipv6cp->fsm.bundle;
198 struct in6_addr myaddr, hisaddr;
199 struct ncprange myrange, range;
201 struct sockaddr_storage ssdst, ssgw, ssmask;
202 struct sockaddr *sadst, *sagw, *samask;
204 sadst = (struct sockaddr *)&ssdst;
205 sagw = (struct sockaddr *)&ssgw;
206 samask = (struct sockaddr *)&ssmask;
208 memset(&myaddr, '\0', sizeof myaddr);
209 memset(&hisaddr, '\0', sizeof hisaddr);
211 myaddr.s6_addr[0] = 0xfe;
212 myaddr.s6_addr[1] = 0x80;
213 memcpy(&myaddr.s6_addr[8], myifid, IPV6CP_IFIDLEN);
215 myaddr.s6_addr[8] |= 0x02; /* set 'universal' bit */
218 hisaddr.s6_addr[0] = 0xfe;
219 hisaddr.s6_addr[1] = 0x80;
220 memcpy(&hisaddr.s6_addr[8], hisifid, IPV6CP_IFIDLEN);
222 hisaddr.s6_addr[8] |= 0x02; /* set 'universal' bit */
225 ncpaddr_setip6(&ipv6cp->myaddr, &myaddr);
226 ncpaddr_setip6(&ipv6cp->hisaddr, &hisaddr);
227 ncprange_set(&myrange, &ipv6cp->myaddr, 64);
229 if (!iface_Add(bundle->iface, &bundle->ncp, &myrange, &ipv6cp->hisaddr,
230 IFACE_ADD_FIRST|IFACE_FORCE_ADD|IFACE_SYSTEM))
233 if (!Enabled(bundle, OPT_IFACEALIAS))
234 iface_Clear(bundle->iface, &bundle->ncp, AF_INET6,
235 IFACE_CLEAR_ALIASES|IFACE_SYSTEM);
237 ncpaddr_setip6(&addr, &in6addr_linklocal_mcast);
238 ncprange_set(&range, &addr, 32);
239 rt_Set(bundle, RTM_ADD, &range, &ipv6cp->myaddr, 1, 0);
241 if (bundle->ncp.cfg.sendpipe > 0 || bundle->ncp.cfg.recvpipe > 0) {
242 ncprange_getsa(&myrange, &ssgw, &ssmask);
243 if (ncpaddr_isset(&ipv6cp->hisaddr))
244 ncpaddr_getsa(&ipv6cp->hisaddr, &ssdst);
247 rt_Update(bundle, sadst, sagw, samask);
250 if (Enabled(bundle, OPT_SROUTES))
251 route_Change(bundle, bundle->ncp.route, &ipv6cp->myaddr, &ipv6cp->hisaddr);
254 if (bundle->radius.valid)
255 route_Change(bundle, bundle->radius.routes, &ipv6cp->myaddr,
263 ipv6cp_Init(struct ipv6cp *ipv6cp, struct bundle *bundle, struct link *l,
264 const struct fsm_parent *parent)
266 static const char * const timer_names[] =
267 {"IPV6CP restart", "IPV6CP openmode", "IPV6CP stopped"};
270 fsm_Init(&ipv6cp->fsm, "IPV6CP", PROTO_IPV6CP, 1, IPV6CP_MAXCODE, LogIPV6CP,
271 bundle, l, parent, &ipv6cp_Callbacks, timer_names);
273 ipv6cp->cfg.fsm.timeout = DEF_FSMRETRY;
274 ipv6cp->cfg.fsm.maxreq = DEF_FSMTRIES;
275 ipv6cp->cfg.fsm.maxtrm = DEF_FSMTRIES;
277 SetInterfaceID(ipv6cp->my_ifid, 0);
279 SetInterfaceID(ipv6cp->his_ifid, 1);
280 } while (memcmp(ipv6cp->his_ifid, ipv6cp->my_ifid, IPV6CP_IFIDLEN) == 0);
282 if (probe.ipv6_available) {
285 !ipcp_SetIPv6address(ipv6cp, ipv6cp->my_ifid, ipv6cp->his_ifid)) {
288 SetInterfaceID(ipv6cp->my_ifid, 1);
290 && memcmp(ipv6cp->his_ifid, ipv6cp->my_ifid, IPV6CP_IFIDLEN) == 0);
294 throughput_init(&ipv6cp->throughput, SAMPLE_PERIOD);
295 memset(ipv6cp->Queue, '\0', sizeof ipv6cp->Queue);
296 ipv6cp_Setup(ipv6cp);
300 ipv6cp_Destroy(struct ipv6cp *ipv6cp)
302 throughput_destroy(&ipv6cp->throughput);
306 ipv6cp_Setup(struct ipv6cp *ipv6cp)
308 ncpaddr_init(&ipv6cp->myaddr);
309 ncpaddr_init(&ipv6cp->hisaddr);
311 ipv6cp->his_reject = 0;
312 ipv6cp->my_reject = 0;
316 ipv6cp_SetLink(struct ipv6cp *ipv6cp, struct link *l)
318 ipv6cp->fsm.link = l;
322 ipv6cp_Show(struct cmdargs const *arg)
324 struct ipv6cp *ipv6cp = &arg->bundle->ncp.ipv6cp;
326 prompt_Printf(arg->prompt, "%s [%s]\n", ipv6cp->fsm.name,
327 State2Nam(ipv6cp->fsm.state));
328 if (ipv6cp->fsm.state == ST_OPENED) {
329 prompt_Printf(arg->prompt, " His side: %s\n",
330 ncpaddr_ntoa(&ipv6cp->hisaddr));
331 prompt_Printf(arg->prompt, " My side: %s\n",
332 ncpaddr_ntoa(&ipv6cp->myaddr));
333 prompt_Printf(arg->prompt, " Queued packets: %lu\n",
334 (unsigned long)ipv6cp_QueueLen(ipv6cp));
337 prompt_Printf(arg->prompt, "\nDefaults:\n");
338 prompt_Printf(arg->prompt, " FSM retry = %us, max %u Config"
339 " REQ%s, %u Term REQ%s\n\n", ipv6cp->cfg.fsm.timeout,
340 ipv6cp->cfg.fsm.maxreq, ipv6cp->cfg.fsm.maxreq == 1 ? "" : "s",
341 ipv6cp->cfg.fsm.maxtrm, ipv6cp->cfg.fsm.maxtrm == 1 ? "" : "s");
343 throughput_disp(&ipv6cp->throughput, arg->prompt);
349 ipv6cp_Input(struct bundle *bundle, struct link *l, struct mbuf *bp)
351 /* Got PROTO_IPV6CP from link */
352 m_settype(bp, MB_IPV6CPIN);
353 if (bundle_Phase(bundle) == PHASE_NETWORK)
354 fsm_Input(&bundle->ncp.ipv6cp.fsm, bp);
356 if (bundle_Phase(bundle) < PHASE_NETWORK)
357 log_Printf(LogIPV6CP, "%s: Error: Unexpected IPV6CP in phase %s"
358 " (ignored)\n", l->name, bundle_PhaseName(bundle));
365 ipv6cp_AddInOctets(struct ipv6cp *ipv6cp, int n)
367 throughput_addin(&ipv6cp->throughput, n);
371 ipv6cp_AddOutOctets(struct ipv6cp *ipv6cp, int n)
373 throughput_addout(&ipv6cp->throughput, n);
377 ipv6cp_IfaceAddrAdded(struct ipv6cp *ipv6cp, const struct iface_addr *addr)
382 ipv6cp_IfaceAddrDeleted(struct ipv6cp *ipv6cp, const struct iface_addr *addr)
387 ipv6cp_InterfaceUp(struct ipv6cp *ipv6cp)
389 if (!ipcp_SetIPv6address(ipv6cp, ipv6cp->my_ifid, ipv6cp->his_ifid)) {
390 log_Printf(LogERROR, "ipv6cp_InterfaceUp: unable to set ipv6 address\n");
394 if (!iface_SetFlags(ipv6cp->fsm.bundle->iface->name, IFF_UP)) {
395 log_Printf(LogERROR, "ipv6cp_InterfaceUp: Can't set the IFF_UP"
396 " flag on %s\n", ipv6cp->fsm.bundle->iface->name);
404 ipv6cp_QueueLen(struct ipv6cp *ipv6cp)
410 for (q = ipv6cp->Queue; q < ipv6cp->Queue + IPV6CP_QUEUES(ipv6cp); q++)
417 ipv6cp_PushPacket(struct ipv6cp *ipv6cp, struct link *l)
419 struct bundle *bundle = ipv6cp->fsm.bundle;
420 struct mqueue *queue;
424 unsigned alivesecs = 0;
426 if (ipv6cp->fsm.state != ST_OPENED)
430 * If ccp is not open but is required, do nothing.
432 if (l->ccp.fsm.state != ST_OPENED && ccp_Required(&l->ccp)) {
433 log_Printf(LogPHASE, "%s: Not transmitting... waiting for CCP\n", l->name);
437 queue = ipv6cp->Queue + IPV6CP_QUEUES(ipv6cp) - 1;
440 bp = m_dequeue(queue);
441 bp = mbuf_Read(bp, &secs, sizeof secs);
443 m_len = m_length(bp);
444 if (!FilterCheck(MBUF_CTOP(bp), AF_INET6, &bundle->filter.alive,
448 bundle_StartIdleTimer(bundle, secs);
450 link_PushPacket(l, bp, bundle, 0, PROTO_IPV6);
451 ipv6cp_AddOutOctets(ipv6cp, m_len);
454 } while (queue-- != ipv6cp->Queue);
460 ipv6cp_LayerUp(struct fsm *fp)
463 struct ipv6cp *ipv6cp = fsm2ipv6cp(fp);
466 log_Printf(LogIPV6CP, "%s: LayerUp.\n", fp->link->name);
467 if (!ipv6cp_InterfaceUp(ipv6cp))
470 snprintf(tbuff, sizeof tbuff, "%s", ncpaddr_ntoa(&ipv6cp->myaddr));
471 log_Printf(LogIPV6CP, "myaddr %s hisaddr = %s\n",
472 tbuff, ncpaddr_ntoa(&ipv6cp->hisaddr));
474 /* XXX: Call radius_Account() */
476 if (!Enabled(fp->bundle, OPT_IPCP)) {
478 * XXX this stuff should really live in the FSM. Our config should
479 * associate executable sections in files with events.
481 if (system_Select(fp->bundle, tbuff, LINKUPFILE, NULL, NULL) < 0) {
482 if (bundle_GetLabel(fp->bundle)) {
483 if (system_Select(fp->bundle, bundle_GetLabel(fp->bundle),
484 LINKUPFILE, NULL, NULL) < 0)
485 system_Select(fp->bundle, "MYADDR6", LINKUPFILE, NULL, NULL);
487 system_Select(fp->bundle, "MYADDR6", LINKUPFILE, NULL, NULL);
491 fp->more.reqs = fp->more.naks = fp->more.rejs = ipv6cp->cfg.fsm.maxreq * 3;
492 log_DisplayPrompts();
498 ipv6cp_LayerDown(struct fsm *fp)
500 /* About to come down */
501 struct ipv6cp *ipv6cp = fsm2ipv6cp(fp);
502 static int recursing;
506 snprintf(addr, sizeof addr, "%s", ncpaddr_ntoa(&ipv6cp->myaddr));
507 log_Printf(LogIPV6CP, "%s: LayerDown: %s\n", fp->link->name, addr);
509 /* XXX: Call radius_Account() */
511 if (!Enabled(fp->bundle, OPT_IPCP)) {
513 * XXX this stuff should really live in the FSM. Our config should
514 * associate executable sections in files with events.
516 if (system_Select(fp->bundle, addr, LINKDOWNFILE, NULL, NULL) < 0) {
517 if (bundle_GetLabel(fp->bundle)) {
518 if (system_Select(fp->bundle, bundle_GetLabel(fp->bundle),
519 LINKDOWNFILE, NULL, NULL) < 0)
520 system_Select(fp->bundle, "MYADDR6", LINKDOWNFILE, NULL, NULL);
522 system_Select(fp->bundle, "MYADDR6", LINKDOWNFILE, NULL, NULL);
526 ipv6cp_Setup(ipv6cp);
532 ipv6cp_LayerStart(struct fsm *fp)
534 /* We're about to start up ! */
535 struct ipv6cp *ipv6cp = fsm2ipv6cp(fp);
537 log_Printf(LogIPV6CP, "%s: LayerStart.\n", fp->link->name);
538 throughput_start(&ipv6cp->throughput, "IPV6CP throughput",
539 Enabled(fp->bundle, OPT_THROUGHPUT));
540 fp->more.reqs = fp->more.naks = fp->more.rejs = ipv6cp->cfg.fsm.maxreq * 3;
541 ipv6cp->peer_tokenreq = 0;
545 ipv6cp_LayerFinish(struct fsm *fp)
548 struct ipv6cp *ipv6cp = fsm2ipv6cp(fp);
550 log_Printf(LogIPV6CP, "%s: LayerFinish.\n", fp->link->name);
551 throughput_stop(&ipv6cp->throughput);
552 throughput_log(&ipv6cp->throughput, LogIPV6CP, NULL);
556 ipv6cp_InitRestartCounter(struct fsm *fp, int what)
558 /* Set fsm timer load */
559 struct ipv6cp *ipv6cp = fsm2ipv6cp(fp);
561 fp->FsmTimer.load = ipv6cp->cfg.fsm.timeout * SECTICKS;
564 fp->restart = ipv6cp->cfg.fsm.maxreq;
567 fp->restart = ipv6cp->cfg.fsm.maxtrm;
576 ipv6cp_SendConfigReq(struct fsm *fp)
578 /* Send config REQ please */
579 struct physical *p = link2physical(fp->link);
580 struct ipv6cp *ipv6cp = fsm2ipv6cp(fp);
581 u_char buff[IPV6CP_IFIDLEN+2];
584 o = (struct fsm_opt *)buff;
586 if ((p && !physical_IsSync(p)) || !REJECTED(ipv6cp, TY_TOKEN)) {
587 memcpy(o->data, ipv6cp->my_ifid, IPV6CP_IFIDLEN);
588 INC_FSM_OPT(TY_TOKEN, IPV6CP_IFIDLEN + 2, o);
591 fsm_Output(fp, CODE_CONFIGREQ, fp->reqid, buff, (u_char *)o - buff,
596 ipv6cp_SentTerminateReq(struct fsm *fp)
598 /* Term REQ just sent by FSM */
602 ipv6cp_SendTerminateAck(struct fsm *fp, u_char id)
604 /* Send Term ACK please */
605 fsm_Output(fp, CODE_TERMACK, id, NULL, 0, MB_IPV6CPOUT);
611 static const char *cftypes[] = { "IFACEID", "COMPPROTO" };
613 if (proto > 0 && proto <= sizeof cftypes / sizeof *cftypes)
614 return cftypes[proto - 1];
616 return NumStr(proto, NULL, 0);
620 ipv6cp_ValidateInterfaceID(struct ipv6cp *ipv6cp, u_char *ifid,
621 struct fsm_decode *dec)
624 u_char zero[IPV6CP_IFIDLEN];
626 memset(zero, 0, IPV6CP_IFIDLEN);
628 if (memcmp(ifid, zero, IPV6CP_IFIDLEN) != 0
629 && memcmp(ifid, ipv6cp->my_ifid, IPV6CP_IFIDLEN) != 0)
630 memcpy(ipv6cp->his_ifid, ifid, IPV6CP_IFIDLEN);
632 opt.hdr.id = TY_TOKEN;
633 opt.hdr.len = IPV6CP_IFIDLEN + 2;
634 memcpy(opt.data, &ipv6cp->his_ifid, IPV6CP_IFIDLEN);
635 if (memcmp(ifid, ipv6cp->his_ifid, IPV6CP_IFIDLEN) == 0)
642 ipv6cp_DecodeConfig(struct fsm *fp, u_char *cp, u_char *end, int mode_type,
643 struct fsm_decode *dec)
645 /* Deal with incoming PROTO_IPV6CP */
646 struct ipv6cp *ipv6cp = fsm2ipv6cp(fp);
649 u_char ifid[IPV6CP_IFIDLEN], zero[IPV6CP_IFIDLEN];
652 memset(zero, 0, IPV6CP_IFIDLEN);
654 while (end - cp >= sizeof(opt->hdr)) {
655 if ((opt = fsm_readopt(&cp)) == NULL)
658 snprintf(tbuff, sizeof tbuff, " %s[%d]", protoname(opt->hdr.id),
661 switch (opt->hdr.id) {
663 memcpy(ifid, opt->data, IPV6CP_IFIDLEN);
664 log_Printf(LogIPV6CP, "%s 0x%02x%02x%02x%02x%02x%02x%02x%02x\n", tbuff,
665 ifid[0], ifid[1], ifid[2], ifid[3], ifid[4], ifid[5], ifid[6], ifid[7]);
669 ipv6cp->peer_tokenreq = 1;
670 ipv6cp_ValidateInterfaceID(ipv6cp, ifid, dec);
674 if (memcmp(ifid, zero, IPV6CP_IFIDLEN) == 0) {
675 log_Printf(log_IsKept(LogIPV6CP) ? LogIPV6CP : LogPHASE,
676 "0x0000000000000000: Unacceptable IntefaceID!\n");
677 fsm_Close(&ipv6cp->fsm);
678 } else if (memcmp(ifid, ipv6cp->his_ifid, IPV6CP_IFIDLEN) == 0) {
679 log_Printf(log_IsKept(LogIPV6CP) ? LogIPV6CP : LogPHASE,
680 "0x%02x%02x%02x%02x%02x%02x%02x%02x: "
681 "Unacceptable IntefaceID!\n",
682 ifid[0], ifid[1], ifid[2], ifid[3],
683 ifid[4], ifid[5], ifid[6], ifid[7]);
684 } else if (memcmp(ifid, ipv6cp->my_ifid, IPV6CP_IFIDLEN) != 0) {
686 while (n && !ipcp_SetIPv6address(ipv6cp, ifid, ipv6cp->his_ifid)) {
689 SetInterfaceID(ifid, 1);
690 } while (n && memcmp(ifid, ipv6cp->his_ifid, IPV6CP_IFIDLEN) == 0);
694 log_Printf(log_IsKept(LogIPV6CP) ? LogIPV6CP : LogPHASE,
695 "0x0000000000000000: Unacceptable IntefaceID!\n");
696 fsm_Close(&ipv6cp->fsm);
698 log_Printf(LogIPV6CP, "%s changing IntefaceID: "
699 "0x%02x%02x%02x%02x%02x%02x%02x%02x "
700 "--> 0x%02x%02x%02x%02x%02x%02x%02x%02x\n", tbuff,
701 ipv6cp->my_ifid[0], ipv6cp->my_ifid[1],
702 ipv6cp->my_ifid[2], ipv6cp->my_ifid[3],
703 ipv6cp->my_ifid[4], ipv6cp->my_ifid[5],
704 ipv6cp->my_ifid[6], ipv6cp->my_ifid[7],
705 ifid[0], ifid[1], ifid[2], ifid[3],
706 ifid[4], ifid[5], ifid[6], ifid[7]);
707 memcpy(ipv6cp->my_ifid, ifid, IPV6CP_IFIDLEN);
708 bundle_AdjustFilters(fp->bundle, &ipv6cp->myaddr, NULL);
714 ipv6cp->his_reject |= (1 << opt->hdr.id);
720 if (mode_type != MODE_NOP) {
721 ipv6cp->my_reject |= (1 << opt->hdr.id);
728 if (mode_type != MODE_NOP) {
729 if (mode_type == MODE_REQ && !ipv6cp->peer_tokenreq) {
730 if (dec->rejend == dec->rej && dec->nakend == dec->nak) {
732 * Pretend the peer has requested a TOKEN.
733 * We do this to ensure that we only send one NAK if the only
734 * reason for the NAK is because the peer isn't sending a
735 * TY_TOKEN REQ. This stops us from repeatedly trying to tell
736 * the peer that we have to have an IP address on their end.
738 ipv6cp->peer_tokenreq = 1;
740 memset(ifid, 0, IPV6CP_IFIDLEN);
741 ipv6cp_ValidateInterfaceID(ipv6cp, ifid, dec);
743 fsm_opt_normalise(dec);