Changeset 4115


Ignore:
Timestamp:
Dec 9, 2007, 10:46:36 PM (15 years ago)
Author:
charles
Message:

fix UPNP for 0.96

Location:
branches/0.9x/libtransmission
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/0.9x/libtransmission/natpmp.c

    r4037 r4115  
    4141#include "utils.h"
    4242
     43#define PMP_MCAST_ADDR          "224.0.0.1"
    4344#define PMP_PORT                5351
    4445#define PMP_INITIAL_DELAY       250     /* ms, 1/4 second */
     
    137138
    138139tr_natpmp *
    139 tr_natpmpInit()
     140tr_natpmpInit( void )
    140141{
    141142    tr_natpmp * pmp;
     
    674675
    675676static int
    676 mcastsetup()
     677mcastsetup( void )
    677678{
    678679    int fd;
  • branches/0.9x/libtransmission/natpmp.h

    r4037 r4115  
    3737void        tr_natpmpClose( tr_natpmp * );
    3838
    39 #define PMP_MCAST_ADDR "224.0.0.1"
    40 
    4139#endif
  • branches/0.9x/libtransmission/net.c

    r4037 r4115  
    158158    struct ip_mreq req;
    159159
    160     fd = tr_netBindUDP( port );
     160    fd = tr_netBindUDP( port, addr );
    161161    if( 0 > fd )
    162162    {
     
    184184
    185185static int
    186 tr_netBind( int port, int type )
     186tr_netBind( int port, int type, const struct in_addr * addr )
    187187{
    188188    int s;
     
    212212    memset( &sock, 0, sizeof( sock ) );
    213213    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 {
    223218        sock.sin_addr.s_addr = INADDR_ANY;
    224 
    225     sock.sin_port        = htons( port );
     219        tr_inf( "using INADDR_ANY\n" );
     220    }
    226221
    227222    if( bind( s, (struct sockaddr *) &sock,
     
    239234tr_netBindTCP( int port )
    240235{
    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
     239int
     240tr_netBindUDP( int port, const struct in_addr * addr )
     241{
     242    return tr_netBind( port, SOCK_DGRAM, addr );
     243}
    250244
    251245int
  • branches/0.9x/libtransmission/net.h

    r3706 r4115  
    7272int  tr_netMcastOpen( int port, const struct in_addr * addr );
    7373int  tr_netBindTCP  ( int port );
    74 int  tr_netBindUDP  ( int port );
     74int  tr_netBindUDP  ( int port, const struct in_addr * addr );
    7575int  tr_netAccept   ( int s, struct in_addr *, tr_port_t * );
    7676void tr_netClose    ( int s );
  • branches/0.9x/libtransmission/upnp.c

    r3706 r4115  
    374374    if( 0 > fd )
    375375    {
    376         fd = tr_netBindUDP( 0 );
     376        struct in_addr addr;
     377        addr.s_addr = inet_addr( SSDP_ADDR );
     378        fd = tr_netBindUDP( 0, &addr );
    377379        if( 0 > fd )
    378380        {
Note: See TracChangeset for help on using the changeset viewer.