Added DSCP support

This commit is contained in:
Alexander Amanuel 2014-01-24 23:50:51 +04:00
parent f2fa24b418
commit 924feb12b0
8 changed files with 27 additions and 0 deletions

View File

@ -730,6 +730,15 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->addTag(TAG_ADVANCED);
handlers.push_back(op);
}
{
OptionHandler* op(new NumberOptionHandler
(PREF_DSCP,
TEXT_DSCP,
"0",
0));
op->addTag(TAG_ADVANCED);
handlers.push_back(op);
}
{
OptionHandler* op(new BooleanOptionHandler
(PREF_SELECT_LEAST_USED_HOST,

View File

@ -41,6 +41,7 @@
#include "prefs.h"
#include "SocketCore.h"
#include "Logger.h"
#include "Option.h"
#include "LogFactory.h"
#include "Peer.h"
#include "BtRuntime.h"
@ -83,6 +84,7 @@ bool PeerInitiateConnectionCommand::executeInternal() {
createSocket();
getSocket()->establishConnection(getPeer()->getIPAddress(),
getPeer()->getPort(), false);
getSocket()->setIpDscp(requestGroup_->getOption()->getAsInt(PREF_DSCP));
if(mseHandshakeEnabled_) {
auto c = make_unique<InitiatorMSEHandshakeCommand>
(getCuid(), requestGroup_, getPeer(),

View File

@ -44,6 +44,7 @@
#include "message.h"
#include "ReceiverMSEHandshakeCommand.h"
#include "Logger.h"
#include "Option.h"
#include "LogFactory.h"
#include "SocketCore.h"
#include "SimpleRandomizer.h"
@ -110,6 +111,7 @@ bool PeerListenCommand::execute() {
std::shared_ptr<SocketCore> peerSocket;
try {
peerSocket = socket_->acceptConnection();
peerSocket->setIpDscp(e_->getOption()->getAsInt(PREF_DSCP));
std::pair<std::string, uint16_t> peerInfo;
peerSocket->getPeerInfo(peerInfo);

View File

@ -532,6 +532,11 @@ void SocketCore::setTcpNodelay(bool f)
setSockOpt(IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
}
void SocketCore::setIpDscp(int32_t dscp)
{
setSockOpt(IPPROTO_IP, IP_TOS, &dscp, sizeof(dscp));
}
void SocketCore::setNonBlockingMode()
{
#ifdef __MINGW32__

View File

@ -120,6 +120,9 @@ public:
// Enables TCP_NODELAY socket option if f == true.
void setTcpNodelay(bool f);
// Set DSCP byte
void setIpDscp(int32_t);
void create(int family, int protocol = 0);
void bindWithFamily(uint16_t port, int family, int flags = AI_PASSIVE);

View File

@ -358,6 +358,8 @@ PrefPtr PREF_DISK_CACHE = makePref("disk-cache");
PrefPtr PREF_GID = makePref("gid");
// values: 1*digit
PrefPtr PREF_SAVE_SESSION_INTERVAL = makePref("save-session-interval");
// values: 1*digit
PrefPtr PREF_DSCP = makePref("dscp");
/**
* FTP related preferences

View File

@ -294,6 +294,8 @@ extern PrefPtr PREF_DISK_CACHE;
extern PrefPtr PREF_GID;
// values: 1*digit
extern PrefPtr PREF_SAVE_SESSION_INTERVAL;
// values: 1*digit
extern PrefPtr PREF_DSCP;
/**
* FTP related preferences

View File

@ -958,3 +958,5 @@
" specified by --save-session option every SEC\n" \
" seconds. If 0 is given, file will be saved only\n" \
" when aria2 exits.")
#define TEXT_DSCP \
_(" --dscp=DSCP Set DSCP code")