]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ospf6.c
There's no link-layer header on Linux ARPHRD_ATM packets; there's
[tcpdump] / print-ospf6.c
index cd3b322f392d5e03077a49fba1415b2cc404e764..b7fe99f4b728d27068c49caabaf2d72c06b29bda 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.7 2001-05-09 01:08:03 fenner Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -35,9 +35,6 @@ static const char rcsid[] =
 #include <sys/socket.h>
 
 #include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_var.h>
 
 #include <ctype.h>
 #include <stdio.h>
@@ -71,6 +68,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 +245,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 +260,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 +276,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 +349,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",
+                      (u_int32_t)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 +410,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 +448,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 +471,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);
                }