]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ppp.c
Get rid of unneeded includes of <netinet/in_systm.h> and <netinet/ip.h>.
[tcpdump] / print-ppp.c
index c695699c14a30a5fd5ccf7e9a7e3e59e2025ab33..597898534aad8d86d520e1f9edfbcddaf27f8542 100644 (file)
@@ -31,7 +31,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.53 2000-10-06 04:25:59 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.66 2002-05-29 10:32:02 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -40,12 +40,11 @@ static const char rcsid[] =
 
 #include <sys/param.h>
 #include <sys/time.h>
-#include <sys/socket.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
 
-struct mbuf;
-struct rtentry;
+#ifdef __bsdi__
+#include <net/slcompress.h>
+#include <net/if_ppp.h>
+#endif
 
 #include <netinet/in.h>
 
@@ -53,10 +52,6 @@ struct rtentry;
 #include <netdb.h>
 #include <pcap.h>
 #include <stdio.h>
-#ifdef __bsdi__
-#include <net/slcompress.h>
-#include <net/if_ppp.h>
-#endif
 
 #include "interface.h"
 #include "extract.h"
@@ -65,9 +60,6 @@ struct rtentry;
 #include "chdlc.h"
 #include "ethertype.h"
 
-/* XXX This goes somewhere else. */
-#define PPP_HDRLEN 4
-
 /*
  * The following constatns are defined by IANA. Please refer to
  *    http://www.isi.edu/in-notes/iana/assignments/ppp-numbers
@@ -337,16 +329,16 @@ static const char *papcode[] = {
 #define BAP_CSIND      7
 #define BAP_CSRES      8
 
-static const char *ppp_protoname __P((u_int proto));
-static void handle_ctrl_proto __P((u_int proto,const u_char *p, int length));
-static void handle_chap __P((const u_char *p, int length));
-static void handle_pap __P((const u_char *p, int length));
-static void handle_bap __P((const u_char *p, int length));
-static int print_lcp_config_options __P((const u_char *p, int));
-static int print_ipcp_config_options __P((const u_char *p, int));
-static int print_ccp_config_options __P((const u_char *p, int));
-static int print_bacp_config_options __P((const u_char *p, int));
-static void handle_ppp __P((u_int proto, const u_char *p, int length));
+static const char *ppp_protoname (u_int proto);
+static void handle_ctrl_proto (u_int proto,const u_char *p, int length);
+static void handle_chap (const u_char *p, int length);
+static void handle_pap (const u_char *p, int length);
+static void handle_bap (const u_char *p, int length);
+static int print_lcp_config_options (const u_char *p, int);
+static int print_ipcp_config_options (const u_char *p, int);
+static int print_ccp_config_options (const u_char *p, int);
+static int print_bacp_config_options (const u_char *p, int);
+static void handle_ppp (u_int proto, const u_char *p, int length);
 
 static const char *
 ppp_protoname(u_int proto)
@@ -355,18 +347,19 @@ ppp_protoname(u_int proto)
 
        switch (proto) {
        case PPP_IP:    return "IP";
+       case PPP_IPV6:  return "IPv6";
 #ifdef PPP_XNS
        case PPP_XNS:   return "XNS";
 #endif
        case PPP_IPX:   return "IPX";
+       case PPP_OSI:   return "OSI";
        case PPP_VJC:   return "VJC";
        case PPP_VJNC:  return "VJNC";
-#ifdef PPP_COMP
        case PPP_COMP:  return "COMP";
-#endif
        case PPP_IPCP:  return "IPCP";
-       case PPP_IPV6CP: return "IPV6CP";
+       case PPP_IPV6CP: return "IPv6CP";
        case PPP_IPXCP: return "IPXCP";
+       case PPP_OSICP: return "OSICP";
        case PPP_CCP:   return "CCP";
        case PPP_LCP:   return "LCP";
        case PPP_PAP:   return "PAP";
@@ -988,14 +981,21 @@ handle_ppp(u_int proto, const u_char *p, int length)
        case PPP_IPX:
                ipx_print(p, length);
                break;
+       case PPP_OSI:
+               isoclns_print(p, length, length, NULL, NULL);
+               break;
+       default:
+               break;
        }
 }
 
 /* Standard PPP printer */
-void
+u_int
 ppp_print(register const u_char *p, u_int length)
 {
        u_int proto;
+       u_int full_length = length;
+       u_int hdr_len = 0;
 
        /*
         * Here, we assume that p points to the Address and Control
@@ -1006,6 +1006,7 @@ ppp_print(register const u_char *p, u_int length)
        if (*p == PPP_ADDRESS && *(p + 1) == PPP_CONTROL) {
                p += 2;                 /* ACFC not used */
                length -= 2;
+               hdr_len += 2;
        }
 
        if (length < 2)
@@ -1014,18 +1015,21 @@ ppp_print(register const u_char *p, u_int length)
                proto = *p;             /* PFC is used */
                p++;
                length--;
+               hdr_len++;
        } else {
                proto = EXTRACT_16BITS(p);
                p += 2;
                length -= 2;
+               hdr_len += 2;
        }
 
-       printf("%s: ", ppp_protoname(proto));
+       printf("%s %d: ", ppp_protoname(proto), full_length);
 
        handle_ppp(proto, p, length);
-       return;
+       return (hdr_len);
 trunc:
        printf("[|ppp]");
+       return (0);
 }
 
 
@@ -1037,6 +1041,7 @@ ppp_if_print(u_char *user, const struct pcap_pkthdr *h,
        register u_int length = h->len;
        register u_int caplen = h->caplen;
 
+       ++infodelay;
        ts_print(&h->ts);
 
        if (caplen < PPP_HDRLEN) {
@@ -1099,6 +1104,9 @@ ppp_if_print(u_char *user, const struct pcap_pkthdr *h,
                default_print(p, caplen);
 out:
        putchar('\n');
+       --infodelay;
+       if (infoprint)
+               info(0);
 }
 
 /*
@@ -1118,6 +1126,9 @@ ppp_hdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
        register u_int caplen = h->caplen;
        u_int proto;
 
+       ++infodelay;
+       ts_print(&h->ts);
+
        if (caplen < 2) {
                printf("[|ppp]");
                goto out;
@@ -1139,7 +1150,6 @@ ppp_hdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
                        goto out;
                }
 
-               ts_print(&h->ts);
                if (eflag)
                        printf("%02x %02x %d ", p[0], p[1], length);
                p += 2;
@@ -1155,14 +1165,10 @@ ppp_hdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
 
        case CHDLC_UNICAST:
        case CHDLC_BCAST:
-               /*
-                * Have the Cisco HDLC print routine do all the work.
-                */
-               chdlc_if_print(user, h, p);
-               return;
+               chdlc_print(p, length, caplen);
+               goto out;
 
        default:
-               ts_print(&h->ts);
                if (eflag)
                        printf("%02x %02x %d ", p[0], p[1], length);
                p += 2;
@@ -1181,6 +1187,9 @@ ppp_hdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
                default_print(p, caplen);
 out:
        putchar('\n');
+       --infodelay;
+       if (infoprint)
+               info(0);
 }
 
 
@@ -1235,6 +1244,7 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
        const u_char *q;
        int i;
 
+       ++infodelay;
        ts_print(&h->ts);
 
        if (caplen < PPP_BSDI_HDRLEN) {
@@ -1304,9 +1314,9 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
                                printf("] ");
                        }
                }
-               if (eflag)
-                       printf("%d ", length);
        }
+       if (eflag)
+               printf("%d ", length);
        if (p[SLC_CHL]) {
                q = p + SLC_BPFHDRLEN + p[SLC_LLHL];
 
@@ -1376,5 +1386,8 @@ printx:
                default_print((const u_char *)p, caplen - hdrlength);
 out:
        putchar('\n');
+       --infodelay;
+       if (infoprint)
+               info(0);
 #endif /* __bsdi__ */
 }