mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-02-21 10:01:46 +00:00
Deserialize new style netconf.
This commit is contained in:
parent
b9dba97fdb
commit
59eb09d063
@ -186,8 +186,8 @@ int Network::setConfiguration(const void *confBytes,unsigned int confLen,bool sa
|
|||||||
|
|
||||||
NetworkConfig newConfig;
|
NetworkConfig newConfig;
|
||||||
if (reinterpret_cast<const uint8_t *>(confBytes)[0] == ZT_NETWORKCONFIG_V2_MARKER_BYTE) {
|
if (reinterpret_cast<const uint8_t *>(confBytes)[0] == ZT_NETWORKCONFIG_V2_MARKER_BYTE) {
|
||||||
// TODO: deserialize new binary format netconf
|
Buffer<8194> tmp(confBytes,confLen);
|
||||||
return 0;
|
newConfig.deserialize(tmp,0);
|
||||||
} else {
|
} else {
|
||||||
#ifdef ZT_SUPPORT_OLD_STYLE_NETCONF
|
#ifdef ZT_SUPPORT_OLD_STYLE_NETCONF
|
||||||
newConfig.fromDictionary(reinterpret_cast<const char *>(confBytes),confLen); // throws if invalid
|
newConfig.fromDictionary(reinterpret_cast<const char *>(confBytes),confLen); // throws if invalid
|
||||||
|
@ -529,6 +529,8 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,7 +542,7 @@ public:
|
|||||||
unsigned int p = startAt;
|
unsigned int p = startAt;
|
||||||
|
|
||||||
if (b[p++] != ZT_NETWORKCONFIG_V2_MARKER_BYTE)
|
if (b[p++] != ZT_NETWORKCONFIG_V2_MARKER_BYTE)
|
||||||
throw std::invalid_argument("use fromDictionary() for old style netconf deserialization");
|
throw std::invalid_argument("unrecognized format");
|
||||||
if (b.template at<uint16_t>(p) != 0)
|
if (b.template at<uint16_t>(p) != 0)
|
||||||
throw std::invalid_argument("unrecognized version");
|
throw std::invalid_argument("unrecognized version");
|
||||||
p += 2;
|
p += 2;
|
||||||
@ -660,6 +662,8 @@ public:
|
|||||||
p += rlen;
|
p += rlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p += _com.deserialize(b,p);
|
||||||
|
|
||||||
p += b.template at<uint16_t>(p) + 2;
|
p += b.template at<uint16_t>(p) + 2;
|
||||||
|
|
||||||
return (p - startAt);
|
return (p - startAt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user