if_spppsubr.c (161556) | if_spppsubr.c (165118) |
---|---|
1/* 2 * Synchronous PPP/Cisco/Frame Relay link level subroutines. 3 * Keepalive protocol implemented in both Cisco and PPP modes. 4 */ 5/*- 6 * Copyright (C) 1994-2000 Cronyx Engineering. 7 * Author: Serge Vakulenko, <vak@cronyx.ru> 8 * --- 4 unchanged lines hidden (view full) --- 13 * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 * 15 * Authors grant any other persons or organisations permission to use 16 * or modify this software as long as this message is kept with the software, 17 * all derivative works or modified versions. 18 * 19 * From: Version 2.4, Thu Apr 30 17:17:21 MSD 1997 20 * | 1/* 2 * Synchronous PPP/Cisco/Frame Relay link level subroutines. 3 * Keepalive protocol implemented in both Cisco and PPP modes. 4 */ 5/*- 6 * Copyright (C) 1994-2000 Cronyx Engineering. 7 * Author: Serge Vakulenko, <vak@cronyx.ru> 8 * --- 4 unchanged lines hidden (view full) --- 13 * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 * 15 * Authors grant any other persons or organisations permission to use 16 * or modify this software as long as this message is kept with the software, 17 * all derivative works or modified versions. 18 * 19 * From: Version 2.4, Thu Apr 30 17:17:21 MSD 1997 20 * |
21 * $FreeBSD: head/sys/net/if_spppsubr.c 161556 2006-08-23 22:06:08Z cperciva $ | 21 * $FreeBSD: head/sys/net/if_spppsubr.c 165118 2006-12-12 12:17:58Z bz $ |
22 */ 23 24#include <sys/param.h> 25 26#if defined(__FreeBSD__) && __FreeBSD__ >= 3 27#include "opt_inet.h" 28#include "opt_inet6.h" 29#include "opt_ipx.h" --- 3467 unchanged lines hidden (view full) --- 3497{ 3498 u_char *buf, *r, *p; 3499 struct ifnet *ifp = SP2IFP(sp); 3500 int rlen, origlen, debug = ifp->if_flags & IFF_DEBUG; 3501 struct in6_addr myaddr, desiredaddr, suggestaddr; 3502 int ifidcount; 3503 int type; 3504 int collision, nohisaddr; | 22 */ 23 24#include <sys/param.h> 25 26#if defined(__FreeBSD__) && __FreeBSD__ >= 3 27#include "opt_inet.h" 28#include "opt_inet6.h" 29#include "opt_ipx.h" --- 3467 unchanged lines hidden (view full) --- 3497{ 3498 u_char *buf, *r, *p; 3499 struct ifnet *ifp = SP2IFP(sp); 3500 int rlen, origlen, debug = ifp->if_flags & IFF_DEBUG; 3501 struct in6_addr myaddr, desiredaddr, suggestaddr; 3502 int ifidcount; 3503 int type; 3504 int collision, nohisaddr; |
3505 char ip6buf[INET6_ADDRSTRLEN]; |
|
3505 3506 len -= 4; 3507 origlen = len; 3508 /* 3509 * Make sure to allocate a buf that can at least hold a 3510 * conf-nak with an `address' option. We might need it below. 3511 */ 3512 buf = r = malloc ((len < 6? 6: len), M_TEMP, M_NOWAIT); --- 77 unchanged lines hidden (view full) --- 3590 (void)in6_setscope(&desiredaddr, SP2IFP(sp), NULL); 3591 3592 if (!collision && !nohisaddr) { 3593 /* no collision, hisaddr known - Conf-Ack */ 3594 type = CONF_ACK; 3595 3596 if (debug) { 3597 log(-1, " %s [%s]", | 3506 3507 len -= 4; 3508 origlen = len; 3509 /* 3510 * Make sure to allocate a buf that can at least hold a 3511 * conf-nak with an `address' option. We might need it below. 3512 */ 3513 buf = r = malloc ((len < 6? 6: len), M_TEMP, M_NOWAIT); --- 77 unchanged lines hidden (view full) --- 3591 (void)in6_setscope(&desiredaddr, SP2IFP(sp), NULL); 3592 3593 if (!collision && !nohisaddr) { 3594 /* no collision, hisaddr known - Conf-Ack */ 3595 type = CONF_ACK; 3596 3597 if (debug) { 3598 log(-1, " %s [%s]", |
3598 ip6_sprintf(&desiredaddr), 3599 sppp_cp_type_name(type)); | 3599 ip6_sprintf(ip6buf, &desiredaddr), 3600 sppp_cp_type_name(type)); |
3600 } 3601 continue; 3602 } 3603 3604 bzero(&suggestaddr, sizeof(&suggestaddr)); 3605 if (collision && nohisaddr) { 3606 /* collision, hisaddr unknown - Conf-Rej */ 3607 type = CONF_REJ; --- 4 unchanged lines hidden (view full) --- 3612 * - collision, hisaddr known 3613 * Conf-Nak, suggest hisaddr 3614 */ 3615 type = CONF_NAK; 3616 sppp_suggest_ip6_addr(sp, &suggestaddr); 3617 bcopy(&suggestaddr.s6_addr[8], &p[2], 8); 3618 } 3619 if (debug) | 3601 } 3602 continue; 3603 } 3604 3605 bzero(&suggestaddr, sizeof(&suggestaddr)); 3606 if (collision && nohisaddr) { 3607 /* collision, hisaddr unknown - Conf-Rej */ 3608 type = CONF_REJ; --- 4 unchanged lines hidden (view full) --- 3613 * - collision, hisaddr known 3614 * Conf-Nak, suggest hisaddr 3615 */ 3616 type = CONF_NAK; 3617 sppp_suggest_ip6_addr(sp, &suggestaddr); 3618 bcopy(&suggestaddr.s6_addr[8], &p[2], 8); 3619 } 3620 if (debug) |
3620 log(-1, " %s [%s]", ip6_sprintf(&desiredaddr), 3621 sppp_cp_type_name(type)); | 3621 log(-1, " %s [%s]", 3622 ip6_sprintf(ip6buf, &desiredaddr), 3623 sppp_cp_type_name(type)); |
3622 break; 3623 } 3624 /* Add the option to nak'ed list. */ 3625 bcopy (p, r, p[1]); 3626 r += p[1]; 3627 rlen += p[1]; 3628 } 3629 --- 4 unchanged lines hidden (view full) --- 3634 } else { 3635#ifdef DIAGNOSTIC 3636 if (type == CONF_ACK) 3637 panic("IPv6CP RCR: CONF_ACK with non-zero rlen"); 3638#endif 3639 3640 if (debug) { 3641 log(-1, " send %s suggest %s\n", | 3624 break; 3625 } 3626 /* Add the option to nak'ed list. */ 3627 bcopy (p, r, p[1]); 3628 r += p[1]; 3629 rlen += p[1]; 3630 } 3631 --- 4 unchanged lines hidden (view full) --- 3636 } else { 3637#ifdef DIAGNOSTIC 3638 if (type == CONF_ACK) 3639 panic("IPv6CP RCR: CONF_ACK with non-zero rlen"); 3640#endif 3641 3642 if (debug) { 3643 log(-1, " send %s suggest %s\n", |
3642 sppp_cp_type_name(type), ip6_sprintf(&suggestaddr)); | 3644 sppp_cp_type_name(type), 3645 ip6_sprintf(ip6buf, &suggestaddr)); |
3643 } 3644 sppp_cp_send (sp, PPP_IPV6CP, type, h->ident, rlen, buf); 3645 } 3646 3647 end: 3648 free (buf, M_TEMP); 3649 return (rlen == 0); 3650} --- 50 unchanged lines hidden (view full) --- 3701 */ 3702static void 3703sppp_ipv6cp_RCN_nak(struct sppp *sp, struct lcp_header *h, int len) 3704{ 3705 u_char *buf, *p; 3706 struct ifnet *ifp = SP2IFP(sp); 3707 int debug = ifp->if_flags & IFF_DEBUG; 3708 struct in6_addr suggestaddr; | 3646 } 3647 sppp_cp_send (sp, PPP_IPV6CP, type, h->ident, rlen, buf); 3648 } 3649 3650 end: 3651 free (buf, M_TEMP); 3652 return (rlen == 0); 3653} --- 50 unchanged lines hidden (view full) --- 3704 */ 3705static void 3706sppp_ipv6cp_RCN_nak(struct sppp *sp, struct lcp_header *h, int len) 3707{ 3708 u_char *buf, *p; 3709 struct ifnet *ifp = SP2IFP(sp); 3710 int debug = ifp->if_flags & IFF_DEBUG; 3711 struct in6_addr suggestaddr; |
3712 char ip6buf[INET6_ADDRSTRLEN]; |
|
3709 3710 len -= 4; 3711 buf = malloc (len, M_TEMP, M_NOWAIT); 3712 if (!buf) 3713 return; 3714 3715 if (debug) 3716 log(LOG_DEBUG, SPP_FMT "ipv6cp nak opts:", --- 16 unchanged lines hidden (view full) --- 3733 bzero(&suggestaddr, sizeof(suggestaddr)); 3734 suggestaddr.s6_addr16[0] = htons(0xfe80); 3735 (void)in6_setscope(&suggestaddr, SP2IFP(sp), NULL); 3736 bcopy(&p[2], &suggestaddr.s6_addr[8], 8); 3737 3738 sp->ipv6cp.opts |= (1 << IPV6CP_OPT_IFID); 3739 if (debug) 3740 log(-1, " [suggestaddr %s]", | 3713 3714 len -= 4; 3715 buf = malloc (len, M_TEMP, M_NOWAIT); 3716 if (!buf) 3717 return; 3718 3719 if (debug) 3720 log(LOG_DEBUG, SPP_FMT "ipv6cp nak opts:", --- 16 unchanged lines hidden (view full) --- 3737 bzero(&suggestaddr, sizeof(suggestaddr)); 3738 suggestaddr.s6_addr16[0] = htons(0xfe80); 3739 (void)in6_setscope(&suggestaddr, SP2IFP(sp), NULL); 3740 bcopy(&p[2], &suggestaddr.s6_addr[8], 8); 3741 3742 sp->ipv6cp.opts |= (1 << IPV6CP_OPT_IFID); 3743 if (debug) 3744 log(-1, " [suggestaddr %s]", |
3741 ip6_sprintf(&suggestaddr)); | 3745 ip6_sprintf(ip6buf, &suggestaddr)); |
3742#ifdef IPV6CP_MYIFID_DYN 3743 /* 3744 * When doing dynamic address assignment, 3745 * we accept his offer. 3746 */ 3747 if (sp->ipv6cp.flags & IPV6CP_MYIFID_DYN) { 3748 struct in6_addr lastsuggest; 3749 /* --- 1768 unchanged lines hidden --- | 3746#ifdef IPV6CP_MYIFID_DYN 3747 /* 3748 * When doing dynamic address assignment, 3749 * we accept his offer. 3750 */ 3751 if (sp->ipv6cp.flags & IPV6CP_MYIFID_DYN) { 3752 struct in6_addr lastsuggest; 3753 /* --- 1768 unchanged lines hidden --- |