Ignore:
File:
1 edited

Legend:

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

    r1d03e86 r1f2b07a  
    5252#define NAME "udp"
    5353
    54 /** Maximum message size */
    5554#define MAX_MSG_SIZE DATA_XFER_LIMIT
    5655
    5756static void udp_cassoc_recv_msg(void *, inet_ep2_t *, udp_msg_t *);
    5857
    59 /** Callbacks to tie us to association layer */
    6058static udp_assoc_cb_t udp_cassoc_cb = {
    6159        .recv_msg = udp_cassoc_recv_msg
    6260};
    6361
    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  */
    7262static int udp_cassoc_queue_msg(udp_cassoc_t *cassoc, inet_ep2_t *epp,
    7363    udp_msg_t *msg)
     
    9686}
    9787
    98 /** Send 'data' event to client.
    99  *
    100  * @param client Client
    101  */
    10288static void udp_ev_data(udp_client_t *client)
    10389{
     
    11399}
    114100
    115 /** Create client association.
    116  *
    117  * This effectively adds an association into a client's namespace.
    118  *
    119  * @param client  Client
    120  * @param assoc   Association
    121  * @param rcassoc Place to store pointer to new client association
    122  *
    123  * @return EOK on soccess, ENOMEM if out of memory
    124  */
    125101static int udp_cassoc_create(udp_client_t *client, udp_assoc_t *assoc,
    126102    udp_cassoc_t **rcassoc)
     
    149125}
    150126
    151 /** Destroy client association.
    152  *
    153  * @param cassoc Client association
    154  */
    155127static void udp_cassoc_destroy(udp_cassoc_t *cassoc)
    156128{
     
    159131}
    160132
    161 /** Get client association by ID.
    162  *
    163  * @param client  Client
    164  * @param id      Client association ID
    165  * @param rcassoc Place to store pointer to client association
    166  *
    167  * @return EOK on success, ENOENT if no client association with the given ID
    168  *         is found.
    169  */
    170133static int udp_cassoc_get(udp_client_t *client, sysarg_t id,
    171134    udp_cassoc_t **rcassoc)
     
    181144}
    182145
    183 /** Message received on client association.
    184  *
    185  * Used as udp_assoc_cb.recv_msg callback.
    186  *
    187  * @param arg Callback argument, client association
    188  * @param epp Endpoint pair where message was received
    189  * @param msg Message
    190  */
    191146static void udp_cassoc_recv_msg(void *arg, inet_ep2_t *epp, udp_msg_t *msg)
    192147{
     
    197152}
    198153
    199 /** Create association.
    200  *
    201  * Handle client request to create association (with parameters unmarshalled).
    202  *
    203  * @param client    UDP client
    204  * @param epp       Endpoint pair
    205  * @param rassoc_id Place to store ID of new association
    206  *
    207  * @return EOK on success or negative error code
    208  */
    209154static int udp_assoc_create_impl(udp_client_t *client, inet_ep2_t *epp,
    210155    sysarg_t *rassoc_id)
     
    244189}
    245190
    246 /** Destroy association.
    247  *
    248  * Handle client request to destroy association (with parameters unmarshalled).
    249  *
    250  * @param client   UDP client
    251  * @param assoc_id Association ID
    252  * @return EOK on success, ENOENT if no such association is found
    253  */
    254191static int udp_assoc_destroy_impl(udp_client_t *client, sysarg_t assoc_id)
    255192{
     
    270207}
    271208
    272 /** Send message via association.
    273  *
    274  * Handle client request to send message (with parameters unmarshalled).
    275  *
    276  * @param client   UDP client
    277  * @param assoc_id Association ID
    278  * @param dest     Destination endpoint or @c NULL to use the default from
    279  *                 association
    280  * @param data     Message data
    281  * @param size     Message size
    282  *
    283  * @return EOK on success or negative error code
    284  */
    285209static int udp_assoc_send_msg_impl(udp_client_t *client, sysarg_t assoc_id,
    286210    inet_ep_t *dest, void *data, size_t size)
     
    303227}
    304228
    305 /** Create callback session.
    306  *
    307  * Handle client request to create callback session.
    308  *
    309  * @param client   UDP client
    310  * @param iid      Async request ID
    311  * @param icall    Async request data
    312  */
    313229static void udp_callback_create_srv(udp_client_t *client, ipc_callid_t iid,
    314230    ipc_call_t *icall)
     
    326242}
    327243
    328 /** Create association.
    329  *
    330  * Handle client request to create association.
    331  *
    332  * @param client   UDP client
    333  * @param iid      Async request ID
    334  * @param icall    Async request data
    335  */
    336244static void udp_assoc_create_srv(udp_client_t *client, ipc_callid_t iid,
    337245    ipc_call_t *icall)
     
    373281}
    374282
    375 /** Destroy association.
    376  *
    377  * Handle client request to destroy association.
    378  *
    379  * @param client   UDP client
    380  * @param iid      Async request ID
    381  * @param icall    Async request data
    382  */
    383283static void udp_assoc_destroy_srv(udp_client_t *client, ipc_callid_t iid,
    384284    ipc_call_t *icall)
     
    394294}
    395295
    396 /** Send message via association.
    397  *
    398  * Handle client request to send message.
    399  *
    400  * @param client   UDP client
    401  * @param iid      Async request ID
    402  * @param icall    Async request data
    403  */
    404296static void udp_assoc_send_msg_srv(udp_client_t *client, ipc_callid_t iid,
    405297    ipc_call_t *icall)
     
    476368}
    477369
    478 /** Get next received message.
    479  *
    480  * @param client UDP Client
    481  * @return Pointer to queue entry for next received message
    482  */
    483370static udp_crcv_queue_entry_t *udp_rmsg_get_next(udp_client_t *client)
    484371{
     
    492379}
    493380
    494 /** Get info on first received message.
    495  *
    496  * Handle client request to get information on received message.
    497  *
    498  * @param client   UDP client
    499  * @param iid      Async request ID
    500  * @param icall    Async request data
    501  */
    502381static void udp_rmsg_info_srv(udp_client_t *client, ipc_callid_t iid,
    503382    ipc_call_t *icall)
     
    539418}
    540419
    541 /** Read data from first received message.
    542  *
    543  * Handle client request to read data from first received message.
    544  *
    545  * @param client   UDP client
    546  * @param iid      Async request ID
    547  * @param icall    Async request data
    548  */
    549420static void udp_rmsg_read_srv(udp_client_t *client, ipc_callid_t iid,
    550421    ipc_call_t *icall)
     
    589460}
    590461
    591 /** Discard first received message.
    592  *
    593  * Handle client request to discard first received message, advancing
    594  * to the next one.
    595  *
    596  * @param client   UDP client
    597  * @param iid      Async request ID
    598  * @param icall    Async request data
    599  */
    600462static void udp_rmsg_discard_srv(udp_client_t *client, ipc_callid_t iid,
    601463    ipc_call_t *icall)
     
    618480}
    619481
    620 /** Handle UDP client connection.
    621  *
    622  * @param iid   Connect call ID
    623  * @param icall Connect call data
    624  * @param arg   Connection argument
    625  */
    626482static void udp_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    627483{
    628484        udp_client_t client;
    629         unsigned long n;
     485        size_t n;
    630486
    631487        /* Accept the connection */
     
    685541        if (n != 0) {
    686542                log_msg(LOG_DEFAULT, LVL_WARN, "udp_client_conn: "
    687                     "Client with %lu active associations closed session.", n);
     543                    "Client with %zu active associations closed session.", n);
    688544                /* XXX Clean up */
    689545        }
     
    695551}
    696552
    697 /** Initialize UDP service.
    698  *
    699  * @return EOK on success or negative error code.
    700  */
    701553int udp_service_init(void)
    702554{
     
    704556        service_id_t sid;
    705557
    706         async_set_fallback_port_handler(udp_client_conn, NULL);
     558        async_set_client_connection(udp_client_conn);
    707559
    708560        rc = loc_server_register(NAME);
Note: See TracChangeset for help on using the changeset viewer.