if_spppsubr.c (59604) | if_spppsubr.c (69152) |
---|---|
1/* 2 * Synchronous PPP/Cisco link level subroutines. 3 * Keepalive protocol implemented in both Cisco and PPP modes. 4 * 5 * Copyright (C) 1994-1996 Cronyx Engineering Ltd. 6 * Author: Serge Vakulenko, <vak@cronyx.ru> 7 * 8 * Heavily revamped to conform to RFC 1661. 9 * Copyright (C) 1997, Joerg Wunsch. 10 * 11 * This software is distributed with NO WARRANTIES, not even the implied 12 * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * 14 * Authors grant any other persons or organisations permission to use 15 * or modify this software as long as this message is kept with the software, 16 * all derivative works or modified versions. 17 * 18 * From: Version 2.4, Thu Apr 30 17:17:21 MSD 1997 19 * | 1/* 2 * Synchronous PPP/Cisco link level subroutines. 3 * Keepalive protocol implemented in both Cisco and PPP modes. 4 * 5 * Copyright (C) 1994-1996 Cronyx Engineering Ltd. 6 * Author: Serge Vakulenko, <vak@cronyx.ru> 7 * 8 * Heavily revamped to conform to RFC 1661. 9 * Copyright (C) 1997, Joerg Wunsch. 10 * 11 * This software is distributed with NO WARRANTIES, not even the implied 12 * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * 14 * Authors grant any other persons or organisations permission to use 15 * or modify this software as long as this message is kept with the software, 16 * all derivative works or modified versions. 17 * 18 * From: Version 2.4, Thu Apr 30 17:17:21 MSD 1997 19 * |
20 * $FreeBSD: head/sys/net/if_spppsubr.c 59604 2000-04-24 17:30:08Z obrien $ | 20 * $FreeBSD: head/sys/net/if_spppsubr.c 69152 2000-11-25 07:35:38Z jlemon $ |
21 */ 22 23#include <sys/param.h> 24 25#if defined(__FreeBSD__) && __FreeBSD__ >= 3 26#include "opt_inet.h" 27#include "opt_inet6.h" 28#include "opt_ipx.h" --- 556 unchanged lines hidden (view full) --- 585 h->address, h->control, ntohs(h->protocol)); 586 goto drop; 587 } 588 589 if (! (ifp->if_flags & IFF_UP) || ! inq) 590 goto drop; 591 592 /* Check queue. */ | 21 */ 22 23#include <sys/param.h> 24 25#if defined(__FreeBSD__) && __FreeBSD__ >= 3 26#include "opt_inet.h" 27#include "opt_inet6.h" 28#include "opt_ipx.h" --- 556 unchanged lines hidden (view full) --- 585 h->address, h->control, ntohs(h->protocol)); 586 goto drop; 587 } 588 589 if (! (ifp->if_flags & IFF_UP) || ! inq) 590 goto drop; 591 592 /* Check queue. */ |
593 s = splimp(); 594 if (IF_QFULL (inq)) { 595 /* Queue overflow. */ 596 IF_DROP(inq); 597 splx(s); | 593 if (! IF_HANDOFF(inq, m, NULL)) { |
598 if (debug) 599 log(LOG_DEBUG, SPP_FMT "protocol queue overflow\n", 600 SPP_ARGS(ifp)); 601 goto drop; 602 } | 594 if (debug) 595 log(LOG_DEBUG, SPP_FMT "protocol queue overflow\n", 596 SPP_ARGS(ifp)); 597 goto drop; 598 } |
603 IF_ENQUEUE(inq, m); 604 splx(s); | |
605} 606 607/* 608 * Enqueue transmit packet. 609 */ 610static int 611sppp_output(struct ifnet *ifp, struct mbuf *m, 612 struct sockaddr *dst, struct rtentry *rt) --- 51 unchanged lines hidden (view full) --- 664 else 665 return(0); 666 } 667 668 /* 669 * Put low delay, telnet, rlogin and ftp control packets 670 * in front of the queue. 671 */ | 599} 600 601/* 602 * Enqueue transmit packet. 603 */ 604static int 605sppp_output(struct ifnet *ifp, struct mbuf *m, 606 struct sockaddr *dst, struct rtentry *rt) --- 51 unchanged lines hidden (view full) --- 658 else 659 return(0); 660 } 661 662 /* 663 * Put low delay, telnet, rlogin and ftp control packets 664 * in front of the queue. 665 */ |
672 if (IF_QFULL (&sp->pp_fastq)) | 666 if (_IF_QFULL(&sp->pp_fastq)) |
673 ; 674 else if (ip->ip_tos & IPTOS_LOWDELAY) 675 ifq = &sp->pp_fastq; 676 else if (m->m_len < sizeof *ip + sizeof *tcp) 677 ; 678 else if (ip->ip_p != IPPROTO_TCP) 679 ; 680 else if (INTERACTIVE (ntohs (tcp->th_sport))) --- 75 unchanged lines hidden (view full) --- 756 m_freem (m); 757 ++ifp->if_oerrors; 758 splx (s); 759 return (EAFNOSUPPORT); 760 } 761 762 /* 763 * Queue message on interface, and start output if interface | 667 ; 668 else if (ip->ip_tos & IPTOS_LOWDELAY) 669 ifq = &sp->pp_fastq; 670 else if (m->m_len < sizeof *ip + sizeof *tcp) 671 ; 672 else if (ip->ip_p != IPPROTO_TCP) 673 ; 674 else if (INTERACTIVE (ntohs (tcp->th_sport))) --- 75 unchanged lines hidden (view full) --- 750 m_freem (m); 751 ++ifp->if_oerrors; 752 splx (s); 753 return (EAFNOSUPPORT); 754 } 755 756 /* 757 * Queue message on interface, and start output if interface |
764 * not yet active. | 758 * not yet active. Also adjust output byte count. 759 * The packet length includes header, FCS and 1 flag, 760 * according to RFC 1333. |
765 */ | 761 */ |
766 if (IF_QFULL (ifq)) { 767 IF_DROP (&ifp->if_snd); 768 m_freem (m); | 762 if (! IF_HANDOFF_ADJ(ifq, m, ifp, 3)) { |
769 ++ifp->if_oerrors; | 763 ++ifp->if_oerrors; |
770 splx (s); | |
771 return (rv? rv: ENOBUFS); 772 } | 764 return (rv? rv: ENOBUFS); 765 } |
773 IF_ENQUEUE (ifq, m); 774 if (! (ifp->if_flags & IFF_OACTIVE)) 775 (*ifp->if_start) (ifp); 776 777 /* 778 * Count output packets and bytes. 779 * The packet length includes header, FCS and 1 flag, 780 * according to RFC 1333. 781 */ 782 ifp->if_obytes += m->m_pkthdr.len + 3; 783 splx (s); | |
784 return (0); 785} 786 787void 788sppp_attach(struct ifnet *ifp) 789{ 790 struct sppp *sp = (struct sppp*) ifp; 791 --- 16 unchanged lines hidden (view full) --- 808 sp->pp_cpq.ifq_maxlen = 20; 809 sp->pp_loopcnt = 0; 810 sp->pp_alivecnt = 0; 811 sp->pp_seq = 0; 812 sp->pp_rseq = 0; 813 sp->pp_phase = PHASE_DEAD; 814 sp->pp_up = lcp.Up; 815 sp->pp_down = lcp.Down; | 766 return (0); 767} 768 769void 770sppp_attach(struct ifnet *ifp) 771{ 772 struct sppp *sp = (struct sppp*) ifp; 773 --- 16 unchanged lines hidden (view full) --- 790 sp->pp_cpq.ifq_maxlen = 20; 791 sp->pp_loopcnt = 0; 792 sp->pp_alivecnt = 0; 793 sp->pp_seq = 0; 794 sp->pp_rseq = 0; 795 sp->pp_phase = PHASE_DEAD; 796 sp->pp_up = lcp.Up; 797 sp->pp_down = lcp.Down; |
798 mtx_init(&sp->pp_cpq.ifq_mtx, "sppp_cpq", MTX_DEF); 799 mtx_init(&sp->pp_fastq.ifq_mtx, "sppp_fastq", MTX_DEF); |
|
816 817 sppp_lcp_init(sp); 818 sppp_ipcp_init(sp); 819 sppp_pap_init(sp); 820 sppp_chap_init(sp); 821} 822 823void --- 11 unchanged lines hidden (view full) --- 835 836 /* Stop keepalive handler. */ 837 if (! spppq) 838 UNTIMEOUT(sppp_keepalive, 0, keepalive_ch); 839 840 for (i = 0; i < IDX_COUNT; i++) 841 UNTIMEOUT((cps[i])->TO, (void *)sp, sp->ch[i]); 842 UNTIMEOUT(sppp_pap_my_TO, (void *)sp, sp->pap_my_to_ch); | 800 801 sppp_lcp_init(sp); 802 sppp_ipcp_init(sp); 803 sppp_pap_init(sp); 804 sppp_chap_init(sp); 805} 806 807void --- 11 unchanged lines hidden (view full) --- 819 820 /* Stop keepalive handler. */ 821 if (! spppq) 822 UNTIMEOUT(sppp_keepalive, 0, keepalive_ch); 823 824 for (i = 0; i < IDX_COUNT; i++) 825 UNTIMEOUT((cps[i])->TO, (void *)sp, sp->ch[i]); 826 UNTIMEOUT(sppp_pap_my_TO, (void *)sp, sp->pap_my_to_ch); |
827 mtx_destroy(&sp->pp_cpq.ifq_mtx); 828 mtx_destroy(&sp->pp_fastq.ifq_mtx); |
|
843} 844 845/* 846 * Flush the interface output queue. 847 */ 848void 849sppp_flush(struct ifnet *ifp) 850{ --- 305 unchanged lines hidden (view full) --- 1156#endif 1157 1158 if (debug) 1159 log(LOG_DEBUG, 1160 SPP_FMT "cisco output: <0x%lx 0x%lx 0x%lx 0x%x 0x%x-0x%x>\n", 1161 SPP_ARGS(ifp), (u_long)ntohl (ch->type), (u_long)ch->par1, 1162 (u_long)ch->par2, (u_int)ch->rel, (u_int)ch->time0, (u_int)ch->time1); 1163 | 829} 830 831/* 832 * Flush the interface output queue. 833 */ 834void 835sppp_flush(struct ifnet *ifp) 836{ --- 305 unchanged lines hidden (view full) --- 1142#endif 1143 1144 if (debug) 1145 log(LOG_DEBUG, 1146 SPP_FMT "cisco output: <0x%lx 0x%lx 0x%lx 0x%x 0x%x-0x%x>\n", 1147 SPP_ARGS(ifp), (u_long)ntohl (ch->type), (u_long)ch->par1, 1148 (u_long)ch->par2, (u_int)ch->rel, (u_int)ch->time0, (u_int)ch->time1); 1149 |
1164 if (IF_QFULL (&sp->pp_cpq)) { 1165 IF_DROP (&sp->pp_fastq); 1166 IF_DROP (&ifp->if_snd); 1167 m_freem (m); 1168 } else 1169 IF_ENQUEUE (&sp->pp_cpq, m); 1170 if (! (ifp->if_flags & IFF_OACTIVE)) 1171 (*ifp->if_start) (ifp); 1172 ifp->if_obytes += m->m_pkthdr.len + 3; | 1150 if (! IF_HANDOFF_ADJ(&sp->pp_cpq, m, ifp, 3)) 1151 ifp->if_oerrors++; |
1173} 1174 1175/* 1176 * PPP protocol implementation. 1177 */ 1178 1179/* 1180 * Send PPP control protocol packet. --- 31 unchanged lines hidden (view full) --- 1212 log(LOG_DEBUG, SPP_FMT "%s output <%s id=0x%x len=%d", 1213 SPP_ARGS(ifp), 1214 sppp_proto_name(proto), 1215 sppp_cp_type_name (lh->type), lh->ident, 1216 ntohs (lh->len)); 1217 sppp_print_bytes ((u_char*) (lh+1), len); 1218 addlog(">\n"); 1219 } | 1152} 1153 1154/* 1155 * PPP protocol implementation. 1156 */ 1157 1158/* 1159 * Send PPP control protocol packet. --- 31 unchanged lines hidden (view full) --- 1191 log(LOG_DEBUG, SPP_FMT "%s output <%s id=0x%x len=%d", 1192 SPP_ARGS(ifp), 1193 sppp_proto_name(proto), 1194 sppp_cp_type_name (lh->type), lh->ident, 1195 ntohs (lh->len)); 1196 sppp_print_bytes ((u_char*) (lh+1), len); 1197 addlog(">\n"); 1198 } |
1220 if (IF_QFULL (&sp->pp_cpq)) { 1221 IF_DROP (&sp->pp_fastq); 1222 IF_DROP (&ifp->if_snd); 1223 m_freem (m); 1224 ++ifp->if_oerrors; 1225 } else 1226 IF_ENQUEUE (&sp->pp_cpq, m); 1227 if (! (ifp->if_flags & IFF_OACTIVE)) 1228 (*ifp->if_start) (ifp); 1229 ifp->if_obytes += m->m_pkthdr.len + 3; | 1199 if (! IF_HANDOFF_ADJ(&sp->pp_cpq, m, ifp, 3)) 1200 ifp->if_oerrors++; |
1230} 1231 1232/* 1233 * Handle incoming PPP control protocol packets. 1234 */ 1235static void 1236sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) 1237{ --- 2484 unchanged lines hidden (view full) --- 3722 if (debug) { 3723 log(LOG_DEBUG, SPP_FMT "%s output <%s id=0x%x len=%d", 3724 SPP_ARGS(ifp), cp->name, 3725 sppp_auth_type_name(cp->proto, lh->type), 3726 lh->ident, ntohs(lh->len)); 3727 sppp_print_bytes((u_char*) (lh+1), len); 3728 addlog(">\n"); 3729 } | 1201} 1202 1203/* 1204 * Handle incoming PPP control protocol packets. 1205 */ 1206static void 1207sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) 1208{ --- 2484 unchanged lines hidden (view full) --- 3693 if (debug) { 3694 log(LOG_DEBUG, SPP_FMT "%s output <%s id=0x%x len=%d", 3695 SPP_ARGS(ifp), cp->name, 3696 sppp_auth_type_name(cp->proto, lh->type), 3697 lh->ident, ntohs(lh->len)); 3698 sppp_print_bytes((u_char*) (lh+1), len); 3699 addlog(">\n"); 3700 } |
3730 if (IF_QFULL (&sp->pp_cpq)) { 3731 IF_DROP (&sp->pp_fastq); 3732 IF_DROP (&ifp->if_snd); 3733 m_freem (m); 3734 ++ifp->if_oerrors; 3735 } else 3736 IF_ENQUEUE (&sp->pp_cpq, m); 3737 if (! (ifp->if_flags & IFF_OACTIVE)) 3738 (*ifp->if_start) (ifp); 3739 ifp->if_obytes += m->m_pkthdr.len + 3; | 3701 if (! IF_HANDOFF_ADJ(&sp->pp_cpq, m, ifp, 3)) 3702 ifp->if_oerrors++; |
3740} 3741 3742/* 3743 * Flush interface queue. 3744 */ 3745static void 3746sppp_qflush(struct ifqueue *ifq) 3747{ --- 489 unchanged lines hidden --- | 3703} 3704 3705/* 3706 * Flush interface queue. 3707 */ 3708static void 3709sppp_qflush(struct ifqueue *ifq) 3710{ --- 489 unchanged lines hidden --- |