Deleted Added
full compact
if_spppsubr.c (111119) if_spppsubr.c (111888)
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, 2001 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, 2001 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 111119 2003-02-19 05:47:46Z imp $
20 * $FreeBSD: head/sys/net/if_spppsubr.c 111888 2003-03-04 23:19:55Z 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"

--- 480 unchanged lines hidden (view full) ---

509
510/*
511 * Process the received packet.
512 */
513void
514sppp_input(struct ifnet *ifp, struct mbuf *m)
515{
516 struct ppp_header *h;
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"

--- 480 unchanged lines hidden (view full) ---

509
510/*
511 * Process the received packet.
512 */
513void
514sppp_input(struct ifnet *ifp, struct mbuf *m)
515{
516 struct ppp_header *h;
517 struct ifqueue *inq = 0;
517 int isr = -1;
518 struct sppp *sp = (struct sppp *)ifp;
519 u_char *iphdr;
520 int hlen, vjlen, do_account = 0;
521 int debug = ifp->if_flags & IFF_DEBUG;
522
523 if (ifp->if_flags & IFF_UP)
524 /* Count received bytes, add FCS and one flag */
525 ifp->if_ibytes += m->m_pkthdr.len + 3;

--- 60 unchanged lines hidden (view full) ---

586#ifdef INET
587 case PPP_IPCP:
588 if (sp->pp_phase == PHASE_NETWORK)
589 sppp_cp_input(&ipcp, sp, m);
590 m_freem (m);
591 return;
592 case PPP_IP:
593 if (sp->state[IDX_IPCP] == STATE_OPENED) {
518 struct sppp *sp = (struct sppp *)ifp;
519 u_char *iphdr;
520 int hlen, vjlen, do_account = 0;
521 int debug = ifp->if_flags & IFF_DEBUG;
522
523 if (ifp->if_flags & IFF_UP)
524 /* Count received bytes, add FCS and one flag */
525 ifp->if_ibytes += m->m_pkthdr.len + 3;

--- 60 unchanged lines hidden (view full) ---

586#ifdef INET
587 case PPP_IPCP:
588 if (sp->pp_phase == PHASE_NETWORK)
589 sppp_cp_input(&ipcp, sp, m);
590 m_freem (m);
591 return;
592 case PPP_IP:
593 if (sp->state[IDX_IPCP] == STATE_OPENED) {
594 schednetisr (NETISR_IP);
595 inq = &ipintrq;
594 isr = NETISR_IP;
596 }
597 do_account++;
598 break;
599 case PPP_VJ_COMP:
600 if (sp->state[IDX_IPCP] == STATE_OPENED) {
601 if ((vjlen =
602 sl_uncompress_tcp_core(mtod(m, u_char *),
603 m->m_len, m->m_len,

--- 13 unchanged lines hidden (view full) ---

617 * end up in two chained mbufs since there's not
618 * enough leading space in the existing mbuf).
619 */
620 m_adj(m, vjlen);
621 M_PREPEND(m, hlen, M_DONTWAIT);
622 if (m == NULL)
623 goto drop2;
624 bcopy(iphdr, mtod(m, u_char *), hlen);
595 }
596 do_account++;
597 break;
598 case PPP_VJ_COMP:
599 if (sp->state[IDX_IPCP] == STATE_OPENED) {
600 if ((vjlen =
601 sl_uncompress_tcp_core(mtod(m, u_char *),
602 m->m_len, m->m_len,

--- 13 unchanged lines hidden (view full) ---

616 * end up in two chained mbufs since there's not
617 * enough leading space in the existing mbuf).
618 */
619 m_adj(m, vjlen);
620 M_PREPEND(m, hlen, M_DONTWAIT);
621 if (m == NULL)
622 goto drop2;
623 bcopy(iphdr, mtod(m, u_char *), hlen);
625
626 schednetisr (NETISR_IP);
627 inq = &ipintrq;
624 isr = NETISR_IP;
628 }
629 do_account++;
630 break;
631 case PPP_VJ_UCOMP:
632 if (sp->state[IDX_IPCP] == STATE_OPENED) {
633 if (sl_uncompress_tcp_core(mtod(m, u_char *),
634 m->m_len, m->m_len,
635 TYPE_UNCOMPRESSED_TCP,
636 sp->pp_comp,
637 &iphdr, &hlen) != 0) {
638 if (debug)
639 log(LOG_INFO,
640 SPP_FMT "VJ uncompress failed on uncompressed packet\n",
641 SPP_ARGS(ifp));
642 goto drop;
643 }
625 }
626 do_account++;
627 break;
628 case PPP_VJ_UCOMP:
629 if (sp->state[IDX_IPCP] == STATE_OPENED) {
630 if (sl_uncompress_tcp_core(mtod(m, u_char *),
631 m->m_len, m->m_len,
632 TYPE_UNCOMPRESSED_TCP,
633 sp->pp_comp,
634 &iphdr, &hlen) != 0) {
635 if (debug)
636 log(LOG_INFO,
637 SPP_FMT "VJ uncompress failed on uncompressed packet\n",
638 SPP_ARGS(ifp));
639 goto drop;
640 }
644 schednetisr (NETISR_IP);
645 inq = &ipintrq;
641 isr = NETISR_IP;
646 }
647 do_account++;
648 break;
649#endif
650#ifdef INET6
651 case PPP_IPV6CP:
652 if (sp->pp_phase == PHASE_NETWORK)
653 sppp_cp_input(&ipv6cp, sp, m);
654 m_freem (m);
655 return;
656
657 case PPP_IPV6:
642 }
643 do_account++;
644 break;
645#endif
646#ifdef INET6
647 case PPP_IPV6CP:
648 if (sp->pp_phase == PHASE_NETWORK)
649 sppp_cp_input(&ipv6cp, sp, m);
650 m_freem (m);
651 return;
652
653 case PPP_IPV6:
658 if (sp->state[IDX_IPV6CP] == STATE_OPENED) {
659 schednetisr (NETISR_IPV6);
660 inq = &ip6intrq;
661 }
654 if (sp->state[IDX_IPV6CP] == STATE_OPENED)
655 isr = NETISR_IPV6;
662 do_account++;
663 break;
664#endif
665#ifdef IPX
666 case PPP_IPX:
667 /* IPX IPXCP not implemented yet */
656 do_account++;
657 break;
658#endif
659#ifdef IPX
660 case PPP_IPX:
661 /* IPX IPXCP not implemented yet */
668 if (sp->pp_phase == PHASE_NETWORK) {
669 schednetisr (NETISR_IPX);
670 inq = &ipxintrq;
671 }
662 if (sp->pp_phase == PHASE_NETWORK)
663 isr = NETISR_IPX;
672 do_account++;
673 break;
674#endif
675#ifdef NS
676 case PPP_XNS:
677 /* XNS IDPCP not implemented yet */
664 do_account++;
665 break;
666#endif
667#ifdef NS
668 case PPP_XNS:
669 /* XNS IDPCP not implemented yet */
678 if (sp->pp_phase == PHASE_NETWORK) {
679 schednetisr (NETISR_NS);
680 inq = &nsintrq;
681 }
670 if (sp->pp_phase == PHASE_NETWORK)
671 isr = NETISR_NS;
682 do_account++;
683 break;
684#endif
685 }
686 break;
687 case CISCO_MULTICAST:
688 case CISCO_UNICAST:
689 /* Don't check the control field here (RFC 1547). */

--- 11 unchanged lines hidden (view full) ---

701 ++ifp->if_noproto;
702 goto invalid;
703 case CISCO_KEEPALIVE:
704 sppp_cisco_input ((struct sppp*) ifp, m);
705 m_freem (m);
706 return;
707#ifdef INET
708 case ETHERTYPE_IP:
672 do_account++;
673 break;
674#endif
675 }
676 break;
677 case CISCO_MULTICAST:
678 case CISCO_UNICAST:
679 /* Don't check the control field here (RFC 1547). */

--- 11 unchanged lines hidden (view full) ---

691 ++ifp->if_noproto;
692 goto invalid;
693 case CISCO_KEEPALIVE:
694 sppp_cisco_input ((struct sppp*) ifp, m);
695 m_freem (m);
696 return;
697#ifdef INET
698 case ETHERTYPE_IP:
709 schednetisr (NETISR_IP);
710 inq = &ipintrq;
699 isr = NETISR_IP;
711 do_account++;
712 break;
713#endif
714#ifdef INET6
715 case ETHERTYPE_IPV6:
700 do_account++;
701 break;
702#endif
703#ifdef INET6
704 case ETHERTYPE_IPV6:
716 schednetisr (NETISR_IPV6);
717 inq = &ip6intrq;
705 isr = NETISR_IPV6;
718 do_account++;
719 break;
720#endif
721#ifdef IPX
722 case ETHERTYPE_IPX:
706 do_account++;
707 break;
708#endif
709#ifdef IPX
710 case ETHERTYPE_IPX:
723 schednetisr (NETISR_IPX);
724 inq = &ipxintrq;
711 isr = NETISR_IPX;
725 do_account++;
726 break;
727#endif
728#ifdef NS
729 case ETHERTYPE_NS:
712 do_account++;
713 break;
714#endif
715#ifdef NS
716 case ETHERTYPE_NS:
730 schednetisr (NETISR_NS);
731 inq = &nsintrq;
717 isr = NETISR_NS;
732 do_account++;
733 break;
734#endif
735 }
736 break;
737 default: /* Invalid PPP packet. */
738 invalid:
739 if (debug)
740 log(LOG_DEBUG,
741 SPP_FMT "invalid input packet "
742 "<addr=0x%x ctrl=0x%x proto=0x%x>\n",
743 SPP_ARGS(ifp),
744 h->address, h->control, ntohs(h->protocol));
745 goto drop;
746 }
747
718 do_account++;
719 break;
720#endif
721 }
722 break;
723 default: /* Invalid PPP packet. */
724 invalid:
725 if (debug)
726 log(LOG_DEBUG,
727 SPP_FMT "invalid input packet "
728 "<addr=0x%x ctrl=0x%x proto=0x%x>\n",
729 SPP_ARGS(ifp),
730 h->address, h->control, ntohs(h->protocol));
731 goto drop;
732 }
733
748 if (! (ifp->if_flags & IFF_UP) || ! inq)
734 if (! (ifp->if_flags & IFF_UP) || isr == -1)
749 goto drop;
750
751 /* Check queue. */
735 goto drop;
736
737 /* Check queue. */
752 if (! IF_HANDOFF(inq, m, NULL)) {
738 if (! netisr_queue(isr, m)) {
753 if (debug)
754 log(LOG_DEBUG, SPP_FMT "protocol queue overflow\n",
755 SPP_ARGS(ifp));
756 goto drop;
757 }
758 if (do_account)
759 /*
760 * Do only account for network packets, not for control

--- 4616 unchanged lines hidden ---
739 if (debug)
740 log(LOG_DEBUG, SPP_FMT "protocol queue overflow\n",
741 SPP_ARGS(ifp));
742 goto drop;
743 }
744 if (do_account)
745 /*
746 * Do only account for network packets, not for control

--- 4616 unchanged lines hidden ---