Changes in uspace/srv/net/tcp/service.c [4f29118:1f2b07a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tcp/service.c
r4f29118 r1f2b07a 27 27 */ 28 28 29 /** @addtogroup tcp29 /** @addtogroup udp 30 30 * @{ 31 31 */ … … 44 44 #include <loc.h> 45 45 #include <macros.h> 46 #include <mem.h>47 46 #include <stdlib.h> 48 47 … … 54 53 #define NAME "tcp" 55 54 56 /** Maximum amount of data transferred in one send call */57 55 #define MAX_MSG_SIZE DATA_XFER_LIMIT 58 56 … … 69 67 static int tcp_cconn_create(tcp_client_t *, tcp_conn_t *, tcp_cconn_t **); 70 68 71 /** Connection callbacks to tie us to lower layer */72 69 static tcp_cb_t tcp_service_cb = { 73 70 .cstate_change = tcp_service_cstate_change, … … 75 72 }; 76 73 77 /** Sentinel connection callbacks to tie us to lower layer */78 74 static tcp_cb_t tcp_service_lst_cb = { 79 75 .cstate_change = tcp_service_lst_cstate_change, … … 81 77 }; 82 78 83 /** Connection state has changed.84 *85 * @param conn Connection86 * @param arg Argument (not used)87 * @param old_state Previous connection state88 */89 79 static void tcp_service_cstate_change(tcp_conn_t *conn, void *arg, 90 80 tcp_cstate_t old_state) … … 118 108 } 119 109 120 /** Sentinel connection state has changed.121 *122 * @param conn Connection123 * @param arg Argument (not used)124 * @param old_state Previous connection state125 */126 110 static void tcp_service_lst_cstate_change(tcp_conn_t *conn, void *arg, 127 111 tcp_cstate_t old_state) … … 185 169 } 186 170 187 /** Received data became available on connection.188 *189 * @param conn Connection190 * @param arg Client connection191 */192 171 static void tcp_service_recv_data(tcp_conn_t *conn, void *arg) 193 172 { … … 197 176 } 198 177 199 /** Send 'data' event to client.200 *201 * @param cconn Client connection202 */203 178 static void tcp_ev_data(tcp_cconn_t *cconn) 204 179 { … … 217 192 } 218 193 219 /** Send 'connected' event to client.220 *221 * @param cconn Client connection222 */223 194 static void tcp_ev_connected(tcp_cconn_t *cconn) 224 195 { … … 234 205 } 235 206 236 /** Send 'conn_failed' event to client.237 *238 * @param cconn Client connection239 */240 207 static void tcp_ev_conn_failed(tcp_cconn_t *cconn) 241 208 { … … 251 218 } 252 219 253 /** Send 'conn_reset' event to client.254 *255 * @param cconn Client connection256 */257 220 static void tcp_ev_conn_reset(tcp_cconn_t *cconn) 258 221 { … … 268 231 } 269 232 270 /** Send 'new_conn' event to client. 271 * 272 * @param clst Client listener that received the connection 273 * @param cconn New client connection 274 */ 233 /** New incoming connection */ 275 234 static void tcp_ev_new_conn(tcp_clst_t *clst, tcp_cconn_t *cconn) 276 235 { … … 287 246 } 288 247 289 /** Create client connection.290 *291 * This effectively adds a connection into a client's namespace.292 *293 * @param client TCP client294 * @param conn Connection295 * @param rcconn Place to store pointer to new client connection296 *297 * @return EOK on success or ENOMEM if out of memory298 */299 248 static int tcp_cconn_create(tcp_client_t *client, tcp_conn_t *conn, 300 249 tcp_cconn_t **rcconn) … … 323 272 } 324 273 325 /** Destroy client connection.326 *327 * @param cconn Client connection328 */329 274 static void tcp_cconn_destroy(tcp_cconn_t *cconn) 330 275 { … … 333 278 } 334 279 335 /** Create client listener.336 *337 * Create client listener based on sentinel connection.338 * XXX Implement actual listener in protocol core339 *340 * @param client TCP client341 * @param conn Sentinel connection342 * @param rclst Place to store pointer to new client listener343 *344 * @return EOK on success or ENOMEM if out of memory345 */346 280 static int tcp_clistener_create(tcp_client_t *client, tcp_conn_t *conn, 347 281 tcp_clst_t **rclst) … … 370 304 } 371 305 372 /** Destroy client listener.373 *374 * @param clst Client listener375 */376 306 static void tcp_clistener_destroy(tcp_clst_t *clst) 377 307 { … … 380 310 } 381 311 382 /** Get client connection by ID.383 *384 * @param client Client385 * @param id Client connection ID386 * @param rcconn Place to store pointer to client connection387 *388 * @return EOK on success, ENOENT if no client connection with the given ID389 * is found.390 */391 312 static int tcp_cconn_get(tcp_client_t *client, sysarg_t id, 392 313 tcp_cconn_t **rcconn) … … 402 323 } 403 324 404 /** Get client listener by ID.405 *406 * @param client Client407 * @param id Client connection ID408 * @param rclst Place to store pointer to client listener409 *410 * @return EOK on success, ENOENT if no client listener with the given ID411 * is found.412 */413 325 static int tcp_clistener_get(tcp_client_t *client, sysarg_t id, 414 326 tcp_clst_t **rclst) … … 424 336 } 425 337 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 */ 338 436 339 static int tcp_conn_create_impl(tcp_client_t *client, inet_ep2_t *epp, 437 340 sysarg_t *rconn_id) … … 473 376 } 474 377 475 /** Destroy connection.476 *477 * Handle client request to destroy connection (with parameters unmarshalled).478 *479 * @param client TCP client480 * @param conn_id Connection ID481 * @return EOK on success, ENOENT if no such connection is found482 */483 378 static int tcp_conn_destroy_impl(tcp_client_t *client, sysarg_t conn_id) 484 379 { … … 498 393 } 499 394 500 /** Create listener.501 *502 * Handle client request to create listener (with parameters unmarshalled).503 *504 * @param client TCP client505 * @param ep Endpoint506 * @param rlst_id Place to store ID of new listener507 *508 * @return EOK on success or negative error code509 */510 395 static int tcp_listener_create_impl(tcp_client_t *client, inet_ep_t *ep, 511 396 sysarg_t *rlst_id) … … 545 430 } 546 431 547 /** Destroy listener.548 *549 * Handle client request to destroy listener (with parameters unmarshalled).550 *551 * @param client TCP client552 * @param lst_id Listener ID553 *554 * @return EOK on success, ENOENT if no such listener is found555 */556 432 static int tcp_listener_destroy_impl(tcp_client_t *client, sysarg_t lst_id) 557 433 { … … 570 446 } 571 447 572 /** Send FIN.573 *574 * Handle client request to send FIN (with parameters unmarshalled).575 *576 * @param client TCP client577 * @param conn_id Connection ID578 *579 * @return EOK on success or negative error code580 */581 448 static int tcp_conn_send_fin_impl(tcp_client_t *client, sysarg_t conn_id) 582 449 { … … 595 462 } 596 463 597 /** Push connection.598 *599 * Handle client request to push connection (with parameters unmarshalled).600 *601 * @param client TCP client602 * @param conn_id Connection ID603 *604 * @return EOK on success or negative error code605 */606 464 static int tcp_conn_push_impl(tcp_client_t *client, sysarg_t conn_id) 607 465 { … … 620 478 } 621 479 622 /** Reset connection.623 *624 * Handle client request to reset connection (with parameters unmarshalled).625 *626 * @param client TCP client627 * @param conn_id Connection ID628 *629 * @return EOK on success or negative error code630 */631 480 static int tcp_conn_reset_impl(tcp_client_t *client, sysarg_t conn_id) 632 481 { … … 644 493 } 645 494 646 /** Send data over connection..647 *648 * Handle client request to send data (with parameters unmarshalled).649 *650 * @param client TCP client651 * @param conn_id Connection ID652 * @param data Data buffer653 * @param size Data size in bytes654 *655 * @return EOK on success or negative error code656 */657 495 static int tcp_conn_send_impl(tcp_client_t *client, sysarg_t conn_id, 658 496 void *data, size_t size) … … 672 510 } 673 511 674 /** Receive data from connection.675 *676 * Handle client request to receive data (with parameters unmarshalled).677 *678 * @param client TCP client679 * @param conn_id Connection ID680 * @param data Data buffer681 * @param size Buffer size in bytes682 * @param nrecv Place to store actual number of bytes received683 *684 * @return EOK on success or negative error code685 */686 512 static int tcp_conn_recv_impl(tcp_client_t *client, sysarg_t conn_id, 687 513 void *data, size_t size, size_t *nrecv) … … 714 540 } 715 541 716 /** Create client callback session.717 *718 * Handle client request to create callback session.719 *720 * @param client TCP client721 * @param iid Async request ID722 * @param icall Async request data723 */724 542 static void tcp_callback_create_srv(tcp_client_t *client, ipc_callid_t iid, 725 543 ipc_call_t *icall) … … 737 555 } 738 556 739 /** Create connection.740 *741 * Handle client request to create connection.742 *743 * @param client TCP client744 * @param iid Async request ID745 * @param icall Async request data746 */747 557 static void tcp_conn_create_srv(tcp_client_t *client, ipc_callid_t iid, 748 558 ipc_call_t *icall) … … 784 594 } 785 595 786 /** Destroy connection.787 *788 * Handle client request to destroy connection.789 *790 * @param client TCP client791 * @param iid Async request ID792 * @param icall Async request data793 */794 596 static void tcp_conn_destroy_srv(tcp_client_t *client, ipc_callid_t iid, 795 597 ipc_call_t *icall) … … 805 607 } 806 608 807 /** Create listener.808 *809 * Handle client request to create listener.810 *811 * @param client TCP client812 * @param iid Async request ID813 * @param icall Async request data814 */815 609 static void tcp_listener_create_srv(tcp_client_t *client, ipc_callid_t iid, 816 610 ipc_call_t *icall) … … 852 646 } 853 647 854 /** Destroy listener.855 *856 * Handle client request to destroy listener.857 *858 * @param client TCP client859 * @param iid Async request ID860 * @param icall Async request data861 */862 648 static void tcp_listener_destroy_srv(tcp_client_t *client, ipc_callid_t iid, 863 649 ipc_call_t *icall) … … 873 659 } 874 660 875 /** Send FIN.876 *877 * Handle client request to send FIN.878 *879 * @param client TCP client880 * @param iid Async request ID881 * @param icall Async request data882 */883 661 static void tcp_conn_send_fin_srv(tcp_client_t *client, ipc_callid_t iid, 884 662 ipc_call_t *icall) … … 894 672 } 895 673 896 /** Push connection.897 *898 * Handle client request to push connection.899 *900 * @param client TCP client901 * @param iid Async request ID902 * @param icall Async request data903 */904 674 static void tcp_conn_push_srv(tcp_client_t *client, ipc_callid_t iid, 905 675 ipc_call_t *icall) … … 915 685 } 916 686 917 /** Reset connection.918 *919 * Handle client request to reset connection.920 *921 * @param client TCP client922 * @param iid Async request ID923 * @param icall Async request data924 */925 687 static void tcp_conn_reset_srv(tcp_client_t *client, ipc_callid_t iid, 926 688 ipc_call_t *icall) … … 936 698 } 937 699 938 /** Send data via connection..939 *940 * Handle client request to send data via connection.941 *942 * @param client TCP client943 * @param iid Async request ID944 * @param icall Async request data945 */946 700 static void tcp_conn_send_srv(tcp_client_t *client, ipc_callid_t iid, 947 701 ipc_call_t *icall) … … 973 727 async_answer_0(callid, ENOMEM); 974 728 async_answer_0(iid, ENOMEM); 975 return;976 729 } 977 730 … … 997 750 } 998 751 999 /** Read received data from connection without blocking.1000 *1001 * Handle client request to read received data via connection without blocking.1002 *1003 * @param client TCP client1004 * @param iid Async request ID1005 * @param icall Async request data1006 */1007 752 static void tcp_conn_recv_srv(tcp_client_t *client, ipc_callid_t iid, 1008 753 ipc_call_t *icall) … … 1053 798 } 1054 799 1055 /** Read received data from connection with blocking.1056 *1057 * Handle client request to read received data via connection with blocking.1058 *1059 * @param client TCP client1060 * @param iid Async request ID1061 * @param icall Async request data1062 */1063 800 static void tcp_conn_recv_wait_srv(tcp_client_t *client, ipc_callid_t iid, 1064 801 ipc_call_t *icall) … … 1114 851 } 1115 852 1116 /** Initialize TCP client structure. 1117 * 1118 * @param client TCP client 1119 */ 853 #include <mem.h> 854 1120 855 static void tcp_client_init(tcp_client_t *client) 1121 856 { … … 1126 861 } 1127 862 1128 /** Finalize TCP client structure.1129 *1130 * @param client TCP client1131 */1132 863 static void tcp_client_fini(tcp_client_t *client) 1133 864 { 1134 865 tcp_cconn_t *cconn; 1135 unsigned longn;866 size_t n; 1136 867 1137 868 n = list_count(&client->cconn); 1138 869 if (n != 0) { 1139 log_msg(LOG_DEFAULT, LVL_WARN, "Client with % lu active "870 log_msg(LOG_DEFAULT, LVL_WARN, "Client with %zu active " 1140 871 "connections closed session", n); 1141 872 … … 1151 882 n = list_count(&client->clst); 1152 883 if (n != 0) { 1153 log_msg(LOG_DEFAULT, LVL_WARN, "Client with % lu active "884 log_msg(LOG_DEFAULT, LVL_WARN, "Client with %zu active " 1154 885 "listeners closed session", n); 1155 886 /* XXX Destroy listeners */ … … 1160 891 } 1161 892 1162 /** Handle TCP client connection.1163 *1164 * @param iid Connect call ID1165 * @param icall Connect call data1166 * @param arg Connection argument1167 */1168 893 static void tcp_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg) 1169 894 { … … 1236 961 } 1237 962 1238 /** Initialize TCP service.1239 *1240 * @return EOK on success or negative error code.1241 */1242 963 int tcp_service_init(void) 1243 964 { … … 1245 966 service_id_t sid; 1246 967 1247 async_set_ fallback_port_handler(tcp_client_conn, NULL);968 async_set_client_connection(tcp_client_conn); 1248 969 1249 970 rc = loc_server_register(NAME);
Note:
See TracChangeset
for help on using the changeset viewer.