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/net.c

    r11971 r12094  
    250250}
    251251
     252tr_bool
     253tr_ssToAddr( tr_address * setme_addr,     
     254             tr_port    * setme_port,     
     255             const struct sockaddr_storage * from )
     256{
     257    if( from->ss_family == AF_INET )
     258    {
     259        struct sockaddr_in * sin = (struct sockaddr_in *)from;
     260        setme_addr->type = TR_AF_INET;
     261        setme_addr->addr.addr4.s_addr = sin->sin_addr.s_addr;
     262        *setme_port = sin->sin_port;
     263        return TRUE;
     264    }
     265
     266    if( from->ss_family == AF_INET6 )
     267    {
     268        struct sockaddr_in6 *sin6 = (struct sockaddr_in6*) from;
     269        setme_addr->type = TR_AF_INET6;
     270        setme_addr->addr.addr6 = sin6->sin6_addr;
     271        *setme_port = sin6->sin6_port;
     272        return TRUE;
     273    }
     274
     275    return FALSE;
     276}
     277
    252278static socklen_t
    253279setup_sockaddr( const tr_address        * addr,
Note: See TracChangeset for help on using the changeset viewer.