Brief description of class still missing. More...
#include <KernelRoute.h>
Public Member Functions | |
| void | add (const Address &dest, const Address &gw) |
| void | clear () |
| int | count () const |
| Address | destination (const Address &gateway) const |
| KernelRoute (const char *interface) | |
| void | remove (const Address &dest, const Address &gw) |
| void | removeDestination (const Address &destination) |
| Route * | routes () const |
| ~KernelRoute () | |
Brief description of class still missing.
Full description of class still missing
| KernelRoute::KernelRoute | ( | const char * | interface | ) |
{
_interface=interface;
_fd=socket(AF_INET, SOCK_DGRAM, 0);
if(_fd<0) {
Log::write(1, "kernel route: %s\n", strerror(errno));
CoreApplication::exit(2);
}
// Set ip_forward bit to one to allow packet forward on all nodes
int fdf=open("/proc/sys/net/ipv4/ip_forward", O_WRONLY);
if(fdf>0) {
write(fdf, "1", 1);
close(fdf);
}
}
| void KernelRoute::add | ( | const Address & | dest, |
| const Address & | gw | ||
| ) |
Referenced by PeerTracker::addFromMasterRoute().
{
std::list<Route>::iterator it=find(destination, gateway);
if(it==_routes.end()) {
Route rt(destination, gateway);
if(add(rt)) {
_routes.push_back(rt);
}
} else {
Log::write(1, "Route to %s already exists", Route(destination, gateway).toString().data());
}
}
| void KernelRoute::clear | ( | ) |
Referenced by ~KernelRoute().
{
for(std::list<Route>::iterator it=_routes.begin(); it!=_routes.end(); it++) {
Route& rt=*it;
remove(rt);
}
_routes.clear();
}
| int KernelRoute::count | ( | ) | const [inline] |
{return _routes.size();}
| Address KernelRoute::destination | ( | const Address & | gateway | ) | const |
Returns destination address of first entry with gateway.
References Route::destination(), and Route::gateway().
Referenced by PeerTracker::stop().
{
std::list<Route>::const_iterator it;
for(it=_routes.begin(); it!=_routes.end(); it++) {
Route rt=*it;
if(rt.gateway()==gateway) {
return rt.destination();
}
}
return Address();
}
| void KernelRoute::remove | ( | const Address & | dest, |
| const Address & | gw | ||
| ) |
{
std::list<Route>::iterator it=find(destination, gateway);
if(it!=_routes.end()) {
if(remove(*it)) {
_routes.erase(it);
}
}
}
| void KernelRoute::removeDestination | ( | const Address & | destination | ) |
Referenced by PeerTracker::removeFromMasterRoute().
{
std::list<Route>::iterator it=find(destination);
if(it!=_routes.end()) {
if(remove(*it)) {
_routes.erase(it);
}
}
}
| Route * KernelRoute::routes | ( | ) | const |