aarch64: add HWCAP_ flags from linux v4.17
[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 #define TCP_ULP          31
36 #define TCP_MD5SIG_EXT   32
37 #define TCP_FASTOPEN_KEY 33
38 #define TCP_FASTOPEN_NO_COOKIE 34
39
40 #define TCP_ESTABLISHED  1
41 #define TCP_SYN_SENT     2
42 #define TCP_SYN_RECV     3
43 #define TCP_FIN_WAIT1    4
44 #define TCP_FIN_WAIT2    5
45 #define TCP_TIME_WAIT    6
46 #define TCP_CLOSE        7
47 #define TCP_CLOSE_WAIT   8
48 #define TCP_LAST_ACK     9
49 #define TCP_LISTEN       10
50 #define TCP_CLOSING      11
51
52 enum {
53         TCP_NLA_PAD,
54         TCP_NLA_BUSY,
55         TCP_NLA_RWND_LIMITED,
56         TCP_NLA_SNDBUF_LIMITED,
57         TCP_NLA_DATA_SEGS_OUT,
58         TCP_NLA_TOTAL_RETRANS,
59         TCP_NLA_PACING_RATE,
60         TCP_NLA_DELIVERY_RATE,
61         TCP_NLA_SND_CWND,
62         TCP_NLA_REORDERING,
63         TCP_NLA_MIN_RTT,
64         TCP_NLA_RECUR_RETRANS,
65         TCP_NLA_DELIVERY_RATE_APP_LMT,
66         TCP_NLA_SNDQ_SIZE,
67         TCP_NLA_CA_STATE,
68         TCP_NLA_SND_SSTHRESH,
69 };
70
71 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
72 #define TCPOPT_EOL              0
73 #define TCPOPT_NOP              1
74 #define TCPOPT_MAXSEG           2
75 #define TCPOPT_WINDOW           3
76 #define TCPOPT_SACK_PERMITTED   4
77 #define TCPOPT_SACK             5
78 #define TCPOPT_TIMESTAMP        8
79 #define TCPOLEN_SACK_PERMITTED  2
80 #define TCPOLEN_WINDOW          3
81 #define TCPOLEN_MAXSEG          4
82 #define TCPOLEN_TIMESTAMP       10
83
84 #define SOL_TCP 6
85
86 #include <sys/types.h>
87 #include <sys/socket.h>
88 #include <stdint.h>
89 #include <endian.h>
90
91 typedef uint32_t tcp_seq;
92
93 #define TH_FIN 0x01
94 #define TH_SYN 0x02
95 #define TH_RST 0x04
96 #define TH_PUSH 0x08
97 #define TH_ACK 0x10
98 #define TH_URG 0x20
99
100 struct tcphdr {
101 #ifdef _GNU_SOURCE
102 #ifdef __GNUC__
103         __extension__
104 #endif
105         union { struct {
106
107         uint16_t source;
108         uint16_t dest;
109         uint32_t seq;
110         uint32_t ack_seq;
111 #if __BYTE_ORDER == __LITTLE_ENDIAN
112         uint16_t res1:4;
113         uint16_t doff:4;
114         uint16_t fin:1;
115         uint16_t syn:1;
116         uint16_t rst:1;
117         uint16_t psh:1;
118         uint16_t ack:1;
119         uint16_t urg:1;
120         uint16_t res2:2;
121 #else
122         uint16_t doff:4;
123         uint16_t res1:4;
124         uint16_t res2:2;
125         uint16_t urg:1;
126         uint16_t ack:1;
127         uint16_t psh:1;
128         uint16_t rst:1;
129         uint16_t syn:1;
130         uint16_t fin:1;
131 #endif
132         uint16_t window;
133         uint16_t check;
134         uint16_t urg_ptr;
135
136         }; struct {
137 #endif
138
139         uint16_t th_sport;
140         uint16_t th_dport;
141         uint32_t th_seq;
142         uint32_t th_ack;
143 #if __BYTE_ORDER == __LITTLE_ENDIAN
144         uint8_t th_x2:4;
145         uint8_t th_off:4;
146 #else
147         uint8_t th_off:4;
148         uint8_t th_x2:4;
149 #endif
150         uint8_t th_flags;
151         uint16_t th_win;
152         uint16_t th_sum;
153         uint16_t th_urp;
154
155 #ifdef _GNU_SOURCE
156         }; };
157 #endif
158 };
159 #endif
160
161 #ifdef _GNU_SOURCE
162 #define TCPI_OPT_TIMESTAMPS     1
163 #define TCPI_OPT_SACK           2
164 #define TCPI_OPT_WSCALE         4
165 #define TCPI_OPT_ECN            8
166
167 #define TCP_CA_Open             0
168 #define TCP_CA_Disorder         1
169 #define TCP_CA_CWR              2
170 #define TCP_CA_Recovery         3
171 #define TCP_CA_Loss             4
172
173 struct tcp_info {
174         uint8_t tcpi_state;
175         uint8_t tcpi_ca_state;
176         uint8_t tcpi_retransmits;
177         uint8_t tcpi_probes;
178         uint8_t tcpi_backoff;
179         uint8_t tcpi_options;
180         uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
181         uint8_t tcpi_delivery_rate_app_limited : 1;
182         uint32_t tcpi_rto;
183         uint32_t tcpi_ato;
184         uint32_t tcpi_snd_mss;
185         uint32_t tcpi_rcv_mss;
186         uint32_t tcpi_unacked;
187         uint32_t tcpi_sacked;
188         uint32_t tcpi_lost;
189         uint32_t tcpi_retrans;
190         uint32_t tcpi_fackets;
191         uint32_t tcpi_last_data_sent;
192         uint32_t tcpi_last_ack_sent;
193         uint32_t tcpi_last_data_recv;
194         uint32_t tcpi_last_ack_recv;
195         uint32_t tcpi_pmtu;
196         uint32_t tcpi_rcv_ssthresh;
197         uint32_t tcpi_rtt;
198         uint32_t tcpi_rttvar;
199         uint32_t tcpi_snd_ssthresh;
200         uint32_t tcpi_snd_cwnd;
201         uint32_t tcpi_advmss;
202         uint32_t tcpi_reordering;
203         uint32_t tcpi_rcv_rtt;
204         uint32_t tcpi_rcv_space;
205         uint32_t tcpi_total_retrans;
206         uint64_t tcpi_pacing_rate;
207         uint64_t tcpi_max_pacing_rate;
208         uint64_t tcpi_bytes_acked;
209         uint64_t tcpi_bytes_received;
210         uint32_t tcpi_segs_out;
211         uint32_t tcpi_segs_in;
212         uint32_t tcpi_notsent_bytes;
213         uint32_t tcpi_min_rtt;
214         uint32_t tcpi_data_segs_in;
215         uint32_t tcpi_data_segs_out;
216         uint64_t tcpi_delivery_rate;
217         uint64_t tcpi_busy_time;
218         uint64_t tcpi_rwnd_limited;
219         uint64_t tcpi_sndbuf_limited;
220 };
221
222 #define TCP_MD5SIG_MAXKEYLEN    80
223
224 #define TCP_MD5SIG_FLAG_PREFIX  1
225
226 struct tcp_md5sig {
227         struct sockaddr_storage tcpm_addr;
228         uint8_t tcpm_flags;
229         uint8_t tcpm_prefixlen;
230         uint16_t tcpm_keylen;
231         uint32_t __tcpm_pad;
232         uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
233 };
234
235 struct tcp_diag_md5sig {
236         uint8_t tcpm_family;
237         uint8_t tcpm_prefixlen;
238         uint16_t tcpm_keylen;
239         uint32_t tcpm_addr[4];
240         uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
241 };
242
243 struct tcp_repair_window {
244         uint32_t snd_wl1;
245         uint32_t snd_wnd;
246         uint32_t max_window;
247         uint32_t rcv_wnd;
248         uint32_t rcv_wup;
249 };
250
251 #endif
252
253 #endif