Changeset b10460a in mainline for uspace/lib/c/generic/inet/udp.c


Ignore:
Timestamp:
2015-08-07T21:39:00Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b688fd8
Parents:
6accc5cf
Message:

Add missing docblocks in network code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/inet/udp.c

    r6accc5cf rb10460a  
    4343static void udp_cb_conn(ipc_callid_t, ipc_call_t *, void *);
    4444
     45/** Create callback connection from UDP service.
     46 *
     47 * @param udp UDP service
     48 * @return EOK on success or negative error code
     49 */
    4550static int udp_callback_create(udp_t *udp)
    4651{
     
    6065}
    6166
     67/** Create UDP client instance.
     68 *
     69 * @param  rudp Place to store pointer to new UDP client
     70 * @return EOK on success, ENOMEM if out of memory, EIO if service
     71 *         cannot be contacted
     72 */
    6273int udp_create(udp_t **rudp)
    6374{
     
    103114}
    104115
     116/** Destroy UDP client instance.
     117 *
     118 * @param udp UDP client
     119 */
    105120void udp_destroy(udp_t *udp)
    106121{
     
    118133}
    119134
    120 int udp_assoc_create(udp_t *udp, inet_ep2_t *ep2, udp_cb_t *cb, void *arg,
     135/** Create new UDP association.
     136 *
     137 * Create a UDP association that allows sending and receiving messages.
     138 *
     139 * @a epp may specify remote address and port, in which case only messages
     140 * from that remote endpoint will be received. Also, that remote endpoint
     141 * is used as default when @c NULL is passed as destination to
     142 * udp_assoc_send_msg.
     143 *
     144 * @a epp may specify a local link or address. If it does not, the association
     145 * will listen on all local links/addresses. If @a epp does not specify
     146 * a local port number, a free dynamic port number will be allocated.
     147 *
     148 * The caller is informed about incoming data by invoking @a cb->recv_msg
     149 *
     150 * @param udp    UDP client
     151 * @param epp    Internet endpoint pair
     152 * @param cb     Callbacks
     153 * @param arg    Argument to callbacks
     154 * @param rassoc Place to store pointer to new association
     155 *
     156 * @return EOK on success or negative error code.
     157 */
     158int udp_assoc_create(udp_t *udp, inet_ep2_t *epp, udp_cb_t *cb, void *arg,
    121159    udp_assoc_t **rassoc)
    122160{
     
    131169        exch = async_exchange_begin(udp->sess);
    132170        aid_t req = async_send_0(exch, UDP_ASSOC_CREATE, &answer);
    133         sysarg_t rc = async_data_write_start(exch, (void *)ep2,
     171        sysarg_t rc = async_data_write_start(exch, (void *)epp,
    134172            sizeof(inet_ep2_t));
    135173        async_exchange_end(exch);
     
    161199}
    162200
     201/** Destroy UDP association.
     202 *
     203 * Destroy UDP association. The caller should destroy all associations
     204 * he created before destroying the UDP client and before terminating.
     205 *
     206 * @param assoc UDP association
     207 */
    163208void udp_assoc_destroy(udp_assoc_t *assoc)
    164209{
     
    178223}
    179224
     225/** Send message via UDP association.
     226 *
     227 * @param assoc Association
     228 * @param dest  Destination endpoint or @c NULL to use association's remote ep.
     229 * @param data  Message data
     230 * @param bytes Message size in bytes
     231 *
     232 * @return EOK on success or negative error code
     233 */
    180234int udp_assoc_send_msg(udp_assoc_t *assoc, inet_ep_t *dest, void *data,
    181235    size_t bytes)
     
    211265}
    212266
     267/** Get the user/callback argument for an association.
     268 *
     269 * @param assoc UDP association
     270 * @return User argument associated with association
     271 */
    213272void *udp_assoc_userptr(udp_assoc_t *assoc)
    214273{
     
    216275}
    217276
     277/** Get size of received message in bytes.
     278 *
     279 * Assuming jumbo messages can be received, the caller first needs to determine
     280 * the size of the received message by calling this function, then they can
     281 * read the message piece-wise using udp_rmsg_read().
     282 *
     283 * @param rmsg Received message
     284 * @return Size of received message in bytes
     285 */
    218286size_t udp_rmsg_size(udp_rmsg_t *rmsg)
    219287{
     
    221289}
    222290
     291/** Read part of received message.
     292 *
     293 * @param rmsg  Received message
     294 * @param off   Start offset
     295 * @param buf   Buffer for storing data
     296 * @param bsize Buffer size
     297 *
     298 * @return EOK on success or negative error code.
     299 */
    223300int udp_rmsg_read(udp_rmsg_t *rmsg, size_t off, void *buf, size_t bsize)
    224301{
     
    245322}
    246323
     324/** Get remote endpoint of received message.
     325 *
     326 * Place the remote endpoint (the one from which the message was supposedly
     327 * sent) to @a ep.
     328 *
     329 * @param rmsg Received message
     330 * @param ep   Place to store remote endpoint
     331 */
    247332void udp_rmsg_remote_ep(udp_rmsg_t *rmsg, inet_ep_t *ep)
    248333{
     
    250335}
    251336
     337/** Get type of received ICMP error message.
     338 *
     339 * @param rerr Received error message
     340 * @return Error message type
     341 */
    252342uint8_t udp_rerr_type(udp_rerr_t *rerr)
    253343{
     
    255345}
    256346
     347/** Get code of received ICMP error message.
     348 *
     349 * @param rerr Received error message
     350 * @return Error message code
     351 */
    257352uint8_t udp_rerr_code(udp_rerr_t *rerr)
    258353{
     
    260355}
    261356
     357/** Get information about the next received message from UDP service.
     358 *
     359 * @param udp  UDP client
     360 * @param rmsg Place to store message information
     361 *
     362 * @return EOK on success or negative error code
     363 */
    262364static int udp_rmsg_info(udp_t *udp, udp_rmsg_t *rmsg)
    263365{
     
    288390}
    289391
     392/** Discard next received message in UDP service.
     393 *
     394 * @param udp UDP client
     395 * @return EOK on success or negative error code
     396 */
    290397static int udp_rmsg_discard(udp_t *udp)
    291398{
     
    299406}
    300407
     408/** Get association based on its ID.
     409 *
     410 * @param udp    UDP client
     411 * @param id     Association ID
     412 * @param rassoc Place to store pointer to association
     413 *
     414 * @return EOK on success, EINVAL if no association with the given ID exists
     415 */
    301416static int udp_assoc_get(udp_t *udp, sysarg_t id, udp_assoc_t **rassoc)
    302417{
     
    311426}
    312427
     428/** Handle 'data' event, i.e. some message(s) arrived.
     429 *
     430 * For each received message, get information about it, call @c recv_msg
     431 * callback and discard it.
     432 *
     433 * @param udp UDP client
     434 * @param iid IPC message ID
     435 * @param icall IPC message
     436 */
    313437static void udp_ev_data(udp_t *udp, ipc_callid_t iid, ipc_call_t *icall)
    314438{
     
    340464}
    341465
     466/** UDP service callback connection.
     467 *
     468 * @param iid Connect message ID
     469 * @param icall Connect message
     470 * @param arg Argument, UDP client
     471 */
    342472static void udp_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    343473{
Note: See TracChangeset for help on using the changeset viewer.