Changeset 048cd69 in mainline for uspace/srv/net/tcp/tcp_type.h


Ignore:
Timestamp:
2015-06-07T15:41:04Z (9 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
204ba47
Parents:
4d11204 (diff), c3f7d37 (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 network transport layer API rewrite.

File:
1 edited

Legend:

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

    r4d11204 r048cd69  
    11/*
    2  * Copyright (c) 2011 Jiri Svoboda
     2 * Copyright (c) 2015 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4141#include <fibril.h>
    4242#include <fibril_synch.h>
    43 #include <socket_core.h>
    4443#include <sys/types.h>
    4544#include <inet/addr.h>
     45#include <inet/endpoint.h>
    4646
    4747struct tcp_conn;
     
    9090        /* Connection reset */
    9191        TCP_ERESET,
    92         /* Foreign socket unspecified */
     92        /* Remote endpoint unspecified */
    9393        TCP_EUNSPEC,
    9494        /* Insufficient resources */
     
    9797        TCP_EINVPREC,
    9898        /* Security/compartment not allowed */
    99         TCP_EINVCOMP
     99        TCP_EINVCOMP,
     100        TCP_EAGAIN
    100101} tcp_error_t;
    101102
     
    112113} tcp_control_t;
    113114
    114 typedef struct {
    115         inet_addr_t addr;
    116         uint16_t port;
    117 } tcp_sock_t;
    118 
    119 enum tcp_port {
    120         TCP_PORT_ANY = 0
    121 };
    122 
    123 typedef struct {
    124         tcp_sock_t local;
    125         tcp_sock_t foreign;
    126 } tcp_sockpair_t;
    127 
    128115/** Connection incoming segments queue */
    129116typedef struct {
     
    155142typedef void (*tcp_cstate_cb_t)(tcp_conn_t *, void *);
    156143
     144/** Connection callbacks */
     145typedef struct {
     146        void (*cstate_change)(tcp_conn_t *, void *, tcp_cstate_t);
     147        void (*recv_data)(tcp_conn_t *, void *);
     148} tcp_cb_t;
     149
    157150/** Connection */
    158151struct tcp_conn {
     
    160153        link_t link;
    161154
    162         /** Connection state change callback function */
    163         tcp_cstate_cb_t cstate_cb;
     155        /** Connection callbacks function */
     156        tcp_cb_t *cb;
    164157        /** Argument to @c cstate_cb */
    165         void *cstate_cb_arg;
    166 
    167         /** Connection identification (local and foreign socket) */
    168         tcp_sockpair_t ident;
     158        void *cb_arg;
     159
     160        /** Connection identification (local and remote endpoint) */
     161        inet_ep2_t ident;
    169162
    170163        /** Active or passive connection */
     
    274267typedef struct {
    275268        link_t link;
    276         tcp_sockpair_t sp;
     269        inet_ep2_t epp;
    277270        tcp_segment_t *seg;
    278271} tcp_rqueue_entry_t;
     
    282275        link_t link;
    283276        suseconds_t delay;
    284         tcp_sockpair_t sp;
     277        inet_ep2_t epp;
    285278        tcp_segment_t *seg;
    286279} tcp_squeue_entry_t;
     
    319312} tcp_pdu_t;
    320313
    321 typedef struct {
    322         async_sess_t *sess;
    323         socket_cores_t sockets;
    324 } tcp_client_t;
    325 
    326 #define TCP_SOCK_FRAGMENT_SIZE 1024
    327 
    328 typedef struct tcp_sockdata {
    329         /** Lock */
    330         fibril_mutex_t lock;
    331         /** Socket core */
    332         socket_core_t *sock_core;
    333         /** Client */
    334         tcp_client_t *client;
     314/** TCP client connection */
     315typedef struct tcp_cconn {
    335316        /** Connection */
    336317        tcp_conn_t *conn;
    337         /** Local address */
    338         inet_addr_t laddr;
    339         /** Backlog size */
    340         int backlog;
    341         /** Array of listening connections, @c backlog elements */
    342         struct tcp_sock_lconn **lconn;
    343         /** List of connections (from lconn) that are ready to be accepted */
    344         list_t ready;
    345         /** Receiving fibril */
    346         fid_t recv_fibril;
    347         uint8_t recv_buffer[TCP_SOCK_FRAGMENT_SIZE];
    348         size_t recv_buffer_used;
    349         fibril_mutex_t recv_buffer_lock;
    350         fibril_condvar_t recv_buffer_cv;
    351         tcp_error_t recv_error;
    352 } tcp_sockdata_t;
    353 
    354 typedef struct tcp_sock_lconn {
     318        /** Connection ID for the client */
     319        sysarg_t id;
     320        /** Client */
     321        struct tcp_client *client;
     322        link_t lclient;
     323} tcp_cconn_t;
     324
     325/** TCP client listener */
     326typedef struct tcp_clst {
     327        /** Local endpoint */
     328        inet_ep_t elocal;
     329        /** Connection */
    355330        tcp_conn_t *conn;
    356         tcp_sockdata_t *socket;
    357         int index;
    358         link_t ready_list;
    359 } tcp_sock_lconn_t;
    360 
     331        /** Listener ID for the client */
     332        sysarg_t id;
     333        /** Client */
     334        struct tcp_client *client;
     335        /** Link to tcp_client_t.clst */
     336        link_t lclient;
     337} tcp_clst_t;
     338
     339/** TCP client */
     340typedef struct tcp_client {
     341        /** Client callbac session */
     342        async_sess_t *sess;
     343        /** Client's connections */
     344        list_t cconn; /* of tcp_cconn_t */
     345        /** Client's listeners */
     346        list_t clst;
     347} tcp_client_t;
    361348
    362349#endif
Note: See TracChangeset for help on using the changeset viewer.