Changeset b10460a in mainline


Ignore:
Timestamp:
2015-08-07T21:39:00Z (9 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.

Location:
uspace
Files:
9 edited

Legend:

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

    r6accc5cf rb10460a  
    3636#include <mem.h>
    3737
     38/** Initialize endpoint structure.
     39 *
     40 * Sets any address, any port number.
     41 *
     42 * @param ep Endpoint
     43 */
    3844void inet_ep_init(inet_ep_t *ep)
    3945{
     
    4147}
    4248
     49/** Initialize endpoint pair structure.
     50 *
     51 * Sets any address, any port number for both local and remote sides.
     52 *
     53 * @param ep2 Endpoint pair
     54 */
    4355void inet_ep2_init(inet_ep2_t *ep2)
    4456{
  • uspace/lib/c/generic/inet/tcp.c

    r6accc5cf rb10460a  
    4444static int tcp_conn_fibril(void *);
    4545
    46 /** Incoming TCP connection info */
     46/** Incoming TCP connection info
     47 *
     48 * Used to pass information about incoming TCP connection to the connection
     49 * fibril
     50 */
    4751typedef struct {
     52        /** Listener who received the connection */
    4853        tcp_listener_t *lst;
     54        /** Incoming connection */
    4955        tcp_conn_t *conn;
    5056} tcp_in_conn_t;
    5157
     58/** Create callback connection from TCP service.
     59 *
     60 * @param tcp TCP service
     61 * @return EOK on success or negative error code
     62 */
    5263static int tcp_callback_create(tcp_t *tcp)
    5364{
     
    6778}
    6879
     80/** Create TCP client instance.
     81 *
     82 * @param  rtcp Place to store pointer to new TCP client
     83 * @return EOK on success, ENOMEM if out of memory, EIO if service
     84 *         cannot be contacted
     85 */
    6986int tcp_create(tcp_t **rtcp)
    7087{
     
    111128}
    112129
     130/** Destroy TCP client instance.
     131 *
     132 * @param tcp TCP client
     133 */
    113134void tcp_destroy(tcp_t *tcp)
    114135{
     
    126147}
    127148
     149/** Create new TCP connection
     150 *
     151 * @param tcp   TCP client instance
     152 * @param id    Connection ID
     153 * @param cb    Callbacks
     154 * @param arg   Callback argument
     155 * @param rconn Place to store pointer to new connection
     156 *
     157 * @return EOK on success, ENOMEM if out of memory
     158 */
    128159static int tcp_conn_new(tcp_t *tcp, sysarg_t id, tcp_cb_t *cb, void *arg,
    129160    tcp_conn_t **rconn)
     
    150181}
    151182
     183/** Create new TCP connection.
     184 *
     185 * Open a connection to the specified destination. This function returns
     186 * even before the connection is established (or not). When the connection
     187 * is established, @a cb->connected is called. If the connection fails,
     188 * @a cb->conn_failed is called. Alternatively, the caller can call
     189 * @c tcp_conn_wait_connected() to wait for connection to complete or fail.
     190 * Other callbacks are available to monitor the changes in connection state.
     191 *
     192 * @a epp must specify the remote address and port. Both local address and
     193 * port are optional. If local address is not specified, address selection
     194 * will take place. If local port number is not specified, a suitable
     195 * free dynamic port number will be allocated.
     196 *
     197 * @param tcp   TCP client
     198 * @param epp   Internet endpoint pair
     199 * @param cb    Callbacks
     200 * @param arg   Argument to callbacks
     201 * @param rconn Place to store pointer to new connection
     202 *
     203 * @return EOK on success or negative error code.
     204 */
    152205int tcp_conn_create(tcp_t *tcp, inet_ep2_t *epp, tcp_cb_t *cb, void *arg,
    153206    tcp_conn_t **rconn)
     
    186239}
    187240
     241/** Destroy TCP connection.
     242 *
     243 * Destroy TCP connection. The caller should destroy all connections
     244 * he created before destroying the TCP client and before terminating.
     245 *
     246 * @param conn TCP connection
     247 */
    188248void tcp_conn_destroy(tcp_conn_t *conn)
    189249{
     
    203263}
    204264
     265/** Get connection based on its ID.
     266 *
     267 * @param tcp   TCP client
     268 * @param id    Connection ID
     269 * @param rconn Place to store pointer to connection
     270 *
     271 * @return EOK on success, EINVAL if no connection with the given ID exists
     272 */
    205273static int tcp_conn_get(tcp_t *tcp, sysarg_t id, tcp_conn_t **rconn)
    206274{
     
    215283}
    216284
     285/** Get the user/callback argument for a connection.
     286 *
     287 * @param conn TCP connection
     288 * @return User argument associated with connection
     289 */
    217290void *tcp_conn_userptr(tcp_conn_t *conn)
    218291{
     
    220293}
    221294
     295/** Create a TCP connection listener.
     296 *
     297 * A listener listens for connections on the set of endpoints specified
     298 * by @a ep. Each time a new incoming connection is established,
     299 * @a lcb->new_conn is called (and passed @a larg). Also, the new connection
     300 * will have callbacks set to @a cb and argument to @a arg.
     301 *
     302 * @a ep must specify a valid port number. @a ep may specify an address
     303 * or link to listen on. If it does not, the listener will listen on
     304 * all links/addresses.
     305 *
     306 * @param tcp  TCP client
     307 * @param ep   Internet endpoint
     308 * @param lcb  Listener callbacks
     309 * @param larg Listener callback argument
     310 * @param cb   Connection callbacks for every new connection
     311 * @param arg  Connection argument for every new connection
     312 * @param rlst Place to store pointer to new listener
     313 *
     314 * @return EOK on success or negative error code
     315 */
    222316int tcp_listener_create(tcp_t *tcp, inet_ep_t *ep, tcp_listen_cb_t *lcb,
    223317    void *larg, tcp_cb_t *cb, void *arg, tcp_listener_t **rlst)
     
    265359}
    266360
     361/** Destroy TCP connection listener.
     362 *
     363 * @param lst Listener
     364 */
    267365void tcp_listener_destroy(tcp_listener_t *lst)
    268366{
     
    282380}
    283381
     382/** Get TCP connection listener based on its ID.
     383 *
     384 * @param tcp TCP client
     385 * @param id  Listener ID
     386 * @param rlst Place to store pointer to listener
     387 *
     388 * @return EOK on success, EINVAL if no listener with the given ID is found
     389 */
    284390static int tcp_listener_get(tcp_t *tcp, sysarg_t id, tcp_listener_t **rlst)
    285391{
     
    294400}
    295401
     402/** Get callback/user argument associated with listener.
     403 *
     404 * @param lst Listener
     405 * @return Callback/user argument
     406 */
    296407void *tcp_listener_userptr(tcp_listener_t *lst)
    297408{
     
    299410}
    300411
     412/** Wait until connection is either established or connection fails.
     413 *
     414 * Can be called after calling tcp_conn_create() to block until connection
     415 * either completes or fails. If the connection fails, EIO is returned.
     416 * In this case the connection still exists, but is in a failed
     417 * state.
     418 *
     419 * @param conn Connection
     420 * @return EOK if connection is established, EIO otherwise
     421 */
    301422int tcp_conn_wait_connected(tcp_conn_t *conn)
    302423{
     
    315436}
    316437
     438/** Send data over TCP connection.
     439 *
     440 * @param conn  Connection
     441 * @param data  Data
     442 * @param bytes Data size in bytes
     443 *
     444 * @return EOK on success or negative error code
     445 */
    317446int tcp_conn_send(tcp_conn_t *conn, const void *data, size_t bytes)
    318447{
     
    340469}
    341470
    342 
     471/** Send FIN.
     472 *
     473 * Send FIN, indicating no more data will be send over the connection.
     474 *
     475 * @param conn Connection
     476 * @return EOK on success or negative error code
     477 */
    343478int tcp_conn_send_fin(tcp_conn_t *conn)
    344479{
     
    352487}
    353488
     489/** Push connection.
     490 *
     491 * @param conn Connection
     492 * @return EOK on success or negative error code
     493 */
    354494int tcp_conn_push(tcp_conn_t *conn)
    355495{
     
    363503}
    364504
     505/** Reset connection.
     506 *
     507 * @param conn Connection
     508 * @return EOK on success or negative error code
     509 */
    365510int tcp_conn_reset(tcp_conn_t *conn)
    366511{
     
    374519}
    375520
     521/** Read received data from connection without blocking.
     522 *
     523 * If any received data is pending on the connection, up to @a bsize bytes
     524 * are copied to @a buf and the acutal number is stored in @a *nrecv.
     525 * The entire buffer of @a bsize bytes is filled except when less data
     526 * is currently available or FIN is received. EOK is returned.
     527 *
     528 * If no received data is pending, returns EAGAIN.
     529 *
     530 * @param conn Connection
     531 * @param buf  Buffer
     532 * @param bsize Buffer size
     533 * @param nrecv Place to store actual number of received bytes
     534 *
     535 * @return EOK on success, EAGAIN if no received data is pending, or other
     536 *         negative error code in case of other error
     537 */
    376538int tcp_conn_recv(tcp_conn_t *conn, void *buf, size_t bsize, size_t *nrecv)
    377539{
     
    408570}
    409571
    410 int tcp_conn_recv_wait(tcp_conn_t *conn, void *buf, size_t bsize, size_t *nrecv)
     572/** Read received data from connection with blocking.
     573 *
     574 * Wait for @a bsize bytes of data to be received and copy them to
     575 * @a buf. Less data may be returned if FIN is received on the connection.
     576 * The actual If any received data is written to @a *nrecv and EOK
     577 * is returned on success.
     578 *
     579 * @param conn Connection
     580 * @param buf  Buffer
     581 * @param bsize Buffer size
     582 * @param nrecv Place to store actual number of received bytes
     583 *
     584 * @return EOK on success or negative error code
     585 */
     586int tcp_conn_recv_wait(tcp_conn_t *conn, void *buf, size_t bsize,
     587    size_t *nrecv)
    411588{
    412589        async_exch_t *exch;
     
    450627}
    451628
     629/** Connection established event.
     630 *
     631 * @param tcp TCP client
     632 * @param iid Call ID
     633 * @param icall Call data
     634 */
    452635static void tcp_ev_connected(tcp_t *tcp, ipc_callid_t iid, ipc_call_t *icall)
    453636{
     
    472655}
    473656
     657/** Connection failed event.
     658 *
     659 * @param tcp TCP client
     660 * @param iid Call ID
     661 * @param icall Call data
     662 */
    474663static void tcp_ev_conn_failed(tcp_t *tcp, ipc_callid_t iid, ipc_call_t *icall)
    475664{
     
    494683}
    495684
     685/** Connection reset event.
     686 *
     687 * @param tcp TCP client
     688 * @param iid Call ID
     689 * @param icall Call data
     690 */
    496691static void tcp_ev_conn_reset(tcp_t *tcp, ipc_callid_t iid, ipc_call_t *icall)
    497692{
     
    516711}
    517712
     713/** Data available event.
     714 *
     715 * @param tcp TCP client
     716 * @param iid Call ID
     717 * @param icall Call data
     718 */
    518719static void tcp_ev_data(tcp_t *tcp, ipc_callid_t iid, ipc_call_t *icall)
    519720{
     
    539740}
    540741
     742/** Urgent data event.
     743 *
     744 * @param tcp TCP client
     745 * @param iid Call ID
     746 * @param icall Call data
     747 */
    541748static void tcp_ev_urg_data(tcp_t *tcp, ipc_callid_t iid, ipc_call_t *icall)
    542749{
     
    544751}
    545752
     753/** New connection event.
     754 *
     755 * @param tcp TCP client
     756 * @param iid Call ID
     757 * @param icall Call data
     758 */
    546759static void tcp_ev_new_conn(tcp_t *tcp, ipc_callid_t iid, ipc_call_t *icall)
    547760{
     
    590803}
    591804
     805/** Callback connection handler.
     806 *
     807 * @param iid Connect call ID
     808 * @param icall Connect call data
     809 * @param arg Argument, TCP client
     810 */
    592811static void tcp_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    593812{
     
    636855}
    637856
    638 /** Fibril for handling incoming TCP connection in background */
     857/** Fibril for handling incoming TCP connection in background.
     858 *
     859 * @param arg Argument, incoming connection information (@c tcp_in_conn_t)
     860 */
    639861static int tcp_conn_fibril(void *arg)
    640862{
  • 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{
  • uspace/lib/nettl/src/amap.c

    r6accc5cf rb10460a  
    3636 * Manages allocations of endpoints / endpoint pairs (corresponding to
    3737 * UDP associations, TCP listeners and TCP connections)
     38 *
     39 * An association map contains different types of entries, based on which
     40 * set of attributes (key) they specify. In order from most specific to the
     41 * least specific one:
     42 *
     43 *  - repla (remote endpoint, local address)
     44 *  - laddr (local address)
     45 *  - llink (local link)
     46 *  - unspec (unspecified)
     47 *
     48 * In the unspecified case only the local port is known and the entry matches
     49 * all remote and local addresses.
    3850 */
    3951
     
    4759#include <stdlib.h>
    4860
     61/** Create association map.
     62 *
     63 * @param rmap Place to store pointer to new association map
     64 * @return EOk on success, ENOMEM if out of memory
     65 */
    4966int amap_create(amap_t **rmap)
    5067{
     
    7390}
    7491
     92/** Destroy association map.
     93 *
     94 * @param map Association map
     95 */
    7596void amap_destroy(amap_t *map)
    7697{
     
    79100}
    80101
    81 /** Find exact repla */
     102/** Find exact repla.
     103 *
     104 * Find repla (remote endpoint, local address) entry by exact match.
     105 *
     106 * @param map Association map
     107 * @param rep Remote endpoint
     108 * @param la  Local address
     109 * @param rrepla Place to store pointer to repla
     110 *
     111 * @return EOK on success, ENOENT if not found
     112 */
    82113static int amap_repla_find(amap_t *map, inet_ep_t *rep, inet_addr_t *la,
    83114    amap_repla_t **rrepla)
     
    113144}
    114145
     146/** Insert repla.
     147 *
     148 * Insert new repla (remote endpoint, local address) entry to association map.
     149 *
     150 * @param amap   Association map
     151 * @param rep    Remote endpoint
     152 * @param la     Local address
     153 * @param rrepla Place to store pointer to new repla
     154 *
     155 * @return EOK on success, ENOMEM if out of memory
     156 */
    115157static int amap_repla_insert(amap_t *map, inet_ep_t *rep, inet_addr_t *la,
    116158    amap_repla_t **rrepla)
     
    139181}
    140182
     183/** Remove repla from association map.
     184 *
     185 * Remove repla (remote endpoint, local address) from association map.
     186 *
     187 * @param map   Association map
     188 * @param repla Repla
     189 */
    141190static void amap_repla_remove(amap_t *map, amap_repla_t *repla)
    142191{
     
    146195}
    147196
    148 /** Find exact laddr */
     197/** Find exact laddr.
     198 *
     199 * Find laddr (local address) entry by exact match.
     200 *
     201 * @param map    Association map
     202 * @param addr   Address
     203 * @param rladdr Place to store pointer to laddr entry
     204 *
     205 * @return EOK on success, ENOENT if not found.
     206 */
    149207static int amap_laddr_find(amap_t *map, inet_addr_t *addr,
    150208    amap_laddr_t **rladdr)
     
    161219}
    162220
     221/** Insert laddr.
     222 *
     223 * Insert new laddr (local address) entry to association map.
     224 *
     225 * @param addr   Local address
     226 * @param rladdr Place to store pointer to new laddr
     227 *
     228 * @return EOK on success, ENOMEM if out of memory
     229 */
    163230static int amap_laddr_insert(amap_t *map, inet_addr_t *addr,
    164231    amap_laddr_t **rladdr)
     
    186253}
    187254
     255/** Remove laddr from association map.
     256 *
     257 * Remove laddr (local address) entry from association map.
     258 *
     259 * @param map   Association map
     260 * @param laddr Laddr entry
     261 */
    188262static void amap_laddr_remove(amap_t *map, amap_laddr_t *laddr)
    189263{
     
    193267}
    194268
    195 /** Find exact llink */
     269/** Find exact llink.
     270 *
     271 * Find llink (local link) entry by exact match.
     272 *
     273 * @param map     Association map
     274 * @param link_id Local link ID
     275 * @param rllink  Place to store pointer to llink entry
     276 *
     277 * @return EOK on success, ENOENT if not found.
     278 */
    196279static int amap_llink_find(amap_t *map, sysarg_t link_id,
    197280    amap_llink_t **rllink)
     
    208291}
    209292
     293/** Insert llink.
     294 *
     295 * Insert new llink (local link) entry to association map.
     296 *
     297 * @param link_id Local link
     298 * @param rllink  Place to store pointer to new llink
     299 *
     300 * @return EOK on success, ENOMEM if out of memory
     301 */
    210302static int amap_llink_insert(amap_t *map, sysarg_t link_id,
    211303    amap_llink_t **rllink)
     
    233325}
    234326
     327/** Remove llink from association map.
     328 *
     329 * Remove llink (local link) entry from association map.
     330 *
     331 * @param map   Association map
     332 * @param llink Llink entry
     333 */
    235334static void amap_llink_remove(amap_t *map, amap_llink_t *llink)
    236335{
     
    240339}
    241340
     341/** Insert endpoint pair into map with repla as key.
     342 *
     343 * If local port number is not specified, it is allocated.
     344 *
     345 * @param map Association map
     346 * @param epp Endpoint pair, possibly with local port inet_port_any
     347 * @param arg arg User value
     348 * @param flags Flags
     349 * @param aepp Place to store actual endpoint pair, possibly with allocated port
     350 *
     351 * @return EOK on success, EEXISTS if conflicting epp exists,
     352 *         ENOMEM if out of memory
     353 */
    242354static int amap_insert_repla(amap_t *map, inet_ep2_t *epp, void *arg,
    243355    amap_flags_t flags, inet_ep2_t *aepp)
     
    272384}
    273385
     386/** Insert endpoint pair into map with laddr as key.
     387 *
     388 * If local port number is not specified, it is allocated.
     389 *
     390 * @param map Association map
     391 * @param epp Endpoint pair, possibly with local port inet_port_any
     392 * @param arg arg User value
     393 * @param flags Flags
     394 * @param aepp Place to store actual endpoint pair, possibly with allocated port
     395 *
     396 * @return EOK on success, EEXISTS if conflicting epp exists,
     397 *         ENOMEM if out of memory
     398 */
    274399static int amap_insert_laddr(amap_t *map, inet_ep2_t *epp, void *arg,
    275400    amap_flags_t flags, inet_ep2_t *aepp)
     
    303428}
    304429
     430/** Insert endpoint pair into map with llink as key.
     431 *
     432 * If local port number is not specified, it is allocated.
     433 *
     434 * @param map Association map
     435 * @param epp Endpoint pair, possibly with local port inet_port_any
     436 * @param arg arg User value
     437 * @param flags Flags
     438 * @param aepp Place to store actual endpoint pair, possibly with allocated port
     439 *
     440 * @return EOK on success, EEXISTS if conflicting epp exists,
     441 *         ENOMEM if out of memory
     442 */
    305443static int amap_insert_llink(amap_t *map, inet_ep2_t *epp, void *arg,
    306444    amap_flags_t flags, inet_ep2_t *aepp)
     
    334472}
    335473
     474/** Insert endpoint pair into map with unspec as key.
     475 *
     476 * If local port number is not specified, it is allocated.
     477 *
     478 * @param map Association map
     479 * @param epp Endpoint pair, possibly with local port inet_port_any
     480 * @param arg arg User value
     481 * @param flags Flags
     482 * @param aepp Place to store actual endpoint pair, possibly with allocated port
     483 *
     484 * @return EOK on success, EEXISTS if conflicting epp exists,
     485 *         ENOMEM if out of memory
     486 */
    336487static int amap_insert_unspec(amap_t *map, inet_ep2_t *epp, void *arg,
    337488    amap_flags_t flags, inet_ep2_t *aepp)
     
    417568}
    418569
     570/** Remove endpoint pair using repla as key from map.
     571 *
     572 * The endpoint pair must be present in the map, otherwise behavior
     573 * is unspecified.
     574 *
     575 * @param map Association map
     576 * @param epp Endpoint pair
     577 */
    419578static void amap_remove_repla(amap_t *map, inet_ep2_t *epp)
    420579{
     
    434593}
    435594
     595/** Remove endpoint pair using laddr as key from map.
     596 *
     597 * The endpoint pair must be present in the map, otherwise behavior
     598 * is unspecified.
     599 *
     600 * @param map Association map
     601 * @param epp Endpoint pair
     602 */
    436603static void amap_remove_laddr(amap_t *map, inet_ep2_t *epp)
    437604{
     
    451618}
    452619
     620/** Remove endpoint pair using llink as key from map.
     621 *
     622 * The endpoint pair must be present in the map, otherwise behavior
     623 * is unspecified.
     624 *
     625 * @param map Association map
     626 * @param epp Endpoint pair
     627 */
    453628static void amap_remove_llink(amap_t *map, inet_ep2_t *epp)
    454629{
     
    468643}
    469644
     645/** Remove endpoint pair using unspec as key from map.
     646 *
     647 * The endpoint pair must be present in the map, otherwise behavior
     648 * is unspecified.
     649 *
     650 * @param map Association map
     651 * @param epp Endpoint pair
     652 */
    470653static void amap_remove_unspec(amap_t *map, inet_ep2_t *epp)
    471654{
     
    473656}
    474657
     658/** Remove endpoint pair from map.
     659 *
     660 * The endpoint pair must be present in the map, otherwise behavior
     661 * is unspecified.
     662 *
     663 * @param map Association map
     664 * @param epp Endpoint pair
     665 */
    475666void amap_remove(amap_t *map, inet_ep2_t *epp)
    476667{
  • uspace/lib/nettl/src/portrng.c

    r6accc5cf rb10460a  
    4646#include <io/log.h>
    4747
     48/** Create port range.
     49 *
     50 * @param rpr Place to store pointer to new port range
     51 * @return EOK on success, ENOMEM if out of memory
     52 */
    4853int portrng_create(portrng_t **rpr)
    4954{
     
    6267}
    6368
     69/** Destroy port range.
     70 *
     71 * @param pr Port range
     72 */
    6473void portrng_destroy(portrng_t *pr)
    6574{
     
    6978}
    7079
     80/** Allocate port number from port range.
     81 *
     82 * @param pr    Port range
     83 * @param pnum  Port number to allocate specific port, or zero to allocate
     84 *              any valid port from range
     85 * @param arg   User argument to set for port
     86 * @param flags Flags, @c pf_allow_system to allow ports from system range
     87 *              to be specified by @a pnum.
     88 * @param apnum Place to store allocated port number
     89 *
     90 * @return EOK on success, ENOENT if no free port number found, EEXISTS
     91 *         if @a pnum is specified but it is already allocated,
     92 *         EINVAL if @a pnum is specified from the system range, but
     93 *         @c pf_allow_system was not set.
     94 */
    7195int portrng_alloc(portrng_t *pr, uint16_t pnum, void *arg,
    7296    portrng_flags_t flags, uint16_t *apnum)
     
    131155}
    132156
     157/** Find allocated port number and return its argument.
     158 *
     159 * @param pr   Port range
     160 * @param pnum Port number
     161 * @param rarg Place to store user argument
     162 *
     163 * @return EOK on success, ENOENT if specified port number is not allocated
     164 */
    133165int portrng_find_port(portrng_t *pr, uint16_t pnum, void **rarg)
    134166{
     
    143175}
    144176
     177/** Free port in port range.
     178 *
     179 * @param pr   Port range
     180 * @param pnum Port number
     181 */
    145182void portrng_free_port(portrng_t *pr, uint16_t pnum)
    146183{
     
    158195}
    159196
     197/** Determine if port range is empty.
     198 *
     199 * @param pr Port range
     200 * @return @c true if no ports are allocated from @a pr, @c false otherwise
     201 */
    160202bool portrng_empty(portrng_t *pr)
    161203{
  • uspace/srv/net/tcp/service.c

    r6accc5cf rb10460a  
    2727 */
    2828
    29 /** @addtogroup udp
     29/** @addtogroup tcp
    3030 * @{
    3131 */
     
    4444#include <loc.h>
    4545#include <macros.h>
     46#include <mem.h>
    4647#include <stdlib.h>
    4748
     
    5354#define NAME "tcp"
    5455
     56/** Maximum amount of data transferred in one send call */
    5557#define MAX_MSG_SIZE DATA_XFER_LIMIT
    5658
     
    6769static int tcp_cconn_create(tcp_client_t *, tcp_conn_t *, tcp_cconn_t **);
    6870
     71/** Connection callbacks to tie us to lower layer */
    6972static tcp_cb_t tcp_service_cb = {
    7073        .cstate_change = tcp_service_cstate_change,
     
    7275};
    7376
     77/** Sentinel connection callbacks to tie us to lower layer */
    7478static tcp_cb_t tcp_service_lst_cb = {
    7579        .cstate_change = tcp_service_lst_cstate_change,
     
    7781};
    7882
     83/** Connection state has changed.
     84 *
     85 * @param conn      Connection
     86 * @param arg       Argument (not used)
     87 * @param old_state Previous connection state
     88 */
    7989static void tcp_service_cstate_change(tcp_conn_t *conn, void *arg,
    8090    tcp_cstate_t old_state)
     
    108118}
    109119
     120/** Sentinel connection state has changed.
     121 *
     122 * @param conn      Connection
     123 * @param arg       Argument (not used)
     124 * @param old_state Previous connection state
     125 */
    110126static void tcp_service_lst_cstate_change(tcp_conn_t *conn, void *arg,
    111127    tcp_cstate_t old_state)
     
    169185}
    170186
     187/** Received data became available on connection.
     188 *
     189 * @param conn Connection
     190 * @param arg  Client connection
     191 */
    171192static void tcp_service_recv_data(tcp_conn_t *conn, void *arg)
    172193{
     
    176197}
    177198
     199/** Send 'data' event to client.
     200 *
     201 * @param cconn Client connection
     202 */
    178203static void tcp_ev_data(tcp_cconn_t *cconn)
    179204{
     
    192217}
    193218
     219/** Send 'connected' event to client.
     220 *
     221 * @param cconn Client connection
     222 */
    194223static void tcp_ev_connected(tcp_cconn_t *cconn)
    195224{
     
    205234}
    206235
     236/** Send 'conn_failed' event to client.
     237 *
     238 * @param cconn Client connection
     239 */
    207240static void tcp_ev_conn_failed(tcp_cconn_t *cconn)
    208241{
     
    218251}
    219252
     253/** Send 'conn_reset' event to client.
     254 *
     255 * @param cconn Client connection
     256 */
    220257static void tcp_ev_conn_reset(tcp_cconn_t *cconn)
    221258{
     
    231268}
    232269
    233 /** New incoming connection */
     270/** Send 'new_conn' event to client.
     271 *
     272 * @param clst Client listener that received the connection
     273 * @param cconn New client connection
     274 */
    234275static void tcp_ev_new_conn(tcp_clst_t *clst, tcp_cconn_t *cconn)
    235276{
     
    246287}
    247288
     289/** Create client connection.
     290 *
     291 * This effectively adds a connection into a client's namespace.
     292 *
     293 * @param client TCP client
     294 * @param conn   Connection
     295 * @param rcconn Place to store pointer to new client connection
     296 *
     297 * @return EOK on success or ENOMEM if out of memory
     298 */
    248299static int tcp_cconn_create(tcp_client_t *client, tcp_conn_t *conn,
    249300    tcp_cconn_t **rcconn)
     
    272323}
    273324
     325/** Destroy client connection.
     326 *
     327 * @param cconn Client connection
     328 */
    274329static void tcp_cconn_destroy(tcp_cconn_t *cconn)
    275330{
     
    278333}
    279334
     335/** Create client listener.
     336 *
     337 * Create client listener based on sentinel connection.
     338 * XXX Implement actual listener in protocol core
     339 *
     340 * @param client TCP client
     341 * @param conn   Sentinel connection
     342 * @param rclst  Place to store pointer to new client listener
     343 *
     344 * @return EOK on success or ENOMEM if out of memory
     345 */
    280346static int tcp_clistener_create(tcp_client_t *client, tcp_conn_t *conn,
    281347    tcp_clst_t **rclst)
     
    304370}
    305371
     372/** Destroy client listener.
     373 *
     374 * @param clst Client listener
     375 */
    306376static void tcp_clistener_destroy(tcp_clst_t *clst)
    307377{
     
    310380}
    311381
     382/** Get client connection by ID.
     383 *
     384 * @param client Client
     385 * @param id     Client connection ID
     386 * @param rcconn Place to store pointer to client connection
     387 *
     388 * @return EOK on success, ENOENT if no client connection with the given ID
     389 *         is found.
     390 */
    312391static int tcp_cconn_get(tcp_client_t *client, sysarg_t id,
    313392    tcp_cconn_t **rcconn)
     
    323402}
    324403
     404/** Get client listener by ID.
     405 *
     406 * @param client Client
     407 * @param id     Client connection ID
     408 * @param rclst  Place to store pointer to client listener
     409 *
     410 * @return EOK on success, ENOENT if no client listener with the given ID
     411 *         is found.
     412 */
    325413static int tcp_clistener_get(tcp_client_t *client, sysarg_t id,
    326414    tcp_clst_t **rclst)
     
    336424}
    337425
    338 
     426/** Create connection.
     427 *
     428 * Handle client request to create connection (with parameters unmarshalled).
     429 *
     430 * @param client   TCP client
     431 * @param epp      Endpoint pair
     432 * @param rconn_id Place to store ID of new connection
     433 *
     434 * @return EOK on success or negative error code
     435 */
    339436static int tcp_conn_create_impl(tcp_client_t *client, inet_ep2_t *epp,
    340437    sysarg_t *rconn_id)
     
    376473}
    377474
     475/** Destroy connection.
     476 *
     477 * Handle client request to destroy connection (with parameters unmarshalled).
     478 *
     479 * @param client  TCP client
     480 * @param conn_id Connection ID
     481 * @return EOK on success, ENOENT if no such connection is found
     482 */
    378483static int tcp_conn_destroy_impl(tcp_client_t *client, sysarg_t conn_id)
    379484{
     
    393498}
    394499
     500/** Create listener.
     501 *
     502 * Handle client request to create listener (with parameters unmarshalled).
     503 *
     504 * @param client  TCP client
     505 * @param ep      Endpoint
     506 * @param rlst_id Place to store ID of new listener
     507 *
     508 * @return EOK on success or negative error code
     509*/
    395510static int tcp_listener_create_impl(tcp_client_t *client, inet_ep_t *ep,
    396511    sysarg_t *rlst_id)
     
    430545}
    431546
     547/** Destroy listener.
     548 *
     549 * Handle client request to destroy listener (with parameters unmarshalled).
     550 *
     551 * @param client TCP client
     552 * @param lst_id Listener ID
     553 *
     554 * @return EOK on success, ENOENT if no such listener is found
     555 */
    432556static int tcp_listener_destroy_impl(tcp_client_t *client, sysarg_t lst_id)
    433557{
     
    446570}
    447571
     572/** Send FIN.
     573 *
     574 * Handle client request to send FIN (with parameters unmarshalled).
     575 *
     576 * @param client  TCP client
     577 * @param conn_id Connection ID
     578 *
     579 * @return EOK on success or negative error code
     580 */
    448581static int tcp_conn_send_fin_impl(tcp_client_t *client, sysarg_t conn_id)
    449582{
     
    462595}
    463596
     597/** Push connection.
     598 *
     599 * Handle client request to push connection (with parameters unmarshalled).
     600 *
     601 * @param client  TCP client
     602 * @param conn_id Connection ID
     603 *
     604 * @return EOK on success or negative error code
     605 */
    464606static int tcp_conn_push_impl(tcp_client_t *client, sysarg_t conn_id)
    465607{
     
    478620}
    479621
     622/** Reset connection.
     623 *
     624 * Handle client request to reset connection (with parameters unmarshalled).
     625 *
     626 * @param client  TCP client
     627 * @param conn_id Connection ID
     628 *
     629 * @return EOK on success or negative error code
     630 */
    480631static int tcp_conn_reset_impl(tcp_client_t *client, sysarg_t conn_id)
    481632{
     
    493644}
    494645
     646/** Send data over connection..
     647 *
     648 * Handle client request to send data (with parameters unmarshalled).
     649 *
     650 * @param client  TCP client
     651 * @param conn_id Connection ID
     652 * @param data    Data buffer
     653 * @param size    Data size in bytes
     654 *
     655 * @return EOK on success or negative error code
     656 */
    495657static int tcp_conn_send_impl(tcp_client_t *client, sysarg_t conn_id,
    496658    void *data, size_t size)
     
    510672}
    511673
     674/** Receive data from connection.
     675 *
     676 * Handle client request to receive data (with parameters unmarshalled).
     677 *
     678 * @param client  TCP client
     679 * @param conn_id Connection ID
     680 * @param data    Data buffer
     681 * @param size    Buffer size in bytes
     682 * @param nrecv   Place to store actual number of bytes received
     683 *
     684 * @return EOK on success or negative error code
     685 */
    512686static int tcp_conn_recv_impl(tcp_client_t *client, sysarg_t conn_id,
    513687    void *data, size_t size, size_t *nrecv)
     
    540714}
    541715
     716/** Create client callback session.
     717 *
     718 * Handle client request to create callback session.
     719 *
     720 * @param client  TCP client
     721 * @param iid     Async request ID
     722 * @param icall   Async request data
     723 */
    542724static void tcp_callback_create_srv(tcp_client_t *client, ipc_callid_t iid,
    543725    ipc_call_t *icall)
     
    555737}
    556738
     739/** Create connection.
     740 *
     741 * Handle client request to create connection.
     742 *
     743 * @param client   TCP client
     744 * @param iid      Async request ID
     745 * @param icall    Async request data
     746 */
    557747static void tcp_conn_create_srv(tcp_client_t *client, ipc_callid_t iid,
    558748    ipc_call_t *icall)
     
    594784}
    595785
     786/** Destroy connection.
     787 *
     788 * Handle client request to destroy connection.
     789 *
     790 * @param client   TCP client
     791 * @param iid      Async request ID
     792 * @param icall    Async request data
     793 */
    596794static void tcp_conn_destroy_srv(tcp_client_t *client, ipc_callid_t iid,
    597795    ipc_call_t *icall)
     
    607805}
    608806
     807/** Create listener.
     808 *
     809 * Handle client request to create listener.
     810 *
     811 * @param client   TCP client
     812 * @param iid      Async request ID
     813 * @param icall    Async request data
     814 */
    609815static void tcp_listener_create_srv(tcp_client_t *client, ipc_callid_t iid,
    610816    ipc_call_t *icall)
     
    646852}
    647853
     854/** Destroy listener.
     855 *
     856 * Handle client request to destroy listener.
     857 *
     858 * @param client   TCP client
     859 * @param iid      Async request ID
     860 * @param icall    Async request data
     861 */
    648862static void tcp_listener_destroy_srv(tcp_client_t *client, ipc_callid_t iid,
    649863    ipc_call_t *icall)
     
    659873}
    660874
     875/** Send FIN.
     876 *
     877 * Handle client request to send FIN.
     878 *
     879 * @param client   TCP client
     880 * @param iid      Async request ID
     881 * @param icall    Async request data
     882 */
    661883static void tcp_conn_send_fin_srv(tcp_client_t *client, ipc_callid_t iid,
    662884    ipc_call_t *icall)
     
    672894}
    673895
     896/** Push connection.
     897 *
     898 * Handle client request to push connection.
     899 *
     900 * @param client   TCP client
     901 * @param iid      Async request ID
     902 * @param icall    Async request data
     903 */
    674904static void tcp_conn_push_srv(tcp_client_t *client, ipc_callid_t iid,
    675905    ipc_call_t *icall)
     
    685915}
    686916
     917/** Reset connection.
     918 *
     919 * Handle client request to reset connection.
     920 *
     921 * @param client   TCP client
     922 * @param iid      Async request ID
     923 * @param icall    Async request data
     924 */
    687925static void tcp_conn_reset_srv(tcp_client_t *client, ipc_callid_t iid,
    688926    ipc_call_t *icall)
     
    698936}
    699937
     938/** Send data via connection..
     939 *
     940 * Handle client request to send data via connection.
     941 *
     942 * @param client   TCP client
     943 * @param iid      Async request ID
     944 * @param icall    Async request data
     945 */
    700946static void tcp_conn_send_srv(tcp_client_t *client, ipc_callid_t iid,
    701947    ipc_call_t *icall)
     
    750996}
    751997
     998/** Read received data from connection without blocking.
     999 *
     1000 * Handle client request to read received data via connection without blocking.
     1001 *
     1002 * @param client   TCP client
     1003 * @param iid      Async request ID
     1004 * @param icall    Async request data
     1005 */
    7521006static void tcp_conn_recv_srv(tcp_client_t *client, ipc_callid_t iid,
    7531007    ipc_call_t *icall)
     
    7981052}
    7991053
     1054/** Read received data from connection with blocking.
     1055 *
     1056 * Handle client request to read received data via connection with blocking.
     1057 *
     1058 * @param client   TCP client
     1059 * @param iid      Async request ID
     1060 * @param icall    Async request data
     1061 */
    8001062static void tcp_conn_recv_wait_srv(tcp_client_t *client, ipc_callid_t iid,
    8011063    ipc_call_t *icall)
     
    8511113}
    8521114
    853 #include <mem.h>
    854 
     1115/** Initialize TCP client structure.
     1116 *
     1117 * @param client TCP client
     1118 */
    8551119static void tcp_client_init(tcp_client_t *client)
    8561120{
     
    8611125}
    8621126
     1127/** Finalize TCP client structure.
     1128 *
     1129 * @param client TCP client
     1130 */
    8631131static void tcp_client_fini(tcp_client_t *client)
    8641132{
     
    8911159}
    8921160
     1161/** Handle TCP client connection.
     1162 *
     1163 * @param iid   Connect call ID
     1164 * @param icall Connect call data
     1165 * @param arg   Connection argument
     1166 */
    8931167static void tcp_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    8941168{
     
    9611235}
    9621236
     1237/** Initialize TCP service.
     1238 *
     1239 * @return EOK on success or negative error code.
     1240 */
    9631241int tcp_service_init(void)
    9641242{
  • uspace/srv/net/tcp/tcp_type.h

    r6accc5cf rb10460a  
    4747struct tcp_conn;
    4848
     49/** Connection state */
    4950typedef enum {
    5051        /** Listen */
     
    101102} tcp_error_t;
    102103
     104/** Transfer flags */
    103105typedef enum {
    104106        XF_PUSH         = 0x1,
     
    106108} xflags_t;
    107109
     110/** Control message bits
     111 *
     112 * Note this is not the actual on-the-wire encoding
     113 */
    108114typedef enum {
    109115        CTL_SYN         = 0x1,
     
    128134} tcp_tqueue_t;
    129135
     136/** Active or passive connection */
    130137typedef enum {
    131138        ap_active,
     
    133140} acpass_t;
    134141
     142/** Flags for TCP open operation */
    135143typedef enum {
    136144        tcp_open_nonblock = 1
     
    264272} tcp_segment_t;
    265273
    266 
     274/** Receive queue entry */
    267275typedef struct {
    268276        link_t link;
     
    279287} tcp_squeue_entry_t;
    280288
     289/** Incoming queue entry */
    281290typedef struct {
    282291        link_t link;
     
    291300} tcp_tqueue_entry_t;
    292301
     302/** Continuation of processing.
     303 *
     304 * When processing incoming segment, are we done or should we continue
     305 * processing it?
     306 */
    293307typedef enum {
    294308        cp_continue,
  • uspace/srv/net/udp/service.c

    r6accc5cf rb10460a  
    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{
     
    551695}
    552696
     697/** Initialize UDP service.
     698 *
     699 * @return EOK on success or negative error code.
     700 */
    553701int udp_service_init(void)
    554702{
  • uspace/srv/net/udp/udp_type.h

    r6accc5cf rb10460a  
    4646#define UDP_FRAGMENT_SIZE 65535
    4747
     48/** UDP error codes */
    4849typedef enum {
    4950        UDP_EOK,
     
    8485} udp_pdu_t;
    8586
     87/** Association callbacks */
    8688typedef struct {
     89        /** Message received */
    8790        void (*recv_msg)(void *, inet_ep2_t *, udp_msg_t *);
    8891} udp_assoc_cb_t;
     
    124127} udp_assoc_status_t;
    125128
     129/** UDP receive queue entry */
    126130typedef struct {
    127131        /** Link to receive queue */
     
    133137} udp_rcv_queue_entry_t;
    134138
     139/** UDP client association.
     140 *
     141 * Ties a UDP association into the namespace of a client
     142 */
    135143typedef struct udp_cassoc {
    136144        /** Association */
     
    143151} udp_cassoc_t;
    144152
     153/** UDP client receive queue entry */
    145154typedef struct {
    146155        /** Link to receive queue */
     
    154163} udp_crcv_queue_entry_t;
    155164
     165/** UDP client */
    156166typedef struct udp_client {
    157167        /** Client callback session */
Note: See TracChangeset for help on using the changeset viewer.