Changeset 3450


Ignore:
Timestamp:
Oct 17, 2007, 6:53:17 PM (14 years ago)
Author:
charles
Message:

remove stubs for Azureus extension negotiation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/handshake.c

    r3397 r3450  
    3333#define ENABLE_LTEP */
    3434
    35 /* enable Azureus messaging protocol */
    36 /* (disabled because it's not fully implemented yet) */
    37 /* #define ENABLE_AZMP */
    38 
    3935/* enable fast peers extension protocol */
    4036/* #define ENABLE_FASTPEER */
     
    5349    HANDSHAKE_SIZE                 = 68,
    5450    PEER_ID_LEN                    = 20,
    55 
    56     /* Extension Negotiation Constants */
    57     HANDSHAKE_EXTPREF_LTEP_FORCE   = 0x0,
    58     HANDSHAKE_EXTPREF_LTEP_PREFER  = 0x1,
    59     HANDSHAKE_EXTPREF_AZMP_PREFER  = 0x2,
    60     HANDSHAKE_EXTPREF_AZMP_FORCE   = 0x3,
    6151
    6252    /* Encryption Constants */
     
    7363
    7464#ifdef ENABLE_LTEP
    75 #define HANDSHAKE_HAS_EXTMSGS( bits ) ( ( (bits)[5] & 0x10 ) ? 1 : 0 )
    76 #define HANDSHAKE_SET_EXTMSGS( bits ) ( (bits)[5] |= 0x10 )
     65#define HANDSHAKE_HAS_LTEP( bits ) ( ( (bits)[5] & 0x10 ) ? 1 : 0 )
     66#define HANDSHAKE_SET_LTEP( bits ) ( (bits)[5] |= 0x10 )
    7767#else
    78 #define HANDSHAKE_HAS_EXTMSGS( bits ) ( 0 )
    79 #define HANDSHAKE_SET_EXTMSGS( bits ) ( (void)0 )
    80 #endif
    81 
    82 #ifdef ENABLE_AZMP
    83 #define HANDSHAKE_HAS_AZPROTO( bits ) ( ( (bits)[0] & 0x80 ) ? 1 : 0 )
    84 #define HANDSHAKE_SET_AZPROTO( bits ) ( (bits)[0] |= 0x80 )
    85 #else
    86 #define HANDSHAKE_HAS_AZPROTO( bits ) ( 0 )
    87 #define HANDSHAKE_SET_AZPROTO( bits ) ( (void)0 )
     68#define HANDSHAKE_HAS_LTEP( bits ) ( 0 )
     69#define HANDSHAKE_SET_LTEP( bits ) ( (void)0 )
    8870#endif
    8971
     
    208190static uint8_t *
    209191buildHandshakeMessage( tr_handshake * handshake,
    210                        int            extensionPreference,
    211192                       int          * setme_len )
    212193{
     
    218199    walk += HANDSHAKE_NAME_LEN;
    219200    memset( walk, 0, HANDSHAKE_FLAGS_LEN );
    220     switch( extensionPreference )
    221     {
    222         case HANDSHAKE_EXTPREF_LTEP_FORCE:
    223             HANDSHAKE_SET_EXTMSGS( walk );
    224             HANDSHAKE_SET_EXTPREF( walk, extensionPreference );
    225             break;
    226 
    227         case HANDSHAKE_EXTPREF_LTEP_PREFER:
    228             HANDSHAKE_SET_EXTMSGS( walk );
    229             HANDSHAKE_SET_AZPROTO( walk );
    230             HANDSHAKE_SET_EXTPREF( walk, extensionPreference );
    231             break;
    232 
    233         case HANDSHAKE_EXTPREF_AZMP_PREFER:
    234             HANDSHAKE_SET_EXTMSGS( walk );
    235             HANDSHAKE_SET_AZPROTO( walk );
    236             HANDSHAKE_SET_EXTPREF( walk, extensionPreference );
    237             break;
    238 
    239         case HANDSHAKE_EXTPREF_AZMP_FORCE:
    240             HANDSHAKE_SET_AZPROTO( walk );
    241             HANDSHAKE_SET_EXTPREF( walk, extensionPreference );
    242             break;
    243     }
    244    
     201    HANDSHAKE_SET_LTEP( walk );
    245202    HANDSHAKE_SET_FASTEXT( walk );
    246203
     
    271228                struct evbuffer  * inbuf )
    272229{
    273     uint8_t ltep = 0;
    274     uint8_t azmp = 0;
    275     uint8_t fpex = 0;
    276230    uint8_t name[HANDSHAKE_NAME_LEN];
    277231    uint8_t reserved[HANDSHAKE_FLAGS_LEN];
     
    313267
    314268    /**
    315     *** Extension negotiation
     269    *** Extensions
    316270    **/
    317271
    318     ltep = HANDSHAKE_HAS_EXTMSGS( reserved );
    319     azmp = HANDSHAKE_HAS_AZPROTO( reserved );
    320     fpex = HANDSHAKE_HAS_FASTEXT( reserved );
    321 
    322     if( ltep && azmp ) {
    323         switch( HANDSHAKE_GET_EXTPREF( reserved ) ) {
    324             case HANDSHAKE_EXTPREF_LTEP_FORCE:
    325             case HANDSHAKE_EXTPREF_LTEP_PREFER:
    326                 azmp = 0;
    327                 break;
    328             case HANDSHAKE_EXTPREF_AZMP_FORCE:
    329             case HANDSHAKE_EXTPREF_AZMP_PREFER:
    330                 ltep = 0;
    331                 break;
    332         }
    333     }
    334     assert( !ltep || !azmp );
    335    
    336     if( ltep ) { tr_peerIoEnableLTEP( handshake->io, 1 ); dbgmsg(handshake,"using ltep" ); }
    337     if( azmp ) { tr_peerIoEnableAZMP( handshake->io, 1 ); dbgmsg(handshake,"using azmp" ); }
    338     if( fpex ) { tr_peerIoEnableFEXT( handshake->io, 1 ); dbgmsg(handshake,"using fext" ); }
     272    if( HANDSHAKE_HAS_LTEP( reserved ) )
     273    {
     274        tr_peerIoEnableLTEP( handshake->io, 1 );
     275        dbgmsg(handshake,"using ltep" );
     276    }
     277
     278    if( HANDSHAKE_HAS_FASTEXT( reserved ) )
     279    {
     280        tr_peerIoEnableFEXT( handshake->io, 1 );
     281        dbgmsg(handshake,"using fext" );
     282    }
    339283       
    340284    return HANDSHAKE_OK;
     
    468412    {
    469413        int msglen;
    470         uint8_t * msg = buildHandshakeMessage( handshake, HANDSHAKE_EXTPREF_LTEP_PREFER, &msglen );
     414        uint8_t * msg = buildHandshakeMessage( handshake, &msglen );
    471415
    472416        tr_peerIoWriteUint16( handshake->io, outbuf, msglen );
     
    578522readHandshake( tr_handshake * handshake, struct evbuffer * inbuf )
    579523{
    580     uint8_t ltep = 0;
    581     uint8_t azmp = 0;
    582     uint8_t fpex = 0;
    583524    uint8_t pstrlen;
    584525    uint8_t * pstr;
     
    688629    **/
    689630
    690     ltep = HANDSHAKE_HAS_EXTMSGS( reserved );
    691     azmp = HANDSHAKE_HAS_AZPROTO( reserved );
    692     fpex = HANDSHAKE_HAS_FASTEXT( reserved );
    693 
    694     if( ltep && azmp ) {
    695         switch( HANDSHAKE_GET_EXTPREF( reserved ) ) {
    696             case HANDSHAKE_EXTPREF_LTEP_FORCE:
    697             case HANDSHAKE_EXTPREF_LTEP_PREFER:
    698                 azmp = 0;
    699                 break;
    700             case HANDSHAKE_EXTPREF_AZMP_FORCE:
    701             case HANDSHAKE_EXTPREF_AZMP_PREFER:
    702                 ltep = 0;
    703                 break;
    704         }
    705     }
    706     assert( !ltep || !azmp );
    707    
    708     if( ltep ) { tr_peerIoEnableLTEP( handshake->io, 1 ); dbgmsg(handshake,"using ltep" ); }
    709     if( azmp ) { tr_peerIoEnableAZMP( handshake->io, 1 ); dbgmsg(handshake,"using azmp" ); }
    710     if( fpex ) { tr_peerIoEnableFEXT( handshake->io, 1 ); dbgmsg(handshake,"using fext" ); }
     631    if( HANDSHAKE_HAS_LTEP( reserved ) )
     632    {
     633        tr_peerIoEnableLTEP( handshake->io, 1 );
     634        dbgmsg( handshake,"using ltep" );
     635    }
     636    if( HANDSHAKE_HAS_FASTEXT( reserved ) )
     637    {
     638        tr_peerIoEnableFEXT( handshake->io, 1 );
     639        dbgmsg( handshake,"using fext" );
     640    }
    711641   
    712642    /**
     
    716646    if( !handshake->haveSentBitTorrentHandshake )
    717647    {
    718         const int ext = ltep ? HANDSHAKE_EXTPREF_LTEP_FORCE
    719                              : HANDSHAKE_EXTPREF_AZMP_FORCE;
    720648        int msgSize;
    721         uint8_t * msg = buildHandshakeMessage( handshake, ext, &msgSize );
     649        uint8_t * msg = buildHandshakeMessage( handshake, &msgSize );
    722650        tr_peerIoWrite( handshake->io, msg, msgSize );
    723651        tr_free( msg );
     
    945873    {
    946874        int msgSize;
    947         int ext;
    948         uint8_t * msg;
    949 
    950         /* add our choice of protocol extension */
    951         if( tr_peerIoSupportsAZMP( handshake->io ) )
    952             ext = HANDSHAKE_EXTPREF_AZMP_FORCE;
    953         else if( tr_peerIoSupportsLTEP( handshake->io ) )
    954             ext = HANDSHAKE_EXTPREF_LTEP_FORCE;
    955         else
    956             ext = 0;
    957 
    958         msg = buildHandshakeMessage( handshake, ext, &msgSize );
     875        uint8_t * msg = buildHandshakeMessage( handshake, &msgSize );
    959876        tr_peerIoWriteBytes( handshake->io, outbuf, msg, msgSize );
     877        handshake->haveSentBitTorrentHandshake = 1;
    960878        tr_free( msg );
    961         handshake->haveSentBitTorrentHandshake = 1;
    962879    }
    963880
     
    1049966        dbgmsg( handshake, "handshake failed, trying plaintext..." );
    1050967        int msgSize;
    1051         uint8_t * msg = buildHandshakeMessage( handshake, HANDSHAKE_EXTPREF_LTEP_PREFER, &msgSize );
     968        uint8_t * msg = buildHandshakeMessage( handshake, &msgSize );
    1052969        setReadState( handshake, AWAITING_HANDSHAKE );
    1053970        tr_peerIoWrite( handshake->io, msg, msgSize );
Note: See TracChangeset for help on using the changeset viewer.