Adam Ierymenko 5 years ago
parent
commit
5c06d40358
11 changed files with 189 additions and 227 deletions
  1. 50 50
      node/InetAddress.hpp
  2. 20 20
      node/Locator.hpp
  3. 2 2
      node/Network.hpp
  4. 25 31
      node/Node.hpp
  5. 3 3
      node/Path.hpp
  6. 7 10
      node/Peer.hpp
  7. 33 61
      node/SHA512.cpp
  8. 5 4
      node/Switch.hpp
  9. 17 17
      node/Tag.hpp
  10. 19 19
      node/Topology.hpp
  11. 8 10
      node/Trace.hpp

+ 50 - 50
node/InetAddress.hpp

@@ -79,55 +79,55 @@ struct InetAddress : public sockaddr_storage
 	// but this is safe to put here.
 	struct Hasher
 	{
-		inline std::size_t operator()(const InetAddress &a) const { return (std::size_t)a.hashCode(); }
+		ZT_ALWAYS_INLINE std::size_t operator()(const InetAddress &a) const { return (std::size_t)a.hashCode(); }
 	};
 
-	inline InetAddress() { memset(this,0,sizeof(InetAddress)); }
-	inline InetAddress(const InetAddress &a) { memcpy(this,&a,sizeof(InetAddress)); }
-	inline InetAddress(const InetAddress *a) { memcpy(this,a,sizeof(InetAddress)); }
-	inline InetAddress(const struct sockaddr_storage &ss) { *this = ss; }
-	inline InetAddress(const struct sockaddr_storage *ss) { *this = ss; }
-	inline InetAddress(const struct sockaddr &sa) { *this = sa; }
-	inline InetAddress(const struct sockaddr *sa) { *this = sa; }
-	inline InetAddress(const struct sockaddr_in &sa) { *this = sa; }
-	inline InetAddress(const struct sockaddr_in *sa) { *this = sa; }
-	inline InetAddress(const struct sockaddr_in6 &sa) { *this = sa; }
-	inline InetAddress(const struct sockaddr_in6 *sa) { *this = sa; }
-	inline InetAddress(const void *ipBytes,unsigned int ipLen,unsigned int port) { this->set(ipBytes,ipLen,port); }
-	inline InetAddress(const uint32_t ipv4,unsigned int port) { this->set(&ipv4,4,port); }
-	inline InetAddress(const char *ipSlashPort) { this->fromString(ipSlashPort); }
-
-	inline void clear() { memset(this,0,sizeof(InetAddress)); }
-
-	inline InetAddress &operator=(const InetAddress &a)
+	ZT_ALWAYS_INLINE InetAddress() { memset(this,0,sizeof(InetAddress)); }
+	ZT_ALWAYS_INLINE InetAddress(const InetAddress &a) { memcpy(this,&a,sizeof(InetAddress)); }
+	ZT_ALWAYS_INLINE InetAddress(const InetAddress *a) { memcpy(this,a,sizeof(InetAddress)); }
+	ZT_ALWAYS_INLINE InetAddress(const struct sockaddr_storage &ss) { *this = ss; }
+	ZT_ALWAYS_INLINE InetAddress(const struct sockaddr_storage *ss) { *this = ss; }
+	ZT_ALWAYS_INLINE InetAddress(const struct sockaddr &sa) { *this = sa; }
+	ZT_ALWAYS_INLINE InetAddress(const struct sockaddr *sa) { *this = sa; }
+	ZT_ALWAYS_INLINE InetAddress(const struct sockaddr_in &sa) { *this = sa; }
+	ZT_ALWAYS_INLINE InetAddress(const struct sockaddr_in *sa) { *this = sa; }
+	ZT_ALWAYS_INLINE InetAddress(const struct sockaddr_in6 &sa) { *this = sa; }
+	ZT_ALWAYS_INLINE InetAddress(const struct sockaddr_in6 *sa) { *this = sa; }
+	ZT_ALWAYS_INLINE InetAddress(const void *ipBytes,unsigned int ipLen,unsigned int port) { this->set(ipBytes,ipLen,port); }
+	ZT_ALWAYS_INLINE InetAddress(const uint32_t ipv4,unsigned int port) { this->set(&ipv4,4,port); }
+	ZT_ALWAYS_INLINE InetAddress(const char *ipSlashPort) { this->fromString(ipSlashPort); }
+
+	ZT_ALWAYS_INLINE void clear() { memset(this,0,sizeof(InetAddress)); }
+
+	ZT_ALWAYS_INLINE InetAddress &operator=(const InetAddress &a)
 	{
 		if (&a != this)
 			memcpy(this,&a,sizeof(InetAddress));
 		return *this;
 	}
 
-	inline InetAddress &operator=(const InetAddress *a)
+	ZT_ALWAYS_INLINE InetAddress &operator=(const InetAddress *a)
 	{
 		if (a != this)
 			memcpy(this,a,sizeof(InetAddress));
 		return *this;
 	}
 
-	inline InetAddress &operator=(const struct sockaddr_storage &ss)
+	ZT_ALWAYS_INLINE InetAddress &operator=(const struct sockaddr_storage &ss)
 	{
 		if (reinterpret_cast<const InetAddress *>(&ss) != this)
 			memcpy(this,&ss,sizeof(InetAddress));
 		return *this;
 	}
 
-	inline InetAddress &operator=(const struct sockaddr_storage *ss)
+	ZT_ALWAYS_INLINE InetAddress &operator=(const struct sockaddr_storage *ss)
 	{
 		if (reinterpret_cast<const InetAddress *>(ss) != this)
 			memcpy(this,ss,sizeof(InetAddress));
 		return *this;
 	}
 
-	inline InetAddress &operator=(const struct sockaddr_in &sa)
+	ZT_ALWAYS_INLINE InetAddress &operator=(const struct sockaddr_in &sa)
 	{
 		if (reinterpret_cast<const InetAddress *>(&sa) != this) {
 			memset(this,0,sizeof(InetAddress));
@@ -136,7 +136,7 @@ struct InetAddress : public sockaddr_storage
 		return *this;
 	}
 
-	inline InetAddress &operator=(const struct sockaddr_in *sa)
+	ZT_ALWAYS_INLINE InetAddress &operator=(const struct sockaddr_in *sa)
 	{
 		if (reinterpret_cast<const InetAddress *>(sa) != this) {
 			memset(this,0,sizeof(InetAddress));
@@ -145,7 +145,7 @@ struct InetAddress : public sockaddr_storage
 		return *this;
 	}
 
-	inline InetAddress &operator=(const struct sockaddr_in6 &sa)
+	ZT_ALWAYS_INLINE InetAddress &operator=(const struct sockaddr_in6 &sa)
 	{
 		if (reinterpret_cast<const InetAddress *>(&sa) != this) {
 			memset(this,0,sizeof(InetAddress));
@@ -154,7 +154,7 @@ struct InetAddress : public sockaddr_storage
 		return *this;
 	}
 
-	inline InetAddress &operator=(const struct sockaddr_in6 *sa)
+	ZT_ALWAYS_INLINE InetAddress &operator=(const struct sockaddr_in6 *sa)
 	{
 		if (reinterpret_cast<const InetAddress *>(sa) != this) {
 			memset(this,0,sizeof(InetAddress));
@@ -163,7 +163,7 @@ struct InetAddress : public sockaddr_storage
 		return *this;
 	}
 
-	inline InetAddress &operator=(const struct sockaddr &sa)
+	ZT_ALWAYS_INLINE InetAddress &operator=(const struct sockaddr &sa)
 	{
 		if (reinterpret_cast<const InetAddress *>(&sa) != this) {
 			memset(this,0,sizeof(InetAddress));
@@ -179,7 +179,7 @@ struct InetAddress : public sockaddr_storage
 		return *this;
 	}
 
-	inline InetAddress &operator=(const struct sockaddr *sa)
+	ZT_ALWAYS_INLINE InetAddress &operator=(const struct sockaddr *sa)
 	{
 		if (reinterpret_cast<const InetAddress *>(sa) != this) {
 			memset(this,0,sizeof(InetAddress));
@@ -214,7 +214,7 @@ struct InetAddress : public sockaddr_storage
 	 *
 	 * @param port Port, 0 to 65535
 	 */
-	inline void setPort(unsigned int port)
+	ZT_ALWAYS_INLINE void setPort(unsigned int port)
 	{
 		switch(ss_family) {
 			case AF_INET:
@@ -229,7 +229,7 @@ struct InetAddress : public sockaddr_storage
 	/**
 	 * @return True if this network/netmask route describes a default route (e.g. 0.0.0.0/0)
 	 */
-	inline bool isDefaultRoute() const
+	ZT_ALWAYS_INLINE bool isDefaultRoute() const
 	{
 		switch(ss_family) {
 			case AF_INET:
@@ -264,7 +264,7 @@ struct InetAddress : public sockaddr_storage
 	/**
 	 * @return Port or 0 if no port component defined
 	 */
-	inline unsigned int port() const
+	ZT_ALWAYS_INLINE unsigned int port() const
 	{
 		switch(ss_family) {
 			case AF_INET: return Utils::ntoh((uint16_t)(reinterpret_cast<const struct sockaddr_in *>(this)->sin_port));
@@ -282,12 +282,12 @@ struct InetAddress : public sockaddr_storage
 	 *
 	 * @return Netmask bits
 	 */
-	inline unsigned int netmaskBits() const { return port(); }
+	ZT_ALWAYS_INLINE unsigned int netmaskBits() const { return port(); }
 
 	/**
 	 * @return True if netmask bits is valid for the address type
 	 */
-	inline bool netmaskBitsValid() const
+	ZT_ALWAYS_INLINE bool netmaskBitsValid() const
 	{
 		const unsigned int n = port();
 		switch(ss_family) {
@@ -305,7 +305,7 @@ struct InetAddress : public sockaddr_storage
 	 *
 	 * @return Gateway metric
 	 */
-	inline unsigned int metric() const { return port(); }
+	ZT_ALWAYS_INLINE unsigned int metric() const { return port(); }
 
 	/**
 	 * Construct a full netmask as an InetAddress
@@ -350,17 +350,17 @@ struct InetAddress : public sockaddr_storage
 	/**
 	 * @return True if this is an IPv4 address
 	 */
-	inline bool isV4() const { return (ss_family == AF_INET); }
+	ZT_ALWAYS_INLINE bool isV4() const { return (ss_family == AF_INET); }
 
 	/**
 	 * @return True if this is an IPv6 address
 	 */
-	inline bool isV6() const { return (ss_family == AF_INET6); }
+	ZT_ALWAYS_INLINE bool isV6() const { return (ss_family == AF_INET6); }
 
 	/**
 	 * @return pointer to raw address bytes or NULL if not available
 	 */
-	inline const void *rawIpData() const
+	ZT_ALWAYS_INLINE const void *rawIpData() const
 	{
 		switch(ss_family) {
 			case AF_INET: return (const void *)&(reinterpret_cast<const struct sockaddr_in *>(this)->sin_addr.s_addr);
@@ -372,7 +372,7 @@ struct InetAddress : public sockaddr_storage
 	/**
 	 * @return InetAddress containing only the IP portion of this address and a zero port, or NULL if not IPv4 or IPv6
 	 */
-	inline InetAddress ipOnly() const
+	ZT_ALWAYS_INLINE InetAddress ipOnly() const
 	{
 		InetAddress r;
 		switch(ss_family) {
@@ -394,7 +394,7 @@ struct InetAddress : public sockaddr_storage
 	 * @param a InetAddress to compare again
 	 * @return True if only IP portions are equal (false for non-IP or null addresses)
 	 */
-	inline bool ipsEqual(const InetAddress &a) const
+	ZT_ALWAYS_INLINE bool ipsEqual(const InetAddress &a) const
 	{
 		if (ss_family == a.ss_family) {
 			if (ss_family == AF_INET)
@@ -414,7 +414,7 @@ struct InetAddress : public sockaddr_storage
 	 * @param a InetAddress to compare again
 	 * @return True if only IP portions are equal (false for non-IP or null addresses)
 	 */
-	inline bool ipsEqual2(const InetAddress &a) const
+	ZT_ALWAYS_INLINE bool ipsEqual2(const InetAddress &a) const
 	{
 		if (ss_family == a.ss_family) {
 			if (ss_family == AF_INET)
@@ -426,7 +426,7 @@ struct InetAddress : public sockaddr_storage
 		return false;
 	}
 
-	inline unsigned long hashCode() const
+	ZT_ALWAYS_INLINE unsigned long hashCode() const
 	{
 		if (ss_family == AF_INET) {
 			return ((unsigned long)reinterpret_cast<const struct sockaddr_in *>(this)->sin_addr.s_addr + (unsigned long)reinterpret_cast<const struct sockaddr_in *>(this)->sin_port);
@@ -448,7 +448,7 @@ struct InetAddress : public sockaddr_storage
 	/**
 	 * Set to null/zero
 	 */
-	inline void zero() { memset(this,0,sizeof(InetAddress)); }
+	ZT_ALWAYS_INLINE void zero() { memset(this,0,sizeof(InetAddress)); }
 
 	/**
 	 * Check whether this is a network/route rather than an IP assignment
@@ -463,7 +463,7 @@ struct InetAddress : public sockaddr_storage
 	/**
 	 * @return 14-bit (0-16383) hash of this IP's first 24 or 48 bits (for V4 or V6) for rate limiting code, or 0 if non-IP
 	 */
-	inline unsigned long rateGateHash() const
+	ZT_ALWAYS_INLINE unsigned long rateGateHash() const
 	{
 		unsigned long h = 0;
 		switch(ss_family) {
@@ -487,10 +487,10 @@ struct InetAddress : public sockaddr_storage
 	/**
 	 * @return True if address family is non-zero
 	 */
-	inline operator bool() const { return (ss_family != 0); }
+	ZT_ALWAYS_INLINE operator bool() const { return (ss_family != 0); }
 
 	template<unsigned int C>
-	inline void serialize(Buffer<C> &b) const
+	ZT_ALWAYS_INLINE void serialize(Buffer<C> &b) const
 	{
 		// This is used in the protocol and must be the same as describe in places
 		// like VERB_HELLO in Packet.hpp.
@@ -512,7 +512,7 @@ struct InetAddress : public sockaddr_storage
 	}
 
 	template<unsigned int C>
-	inline unsigned int deserialize(const Buffer<C> &b,unsigned int startAt = 0)
+	ZT_ALWAYS_INLINE unsigned int deserialize(const Buffer<C> &b,unsigned int startAt = 0)
 	{
 		memset(this,0,sizeof(InetAddress));
 		unsigned int p = startAt;
@@ -547,10 +547,10 @@ struct InetAddress : public sockaddr_storage
 
 	bool operator==(const InetAddress &a) const;
 	bool operator<(const InetAddress &a) const;
-	inline bool operator!=(const InetAddress &a) const { return !(*this == a); }
-	inline bool operator>(const InetAddress &a) const { return (a < *this); }
-	inline bool operator<=(const InetAddress &a) const { return !(a < *this); }
-	inline bool operator>=(const InetAddress &a) const { return !(*this < a); }
+	ZT_ALWAYS_INLINE bool operator!=(const InetAddress &a) const { return !(*this == a); }
+	ZT_ALWAYS_INLINE bool operator>(const InetAddress &a) const { return (a < *this); }
+	ZT_ALWAYS_INLINE bool operator<=(const InetAddress &a) const { return !(a < *this); }
+	ZT_ALWAYS_INLINE bool operator>=(const InetAddress &a) const { return !(*this < a); }
 
 	/**
 	 * @param mac MAC address seed

+ 20 - 20
node/Locator.hpp

@@ -46,19 +46,19 @@ namespace ZeroTier {
 class Locator
 {
 public:
-	inline Locator() : _ts(0),_signatureLength(0) {}
+	ZT_ALWAYS_INLINE Locator() : _ts(0),_signatureLength(0) {}
 
-	inline const Identity &id() const { return _id; }
-	inline const Identity &signer() const { return ((_signedBy) ? _signedBy : _id); }
-	inline int64_t timestamp() const { return _ts; }
+	ZT_ALWAYS_INLINE const Identity &id() const { return _id; }
+	ZT_ALWAYS_INLINE const Identity &signer() const { return ((_signedBy) ? _signedBy : _id); }
+	ZT_ALWAYS_INLINE int64_t timestamp() const { return _ts; }
 
-	inline const std::vector<InetAddress> &phy() const { return _physical; }
-	inline const std::vector<Identity> &virt() const { return _virtual; }
+	ZT_ALWAYS_INLINE const std::vector<InetAddress> &phy() const { return _physical; }
+	ZT_ALWAYS_INLINE const std::vector<Identity> &virt() const { return _virtual; }
 
 	/**
 	 * Add a physical address to this locator (call before finish() to build a new Locator)
 	 */
-	inline void add(const InetAddress &ip)
+	ZT_ALWAYS_INLINE void add(const InetAddress &ip)
 	{
 		if (_physical.size() < ZT_LOCATOR_MAX_PHYSICAL_ADDRESSES)
 			_physical.push_back(ip);
@@ -67,7 +67,7 @@ public:
 	/**
 	 * Add a forwarding ZeroTier node to this locator (call before finish() to build a new Locator)
 	 */
-	inline void add(const Identity &zt)
+	ZT_ALWAYS_INLINE void add(const Identity &zt)
 	{
 		if (_virtual.size() < ZT_LOCATOR_MAX_VIRTUAL_ADDRESSES)
 			_virtual.push_back(zt);
@@ -80,7 +80,7 @@ public:
 	 * lists but does not sign the locator. The sign() method should be used after
 	 * finish().
 	 */
-	inline void finish(const Identity &id,const int64_t ts)
+	ZT_ALWAYS_INLINE void finish(const Identity &id,const int64_t ts)
 	{
 		_ts = ts;
 		_id = id;
@@ -93,7 +93,7 @@ public:
 	/**
 	 * Sign this locator (must be called after finish())
 	 */
-	inline bool sign(const Identity &signingId)
+	ZT_ALWAYS_INLINE bool sign(const Identity &signingId)
 	{
 		if (!signingId.hasPrivate())
 			return false;
@@ -115,7 +115,7 @@ public:
 	/**
 	 * Verify this locator's signature against its embedded signing identity
 	 */
-	inline bool verify() const
+	ZT_ALWAYS_INLINE bool verify() const
 	{
 		if ((_signatureLength == 0)||(_signatureLength > sizeof(_signature)))
 			return false;
@@ -286,13 +286,13 @@ public:
 		return (p - startAt);
 	}
 
-	inline operator bool() const { return (_id); }
+	ZT_ALWAYS_INLINE operator bool() const { return (_id); }
 
-	inline bool addressesEqual(const Locator &l) const { return ((_physical == l._physical)&&(_virtual == l._virtual)); }
+	ZT_ALWAYS_INLINE bool addressesEqual(const Locator &l) const { return ((_physical == l._physical)&&(_virtual == l._virtual)); }
 
-	inline bool operator==(const Locator &l) const { return ((_ts == l._ts)&&(_id == l._id)&&(_signedBy == l._signedBy)&&(_physical == l._physical)&&(_virtual == l._virtual)&&(_signatureLength == l._signatureLength)&&(memcmp(_signature,l._signature,_signatureLength) == 0)); }
-	inline bool operator!=(const Locator &l) const { return (!(*this == l)); }
-	inline bool operator<(const Locator &l) const
+	ZT_ALWAYS_INLINE bool operator==(const Locator &l) const { return ((_ts == l._ts)&&(_id == l._id)&&(_signedBy == l._signedBy)&&(_physical == l._physical)&&(_virtual == l._virtual)&&(_signatureLength == l._signatureLength)&&(memcmp(_signature,l._signature,_signatureLength) == 0)); }
+	ZT_ALWAYS_INLINE bool operator!=(const Locator &l) const { return (!(*this == l)); }
+	ZT_ALWAYS_INLINE bool operator<(const Locator &l) const
 	{
 		if (_id < l._id) return true;
 		if (_ts < l._ts) return true;
@@ -301,11 +301,11 @@ public:
 		if (_virtual < l._virtual) return true;
 		return false;
 	}
-	inline bool operator>(const Locator &l) const { return (l < *this); }
-	inline bool operator<=(const Locator &l) const { return (!(l < *this)); }
-	inline bool operator>=(const Locator &l) const { return (!(*this < l)); }
+	ZT_ALWAYS_INLINE bool operator>(const Locator &l) const { return (l < *this); }
+	ZT_ALWAYS_INLINE bool operator<=(const Locator &l) const { return (!(l < *this)); }
+	ZT_ALWAYS_INLINE bool operator>=(const Locator &l) const { return (!(*this < l)); }
 
-	inline unsigned long hashCode() const { return (unsigned long)(_id.address().toInt() ^ (uint64_t)_ts); }
+	ZT_ALWAYS_INLINE unsigned long hashCode() const { return (unsigned long)(_id.address().toInt() ^ (uint64_t)_ts); }
 
 private:
 	int64_t _ts;

+ 2 - 2
node/Network.hpp

@@ -62,7 +62,7 @@ public:
 	/**
 	 * Compute primary controller device ID from network ID
 	 */
-	static inline Address controllerFor(uint64_t nwid) { return Address(nwid >> 24); }
+	static ZT_ALWAYS_INLINE Address controllerFor(uint64_t nwid) { return Address(nwid >> 24); }
 
 	/**
 	 * Construct a new network
@@ -441,7 +441,7 @@ private:
 
 	struct _IncomingConfigChunk
 	{
-		_IncomingConfigChunk() : ts(0),updateId(0),haveChunks(0),haveBytes(0),data() {}
+		ZT_ALWAYS_INLINE _IncomingConfigChunk() : ts(0),updateId(0),haveChunks(0),haveBytes(0),data() {}
 		uint64_t ts;
 		uint64_t updateId;
 		uint64_t haveChunkIds[ZT_NETWORK_MAX_UPDATE_CHUNKS];

+ 25 - 31
node/Node.hpp

@@ -97,9 +97,9 @@ public:
 
 	// Internal functions ------------------------------------------------------
 
-	inline int64_t now() const { return _now; }
+	ZT_ALWAYS_INLINE int64_t now() const { return _now; }
 
-	inline bool putPacket(void *tPtr,const int64_t localSocket,const InetAddress &addr,const void *data,unsigned int len,unsigned int ttl = 0)
+	ZT_ALWAYS_INLINE bool putPacket(void *tPtr,const int64_t localSocket,const InetAddress &addr,const void *data,unsigned int len,unsigned int ttl = 0)
 	{
 		return (_cb.wirePacketSendFunction(
 			reinterpret_cast<ZT_Node *>(this),
@@ -112,7 +112,7 @@ public:
 			ttl) == 0);
 	}
 
-	inline void putFrame(void *tPtr,uint64_t nwid,void **nuptr,const MAC &source,const MAC &dest,unsigned int etherType,unsigned int vlanId,const void *data,unsigned int len)
+	ZT_ALWAYS_INLINE void putFrame(void *tPtr,uint64_t nwid,void **nuptr,const MAC &source,const MAC &dest,unsigned int etherType,unsigned int vlanId,const void *data,unsigned int len)
 	{
 		_cb.virtualNetworkFrameFunction(
 			reinterpret_cast<ZT_Node *>(this),
@@ -128,7 +128,7 @@ public:
 			len);
 	}
 
-	inline SharedPtr<Network> network(uint64_t nwid) const
+	ZT_ALWAYS_INLINE SharedPtr<Network> network(uint64_t nwid) const
 	{
 		Mutex::Lock _l(_networks_m);
 		const SharedPtr<Network> *n = _networks.get(nwid);
@@ -137,13 +137,13 @@ public:
 		return SharedPtr<Network>();
 	}
 
-	inline bool belongsToNetwork(uint64_t nwid) const
+	ZT_ALWAYS_INLINE bool belongsToNetwork(uint64_t nwid) const
 	{
 		Mutex::Lock _l(_networks_m);
 		return _networks.contains(nwid);
 	}
 
-	inline std::vector< SharedPtr<Network> > allNetworks() const
+	ZT_ALWAYS_INLINE std::vector< SharedPtr<Network> > allNetworks() const
 	{
 		std::vector< SharedPtr<Network> > nw;
 		Mutex::Lock _l(_networks_m);
@@ -155,28 +155,22 @@ public:
 		return nw;
 	}
 
-	inline std::vector<InetAddress> directPaths() const
+	ZT_ALWAYS_INLINE std::vector<InetAddress> directPaths() const
 	{
 		Mutex::Lock _l(_localInterfaceAddresses_m);
 		return _localInterfaceAddresses;
 	}
 
-	inline void postEvent(void *tPtr,ZT_Event ev,const void *md = (const void *)0) { _cb.eventCallback(reinterpret_cast<ZT_Node *>(this),_uPtr,tPtr,ev,md); }
-
-	inline int configureVirtualNetworkPort(void *tPtr,uint64_t nwid,void **nuptr,ZT_VirtualNetworkConfigOperation op,const ZT_VirtualNetworkConfig *nc) { return _cb.virtualNetworkConfigFunction(reinterpret_cast<ZT_Node *>(this),_uPtr,tPtr,nwid,nuptr,op,nc); }
-
-	inline bool online() const { return _online; }
-
-	inline int stateObjectGet(void *const tPtr,ZT_StateObjectType type,const uint64_t id[2],void *const data,const unsigned int maxlen) { return _cb.stateGetFunction(reinterpret_cast<ZT_Node *>(this),_uPtr,tPtr,type,id,data,maxlen); }
-	inline void stateObjectPut(void *const tPtr,ZT_StateObjectType type,const uint64_t id[2],const void *const data,const unsigned int len) { _cb.statePutFunction(reinterpret_cast<ZT_Node *>(this),_uPtr,tPtr,type,id,data,(int)len); }
-	inline void stateObjectDelete(void *const tPtr,ZT_StateObjectType type,const uint64_t id[2]) { _cb.statePutFunction(reinterpret_cast<ZT_Node *>(this),_uPtr,tPtr,type,id,(const void *)0,-1); }
-
+	ZT_ALWAYS_INLINE void postEvent(void *tPtr,ZT_Event ev,const void *md = (const void *)0) { _cb.eventCallback(reinterpret_cast<ZT_Node *>(this),_uPtr,tPtr,ev,md); }
+	ZT_ALWAYS_INLINE int configureVirtualNetworkPort(void *tPtr,uint64_t nwid,void **nuptr,ZT_VirtualNetworkConfigOperation op,const ZT_VirtualNetworkConfig *nc) { return _cb.virtualNetworkConfigFunction(reinterpret_cast<ZT_Node *>(this),_uPtr,tPtr,nwid,nuptr,op,nc); }
+	ZT_ALWAYS_INLINE bool online() const { return _online; }
+	ZT_ALWAYS_INLINE int stateObjectGet(void *const tPtr,ZT_StateObjectType type,const uint64_t id[2],void *const data,const unsigned int maxlen) { return _cb.stateGetFunction(reinterpret_cast<ZT_Node *>(this),_uPtr,tPtr,type,id,data,maxlen); }
+	ZT_ALWAYS_INLINE void stateObjectPut(void *const tPtr,ZT_StateObjectType type,const uint64_t id[2],const void *const data,const unsigned int len) { _cb.statePutFunction(reinterpret_cast<ZT_Node *>(this),_uPtr,tPtr,type,id,data,(int)len); }
+	ZT_ALWAYS_INLINE void stateObjectDelete(void *const tPtr,ZT_StateObjectType type,const uint64_t id[2]) { _cb.statePutFunction(reinterpret_cast<ZT_Node *>(this),_uPtr,tPtr,type,id,(const void *)0,-1); }
 	bool shouldUsePathForZeroTierTraffic(void *tPtr,const Address &ztaddr,const int64_t localSocket,const InetAddress &remoteAddress);
-	inline bool externalPathLookup(void *tPtr,const Address &ztaddr,int family,InetAddress &addr) { return ( (_cb.pathLookupFunction) ? (_cb.pathLookupFunction(reinterpret_cast<ZT_Node *>(this),_uPtr,tPtr,ztaddr.toInt(),family,reinterpret_cast<struct sockaddr_storage *>(&addr)) != 0) : false ); }
-
+	ZT_ALWAYS_INLINE bool externalPathLookup(void *tPtr,const Address &ztaddr,int family,InetAddress &addr) { return ( (_cb.pathLookupFunction) ? (_cb.pathLookupFunction(reinterpret_cast<ZT_Node *>(this),_uPtr,tPtr,ztaddr.toInt(),family,reinterpret_cast<struct sockaddr_storage *>(&addr)) != 0) : false ); }
 	ZT_ResultCode setPhysicalPathConfiguration(const struct sockaddr_storage *pathNetwork,const ZT_PhysicalPathConfiguration *pathConfig);
-
-	inline const Identity &identity() const { return _RR.identity; }
+	ZT_ALWAYS_INLINE const Identity &identity() const { return _RR.identity; }
 
 	/**
 	 * Register that we are expecting a reply to a packet ID
@@ -187,7 +181,7 @@ public:
 	 *
 	 * @param packetId Packet ID to expect reply to
 	 */
-	inline void expectReplyTo(const uint64_t packetId)
+	ZT_ALWAYS_INLINE void expectReplyTo(const uint64_t packetId)
 	{
 		const unsigned long pid2 = (unsigned long)(packetId >> 32);
 		const unsigned long bucket = (unsigned long)(pid2 & ZT_EXPECTING_REPLIES_BUCKET_MASK1);
@@ -204,7 +198,7 @@ public:
 	 * @param packetId Packet ID to check
 	 * @return True if we're expecting a reply
 	 */
-	inline bool expectingReplyTo(const uint64_t packetId) const
+	ZT_ALWAYS_INLINE bool expectingReplyTo(const uint64_t packetId) const
 	{
 		const uint32_t pid2 = (uint32_t)(packetId >> 32);
 		const unsigned long bucket = (unsigned long)(pid2 & ZT_EXPECTING_REPLIES_BUCKET_MASK1);
@@ -222,7 +216,7 @@ public:
 	 * @param from Source address of packet
 	 * @return True if within rate limits
 	 */
-	inline bool rateGateIdentityVerification(const int64_t now,const InetAddress &from)
+	ZT_ALWAYS_INLINE bool rateGateIdentityVerification(const int64_t now,const InetAddress &from)
 	{
 		unsigned long iph = from.rateGateHash();
 		if ((now - _lastIdentityVerification[iph]) >= ZT_IDENTITY_VALIDATION_SOURCE_RATE_LIMIT) {
@@ -236,10 +230,10 @@ public:
 	virtual void ncSendRevocation(const Address &destination,const Revocation &rev);
 	virtual void ncSendError(uint64_t nwid,uint64_t requestPacketId,const Address &destination,NetworkController::ErrorCode errorCode);
 
-	inline void setMultipathMode(uint8_t mode) { _multipathMode = mode; }
-	inline uint8_t getMultipathMode() { return _multipathMode; }
+	ZT_ALWAYS_INLINE void setMultipathMode(uint8_t mode) { _multipathMode = mode; }
+	ZT_ALWAYS_INLINE uint8_t getMultipathMode() { return _multipathMode; }
 
-	inline bool localControllerHasAuthorized(const int64_t now,const uint64_t nwid,const Address &addr) const
+	ZT_ALWAYS_INLINE bool localControllerHasAuthorized(const int64_t now,const uint64_t nwid,const Address &addr) const
 	{
 		_localControllerAuthorizations_m.lock();
 		const int64_t *const at = _localControllerAuthorizations.get(_LocalControllerAuth(nwid,addr));
@@ -270,10 +264,10 @@ private:
 	struct _LocalControllerAuth
 	{
 		uint64_t nwid,address;
-		_LocalControllerAuth(const uint64_t nwid_,const Address &address_) : nwid(nwid_),address(address_.toInt()) {}
-		inline unsigned long hashCode() const { return (unsigned long)(nwid ^ address); }
-		inline bool operator==(const _LocalControllerAuth &a) const { return ((a.nwid == nwid)&&(a.address == address)); }
-		inline bool operator!=(const _LocalControllerAuth &a) const { return ((a.nwid != nwid)||(a.address != address)); }
+		ZT_ALWAYS_INLINE _LocalControllerAuth(const uint64_t nwid_,const Address &address_) : nwid(nwid_),address(address_.toInt()) {}
+		ZT_ALWAYS_INLINE unsigned long hashCode() const { return (unsigned long)(nwid ^ address); }
+		ZT_ALWAYS_INLINE bool operator==(const _LocalControllerAuth &a) const { return ((a.nwid == nwid)&&(a.address == address)); }
+		ZT_ALWAYS_INLINE bool operator!=(const _LocalControllerAuth &a) const { return ((a.nwid != nwid)||(a.address != address)); }
 	};
 	Hashtable< _LocalControllerAuth,int64_t > _localControllerAuthorizations;
 	Mutex _localControllerAuthorizations_m;

+ 3 - 3
node/Path.hpp

@@ -81,7 +81,7 @@ public:
 		uint64_t _k[3];
 	};
 
-	inline Path() :
+	ZT_ALWAYS_INLINE Path() :
 		_lastOut(0),
 		_lastIn(0),
 		_lastPathQualityComputeTime(0),
@@ -113,7 +113,7 @@ public:
 		memset(_addrString, 0, sizeof(_addrString));
 	}
 
-	inline Path(const int64_t localSocket,const InetAddress &addr) :
+	ZT_ALWAYS_INLINE Path(const int64_t localSocket,const InetAddress &addr) :
 		_lastOut(0),
 		_lastIn(0),
 		_lastPathQualityComputeTime(0),
@@ -225,7 +225,7 @@ public:
 	 * @param a Address to check
 	 * @return True if address is good for ZeroTier path use
 	 */
-	static inline bool isAddressValidForPath(const InetAddress &a)
+	static ZT_ALWAYS_INLINE bool isAddressValidForPath(const InetAddress &a)
 	{
 		if ((a.ss_family == AF_INET)||(a.ss_family == AF_INET6)) {
 			switch(a.ipScope()) {

+ 7 - 10
node/Peer.hpp

@@ -100,7 +100,7 @@ public:
 	 * @param addr Remote address
 	 * @return True if we have an active path to this destination
 	 */
-	inline bool hasActivePathTo(int64_t now,const InetAddress &addr) const
+	ZT_ALWAYS_INLINE bool hasActivePathTo(int64_t now,const InetAddress &addr) const
 	{
 		Mutex::Lock _l(_paths_m);
 		for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
@@ -262,7 +262,7 @@ public:
 	 * @param now Current time
 	 * @return All known paths to this peer
 	 */
-	inline std::vector< SharedPtr<Path> > paths(const int64_t now) const
+	ZT_ALWAYS_INLINE std::vector< SharedPtr<Path> > paths(const int64_t now) const
 	{
 		std::vector< SharedPtr<Path> > pp;
 		Mutex::Lock _l(_paths_m);
@@ -360,23 +360,23 @@ public:
 	 * or a VERB_QOS_MEASUREMENT packet at some point in the past. Until this flag is set, the local client
 	 * shall assume that multipath is not enabled and should only use classical Protocol 9 logic.
 	 */
-	inline void inferRemoteMultipathEnabled() { _remotePeerMultipathEnabled = true; }
+	ZT_ALWAYS_INLINE void inferRemoteMultipathEnabled() { _remotePeerMultipathEnabled = true; }
 
 	/**
 	 * @return Whether the local client supports and is configured to use multipath
 	 */
-	inline bool localMultipathSupport() { return _localMultipathSupported; }
+	ZT_ALWAYS_INLINE bool localMultipathSupport() { return _localMultipathSupported; }
 
 	/**
 	 * @return Whether the remote peer supports and is configured to use multipath
 	 */
-	inline bool remoteMultipathSupport() { return _remoteMultipathSupported; }
+	ZT_ALWAYS_INLINE bool remoteMultipathSupport() { return _remoteMultipathSupported; }
 
 	/**
 	 * @return Whether this client can use multipath to communicate with this peer. True if both peers are using
 	 * the correct protocol and if both peers have multipath enabled. False if otherwise.
 	 */
-	inline bool canUseMultipath() { return _canUseMultipath; }
+	ZT_ALWAYS_INLINE bool canUseMultipath() { return _canUseMultipath; }
 
 	/**
 	 * Rate limit gate for VERB_PUSH_DIRECT_PATHS
@@ -544,10 +544,7 @@ private:
 // Add a swap() for shared ptr's to peers to speed up peer sorts
 namespace std {
 	template<>
-	inline void swap(ZeroTier::SharedPtr<ZeroTier::Peer> &a,ZeroTier::SharedPtr<ZeroTier::Peer> &b)
-	{
-		a.swap(b);
-	}
+	ZT_ALWAYS_INLINE void swap(ZeroTier::SharedPtr<ZeroTier::Peer> &a,ZeroTier::SharedPtr<ZeroTier::Peer> &b) { a.swap(b); }
 }
 
 #endif

+ 33 - 61
node/SHA512.cpp

@@ -23,59 +23,39 @@ struct sha512_state {
 };
 
 static const uint64_t K[80] = {
-	0x428a2f98d728ae22ULL,0x7137449123ef65cdULL,
-	0xb5c0fbcfec4d3b2fULL,0xe9b5dba58189dbbcULL,
-	0x3956c25bf348b538ULL,0x59f111f1b605d019ULL,
-	0x923f82a4af194f9bULL,0xab1c5ed5da6d8118ULL,
-	0xd807aa98a3030242ULL,0x12835b0145706fbeULL,
-	0x243185be4ee4b28cULL,0x550c7dc3d5ffb4e2ULL,
-	0x72be5d74f27b896fULL,0x80deb1fe3b1696b1ULL,
-	0x9bdc06a725c71235ULL,0xc19bf174cf692694ULL,
-	0xe49b69c19ef14ad2ULL,0xefbe4786384f25e3ULL,
-	0x0fc19dc68b8cd5b5ULL,0x240ca1cc77ac9c65ULL,
-	0x2de92c6f592b0275ULL,0x4a7484aa6ea6e483ULL,
-	0x5cb0a9dcbd41fbd4ULL,0x76f988da831153b5ULL,
-	0x983e5152ee66dfabULL,0xa831c66d2db43210ULL,
-	0xb00327c898fb213fULL,0xbf597fc7beef0ee4ULL,
-	0xc6e00bf33da88fc2ULL,0xd5a79147930aa725ULL,
-	0x06ca6351e003826fULL,0x142929670a0e6e70ULL,
-	0x27b70a8546d22ffcULL,0x2e1b21385c26c926ULL,
-	0x4d2c6dfc5ac42aedULL,0x53380d139d95b3dfULL,
-	0x650a73548baf63deULL,0x766a0abb3c77b2a8ULL,
-	0x81c2c92e47edaee6ULL,0x92722c851482353bULL,
-	0xa2bfe8a14cf10364ULL,0xa81a664bbc423001ULL,
-	0xc24b8b70d0f89791ULL,0xc76c51a30654be30ULL,
-	0xd192e819d6ef5218ULL,0xd69906245565a910ULL,
-	0xf40e35855771202aULL,0x106aa07032bbd1b8ULL,
-	0x19a4c116b8d2d0c8ULL,0x1e376c085141ab53ULL,
-	0x2748774cdf8eeb99ULL,0x34b0bcb5e19b48a8ULL,
-	0x391c0cb3c5c95a63ULL,0x4ed8aa4ae3418acbULL,
-	0x5b9cca4f7763e373ULL,0x682e6ff3d6b2b8a3ULL,
-	0x748f82ee5defb2fcULL,0x78a5636f43172f60ULL,
-	0x84c87814a1f0ab72ULL,0x8cc702081a6439ecULL,
-	0x90befffa23631e28ULL,0xa4506cebde82bde9ULL,
-	0xbef9a3f7b2c67915ULL,0xc67178f2e372532bULL,
-	0xca273eceea26619cULL,0xd186b8c721c0c207ULL,
-	0xeada7dd6cde0eb1eULL,0xf57d4f7fee6ed178ULL,
-	0x06f067aa72176fbaULL,0x0a637dc5a2c898a6ULL,
-	0x113f9804bef90daeULL,0x1b710b35131c471bULL,
-	0x28db77f523047d84ULL,0x32caab7b40c72493ULL,
-	0x3c9ebe0a15c9bebcULL,0x431d67c49c100d4cULL,
-	0x4cc5d4becb3e42b6ULL,0x597f299cfc657e2aULL,
-	0x5fcb6fab3ad6faecULL,0x6c44198c4a475817ULL
+	0x428a2f98d728ae22ULL,0x7137449123ef65cdULL,0xb5c0fbcfec4d3b2fULL,0xe9b5dba58189dbbcULL,
+	0x3956c25bf348b538ULL,0x59f111f1b605d019ULL,0x923f82a4af194f9bULL,0xab1c5ed5da6d8118ULL,
+	0xd807aa98a3030242ULL,0x12835b0145706fbeULL,0x243185be4ee4b28cULL,0x550c7dc3d5ffb4e2ULL,
+	0x72be5d74f27b896fULL,0x80deb1fe3b1696b1ULL,0x9bdc06a725c71235ULL,0xc19bf174cf692694ULL,
+	0xe49b69c19ef14ad2ULL,0xefbe4786384f25e3ULL,0x0fc19dc68b8cd5b5ULL,0x240ca1cc77ac9c65ULL,
+	0x2de92c6f592b0275ULL,0x4a7484aa6ea6e483ULL,0x5cb0a9dcbd41fbd4ULL,0x76f988da831153b5ULL,
+	0x983e5152ee66dfabULL,0xa831c66d2db43210ULL,0xb00327c898fb213fULL,0xbf597fc7beef0ee4ULL,
+	0xc6e00bf33da88fc2ULL,0xd5a79147930aa725ULL,0x06ca6351e003826fULL,0x142929670a0e6e70ULL,
+	0x27b70a8546d22ffcULL,0x2e1b21385c26c926ULL,0x4d2c6dfc5ac42aedULL,0x53380d139d95b3dfULL,
+	0x650a73548baf63deULL,0x766a0abb3c77b2a8ULL,0x81c2c92e47edaee6ULL,0x92722c851482353bULL,
+	0xa2bfe8a14cf10364ULL,0xa81a664bbc423001ULL,0xc24b8b70d0f89791ULL,0xc76c51a30654be30ULL,
+	0xd192e819d6ef5218ULL,0xd69906245565a910ULL,0xf40e35855771202aULL,0x106aa07032bbd1b8ULL,
+	0x19a4c116b8d2d0c8ULL,0x1e376c085141ab53ULL,0x2748774cdf8eeb99ULL,0x34b0bcb5e19b48a8ULL,
+	0x391c0cb3c5c95a63ULL,0x4ed8aa4ae3418acbULL,0x5b9cca4f7763e373ULL,0x682e6ff3d6b2b8a3ULL,
+	0x748f82ee5defb2fcULL,0x78a5636f43172f60ULL,0x84c87814a1f0ab72ULL,0x8cc702081a6439ecULL,
+	0x90befffa23631e28ULL,0xa4506cebde82bde9ULL,0xbef9a3f7b2c67915ULL,0xc67178f2e372532bULL,
+	0xca273eceea26619cULL,0xd186b8c721c0c207ULL,0xeada7dd6cde0eb1eULL,0xf57d4f7fee6ed178ULL,
+	0x06f067aa72176fbaULL,0x0a637dc5a2c898a6ULL,0x113f9804bef90daeULL,0x1b710b35131c471bULL,
+	0x28db77f523047d84ULL,0x32caab7b40c72493ULL,0x3c9ebe0a15c9bebcULL,0x431d67c49c100d4cULL,
+	0x4cc5d4becb3e42b6ULL,0x597f299cfc657e2aULL,0x5fcb6fab3ad6faecULL,0x6c44198c4a475817ULL
 };
 
-#define STORE64H(x, y)                                                                     \
-   { (y)[0] = (unsigned char)(((x)>>56)&255); (y)[1] = (unsigned char)(((x)>>48)&255);     \
-     (y)[2] = (unsigned char)(((x)>>40)&255); (y)[3] = (unsigned char)(((x)>>32)&255);     \
-     (y)[4] = (unsigned char)(((x)>>24)&255); (y)[5] = (unsigned char)(((x)>>16)&255);     \
-     (y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); }
+#define STORE64H(x, y)                                                               \
+ { (y)[0] = (unsigned char)(((x)>>56)&255); (y)[1] = (unsigned char)(((x)>>48)&255); \
+   (y)[2] = (unsigned char)(((x)>>40)&255); (y)[3] = (unsigned char)(((x)>>32)&255); \
+   (y)[4] = (unsigned char)(((x)>>24)&255); (y)[5] = (unsigned char)(((x)>>16)&255); \
+   (y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); }
 
 #define LOAD64H(x, y)                                                      \
-   { x = (((uint64_t)((y)[0] & 255))<<56)|(((uint64_t)((y)[1] & 255))<<48) | \
-         (((uint64_t)((y)[2] & 255))<<40)|(((uint64_t)((y)[3] & 255))<<32) | \
-         (((uint64_t)((y)[4] & 255))<<24)|(((uint64_t)((y)[5] & 255))<<16) | \
-         (((uint64_t)((y)[6] & 255))<<8)|(((uint64_t)((y)[7] & 255))); }
+ { x = (((uint64_t)((y)[0] & 255))<<56)|(((uint64_t)((y)[1] & 255))<<48) | \
+       (((uint64_t)((y)[2] & 255))<<40)|(((uint64_t)((y)[3] & 255))<<32) | \
+       (((uint64_t)((y)[4] & 255))<<24)|(((uint64_t)((y)[5] & 255))<<16) | \
+       (((uint64_t)((y)[6] & 255))<<8)|(((uint64_t)((y)[7] & 255))); }
 
 #define ROL64c(x,y) (((x)<<(y)) | ((x)>>(64-(y))))
 #define ROR64c(x,y) (((x)>>(y)) | ((x)<<(64-(y))))
@@ -94,17 +74,12 @@ static ZT_ALWAYS_INLINE void sha512_compress(sha512_state *const md,uint8_t *con
 	uint64_t S[8], W[80], t0, t1;
 	int i;
 
-	for (i = 0; i < 8; i++) {
+	for (i = 0; i < 8; i++)
 		S[i] = md->state[i];
-	}
-
-	for (i = 0; i < 16; i++) {
+	for (i = 0; i < 16; i++)
 		LOAD64H(W[i], buf + (8*i));
-	}
-
-	for (i = 16; i < 80; i++) {
+	for (i = 16; i < 80; i++)
 		W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];
-	}
 
 #define RND(a,b,c,d,e,f,g,h,i) \
 	t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
@@ -123,11 +98,8 @@ static ZT_ALWAYS_INLINE void sha512_compress(sha512_state *const md,uint8_t *con
 		RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],i+7);
 	}
 
-
-	/* feedback */
-	for (i = 0; i < 8; i++) {
+	for (i = 0; i < 8; i++)
 		md->state[i] = md->state[i] + S[i];
-	}
 }
 
 static ZT_ALWAYS_INLINE void sha384_init(sha512_state *const md)

+ 5 - 4
node/Switch.hpp

@@ -226,7 +226,7 @@ private:
 	AtomicCounter _rxQueuePtr;
 
 	// Returns matching or next available RX queue entry
-	inline RXQueueEntry *_findRXQueueEntry(uint64_t packetId)
+	ZT_ALWAYS_INLINE RXQueueEntry *_findRXQueueEntry(uint64_t packetId)
 	{
 		const unsigned int current = static_cast<unsigned int>(_rxQueuePtr.load());
 		for(unsigned int k=1;k<=ZT_RX_QUEUE_SIZE;++k) {
@@ -239,7 +239,7 @@ private:
 	}
 
 	// Returns current entry in rx queue ring buffer and increments ring pointer
-	inline RXQueueEntry *_nextRXQueueEntry()
+	ZT_ALWAYS_INLINE RXQueueEntry *_nextRXQueueEntry()
 	{
 		return &(_rxQueue[static_cast<unsigned int>((++_rxQueuePtr) - 1) % ZT_RX_QUEUE_SIZE]);
 	}
@@ -277,8 +277,9 @@ private:
 				y = a2.toInt();
 			}
 		}
-		inline unsigned long hashCode() const { return ((unsigned long)x ^ (unsigned long)y); }
-		inline bool operator==(const _LastUniteKey &k) const { return ((x == k.x)&&(y == k.y)); }
+		ZT_ALWAYS_INLINE unsigned long hashCode() const { return ((unsigned long)x ^ (unsigned long)y); }
+		ZT_ALWAYS_INLINE bool operator==(const _LastUniteKey &k) const { return ((x == k.x)&&(y == k.y)); }
+		ZT_ALWAYS_INLINE bool operator!=(const _LastUniteKey &k) const { return ((x != k.x)||(y != k.y)); }
 		uint64_t x,y;
 	};
 	Hashtable< _LastUniteKey,uint64_t > _lastUniteAttempt; // key is always sorted in ascending order, for set-like behavior

+ 17 - 17
node/Tag.hpp

@@ -52,9 +52,9 @@ class Tag : public Credential
 	friend class Credential;
 
 public:
-	static inline Credential::Type credentialType() { return Credential::CREDENTIAL_TYPE_TAG; }
+	static ZT_ALWAYS_INLINE Credential::Type credentialType() { return Credential::CREDENTIAL_TYPE_TAG; }
 
-	inline Tag() :
+	ZT_ALWAYS_INLINE Tag() :
 		_id(0),
 		_value(0),
 		_networkId(0),
@@ -70,7 +70,7 @@ public:
 	 * @param id Tag ID
 	 * @param value Tag value
 	 */
-	inline Tag(const uint64_t nwid,const int64_t ts,const Address &issuedTo,const uint32_t id,const uint32_t value) :
+	ZT_ALWAYS_INLINE Tag(const uint64_t nwid,const int64_t ts,const Address &issuedTo,const uint32_t id,const uint32_t value) :
 		_id(id),
 		_value(value),
 		_networkId(nwid),
@@ -96,7 +96,7 @@ public:
 	 * @param signer Signing identity, must have private key
 	 * @return True if signature was successful
 	 */
-	inline bool sign(const Identity &signer)
+	ZT_ALWAYS_INLINE bool sign(const Identity &signer)
 	{
 		if (signer.hasPrivate()) {
 			Buffer<sizeof(Tag) + 64> tmp;
@@ -114,7 +114,7 @@ public:
 	 * @param RR Runtime environment to allow identity lookup for signedBy
 	 * @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
 	 */
-	inline Credential::VerifyResult verify(const RuntimeEnvironment *RR,void *tPtr) const { return _verify(RR,tPtr,*this); }
+	ZT_ALWAYS_INLINE Credential::VerifyResult verify(const RuntimeEnvironment *RR,void *tPtr) const { return _verify(RR,tPtr,*this); }
 
 	template<unsigned int C>
 	inline void serialize(Buffer<C> &b,const bool forSign = false) const
@@ -172,23 +172,23 @@ public:
 	}
 
 	// Provides natural sort order by ID
-	inline bool operator<(const Tag &t) const { return (_id < t._id); }
+	ZT_ALWAYS_INLINE bool operator<(const Tag &t) const { return (_id < t._id); }
 
-	inline bool operator==(const Tag &t) const { return (memcmp(this,&t,sizeof(Tag)) == 0); }
-	inline bool operator!=(const Tag &t) const { return (memcmp(this,&t,sizeof(Tag)) != 0); }
+	ZT_ALWAYS_INLINE bool operator==(const Tag &t) const { return (memcmp(this,&t,sizeof(Tag)) == 0); }
+	ZT_ALWAYS_INLINE bool operator!=(const Tag &t) const { return (memcmp(this,&t,sizeof(Tag)) != 0); }
 
 	// For searching sorted arrays or lists of Tags by ID
 	struct IdComparePredicate
 	{
-		inline bool operator()(const Tag &a,const Tag &b) const { return (a.id() < b.id()); }
-		inline bool operator()(const uint32_t a,const Tag &b) const { return (a < b.id()); }
-		inline bool operator()(const Tag &a,const uint32_t b) const { return (a.id() < b); }
-		inline bool operator()(const Tag *a,const Tag *b) const { return (a->id() < b->id()); }
-		inline bool operator()(const Tag *a,const Tag &b) const { return (a->id() < b.id()); }
-		inline bool operator()(const Tag &a,const Tag *b) const { return (a.id() < b->id()); }
-		inline bool operator()(const uint32_t a,const Tag *b) const { return (a < b->id()); }
-		inline bool operator()(const Tag *a,const uint32_t b) const { return (a->id() < b); }
-		inline bool operator()(const uint32_t a,const uint32_t b) const { return (a < b); }
+		ZT_ALWAYS_INLINE bool operator()(const Tag &a,const Tag &b) const { return (a.id() < b.id()); }
+		ZT_ALWAYS_INLINE bool operator()(const uint32_t a,const Tag &b) const { return (a < b.id()); }
+		ZT_ALWAYS_INLINE bool operator()(const Tag &a,const uint32_t b) const { return (a.id() < b); }
+		ZT_ALWAYS_INLINE bool operator()(const Tag *a,const Tag *b) const { return (a->id() < b->id()); }
+		ZT_ALWAYS_INLINE bool operator()(const Tag *a,const Tag &b) const { return (a->id() < b.id()); }
+		ZT_ALWAYS_INLINE bool operator()(const Tag &a,const Tag *b) const { return (a.id() < b->id()); }
+		ZT_ALWAYS_INLINE bool operator()(const uint32_t a,const Tag *b) const { return (a < b->id()); }
+		ZT_ALWAYS_INLINE bool operator()(const Tag *a,const uint32_t b) const { return (a->id() < b); }
+		ZT_ALWAYS_INLINE bool operator()(const uint32_t a,const uint32_t b) const { return (a < b); }
 	};
 
 private:

+ 19 - 19
node/Topology.hpp

@@ -45,11 +45,11 @@ class RuntimeEnvironment;
 class Topology
 {
 public:
-	inline Topology(const RuntimeEnvironment *renv,const Identity &myId) :
+	ZT_ALWAYS_INLINE Topology(const RuntimeEnvironment *renv,const Identity &myId) :
 		RR(renv),
 		_myIdentity(myId),
 		_numConfiguredPhysicalPaths(0) {}
-	inline ~Topology() {}
+	ZT_ALWAYS_INLINE ~Topology() {}
 
 	/**
 	 * Add a peer to database
@@ -61,7 +61,7 @@ public:
 	 * @param peer Peer to add
 	 * @return New or existing peer (should replace 'peer')
 	 */
-	inline SharedPtr<Peer> add(const SharedPtr<Peer> &peer)
+	ZT_ALWAYS_INLINE SharedPtr<Peer> add(const SharedPtr<Peer> &peer)
 	{
 		SharedPtr<Peer> np;
 		{
@@ -81,7 +81,7 @@ public:
 	 * @param zta ZeroTier address of peer
 	 * @return Peer or NULL if not found
 	 */
-	inline SharedPtr<Peer> get(const Address &zta)
+	ZT_ALWAYS_INLINE SharedPtr<Peer> get(const Address &zta)
 	{
 		if (zta == _myIdentity.address())
 			return SharedPtr<Peer>();
@@ -110,7 +110,7 @@ public:
 	 * @param zta ZeroTier address of peer
 	 * @return Identity or NULL identity if not found
 	 */
-	inline Identity getIdentity(void *tPtr,const Address &zta)
+	ZT_ALWAYS_INLINE Identity getIdentity(void *tPtr,const Address &zta)
 	{
 		if (zta == _myIdentity.address()) {
 			return _myIdentity;
@@ -130,7 +130,7 @@ public:
 	 * @param r Remote address
 	 * @return Pointer to canonicalized Path object
 	 */
-	inline SharedPtr<Path> getPath(const int64_t l,const InetAddress &r)
+	ZT_ALWAYS_INLINE SharedPtr<Path> getPath(const int64_t l,const InetAddress &r)
 	{
 		Mutex::Lock _l(_paths_m);
 		SharedPtr<Path> &p = _paths[Path::HashKey(l,r)];
@@ -143,7 +143,7 @@ public:
 	 * @param id Identity to check
 	 * @return True if this identity corresponds to a root
 	 */
-	inline bool isRoot(const Identity &id) const
+	ZT_ALWAYS_INLINE bool isRoot(const Identity &id) const
 	{
 		Mutex::Lock l(_roots_m);
 		for(std::vector<Root>::const_iterator r(_roots.begin());r!=_roots.end();++r) {
@@ -156,7 +156,7 @@ public:
 	/**
 	 * Do periodic tasks such as database cleanup
 	 */
-	inline void doPeriodicTasks(int64_t now)
+	ZT_ALWAYS_INLINE void doPeriodicTasks(int64_t now)
 	{
 		{
 			Mutex::Lock _l1(_peers_m);
@@ -185,7 +185,7 @@ public:
 	 * @param now Current time
 	 * @return Number of peers with active direct paths
 	 */
-	inline unsigned long countActive(int64_t now) const
+	ZT_ALWAYS_INLINE unsigned long countActive(int64_t now) const
 	{
 		unsigned long cnt = 0;
 		Mutex::Lock _l(_peers_m);
@@ -210,7 +210,7 @@ public:
 	 * @tparam F Function or function object type
 	 */
 	template<typename F>
-	inline void eachPeer(F f)
+	ZT_ALWAYS_INLINE void eachPeer(F f)
 	{
 		Mutex::Lock l(_peers_m);
 		Hashtable< Address,SharedPtr<Peer> >::Iterator i(_peers);
@@ -231,7 +231,7 @@ public:
 	 * @tparam F function or function object type
 	 */
 	template<typename F>
-	inline void eachRoot(F f)
+	ZT_ALWAYS_INLINE void eachRoot(F f)
 	{
 		Mutex::Lock l(_roots_m);
 		SharedPtr<Peer> rp;
@@ -256,7 +256,7 @@ public:
 	 * @param now Current time
 	 * @return Best/fastest currently connected root or NULL if none
 	 */
-	inline SharedPtr<Peer> root(const int64_t now)
+	ZT_ALWAYS_INLINE SharedPtr<Peer> root(const int64_t now)
 	{
 		Mutex::Lock l(_bestRoot_m);
 		if ((!_bestRoot)||((now - _lastRankedBestRoot) >= ZT_FIND_BEST_ROOT_PERIOD)) {
@@ -295,7 +295,7 @@ public:
 	 * @param toAddr Destination address
 	 * @return Best current relay or NULL if none
 	 */
-	inline SharedPtr<Peer> findRelayTo(const int64_t now,const Address &toAddr)
+	ZT_ALWAYS_INLINE SharedPtr<Peer> findRelayTo(const int64_t now,const Address &toAddr)
 	{
 		// TODO: in the future this will check 'mesh-like' relays and if enabled consult LF for other roots (for if this is a root)
 		return root(now);
@@ -304,7 +304,7 @@ public:
 	/**
 	 * @param allPeers vector to fill with all current peers
 	 */
-	inline void getAllPeers(std::vector< SharedPtr<Peer> > &allPeers) const
+	ZT_ALWAYS_INLINE void getAllPeers(std::vector< SharedPtr<Peer> > &allPeers) const
 	{
 		Mutex::Lock l(_peers_m);
 		allPeers.clear();
@@ -326,7 +326,7 @@ public:
 	 * @param mtu Variable set to MTU
 	 * @param trustedPathId Variable set to trusted path ID
 	 */
-	inline void getOutboundPathInfo(const InetAddress &physicalAddress,unsigned int &mtu,uint64_t &trustedPathId)
+	ZT_ALWAYS_INLINE void getOutboundPathInfo(const InetAddress &physicalAddress,unsigned int &mtu,uint64_t &trustedPathId)
 	{
 		for(unsigned int i=0,j=_numConfiguredPhysicalPaths;i<j;++i) {
 			if (_physicalPathConfig[i].first.containsAddress(physicalAddress)) {
@@ -343,7 +343,7 @@ public:
 	 * @param physicalAddress Physical endpoint address
 	 * @return MTU
 	 */
-	inline unsigned int getOutboundPathMtu(const InetAddress &physicalAddress)
+	ZT_ALWAYS_INLINE unsigned int getOutboundPathMtu(const InetAddress &physicalAddress)
 	{
 		for(unsigned int i=0,j=_numConfiguredPhysicalPaths;i<j;++i) {
 			if (_physicalPathConfig[i].first.containsAddress(physicalAddress))
@@ -358,7 +358,7 @@ public:
 	 * @param physicalAddress Physical address to which we are sending the packet
 	 * @return Trusted path ID or 0 if none (0 is not a valid trusted path ID)
 	 */
-	inline uint64_t getOutboundPathTrust(const InetAddress &physicalAddress)
+	ZT_ALWAYS_INLINE uint64_t getOutboundPathTrust(const InetAddress &physicalAddress)
 	{
 		for(unsigned int i=0,j=_numConfiguredPhysicalPaths;i<j;++i) {
 			if (_physicalPathConfig[i].first.containsAddress(physicalAddress))
@@ -373,7 +373,7 @@ public:
 	 * @param physicalAddress Originating physical address
 	 * @param trustedPathId Trusted path ID from packet (from MAC field)
 	 */
-	inline bool shouldInboundPathBeTrusted(const InetAddress &physicalAddress,const uint64_t trustedPathId)
+	ZT_ALWAYS_INLINE bool shouldInboundPathBeTrusted(const InetAddress &physicalAddress,const uint64_t trustedPathId)
 	{
 		for(unsigned int i=0,j=_numConfiguredPhysicalPaths;i<j;++i) {
 			if ((_physicalPathConfig[i].second.trustedPathId == trustedPathId)&&(_physicalPathConfig[i].first.containsAddress(physicalAddress)))
@@ -385,7 +385,7 @@ public:
 	/**
 	 * Set or clear physical path configuration (called via Node::setPhysicalPathConfiguration)
 	 */
-	inline void setPhysicalPathConfiguration(const struct sockaddr_storage *pathNetwork,const ZT_PhysicalPathConfiguration *pathConfig)
+	ZT_ALWAYS_INLINE void setPhysicalPathConfiguration(const struct sockaddr_storage *pathNetwork,const ZT_PhysicalPathConfiguration *pathConfig)
 	{
 		if (!pathNetwork) {
 			_numConfiguredPhysicalPaths = 0;

+ 8 - 10
node/Trace.hpp

@@ -75,34 +75,32 @@ public:
 	class RuleResultLog
 	{
 	public:
-		inline RuleResultLog() {}
+		ZT_ALWAYS_INLINE RuleResultLog() {}
 
-		inline void log(const unsigned int rn,const uint8_t thisRuleMatches,const uint8_t thisSetMatches)
+		ZT_ALWAYS_INLINE void log(const unsigned int rn,const uint8_t thisRuleMatches,const uint8_t thisSetMatches)
 		{
 			_l[rn >> 1] |= ( ((thisRuleMatches + 1) << 2) | (thisSetMatches + 1) ) << ((rn & 1) << 2);
 		}
-		inline void logSkipped(const unsigned int rn,const uint8_t thisSetMatches)
+		ZT_ALWAYS_INLINE void logSkipped(const unsigned int rn,const uint8_t thisSetMatches)
 		{
 			_l[rn >> 1] |= (thisSetMatches + 1) << ((rn & 1) << 2);
 		}
 
-		inline void clear()
+		ZT_ALWAYS_INLINE void clear()
 		{
 			memset(_l,0,sizeof(_l));
 		}
 
-		inline const uint8_t *data() const { return _l; }
-		inline unsigned int sizeBytes() const { return (ZT_MAX_NETWORK_RULES / 2); }
+		ZT_ALWAYS_INLINE const uint8_t *data() const { return _l; }
+		ZT_ALWAYS_INLINE unsigned int sizeBytes() const { return (ZT_MAX_NETWORK_RULES / 2); }
 
 	private:
 		uint8_t _l[ZT_MAX_NETWORK_RULES / 2];
 	};
 
-	inline Trace(const RuntimeEnvironment *renv) :
+	ZT_ALWAYS_INLINE Trace(const RuntimeEnvironment *renv) :
 		RR(renv),
-		_byNet(8)
-	{
-	}
+		_byNet(8) {}
 
 	void resettingPathsInScope(void *const tPtr,const Address &reporter,const InetAddress &reporterPhysicalAddress,const InetAddress &myPhysicalAddress,const InetAddress::IpScope scope);
 	void peerConfirmingUnknownPath(void *const tPtr,const uint64_t networkId,Peer &peer,const SharedPtr<Path> &path,const uint64_t packetId,const Packet::Verb verb);