Ignore:
Timestamp:
Jan 17, 2009, 11:34:00 PM (12 years ago)
Author:
charles
Message:

(1.5x) copy r7739 and r7740 to 1.5x

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.5x/libtransmission/net.c

    r7729 r7741  
    5858    { { { { INADDR_ANY, 0x00, 0x00, 0x00 } } } } };
    5959
    60 
    6160#ifdef WIN32
    6261static const char *
     
    463462}
    464463
     464static tr_bool
     465isMulticastAddress( const tr_address * addr )
     466{
     467    if( addr->type == TR_AF_INET && IN_MULTICAST( htonl( addr->addr.addr4.s_addr ) ) )
     468        return TRUE;
     469
     470    if( addr->type == TR_AF_INET6 && ( addr->addr.addr6.s6_addr[0] == 0xff ) )
     471        return TRUE;
     472
     473    return FALSE;
     474}
     475
     476tr_bool
     477tr_isValidPeerAddress( const tr_address * addr, tr_port port )
     478{
     479    if( isMulticastAddress( addr ) )
     480        return FALSE;
     481
     482    if( port == 0 )
     483        return FALSE;
     484
     485    return TRUE;
     486}
     487
    465488int
    466489tr_netOpenTCP( tr_session        * session,
     
    475498    assert( tr_isAddress( addr ) );
    476499
    477     /* don't try to connect to multicast addresses */
    478     if( addr->type == TR_AF_INET && IN_MULTICAST( htonl( addr->addr.addr4.s_addr ) ) )
    479         return -EINVAL;
    480     if( addr->type == TR_AF_INET6 && ( addr->addr.addr6.s6_addr[0] == 0xff ) )
     500    if( isMulticastAddress( addr ) )
    481501        return -EINVAL;
    482502
Note: See TracChangeset for help on using the changeset viewer.