]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ppp.c
The stuff in the "linux-include" directory is no longer needed, as we no
[tcpdump] / print-ppp.c
index 28d5bd38700fdec2a42b80eb60761f66509371f9..8ba6710bb7e55334d1ca3e95b41c059731e7b079 100644 (file)
@@ -31,7 +31,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.51 2000-10-04 22:37:29 itojun Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.57 2000-12-04 06:47:18 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)
@@ -444,6 +436,14 @@ handle_ctrl_proto(u_int proto, const u_char *p, int length)
                        case PPP_BACP:
                                pfunc = print_bacp_config_options;
                                break;
+                       default:
+                               /*
+                                * This should never happen, but we set
+                                * "pfunc" to squelch uninitialized
+                                * variable warnings from compilers.
+                                */
+                               pfunc = NULL;
+                               break;
                        }
                        if ((j = (*pfunc)(p, len)) == 0)
                                break;
@@ -492,7 +492,6 @@ static int
 print_lcp_config_options(const u_char *p, int length)
 {
        int len, opt;
-       int i;
 
        if (length < 2)
                return 0;
@@ -753,7 +752,6 @@ handle_pap(const u_char *p, int length)
        }
 
        code = *p;
-       if (length < 4)
        if ((code >= PAP_CODEMIN) && (code <= PAP_CODEMAX))
                printf("%s", papcode[code - 1]);
        else {
@@ -990,6 +988,7 @@ void
 ppp_print(register const u_char *p, u_int length)
 {
        u_int proto;
+       u_int full_length = length;
 
        /*
         * Here, we assume that p points to the Address and Control
@@ -1014,7 +1013,7 @@ ppp_print(register const u_char *p, u_int length)
                length -= 2;
        }
 
-       printf("%s: ", ppp_protoname(proto));
+       printf("%s %d: ", ppp_protoname(proto), full_length);
 
        handle_ppp(proto, p, length);
        return;
@@ -1030,8 +1029,6 @@ ppp_if_print(u_char *user, const struct pcap_pkthdr *h,
 {
        register u_int length = h->len;
        register u_int caplen = h->caplen;
-       const struct ip *ip;
-       u_int proto;
 
        ts_print(&h->ts);
 
@@ -1300,9 +1297,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];