16 #ifndef included_tcp_packet_h 17 #define included_tcp_packet_h 22 #define foreach_tcp_flag \ 34 #define _(f) TCP_FLAG_BIT_##f, 42 #define _(f) TCP_FLAG_##f = 1 << TCP_FLAG_BIT_##f, 47 typedef struct _tcp_header
69 u8 data_offset_and_reserved;
78 #define tcp_doff(_th) ((_th)->data_offset_and_reserved >> 4) 79 #define tcp_fin(_th) ((_th)->flags & TCP_FLAG_FIN) 80 #define tcp_syn(_th) ((_th)->flags & TCP_FLAG_SYN) 81 #define tcp_rst(_th) ((_th)->flags & TCP_FLAG_RST) 82 #define tcp_psh(_th) ((_th)->flags & TCP_FLAG_PSH) 83 #define tcp_ack(_th) ((_th)->flags & TCP_FLAG_ACK) 84 #define tcp_urg(_th) ((_th)->flags & TCP_FLAG_URG) 85 #define tcp_ece(_th) ((_th)->flags & TCP_FLAG_ECE) 86 #define tcp_cwr(_th) ((_th)->flags & TCP_FLAG_CWR) 89 #define tcp_is_syn(_th) !!((_th)->flags & TCP_FLAG_SYN) 90 #define tcp_is_fin(_th) !!((_th)->flags & TCP_FLAG_FIN) 115 #define foreach_tcp_options_flag \ 124 #define _(f) TCP_OPTS_FLAG_BIT_##f, 132 #define _(f) TCP_OPTS_FLAG_##f = 1 << TCP_OPTS_FLAG_BIT_##f, 137 typedef struct _sack_block
155 #define tcp_opts_mss(_to) ((_to)->flags & TCP_OPTS_FLAG_MSS) 156 #define tcp_opts_tstamp(_to) ((_to)->flags & TCP_OPTS_FLAG_TSTAMP) 157 #define tcp_opts_wscale(_to) ((_to)->flags & TCP_OPTS_FLAG_WSCALE) 158 #define tcp_opts_sack(_to) ((_to)->flags & TCP_OPTS_FLAG_SACK) 159 #define tcp_opts_sack_permitted(_to) ((_to)->flags & TCP_OPTS_FLAG_SACK_PERMITTED) 162 #define TCP_OPTION_LEN_EOL 1 163 #define TCP_OPTION_LEN_NOOP 1 164 #define TCP_OPTION_LEN_MSS 4 165 #define TCP_OPTION_LEN_WINDOW_SCALE 3 166 #define TCP_OPTION_LEN_SACK_PERMITTED 2 167 #define TCP_OPTION_LEN_TIMESTAMP 10 168 #define TCP_OPTION_LEN_SACK_BLOCK 8 170 #define TCP_HDR_LEN_MAX 60 171 #define TCP_WND_MAX 65535U 172 #define TCP_MAX_WND_SCALE 14 173 #define TCP_OPTS_ALIGN 4 174 #define TCP_OPTS_MAX_SACK_BLOCKS 3
struct _sack_block sack_block_t
u8 n_sack_blocks
Number of SACKs blocks.
struct _tcp_header tcp_header_t
u8 wscale
Option flags, see above.
enum tcp_option_type tcp_option_type_t
sack_block_t * sacks
SACK blocks.
#define foreach_tcp_options_flag
SACK present.
u16 mss
Maximum segment size advertised.
#define foreach_tcp_flag
Sender reduced congestion window.
u32 tsval
Timestamp value.
u32 tsecr
Echoed/reflected time stamp.
static int tcp_header_bytes(tcp_header_t *t)