source: trunk/minix/servers/inet/generic/tcp_int.h@ 11

Last change on this file since 11 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 7.4 KB
Line 
1/*
2tcp_int.h
3
4Copyright 1995 Philip Homburg
5*/
6
7#ifndef TCP_INT_H
8#define TCP_INT_H
9
10#define IP_TCP_MIN_HDR_SIZE (IP_MIN_HDR_SIZE+TCP_MIN_HDR_SIZE)
11
12#define TCP_CONN_HASH_SHIFT 4
13#define TCP_CONN_HASH_NR (1 << TCP_CONN_HASH_SHIFT)
14
15typedef struct tcp_port
16{
17 int tp_ipdev;
18 int tp_flags;
19 int tp_state;
20 int tp_ipfd;
21 acc_t *tp_pack;
22 ipaddr_t tp_ipaddr;
23 ipaddr_t tp_subnetmask;
24 u16_t tp_mtu;
25 struct tcp_conn *tp_snd_head;
26 struct tcp_conn *tp_snd_tail;
27 event_t tp_snd_event;
28 struct tcp_conn *tp_conn_hash[TCP_CONN_HASH_NR][4];
29} tcp_port_t;
30
31#define TPF_EMPTY 0x0
32#define TPF_SUSPEND 0x1
33#define TPF_READ_IP 0x2
34#define TPF_READ_SP 0x4
35#define TPF_WRITE_IP 0x8
36#define TPF_WRITE_SP 0x10
37#define TPF_DELAY_TCP 0x40
38
39#define TPS_EMPTY 0
40#define TPS_SETPROTO 1
41#define TPS_GETCONF 2
42#define TPS_MAIN 3
43#define TPS_ERROR 4
44
45#define TFL_LISTEN_MAX 5
46
47typedef struct tcp_fd
48{
49 unsigned long tf_flags;
50 tcp_port_t *tf_port;
51 int tf_srfd;
52 ioreq_t tf_ioreq;
53 nwio_tcpconf_t tf_tcpconf;
54 nwio_tcpopt_t tf_tcpopt;
55 get_userdata_t tf_get_userdata;
56 put_userdata_t tf_put_userdata;
57 select_res_t tf_select_res;
58 struct tcp_conn *tf_conn;
59 struct tcp_conn *tf_listenq[TFL_LISTEN_MAX];
60 size_t tf_write_offset;
61 size_t tf_write_count;
62 size_t tf_read_offset;
63 size_t tf_read_count;
64 int tf_error; /* Error for nonblocking connect */
65 tcp_cookie_t tf_cookie;
66} tcp_fd_t;
67
68#define TFF_EMPTY 0x0
69#define TFF_INUSE 0x1
70#define TFF_READ_IP 0x2
71#define TFF_WRITE_IP 0x4
72#define TFF_IOCTL_IP 0x8
73#define TFF_CONF_SET 0x10
74#define TFF_IOC_INIT_SP 0x20
75#define TFF_LISTENQ 0x40
76#define TFF_CONNECTING 0x80
77#define TFF_CONNECTED 0x100
78#define TFF_WR_URG 0x200
79#define TFF_PUSH_DATA 0x400
80#define TFF_RECV_URG 0x800
81#define TFF_SEL_READ 0x1000
82#define TFF_SEL_WRITE 0x2000
83#define TFF_SEL_EXCEPT 0x4000
84#define TFF_DEL_RST 0x8000
85#define TFF_COOKIE 0x10000
86
87typedef struct tcp_conn
88{
89 int tc_flags;
90 int tc_state;
91 int tc_busy; /* do not steal buffer when a connection is
92 * busy
93 */
94 tcp_port_t *tc_port;
95 tcp_fd_t *tc_fd;
96
97 tcpport_t tc_locport;
98 ipaddr_t tc_locaddr;
99 tcpport_t tc_remport;
100 ipaddr_t tc_remaddr;
101
102 int tc_connInprogress;
103 int tc_orglisten;
104 clock_t tc_senddis;
105
106 /* Sending side */
107 u32_t tc_ISS; /* initial sequence number */
108 u32_t tc_SND_UNA; /* least unacknowledged sequence number */
109 u32_t tc_SND_TRM; /* next sequence number to be transmitted */
110 u32_t tc_SND_NXT; /* next sequence number for new data */
111 u32_t tc_SND_UP; /* urgent pointer, first sequence number not
112 * urgent */
113 u32_t tc_SND_PSH; /* push pointer, data should be pushed until
114 * the push pointer is reached */
115
116 u32_t tc_snd_cwnd; /* highest sequence number to be sent */
117 u32_t tc_snd_cthresh; /* threshold for send window */
118 u32_t tc_snd_cinc; /* increment for send window threshold */
119 u16_t tc_snd_wnd; /* max send queue size */
120 u16_t tc_snd_dack; /* # of duplicate ACKs */
121
122 /* round trip calculation. */
123 clock_t tc_rt_time;
124 u32_t tc_rt_seq;
125 u32_t tc_rt_threshold;
126 clock_t tc_artt; /* Avg. retransmission time. Scaled. */
127 clock_t tc_drtt; /* Diviation, also scaled. */
128 clock_t tc_rtt; /* Computed retrans time */
129
130 acc_t *tc_send_data;
131 acc_t *tc_frag2send;
132 struct tcp_conn *tc_send_link;
133
134 /* Receiving side */
135 u32_t tc_IRS;
136 u32_t tc_RCV_LO;
137 u32_t tc_RCV_NXT;
138 u32_t tc_RCV_HI;
139 u32_t tc_RCV_UP;
140
141 u16_t tc_rcv_wnd;
142 acc_t *tc_rcvd_data;
143 acc_t *tc_adv_data;
144 u32_t tc_adv_seq;
145
146 /* Keep alive. Record SDN_NXT and RCV_NXT in tc_ka_snd and
147 * tc_ka_rcv when setting the keepalive timer to detect
148 * any activity that may have happend before the timer
149 * expired.
150 */
151 u32_t tc_ka_snd;
152 u32_t tc_ka_rcv;
153 clock_t tc_ka_time;
154
155 acc_t *tc_remipopt;
156 acc_t *tc_tcpopt;
157 u8_t tc_tos;
158 u8_t tc_ttl;
159 u16_t tc_max_mtu; /* Max. negotiated (or selected) MTU */
160 u16_t tc_mtu; /* discovered PMTU */
161 clock_t tc_mtutim; /* Last time MTU/TCF_PMTU flag was changed */
162
163 struct timer tc_transmit_timer;
164 u32_t tc_transmit_seq;
165 clock_t tc_0wnd_to;
166 clock_t tc_stt; /* time of first send after last ack */
167 clock_t tc_rt_dead;
168
169 int tc_error;
170 int tc_inconsistent;
171} tcp_conn_t;
172
173#define TCF_EMPTY 0x0
174#define TCF_INUSE 0x1
175#define TCF_FIN_RECV 0x2
176#define TCF_RCV_PUSH 0x4
177#define TCF_MORE2WRITE 0x8
178#define TCF_SEND_ACK 0x10
179#define TCF_FIN_SENT 0x20
180#define TCF_BSD_URG 0x40
181#define TCF_NO_PUSH 0x80
182#define TCF_PUSH_NOW 0x100
183#define TCF_PMTU 0x200
184
185#if DEBUG & 0x200
186#define TCF_DEBUG 0x1000
187#endif
188
189#define TCS_CLOSED 0
190#define TCS_LISTEN 1
191#define TCS_SYN_RECEIVED 2
192#define TCS_SYN_SENT 3
193#define TCS_ESTABLISHED 4
194#define TCS_CLOSING 5
195
196/* tcp_recv.c */
197void tcp_frag2conn ARGS(( tcp_conn_t *tcp_conn, ip_hdr_t *ip_hdr,
198 tcp_hdr_t *tcp_hdr, acc_t *tcp_data, size_t data_len ));
199void tcp_fd_read ARGS(( tcp_conn_t *tcp_conn, int enq ));
200unsigned tcp_sel_read ARGS(( tcp_conn_t *tcp_conn ));
201void tcp_rsel_read ARGS(( tcp_conn_t *tcp_conn ));
202void tcp_bytesavailable ARGS(( tcp_fd_t *tcp_fd, int *bytesp ));
203
204/* tcp_send.c */
205void tcp_conn_write ARGS(( tcp_conn_t *tcp_conn, int enq ));
206void tcp_release_retrans ARGS(( tcp_conn_t *tcp_conn, u32_t seg_ack,
207 U16_t new_win ));
208void tcp_fast_retrans ARGS(( tcp_conn_t *tcp_conn ));
209void tcp_set_send_timer ARGS(( tcp_conn_t *tcp_conn ));
210void tcp_fd_write ARGS(( tcp_conn_t *tcp_conn ));
211unsigned tcp_sel_write ARGS(( tcp_conn_t *tcp_conn ));
212void tcp_rsel_write ARGS(( tcp_conn_t *tcp_conn ));
213void tcp_close_connection ARGS(( tcp_conn_t *tcp_conn,
214 int error ));
215void tcp_port_write ARGS(( tcp_port_t *tcp_port ));
216void tcp_shutdown ARGS(( tcp_conn_t *tcp_conn ));
217
218/* tcp_lib.c */
219void tcp_extract_ipopt ARGS(( tcp_conn_t *tcp_conn,
220 ip_hdr_t *ip_hdr ));
221void tcp_extract_tcpopt ARGS(( tcp_conn_t *tcp_conn,
222 tcp_hdr_t *tcp_hdr, size_t *mssp ));
223void tcp_get_ipopt ARGS(( tcp_conn_t *tcp_conn, ip_hdropt_t
224 *ip_hdropt ));
225void tcp_get_tcpopt ARGS(( tcp_conn_t *tcp_conn, tcp_hdropt_t
226 *tcp_hdropt ));
227acc_t *tcp_make_header ARGS(( tcp_conn_t *tcp_conn,
228 ip_hdr_t **ref_ip_hdr, tcp_hdr_t **ref_tcp_hdr, acc_t *data ));
229u16_t tcp_pack_oneCsum ARGS(( ip_hdr_t *ip_hdr, acc_t *tcp_pack ));
230int tcp_check_conn ARGS(( tcp_conn_t *tcp_conn ));
231void tcp_print_pack ARGS(( ip_hdr_t *ip_hdr, tcp_hdr_t *tcp_hdr ));
232void tcp_print_state ARGS(( tcp_conn_t *tcp_conn ));
233void tcp_print_conn ARGS(( tcp_conn_t *tcp_conn ));
234int tcp_LEmod4G ARGS(( u32_t n1, u32_t n2 ));
235int tcp_Lmod4G ARGS(( u32_t n1, u32_t n2 ));
236int tcp_GEmod4G ARGS(( u32_t n1, u32_t n2 ));
237int tcp_Gmod4G ARGS(( u32_t n1, u32_t n2 ));
238
239/* tcp.c */
240void tcp_restart_connect ARGS(( tcp_conn_t *tcp_conn ));
241int tcp_su4listen ARGS(( tcp_fd_t *tcp_fd, tcp_conn_t *tcp_conn,
242 int do_listenq ));
243void tcp_reply_ioctl ARGS(( tcp_fd_t *tcp_fd, int reply ));
244void tcp_reply_write ARGS(( tcp_fd_t *tcp_fd, size_t reply ));
245void tcp_reply_read ARGS(( tcp_fd_t *tcp_fd, size_t reply ));
246void tcp_notreach ARGS(( tcp_conn_t *tcp_conn ));
247void tcp_mtu_exceeded ARGS(( tcp_conn_t *tcp_conn ));
248void tcp_mtu_incr ARGS(( tcp_conn_t *tcp_conn ));
249
250#define TCP_FD_NR (10*IP_PORT_MAX)
251#define TCP_CONN_NR (2*TCP_FD_NR)
252
253EXTERN tcp_port_t *tcp_port_table;
254EXTERN tcp_conn_t tcp_conn_table[TCP_CONN_NR];
255EXTERN tcp_fd_t tcp_fd_table[TCP_FD_NR];
256
257#define tcp_Lmod4G(n1,n2) (!!(((n1)-(n2)) & 0x80000000L))
258#define tcp_GEmod4G(n1,n2) (!(((n1)-(n2)) & 0x80000000L))
259#define tcp_Gmod4G(n1,n2) (!!(((n2)-(n1)) & 0x80000000L))
260#define tcp_LEmod4G(n1,n2) (!(((n2)-(n1)) & 0x80000000L))
261
262#endif /* TCP_INT_H */
263
264/*
265 * $PchId: tcp_int.h,v 1.17 2005/06/28 14:21:08 philip Exp $
266 */
Note: See TracBrowser for help on using the repository browser.