From fc767a3f0376ea56d34470f6527f5e4217930b83 Mon Sep 17 00:00:00 2001 From: Erick Turnquist Date: Sun, 8 Feb 2009 22:45:30 +0000 Subject: [PATCH] (trunk libT) don't attempt to connect to (half-complete) ipv6 link-local addresses --- libtransmission/net.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libtransmission/net.c b/libtransmission/net.c index 11109c24e..9b0bcce7d 100644 --- a/libtransmission/net.c +++ b/libtransmission/net.c @@ -462,10 +462,19 @@ isMulticastAddress( const tr_address * addr ) return FALSE; } +static TR_INLINE tr_bool +isIPv6LinkLocalAddress( const tr_address * addr ) +{ + if( addr->type == TR_AF_INET6 && + IN6_IS_ADDR_LINKLOCAL( &addr->addr.addr6 )) + return TRUE; + return FALSE; +} + tr_bool tr_isValidPeerAddress( const tr_address * addr, tr_port port ) { - if( isMulticastAddress( addr ) ) + if( isMulticastAddress( addr ) || isIPv6LinkLocalAddress( addr ) ) return FALSE; if( port == 0 ) @@ -486,7 +495,7 @@ tr_netOpenTCP( tr_session * session, assert( tr_isAddress( addr ) ); - if( isMulticastAddress( addr ) ) + if( isMulticastAddress( addr ) || isIPv6LinkLocalAddress( addr )) return -EINVAL; if( ( s = createSocket( ( addr->type == TR_AF_INET ? AF_INET : AF_INET6 ), type ) ) < 0 )