Changes in uspace/lib/c/generic/inet/udp.c [f9b2cb4c:1f2b07a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/inet/udp.c
rf9b2cb4c r1f2b07a 43 43 static void udp_cb_conn(ipc_callid_t, ipc_call_t *, void *); 44 44 45 /** Create callback connection from UDP service.46 *47 * @param udp UDP service48 * @return EOK on success or negative error code49 */50 45 static int udp_callback_create(udp_t *udp) 51 46 { … … 53 48 54 49 aid_t req = async_send_0(exch, UDP_CALLBACK_CREATE, NULL); 55 56 port_id_t port; 57 int rc = async_create_callback_port(exch, INTERFACE_UDP_CB, 0, 0, 58 udp_cb_conn, udp, &port); 59 50 int rc = async_connect_to_me(exch, 0, 0, 0, udp_cb_conn, udp); 60 51 async_exchange_end(exch); 61 52 … … 69 60 } 70 61 71 /** Create UDP client instance.72 *73 * @param rudp Place to store pointer to new UDP client74 * @return EOK on success, ENOMEM if out of memory, EIO if service75 * cannot be contacted76 */77 62 int udp_create(udp_t **rudp) 78 63 { … … 98 83 } 99 84 100 udp->sess = loc_service_connect( udp_svcid, INTERFACE_UDP,85 udp->sess = loc_service_connect(EXCHANGE_SERIALIZE, udp_svcid, 101 86 IPC_FLAG_BLOCKING); 102 87 if (udp->sess == NULL) { … … 118 103 } 119 104 120 /** Destroy UDP client instance.121 *122 * @param udp UDP client123 */124 105 void udp_destroy(udp_t *udp) 125 106 { … … 137 118 } 138 119 139 /** Create new UDP association. 140 * 141 * Create a UDP association that allows sending and receiving messages. 142 * 143 * @a epp may specify remote address and port, in which case only messages 144 * from that remote endpoint will be received. Also, that remote endpoint 145 * is used as default when @c NULL is passed as destination to 146 * udp_assoc_send_msg. 147 * 148 * @a epp may specify a local link or address. If it does not, the association 149 * will listen on all local links/addresses. If @a epp does not specify 150 * a local port number, a free dynamic port number will be allocated. 151 * 152 * The caller is informed about incoming data by invoking @a cb->recv_msg 153 * 154 * @param udp UDP client 155 * @param epp Internet endpoint pair 156 * @param cb Callbacks 157 * @param arg Argument to callbacks 158 * @param rassoc Place to store pointer to new association 159 * 160 * @return EOK on success or negative error code. 161 */ 162 int udp_assoc_create(udp_t *udp, inet_ep2_t *epp, udp_cb_t *cb, void *arg, 120 int udp_assoc_create(udp_t *udp, inet_ep2_t *ep2, udp_cb_t *cb, void *arg, 163 121 udp_assoc_t **rassoc) 164 122 { … … 173 131 exch = async_exchange_begin(udp->sess); 174 132 aid_t req = async_send_0(exch, UDP_ASSOC_CREATE, &answer); 175 sysarg_t rc = async_data_write_start(exch, (void *)ep p,133 sysarg_t rc = async_data_write_start(exch, (void *)ep2, 176 134 sizeof(inet_ep2_t)); 177 135 async_exchange_end(exch); … … 203 161 } 204 162 205 /** Destroy UDP association.206 *207 * Destroy UDP association. The caller should destroy all associations208 * he created before destroying the UDP client and before terminating.209 *210 * @param assoc UDP association211 */212 163 void udp_assoc_destroy(udp_assoc_t *assoc) 213 164 { … … 227 178 } 228 179 229 /** Send message via UDP association.230 *231 * @param assoc Association232 * @param dest Destination endpoint or @c NULL to use association's remote ep.233 * @param data Message data234 * @param bytes Message size in bytes235 *236 * @return EOK on success or negative error code237 */238 180 int udp_assoc_send_msg(udp_assoc_t *assoc, inet_ep_t *dest, void *data, 239 181 size_t bytes) … … 269 211 } 270 212 271 /** Get the user/callback argument for an association.272 *273 * @param assoc UDP association274 * @return User argument associated with association275 */276 213 void *udp_assoc_userptr(udp_assoc_t *assoc) 277 214 { … … 279 216 } 280 217 281 /** Get size of received message in bytes.282 *283 * Assuming jumbo messages can be received, the caller first needs to determine284 * the size of the received message by calling this function, then they can285 * read the message piece-wise using udp_rmsg_read().286 *287 * @param rmsg Received message288 * @return Size of received message in bytes289 */290 218 size_t udp_rmsg_size(udp_rmsg_t *rmsg) 291 219 { … … 293 221 } 294 222 295 /** Read part of received message.296 *297 * @param rmsg Received message298 * @param off Start offset299 * @param buf Buffer for storing data300 * @param bsize Buffer size301 *302 * @return EOK on success or negative error code.303 */304 223 int udp_rmsg_read(udp_rmsg_t *rmsg, size_t off, void *buf, size_t bsize) 305 224 { … … 326 245 } 327 246 328 /** Get remote endpoint of received message.329 *330 * Place the remote endpoint (the one from which the message was supposedly331 * sent) to @a ep.332 *333 * @param rmsg Received message334 * @param ep Place to store remote endpoint335 */336 247 void udp_rmsg_remote_ep(udp_rmsg_t *rmsg, inet_ep_t *ep) 337 248 { … … 339 250 } 340 251 341 /** Get type of received ICMP error message.342 *343 * @param rerr Received error message344 * @return Error message type345 */346 252 uint8_t udp_rerr_type(udp_rerr_t *rerr) 347 253 { … … 349 255 } 350 256 351 /** Get code of received ICMP error message.352 *353 * @param rerr Received error message354 * @return Error message code355 */356 257 uint8_t udp_rerr_code(udp_rerr_t *rerr) 357 258 { … … 359 260 } 360 261 361 /** Get information about the next received message from UDP service.362 *363 * @param udp UDP client364 * @param rmsg Place to store message information365 *366 * @return EOK on success or negative error code367 */368 262 static int udp_rmsg_info(udp_t *udp, udp_rmsg_t *rmsg) 369 263 { … … 394 288 } 395 289 396 /** Discard next received message in UDP service.397 *398 * @param udp UDP client399 * @return EOK on success or negative error code400 */401 290 static int udp_rmsg_discard(udp_t *udp) 402 291 { … … 410 299 } 411 300 412 /** Get association based on its ID.413 *414 * @param udp UDP client415 * @param id Association ID416 * @param rassoc Place to store pointer to association417 *418 * @return EOK on success, EINVAL if no association with the given ID exists419 */420 301 static int udp_assoc_get(udp_t *udp, sysarg_t id, udp_assoc_t **rassoc) 421 302 { … … 430 311 } 431 312 432 /** Handle 'data' event, i.e. some message(s) arrived.433 *434 * For each received message, get information about it, call @c recv_msg435 * callback and discard it.436 *437 * @param udp UDP client438 * @param iid IPC message ID439 * @param icall IPC message440 */441 313 static void udp_ev_data(udp_t *udp, ipc_callid_t iid, ipc_call_t *icall) 442 314 { … … 468 340 } 469 341 470 /** UDP service callback connection.471 *472 * @param iid Connect message ID473 * @param icall Connect message474 * @param arg Argument, UDP client475 */476 342 static void udp_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg) 477 343 {
Note:
See TracChangeset
for help on using the changeset viewer.