]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Use nd_ types for OSPF and OSPF6 packets.
authorGuy Harris <[email protected]>
Thu, 14 Dec 2017 18:28:57 +0000 (10:28 -0800)
committerGuy Harris <[email protected]>
Thu, 14 Dec 2017 18:28:57 +0000 (10:28 -0800)
And add EXTRACT_ calls as required.

Remove no-longer-necessary & operators in EXTRACT_ calls.

ospf.h
print-ospf.c
print-ospf6.c

diff --git a/ospf.h b/ospf.h
index 9d0b4c46ba7572222673d559b46d8ec30a36f68b..4dca0af38b1951136655e5c1d169d21b144e64b8 100644 (file)
--- a/ospf.h
+++ b/ospf.h
  * TOS metric struct (will be 0 or more in router links update)
  */
 struct tos_metric {
-    uint8_t tos_type;
-    uint8_t reserved;
-    uint8_t tos_metric[2];
+    nd_uint8_t  tos_type;
+    nd_uint8_t  reserved;
+    nd_uint16_t tos_metric;
 };
 struct tos_link {
-    uint8_t link_type;
-    uint8_t link_tos_count;
-    uint8_t tos_metric[2];
+    nd_uint8_t  link_type;
+    nd_uint8_t  link_tos_count;
+    nd_uint16_t tos_metric;
 };
 union un_tos {
     struct tos_link link;
@@ -163,20 +163,20 @@ union un_tos {
 
 /* link state advertisement header */
 struct lsa_hdr {
-    uint16_t ls_age;
-    uint8_t ls_options;
-    uint8_t ls_type;
+    nd_uint16_t ls_age;
+    nd_uint8_t  ls_options;
+    nd_uint8_t  ls_type;
     union {
         struct in_addr lsa_id;
         struct { /* opaque LSAs change the LSA-ID field */
-            uint8_t opaque_type;
-            uint8_t opaque_id[3];
+            nd_uint8_t  opaque_type;
+            nd_uint24_t opaque_id;
        } opaque_field;
     } un_lsa_id;
     struct in_addr ls_router;
-    uint32_t ls_seq;
-    uint16_t ls_chksum;
-    uint16_t ls_length;
+    nd_uint32_t ls_seq;
+    nd_uint16_t ls_chksum;
+    nd_uint16_t ls_length;
 };
 
 /* link state advertisement */
@@ -187,9 +187,9 @@ struct lsa {
     union {
        /* Router links advertisements */
        struct {
-           uint8_t rla_flags;
-           uint8_t rla_zero[1];
-           uint16_t rla_count;
+           nd_uint8_t  rla_flags;
+           nd_byte     rla_zero;
+           nd_uint16_t rla_count;
            struct rlalink {
                struct in_addr link_id;
                struct in_addr link_data;
@@ -206,14 +206,14 @@ struct lsa {
        /* Summary links advertisements */
        struct {
            struct in_addr sla_mask;
-           uint32_t sla_tosmetric[1];  /* may repeat   */
+           nd_uint32_t sla_tosmetric[1];       /* may repeat   */
        } un_sla;
 
        /* AS external links advertisements */
        struct {
            struct in_addr asla_mask;
            struct aslametric {
-               uint32_t asla_tosmetric;
+               nd_uint32_t asla_tosmetric;
                struct in_addr asla_forward;
                struct in_addr asla_tag;
            } asla_metric[1];           /* may repeat   */
@@ -221,34 +221,34 @@ struct lsa {
 
        /* Multicast group membership */
        struct mcla {
-           uint32_t mcla_vtype;
+           nd_uint32_t mcla_vtype;
            struct in_addr mcla_vid;
        } un_mcla[1];
 
         /* Opaque TE LSA */
         struct {
-           uint16_t type;
-           uint16_t length;
-           uint8_t data[1]; /* may repeat   */
+           nd_uint16_t type;
+           nd_uint16_t length;
+           nd_byte     data[1]; /* may repeat   */
        } un_te_lsa_tlv;
 
         /* Opaque Grace LSA */
         struct {
-           uint16_t type;
-           uint16_t length;
-           uint8_t data[1]; /* may repeat   */
+           nd_uint16_t type;
+           nd_uint16_t length;
+           nd_byte     data[1]; /* may repeat   */
        } un_grace_tlv;
 
         /* Opaque Router information LSA */
         struct {
-           uint16_t type;
-           uint16_t length;
-           uint8_t data[1]; /* may repeat   */
+           nd_uint16_t type;
+           nd_uint16_t length;
+           nd_byte     data[1]; /* may repeat   */
        } un_ri_tlv;
 
         /* Unknown LSA */
         struct unknown {
-           uint8_t data[1]; /* may repeat   */
+           nd_byte data[1]; /* may repeat   */
        } un_unknown[1];
 
     } lsa_un;
@@ -260,23 +260,23 @@ struct lsa {
  * the main header
  */
 struct ospfhdr {
-    uint8_t ospf_version;
-    uint8_t ospf_type;
-    uint16_t ospf_len;
+    nd_uint8_t  ospf_version;
+    nd_uint8_t  ospf_type;
+    nd_uint16_t ospf_len;
     struct in_addr ospf_routerid;
     struct in_addr ospf_areaid;
-    uint16_t ospf_chksum;
-    uint16_t ospf_authtype;
-    uint8_t ospf_authdata[OSPF_AUTH_SIZE];
+    nd_uint16_t ospf_chksum;
+    nd_uint16_t ospf_authtype;
+    nd_byte     ospf_authdata[OSPF_AUTH_SIZE];
     union {
 
        /* Hello packet */
        struct {
            struct in_addr hello_mask;
-           uint16_t hello_helloint;
-           uint8_t hello_options;
-           uint8_t hello_priority;
-           uint32_t hello_deadint;
+           nd_uint16_t hello_helloint;
+           nd_uint8_t  hello_options;
+           nd_uint8_t  hello_priority;
+           nd_uint32_t hello_deadint;
            struct in_addr hello_dr;
            struct in_addr hello_bdr;
            struct in_addr hello_neighbor[1]; /* may repeat     */
@@ -284,21 +284,21 @@ struct ospfhdr {
 
        /* Database Description packet */
        struct {
-           uint16_t db_ifmtu;
-           uint8_t db_options;
-           uint8_t db_flags;
-           uint32_t db_seq;
+           nd_uint16_t db_ifmtu;
+           nd_uint8_t  db_options;
+           nd_uint8_t  db_flags;
+           nd_uint32_t db_seq;
            struct lsa_hdr db_lshdr[1]; /* may repeat   */
        } un_db;
 
        /* Link State Request */
        struct lsr {
-           uint8_t ls_type[4];
+           nd_uint32_t ls_type;
             union {
                 struct in_addr ls_stateid;
                 struct { /* opaque LSAs change the LSA-ID field */
-                    uint8_t opaque_type;
-                    uint8_t opaque_id[3];
+                    nd_uint8_t  opaque_type;
+                    nd_uint24_t opaque_id;
                 } opaque_field;
             } un_ls_stateid;
            struct in_addr ls_router;
@@ -306,8 +306,8 @@ struct ospfhdr {
 
        /* Link State Update */
        struct {
-           uint32_t lsu_count;
-           struct lsa lsu_lsa[1]; /* may repeat        */
+           nd_uint32_t lsu_count;
+           struct lsa  lsu_lsa[1]; /* may repeat       */
        } un_lsu;
 
        /* Link State Acknowledgement */
index 025d97e1c13af580e4a25d6af92342f3a017e5b1..9b8d7dd664f5756f40af3219cf75f340ac62e168 100644 (file)
@@ -512,10 +512,11 @@ static int
 ospf_print_lshdr(netdissect_options *ndo,
                  const struct lsa_hdr *lshp)
 {
+        u_int ls_type;
         u_int ls_length;
 
         ND_TCHECK(lshp->ls_length);
-        ls_length = EXTRACT_BE_U_2(&lshp->ls_length);
+        ls_length = EXTRACT_BE_U_2(lshp->ls_length);
         if (ls_length < sizeof(struct lsa_hdr)) {
                 ND_PRINT((ndo, "\n\t    Bogus length %u < header (%lu)", ls_length,
                     (unsigned long)sizeof(struct lsa_hdr)));
@@ -525,25 +526,26 @@ ospf_print_lshdr(netdissect_options *ndo,
         ND_TCHECK(lshp->ls_seq); /* XXX - ls_length check checked this */
         ND_PRINT((ndo, "\n\t  Advertising Router %s, seq 0x%08x, age %us, length %u",
                   ipaddr_string(ndo, &lshp->ls_router),
-                  EXTRACT_BE_U_4(&lshp->ls_seq),
-                  EXTRACT_BE_U_2(&lshp->ls_age),
+                  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 */
-        switch (lshp->ls_type) {
+        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((ndo, "\n\t    %s LSA (%d), Opaque-Type %s LSA (%u), Opaque-ID %u",
-                   tok2str(lsa_values,"unknown",lshp->ls_type),
-                   lshp->ls_type,
+                   tok2str(lsa_values,"unknown",ls_type),
+                   ls_type,
 
                   tok2str(lsa_opaque_values,
                           "unknown",
-                          *(&lshp->un_lsa_id.opaque_field.opaque_type)),
-                  *(&lshp->un_lsa_id.opaque_field.opaque_type),
-                  EXTRACT_BE_U_3(&lshp->un_lsa_id.opaque_field.opaque_id)
+                          EXTRACT_U_1(lshp->un_lsa_id.opaque_field.opaque_type)),
+                  EXTRACT_U_1(lshp->un_lsa_id.opaque_field.opaque_type),
+                  EXTRACT_BE_U_3(lshp->un_lsa_id.opaque_field.opaque_id)
 
                    ));
             break;
@@ -551,14 +553,14 @@ ospf_print_lshdr(netdissect_options *ndo,
         /* all other LSA types use regular style LSA headers */
         default:
             ND_PRINT((ndo, "\n\t    %s LSA (%d), LSA-ID: %s",
-                   tok2str(lsa_values,"unknown",lshp->ls_type),
-                   lshp->ls_type,
+                   tok2str(lsa_values,"unknown",ls_type),
+                   ls_type,
                    ipaddr_string(ndo, &lshp->un_lsa_id.lsa_id)));
             break;
         }
 
         ND_TCHECK(lshp->ls_options); /* XXX - ls_length check checked this */
-        ND_PRINT((ndo, "\n\t    Options: [%s]", bittok2str(ospf_option_values, "none", lshp->ls_options)));
+        ND_PRINT((ndo, "\n\t    Options: [%s]", bittok2str(ospf_option_values, "none", EXTRACT_U_1(lshp->ls_options))));
 
         return (ls_length);
 trunc:
@@ -580,22 +582,24 @@ static int
 ospf_print_tos_metrics(netdissect_options *ndo,
                        const union un_tos *tos)
 {
-    int metric_count;
-    int toscount;
+    u_int metric_count;
+    u_int toscount;
+    u_int tos_type;
 
-    toscount = tos->link.link_tos_count+1;
+    toscount = EXTRACT_U_1(tos->link.link_tos_count)+1;
     metric_count = 0;
 
     /*
      * All but the first metric contain a valid topology id.
      */
-    while (toscount > 0) {
+    while (toscount != 0) {
         ND_TCHECK(*tos);
+        tos_type = EXTRACT_U_1(tos->metrics.tos_type);
         ND_PRINT((ndo, "\n\t\ttopology %s (%u), metric %u",
                tok2str(ospf_topology_values, "Unknown",
-                       metric_count ? tos->metrics.tos_type : 0),
-               metric_count ? tos->metrics.tos_type : 0,
-               EXTRACT_BE_U_2(&tos->metrics.tos_metric)));
+                       metric_count ? tos_type : 0),
+               metric_count ? tos_type : 0,
+               EXTRACT_BE_U_2(tos->metrics.tos_metric)));
         metric_count++;
         tos++;
         toscount--;
@@ -619,7 +623,7 @@ ospf_print_lsa(netdissect_options *ndo,
        const struct in_addr *ap;
        const struct aslametric *almp;
        const struct mcla *mcp;
-       const uint32_t *lp;
+       const uint8_t *lp;
        int j, tlv_type, tlv_length, topology;
        int ls_length;
        const uint8_t *tptr;
@@ -631,20 +635,20 @@ ospf_print_lsa(netdissect_options *ndo,
        ls_end = (const uint8_t *)lsap + ls_length;
        ls_length -= sizeof(struct lsa_hdr);
 
-       switch (lsap->ls_hdr.ls_type) {
+       switch (EXTRACT_U_1(lsap->ls_hdr.ls_type)) {
 
        case LS_TYPE_ROUTER:
                ND_TCHECK(lsap->lsa_un.un_rla.rla_flags);
                ND_PRINT((ndo, "\n\t    Router LSA Options: [%s]",
-                         bittok2str(ospf_rla_flag_values, "none", lsap->lsa_un.un_rla.rla_flags)));
+                         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);
-               j = EXTRACT_BE_U_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);
                rlp = lsap->lsa_un.un_rla.rla_link;
                while (j--) {
                        ND_TCHECK(*rlp);
-                       switch (rlp->un_tos.link.link_type) {
+                       switch (EXTRACT_U_1(rlp->un_tos.link.link_type)) {
 
                        case RLA_TYPE_VIRTUAL:
                                ND_PRINT((ndo, "\n\t      Virtual Link: Neighbor Router-ID: %s, Interface Address: %s",
@@ -672,7 +676,7 @@ ospf_print_lsa(netdissect_options *ndo,
 
                        default:
                                ND_PRINT((ndo, "\n\t      Unknown Router Link Type (%u)",
-                                   rlp->un_tos.link.link_type));
+                                   EXTRACT_U_1(rlp->un_tos.link.link_type)));
                                return (ls_end);
                        }
 
@@ -680,7 +684,7 @@ ospf_print_lsa(netdissect_options *ndo,
                                goto trunc;
 
                        rlp = (const struct rlalink *)((const u_char *)(rlp + 1) +
-                           ((rlp->un_tos.link.link_tos_count) * sizeof(union un_tos)));
+                           (EXTRACT_U_1(rlp->un_tos.link.link_tos_count) * sizeof(union un_tos)));
                }
                break;
 
@@ -701,8 +705,8 @@ ospf_print_lsa(netdissect_options *ndo,
                ND_PRINT((ndo, "\n\t    Mask %s",
                    ipaddr_string(ndo, &lsap->lsa_un.un_sla.sla_mask)));
                ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
-               lp = lsap->lsa_un.un_sla.sla_tosmetric;
-               while ((const u_char *)lp < ls_end) {
+               lp = (const uint8_t *)lsap->lsa_un.un_sla.sla_tosmetric;
+               while (lp < ls_end) {
                        uint32_t ul;
 
                        ND_TCHECK(*lp);
@@ -712,14 +716,14 @@ ospf_print_lsa(netdissect_options *ndo,
                                tok2str(ospf_topology_values, "Unknown", topology),
                                topology,
                                ul & SLA_MASK_METRIC));
-                       ++lp;
+                       lp += 4;
                }
                break;
 
        case LS_TYPE_SUM_ABR:
                ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
-               lp = lsap->lsa_un.un_sla.sla_tosmetric;
-               while ((const u_char *)lp < ls_end) {
+               lp = (const uint8_t *)lsap->lsa_un.un_sla.sla_tosmetric;
+               while (lp < ls_end) {
                        uint32_t ul;
 
                        ND_TCHECK(*lp);
@@ -729,7 +733,7 @@ ospf_print_lsa(netdissect_options *ndo,
                                tok2str(ospf_topology_values, "Unknown", topology),
                                topology,
                                ul & SLA_MASK_METRIC));
-                       ++lp;
+                       lp += 4;
                }
                break;
 
@@ -745,7 +749,7 @@ ospf_print_lsa(netdissect_options *ndo,
                        uint32_t ul;
 
                        ND_TCHECK(almp->asla_tosmetric);
-                       ul = EXTRACT_BE_U_4(&almp->asla_tosmetric);
+                       ul = EXTRACT_BE_U_4(almp->asla_tosmetric);
                         topology = ((ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS);
                        ND_PRINT((ndo, "\n\t\ttopology %s (%u), type %d, metric",
                                tok2str(ospf_topology_values, "Unknown", topology),
@@ -773,7 +777,7 @@ ospf_print_lsa(netdissect_options *ndo,
                mcp = lsap->lsa_un.un_mcla;
                while ((const u_char *)mcp < ls_end) {
                        ND_TCHECK(mcp->mcla_vid);
-                       switch (EXTRACT_BE_U_4(&mcp->mcla_vtype)) {
+                       switch (EXTRACT_BE_U_4(mcp->mcla_vtype)) {
 
                        case MCLA_VERTEX_ROUTER:
                                ND_PRINT((ndo, "\n\t    Router Router-ID %s",
@@ -787,7 +791,7 @@ ospf_print_lsa(netdissect_options *ndo,
 
                        default:
                                ND_PRINT((ndo, "\n\t    unknown VertexType (%u)",
-                                   EXTRACT_BE_U_4(&mcp->mcla_vtype)));
+                                   EXTRACT_BE_U_4(mcp->mcla_vtype)));
                                break;
                        }
                ++mcp;
@@ -798,7 +802,7 @@ ospf_print_lsa(netdissect_options *ndo,
        case LS_TYPE_OPAQUE_AL:
        case LS_TYPE_OPAQUE_DW:
 
-           switch (*(&lsap->ls_hdr.un_lsa_id.opaque_field.opaque_type)) {
+           switch (EXTRACT_U_1(lsap->ls_hdr.un_lsa_id.opaque_field.opaque_type)) {
             case LS_OPAQUE_TYPE_RI:
                tptr = (const uint8_t *)(&lsap->lsa_un.un_ri_tlv.type);
 
@@ -893,15 +897,15 @@ ospf_decode_lls(netdissect_options *ndo,
     uint16_t lls_type, lls_len;
     uint32_t lls_flags;
 
-    switch (op->ospf_type) {
+    switch (EXTRACT_U_1(op->ospf_type)) {
 
     case OSPF_TYPE_HELLO:
-        if (!(op->ospf_hello.hello_options & OSPF_OPTION_L))
+        if (!(EXTRACT_U_1(op->ospf_hello.hello_options) & OSPF_OPTION_L))
             return (0);
         break;
 
     case OSPF_TYPE_DD:
-        if (!(op->ospf_db.db_options & OSPF_OPTION_L))
+        if (!(EXTRACT_U_1(op->ospf_db.db_options) & OSPF_OPTION_L))
             return (0);
         break;
 
@@ -910,11 +914,11 @@ ospf_decode_lls(netdissect_options *ndo,
     }
 
     /* dig deeper if LLS data is available; see RFC4813 */
-    length2 = EXTRACT_BE_U_2(&op->ospf_len);
+    length2 = EXTRACT_BE_U_2(op->ospf_len);
     dptr = (const u_char *)op + length2;
     dataend = (const u_char *)op + length;
 
-    if (EXTRACT_BE_U_2(&op->ospf_authtype) == OSPF_AUTH_MD5) {
+    if (EXTRACT_BE_U_2(op->ospf_authtype) == OSPF_AUTH_MD5) {
         dptr = dptr + op->ospf_authdata[3];
         length2 += op->ospf_authdata[3];
     }
@@ -985,19 +989,19 @@ ospf_decode_v2(netdissect_options *ndo,
        const struct lsa *lsap;
        uint32_t lsa_count,lsa_count_max;
 
-       switch (op->ospf_type) {
+       switch (EXTRACT_U_1(op->ospf_type)) {
 
        case OSPF_TYPE_HELLO:
                ND_TCHECK(op->ospf_hello.hello_options);
                ND_PRINT((ndo, "\n\tOptions [%s]",
-                         bittok2str(ospf_option_values,"none",op->ospf_hello.hello_options)));
+                         bittok2str(ospf_option_values,"none",EXTRACT_U_1(op->ospf_hello.hello_options))));
 
                ND_TCHECK(op->ospf_hello.hello_deadint);
                ND_PRINT((ndo, "\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),
+                         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),
-                         op->ospf_hello.hello_priority));
+                         EXTRACT_U_1(op->ospf_hello.hello_priority)));
 
                ND_TCHECK(op->ospf_hello.hello_dr);
                if (op->ospf_hello.hello_dr.s_addr != 0)
@@ -1022,16 +1026,16 @@ ospf_decode_v2(netdissect_options *ndo,
        case OSPF_TYPE_DD:
                ND_TCHECK(op->ospf_db.db_options);
                ND_PRINT((ndo, "\n\tOptions [%s]",
-                         bittok2str(ospf_option_values, "none", op->ospf_db.db_options)));
+                         bittok2str(ospf_option_values, "none", EXTRACT_U_1(op->ospf_db.db_options))));
                ND_TCHECK(op->ospf_db.db_flags);
                ND_PRINT((ndo, ", DD Flags [%s]",
-                         bittok2str(ospf_dd_flag_values, "none", op->ospf_db.db_flags)));
+                         bittok2str(ospf_dd_flag_values, "none", EXTRACT_U_1(op->ospf_db.db_flags))));
                ND_TCHECK(op->ospf_db.db_ifmtu);
-               if (op->ospf_db.db_ifmtu) {
-                       ND_PRINT((ndo, ", MTU: %u", EXTRACT_BE_U_2(&op->ospf_db.db_ifmtu)));
+               if (EXTRACT_BE_U_2(op->ospf_db.db_ifmtu)) {
+                       ND_PRINT((ndo, ", MTU: %u", EXTRACT_BE_U_2(op->ospf_db.db_ifmtu)));
                }
                ND_TCHECK(op->ospf_db.db_seq);
-               ND_PRINT((ndo, ", Sequence: 0x%08x", EXTRACT_BE_U_4(&op->ospf_db.db_seq)));
+               ND_PRINT((ndo, ", Sequence: 0x%08x", EXTRACT_BE_U_4(op->ospf_db.db_seq)));
 
                /* Print all the LS adv's */
                lshp = op->ospf_db.db_lshdr;
@@ -1048,7 +1052,7 @@ ospf_decode_v2(netdissect_options *ndo,
                     ND_PRINT((ndo, "\n\t  Advertising Router: %s, %s LSA (%u)",
                            ipaddr_string(ndo, &lsrp->ls_router),
                            tok2str(lsa_values,"unknown",EXTRACT_BE_U_4(lsrp->ls_type)),
-                           EXTRACT_BE_U_4(&lsrp->ls_type)));
+                           EXTRACT_BE_U_4(lsrp->ls_type)));
 
                     switch (EXTRACT_BE_U_4(lsrp->ls_type)) {
                         /* the LSA header for opaque LSAs was slightly changed */
@@ -1056,9 +1060,9 @@ ospf_decode_v2(netdissect_options *ndo,
                     case LS_TYPE_OPAQUE_AL:
                     case LS_TYPE_OPAQUE_DW:
                         ND_PRINT((ndo, ", Opaque-Type: %s LSA (%u), Opaque-ID: %u",
-                               tok2str(lsa_opaque_values, "unknown",lsrp->un_ls_stateid.opaque_field.opaque_type),
-                               lsrp->un_ls_stateid.opaque_field.opaque_type,
-                               EXTRACT_BE_U_3(&lsrp->un_ls_stateid.opaque_field.opaque_id)));
+                               tok2str(lsa_opaque_values, "unknown",EXTRACT_U_1(lsrp->un_ls_stateid.opaque_field.opaque_type)),
+                               EXTRACT_U_1(lsrp->un_ls_stateid.opaque_field.opaque_type),
+                               EXTRACT_BE_U_3(lsrp->un_ls_stateid.opaque_field.opaque_id)));
                         break;
                     default:
                         ND_PRINT((ndo, ", LSA-ID: %s",
@@ -1073,7 +1077,7 @@ ospf_decode_v2(netdissect_options *ndo,
        case OSPF_TYPE_LS_UPDATE:
                 lsap = op->ospf_lsu.lsu_lsa;
                 ND_TCHECK(op->ospf_lsu.lsu_count);
-                lsa_count_max = EXTRACT_BE_U_4(&op->ospf_lsu.lsu_count);
+                lsa_count_max = EXTRACT_BE_U_4(op->ospf_lsu.lsu_count);
                 ND_PRINT((ndo, ", %d LSA%s", lsa_count_max, PLURAL_SUFFIX(lsa_count_max)));
                 for (lsa_count=1;lsa_count <= lsa_count_max;lsa_count++) {
                     ND_PRINT((ndo, "\n\t  LSA #%u", lsa_count));
@@ -1111,7 +1115,7 @@ ospf_print(netdissect_options *ndo,
 
        /* XXX Before we do anything else, strip off the MD5 trailer */
        ND_TCHECK(op->ospf_authtype);
-       if (EXTRACT_BE_U_2(&op->ospf_authtype) == OSPF_AUTH_MD5) {
+       if (EXTRACT_BE_U_2(op->ospf_authtype) == OSPF_AUTH_MD5) {
                length -= OSPF_AUTH_MD5_LEN;
                ndo->ndo_snapend -= OSPF_AUTH_MD5_LEN;
        }
@@ -1119,8 +1123,8 @@ 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);
-       cp = tok2str(type2str, "unknown LS-type %u", op->ospf_type);
-       ND_PRINT((ndo, "OSPFv%u, %s, length %u", op->ospf_version, cp, length));
+       cp = tok2str(type2str, "unknown LS-type %u", EXTRACT_U_1(op->ospf_type));
+       ND_PRINT((ndo, "OSPFv%u, %s, length %u", EXTRACT_U_1(op->ospf_version), cp, length));
        if (*cp == 'u')
                return;
 
@@ -1129,12 +1133,12 @@ ospf_print(netdissect_options *ndo,
        }
 
        ND_TCHECK(op->ospf_len);
-       if (length != EXTRACT_BE_U_2(&op->ospf_len)) {
-               ND_PRINT((ndo, " [len %d]", EXTRACT_BE_U_2(&op->ospf_len)));
+       if (length != EXTRACT_BE_U_2(op->ospf_len)) {
+               ND_PRINT((ndo, " [len %d]", EXTRACT_BE_U_2(op->ospf_len)));
        }
 
-       if (length > EXTRACT_BE_U_2(&op->ospf_len)) {
-               dataend = bp + EXTRACT_BE_U_2(&op->ospf_len);
+       if (length > EXTRACT_BE_U_2(op->ospf_len)) {
+               dataend = bp + EXTRACT_BE_U_2(op->ospf_len);
        } else {
                dataend = bp + length;
        }
@@ -1153,10 +1157,10 @@ ospf_print(netdissect_options *ndo,
                ND_TCHECK_LEN(op->ospf_authdata, sizeof(op->ospf_authdata));
 
                ND_PRINT((ndo, ", Authentication Type: %s (%u)",
-                         tok2str(ospf_authtype_values, "unknown", EXTRACT_BE_U_2(&op->ospf_authtype)),
-                         EXTRACT_BE_U_2(&op->ospf_authtype)));
+                         tok2str(ospf_authtype_values, "unknown", EXTRACT_BE_U_2(op->ospf_authtype)),
+                         EXTRACT_BE_U_2(op->ospf_authtype)));
 
-               switch (EXTRACT_BE_U_2(&op->ospf_authtype)) {
+               switch (EXTRACT_BE_U_2(op->ospf_authtype)) {
 
                case OSPF_AUTH_NONE:
                        break;
@@ -1178,20 +1182,20 @@ ospf_print(netdissect_options *ndo,
                }
        }
        /* Do rest according to version.         */
-       switch (op->ospf_version) {
+       switch (EXTRACT_U_1(op->ospf_version)) {
 
        case 2:
                /* ospf version 2 */
                if (ospf_decode_v2(ndo, op, dataend))
                        goto trunc;
-               if (length > EXTRACT_BE_U_2(&op->ospf_len)) {
+               if (length > EXTRACT_BE_U_2(op->ospf_len)) {
                        if (ospf_decode_lls(ndo, op, length))
                                goto trunc;
                }
                break;
 
        default:
-               ND_PRINT((ndo, " ospf [version %d]", op->ospf_version));
+               ND_PRINT((ndo, " ospf [version %u]", EXTRACT_U_1(op->ospf_version)));
                break;
        }                       /* end switch on version */
 
index e38c455708195f3048a0a653fccec13873d06829..58958c2e2d0f098afb1c265e235b414ad5f2c4b4 100644 (file)
 #define OSPF6_AT_HDRLEN             16U
 #define OSPF6_AUTH_TYPE_HMAC        0x0001
 
-typedef uint32_t rtrid_t;
+typedef nd_uint32_t rtrid_t;
 
 /* link state advertisement header */
 struct lsa6_hdr {
-    uint16_t ls_age;
-    uint16_t ls_type;
+    nd_uint16_t ls_age;
+    nd_uint16_t ls_type;
     rtrid_t ls_stateid;
     rtrid_t ls_router;
-    uint32_t ls_seq;
-    uint16_t ls_chksum;
-    uint16_t ls_length;
+    nd_uint32_t ls_seq;
+    nd_uint16_t ls_chksum;
+    nd_uint16_t ls_length;
 };
 
 /* Length of an IPv6 address, in bytes. */
 #define IPV6_ADDR_LEN_BYTES (128/8)
 
 struct lsa6_prefix {
-    uint8_t lsa_p_len;
-    uint8_t lsa_p_opt;
-    uint16_t lsa_p_metric;
-    uint8_t lsa_p_prefix[IPV6_ADDR_LEN_BYTES]; /* maximum length */
+    nd_uint8_t lsa_p_len;
+    nd_uint8_t lsa_p_opt;
+    nd_uint16_t lsa_p_metric;
+    nd_byte lsa_p_prefix[IPV6_ADDR_LEN_BYTES]; /* maximum length */
 };
 
 /* link state advertisement */
@@ -150,36 +150,36 @@ struct lsa6 {
        /* Router links advertisements */
        struct {
            union {
-               uint8_t flg;
-               uint32_t opt;
+               nd_uint8_t flg;
+               nd_uint32_t opt;
            } rla_flgandopt;
 #define rla_flags      rla_flgandopt.flg
 #define rla_options    rla_flgandopt.opt
            struct rlalink6 {
-               uint8_t link_type;
-               uint8_t link_zero[1];
-               uint16_t link_metric;
-               uint32_t link_ifid;
-               uint32_t link_nifid;
+               nd_uint8_t link_type;
+               nd_byte link_zero;
+               nd_uint16_t link_metric;
+               nd_uint32_t link_ifid;
+               nd_uint32_t link_nifid;
                rtrid_t link_nrtid;
            } rla_link[1];              /* may repeat   */
        } un_rla;
 
        /* Network links advertisements */
        struct {
-           uint32_t nla_options;
+           nd_uint32_t nla_options;
            rtrid_t nla_router[1];      /* may repeat   */
        } un_nla;
 
        /* Inter Area Prefix LSA */
        struct {
-           uint32_t inter_ap_metric;
+           nd_uint32_t inter_ap_metric;
            struct lsa6_prefix inter_ap_prefix[1];
        } un_inter_ap;
 
        /* AS external links advertisements */
        struct {
-           uint32_t asla_metric;
+           nd_uint32_t asla_metric;
            struct lsa6_prefix asla_prefix[1];
            /* some optional fields follow */
        } un_asla;
@@ -188,12 +188,12 @@ struct lsa6 {
        /* Summary links advertisements */
        struct {
            struct in_addr sla_mask;
-           uint32_t sla_tosmetric[1];  /* may repeat   */
+           nd_uint32_t sla_tosmetric[1];       /* may repeat   */
        } un_sla;
 
        /* Multicast group membership */
        struct mcla {
-           uint32_t mcla_vtype;
+           nd_uint32_t mcla_vtype;
            struct in_addr mcla_vid;
        } un_mcla[1];
 #endif
@@ -203,20 +203,20 @@ struct lsa6 {
        /* Link LSA */
        struct llsa {
            union {
-               uint8_t pri;
-               uint32_t opt;
+               nd_uint8_t pri;
+               nd_uint32_t opt;
            } llsa_priandopt;
 #define llsa_priority  llsa_priandopt.pri
 #define llsa_options   llsa_priandopt.opt
            struct in6_addr llsa_lladdr;
-           uint32_t llsa_nprefix;
+           nd_uint32_t llsa_nprefix;
            struct lsa6_prefix llsa_prefix[1];
        } un_llsa;
 
        /* Intra-Area-Prefix */
        struct {
-           uint16_t intra_ap_nprefix;
-           uint16_t intra_ap_lstype;
+           nd_uint16_t intra_ap_nprefix;
+           nd_uint16_t intra_ap_lstype;
            rtrid_t intra_ap_lsid;
            rtrid_t intra_ap_rtid;
            struct lsa6_prefix intra_ap_prefix[1];
@@ -228,14 +228,14 @@ struct lsa6 {
  * the main header
  */
 struct ospf6hdr {
-    uint8_t ospf6_version;
-    uint8_t ospf6_type;
-    uint16_t ospf6_len;
+    nd_uint8_t ospf6_version;
+    nd_uint8_t ospf6_type;
+    nd_uint16_t ospf6_len;
     rtrid_t ospf6_routerid;
     rtrid_t ospf6_areaid;
-    uint16_t ospf6_chksum;
-    uint8_t ospf6_instanceid;
-    uint8_t ospf6_rsvd;
+    nd_uint16_t ospf6_chksum;
+    nd_uint8_t ospf6_instanceid;
+    nd_uint8_t ospf6_rsvd;
 };
 
 /*
@@ -246,15 +246,15 @@ struct ospf6hdr {
 
 /* Hello packet */
 struct hello6 {
-    uint32_t hello_ifid;
+    nd_uint32_t hello_ifid;
     union {
-       uint8_t pri;
-       uint32_t opt;
+       nd_uint8_t pri;
+       nd_uint32_t opt;
     } hello_priandopt;
 #define hello_priority hello_priandopt.pri
 #define hello_options  hello_priandopt.opt
-    uint16_t hello_helloint;
-    uint16_t hello_deadint;
+    nd_uint16_t hello_helloint;
+    nd_uint16_t hello_deadint;
     rtrid_t hello_dr;
     rtrid_t hello_bdr;
     rtrid_t hello_neighbor[1]; /* may repeat   */
@@ -262,25 +262,25 @@ struct hello6 {
 
 /* Database Description packet */
 struct dd6 {
-    uint32_t db_options;
-    uint16_t db_mtu;
-    uint8_t db_mbz;
-    uint8_t db_flags;
-    uint32_t db_seq;
+    nd_uint32_t db_options;
+    nd_uint16_t db_mtu;
+    nd_uint8_t db_mbz;
+    nd_uint8_t db_flags;
+    nd_uint32_t db_seq;
     struct lsa6_hdr db_lshdr[1]; /* may repeat */
 };
 
 /* Link State Request */
 struct lsr6 {
-    uint16_t ls_mbz;
-    uint16_t ls_type;
+    nd_uint16_t ls_mbz;
+    nd_uint16_t ls_type;
     rtrid_t ls_stateid;
     rtrid_t ls_router;
 };
 
 /* Link State Update */
 struct lsu6 {
-    uint32_t lsu_count;
+    nd_uint32_t lsu_count;
     struct lsa6 lsu_lsa[1]; /* may repeat      */
 };
 
@@ -394,11 +394,11 @@ ospf6_print_lshdr(netdissect_options *ndo,
 
        ND_PRINT((ndo, "\n\t  Advertising Router %s, seq 0x%08x, age %us, length %u",
                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)));
+               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)));
 
-       ospf6_print_ls_type(ndo, EXTRACT_BE_U_2(&lshp->ls_type),
+       ospf6_print_ls_type(ndo, EXTRACT_BE_U_2(lshp->ls_type),
                            &lshp->ls_stateid);
 
        return (0);
@@ -418,9 +418,9 @@ ospf6_print_lsaprefix(netdissect_options *ndo,
                goto trunc;
        lsa_length -= sizeof (*lsapp) - IPV6_ADDR_LEN_BYTES;
        ND_TCHECK_LEN(lsapp, sizeof(*lsapp) - IPV6_ADDR_LEN_BYTES);
-       wordlen = (lsapp->lsa_p_len + 31) / 32;
+       wordlen = (EXTRACT_U_1(lsapp->lsa_p_len) + 31) / 32;
        if (wordlen * 4 > sizeof(struct in6_addr)) {
-               ND_PRINT((ndo, " bogus prefixlen /%d", lsapp->lsa_p_len));
+               ND_PRINT((ndo, " bogus prefixlen /%u", EXTRACT_U_1(lsapp->lsa_p_len)));
                goto trunc;
        }
        if (lsa_length < wordlen * 4)
@@ -429,14 +429,14 @@ ospf6_print_lsaprefix(netdissect_options *ndo,
        ND_TCHECK2(lsapp->lsa_p_prefix, wordlen * 4);
        memset(&prefix, 0, sizeof(prefix));
        memcpy(&prefix, lsapp->lsa_p_prefix, wordlen * 4);
-       ND_PRINT((ndo, "\n\t\t%s/%d", ip6addr_string(ndo, &prefix),
-               lsapp->lsa_p_len));
-        if (lsapp->lsa_p_opt) {
+       ND_PRINT((ndo, "\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((ndo, ", Options [%s]",
                    bittok2str(ospf6_lsa_prefix_option_values,
-                              "none", lsapp->lsa_p_opt)));
+                              "none", EXTRACT_U_1(lsapp->lsa_p_opt))));
         }
-        ND_PRINT((ndo, ", metric %u", EXTRACT_BE_U_2(&lsapp->lsa_p_metric)));
+        ND_PRINT((ndo, ", metric %u", EXTRACT_BE_U_2(lsapp->lsa_p_metric)));
        return sizeof(*lsapp) - IPV6_ADDR_LEN_BYTES + wordlen * 4;
 
 trunc:
@@ -474,7 +474,7 @@ ospf6_print_lsa(netdissect_options *ndo,
        if (ospf6_print_lshdr(ndo, &lsap->ls_hdr, dataend))
                return (1);
        ND_TCHECK(lsap->ls_hdr.ls_length);
-        length = EXTRACT_BE_U_2(&lsap->ls_hdr.ls_length);
+        length = EXTRACT_BE_U_2(lsap->ls_hdr.ls_length);
 
        /*
         * The LSA length includes the length of the header;
@@ -487,7 +487,7 @@ ospf6_print_lsa(netdissect_options *ndo,
         lsa_length = length - sizeof(struct lsa6_hdr);
         tptr = (const uint8_t *)lsap+sizeof(struct lsa6_hdr);
 
-       switch (EXTRACT_BE_U_2(&lsap->ls_hdr.ls_type)) {
+       switch (EXTRACT_BE_U_2(lsap->ls_hdr.ls_type)) {
        case LS_TYPE_ROUTER | LS_SCOPE_AREA:
                if (lsa_length < sizeof (lsap->lsa_un.un_rla.rla_options))
                        return (1);
@@ -495,10 +495,10 @@ ospf6_print_lsa(netdissect_options *ndo,
                ND_TCHECK(lsap->lsa_un.un_rla.rla_options);
                ND_PRINT((ndo, "\n\t      Options [%s]",
                          bittok2str(ospf6_option_values, "none",
-                         EXTRACT_BE_U_4(&lsap->lsa_un.un_rla.rla_options))));
+                         EXTRACT_BE_U_4(lsap->lsa_un.un_rla.rla_options))));
                ND_PRINT((ndo, ", RLA-Flags [%s]",
                          bittok2str(ospf6_rla_flag_values, "none",
-                         lsap->lsa_un.un_rla.rla_flags)));
+                         EXTRACT_U_1(lsap->lsa_un.un_rla.rla_flags))));
 
                rlp = lsap->lsa_un.un_rla.rla_link;
                while (lsa_length != 0) {
@@ -506,7 +506,7 @@ ospf6_print_lsa(netdissect_options *ndo,
                                return (1);
                        lsa_length -= sizeof (*rlp);
                        ND_TCHECK(*rlp);
-                       switch (rlp->link_type) {
+                       switch (EXTRACT_U_1(rlp->link_type)) {
 
                        case RLA_TYPE_VIRTUAL:
                                ND_PRINT((ndo, "\n\t      Virtual Link: Neighbor Router-ID %s"
@@ -534,10 +534,10 @@ ospf6_print_lsa(netdissect_options *ndo,
 
                        default:
                                ND_PRINT((ndo, "\n\t      Unknown Router Links Type 0x%02x",
-                                   rlp->link_type));
+                                   EXTRACT_U_1(rlp->link_type)));
                                return (0);
                        }
-                       ND_PRINT((ndo, ", metric %d", EXTRACT_BE_U_2(&rlp->link_metric)));
+                       ND_PRINT((ndo, ", metric %d", EXTRACT_BE_U_2(rlp->link_metric)));
                        rlp++;
                }
                break;
@@ -549,7 +549,7 @@ ospf6_print_lsa(netdissect_options *ndo,
                ND_TCHECK(lsap->lsa_un.un_nla.nla_options);
                ND_PRINT((ndo, "\n\t      Options [%s]",
                          bittok2str(ospf6_option_values, "none",
-                         EXTRACT_BE_U_4(&lsap->lsa_un.un_nla.nla_options))));
+                         EXTRACT_BE_U_4(lsap->lsa_un.un_nla.nla_options))));
 
                ND_PRINT((ndo, "\n\t      Connected Routers:"));
                ap = lsap->lsa_un.un_nla.nla_router;
@@ -569,7 +569,7 @@ ospf6_print_lsa(netdissect_options *ndo,
                lsa_length -= sizeof (lsap->lsa_un.un_inter_ap.inter_ap_metric);
                ND_TCHECK(lsap->lsa_un.un_inter_ap.inter_ap_metric);
                ND_PRINT((ndo, ", metric %u",
-                       EXTRACT_BE_U_4(&lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC));
+                       EXTRACT_BE_U_4(lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC));
 
                tptr = (const uint8_t *)lsap->lsa_un.un_inter_ap.inter_ap_prefix;
                while (lsa_length != 0) {
@@ -586,11 +586,11 @@ ospf6_print_lsa(netdissect_options *ndo,
                        return (1);
                lsa_length -= sizeof (lsap->lsa_un.un_asla.asla_metric);
                ND_TCHECK(lsap->lsa_un.un_asla.asla_metric);
-               flags32 = EXTRACT_BE_U_4(&lsap->lsa_un.un_asla.asla_metric);
+               flags32 = EXTRACT_BE_U_4(lsap->lsa_un.un_asla.asla_metric);
                ND_PRINT((ndo, "\n\t     Flags [%s]",
                          bittok2str(ospf6_asla_flag_values, "none", flags32)));
                ND_PRINT((ndo, " metric %u",
-                      EXTRACT_BE_U_4(&lsap->lsa_un.un_asla.asla_metric) &
+                      EXTRACT_BE_U_4(lsap->lsa_un.un_asla.asla_metric) &
                       ASLA_MASK_METRIC));
 
                tptr = (const uint8_t *)lsap->lsa_un.un_asla.asla_prefix;
@@ -624,7 +624,7 @@ ospf6_print_lsa(netdissect_options *ndo,
                        tptr += sizeof(uint32_t);
                }
 
-               if (lsapp->lsa_p_metric) {
+               if (EXTRACT_U_1(lsapp->lsa_p_metric)) {
                        if (lsa_length < sizeof (uint32_t))
                                return (1);
                        lsa_length -= sizeof (uint32_t);
@@ -644,15 +644,15 @@ ospf6_print_lsa(netdissect_options *ndo,
                ND_TCHECK(llsap->llsa_priandopt);
                ND_PRINT((ndo, "\n\t      Options [%s]",
                          bittok2str(ospf6_option_values, "none",
-                         EXTRACT_BE_U_4(&llsap->llsa_options))));
+                         EXTRACT_BE_U_4(llsap->llsa_options))));
 
                if (lsa_length < sizeof (llsap->llsa_lladdr) + sizeof (llsap->llsa_nprefix))
                        return (1);
                lsa_length -= sizeof (llsap->llsa_lladdr) + sizeof (llsap->llsa_nprefix);
                 ND_TCHECK(llsap->llsa_nprefix);
-                prefixes = EXTRACT_BE_U_4(&llsap->llsa_nprefix);
+                prefixes = EXTRACT_BE_U_4(llsap->llsa_nprefix);
                ND_PRINT((ndo, "\n\t      Priority %d, Link-local address %s, Prefixes %d:",
-                       llsap->llsa_priority,
+                       EXTRACT_U_1(llsap->llsa_priority),
                        ip6addr_string(ndo, &llsap->llsa_lladdr),
                        prefixes));
 
@@ -674,14 +674,14 @@ ospf6_print_lsa(netdissect_options *ndo,
                lsa_length -= sizeof (lsap->lsa_un.un_intra_ap.intra_ap_rtid);
                ND_TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_rtid);
                ospf6_print_ls_type(ndo,
-                       EXTRACT_BE_U_2(&lsap->lsa_un.un_intra_ap.intra_ap_lstype),
+                       EXTRACT_BE_U_2(lsap->lsa_un.un_intra_ap.intra_ap_lstype),
                        &lsap->lsa_un.un_intra_ap.intra_ap_lsid);
 
                if (lsa_length < sizeof (lsap->lsa_un.un_intra_ap.intra_ap_nprefix))
                        return (1);
                lsa_length -= sizeof (lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
                ND_TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
-                prefixes = EXTRACT_BE_U_2(&lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
+                prefixes = EXTRACT_BE_U_2(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
                ND_PRINT((ndo, "\n\t      Prefixes %d:", prefixes));
 
                tptr = (const uint8_t *)lsap->lsa_un.un_intra_ap.intra_ap_prefix;
@@ -732,29 +732,29 @@ ospf6_decode_v3(netdissect_options *ndo,
        const struct lsa6 *lsap;
        int i;
 
-       switch (op->ospf6_type) {
+       switch (EXTRACT_U_1(op->ospf6_type)) {
 
        case OSPF_TYPE_HELLO: {
                const struct hello6 *hellop = (const struct hello6 *)((const uint8_t *)op + OSPF6HDR_LEN);
 
-               ND_TCHECK_4(&hellop->hello_options);
+               ND_TCHECK_4(hellop->hello_options);
                ND_PRINT((ndo, "\n\tOptions [%s]",
                          bittok2str(ospf6_option_values, "none",
-                         EXTRACT_BE_U_4(&hellop->hello_options))));
+                         EXTRACT_BE_U_4(hellop->hello_options))));
 
                ND_TCHECK(hellop->hello_deadint);
                ND_PRINT((ndo, "\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),
+                         EXTRACT_BE_U_2(hellop->hello_helloint),
+                         EXTRACT_BE_U_2(hellop->hello_deadint),
                          ipaddr_string(ndo, &hellop->hello_ifid),
-                         hellop->hello_priority));
+                         EXTRACT_U_1(hellop->hello_priority)));
 
                ND_TCHECK(hellop->hello_dr);
-               if (EXTRACT_BE_U_4(&hellop->hello_dr) != 0)
+               if (EXTRACT_BE_U_4(hellop->hello_dr) != 0)
                        ND_PRINT((ndo, "\n\t  Designated Router %s",
                            ipaddr_string(ndo, &hellop->hello_dr)));
                ND_TCHECK(hellop->hello_bdr);
-               if (EXTRACT_BE_U_4(&hellop->hello_bdr) != 0)
+               if (EXTRACT_BE_U_4(hellop->hello_bdr) != 0)
                        ND_PRINT((ndo, ", Backup Designated Router %s",
                            ipaddr_string(ndo, &hellop->hello_bdr)));
                if (ndo->ndo_vflag > 1) {
@@ -775,15 +775,15 @@ ospf6_decode_v3(netdissect_options *ndo,
                ND_TCHECK(ddp->db_options);
                ND_PRINT((ndo, "\n\tOptions [%s]",
                          bittok2str(ospf6_option_values, "none",
-                         EXTRACT_BE_U_4(&ddp->db_options))));
+                         EXTRACT_BE_U_4(ddp->db_options))));
                ND_TCHECK(ddp->db_flags);
                ND_PRINT((ndo, ", DD Flags [%s]",
-                         bittok2str(ospf6_dd_flag_values,"none",ddp->db_flags)));
+                         bittok2str(ospf6_dd_flag_values,"none",EXTRACT_U_1(ddp->db_flags))));
 
                ND_TCHECK(ddp->db_seq);
                ND_PRINT((ndo, ", MTU %u, DD-Sequence 0x%08x",
-                       EXTRACT_BE_U_2(&ddp->db_mtu),
-                       EXTRACT_BE_U_4(&ddp->db_seq)));
+                       EXTRACT_BE_U_2(ddp->db_mtu),
+                       EXTRACT_BE_U_4(ddp->db_seq)));
                if (ndo->ndo_vflag > 1) {
                        /* Print all the LS adv's */
                        lshp = ddp->db_lshdr;
@@ -803,7 +803,7 @@ ospf6_decode_v3(netdissect_options *ndo,
                                ND_PRINT((ndo, "\n\t  Advertising Router %s",
                                          ipaddr_string(ndo, &lsrp->ls_router)));
                                ospf6_print_ls_type(ndo,
-                                                    EXTRACT_BE_U_2(&lsrp->ls_type),
+                                                    EXTRACT_BE_U_2(lsrp->ls_type),
                                                     &lsrp->ls_stateid);
                                ++lsrp;
                        }
@@ -815,13 +815,13 @@ ospf6_decode_v3(netdissect_options *ndo,
                        const struct lsu6 *lsup = (const struct lsu6 *)((const uint8_t *)op + OSPF6HDR_LEN);
 
                        ND_TCHECK(lsup->lsu_count);
-                       i = EXTRACT_BE_U_4(&lsup->lsu_count);
+                       i = EXTRACT_BE_U_4(lsup->lsu_count);
                        lsap = lsup->lsu_lsa;
                        while ((const u_char *)lsap < dataend && i--) {
                                if (ospf6_print_lsa(ndo, lsap, dataend))
                                        goto trunc;
                                lsap = (const struct lsa6 *)((const u_char *)lsap +
-                                   EXTRACT_BE_U_2(&lsap->ls_hdr.ls_length));
+                                   EXTRACT_BE_U_2(lsap->ls_hdr.ls_length));
                        }
                }
                break;
@@ -931,19 +931,21 @@ static int
 ospf6_decode_v3_trailer(netdissect_options *ndo,
                         const struct ospf6hdr *op, const u_char *cp, const unsigned len)
 {
+       uint8_t type;
        int llslen = 0;
        int lls_hello = 0;
        int lls_dd = 0;
 
-       if (op->ospf6_type == OSPF_TYPE_HELLO) {
+       type = EXTRACT_U_1(op->ospf6_type);
+       if (type == OSPF_TYPE_HELLO) {
                const struct hello6 *hellop = (const struct hello6 *)((const uint8_t *)op + OSPF6HDR_LEN);
                ND_TCHECK(hellop->hello_options);
-               if (EXTRACT_BE_U_4(&hellop->hello_options) & OSPF6_OPTION_L)
+               if (EXTRACT_BE_U_4(hellop->hello_options) & OSPF6_OPTION_L)
                        lls_hello = 1;
-       } else if (op->ospf6_type == OSPF_TYPE_DD) {
+       } else if (type == OSPF_TYPE_DD) {
                const struct dd6 *ddp = (const struct dd6 *)((const uint8_t *)op + OSPF6HDR_LEN);
                ND_TCHECK(ddp->db_options);
-               if (EXTRACT_BE_U_4(&ddp->db_options) & OSPF6_OPTION_L)
+               if (EXTRACT_BE_U_4(ddp->db_options) & OSPF6_OPTION_L)
                        lls_dd = 1;
        }
        if ((lls_hello || lls_dd) && (llslen = ospf6_print_lls(ndo, cp, len)) < 0)
@@ -968,8 +970,8 @@ ospf6_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->ospf6_type);
-       cp = tok2str(ospf6_type_values, "unknown packet type (%u)", op->ospf6_type);
-       ND_PRINT((ndo, "OSPFv%u, %s, length %d", op->ospf6_version, cp, length));
+       cp = tok2str(ospf6_type_values, "unknown packet type (%u)", EXTRACT_U_1(op->ospf6_type));
+       ND_PRINT((ndo, "OSPFv%u, %s, length %u", EXTRACT_U_1(op->ospf6_version), cp, length));
        if (*cp == 'u') {
                return;
        }
@@ -980,7 +982,7 @@ ospf6_print(netdissect_options *ndo,
 
        /* OSPFv3 data always comes first and optional trailing data may follow. */
        ND_TCHECK(op->ospf6_len);
-       datalen = EXTRACT_BE_U_2(&op->ospf6_len);
+       datalen = EXTRACT_BE_U_2(op->ospf6_len);
        if (datalen > length) {
                ND_PRINT((ndo, " [len %d]", datalen));
                return;
@@ -991,16 +993,16 @@ ospf6_print(netdissect_options *ndo,
        ND_PRINT((ndo, "\n\tRouter-ID %s", ipaddr_string(ndo, &op->ospf6_routerid)));
 
        ND_TCHECK(op->ospf6_areaid);
-       if (EXTRACT_BE_U_4(&op->ospf6_areaid) != 0)
+       if (EXTRACT_BE_U_4(op->ospf6_areaid) != 0)
                ND_PRINT((ndo, ", Area %s", ipaddr_string(ndo, &op->ospf6_areaid)));
        else
                ND_PRINT((ndo, ", Backbone Area"));
        ND_TCHECK(op->ospf6_instanceid);
-       if (op->ospf6_instanceid)
-               ND_PRINT((ndo, ", Instance %u", op->ospf6_instanceid));
+       if (EXTRACT_U_1(op->ospf6_instanceid))
+               ND_PRINT((ndo, ", Instance %u", EXTRACT_U_1(op->ospf6_instanceid)));
 
        /* Do rest according to version.         */
-       switch (op->ospf6_version) {
+       switch (EXTRACT_U_1(op->ospf6_version)) {
 
        case 3:
                /* ospf version 3 */