]> The Tcpdump Group git mirrors - tcpdump/commitdiff
IPv6: refresh options decoding (GH #47 pt. 3)
authorDenis Ovsienko <[email protected]>
Sat, 4 Jan 2014 12:39:33 +0000 (16:39 +0400)
committerDenis Ovsienko <[email protected]>
Sat, 4 Jan 2014 12:39:33 +0000 (16:39 +0400)
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.

ip6.h
print-ip6opts.c
print-mobility.c

diff --git a/ip6.h b/ip6.h
index da5a570a14899b909daf5fbf7dcf609f3fe6c841..c19d7ee4eb754a53470bd20f470700e05c80fb4d 100644 (file)
--- 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
index 409d42a6de2ed61a33652489c9f69e43157997d2..784edcee4862f1db139af965acb6d10464b31b03 100644 (file)
 #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:
index efc18131bf37dc13e41d6597effaf85e7f2edeb3..d4dfcc0c07a06a7f88024410fd32b068251d8829 100644 (file)
@@ -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 */