]> The Tcpdump Group git mirrors - tcpdump/commitdiff
correct ospf6 AS external LSA printing.
authoritojun <itojun>
Fri, 12 May 2000 13:01:01 +0000 (13:01 +0000)
committeritojun <itojun>
Fri, 12 May 2000 13:01:01 +0000 (13:01 +0000)
From: [email protected]

ospf6.h
print-ospf6.c

diff --git a/ospf6.h b/ospf6.h
index 85e81d7f7e67d492fc7fa93204e208a7869416fd..99a766e61ac5305bdef7421a83589010a08d0cba 100644 (file)
--- a/ospf6.h
+++ b/ospf6.h
 #define        SLA_MASK_METRIC         0x00ffffff
 #define SLA_SHIFT_TOS          24
 
-/* asla_tosmetric breakdown    */
-#define        ASLA_FLAG_EXTERNAL      0x80000000
-#define        ASLA_MASK_TOS           0x7f000000
-#define        ASLA_SHIFT_TOS          24
+/* asla_metric */
+#define ASLA_FLAG_EXTERNAL     0x04000000
+#define ASLA_FLAG_FWDADDR      0x02000000
+#define ASLA_FLAG_ROUTETAG     0x01000000
 #define        ASLA_MASK_METRIC        0x00ffffff
 
 /* multicast vertex type */
@@ -149,6 +149,13 @@ struct lsa {
            struct lsa_prefix inter_ap_prefix[1];
        } un_inter_ap;
 
+       /* AS external links advertisements */
+       struct {
+           u_int32_t asla_metric;
+           struct lsa_prefix asla_prefix[1]; 
+           /* some optional fields follow */
+       } un_asla;
+
 #if 0
        /* Summary links advertisements */
        struct {
@@ -156,16 +163,6 @@ struct lsa {
            u_int32_t sla_tosmetric[1]; /* may repeat   */
        } un_sla;
 
-       /* AS external links advertisements */
-       struct {
-           struct in_addr asla_mask;
-           struct aslametric {
-               u_int32_t asla_tosmetric;
-               struct in_addr asla_forward;
-               struct in_addr asla_tag;
-           } asla_metric[1];           /* may repeat   */
-       } un_asla;
-
        /* Multicast group membership */
        struct mcla {
            u_int32_t mcla_vtype;
index cd3b322f392d5e03077a49fba1415b2cc404e764..bd1b0c5fdab26154495bbc590db8f633ceeb7c75 100644 (file)
@@ -23,7 +23,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.3 2000-03-15 18:32:09 itojun Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.4 2000-05-12 13:01:02 itojun Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -71,6 +71,13 @@ static const struct bits ospf6_rla_flag_bits[] = {
        { 0,                    NULL }
 };
 
+static const struct bits ospf6_asla_flag_bits[] = {
+       { ASLA_FLAG_EXTERNAL,   "E" },
+       { ASLA_FLAG_FWDADDR,    "F" },
+       { ASLA_FLAG_ROUTETAG,   "T" },
+       { 0,                    NULL }
+};
+
 static struct tok type2str[] = {
        { OSPF_TYPE_UMD,        "umd" },
        { OSPF_TYPE_HELLO,      "hello" },
@@ -241,6 +248,8 @@ ospf6_print_lsaprefix(register const struct lsa_prefix *lsapp)
                lsapp->lsa_p_len);
        if (lsapp->lsa_p_opt)
                printf("(opt=%x)", lsapp->lsa_p_opt);
+       if (lsapp->lsa_p_mbz)
+               printf("(mbz=%x)", ntohs(lsapp->lsa_p_mbz)); /* XXX */
        return sizeof(*lsapp) - 4 + k * 4;
 
 trunc:
@@ -254,7 +263,7 @@ trunc:
 static int
 ospf6_print_lsa(register const struct lsa *lsap)
 {
-       register const u_char *ls_end;
+       register const u_char *ls_end, *ls_opt;
        register const struct rlalink *rlp;
 #if 0
        register const struct tos_metric *tosp;
@@ -270,6 +279,7 @@ ospf6_print_lsa(register const struct lsa *lsap)
        register const u_int32_t *lp;
 #endif
        register int j, k;
+       u_int32_t flags32;
 
        if (ospf6_print_lshdr(&lsap->ls_hdr))
                return (1);
@@ -342,12 +352,51 @@ ospf6_print_lsa(register const struct lsa *lsap)
                lsapp = lsap->lsa_un.un_inter_ap.inter_ap_prefix;
                while (lsapp + sizeof(lsapp) <= (struct lsa_prefix *)ls_end) {
                        k = ospf6_print_lsaprefix(lsapp);
-                       if (k < 0)
+                       if (k)
                                goto trunc;
                        lsapp = (struct lsa_prefix *)(((u_char *)lsapp) + k);
                }
                break;
+       case LS_SCOPE_AS | LS_TYPE_ASE:
+               TCHECK(lsap->lsa_un.un_asla.asla_metric);
+               flags32 = ntohl(lsap->lsa_un.un_asla.asla_metric);
+               ospf6_print_bits(ospf6_asla_flag_bits, flags32);
+               printf(" metric %u",
+                      ntohl(lsap->lsa_un.un_asla.asla_metric) &
+                      ASLA_MASK_METRIC);
+               lsapp = lsap->lsa_un.un_asla.asla_prefix;
+               k = ospf6_print_lsaprefix(lsapp);
+               if (k < 0)
+                       goto trunc;
+               if ((ls_opt = (u_char *)(((u_char *)lsapp) + k)) < ls_end) {
+                       struct in6_addr *fwdaddr6;
+
+                       if ((flags32 & ASLA_FLAG_FWDADDR) != 0) {
+                               fwdaddr6 = (struct in6_addr *)ls_opt;
+                               TCHECK(*fwdaddr6);
+                               printf(" forward %s",
+                                      ip6addr_string(fwdaddr6));
 
+                               ls_opt += sizeof(struct in6_addr);
+                       }
+
+                       if ((flags32 & ASLA_FLAG_ROUTETAG) != 0) {
+                               TCHECK(*(u_int32_t *)ls_opt);
+                               printf(" tag %s", 
+                                      ipaddr_string((u_int32_t *)ls_opt));
+
+                               ls_opt += sizeof(u_int32_t);
+                       }
+
+                       if (lsapp->lsa_p_mbz) {
+                               TCHECK(*(u_int32_t *)ls_opt);
+                               printf(" RefLSID: %s",
+                                      ipaddr_string((u_int32_t *)ls_opt));
+
+                               ls_opt += sizeof(u_int32_t);
+                       }
+               }
+               break;
 #if 0
        case LS_TYPE_SUM_ABR:
                TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
@@ -364,36 +413,6 @@ ospf6_print_lsa(register const struct lsa *lsap)
                }
                break;
 
-       case LS_TYPE_ASE:
-               TCHECK(lsap->lsa_un.un_nla.nla_mask);
-               printf(" mask %s",
-                   ipaddr_string(&lsap->lsa_un.un_asla.asla_mask));
-
-               TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
-               almp = lsap->lsa_un.un_asla.asla_metric;
-               while ((u_char *)almp < ls_end) {
-                       register u_int32_t ul;
-
-                       TCHECK(almp->asla_tosmetric);
-                       ul = ntohl(almp->asla_tosmetric);
-                       printf(" type %d tos %d metric %d",
-                           (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1,
-                           (ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS,
-                           (ul & ASLA_MASK_METRIC));
-                       TCHECK(almp->asla_forward);
-                       if (almp->asla_forward.s_addr) {
-                               printf(" forward %s",
-                                   ipaddr_string(&almp->asla_forward));
-                       }
-                       TCHECK(almp->asla_tag);
-                       if (almp->asla_tag.s_addr) {
-                               printf(" tag %s",
-                                   ipaddr_string(&almp->asla_tag));
-                       }
-                       ++almp;
-               }
-               break;
-
        case LS_TYPE_GROUP:
                /* Multicast extensions as of 23 July 1991 */
                mcp = lsap->lsa_un.un_mcla;
@@ -432,7 +451,7 @@ ospf6_print_lsa(register const struct lsa *lsap)
                lsapp = llsap->llsa_prefix;
                for (j = 0; j < ntohl(llsap->llsa_nprefix); j++) {
                        k = ospf6_print_lsaprefix(lsapp);
-                       if (k < 0)
+                       if (k)
                                goto trunc;
                        lsapp = (struct lsa_prefix *)(((u_char *)lsapp) + k);
                }
@@ -455,7 +474,7 @@ ospf6_print_lsa(register const struct lsa *lsap)
                     j < ntohs(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
                     j++) {
                        k = ospf6_print_lsaprefix(lsapp);
-                       if (k < 0)
+                       if (k)
                                goto trunc;
                        lsapp = (struct lsa_prefix *)(((u_char *)lsapp) + k);
                }