add TCP_NLA_* enums from linux v4.11
[musl] / include / netinet / tcp.h
1 #ifndef _NETINET_TCP_H
2 #define _NETINET_TCP_H
3
4 #include <features.h>
5
6 #define TCP_NODELAY 1
7 #define TCP_MAXSEG       2
8 #define TCP_CORK         3
9 #define TCP_KEEPIDLE     4
10 #define TCP_KEEPINTVL    5
11 #define TCP_KEEPCNT      6
12 #define TCP_SYNCNT       7
13 #define TCP_LINGER2      8
14 #define TCP_DEFER_ACCEPT 9
15 #define TCP_WINDOW_CLAMP 10
16 #define TCP_INFO         11
17 #define TCP_QUICKACK     12
18 #define TCP_CONGESTION   13
19 #define TCP_MD5SIG       14
20 #define TCP_THIN_LINEAR_TIMEOUTS 16
21 #define TCP_THIN_DUPACK  17
22 #define TCP_USER_TIMEOUT 18
23 #define TCP_REPAIR       19
24 #define TCP_REPAIR_QUEUE 20
25 #define TCP_QUEUE_SEQ    21
26 #define TCP_REPAIR_OPTIONS 22
27 #define TCP_FASTOPEN     23
28 #define TCP_TIMESTAMP    24
29 #define TCP_NOTSENT_LOWAT 25
30 #define TCP_CC_INFO      26
31 #define TCP_SAVE_SYN     27
32 #define TCP_SAVED_SYN    28
33 #define TCP_REPAIR_WINDOW 29
34 #define TCP_FASTOPEN_CONNECT 30
35
36 #define TCP_ESTABLISHED  1
37 #define TCP_SYN_SENT     2
38 #define TCP_SYN_RECV     3
39 #define TCP_FIN_WAIT1    4
40 #define TCP_FIN_WAIT2    5
41 #define TCP_TIME_WAIT    6
42 #define TCP_CLOSE        7
43 #define TCP_CLOSE_WAIT   8
44 #define TCP_LAST_ACK     9
45 #define TCP_LISTEN       10
46 #define TCP_CLOSING      11
47
48 enum {
49         TCP_NLA_PAD,
50         TCP_NLA_BUSY,
51         TCP_NLA_RWND_LIMITED,
52         TCP_NLA_SNDBUF_LIMITED,
53         TCP_NLA_DATA_SEGS_OUT,
54         TCP_NLA_TOTAL_RETRANS,
55 };
56
57 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
58 #define TCPOPT_EOL              0
59 #define TCPOPT_NOP              1
60 #define TCPOPT_MAXSEG           2
61 #define TCPOPT_WINDOW           3
62 #define TCPOPT_SACK_PERMITTED   4
63 #define TCPOPT_SACK             5
64 #define TCPOPT_TIMESTAMP        8
65 #define TCPOLEN_SACK_PERMITTED  2
66 #define TCPOLEN_WINDOW          3
67 #define TCPOLEN_MAXSEG          4
68 #define TCPOLEN_TIMESTAMP       10
69
70 #define SOL_TCP 6
71
72 #include <sys/types.h>
73 #include <sys/socket.h>
74 #include <stdint.h>
75 #include <endian.h>
76
77 typedef uint32_t tcp_seq;
78
79 #define TH_FIN 0x01
80 #define TH_SYN 0x02
81 #define TH_RST 0x04
82 #define TH_PUSH 0x08
83 #define TH_ACK 0x10
84 #define TH_URG 0x20
85
86 struct tcphdr {
87 #ifdef _GNU_SOURCE
88 #ifdef __GNUC__
89         __extension__
90 #endif
91         union { struct {
92
93         uint16_t source;
94         uint16_t dest;
95         uint32_t seq;
96         uint32_t ack_seq;
97 #if __BYTE_ORDER == __LITTLE_ENDIAN
98         uint16_t res1:4;
99         uint16_t doff:4;
100         uint16_t fin:1;
101         uint16_t syn:1;
102         uint16_t rst:1;
103         uint16_t psh:1;
104         uint16_t ack:1;
105         uint16_t urg:1;
106         uint16_t res2:2;
107 #else
108         uint16_t doff:4;
109         uint16_t res1:4;
110         uint16_t res2:2;
111         uint16_t urg:1;
112         uint16_t ack:1;
113         uint16_t psh:1;
114         uint16_t rst:1;
115         uint16_t syn:1;
116         uint16_t fin:1;
117 #endif
118         uint16_t window;
119         uint16_t check;
120         uint16_t urg_ptr;
121
122         }; struct {
123 #endif
124
125         uint16_t th_sport;
126         uint16_t th_dport;
127         uint32_t th_seq;
128         uint32_t th_ack;
129 #if __BYTE_ORDER == __LITTLE_ENDIAN
130         uint8_t th_x2:4;
131         uint8_t th_off:4;
132 #else
133         uint8_t th_off:4;
134         uint8_t th_x2:4;
135 #endif
136         uint8_t th_flags;
137         uint16_t th_win;
138         uint16_t th_sum;
139         uint16_t th_urp;
140
141 #ifdef _GNU_SOURCE
142         }; };
143 #endif
144 };
145 #endif
146
147 #ifdef _GNU_SOURCE
148 #define TCPI_OPT_TIMESTAMPS     1
149 #define TCPI_OPT_SACK           2
150 #define TCPI_OPT_WSCALE         4
151 #define TCPI_OPT_ECN            8
152
153 #define TCP_CA_Open             0
154 #define TCP_CA_Disorder         1
155 #define TCP_CA_CWR              2
156 #define TCP_CA_Recovery         3
157 #define TCP_CA_Loss             4
158
159 struct tcp_info {
160         uint8_t tcpi_state;
161         uint8_t tcpi_ca_state;
162         uint8_t tcpi_retransmits;
163         uint8_t tcpi_probes;
164         uint8_t tcpi_backoff;
165         uint8_t tcpi_options;
166         uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
167         uint8_t tcpi_delivery_rate_app_limited : 1;
168         uint32_t tcpi_rto;
169         uint32_t tcpi_ato;
170         uint32_t tcpi_snd_mss;
171         uint32_t tcpi_rcv_mss;
172         uint32_t tcpi_unacked;
173         uint32_t tcpi_sacked;
174         uint32_t tcpi_lost;
175         uint32_t tcpi_retrans;
176         uint32_t tcpi_fackets;
177         uint32_t tcpi_last_data_sent;
178         uint32_t tcpi_last_ack_sent;
179         uint32_t tcpi_last_data_recv;
180         uint32_t tcpi_last_ack_recv;
181         uint32_t tcpi_pmtu;
182         uint32_t tcpi_rcv_ssthresh;
183         uint32_t tcpi_rtt;
184         uint32_t tcpi_rttvar;
185         uint32_t tcpi_snd_ssthresh;
186         uint32_t tcpi_snd_cwnd;
187         uint32_t tcpi_advmss;
188         uint32_t tcpi_reordering;
189         uint32_t tcpi_rcv_rtt;
190         uint32_t tcpi_rcv_space;
191         uint32_t tcpi_total_retrans;
192         uint64_t tcpi_pacing_rate;
193         uint64_t tcpi_max_pacing_rate;
194         uint64_t tcpi_bytes_acked;
195         uint64_t tcpi_bytes_received;
196         uint32_t tcpi_segs_out;
197         uint32_t tcpi_segs_in;
198         uint32_t tcpi_notsent_bytes;
199         uint32_t tcpi_min_rtt;
200         uint32_t tcpi_data_segs_in;
201         uint32_t tcpi_data_segs_out;
202         uint64_t tcpi_delivery_rate;
203         uint64_t tcpi_busy_time;
204         uint64_t tcpi_rwnd_limited;
205         uint64_t tcpi_sndbuf_limited;
206 };
207
208 #define TCP_MD5SIG_MAXKEYLEN    80
209
210 struct tcp_md5sig {
211         struct sockaddr_storage tcpm_addr;
212         uint16_t __tcpm_pad1;
213         uint16_t tcpm_keylen;
214         uint32_t __tcpm_pad2;
215         uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
216 };
217
218 struct tcp_repair_window {
219         uint32_t snd_wl1;
220         uint32_t snd_wnd;
221         uint32_t max_window;
222         uint32_t rcv_wnd;
223         uint32_t rcv_wup;
224 };
225
226 #endif
227
228 #endif