(libT) janitorial: use the tr_port type whenever we have a `port' as a function argument or as a field in a struct.
This commit is contained in:
parent
7fa9813955
commit
a14621c363
|
@ -471,9 +471,9 @@ tr_fdSocketCreate( int type )
|
|||
}
|
||||
|
||||
int
|
||||
tr_fdSocketAccept( int b,
|
||||
struct in_addr * addr,
|
||||
tr_port_t * port )
|
||||
tr_fdSocketAccept( int b,
|
||||
struct in_addr * addr,
|
||||
tr_port * port )
|
||||
{
|
||||
int s = -1;
|
||||
unsigned int len;
|
||||
|
|
|
@ -87,9 +87,9 @@ void tr_fdFileClose( const char * filename );
|
|||
**********************************************************************/
|
||||
int tr_fdSocketCreate( int type );
|
||||
|
||||
int tr_fdSocketAccept( int b,
|
||||
struct in_addr * addr,
|
||||
tr_port_t * port );
|
||||
int tr_fdSocketAccept( int b,
|
||||
struct in_addr * addr,
|
||||
tr_port * port );
|
||||
|
||||
void tr_fdSocketClose( int s );
|
||||
|
||||
|
|
|
@ -1198,7 +1198,7 @@ tr_handshakeGetIO( tr_handshake * handshake )
|
|||
|
||||
const struct in_addr *
|
||||
tr_handshakeGetAddr( const struct tr_handshake * handshake,
|
||||
uint16_t * port )
|
||||
tr_port * port )
|
||||
{
|
||||
assert( handshake );
|
||||
assert( handshake->io );
|
||||
|
|
|
@ -35,10 +35,8 @@ tr_handshake * tr_handshakeNew( struct tr_peerIo * io,
|
|||
handshakeDoneCB doneCB,
|
||||
void * doneUserData );
|
||||
|
||||
const struct in_addr * tr_handshakeGetAddr(
|
||||
const struct tr_handshake * handshake,
|
||||
uint16_t
|
||||
* setme_port );
|
||||
const struct in_addr * tr_handshakeGetAddr( const struct tr_handshake * handshake,
|
||||
tr_port * port );
|
||||
|
||||
void tr_handshakeAbort( tr_handshake * handshake );
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ setSndBuf( tr_session * session UNUSED, int fd UNUSED )
|
|||
int
|
||||
tr_netOpenTCP( tr_session * session,
|
||||
const struct in_addr * addr,
|
||||
tr_port_t port )
|
||||
tr_port port )
|
||||
{
|
||||
int s;
|
||||
struct sockaddr_in sock;
|
||||
|
@ -162,10 +162,8 @@ tr_netOpenTCP( tr_session * session,
|
|||
#endif
|
||||
&& ( sockerrno != EINPROGRESS ) )
|
||||
{
|
||||
tr_err( _(
|
||||
"Couldn't connect socket %d to %s, port %d (errno %d - %s)" ),
|
||||
s, inet_ntoa( *addr ), port,
|
||||
sockerrno, tr_strerror( sockerrno ) );
|
||||
tr_err( _( "Couldn't connect socket %d to %s, port %d (errno %d - %s)" ),
|
||||
s, inet_ntoa( *addr ), (int)port, sockerrno, tr_strerror( sockerrno ) );
|
||||
tr_netClose( s );
|
||||
s = -1;
|
||||
}
|
||||
|
@ -217,7 +215,7 @@ int
|
|||
tr_netAccept( tr_session * session,
|
||||
int b,
|
||||
struct in_addr * addr,
|
||||
tr_port_t * port )
|
||||
tr_port * port )
|
||||
{
|
||||
int fd = makeSocketNonBlocking( tr_fdSocketAccept( b, addr, port ) );
|
||||
setSndBuf( session, fd );
|
||||
|
|
|
@ -33,18 +33,15 @@
|
|||
#include <inttypes.h>
|
||||
#include <winsock2.h>
|
||||
typedef int socklen_t;
|
||||
typedef uint16_t tr_port_t;
|
||||
#elif defined( __BEOS__ )
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
typedef unsigned short tr_port_t;
|
||||
typedef int socklen_t;
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
typedef in_port_t tr_port_t;
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -76,14 +73,14 @@ int tr_netResolve( const char *,
|
|||
**********************************************************************/
|
||||
int tr_netOpenTCP( struct tr_handle * session,
|
||||
const struct in_addr * addr,
|
||||
tr_port_t port );
|
||||
tr_port port );
|
||||
|
||||
int tr_netBindTCP( int port );
|
||||
|
||||
int tr_netAccept( struct tr_handle * session,
|
||||
int bound,
|
||||
struct in_addr * setme_addr,
|
||||
tr_port_t * setme_port );
|
||||
tr_port * setme_port );
|
||||
|
||||
int tr_netSetTOS( int s,
|
||||
int tos );
|
||||
|
|
|
@ -89,7 +89,7 @@ struct tr_peerIo
|
|||
|
||||
uint8_t encryptionMode;
|
||||
uint8_t timeout;
|
||||
uint16_t port;
|
||||
tr_port port;
|
||||
int socket;
|
||||
|
||||
uint8_t peerId[20];
|
||||
|
@ -240,7 +240,7 @@ isPeerIo( const tr_peerIo * io )
|
|||
static tr_peerIo*
|
||||
tr_peerIoNew( tr_session * session,
|
||||
const struct in_addr * in_addr,
|
||||
uint16_t port,
|
||||
tr_port port,
|
||||
const uint8_t * torrentHash,
|
||||
int isIncoming,
|
||||
int socket )
|
||||
|
@ -268,7 +268,7 @@ tr_peerIoNew( tr_session * session,
|
|||
tr_peerIo*
|
||||
tr_peerIoNewIncoming( tr_session * session,
|
||||
const struct in_addr * in_addr,
|
||||
uint16_t port,
|
||||
tr_port port,
|
||||
int socket )
|
||||
{
|
||||
assert( session );
|
||||
|
@ -338,7 +338,7 @@ tr_peerIoGetSession( tr_peerIo * io )
|
|||
|
||||
const struct in_addr*
|
||||
tr_peerIoGetAddress( const tr_peerIo * io,
|
||||
uint16_t * port )
|
||||
tr_port * port )
|
||||
{
|
||||
assert( isPeerIo( io ) );
|
||||
|
||||
|
@ -350,7 +350,7 @@ tr_peerIoGetAddress( const tr_peerIo * io,
|
|||
|
||||
const char*
|
||||
tr_peerIoAddrStr( const struct in_addr * addr,
|
||||
uint16_t port )
|
||||
tr_port port )
|
||||
{
|
||||
static char buf[512];
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ tr_peerIo* tr_peerIoNewOutgoing( struct tr_handle * session,
|
|||
|
||||
tr_peerIo* tr_peerIoNewIncoming( struct tr_handle * session,
|
||||
const struct in_addr * addr,
|
||||
uint16_t port,
|
||||
tr_port port,
|
||||
int socket );
|
||||
|
||||
void tr_peerIoFree( tr_peerIo * io );
|
||||
|
@ -60,12 +60,12 @@ int tr_peerIoSupportsLTEP( const tr_peerIo * io );
|
|||
**/
|
||||
|
||||
const char* tr_peerIoAddrStr( const struct in_addr * addr,
|
||||
uint16_t port );
|
||||
tr_port port );
|
||||
|
||||
const char* tr_peerIoGetAddrStr( const tr_peerIo * io );
|
||||
|
||||
const struct in_addr*tr_peerIoGetAddress( const tr_peerIo * io,
|
||||
uint16_t * port );
|
||||
tr_port * port );
|
||||
|
||||
const uint8_t* tr_peerIoGetTorrentHash( tr_peerIo * io );
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ typedef struct tr_peer
|
|||
uint8_t strikes;
|
||||
|
||||
uint8_t encryption_preference;
|
||||
uint16_t port;
|
||||
tr_port port;
|
||||
struct in_addr in_addr;
|
||||
struct tr_peerIo * io;
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ struct peer_atom
|
|||
uint8_t from;
|
||||
uint8_t flags; /* these match the added_f flags */
|
||||
uint8_t myflags; /* flags that aren't defined in added_f */
|
||||
uint16_t port;
|
||||
tr_port port;
|
||||
uint16_t numFails;
|
||||
struct in_addr addr;
|
||||
time_t time; /* when the peer's connection status last changed */
|
||||
|
@ -1113,7 +1113,7 @@ peerCallbackFunc( void * vpeer,
|
|||
static void
|
||||
ensureAtomExists( Torrent * t,
|
||||
const struct in_addr * addr,
|
||||
uint16_t port,
|
||||
tr_port port,
|
||||
uint8_t flags,
|
||||
uint8_t from )
|
||||
{
|
||||
|
@ -1154,7 +1154,7 @@ myHandshakeDoneCB( tr_handshake * handshake,
|
|||
{
|
||||
int ok = isConnected;
|
||||
int success = FALSE;
|
||||
uint16_t port;
|
||||
tr_port port;
|
||||
const struct in_addr * addr;
|
||||
tr_peerMgr * manager = (tr_peerMgr*) vmanager;
|
||||
Torrent * t;
|
||||
|
@ -1255,7 +1255,7 @@ myHandshakeDoneCB( tr_handshake * handshake,
|
|||
void
|
||||
tr_peerMgrAddIncoming( tr_peerMgr * manager,
|
||||
struct in_addr * addr,
|
||||
uint16_t port,
|
||||
tr_port port,
|
||||
int socket )
|
||||
{
|
||||
managerLock( manager );
|
||||
|
|
|
@ -43,7 +43,7 @@ enum
|
|||
typedef struct tr_pex
|
||||
{
|
||||
struct in_addr in_addr;
|
||||
uint16_t port;
|
||||
tr_port port;
|
||||
uint8_t flags;
|
||||
}
|
||||
tr_pex;
|
||||
|
@ -60,7 +60,7 @@ int tr_peerMgrPeerIsSeed( const tr_peerMgr * mgr,
|
|||
|
||||
void tr_peerMgrAddIncoming( tr_peerMgr * manager,
|
||||
struct in_addr * addr,
|
||||
uint16_t port,
|
||||
tr_port port,
|
||||
int socket );
|
||||
|
||||
tr_pex * tr_peerMgrCompactToPex( const void * compact,
|
||||
|
|
|
@ -139,7 +139,7 @@ incomingPeersPulse( tr_shared * s )
|
|||
for( ; ; ) /* check for new incoming peer connections */
|
||||
{
|
||||
int socket;
|
||||
uint16_t port;
|
||||
tr_port port;
|
||||
struct in_addr addr;
|
||||
|
||||
if( s->bindSocket < 0 )
|
||||
|
|
|
@ -50,7 +50,7 @@ struct tr_rpc_server
|
|||
tr_bool isEnabled;
|
||||
tr_bool isPasswordEnabled;
|
||||
tr_bool isWhitelistEnabled;
|
||||
uint16_t port;
|
||||
tr_port port;
|
||||
struct evhttp * httpd;
|
||||
tr_handle * session;
|
||||
char * username;
|
||||
|
@ -566,7 +566,7 @@ restartServer( void * vserver )
|
|||
|
||||
void
|
||||
tr_rpcSetPort( tr_rpc_server * server,
|
||||
uint16_t port )
|
||||
tr_port port )
|
||||
{
|
||||
if( server->port != port )
|
||||
{
|
||||
|
@ -577,7 +577,7 @@ tr_rpcSetPort( tr_rpc_server * server,
|
|||
}
|
||||
}
|
||||
|
||||
uint16_t
|
||||
tr_port
|
||||
tr_rpcGetPort( const tr_rpc_server * server )
|
||||
{
|
||||
return server->port;
|
||||
|
@ -684,7 +684,7 @@ tr_rpcClose( tr_rpc_server ** ps )
|
|||
tr_rpc_server *
|
||||
tr_rpcInit( tr_handle * session,
|
||||
int isEnabled,
|
||||
uint16_t port,
|
||||
tr_port port,
|
||||
int isWhitelistEnabled,
|
||||
const char * whitelist,
|
||||
int isPasswordEnabled,
|
||||
|
|
|
@ -21,7 +21,7 @@ typedef struct tr_rpc_server tr_rpc_server;
|
|||
|
||||
tr_rpc_server * tr_rpcInit( struct tr_handle * session,
|
||||
int isEnabled,
|
||||
uint16_t port,
|
||||
tr_port port,
|
||||
int isWhitelistEnabled,
|
||||
const char * whitelist,
|
||||
int isPasswordEnabled,
|
||||
|
@ -36,9 +36,9 @@ void tr_rpcSetEnabled( tr_rpc_server * server,
|
|||
int tr_rpcIsEnabled( const tr_rpc_server * server );
|
||||
|
||||
void tr_rpcSetPort( tr_rpc_server * server,
|
||||
uint16_t port );
|
||||
tr_port port );
|
||||
|
||||
uint16_t tr_rpcGetPort( const tr_rpc_server * server );
|
||||
tr_port tr_rpcGetPort( const tr_rpc_server * server );
|
||||
|
||||
int tr_rpcSetTest( const tr_rpc_server * server,
|
||||
const char * whitelist,
|
||||
|
|
|
@ -215,7 +215,7 @@ tr_sessionInitFull( const char * configDir,
|
|||
int isBlocklistEnabled,
|
||||
int peerSocketTOS,
|
||||
int rpcIsEnabled,
|
||||
uint16_t rpcPort,
|
||||
tr_port rpcPort,
|
||||
int rpcWhitelistIsEnabled,
|
||||
const char * rpcWhitelist,
|
||||
int rpcAuthIsEnabled,
|
||||
|
@ -975,12 +975,12 @@ tr_sessionIsRPCEnabled( const tr_session * session )
|
|||
|
||||
void
|
||||
tr_sessionSetRPCPort( tr_session * session,
|
||||
uint16_t port )
|
||||
tr_port port )
|
||||
{
|
||||
tr_rpcSetPort( session->rpcServer, port );
|
||||
}
|
||||
|
||||
uint16_t
|
||||
tr_port
|
||||
tr_sessionGetRPCPort( const tr_session * session )
|
||||
{
|
||||
return tr_rpcGetPort( session->rpcServer );
|
||||
|
|
|
@ -293,7 +293,7 @@ parseOldPeers( tr_benc * bePeers,
|
|||
const char * s;
|
||||
int64_t itmp;
|
||||
struct in_addr addr;
|
||||
tr_port_t port;
|
||||
tr_port port;
|
||||
tr_benc * peer = &bePeers->val.l.vals[i];
|
||||
|
||||
if( !tr_bencDictFindStr( peer, "ip",
|
||||
|
|
|
@ -55,6 +55,7 @@ extern "C" {
|
|||
typedef uint32_t tr_file_index_t;
|
||||
typedef uint32_t tr_piece_index_t;
|
||||
typedef uint64_t tr_block_index_t;
|
||||
typedef uint16_t tr_port;
|
||||
typedef uint8_t tr_bool;
|
||||
|
||||
/**
|
||||
|
@ -279,7 +280,7 @@ tr_session * tr_sessionInitFull( const char * configDir,
|
|||
int isBlocklistEnabled,
|
||||
int peerSocketTOS,
|
||||
int rpcIsEnabled,
|
||||
uint16_t rpcPort,
|
||||
tr_port rpcPort,
|
||||
int rpcWhitelistIsEnabled,
|
||||
const char * rpcWhitelist,
|
||||
int rpcPasswordIsEnabled,
|
||||
|
@ -349,12 +350,12 @@ int tr_sessionIsRPCEnabled( const tr_session * session );
|
|||
@see tr_sessionInitFull()
|
||||
@see tr_sessionGetRPCPort */
|
||||
void tr_sessionSetRPCPort( tr_session * session,
|
||||
uint16_t port );
|
||||
tr_port port );
|
||||
|
||||
/** @brief Get which port to listen for RPC requests on.
|
||||
@see tr_sessionInitFull()
|
||||
@see tr_sessionSetRPCPort */
|
||||
uint16_t tr_sessionGetRPCPort( const tr_session * session );
|
||||
tr_port tr_sessionGetRPCPort( const tr_session * session );
|
||||
|
||||
/**
|
||||
* @brief Specify a whitelist for remote RPC access
|
||||
|
@ -1059,7 +1060,7 @@ typedef struct tr_peer_stat
|
|||
tr_bool isIncoming;
|
||||
|
||||
uint8_t from;
|
||||
uint16_t port;
|
||||
tr_port port;
|
||||
|
||||
char addr[16];
|
||||
char client[80];
|
||||
|
|
Loading…
Reference in New Issue