Deleted Added
sdiff udiff text old ( 111119 ) new ( 111888 )
full compact
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 $
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;
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;
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);
625
626 schednetisr (NETISR_IP);
627 inq = &ipintrq;
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 }
644 schednetisr (NETISR_IP);
645 inq = &ipintrq;
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:
658 if (sp->state[IDX_IPV6CP] == STATE_OPENED) {
659 schednetisr (NETISR_IPV6);
660 inq = &ip6intrq;
661 }
662 do_account++;
663 break;
664#endif
665#ifdef IPX
666 case PPP_IPX:
667 /* IPX IPXCP not implemented yet */
668 if (sp->pp_phase == PHASE_NETWORK) {
669 schednetisr (NETISR_IPX);
670 inq = &ipxintrq;
671 }
672 do_account++;
673 break;
674#endif
675#ifdef NS
676 case PPP_XNS:
677 /* XNS IDPCP not implemented yet */
678 if (sp->pp_phase == PHASE_NETWORK) {
679 schednetisr (NETISR_NS);
680 inq = &nsintrq;
681 }
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:
709 schednetisr (NETISR_IP);
710 inq = &ipintrq;
711 do_account++;
712 break;
713#endif
714#ifdef INET6
715 case ETHERTYPE_IPV6:
716 schednetisr (NETISR_IPV6);
717 inq = &ip6intrq;
718 do_account++;
719 break;
720#endif
721#ifdef IPX
722 case ETHERTYPE_IPX:
723 schednetisr (NETISR_IPX);
724 inq = &ipxintrq;
725 do_account++;
726 break;
727#endif
728#ifdef NS
729 case ETHERTYPE_NS:
730 schednetisr (NETISR_NS);
731 inq = &nsintrq;
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
748 if (! (ifp->if_flags & IFF_UP) || ! inq)
749 goto drop;
750
751 /* Check queue. */
752 if (! IF_HANDOFF(inq, m, NULL)) {
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 ---