From Carles Kishimoto <carles.kishimoto@gmail.com>:
authorhannes <hannes>
Mon, 26 Feb 2007 13:32:36 +0000 (13:32 +0000)
committerhannes <hannes>
Mon, 26 Feb 2007 13:32:36 +0000 (13:32 +0000)
add support for OIF RSVP Extensions UNI 1.0 Rev. 2

print-rsvp.c

index a7117efbe44a8a28e42272a46060e04988242204..81e8fa66636ecfb9d420603c33d3708540647706 100644 (file)
@@ -17,7 +17,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.33.2.13 2007-02-26 11:11:13 hannes Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.33.2.14 2007-02-26 13:32:36 hannes Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -35,6 +35,7 @@ static const char rcsid[] _U_ =
 #include "addrtoname.h"
 #include "ethertype.h"
 #include "gmpls.h"
+#include "af.h"
 
 /*
  * RFC 2205 common header
@@ -152,6 +153,7 @@ static const struct tok rsvp_header_flag_values[] = {
 #define        RSVP_OBJ_PROPERTIES         204 /* juniper proprietary */
 #define        RSVP_OBJ_FASTREROUTE        205 /* draft-ietf-mpls-rsvp-lsp-fastreroute-07 */
 #define        RSVP_OBJ_SESSION_ATTRIBUTE  207 /* rfc3209 */
+#define RSVP_OBJ_GENERALIZED_UNI    229 /* OIF RSVP extensions UNI 1.0 Signaling, Rel. 2 */
 #define RSVP_OBJ_CALL_ID            230 /* rfc3474 */
 #define RSVP_OBJ_CALL_OPS           236 /* rfc3474 */
 
@@ -189,6 +191,7 @@ static const struct tok rsvp_obj_values[] = {
     { RSVP_OBJ_PROPERTIES,         "Properties" },
     { RSVP_OBJ_FASTREROUTE,        "Fast Re-Route" },
     { RSVP_OBJ_SESSION_ATTRIBUTE,  "Session Attribute" },
+    { RSVP_OBJ_GENERALIZED_UNI,    "Generalized UNI" },
     { RSVP_OBJ_CALL_ID,            "Call-ID" },
     { RSVP_OBJ_CALL_OPS,           "Call Capability" },
     { RSVP_OBJ_RESTART_CAPABILITY, "Restart Capability" },
@@ -202,6 +205,7 @@ static const struct tok rsvp_obj_values[] = {
 #define        RSVP_CTYPE_IPV6        2
 #define        RSVP_CTYPE_TUNNEL_IPV4 7
 #define        RSVP_CTYPE_TUNNEL_IPV6 8
+#define        RSVP_CTYPE_UNI_IPV4    11 /* OIF RSVP extensions UNI 1.0 Signaling Rel. 2 */
 #define RSVP_CTYPE_1           1
 #define RSVP_CTYPE_2           2
 #define RSVP_CTYPE_3           3
@@ -234,6 +238,7 @@ static const struct tok rsvp_ctype_values[] = {
     { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_IPV4,                 "IPv4" },
     { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_IPV6,                 "IPv6" },
     { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_TUNNEL_IPV4,           "Tunnel IPv4" },
+    { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_UNI_IPV4,              "UNI IPv4" },
     { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_IPV4,          "IPv4" },
     { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_IPV6,          "IPv6" },
     { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_TUNNEL_IPV4,   "Tunnel IPv4" },
@@ -276,6 +281,7 @@ static const struct tok rsvp_ctype_values[] = {
     { 256*RSVP_OBJ_CLASSTYPE+RSVP_CTYPE_1,                   "1" },
     { 256*RSVP_OBJ_CLASSTYPE_OLD+RSVP_CTYPE_1,               "1" },
     { 256*RSVP_OBJ_LABEL_SET+RSVP_CTYPE_1,                   "1" },
+    { 256*RSVP_OBJ_GENERALIZED_UNI+RSVP_CTYPE_1,             "1" },
     { 0, NULL}
 };
 
@@ -434,7 +440,7 @@ static const struct tok rsvp_obj_admin_status_flag_values[] = {
 #define LABEL_SET_INCLUSIVE_RANGE 2
 #define LABEL_SET_EXCLUSIVE_RANGE 3
 
-static const struct tok label_set_action_values[] = {
+static const struct tok rsvp_obj_label_set_action_values[] = {
     { LABEL_SET_INCLUSIVE_LIST, "Inclusive list" },
     { LABEL_SET_EXCLUSIVE_LIST, "Exclusive list" },
     { LABEL_SET_INCLUSIVE_RANGE, "Inclusive range" },
@@ -442,6 +448,22 @@ static const struct tok label_set_action_values[] = {
     { 0, NULL}
 };
 
+/* OIF RSVP extensions UNI 1.0 Signaling, release 2 */
+#define RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS     1
+#define RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS 2
+#define RSVP_GEN_UNI_SUBOBJ_DIVERSITY              3
+#define RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL            4
+#define RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL           5
+
+static const struct tok rsvp_obj_generalized_uni_values[] = {
+    { RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS, "Source TNA address" },
+    { RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS, "Destination TNA address" },
+    { RSVP_GEN_UNI_SUBOBJ_DIVERSITY, "Diversity" },
+    { RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL, "Egress label" },
+    { RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL, "Service level" },
+    { 0, NULL}
+};
+
 static int rsvp_intserv_print(const u_char *, u_short);
 
 /* 
@@ -706,6 +728,7 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
                 break;
 #endif
             case RSVP_CTYPE_TUNNEL_IPV4:
+            case RSVP_CTYPE_UNI_IPV4:
                 if (obj_tlen < 12)
                     return -1;
                 printf("%s  IPv4 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
@@ -1046,6 +1069,106 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
             }
             break;
 
+       case RSVP_OBJ_GENERALIZED_UNI:
+            switch(rsvp_obj_ctype) {
+               int subobj_type,af,subobj_len,total_subobj_len;
+
+            case RSVP_CTYPE_1: 
+
+                if (obj_tlen < 4)
+                    return-1;
+
+               /* read variable length subobjects */
+               total_subobj_len = obj_tlen;
+                while(total_subobj_len > 0) {
+                    subobj_len  = EXTRACT_16BITS(obj_tptr);
+                    subobj_type = (EXTRACT_16BITS(obj_tptr+2))>>8;
+                    af = (EXTRACT_16BITS(obj_tptr+2))&0x00FF;
+
+                    printf("%s  Subobject Type: %s (%u), AF: %s (%u), length: %u",
+                           ident,
+                           tok2str(rsvp_obj_generalized_uni_values, "Unknown", subobj_type),
+                           subobj_type,
+                           tok2str(af_values, "Unknown", af), af,
+                           subobj_len);
+
+                    switch(subobj_type) {
+                    case RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS:
+                    case RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS:
+
+                        switch(af) {
+                        case AFNUM_INET:
+                            if (subobj_len < 8)
+                                return -1;
+                            printf("%s    UNI IPv4 TNA address: %s",
+                                   ident, ipaddr_string(obj_tptr+4));
+                            break;
+#ifdef INET6
+                        case AFNUM_INET6:
+                            if (subobj_len < 20)
+                                return -1;
+                            printf("%s    UNI IPv6 TNA address: %s",
+                                   ident, ip6addr_string(obj_tptr+4));
+                            break;
+#endif
+                        case AFNUM_NSAP:
+                            if (subobj_len) {
+                                /* unless we have a TLV parser lets just hexdump */
+                                hexdump=TRUE;
+                            }
+                            break;
+                        }
+                        break;
+
+                    case RSVP_GEN_UNI_SUBOBJ_DIVERSITY:
+                        if (subobj_len) {
+                            /* unless we have a TLV parser lets just hexdump */
+                            hexdump=TRUE;
+                        }
+                        break;
+
+                    case RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL:
+                        if (subobj_len < 16) {
+                            return -1;
+                        }
+
+                        printf("%s    U-bit: %x, Label type: %u, Logical port id: %u, Label: %u",
+                               ident,
+                               ((EXTRACT_32BITS(obj_tptr+4))>>31),
+                               ((EXTRACT_32BITS(obj_tptr+4))&0xFF),
+                               EXTRACT_32BITS(obj_tptr+8),
+                               EXTRACT_32BITS(obj_tptr+12));
+                        break;
+
+                    case RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL:
+                        if (subobj_len < 8) {
+                            return -1;
+                        }
+
+                        printf("%s    Service level: %u",
+                               ident, (EXTRACT_32BITS(obj_tptr+4))>>24);
+                        break;
+
+                    default:
+                        hexdump=TRUE;
+                        break;
+                    }
+                    total_subobj_len-=subobj_len;
+                    obj_tptr+=subobj_len;
+                    obj_tlen+=subobj_len;
+               }
+
+                if (total_subobj_len) {
+                    /* unless we have a TLV parser lets just hexdump */
+                    hexdump=TRUE;
+                }
+                break;
+
+            default:
+                hexdump=TRUE;
+            }
+            break;
+
         case RSVP_OBJ_RSVP_HOP:
             switch(rsvp_obj_ctype) {
             case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */
@@ -1459,7 +1582,7 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
                 action = (EXTRACT_16BITS(obj_tptr)>>8);
 
                 printf("%s  Action: %s (%u), Label type: %u", ident,
-                       tok2str(label_set_action_values, "Unknown", action),
+                       tok2str(rsvp_obj_label_set_action_values, "Unknown", action),
                        action, ((EXTRACT_32BITS(obj_tptr) & 0x7F)));
 
                 switch (action) {