Changeset 7719958 in mainline for uspace/srv/net/tcp/sock.c


Ignore:
Timestamp:
2012-04-23T22:51:36Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
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.
Message:

merge mainline changes

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tcp/sock.c

    r3293a94 r7719958  
    3838#include <async.h>
    3939#include <errno.h>
     40#include <inet/inet.h>
    4041#include <io/log.h>
    41 #include <ip_client.h>
     42#include <ipc/services.h>
    4243#include <ipc/socket.h>
    4344#include <net/modules.h>
    4445#include <net/socket.h>
     46#include <ns.h>
    4547
    4648#include "sock.h"
     
    6365static socket_ports_t gsock;
    6466
     67static void tcp_sock_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg);
    6568static void tcp_sock_cstate_cb(tcp_conn_t *conn, void *arg);
    6669
    67 void tcp_sock_init(void)
    68 {
     70int tcp_sock_init(void)
     71{
     72        int rc;
     73
    6974        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;
    7083}
    7184
     
    7689        socket = (tcp_sockdata_t *)sock_core->specific_data;
    7790        (void)socket;
     91
     92        /* XXX We need to initiate connection cleanup here */
    7893}
    7994
     
    273288        tcp_sock_t lsocket;
    274289        tcp_sock_t fsocket;
    275         nic_device_id_t dev_id;
    276         tcp_phdr_t *phdr;
    277         size_t phdr_len;
    278290
    279291        log_msg(LVL_DEBUG, "tcp_sock_connect()");
     
    309321
    310322        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);
    315328                if (rc != EOK) {
    316329                        fibril_mutex_unlock(&socket->lock);
    317330                        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;
    323337                log_msg(LVL_DEBUG, "Local IP address is %x", socket->laddr.ipv4);
    324                 free(phdr);
    325338        }
    326339
     
    713726        }
    714727
    715         rc = socket_destroy(net_sess, socket_id, &client->sockets, &gsock,
     728        rc = socket_destroy(NULL, socket_id, &client->sockets, &gsock,
    716729            tcp_free_sock_data);
    717730        if (rc != EOK) {
     
    764777}
    765778
    766 int tcp_sock_connection(async_sess_t *sess, ipc_callid_t iid, ipc_call_t icall)
     779static void tcp_sock_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    767780{
    768781        ipc_callid_t callid;
     
    773786        async_answer_0(iid, EOK);
    774787
    775         client.sess = sess;
     788        client.sess = async_callback_receive(EXCHANGE_SERIALIZE);
    776789        socket_cores_initialize(&client.sockets);
    777790
     
    825838        }
    826839
    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);
    828844}
    829845
Note: See TracChangeset for help on using the changeset viewer.