]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-mobility.c
CI: Add warning exemptions for Sun C (suncc-5.14) on Solaris 10
[tcpdump] / print-mobility.c
index 329f84a8b76f106b116a971bd887bb1031bea552..2f905f1ba9e9da899ec0374bc1ddf9987cd4ee1a 100644 (file)
@@ -30,9 +30,7 @@
 /* \summary: IPv6 mobility printer */
 /* RFC 3775 */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 
@@ -110,6 +108,14 @@ static const unsigned ip6m_hdrlen[IP6M_MAX + 1] = {
 #define IP6MOPT_AUTH          0x5      /* Binding Authorization Data */
 #define IP6MOPT_AUTH_MINLEN    12
 
+static const struct tok ip6m_binding_update_bits [] = {
+       { 0x08, "A" },
+       { 0x04, "H" },
+       { 0x02, "L" },
+       { 0x01, "K" },
+       { 0, NULL }
+};
+
 static int
 mobility_opt_print(netdissect_options *ndo,
                    const u_char *bp, const unsigned len)
@@ -117,15 +123,12 @@ mobility_opt_print(netdissect_options *ndo,
        unsigned i, optlen;
 
        for (i = 0; i < len; i += optlen) {
-               ND_TCHECK_1(bp + i);
                if (GET_U_1(bp + i) == IP6MOPT_PAD1)
                        optlen = 1;
                else {
                        if (i + 1 < len) {
-                               ND_TCHECK_1(bp + i + 1);
                                optlen = GET_U_1(bp + i + 1) + 2;
-                       }
-                       else
+                       } else
                                goto trunc;
                }
                if (i + optlen > len)
@@ -149,7 +152,6 @@ mobility_opt_print(netdissect_options *ndo,
                                goto trunc;
                        }
                        /* units of 4 secs */
-                       ND_TCHECK_2(bp + i + 2);
                        ND_PRINT("(refresh: %u)",
                                GET_BE_U_2(bp + i + 2) << 2);
                        break;
@@ -158,16 +160,13 @@ mobility_opt_print(netdissect_options *ndo,
                                ND_PRINT("(altcoa: trunc)");
                                goto trunc;
                        }
-                       ND_TCHECK_16(bp + i + 2);
-                       ND_PRINT("(alt-CoA: %s)", ip6addr_string(ndo, bp + i + 2));
+                       ND_PRINT("(alt-CoA: %s)", GET_IP6ADDR_STRING(bp + i + 2));
                        break;
                case IP6MOPT_NONCEID:
                        if (len - i < IP6MOPT_NONCEID_MINLEN) {
                                ND_PRINT("(ni: trunc)");
                                goto trunc;
                        }
-                       ND_TCHECK_2(bp + i + 2);
-                       ND_TCHECK_2(bp + i + 4);
                        ND_PRINT("(ni: ho=0x%04x co=0x%04x)",
                                GET_BE_U_2(bp + i + 2),
                                GET_BE_U_2(bp + i + 4));
@@ -234,7 +233,6 @@ mobility_print(netdissect_options *ndo,
 
        /* XXX ip6m_cksum */
 
-       ND_TCHECK_1(mh->ip6m_type);
        type = GET_U_1(mh->ip6m_type);
        if (type <= IP6M_MAX && mhlen < ip6m_hdrlen[type]) {
                ND_PRINT("(header length %u is too small for type %u)", mhlen, type);
@@ -249,7 +247,6 @@ mobility_print(netdissect_options *ndo,
        case IP6M_CAREOF_TEST_INIT:
                hlen = IP6M_MINLEN;
                if (ndo->ndo_vflag) {
-                       ND_TCHECK_4(bp + hlen + 4);
                        ND_PRINT(" %s Init Cookie=%08x:%08x",
                               type == IP6M_HOME_TEST_INIT ? "Home" : "Care-of",
                               GET_BE_U_4(bp + hlen),
@@ -259,11 +256,9 @@ mobility_print(netdissect_options *ndo,
                break;
        case IP6M_HOME_TEST:
        case IP6M_CAREOF_TEST:
-               ND_TCHECK_2(mh->ip6m_data16[0]);
                ND_PRINT(" nonce id=0x%x", GET_BE_U_2(mh->ip6m_data16[0]));
                hlen = IP6M_MINLEN;
                if (ndo->ndo_vflag) {
-                       ND_TCHECK_4(bp + hlen + 4);
                        ND_PRINT(" %s Init Cookie=%08x:%08x",
                               type == IP6M_HOME_TEST ? "Home" : "Care-of",
                               GET_BE_U_4(bp + hlen),
@@ -271,7 +266,6 @@ mobility_print(netdissect_options *ndo,
                }
                hlen += 8;
                if (ndo->ndo_vflag) {
-                       ND_TCHECK_4(bp + hlen + 4);
                        ND_PRINT(" %s Keygen Token=%08x:%08x",
                               type == IP6M_HOME_TEST ? "Home" : "Care-of",
                               GET_BE_U_4(bp + hlen),
@@ -280,59 +274,49 @@ mobility_print(netdissect_options *ndo,
                hlen += 8;
                break;
        case IP6M_BINDING_UPDATE:
-               ND_TCHECK_2(mh->ip6m_data16[0]);
+           {
+               int bits;
                ND_PRINT(" seq#=%u", GET_BE_U_2(mh->ip6m_data16[0]));
                hlen = IP6M_MINLEN;
                ND_TCHECK_2(bp + hlen);
-               if (GET_U_1(bp + hlen) & 0xf0) {
+               bits = (GET_U_1(bp + hlen) & 0xf0) >> 4;
+               if (bits) {
                        ND_PRINT(" ");
-                       if (GET_U_1(bp + hlen) & 0x80)
-                               ND_PRINT("A");
-                       if (GET_U_1(bp + hlen) & 0x40)
-                               ND_PRINT("H");
-                       if (GET_U_1(bp + hlen) & 0x20)
-                               ND_PRINT("L");
-                       if (GET_U_1(bp + hlen) & 0x10)
-                               ND_PRINT("K");
+                       ND_PRINT("%s",
+                                bittok2str_nosep(ip6m_binding_update_bits,
+                                "bits-#0x%x", bits));
                }
                /* Reserved (4bits) */
                hlen += 1;
                /* Reserved (8bits) */
                hlen += 1;
-               ND_TCHECK_2(bp + hlen);
                /* units of 4 secs */
                ND_PRINT(" lifetime=%u", GET_BE_U_2(bp + hlen) << 2);
                hlen += 2;
                break;
+           }
        case IP6M_BINDING_ACK:
-               ND_TCHECK_1(mh->ip6m_data8[0]);
                ND_PRINT(" status=%u", GET_U_1(mh->ip6m_data8[0]));
-               ND_TCHECK_1(mh->ip6m_data8[1]);
                if (GET_U_1(mh->ip6m_data8[1]) & 0x80)
                        ND_PRINT(" K");
                /* Reserved (7bits) */
                hlen = IP6M_MINLEN;
-               ND_TCHECK_2(bp + hlen);
                ND_PRINT(" seq#=%u", GET_BE_U_2(bp + hlen));
                hlen += 2;
-               ND_TCHECK_2(bp + hlen);
                /* units of 4 secs */
                ND_PRINT(" lifetime=%u", GET_BE_U_2(bp + hlen) << 2);
                hlen += 2;
                break;
        case IP6M_BINDING_ERROR:
-               ND_TCHECK_1(mh->ip6m_data8[0]);
                ND_PRINT(" status=%u", GET_U_1(mh->ip6m_data8[0]));
                /* Reserved */
                hlen = IP6M_MINLEN;
-               ND_TCHECK_16(bp + hlen);
-               ND_PRINT(" homeaddr %s", ip6addr_string(ndo, bp + hlen));
+               ND_PRINT(" homeaddr %s", GET_IP6ADDR_STRING(bp + hlen));
                hlen += 16;
                break;
        default:
                ND_PRINT(" len=%u", GET_U_1(mh->ip6m_len));
                return(mhlen);
-               break;
        }
        if (ndo->ndo_vflag)
                if (mobility_opt_print(ndo, bp + hlen, mhlen - hlen))