]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ospf.c
Fixed some warnings, added print-zep.c to CMakeLists
[tcpdump] / print-ospf.c
index 1bf03652a4a011157b03016d837b8950be5074d3..2a502a6c8c4d26fb435b4c7aeaa9697e8d809852 100644 (file)
 /* \summary: Open Shortest Path First (OSPF) printer */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
-#include <netdissect-stdinc.h>
+#include "netdissect-stdinc.h"
 
 #include "netdissect.h"
 #include "addrtoname.h"
@@ -36,7 +36,6 @@
 
 #include "ospf.h"
 
-static const char tstr[] = " [|ospf2]";
 
 static const struct tok ospf_option_values[] = {
         { OSPF_OPTION_T,       "MultiTopology" }, /* draft-ietf-ospf-mt-09 */
@@ -180,7 +179,7 @@ static const struct tok ospf_lls_eo_options[] = {
 };
 
 int
-ospf_print_grace_lsa(netdissect_options *ndo,
+ospf_grace_lsa_print(netdissect_options *ndo,
                      const u_char *tptr, u_int ls_length)
 {
     u_int tlv_type, tlv_length;
@@ -263,7 +262,7 @@ trunc:
 }
 
 int
-ospf_print_te_lsa(netdissect_options *ndo,
+ospf_te_lsa_print(netdissect_options *ndo,
                   const u_char *tptr, u_int ls_length)
 {
     u_int tlv_type, tlv_length, subtlv_type, subtlv_length;
@@ -428,7 +427,7 @@ ospf_print_te_lsa(netdissect_options *ndo,
                            tok2str(gmpls_encoding_values, "Unknown", EXTRACT_U_1((tptr + 1))));
                     for (priority_level = 0; priority_level < 8; priority_level++) {
                         bw.i = EXTRACT_BE_U_4(tptr + 4 + (priority_level * 4));
-                        ND_PRINT("\n\t\t  priority level %d: %.3f Mbps",
+                        ND_PRINT("\n\t\t  priority level %u: %.3f Mbps",
                                priority_level,
                                bw.f * 8 / 1000000);
                     }
@@ -453,7 +452,7 @@ ospf_print_te_lsa(netdissect_options *ndo,
                         ND_PRINT("\n\t\t  Shared risk group: ");
                     while (count_srlg > 0) {
                         bw.i = EXTRACT_BE_U_4(tptr);
-                        ND_PRINT("%d", bw.i);
+                        ND_PRINT("%u", bw.i);
                         tptr+=4;
                         count_srlg--;
                         if (count_srlg > 0)
@@ -504,7 +503,7 @@ ospf_print_te_lsa(netdissect_options *ndo,
 trunc:
     return -1;
 invalid:
-    ND_PRINT("%s", istr);
+    nd_print_invalid(ndo);
     return -1;
 }
 
@@ -515,7 +514,7 @@ ospf_print_lshdr(netdissect_options *ndo,
         u_int ls_type;
         u_int ls_length;
 
-        ND_TCHECK(lshp->ls_length);
+        ND_TCHECK_2(lshp->ls_length);
         ls_length = EXTRACT_BE_U_2(lshp->ls_length);
         if (ls_length < sizeof(struct lsa_hdr)) {
                 ND_PRINT("\n\t    Bogus length %u < header (%lu)", ls_length,
@@ -523,21 +522,21 @@ ospf_print_lshdr(netdissect_options *ndo,
                 return(-1);
         }
 
-        ND_TCHECK(lshp->ls_seq); /* XXX - ls_length check checked this */
+        ND_TCHECK_4(lshp->ls_seq); /* XXX - ls_length check checked this */
         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),
                   ls_length - (u_int)sizeof(struct lsa_hdr));
 
-        ND_TCHECK(lshp->ls_type); /* XXX - ls_length check checked this */
+        ND_TCHECK_1(lshp->ls_type); /* XXX - ls_length check checked this */
         ls_type = EXTRACT_U_1(lshp->ls_type);
         switch (ls_type) {
         /* the LSA header for opaque LSAs was slightly changed */
         case LS_TYPE_OPAQUE_LL:
         case LS_TYPE_OPAQUE_AL:
         case LS_TYPE_OPAQUE_DW:
-            ND_PRINT("\n\t    %s LSA (%d), Opaque-Type %s LSA (%u), Opaque-ID %u",
+            ND_PRINT("\n\t    %s LSA (%u), Opaque-Type %s LSA (%u), Opaque-ID %u",
                    tok2str(lsa_values,"unknown",ls_type),
                    ls_type,
 
@@ -552,14 +551,14 @@ ospf_print_lshdr(netdissect_options *ndo,
 
         /* all other LSA types use regular style LSA headers */
         default:
-            ND_PRINT("\n\t    %s LSA (%d), LSA-ID: %s",
+            ND_PRINT("\n\t    %s LSA (%u), LSA-ID: %s",
                    tok2str(lsa_values,"unknown",ls_type),
                    ls_type,
-                   ipaddr_string(ndo, &lshp->un_lsa_id.lsa_id));
+                   ipaddr_string(ndo, lshp->un_lsa_id.lsa_id));
             break;
         }
 
-        ND_TCHECK(lshp->ls_options); /* XXX - ls_length check checked this */
+        ND_TCHECK_1(lshp->ls_options); /* XXX - ls_length check checked this */
         ND_PRINT("\n\t    Options: [%s]", bittok2str(ospf_option_values, "none", EXTRACT_U_1(lshp->ls_options)));
 
         return (ls_length);
@@ -620,7 +619,7 @@ ospf_print_lsa(netdissect_options *ndo,
 {
        const uint8_t *ls_end;
        const struct rlalink *rlp;
-       const struct in_addr *ap;
+       const nd_ipv4 *ap;
        const struct aslametric *almp;
        const struct mcla *mcp;
        const uint8_t *lp;
@@ -638,13 +637,13 @@ ospf_print_lsa(netdissect_options *ndo,
        switch (EXTRACT_U_1(lsap->ls_hdr.ls_type)) {
 
        case LS_TYPE_ROUTER:
-               ND_TCHECK(lsap->lsa_un.un_rla.rla_flags);
+               ND_TCHECK_1(lsap->lsa_un.un_rla.rla_flags);
                ND_PRINT("\n\t    Router LSA Options: [%s]",
                          bittok2str(ospf_rla_flag_values, "none", EXTRACT_U_1(lsap->lsa_un.un_rla.rla_flags)));
 
-               ND_TCHECK(lsap->lsa_un.un_rla.rla_count);
+               ND_TCHECK_2(lsap->lsa_un.un_rla.rla_count);
                j = EXTRACT_BE_U_2(lsap->lsa_un.un_rla.rla_count);
-               ND_TCHECK(lsap->lsa_un.un_rla.rla_link);
+               ND_TCHECK_SIZE(lsap->lsa_un.un_rla.rla_link);
                rlp = lsap->lsa_un.un_rla.rla_link;
                while (j--) {
                        ND_TCHECK_SIZE(rlp);
@@ -652,26 +651,26 @@ ospf_print_lsa(netdissect_options *ndo,
 
                        case RLA_TYPE_VIRTUAL:
                                ND_PRINT("\n\t      Virtual Link: Neighbor Router-ID: %s, Interface Address: %s",
-                                   ipaddr_string(ndo, &rlp->link_id),
-                                   ipaddr_string(ndo, &rlp->link_data));
+                                   ipaddr_string(ndo, rlp->link_id),
+                                   ipaddr_string(ndo, rlp->link_data));
                                break;
 
                        case RLA_TYPE_ROUTER:
                                ND_PRINT("\n\t      Neighbor Router-ID: %s, Interface Address: %s",
-                                   ipaddr_string(ndo, &rlp->link_id),
-                                   ipaddr_string(ndo, &rlp->link_data));
+                                   ipaddr_string(ndo, rlp->link_id),
+                                   ipaddr_string(ndo, rlp->link_data));
                                break;
 
                        case RLA_TYPE_TRANSIT:
                                ND_PRINT("\n\t      Neighbor Network-ID: %s, Interface Address: %s",
-                                   ipaddr_string(ndo, &rlp->link_id),
-                                   ipaddr_string(ndo, &rlp->link_data));
+                                   ipaddr_string(ndo, rlp->link_id),
+                                   ipaddr_string(ndo, rlp->link_data));
                                break;
 
                        case RLA_TYPE_STUB:
                                ND_PRINT("\n\t      Stub Network: %s, Mask: %s",
-                                   ipaddr_string(ndo, &rlp->link_id),
-                                   ipaddr_string(ndo, &rlp->link_data));
+                                   ipaddr_string(ndo, rlp->link_id),
+                                   ipaddr_string(ndo, rlp->link_data));
                                break;
 
                        default:
@@ -689,22 +688,22 @@ ospf_print_lsa(netdissect_options *ndo,
                break;
 
        case LS_TYPE_NETWORK:
-               ND_TCHECK(lsap->lsa_un.un_nla.nla_mask);
+               ND_TCHECK_4(lsap->lsa_un.un_nla.nla_mask);
                ND_PRINT("\n\t    Mask %s\n\t    Connected Routers:",
-                   ipaddr_string(ndo, &lsap->lsa_un.un_nla.nla_mask));
+                   ipaddr_string(ndo, lsap->lsa_un.un_nla.nla_mask));
                ap = lsap->lsa_un.un_nla.nla_router;
                while ((const u_char *)ap < ls_end) {
                        ND_TCHECK_SIZE(ap);
-                       ND_PRINT("\n\t      %s", ipaddr_string(ndo, ap));
+                       ND_PRINT("\n\t      %s", ipaddr_string(ndo, *ap));
                        ++ap;
                }
                break;
 
        case LS_TYPE_SUM_IP:
-               ND_TCHECK(lsap->lsa_un.un_nla.nla_mask);
+               ND_TCHECK_4(lsap->lsa_un.un_nla.nla_mask);
                ND_PRINT("\n\t    Mask %s",
-                   ipaddr_string(ndo, &lsap->lsa_un.un_sla.sla_mask));
-               ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
+                   ipaddr_string(ndo, lsap->lsa_un.un_sla.sla_mask));
+               ND_TCHECK_SIZE(lsap->lsa_un.un_sla.sla_tosmetric);
                lp = (const uint8_t *)lsap->lsa_un.un_sla.sla_tosmetric;
                while (lp < ls_end) {
                        uint32_t ul;
@@ -712,7 +711,7 @@ ospf_print_lsa(netdissect_options *ndo,
                        ND_TCHECK_4(lp);
                        ul = EXTRACT_BE_U_4(lp);
                         topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
-                       ND_PRINT("\n\t\ttopology %s (%u) metric %d",
+                       ND_PRINT("\n\t\ttopology %s (%u) metric %u",
                                tok2str(ospf_topology_values, "Unknown", topology),
                                topology,
                                ul & SLA_MASK_METRIC);
@@ -721,7 +720,7 @@ ospf_print_lsa(netdissect_options *ndo,
                break;
 
        case LS_TYPE_SUM_ABR:
-               ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
+               ND_TCHECK_SIZE(lsap->lsa_un.un_sla.sla_tosmetric);
                lp = (const uint8_t *)lsap->lsa_un.un_sla.sla_tosmetric;
                while (lp < ls_end) {
                        uint32_t ul;
@@ -729,7 +728,7 @@ ospf_print_lsa(netdissect_options *ndo,
                        ND_TCHECK_4(lp);
                        ul = EXTRACT_BE_U_4(lp);
                         topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
-                       ND_PRINT("\n\t\ttopology %s (%u) metric %d",
+                       ND_PRINT("\n\t\ttopology %s (%u) metric %u",
                                tok2str(ospf_topology_values, "Unknown", topology),
                                topology,
                                ul & SLA_MASK_METRIC);
@@ -739,34 +738,34 @@ ospf_print_lsa(netdissect_options *ndo,
 
        case LS_TYPE_ASE:
         case LS_TYPE_NSSA: /* fall through - those LSAs share the same format */
-               ND_TCHECK(lsap->lsa_un.un_nla.nla_mask);
+               ND_TCHECK_4(lsap->lsa_un.un_nla.nla_mask);
                ND_PRINT("\n\t    Mask %s",
-                   ipaddr_string(ndo, &lsap->lsa_un.un_asla.asla_mask));
+                   ipaddr_string(ndo, lsap->lsa_un.un_asla.asla_mask));
 
-               ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
+               ND_TCHECK_SIZE(lsap->lsa_un.un_sla.sla_tosmetric);
                almp = lsap->lsa_un.un_asla.asla_metric;
                while ((const u_char *)almp < ls_end) {
                        uint32_t ul;
 
-                       ND_TCHECK(almp->asla_tosmetric);
+                       ND_TCHECK_4(almp->asla_tosmetric);
                        ul = EXTRACT_BE_U_4(almp->asla_tosmetric);
                         topology = ((ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS);
-                       ND_PRINT("\n\t\ttopology %s (%u), type %d, metric",
+                       ND_PRINT("\n\t\ttopology %s (%u), type %u, metric",
                                tok2str(ospf_topology_values, "Unknown", topology),
                                topology,
                                (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1);
                        if ((ul & ASLA_MASK_METRIC) == 0xffffff)
                                ND_PRINT(" infinite");
                        else
-                               ND_PRINT(" %d", (ul & ASLA_MASK_METRIC));
+                               ND_PRINT(" %u", (ul & ASLA_MASK_METRIC));
 
-                       ND_TCHECK(almp->asla_forward);
-                       if (almp->asla_forward.s_addr) {
-                               ND_PRINT(", forward %s", ipaddr_string(ndo, &almp->asla_forward));
+                       ND_TCHECK_4(almp->asla_forward);
+                       if (EXTRACT_IPV4_TO_NETWORK_ORDER(almp->asla_forward) != 0) {
+                               ND_PRINT(", forward %s", ipaddr_string(ndo, almp->asla_forward));
                        }
-                       ND_TCHECK(almp->asla_tag);
-                       if (almp->asla_tag.s_addr) {
-                               ND_PRINT(", tag %s", ipaddr_string(ndo, &almp->asla_tag));
+                       ND_TCHECK_4(almp->asla_tag);
+                       if (EXTRACT_IPV4_TO_NETWORK_ORDER(almp->asla_tag) != 0) {
+                               ND_PRINT(", tag %s", ipaddr_string(ndo, almp->asla_tag));
                        }
                        ++almp;
                }
@@ -776,17 +775,17 @@ ospf_print_lsa(netdissect_options *ndo,
                /* Multicast extensions as of 23 July 1991 */
                mcp = lsap->lsa_un.un_mcla;
                while ((const u_char *)mcp < ls_end) {
-                       ND_TCHECK(mcp->mcla_vid);
+                       ND_TCHECK_4(mcp->mcla_vid);
                        switch (EXTRACT_BE_U_4(mcp->mcla_vtype)) {
 
                        case MCLA_VERTEX_ROUTER:
                                ND_PRINT("\n\t    Router Router-ID %s",
-                                   ipaddr_string(ndo, &mcp->mcla_vid));
+                                   ipaddr_string(ndo, mcp->mcla_vid));
                                break;
 
                        case MCLA_VERTEX_NETWORK:
                                ND_PRINT("\n\t    Network Designated Router %s",
-                                   ipaddr_string(ndo, &mcp->mcla_vid));
+                                   ipaddr_string(ndo, mcp->mcla_vid));
                                break;
 
                        default:
@@ -852,14 +851,14 @@ ospf_print_lsa(netdissect_options *ndo,
                 break;
 
             case LS_OPAQUE_TYPE_GRACE:
-                if (ospf_print_grace_lsa(ndo, (const u_char *)(lsap->lsa_un.un_grace_tlv),
+                if (ospf_grace_lsa_print(ndo, (const u_char *)(lsap->lsa_un.un_grace_tlv),
                                          ls_length) == -1) {
                     return(ls_end);
                 }
                 break;
 
            case LS_OPAQUE_TYPE_TE:
-                if (ospf_print_te_lsa(ndo, (const u_char *)(lsap->lsa_un.un_te_lsa_tlv),
+                if (ospf_te_lsa_print(ndo, (const u_char *)(lsap->lsa_un.un_te_lsa_tlv),
                                       ls_length) == -1) {
                     return(ls_end);
                 }
@@ -983,7 +982,7 @@ static int
 ospf_decode_v2(netdissect_options *ndo,
                const struct ospfhdr *op, const u_char *dataend)
 {
-       const struct in_addr *ap;
+       const nd_ipv4 *ap;
        const struct lsr *lsrp;
        const struct lsa_hdr *lshp;
        const struct lsa *lsap;
@@ -992,49 +991,49 @@ ospf_decode_v2(netdissect_options *ndo,
        switch (EXTRACT_U_1(op->ospf_type)) {
 
        case OSPF_TYPE_HELLO:
-               ND_TCHECK(op->ospf_hello.hello_options);
+               ND_TCHECK_1(op->ospf_hello.hello_options);
                ND_PRINT("\n\tOptions [%s]",
                          bittok2str(ospf_option_values,"none",EXTRACT_U_1(op->ospf_hello.hello_options)));
 
-               ND_TCHECK(op->ospf_hello.hello_deadint);
+               ND_TCHECK_4(op->ospf_hello.hello_deadint);
                ND_PRINT("\n\t  Hello Timer %us, Dead Timer %us, Mask %s, Priority %u",
                          EXTRACT_BE_U_2(op->ospf_hello.hello_helloint),
                          EXTRACT_BE_U_4(op->ospf_hello.hello_deadint),
-                         ipaddr_string(ndo, &op->ospf_hello.hello_mask),
+                         ipaddr_string(ndo, op->ospf_hello.hello_mask),
                          EXTRACT_U_1(op->ospf_hello.hello_priority));
 
-               ND_TCHECK(op->ospf_hello.hello_dr);
-               if (op->ospf_hello.hello_dr.s_addr != 0)
+               ND_TCHECK_4(op->ospf_hello.hello_dr);
+               if (EXTRACT_IPV4_TO_NETWORK_ORDER(op->ospf_hello.hello_dr) != 0)
                        ND_PRINT("\n\t  Designated Router %s",
-                           ipaddr_string(ndo, &op->ospf_hello.hello_dr));
+                           ipaddr_string(ndo, op->ospf_hello.hello_dr));
 
-               ND_TCHECK(op->ospf_hello.hello_bdr);
-               if (op->ospf_hello.hello_bdr.s_addr != 0)
+               ND_TCHECK_4(op->ospf_hello.hello_bdr);
+               if (EXTRACT_IPV4_TO_NETWORK_ORDER(op->ospf_hello.hello_bdr) != 0)
                        ND_PRINT(", Backup Designated Router %s",
-                                 ipaddr_string(ndo, &op->ospf_hello.hello_bdr));
+                                 ipaddr_string(ndo, op->ospf_hello.hello_bdr));
 
                ap = op->ospf_hello.hello_neighbor;
                if ((const u_char *)ap < dataend)
                        ND_PRINT("\n\t  Neighbor List:");
                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;
                }
                break;  /* HELLO */
 
        case OSPF_TYPE_DD:
-               ND_TCHECK(op->ospf_db.db_options);
+               ND_TCHECK_1(op->ospf_db.db_options);
                ND_PRINT("\n\tOptions [%s]",
                          bittok2str(ospf_option_values, "none", EXTRACT_U_1(op->ospf_db.db_options)));
-               ND_TCHECK(op->ospf_db.db_flags);
+               ND_TCHECK_1(op->ospf_db.db_flags);
                ND_PRINT(", DD Flags [%s]",
                          bittok2str(ospf_dd_flag_values, "none", EXTRACT_U_1(op->ospf_db.db_flags)));
-               ND_TCHECK(op->ospf_db.db_ifmtu);
+               ND_TCHECK_2(op->ospf_db.db_ifmtu);
                if (EXTRACT_BE_U_2(op->ospf_db.db_ifmtu)) {
                        ND_PRINT(", MTU: %u", EXTRACT_BE_U_2(op->ospf_db.db_ifmtu));
                }
-               ND_TCHECK(op->ospf_db.db_seq);
+               ND_TCHECK_4(op->ospf_db.db_seq);
                ND_PRINT(", Sequence: 0x%08x", EXTRACT_BE_U_4(op->ospf_db.db_seq));
 
                /* Print all the LS adv's */
@@ -1050,7 +1049,7 @@ ospf_decode_v2(netdissect_options *ndo,
                     ND_TCHECK_SIZE(lsrp);
 
                     ND_PRINT("\n\t  Advertising Router: %s, %s LSA (%u)",
-                           ipaddr_string(ndo, &lsrp->ls_router),
+                           ipaddr_string(ndo, lsrp->ls_router),
                            tok2str(lsa_values,"unknown",EXTRACT_BE_U_4(lsrp->ls_type)),
                            EXTRACT_BE_U_4(lsrp->ls_type));
 
@@ -1066,7 +1065,7 @@ ospf_decode_v2(netdissect_options *ndo,
                         break;
                     default:
                         ND_PRINT(", LSA-ID: %s",
-                               ipaddr_string(ndo, &lsrp->un_ls_stateid.ls_stateid));
+                               ipaddr_string(ndo, lsrp->un_ls_stateid.ls_stateid));
                         break;
                     }
 
@@ -1076,9 +1075,9 @@ ospf_decode_v2(netdissect_options *ndo,
 
        case OSPF_TYPE_LS_UPDATE:
                 lsap = op->ospf_lsu.lsu_lsa;
-                ND_TCHECK(op->ospf_lsu.lsu_count);
+                ND_TCHECK_4(op->ospf_lsu.lsu_count);
                 lsa_count_max = EXTRACT_BE_U_4(op->ospf_lsu.lsu_count);
-                ND_PRINT(", %d LSA%s", lsa_count_max, PLURAL_SUFFIX(lsa_count_max));
+                ND_PRINT(", %u LSA%s", lsa_count_max, PLURAL_SUFFIX(lsa_count_max));
                 for (lsa_count=1;lsa_count <= lsa_count_max;lsa_count++) {
                     ND_PRINT("\n\t  LSA #%u", lsa_count);
                         lsap = (const struct lsa *)ospf_print_lsa(ndo, lsap);
@@ -1111,10 +1110,11 @@ ospf_print(netdissect_options *ndo,
        const u_char *dataend;
        const char *cp;
 
+       ndo->ndo_protocol = "ospf2";
        op = (const struct ospfhdr *)bp;
 
        /* XXX Before we do anything else, strip off the MD5 trailer */
-       ND_TCHECK(op->ospf_authtype);
+       ND_TCHECK_2(op->ospf_authtype);
        if (EXTRACT_BE_U_2(op->ospf_authtype) == OSPF_AUTH_MD5) {
                length -= OSPF_AUTH_MD5_LEN;
                ndo->ndo_snapend -= OSPF_AUTH_MD5_LEN;
@@ -1122,7 +1122,7 @@ ospf_print(netdissect_options *ndo,
 
        /* If the type is valid translate it, or just print the type */
        /* value.  If it's not valid, say so and return */
-       ND_TCHECK(op->ospf_type);
+       ND_TCHECK_1(op->ospf_type);
        cp = tok2str(type2str, "unknown LS-type %u", EXTRACT_U_1(op->ospf_type));
        ND_PRINT("OSPFv%u, %s, length %u", EXTRACT_U_1(op->ospf_version), cp, length);
        if (*cp == 'u')
@@ -1132,9 +1132,9 @@ ospf_print(netdissect_options *ndo,
                return;
        }
 
-       ND_TCHECK(op->ospf_len);
+       ND_TCHECK_2(op->ospf_len);
        if (length != EXTRACT_BE_U_2(op->ospf_len)) {
-               ND_PRINT(" [len %d]", EXTRACT_BE_U_2(op->ospf_len));
+               ND_PRINT(" [len %u]", EXTRACT_BE_U_2(op->ospf_len));
        }
 
        if (length > EXTRACT_BE_U_2(op->ospf_len)) {
@@ -1143,12 +1143,12 @@ ospf_print(netdissect_options *ndo,
                dataend = bp + length;
        }
 
-       ND_TCHECK(op->ospf_routerid);
-       ND_PRINT("\n\tRouter-ID %s", ipaddr_string(ndo, &op->ospf_routerid));
+       ND_TCHECK_4(op->ospf_routerid);
+       ND_PRINT("\n\tRouter-ID %s", ipaddr_string(ndo, op->ospf_routerid));
 
-       ND_TCHECK(op->ospf_areaid);
-       if (op->ospf_areaid.s_addr != 0)
-               ND_PRINT(", Area %s", ipaddr_string(ndo, &op->ospf_areaid));
+       ND_TCHECK_4(op->ospf_areaid);
+       if (EXTRACT_IPV4_TO_NETWORK_ORDER(op->ospf_areaid) != 0)
+               ND_PRINT(", Area %s", ipaddr_string(ndo, op->ospf_areaid));
        else
                ND_PRINT(", Backbone Area");
 
@@ -1167,7 +1167,7 @@ ospf_print(netdissect_options *ndo,
 
                case OSPF_AUTH_SIMPLE:
                        ND_PRINT("\n\tSimple text password: ");
-                       safeputs(ndo, op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN);
+                       (void)nd_printzp(ndo, op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN, NULL);
                        break;
 
                case OSPF_AUTH_MD5:
@@ -1201,5 +1201,5 @@ ospf_print(netdissect_options *ndo,
 
        return;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
 }