Add two more configuration options
- 'ttl' to control how long a session will stay in the cache once the session becomes valid or invalid. Default is 30 seconds. - 'timeout' to control how long a session will wait for a Neighbor Advertisement before being invalidated. Default is 500 ms.
This commit is contained in:
parent
869fdbca2a
commit
17bdd6ebac
@ -66,6 +66,10 @@ bool conf::setup(cfg_t *cfg)
|
||||
|
||||
pr->router(cfg_getbool(proxy_cfg, "router"));
|
||||
|
||||
pr->ttl(cfg_getint(proxy_cfg, "ttl"));
|
||||
|
||||
pr->timeout(cfg_getint(proxy_cfg, "timeout"));
|
||||
|
||||
for(i2 = 0; i2 < cfg_size(proxy_cfg, "rule"); i2++)
|
||||
{
|
||||
cfg_t *rule_cfg;
|
||||
@ -112,6 +116,8 @@ bool conf::load(const std::string& path)
|
||||
{
|
||||
CFG_SEC (_S "rule", rule_opts, CFGF_MULTI | CFGF_TITLE),
|
||||
CFG_BOOL (_S "router", cfg_true, CFGF_NONE),
|
||||
CFG_INT (_S "ttl", 30000, CFGF_NONE),
|
||||
CFG_INT (_S "timeout", 500, CFGF_NONE),
|
||||
CFG_END ()
|
||||
};
|
||||
|
||||
|
23
src/proxy.cc
23
src/proxy.cc
@ -26,7 +26,8 @@
|
||||
|
||||
__NDPPD_NS_BEGIN
|
||||
|
||||
proxy::proxy()
|
||||
proxy::proxy() :
|
||||
_router(true), _ttl(30000), _timeout(500)
|
||||
{
|
||||
}
|
||||
|
||||
@ -153,5 +154,25 @@ void proxy::router(bool val)
|
||||
_router = val;
|
||||
}
|
||||
|
||||
int proxy::ttl() const
|
||||
{
|
||||
return _ttl;
|
||||
}
|
||||
|
||||
void proxy::ttl(int val)
|
||||
{
|
||||
_ttl = (val >= 0) ? val : 30000;
|
||||
}
|
||||
|
||||
int proxy::timeout() const
|
||||
{
|
||||
return _timeout;
|
||||
}
|
||||
|
||||
void proxy::timeout(int val)
|
||||
{
|
||||
_timeout = (val >= 0) ? val : 500;
|
||||
}
|
||||
|
||||
__NDPPD_NS_END
|
||||
|
||||
|
10
src/proxy.h
10
src/proxy.h
@ -42,6 +42,8 @@ private:
|
||||
|
||||
bool _router;
|
||||
|
||||
int _ttl, _timeout;
|
||||
|
||||
proxy();
|
||||
|
||||
public:
|
||||
@ -63,6 +65,14 @@ public:
|
||||
bool router() const;
|
||||
|
||||
void router(bool val);
|
||||
|
||||
int timeout() const;
|
||||
|
||||
void timeout(int val);
|
||||
|
||||
int ttl() const;
|
||||
|
||||
void ttl(int val);
|
||||
};
|
||||
|
||||
__NDPPD_NS_END
|
||||
|
@ -39,7 +39,7 @@ void session::update_all(int elapsed_time)
|
||||
case session::WAITING:
|
||||
DBG("session is now invalid");
|
||||
se->_status = session::INVALID;
|
||||
se->_ttl = 30 * 1000;
|
||||
se->_ttl = se->_pr->ttl();
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -71,7 +71,7 @@ strong_ptr<session> session::create(const strong_ptr<proxy>& pr, const address&
|
||||
se->_saddr = saddr;
|
||||
se->_taddr = taddr;
|
||||
se->_daddr = daddr;
|
||||
se->_ttl = 500;
|
||||
se->_ttl = pr->timeout();
|
||||
|
||||
_sessions.push_back(se);
|
||||
|
||||
@ -111,7 +111,7 @@ void session::send_advert()
|
||||
void session::handle_advert()
|
||||
{
|
||||
_status = VALID;
|
||||
_ttl = 30 * 1000;
|
||||
_ttl = _pr->ttl();
|
||||
|
||||
send_advert();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user