]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-fr.c
bgp: Parse BGP extended message support capability
[tcpdump] / print-fr.c
index f1c69b420f0378a9eaf06a61a61024607bce1f6d..f0d7fbeb12b38d4019a4f0bfa618e6124ec74966 100644 (file)
@@ -147,14 +147,22 @@ q922_string(netdissect_options *ndo, const u_char *p, u_int length)
 
     static u_int dlci, addr_len;
     static uint32_t flags;
-    static char buffer[sizeof("DLCI xxxxxxxxxx")];
+    static char buffer[sizeof("parse_q922_header() returned XXXXXXXXXXX")];
+    int ret;
     memset(buffer, 0, sizeof(buffer));
 
-    if (parse_q922_header(ndo, p, &dlci, &addr_len, &flags, length) == 1){
+    ret = parse_q922_header(ndo, p, &dlci, &addr_len, &flags, length);
+    if (ret == 1) {
         snprintf(buffer, sizeof(buffer), "DLCI %u", dlci);
+        return buffer;
+    } else if (ret == 0) {
+        return "<Invalid DLCI>";
+    } else if (ret == -1) {
+        return "<Truncated>";
+    } else {
+        snprintf(buffer, sizeof(buffer), "parse_q922_header() returned %d", ret);
+        return buffer;
     }
-
-    return buffer;
 }
 
 
@@ -212,23 +220,22 @@ fr_hdr_print(netdissect_options *ndo, int length, u_int addr_len,
     }
 }
 
-u_int
+/* Frame Relay */
+void
 fr_if_print(netdissect_options *ndo,
             const struct pcap_pkthdr *h, const u_char *p)
 {
        u_int length = h->len;
        u_int caplen = h->caplen;
 
-       ndo->ndo_protocol = "fr_if";
-        ND_TCHECK_4(p); /* minimum frame header length */
+       ndo->ndo_protocol = "fr";
+       if (caplen < 4) {       /* minimum frame header length */
+               nd_print_trunc(ndo);
+               ndo->ndo_ll_hdr_len += caplen;
+               return;
+       }
 
-        if ((length = fr_print(ndo, p, length)) == 0)
-            return (0);
-        else
-            return length;
-trunc:
-        nd_print_trunc(ndo);
-        return caplen;
+       ndo->ndo_ll_hdr_len += fr_print(ndo, p, length);
 }
 
 u_int
@@ -370,23 +377,22 @@ trunc:
 
 }
 
-u_int
+/* Multi Link Frame Relay (FRF.16) */
+void
 mfr_if_print(netdissect_options *ndo,
              const struct pcap_pkthdr *h, const u_char *p)
 {
        u_int length = h->len;
        u_int caplen = h->caplen;
 
-       ndo->ndo_protocol = "mfr_if";
-        ND_TCHECK_2(p); /* minimum frame header length */
+       ndo->ndo_protocol = "mfr";
+       if (caplen < 2) {       /* minimum frame header length */
+               nd_print_trunc(ndo);
+               ndo->ndo_ll_hdr_len += caplen;
+               return;
+       }
 
-        if ((length = mfr_print(ndo, p, length)) == 0)
-            return (0);
-        else
-            return length;
-trunc:
-        nd_print_trunc(ndo);
-        return caplen;
+       ndo->ndo_ll_hdr_len += mfr_print(ndo, p, length);
 }
 
 
@@ -615,7 +621,6 @@ frf15_print(netdissect_options *ndo,
 
     if (length < 2)
         goto trunc;
-    ND_TCHECK_2(p);
 
     flags = GET_U_1(p)&MFR_BEC_MASK;
     sequence_num = (GET_U_1(p)&0x1e)<<7 | GET_U_1(p + 1);
@@ -631,7 +636,7 @@ frf15_print(netdissect_options *ndo,
  * dig as deep as we can - e.g. on the first (B) fragment
  * there is enough payload to print the IP header
  * on non (B) fragments it depends if the fragmentation
- * model is end-to-end or interface based wether we want to print
+ * model is end-to-end or interface based whether we want to print
  * another Q.922 header
  */
     return;
@@ -921,7 +926,6 @@ q933_print(netdissect_options *ndo,
        ND_PRINT("%s, codeset %u", is_ansi ? "ANSI" : "CCITT", codeset);
 
        if (call_ref_length != 0) {
-               ND_TCHECK_1(p);
                if (call_ref_length > 1 || GET_U_1(p) != 0) {
                        /*
                         * Not a dummy call reference.