Changeset 8d48c7e in mainline for uspace/srv/net/tcp/conn.c


Ignore:
Timestamp:
2015-06-02T16:00:42Z (9 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2c4bb828
Parents:
ab6326bc
Message:

Find the association to deliver the datagram using amap.

File:
1 edited

Legend:

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

    rab6326bc r8d48c7e  
    199199void tcp_conn_addref(tcp_conn_t *conn)
    200200{
    201         log_msg(LOG_DEFAULT, LVL_DEBUG2, "%s: tcp_conn_addref(%p)", conn->name, conn);
     201        log_msg(LOG_DEFAULT, LVL_DEBUG2, "%s: tcp_conn_addref(%p) before=%zu",
     202            conn->name, conn, atomic_get(&conn->refcnt));
    202203        atomic_inc(&conn->refcnt);
    203204}
     
    211212void tcp_conn_delref(tcp_conn_t *conn)
    212213{
    213         log_msg(LOG_DEFAULT, LVL_DEBUG2, "%s: tcp_conn_delref(%p)", conn->name, conn);
     214        log_msg(LOG_DEFAULT, LVL_DEBUG2, "%s: tcp_conn_delref(%p) before=%zu",
     215            conn->name, conn, atomic_get(&conn->refcnt));
    214216
    215217        if (atomic_predec(&conn->refcnt) == 0)
     
    269271        tcp_conn_addref(conn);
    270272        fibril_mutex_lock(&conn_list_lock);
     273
     274        log_msg(LOG_DEFAULT, LVL_NOTE, "tcp_conn_add: conn=%p", conn);
    271275
    272276        rc = amap_insert(amap, &conn->ident, conn, af_allow_system, &aepp);
     
    365369}
    366370
    367 /** Match endpoint with pattern. */
    368 static bool tcp_ep_match(inet_ep_t *ep, inet_ep_t *patt)
    369 {
    370         log_msg(LOG_DEFAULT, LVL_DEBUG2,
    371             "tcp_ep_match(ep=(%u), pat=(%u))", ep->port, patt->port);
    372 
    373         if ((!inet_addr_is_any(&patt->addr)) &&
    374             (!inet_addr_compare(&patt->addr, &ep->addr)))
    375                 return false;
    376 
    377         if ((patt->port != inet_port_any) &&
    378             (patt->port != ep->port))
    379                 return false;
    380 
    381         log_msg(LOG_DEFAULT, LVL_DEBUG2, " -> match");
    382 
    383         return true;
    384 }
    385 
    386 /** Match endpoint pair with pattern. */
    387 static bool tcp_ep2_match(inet_ep2_t *epp, inet_ep2_t *pattern)
    388 {
    389         log_msg(LOG_DEFAULT, LVL_DEBUG2, "tcp_ep2_match(%p, %p)", epp, pattern);
    390 
    391         if (!tcp_ep_match(&epp->local, &pattern->local))
    392                 return false;
    393 
    394         if (!tcp_ep_match(&epp->remote, &pattern->remote))
    395                 return false;
    396 
    397         return true;
    398 }
    399 
    400371/** Find connection structure for specified endpoint pair.
    401372 *
     
    409380tcp_conn_t *tcp_conn_find_ref(inet_ep2_t *epp)
    410381{
     382        int rc;
     383        void *arg;
     384        tcp_conn_t *conn;
     385
    411386        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_conn_find_ref(%p)", epp);
    412387
    413         log_msg(LOG_DEFAULT, LVL_DEBUG2, "compare conn (f:(%u), l:(%u))",
    414             epp->remote.port, epp->local.port);
    415 
    416388        fibril_mutex_lock(&conn_list_lock);
    417389
    418         list_foreach(conn_list, link, tcp_conn_t, conn) {
    419                 inet_ep2_t *cepp = &conn->ident;
    420 
    421                 log_msg(LOG_DEFAULT, LVL_DEBUG2, " - with (f:(%u), l:(%u))",
    422                     cepp->remote.port, cepp->local.port);
    423 
    424                 if (tcp_ep2_match(epp, cepp)) {
    425                         tcp_conn_addref(conn);
    426                         fibril_mutex_unlock(&conn_list_lock);
    427                         return conn;
    428                 }
    429         }
     390        rc = amap_find_match(amap, epp, &arg);
     391        if (rc != EOK) {
     392                assert(rc == ENOENT);
     393                fibril_mutex_unlock(&conn_list_lock);
     394                return NULL;
     395        }
     396
     397        conn = (tcp_conn_t *)arg;
     398        tcp_conn_addref(conn);
    430399
    431400        fibril_mutex_unlock(&conn_list_lock);
    432         return NULL;
     401        log_msg(LOG_DEFAULT, LVL_NOTE, "tcp_conn_find_ref: got conn=%p",
     402            conn);
     403        return conn;
    433404}
    434405
     
    12091180void tcp_conn_segment_arrived(tcp_conn_t *conn, tcp_segment_t *seg)
    12101181{
    1211         log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: tcp_conn_segment_arrived(%p)",
     1182        log_msg(LOG_DEFAULT, LVL_NOTE, "conn=%p", conn);
     1183        log_msg(LOG_DEFAULT, LVL_NOTE, "conn->name=%p", conn->name);
     1184        log_msg(LOG_DEFAULT, LVL_NOTE, "%s: tcp_conn_segment_arrived(%p)",
    12121185            conn->name, seg);
    12131186
Note: See TracChangeset for help on using the changeset viewer.