Add support for static rules
This commit is contained in:
parent
9bf5799109
commit
869fdbca2a
@ -77,13 +77,20 @@ 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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
17
src/proxy.cc
17
src/proxy.cc
@ -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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -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();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user