Changeset f343a16 in mainline for uspace/srv/net/tl/tcp/conn.c


Ignore:
Timestamp:
2011-10-23T23:43:38Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6df418c4
Parents:
32aea9f4
Message:

Connection state change when FIN is sent.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tl/tcp/conn.c

    r32aea9f4 rf343a16  
    130130        tcp_tqueue_ctrl_seg(conn, CTL_SYN);
    131131        conn->cstate = st_syn_sent;
     132}
     133
     134/** FIN has been sent.
     135 *
     136 * This function should be called when FIN is sent over the connection,
     137 * as a result the connection state is changed appropriately.
     138 */
     139void tcp_conn_fin_sent(tcp_conn_t *conn)
     140{
     141        switch (conn->cstate) {
     142        case st_syn_received:
     143        case st_established:
     144                log_msg(LVL_DEBUG, "FIN sent -> Fin-Wait-1");
     145                conn->cstate = st_fin_wait_1;
     146                break;
     147        case st_close_wait:
     148                log_msg(LVL_DEBUG, "FIN sent -> Close-Wait");
     149                conn->cstate = st_last_ack;
     150                break;
     151        default:
     152                assert(false);
     153        }
    132154}
    133155
     
    734756                conn->rcv_wnd--;
    735757
    736                 /* TODO Change connection state */
     758                /* Change connection state */
     759                switch (conn->cstate) {
     760                case st_listen:
     761                case st_syn_sent:
     762                case st_closed:
     763                        /* Connection not synchronized */
     764                        assert(false);
     765                case st_syn_received:
     766                case st_established:
     767                        log_msg(LVL_DEBUG, "FIN received -> Close-Wait");
     768                        conn->cstate = st_close_wait;
     769                        break;
     770                case st_fin_wait_1:
     771                        log_msg(LVL_DEBUG, "FIN received -> Closing");
     772                        conn->cstate = st_closing;
     773                        break;
     774                case st_fin_wait_2:
     775                        log_msg(LVL_DEBUG, "FIN received -> Time-Wait");
     776                        conn->cstate = st_time_wait;
     777                        /* XXX start time-wait timer */
     778                        break;
     779                case st_close_wait:
     780                case st_closing:
     781                case st_last_ack:
     782                        /* Do nothing */
     783                        break;
     784                case st_time_wait:
     785                        /* XXX Restart the 2 MSL time-wait timeout */
     786                        break;
     787                }
    737788
    738789                /* Add FIN to the receive buffer */
Note: See TracChangeset for help on using the changeset viewer.