#857: DSCP support for Transmission

This commit is contained in:
Charles Kerr
2008-04-12 00:29:49 +00:00
parent f12ac60d0a
commit 57c7fcb507
11 changed files with 65 additions and 31 deletions
+15 -14
View File
@@ -145,20 +145,21 @@ main( int argc, char ** argv )
bindPort = -1;
/* Initialize libtransmission */
h = tr_initFull( tr_getDefaultConfigDir(),
"cli", /* tag */
1, /* pex enabled */
natTraversal, /* nat enabled */
bindPort, /* public port */
TR_ENCRYPTION_PREFERRED, /* encryption mode */
uploadLimit >= 0, /* use upload speed limit? */
uploadLimit, /* upload speed limit */
downloadLimit >= 0, /* use download speed limit? */
downloadLimit, /* download speed limit */
512, /* globalPeerLimit */
verboseLevel + 1, /* messageLevel */
0, /* is message queueing enabled? */
0 ); /* use the blocklist? */
h = tr_initFull( TR_DEFAULT_CONFIG_DIR,
"cli", /* tag */
1, /* pex enabled */
natTraversal, /* nat enabled */
bindPort, /* public port */
TR_ENCRYPTION_PREFERRED, /* encryption mode */
uploadLimit >= 0, /* use upload speed limit? */
uploadLimit, /* upload speed limit */
downloadLimit >= 0, /* use download speed limit? */
downloadLimit, /* download speed limit */
TR_DEFAULT_GLOBAL_PEER_LIMIT,
verboseLevel + 1, /* messageLevel */
0, /* is message queueing enabled? */
0, /* use the blocklist? */
TR_DEFAULT_PEER_SOCKET_TOS );
if( sourceFile && *sourceFile ) /* creating a torrent */
{
+2 -1
View File
@@ -494,7 +494,8 @@ tr_core_init( GTypeInstance * instance, gpointer g_class UNUSED )
pref_int_get( PREF_KEY_MAX_PEERS_GLOBAL ),
pref_int_get( PREF_KEY_MSGLEVEL ),
TRUE, /* message queueing */
pref_flag_get( PREF_KEY_BLOCKLIST_ENABLED ) );
pref_flag_get( PREF_KEY_BLOCKLIST_ENABLED ),
pref_int_get( PREF_KEY_PEER_SOCKET_TOS ) );
/* create the model used to store torrent data */
g_assert( ALEN( types ) == MC_ROW_COUNT );
+4 -2
View File
@@ -42,11 +42,13 @@ tr_prefs_init_global( void )
pref_flag_set_default ( PREF_KEY_DIR_WATCH_ENABLED, FALSE );
#endif
pref_int_set_default ( PREF_KEY_PEER_SOCKET_TOS, TR_DEFAULT_PEER_SOCKET_TOS );
pref_flag_set_default ( PREF_KEY_BLOCKLIST_ENABLED, FALSE );
pref_string_set_default ( PREF_KEY_OPEN_DIALOG_FOLDER, g_get_home_dir( ) );
pref_int_set_default ( PREF_KEY_MAX_PEERS_GLOBAL, 200 );
pref_int_set_default ( PREF_KEY_MAX_PEERS_GLOBAL, TR_DEFAULT_GLOBAL_PEER_LIMIT );
pref_int_set_default ( PREF_KEY_MAX_PEERS_PER_TORRENT, 50 );
pref_flag_set_default ( PREF_KEY_TOOLBAR, TRUE );
@@ -70,7 +72,7 @@ tr_prefs_init_global( void )
pref_int_set_default ( PREF_KEY_PORT, TR_DEFAULT_PORT );
pref_flag_set_default ( PREF_KEY_NAT, TRUE );
pref_flag_set_default ( PREF_KEY_PEX, TRUE );
pref_flag_set_default ( PREF_KEY_PEX, TR_DEFAULT_PEX_ENABLED );
pref_flag_set_default ( PREF_KEY_ASKQUIT, TRUE );
pref_flag_set_default ( PREF_KEY_ENCRYPTED_ONLY, FALSE );
+1
View File
@@ -31,6 +31,7 @@ GtkWidget * tr_prefs_dialog_new( GObject * core, GtkWindow * parent );
#define PREF_KEY_DIR_WATCH_ENABLED "watch-folder-enabled"
#define PREF_KEY_START "start-added-torrents"
#define PREF_KEY_TRASH_ORIGINAL "trash-original-torrent-files"
#define PREF_KEY_PEER_SOCKET_TOS "peer-socket-tos"
#define PREF_KEY_PORT "listening-port"
#define PREF_KEY_NAT "nat-traversal-enabled"
#define PREF_KEY_PEX "pex-enabled"
+10
View File
@@ -79,6 +79,16 @@ int tr_netResolve( const char * address, struct in_addr * addr )
* TCP/UDP sockets
**********************************************************************/
int
tr_netSetTOS( int s, int tos )
{
#ifdef IP_TOS
return setsockopt( s, IPPROTO_IP, IP_TOS, (char*)&tos, sizeof( tos ) );
#else
return 0;
#endif
}
static int
makeSocketNonBlocking( int fd )
{
+1
View File
@@ -73,6 +73,7 @@ int tr_netOpenUDP ( const struct in_addr * addr, tr_port_t port, int priority
int tr_netBindTCP ( int port );
int tr_netBindUDP ( int port );
int tr_netAccept ( int s, struct in_addr *, tr_port_t * );
int tr_netSetTOS ( int s, int tos );
void tr_netClose ( int s );
#define TR_NET_BLOCK 0x80000000
+6
View File
@@ -139,6 +139,10 @@ tr_peerIoNew( struct tr_handle * handle,
int socket )
{
tr_peerIo * c;
if( socket >= 0 )
tr_netSetTOS( socket, handle->peerSocketTOS );
c = tr_new0( tr_peerIo, 1 );
c->crypto = tr_cryptoNew( torrentHash, isIncoming );
c->handle = handle;
@@ -292,6 +296,8 @@ tr_peerIoReconnect( tr_peerIo * io )
if( io->socket >= 0 )
{
tr_netSetTOS( io->socket, io->handle->peerSocketTOS );
bufferevent_free( io->bufev );
io->bufev = bufferevent_new( io->socket,
+11 -8
View File
@@ -1,5 +1,5 @@
/******************************************************************************
* $Id:$
* $Id$
*
* Copyright (c) 2005-2008 Transmission authors and contributors
*
@@ -117,7 +117,7 @@ tr_handle *
tr_initFull( const char * configDir,
const char * tag,
int isPexEnabled,
int isNatEnabled,
int isPortForwardingEnabled,
int publicPort,
int encryptionMode,
int isUploadLimitEnabled,
@@ -127,7 +127,8 @@ tr_initFull( const char * configDir,
int globalPeerLimit,
int messageLevel,
int isMessageQueueingEnabled,
int isBlocklistEnabled )
int isBlocklistEnabled,
int peerSocketTOS )
{
tr_handle * h;
char filename[MAX_PATH_LENGTH];
@@ -149,6 +150,7 @@ tr_initFull( const char * configDir,
h->isPexEnabled = isPexEnabled ? 1 : 0;
h->encryptionMode = encryptionMode;
h->configDir = tr_strdup( configDir );
h->peerSocketTOS = peerSocketTOS;
tr_setConfigDir( h, configDir );
@@ -177,7 +179,7 @@ tr_initFull( const char * configDir,
h->useDownloadLimit = isDownloadLimitEnabled;
tr_fdInit( globalPeerLimit );
h->shared = tr_sharedInit( h, isNatEnabled, publicPort );
h->shared = tr_sharedInit( h, isPortForwardingEnabled, publicPort );
h->isPortSet = publicPort >= 0;
/* first %s is the application name
@@ -201,18 +203,19 @@ tr_init( const char * configDir,
{
return tr_initFull( configDir,
tag,
TRUE, /* pex enabled */
FALSE, /* nat enabled */
TR_DEFAULT_PEX_ENABLED,
TR_DEFAULT_PORT_FORWARDING_ENABLED,
-1, /* public port */
TR_ENCRYPTION_PREFERRED, /* encryption mode */
FALSE, /* use upload speed limit? */
-1, /* upload speed limit */
FALSE, /* use download speed limit? */
-1, /* download speed limit */
200, /* globalPeerLimit */
TR_DEFAULT_GLOBAL_PEER_LIMIT,
TR_MSG_INF, /* message level */
FALSE, /* is message queueing enabled? */
FALSE ); /* is the blocklist enabled? */
FALSE, /* is the blocklist enabled? */
TR_DEFAULT_PEER_SOCKET_TOS );
}
/***
+3 -1
View File
@@ -1,5 +1,5 @@
/******************************************************************************
* $Id:$
* $Id$
*
* Copyright (c) 2005-2008 Transmission authors and contributors
*
@@ -65,6 +65,8 @@ struct tr_handle
struct tr_event_handle * events;
int peerSocketTOS;
int torrentCount;
tr_torrent * torrentList;
+10 -4
View File
@@ -48,8 +48,6 @@ extern "C" {
# define MAX_PATH_LENGTH 1024
#endif
#define TR_DEFAULT_PORT 51413
typedef uint32_t tr_file_index_t;
typedef uint32_t tr_piece_index_t;
typedef uint64_t tr_block_index_t;
@@ -78,10 +76,17 @@ typedef struct tr_handle tr_handle;
const char* tr_getDefaultConfigDir( void );
#define TR_DEFAULT_CONFIG_DIR tr_getDefaultConfigDir()
#define TR_DEFAULT_PEX_ENABLED 1
#define TR_DEFAULT_PORT_FORWARDING_ENABLED 0
#define TR_DEFAULT_PORT 51413
#define TR_DEFAULT_GLOBAL_PEER_LIMIT 200
#define TR_DEFAULT_PEER_SOCKET_TOS 8
tr_handle * tr_initFull( const char * configDir,
const char * tag,
int isPexEnabled,
int isNatEnabled,
int isPortForwardingEnabled,
int publicPort,
int encryptionMode,
int isUploadLimitEnabled,
@@ -91,7 +96,8 @@ tr_handle * tr_initFull( const char * configDir,
int globalPeerLimit,
int messageLevel,
int isMessageQueueingEnabled,
int isBlocklistEnabled );
int isBlocklistEnabled,
int peerSocketTOS );
/**
* Like tr_initFull() but with default values supplied.
+2 -1
View File
@@ -208,7 +208,8 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
[fDefaults integerForKey: @"PeersTotal"],
[fDefaults integerForKey: @"MessageLevel"],
YES,
[fDefaults boolForKey: @"Blocklist"]);
[fDefaults boolForKey: @"Blocklist"],
TR_DEFAULT_PEER_SOCKET_TOS );
[NSApp setDelegate: self];