]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ospf6.c
Add a nd_print_trunc() call
[tcpdump] / print-ospf6.c
index 1283360a17d0285dea5faf23bf5b3b3b2c667fdf..756d25e21a92e55577c7d79d400d8d63564dd9cc 100644 (file)
@@ -284,7 +284,6 @@ struct lsu6 {
     struct lsa6 lsu_lsa[1]; /* may repeat      */
 };
 
-static const char tstr[] = " [|ospf3]";
 
 static const struct tok ospf6_option_values[] = {
        { OSPF6_OPTION_V6,      "V6" },
@@ -380,7 +379,7 @@ ospf6_print_ls_type(netdissect_options *ndo,
                ls_type & LS_TYPE_MASK,
                tok2str(ospf6_ls_scope_values, "Unknown", ls_type & LS_SCOPE_MASK),
                ls_type &0x8000 ? ", transitive" : "", /* U-bit */
-               ipaddr_string(ndo, ls_stateid));
+               ipaddr_string(ndo, (const u_char *)ls_stateid));
 }
 
 static int
@@ -393,7 +392,7 @@ ospf6_print_lshdr(netdissect_options *ndo,
        ND_TCHECK_4(lshp->ls_seq);
 
        ND_PRINT("\n\t  Advertising Router %s, seq 0x%08x, age %us, length %u",
-               ipaddr_string(ndo, &lshp->ls_router),
+               ipaddr_string(ndo, lshp->ls_router),
                EXTRACT_BE_U_4(lshp->ls_seq),
                EXTRACT_BE_U_2(lshp->ls_age),
                EXTRACT_BE_U_2(lshp->ls_length)-(u_int)sizeof(struct lsa6_hdr));
@@ -412,7 +411,7 @@ ospf6_print_lsaprefix(netdissect_options *ndo,
 {
        const struct lsa6_prefix *lsapp = (const struct lsa6_prefix *)tptr;
        u_int wordlen;
-       struct in6_addr prefix;
+       nd_ipv6 prefix;
 
        if (lsa_length < sizeof (*lsapp) - IPV6_ADDR_LEN_BYTES)
                goto trunc;
@@ -427,10 +426,10 @@ ospf6_print_lsaprefix(netdissect_options *ndo,
                goto trunc;
        lsa_length -= wordlen * 4;
        ND_TCHECK_LEN(lsapp->lsa_p_prefix, wordlen * 4);
-       memset(&prefix, 0, sizeof(prefix));
-       memcpy(&prefix, lsapp->lsa_p_prefix, wordlen * 4);
-       ND_PRINT("\n\t\t%s/%u", ip6addr_string(ndo, &prefix),
-               EXTRACT_U_1(lsapp->lsa_p_len));
+       memset(prefix, 0, sizeof(prefix));
+       memcpy(prefix, lsapp->lsa_p_prefix, wordlen * 4);
+       ND_PRINT("\n\t\t%s/%u", ip6addr_string(ndo, prefix),
+                EXTRACT_U_1(lsapp->lsa_p_len));
         if (EXTRACT_U_1(lsapp->lsa_p_opt)) {
             ND_PRINT(", Options [%s]",
                    bittok2str(ospf6_lsa_prefix_option_values,
@@ -483,7 +482,7 @@ ospf6_print_lsa(netdissect_options *ndo,
         * header.
         */
         if (length < sizeof(struct lsa6_hdr) || (const u_char *)lsap + length > dataend)
-               return (1);
+               return (1);
         lsa_length = length - sizeof(struct lsa6_hdr);
         tptr = (const uint8_t *)lsap+sizeof(struct lsa6_hdr);
 
@@ -511,25 +510,25 @@ ospf6_print_lsa(netdissect_options *ndo,
                        case RLA_TYPE_VIRTUAL:
                                ND_PRINT("\n\t      Virtual Link: Neighbor Router-ID %s"
                                        "\n\t      Neighbor Interface-ID %s, Interface %s",
-                                       ipaddr_string(ndo, &rlp->link_nrtid),
-                                       ipaddr_string(ndo, &rlp->link_nifid),
-                                       ipaddr_string(ndo, &rlp->link_ifid));
+                                       ipaddr_string(ndo, rlp->link_nrtid),
+                                       ipaddr_string(ndo, rlp->link_nifid),
+                                       ipaddr_string(ndo, rlp->link_ifid));
                                 break;
 
                        case RLA_TYPE_ROUTER:
                                ND_PRINT("\n\t      Neighbor Router-ID %s"
                                        "\n\t      Neighbor Interface-ID %s, Interface %s",
-                                       ipaddr_string(ndo, &rlp->link_nrtid),
-                                       ipaddr_string(ndo, &rlp->link_nifid),
-                                       ipaddr_string(ndo, &rlp->link_ifid));
+                                       ipaddr_string(ndo, rlp->link_nrtid),
+                                       ipaddr_string(ndo, rlp->link_nifid),
+                                       ipaddr_string(ndo, rlp->link_ifid));
                                break;
 
                        case RLA_TYPE_TRANSIT:
                                ND_PRINT("\n\t      Neighbor Network-ID %s"
                                        "\n\t      Neighbor Interface-ID %s, Interface %s",
-                                   ipaddr_string(ndo, &rlp->link_nrtid),
-                                   ipaddr_string(ndo, &rlp->link_nifid),
-                                   ipaddr_string(ndo, &rlp->link_ifid));
+                                   ipaddr_string(ndo, rlp->link_nrtid),
+                                   ipaddr_string(ndo, rlp->link_nifid),
+                                   ipaddr_string(ndo, rlp->link_ifid));
                                break;
 
                        default:
@@ -558,7 +557,7 @@ ospf6_print_lsa(netdissect_options *ndo,
                                return (1);
                        lsa_length -= sizeof (*ap);
                        ND_TCHECK_SIZE(ap);
-                       ND_PRINT("\n\t\t%s", ipaddr_string(ndo, ap));
+                       ND_PRINT("\n\t\t%s", ipaddr_string(ndo, *ap));
                        ++ap;
                }
                break;
@@ -602,16 +601,13 @@ ospf6_print_lsa(netdissect_options *ndo,
                tptr += bytelen;
 
                if ((flags32 & ASLA_FLAG_FWDADDR) != 0) {
-                       const nd_ipv6 *fwdaddr6;
-
-                       fwdaddr6 = (const nd_ipv6 *)tptr;
-                       if (lsa_length < sizeof (*fwdaddr6))
+                       if (lsa_length < sizeof (nd_ipv6))
                                return (1);
-                       lsa_length -= sizeof (*fwdaddr6);
-                       ND_TCHECK_SIZE(fwdaddr6);
+                       lsa_length -= sizeof (nd_ipv6);
+                       ND_TCHECK_8(tptr);
                        ND_PRINT(" forward %s",
-                              ip6addr_string(ndo, fwdaddr6));
-                       tptr += sizeof(*fwdaddr6);
+                              ip6addr_string(ndo, tptr));
+                       tptr += sizeof(nd_ipv6);
                }
 
                if ((flags32 & ASLA_FLAG_ROUTETAG) != 0) {
@@ -620,7 +616,7 @@ ospf6_print_lsa(netdissect_options *ndo,
                        lsa_length -= sizeof (uint32_t);
                        ND_TCHECK_4(tptr);
                        ND_PRINT(" tag %s",
-                              ipaddr_string(ndo, (const uint32_t *)tptr));
+                              ipaddr_string(ndo, tptr));
                        tptr += sizeof(uint32_t);
                }
 
@@ -630,7 +626,7 @@ ospf6_print_lsa(netdissect_options *ndo,
                        lsa_length -= sizeof (uint32_t);
                        ND_TCHECK_4(tptr);
                        ND_PRINT(" RefLSID: %s",
-                              ipaddr_string(ndo, (const uint32_t *)tptr));
+                              ipaddr_string(ndo, tptr));
                        tptr += sizeof(uint32_t);
                }
                break;
@@ -696,13 +692,13 @@ ospf6_print_lsa(netdissect_options *ndo,
                break;
 
         case LS_TYPE_GRACE | LS_SCOPE_LINKLOCAL:
-                if (ospf_print_grace_lsa(ndo, tptr, lsa_length) == -1) {
+                if (ospf_grace_lsa_print(ndo, tptr, lsa_length) == -1) {
                     return 1;
                 }
                 break;
 
         case LS_TYPE_INTRA_ATE | LS_SCOPE_LINKLOCAL:
-                if (ospf_print_te_lsa(ndo, tptr, lsa_length) == -1) {
+                if (ospf_te_lsa_print(ndo, tptr, lsa_length) == -1) {
                     return 1;
                 }
                 break;
@@ -746,23 +742,23 @@ ospf6_decode_v3(netdissect_options *ndo,
                ND_PRINT("\n\t  Hello Timer %us, Dead Timer %us, Interface-ID %s, Priority %u",
                          EXTRACT_BE_U_2(hellop->hello_helloint),
                          EXTRACT_BE_U_2(hellop->hello_deadint),
-                         ipaddr_string(ndo, &hellop->hello_ifid),
+                         ipaddr_string(ndo, hellop->hello_ifid),
                          EXTRACT_U_1(hellop->hello_priority));
 
                ND_TCHECK_4(hellop->hello_dr);
                if (EXTRACT_BE_U_4(hellop->hello_dr) != 0)
                        ND_PRINT("\n\t  Designated Router %s",
-                           ipaddr_string(ndo, &hellop->hello_dr));
+                           ipaddr_string(ndo, hellop->hello_dr));
                ND_TCHECK_4(hellop->hello_bdr);
                if (EXTRACT_BE_U_4(hellop->hello_bdr) != 0)
                        ND_PRINT(", Backup Designated Router %s",
-                           ipaddr_string(ndo, &hellop->hello_bdr));
+                           ipaddr_string(ndo, hellop->hello_bdr));
                if (ndo->ndo_vflag > 1) {
                        ND_PRINT("\n\t  Neighbor List:");
                        ap = hellop->hello_neighbor;
                        while ((const u_char *)ap < dataend) {
                                ND_TCHECK_SIZE(ap);
-                               ND_PRINT("\n\t    %s", ipaddr_string(ndo, ap));
+                               ND_PRINT("\n\t    %s", ipaddr_string(ndo, *ap));
                                ++ap;
                        }
                }
@@ -801,7 +797,7 @@ ospf6_decode_v3(netdissect_options *ndo,
                        while ((const u_char *)lsrp < dataend) {
                                ND_TCHECK_SIZE(lsrp);
                                ND_PRINT("\n\t  Advertising Router %s",
-                                         ipaddr_string(ndo, &lsrp->ls_router));
+                                         ipaddr_string(ndo, lsrp->ls_router));
                                ospf6_print_ls_type(ndo,
                                                     EXTRACT_BE_U_2(lsrp->ls_type),
                                                     &lsrp->ls_stateid);
@@ -965,6 +961,7 @@ ospf6_print(netdissect_options *ndo,
        const char *cp;
        uint16_t datalen;
 
+       ndo->ndo_protocol = "ospf3";
        op = (const struct ospf6hdr *)bp;
 
        /* If the type is valid translate it, or just print the type */
@@ -990,11 +987,11 @@ ospf6_print(netdissect_options *ndo,
        dataend = bp + datalen;
 
        ND_TCHECK_4(op->ospf6_routerid);
-       ND_PRINT("\n\tRouter-ID %s", ipaddr_string(ndo, &op->ospf6_routerid));
+       ND_PRINT("\n\tRouter-ID %s", ipaddr_string(ndo, op->ospf6_routerid));
 
        ND_TCHECK_4(op->ospf6_areaid);
        if (EXTRACT_BE_U_4(op->ospf6_areaid) != 0)
-               ND_PRINT(", Area %s", ipaddr_string(ndo, &op->ospf6_areaid));
+               ND_PRINT(", Area %s", ipaddr_string(ndo, op->ospf6_areaid));
        else
                ND_PRINT(", Backbone Area");
        ND_TCHECK_1(op->ospf6_instanceid);
@@ -1014,5 +1011,5 @@ ospf6_print(netdissect_options *ndo,
 
        return;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
 }