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


Ignore:
Timestamp:
2011-09-22T19:53:07Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
32105348
Parents:
0093ab6
Message:

Document functions and files.

File:
1 edited

Legend:

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

    r0093ab6 r032bbe7  
    3232
    3333/**
    34  * @file
     34 * @file TCP connection processing and state machine
    3535 */
    3636
     
    5353static void tcp_conn_seg_process(tcp_conn_t *conn, tcp_segment_t *seg);
    5454
     55/** Create new segment structure.
     56 *
     57 * @param lsock         Local socket (will be deeply copied)
     58 * @param fsock         Foreign socket (will be deeply copied)
     59 * @return              New segment or NULL
     60 */
    5561tcp_conn_t *tcp_conn_new(tcp_sock_t *lsock, tcp_sock_t *fsock)
    5662{
     
    8591}
    8692
     93/** Enlist connection.
     94 *
     95 * Add connection to the connection map.
     96 */
    8797void tcp_conn_add(tcp_conn_t *conn)
    8898{
     
    90100}
    91101
     102/** Synchronize connection.
     103 *
     104 * This is the first step of an active connection attempt,
     105 * sends out SYN and sets up ISS and SND.xxx.
     106 */
    92107void tcp_conn_sync(tcp_conn_t *conn)
    93108{
     
    101116}
    102117
     118/** Compare two sockets.
     119 *
     120 * Two sockets are equal if the address is equal and the port number
     121 * is equal.
     122 */
    103123static bool tcp_socket_equal(tcp_sock_t *a, tcp_sock_t *b)
    104124{
     
    117137}
    118138
     139/** Match socket with pattern. */
    119140static bool tcp_sockpair_match(tcp_sockpair_t *sp, tcp_sockpair_t *pattern)
    120141{
     
    130151}
    131152
     153/** Find connection structure for specified socket pair.
     154 *
     155 * A connection is uniquely identified by a socket pair. Look up our
     156 * connection map and return connection structure based on socket pair.
     157 *
     158 * @param sp    Socket pair
     159 * @return      Connection structure or NULL if not found.
     160 */
    132161tcp_conn_t *tcp_conn_find(tcp_sockpair_t *sp)
    133162{
     
    144173}
    145174
     175/** Segment arrived in Listen state.
     176 *
     177 * @param conn          Connection
     178 * @param seg           Segment
     179 */
    146180static void tcp_conn_sa_listen(tcp_conn_t *conn, tcp_segment_t *seg)
    147181{
     
    196230}
    197231
     232/** Segment arrived in Syn-Sent state.
     233 *
     234 * @param conn          Connection
     235 * @param seg           Segment
     236 */
    198237static void tcp_conn_sa_syn_sent(tcp_conn_t *conn, tcp_segment_t *seg)
    199238{
     
    248287}
    249288
     289/** Segment arrived in state where segments are processed in sequence order.
     290 *
     291 * Queue segment in incoming segments queue for processing.
     292 *
     293 * @param conn          Connection
     294 * @param seg           Segment
     295 */
    250296static void tcp_conn_sa_queue(tcp_conn_t *conn, tcp_segment_t *seg)
    251297{
     
    269315}
    270316
     317/** Process segment RST field.
     318 *
     319 * @param conn          Connection
     320 * @param seg           Segment
     321 * @return              cp_done if we are done with this segment, cp_continue
     322 *                      if not
     323 */
    271324static cproc_t tcp_conn_seg_proc_rst(tcp_conn_t *conn, tcp_segment_t *seg)
    272325{
     
    275328}
    276329
     330/** Process segment security and precedence fields.
     331 *
     332 * @param conn          Connection
     333 * @param seg           Segment
     334 * @return              cp_done if we are done with this segment, cp_continue
     335 *                      if not
     336 */
    277337static cproc_t tcp_conn_seg_proc_sp(tcp_conn_t *conn, tcp_segment_t *seg)
    278338{
     
    281341}
    282342
     343/** Process segment SYN field.
     344 *
     345 * @param conn          Connection
     346 * @param seg           Segment
     347 * @return              cp_done if we are done with this segment, cp_continue
     348 *                      if not
     349 */
    283350static cproc_t tcp_conn_seg_proc_syn(tcp_conn_t *conn, tcp_segment_t *seg)
    284351{
     
    287354}
    288355
     356/** Process segment ACK field in Syn-Received state.
     357 *
     358 * @param conn          Connection
     359 * @param seg           Segment
     360 * @return              cp_done if we are done with this segment, cp_continue
     361 *                      if not
     362 */
    289363static cproc_t tcp_conn_seg_proc_ack_sr(tcp_conn_t *conn, tcp_segment_t *seg)
    290364{
     
    307381}
    308382
     383/** Process segment ACK field in Established state.
     384 *
     385 * @param conn          Connection
     386 * @param seg           Segment
     387 * @return              cp_done if we are done with this segment, cp_continue
     388 *                      if not
     389 */
    309390static cproc_t tcp_conn_seg_proc_ack_est(tcp_conn_t *conn, tcp_segment_t *seg)
    310391{
     
    344425}
    345426
     427/** Process segment ACK field in Fin-Wait-1 state.
     428 *
     429 * @param conn          Connection
     430 * @param seg           Segment
     431 * @return              cp_done if we are done with this segment, cp_continue
     432 *                      if not
     433 */
    346434static cproc_t tcp_conn_seg_proc_ack_fw1(tcp_conn_t *conn, tcp_segment_t *seg)
    347435{
     
    353441}
    354442
     443/** Process segment ACK field in Fin-Wait-2 state.
     444 *
     445 * @param conn          Connection
     446 * @param seg           Segment
     447 * @return              cp_done if we are done with this segment, cp_continue
     448 *                      if not
     449 */
    355450static cproc_t tcp_conn_seg_proc_ack_fw2(tcp_conn_t *conn, tcp_segment_t *seg)
    356451{
     
    362457}
    363458
     459/** Process segment ACK field in Close-Wait state.
     460 *
     461 * @param conn          Connection
     462 * @param seg           Segment
     463 * @return              cp_done if we are done with this segment, cp_continue
     464 *                      if not
     465 */
    364466static cproc_t tcp_conn_seg_proc_ack_cw(tcp_conn_t *conn, tcp_segment_t *seg)
    365467{
     
    368470}
    369471
     472/** Process segment ACK field in Closing state.
     473 *
     474 * @param conn          Connection
     475 * @param seg           Segment
     476 * @return              cp_done if we are done with this segment, cp_continue
     477 *                      if not
     478 */
    370479static cproc_t tcp_conn_seg_proc_ack_cls(tcp_conn_t *conn, tcp_segment_t *seg)
    371480{
     
    377486}
    378487
     488/** Process segment ACK field in Last-Ack state.
     489 *
     490 * @param conn          Connection
     491 * @param seg           Segment
     492 * @return              cp_done if we are done with this segment, cp_continue
     493 *                      if not
     494 */
    379495static cproc_t tcp_conn_seg_proc_ack_la(tcp_conn_t *conn, tcp_segment_t *seg)
    380496{
     
    386502}
    387503
     504/** Process segment ACK field in Time-Wait state.
     505 *
     506 * @param conn          Connection
     507 * @param seg           Segment
     508 * @return              cp_done if we are done with this segment, cp_continue
     509 *                      if not
     510 */
    388511static cproc_t tcp_conn_seg_proc_ack_tw(tcp_conn_t *conn, tcp_segment_t *seg)
    389512{
     
    392515}
    393516
     517/** Process segment ACK field.
     518 *
     519 * @param conn          Connection
     520 * @param seg           Segment
     521 * @return              cp_done if we are done with this segment, cp_continue
     522 *                      if not
     523 */
    394524static cproc_t tcp_conn_seg_proc_ack(tcp_conn_t *conn, tcp_segment_t *seg)
    395525{
     
    428558}
    429559
     560/** Process segment URG field.
     561 *
     562 * @param conn          Connection
     563 * @param seg           Segment
     564 * @return              cp_done if we are done with this segment, cp_continue
     565 *                      if not
     566 */
    430567static cproc_t tcp_conn_seg_proc_urg(tcp_conn_t *conn, tcp_segment_t *seg)
    431568{
     
    433570}
    434571
    435 /** Process segment text. */
     572/** Process segment text.
     573 *
     574 * @param conn          Connection
     575 * @param seg           Segment
     576 * @return              cp_done if we are done with this segment, cp_continue
     577 *                      if not
     578 */
    436579static cproc_t tcp_conn_seg_proc_text(tcp_conn_t *conn, tcp_segment_t *seg)
    437580{
     
    502645}
    503646
     647/** Process segment FIN field.
     648 *
     649 * @param conn          Connection
     650 * @param seg           Segment
     651 * @return              cp_done if we are done with this segment, cp_continue
     652 *                      if not
     653 */
    504654static cproc_t tcp_conn_seg_proc_fin(tcp_conn_t *conn, tcp_segment_t *seg)
    505655{
     
    512662 * of sequence number. This processes one segment taken from the
    513663 * connection incoming segments queue.
     664 *
     665 * @param conn          Connection
     666 * @param seg           Segment
    514667 */
    515668static void tcp_conn_seg_process(tcp_conn_t *conn, tcp_segment_t *seg)
     
    552705}
    553706
     707/** Segment arrived on a connection.
     708 *
     709 * @param conn          Connection
     710 * @param seg           Segment
     711 */
    554712void tcp_conn_segment_arrived(tcp_conn_t *conn, tcp_segment_t *seg)
    555713{
     
    576734}
    577735
     736/** Trim segment to the receive window.
     737 *
     738 * @param conn          Connection
     739 * @param seg           Segment
     740 */
    578741void tcp_conn_trim_seg_to_wnd(tcp_conn_t *conn, tcp_segment_t *seg)
    579742{
     
    584747}
    585748
     749/** Handle unexpected segment received on a socket pair.
     750 *
     751 * We reply with an RST unless the received segment has RST.
     752 *
     753 * @param sp            Socket pair which received the segment
     754 * @param seg           Unexpected segment
     755 */
    586756void tcp_unexpected_segment(tcp_sockpair_t *sp, tcp_segment_t *seg)
    587757{
     
    592762}
    593763
     764/** Compute flipped socket pair for response.
     765 *
     766 * Flipped socket pair has local and foreign sockes exchanged.
     767 *
     768 * @param sp            Socket pair
     769 * @param fsp           Place to store flipped socket pair
     770 */
    594771void tcp_sockpair_flipped(tcp_sockpair_t *sp, tcp_sockpair_t *fsp)
    595772{
     
    598775}
    599776
    600 /** Send RST in response to an incoming segment. */
     777/** Send RST in response to an incoming segment.
     778 *
     779 * @param sp            Socket pair which received the segment
     780 * @param seg           Incoming segment
     781 */
    601782void tcp_reply_rst(tcp_sockpair_t *sp, tcp_segment_t *seg)
    602783{
Note: See TracChangeset for help on using the changeset viewer.