Changeset b7fd2a0 in mainline for uspace/lib/c/generic/inet/tcp.c
- Timestamp:
- 2018-01-13T03:10:29Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a53ed3a
- Parents:
- 36f0738
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/inet/tcp.c
r36f0738 rb7fd2a0 42 42 43 43 static void tcp_cb_conn(ipc_callid_t, ipc_call_t *, void *); 44 static int tcp_conn_fibril(void *);44 static errno_t tcp_conn_fibril(void *); 45 45 46 46 /** Incoming TCP connection info … … 61 61 * @return EOK on success or an error code 62 62 */ 63 static int tcp_callback_create(tcp_t *tcp)63 static errno_t tcp_callback_create(tcp_t *tcp) 64 64 { 65 65 async_exch_t *exch = async_exchange_begin(tcp->sess); … … 68 68 69 69 port_id_t port; 70 int rc = async_create_callback_port(exch, INTERFACE_TCP_CB, 0, 0,70 errno_t rc = async_create_callback_port(exch, INTERFACE_TCP_CB, 0, 0, 71 71 tcp_cb_conn, tcp, &port); 72 72 … … 76 76 return rc; 77 77 78 int retval;78 errno_t retval; 79 79 async_wait_for(req, &retval); 80 80 … … 88 88 * cannot be contacted 89 89 */ 90 int tcp_create(tcp_t **rtcp)90 errno_t tcp_create(tcp_t **rtcp) 91 91 { 92 92 tcp_t *tcp; 93 93 service_id_t tcp_svcid; 94 int rc;94 errno_t rc; 95 95 96 96 tcp = calloc(1, sizeof(tcp_t)); … … 161 161 * @return EOK on success, ENOMEM if out of memory 162 162 */ 163 static int tcp_conn_new(tcp_t *tcp, sysarg_t id, tcp_cb_t *cb, void *arg,163 static errno_t tcp_conn_new(tcp_t *tcp, sysarg_t id, tcp_cb_t *cb, void *arg, 164 164 tcp_conn_t **rconn) 165 165 { … … 207 207 * @return EOK on success or an error code. 208 208 */ 209 int tcp_conn_create(tcp_t *tcp, inet_ep2_t *epp, tcp_cb_t *cb, void *arg,209 errno_t tcp_conn_create(tcp_t *tcp, inet_ep2_t *epp, tcp_cb_t *cb, void *arg, 210 210 tcp_conn_t **rconn) 211 211 { … … 216 216 exch = async_exchange_begin(tcp->sess); 217 217 aid_t req = async_send_0(exch, TCP_CONN_CREATE, &answer); 218 int rc = async_data_write_start(exch, (void *)epp,218 errno_t rc = async_data_write_start(exch, (void *)epp, 219 219 sizeof(inet_ep2_t)); 220 220 async_exchange_end(exch); 221 221 222 222 if (rc != EOK) { 223 int rc_orig;223 errno_t rc_orig; 224 224 async_wait_for(req, &rc_orig); 225 225 if (rc_orig != EOK) … … 240 240 return EOK; 241 241 error: 242 return ( int) rc;242 return (errno_t) rc; 243 243 } 244 244 … … 260 260 261 261 exch = async_exchange_begin(conn->tcp->sess); 262 int rc = async_req_1_0(exch, TCP_CONN_DESTROY, conn->id);262 errno_t rc = async_req_1_0(exch, TCP_CONN_DESTROY, conn->id); 263 263 async_exchange_end(exch); 264 264 … … 275 275 * @return EOK on success, EINVAL if no connection with the given ID exists 276 276 */ 277 static int tcp_conn_get(tcp_t *tcp, sysarg_t id, tcp_conn_t **rconn)277 static errno_t tcp_conn_get(tcp_t *tcp, sysarg_t id, tcp_conn_t **rconn) 278 278 { 279 279 list_foreach(tcp->conn, ltcp, tcp_conn_t, conn) { … … 318 318 * @return EOK on success or an error code 319 319 */ 320 int tcp_listener_create(tcp_t *tcp, inet_ep_t *ep, tcp_listen_cb_t *lcb,320 errno_t tcp_listener_create(tcp_t *tcp, inet_ep_t *ep, tcp_listen_cb_t *lcb, 321 321 void *larg, tcp_cb_t *cb, void *arg, tcp_listener_t **rlst) 322 322 { … … 331 331 exch = async_exchange_begin(tcp->sess); 332 332 aid_t req = async_send_0(exch, TCP_LISTENER_CREATE, &answer); 333 int rc = async_data_write_start(exch, (void *)ep,333 errno_t rc = async_data_write_start(exch, (void *)ep, 334 334 sizeof(inet_ep_t)); 335 335 async_exchange_end(exch); 336 336 337 337 if (rc != EOK) { 338 int rc_orig;338 errno_t rc_orig; 339 339 async_wait_for(req, &rc_orig); 340 340 if (rc_orig != EOK) … … 360 360 error: 361 361 free(lst); 362 return ( int) rc;362 return (errno_t) rc; 363 363 } 364 364 … … 377 377 378 378 exch = async_exchange_begin(lst->tcp->sess); 379 int rc = async_req_1_0(exch, TCP_LISTENER_DESTROY, lst->id);379 errno_t rc = async_req_1_0(exch, TCP_LISTENER_DESTROY, lst->id); 380 380 async_exchange_end(exch); 381 381 … … 392 392 * @return EOK on success, EINVAL if no listener with the given ID is found 393 393 */ 394 static int tcp_listener_get(tcp_t *tcp, sysarg_t id, tcp_listener_t **rlst)394 static errno_t tcp_listener_get(tcp_t *tcp, sysarg_t id, tcp_listener_t **rlst) 395 395 { 396 396 list_foreach(tcp->listener, ltcp, tcp_listener_t, lst) { … … 424 424 * @return EOK if connection is established, EIO otherwise 425 425 */ 426 int tcp_conn_wait_connected(tcp_conn_t *conn)426 errno_t tcp_conn_wait_connected(tcp_conn_t *conn) 427 427 { 428 428 fibril_mutex_lock(&conn->lock); … … 448 448 * @return EOK on success or an error code 449 449 */ 450 int tcp_conn_send(tcp_conn_t *conn, const void *data, size_t bytes)451 { 452 async_exch_t *exch; 453 int rc;450 errno_t tcp_conn_send(tcp_conn_t *conn, const void *data, size_t bytes) 451 { 452 async_exch_t *exch; 453 errno_t rc; 454 454 455 455 exch = async_exchange_begin(conn->tcp->sess); … … 480 480 * @return EOK on success or an error code 481 481 */ 482 int tcp_conn_send_fin(tcp_conn_t *conn)482 errno_t tcp_conn_send_fin(tcp_conn_t *conn) 483 483 { 484 484 async_exch_t *exch; 485 485 486 486 exch = async_exchange_begin(conn->tcp->sess); 487 int rc = async_req_1_0(exch, TCP_CONN_SEND_FIN, conn->id);487 errno_t rc = async_req_1_0(exch, TCP_CONN_SEND_FIN, conn->id); 488 488 async_exchange_end(exch); 489 489 … … 496 496 * @return EOK on success or an error code 497 497 */ 498 int tcp_conn_push(tcp_conn_t *conn)498 errno_t tcp_conn_push(tcp_conn_t *conn) 499 499 { 500 500 async_exch_t *exch; 501 501 502 502 exch = async_exchange_begin(conn->tcp->sess); 503 int rc = async_req_1_0(exch, TCP_CONN_PUSH, conn->id);503 errno_t rc = async_req_1_0(exch, TCP_CONN_PUSH, conn->id); 504 504 async_exchange_end(exch); 505 505 … … 512 512 * @return EOK on success or an error code 513 513 */ 514 int tcp_conn_reset(tcp_conn_t *conn)514 errno_t tcp_conn_reset(tcp_conn_t *conn) 515 515 { 516 516 async_exch_t *exch; 517 517 518 518 exch = async_exchange_begin(conn->tcp->sess); 519 int rc = async_req_1_0(exch, TCP_CONN_RESET, conn->id);519 errno_t rc = async_req_1_0(exch, TCP_CONN_RESET, conn->id); 520 520 async_exchange_end(exch); 521 521 … … 540 540 * error code in case of other error 541 541 */ 542 int tcp_conn_recv(tcp_conn_t *conn, void *buf, size_t bsize, size_t *nrecv)542 errno_t tcp_conn_recv(tcp_conn_t *conn, void *buf, size_t bsize, size_t *nrecv) 543 543 { 544 544 async_exch_t *exch; … … 553 553 exch = async_exchange_begin(conn->tcp->sess); 554 554 aid_t req = async_send_1(exch, TCP_CONN_RECV, conn->id, &answer); 555 int rc = async_data_read_start(exch, buf, bsize);555 errno_t rc = async_data_read_start(exch, buf, bsize); 556 556 async_exchange_end(exch); 557 557 … … 562 562 } 563 563 564 int retval;564 errno_t retval; 565 565 async_wait_for(req, &retval); 566 566 if (retval != EOK) { … … 588 588 * @return EOK on success or an error code 589 589 */ 590 int tcp_conn_recv_wait(tcp_conn_t *conn, void *buf, size_t bsize,590 errno_t tcp_conn_recv_wait(tcp_conn_t *conn, void *buf, size_t bsize, 591 591 size_t *nrecv) 592 592 { … … 602 602 exch = async_exchange_begin(conn->tcp->sess); 603 603 aid_t req = async_send_1(exch, TCP_CONN_RECV_WAIT, conn->id, &answer); 604 int rc = async_data_read_start(exch, buf, bsize);604 errno_t rc = async_data_read_start(exch, buf, bsize); 605 605 async_exchange_end(exch); 606 606 … … 616 616 } 617 617 618 int retval;618 errno_t retval; 619 619 async_wait_for(req, &retval); 620 620 if (retval != EOK) { … … 641 641 tcp_conn_t *conn; 642 642 sysarg_t conn_id; 643 int rc;643 errno_t rc; 644 644 645 645 conn_id = IPC_GET_ARG1(*icall); … … 669 669 tcp_conn_t *conn; 670 670 sysarg_t conn_id; 671 int rc;671 errno_t rc; 672 672 673 673 conn_id = IPC_GET_ARG1(*icall); … … 697 697 tcp_conn_t *conn; 698 698 sysarg_t conn_id; 699 int rc;699 errno_t rc; 700 700 701 701 conn_id = IPC_GET_ARG1(*icall); … … 725 725 tcp_conn_t *conn; 726 726 sysarg_t conn_id; 727 int rc;727 errno_t rc; 728 728 729 729 conn_id = IPC_GET_ARG1(*icall); … … 769 769 fid_t fid; 770 770 tcp_in_conn_t *cinfo; 771 int rc;771 errno_t rc; 772 772 773 773 lst_id = IPC_GET_ARG1(*icall); … … 863 863 * @param arg Argument, incoming connection information (@c tcp_in_conn_t) 864 864 */ 865 static int tcp_conn_fibril(void *arg)865 static errno_t tcp_conn_fibril(void *arg) 866 866 { 867 867 tcp_in_conn_t *cinfo = (tcp_in_conn_t *)arg;
Note:
See TracChangeset
for help on using the changeset viewer.