]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-mobility.c
Translate UDP/1700 as RADIUS
[tcpdump] / print-mobility.c
index b6fa61e9dc747463a10cd1c5a7f75f84f171320f..85aa5bb98b9d31ba5d8380119d197f4c97629e12 100644 (file)
  * SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#ifdef INET6
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
 
 #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 +69,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 +92,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 +197,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 +228,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 +247,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 +268,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 +292,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 +307,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 +316,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;
        }
@@ -331,4 +329,3 @@ mobility_print(netdissect_options *ndo,
        ND_PRINT((ndo, "[|MOBILITY]"));
        return(mhlen);
 }
-#endif /* INET6 */