]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-rsvp.c
EIGRP: Modernize packet parsing style.
[tcpdump] / print-rsvp.c
index 4254881dc45c6fc1ffebe627514b28d342b44239..29deb44dac3a442b54ab03aea9315e3d6e08cf9b 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "netdissect-stdinc.h"
 
+#define ND_LONGJMP_FROM_TCHECK
 #include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
@@ -305,6 +306,14 @@ static const struct tok rsvp_ctype_values[] = {
     { 0, NULL}
 };
 
+/*
+ * XXX - this assumes a 16-byte digest, which is true for HMAC-MD5, but
+ * isn't necessarily the case for other hash algorithms.
+ *
+ * Unless I've missed something, there's nothing in RFC 2747 to indicate
+ * the hash algorithm being used, so it's presumably something set up
+ * out-of-band, or negotiated by other RSVP objects.
+ */
 struct rsvp_obj_integrity_t {
     uint8_t flags;
     uint8_t res;
@@ -333,7 +342,7 @@ struct rsvp_obj_frr_t {
 #define RSVP_OBJ_XRO_MASK_SUBOBJ(x)   ((x)&0x7f)
 #define RSVP_OBJ_XRO_MASK_LOOSE(x)    ((x)&0x80)
 
-#define RSVP_OBJ_CAPABILITY_FLAGS_MASK  0x7
+#define RSVP_OBJ_CAPABILITY_FLAGS_MASK  0x7U
 
 #define        RSVP_OBJ_XRO_RES       0
 #define        RSVP_OBJ_XRO_IPV4      1
@@ -510,11 +519,11 @@ rsvp_intserv_print(netdissect_options *ndo,
        uint32_t i;
     } bw;
 
-    if (obj_tlen < 4)
-        return 0;
-    ND_TCHECK_1(tptr);
+    if (obj_tlen < 4) {
+        ND_PRINT(" (obj_tlen %u < 4)", obj_tlen);
+        goto invalid;
+    }
     parameter_id = GET_U_1(tptr);
-    ND_TCHECK_2(tptr + 2);
     parameter_length = GET_BE_U_2(tptr + 2)<<2; /* convert wordcount to bytecount */
 
     ND_PRINT("\n\t      Parameter ID: %s (%u), length: %u, Flags: [0x%02x]",
@@ -523,8 +532,10 @@ rsvp_intserv_print(netdissect_options *ndo,
            parameter_length,
            GET_U_1(tptr + 1));
 
-    if (obj_tlen < parameter_length+4)
-        return 0;
+    if (obj_tlen < parameter_length + 4) {
+        ND_PRINT(" (obj_tlen %u < %u)", obj_tlen, parameter_length + 4);
+        goto invalid;
+    }
     switch(parameter_id) { /* parameter_id */
 
     case 4:
@@ -536,7 +547,6 @@ rsvp_intserv_print(netdissect_options *ndo,
         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         */
         if (parameter_length == 4) {
-           ND_TCHECK_4(tptr + 4);
             ND_PRINT("\n\t\tIS hop count: %u", GET_BE_U_4(tptr + 4));
         }
         break;
@@ -550,7 +560,6 @@ rsvp_intserv_print(netdissect_options *ndo,
         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         */
         if (parameter_length == 4) {
-           ND_TCHECK_4(tptr + 4);
             bw.i = GET_BE_U_4(tptr + 4);
             ND_PRINT("\n\t\tPath b/w estimate: %.10g Mbps", bw.f / 125000);
         }
@@ -565,7 +574,6 @@ rsvp_intserv_print(netdissect_options *ndo,
         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         */
         if (parameter_length == 4) {
-           ND_TCHECK_4(tptr + 4);
             ND_PRINT("\n\t\tMinimum path latency: ");
             if (GET_BE_U_4(tptr + 4) == 0xffffffff)
                 ND_PRINT("don't care");
@@ -584,7 +592,6 @@ rsvp_intserv_print(netdissect_options *ndo,
         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         */
         if (parameter_length == 4) {
-           ND_TCHECK_4(tptr + 4);
             ND_PRINT("\n\t\tComposed MTU: %u bytes", GET_BE_U_4(tptr + 4));
         }
         break;
@@ -606,7 +613,6 @@ rsvp_intserv_print(netdissect_options *ndo,
         */
 
         if (parameter_length == 20) {
-           ND_TCHECK_LEN(tptr + 4, 20);
             bw.i = GET_BE_U_4(tptr + 4);
             ND_PRINT("\n\t\tToken Bucket Rate: %.10g Mbps", bw.f / 125000);
             bw.i = GET_BE_U_4(tptr + 8);
@@ -632,7 +638,6 @@ rsvp_intserv_print(netdissect_options *ndo,
         */
 
         if (parameter_length == 8) {
-           ND_TCHECK_8(tptr + 4);
             bw.i = GET_BE_U_4(tptr + 4);
             ND_PRINT("\n\t\tRate: %.10g Mbps", bw.f / 125000);
             ND_PRINT("\n\t\tSlack Term: %u", GET_BE_U_4(tptr + 8));
@@ -644,7 +649,6 @@ rsvp_intserv_print(netdissect_options *ndo,
     case 135:
     case 136:
         if (parameter_length == 4) {
-           ND_TCHECK_4(tptr + 4);
             ND_PRINT("\n\t\tValue: %u", GET_BE_U_4(tptr + 4));
         }
         break;
@@ -655,8 +659,8 @@ rsvp_intserv_print(netdissect_options *ndo,
     }
     return (parameter_length+4); /* header length 4 bytes */
 
-trunc:
-    nd_print_trunc(ndo);
+invalid:
+    nd_print_invalid(ndo);
     return 0;
 }
 
@@ -698,9 +702,6 @@ rsvp_obj_print(netdissect_options *ndo,
     u_int action, subchannel;
 
     while(tlen>=sizeof(struct rsvp_object_header)) {
-        /* did we capture enough for fully decoding the object header ? */
-        ND_TCHECK_LEN(tptr, sizeof(struct rsvp_object_header));
-
         rsvp_obj_header = (const struct rsvp_object_header *)tptr;
         rsvp_obj_len=GET_BE_U_2(rsvp_obj_header->length);
         rsvp_obj_ctype=GET_U_1(rsvp_obj_header->ctype);
@@ -1132,7 +1133,6 @@ rsvp_obj_print(netdissect_options *ndo,
                                ND_PRINT(" ERROR: length != 8");
                                goto invalid;
                        }
-                       ND_TCHECK_8(obj_tptr);
                         ND_PRINT(", Flags: [%s] (%#x), Class-Type: %s (%u), %u",
                                bittok2str(rsvp_obj_rro_label_flag_values,
                                    "none",
@@ -1910,9 +1910,6 @@ obj_tooshort:
 invalid:
     nd_print_invalid(ndo);
     return -1;
-trunc:
-    nd_print_trunc(ndo);
-    return -1;
 }
 
 void
@@ -2061,8 +2058,4 @@ rsvp_print(netdissect_options *ndo,
         print_unknown_data(ndo, tptr, "\n\t    ", tlen);
         break;
     }
-
-    return;
-trunc:
-    nd_print_trunc(ndo);
 }