X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/3824a6c0417a551961d1a1bf4f94f10eff736afc..39d15607cad1b4b463794c1a67873f6182dc52f7:/print-mobility.c diff --git a/print-mobility.c b/print-mobility.c index 8311a03a..d4dfcc0c 100644 --- a/print-mobility.c +++ b/print-mobility.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2002 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -31,7 +31,6 @@ #include "config.h" #endif - #ifdef INET6 #include @@ -43,10 +42,6 @@ #include "addrtoname.h" #include "extract.h" /* must come after interface.h */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-mobility.c,v 1.10 2003-11-15 00:39:31 guy Exp $"; -#endif /* Mobility header */ struct ip6_mobility { u_int8_t ip6m_pproto; /* following payload protocol (for PG) */ @@ -65,6 +60,8 @@ struct ip6_mobility { #define IP6M_MINLEN 8 +/* http://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml */ + /* message type */ #define IP6M_BINDING_REQUEST 0 /* Binding Refresh Request */ #define IP6M_HOME_TEST_INIT 1 /* Home Test Init */ @@ -75,6 +72,11 @@ struct ip6_mobility { #define IP6M_BINDING_ACK 6 /* Binding Acknowledgement */ #define IP6M_BINDING_ERROR 7 /* 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 */ @@ -89,10 +91,9 @@ struct ip6_mobility { #define IP6MOPT_AUTH_MINLEN 12 static void -mobility_opt_print(const u_char *bp, int len) +mobility_opt_print(const u_char *bp, const unsigned len) { - int i; - int optlen; + unsigned i, optlen; for (i = 0; i < len; i += optlen) { if (bp[i] == IP6MOPT_PAD1) @@ -123,7 +124,7 @@ mobility_opt_print(const u_char *bp, int len) goto trunc; } /* units of 4 secs */ - printf("(refresh: %d)", + printf("(refresh: %u)", EXTRACT_16BITS(&bp[i+2]) << 2); break; case IP6MOPT_ALTCOA: @@ -151,10 +152,10 @@ mobility_opt_print(const u_char *bp, int len) break; default: if (len - i < IP6MOPT_MINLEN) { - printf("(sopt_type %d: trunc)", bp[i]); + printf("(sopt_type %u: trunc)", bp[i]); goto trunc; } - printf("(type-0x%02x: len=%d)", bp[i], bp[i + 1]); + printf("(type-0x%02x: len=%u)", bp[i], bp[i + 1]); break; } } @@ -168,15 +169,14 @@ trunc: * Mobility Header */ int -mobility_print(const u_char *bp, const u_char *bp2) +mobility_print(const u_char *bp, const u_char *bp2 _U_) { const struct ip6_mobility *mh; - const struct ip6_hdr *ip6; const u_char *ep; - int mhlen, hlen, type; + unsigned mhlen, hlen; + u_int8_t type; mh = (struct ip6_mobility *)bp; - ip6 = (struct ip6_hdr *)bp2; /* 'ep' points to the end of available data. */ ep = snapend; @@ -197,7 +197,7 @@ mobility_print(const u_char *bp, const u_char *bp2) mhlen = ep - bp; goto trunc; } - mhlen = (int)((mh->ip6m_len + 1) << 3); + mhlen = (mh->ip6m_len + 1) << 3; /* XXX ip6m_cksum */ @@ -249,7 +249,7 @@ mobility_print(const u_char *bp, const u_char *bp2) case IP6M_BINDING_UPDATE: printf("mobility: BU"); TCHECK(mh->ip6m_data16[0]); - printf(" seq#=%d", EXTRACT_16BITS(&mh->ip6m_data16[0])); + printf(" seq#=%u", EXTRACT_16BITS(&mh->ip6m_data16[0])); hlen = IP6M_MINLEN; TCHECK2(*mh, hlen + 1); if (bp[hlen] & 0xf0) @@ -268,29 +268,29 @@ mobility_print(const u_char *bp, const u_char *bp2) hlen += 1; TCHECK2(*mh, hlen + 2); /* units of 4 secs */ - printf(" lifetime=%d", EXTRACT_16BITS(&bp[hlen]) << 2); + printf(" lifetime=%u", EXTRACT_16BITS(&bp[hlen]) << 2); hlen += 2; break; case IP6M_BINDING_ACK: printf("mobility: BA"); TCHECK(mh->ip6m_data8[0]); - printf(" status=%d", mh->ip6m_data8[0]); + printf(" status=%u", mh->ip6m_data8[0]); if (mh->ip6m_data8[1] & 0x80) printf(" K"); /* Reserved (7bits) */ hlen = IP6M_MINLEN; TCHECK2(*mh, hlen + 2); - printf(" seq#=%d", EXTRACT_16BITS(&bp[hlen])); + printf(" seq#=%u", EXTRACT_16BITS(&bp[hlen])); hlen += 2; TCHECK2(*mh, hlen + 2); /* units of 4 secs */ - printf(" lifetime=%d", EXTRACT_16BITS(&bp[hlen]) << 2); + printf(" lifetime=%u", EXTRACT_16BITS(&bp[hlen]) << 2); hlen += 2; break; case IP6M_BINDING_ERROR: printf("mobility: BE"); TCHECK(mh->ip6m_data8[0]); - printf(" status=%d", mh->ip6m_data8[0]); + printf(" status=%u", mh->ip6m_data8[0]); /* Reserved */ hlen = IP6M_MINLEN; TCHECK2(*mh, hlen + 16); @@ -298,7 +298,7 @@ mobility_print(const u_char *bp, const u_char *bp2) hlen += 16; break; default: - printf("mobility: type-#%d len=%d", type, mh->ip6m_len); + printf("mobility: type-#%u len=%u", type, mh->ip6m_len); return(mhlen); break; }