]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-rsvp.c
add boundary, infinite loop checks
[tcpdump] / print-rsvp.c
index b0c5e45f2a3b37b300362695da171566051c2cf6..fe7d1bdaa74d8753144ee4206c92a52b92c9b3af 100644 (file)
@@ -15,7 +15,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.28 2004-07-16 00:13:51 hannes Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.35 2005-04-25 19:28:30 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -140,6 +140,7 @@ static const struct tok rsvp_header_flag_values[] = {
 #define        RSVP_OBJ_LABEL_SET          36  /* rfc3473 */
 #define        RSVP_OBJ_PROTECTION         37  /* rfc3473 */
 #define        RSVP_OBJ_DETOUR             63  /* draft-ietf-mpls-rsvp-lsp-fastreroute-01 */
+#define        RSVP_OBJ_CLASSTYPE          125 /* draft-ietf-tewg-diff-te-proto-07 */
 #define        RSVP_OBJ_SUGGESTED_LABEL    129 /* rfc3473 */
 #define        RSVP_OBJ_ACCEPT_LABEL_SET   130 /* rfc3473 */
 #define        RSVP_OBJ_RESTART_CAPABILITY 131 /* rfc3473 */
@@ -179,6 +180,7 @@ static const struct tok rsvp_obj_values[] = {
     { RSVP_OBJ_LABEL_SET,          "Label Set" },
     { RSVP_OBJ_ACCEPT_LABEL_SET,   "Acceptable Label Set" },
     { RSVP_OBJ_DETOUR,             "Detour" },
+    { RSVP_OBJ_CLASSTYPE,          "Class Type" },
     { RSVP_OBJ_SUGGESTED_LABEL,    "Suggested Label" },
     { RSVP_OBJ_PROPERTIES,         "Properties" },
     { RSVP_OBJ_FASTREROUTE,        "Fast Re-Route" },
@@ -264,6 +266,7 @@ static const struct tok rsvp_ctype_values[] = {
     { 256*RSVP_OBJ_FASTREROUTE+RSVP_CTYPE_TUNNEL_IPV4,       "Tunnel IPv4" },
     { 256*RSVP_OBJ_DETOUR+RSVP_CTYPE_TUNNEL_IPV4,            "Tunnel IPv4" },
     { 256*RSVP_OBJ_PROPERTIES+RSVP_CTYPE_1,                  "1" },
+    { 256*RSVP_OBJ_CLASSTYPE+RSVP_CTYPE_1,                   "1" },
     { 0, NULL}
 };
 
@@ -345,10 +348,12 @@ static struct tok rsvp_obj_prop_tlv_values[] = {
 
 #define RSVP_OBJ_ERROR_SPEC_CODE_ROUTING 24
 #define RSVP_OBJ_ERROR_SPEC_CODE_NOTIFY  25
+#define RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE 125
 
 static struct tok rsvp_obj_error_code_values[] = {
     { RSVP_OBJ_ERROR_SPEC_CODE_ROUTING, "Routing Problem" },
     { RSVP_OBJ_ERROR_SPEC_CODE_NOTIFY,  "Notify Error" },
+    { RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE, "Diffserv TE Error" },
     { 0, NULL}
 };
 
@@ -366,6 +371,17 @@ static struct tok rsvp_obj_error_code_routing_values[] = {
     { 0, NULL}
 };
 
+static struct tok rsvp_obj_error_code_diffserv_te_values[] = {
+    { 1,                      "Unexpected CLASSTYPE object" },
+    { 2,                      "Unsupported Class-Type" },
+    { 3,                      "Invalid Class-Type value" },
+    { 4,                      "Class-Type and setup priority do not form a configured TE-Class" },
+    { 5,                      "Class-Type and holding priority do not form a configured TE-Class" },
+    { 6,                      "Inconsistency between signaled PSC and signaled Class-Type" },
+    { 7,                      "Inconsistency between signaled PHBs and signaled Class-Type" },
+    { 0, NULL}
+};
+
 #define FALSE 0
 #define TRUE  1
 
@@ -520,7 +536,7 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
 }
 
 static int
-rsvp_obj_print (const u_char *tptr, const u_char *ident, u_int tlen) {
+rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
 
     const struct rsvp_object_header *rsvp_obj_header;
     const u_char *obj_tptr;
@@ -542,7 +558,8 @@ rsvp_obj_print (const u_char *tptr, const u_char *ident, u_int tlen) {
         rsvp_obj_ctype=rsvp_obj_header->ctype;
 
         if(rsvp_obj_len % 4 || rsvp_obj_len < sizeof(struct rsvp_object_header)) {
-            printf("ERROR: object header too short %u < %u", rsvp_obj_len, sizeof(const struct rsvp_object_header));
+            printf("%sERROR: object header too short %u < %lu", ident, rsvp_obj_len,
+                   (unsigned long)sizeof(const struct rsvp_object_header));
             return -1;
         }
 
@@ -866,11 +883,18 @@ rsvp_obj_print (const u_char *tptr, const u_char *ident, u_int tlen) {
             switch(rsvp_obj_ctype) {
             case RSVP_CTYPE_IPV4:
                 while(obj_tlen >= 4 ) {
-                    printf("%s  Subobject Type: %s",
+                    printf("%s  Subobject Type: %s, length %u",
                            ident,
                            tok2str(rsvp_obj_xro_values,
                                    "Unknown %u",
-                                   RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)));                
+                                   RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)),
+                           *(obj_tptr+1));                
+
+                    if (*(obj_tptr+1) == 0) { /* prevent infinite loops */
+                        printf("%s  ERROR: zero length ERO subtype",ident);
+                        break;
+                    }
+
                     switch(RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)) {
                     case RSVP_OBJ_XRO_IPV4:
                         printf(", %s, %s/%u, Flags: [%s]",
@@ -915,8 +939,8 @@ rsvp_obj_print (const u_char *tptr, const u_char *ident, u_int tlen) {
                     return-1;
                 printf("%s  Restart  Time: %ums, Recovery Time: %ums",
                        ident,
-                       EXTRACT_16BITS(obj_tptr),
-                       EXTRACT_16BITS(obj_tptr+4));
+                       EXTRACT_32BITS(obj_tptr),
+                       EXTRACT_32BITS(obj_tptr+4));
                 obj_tlen-=8;
                 obj_tptr+=8;
                 break;
@@ -1143,6 +1167,20 @@ rsvp_obj_print (const u_char *tptr, const u_char *ident, u_int tlen) {
             }
             break;
 
+        case RSVP_OBJ_CLASSTYPE:
+            switch(rsvp_obj_ctype) {
+            case RSVP_CTYPE_1:
+                printf("%s  Class Type: %u",
+                       ident,
+                       EXTRACT_32BITS(obj_tptr)&0x7);              
+                obj_tlen-=4;
+                obj_tptr+=4;
+                break;
+            default:
+                hexdump=TRUE;
+            }
+            break;
+
         case RSVP_OBJ_ERROR_SPEC:
             switch(rsvp_obj_ctype) {
             case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */
@@ -1151,7 +1189,7 @@ rsvp_obj_print (const u_char *tptr, const u_char *ident, u_int tlen) {
                     return-1;
                 error_code=*(obj_tptr+5);
                 error_value=EXTRACT_16BITS(obj_tptr+6);
-                printf("%s  Error Node Adress: %s, Flags: [0x%02x]%s  Error Code: %s (%u)",
+                printf("%s  Error Node Address: %s, Flags: [0x%02x]%s  Error Code: %s (%u)",
                        ident,
                        ipaddr_string(obj_tptr),
                        *(obj_tptr+4),
@@ -1164,6 +1202,11 @@ rsvp_obj_print (const u_char *tptr, const u_char *ident, u_int tlen) {
                            tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value),
                            error_value);
                     break;
+                case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE:
+                    printf(", Error Value: %s (%u)",
+                           tok2str(rsvp_obj_error_code_diffserv_te_values,"unknown",error_value),
+                           error_value);
+                    break;
                 default:
                     printf(", Unknown Error Value (%u)", error_value);
                     break;
@@ -1178,7 +1221,7 @@ rsvp_obj_print (const u_char *tptr, const u_char *ident, u_int tlen) {
                     return-1;
                 error_code=*(obj_tptr+17);
                 error_value=EXTRACT_16BITS(obj_tptr+18);
-                printf("%s  Error Node Adress: %s, Flags: [0x%02x]%s  Error Code: %s (%u)",
+                printf("%s  Error Node Address: %s, Flags: [0x%02x]%s  Error Code: %s (%u)",
                        ident,
                        ip6addr_string(obj_tptr),
                        *(obj_tptr+16),
@@ -1276,12 +1319,12 @@ rsvp_obj_print (const u_char *tptr, const u_char *ident, u_int tlen) {
         case RSVP_OBJ_PROTECTION:
         default:
             if (vflag <= 1)
-                print_unknown_data(obj_tptr,"\n\t    ",obj_tlen); /* FIXME identation */
+                print_unknown_data(obj_tptr,"\n\t    ",obj_tlen); /* FIXME indentation */
             break;
         }
-        /* do we want to see an additionally hexdump ? */
+        /* do we also want to see a hex dump ? */
         if (vflag > 1 || hexdump==TRUE)
-            print_unknown_data(tptr+sizeof(sizeof(struct rsvp_object_header)),"\n\t    ", /* FIXME identation */
+            print_unknown_data(tptr+sizeof(sizeof(struct rsvp_object_header)),"\n\t    ", /* FIXME indentation */
                                rsvp_obj_len-sizeof(struct rsvp_object_header));
 
         tptr+=rsvp_obj_len;
@@ -1338,7 +1381,8 @@ rsvp_print(register const u_char *pptr, register u_int len) {
            EXTRACT_16BITS(rsvp_com_header->checksum));
 
     if (tlen < sizeof(const struct rsvp_common_header)) {
-        printf("ERROR: common header too short %u < %u", tlen, sizeof(const struct rsvp_common_header));
+        printf("ERROR: common header too short %u < %lu", tlen,
+               (unsigned long)sizeof(const struct rsvp_common_header));
         return;
     }
 
@@ -1373,7 +1417,8 @@ rsvp_print(register const u_char *pptr, register u_int len) {
                    EXTRACT_16BITS(rsvp_com_header->checksum));
             
             if (subtlen < sizeof(const struct rsvp_common_header)) {
-                printf("ERROR: common header too short %u < %u", subtlen, sizeof(const struct rsvp_common_header));
+                printf("ERROR: common header too short %u < %lu", subtlen,
+                       (unsigned long)sizeof(const struct rsvp_common_header));
                 return;
             }