4 Copyright 1995 Philip Homburg
10 #define IP_TCP_MIN_HDR_SIZE (IP_MIN_HDR_SIZE+TCP_MIN_HDR_SIZE)
12 #define TCP_CONN_HASH_SHIFT 4
13 #define TCP_CONN_HASH_NR (1 << TCP_CONN_HASH_SHIFT)
15 typedef struct tcp_port
23 ipaddr_t tp_subnetmask
;
25 struct tcp_conn
*tp_snd_head
;
26 struct tcp_conn
*tp_snd_tail
;
28 struct tcp_conn
*tp_conn_hash
[TCP_CONN_HASH_NR
][4];
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
40 #define TPS_SETPROTO 1
45 #define TFL_LISTEN_MAX 5
49 unsigned long tf_flags
;
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
;
64 int tf_error
; /* Error for nonblocking connect */
65 tcp_cookie_t tf_cookie
;
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
87 typedef struct tcp_conn
91 int tc_busy
; /* do not steal buffer when a connection is
102 int tc_connInprogress
;
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
113 u32_t tc_SND_PSH
; /* push pointer, data should be pushed until
114 * the push pointer is reached */
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 */
122 /* round trip calculation. */
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 */
132 struct tcp_conn
*tc_send_link
;
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
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 */
163 struct timer tc_transmit_timer
;
164 u32_t tc_transmit_seq
;
166 clock_t tc_stt
; /* time of first send after last ack */
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
186 #define TCF_DEBUG 0x1000
191 #define TCS_SYN_RECEIVED 2
192 #define TCS_SYN_SENT 3
193 #define TCS_ESTABLISHED 4
194 #define TCS_CLOSING 5
197 void 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
));
199 void tcp_fd_read
ARGS(( tcp_conn_t
*tcp_conn
, int enq
));
200 unsigned tcp_sel_read
ARGS(( tcp_conn_t
*tcp_conn
));
201 void tcp_rsel_read
ARGS(( tcp_conn_t
*tcp_conn
));
202 void tcp_bytesavailable
ARGS(( tcp_fd_t
*tcp_fd
, int *bytesp
));
205 void tcp_conn_write
ARGS(( tcp_conn_t
*tcp_conn
, int enq
));
206 void tcp_release_retrans
ARGS(( tcp_conn_t
*tcp_conn
, u32_t seg_ack
,
208 void tcp_fast_retrans
ARGS(( tcp_conn_t
*tcp_conn
));
209 void tcp_set_send_timer
ARGS(( tcp_conn_t
*tcp_conn
));
210 void tcp_fd_write
ARGS(( tcp_conn_t
*tcp_conn
));
211 unsigned tcp_sel_write
ARGS(( tcp_conn_t
*tcp_conn
));
212 void tcp_rsel_write
ARGS(( tcp_conn_t
*tcp_conn
));
213 void tcp_close_connection
ARGS(( tcp_conn_t
*tcp_conn
,
215 void tcp_port_write
ARGS(( tcp_port_t
*tcp_port
));
216 void tcp_shutdown
ARGS(( tcp_conn_t
*tcp_conn
));
219 void tcp_extract_ipopt
ARGS(( tcp_conn_t
*tcp_conn
,
221 void tcp_extract_tcpopt
ARGS(( tcp_conn_t
*tcp_conn
,
222 tcp_hdr_t
*tcp_hdr
, size_t *mssp
));
223 void tcp_get_ipopt
ARGS(( tcp_conn_t
*tcp_conn
, ip_hdropt_t
225 void tcp_get_tcpopt
ARGS(( tcp_conn_t
*tcp_conn
, tcp_hdropt_t
227 acc_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
));
229 u16_t tcp_pack_oneCsum
ARGS(( ip_hdr_t
*ip_hdr
, acc_t
*tcp_pack
));
230 int tcp_check_conn
ARGS(( tcp_conn_t
*tcp_conn
));
231 void tcp_print_pack
ARGS(( ip_hdr_t
*ip_hdr
, tcp_hdr_t
*tcp_hdr
));
232 void tcp_print_state
ARGS(( tcp_conn_t
*tcp_conn
));
233 void tcp_print_conn
ARGS(( tcp_conn_t
*tcp_conn
));
234 int tcp_LEmod4G
ARGS(( u32_t n1
, u32_t n2
));
235 int tcp_Lmod4G
ARGS(( u32_t n1
, u32_t n2
));
236 int tcp_GEmod4G
ARGS(( u32_t n1
, u32_t n2
));
237 int tcp_Gmod4G
ARGS(( u32_t n1
, u32_t n2
));
240 void tcp_restart_connect
ARGS(( tcp_conn_t
*tcp_conn
));
241 int tcp_su4listen
ARGS(( tcp_fd_t
*tcp_fd
, tcp_conn_t
*tcp_conn
,
243 void tcp_reply_ioctl
ARGS(( tcp_fd_t
*tcp_fd
, int reply
));
244 void tcp_reply_write
ARGS(( tcp_fd_t
*tcp_fd
, size_t reply
));
245 void tcp_reply_read
ARGS(( tcp_fd_t
*tcp_fd
, size_t reply
));
246 void tcp_notreach
ARGS(( tcp_conn_t
*tcp_conn
));
247 void tcp_mtu_exceeded
ARGS(( tcp_conn_t
*tcp_conn
));
248 void tcp_mtu_incr
ARGS(( tcp_conn_t
*tcp_conn
));
250 #define TCP_FD_NR (10*IP_PORT_MAX)
251 #define TCP_CONN_NR (2*TCP_FD_NR)
253 EXTERN tcp_port_t
*tcp_port_table
;
254 EXTERN tcp_conn_t tcp_conn_table
[TCP_CONN_NR
];
255 EXTERN tcp_fd_t tcp_fd_table
[TCP_FD_NR
];
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))
262 #endif /* TCP_INT_H */
265 * $PchId: tcp_int.h,v 1.17 2005/06/28 14:21:08 philip Exp $