mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
Fix new binary meta-data deserialization and add some debug code (will disable later).
This commit is contained in:
parent
de1b745988
commit
93b673043c
3 changed files with 41 additions and 1 deletions
|
@ -207,6 +207,9 @@ int Network::setConfiguration(const void *confBytes,unsigned int confLen,bool sa
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!newConfig)
|
||||||
|
return 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
Mutex::Lock _l(_lock);
|
Mutex::Lock _l(_lock);
|
||||||
if (_config == newConfig)
|
if (_config == newConfig)
|
||||||
|
|
|
@ -353,6 +353,8 @@ public:
|
||||||
template<unsigned int C>
|
template<unsigned int C>
|
||||||
inline void serialize(Buffer<C> &b) const
|
inline void serialize(Buffer<C> &b) const
|
||||||
{
|
{
|
||||||
|
printf("!!! sending\n");
|
||||||
|
|
||||||
b.append((uint16_t)1); // version
|
b.append((uint16_t)1); // version
|
||||||
|
|
||||||
b.append((uint64_t)networkId);
|
b.append((uint64_t)networkId);
|
||||||
|
@ -471,6 +473,8 @@ public:
|
||||||
this->com.serialize(b);
|
this->com.serialize(b);
|
||||||
|
|
||||||
b.append((uint16_t)0); // extended bytes, currently 0 since unused
|
b.append((uint16_t)0); // extended bytes, currently 0 since unused
|
||||||
|
|
||||||
|
dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<unsigned int C>
|
template<unsigned int C>
|
||||||
|
@ -478,6 +482,8 @@ public:
|
||||||
{
|
{
|
||||||
memset(this,0,sizeof(NetworkConfig));
|
memset(this,0,sizeof(NetworkConfig));
|
||||||
|
|
||||||
|
printf("!!! deserializing\n");
|
||||||
|
|
||||||
unsigned int p = startAt;
|
unsigned int p = startAt;
|
||||||
|
|
||||||
if (b.template at<uint16_t>(p) != 1)
|
if (b.template at<uint16_t>(p) != 1)
|
||||||
|
@ -493,7 +499,7 @@ public:
|
||||||
type = (ZT_VirtualNetworkType)b[p++];
|
type = (ZT_VirtualNetworkType)b[p++];
|
||||||
|
|
||||||
unsigned int nl = (unsigned int)b[p++];
|
unsigned int nl = (unsigned int)b[p++];
|
||||||
memcpy(this->name,b.field(p,nl),std::max(nl,(unsigned int)ZT_MAX_NETWORK_SHORT_NAME_LENGTH));
|
memcpy(this->name,b.field(p,nl),std::min(nl,(unsigned int)ZT_MAX_NETWORK_SHORT_NAME_LENGTH));
|
||||||
p += nl;
|
p += nl;
|
||||||
// _name will always be null terminated since field size is ZT_MAX_NETWORK_SHORT_NAME_LENGTH + 1
|
// _name will always be null terminated since field size is ZT_MAX_NETWORK_SHORT_NAME_LENGTH + 1
|
||||||
|
|
||||||
|
@ -602,6 +608,7 @@ public:
|
||||||
|
|
||||||
p += b.template at<uint16_t>(p) + 2;
|
p += b.template at<uint16_t>(p) + 2;
|
||||||
|
|
||||||
|
dump();
|
||||||
return (p - startAt);
|
return (p - startAt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -609,6 +616,35 @@ public:
|
||||||
void fromDictionary(const char *ds,unsigned int dslen);
|
void fromDictionary(const char *ds,unsigned int dslen);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
inline void dump() const
|
||||||
|
{
|
||||||
|
printf("networkId==%.16llx\n",networkId);
|
||||||
|
printf("timestamp==%llu\n",timestamp);
|
||||||
|
printf("revision==%llu\n",revision);
|
||||||
|
printf("issuedTo==%.10llx\n",issuedTo.toInt());
|
||||||
|
printf("multicastLimit==%u\n",multicastLimit);
|
||||||
|
printf("flags=%.8lx\n",(unsigned long)flags);
|
||||||
|
printf("specialistCount==%u\n",specialistCount);
|
||||||
|
for(unsigned int i=0;i<specialistCount;++i)
|
||||||
|
printf(" specialists[%u]==%.16llx\n",i,specialists[i]);
|
||||||
|
printf("routeCount==%u\n",routeCount);
|
||||||
|
for(unsigned int i=0;i<routeCount;++i) {
|
||||||
|
printf(" routes[i].target==%s\n",reinterpret_cast<const struct sockaddr_storage *>(&(routes[i].target))->toString().c_str());
|
||||||
|
printf(" routes[i].via==%s\n",reinterpret_cast<const struct sockaddr_storage *>(&(routes[i].via))->toString().c_str());
|
||||||
|
}
|
||||||
|
printf("staticIpCount==%u\n",staticIpCount);
|
||||||
|
for(unsigned int i=0;i<staticIpCount;++i)
|
||||||
|
printf(" staticIps[i]==%s\n",staticIps[i].toString().c_str());
|
||||||
|
printf("pinnedCount==%u\n",pinnedCount);
|
||||||
|
for(unsigned int i=0;i<pinnedCount;++i) {
|
||||||
|
printf(" pinned[i].zt==%s\n",pinned[i].zt->toString().c_str());
|
||||||
|
printf(" pinned[i].phy==%s\n",pinned[i].zt->toString().c_str());
|
||||||
|
}
|
||||||
|
printf("ruleCount==%u\n",ruleCount);
|
||||||
|
printf("name==%s\n",name);
|
||||||
|
printf("com==%s\n",com.toString().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Network ID that this configuration applies to
|
* Network ID that this configuration applies to
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -115,6 +115,7 @@ public:
|
||||||
|
|
||||||
// Seek past old style meta-data
|
// Seek past old style meta-data
|
||||||
while (b[p]) ++p;
|
while (b[p]) ++p;
|
||||||
|
++p;
|
||||||
|
|
||||||
if (b.template at<uint16_t>(p) != 1)
|
if (b.template at<uint16_t>(p) != 1)
|
||||||
throw std::invalid_argument("unrecognized version");
|
throw std::invalid_argument("unrecognized version");
|
||||||
|
|
Loading…
Add table
Reference in a new issue