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