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


Ignore:
Timestamp:
2015-11-02T20:54:19Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d8513177
Parents:
3feeab2 (diff), 5265eea4 (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 mainline changes.

File:
1 edited

Legend:

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

    r3feeab2 rff381a7  
    5252#define NAME "udp"
    5353
     54/** Maximum message size */
    5455#define MAX_MSG_SIZE DATA_XFER_LIMIT
    5556
    5657static void udp_cassoc_recv_msg(void *, inet_ep2_t *, udp_msg_t *);
    5758
     59/** Callbacks to tie us to association layer */
    5860static udp_assoc_cb_t udp_cassoc_cb = {
    5961        .recv_msg = udp_cassoc_recv_msg
    6062};
    6163
     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 */
    6272static int udp_cassoc_queue_msg(udp_cassoc_t *cassoc, inet_ep2_t *epp,
    6373    udp_msg_t *msg)
     
    8696}
    8797
     98/** Send 'data' event to client.
     99 *
     100 * @param client Client
     101 */
    88102static void udp_ev_data(udp_client_t *client)
    89103{
     
    99113}
    100114
     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 */
    101125static int udp_cassoc_create(udp_client_t *client, udp_assoc_t *assoc,
    102126    udp_cassoc_t **rcassoc)
     
    125149}
    126150
     151/** Destroy client association.
     152 *
     153 * @param cassoc Client association
     154 */
    127155static void udp_cassoc_destroy(udp_cassoc_t *cassoc)
    128156{
     
    131159}
    132160
     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 */
    133170static int udp_cassoc_get(udp_client_t *client, sysarg_t id,
    134171    udp_cassoc_t **rcassoc)
     
    144181}
    145182
     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 */
    146191static void udp_cassoc_recv_msg(void *arg, inet_ep2_t *epp, udp_msg_t *msg)
    147192{
     
    152197}
    153198
     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 */
    154209static int udp_assoc_create_impl(udp_client_t *client, inet_ep2_t *epp,
    155210    sysarg_t *rassoc_id)
     
    189244}
    190245
     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 */
    191254static int udp_assoc_destroy_impl(udp_client_t *client, sysarg_t assoc_id)
    192255{
     
    207270}
    208271
     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 */
    209285static int udp_assoc_send_msg_impl(udp_client_t *client, sysarg_t assoc_id,
    210286    inet_ep_t *dest, void *data, size_t size)
     
    227303}
    228304
     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 */
    229313static void udp_callback_create_srv(udp_client_t *client, ipc_callid_t iid,
    230314    ipc_call_t *icall)
     
    242326}
    243327
     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 */
    244336static void udp_assoc_create_srv(udp_client_t *client, ipc_callid_t iid,
    245337    ipc_call_t *icall)
     
    281373}
    282374
     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 */
    283383static void udp_assoc_destroy_srv(udp_client_t *client, ipc_callid_t iid,
    284384    ipc_call_t *icall)
     
    294394}
    295395
     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 */
    296404static void udp_assoc_send_msg_srv(udp_client_t *client, ipc_callid_t iid,
    297405    ipc_call_t *icall)
     
    368476}
    369477
     478/** Get next received message.
     479 *
     480 * @param client UDP Client
     481 * @return Pointer to queue entry for next received message
     482 */
    370483static udp_crcv_queue_entry_t *udp_rmsg_get_next(udp_client_t *client)
    371484{
     
    379492}
    380493
     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 */
    381502static void udp_rmsg_info_srv(udp_client_t *client, ipc_callid_t iid,
    382503    ipc_call_t *icall)
     
    418539}
    419540
     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 */
    420549static void udp_rmsg_read_srv(udp_client_t *client, ipc_callid_t iid,
    421550    ipc_call_t *icall)
     
    460589}
    461590
     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 */
    462600static void udp_rmsg_discard_srv(udp_client_t *client, ipc_callid_t iid,
    463601    ipc_call_t *icall)
     
    480618}
    481619
     620/** Handle UDP client connection.
     621 *
     622 * @param iid   Connect call ID
     623 * @param icall Connect call data
     624 * @param arg   Connection argument
     625 */
    482626static void udp_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    483627{
    484628        udp_client_t client;
    485         size_t n;
     629        unsigned long n;
    486630
    487631        /* Accept the connection */
     
    541685        if (n != 0) {
    542686                log_msg(LOG_DEFAULT, LVL_WARN, "udp_client_conn: "
    543                     "Client with %zu active associations closed session.", n);
     687                    "Client with %lu active associations closed session.", n);
    544688                /* XXX Clean up */
    545689        }
     
    551695}
    552696
     697/** Initialize UDP service.
     698 *
     699 * @return EOK on success or negative error code.
     700 */
    553701int udp_service_init(void)
    554702{
     
    556704        service_id_t sid;
    557705
    558         async_set_client_connection(udp_client_conn);
     706        async_set_fallback_port_handler(udp_client_conn, NULL);
    559707
    560708        rc = loc_server_register(NAME);
Note: See TracChangeset for help on using the changeset viewer.