Changeset 779541b in mainline for uspace/srv/net/tcp


Ignore:
Timestamp:
2015-05-09T13:43:50Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1d4b815
Parents:
99ea91b2
Message:

TCP transport layer API - somewhat working.

Location:
uspace/srv/net/tcp
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tcp/Makefile

    r99ea91b2 r779541b  
    3737        rqueue.c \
    3838        segment.c \
     39        service.c \
    3940        seq_no.c \
    4041        tcp.c \
  • uspace/srv/net/tcp/conn.c

    r99ea91b2 r779541b  
    121121        fibril_condvar_initialize(&conn->cstate_cv);
    122122
    123         conn->cstate_cb = NULL;
     123        conn->cb = NULL;
    124124
    125125        conn->cstate = st_listen;
     
    275275
    276276        /* Run user callback function */
    277         if (conn->cstate_cb != NULL) {
     277        if (conn->cb != NULL && conn->cb->cstate_change != NULL) {
    278278                log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_conn_state_set() - run user CB");
    279                 conn->cstate_cb(conn, conn->cstate_cb_arg);
     279                conn->cb->cstate_change(conn, conn->cb_arg);
    280280        } else {
    281281                log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_conn_state_set() - no user CB");
     
    10071007        /* Signal to the receive function that new data has arrived */
    10081008        fibril_condvar_broadcast(&conn->rcv_buf_cv);
     1009        if (conn->cb != NULL && conn->cb->recv_data != NULL)
     1010                conn->cb->recv_data(conn, conn->cb_arg);
    10091011
    10101012        log_msg(LOG_DEFAULT, LVL_DEBUG, "Received %zu bytes of data.", xfer_size);
     
    10981100                conn->rcv_buf_fin = true;
    10991101                fibril_condvar_broadcast(&conn->rcv_buf_cv);
     1102                if (conn->cb != NULL && conn->cb->recv_data != NULL)
     1103                        conn->cb->recv_data(conn, conn->cb_arg);
    11001104
    11011105                tcp_segment_delete(seg);
  • uspace/srv/net/tcp/tcp.c

    r99ea91b2 r779541b  
    4848#include "pdu.h"
    4949#include "rqueue.h"
     50#include "service.h"
    5051#include "std.h"
    5152#include "tcp.h"
     
    192193        }
    193194
    194 //      rc = tcp_sock_init();
    195 //      if (rc != EOK) {
    196 //              log_msg(LOG_DEFAULT, LVL_ERROR, "Failed initializing socket service.");
    197 //              return ENOENT;
    198 //      }
     195        rc = tcp_service_init();
     196        if (rc != EOK) {
     197                log_msg(LOG_DEFAULT, LVL_ERROR, "Failed initializing service.");
     198                return ENOENT;
     199        }
    199200
    200201        return EOK;
  • uspace/srv/net/tcp/tcp_type.h

    r99ea91b2 r779541b  
    9696        TCP_EINVPREC,
    9797        /* Security/compartment not allowed */
    98         TCP_EINVCOMP
     98        TCP_EINVCOMP,
     99        TCP_EAGAIN
    99100} tcp_error_t;
    100101
     
    154155typedef void (*tcp_cstate_cb_t)(tcp_conn_t *, void *);
    155156
     157/** Connection callbacks */
     158typedef struct {
     159        void (*cstate_change)(tcp_conn_t *, void *);
     160        void (*recv_data)(tcp_conn_t *, void *);
     161} tcp_cb_t;
     162
    156163/** Connection */
    157164struct tcp_conn {
     
    159166        link_t link;
    160167
    161         /** Connection state change callback function */
    162         tcp_cstate_cb_t cstate_cb;
     168        /** Connection callbacks function */
     169        tcp_cb_t *cb;
    163170        /** Argument to @c cstate_cb */
    164         void *cstate_cb_arg;
     171        void *cb_arg;
    165172
    166173        /** Connection identification (local and foreign socket) */
     
    318325} tcp_pdu_t;
    319326
    320 typedef struct {
     327/** TCP client connection */
     328typedef struct tcp_cconn {
     329        /** Connection */
     330        tcp_conn_t *conn;
     331        /** Connection ID for the client */
     332        sysarg_t id;
     333        /** Client */
     334        struct tcp_client *client;
     335        link_t lclient;
     336} tcp_cconn_t;
     337
     338/** TCP client listener */
     339typedef struct tcp_clst {
     340        /** Connection */
     341        tcp_conn_t *conn;
     342        /** Listener ID for the client */
     343        sysarg_t id;
     344        /** Client */
     345        struct tcp_client *client;
     346        /** Link to tcp_client_t.clst */
     347        link_t lclient;
     348} tcp_clst_t;
     349
     350/** TCP client */
     351typedef struct tcp_client {
     352        /** Client callbac session */
    321353        async_sess_t *sess;
    322 //      socket_cores_t sockets;
     354        /** Client's connections */
     355        list_t cconn; /* of tcp_cconn_t */
     356        /** Client's listeners */
     357        list_t clst;
    323358} tcp_client_t;
    324359
     
    358393} tcp_sock_lconn_t;
    359394
    360 
    361395#endif
    362396
  • uspace/srv/net/tcp/tqueue.c

    r99ea91b2 r779541b  
    285285{
    286286        log_msg(LOG_DEFAULT, LVL_DEBUG,
    287             "tcp_transmit_segment(f:(%u),l:(%u), %p)",
     287            "tcp_transmit_segment(l:(%u),f:(%u), %p)",
    288288            sp->local.port, sp->foreign.port, seg);
    289289       
  • uspace/srv/net/tcp/ucall.c

    r99ea91b2 r779541b  
    188188        /* Wait for data to become available */
    189189        while (conn->rcv_buf_used == 0 && !conn->rcv_buf_fin && !conn->reset) {
     190                tcp_conn_unlock(conn);
     191                return TCP_EAGAIN;
    190192                log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_uc_receive() - wait for data");
    191193                fibril_condvar_wait(&conn->rcv_buf_cv, &conn->lock);
     
    294296}
    295297
    296 void tcp_uc_set_cstate_cb(tcp_conn_t *conn, tcp_cstate_cb_t cb, void *arg)
    297 {
    298         log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_uc_set_ctate_cb(%p, %p, %p)",
     298void tcp_uc_set_cb(tcp_conn_t *conn, tcp_cb_t *cb, void *arg)
     299{
     300        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_uc_set_cb(%p, %p, %p)",
    299301            conn, cb, arg);
    300302
    301         conn->cstate_cb = cb;
    302         conn->cstate_cb_arg = arg;
     303        conn->cb = cb;
     304        conn->cb_arg = arg;
    303305}
    304306
  • uspace/srv/net/tcp/ucall.h

    r99ea91b2 r779541b  
    5050extern void tcp_uc_status(tcp_conn_t *, tcp_conn_status_t *);
    5151extern void tcp_uc_delete(tcp_conn_t *);
    52 extern void tcp_uc_set_cstate_cb(tcp_conn_t *, tcp_cstate_cb_t, void *);
     52extern void tcp_uc_set_cb(tcp_conn_t *, tcp_cb_t *, void *);
    5353
    5454/*
Note: See TracChangeset for help on using the changeset viewer.