Now only unwiring if the NDP proxy did the wiring in the first place

This commit is contained in:
John Sharratt 2017-07-01 12:25:19 +02:00
parent 701476417a
commit 55ad4b11f0
2 changed files with 29 additions and 12 deletions

View File

@ -79,13 +79,16 @@ session::~session()
{ {
logger::debug() << "session::~session() this=" << logger::format("%x", this); logger::debug() << "session::~session() this=" << logger::format("%x", this);
if (_wired == true) {
for (std::list<ptr<iface> >::iterator it = _ifaces.begin();
it != _ifaces.end(); it++) {
handle_auto_unwire((*it));
}
}
for (std::list<ptr<iface> >::iterator it = _ifaces.begin(); for (std::list<ptr<iface> >::iterator it = _ifaces.begin();
it != _ifaces.end(); it++) it != _ifaces.end(); it++)
{ {
if (_autowire == true) {
handle_auto_unwire((*it));
}
(*it)->remove_session(_ptr); (*it)->remove_session(_ptr);
} }
} }
@ -101,6 +104,7 @@ ptr<session> session::create(const ptr<proxy>& pr, const address& saddr,
se->_taddr = taddr; se->_taddr = taddr;
se->_daddr = daddr; se->_daddr = daddr;
se->_autowire = auto_wire; se->_autowire = auto_wire;
se->_wired = false;
se->_ttl = pr->timeout(); se->_ttl = pr->timeout();
se->_touched = true; se->_touched = true;
@ -161,6 +165,8 @@ void session::handle_auto_wire(const ptr<iface>& ifa)
<< "session::system(" << route_cmd.str() << ")"; << "session::system(" << route_cmd.str() << ")";
system(route_cmd.str().c_str()); system(route_cmd.str().c_str());
_wired = true;
} }
void session::handle_auto_unwire(const ptr<iface>& ifa) void session::handle_auto_unwire(const ptr<iface>& ifa)
@ -181,6 +187,8 @@ void session::handle_auto_unwire(const ptr<iface>& ifa)
<< "session::system(" << route_cmd.str() << ")"; << "session::system(" << route_cmd.str() << ")";
system(route_cmd.str().c_str()); system(route_cmd.str().c_str());
_wired = false;
} }
void session::handle_advert(const ptr<iface>& ifa) void session::handle_advert(const ptr<iface>& ifa)
@ -223,6 +231,11 @@ bool session::autowire() const
return _autowire; return _autowire;
} }
bool session::wired() const
{
return _wired;
}
bool session::touched() const bool session::touched() const
{ {
return _touched; return _touched;

View File

@ -34,6 +34,8 @@ private:
bool _autowire; bool _autowire;
bool _wired;
bool _touched; bool _touched;
// An array of interfaces this session is monitoring for // An array of interfaces this session is monitoring for
@ -75,6 +77,8 @@ public:
bool autowire() const; bool autowire() const;
bool wired() const;
bool touched() const; bool touched() const;
int status() const; int status() const;