Commit 0475bcef authored by Ryan Jackson's avatar Ryan Jackson

The linux backend now works on the 2.4 kernel, and should work on the 2.6...

The linux backend now works on the 2.4 kernel, and should work on the 2.6 kernel once the bugs in the modules for it are fixed.
parent a407c995
......@@ -214,10 +214,6 @@ extern "C"
using namespace std;
struct rtnl_class * rtnl_class_get(struct nl_cache *, uint32_t);
/* extern int rtnl_delay_set_delay(struct rtnl_qdisc *, unsigned long); */
NetlinkPipe::NetlinkPipe(std::string const & iface, std::string const & pipeno)
{
interfaceName = iface;
......@@ -227,6 +223,14 @@ NetlinkPipe::NetlinkPipe(std::string const & iface, std::string const & pipeno)
qdisc_cache = NULL;
init();
/* test(); */
}
void NetlinkPipe::test(void)
{
Parameter testParam(Parameter::LOSS, 50000);
updateParameter(testParam);
}
int NetlinkPipe::init(void)
......@@ -237,6 +241,10 @@ int NetlinkPipe::init(void)
link_cache = NULL;
cerr << "Got pipe number " << pipeNumber << endl;
handle = hexStringToInt(pipeNumber);
cerr << "handle: " << handle << endl;
nl_handle = nl_handle_alloc();
if (nl_handle == NULL) {
cerr << "Unable to allocate nl_handle" << endl;
......@@ -265,18 +273,20 @@ int NetlinkPipe::init(void)
cerr << "Unable to allocate qdisc cache" << endl;
return -1;
}
plrHandle = handle << 16;
delayHandle = (handle + 0x10) << 16;
htbHandle = (handle + 0x20) << 16;
class_cache = rtnl_class_alloc_cache(nl_handle, ifindex);
if (class_cache == NULL) {
cerr << "Unable to allocate class cache" << endl;
return -1;
}
handle = stringToInt(pipeNumber);
plrHandle = handle << 16;
delayHandle = (handle + 10) << 16;
htbHandle = (handle + 20) << 16;
htbClassHandle = htbHandle + 1;
return 0;
}
......@@ -324,24 +334,27 @@ void NetlinkPipe::updateParameter(Parameter const & newParameter)
}
rtnl_htb_set_rate(htbClass, newParameter.getValue());
rtnl_htb_set_ceil(htbClass, newParameter.getValue());
nl_object_put((nl_object *)htbClass);
rtnl_class_change(nl_handle, htbClass, NULL);
rtnl_class_put(htbClass);
break;
case Parameter::DELAY:
qdisc = rtnl_qdisc_get(qdisc_cache, ifindex, delayHandle);
if (qdisc == NULL) {
cerr << "Couldn't find htb class " << delayHandle << endl;
cerr << "Couldn't find delay qdisc " << delayHandle << endl;
return;
}
rtnl_delay_set_delay(qdisc, newParameter.getValue());
rtnl_qdisc_change(nl_handle, qdisc, NULL);
rtnl_qdisc_put(qdisc);
break;
case Parameter::LOSS:
qdisc = rtnl_qdisc_get(qdisc_cache, ifindex, plrHandle);
if (qdisc == NULL) {
cerr << "Couldn't find htb class " << delayHandle << endl;
cerr << "Couldn't find plr qdisc " << plrHandle << endl;
return;
}
rtnl_plr_set_plr(qdisc, newParameter.getValue());
rtnl_qdisc_change(nl_handle, qdisc, NULL);
rtnl_qdisc_put(qdisc);
break;
default:
......
......@@ -41,6 +41,8 @@ private:
#ifndef NETLINK_PIPE_HH_DELAY_AGENT_1
#define NETLINK_PIPE_HH_DELAY_AGENT_1
#include <stdint.h>
class NetlinkPipe : public RootPipe
{
public:
......@@ -53,6 +55,7 @@ public:
private:
virtual void updateParameter(Parameter const & newParameter);
virtual int init(void);
virtual void test(void);
std::string interfaceName;
std::string pipeNumber;
......
......@@ -16,8 +16,8 @@ CXXFLAGS += -DFREEBSD
endif
ifeq ($(OS), Linux)
CXXFLAGS += -DLINUX -I../../../../libnl-1.1/include
LDFLAGS += -L../../../../libnl-1.1/lib -lnl
CXXFLAGS += -DLINUX -I../../../../libnl/include
LDFLAGS += -L../../../../libnl/lib -lnl
endif
CFLAGS = $(CXXFLAGS)
......
......@@ -5,6 +5,7 @@
#include "Pipe.hh"
#include "EventPipe.hh"
#include "DummynetPipe.hh"
// Each pipe here is uni-directional. Multiple directions are
// accounted for with multiple pipes.
......@@ -22,7 +23,11 @@ struct PipeInfo
, parameters(g::defaultParameters)
, interface(newInterface)
, pipeData(newPipeData)
#if 0
, rawPipe(new EventPipe(linkName))
#else
, rawPipe(new NetlinkPipe(newInterface, newPipeData))
#endif
{
}
......
......@@ -26,6 +26,14 @@ int stringToInt(std::string const & val)
return result;
}
int hexStringToInt(std::string const & val)
{
int result = 0;
istringstream stream(val);
stream >> std::hex >> result;
return result;
}
string intToString(int val)
{
ostringstream stream;
......
......@@ -25,6 +25,7 @@
enum { EVENT_BUFFER_SIZE = 50 };
int stringToInt(std::string const & val);
int hexStringToInt(std::string const & val);
std::string intToString(int val);
void resetCallback(event_handle_t handle,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment