Add support for static rules

This commit is contained in:
Daniel Adolfsson 2011-09-18 02:46:51 +02:00
parent 9bf5799109
commit 869fdbca2a
4 changed files with 29 additions and 4 deletions

View File

@ -77,10 +77,17 @@ bool conf::setup(cfg_t *cfg)
std::string ifname(cfg_getstr(rule_cfg, "iface")); std::string ifname(cfg_getstr(rule_cfg, "iface"));
if(ifname == "") if(ifname.empty())
{
if(addr.prefix() <= 120)
NCE("Static rule prefix /%d <= 120 - is this what you want?", addr.prefix());
pr->add_rule(addr); pr->add_rule(addr);
}
else else
{
pr->add_rule(addr, iface::open_ifd(ifname)); pr->add_rule(addr, iface::open_ifd(ifname));
}
} }
} }
} }

View File

@ -89,14 +89,25 @@ void proxy::handle_solicit(const address& saddr, const address& daddr,
for(std::list<strong_ptr<rule> >::iterator it = _rules.begin(); for(std::list<strong_ptr<rule> >::iterator it = _rules.begin();
it != _rules.end(); it++) it != _rules.end(); it++)
{ {
DBG("comparing %s against %s", strong_ptr<rule> ru = *it;
(*it)->addr().to_string().c_str(), taddr.to_string().c_str());
if((*it)->addr() == taddr) DBG("comparing %s against %s",
ru->addr().to_string().c_str(), taddr.to_string().c_str());
if(ru->addr() == taddr)
{ {
if(se.is_null()) if(se.is_null())
se = session::create(_ptr, saddr, daddr, taddr); se = session::create(_ptr, saddr, daddr, taddr);
if(ru->ifa().is_null())
{
// This rule doesn't have an interface, and thus we'll consider
// it "static" and immediately send the response.
se->handle_advert();
return;
}
se->add_iface((*it)->ifa()); se->add_iface((*it)->ifa());
} }
} }

View File

@ -136,4 +136,9 @@ int session::status() const
return _status; return _status;
} }
void session::status(int val)
{
_status = val;
}
__NDPPD_NS_END __NDPPD_NS_END

View File

@ -72,6 +72,8 @@ public:
int status() const; int status() const;
void status(int val);
void handle_advert(); void handle_advert();
void send_advert(); void send_advert();