**/
void
-tr_peerIoSetEncryption( tr_peerIo * io, uint32_t encryptionMode )
+tr_peerIoSetEncryption( tr_peerIo * io, tr_encryption_type encryption_type )
{
assert( tr_isPeerIo( io ) );
- assert( encryptionMode == PEER_ENCRYPTION_NONE
- || encryptionMode == PEER_ENCRYPTION_RC4 );
+ assert( encryption_type == PEER_ENCRYPTION_NONE
+ || encryption_type == PEER_ENCRYPTION_RC4 );
- io->encryptionMode = encryptionMode;
+ io->encryption_type = encryption_type;
}
/**
static void
maybeEncryptBuffer( tr_peerIo * io, struct evbuffer * buf )
{
- if( io->encryptionMode == PEER_ENCRYPTION_RC4 )
+ if( io->encryption_type == PEER_ENCRYPTION_RC4 )
{
size_t i, n;
struct evbuffer_iovec * iovec = evbuffer_peek_all( buf, &n );
assert( tr_isPeerIo( io ) );
assert( evbuffer_get_length( inbuf ) >= byteCount );
- switch( io->encryptionMode )
+ switch( io->encryption_type )
{
case PEER_ENCRYPTION_NONE:
evbuffer_remove( inbuf, bytes, byteCount );
}
ReadState;
+typedef enum
+{
+ /* these match the values in MSE's crypto_select */
+ PEER_ENCRYPTION_NONE = ( 1 << 0 ),
+ PEER_ENCRYPTION_RC4 = ( 1 << 1 )
+}
+tr_encryption_type;
+
+
typedef ReadState ( *tr_can_read_cb )( struct tr_peerIo * io,
void * user_data,
size_t * setme_piece_byte_count );
int magicNumber;
- uint32_t encryptionMode;
+ tr_encryption_type encryption_type;
bool isSeed;
tr_port port;
return io->crypto;
}
-typedef enum
-{
- /* these match the values in MSE's crypto_select */
- PEER_ENCRYPTION_NONE = ( 1 << 0 ),
- PEER_ENCRYPTION_RC4 = ( 1 << 1 )
-}
-EncryptionMode;
-
-void tr_peerIoSetEncryption( tr_peerIo * io, uint32_t encryptionMode );
+void tr_peerIoSetEncryption( tr_peerIo * io, tr_encryption_type encryption_type );
static inline bool
tr_peerIoIsEncrypted( const tr_peerIo * io )
{
- return ( io != NULL ) && ( io->encryptionMode == PEER_ENCRYPTION_RC4 );
+ return ( io != NULL ) && ( io->encryption_type == PEER_ENCRYPTION_RC4 );
}
void evbuffer_add_uint8 ( struct evbuffer * outbuf, uint8_t byte );