Netconf support for ARP and NDP caching TTLs.

This commit is contained in:
Adam Ierymenko 2013-10-17 16:49:31 -04:00
parent dd7758e33e
commit e6eb65be00
3 changed files with 39 additions and 1 deletions

View file

@ -245,11 +245,13 @@ int main(int argc,char **argv)
unsigned int multicastDepth = 0; unsigned int multicastDepth = 0;
bool emulateArp = false; bool emulateArp = false;
bool emulateNdp = false; bool emulateNdp = false;
unsigned int arpCacheTtl = 0;
unsigned int ndpCacheTtl = 0;
std::string name; std::string name;
std::string desc; std::string desc;
{ {
Query q = dbCon->query(); Query q = dbCon->query();
q << "SELECT name,`desc`,isOpen,multicastPrefixBits,multicastDepth,emulateArp,emulateNdp FROM Network WHERE id = " << nwid; q << "SELECT name,`desc`,isOpen,multicastPrefixBits,multicastDepth,emulateArp,emulateNdp,arpCacheTtl,ndpCacheTtl FROM Network WHERE id = " << nwid;
StoreQueryResult rs = q.store(); StoreQueryResult rs = q.store();
if (rs.num_rows() > 0) { if (rs.num_rows() > 0) {
name = rs[0]["name"].c_str(); name = rs[0]["name"].c_str();
@ -257,6 +259,8 @@ int main(int argc,char **argv)
isOpen = ((int)rs[0]["isOpen"] > 0); isOpen = ((int)rs[0]["isOpen"] > 0);
emulateArp = ((int)rs[0]["emulateArp"] > 0); emulateArp = ((int)rs[0]["emulateArp"] > 0);
emulateNdp = ((int)rs[0]["emulateNdp"] > 0); emulateNdp = ((int)rs[0]["emulateNdp"] > 0);
arpCacheTtl = (unsigned int)rs[0]["arpCacheTtl"];
ndpCacheTtl = (unsigned int)rs[0]["ndpCacheTtl"];
multicastPrefixBits = (unsigned int)rs[0]["multicastPrefixBits"]; multicastPrefixBits = (unsigned int)rs[0]["multicastPrefixBits"];
multicastDepth = (unsigned int)rs[0]["multicastDepth"]; multicastDepth = (unsigned int)rs[0]["multicastDepth"];
} else { } else {
@ -427,6 +431,10 @@ int main(int argc,char **argv)
netconf["ts"] = buf; netconf["ts"] = buf;
netconf["eARP"] = (emulateArp ? "1" : "0"); netconf["eARP"] = (emulateArp ? "1" : "0");
netconf["eNDP"] = (emulateNdp ? "1" : "0"); netconf["eNDP"] = (emulateNdp ? "1" : "0");
sprintf(buf,"%x",arpCacheTtl);
netconf["cARP"] = buf;
sprintf(buf,"%x",ndpCacheTtl);
netconf["cNDP"] = buf;
if (multicastPrefixBits) { if (multicastPrefixBits) {
sprintf(buf,"%x",multicastPrefixBits); sprintf(buf,"%x",multicastPrefixBits);
netconf["mpb"] = buf; netconf["mpb"] = buf;

View file

@ -91,6 +91,8 @@ SharedPtr<Network> Network::newInstance(const RuntimeEnvironment *renv,uint64_t
nw->_isOpen = false; nw->_isOpen = false;
nw->_emulateArp = false; nw->_emulateArp = false;
nw->_emulateNdp = false; nw->_emulateNdp = false;
nw->_arpCacheTtl = 0;
nw->_ndpCacheTtl = 0;
nw->_multicastPrefixBits = ZT_DEFAULT_MULTICAST_PREFIX_BITS; nw->_multicastPrefixBits = ZT_DEFAULT_MULTICAST_PREFIX_BITS;
nw->_multicastDepth = ZT_DEFAULT_MULTICAST_DEPTH; nw->_multicastDepth = ZT_DEFAULT_MULTICAST_DEPTH;
nw->_status = NETWORK_WAITING_FOR_FIRST_AUTOCONF; nw->_status = NETWORK_WAITING_FOR_FIRST_AUTOCONF;
@ -120,6 +122,8 @@ void Network::setConfiguration(const Network::Config &conf,bool saveToDisk)
_isOpen = conf.isOpen(); _isOpen = conf.isOpen();
_emulateArp = conf.emulateArp(); _emulateArp = conf.emulateArp();
_emulateNdp = conf.emulateNdp(); _emulateNdp = conf.emulateNdp();
_arpCacheTtl = conf.arpCacheTtl();
_ndpCacheTtl = conf.ndpCacheTtl();
_multicastPrefixBits = conf.multicastPrefixBits(); _multicastPrefixBits = conf.multicastPrefixBits();
_multicastDepth = conf.multicastDepth(); _multicastDepth = conf.multicastDepth();
@ -153,6 +157,8 @@ void Network::setConfiguration(const Network::Config &conf,bool saveToDisk)
_isOpen = false; _isOpen = false;
_emulateArp = false; _emulateArp = false;
_emulateNdp = false; _emulateNdp = false;
_arpCacheTtl = 0;
_ndpCacheTtl = 0;
_status = NETWORK_WAITING_FOR_FIRST_AUTOCONF; _status = NETWORK_WAITING_FOR_FIRST_AUTOCONF;
_lastConfigUpdate = 0; _lastConfigUpdate = 0;

View file

@ -272,6 +272,28 @@ public:
else return (e->second == "1"); else return (e->second == "1");
} }
/**
* @return ARP cache TTL in seconds or 0 for no ARP caching
*/
inline unsigned int arpCacheTtl() const
{
const_iterator ttl(find("cARP"));
if (ttl == end())
return 0;
return Utils::hexStrToUInt(ttl->second.c_str());
}
/**
* @return NDP cache TTL in seconds or 0 for no NDP caching
*/
inline unsigned int ndpCacheTtl() const
{
const_iterator ttl(find("cNDP"));
if (ttl == end())
return 0;
return Utils::hexStrToUInt(ttl->second.c_str());
}
/** /**
* @return Multicast rates for this network * @return Multicast rates for this network
*/ */
@ -684,6 +706,8 @@ private:
bool _isOpen; bool _isOpen;
bool _emulateArp; bool _emulateArp;
bool _emulateNdp; bool _emulateNdp;
unsigned int _arpCacheTtl;
unsigned int _ndpCacheTtl;
unsigned int _multicastPrefixBits; unsigned int _multicastPrefixBits;
unsigned int _multicastDepth; unsigned int _multicastDepth;