Ignore:
Timestamp:
Mar 4, 2011, 9:00:52 PM (11 years ago)
Author:
jordan
Message:

(trunk libT) new function: tr_ssToAddr()

This handles converting the data in a sockaddr_storage to a tr_address + port, and removes redundant code from fdlimit.c and tr-udp.c that previously did this work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fdlimit.c

    r12076 r12094  
    679679    if( fd >= 0 )
    680680    {
    681         /* "The ss_family field of the sockaddr_storage structure will always
    682          * align with the family field of any protocol-specific structure." */
    683         if( sock.ss_family == AF_INET )
    684         {
    685             struct sockaddr_in *si;
    686             union { struct sockaddr_storage dummy; struct sockaddr_in si; } s;
    687             s.dummy = sock;
    688             si = &s.si;
    689             addr->type = TR_AF_INET;
    690             addr->addr.addr4.s_addr = si->sin_addr.s_addr;
    691             *port = si->sin_port;
    692         }
    693         else
    694         {
    695             struct sockaddr_in6 *si;
    696             union { struct sockaddr_storage dummy; struct sockaddr_in6 si; } s;
    697             s.dummy = sock;
    698             si = &s.si;
    699             addr->type = TR_AF_INET6;
    700             addr->addr.addr6 = si->sin6_addr;
    701             *port = si->sin6_port;
    702         }
     681        tr_ssToAddr( addr, port, &sock );
    703682        ++gFd->socket_count;
    704683    }
Note: See TracChangeset for help on using the changeset viewer.