]> The Tcpdump Group git mirrors - tcpdump/commitdiff
add support for experimental tcp fast open and parsing experimental options
authorLonginus00 <[email protected]>
Sun, 16 Jun 2013 03:46:54 +0000 (20:46 -0700)
committerDenis Ovsienko <[email protected]>
Thu, 3 Oct 2013 07:04:06 +0000 (11:04 +0400)
print-tcp.c
tcp.h

index 48dd6254132b959635bed5ab4585f3c208431915..81b4ad3a8b192d92c60273706c019e2b01a1aadb 100644 (file)
@@ -123,6 +123,7 @@ static const struct tok tcp_option_values[] = {
         { TCPOPT_AUTH, "enhanced auth" },
         { TCPOPT_UTO, "uto" },
         { TCPOPT_MPTCP, "mptcp" },
+        { TCPOPT_EXPERIMENT2, "exp" },
         { 0, NULL }
 };
 
@@ -146,6 +147,7 @@ tcp_print(register const u_char *bp, register u_int length,
         u_int16_t sport, dport, win, urp;
         u_int32_t seq, ack, thseq, thack;
         u_int utoval;
+        u_int16_t magic;
         int threv;
 #ifdef INET6
         register const struct ip6_hdr *ip6;
@@ -604,6 +606,40 @@ tcp_print(register const u_char *bp, register u_int length,
                                         goto bad;
                                 break;
 
+                        case TCPOPT_EXPERIMENT2:
+                                datalen = len - 2;
+                                LENCHECK(datalen);
+                                if (datalen < 2)
+                                        goto bad;
+                                magic = EXTRACT_16BITS(cp);
+                                (void)printf("-");
+
+                                switch(magic) {
+
+                                case 0xf989:
+                                        /* TCP Fast Open: draft-ietf-tcpm-fastopen-04 */
+                                        if (datalen == 2) {
+                                                /* Fast Open Cookie Request */
+                                                (void)printf("tfo cookiereq");
+                                        } else {
+                                                /* Fast Open Cookie */
+                                                if (datalen % 2 != 0 || datalen < 6 || datalen > 18) {
+                                                        (void)printf("tfo malformed");
+                                                } else {
+                                                        (void)printf("tfo cookie ");
+                                                        for (i = 2; i < datalen; ++i)
+                                                                (void)printf("%02x", cp[i]);
+                                                }
+                                        }
+                                        break;
+
+                                default:
+                                        /* Unknown magic number */
+                                        (void)printf("%04x", magic);
+                                        break;
+                                }
+                                break;
+
                         default:
                                 datalen = len - 2;
                                 for (i = 0; i < datalen; ++i) {
diff --git a/tcp.h b/tcp.h
index 79b67ec5df628e2aa97b0224ee19e76beb15ca7e..196115705df75133022256f2987a9989f9f7bf3e 100644 (file)
--- a/tcp.h
+++ b/tcp.h
@@ -86,6 +86,7 @@ struct tcphdr {
 #define        TCPOPT_UTO              28      /* tcp user timeout (rfc5482) */
 #define           TCPOLEN_UTO                  4
 #define        TCPOPT_MPTCP            30      /* MPTCP options */
+#define TCPOPT_EXPERIMENT2     254     /* experimental headers (rfc4727) */
 
 #define TCPOPT_TSTAMP_HDR      \
     (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)