Changeset 11904


Ignore:
Timestamp:
Feb 18, 2011, 12:23:58 AM (11 years ago)
Author:
jch
Message:

Accept UTP connexions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/tr-utp.c

    r11902 r11904  
    3131#include "session.h"
    3232#include "crypto.h"
     33#include "peer-io.h"
     34#include "peer-mgr.h"
    3335#include "tr-utp.h"
    3436
     
    3638
    3739static void
    38 incoming(void *closure UNUSED, struct UTPSocket *s)
     40incoming(void *closure, struct UTPSocket *s)
    3941{
    40     UTP_Close(s);
     42    tr_session *ss = (tr_session*)closure;
     43    struct sockaddr_storage from_storage;
     44    struct sockaddr *from = (struct sockaddr*)&from_storage;
     45    socklen_t fromlen = sizeof(from_storage);
     46    tr_address addr;
     47    tr_port port;
     48   
     49    UTP_GetPeerName(s, from, &fromlen);
     50    if(from->sa_family == AF_INET) {
     51        struct sockaddr_in *sin = (struct sockaddr_in*)from;
     52        addr.type = TR_AF_INET;
     53        addr.addr.addr4.s_addr = sin->sin_addr.s_addr;
     54        port = sin->sin_port;
     55    } else if(from->sa_family == AF_INET6) {
     56        struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)from;
     57        addr.type = TR_AF_INET6;
     58        addr.addr.addr6 = sin6->sin6_addr;
     59        port = sin6->sin6_port;
     60    } else {
     61        tr_nerr("UTP", "Unknown socket family");
     62        UTP_Close(s);
     63        return;
     64    }
     65
     66    tr_peerMgrAddIncoming(ss->peerMgr, &addr, port, -1, s);
    4167}
    4268
Note: See TracChangeset for help on using the changeset viewer.