tcp.h
001:
002:
003:
004:
005:
006:
007:
008:
009:
010:
011:
012:
013:
014:
015:
016:
017:
018:
019:
020:
021:
022:
023:
024:
025:
026:
027:
028:
029:
030:
031:
032: #ifndef _NETINET_TCP_H
033: #define _NETINET_TCP_H 1
034:
035: #include <features.h>
036:
037:
038:
039:
040: #define TCP_NODELAY 1
041: #define TCP_MAXSEG 2
042: #define TCP_CORK 3
043: #define TCP_KEEPIDLE 4
044: #define TCP_KEEPINTVL 5
045: #define TCP_KEEPCNT 6
046: #define TCP_SYNCNT 7
047: #define TCP_LINGER2 8
048: #define TCP_DEFER_ACCEPT 9
049: #define TCP_WINDOW_CLAMP 10
050: #define TCP_INFO 11
051: #define TCP_QUICKACK 12
052: #define TCP_CONGESTION 13
053: #define TCP_MD5SIG 14
054:
055: #ifdef __USE_MISC
056: # include <sys/types.h>
057: # include <sys/socket.h>
058:
059: # ifdef __FAVOR_BSD
060: typedef u_int32_t tcp_seq;
061:
062:
063:
064:
065: struct tcphdr
066: {
067: u_int16_t th_sport;
068: u_int16_t th_dport;
069: tcp_seq th_seq;
070: tcp_seq th_ack;
071: # if __BYTE_ORDER == __LITTLE_ENDIAN
072: u_int8_t th_x2:4;
073: u_int8_t th_off:4;
074: # endif
075: # if __BYTE_ORDER == __BIG_ENDIAN
076: u_int8_t th_off:4;
077: u_int8_t th_x2:4;
078: # endif
079: u_int8_t th_flags;
080: # define TH_FIN 0x01
081: # define TH_SYN 0x02
082: # define TH_RST 0x04
083: # define TH_PUSH 0x08
084: # define TH_ACK 0x10
085: # define TH_URG 0x20
086: u_int16_t th_win;
087: u_int16_t th_sum;
088: u_int16_t th_urp;
089: };
090:
091: # else
092: struct tcphdr
093: {
094: u_int16_t source;
095: u_int16_t dest;
096: u_int32_t seq;
097: u_int32_t ack_seq;
098: # if __BYTE_ORDER == __LITTLE_ENDIAN
099: u_int16_t res1:4;
100: u_int16_t doff:4;
101: u_int16_t fin:1;
102: u_int16_t syn:1;
103: u_int16_t rst:1;
104: u_int16_t psh:1;
105: u_int16_t ack:1;
106: u_int16_t urg:1;
107: u_int16_t res2:2;
108: # elif __BYTE_ORDER == __BIG_ENDIAN
109: u_int16_t doff:4;
110: u_int16_t res1:4;
111: u_int16_t res2:2;
112: u_int16_t urg:1;
113: u_int16_t ack:1;
114: u_int16_t psh:1;
115: u_int16_t rst:1;
116: u_int16_t syn:1;
117: u_int16_t fin:1;
118: # else
119: # error "Adjust your <bits/endian.h> defines"
120: # endif
121: u_int16_t window;
122: u_int16_t check;
123: u_int16_t urg_ptr;
124: };
125: # endif
126:
127: enum
128: {
129: TCP_ESTABLISHED = 1,
130: TCP_SYN_SENT,
131: TCP_SYN_RECV,
132: TCP_FIN_WAIT1,
133: TCP_FIN_WAIT2,
134: TCP_TIME_WAIT,
135: TCP_CLOSE,
136: TCP_CLOSE_WAIT,
137: TCP_LAST_ACK,
138: TCP_LISTEN,
139: TCP_CLOSING
140: };
141:
142: # define TCPOPT_EOL 0
143: # define TCPOPT_NOP 1
144: # define TCPOPT_MAXSEG 2
145: # define TCPOLEN_MAXSEG 4
146: # define TCPOPT_WINDOW 3
147: # define TCPOLEN_WINDOW 3
148: # define TCPOPT_SACK_PERMITTED 4
149: # define TCPOLEN_SACK_PERMITTED 2
150: # define TCPOPT_SACK 5
151: # define TCPOPT_TIMESTAMP 8
152: # define TCPOLEN_TIMESTAMP 10
153: # define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2)
154:
155: # define TCPOPT_TSTAMP_HDR \
156: (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
157:
158:
159:
160:
161:
162:
163:
164: # define TCP_MSS 512
165:
166: # define TCP_MAXWIN 65535
167:
168: # define TCP_MAX_WINSHIFT 14
169:
170: # define SOL_TCP 6
171:
172:
173: # define TCPI_OPT_TIMESTAMPS 1
174: # define TCPI_OPT_SACK 2
175: # define TCPI_OPT_WSCALE 4
176: # define TCPI_OPT_ECN 8
177:
178:
179: enum tcp_ca_state
180: {
181: TCP_CA_Open = 0,
182: TCP_CA_Disorder = 1,
183: TCP_CA_CWR = 2,
184: TCP_CA_Recovery = 3,
185: TCP_CA_Loss = 4
186: };
187:
188: struct tcp_info
189: {
190: u_int8_t tcpi_state;
191: u_int8_t tcpi_ca_state;
192: u_int8_t tcpi_retransmits;
193: u_int8_t tcpi_probes;
194: u_int8_t tcpi_backoff;
195: u_int8_t tcpi_options;
196: u_int8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
197:
198: u_int32_t tcpi_rto;
199: u_int32_t tcpi_ato;
200: u_int32_t tcpi_snd_mss;
201: u_int32_t tcpi_rcv_mss;
202:
203: u_int32_t tcpi_unacked;
204: u_int32_t tcpi_sacked;
205: u_int32_t tcpi_lost;
206: u_int32_t tcpi_retrans;
207: u_int32_t tcpi_fackets;
208:
209:
210: u_int32_t tcpi_last_data_sent;
211: u_int32_t tcpi_last_ack_sent;
212: u_int32_t tcpi_last_data_recv;
213: u_int32_t tcpi_last_ack_recv;
214:
215:
216: u_int32_t tcpi_pmtu;
217: u_int32_t tcpi_rcv_ssthresh;
218: u_int32_t tcpi_rtt;
219: u_int32_t tcpi_rttvar;
220: u_int32_t tcpi_snd_ssthresh;
221: u_int32_t tcpi_snd_cwnd;
222: u_int32_t tcpi_advmss;
223: u_int32_t tcpi_reordering;
224:
225: u_int32_t tcpi_rcv_rtt;
226: u_int32_t tcpi_rcv_space;
227:
228: u_int32_t tcpi_total_retrans;
229: };
230:
231:
232:
233: #define TCP_MD5SIG_MAXKEYLEN 80
234:
235: struct tcp_md5sig
236: {
237: struct sockaddr_storage tcpm_addr;
238: u_int16_t __tcpm_pad1;
239: u_int16_t tcpm_keylen;
240: u_int32_t __tcpm_pad2;
241: u_int8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
242: };
243:
244: #endif
245:
246: #endif
247:
© Andrew Scott 2006 -
2024,
All Rights Reserved