From fbd3e10488cf880d02a52e1f8d84d6d5192158e3 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 2 Mar 2020 14:41:15 -0800 Subject: [PATCH] cleanup --- node/Fingerprint.hpp | 8 +++++++- node/Trace.cpp | 12 ++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/node/Fingerprint.hpp b/node/Fingerprint.hpp index 1ed230b45..35789994e 100644 --- a/node/Fingerprint.hpp +++ b/node/Fingerprint.hpp @@ -46,7 +46,13 @@ public: ZT_ALWAYS_INLINE Address address() const noexcept { return Address(_fp.address); } ZT_ALWAYS_INLINE const uint8_t *hash() const noexcept { return _fp.hash; } - ZT_ALWAYS_INLINE void setZTFingerprint(ZT_Fingerprint *fp) const noexcept { memcpy(fp,&_fp,sizeof(ZT_Fingerprint)); } + + /** + * Copy into ZT_Fingerprint struct as used in API and trace messages + * + * @param fp ZT_Fingerprint + */ + ZT_ALWAYS_INLINE void getAPIFingerprint(ZT_Fingerprint *fp) const noexcept { memcpy(fp,&_fp,sizeof(ZT_Fingerprint)); } ZT_ALWAYS_INLINE void zero() noexcept { memoryZero(this); } ZT_ALWAYS_INLINE unsigned long hashCode() const noexcept { return _fp.address; } diff --git a/node/Trace.cpp b/node/Trace.cpp index f513dae7a..9862f954d 100644 --- a/node/Trace.cpp +++ b/node/Trace.cpp @@ -116,12 +116,12 @@ void Trace::_tryingNewPath( ev.evSize = ZT_CONST_TO_BE_UINT16(sizeof(ev)); ev.evType = ZT_CONST_TO_BE_UINT16(ZT_TRACE_VL1_TRYING_NEW_PATH); ev.codeLocation = Utils::hton(codeLocation); - trying.fingerprint().setZTFingerprint(&ev.peer); + trying.fingerprint().getAPIFingerprint(&ev.peer); physicalAddress.forTrace(ev.physicalAddress); triggerAddress.forTrace(ev.triggerAddress); ev.triggeringPacketId = triggeringPacketId; ev.triggeringPacketVerb = triggeringPacketVerb; - triggeringPeer.fingerprint().setZTFingerprint(&ev.triggeringPeer); + triggeringPeer.fingerprint().getAPIFingerprint(&ev.triggeringPeer); ev.reason = (uint8_t)reason; RR->node->postEvent(tPtr,ZT_EVENT_TRACE,&ev); } @@ -139,7 +139,7 @@ void Trace::_learnedNewPath( ev.evType = ZT_CONST_TO_BE_UINT16(ZT_TRACE_VL1_LEARNED_NEW_PATH); ev.codeLocation = Utils::hton(codeLocation); ev.packetId = packetId; // packet IDs are kept in big-endian - peerIdentity.fingerprint().setZTFingerprint(&ev.peer); + peerIdentity.fingerprint().getAPIFingerprint(&ev.peer); physicalAddress.forTrace(ev.physicalAddress); replaced.forTrace(ev.replaced); @@ -163,7 +163,7 @@ void Trace::_incomingPacketDropped( ev.codeLocation = Utils::hton(codeLocation); ev.packetId = packetId; // packet IDs are kept in big-endian ev.networkId = Utils::hton(networkId); - peerIdentity.fingerprint().setZTFingerprint(&ev.peer); + peerIdentity.fingerprint().getAPIFingerprint(&ev.peer); physicalAddress.forTrace(ev.physicalAddress); ev.hops = hops; ev.verb = verb; @@ -226,7 +226,7 @@ void Trace::_incomingNetworkFrameDropped( ev.networkId = Utils::hton(networkId); ev.sourceMac = Utils::hton(sourceMac.toInt()); ev.destMac = Utils::hton(destMac.toInt()); - peerIdentity.fingerprint().setZTFingerprint(&ev.sender); + peerIdentity.fingerprint().getAPIFingerprint(&ev.sender); physicalAddress.forTrace(ev.physicalAddress); ev.hops = hops; ev.frameLength = Utils::hton(frameLength); @@ -325,7 +325,7 @@ void Trace::_credentialRejected( ev.codeLocation = Utils::hton(codeLocation); ev.networkId = Utils::hton(networkId); if (identity) { - identity.fingerprint().setZTFingerprint(&ev.peer); + identity.fingerprint().getAPIFingerprint(&ev.peer); } else { ev.peer.address = address.toInt(); memset(ev.peer.hash,0,sizeof(ev.peer.hash));