Ignore:
Timestamp:
Aug 15, 2007, 9:26:24 PM (15 years ago)
Author:
joshe
Message:

Implement proposed extension to indicate which of azrueus or extended messaging are preferred.
This is disabled for now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer.c

    r2769 r2772  
    112112/* #define DISABLE_AZPROTO */
    113113
     114/* uncomment this to use the new reserved bits proposed here:
     115   http://www.azureuswiki.com/index.php/Extension_negotiation_protocol */
     116/* #define NEW_AZ_BITS */
     117
    114118#define HANDSHAKE_NAME          "\023BitTorrent protocol"
    115119#define HANDSHAKE_NAME_LEN      20
     
    120124#define HANDSHAKE_SIZE          ( HANDSHAKE_PEERID_OFF + TR_ID_LEN )
    121125
     126/* these macros test and set the bit indicating extended messaging support */
    122127#ifdef DISABLE_EXTMSGS
    123128#define HANDSHAKE_HAS_EXTMSGS( bits ) ( 0 )
     
    128133#endif
    129134
     135/* these macros test and set the bit indicating azureus protocol support */
    130136#ifdef DISABLE_AZPROTO
    131137#define HANDSHAKE_HAS_AZPROTO( bits ) ( 0 )
     
    135141#define HANDSHAKE_SET_AZPROTO( bits ) ( (bits)[0] |= 0x80 )
    136142#endif
     143
     144/* these macros are to be used if both extended messaging and the
     145   azureus protocol is supported, they indicate which protocol is preferred */
     146#ifdef NEW_AZ_BITS
     147#define HANDSHAKE_GET_EXTPREF( bits )      ( (bits)[5] & 0x03 )
     148#define HANDSHAKE_SET_EXTPREF( bits, val ) ( (bits)[5] |= 0x03 & (val) )
     149#else
     150#define HANDSHAKE_GET_EXTPREF( bits )      ( 0 )
     151#define HANDSHAKE_SET_EXTPREF( bits, val ) ( (void)0 )
     152#endif
     153#define HANDSHAKE_EXTPREF_FORCE_EXT        ( 0x00 )
     154#define HANDSHAKE_EXTPREF_WANT_EXT         ( 0x01 )
     155#define HANDSHAKE_EXTPREF_WANT_AZ          ( 0x10 )
     156#define HANDSHAKE_EXTPREF_FORCE_AZ         ( 0x11 )
    137157
    138158#define PEER_MSG_CHOKE          0
     
    559579        HANDSHAKE_SET_EXTMSGS( buf + HANDSHAKE_FLAGS_OFF );
    560580        HANDSHAKE_SET_AZPROTO( buf + HANDSHAKE_FLAGS_OFF );
     581        HANDSHAKE_SET_EXTPREF( buf + HANDSHAKE_FLAGS_OFF,
     582                               HANDSHAKE_EXTPREF_WANT_EXT );
    561583        memcpy( buf + HANDSHAKE_HASH_OFF, inf->hash, SHA_DIGEST_LENGTH );
    562584        memcpy( buf + HANDSHAKE_PEERID_OFF, tor->peer_id, TR_ID_LEN );
Note: See TracChangeset for help on using the changeset viewer.