VSF Documented
tcp.h
Go to the documentation of this file.
1#ifndef __VSF_LINUX_NETINET_TCP_H__
2#define __VSF_LINUX_NETINET_TCP_H__
3
5
6#if VSF_LINUX_CFG_RELATIVE_PATH == ENABLED
7# include "../sys/types.h"
8#else
9# include <sys/types.h>
10#endif
11// for stdint.h
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18#if !defined(__LITTLE_ENDIAN_BITFIELD) && !defined(__BIG_ENDIAN_BITFIELD)
19# define __LITTLE_ENDIAN_BITFIELD
20#endif
21
22#define SOL_TCP IPPROTO_TCP
23// tcp options
24// refer: https://code.woboq.org/gtk/include/netinet/tcp.h.html
25#define TCP_NODELAY 1
26#define TCP_MAXSEG 2
27//#define TCP_CORK 3
28//#define TCP_KEEPIDLE 4
29//#define TCP_KEEPINTVL 5
30//#define TCP_KEEPCNT 6
31//#define TCP_SYNCNT 7
32//#define TCP_LINGER2 8
33//#define TCP_DEFER_ACCEPT 9
34//#define TCP_WINDOW_CLAMP 10
35//#define TCP_INFO 11
36//#define TCP_QUICKACK 12
37//#define TCP_CONGESTION 13
38//#define TCP_MD5SIG 14
39//#define TCP_COOKIE_TRANSACTIONS 15
40//#define TCP_THIN_LINEAR_TIMEOUTS 16
41//#define TCP_THIN_DUPACK 17
42//#define TCP_USER_TIMEOUT 18
43//#define TCP_REPAIR 19
44//#define TCP_REPAIR_QUEUE 20
45//#define TCP_QUEUE_SEQ 21
46//#define TCP_REPAIR_OPTIONS 22
47//#define TCP_FASTOPEN 23
48//#define TCP_TIMESTAMP 24
49//#define TCP_NOTSENT_LOWAT 25
50//#define TCP_CC_INFO 26
51//#define TCP_SAVE_SYN 27
52//#define TCP_SAVED_SYN 28
53#define TCP_KEEPALIVE 100
54
55#if defined(__FAVOR_BSD) || defined(_BSD_SOURCE)
56typedef uint32_t tcp_seq;
57struct tcphdr {
58 uint16_t th_sport;
59 uint16_t th_dport;
60 tcp_seq th_seq;
61 tcp_seq th_ack;
62
63# if __BYTE_ORDER == __LITTLE_ENDIAN
64 uint8_t th_x2:4;
65 uint8_t th_off:4;
66# elif __BYTE_ORDER == __BIG_ENDIAN
67 uint8_t th_off:4;
68 uint8_t th_x2:4;
69# else
70# error "invalid __BYTE_ORDER"
71# endif
72
73 uint8_t th_flags;
74# define TH_FIN 0x01
75# define TH_SYN 0x02
76# define TH_RST 0x04
77# define TH_PUSH 0x08
78# define TH_ACK 0x10
79# define TH_URG 0x20
80 uint16_t th_win;
81 uint16_t th_sum;
82 uint16_t th_urp;
83};
84
85#else
86struct tcphdr {
91# if __BYTE_ORDER == __LITTLE_ENDIAN
94 fin:1,
95 syn:1,
96 rst:1,
97 psh:1,
98 ack:1,
99 urg:1,
102# elif __BYTE_ORDER == __BIG_ENDIAN
103 uint16_t doff:4,
104 res1:4,
105 cwr:1,
106 ece:1,
107 urg:1,
108 ack:1,
109 psh:1,
110 rst:1,
111 syn:1,
112 fin:1;
113# else
114# error "invalid __BYTE_ORDER"
115# endif
119};
120#endif
121
122#ifdef __cplusplus
123}
124#endif
125
126#endif
unsigned short uint16_t
Definition stdint.h:7
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5
Definition tcp.h:86
uint16_t urg_ptr
Definition tcp.h:118
uint16_t dest
Definition tcp.h:88
uint16_t fin
Definition tcp.h:94
uint16_t psh
Definition tcp.h:97
uint16_t ece
Definition tcp.h:100
uint16_t window
Definition tcp.h:116
uint16_t rst
Definition tcp.h:96
uint16_t res1
Definition tcp.h:92
uint16_t syn
Definition tcp.h:95
uint16_t ack
Definition tcp.h:98
uint16_t check
Definition tcp.h:117
uint32_t seq
Definition tcp.h:89
uint16_t doff
Definition tcp.h:93
uint16_t source
Definition tcp.h:87
uint16_t urg
Definition tcp.h:99
uint16_t cwr
Definition tcp.h:101
uint32_t ack_seq
Definition tcp.h:90