Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 3aa2642a in mainline


Ignore:
Timestamp:
2011-12-04T12:46:44Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
bf600510
Parents:
704586fb
Message:

Allow accepting connection from arbitray foreign address, port.

Location:
uspace/srv/net/tl/tcp
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tl/tcp/conn.c

    r704586fb r3aa2642a  
    212212 * is equal.
    213213 */
    214 static bool tcp_socket_equal(tcp_sock_t *a, tcp_sock_t *b)
    215 {
    216         log_msg(LVL_DEBUG, "tcp_socket_equal((%x,%u), (%x,%u))",
    217             a->addr.ipv4, a->port, b->addr.ipv4, b->port);
    218 
    219         if (a->addr.ipv4 != b->addr.ipv4)
     214static bool tcp_socket_match(tcp_sock_t *sock, tcp_sock_t *patt)
     215{
     216        log_msg(LVL_DEBUG, "tcp_socket_match(sock=(%x,%u), pat=(%x,%u))",
     217            sock->addr.ipv4, sock->port, patt->addr.ipv4, patt->port);
     218
     219        if (patt->addr.ipv4 != TCP_IPV4_ANY &&
     220            patt->addr.ipv4 != sock->addr.ipv4)
    220221                return false;
    221222
    222         if (a->port != b->port)
     223        if (patt->port != TCP_PORT_ANY &&
     224            patt->port != sock->port)
    223225                return false;
    224226
     
    233235        log_msg(LVL_DEBUG, "tcp_sockpair_match(%p, %p)", sp, pattern);
    234236
    235         if (!tcp_socket_equal(&sp->local, &pattern->local))
     237        if (!tcp_socket_match(&sp->local, &pattern->local))
    236238                return false;
    237239
    238         if (!tcp_socket_equal(&sp->foreign, &pattern->foreign))
     240        if (!tcp_socket_match(&sp->foreign, &pattern->foreign))
    239241                return false;
    240242
  • uspace/srv/net/tl/tcp/sock.c

    r704586fb r3aa2642a  
    305305        log_msg(LVL_DEBUG, " - open connection");
    306306
    307         fsocket.addr.ipv4 = 0x7f000001; /* XXX */
    308         fsocket.port = 1025; /* XXX */
     307        fsocket.addr.ipv4 = TCP_IPV4_ANY;
     308        fsocket.port = TCP_PORT_ANY;
    309309
    310310        trc = tcp_uc_open(sock_core->port, &fsocket, ap_passive, &conn);
  • uspace/srv/net/tl/tcp/tcp_type.h

    r704586fb r3aa2642a  
    119119} tcp_sock_t;
    120120
     121enum netaddr {
     122        TCP_IPV4_ANY = 0
     123};
     124
     125enum tcp_port {
     126        TCP_PORT_ANY = 0
     127};
     128
    121129typedef struct {
    122130        tcp_sock_t local;
  • uspace/srv/net/tl/tcp/ucall.c

    r704586fb r3aa2642a  
    242242        conn = tcp_conn_find(sp);
    243243        if (conn != NULL && conn->cstate != st_closed) {
     244                if (conn->ident.foreign.addr.ipv4 == TCP_IPV4_ANY)
     245                        conn->ident.foreign.addr.ipv4 = sp->foreign.addr.ipv4;
     246                if (conn->ident.foreign.port == TCP_PORT_ANY)
     247                        conn->ident.foreign.port = sp->foreign.port;
     248
    244249                tcp_conn_segment_arrived(conn, seg);
    245250        } else {
Note: See TracChangeset for help on using the changeset viewer.