From: Longinus00 Date: Sun, 16 Jun 2013 03:46:54 +0000 (-0700) Subject: add support for experimental tcp fast open and parsing experimental options X-Git-Tag: tcpdump-4.5.0~32 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/b0614b45ac23de38058e8b179ec0ee3c7a8019fa add support for experimental tcp fast open and parsing experimental options --- diff --git a/print-tcp.c b/print-tcp.c index 48dd6254..81b4ad3a 100644 --- a/print-tcp.c +++ b/print-tcp.c @@ -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 79b67ec5..19611570 100644 --- 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)