summaryrefslogtreecommitdiff
path: root/node/Node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'node/Node.cpp')
-rw-r--r--node/Node.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/node/Node.cpp b/node/Node.cpp
index 655e3188..9be0b768 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -62,6 +62,7 @@
#include "Identity.hpp"
#include "Topology.hpp"
#include "SocketManager.hpp"
+#include "Packet.hpp"
#include "Switch.hpp"
#include "EthernetTap.hpp"
#include "CMWC4096.hpp"
@@ -534,6 +535,7 @@ Node::ReasonForTermination Node::run()
uint64_t lastNetworkFingerprintCheck = 0;
uint64_t lastMulticastCheck = 0;
uint64_t lastSupernodePingCheck = 0;
+ uint64_t lastBeacon = 0;
long lastDelayDelta = 0;
uint64_t networkConfigurationFingerprint = 0;
@@ -676,6 +678,18 @@ Node::ReasonForTermination Node::run()
_r->updater->checkIfMaxIntervalExceeded(now);
}
+ // Send beacons to physical local LANs
+ if ((resynchronize)||((now - lastBeacon) >= ZT_BEACON_INTERVAL)) {
+ lastBeacon = now;
+ char bcn[ZT_PROTO_BEACON_LENGTH];
+ *((uint32_t *)(bcn)) = _r->prng->next32();
+ *((uint32_t *)(bcn + 4)) = _r->prng->next32();
+ _r->identity.address().copyTo(bcn + ZT_PROTO_BEACON_IDX_ADDRESS,ZT_ADDRESS_LENGTH);
+ TRACE("sending LAN beacon to %s",ZT_DEFAULTS.v4Broadcast.toString().c_str());
+ _r->antiRec->logOutgoingZT(bcn,ZT_PROTO_BEACON_LENGTH);
+ _r->sm->send(ZT_DEFAULTS.v4Broadcast,false,false,bcn,ZT_PROTO_BEACON_LENGTH);
+ }
+
// Sleep for loop interval or until something interesting happens.
try {
unsigned long delay = std::min((unsigned long)ZT_MAX_SERVICE_LOOP_INTERVAL,_r->sw->doTimerTasks());