From e26e77dd6db3bbe427c37d33471a2c8b63f2f2c6 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 7 Apr 2021 19:04:24 -0400 Subject: [PATCH] Forgot some consts. --- core/Context.hpp | 4 +--- core/Network.cpp | 14 +++++++------- core/Network.hpp | 14 +++++++------- core/Node.cpp | 22 +++++++++++----------- core/Node.hpp | 22 +++++++++++----------- core/Peer.cpp | 2 +- core/Peer.hpp | 2 +- core/SelfAwareness.cpp | 4 ++-- core/SelfAwareness.hpp | 4 ++-- 9 files changed, 43 insertions(+), 45 deletions(-) diff --git a/core/Context.hpp b/core/Context.hpp index 3e32fcebf..aa9678342 100644 --- a/core/Context.hpp +++ b/core/Context.hpp @@ -61,9 +61,7 @@ public: } ZT_INLINE ~Context() noexcept - { - Utils::burn(secretIdentityStr, sizeof(secretIdentityStr)); - } + { Utils::burn(secretIdentityStr, sizeof(secretIdentityStr)); } // Unique ID generated on startup const uint64_t instanceId; diff --git a/core/Network.cpp b/core/Network.cpp index 8cb9b9e34..b119f0fce 100644 --- a/core/Network.cpp +++ b/core/Network.cpp @@ -1095,7 +1095,7 @@ bool Network::gate(void *tPtr, const SharedPtr< Peer > &peer) noexcept return false; } -void Network::doPeriodicTasks(CallContext &cc) +void Network::doPeriodicTasks(const CallContext &cc) { if (m_destroyed) return; @@ -1157,7 +1157,7 @@ void Network::learnBridgeRoute(const MAC &mac, const Address &addr) } } -Member::AddCredentialResult Network::addCredential(CallContext &cc, const Identity &sourcePeerIdentity, const MembershipCredential &com) +Member::AddCredentialResult Network::addCredential(const CallContext &cc, const Identity &sourcePeerIdentity, const MembershipCredential &com) { if (com.networkId() != m_id) return Member::ADD_REJECTED; @@ -1165,7 +1165,7 @@ Member::AddCredentialResult Network::addCredential(CallContext &cc, const Identi return m_memberships[com.issuedTo().address].addCredential(m_ctx, cc, sourcePeerIdentity, m_config, com); } -Member::AddCredentialResult Network::addCredential(CallContext &cc, const Identity &sourcePeerIdentity, const CapabilityCredential &cap) +Member::AddCredentialResult Network::addCredential(const CallContext &cc, const Identity &sourcePeerIdentity, const CapabilityCredential &cap) { if (cap.networkId() != m_id) return Member::ADD_REJECTED; @@ -1173,7 +1173,7 @@ Member::AddCredentialResult Network::addCredential(CallContext &cc, const Identi return m_memberships[cap.issuedTo()].addCredential(m_ctx, cc, sourcePeerIdentity, m_config, cap); } -Member::AddCredentialResult Network::addCredential(CallContext &cc, const Identity &sourcePeerIdentity, const TagCredential &tag) +Member::AddCredentialResult Network::addCredential(const CallContext &cc, const Identity &sourcePeerIdentity, const TagCredential &tag) { if (tag.networkId() != m_id) return Member::ADD_REJECTED; @@ -1181,7 +1181,7 @@ Member::AddCredentialResult Network::addCredential(CallContext &cc, const Identi return m_memberships[tag.issuedTo()].addCredential(m_ctx, cc, sourcePeerIdentity, m_config, tag); } -Member::AddCredentialResult Network::addCredential(CallContext &cc, const Identity &sourcePeerIdentity, const RevocationCredential &rev) +Member::AddCredentialResult Network::addCredential(const CallContext &cc, const Identity &sourcePeerIdentity, const RevocationCredential &rev) { if (rev.networkId() != m_id) return Member::ADD_REJECTED; @@ -1215,7 +1215,7 @@ Member::AddCredentialResult Network::addCredential(CallContext &cc, const Identi return result; } -Member::AddCredentialResult Network::addCredential(CallContext &cc, const Identity &sourcePeerIdentity, const OwnershipCredential &coo) +Member::AddCredentialResult Network::addCredential(const CallContext &cc, const Identity &sourcePeerIdentity, const OwnershipCredential &coo) { if (coo.networkId() != m_id) return Member::ADD_REJECTED; @@ -1223,7 +1223,7 @@ Member::AddCredentialResult Network::addCredential(CallContext &cc, const Identi return m_memberships[coo.issuedTo()].addCredential(m_ctx, cc, sourcePeerIdentity, m_config, coo); } -void Network::pushCredentials(CallContext &cc, const SharedPtr< Peer > &to) +void Network::pushCredentials(const CallContext &cc, const SharedPtr< Peer > &to) { const int64_t tout = std::min(m_config.credentialTimeMaxDelta, m_config.com.timestampMaxDelta()); Mutex::Lock _l(m_memberships_l); diff --git a/core/Network.hpp b/core/Network.hpp index 08dfb49e8..274d07236 100644 --- a/core/Network.hpp +++ b/core/Network.hpp @@ -237,7 +237,7 @@ public: /** * Do periodic cleanup and housekeeping tasks */ - void doPeriodicTasks(CallContext &cc); + void doPeriodicTasks(const CallContext &cc); /** * Find the node on this network that has this MAC behind it (if any) @@ -276,34 +276,34 @@ public: /** * Validate a credential and learn it if it passes certificate and other checks */ - Member::AddCredentialResult addCredential(CallContext &cc, const Identity &sourcePeerIdentity, const MembershipCredential &com); + Member::AddCredentialResult addCredential(const CallContext &cc, const Identity &sourcePeerIdentity, const MembershipCredential &com); /** * Validate a credential and learn it if it passes certificate and other checks */ - Member::AddCredentialResult addCredential(CallContext &cc, const Identity &sourcePeerIdentity, const CapabilityCredential &cap); + Member::AddCredentialResult addCredential(const CallContext &cc, const Identity &sourcePeerIdentity, const CapabilityCredential &cap); /** * Validate a credential and learn it if it passes certificate and other checks */ - Member::AddCredentialResult addCredential(CallContext &cc, const Identity &sourcePeerIdentity, const TagCredential &tag); + Member::AddCredentialResult addCredential(const CallContext &cc, const Identity &sourcePeerIdentity, const TagCredential &tag); /** * Validate a credential and learn it if it passes certificate and other checks */ - Member::AddCredentialResult addCredential(CallContext &cc, const Identity &sourcePeerIdentity, const RevocationCredential &rev); + Member::AddCredentialResult addCredential(const CallContext &cc, const Identity &sourcePeerIdentity, const RevocationCredential &rev); /** * Validate a credential and learn it if it passes certificate and other checks */ - Member::AddCredentialResult addCredential(CallContext &cc, const Identity &sourcePeerIdentity, const OwnershipCredential &coo); + Member::AddCredentialResult addCredential(const CallContext &cc, const Identity &sourcePeerIdentity, const OwnershipCredential &coo); /** * Push credentials to a peer if timeouts indicate that we should do so * * @param to Destination peer */ - void pushCredentials(CallContext &cc, const SharedPtr< Peer > &to); + void pushCredentials(const CallContext &cc, const SharedPtr< Peer > &to); /** * Destroy this network diff --git a/core/Node.cpp b/core/Node.cpp index bdca91cd6..dbcb194ee 100644 --- a/core/Node.cpp +++ b/core/Node.cpp @@ -70,7 +70,7 @@ struct _NodeObjects Node::Node( void *uPtr, const struct ZT_Node_Callbacks *callbacks, - CallContext &cc) : + const CallContext &cc) : m_ctx(this), m_store(&m_ctx), m_objects(nullptr), @@ -154,7 +154,7 @@ Node::~Node() Buf::freePool(); } -void Node::shutdown(CallContext &cc) +void Node::shutdown(const CallContext &cc) { m_allNetworks_l.lock(); m_ctx.networks->clear(); @@ -168,7 +168,7 @@ void Node::shutdown(CallContext &cc) } ZT_ResultCode Node::processBackgroundTasks( - CallContext &cc, + const CallContext &cc, volatile int64_t *nextBackgroundTaskDeadline) { Mutex::Lock bl(m_backgroundTasksLock); @@ -241,7 +241,7 @@ ZT_ResultCode Node::join( uint64_t nwid, const ZT_Fingerprint *controllerFingerprint, void *uptr, - CallContext &cc) + const CallContext &cc) { Mutex::Lock l(m_allNetworks_l); @@ -267,7 +267,7 @@ ZT_ResultCode Node::join( ZT_ResultCode Node::leave( uint64_t nwid, void **uptr, - CallContext &cc) + const CallContext &cc) { Mutex::Lock l(m_allNetworks_l); @@ -302,7 +302,7 @@ ZT_ResultCode Node::leave( } ZT_ResultCode Node::multicastSubscribe( - CallContext &cc, + const CallContext &cc, uint64_t nwid, uint64_t multicastGroup, unsigned long multicastAdi) @@ -318,7 +318,7 @@ ZT_ResultCode Node::multicastSubscribe( } ZT_ResultCode Node::multicastUnsubscribe( - CallContext &cc, + const CallContext &cc, uint64_t nwid, uint64_t multicastGroup, unsigned long multicastAdi) @@ -363,7 +363,7 @@ struct p_sortPeerPtrsByAddress { return (a->address() < b->address()); } }; -ZT_PeerList *Node::peers(CallContext &cc) const +ZT_PeerList *Node::peers(const CallContext &cc) const { p_ZT_PeerListPrivate *pl = nullptr; try { @@ -509,7 +509,7 @@ void Node::setInterfaceAddresses( } ZT_CertificateError Node::addCertificate( - CallContext &cc, + const CallContext &cc, unsigned int localTrust, const ZT_Certificate *cert, const void *certData, @@ -531,7 +531,7 @@ ZT_CertificateError Node::addCertificate( } ZT_ResultCode Node::deleteCertificate( - CallContext &cc, + const CallContext &cc, const void *serialNo) { if (!serialNo) @@ -582,7 +582,7 @@ ZT_CertificateList *Node::listCertificates() } int Node::sendUserMessage( - CallContext &cc, + const CallContext &cc, uint64_t dest, uint64_t /*typeId*/, const void */*data*/, diff --git a/core/Node.hpp b/core/Node.hpp index 8ec4d8844..fa81a233d 100644 --- a/core/Node.hpp +++ b/core/Node.hpp @@ -44,35 +44,35 @@ public: void operator delete(void* p) { _mm_free(p); } #endif - Node(void *uPtr, const struct ZT_Node_Callbacks *callbacks, CallContext &cc); + Node(void *uPtr, const struct ZT_Node_Callbacks *callbacks, const CallContext &cc); virtual ~Node(); - void shutdown(CallContext &cc); + void shutdown(const CallContext &cc); ZT_ResultCode processBackgroundTasks( - CallContext &cc, + const CallContext &cc, volatile int64_t *nextBackgroundTaskDeadline); ZT_ResultCode join( uint64_t nwid, const ZT_Fingerprint *controllerFingerprint, void *uptr, - CallContext &cc); + const CallContext &cc); ZT_ResultCode leave( uint64_t nwid, void **uptr, - CallContext &cc); + const CallContext &cc); ZT_ResultCode multicastSubscribe( - CallContext &cc, + const CallContext &cc, uint64_t nwid, uint64_t multicastGroup, unsigned long multicastAdi); ZT_ResultCode multicastUnsubscribe( - CallContext &cc, + const CallContext &cc, uint64_t nwid, uint64_t multicastGroup, unsigned long multicastAdi); @@ -81,7 +81,7 @@ public: ZT_NodeStatus *status) const; ZT_PeerList *peers( - CallContext &cc) const; + const CallContext &cc) const; ZT_VirtualNetworkConfig *networkConfig( uint64_t nwid) const; @@ -97,20 +97,20 @@ public: unsigned int addrCount); ZT_CertificateError addCertificate( - CallContext &cc, + const CallContext &cc, unsigned int localTrust, const ZT_Certificate *cert, const void *certData, unsigned int certSize); ZT_ResultCode deleteCertificate( - CallContext &cc, + const CallContext &cc, const void *serialNo); ZT_CertificateList *listCertificates(); int sendUserMessage( - CallContext &cc, + const CallContext &cc, uint64_t dest, uint64_t typeId, const void *data, diff --git a/core/Peer.cpp b/core/Peer.cpp index a98c6162e..b77232bb8 100644 --- a/core/Peer.cpp +++ b/core/Peer.cpp @@ -475,7 +475,7 @@ void Peer::resetWithinScope(const Context &ctx, const CallContext &cc, InetAddre m_paths[pc++].zero(); } -bool Peer::directlyConnected(CallContext &cc) +bool Peer::directlyConnected(const CallContext &cc) { if ((cc.ticks - m_lastPrioritizedPaths) > ZT_PEER_PRIORITIZE_PATHS_INTERVAL) { RWMutex::Lock l(m_lock); diff --git a/core/Peer.hpp b/core/Peer.hpp index 248a0b68f..c754b1ba0 100644 --- a/core/Peer.hpp +++ b/core/Peer.hpp @@ -355,7 +355,7 @@ public: /** * @return True if there is at least one alive direct path */ - bool directlyConnected(CallContext &cc); + bool directlyConnected(const CallContext &cc); /** * Get all paths diff --git a/core/SelfAwareness.cpp b/core/SelfAwareness.cpp index 7835f0c54..9a42f23aa 100644 --- a/core/SelfAwareness.cpp +++ b/core/SelfAwareness.cpp @@ -28,7 +28,7 @@ SelfAwareness::SelfAwareness(const Context &ctx) : m_ctx(ctx) {} -void SelfAwareness::iam(CallContext &cc, const Identity &reporter, const int64_t receivedOnLocalSocket, const InetAddress &reporterPhysicalAddress, const InetAddress &myPhysicalAddress, bool trusted) +void SelfAwareness::iam(const CallContext &cc, const Identity &reporter, const int64_t receivedOnLocalSocket, const InetAddress &reporterPhysicalAddress, const InetAddress &myPhysicalAddress, bool trusted) { const InetAddress::IpScope scope = myPhysicalAddress.ipScope(); @@ -68,7 +68,7 @@ void SelfAwareness::iam(CallContext &cc, const Identity &reporter, const int64_t } } -void SelfAwareness::clean(CallContext &cc) +void SelfAwareness::clean(const CallContext &cc) { Mutex::Lock l(m_phy_l); for (Map< p_PhySurfaceKey, p_PhySurfaceEntry >::iterator i(m_phy.begin()); i != m_phy.end();) { diff --git a/core/SelfAwareness.hpp b/core/SelfAwareness.hpp index 1a4827b42..1bf5ee5ea 100644 --- a/core/SelfAwareness.hpp +++ b/core/SelfAwareness.hpp @@ -46,12 +46,12 @@ public: * @param myPhysicalAddress Physical address that peer says we have * @param trusted True if this peer is trusted as an authority to inform us of external address changes */ - void iam(CallContext &cc, const Identity &reporter, int64_t receivedOnLocalSocket, const InetAddress &reporterPhysicalAddress, const InetAddress &myPhysicalAddress, bool trusted); + void iam(const CallContext &cc, const Identity &reporter, int64_t receivedOnLocalSocket, const InetAddress &reporterPhysicalAddress, const InetAddress &myPhysicalAddress, bool trusted); /** * Clean up database periodically */ - void clean(CallContext &cc); + void clean(const CallContext &cc); /** * Get external address consensus, which is the statistical "mode" of external addresses.