Changeset 7719958 in mainline for uspace/srv/net/tcp/sock.c
- Timestamp:
- 2012-04-23T22:51:36Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6a3808e
- Parents:
- 3293a94 (diff), 32fef47 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tcp/sock.c
r3293a94 r7719958 38 38 #include <async.h> 39 39 #include <errno.h> 40 #include <inet/inet.h> 40 41 #include <io/log.h> 41 #include <ip _client.h>42 #include <ipc/services.h> 42 43 #include <ipc/socket.h> 43 44 #include <net/modules.h> 44 45 #include <net/socket.h> 46 #include <ns.h> 45 47 46 48 #include "sock.h" … … 63 65 static socket_ports_t gsock; 64 66 67 static void tcp_sock_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg); 65 68 static void tcp_sock_cstate_cb(tcp_conn_t *conn, void *arg); 66 69 67 void tcp_sock_init(void) 68 { 70 int tcp_sock_init(void) 71 { 72 int rc; 73 69 74 socket_ports_initialize(&gsock); 75 76 async_set_client_connection(tcp_sock_connection); 77 78 rc = service_register(SERVICE_TCP); 79 if (rc != EOK) 80 return EEXIST; 81 82 return EOK; 70 83 } 71 84 … … 76 89 socket = (tcp_sockdata_t *)sock_core->specific_data; 77 90 (void)socket; 91 92 /* XXX We need to initiate connection cleanup here */ 78 93 } 79 94 … … 273 288 tcp_sock_t lsocket; 274 289 tcp_sock_t fsocket; 275 nic_device_id_t dev_id;276 tcp_phdr_t *phdr;277 size_t phdr_len;278 290 279 291 log_msg(LVL_DEBUG, "tcp_sock_connect()"); … … 309 321 310 322 if (socket->laddr.ipv4 == TCP_IPV4_ANY) { 311 /* Find route to determine local IP address. */ 312 rc = ip_get_route_req(ip_sess, IPPROTO_TCP, 313 (struct sockaddr *)addr, sizeof(*addr), &dev_id, 314 (void **)&phdr, &phdr_len); 323 /* Determine local IP address */ 324 inet_addr_t loc_addr, rem_addr; 325 326 rem_addr.ipv4 = uint32_t_be2host(addr->sin_addr.s_addr); 327 rc = inet_get_srcaddr(&rem_addr, 0, &loc_addr); 315 328 if (rc != EOK) { 316 329 fibril_mutex_unlock(&socket->lock); 317 330 async_answer_0(callid, rc); 318 log_msg(LVL_DEBUG, "tcp_transmit_connect: Failed to find route."); 319 return; 320 } 321 322 socket->laddr.ipv4 = uint32_t_be2host(phdr->src_addr); 331 log_msg(LVL_DEBUG, "tcp_sock_connect: Failed to " 332 "determine local address."); 333 return; 334 } 335 336 socket->laddr.ipv4 = loc_addr.ipv4; 323 337 log_msg(LVL_DEBUG, "Local IP address is %x", socket->laddr.ipv4); 324 free(phdr);325 338 } 326 339 … … 713 726 } 714 727 715 rc = socket_destroy( net_sess, socket_id, &client->sockets, &gsock,728 rc = socket_destroy(NULL, socket_id, &client->sockets, &gsock, 716 729 tcp_free_sock_data); 717 730 if (rc != EOK) { … … 764 777 } 765 778 766 int tcp_sock_connection(async_sess_t *sess, ipc_callid_t iid, ipc_call_t icall)779 static void tcp_sock_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 767 780 { 768 781 ipc_callid_t callid; … … 773 786 async_answer_0(iid, EOK); 774 787 775 client.sess = sess;788 client.sess = async_callback_receive(EXCHANGE_SERIALIZE); 776 789 socket_cores_initialize(&client.sockets); 777 790 … … 825 838 } 826 839 827 return EOK; 840 /* Clean up */ 841 log_msg(LVL_DEBUG, "tcp_sock_connection: Clean up"); 842 async_hangup(client.sess); 843 socket_cores_release(NULL, &client.sockets, &gsock, tcp_free_sock_data); 828 844 } 829 845
Note:
See TracChangeset
for help on using the changeset viewer.