if (best_conn)
{
- assert(!best_conn->tc_fd);
if (!listen_conn)
+ {
+ assert(!best_conn->tc_fd);
return best_conn;
+ }
+ assert(listen_conn->tc_connInprogress);
tcp_fd= listen_conn->tc_fd;
- assert(tcp_fd && listen_conn->tc_connInprogress &&
- tcp_fd->tf_conn == listen_conn);
+ assert(tcp_fd);
+ assert((tcp_fd->tf_flags & TFF_LISTENQ) ||
+ tcp_fd->tf_conn == listen_conn);
if (best_conn->tc_state != TCS_CLOSED)
tcp_close_connection(best_conn, ENOCONN);
if (tcp_fd->tf_flags & TFF_LISTENQ)
{
/* Special code for listen queues */
- if (tcp_conn->tc_state == TCS_CLOSED)
- {
- assert(NOT_IMPLEMENTED);
- reply= tcp_conn->tc_error;
- tcp_conn->tc_fd= NULL;
- }
+ assert(tcp_conn->tc_state != TCS_CLOSED);
/* Reply for select */
if ((tcp_fd->tf_flags & TFF_SEL_READ) &&
THIS_FILE
-#define NOT_IMPLEMENTED 0
-
FORWARD void create_RST ARGS(( tcp_conn_t *tcp_conn,
ip_hdr_t *ip_hdr, tcp_hdr_t *tcp_hdr, int data_len ));
FORWARD void process_data ARGS(( tcp_conn_t *tcp_conn,
u32_t seg_ack, seg_seq, rcv_hi, snd_una, snd_nxt;
u16_t seg_wnd, mtu;
size_t mss;
- int acceptable_ACK, segm_acceptable, send_rst;
+ int acceptable_ACK, segm_acceptable, send_rst, close_connection;
ip_hdr_len= (ip_hdr->ih_vers_ihl & IH_IHL_MASK) << 2;
tcp_hdr_len= (tcp_hdr->th_data_off & TH_DO_MASK) >> 2;
rcv_hi++;
send_rst= tcp_Lmod4G(seg_seq, tcp_conn->tc_IRS) ||
tcp_Gmod4G(seg_seq, tcp_conn->tc_RCV_NXT+0x10000);
+ close_connection= 0;
if (!data_len)
{
error "connection refused"
exit
*/
- if (tcp_hdr_flags & THF_RST)
- {
- if (tcp_conn->tc_orglisten)
- {
- assert(NOT_IMPLEMENTED);
- connuser= tcp_conn->tc_fd;
- tcp_conn->tc_connInprogress= 0;
- tcp_conn->tc_fd= NULL;
-
- tcp_close_connection (tcp_conn, ECONNREFUSED);
-
- /* Pick a new ISS next time */
- tcp_conn->tc_ISS= 0;
+ if (tcp_hdr_flags & THF_RST)
+ close_connection= 1;
- if (connuser)
- {
- (void)tcp_su4listen(connuser, tcp_conn,
- 0 /* !do_listenq */);
- }
- break;
- }
- else
- {
- tcp_close_connection(tcp_conn, ECONNREFUSED);
- break;
- }
- }
/*
SYN in window ?
initiated by a LISTEN ?
if ((tcp_hdr_flags & THF_SYN) && tcp_GEmod4G(seg_seq,
tcp_conn->tc_RCV_NXT))
{
- if (tcp_conn->tc_orglisten)
- {
- assert(NOT_IMPLEMENTED);
+ close_connection= 1;
+ }
- connuser= tcp_conn->tc_fd;
+ if (close_connection)
+ {
+ if (!tcp_conn->tc_orglisten)
+ {
+ tcp_close_connection(tcp_conn, ECONNREFUSED);
+ break;
+ }
+ connuser= tcp_conn->tc_fd;
+ assert(connuser);
+ if (connuser->tf_flags & TFF_LISTENQ)
+ {
+ tcp_close_connection (tcp_conn,
+ ECONNREFUSED);
+ }
+ else
+ {
tcp_conn->tc_connInprogress= 0;
tcp_conn->tc_fd= NULL;
- tcp_close_connection(tcp_conn, ECONNRESET);
- if (connuser)
- {
- (void)tcp_su4listen(connuser, tcp_conn,
- 0 /* !do_listenq */);
- }
- break;
+ tcp_close_connection (tcp_conn,
+ ECONNREFUSED);
+
+ /* Pick a new ISS next time */
+ tcp_conn->tc_ISS= 0;
+
+ (void)tcp_su4listen(connuser, tcp_conn,
+ 0 /* !do_listenq */);
}
- tcp_close_connection(tcp_conn, ECONNRESET);
break;
}
/*
tcp_conn_t *tcp_conn;
int error;
{
+ int i;
tcp_port_t *tcp_port;
tcp_fd_t *tcp_fd;
tcp_conn_t *tc;
tcp_conn->tc_state= TCS_CLOSED;
DBLOCK(0x10, tcp_print_state(tcp_conn); printf("\n"));
- if (tcp_fd)
+ if (tcp_fd && (tcp_fd->tf_flags & TFF_LISTENQ))
{
+ for (i= 0; i<TFL_LISTEN_MAX; i++)
+ {
+ if (tcp_fd->tf_listenq[i] == tcp_conn)
+ break;
+ }
+ assert(i < TFL_LISTEN_MAX);
+ tcp_fd->tf_listenq[i]= NULL;
+
+ assert(tcp_conn->tc_connInprogress);
+ tcp_conn->tc_connInprogress= 0;
+
+ tcp_conn->tc_fd= NULL;
+ tcp_fd= NULL;
+ }
+ else if (tcp_fd)
+ {
+
tcp_conn->tc_busy++;
assert(tcp_fd->tf_conn == tcp_conn);