summaryrefslogtreecommitdiff
path: root/node/Network.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-10-07 17:00:53 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-10-07 17:00:53 -0400
commit58fa6cab4397fe7b0f4fe883e9d1632f5b73f6f9 (patch)
tree9ba25154272a47ed06ea2691f561f89001ac99d4 /node/Network.cpp
parent4d594b24bc992962c125b3c0ff18ad4d670090c3 (diff)
downloadinfinitytier-58fa6cab4397fe7b0f4fe883e9d1632f5b73f6f9.tar.gz
infinitytier-58fa6cab4397fe7b0f4fe883e9d1632f5b73f6f9.zip
Auto-pushing of membership certs on: MULTICAST_FRAME,FRAME,MULTICAST_LIKE and on receipt of MULTICAST_LIKE.
Diffstat (limited to 'node/Network.cpp')
-rw-r--r--node/Network.cpp43
1 files changed, 19 insertions, 24 deletions
diff --git a/node/Network.cpp b/node/Network.cpp
index 2d08a91f..1973b643 100644
--- a/node/Network.cpp
+++ b/node/Network.cpp
@@ -169,30 +169,6 @@ void Network::addMembershipCertificate(const Address &peer,const CertificateOfMe
_membershipCertificates[peer] = cert;
}
-void Network::pushMembershipCertificate(const Address &peer,bool force,uint64_t now)
-{
- Mutex::Lock _l(_lock);
-
- if (_isOpen)
- return;
-
- uint64_t timestampMaxDelta = _myCertificate.timestampMaxDelta();
- if (!timestampMaxDelta) {
- LOG("unable to push my certificate to %s for network %.16llx: certificate invalid, missing required timestamp field",peer.toString().c_str(),_id);
- return; // required field missing!
- }
-
- uint64_t &lastPushed = _lastPushedMembershipCertificate[peer];
- if ((force)||((now - lastPushed) > (timestampMaxDelta / 2))) {
- lastPushed = now;
-
- Packet outp(peer,_r->identity.address(),Packet::VERB_NETWORK_MEMBERSHIP_CERTIFICATE);
- outp.append((uint64_t)_id);
- _myCertificate.serialize(outp);
- _r->sw->send(outp,true);
- }
-}
-
bool Network::isAllowed(const Address &peer) const
{
// Exceptions can occur if we do not yet have *our* configuration.
@@ -282,6 +258,25 @@ void Network::_CBhandleTapData(void *arg,const MAC &from,const MAC &to,unsigned
}
}
+void Network::_pushMembershipCertificate(const Address &peer,bool force,uint64_t now)
+{
+ uint64_t timestampMaxDelta = _myCertificate.timestampMaxDelta();
+ if (!timestampMaxDelta) {
+ LOG("unable to push my certificate to %s for network %.16llx: certificate invalid, missing required timestamp field",peer.toString().c_str(),_id);
+ return; // required field missing!
+ }
+
+ uint64_t &lastPushed = _lastPushedMembershipCertificate[peer];
+ if ((force)||((now - lastPushed) > (timestampMaxDelta / 2))) {
+ lastPushed = now;
+
+ Packet outp(peer,_r->identity.address(),Packet::VERB_NETWORK_MEMBERSHIP_CERTIFICATE);
+ outp.append((uint64_t)_id);
+ _myCertificate.serialize(outp);
+ _r->sw->send(outp,true);
+ }
+}
+
void Network::_restoreState()
{
std::string confPath(_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + idString() + ".conf");