FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
tcp_packet.h File Reference
+ Include dependency graph for tcp_packet.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tcp_options_t
 

Macros

#define foreach_tcp_flag
 Sender reduced congestion window. More...
 
#define tcp_doff(_th)   ((_th)->data_offset_and_reserved >> 4)
 
#define tcp_fin(_th)   ((_th)->flags & TCP_FLAG_FIN)
 
#define tcp_syn(_th)   ((_th)->flags & TCP_FLAG_SYN)
 
#define tcp_rst(_th)   ((_th)->flags & TCP_FLAG_RST)
 
#define tcp_psh(_th)   ((_th)->flags & TCP_FLAG_PSH)
 
#define tcp_ack(_th)   ((_th)->flags & TCP_FLAG_ACK)
 
#define tcp_urg(_th)   ((_th)->flags & TCP_FLAG_URG)
 
#define tcp_ece(_th)   ((_th)->flags & TCP_FLAG_ECE)
 
#define tcp_cwr(_th)   ((_th)->flags & TCP_FLAG_CWR)
 
#define tcp_is_syn(_th)   !!((_th)->flags & TCP_FLAG_SYN)
 
#define tcp_is_fin(_th)   !!((_th)->flags & TCP_FLAG_FIN)
 
#define foreach_tcp_options_flag
 SACK present. More...
 
#define tcp_opts_mss(_to)   ((_to)->flags & TCP_OPTS_FLAG_MSS)
 
#define tcp_opts_tstamp(_to)   ((_to)->flags & TCP_OPTS_FLAG_TSTAMP)
 
#define tcp_opts_wscale(_to)   ((_to)->flags & TCP_OPTS_FLAG_WSCALE)
 
#define tcp_opts_sack(_to)   ((_to)->flags & TCP_OPTS_FLAG_SACK)
 
#define tcp_opts_sack_permitted(_to)   ((_to)->flags & TCP_OPTS_FLAG_SACK_PERMITTED)
 
#define TCP_OPTION_LEN_EOL   1
 
#define TCP_OPTION_LEN_NOOP   1
 
#define TCP_OPTION_LEN_MSS   4
 
#define TCP_OPTION_LEN_WINDOW_SCALE   3
 
#define TCP_OPTION_LEN_SACK_PERMITTED   2
 
#define TCP_OPTION_LEN_TIMESTAMP   10
 
#define TCP_OPTION_LEN_SACK_BLOCK   8
 
#define TCP_HDR_LEN_MAX   60
 
#define TCP_WND_MAX   65535U
 
#define TCP_MAX_WND_SCALE   14 /* See RFC 1323 */
 
#define TCP_OPTS_ALIGN   4
 
#define TCP_OPTS_MAX_SACK_BLOCKS   3
 
#define TCP_MAX_GSO_SZ   65536
 
#define seq_lt(_s1, _s2)   ((i32)((_s1)-(_s2)) < 0)
 
#define seq_leq(_s1, _s2)   ((i32)((_s1)-(_s2)) <= 0)
 
#define seq_gt(_s1, _s2)   ((i32)((_s1)-(_s2)) > 0)
 
#define seq_geq(_s1, _s2)   ((i32)((_s1)-(_s2)) >= 0)
 
#define seq_max(_s1, _s2)   (seq_gt((_s1), (_s2)) ? (_s1) : (_s2))
 
#define timestamp_lt(_t1, _t2)   ((i32)((_t1)-(_t2)) < 0)
 
#define timestamp_leq(_t1, _t2)   ((i32)((_t1)-(_t2)) <= 0)
 

Typedefs

typedef struct _tcp_header tcp_header_t
 
typedef enum tcp_option_type tcp_option_type_t
 
typedef struct _sack_block sack_block_t
 

Enumerations

enum  { TCP_N_FLAG_BITS }
 
enum  { foreach_tcp_flag }
 
enum  tcp_option_type {
  TCP_OPTION_EOL = 0, TCP_OPTION_NOOP = 1, TCP_OPTION_MSS = 2, TCP_OPTION_WINDOW_SCALE = 3,
  TCP_OPTION_SACK_PERMITTED = 4, TCP_OPTION_SACK_BLOCK = 5, TCP_OPTION_TIMESTAMP = 8, TCP_OPTION_UTO = 28,
  TCP_OPTION_AO = 29
}
 
enum  { TCP_OPTIONS_N_FLAG_BITS }
 
enum  { foreach_tcp_options_flag }
 

Functions

static int tcp_header_bytes (tcp_header_t *t)
 
static int tcp_options_parse (tcp_header_t *th, tcp_options_t *to, u8 is_syn)
 Parse TCP header options. More...
 
static u32 tcp_options_write (u8 *data, tcp_options_t *opts)
 Write TCP options to segment. More...
 

Macro Definition Documentation

◆ foreach_tcp_flag

#define foreach_tcp_flag
Value:
_ (FIN) /**< No more data from sender. */ \
_ (SYN) /**< Synchronize sequence numbers. */ \
_ (RST) /**< Reset the connection. */ \
_ (PSH) /**< Push function. */ \
_ (ACK) /**< Ack field significant. */ \
_ (URG) /**< Urgent pointer field significant. */ \
_ (ECE) /**< ECN-echo. Receiver got CE packet */ \
_ (CWR)

Sender reduced congestion window.

Definition at line 22 of file tcp_packet.h.

◆ foreach_tcp_options_flag

#define foreach_tcp_options_flag
Value:
_ (MSS) /**< MSS advertised in SYN */ \
_ (TSTAMP) /**< Timestamp capability advertised in SYN */ \
_ (WSCALE) /**< Wnd scale capability advertised in SYN */ \
_ (SACK_PERMITTED) /**< SACK capability advertised in SYN */ \
_ (SACK)

SACK present.

Definition at line 115 of file tcp_packet.h.

◆ seq_geq

#define seq_geq (   _s1,
  _s2 
)    ((i32)((_s1)-(_s2)) >= 0)

Definition at line 181 of file tcp_packet.h.

◆ seq_gt

#define seq_gt (   _s1,
  _s2 
)    ((i32)((_s1)-(_s2)) > 0)

Definition at line 180 of file tcp_packet.h.

◆ seq_leq

#define seq_leq (   _s1,
  _s2 
)    ((i32)((_s1)-(_s2)) <= 0)

Definition at line 179 of file tcp_packet.h.

◆ seq_lt

#define seq_lt (   _s1,
  _s2 
)    ((i32)((_s1)-(_s2)) < 0)

Definition at line 178 of file tcp_packet.h.

◆ seq_max

#define seq_max (   _s1,
  _s2 
)    (seq_gt((_s1), (_s2)) ? (_s1) : (_s2))

Definition at line 182 of file tcp_packet.h.

◆ tcp_ack

#define tcp_ack (   _th)    ((_th)->flags & TCP_FLAG_ACK)

Definition at line 83 of file tcp_packet.h.

◆ tcp_cwr

#define tcp_cwr (   _th)    ((_th)->flags & TCP_FLAG_CWR)

Definition at line 86 of file tcp_packet.h.

◆ tcp_doff

#define tcp_doff (   _th)    ((_th)->data_offset_and_reserved >> 4)

Definition at line 78 of file tcp_packet.h.

◆ tcp_ece

#define tcp_ece (   _th)    ((_th)->flags & TCP_FLAG_ECE)

Definition at line 85 of file tcp_packet.h.

◆ tcp_fin

#define tcp_fin (   _th)    ((_th)->flags & TCP_FLAG_FIN)

Definition at line 79 of file tcp_packet.h.

◆ TCP_HDR_LEN_MAX

#define TCP_HDR_LEN_MAX   60

Definition at line 170 of file tcp_packet.h.

◆ tcp_is_fin

#define tcp_is_fin (   _th)    !!((_th)->flags & TCP_FLAG_FIN)

Definition at line 90 of file tcp_packet.h.

◆ tcp_is_syn

#define tcp_is_syn (   _th)    !!((_th)->flags & TCP_FLAG_SYN)

Definition at line 89 of file tcp_packet.h.

◆ TCP_MAX_GSO_SZ

#define TCP_MAX_GSO_SZ   65536

Definition at line 175 of file tcp_packet.h.

◆ TCP_MAX_WND_SCALE

#define TCP_MAX_WND_SCALE   14 /* See RFC 1323 */

Definition at line 172 of file tcp_packet.h.

◆ TCP_OPTION_LEN_EOL

#define TCP_OPTION_LEN_EOL   1

Definition at line 162 of file tcp_packet.h.

◆ TCP_OPTION_LEN_MSS

#define TCP_OPTION_LEN_MSS   4

Definition at line 164 of file tcp_packet.h.

◆ TCP_OPTION_LEN_NOOP

#define TCP_OPTION_LEN_NOOP   1

Definition at line 163 of file tcp_packet.h.

◆ TCP_OPTION_LEN_SACK_BLOCK

#define TCP_OPTION_LEN_SACK_BLOCK   8

Definition at line 168 of file tcp_packet.h.

◆ TCP_OPTION_LEN_SACK_PERMITTED

#define TCP_OPTION_LEN_SACK_PERMITTED   2

Definition at line 166 of file tcp_packet.h.

◆ TCP_OPTION_LEN_TIMESTAMP

#define TCP_OPTION_LEN_TIMESTAMP   10

Definition at line 167 of file tcp_packet.h.

◆ TCP_OPTION_LEN_WINDOW_SCALE

#define TCP_OPTION_LEN_WINDOW_SCALE   3

Definition at line 165 of file tcp_packet.h.

◆ TCP_OPTS_ALIGN

#define TCP_OPTS_ALIGN   4

Definition at line 173 of file tcp_packet.h.

◆ TCP_OPTS_MAX_SACK_BLOCKS

#define TCP_OPTS_MAX_SACK_BLOCKS   3

Definition at line 174 of file tcp_packet.h.

◆ tcp_opts_mss

#define tcp_opts_mss (   _to)    ((_to)->flags & TCP_OPTS_FLAG_MSS)

Definition at line 155 of file tcp_packet.h.

◆ tcp_opts_sack

#define tcp_opts_sack (   _to)    ((_to)->flags & TCP_OPTS_FLAG_SACK)

Definition at line 158 of file tcp_packet.h.

◆ tcp_opts_sack_permitted

#define tcp_opts_sack_permitted (   _to)    ((_to)->flags & TCP_OPTS_FLAG_SACK_PERMITTED)

Definition at line 159 of file tcp_packet.h.

◆ tcp_opts_tstamp

#define tcp_opts_tstamp (   _to)    ((_to)->flags & TCP_OPTS_FLAG_TSTAMP)

Definition at line 156 of file tcp_packet.h.

◆ tcp_opts_wscale

#define tcp_opts_wscale (   _to)    ((_to)->flags & TCP_OPTS_FLAG_WSCALE)

Definition at line 157 of file tcp_packet.h.

◆ tcp_psh

#define tcp_psh (   _th)    ((_th)->flags & TCP_FLAG_PSH)

Definition at line 82 of file tcp_packet.h.

◆ tcp_rst

#define tcp_rst (   _th)    ((_th)->flags & TCP_FLAG_RST)

Definition at line 81 of file tcp_packet.h.

◆ tcp_syn

#define tcp_syn (   _th)    ((_th)->flags & TCP_FLAG_SYN)

Definition at line 80 of file tcp_packet.h.

◆ tcp_urg

#define tcp_urg (   _th)    ((_th)->flags & TCP_FLAG_URG)

Definition at line 84 of file tcp_packet.h.

◆ TCP_WND_MAX

#define TCP_WND_MAX   65535U

Definition at line 171 of file tcp_packet.h.

◆ timestamp_leq

#define timestamp_leq (   _t1,
  _t2 
)    ((i32)((_t1)-(_t2)) <= 0)

Definition at line 186 of file tcp_packet.h.

◆ timestamp_lt

#define timestamp_lt (   _t1,
  _t2 
)    ((i32)((_t1)-(_t2)) < 0)

Definition at line 185 of file tcp_packet.h.

Typedef Documentation

◆ sack_block_t

typedef struct _sack_block sack_block_t

◆ tcp_header_t

typedef struct _tcp_header tcp_header_t

◆ tcp_option_type_t

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
TCP_N_FLAG_BITS 

Definition at line 32 of file tcp_packet.h.

◆ anonymous enum

anonymous enum
Enumerator
foreach_tcp_flag 

Definition at line 40 of file tcp_packet.h.

◆ anonymous enum

anonymous enum
Enumerator
TCP_OPTIONS_N_FLAG_BITS 

Definition at line 122 of file tcp_packet.h.

◆ anonymous enum

anonymous enum
Enumerator
foreach_tcp_options_flag 

Definition at line 130 of file tcp_packet.h.

◆ tcp_option_type

Enumerator
TCP_OPTION_EOL 

End of options.

TCP_OPTION_NOOP 

No operation.

TCP_OPTION_MSS 

Limit MSS.

TCP_OPTION_WINDOW_SCALE 

Window scale.

TCP_OPTION_SACK_PERMITTED 

Selective Ack permitted.

TCP_OPTION_SACK_BLOCK 

Selective Ack block.

TCP_OPTION_TIMESTAMP 

Timestamps.

TCP_OPTION_UTO 

User timeout.

TCP_OPTION_AO 

Authentication Option.

Definition at line 102 of file tcp_packet.h.

Function Documentation

◆ tcp_header_bytes()

static int tcp_header_bytes ( tcp_header_t t)
inlinestatic

Definition at line 93 of file tcp_packet.h.

+ Here is the caller graph for this function:

◆ tcp_options_parse()

static int tcp_options_parse ( tcp_header_t th,
tcp_options_t to,
u8  is_syn 
)
inlinestatic

Parse TCP header options.

Parameters
thTCP header
toTCP options data structure to be populated
is_synset if packet is syn
Returns
-1 if parsing failed

Definition at line 197 of file tcp_packet.h.

+ Here is the caller graph for this function:

◆ tcp_options_write()

static u32 tcp_options_write ( u8 data,
tcp_options_t opts 
)
inlinestatic

Write TCP options to segment.

Parameters
databuffer where to write the options
optsoptions to write
Returns
length of options written

Definition at line 309 of file tcp_packet.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: