add TCP_INFO and TCP_MD5SIG socket option related structures
[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
31 #define TCP_ESTABLISHED  1
32 #define TCP_SYN_SENT     2
33 #define TCP_SYN_RECV     3
34 #define TCP_FIN_WAIT1    4
35 #define TCP_FIN_WAIT2    5
36 #define TCP_TIME_WAIT    6
37 #define TCP_CLOSE        7
38 #define TCP_CLOSE_WAIT   8
39 #define TCP_LAST_ACK     9
40 #define TCP_LISTEN       10
41 #define TCP_CLOSING      11
42
43 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
44 #define SOL_TCP 6
45 #include <sys/types.h>
46 #include <sys/socket.h>
47 #endif
48
49 #ifdef _GNU_SOURCE
50 #include <endian.h>
51 struct tcphdr
52 {
53         u_int16_t source;
54         u_int16_t dest;
55         u_int32_t seq;
56         u_int32_t ack_seq;
57 #if __BYTE_ORDER == __LITTLE_ENDIAN
58         u_int16_t res1:4;
59         u_int16_t doff:4;
60         u_int16_t fin:1;
61         u_int16_t syn:1;
62         u_int16_t rst:1;
63         u_int16_t psh:1;
64         u_int16_t ack:1;
65         u_int16_t urg:1;
66         u_int16_t res2:2;
67 #else
68         u_int16_t doff:4;
69         u_int16_t res1:4;
70         u_int16_t res2:2;
71         u_int16_t urg:1;
72         u_int16_t ack:1;
73         u_int16_t psh:1;
74         u_int16_t rst:1;
75         u_int16_t syn:1;
76         u_int16_t fin:1;
77 #endif
78         u_int16_t window;
79         u_int16_t check;
80         u_int16_t urg_ptr;
81 };
82
83 #define TCPI_OPT_TIMESTAMPS     1
84 #define TCPI_OPT_SACK           2
85 #define TCPI_OPT_WSCALE         4
86 #define TCPI_OPT_ECN            8
87
88 #define TCP_CA_Open             0
89 #define TCP_CA_Disorder         1
90 #define TCP_CA_CWR              2
91 #define TCP_CA_Recovery         3
92 #define TCP_CA_Loss             4
93
94 struct tcp_info
95 {
96         u_int8_t tcpi_state;
97         u_int8_t tcpi_ca_state;
98         u_int8_t tcpi_retransmits;
99         u_int8_t tcpi_probes;
100         u_int8_t tcpi_backoff;
101         u_int8_t tcpi_options;
102         u_int8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
103         u_int32_t tcpi_rto;
104         u_int32_t tcpi_ato;
105         u_int32_t tcpi_snd_mss;
106         u_int32_t tcpi_rcv_mss;
107         u_int32_t tcpi_unacked;
108         u_int32_t tcpi_sacked;
109         u_int32_t tcpi_lost;
110         u_int32_t tcpi_retrans;
111         u_int32_t tcpi_fackets;
112         u_int32_t tcpi_last_data_sent;
113         u_int32_t tcpi_last_ack_sent;
114         u_int32_t tcpi_last_data_recv;
115         u_int32_t tcpi_last_ack_recv;
116         u_int32_t tcpi_pmtu;
117         u_int32_t tcpi_rcv_ssthresh;
118         u_int32_t tcpi_rtt;
119         u_int32_t tcpi_rttvar;
120         u_int32_t tcpi_snd_ssthresh;
121         u_int32_t tcpi_snd_cwnd;
122         u_int32_t tcpi_advmss;
123         u_int32_t tcpi_reordering;
124         u_int32_t tcpi_rcv_rtt;
125         u_int32_t tcpi_rcv_space;
126         u_int32_t tcpi_total_retrans;
127 };
128
129 #define TCP_MD5SIG_MAXKEYLEN    80
130
131 struct tcp_md5sig
132 {
133         struct sockaddr_storage tcpm_addr;
134         u_int16_t __tcpm_pad1;
135         u_int16_t tcpm_keylen;
136         u_int32_t __tcpm_pad2;
137         u_int8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
138 };
139
140 #endif
141
142 #endif