]> The Tcpdump Group git mirrors - tcpdump/commitdiff
add support for the Opaque Router Information LSA and the Router Capabilities TLV...
authorhannes <hannes>
Mon, 20 Sep 2004 14:36:16 +0000 (14:36 +0000)
committerhannes <hannes>
Mon, 20 Sep 2004 14:36:16 +0000 (14:36 +0000)
ospf.h
print-ospf.c

diff --git a/ospf.h b/ospf.h
index ba7eb2afa788583c138b35b88a57ecace732ebde..72c0cf060567d6053e410c525952ffec978c2316 100644 (file)
--- a/ospf.h
+++ b/ospf.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.14 2004-09-09 16:17:38 hannes Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.15 2004-09-20 14:36:16 hannes Exp $ (LBL) */
 /*
  * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
  *     The Regents of the University of California.  All rights reserved.
@@ -70,6 +70,7 @@
 
 #define LS_OPAQUE_TYPE_TE       1   /* rfc3630 */
 #define LS_OPAQUE_TYPE_GRACE    3   /* rfc3623 */
+#define LS_OPAQUE_TYPE_RI       4   /* draft-ietf-ospf-cap-03 */
 
 #define LS_OPAQUE_TE_TLV_ROUTER 1   /* rfc3630 */
 #define LS_OPAQUE_TE_TLV_LINK   2   /* rfc3630 */
 #define LS_OPAQUE_GRACE_TLV_REASON_SW_UPGRADE  2 /* rfc3623 */
 #define LS_OPAQUE_GRACE_TLV_REASON_CP_SWITCH   3 /* rfc3623 */
 
+#define LS_OPAQUE_RI_TLV_CAP             1 /* draft-ietf-ospf-cap-03 */
+
 /*************************************************
  *
  * is the above a bug in the documentation?
@@ -208,13 +211,20 @@ struct lsa {
            u_int8_t data[1]; /* may repeat   */
        } un_te_lsa_tlv;
 
-        /* Grace LSA */
+        /* Opaque Grace LSA */
         struct {
            u_int16_t type;
            u_int16_t length;
            u_int8_t data[1]; /* may repeat   */
        } un_grace_tlv;
 
+        /* Opaque Router information LSA */
+        struct {
+           u_int16_t type;
+           u_int16_t length;
+           u_int8_t data[1]; /* may repeat   */
+       } un_ri_tlv;
+
         /* Unknown LSA */
         struct unknown {
            u_int8_t data[1]; /* may repeat   */
index b6382350cf43e006428a0cd528dceeed6c889faa..baf42f609dc5eaa7b858dbba23f8b82e9b1c8ca2 100644 (file)
@@ -23,7 +23,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.53 2004-09-15 17:54:11 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.54 2004-09-20 14:36:16 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -103,6 +103,7 @@ static struct tok ospf_dd_flag_values[] = {
 static struct tok lsa_opaque_values[] = {
        { LS_OPAQUE_TYPE_TE,    "Traffic Engineering" },
        { LS_OPAQUE_TYPE_GRACE, "Graceful restart" },
+       { LS_OPAQUE_TYPE_RI,    "Router Information" },
        { 0,                    NULL }
 };
 
@@ -151,6 +152,25 @@ static struct tok lsa_opaque_te_tlv_link_type_sub_tlv_values[] = {
        { 0,                    NULL }
 };
 
+static struct tok lsa_opaque_ri_tlv_values[] = {
+       { LS_OPAQUE_RI_TLV_CAP, "Router Capabilities" },
+       { 0,                    NULL }
+};
+
+static struct tok lsa_opaque_ri_tlv_cap_values[] = {
+       { 1, "Reserved" },
+       { 2, "Reserved" },
+       { 4, "Reserved" },
+       { 8, "Reserved" },
+       { 16, "graceful restart capable" },
+       { 32, "graceful restart helper" },
+       { 64, "Stub router support" },
+       { 128, "Traffic engineering" },
+       { 256, "p2p over LAN" },
+       { 512, "path computation server" },
+       { 0,                    NULL }
+};
+
 static char tstr[] = " [|ospf]";
 
 #ifdef WIN32
@@ -426,6 +446,54 @@ ospf_print_lsa(register const struct lsa *lsap)
        case LS_TYPE_OPAQUE_DW:
 
            switch (*(&lsap->ls_hdr.un_lsa_id.opaque_field.opaque_type)) {
+            case LS_OPAQUE_TYPE_RI:
+               tptr = (u_int8_t *)(&lsap->lsa_un.un_ri_tlv.type);
+
+               while (ls_length != 0) {
+                    TCHECK2(*tptr, 4);
+                   if (ls_length < 4) {
+                        printf("\n\t    Remaining LS length %u < 4", ls_length);
+                        return(ls_end);
+                    }
+                    tlv_type = EXTRACT_16BITS(tptr);
+                    tlv_length = EXTRACT_16BITS(tptr+2);
+                    tptr+=4;
+                    ls_length-=4;
+                    
+                    printf("\n\t    %s TLV (%u), length: %u, value: ",
+                           tok2str(lsa_opaque_ri_tlv_values,"unknown",tlv_type),
+                           tlv_type,
+                           tlv_length);
+
+                    if (tlv_length > ls_length) {
+                        printf("\n\t    Bogus length %u > %u", tlv_length,
+                            ls_length);
+                        return(ls_end);
+                    }
+                    ls_length-=tlv_length;
+                    TCHECK2(*tptr, tlv_length);
+                    switch(tlv_type) {
+
+                    case LS_OPAQUE_RI_TLV_CAP:
+                        if (tlv_length != 4) {
+                            printf("\n\t    Bogus length %u != 4", tlv_length);
+                            return(ls_end);
+                        }
+                        printf("Capabilities: %s",
+                               bittok2str(lsa_opaque_ri_tlv_cap_values, "Unknown", EXTRACT_32BITS(tptr)));
+                        break;
+                    default:
+                        if (vflag <= 1) {
+                            if(!print_unknown_data(tptr,"\n\t      ",tlv_length))
+                                return(ls_end);
+                        }
+                        break;
+
+                    }
+                    tptr+=tlv_length;
+                }
+
+                break;
             case LS_OPAQUE_TYPE_GRACE:
                tptr = (u_int8_t *)(&lsap->lsa_un.un_grace_tlv.type);