Changeset 3122


Ignore:
Timestamp:
Sep 21, 2007, 2:50:29 PM (14 years ago)
Author:
charles
Message:
  • accept tiennou's partial patch for `fast peers' extension
  • fix growl problem I introduced in the last checkin, reported by chrissturm
Location:
trunk/libtransmission
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/handshake.c

    r3117 r3122  
    3030
    3131/* enable LibTransmission extension protocol */
    32 #define ENABLE_LTEP
     32#define ENABLE_LTEP */
    3333
    3434/* enable Azureus messaging protocol */
    35 //#define ENABLE_AZMP
     35/* (disabled because it's not fully implemented yet) */
     36/* #define ENABLE_AZMP */
     37
     38/* enable fast peers extension protocol */
     39/* (disabled because it's not fully implemented yet) */
     40/* #define ENABLE_FASTPEER */
    3641
    3742/***
     
    6772#ifdef ENABLE_LTEP
    6873#define HANDSHAKE_HAS_EXTMSGS( bits ) ( ( (bits)[5] & 0x10 ) ? 1 : 0 )
    69 #define HANDSHAKE_SET_EXTMSGS( bits ) ( ( (bits)[5] |= 0x10 ) ? 1 : 0 )
     74#define HANDSHAKE_SET_EXTMSGS( bits ) ( (bits)[5] |= 0x10 )
    7075#else
    7176#define HANDSHAKE_HAS_EXTMSGS( bits ) ( 0 )
     
    7580#ifdef ENABLE_AZMP
    7681#define HANDSHAKE_HAS_AZPROTO( bits ) ( ( (bits)[0] & 0x80 ) ? 1 : 0 )
    77 #define HANDSHAKE_SET_AZPROTO( bits ) ( ( (bits)[0] |= 0x80 ) ? 1 : 0 )
     82#define HANDSHAKE_SET_AZPROTO( bits ) ( (bits)[0] |= 0x80 )
    7883#else
    7984#define HANDSHAKE_HAS_AZPROTO( bits ) ( 0 )
    8085#define HANDSHAKE_SET_AZPROTO( bits ) ( (void)0 )
     86#endif
     87
     88#ifdef ENABLE_FASTPEER
     89#define HANDSHAKE_HAS_FASTEXT( bits ) ( ( (bits)[7] & 0x04 ) ? 1 : 0 )
     90#define HANDSHAKE_SET_FASTEXT( bits ) ( (bits)[7] |= 0x04 )
     91#else
     92#define HANDSHAKE_HAS_FASTEXT( bits ) ( 0 )
     93#define HANDSHAKE_SET_FASTEXT( bits ) ( (void)0 )
    8194#endif
    8295
     
    228241            break;
    229242    }
     243   
     244    HANDSHAKE_SET_FASTEXT ( walk );
    230245
    231246    walk += HANDSHAKE_FLAGS_LEN;
     
    486501readHandshake( tr_handshake * handshake, struct evbuffer * inbuf )
    487502{
    488     int i;
    489503    uint8_t ltep = 0;
    490504    uint8_t azmp = 0;
     505    uint8_t fpex = 0;
    491506    uint8_t pstrlen;
    492507    uint8_t * pstr;
     
    587602    ltep = HANDSHAKE_HAS_EXTMSGS( reserved );
    588603    azmp = HANDSHAKE_HAS_AZPROTO( reserved );
     604    fpex = HANDSHAKE_HAS_FASTEXT( reserved );
     605
    589606    if( ltep && azmp ) {
    590607        switch( HANDSHAKE_GET_EXTPREF( reserved ) ) {
     
    600617    }
    601618    assert( !ltep || !azmp );
    602          if( ltep ) { i = LT_EXTENSIONS_LTEP; dbgmsg(handshake,"using ltep" ); }
    603     else if( azmp ) { i = LT_EXTENSIONS_AZMP; dbgmsg(handshake,"using azmp" ); }
    604     else            { i = LT_EXTENSIONS_NONE; dbgmsg(handshake,"using no extensions" ); }
    605     tr_peerIoSetExtension( handshake->io, i );
    606 
    607 
     619   
     620         if( ltep ) { tr_peerIoEnableLTEP( handshake->io, 1 ); dbgmsg(handshake,"using ltep" ); }
     621    else if( azmp ) { tr_peerIoEnableAZMP( handshake->io, 1 ); dbgmsg(handshake,"using azmp" ); }
     622    else if( fpex ) { tr_peerIoEnableFEXT( handshake->io, 1 ); dbgmsg(handshake,"using fext" ); }
     623    else            { dbgmsg(handshake,"using no extensions" ); }
     624   
    608625    /**
    609626    ***  If this is an incoming message, then we need to send a response handshake
  • trunk/libtransmission/internal.h

    r3121 r3122  
    156156    uint64_t                   activityDate;
    157157
     158    uint8_t                    hasChangedState;
     159
    158160    unsigned int               runStatusToSaveIsSet : 1;
    159     unsigned int               hasChangedState : 1;
    160161    unsigned int               pexDisabled : 1;
    161162    unsigned int               doStopAfterHashCheck : 1;
  • trunk/libtransmission/peer-io.c

    r3105 r3122  
    2929**/
    3030
     31struct tr_extensions
     32{
     33    unsigned int azureusProtocolSupported : 1;
     34    unsigned int extendedProtocolSupported : 1;
     35    unsigned int fastPeersSupported : 1;
     36    /* unsigned int DHTSupported : 1; */
     37};
     38
    3139struct tr_peerIo
    3240{
     
    3644    int port;
    3745    int socket;
    38     int extensions;
    3946    int encryptionMode;
    4047    struct bufferevent * bufev;
    4148    uint8_t peerId[20];
     49
     50    tr_extensions extensions;
    4251
    4352    unsigned int isEncrypted : 1;
     
    325334
    326335void
    327 tr_peerIoSetExtension( tr_peerIo   * io,
    328                        int           extensions )
    329 {
    330     assert( io != NULL );
    331     assert( ( extensions == LT_EXTENSIONS_NONE )
    332          || ( extensions == LT_EXTENSIONS_LTEP )
    333          || ( extensions == LT_EXTENSIONS_AZMP ) );
    334 
    335     io->extensions = extensions;
    336 }
    337 
    338 int
    339 tr_peerIoGetExtension( const tr_peerIo * io )
    340 {
    341     assert( io != NULL );
    342 
    343     return io->extensions;
    344 }
    345 
     336tr_peerIoEnableAZMP( tr_peerIo * io, int flag )
     337{
     338    assert( io != NULL );
     339    assert( flag==0 || flag==1 );
     340   
     341    io->extensions.azureusProtocolSupported = flag;
     342}
     343
     344void
     345tr_peerIoEnableLTEP( tr_peerIo * io, int flag )
     346{
     347    assert( io != NULL );
     348    assert( flag==0 || flag==1 );
     349   
     350    io->extensions.extendedProtocolSupported = flag;
     351}
     352
     353void
     354tr_peerIoEnableFEXT( tr_peerIo * io, int flag )
     355{
     356    assert( io != NULL );
     357    assert( flag==0 || flag==1 );
     358   
     359    io->extensions.fastPeersSupported = flag;
     360}
     361
     362int
     363tr_peerIoSupportsAZMP( const tr_peerIo * io )
     364{
     365    assert( io != NULL );
     366   
     367    return io->extensions.azureusProtocolSupported;
     368}
     369
     370int
     371tr_peerIoSupportsLTEP( const tr_peerIo * io )
     372{
     373    assert( io != NULL );
     374   
     375    return io->extensions.extendedProtocolSupported;
     376}
     377
     378int
     379tr_peerIoSupportsFEXT( const tr_peerIo * io )
     380{
     381    assert( io != NULL );
     382   
     383    return io->extensions.fastPeersSupported;
     384}
    346385/**
    347386***
  • trunk/libtransmission/peer-io.h

    r3105 r3122  
    2424struct tr_crypto;
    2525typedef struct tr_peerIo tr_peerIo;
    26 
     26typedef struct tr_extensions tr_extensions;
    2727
    2828/**
     
    4949**/
    5050
    51 enum
    52 {
    53     LT_EXTENSIONS_NONE,
    54     LT_EXTENSIONS_LTEP,
    55     LT_EXTENSIONS_AZMP
    56 };
     51void  tr_peerIoEnableAZMP( tr_peerIo * io, int flag );
     52void  tr_peerIoEnableLTEP( tr_peerIo * io, int flag );
     53void  tr_peerIoEnableFEXT( tr_peerIo * io, int flag );
    5754
    58 void  tr_peerIoSetExtension( tr_peerIo  * io,
    59                              int          lt_extensions );
    60 
    61 int   tr_peerIoGetExtension( const tr_peerIo * io );
     55int   tr_peerIoSupportsAZMP( const tr_peerIo * io );
     56int   tr_peerIoSupportsLTEP( const tr_peerIo * io );
     57int   tr_peerIoSupportsFEXT( const tr_peerIo * io );
    6258
    6359/**
  • trunk/libtransmission/peer-msgs.c

    r3118 r3122  
    5555    BT_CANCEL          = 8,
    5656    BT_PORT            = 9,
     57    BT_SUGGEST         = 13,
     58    BT_HAVE_ALL        = 14,
     59    BT_HAVE_NONE       = 15,
     60    BT_REJECT          = 16,
     61    BT_ALLOWED_FAST    = 17,
    5762    BT_LTEP            = 20,
    5863
     
    723728            break;
    724729        }
    725 
     730       
     731        case BT_SUGGEST: {
     732            /* tiennou TODO */
     733            break;
     734        }
     735           
     736        case BT_HAVE_ALL: {
     737            /* tiennou TODO */
     738            break;
     739        }
     740           
     741        case BT_HAVE_NONE: {
     742            /* tiennou TODO */
     743            break;
     744        }
     745           
     746        case BT_REJECT: {
     747            /* tiennou TODO */
     748            break;
     749        }
     750           
     751        case BT_ALLOWED_FAST: {
     752            /* tiennou TODO */
     753            break;
     754        }
     755           
    726756        case BT_LTEP:
    727757            dbgmsg( msgs, "peer sent us a BT_LTEP" );
     
    12501280    if( !tr_peerIoIsIncoming( msgs->io ) )
    12511281    {
    1252         const int extensions = tr_peerIoGetExtension( msgs->io );
    1253         switch( extensions )
    1254         {
    1255             case LT_EXTENSIONS_NONE:
    1256                 /* no-op */
    1257                 break;
    1258 
    1259             case LT_EXTENSIONS_LTEP:
    1260                 sendLtepHandshake( msgs );
    1261                 break;
    1262 
    1263             case LT_EXTENSIONS_AZMP:
    1264                 dbgmsg( msgs, "FIXME: need to send AZMP handshake" );
    1265                 break;
     1282        if ( tr_peerIoSupportsLTEP( msgs->io ) ) {
     1283            sendLtepHandshake( msgs );
     1284           
     1285        } else if ( tr_peerIoSupportsAZMP( msgs->io ) ) {
     1286            dbgmsg( msgs, "FIXME: need to send AZMP handshake" );
     1287           
     1288        } else {
     1289            /* no-op */
    12661290        }
    12671291    }
Note: See TracChangeset for help on using the changeset viewer.