Changeset b1213b0 in mainline for uspace/srv/net/tcp/sock.c
- Timestamp:
- 2012-04-17T07:13:35Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 96c0b7b
- Parents:
- d76a329 (diff), 06a1d077 (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
rd76a329 rb1213b0 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 … … 273 286 tcp_sock_t lsocket; 274 287 tcp_sock_t fsocket; 275 nic_device_id_t dev_id;276 tcp_phdr_t *phdr;277 size_t phdr_len;278 288 279 289 log_msg(LVL_DEBUG, "tcp_sock_connect()"); … … 309 319 310 320 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); 321 /* Determine local IP address */ 322 inet_addr_t loc_addr, rem_addr; 323 324 rem_addr.ipv4 = uint32_t_be2host(addr->sin_addr.s_addr); 325 rc = inet_get_srcaddr(&rem_addr, 0, &loc_addr); 315 326 if (rc != EOK) { 316 327 fibril_mutex_unlock(&socket->lock); 317 328 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); 329 log_msg(LVL_DEBUG, "tcp_sock_connect: Failed to " 330 "determine local address."); 331 return; 332 } 333 334 socket->laddr.ipv4 = loc_addr.ipv4; 323 335 log_msg(LVL_DEBUG, "Local IP address is %x", socket->laddr.ipv4); 324 free(phdr);325 336 } 326 337 … … 713 724 } 714 725 715 rc = socket_destroy( net_sess, socket_id, &client->sockets, &gsock,726 rc = socket_destroy(NULL, socket_id, &client->sockets, &gsock, 716 727 tcp_free_sock_data); 717 728 if (rc != EOK) { … … 764 775 } 765 776 766 int tcp_sock_connection(async_sess_t *sess, ipc_callid_t iid, ipc_call_t icall)777 static void tcp_sock_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 767 778 { 768 779 ipc_callid_t callid; … … 773 784 async_answer_0(iid, EOK); 774 785 775 client.sess = sess;786 client.sess = async_callback_receive(EXCHANGE_SERIALIZE); 776 787 socket_cores_initialize(&client.sockets); 777 788 … … 824 835 } 825 836 } 826 827 return EOK;828 837 } 829 838
Note:
See TracChangeset
for help on using the changeset viewer.