X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/192fabf4bd08e17b4be6f0283508b19adfa08afb..0845bc813c1cc48b18cdefff0b387c110647463c:/print-mobility.c diff --git a/print-mobility.c b/print-mobility.c index b6fa61e9..58dabe11 100644 --- a/print-mobility.c +++ b/print-mobility.c @@ -27,7 +27,6 @@ * SUCH DAMAGE. */ -#define NETDISSECT_REWORKED #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -36,9 +35,9 @@ #include #include "ip6.h" -#include "interface.h" +#include "netdissect.h" #include "addrtoname.h" -#include "extract.h" /* must come after interface.h */ +#include "extract.h" /* Mobility header */ struct ip6_mobility { @@ -71,6 +70,18 @@ struct ip6_mobility { #define IP6M_BINDING_ERROR 7 /* Binding Error */ #define IP6M_MAX 7 +static const struct tok ip6m_str[] = { + { IP6M_BINDING_REQUEST, "BRR" }, + { IP6M_HOME_TEST_INIT, "HoTI" }, + { IP6M_CAREOF_TEST_INIT, "CoTI" }, + { IP6M_HOME_TEST, "HoT" }, + { IP6M_CAREOF_TEST, "CoT" }, + { IP6M_BINDING_UPDATE, "BU" }, + { IP6M_BINDING_ACK, "BA" }, + { IP6M_BINDING_ERROR, "BE" }, + { 0, NULL } +}; + static const unsigned ip6m_hdrlen[IP6M_MAX + 1] = { IP6M_MINLEN, /* IP6M_BINDING_REQUEST */ IP6M_MINLEN + 8, /* IP6M_HOME_TEST_INIT */ @@ -82,11 +93,6 @@ static const unsigned ip6m_hdrlen[IP6M_MAX + 1] = { IP6M_MINLEN + 16, /* IP6M_BINDING_ERROR */ }; -/* XXX: unused */ -#define IP6MOPT_BU_MINLEN 10 -#define IP6MOPT_BA_MINLEN 13 -#define IP6MOPT_BR_MINLEN 2 - /* Mobility Header Options */ #define IP6MOPT_MINLEN 2 #define IP6MOPT_PAD1 0x0 /* Pad1 */ @@ -192,7 +198,7 @@ mobility_print(netdissect_options *ndo, unsigned mhlen, hlen; uint8_t type; - mh = (struct ip6_mobility *)bp; + mh = (const struct ip6_mobility *)bp; /* 'ep' points to the end of available data. */ ep = ndo->ndo_snapend; @@ -223,15 +229,13 @@ mobility_print(netdissect_options *ndo, ND_PRINT((ndo, "(header length %u is too small for type %u)", mhlen, type)); goto trunc; } + ND_PRINT((ndo, "mobility: %s", tok2str(ip6m_str, "type-#%u", type))); switch (type) { case IP6M_BINDING_REQUEST: - ND_PRINT((ndo, "mobility: BRR")); hlen = IP6M_MINLEN; break; case IP6M_HOME_TEST_INIT: case IP6M_CAREOF_TEST_INIT: - ND_PRINT((ndo, "mobility: %soTI", - type == IP6M_HOME_TEST_INIT ? "H" : "C")); hlen = IP6M_MINLEN; if (ndo->ndo_vflag) { ND_TCHECK2(*mh, hlen + 8); @@ -244,8 +248,6 @@ mobility_print(netdissect_options *ndo, break; case IP6M_HOME_TEST: case IP6M_CAREOF_TEST: - ND_PRINT((ndo, "mobility: %soT", - type == IP6M_HOME_TEST ? "H" : "C")); ND_TCHECK(mh->ip6m_data16[0]); ND_PRINT((ndo, " nonce id=0x%x", EXTRACT_16BITS(&mh->ip6m_data16[0]))); hlen = IP6M_MINLEN; @@ -267,7 +269,6 @@ mobility_print(netdissect_options *ndo, hlen += 8; break; case IP6M_BINDING_UPDATE: - ND_PRINT((ndo, "mobility: BU")); ND_TCHECK(mh->ip6m_data16[0]); ND_PRINT((ndo, " seq#=%u", EXTRACT_16BITS(&mh->ip6m_data16[0]))); hlen = IP6M_MINLEN; @@ -292,7 +293,6 @@ mobility_print(netdissect_options *ndo, hlen += 2; break; case IP6M_BINDING_ACK: - ND_PRINT((ndo, "mobility: BA")); ND_TCHECK(mh->ip6m_data8[0]); ND_PRINT((ndo, " status=%u", mh->ip6m_data8[0])); if (mh->ip6m_data8[1] & 0x80) @@ -308,7 +308,6 @@ mobility_print(netdissect_options *ndo, hlen += 2; break; case IP6M_BINDING_ERROR: - ND_PRINT((ndo, "mobility: BE")); ND_TCHECK(mh->ip6m_data8[0]); ND_PRINT((ndo, " status=%u", mh->ip6m_data8[0])); /* Reserved */ @@ -318,7 +317,7 @@ mobility_print(netdissect_options *ndo, hlen += 16; break; default: - ND_PRINT((ndo, "mobility: type-#%u len=%u", type, mh->ip6m_len)); + ND_PRINT((ndo, " len=%u", mh->ip6m_len)); return(mhlen); break; }