Changeset 032bbe7 in mainline


Ignore:
Timestamp:
2011-09-22T19:53:07Z (12 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.

Location:
uspace/srv/net/tl/tcp
Files:
17 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{
  • uspace/srv/net/tl/tcp/conn.h

    r0093ab6 r032bbe7  
    3030 * @{
    3131 */
    32 /** @file TCP connections
     32/** @file TCP connection processing and state machine
    3333 */
    3434
  • uspace/srv/net/tl/tcp/header.c

    r0093ab6 r032bbe7  
    3232
    3333/**
    34  * @file
     34 * @file TCP header encoding and decoding
    3535 */
    3636
  • uspace/srv/net/tl/tcp/header.h

    r0093ab6 r032bbe7  
    3030 * @{
    3131 */
    32 /** @file TCP header definitions
    33  *
    34  * Based on IETF RFC 793
     32/** @file TCP header encoding and decoding
    3533 */
    3634
  • uspace/srv/net/tl/tcp/iqueue.c

    r0093ab6 r032bbe7  
    3232
    3333/**
    34  * @file
     34 * @file Connection incoming segments queue
     35 *
     36 * Segments are sorted in order of their sequence number.
    3537 */
    3638
     
    4446#include "tcp_type.h"
    4547
     48/** Initialize incoming segments queue.
     49 *
     50 * @param iqueue        Incoming queue
     51 * @param conn          Connection the queue is associated with
     52 */
    4653void tcp_iqueue_init(tcp_iqueue_t *iqueue, tcp_conn_t *conn)
    4754{
     
    5057}
    5158
     59/** Insert segment into incoming queue.
     60 *
     61 * @param iqueue        Incoming queue
     62 * @param seg           Segment
     63 */
    5264void tcp_iqueue_insert_seg(tcp_iqueue_t *iqueue, tcp_segment_t *seg)
    5365{
     
    6779}
    6880
     81/** Get next ready segment from incoming queue.
     82 *
     83 * Return the segment with the earliest sequence number if it is ready.
     84 * A segment is ready if its SEG.SEQ is earlier or equal to RCV.NXT.
     85 *
     86 * @param iqueue        Incoming queue
     87 * @param seg           Place to store pointer to segment
     88 * @return              EOK on success, ENOENT if no segment is ready
     89 */
    6990int tcp_iqueue_get_ready_seg(tcp_iqueue_t *iqueue, tcp_segment_t **seg)
    7091{
  • uspace/srv/net/tl/tcp/rqueue.c

    r0093ab6 r032bbe7  
    3232
    3333/**
    34  * @file
     34 * @file Global segment receive queue
    3535 */
    3636
     
    4040#include <stdlib.h>
    4141#include <thread.h>
     42#include "conn.h"
    4243#include "rqueue.h"
    4344#include "state.h"
     
    4647static prodcons_t rqueue;
    4748
     49/** Initialize segment receive queue. */
    4850void tcp_rqueue_init(void)
    4951{
     
    5456 *
    5557 * This is for testing purposes only.
     58 *
     59 * @param sp    Socket pair, oriented for transmission
     60 * @param seg   Segment
    5661 */
    5762void tcp_rqueue_bounce_seg(tcp_sockpair_t *sp, tcp_segment_t *seg)
     
    6267
    6368        /* Reverse the identification */
    64         rident.local = sp->foreign;
    65         rident.foreign = sp->local;
     69        tcp_sockpair_flipped(sp, &rident);
    6670
    6771        tcp_rqueue_insert_seg(&rident, seg);
    6872}
    6973
     74/** Insert segment into receive queue.
     75 *
     76 * @param sp    Socket pair, oriented for reception
     77 * @param seg   Segment
     78 */
    7079void tcp_rqueue_insert_seg(tcp_sockpair_t *sp, tcp_segment_t *seg)
    7180{
     
    8594}
    8695
     96/** Receive queue handler thread. */
    8797static void tcp_rqueue_thread(void *arg)
    8898{
     
    100110}
    101111
     112/** Start receive queue handler thread. */
    102113void tcp_rqueue_thread_start(void)
    103114{
  • uspace/srv/net/tl/tcp/rqueue.h

    r0093ab6 r032bbe7  
    3030 * @{
    3131 */
    32 /** @file Global segment reception queue
     32/** @file Global segment receive queue
    3333 */
    3434
  • uspace/srv/net/tl/tcp/segment.c

    r0093ab6 r032bbe7  
    3232
    3333/**
    34  * @file
     34 * @file Segment processing
    3535 */
    3636
     
    4141#include "tcp_type.h"
    4242
     43/** Alocate new segment structure. */
    4344tcp_segment_t *tcp_segment_new(void)
    4445{
     
    4647}
    4748
     49/** Delete segment. */
    4850void tcp_segment_delete(tcp_segment_t *seg)
    4951{
     
    5153}
    5254
    53 /** Create a control segment. */
     55/** Create a control segment.
     56 *
     57  * @return     Control segment
     58 */
    5459tcp_segment_t *tcp_segment_make_ctrl(tcp_control_t ctrl)
    5560{
     
    6671}
    6772
     73/** Create an RST segment.
     74 *
     75 * @param seg   Segment we are replying to
     76 * @return      RST segment
     77 */
    6878tcp_segment_t *tcp_segment_make_rst(tcp_segment_t *seg)
    6979{
     
    8090}
    8191
    82 /** Trim segment to the specified interval.
     92/** Trim segment from left and right by the specified amount.
    8393 *
    84  * Trim any text or control whose sequence number is outside of [lo, hi)
    85  * interval.
     94 * Trim any text or control to remove the specified amount of sequence
     95 * numbers from the left (lower sequence numbers) and right side
     96 * (higher sequence numbers) of the segment.
     97 *
     98 * @param seg           Segment, will be modified in place
     99 * @param left          Amount of sequence numbers to trim from the left
     100 * @param right         Amount of sequence numbers to trim from the right
    86101 */
    87102void tcp_segment_trim(tcp_segment_t *seg, uint32_t left, uint32_t right)
     
    134149/** Copy out text data from segment.
    135150 *
     151 * Data is copied from the beginning of the segment text up to @a size bytes.
     152 * @a size must not be greater than the size of the segment text, but
     153 * it can be less.
     154 *
     155 * @param seg   Segment
     156 * @param buf   Destination buffer
     157 * @param size  Size of destination buffer
    136158 */
    137159void tcp_segment_text_copy(tcp_segment_t *seg, void *buf, size_t size)
     
    141163}
    142164
    143 /** Return number of bytes in segment text. */
     165/** Return number of bytes in segment text.
     166 *
     167 * @param seg   Segment
     168 * @return      Number of bytes in segment text
     169 */
    144170size_t tcp_segment_text_size(tcp_segment_t *seg)
    145171{
  • uspace/srv/net/tl/tcp/segment.h

    r0093ab6 r032bbe7  
    3030 * @{
    3131 */
    32 /** @file
     32/** @file Segment processing
    3333 */
    3434
  • uspace/srv/net/tl/tcp/seq_no.c

    r0093ab6 r032bbe7  
    3232
    3333/**
    34  * @file
     34 * @file Sequence number computations
    3535 */
    3636
  • uspace/srv/net/tl/tcp/seq_no.h

    r0093ab6 r032bbe7  
    3030 * @{
    3131 */
    32 /** @file TCP sequence numbers
     32/** @file Sequence number computations
    3333 */
    3434
  • uspace/srv/net/tl/tcp/state.c

    r0093ab6 r032bbe7  
    3232
    3333/**
    34  * @file
     34 * @file TCP entry points (close to those defined in the RFC)
    3535 */
    3636
  • uspace/srv/net/tl/tcp/state.h

    r0093ab6 r032bbe7  
    3030 * @{
    3131 */
    32 /** @file TCP state machine
     32/** @file TCP entry points (close to those defined in the RFC)
    3333 */
    3434
  • uspace/srv/net/tl/tcp/tcp_type.h

    r0093ab6 r032bbe7  
    3030 * @{
    3131 */
    32 /** @file
     32/** @file TCP type definitions
    3333 */
    3434
  • uspace/srv/net/tl/tcp/test.c

    r0093ab6 r032bbe7  
    3232
    3333/**
    34  * @file
     34 * @file Internal TCP test
    3535 */
    3636
  • uspace/srv/net/tl/tcp/test.h

    r0093ab6 r032bbe7  
    3030 * @{
    3131 */
    32 /** @file
     32/** @file Internal TCP test
    3333 */
    3434
  • uspace/srv/net/tl/tcp/tqueue.c

    r0093ab6 r032bbe7  
    3232
    3333/**
    34  * @file
     34 * @file TCP transmission queue
    3535 */
    3636
Note: See TracChangeset for help on using the changeset viewer.