mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-14 11:16:53 +02:00
Get rid of ZT_FAST_MEMCPY because this is not really needed.
This commit is contained in:
parent
d530356055
commit
2966eac64f
19 changed files with 76 additions and 114 deletions
|
@ -344,14 +344,14 @@ static bool _parseRule(json &r,ZT_VirtualNetworkRule &rule)
|
||||||
} else if (t == "MATCH_IPV6_SOURCE") {
|
} else if (t == "MATCH_IPV6_SOURCE") {
|
||||||
rule.t |= ZT_NETWORK_RULE_MATCH_IPV6_SOURCE;
|
rule.t |= ZT_NETWORK_RULE_MATCH_IPV6_SOURCE;
|
||||||
InetAddress ip(OSUtils::jsonString(r["ip"],"::0").c_str());
|
InetAddress ip(OSUtils::jsonString(r["ip"],"::0").c_str());
|
||||||
ZT_FAST_MEMCPY(rule.v.ipv6.ip,reinterpret_cast<struct sockaddr_in6 *>(&ip)->sin6_addr.s6_addr,16);
|
memcpy(rule.v.ipv6.ip,reinterpret_cast<struct sockaddr_in6 *>(&ip)->sin6_addr.s6_addr,16);
|
||||||
rule.v.ipv6.mask = Utils::ntoh(reinterpret_cast<struct sockaddr_in6 *>(&ip)->sin6_port) & 0xff;
|
rule.v.ipv6.mask = Utils::ntoh(reinterpret_cast<struct sockaddr_in6 *>(&ip)->sin6_port) & 0xff;
|
||||||
if (rule.v.ipv6.mask > 128) rule.v.ipv6.mask = 128;
|
if (rule.v.ipv6.mask > 128) rule.v.ipv6.mask = 128;
|
||||||
return true;
|
return true;
|
||||||
} else if (t == "MATCH_IPV6_DEST") {
|
} else if (t == "MATCH_IPV6_DEST") {
|
||||||
rule.t |= ZT_NETWORK_RULE_MATCH_IPV6_DEST;
|
rule.t |= ZT_NETWORK_RULE_MATCH_IPV6_DEST;
|
||||||
InetAddress ip(OSUtils::jsonString(r["ip"],"::0").c_str());
|
InetAddress ip(OSUtils::jsonString(r["ip"],"::0").c_str());
|
||||||
ZT_FAST_MEMCPY(rule.v.ipv6.ip,reinterpret_cast<struct sockaddr_in6 *>(&ip)->sin6_addr.s6_addr,16);
|
memcpy(rule.v.ipv6.ip,reinterpret_cast<struct sockaddr_in6 *>(&ip)->sin6_addr.s6_addr,16);
|
||||||
rule.v.ipv6.mask = Utils::ntoh(reinterpret_cast<struct sockaddr_in6 *>(&ip)->sin6_port) & 0xff;
|
rule.v.ipv6.mask = Utils::ntoh(reinterpret_cast<struct sockaddr_in6 *>(&ip)->sin6_port) & 0xff;
|
||||||
if (rule.v.ipv6.mask > 128) rule.v.ipv6.mask = 128;
|
if (rule.v.ipv6.mask > 128) rule.v.ipv6.mask = 128;
|
||||||
return true;
|
return true;
|
||||||
|
@ -1555,8 +1555,8 @@ void EmbeddedNetworkController::_request(
|
||||||
InetAddress ipRangeEnd(OSUtils::jsonString(pool["ipRangeEnd"],"").c_str());
|
InetAddress ipRangeEnd(OSUtils::jsonString(pool["ipRangeEnd"],"").c_str());
|
||||||
if ( (ipRangeStart.ss_family == AF_INET6) && (ipRangeEnd.ss_family == AF_INET6) ) {
|
if ( (ipRangeStart.ss_family == AF_INET6) && (ipRangeEnd.ss_family == AF_INET6) ) {
|
||||||
uint64_t s[2],e[2],x[2],xx[2];
|
uint64_t s[2],e[2],x[2],xx[2];
|
||||||
ZT_FAST_MEMCPY(s,ipRangeStart.rawIpData(),16);
|
memcpy(s,ipRangeStart.rawIpData(),16);
|
||||||
ZT_FAST_MEMCPY(e,ipRangeEnd.rawIpData(),16);
|
memcpy(e,ipRangeEnd.rawIpData(),16);
|
||||||
s[0] = Utils::ntoh(s[0]);
|
s[0] = Utils::ntoh(s[0]);
|
||||||
s[1] = Utils::ntoh(s[1]);
|
s[1] = Utils::ntoh(s[1]);
|
||||||
e[0] = Utils::ntoh(e[0]);
|
e[0] = Utils::ntoh(e[0]);
|
||||||
|
|
|
@ -116,9 +116,9 @@ public:
|
||||||
if (unlikely(b._l > C))
|
if (unlikely(b._l > C))
|
||||||
throw ZT_EXCEPTION_OUT_OF_BOUNDS;
|
throw ZT_EXCEPTION_OUT_OF_BOUNDS;
|
||||||
if (C2 == C) {
|
if (C2 == C) {
|
||||||
ZT_FAST_MEMCPY(this,&b,sizeof(Buffer<C>));
|
memcpy(this,&b,sizeof(Buffer<C>));
|
||||||
} else {
|
} else {
|
||||||
ZT_FAST_MEMCPY(_b,b._b,_l = b._l);
|
memcpy(_b,b._b,_l = b._l);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public:
|
||||||
{
|
{
|
||||||
if (unlikely(l > C))
|
if (unlikely(l > C))
|
||||||
throw ZT_EXCEPTION_OUT_OF_BOUNDS;
|
throw ZT_EXCEPTION_OUT_OF_BOUNDS;
|
||||||
ZT_FAST_MEMCPY(_b,b,l);
|
memcpy(_b,b,l);
|
||||||
_l = l;
|
_l = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ public:
|
||||||
{
|
{
|
||||||
if (unlikely((_l + l) > C))
|
if (unlikely((_l + l) > C))
|
||||||
throw ZT_EXCEPTION_OUT_OF_BOUNDS;
|
throw ZT_EXCEPTION_OUT_OF_BOUNDS;
|
||||||
ZT_FAST_MEMCPY(_b + _l,b,l);
|
memcpy(_b + _l,b,l);
|
||||||
_l += l;
|
_l += l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ public:
|
||||||
_maxCustodyChainLength = (mccl > 0) ? ((mccl < ZT_MAX_CAPABILITY_CUSTODY_CHAIN_LENGTH) ? mccl : (unsigned int)ZT_MAX_CAPABILITY_CUSTODY_CHAIN_LENGTH) : 1;
|
_maxCustodyChainLength = (mccl > 0) ? ((mccl < ZT_MAX_CAPABILITY_CUSTODY_CHAIN_LENGTH) ? mccl : (unsigned int)ZT_MAX_CAPABILITY_CUSTODY_CHAIN_LENGTH) : 1;
|
||||||
_ruleCount = (ruleCount < ZT_MAX_CAPABILITY_RULES) ? ruleCount : ZT_MAX_CAPABILITY_RULES;
|
_ruleCount = (ruleCount < ZT_MAX_CAPABILITY_RULES) ? ruleCount : ZT_MAX_CAPABILITY_RULES;
|
||||||
if (_ruleCount)
|
if (_ruleCount)
|
||||||
ZT_FAST_MEMCPY(_rules,rules,sizeof(ZT_VirtualNetworkRule) * _ruleCount);
|
memcpy(_rules,rules,sizeof(ZT_VirtualNetworkRule) * _ruleCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -320,16 +320,16 @@ public:
|
||||||
break;
|
break;
|
||||||
case ZT_NETWORK_RULE_MATCH_MAC_SOURCE:
|
case ZT_NETWORK_RULE_MATCH_MAC_SOURCE:
|
||||||
case ZT_NETWORK_RULE_MATCH_MAC_DEST:
|
case ZT_NETWORK_RULE_MATCH_MAC_DEST:
|
||||||
ZT_FAST_MEMCPY(rules[ruleCount].v.mac,b.field(p,6),6);
|
memcpy(rules[ruleCount].v.mac,b.field(p,6),6);
|
||||||
break;
|
break;
|
||||||
case ZT_NETWORK_RULE_MATCH_IPV4_SOURCE:
|
case ZT_NETWORK_RULE_MATCH_IPV4_SOURCE:
|
||||||
case ZT_NETWORK_RULE_MATCH_IPV4_DEST:
|
case ZT_NETWORK_RULE_MATCH_IPV4_DEST:
|
||||||
ZT_FAST_MEMCPY(&(rules[ruleCount].v.ipv4.ip),b.field(p,4),4);
|
memcpy(&(rules[ruleCount].v.ipv4.ip),b.field(p,4),4);
|
||||||
rules[ruleCount].v.ipv4.mask = (uint8_t)b[p + 4];
|
rules[ruleCount].v.ipv4.mask = (uint8_t)b[p + 4];
|
||||||
break;
|
break;
|
||||||
case ZT_NETWORK_RULE_MATCH_IPV6_SOURCE:
|
case ZT_NETWORK_RULE_MATCH_IPV6_SOURCE:
|
||||||
case ZT_NETWORK_RULE_MATCH_IPV6_DEST:
|
case ZT_NETWORK_RULE_MATCH_IPV6_DEST:
|
||||||
ZT_FAST_MEMCPY(rules[ruleCount].v.ipv6.ip,b.field(p,16),16);
|
memcpy(rules[ruleCount].v.ipv6.ip,b.field(p,16),16);
|
||||||
rules[ruleCount].v.ipv6.mask = (uint8_t)b[p + 16];
|
rules[ruleCount].v.ipv6.mask = (uint8_t)b[p + 16];
|
||||||
break;
|
break;
|
||||||
case ZT_NETWORK_RULE_MATCH_IP_TOS:
|
case ZT_NETWORK_RULE_MATCH_IP_TOS:
|
||||||
|
@ -452,7 +452,7 @@ public:
|
||||||
if (b.template at<uint16_t>(p) != ZT_C25519_SIGNATURE_LEN)
|
if (b.template at<uint16_t>(p) != ZT_C25519_SIGNATURE_LEN)
|
||||||
throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_INVALID_CRYPTOGRAPHIC_TOKEN;
|
throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_INVALID_CRYPTOGRAPHIC_TOKEN;
|
||||||
p += 2;
|
p += 2;
|
||||||
ZT_FAST_MEMCPY(_custody[i].signature.data,b.field(p,ZT_C25519_SIGNATURE_LEN),ZT_C25519_SIGNATURE_LEN); p += ZT_C25519_SIGNATURE_LEN;
|
memcpy(_custody[i].signature.data,b.field(p,ZT_C25519_SIGNATURE_LEN),ZT_C25519_SIGNATURE_LEN); p += ZT_C25519_SIGNATURE_LEN;
|
||||||
} else {
|
} else {
|
||||||
p += 2 + b.template at<uint16_t>(p);
|
p += 2 + b.template at<uint16_t>(p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ public:
|
||||||
|
|
||||||
CertificateOfMembership(const CertificateOfMembership &c)
|
CertificateOfMembership(const CertificateOfMembership &c)
|
||||||
{
|
{
|
||||||
ZT_FAST_MEMCPY(this,&c,sizeof(CertificateOfMembership));
|
memcpy(this,&c,sizeof(CertificateOfMembership));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,7 +147,7 @@ public:
|
||||||
|
|
||||||
inline CertificateOfMembership &operator=(const CertificateOfMembership &c)
|
inline CertificateOfMembership &operator=(const CertificateOfMembership &c)
|
||||||
{
|
{
|
||||||
ZT_FAST_MEMCPY(this,&c,sizeof(CertificateOfMembership));
|
memcpy(this,&c,sizeof(CertificateOfMembership));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ public:
|
||||||
p += ZT_ADDRESS_LENGTH;
|
p += ZT_ADDRESS_LENGTH;
|
||||||
|
|
||||||
if (_signedBy) {
|
if (_signedBy) {
|
||||||
ZT_FAST_MEMCPY(_signature.data,b.field(p,ZT_C25519_SIGNATURE_LEN),ZT_C25519_SIGNATURE_LEN);
|
memcpy(_signature.data,b.field(p,ZT_C25519_SIGNATURE_LEN),ZT_C25519_SIGNATURE_LEN);
|
||||||
p += ZT_C25519_SIGNATURE_LEN;
|
p += ZT_C25519_SIGNATURE_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,11 +115,11 @@ public:
|
||||||
if (_thingCount >= ZT_CERTIFICATEOFOWNERSHIP_MAX_THINGS) return;
|
if (_thingCount >= ZT_CERTIFICATEOFOWNERSHIP_MAX_THINGS) return;
|
||||||
if (ip.ss_family == AF_INET) {
|
if (ip.ss_family == AF_INET) {
|
||||||
_thingTypes[_thingCount] = THING_IPV4_ADDRESS;
|
_thingTypes[_thingCount] = THING_IPV4_ADDRESS;
|
||||||
ZT_FAST_MEMCPY(_thingValues[_thingCount],&(reinterpret_cast<const struct sockaddr_in *>(&ip)->sin_addr.s_addr),4);
|
memcpy(_thingValues[_thingCount],&(reinterpret_cast<const struct sockaddr_in *>(&ip)->sin_addr.s_addr),4);
|
||||||
++_thingCount;
|
++_thingCount;
|
||||||
} else if (ip.ss_family == AF_INET6) {
|
} else if (ip.ss_family == AF_INET6) {
|
||||||
_thingTypes[_thingCount] = THING_IPV6_ADDRESS;
|
_thingTypes[_thingCount] = THING_IPV6_ADDRESS;
|
||||||
ZT_FAST_MEMCPY(_thingValues[_thingCount],reinterpret_cast<const struct sockaddr_in6 *>(&ip)->sin6_addr.s6_addr,16);
|
memcpy(_thingValues[_thingCount],reinterpret_cast<const struct sockaddr_in6 *>(&ip)->sin6_addr.s6_addr,16);
|
||||||
++_thingCount;
|
++_thingCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ public:
|
||||||
for(unsigned int i=0,j=_thingCount;i<j;++i) {
|
for(unsigned int i=0,j=_thingCount;i<j;++i) {
|
||||||
if (i < ZT_CERTIFICATEOFOWNERSHIP_MAX_THINGS) {
|
if (i < ZT_CERTIFICATEOFOWNERSHIP_MAX_THINGS) {
|
||||||
_thingTypes[i] = (uint8_t)b[p++];
|
_thingTypes[i] = (uint8_t)b[p++];
|
||||||
ZT_FAST_MEMCPY(_thingValues[i],b.field(p,ZT_CERTIFICATEOFOWNERSHIP_MAX_THING_VALUE_SIZE),ZT_CERTIFICATEOFOWNERSHIP_MAX_THING_VALUE_SIZE);
|
memcpy(_thingValues[i],b.field(p,ZT_CERTIFICATEOFOWNERSHIP_MAX_THING_VALUE_SIZE),ZT_CERTIFICATEOFOWNERSHIP_MAX_THING_VALUE_SIZE);
|
||||||
p += ZT_CERTIFICATEOFOWNERSHIP_MAX_THING_VALUE_SIZE;
|
p += ZT_CERTIFICATEOFOWNERSHIP_MAX_THING_VALUE_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ public:
|
||||||
if (b.template at<uint16_t>(p) != ZT_C25519_SIGNATURE_LEN)
|
if (b.template at<uint16_t>(p) != ZT_C25519_SIGNATURE_LEN)
|
||||||
throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_INVALID_CRYPTOGRAPHIC_TOKEN;
|
throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_INVALID_CRYPTOGRAPHIC_TOKEN;
|
||||||
p += 2;
|
p += 2;
|
||||||
ZT_FAST_MEMCPY(_signature.data,b.field(p,ZT_C25519_SIGNATURE_LEN),ZT_C25519_SIGNATURE_LEN); p += ZT_C25519_SIGNATURE_LEN;
|
memcpy(_signature.data,b.field(p,ZT_C25519_SIGNATURE_LEN),ZT_C25519_SIGNATURE_LEN); p += ZT_C25519_SIGNATURE_LEN;
|
||||||
} else {
|
} else {
|
||||||
p += 2 + b.template at<uint16_t>(p);
|
p += 2 + b.template at<uint16_t>(p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,7 +248,7 @@ public:
|
||||||
if (b[p++] != 0)
|
if (b[p++] != 0)
|
||||||
throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_INVALID_TYPE;
|
throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_INVALID_TYPE;
|
||||||
|
|
||||||
ZT_FAST_MEMCPY(_publicKey.data,b.field(p,ZT_C25519_PUBLIC_KEY_LEN),ZT_C25519_PUBLIC_KEY_LEN);
|
memcpy(_publicKey.data,b.field(p,ZT_C25519_PUBLIC_KEY_LEN),ZT_C25519_PUBLIC_KEY_LEN);
|
||||||
p += ZT_C25519_PUBLIC_KEY_LEN;
|
p += ZT_C25519_PUBLIC_KEY_LEN;
|
||||||
|
|
||||||
unsigned int privateKeyLength = (unsigned int)b[p++];
|
unsigned int privateKeyLength = (unsigned int)b[p++];
|
||||||
|
@ -256,7 +256,7 @@ public:
|
||||||
if (privateKeyLength != ZT_C25519_PRIVATE_KEY_LEN)
|
if (privateKeyLength != ZT_C25519_PRIVATE_KEY_LEN)
|
||||||
throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_INVALID_CRYPTOGRAPHIC_TOKEN;
|
throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_INVALID_CRYPTOGRAPHIC_TOKEN;
|
||||||
_privateKey = new C25519::Private();
|
_privateKey = new C25519::Private();
|
||||||
ZT_FAST_MEMCPY(_privateKey->data,b.field(p,ZT_C25519_PRIVATE_KEY_LEN),ZT_C25519_PRIVATE_KEY_LEN);
|
memcpy(_privateKey->data,b.field(p,ZT_C25519_PRIVATE_KEY_LEN),ZT_C25519_PRIVATE_KEY_LEN);
|
||||||
p += ZT_C25519_PRIVATE_KEY_LEN;
|
p += ZT_C25519_PRIVATE_KEY_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,13 +115,13 @@ void InetAddress::set(const void *ipBytes,unsigned int ipLen,unsigned int port)
|
||||||
memset(this,0,sizeof(InetAddress));
|
memset(this,0,sizeof(InetAddress));
|
||||||
if (ipLen == 4) {
|
if (ipLen == 4) {
|
||||||
uint32_t ipb[1];
|
uint32_t ipb[1];
|
||||||
ZT_FAST_MEMCPY(ipb,ipBytes,4);
|
memcpy(ipb,ipBytes,4);
|
||||||
ss_family = AF_INET;
|
ss_family = AF_INET;
|
||||||
reinterpret_cast<struct sockaddr_in *>(this)->sin_addr.s_addr = ipb[0];
|
reinterpret_cast<struct sockaddr_in *>(this)->sin_addr.s_addr = ipb[0];
|
||||||
reinterpret_cast<struct sockaddr_in *>(this)->sin_port = Utils::hton((uint16_t)port);
|
reinterpret_cast<struct sockaddr_in *>(this)->sin_port = Utils::hton((uint16_t)port);
|
||||||
} else if (ipLen == 16) {
|
} else if (ipLen == 16) {
|
||||||
ss_family = AF_INET6;
|
ss_family = AF_INET6;
|
||||||
ZT_FAST_MEMCPY(reinterpret_cast<struct sockaddr_in6 *>(this)->sin6_addr.s6_addr,ipBytes,16);
|
memcpy(reinterpret_cast<struct sockaddr_in6 *>(this)->sin6_addr.s6_addr,ipBytes,16);
|
||||||
reinterpret_cast<struct sockaddr_in6 *>(this)->sin6_port = Utils::hton((uint16_t)port);
|
reinterpret_cast<struct sockaddr_in6 *>(this)->sin6_port = Utils::hton((uint16_t)port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ InetAddress InetAddress::netmask() const
|
||||||
nm[0] = 0;
|
nm[0] = 0;
|
||||||
nm[1] = 0;
|
nm[1] = 0;
|
||||||
}
|
}
|
||||||
ZT_FAST_MEMCPY(reinterpret_cast<struct sockaddr_in6 *>(&r)->sin6_addr.s6_addr,nm,16);
|
memcpy(reinterpret_cast<struct sockaddr_in6 *>(&r)->sin6_addr.s6_addr,nm,16);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
|
@ -243,10 +243,10 @@ InetAddress InetAddress::network() const
|
||||||
case AF_INET6: {
|
case AF_INET6: {
|
||||||
uint64_t nm[2];
|
uint64_t nm[2];
|
||||||
const unsigned int bits = netmaskBits();
|
const unsigned int bits = netmaskBits();
|
||||||
ZT_FAST_MEMCPY(nm,reinterpret_cast<struct sockaddr_in6 *>(&r)->sin6_addr.s6_addr,16);
|
memcpy(nm,reinterpret_cast<struct sockaddr_in6 *>(&r)->sin6_addr.s6_addr,16);
|
||||||
nm[0] &= Utils::hton((uint64_t)((bits >= 64) ? 0xffffffffffffffffULL : (0xffffffffffffffffULL << (64 - bits))));
|
nm[0] &= Utils::hton((uint64_t)((bits >= 64) ? 0xffffffffffffffffULL : (0xffffffffffffffffULL << (64 - bits))));
|
||||||
nm[1] &= Utils::hton((uint64_t)((bits <= 64) ? 0ULL : (0xffffffffffffffffULL << (128 - bits))));
|
nm[1] &= Utils::hton((uint64_t)((bits <= 64) ? 0ULL : (0xffffffffffffffffULL << (128 - bits))));
|
||||||
ZT_FAST_MEMCPY(reinterpret_cast<struct sockaddr_in6 *>(&r)->sin6_addr.s6_addr,nm,16);
|
memcpy(reinterpret_cast<struct sockaddr_in6 *>(&r)->sin6_addr.s6_addr,nm,16);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -91,8 +91,8 @@ struct InetAddress : public sockaddr_storage
|
||||||
};
|
};
|
||||||
|
|
||||||
InetAddress() { memset(this,0,sizeof(InetAddress)); }
|
InetAddress() { memset(this,0,sizeof(InetAddress)); }
|
||||||
InetAddress(const InetAddress &a) { ZT_FAST_MEMCPY(this,&a,sizeof(InetAddress)); }
|
InetAddress(const InetAddress &a) { memcpy(this,&a,sizeof(InetAddress)); }
|
||||||
InetAddress(const InetAddress *a) { ZT_FAST_MEMCPY(this,a,sizeof(InetAddress)); }
|
InetAddress(const InetAddress *a) { memcpy(this,a,sizeof(InetAddress)); }
|
||||||
InetAddress(const struct sockaddr_storage &ss) { *this = ss; }
|
InetAddress(const struct sockaddr_storage &ss) { *this = ss; }
|
||||||
InetAddress(const struct sockaddr_storage *ss) { *this = ss; }
|
InetAddress(const struct sockaddr_storage *ss) { *this = ss; }
|
||||||
InetAddress(const struct sockaddr &sa) { *this = sa; }
|
InetAddress(const struct sockaddr &sa) { *this = sa; }
|
||||||
|
@ -108,28 +108,28 @@ struct InetAddress : public sockaddr_storage
|
||||||
inline InetAddress &operator=(const InetAddress &a)
|
inline InetAddress &operator=(const InetAddress &a)
|
||||||
{
|
{
|
||||||
if (&a != this)
|
if (&a != this)
|
||||||
ZT_FAST_MEMCPY(this,&a,sizeof(InetAddress));
|
memcpy(this,&a,sizeof(InetAddress));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline InetAddress &operator=(const InetAddress *a)
|
inline InetAddress &operator=(const InetAddress *a)
|
||||||
{
|
{
|
||||||
if (a != this)
|
if (a != this)
|
||||||
ZT_FAST_MEMCPY(this,a,sizeof(InetAddress));
|
memcpy(this,a,sizeof(InetAddress));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline InetAddress &operator=(const struct sockaddr_storage &ss)
|
inline InetAddress &operator=(const struct sockaddr_storage &ss)
|
||||||
{
|
{
|
||||||
if (reinterpret_cast<const InetAddress *>(&ss) != this)
|
if (reinterpret_cast<const InetAddress *>(&ss) != this)
|
||||||
ZT_FAST_MEMCPY(this,&ss,sizeof(InetAddress));
|
memcpy(this,&ss,sizeof(InetAddress));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline InetAddress &operator=(const struct sockaddr_storage *ss)
|
inline InetAddress &operator=(const struct sockaddr_storage *ss)
|
||||||
{
|
{
|
||||||
if (reinterpret_cast<const InetAddress *>(ss) != this)
|
if (reinterpret_cast<const InetAddress *>(ss) != this)
|
||||||
ZT_FAST_MEMCPY(this,ss,sizeof(InetAddress));
|
memcpy(this,ss,sizeof(InetAddress));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ struct InetAddress : public sockaddr_storage
|
||||||
{
|
{
|
||||||
if (reinterpret_cast<const InetAddress *>(&sa) != this) {
|
if (reinterpret_cast<const InetAddress *>(&sa) != this) {
|
||||||
memset(this,0,sizeof(InetAddress));
|
memset(this,0,sizeof(InetAddress));
|
||||||
ZT_FAST_MEMCPY(this,&sa,sizeof(struct sockaddr_in));
|
memcpy(this,&sa,sizeof(struct sockaddr_in));
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ struct InetAddress : public sockaddr_storage
|
||||||
{
|
{
|
||||||
if (reinterpret_cast<const InetAddress *>(sa) != this) {
|
if (reinterpret_cast<const InetAddress *>(sa) != this) {
|
||||||
memset(this,0,sizeof(InetAddress));
|
memset(this,0,sizeof(InetAddress));
|
||||||
ZT_FAST_MEMCPY(this,sa,sizeof(struct sockaddr_in));
|
memcpy(this,sa,sizeof(struct sockaddr_in));
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ struct InetAddress : public sockaddr_storage
|
||||||
{
|
{
|
||||||
if (reinterpret_cast<const InetAddress *>(&sa) != this) {
|
if (reinterpret_cast<const InetAddress *>(&sa) != this) {
|
||||||
memset(this,0,sizeof(InetAddress));
|
memset(this,0,sizeof(InetAddress));
|
||||||
ZT_FAST_MEMCPY(this,&sa,sizeof(struct sockaddr_in6));
|
memcpy(this,&sa,sizeof(struct sockaddr_in6));
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ struct InetAddress : public sockaddr_storage
|
||||||
{
|
{
|
||||||
if (reinterpret_cast<const InetAddress *>(sa) != this) {
|
if (reinterpret_cast<const InetAddress *>(sa) != this) {
|
||||||
memset(this,0,sizeof(InetAddress));
|
memset(this,0,sizeof(InetAddress));
|
||||||
ZT_FAST_MEMCPY(this,sa,sizeof(struct sockaddr_in6));
|
memcpy(this,sa,sizeof(struct sockaddr_in6));
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -175,10 +175,10 @@ struct InetAddress : public sockaddr_storage
|
||||||
memset(this,0,sizeof(InetAddress));
|
memset(this,0,sizeof(InetAddress));
|
||||||
switch(sa.sa_family) {
|
switch(sa.sa_family) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
ZT_FAST_MEMCPY(this,&sa,sizeof(struct sockaddr_in));
|
memcpy(this,&sa,sizeof(struct sockaddr_in));
|
||||||
break;
|
break;
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
ZT_FAST_MEMCPY(this,&sa,sizeof(struct sockaddr_in6));
|
memcpy(this,&sa,sizeof(struct sockaddr_in6));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,10 +191,10 @@ struct InetAddress : public sockaddr_storage
|
||||||
memset(this,0,sizeof(InetAddress));
|
memset(this,0,sizeof(InetAddress));
|
||||||
switch(sa->sa_family) {
|
switch(sa->sa_family) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
ZT_FAST_MEMCPY(this,sa,sizeof(struct sockaddr_in));
|
memcpy(this,sa,sizeof(struct sockaddr_in));
|
||||||
break;
|
break;
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
ZT_FAST_MEMCPY(this,sa,sizeof(struct sockaddr_in6));
|
memcpy(this,sa,sizeof(struct sockaddr_in6));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -388,7 +388,7 @@ struct InetAddress : public sockaddr_storage
|
||||||
break;
|
break;
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
r.ss_family = AF_INET6;
|
r.ss_family = AF_INET6;
|
||||||
ZT_FAST_MEMCPY(reinterpret_cast<struct sockaddr_in6 *>(&r)->sin6_addr.s6_addr,reinterpret_cast<const struct sockaddr_in6 *>(this)->sin6_addr.s6_addr,16);
|
memcpy(reinterpret_cast<struct sockaddr_in6 *>(&r)->sin6_addr.s6_addr,reinterpret_cast<const struct sockaddr_in6 *>(this)->sin6_addr.s6_addr,16);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
|
@ -537,12 +537,12 @@ struct InetAddress : public sockaddr_storage
|
||||||
return (unsigned int)(b.template at<uint16_t>(p) + 3); // other addresses begin with 16-bit non-inclusive length
|
return (unsigned int)(b.template at<uint16_t>(p) + 3); // other addresses begin with 16-bit non-inclusive length
|
||||||
case 0x04:
|
case 0x04:
|
||||||
ss_family = AF_INET;
|
ss_family = AF_INET;
|
||||||
ZT_FAST_MEMCPY(&(reinterpret_cast<struct sockaddr_in *>(this)->sin_addr.s_addr),b.field(p,4),4); p += 4;
|
memcpy(&(reinterpret_cast<struct sockaddr_in *>(this)->sin_addr.s_addr),b.field(p,4),4); p += 4;
|
||||||
reinterpret_cast<struct sockaddr_in *>(this)->sin_port = Utils::hton(b.template at<uint16_t>(p)); p += 2;
|
reinterpret_cast<struct sockaddr_in *>(this)->sin_port = Utils::hton(b.template at<uint16_t>(p)); p += 2;
|
||||||
break;
|
break;
|
||||||
case 0x06:
|
case 0x06:
|
||||||
ss_family = AF_INET6;
|
ss_family = AF_INET6;
|
||||||
ZT_FAST_MEMCPY(reinterpret_cast<struct sockaddr_in6 *>(this)->sin6_addr.s6_addr,b.field(p,16),16); p += 16;
|
memcpy(reinterpret_cast<struct sockaddr_in6 *>(this)->sin6_addr.s6_addr,b.field(p,16),16); p += 16;
|
||||||
reinterpret_cast<struct sockaddr_in *>(this)->sin_port = Utils::hton(b.template at<uint16_t>(p)); p += 2;
|
reinterpret_cast<struct sockaddr_in *>(this)->sin_port = Utils::hton(b.template at<uint16_t>(p)); p += 2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -976,7 +976,7 @@ uint64_t Network::handleConfigChunk(void *tPtr,const uint64_t packetId,const Add
|
||||||
return false;
|
return false;
|
||||||
c->haveChunkIds[c->haveChunks++] = chunkId;
|
c->haveChunkIds[c->haveChunks++] = chunkId;
|
||||||
|
|
||||||
ZT_FAST_MEMCPY(c->data.unsafeData() + chunkIndex,chunkData,chunkLen);
|
memcpy(c->data.unsafeData() + chunkIndex,chunkData,chunkLen);
|
||||||
c->haveBytes += chunkLen;
|
c->haveBytes += chunkLen;
|
||||||
|
|
||||||
if (c->haveBytes == totalLength) {
|
if (c->haveBytes == totalLength) {
|
||||||
|
@ -1417,7 +1417,7 @@ void Network::_externalConfig(ZT_VirtualNetworkConfig *ec) const
|
||||||
ec->assignedAddressCount = 0;
|
ec->assignedAddressCount = 0;
|
||||||
for(unsigned int i=0;i<ZT_MAX_ZT_ASSIGNED_ADDRESSES;++i) {
|
for(unsigned int i=0;i<ZT_MAX_ZT_ASSIGNED_ADDRESSES;++i) {
|
||||||
if (i < _config.staticIpCount) {
|
if (i < _config.staticIpCount) {
|
||||||
ZT_FAST_MEMCPY(&(ec->assignedAddresses[i]),&(_config.staticIps[i]),sizeof(struct sockaddr_storage));
|
memcpy(&(ec->assignedAddresses[i]),&(_config.staticIps[i]),sizeof(struct sockaddr_storage));
|
||||||
++ec->assignedAddressCount;
|
++ec->assignedAddressCount;
|
||||||
} else {
|
} else {
|
||||||
memset(&(ec->assignedAddresses[i]),0,sizeof(struct sockaddr_storage));
|
memset(&(ec->assignedAddresses[i]),0,sizeof(struct sockaddr_storage));
|
||||||
|
@ -1427,7 +1427,7 @@ void Network::_externalConfig(ZT_VirtualNetworkConfig *ec) const
|
||||||
ec->routeCount = 0;
|
ec->routeCount = 0;
|
||||||
for(unsigned int i=0;i<ZT_MAX_NETWORK_ROUTES;++i) {
|
for(unsigned int i=0;i<ZT_MAX_NETWORK_ROUTES;++i) {
|
||||||
if (i < _config.routeCount) {
|
if (i < _config.routeCount) {
|
||||||
ZT_FAST_MEMCPY(&(ec->routes[i]),&(_config.routes[i]),sizeof(ZT_VirtualNetworkRoute));
|
memcpy(&(ec->routes[i]),&(_config.routes[i]),sizeof(ZT_VirtualNetworkRoute));
|
||||||
++ec->routeCount;
|
++ec->routeCount;
|
||||||
} else {
|
} else {
|
||||||
memset(&(ec->routes[i]),0,sizeof(ZT_VirtualNetworkRoute));
|
memset(&(ec->routes[i]),0,sizeof(ZT_VirtualNetworkRoute));
|
||||||
|
|
|
@ -222,8 +222,8 @@ class NetworkConfig
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NetworkConfig() { memset(this,0,sizeof(NetworkConfig)); }
|
NetworkConfig() { memset(this,0,sizeof(NetworkConfig)); }
|
||||||
NetworkConfig(const NetworkConfig &nc) { ZT_FAST_MEMCPY(this,&nc,sizeof(NetworkConfig)); }
|
NetworkConfig(const NetworkConfig &nc) { memcpy(this,&nc,sizeof(NetworkConfig)); }
|
||||||
inline NetworkConfig &operator=(const NetworkConfig &nc) { ZT_FAST_MEMCPY(this,&nc,sizeof(NetworkConfig)); return *this; }
|
inline NetworkConfig &operator=(const NetworkConfig &nc) { memcpy(this,&nc,sizeof(NetworkConfig)); return *this; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write this network config to a dictionary for transport
|
* Write this network config to a dictionary for transport
|
||||||
|
|
|
@ -66,7 +66,7 @@ Node::Node(void *uptr,void *tptr,const struct ZT_Node_Callbacks *callbacks,int64
|
||||||
{
|
{
|
||||||
if (callbacks->version != 0)
|
if (callbacks->version != 0)
|
||||||
throw ZT_EXCEPTION_INVALID_ARGUMENT;
|
throw ZT_EXCEPTION_INVALID_ARGUMENT;
|
||||||
ZT_FAST_MEMCPY(&_cb,callbacks,sizeof(ZT_Node_Callbacks));
|
memcpy(&_cb,callbacks,sizeof(ZT_Node_Callbacks));
|
||||||
|
|
||||||
// Initialize non-cryptographic PRNG from a good random source
|
// Initialize non-cryptographic PRNG from a good random source
|
||||||
Utils::getSecureRandom((void *)_prngState,sizeof(_prngState));
|
Utils::getSecureRandom((void *)_prngState,sizeof(_prngState));
|
||||||
|
@ -494,7 +494,7 @@ ZT_PeerList *Node::peers() const
|
||||||
p->hadAggregateLink |= pi->second->hasAggregateLink();
|
p->hadAggregateLink |= pi->second->hasAggregateLink();
|
||||||
p->pathCount = 0;
|
p->pathCount = 0;
|
||||||
for(std::vector< SharedPtr<Path> >::iterator path(paths.begin());path!=paths.end();++path) {
|
for(std::vector< SharedPtr<Path> >::iterator path(paths.begin());path!=paths.end();++path) {
|
||||||
ZT_FAST_MEMCPY(&(p->paths[p->pathCount].address),&((*path)->address()),sizeof(struct sockaddr_storage));
|
memcpy(&(p->paths[p->pathCount].address),&((*path)->address()),sizeof(struct sockaddr_storage));
|
||||||
p->paths[p->pathCount].lastSend = (*path)->lastOut();
|
p->paths[p->pathCount].lastSend = (*path)->lastOut();
|
||||||
p->paths[p->pathCount].lastReceive = (*path)->lastIn();
|
p->paths[p->pathCount].lastReceive = (*path)->lastIn();
|
||||||
p->paths[p->pathCount].trustedPathId = RR->topology->getOutboundPathTrust((*path)->address());
|
p->paths[p->pathCount].trustedPathId = RR->topology->getOutboundPathTrust((*path)->address());
|
||||||
|
|
|
@ -78,7 +78,7 @@ void OutboundMulticast::init(
|
||||||
if (!disableCompression)
|
if (!disableCompression)
|
||||||
_packet.compress();
|
_packet.compress();
|
||||||
|
|
||||||
ZT_FAST_MEMCPY(_frameData,payload,_frameLen);
|
memcpy(_frameData,payload,_frameLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutboundMulticast::sendOnly(const RuntimeEnvironment *RR,void *tPtr,const Address &toAddr)
|
void OutboundMulticast::sendOnly(const RuntimeEnvironment *RR,void *tPtr,const Address &toAddr)
|
||||||
|
|
|
@ -257,23 +257,23 @@ static void LZ4_write32(void* memPtr, U32 value) { ((unalign*)memPtr)->u32 = val
|
||||||
#else /* safe and portable access through memcpy() */
|
#else /* safe and portable access through memcpy() */
|
||||||
static inline U16 LZ4_read16(const void* memPtr)
|
static inline U16 LZ4_read16(const void* memPtr)
|
||||||
{
|
{
|
||||||
U16 val; ZT_FAST_MEMCPY(&val, memPtr, sizeof(val)); return val;
|
U16 val; memcpy(&val, memPtr, sizeof(val)); return val;
|
||||||
}
|
}
|
||||||
static inline U32 LZ4_read32(const void* memPtr)
|
static inline U32 LZ4_read32(const void* memPtr)
|
||||||
{
|
{
|
||||||
U32 val; ZT_FAST_MEMCPY(&val, memPtr, sizeof(val)); return val;
|
U32 val; memcpy(&val, memPtr, sizeof(val)); return val;
|
||||||
}
|
}
|
||||||
static inline reg_t LZ4_read_ARCH(const void* memPtr)
|
static inline reg_t LZ4_read_ARCH(const void* memPtr)
|
||||||
{
|
{
|
||||||
reg_t val; ZT_FAST_MEMCPY(&val, memPtr, sizeof(val)); return val;
|
reg_t val; memcpy(&val, memPtr, sizeof(val)); return val;
|
||||||
}
|
}
|
||||||
static inline void LZ4_write16(void* memPtr, U16 value)
|
static inline void LZ4_write16(void* memPtr, U16 value)
|
||||||
{
|
{
|
||||||
ZT_FAST_MEMCPY(memPtr, &value, sizeof(value));
|
memcpy(memPtr, &value, sizeof(value));
|
||||||
}
|
}
|
||||||
static inline void LZ4_write32(void* memPtr, U32 value)
|
static inline void LZ4_write32(void* memPtr, U32 value)
|
||||||
{
|
{
|
||||||
ZT_FAST_MEMCPY(memPtr, &value, sizeof(value));
|
memcpy(memPtr, &value, sizeof(value));
|
||||||
}
|
}
|
||||||
#endif /* LZ4_FORCE_MEMORY_ACCESS */
|
#endif /* LZ4_FORCE_MEMORY_ACCESS */
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ static inline void LZ4_writeLE16(void* memPtr, U16 value)
|
||||||
|
|
||||||
static inline void LZ4_copy8(void* dst, const void* src)
|
static inline void LZ4_copy8(void* dst, const void* src)
|
||||||
{
|
{
|
||||||
ZT_FAST_MEMCPY(dst,src,8);
|
memcpy(dst,src,8);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void LZ4_wildCopy(void* dstPtr, const void* srcPtr, void* dstEnd)
|
static inline void LZ4_wildCopy(void* dstPtr, const void* srcPtr, void* dstEnd)
|
||||||
|
@ -667,7 +667,7 @@ _last_literals:
|
||||||
} else {
|
} else {
|
||||||
*op++ = (BYTE)(lastRun<<ML_BITS);
|
*op++ = (BYTE)(lastRun<<ML_BITS);
|
||||||
}
|
}
|
||||||
ZT_FAST_MEMCPY(op, anchor, lastRun);
|
memcpy(op, anchor, lastRun);
|
||||||
op += lastRun;
|
op += lastRun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -784,7 +784,7 @@ FORCE_INLINE int LZ4_decompress_generic(
|
||||||
if ((!endOnInput) && (cpy != oend)) goto _output_error; /* Error : block decoding must stop exactly there */
|
if ((!endOnInput) && (cpy != oend)) goto _output_error; /* Error : block decoding must stop exactly there */
|
||||||
if ((endOnInput) && ((ip+length != iend) || (cpy > oend))) goto _output_error; /* Error : input must be consumed */
|
if ((endOnInput) && ((ip+length != iend) || (cpy > oend))) goto _output_error; /* Error : input must be consumed */
|
||||||
}
|
}
|
||||||
ZT_FAST_MEMCPY(op, ip, length);
|
memcpy(op, ip, length);
|
||||||
ip += length;
|
ip += length;
|
||||||
op += length;
|
op += length;
|
||||||
break; /* Necessarily EOF, due to parsing restrictions */
|
break; /* Necessarily EOF, due to parsing restrictions */
|
||||||
|
@ -823,14 +823,14 @@ FORCE_INLINE int LZ4_decompress_generic(
|
||||||
/* match encompass external dictionary and current block */
|
/* match encompass external dictionary and current block */
|
||||||
size_t const copySize = (size_t)(lowPrefix-match);
|
size_t const copySize = (size_t)(lowPrefix-match);
|
||||||
size_t const restSize = length - copySize;
|
size_t const restSize = length - copySize;
|
||||||
ZT_FAST_MEMCPY(op, dictEnd - copySize, copySize);
|
memcpy(op, dictEnd - copySize, copySize);
|
||||||
op += copySize;
|
op += copySize;
|
||||||
if (restSize > (size_t)(op-lowPrefix)) { /* overlap copy */
|
if (restSize > (size_t)(op-lowPrefix)) { /* overlap copy */
|
||||||
BYTE* const endOfMatch = op + restSize;
|
BYTE* const endOfMatch = op + restSize;
|
||||||
const BYTE* copyFrom = lowPrefix;
|
const BYTE* copyFrom = lowPrefix;
|
||||||
while (op < endOfMatch) *op++ = *copyFrom++;
|
while (op < endOfMatch) *op++ = *copyFrom++;
|
||||||
} else {
|
} else {
|
||||||
ZT_FAST_MEMCPY(op, lowPrefix, restSize);
|
memcpy(op, lowPrefix, restSize);
|
||||||
op += restSize;
|
op += restSize;
|
||||||
} }
|
} }
|
||||||
continue;
|
continue;
|
||||||
|
@ -845,7 +845,7 @@ FORCE_INLINE int LZ4_decompress_generic(
|
||||||
op[2] = match[2];
|
op[2] = match[2];
|
||||||
op[3] = match[3];
|
op[3] = match[3];
|
||||||
match += dec32table[offset];
|
match += dec32table[offset];
|
||||||
ZT_FAST_MEMCPY(op+4, match, 4);
|
memcpy(op+4, match, 4);
|
||||||
match -= dec64;
|
match -= dec64;
|
||||||
} else { LZ4_copy8(op, match); match+=8; }
|
} else { LZ4_copy8(op, match); match+=8; }
|
||||||
op += 8;
|
op += 8;
|
||||||
|
@ -921,7 +921,7 @@ void Packet::armor(const void *key,bool encryptPayload)
|
||||||
s20.crypt12(payload,payload,payloadLen);
|
s20.crypt12(payload,payload,payloadLen);
|
||||||
uint64_t mac[2];
|
uint64_t mac[2];
|
||||||
Poly1305::compute(mac,payload,payloadLen,macKey);
|
Poly1305::compute(mac,payload,payloadLen,macKey);
|
||||||
ZT_FAST_MEMCPY(data + ZT_PACKET_IDX_MAC,mac,8);
|
memcpy(data + ZT_PACKET_IDX_MAC,mac,8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -993,7 +993,7 @@ bool Packet::compress()
|
||||||
if ((cl > 0)&&(cl < pl)) {
|
if ((cl > 0)&&(cl < pl)) {
|
||||||
data[ZT_PACKET_IDX_VERB] |= (char)ZT_PROTO_VERB_FLAG_COMPRESSED;
|
data[ZT_PACKET_IDX_VERB] |= (char)ZT_PROTO_VERB_FLAG_COMPRESSED;
|
||||||
setSize((unsigned int)cl + ZT_PACKET_IDX_PAYLOAD);
|
setSize((unsigned int)cl + ZT_PACKET_IDX_PAYLOAD);
|
||||||
ZT_FAST_MEMCPY(data + ZT_PACKET_IDX_PAYLOAD,buf,cl);
|
memcpy(data + ZT_PACKET_IDX_PAYLOAD,buf,cl);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1013,7 +1013,7 @@ bool Packet::uncompress()
|
||||||
int ucl = LZ4_decompress_safe((const char *)data + ZT_PACKET_IDX_PAYLOAD,buf,compLen,sizeof(buf));
|
int ucl = LZ4_decompress_safe((const char *)data + ZT_PACKET_IDX_PAYLOAD,buf,compLen,sizeof(buf));
|
||||||
if ((ucl > 0)&&(ucl <= (int)(capacity() - ZT_PACKET_IDX_PAYLOAD))) {
|
if ((ucl > 0)&&(ucl <= (int)(capacity() - ZT_PACKET_IDX_PAYLOAD))) {
|
||||||
setSize((unsigned int)ucl + ZT_PACKET_IDX_PAYLOAD);
|
setSize((unsigned int)ucl + ZT_PACKET_IDX_PAYLOAD);
|
||||||
ZT_FAST_MEMCPY(data + ZT_PACKET_IDX_PAYLOAD,buf,ucl);
|
memcpy(data + ZT_PACKET_IDX_PAYLOAD,buf,ucl);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,10 +77,10 @@ public:
|
||||||
_k[1] = (uint64_t)reinterpret_cast<const struct sockaddr_in *>(&r)->sin_port;
|
_k[1] = (uint64_t)reinterpret_cast<const struct sockaddr_in *>(&r)->sin_port;
|
||||||
_k[2] = (uint64_t)l;
|
_k[2] = (uint64_t)l;
|
||||||
} else if (r.ss_family == AF_INET6) {
|
} else if (r.ss_family == AF_INET6) {
|
||||||
ZT_FAST_MEMCPY(_k,reinterpret_cast<const struct sockaddr_in6 *>(&r)->sin6_addr.s6_addr,16);
|
memcpy(_k,reinterpret_cast<const struct sockaddr_in6 *>(&r)->sin6_addr.s6_addr,16);
|
||||||
_k[2] = ((uint64_t)reinterpret_cast<const struct sockaddr_in6 *>(&r)->sin6_port << 32) ^ (uint64_t)l;
|
_k[2] = ((uint64_t)reinterpret_cast<const struct sockaddr_in6 *>(&r)->sin6_port << 32) ^ (uint64_t)l;
|
||||||
} else {
|
} else {
|
||||||
ZT_FAST_MEMCPY(_k,&r,std::min(sizeof(_k),sizeof(InetAddress)));
|
memcpy(_k,&r,std::min(sizeof(_k),sizeof(InetAddress)));
|
||||||
_k[2] += (uint64_t)l;
|
_k[2] += (uint64_t)l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ public:
|
||||||
if (b[p++] == 1) {
|
if (b[p++] == 1) {
|
||||||
if (b.template at<uint16_t>(p) == ZT_C25519_SIGNATURE_LEN) {
|
if (b.template at<uint16_t>(p) == ZT_C25519_SIGNATURE_LEN) {
|
||||||
p += 2;
|
p += 2;
|
||||||
ZT_FAST_MEMCPY(_signature.data,b.field(p,ZT_C25519_SIGNATURE_LEN),ZT_C25519_SIGNATURE_LEN);
|
memcpy(_signature.data,b.field(p,ZT_C25519_SIGNATURE_LEN),ZT_C25519_SIGNATURE_LEN);
|
||||||
p += ZT_C25519_SIGNATURE_LEN;
|
p += ZT_C25519_SIGNATURE_LEN;
|
||||||
} else throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_INVALID_CRYPTOGRAPHIC_TOKEN;
|
} else throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_INVALID_CRYPTOGRAPHIC_TOKEN;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -163,7 +163,7 @@ public:
|
||||||
if (b.template at<uint16_t>(p) != ZT_C25519_SIGNATURE_LEN)
|
if (b.template at<uint16_t>(p) != ZT_C25519_SIGNATURE_LEN)
|
||||||
throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_INVALID_CRYPTOGRAPHIC_TOKEN;
|
throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_INVALID_CRYPTOGRAPHIC_TOKEN;
|
||||||
p += 2;
|
p += 2;
|
||||||
ZT_FAST_MEMCPY(_signature.data,b.field(p,ZT_C25519_SIGNATURE_LEN),ZT_C25519_SIGNATURE_LEN); p += ZT_C25519_SIGNATURE_LEN;
|
memcpy(_signature.data,b.field(p,ZT_C25519_SIGNATURE_LEN),ZT_C25519_SIGNATURE_LEN); p += ZT_C25519_SIGNATURE_LEN;
|
||||||
} else {
|
} else {
|
||||||
p += 2 + b.template at<uint16_t>(p);
|
p += 2 + b.template at<uint16_t>(p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,44 +44,6 @@
|
||||||
|
|
||||||
#include "Constants.hpp"
|
#include "Constants.hpp"
|
||||||
|
|
||||||
#ifdef __LINUX__
|
|
||||||
//#if (defined(_MSC_VER) || defined(__GNUC__)) && (defined(__amd64) || defined(__amd64__) || defined(__x86_64) || defined(__x86_64__) || defined(__AMD64) || defined(__AMD64__) || defined(_M_X64))
|
|
||||||
#if 0
|
|
||||||
#include <emmintrin.h>
|
|
||||||
static inline void ZT_FAST_MEMCPY(void *a,const void *b,unsigned long k)
|
|
||||||
{
|
|
||||||
char *aa = reinterpret_cast<char *>(a);
|
|
||||||
const char *bb = reinterpret_cast<const char *>(b);
|
|
||||||
while (k >= 64) {
|
|
||||||
__m128 t1 = _mm_loadu_ps(reinterpret_cast<const float *>(bb));
|
|
||||||
__m128 t2 = _mm_loadu_ps(reinterpret_cast<const float *>(bb + 16));
|
|
||||||
__m128 t3 = _mm_loadu_ps(reinterpret_cast<const float *>(bb + 32));
|
|
||||||
__m128 t4 = _mm_loadu_ps(reinterpret_cast<const float *>(bb + 48));
|
|
||||||
_mm_storeu_ps(reinterpret_cast<float *>(aa),t1);
|
|
||||||
_mm_storeu_ps(reinterpret_cast<float *>(aa + 16),t2);
|
|
||||||
_mm_storeu_ps(reinterpret_cast<float *>(aa + 32),t3);
|
|
||||||
_mm_storeu_ps(reinterpret_cast<float *>(aa + 48),t4);
|
|
||||||
bb += 64;
|
|
||||||
aa += 64;
|
|
||||||
k -= 64;
|
|
||||||
}
|
|
||||||
while (k >= 16) {
|
|
||||||
__m128 t1 = _mm_loadu_ps(reinterpret_cast<const float *>(bb));
|
|
||||||
_mm_storeu_ps(reinterpret_cast<float *>(aa),t1);
|
|
||||||
bb += 16;
|
|
||||||
aa += 16;
|
|
||||||
k -= 16;
|
|
||||||
}
|
|
||||||
for(unsigned long i=0;i<k;++i)
|
|
||||||
aa[i] = bb[i];
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define ZT_FAST_MEMCPY(a,b,c) memcpy(a,b,c)
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define ZT_FAST_MEMCPY(a,b,c) memcpy(a,b,c)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -217,8 +217,8 @@ public:
|
||||||
|
|
||||||
_id = b.template at<uint64_t>(p); p += 8;
|
_id = b.template at<uint64_t>(p); p += 8;
|
||||||
_ts = b.template at<uint64_t>(p); p += 8;
|
_ts = b.template at<uint64_t>(p); p += 8;
|
||||||
ZT_FAST_MEMCPY(_updatesMustBeSignedBy.data,b.field(p,ZT_C25519_PUBLIC_KEY_LEN),ZT_C25519_PUBLIC_KEY_LEN); p += ZT_C25519_PUBLIC_KEY_LEN;
|
memcpy(_updatesMustBeSignedBy.data,b.field(p,ZT_C25519_PUBLIC_KEY_LEN),ZT_C25519_PUBLIC_KEY_LEN); p += ZT_C25519_PUBLIC_KEY_LEN;
|
||||||
ZT_FAST_MEMCPY(_signature.data,b.field(p,ZT_C25519_SIGNATURE_LEN),ZT_C25519_SIGNATURE_LEN); p += ZT_C25519_SIGNATURE_LEN;
|
memcpy(_signature.data,b.field(p,ZT_C25519_SIGNATURE_LEN),ZT_C25519_SIGNATURE_LEN); p += ZT_C25519_SIGNATURE_LEN;
|
||||||
const unsigned int numRoots = (unsigned int)b[p++];
|
const unsigned int numRoots = (unsigned int)b[p++];
|
||||||
if (numRoots > ZT_WORLD_MAX_ROOTS)
|
if (numRoots > ZT_WORLD_MAX_ROOTS)
|
||||||
throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_OVERFLOW;
|
throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_OVERFLOW;
|
||||||
|
|
|
@ -1926,9 +1926,9 @@ public:
|
||||||
|
|
||||||
pkt->now = now;
|
pkt->now = now;
|
||||||
pkt->sock = reinterpret_cast<int64_t>(sock);
|
pkt->sock = reinterpret_cast<int64_t>(sock);
|
||||||
ZT_FAST_MEMCPY(&(pkt->from),from,sizeof(struct sockaddr_storage));
|
memcpy(&(pkt->from),from,sizeof(struct sockaddr_storage));
|
||||||
pkt->size = (unsigned int)len;
|
pkt->size = (unsigned int)len;
|
||||||
ZT_FAST_MEMCPY(pkt->data,data,len);
|
memcpy(pkt->data,data,len);
|
||||||
|
|
||||||
_incomingPacketQueue.postLimit(pkt,16 * _incomingPacketConcurrency);
|
_incomingPacketQueue.postLimit(pkt,16 * _incomingPacketConcurrency);
|
||||||
}
|
}
|
||||||
|
@ -2247,7 +2247,7 @@ public:
|
||||||
// After setting up tap, fall through to CONFIG_UPDATE since we also want to do this...
|
// After setting up tap, fall through to CONFIG_UPDATE since we also want to do this...
|
||||||
|
|
||||||
case ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE:
|
case ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE:
|
||||||
ZT_FAST_MEMCPY(&(n.config),nwc,sizeof(ZT_VirtualNetworkConfig));
|
memcpy(&(n.config),nwc,sizeof(ZT_VirtualNetworkConfig));
|
||||||
if (n.tap) { // sanity check
|
if (n.tap) { // sanity check
|
||||||
#if defined(__WINDOWS__) && !defined(ZT_SDK)
|
#if defined(__WINDOWS__) && !defined(ZT_SDK)
|
||||||
// wait for up to 5 seconds for the WindowsEthernetTap to actually be initialized
|
// wait for up to 5 seconds for the WindowsEthernetTap to actually be initialized
|
||||||
|
@ -2754,7 +2754,7 @@ public:
|
||||||
else return 0;
|
else return 0;
|
||||||
const std::vector<InetAddress> *l = lh->get(ztaddr);
|
const std::vector<InetAddress> *l = lh->get(ztaddr);
|
||||||
if ((l)&&(l->size() > 0)) {
|
if ((l)&&(l->size() > 0)) {
|
||||||
ZT_FAST_MEMCPY(result,&((*l)[(unsigned long)_node->prng() % l->size()]),sizeof(struct sockaddr_storage));
|
memcpy(result,&((*l)[(unsigned long)_node->prng() % l->size()]),sizeof(struct sockaddr_storage));
|
||||||
return 1;
|
return 1;
|
||||||
} else return 0;
|
} else return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue