Commit 9783c6e5 authored by Ryan Jackson's avatar Ryan Jackson

Added support for LINK_UP

parent ec7bb2f1
...@@ -245,8 +245,7 @@ NetlinkPipe::NetlinkPipe(std::string const & iface, std::string const & pipeno) ...@@ -245,8 +245,7 @@ NetlinkPipe::NetlinkPipe(std::string const & iface, std::string const & pipeno)
void NetlinkPipe::test(void) void NetlinkPipe::test(void)
{ {
Parameter testParam(Parameter::LOSS, 50000); Parameter testParam(Parameter::DELAY, 90000);
updateParameter(testParam); updateParameter(testParam);
} }
...@@ -260,7 +259,6 @@ int NetlinkPipe::init(void) ...@@ -260,7 +259,6 @@ int NetlinkPipe::init(void)
cerr << "Got pipe number " << pipeNumber << endl; cerr << "Got pipe number " << pipeNumber << endl;
handle = hexStringToInt(pipeNumber); handle = hexStringToInt(pipeNumber);
cerr << "handle: " << handle << endl;
nl_handle = nl_handle_alloc(); nl_handle = nl_handle_alloc();
if (nl_handle == NULL) { if (nl_handle == NULL) {
...@@ -342,27 +340,27 @@ void NetlinkPipe::updateParameter(Parameter const & newParameter) ...@@ -342,27 +340,27 @@ void NetlinkPipe::updateParameter(Parameter const & newParameter)
qdisc = NULL; qdisc = NULL;
switch(newParameter.getType()) { switch(newParameter.getType()) {
case Parameter::BANDWIDTH: case Parameter::BANDWIDTH:
htbClass = rtnl_class_get(class_cache, htbClassHandle); htbClass = rtnl_class_get(class_cache, htbClassHandle);
if (htbClass == NULL) { if (htbClass == NULL) {
cerr << "Couldn't find htb class " << htbClassHandle << endl; cerr << "Couldn't find htb class " << htbClassHandle << endl;
return; return;
} }
rtnl_htb_set_rate(htbClass, newParameter.getValue()); rtnl_htb_set_rate(htbClass, newParameter.getValue() * 1000);
rtnl_htb_set_ceil(htbClass, newParameter.getValue()); rtnl_htb_set_ceil(htbClass, newParameter.getValue() * 1000);
rtnl_class_change(nl_handle, htbClass, NULL); rtnl_class_change(nl_handle, htbClass, NULL);
rtnl_class_put(htbClass); rtnl_class_put(htbClass);
break; break;
case Parameter::DELAY: case Parameter::DELAY:
qdisc = rtnl_qdisc_get(qdisc_cache, ifindex, delayHandle); qdisc = rtnl_qdisc_get(qdisc_cache, ifindex, delayHandle);
if (qdisc == NULL) { if (qdisc == NULL) {
cerr << "Couldn't find delay qdisc " << delayHandle << endl; cerr << "Couldn't find delay qdisc " << delayHandle << endl;
return; return;
} }
rtnl_delay_set_delay(qdisc, newParameter.getValue()); rtnl_delay_set_delay(qdisc, newParameter.getValue() * 1000);
rtnl_qdisc_change(nl_handle, qdisc, NULL); rtnl_qdisc_change(nl_handle, qdisc, NULL);
rtnl_qdisc_put(qdisc); rtnl_qdisc_put(qdisc);
break; break;
case Parameter::LOSS: case Parameter::LOSS:
qdisc = rtnl_qdisc_get(qdisc_cache, ifindex, plrHandle); qdisc = rtnl_qdisc_get(qdisc_cache, ifindex, plrHandle);
...@@ -377,23 +375,23 @@ void NetlinkPipe::updateParameter(Parameter const & newParameter) ...@@ -377,23 +375,23 @@ void NetlinkPipe::updateParameter(Parameter const & newParameter)
case Parameter::LINK_UP: case Parameter::LINK_UP:
uint32_t value; uint32_t value;
if (newParameter.getValue()) { if (newParameter.getValue()) {
value = 1; value = 0;
} }
else { else {
value = 0x7ffffffff; value = 0xffffffff;
} }
qdisc = rtnl_qdisc_get(qdisc_cache, ifindex, plrHandle); qdisc = rtnl_qdisc_get(qdisc_cache, ifindex, plrHandle);
if (qdisc == NULL) { if (qdisc == NULL) {
cerr << "Couldn't find plr qdisc " << plrHandle << endl; cerr << "Couldn't find plr qdisc " << plrHandle << endl;
return; return;
} }
rtnl_plr_set_plr(qdisc, value); rtnl_plr_set_plr(qdisc, value);
rtnl_qdisc_change(nl_handle, qdisc, NULL); rtnl_qdisc_change(nl_handle, qdisc, NULL);
rtnl_qdisc_put(qdisc); rtnl_qdisc_put(qdisc);
break;
default:
break; break;
default:
break;
} }
} }
......
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