]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-mobility.c
On Solaris, for 64-bit builds, use the 64-bit pcap-config.
[tcpdump] / print-mobility.c
index a79c7c2dfe5b24ac97be01f797d9a348bf768813..55340ca56d2f08625ab07819641a54095c686bf3 100644 (file)
@@ -110,6 +110,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)
@@ -155,7 +163,6 @@ mobility_opt_print(netdissect_options *ndo,
                                ND_PRINT("(altcoa: trunc)");
                                goto trunc;
                        }
-                       ND_TCHECK_16(bp + i + 2);
                        ND_PRINT("(alt-CoA: %s)", GET_IP6ADDR_STRING(bp + i + 2));
                        break;
                case IP6MOPT_NONCEID:
@@ -270,19 +277,17 @@ mobility_print(netdissect_options *ndo,
                hlen += 8;
                break;
        case IP6M_BINDING_UPDATE:
+           {
+               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;
@@ -292,6 +297,7 @@ mobility_print(netdissect_options *ndo,
                ND_PRINT(" lifetime=%u", GET_BE_U_2(bp + hlen) << 2);
                hlen += 2;
                break;
+           }
        case IP6M_BINDING_ACK:
                ND_PRINT(" status=%u", GET_U_1(mh->ip6m_data8[0]));
                if (GET_U_1(mh->ip6m_data8[1]) & 0x80)
@@ -308,7 +314,6 @@ mobility_print(netdissect_options *ndo,
                ND_PRINT(" status=%u", GET_U_1(mh->ip6m_data8[0]));
                /* Reserved */
                hlen = IP6M_MINLEN;
-               ND_TCHECK_16(bp + hlen);
                ND_PRINT(" homeaddr %s", GET_IP6ADDR_STRING(bp + hlen));
                hlen += 16;
                break;