]> The Tcpdump Group git mirrors - tcpdump/commitdiff
add ppp support for DLT_PPP_WITHDIRECTION; print direction (hidden under eflag)
authorhannes <hannes>
Wed, 18 Aug 2004 14:56:27 +0000 (14:56 +0000)
committerhannes <hannes>
Wed, 18 Aug 2004 14:56:27 +0000 (14:56 +0000)
ppp.h
print-ppp.c
tcpdump.c

diff --git a/ppp.h b/ppp.h
index 423480861b4167f581b681a12acd695dc1534b64..5c583f84044a0965470f3633ecf39e83c2818ba0 100644 (file)
--- a/ppp.h
+++ b/ppp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.14 2003-05-22 15:29:22 hannes Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.15 2004-08-18 14:56:28 hannes Exp $ (LBL) */
 /*
  * Point to Point Protocol (PPP) RFC1331
  *
@@ -20,6 +20,9 @@
 #define PPP_ADDRESS    0xff    /* The address byte value */
 #define PPP_CONTROL    0x03    /* The control byte value */
 
+#define PPP_WITHDIRECTION_IN  0x00 /* non-standard for DLT_PPP_WITHDIRECTION */
+#define PPP_WITHDIRECTION_OUT 0x01 /* non-standard for DLT_PPP_WITHDIRECTION */
+
 /* Protocol numbers */
 #define PPP_IP         0x0021  /* Raw IP */
 #define PPP_OSI                0x0023  /* OSI Network Layer */
index 486b25ae77f8b432fd1f91f56410d3f011ed7d53..ee903976c33abb7aafbd0a17a751f1804c323c90 100644 (file)
@@ -31,7 +31,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.100 2004-07-15 00:16:49 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.101 2004-08-18 14:56:28 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -1188,7 +1188,7 @@ handle_ppp(u_int proto, const u_char *p, int length)
 u_int
 ppp_print(register const u_char *p, u_int length)
 {
-       u_int proto;
+       u_int proto,ppp_header;
         u_int olen = length; /* _o_riginal length */
        u_int hdr_len = 0;
 
@@ -1199,11 +1199,30 @@ ppp_print(register const u_char *p, u_int length)
        if (length < 2)
                goto trunc;
        TCHECK2(*p, 2);
-       if (*p == PPP_ADDRESS && *(p + 1) == PPP_CONTROL) {
-               p += 2;                 /* ACFC not used */
-               length -= 2;
-               hdr_len += 2;
-       }
+        ppp_header = EXTRACT_16BITS(p);
+
+        switch(ppp_header) {
+        case (PPP_WITHDIRECTION_IN  << 8 | PPP_CONTROL):
+            if (eflag) printf("In  ");
+            p += 2;
+            length -= 2;
+            hdr_len += 2;
+            break;
+        case (PPP_WITHDIRECTION_OUT << 8 | PPP_CONTROL):
+            if (eflag) printf("Out ");
+            p += 2;
+            length -= 2;
+            hdr_len += 2;
+            break;
+        case (PPP_ADDRESS << 8 | PPP_CONTROL):
+            p += 2;                    /* ACFC not used */
+            length -= 2;
+            hdr_len += 2;
+            break;
+
+        default:
+            break;
+        }
 
        if (length < 2)
                goto trunc;
index 25d813010be11eeda033e9239b61c96d61c7ac7c..277e8ca68a0325df08ae445131a69ce760bac591 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -30,7 +30,7 @@ static const char copyright[] _U_ =
     "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
 The Regents of the University of California.  All rights reserved.\n";
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.246 2004-07-21 22:06:47 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.247 2004-08-18 14:56:27 hannes Exp $ (LBL)";
 #endif
 
 /*
@@ -154,6 +154,9 @@ static struct printer printers[] = {
        { sl_bsdos_if_print,    DLT_SLIP_BSDOS },
 #endif
        { ppp_if_print,         DLT_PPP },
+#ifdef DLT_PPP_WITHDIRECTION
+       { ppp_if_print,         DLT_PPP_WITHDIRECTION },
+#endif
 #ifdef DLT_PPP_BSDOS
        { ppp_bsdos_if_print,   DLT_PPP_BSDOS },
 #endif