]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ppp.c
gre: add support for MikroTik Ethernet-over-IP hack.
[tcpdump] / print-ppp.c
index baeb4f00494aa4e6ddb8cee35f924b7a6f1b6363..38505355182ca15067ea3e0b6ac76a8345cc6ece 100644 (file)
@@ -1131,7 +1131,7 @@ print_ipcp_config_options(netdissect_options *ndo,
                        print_unknown_data(ndo, p + 2, "\n\t    ", len - 2);
                break;
        }
-       if (ndo->ndo_vflag > 1)
+       if (ndo->ndo_vflag > 1 && ND_TTEST_LEN(p + 2, len - 2))
                print_unknown_data(ndo, p + 2, "\n\t    ", len - 2); /* exclude TLV header */
        return len;
 
@@ -1363,7 +1363,7 @@ ppp_hdlc(netdissect_options *ndo,
        u_char *b, *t, c;
        const u_char *s;
        u_int i, proto;
-       const void *se;
+       const void *sb, *se;
 
        if (caplen == 0)
                return;
@@ -1395,8 +1395,11 @@ ppp_hdlc(netdissect_options *ndo,
 
        /*
         * Change the end pointer, so bounds checks work.
+        * Change the pointer to packet data to help debugging.
         */
+       sb = ndo->ndo_packetp;
        se = ndo->ndo_snapend;
+       ndo->ndo_packetp = b;
        ndo->ndo_snapend = t;
        length = ND_BYTES_AVAILABLE_AFTER(b);
 
@@ -1425,18 +1428,26 @@ ppp_hdlc(netdissect_options *ndo,
             if (length < 4)
                 goto trunc;
             proto = GET_BE_U_2(b + 2); /* load the PPP proto-id */
-            handle_ppp(ndo, proto, b + 4, length - 4);
+            if ((proto & 0xff00) == 0x7e00)
+                ND_PRINT("(protocol 0x%04x invalid)", proto);
+            else
+                handle_ppp(ndo, proto, b + 4, length - 4);
             break;
         default: /* last guess - proto must be a PPP proto-id */
-            handle_ppp(ndo, proto, b + 2, length - 2);
+            if ((proto & 0xff00) == 0x7e00)
+                ND_PRINT("(protocol 0x%04x invalid)", proto);
+            else
+                handle_ppp(ndo, proto, b + 2, length - 2);
             break;
         }
 
 cleanup:
+       ndo->ndo_packetp = sb;
        ndo->ndo_snapend = se;
         return;
 
 trunc:
+       ndo->ndo_packetp = sb;
        ndo->ndo_snapend = se;
        nd_print_trunc(ndo);
 }
@@ -1559,11 +1570,18 @@ ppp_print(netdissect_options *ndo,
                hdr_len += 2;
        }
 
-       if (ndo->ndo_eflag)
-               ND_PRINT("%s (0x%04x), length %u: ",
-                         tok2str(ppptype2str, "unknown", proto),
+       if (ndo->ndo_eflag) {
+               const char *typestr;
+               typestr = tok2str(ppptype2str, "unknown", proto);
+               ND_PRINT("%s (0x%04x), length %u",
+                         typestr,
                          proto,
                          olen);
+               if (*typestr == 'u')    /* "unknown" */
+                       return hdr_len;
+
+               ND_PRINT(": ");
+       }
 
        handle_ppp(ndo, proto, p, length);
        return (hdr_len);