2007-09-20 16:32:01 +00:00
|
|
|
/*
|
2011-01-19 13:48:47 +00:00
|
|
|
* This file Copyright (C) Mnemosyne LLC
|
2007-09-20 16:32:01 +00:00
|
|
|
*
|
2010-12-27 19:18:17 +00:00
|
|
|
* This file is licensed by the GPL version 2. Works owned by the
|
2007-09-20 16:32:01 +00:00
|
|
|
* Transmission project are granted a special exemption to clause 2(b)
|
2008-09-23 19:11:04 +00:00
|
|
|
* so that the bulk of its code can remain under the MIT license.
|
2007-09-20 16:32:01 +00:00
|
|
|
* This exemption does not extend to derived works not owned by
|
|
|
|
* the Transmission project.
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*/
|
|
|
|
|
2008-11-24 20:17:36 +00:00
|
|
|
#ifndef __TRANSMISSION__
|
|
|
|
#error only libtransmission should #include this header.
|
|
|
|
#endif
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
#ifndef TR_PEER_IO_H
|
|
|
|
#define TR_PEER_IO_H
|
|
|
|
|
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
|
|
|
|
2009-01-02 17:46:22 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "transmission.h"
|
2009-01-02 19:56:06 +00:00
|
|
|
#include "bandwidth.h"
|
2011-04-17 05:22:50 +00:00
|
|
|
#include "crypto.h"
|
2009-01-02 17:46:22 +00:00
|
|
|
#include "net.h" /* tr_address */
|
2010-10-08 13:36:33 +00:00
|
|
|
#include "utils.h" /* tr_time() */
|
2009-01-02 17:46:22 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
struct evbuffer;
|
2008-11-24 04:21:23 +00:00
|
|
|
struct tr_bandwidth;
|
2011-04-10 05:21:51 +00:00
|
|
|
struct tr_datatype;
|
2009-01-02 17:46:22 +00:00
|
|
|
struct tr_peerIo;
|
|
|
|
|
2009-05-29 19:17:12 +00:00
|
|
|
/**
|
|
|
|
* @addtogroup networked_io Networked IO
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2009-01-02 17:46:22 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
READ_NOW,
|
|
|
|
READ_LATER,
|
|
|
|
READ_ERR
|
|
|
|
}
|
|
|
|
ReadState;
|
|
|
|
|
2011-03-31 16:41:52 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
/* these match the values in MSE's crypto_select */
|
|
|
|
PEER_ENCRYPTION_NONE = ( 1 << 0 ),
|
|
|
|
PEER_ENCRYPTION_RC4 = ( 1 << 1 )
|
|
|
|
}
|
|
|
|
tr_encryption_type;
|
|
|
|
|
|
|
|
|
2009-01-02 17:46:22 +00:00
|
|
|
typedef ReadState ( *tr_can_read_cb )( struct tr_peerIo * io,
|
|
|
|
void * user_data,
|
|
|
|
size_t * setme_piece_byte_count );
|
|
|
|
|
|
|
|
typedef void ( *tr_did_write_cb )( struct tr_peerIo * io,
|
|
|
|
size_t bytesWritten,
|
|
|
|
int wasPieceData,
|
|
|
|
void * userData );
|
|
|
|
|
|
|
|
typedef void ( *tr_net_error_cb )( struct tr_peerIo * io,
|
|
|
|
short what,
|
|
|
|
void * userData );
|
|
|
|
|
|
|
|
typedef struct tr_peerIo
|
|
|
|
{
|
2011-03-22 15:19:54 +00:00
|
|
|
bool isEncrypted;
|
|
|
|
bool isIncoming;
|
|
|
|
bool peerIdIsSet;
|
|
|
|
bool extendedProtocolSupported;
|
|
|
|
bool fastExtensionSupported;
|
|
|
|
bool dhtSupported;
|
|
|
|
bool utpSupported;
|
2009-01-02 17:46:22 +00:00
|
|
|
|
2009-04-18 23:17:30 +00:00
|
|
|
tr_priority_t priority;
|
|
|
|
|
2010-06-30 16:40:19 +00:00
|
|
|
short int pendingEvents;
|
2009-01-24 14:49:35 +00:00
|
|
|
|
2009-01-02 19:56:06 +00:00
|
|
|
int magicNumber;
|
2009-01-02 17:46:22 +00:00
|
|
|
|
2011-03-31 16:41:52 +00:00
|
|
|
tr_encryption_type encryption_type;
|
2011-03-22 15:19:54 +00:00
|
|
|
bool isSeed;
|
2009-01-05 04:27:54 +00:00
|
|
|
|
2009-01-02 19:56:06 +00:00
|
|
|
tr_port port;
|
|
|
|
int socket;
|
2011-02-18 00:23:51 +00:00
|
|
|
struct UTPSocket *utp_socket;
|
2009-01-02 17:46:22 +00:00
|
|
|
|
2009-01-19 14:05:43 +00:00
|
|
|
int refCount;
|
2009-01-05 04:27:54 +00:00
|
|
|
|
2009-01-02 19:56:06 +00:00
|
|
|
uint8_t peerId[SHA_DIGEST_LENGTH];
|
|
|
|
time_t timeCreated;
|
2009-01-02 17:46:22 +00:00
|
|
|
|
2009-01-02 19:56:06 +00:00
|
|
|
tr_session * session;
|
2009-01-02 17:46:22 +00:00
|
|
|
|
2009-01-02 19:56:06 +00:00
|
|
|
tr_address addr;
|
2009-01-02 17:46:22 +00:00
|
|
|
|
2009-01-02 19:56:06 +00:00
|
|
|
tr_can_read_cb canRead;
|
|
|
|
tr_did_write_cb didWrite;
|
|
|
|
tr_net_error_cb gotError;
|
|
|
|
void * userData;
|
2009-01-02 17:46:22 +00:00
|
|
|
|
2009-01-02 19:56:06 +00:00
|
|
|
struct tr_bandwidth bandwidth;
|
2011-04-17 05:22:50 +00:00
|
|
|
tr_crypto crypto;
|
2009-01-02 17:46:22 +00:00
|
|
|
|
2009-01-02 19:56:06 +00:00
|
|
|
struct evbuffer * inbuf;
|
|
|
|
struct evbuffer * outbuf;
|
2011-04-10 05:21:51 +00:00
|
|
|
struct tr_datatype * outbuf_datatypes;
|
2009-01-02 17:46:22 +00:00
|
|
|
|
2010-12-20 02:07:51 +00:00
|
|
|
struct event * event_read;
|
|
|
|
struct event * event_write;
|
2009-01-02 17:46:22 +00:00
|
|
|
}
|
|
|
|
tr_peerIo;
|
2007-09-20 16:32:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
|
|
|
|
2008-12-14 11:21:11 +00:00
|
|
|
tr_peerIo* tr_peerIoNewOutgoing( tr_session * session,
|
2009-01-02 19:56:06 +00:00
|
|
|
struct tr_bandwidth * parent,
|
2008-12-02 03:41:58 +00:00
|
|
|
const struct tr_address * addr,
|
|
|
|
tr_port port,
|
2009-12-02 05:30:46 +00:00
|
|
|
const uint8_t * torrentHash,
|
2011-03-22 15:19:54 +00:00
|
|
|
bool isSeed,
|
|
|
|
bool utp );
|
2011-02-18 00:36:19 +00:00
|
|
|
|
2008-11-17 04:00:57 +00:00
|
|
|
|
2008-12-14 11:21:11 +00:00
|
|
|
tr_peerIo* tr_peerIoNewIncoming( tr_session * session,
|
2009-01-02 19:56:06 +00:00
|
|
|
struct tr_bandwidth * parent,
|
2008-12-02 03:41:58 +00:00
|
|
|
const struct tr_address * addr,
|
|
|
|
tr_port port,
|
2011-02-18 00:23:51 +00:00
|
|
|
int socket,
|
|
|
|
struct UTPSocket * utp_socket );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2009-01-24 17:20:07 +00:00
|
|
|
void tr_peerIoRefImpl ( const char * file,
|
|
|
|
int line,
|
|
|
|
tr_peerIo * io );
|
2009-01-05 04:27:54 +00:00
|
|
|
|
2009-01-24 17:20:07 +00:00
|
|
|
#define tr_peerIoRef(io) tr_peerIoRefImpl( __FILE__, __LINE__, (io) );
|
|
|
|
|
|
|
|
void tr_peerIoUnrefImpl ( const char * file,
|
|
|
|
int line,
|
|
|
|
tr_peerIo * io );
|
|
|
|
|
|
|
|
#define tr_peerIoUnref(io) tr_peerIoUnrefImpl( __FILE__, __LINE__, (io) );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2011-03-15 18:11:31 +00:00
|
|
|
#define PEER_IO_MAGIC_NUMBER 206745
|
2008-12-21 18:15:00 +00:00
|
|
|
|
2011-03-22 15:19:54 +00:00
|
|
|
static inline bool
|
2011-03-15 18:11:31 +00:00
|
|
|
tr_isPeerIo( const tr_peerIo * io )
|
|
|
|
{
|
|
|
|
return ( io != NULL )
|
|
|
|
&& ( io->magicNumber == PEER_IO_MAGIC_NUMBER )
|
|
|
|
&& ( io->refCount >= 0 )
|
|
|
|
&& ( tr_isBandwidth( &io->bandwidth ) )
|
2011-03-25 05:34:26 +00:00
|
|
|
&& ( tr_address_is_valid( &io->addr ) );
|
2011-03-15 18:11:31 +00:00
|
|
|
}
|
2007-09-20 16:32:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
|
|
|
|
2011-03-22 15:19:54 +00:00
|
|
|
static inline void tr_peerIoEnableFEXT( tr_peerIo * io, bool flag )
|
2009-01-02 19:56:06 +00:00
|
|
|
{
|
2010-05-20 15:30:18 +00:00
|
|
|
io->fastExtensionSupported = flag;
|
2009-01-02 19:56:06 +00:00
|
|
|
}
|
2011-03-22 15:19:54 +00:00
|
|
|
static inline bool tr_peerIoSupportsFEXT( const tr_peerIo * io )
|
2009-01-02 19:56:06 +00:00
|
|
|
{
|
|
|
|
return io->fastExtensionSupported;
|
|
|
|
}
|
2008-12-02 17:10:54 +00:00
|
|
|
|
2011-03-22 15:19:54 +00:00
|
|
|
static inline void tr_peerIoEnableLTEP( tr_peerIo * io, bool flag )
|
2010-05-20 15:30:18 +00:00
|
|
|
{
|
|
|
|
io->extendedProtocolSupported = flag;
|
|
|
|
}
|
2011-03-22 15:19:54 +00:00
|
|
|
static inline bool tr_peerIoSupportsLTEP( const tr_peerIo * io )
|
2010-05-20 15:30:18 +00:00
|
|
|
{
|
|
|
|
return io->extendedProtocolSupported;
|
|
|
|
}
|
2009-05-19 18:38:26 +00:00
|
|
|
|
2011-03-22 15:19:54 +00:00
|
|
|
static inline void tr_peerIoEnableDHT( tr_peerIo * io, bool flag )
|
2010-05-20 15:30:18 +00:00
|
|
|
{
|
|
|
|
io->dhtSupported = flag;
|
|
|
|
}
|
2011-03-22 15:19:54 +00:00
|
|
|
static inline bool tr_peerIoSupportsDHT( const tr_peerIo * io )
|
2009-05-19 18:38:26 +00:00
|
|
|
{
|
|
|
|
return io->dhtSupported;
|
|
|
|
}
|
|
|
|
|
2011-03-22 15:19:54 +00:00
|
|
|
static inline bool tr_peerIoSupportsUTP( const tr_peerIo * io )
|
2011-02-18 00:41:06 +00:00
|
|
|
{
|
|
|
|
return io->dhtSupported;
|
|
|
|
}
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
|
|
|
|
2010-01-01 22:26:35 +00:00
|
|
|
static inline tr_session* tr_peerIoGetSession ( tr_peerIo * io )
|
2009-01-02 19:56:06 +00:00
|
|
|
{
|
|
|
|
assert( tr_isPeerIo( io ) );
|
|
|
|
assert( io->session );
|
|
|
|
|
|
|
|
return io->session;
|
|
|
|
}
|
2007-09-30 23:55:49 +00:00
|
|
|
|
2008-12-02 03:41:58 +00:00
|
|
|
const char* tr_peerIoAddrStr( const struct tr_address * addr,
|
|
|
|
tr_port port );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2010-10-11 15:41:27 +00:00
|
|
|
const char* tr_peerIoGetAddrStr( const tr_peerIo * io );
|
2008-12-02 03:41:58 +00:00
|
|
|
|
|
|
|
const struct tr_address * tr_peerIoGetAddress( const tr_peerIo * io,
|
|
|
|
tr_port * port );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
const uint8_t* tr_peerIoGetTorrentHash( tr_peerIo * io );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
int tr_peerIoHasTorrentHash( const tr_peerIo * io );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-10-23 02:37:21 +00:00
|
|
|
void tr_peerIoSetTorrentHash( tr_peerIo * io,
|
2008-09-23 19:11:04 +00:00
|
|
|
const uint8_t * hash );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
int tr_peerIoReconnect( tr_peerIo * io );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2011-03-22 15:19:54 +00:00
|
|
|
static inline bool tr_peerIoIsIncoming( const tr_peerIo * io )
|
2009-01-02 19:56:06 +00:00
|
|
|
{
|
|
|
|
return io->isIncoming;
|
|
|
|
}
|
2008-01-11 02:09:20 +00:00
|
|
|
|
2010-01-01 22:26:35 +00:00
|
|
|
static inline int tr_peerIoGetAge( const tr_peerIo * io )
|
2009-01-02 17:46:22 +00:00
|
|
|
{
|
2010-10-08 13:36:33 +00:00
|
|
|
return tr_time() - io->timeCreated;
|
2009-01-02 17:46:22 +00:00
|
|
|
}
|
2007-10-11 03:54:33 +00:00
|
|
|
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
void tr_peerIoSetPeersId( tr_peerIo * io,
|
|
|
|
const uint8_t * peer_id );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2010-01-01 22:26:35 +00:00
|
|
|
static inline const uint8_t* tr_peerIoGetPeersId( const tr_peerIo * io )
|
2009-01-02 19:56:06 +00:00
|
|
|
{
|
|
|
|
assert( tr_isPeerIo( io ) );
|
|
|
|
assert( io->peerIdIsSet );
|
|
|
|
|
|
|
|
return io->peerId;
|
|
|
|
}
|
2007-09-20 16:32:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
|
|
|
|
2008-11-17 04:00:57 +00:00
|
|
|
void tr_peerIoSetIOFuncs ( tr_peerIo * io,
|
|
|
|
tr_can_read_cb readcb,
|
|
|
|
tr_did_write_cb writecb,
|
|
|
|
tr_net_error_cb errcb,
|
|
|
|
void * user_data );
|
2008-10-23 02:37:21 +00:00
|
|
|
|
2009-01-05 18:20:47 +00:00
|
|
|
void tr_peerIoClear ( tr_peerIo * io );
|
|
|
|
|
2008-11-17 04:00:57 +00:00
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
2008-10-23 02:37:21 +00:00
|
|
|
|
2010-12-20 02:07:51 +00:00
|
|
|
void tr_peerIoWriteBytes ( tr_peerIo * io,
|
2008-11-17 04:00:57 +00:00
|
|
|
const void * writeme,
|
|
|
|
size_t writemeLen,
|
2011-03-22 15:19:54 +00:00
|
|
|
bool isPieceData );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-11-17 04:00:57 +00:00
|
|
|
void tr_peerIoWriteBuf ( tr_peerIo * io,
|
|
|
|
struct evbuffer * buf,
|
2011-03-22 15:19:54 +00:00
|
|
|
bool isPieceData );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
|
|
|
|
2011-04-17 05:22:50 +00:00
|
|
|
static inline tr_crypto * tr_peerIoGetCrypto( tr_peerIo * io )
|
2009-01-02 19:56:06 +00:00
|
|
|
{
|
2011-04-17 05:22:50 +00:00
|
|
|
return &io->crypto;
|
2009-01-02 19:56:06 +00:00
|
|
|
}
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2011-03-31 16:41:52 +00:00
|
|
|
void tr_peerIoSetEncryption( tr_peerIo * io, tr_encryption_type encryption_type );
|
2008-12-16 22:08:17 +00:00
|
|
|
|
2011-03-22 15:19:54 +00:00
|
|
|
static inline bool
|
2010-06-30 16:40:19 +00:00
|
|
|
tr_peerIoIsEncrypted( const tr_peerIo * io )
|
2009-01-02 19:56:06 +00:00
|
|
|
{
|
2011-03-31 16:41:52 +00:00
|
|
|
return ( io != NULL ) && ( io->encryption_type == PEER_ENCRYPTION_RC4 );
|
2009-01-02 19:56:06 +00:00
|
|
|
}
|
2008-12-16 22:08:17 +00:00
|
|
|
|
2011-02-09 02:35:16 +00:00
|
|
|
void evbuffer_add_uint8 ( struct evbuffer * outbuf, uint8_t byte );
|
2010-12-20 02:07:51 +00:00
|
|
|
void evbuffer_add_uint16( struct evbuffer * outbuf, uint16_t hs );
|
|
|
|
void evbuffer_add_uint32( struct evbuffer * outbuf, uint32_t hl );
|
2011-03-13 00:18:11 +00:00
|
|
|
void evbuffer_add_uint64( struct evbuffer * outbuf, uint64_t hll );
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
evbuffer_add_hton_16( struct evbuffer * buf, uint16_t val )
|
|
|
|
{
|
|
|
|
evbuffer_add_uint16( buf, val );
|
|
|
|
}
|
|
|
|
static inline void
|
|
|
|
evbuffer_add_hton_32( struct evbuffer * buf, uint32_t val )
|
|
|
|
{
|
|
|
|
evbuffer_add_uint32( buf, val );
|
|
|
|
}
|
|
|
|
static inline void
|
|
|
|
evbuffer_add_hton_64( struct evbuffer * buf, uint64_t val )
|
|
|
|
{
|
|
|
|
evbuffer_add_uint64( buf, val );
|
|
|
|
}
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2011-04-04 04:45:41 +00:00
|
|
|
void tr_peerIoReadBytesToBuf( tr_peerIo * io,
|
|
|
|
struct evbuffer * inbuf,
|
|
|
|
struct evbuffer * outbuf,
|
|
|
|
size_t byteCount );
|
|
|
|
|
2009-01-22 14:32:29 +00:00
|
|
|
void tr_peerIoReadBytes( tr_peerIo * io,
|
|
|
|
struct evbuffer * inbuf,
|
|
|
|
void * bytes,
|
|
|
|
size_t byteCount );
|
2007-09-26 14:42:03 +00:00
|
|
|
|
2010-01-01 22:26:35 +00:00
|
|
|
static inline void tr_peerIoReadUint8( tr_peerIo * io,
|
2009-01-22 14:32:29 +00:00
|
|
|
struct evbuffer * inbuf,
|
|
|
|
uint8_t * setme )
|
2009-01-02 17:46:22 +00:00
|
|
|
{
|
|
|
|
tr_peerIoReadBytes( io, inbuf, setme, sizeof( uint8_t ) );
|
|
|
|
}
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2010-10-11 15:41:27 +00:00
|
|
|
void tr_peerIoReadUint16( tr_peerIo * io,
|
|
|
|
struct evbuffer * inbuf,
|
|
|
|
uint16_t * setme );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2010-10-11 15:41:27 +00:00
|
|
|
void tr_peerIoReadUint32( tr_peerIo * io,
|
|
|
|
struct evbuffer * inbuf,
|
|
|
|
uint32_t * setme );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2009-01-22 14:32:29 +00:00
|
|
|
void tr_peerIoDrain( tr_peerIo * io,
|
|
|
|
struct evbuffer * inbuf,
|
|
|
|
size_t byteCount );
|
2008-12-16 22:08:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
2007-09-26 14:42:03 +00:00
|
|
|
|
2009-01-05 04:27:54 +00:00
|
|
|
size_t tr_peerIoGetWriteBufferSpace( const tr_peerIo * io, uint64_t now );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2010-01-01 22:26:35 +00:00
|
|
|
static inline void tr_peerIoSetParent( tr_peerIo * io,
|
2009-01-24 03:17:59 +00:00
|
|
|
struct tr_bandwidth * parent )
|
2009-01-02 19:56:06 +00:00
|
|
|
{
|
|
|
|
assert( tr_isPeerIo( io ) );
|
|
|
|
|
|
|
|
tr_bandwidthSetParent( &io->bandwidth, parent );
|
|
|
|
}
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-12-16 22:08:17 +00:00
|
|
|
void tr_peerIoBandwidthUsed( tr_peerIo * io,
|
|
|
|
tr_direction direction,
|
|
|
|
size_t byteCount,
|
|
|
|
int isPieceData );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2011-03-22 15:19:54 +00:00
|
|
|
static inline bool
|
2010-07-03 00:25:22 +00:00
|
|
|
tr_peerIoHasBandwidthLeft( const tr_peerIo * io, tr_direction dir )
|
2009-01-02 19:56:06 +00:00
|
|
|
{
|
2011-01-13 01:58:57 +00:00
|
|
|
return tr_bandwidthClamp( &io->bandwidth, dir, 1024 ) > 0;
|
2009-01-02 19:56:06 +00:00
|
|
|
}
|
|
|
|
|
2010-07-03 00:25:22 +00:00
|
|
|
static inline unsigned int
|
|
|
|
tr_peerIoGetPieceSpeed_Bps( const tr_peerIo * io, uint64_t now, tr_direction dir )
|
2009-01-02 19:56:06 +00:00
|
|
|
{
|
2010-07-03 00:25:22 +00:00
|
|
|
return tr_bandwidthGetPieceSpeed_Bps( &io->bandwidth, now, dir );
|
2009-01-02 19:56:06 +00:00
|
|
|
}
|
2009-01-02 17:46:22 +00:00
|
|
|
|
2008-09-17 19:44:24 +00:00
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
|
|
|
|
2008-12-20 22:19:34 +00:00
|
|
|
void tr_peerIoSetEnabled( tr_peerIo * io,
|
|
|
|
tr_direction dir,
|
2011-03-22 15:19:54 +00:00
|
|
|
bool isEnabled );
|
2009-08-12 14:40:32 +00:00
|
|
|
|
2009-01-19 14:05:43 +00:00
|
|
|
int tr_peerIoFlush( tr_peerIo * io,
|
2008-12-16 22:08:17 +00:00
|
|
|
tr_direction dir,
|
|
|
|
size_t byteLimit );
|
2008-09-17 19:44:24 +00:00
|
|
|
|
2009-04-21 16:18:51 +00:00
|
|
|
int tr_peerIoFlushOutgoingProtocolMsgs( tr_peerIo * io );
|
|
|
|
|
2009-01-02 17:46:22 +00:00
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
2008-09-17 19:44:24 +00:00
|
|
|
|
2010-01-01 22:26:35 +00:00
|
|
|
static inline struct evbuffer * tr_peerIoGetReadBuffer( tr_peerIo * io )
|
2009-01-02 17:46:22 +00:00
|
|
|
{
|
|
|
|
return io->inbuf;
|
|
|
|
}
|
2008-11-25 21:35:17 +00:00
|
|
|
|
2009-05-29 19:17:12 +00:00
|
|
|
/* @} */
|
2007-09-20 16:32:01 +00:00
|
|
|
|
|
|
|
#endif
|