Changeset 49d819b4 in mainline for uspace/srv/net/tl/tcp/tcp.h


Ignore:
Timestamp:
2010-11-02T23:15:18Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7ae3d6f
Parents:
e06ef614 (diff), d0d1f4f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from lp:~jakub/helenos/net.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tl/tcp/tcp.h

    re06ef614 r49d819b4  
    2828
    2929/** @addtogroup tcp
    30  *  @{
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  TCP module.
    35  */
    36 
    37 #ifndef __NET_TCP_H__
    38 #define __NET_TCP_H__
     34 * TCP module.
     35 */
     36
     37#ifndef NET_TCP_H_
     38#define NET_TCP_H_
    3939
    4040#include <fibril_synch.h>
     
    4646
    4747/** Type definition of the TCP global data.
    48  *  @see tcp_globals
    49  */
    50 typedef struct tcp_globals      tcp_globals_t;
     48 * @see tcp_globals
     49 */
     50typedef struct tcp_globals tcp_globals_t;
    5151
    5252/** Type definition of the TCP socket specific data.
    53  *  @see tcp_socket_data
    54  */
    55 typedef struct tcp_socket_data  tcp_socket_data_t;
     53 * @see tcp_socket_data
     54 */
     55typedef struct tcp_socket_data tcp_socket_data_t;
    5656
    5757/** Type definition of the TCP socket specific data pointer.
    58  *  @see tcp_socket_data
    59  */
    60 typedef tcp_socket_data_t *     tcp_socket_data_ref;
     58 * @see tcp_socket_data
     59 */
     60typedef tcp_socket_data_t *tcp_socket_data_ref;
    6161
    6262/** Type definition of the TCP operation data.
    63  *  @see tcp_operation
    64  */
    65 typedef struct tcp_operation    tcp_operation_t;
     63 * @see tcp_operation
     64 */
     65typedef struct tcp_operation tcp_operation_t;
    6666
    6767/** Type definition of the TCP operation data pointer.
    68  *  @see tcp_operation
    69  */
    70 typedef tcp_operation_t *       tcp_operation_ref;
     68 * @see tcp_operation
     69 */
     70typedef tcp_operation_t *tcp_operation_ref;
    7171
    7272/** TCP socket state type definition.
    73  *  @see tcp_socket_state
    74  */
    75 typedef enum tcp_socket_state   tcp_socket_state_t;
    76 
    77 /** TCP socket state.
    78  */
    79 enum tcp_socket_state{
     73 * @see tcp_socket_state
     74 */
     75typedef enum tcp_socket_state tcp_socket_state_t;
     76
     77/** TCP socket state. */
     78enum tcp_socket_state {
    8079        /** Initial.
    81          *  Not connected or bound.
     80         *
     81         * Not connected or bound.
    8282         */
    8383        TCP_SOCKET_INITIAL,
     84       
    8485        /** Listening.
    85          *  Awaiting a connection request from another TCP layer.
    86          *  When SYN is received a new bound socket in the TCP_SOCKET_SYN_RECEIVED state should be created.
     86         *
     87         * Awaiting a connection request from another TCP layer.
     88         * When SYN is received a new bound socket in the
     89         * TCP_SOCKET_SYN_RECEIVED state should be created.
    8790         */
    8891        TCP_SOCKET_LISTEN,
     92       
    8993        /** Connecting issued.
    90          *  A~SYN has been sent, and TCP is awaiting the response SYN.
    91          *  Should continue to the TCP_SOCKET_ESTABLISHED state.
     94         *
     95         * A SYN has been sent, and TCP is awaiting the response SYN.
     96         * Should continue to the TCP_SOCKET_ESTABLISHED state.
    9297         */
    9398        TCP_SOCKET_SYN_SENT,
     99       
    94100        /** Connecting received.
    95          *  A~SYN has been received, a~SYN has been sent, and TCP is awaiting an ACK.
    96          *  Should continue to the TCP_SOCKET_ESTABLISHED state.
     101         *
     102         * A SYN has been received, a SYN has been sent, and TCP is awaiting an
     103         * ACK. Should continue to the TCP_SOCKET_ESTABLISHED state.
    97104         */
    98105        TCP_SOCKET_SYN_RECEIVED,
     106       
    99107        /** Connected.
    100          *  The three-way handshake has been completed.
     108         *
     109         * The three-way handshake has been completed.
    101110         */
    102111        TCP_SOCKET_ESTABLISHED,
     112       
    103113        /** Closing started.
    104          *  The local application has issued a~CLOSE.
    105          *  TCP has sent a~FIN, and is awaiting an ACK or a~FIN.
    106          *  Should continue to the TCP_SOCKET_FIN_WAIT_2 state when an ACK is received.
    107          *  Should continue to the TCP_SOCKET_CLOSING state when a~FIN is received.
     114         *
     115         * The local application has issued a CLOSE.
     116         * TCP has sent a FIN, and is awaiting an ACK or a FIN.
     117         * Should continue to the TCP_SOCKET_FIN_WAIT_2 state when an ACK is
     118         * received.
     119         * Should continue to the TCP_SOCKET_CLOSING state when a FIN is
     120         * received.
    108121         */
    109122        TCP_SOCKET_FIN_WAIT_1,
     123       
    110124        /** Closing confirmed.
    111          *  A~FIN has been sent, and an ACK received.
    112          *  TCP is awaiting a~FIN from the remote TCP layer.
    113          *  Should continue to the TCP_SOCKET_CLOSING state.
     125         *
     126         * A FIN has been sent, and an ACK received.
     127         * TCP is awaiting a~FIN from the remote TCP layer.
     128         * Should continue to the TCP_SOCKET_CLOSING state.
    114129         */
    115130        TCP_SOCKET_FIN_WAIT_2,
     131       
    116132        /** Closing.
    117          *  A FIN has been sent, a FIN has been received, and an ACK has been sent.
    118          *  TCP is awaiting an ACK for the FIN that was sent.
    119          *  Should continue to the TCP_SOCKET_TIME_WAIT state.
     133         *
     134         * A FIN has been sent, a FIN has been received, and an ACK has been
     135         * sent.
     136         * TCP is awaiting an ACK for the FIN that was sent.
     137         * Should continue to the TCP_SOCKET_TIME_WAIT state.
    120138         */
    121139        TCP_SOCKET_CLOSING,
     140       
    122141        /** Closing received.
    123          *  TCP has received a~FIN, and has sent an ACK.
    124          *  It is awaiting a~close request from the local application before sending a~FIN.
    125          *  Should continue to the TCP_SOCKET_SOCKET_LAST_ACK state.
     142         *
     143         * TCP has received a FIN, and has sent an ACK.
     144         * It is awaiting a close request from the local application before
     145         * sending a FIN.
     146         * Should continue to the TCP_SOCKET_SOCKET_LAST_ACK state.
    126147         */
    127148        TCP_SOCKET_CLOSE_WAIT,
    128         /**
    129          *  A~FIN has been received, and an ACK and a~FIN have been sent.
    130          *  TCP is awaiting an ACK.
    131          *  Should continue to the TCP_SOCKET_TIME_WAIT state.
     149       
     150        /**
     151         * A FIN has been received, and an ACK and a FIN have been sent.
     152         * TCP is awaiting an ACK.
     153         * Should continue to the TCP_SOCKET_TIME_WAIT state.
    132154         */
    133155        TCP_SOCKET_LAST_ACK,
     156       
    134157        /** Closing finished.
    135          *  FINs have been received and ACK’d, and TCP is waiting two MSLs to remove the connection from the table.
     158         *
     159         * FINs have been received and ACK’d, and TCP is waiting two MSLs to
     160         * remove the connection from the table.
    136161         */
    137162        TCP_SOCKET_TIME_WAIT,
     163       
    138164        /** Closed.
    139          *  Imaginary, this indicates that a~connection has been removed from the connection table.
     165         *
     166         * Imaginary, this indicates that a connection has been removed from
     167         * the connection table.
    140168         */
    141169        TCP_SOCKET_CLOSED
    142170};
    143171
    144 /** TCP operation data.
    145  */
    146 struct tcp_operation{
    147         /** Operation result.
    148          */
     172/** TCP operation data. */
     173struct tcp_operation {
     174        /** Operation result. */
    149175        int result;
    150         /** Safety lock.
    151          */
     176        /** Safety lock. */
    152177        fibril_mutex_t mutex;
    153         /** Operation result signaling.
    154          */
     178        /** Operation result signaling. */
    155179        fibril_condvar_t condvar;
    156180};
    157181
    158 /** TCP socket specific data.
    159  */
    160 struct tcp_socket_data{
    161         /** TCP socket state.
    162          */
     182/** TCP socket specific data. */
     183struct tcp_socket_data {
     184        /** TCP socket state. */
    163185        tcp_socket_state_t state;
    164         /** Data fragment size.
    165          *  Sending optimalization.
     186       
     187        /**
     188         * Data fragment size.
     189         * Sending optimalization.
    166190         */
    167191        size_t data_fragment_size;
    168         /** Device identifier.
    169         */
     192       
     193        /** Device identifier. */
    170194        device_id_t device_id;
    171         /** Listening backlog.
    172          *  The maximal number of connected but not yet accepted sockets.
     195       
     196        /**
     197         * Listening backlog.
     198         * The maximal number of connected but not yet accepted sockets.
    173199         */
    174200        int backlog;
    175 //      /** Segment size.
    176 //       */
    177 //      size_t                  segment_size;
    178         /** Parent listening socket identifier.
    179          *  Set if this socket is an accepted one.
     201       
     202//      /** Segment size. */
     203//      size_t segment_size;
     204
     205        /**
     206         * Parent listening socket identifier.
     207         * Set if this socket is an accepted one.
    180208         */
    181209        int listening_socket_id;
    182         /** Treshold size in bytes.
    183         */
     210       
     211        /** Treshold size in bytes. */
    184212        size_t treshold;
    185         /** Window size in bytes.
    186          */
     213        /** Window size in bytes. */
    187214        size_t window;
    188         /** Acknowledgement timeout.
    189          */
     215        /** Acknowledgement timeout. */
    190216        suseconds_t timeout;
    191         /** Last acknowledged byte.
    192          */
     217        /** Last acknowledged byte. */
    193218        uint32_t acknowledged;
    194         /** Next incoming sequence number.
    195          */
     219        /** Next incoming sequence number. */
    196220        uint32_t next_incoming;
    197         /** Incoming FIN.
    198          */
     221        /** Incoming FIN. */
    199222        uint32_t fin_incoming;
    200         /** Next outgoing sequence number.
    201          */
     223        /** Next outgoing sequence number. */
    202224        uint32_t next_outgoing;
    203         /** Last outgoing sequence number.
    204          */
     225        /** Last outgoing sequence number. */
    205226        uint32_t last_outgoing;
    206         /** Outgoing FIN.
    207          */
     227        /** Outgoing FIN. */
    208228        uint32_t fin_outgoing;
    209         /** Expected sequence number by the remote host.
    210          *  The sequence number the other host expects.
    211          *  The notification is sent only upon a packet reecival.
     229       
     230        /**
     231         * Expected sequence number by the remote host.
     232         * The sequence number the other host expects.
     233         * The notification is sent only upon a packet reecival.
    212234         */
    213235        uint32_t expected;
    214         /** Expected sequence number counter.
    215          *  Counts the number of received notifications for the same sequence number.
     236       
     237        /**
     238         * Expected sequence number counter.
     239         * Counts the number of received notifications for the same sequence
     240         * number.
    216241         */
    217242        int expected_count;
     243       
    218244        /** Incoming packet queue.
    219          *  Packets are buffered until received in the right order.
    220          *  The packets are excluded after successfully read.
    221          *  Packets are sorted by their starting byte.
    222          *  Packets metric is set as their data length.
     245         *
     246         * Packets are buffered until received in the right order.
     247         * The packets are excluded after successfully read.
     248         * Packets are sorted by their starting byte.
     249         * Packets metric is set as their data length.
    223250         */
    224251        packet_t incoming;
     252       
    225253        /** Outgoing packet queue.
    226          *  Packets are buffered until acknowledged by the remote host in the right order.
    227          *  The packets are excluded after acknowledged.
    228          *  Packets are sorted by their starting byte.
    229          *  Packets metric is set as their data length.
     254         *
     255         * Packets are buffered until acknowledged by the remote host in the
     256         * right order.
     257         * The packets are excluded after acknowledged.
     258         * Packets are sorted by their starting byte.
     259         * Packets metric is set as their data length.
    230260         */
    231261        packet_t outgoing;
    232         /** IP pseudo header.
    233         */
     262       
     263        /** IP pseudo header. */
    234264        void *pseudo_header;
    235         /** IP pseudo header length.
    236          */
     265        /** IP pseudo header length. */
    237266        size_t headerlen;
    238         /** Remote host address.
    239          */
    240         struct sockaddr * addr;
    241         /** Remote host address length.
    242          */
     267        /** Remote host address. */
     268        struct sockaddr *addr;
     269        /** Remote host address length. */
    243270        socklen_t addrlen;
    244         /** Remote host port.
    245          */
     271        /** Remote host port. */
    246272        uint16_t dest_port;
    247         /** Parent local sockets.
    248          */
     273        /** Parent local sockets. */
    249274        socket_cores_ref local_sockets;
     275       
    250276        /** Local sockets safety lock.
    251          *  May be locked for writing while holding the global lock for reading when changing the local sockets only.
    252          *  The global lock may to be locked only before locking the local lock.
    253          *  The global lock may be locked more weakly than the local lock.
    254          *  The global lock may be released before releasing the local lock.
    255          *  @see tcp_globals:lock
    256          */
    257         fibril_rwlock_t * local_lock;
    258         /** Pending operation data.
    259          */
     277         *
     278         * May be locked for writing while holding the global lock for reading
     279         * when changing the local sockets only.
     280         * The global lock may be locked only before locking the local lock.
     281         * The global lock may be locked more weakly than the local lock.
     282         * The global lock may be released before releasing the local lock.
     283         * @see tcp_globals:lock
     284         */
     285        fibril_rwlock_t *local_lock;
     286       
     287        /** Pending operation data. */
    260288        tcp_operation_t operation;
    261         /** Timeouts in a row counter.
    262          *  If TCP_MAX_TIMEOUTS is reached, the connection is lost.
     289       
     290        /**
     291         * Timeouts in a row counter.
     292         * If TCP_MAX_TIMEOUTS is reached, the connection is lost.
    263293         */
    264294        int timeout_count;
    265295};
    266296
    267 /** TCP global data.
    268  */
    269 struct  tcp_globals{
    270         /** Networking module phone.
    271          */
     297/** TCP global data. */
     298struct tcp_globals {
     299        /** Networking module phone. */
    272300        int net_phone;
    273         /** IP module phone.
    274          */
     301        /** IP module phone. */
    275302        int ip_phone;
    276         /** ICMP module phone.
    277          */
     303        /** ICMP module phone. */
    278304        int icmp_phone;
    279         /** Last used free port.
    280          */
     305        /** Last used free port. */
    281306        int last_used_port;
    282         /** Active sockets.
    283          */
     307        /** Active sockets. */
    284308        socket_ports_t sockets;
    285         /** Device packet dimensions.
    286          */
     309        /** Device packet dimensions. */
    287310        packet_dimensions_t dimensions;
    288         /** Safety lock.
    289          *  Write lock is used only for adding or removing socket ports.
     311       
     312        /**
     313         * Safety lock.
     314         * Write lock is used only for adding or removing socket ports.
    290315         */
    291316        fibril_rwlock_t lock;
     
    296321/** @}
    297322 */
    298 
Note: See TracChangeset for help on using the changeset viewer.