summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Ovsienko <infrastation@yandex.ru>2014-01-04 16:39:33 +0400
committerDenis Ovsienko <infrastation@yandex.ru>2014-01-04 16:39:33 +0400
commit3ea7a6988e7a038e1b0604a56c828b929c60d0d5 (patch)
treed5959a70d085311c7ba2f02f0b60d657d288e741
parent8607eeea0ad33592bf73bb6de2fca160037166c6 (diff)
downloadtcpdump-3ea7a6988e7a038e1b0604a56c828b929c60d0d5.tar.gz
IPv6: refresh options decoding (GH #47 pt. 3)
Brian Haley points that mobility (sub-)options decoded in print-ip6opts.c are specific to draft-ietf-mobileip-ipv6 only. RFC3775 (and respectively RFC6275) uses different encoding and parameter space, which print-mobility.c already handles. Remove deprecated code and update some related macros.
-rw-r--r--ip6.h15
-rw-r--r--print-ip6opts.c112
-rw-r--r--print-mobility.c7
3 files changed, 19 insertions, 115 deletions
diff --git a/ip6.h b/ip6.h
index da5a570a..c19d7ee4 100644
--- a/ip6.h
+++ b/ip6.h
@@ -127,11 +127,15 @@ struct ip6_dest {
/* followed by options */
} UNALIGNED;
+/* http://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml */
+
/* Option types and related macros */
#define IP6OPT_PAD1 0x00 /* 00 0 00000 */
#define IP6OPT_PADN 0x01 /* 00 0 00001 */
#define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */
#define IP6OPT_JUMBO_LEN 6
+#define IP6OPT_RPL 0x63 /* 01 1 00011 */
+#define IP6OPT_TUN_ENC_LIMIT 0x04 /* 00 0 00100 */
#define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */
#define IP6OPT_RTALERT_LEN 4
@@ -140,11 +144,16 @@ struct ip6_dest {
#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */
#define IP6OPT_MINLEN 2
-#define IP6OPT_BINDING_UPDATE 0xc6 /* 11 0 00110 */
-#define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */
-#define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */
+#define IP6OPT_QUICK_START 0x26 /* 00 1 00110 */
+#define IP6OPT_CALIPSO 0x07 /* 00 0 00111 */
+#define IP6OPT_SMF_DPD 0x08 /* 00 0 01000 */
#define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */
+#define IP6OPT_HOMEADDR_MINLEN 18
#define IP6OPT_EID 0x8a /* 10 0 01010 */
+#define IP6OPT_ILNP_NOTICE 0x8b /* 10 0 01011 */
+#define IP6OPT_LINE_ID 0x8c /* 10 0 01100 */
+#define IP6OPT_MPL 0x6d /* 01 1 01101 */
+#define IP6OPT_IP_DFF 0xee /* 11 1 01110 */
#define IP6OPT_TYPE(o) ((o) & 0xC0)
#define IP6OPT_TYPE_SKIP 0x00
diff --git a/print-ip6opts.c b/print-ip6opts.c
index 409d42a6..784edcee 100644
--- a/print-ip6opts.c
+++ b/print-ip6opts.c
@@ -42,29 +42,6 @@
#include "addrtoname.h"
#include "extract.h"
-/* items outside of rfc2292bis */
-#ifndef IP6OPT_MINLEN
-#define IP6OPT_MINLEN 2
-#endif
-#ifndef IP6OPT_RTALERT_LEN
-#define IP6OPT_RTALERT_LEN 4
-#endif
-#ifndef IP6OPT_JUMBO_LEN
-#define IP6OPT_JUMBO_LEN 6
-#endif
-#define IP6OPT_HOMEADDR_MINLEN 18
-#define IP6OPT_BU_MINLEN 10
-#define IP6OPT_BA_MINLEN 13
-#define IP6OPT_BR_MINLEN 2
-#define IP6SOPT_UI 0x2
-#define IP6SOPT_UI_MINLEN 4
-#define IP6SOPT_ALTCOA 0x3
-#define IP6SOPT_ALTCOA_MINLEN 18
-#define IP6SOPT_AUTH 0x4
-#define IP6SOPT_AUTH_MINLEN 6
-
-static void ip6_sopt_print(const u_char *, int);
-
static void
ip6_sopt_print(const u_char *bp, int len)
{
@@ -94,27 +71,6 @@ ip6_sopt_print(const u_char *bp, int len)
}
printf(", padn");
break;
- case IP6SOPT_UI:
- if (len - i < IP6SOPT_UI_MINLEN) {
- printf(", ui: trunc");
- goto trunc;
- }
- printf(", ui: 0x%04x ", EXTRACT_16BITS(&bp[i + 2]));
- break;
- case IP6SOPT_ALTCOA:
- if (len - i < IP6SOPT_ALTCOA_MINLEN) {
- printf(", altcoa: trunc");
- goto trunc;
- }
- printf(", alt-CoA: %s", ip6addr_string(&bp[i+2]));
- break;
- case IP6SOPT_AUTH:
- if (len - i < IP6SOPT_AUTH_MINLEN) {
- printf(", auth: trunc");
- goto trunc;
- }
- printf(", auth spi: 0x%08x", EXTRACT_32BITS(&bp[i + 2]));
- break;
default:
if (len - i < IP6OPT_MINLEN) {
printf(", sopt_type %d: trunc)", bp[i]);
@@ -199,70 +155,6 @@ ip6_opt_print(const u_char *bp, int len)
}
printf(")");
break;
- case IP6OPT_BINDING_UPDATE:
- if (len - i < IP6OPT_BU_MINLEN) {
- printf("(bu: trunc)");
- goto trunc;
- }
- if (bp[i + 1] < IP6OPT_BU_MINLEN - 2) {
- printf("(bu: invalid len %d)", bp[i + 1]);
- goto trunc;
- }
- printf("(bu: ");
- if (bp[i + 2] & 0x80)
- printf("A");
- if (bp[i + 2] & 0x40)
- printf("H");
- if (bp[i + 2] & 0x20)
- printf("S");
- if (bp[i + 2] & 0x10)
- printf("D");
- if ((bp[i + 2] & 0x0f) || bp[i + 3] || bp[i + 4])
- printf("res");
- printf(", sequence: %u", bp[i + 5]);
- printf(", lifetime: %u", EXTRACT_32BITS(&bp[i + 6]));
-
- if (bp[i + 1] > IP6OPT_BU_MINLEN - 2) {
- ip6_sopt_print(&bp[i + IP6OPT_BU_MINLEN],
- (optlen - IP6OPT_BU_MINLEN));
- }
- printf(")");
- break;
- case IP6OPT_BINDING_ACK:
- if (len - i < IP6OPT_BA_MINLEN) {
- printf("(ba: trunc)");
- goto trunc;
- }
- if (bp[i + 1] < IP6OPT_BA_MINLEN - 2) {
- printf("(ba: invalid len %d)", bp[i + 1]);
- goto trunc;
- }
- printf("(ba: ");
- printf("status: %u", bp[i + 2]);
- if (bp[i + 3])
- printf("res");
- printf(", sequence: %u", bp[i + 4]);
- printf(", lifetime: %u", EXTRACT_32BITS(&bp[i + 5]));
- printf(", refresh: %u", EXTRACT_32BITS(&bp[i + 9]));
-
- if (bp[i + 1] > IP6OPT_BA_MINLEN - 2) {
- ip6_sopt_print(&bp[i + IP6OPT_BA_MINLEN],
- (optlen - IP6OPT_BA_MINLEN));
- }
- printf(")");
- break;
- case IP6OPT_BINDING_REQ:
- if (len - i < IP6OPT_BR_MINLEN) {
- printf("(br: trunc)");
- goto trunc;
- }
- printf("(br");
- if (bp[i + 1] > IP6OPT_BR_MINLEN - 2) {
- ip6_sopt_print(&bp[i + IP6OPT_BR_MINLEN],
- (optlen - IP6OPT_BR_MINLEN));
- }
- printf(")");
- break;
default:
if (len - i < IP6OPT_MINLEN) {
printf("(type %d: trunc)", bp[i]);
@@ -273,10 +165,6 @@ ip6_opt_print(const u_char *bp, int len)
}
}
printf(" ");
-
-#if 0
-end:
-#endif
return;
trunc:
diff --git a/print-mobility.c b/print-mobility.c
index efc18131..d4dfcc0c 100644
--- a/print-mobility.c
+++ b/print-mobility.c
@@ -60,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 */
@@ -70,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 */