]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-rsvp.c
More UNALIGNED_MEM{CPY,CMP} on IP addresses.
[tcpdump] / print-rsvp.c
index 346ff384caf858d3cbdf941992d4f05f5064e089..8d2f02643a0526b9cf74e223df2d4b3dd341c7fb 100644 (file)
  * Original code by Hannes Gredler ([email protected])
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.50 2008-08-16 11:36:20 hannes Exp $";
-#endif
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -59,10 +54,10 @@ struct rsvp_common_header {
     u_int8_t length[2];
 };
 
-/* 
+/*
  * RFC2205 object header
  *
- * 
+ *
  *               0             1              2             3
  *        +-------------+-------------+-------------+-------------+
  *        |       Length (bytes)      |  Class-Num  |   C-Type    |
@@ -80,7 +75,7 @@ struct rsvp_object_header {
 };
 
 #define RSVP_VERSION            1
-#define        RSVP_EXTRACT_VERSION(x) (((x)&0xf0)>>4) 
+#define        RSVP_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
 #define        RSVP_EXTRACT_FLAGS(x)   ((x)&0x0f)
 
 #define        RSVP_MSGTYPE_PATH       1
@@ -121,7 +116,7 @@ static const struct tok rsvp_header_flag_values[] = {
 #define        RSVP_OBJ_RSVP_HOP           3   /* rfc2205, rfc3473 */
 #define        RSVP_OBJ_INTEGRITY          4   /* rfc2747 */
 #define        RSVP_OBJ_TIME_VALUES        5   /* rfc2205 */
-#define        RSVP_OBJ_ERROR_SPEC         6 
+#define        RSVP_OBJ_ERROR_SPEC         6
 #define        RSVP_OBJ_SCOPE              7
 #define        RSVP_OBJ_STYLE              8   /* rfc2205 */
 #define        RSVP_OBJ_FLOWSPEC           9   /* rfc2215 */
@@ -330,6 +325,7 @@ struct rsvp_obj_frr_t {
 #define        RSVP_OBJ_XRO_RES       0
 #define        RSVP_OBJ_XRO_IPV4      1
 #define        RSVP_OBJ_XRO_IPV6      2
+#define        RSVP_OBJ_XRO_LABEL     3
 #define        RSVP_OBJ_XRO_ASN       32
 #define        RSVP_OBJ_XRO_MPLS      64
 
@@ -337,6 +333,7 @@ static const struct tok rsvp_obj_xro_values[] = {
     { RSVP_OBJ_XRO_RES,              "Reserved" },
     { RSVP_OBJ_XRO_IPV4,      "IPv4 prefix" },
     { RSVP_OBJ_XRO_IPV6,      "IPv6 prefix" },
+    { RSVP_OBJ_XRO_LABEL,     "Label" },
     { RSVP_OBJ_XRO_ASN,       "Autonomous system number" },
     { RSVP_OBJ_XRO_MPLS,      "MPLS label switched path termination" },
     { 0, NULL}
@@ -351,6 +348,12 @@ static const struct tok rsvp_obj_rro_flag_values[] = {
     { 0, NULL}
 };
 
+/* RFC3209 */
+static const struct tok rsvp_obj_rro_label_flag_values[] = {
+    { 0x01,                   "Global" },
+    { 0, NULL}
+};
+
 static const struct tok rsvp_resstyle_values[] = {
     { 17,                    "Wildcard Filter" },
     { 10,                     "Fixed Filter" },
@@ -382,16 +385,16 @@ static const struct tok rsvp_intserv_parameter_id_values[] = {
     { 0, NULL}
 };
 
-static struct tok rsvp_session_attribute_flag_values[] = {
-    { 0x01,                  "Local Protection desired" },
-    { 0x02,                   "Label Recording desired" },
-    { 0x04,                   "SE Style desired" },
-    { 0x08,                   "Bandwidth protection desired" }, /* draft-ietf-mpls-rsvp-lsp-fastreroute-02.txt */
-    { 0x10,                   "Node protection desired" },      /* draft-ietf-mpls-rsvp-lsp-fastreroute-02.txt */
+static const struct tok rsvp_session_attribute_flag_values[] = {
+    { 0x01,                  "Local Protection" },
+    { 0x02,                   "Label Recording" },
+    { 0x04,                   "SE Style" },
+    { 0x08,                   "Bandwidth protection" }, /* RFC4090 */
+    { 0x10,                   "Node protection" },      /* RFC4090 */
     { 0, NULL}
 };
 
-static struct tok rsvp_obj_prop_tlv_values[] = {
+static const struct tok rsvp_obj_prop_tlv_values[] = {
     { 0x01,                   "Cos" },
     { 0x02,                   "Metric 1" },
     { 0x04,                   "Metric 2" },
@@ -405,7 +408,7 @@ static struct tok rsvp_obj_prop_tlv_values[] = {
 #define RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE 28
 #define RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD 125
 
-static struct tok rsvp_obj_error_code_values[] = {
+static const 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" },
@@ -413,7 +416,7 @@ static struct tok rsvp_obj_error_code_values[] = {
     { 0, NULL}
 };
 
-static struct tok rsvp_obj_error_code_routing_values[] = {
+static const struct tok rsvp_obj_error_code_routing_values[] = {
     { 1,                      "Bad EXPLICIT_ROUTE object" },
     { 2,                      "Bad strict node" },
     { 3,                      "Bad loose node" },
@@ -427,14 +430,14 @@ static struct tok rsvp_obj_error_code_routing_values[] = {
     { 0, NULL}
 };
 
-static struct tok rsvp_obj_error_code_diffserv_te_values[] = {
+static const struct tok rsvp_obj_error_code_diffserv_te_values[] = {
     { 1,                      "Unexpected CT object" },
     { 2,                      "Unsupported CT" },
     { 3,                      "Invalid CT value" },
     { 4,                      "CT/setup priority do not form a configured TE-Class" },
     { 5,                      "CT/holding priority do not form a configured TE-Class" },
     { 6,                      "CT/setup priority and CT/holding priority do not form a configured TE-Class" },
-    { 7,                      "Inconsistency between signaled PSC and signaled CT" }, 
+    { 7,                      "Inconsistency between signaled PSC and signaled CT" },
     { 8,                      "Inconsistency between signaled PHBs and signaled CT" },
    { 0, NULL}
 };
@@ -480,7 +483,7 @@ static const struct tok rsvp_obj_generalized_uni_values[] = {
 
 static int rsvp_intserv_print(const u_char *, u_short);
 
-/* 
+/*
  * this is a dissector for all the intserv defined
  * specs as defined per rfc2215
  * it is called from various rsvp objects;
@@ -566,7 +569,7 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
             printf("\n\t\tComposed MTU: %u bytes", EXTRACT_32BITS(tptr+4));
         break;
     case 127:
-       /* 
+       /*
         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         * |   127 (e)     |    0 (f)      |             5 (g)             |
         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -595,7 +598,7 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
         break;
 
     case 130:
-       /* 
+       /*
         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         * |     130 (h)   |    0 (i)      |            2 (j)              |
         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -622,13 +625,21 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
 
     default:
         if (vflag <= 1)
-            print_unknown_data(tptr+4,"\n\t\t",parameter_length);
+            print_unknown_data(gndo,tptr+4,"\n\t\t",parameter_length);
     }
     return (parameter_length+4); /* header length 4 bytes */
 }
 
 static int
-rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
+rsvp_obj_print (const u_char *pptr
+#ifndef HAVE_LIBCRYPTO
+_U_
+#endif
+, u_int plen
+#ifndef HAVE_LIBCRYPTO
+_U_
+#endif
+, const u_char *tptr,
                 const char *ident, u_int tlen) {
 
     const struct rsvp_object_header *rsvp_obj_header;
@@ -685,7 +696,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                        ((rsvp_obj_header->class_num)<<8)+rsvp_obj_ctype),
                rsvp_obj_ctype,
                rsvp_obj_len);
-    
+
         if(tlen < rsvp_obj_len) {
             printf("%sERROR: object goes past end of objects TLV", ident);
             return -1;
@@ -714,7 +725,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                        *(obj_tptr+5),
                        EXTRACT_16BITS(obj_tptr+6));
                 obj_tlen-=8;
-                obj_tptr+=8;                
+                obj_tptr+=8;
                 break;
 #ifdef INET6
             case RSVP_CTYPE_IPV6:
@@ -729,7 +740,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                        *(obj_tptr+sizeof(struct in6_addr)+1),
                        EXTRACT_16BITS(obj_tptr+sizeof(struct in6_addr)+2));
                 obj_tlen-=20;
-                obj_tptr+=20;                
+                obj_tptr+=20;
                 break;
 
             case RSVP_CTYPE_TUNNEL_IPV6:
@@ -741,7 +752,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                        EXTRACT_16BITS(obj_tptr+18),
                        ip6addr_string(obj_tptr+20));
                 obj_tlen-=36;
-                obj_tptr+=36;                
+                obj_tptr+=36;
                 break;
 
             case RSVP_CTYPE_14: /* IPv6 p2mp LSP Tunnel */
@@ -753,7 +764,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                        EXTRACT_16BITS(obj_tptr+6),
                        ip6addr_string(obj_tptr+8));
                 obj_tlen-=26;
-                obj_tptr+=26;                
+                obj_tptr+=26;
                 break;
 #endif
             case RSVP_CTYPE_13: /* IPv4 p2mp LSP Tunnel */
@@ -765,7 +776,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                        EXTRACT_16BITS(obj_tptr+6),
                        ipaddr_string(obj_tptr+8));
                 obj_tlen-=12;
-                obj_tptr+=12;                
+                obj_tptr+=12;
                 break;
             case RSVP_CTYPE_TUNNEL_IPV4:
             case RSVP_CTYPE_UNI_IPV4:
@@ -777,7 +788,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                        EXTRACT_16BITS(obj_tptr+6),
                        ipaddr_string(obj_tptr+8));
                 obj_tlen-=12;
-                obj_tptr+=12;                
+                obj_tptr+=12;
                 break;
             default:
                 hexdump=TRUE;
@@ -793,7 +804,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                        ident,
                        ipaddr_string(obj_tptr));
                 obj_tlen-=sizeof(struct in_addr);
-                obj_tptr+=sizeof(struct in_addr);                
+                obj_tptr+=sizeof(struct in_addr);
                 break;
 #ifdef INET6
             case RSVP_CTYPE_IPV6:
@@ -803,7 +814,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                        ident,
                        ip6addr_string(obj_tptr));
                 obj_tlen-=sizeof(struct in6_addr);
-                obj_tptr+=sizeof(struct in6_addr);                
+                obj_tptr+=sizeof(struct in6_addr);
                 break;
 #endif
             default:
@@ -820,7 +831,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                        ident,
                        ipaddr_string(obj_tptr));
                 obj_tlen-=sizeof(struct in_addr);
-                obj_tptr+=sizeof(struct in_addr);                
+                obj_tptr+=sizeof(struct in_addr);
                 break;
 #ifdef INET6
             case RSVP_CTYPE_IPV6:
@@ -830,7 +841,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                        ident,
                        ip6addr_string(obj_tptr));
                 obj_tlen-=sizeof(struct in6_addr);
-                obj_tptr+=sizeof(struct in6_addr);                
+                obj_tptr+=sizeof(struct in6_addr);
                 break;
 #endif
             default:
@@ -1049,7 +1060,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                            tok2str(rsvp_obj_xro_values,
                                    "Unknown %u",
                                    RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)),
-                           *(obj_tptr+1));                
+                           *(obj_tptr+1));
 
                     if (*(obj_tptr+1) == 0) { /* prevent infinite loops */
                         printf("%s  ERROR: zero length ERO subtype",ident);
@@ -1065,6 +1076,18 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                                bittok2str(rsvp_obj_rro_flag_values,
                                    "none",
                                    *(obj_tptr+7))); /* rfc3209 says that this field is rsvd. */
+                    break;
+                    case RSVP_OBJ_XRO_LABEL:
+                        printf(", Flags: [%s] (%#x), Class-Type: %s (%u), %u",
+                               bittok2str(rsvp_obj_rro_label_flag_values,
+                                   "none",
+                                   *(obj_tptr+2)),
+                               *(obj_tptr+2),
+                               tok2str(rsvp_ctype_values,
+                                       "Unknown",
+                                       *(obj_tptr+3) + 256*RSVP_OBJ_RRO),
+                               *(obj_tptr+3),
+                               EXTRACT_32BITS(obj_tptr+4));
                     }
                     obj_tlen-=*(obj_tptr+1);
                     obj_tptr+=*(obj_tptr+1);
@@ -1121,14 +1144,14 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                 printf("%s  Session Name: ", ident);
                 for (i = 0; i < namelen; i++)
                     safeputchar(*(obj_tptr+4+i));
-                printf("%s  Setup Priority: %u, Holding Priority: %u, Flags: [%s]",
+                printf("%s  Setup Priority: %u, Holding Priority: %u, Flags: [%s] (%#x)",
                        ident,
                        (int)*obj_tptr,
                        (int)*(obj_tptr+1),
-                       tok2str(rsvp_session_attribute_flag_values,
+                       bittok2str(rsvp_session_attribute_flag_values,
                                   "none",
-                                  *(obj_tptr+2)));
-
+                                  *(obj_tptr+2)),
+                       *(obj_tptr+2));
                 obj_tlen-=4+*(obj_tptr+3);
                 obj_tptr+=4+*(obj_tptr+3);
                 break;
@@ -1141,7 +1164,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
             switch(rsvp_obj_ctype) {
                int subobj_type,af,subobj_len,total_subobj_len;
 
-            case RSVP_CTYPE_1: 
+            case RSVP_CTYPE_1:
 
                 if (obj_tlen < 4)
                     return-1;
@@ -1310,7 +1333,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                            *(obj_tptr),
                            (*(obj_tptr+1)&0x80) ? "" : "not",
                            intserv_serv_tlen);
-                    
+
                     obj_tptr+=4; /* get to the start of the parameter list */
                     obj_tlen-=4;
 
@@ -1430,7 +1453,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                        (int)obj_ptr.rsvp_obj_frr->setup_prio,
                        (int)obj_ptr.rsvp_obj_frr->hold_prio,
                        (int)obj_ptr.rsvp_obj_frr->hop_limit,
-                        bw.f*8/1000000);              
+                        bw.f*8/1000000);
                 printf("%s  Include-any: 0x%08x, Exclude-any: 0x%08x, Include-all: 0x%08x",
                        ident,
                        EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_any),
@@ -1448,7 +1471,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                        (int)obj_ptr.rsvp_obj_frr->setup_prio,
                        (int)obj_ptr.rsvp_obj_frr->hold_prio,
                        (int)obj_ptr.rsvp_obj_frr->hop_limit,
-                        bw.f*8/1000000);              
+                        bw.f*8/1000000);
                 printf("%s  Include Colors: 0x%08x, Exclude Colors: 0x%08x",
                        ident,
                        EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_any),
@@ -1469,7 +1492,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                     printf("%s  PLR-ID: %s, Avoid-Node-ID: %s",
                            ident,
                            ipaddr_string(obj_tptr),
-                           ipaddr_string(obj_tptr+4));              
+                           ipaddr_string(obj_tptr+4));
                     obj_tlen-=8;
                     obj_tptr+=8;
                 }
@@ -1485,7 +1508,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
             case RSVP_CTYPE_1:
                 printf("%s  CT: %u",
                        ident,
-                       EXTRACT_32BITS(obj_tptr)&0x7);              
+                       EXTRACT_32BITS(obj_tptr)&0x7);
                 obj_tlen-=4;
                 obj_tptr+=4;
                 break;
@@ -1584,7 +1607,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                         return-1;
                     if (*(obj_tptr+1) < 2)
                         return -1;
-                    print_unknown_data(obj_tptr+2,"\n\t\t",*(obj_tptr+1)-2);
+                    print_unknown_data(gndo,obj_tptr+2,"\n\t\t",*(obj_tptr+1)-2);
                     obj_tlen-=*(obj_tptr+1);
                     obj_tptr+=*(obj_tptr+1);
                 }
@@ -1659,11 +1682,11 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
             default:
                 hexdump=TRUE;
             }
-            break;           
+            break;
 
         case RSVP_OBJ_ADMIN_STATUS:
             switch(rsvp_obj_ctype) {
-            case RSVP_CTYPE_1: 
+            case RSVP_CTYPE_1:
                 if (obj_tlen < 4)
                     return-1;
                 printf("%s  Flags [%s]", ident,
@@ -1679,7 +1702,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
 
         case RSVP_OBJ_LABEL_SET:
             switch(rsvp_obj_ctype) {
-            case RSVP_CTYPE_1: 
+            case RSVP_CTYPE_1:
                 if (obj_tlen < 4)
                     return-1;
                 action = (EXTRACT_16BITS(obj_tptr)>>8);
@@ -1722,7 +1745,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
 
         case RSVP_OBJ_S2L:
             switch (rsvp_obj_ctype) {
-            case RSVP_CTYPE_IPV4: 
+            case RSVP_CTYPE_IPV4:
                 if (obj_tlen < 4)
                     return-1;
                 printf("%s  Sub-LSP destination address: %s",
@@ -1732,7 +1755,7 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
                 obj_tptr+=4;
                 break;
 #ifdef INET6
-            case RSVP_CTYPE_IPV6: 
+            case RSVP_CTYPE_IPV6:
                 if (obj_tlen < 16)
                     return-1;
                 printf("%s  Sub-LSP destination address: %s",
@@ -1757,12 +1780,12 @@ rsvp_obj_print (const u_char *pptr, u_int plen, const u_char *tptr,
         case RSVP_OBJ_PROTECTION:
         default:
             if (vflag <= 1)
-                print_unknown_data(obj_tptr,"\n\t    ",obj_tlen); /* FIXME indentation */
+                print_unknown_data(gndo,obj_tptr,"\n\t    ",obj_tlen); /* FIXME indentation */
             break;
         }
         /* 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 indentation */
+            print_unknown_data(gndo,tptr+sizeof(struct rsvp_object_header),"\n\t    ", /* FIXME indentation */
                                rsvp_obj_len-sizeof(struct rsvp_object_header));
 
         tptr+=rsvp_obj_len;
@@ -1850,7 +1873,7 @@ rsvp_print(register const u_char *pptr, register u_int len) {
                 return;
             }
             subtlen=EXTRACT_16BITS(rsvp_com_header->length);
-            
+
             printf("\n\t  RSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
                    RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
                    tok2str(rsvp_msg_type_values, "unknown, type: %u",rsvp_com_header->msg_type),
@@ -1865,7 +1888,7 @@ rsvp_print(register const u_char *pptr, register u_int len) {
              */
             rsvp_com_header->checksum[0] = 0;
             rsvp_com_header->checksum[1] = 0;
-            
+
             if (subtlen < sizeof(const struct rsvp_common_header)) {
                 printf("ERROR: common header too short %u < %lu", subtlen,
                        (unsigned long)sizeof(const struct rsvp_common_header));
@@ -1905,8 +1928,8 @@ rsvp_print(register const u_char *pptr, register u_int len) {
             return;
         break;
 
-    default: 
-        print_unknown_data(tptr,"\n\t    ",tlen);  
+    default:
+        print_unknown_data(gndo,tptr,"\n\t    ",tlen);
         break;
     }