Ignore:
Timestamp:
Dec 15, 2009, 8:06:48 PM (12 years ago)
Author:
charles
Message:

(trunk libT) #2667 "Ignore martian addresses" -- apply jch's 0001-Simplify-martian-address-detection.patch cleanup patch from http://trac.transmissionbt.com/ticket/2667#comment:8

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/net.c

    r9780 r9781  
    595595
    596596static tr_bool
    597 isMulticastAddress( const tr_address * addr )
    598 {
    599     if( addr->type == TR_AF_INET && IN_MULTICAST( htonl( addr->addr.addr4.s_addr ) ) )
    600         return TRUE;
    601 
    602     if( addr->type == TR_AF_INET6 && ( addr->addr.addr6.s6_addr[0] == 0xff ) )
    603         return TRUE;
    604 
    605     return FALSE;
    606 }
    607 
    608 static tr_bool
    609597isIPv4MappedAddress( const tr_address * addr )
    610598{
     
    624612isMartianAddr( const struct tr_address * a )
    625613{
    626     static const unsigned char v4prefix[16] =
    627         { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
    628614    static const unsigned char zeroes[16] =
    629615        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
     
    644630            const unsigned char * address = (const unsigned char*)&a->addr.addr6;
    645631            return (address[0] == 0xFF) ||
    646                    (address[0] == 0xFE && (address[1] & 0xC0) == 0x80) ||
    647                    (memcmp(address, zeroes, 15) == 0 && (address[15] == 0 || address[15] == 1)) ||
    648                    (memcmp(address, v4prefix, 12) == 0);
     632                   (memcmp(address, zeroes, 15) == 0 &&
     633                    (address[15] == 0 || address[15] == 1));
    649634            break;
    650635        }
     
    660645    return ( port != 0 )
    661646        && ( tr_isAddress( addr ) )
    662         && ( !isMulticastAddress( addr ) )
    663647        && ( !isIPv6LinkLocalAddress( addr ) )
    664648        && ( !isIPv4MappedAddress( addr ) )
Note: See TracChangeset for help on using the changeset viewer.