Changeset 4115
- Timestamp:
- Dec 9, 2007, 10:46:36 PM (15 years ago)
- Location:
- branches/0.9x/libtransmission
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/0.9x/libtransmission/natpmp.c
r4037 r4115 41 41 #include "utils.h" 42 42 43 #define PMP_MCAST_ADDR "224.0.0.1" 43 44 #define PMP_PORT 5351 44 45 #define PMP_INITIAL_DELAY 250 /* ms, 1/4 second */ … … 137 138 138 139 tr_natpmp * 139 tr_natpmpInit( )140 tr_natpmpInit( void ) 140 141 { 141 142 tr_natpmp * pmp; … … 674 675 675 676 static int 676 mcastsetup( )677 mcastsetup( void ) 677 678 { 678 679 int fd; -
branches/0.9x/libtransmission/natpmp.h
r4037 r4115 37 37 void tr_natpmpClose( tr_natpmp * ); 38 38 39 #define PMP_MCAST_ADDR "224.0.0.1"40 41 39 #endif -
branches/0.9x/libtransmission/net.c
r4037 r4115 158 158 struct ip_mreq req; 159 159 160 fd = tr_netBindUDP( port );160 fd = tr_netBindUDP( port, addr ); 161 161 if( 0 > fd ) 162 162 { … … 184 184 185 185 static int 186 tr_netBind( int port, int type )186 tr_netBind( int port, int type, const struct in_addr * addr ) 187 187 { 188 188 int s; … … 212 212 memset( &sock, 0, sizeof( sock ) ); 213 213 sock.sin_family = AF_INET; 214 215 /* Leopard closes a SO_REUSEADDR + INADDR_ANY hole, so we can't 216 * use INADDR_ANY when binding for nat-pmp. For details, refer to 217 * http://www.uwsg.indiana.edu/hypermail/linux/kernel/9902.1/0828.html . 218 * This can probably be done cleaner, but since we're only using SOCK_DGRAM 219 * for nat-pmp, this quick fix should work. */ 220 if ( SOCK_DGRAM == type ) 221 sock.sin_addr.s_addr = inet_addr( PMP_MCAST_ADDR ); 222 else 214 if( addr != NULL ) { 215 sock.sin_addr.s_addr = addr->s_addr; 216 tr_inf( "using the specified address\n" ); 217 } else { 223 218 sock.sin_addr.s_addr = INADDR_ANY; 224 225 sock.sin_port = htons( port );219 tr_inf( "using INADDR_ANY\n" ); 220 } 226 221 227 222 if( bind( s, (struct sockaddr *) &sock, … … 239 234 tr_netBindTCP( int port ) 240 235 { 241 return tr_netBind( port, SOCK_STREAM ); 242 } 243 244 int 245 tr_netBindUDP( int port ) 246 { 247 return tr_netBind( port, SOCK_DGRAM ); 248 } 249 236 return tr_netBind( port, SOCK_STREAM, NULL ); 237 } 238 239 int 240 tr_netBindUDP( int port, const struct in_addr * addr ) 241 { 242 return tr_netBind( port, SOCK_DGRAM, addr ); 243 } 250 244 251 245 int -
branches/0.9x/libtransmission/net.h
r3706 r4115 72 72 int tr_netMcastOpen( int port, const struct in_addr * addr ); 73 73 int tr_netBindTCP ( int port ); 74 int tr_netBindUDP ( int port );74 int tr_netBindUDP ( int port, const struct in_addr * addr ); 75 75 int tr_netAccept ( int s, struct in_addr *, tr_port_t * ); 76 76 void tr_netClose ( int s ); -
branches/0.9x/libtransmission/upnp.c
r3706 r4115 374 374 if( 0 > fd ) 375 375 { 376 fd = tr_netBindUDP( 0 ); 376 struct in_addr addr; 377 addr.s_addr = inet_addr( SSDP_ADDR ); 378 fd = tr_netBindUDP( 0, &addr ); 377 379 if( 0 > fd ) 378 380 {
Note: See TracChangeset
for help on using the changeset viewer.