Changeset e1abc964 in mainline for uspace/srv/net/udp/service.c


Ignore:
Timestamp:
2019-11-13T13:14:16Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1b9a853
Parents:
453c5ce
git-author:
Jiri Svoboda <jiri@…> (2019-11-12 19:13:52)
git-committer:
Jiri Svoboda <jiri@…> (2019-11-13 13:14:16)
Message:

Move UDP's client association to a separate module

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/udp/service.c

    r453c5ce re1abc964  
    4646
    4747#include "assoc.h"
     48#include "cassoc.h"
    4849#include "msg.h"
    4950#include "service.h"
     
    5556#define MAX_MSG_SIZE DATA_XFER_LIMIT
    5657
    57 static void udp_cassoc_recv_msg(void *, inet_ep2_t *, udp_msg_t *);
     58static void udp_recv_msg_cassoc(void *, inet_ep2_t *, udp_msg_t *);
    5859
    5960/** Callbacks to tie us to association layer */
    6061static udp_assoc_cb_t udp_cassoc_cb = {
    61         .recv_msg = udp_cassoc_recv_msg
     62        .recv_msg = udp_recv_msg_cassoc
    6263};
    63 
    64 /** Add message to client receive queue.
    65  *
    66  * @param cassoc Client association
    67  * @param epp    Endpoint pair on which message was received
    68  * @param msg    Message
    69  *
    70  * @return EOK on success, ENOMEM if out of memory
    71  */
    72 static errno_t udp_cassoc_queue_msg(udp_cassoc_t *cassoc, inet_ep2_t *epp,
    73     udp_msg_t *msg)
    74 {
    75         udp_crcv_queue_entry_t *rqe;
    76 
    77         log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_cassoc_queue_msg(%p, %p, %p)",
    78             cassoc, epp, msg);
    79 
    80         rqe = calloc(1, sizeof(udp_crcv_queue_entry_t));
    81         if (rqe == NULL)
    82                 return ENOMEM;
    83 
    84         link_initialize(&rqe->link);
    85         rqe->epp = *epp;
    86         rqe->msg = msg;
    87         rqe->cassoc = cassoc;
    88 
    89         list_append(&rqe->link, &cassoc->client->crcv_queue);
    90         return EOK;
    91 }
    9264
    9365/** Send 'data' event to client.
     
    10880}
    10981
    110 /** Create client association.
    111  *
    112  * This effectively adds an association into a client's namespace.
    113  *
    114  * @param client  Client
    115  * @param assoc   Association
    116  * @param rcassoc Place to store pointer to new client association
    117  *
    118  * @return EOK on soccess, ENOMEM if out of memory
    119  */
    120 static errno_t udp_cassoc_create(udp_client_t *client, udp_assoc_t *assoc,
    121     udp_cassoc_t **rcassoc)
    122 {
    123         udp_cassoc_t *cassoc;
    124         sysarg_t id;
    125 
    126         cassoc = calloc(1, sizeof(udp_cassoc_t));
    127         if (cassoc == NULL)
    128                 return ENOMEM;
    129 
    130         /* Allocate new ID */
    131         id = 0;
    132         list_foreach (client->cassoc, lclient, udp_cassoc_t, cassoc) {
    133                 if (cassoc->id >= id)
    134                         id = cassoc->id + 1;
    135         }
    136 
    137         cassoc->id = id;
    138         cassoc->client = client;
    139         cassoc->assoc = assoc;
    140 
    141         list_append(&cassoc->lclient, &client->cassoc);
    142         *rcassoc = cassoc;
    143         return EOK;
    144 }
    145 
    146 /** Destroy client association.
    147  *
    148  * @param cassoc Client association
    149  */
    150 static void udp_cassoc_destroy(udp_cassoc_t *cassoc)
    151 {
    152         list_remove(&cassoc->lclient);
    153         free(cassoc);
    154 }
    155 
    156 /** Get client association by ID.
    157  *
    158  * @param client  Client
    159  * @param id      Client association ID
    160  * @param rcassoc Place to store pointer to client association
    161  *
    162  * @return EOK on success, ENOENT if no client association with the given ID
    163  *         is found.
    164  */
    165 static errno_t udp_cassoc_get(udp_client_t *client, sysarg_t id,
    166     udp_cassoc_t **rcassoc)
    167 {
    168         list_foreach (client->cassoc, lclient, udp_cassoc_t, cassoc) {
    169                 if (cassoc->id == id) {
    170                         *rcassoc = cassoc;
    171                         return EOK;
    172                 }
    173         }
    174 
    175         return ENOENT;
    176 }
    177 
    17882/** Message received on client association.
    17983 *
     
    18488 * @param msg Message
    18589 */
    186 static void udp_cassoc_recv_msg(void *arg, inet_ep2_t *epp, udp_msg_t *msg)
     90static void udp_recv_msg_cassoc(void *arg, inet_ep2_t *epp, udp_msg_t *msg)
    18791{
    18892        udp_cassoc_t *cassoc = (udp_cassoc_t *) arg;
Note: See TracChangeset for help on using the changeset viewer.