diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2019-08-02 20:43:02 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2019-08-02 20:43:02 -0700 |
| commit | 75ebe5172f6eac21f2d113efae478c4b01f2fd0c (patch) | |
| tree | e4ebd156d0d3ed1f9d5917101d5c3321a74181d2 /node/Membership.cpp | |
| parent | 4a9030b4a0aaee695b5affaa360d77977dd558b7 (diff) | |
| download | infinitytier-75ebe5172f6eac21f2d113efae478c4b01f2fd0c.tar.gz infinitytier-75ebe5172f6eac21f2d113efae478c4b01f2fd0c.zip | |
Fix for sharing of capabilities in 1.4 (problem introduced when push frequency was reduced)
Diffstat (limited to 'node/Membership.cpp')
| -rw-r--r-- | node/Membership.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/node/Membership.cpp b/node/Membership.cpp index 92dd30cb..031eb0b7 100644 --- a/node/Membership.cpp +++ b/node/Membership.cpp @@ -48,9 +48,12 @@ Membership::Membership() : { } -void Membership::pushCredentials(const RuntimeEnvironment *RR,void *tPtr,const int64_t now,const Address &peerAddress,const NetworkConfig &nconf,int localCapabilityIndex) +void Membership::pushCredentials(const RuntimeEnvironment *RR,void *tPtr,const int64_t now,const Address &peerAddress,const NetworkConfig &nconf) { - const Capability *sendCap = (localCapabilityIndex >= 0) ? &(nconf.capabilities[localCapabilityIndex]) : (const Capability *)0; + const Capability *sendCaps[ZT_MAX_NETWORK_CAPABILITIES]; + unsigned int sendCapCount = 0; + for(unsigned int c=0;c<nconf.capabilityCount;++c) + sendCaps[sendCapCount++] = &(nconf.capabilities[c]); const Tag *sendTags[ZT_MAX_NETWORK_TAGS]; unsigned int sendTagCount = 0; @@ -62,10 +65,11 @@ void Membership::pushCredentials(const RuntimeEnvironment *RR,void *tPtr,const i for(unsigned int c=0;c<nconf.certificateOfOwnershipCount;++c) sendCoos[sendCooCount++] = &(nconf.certificatesOfOwnership[c]); + unsigned int capPtr = 0; unsigned int tagPtr = 0; unsigned int cooPtr = 0; bool sendCom = (bool)(nconf.com); - while ((tagPtr < sendTagCount)||(cooPtr < sendCooCount)||(sendCom)||(sendCap)) { + while ((capPtr < sendCapCount)||(tagPtr < sendTagCount)||(cooPtr < sendCooCount)||(sendCom)) { Packet outp(peerAddress,RR->identity.address(),Packet::VERB_NETWORK_CREDENTIALS); if (sendCom) { @@ -74,11 +78,14 @@ void Membership::pushCredentials(const RuntimeEnvironment *RR,void *tPtr,const i } outp.append((uint8_t)0x00); - if (sendCap) { - outp.append((uint16_t)1); - sendCap->serialize(outp); - sendCap = (const Capability *)0; - } else outp.append((uint16_t)0); + const unsigned int capCountAt = outp.size(); + outp.addSize(2); + unsigned int thisPacketCapCount = 0; + while ((capPtr < sendCapCount)&&((outp.size() + sizeof(Capability) + 16) < ZT_PROTO_MAX_PACKET_LENGTH)) { + sendCaps[capPtr++]->serialize(outp); + ++thisPacketCapCount; + } + outp.setAt(capCountAt,(uint16_t)thisPacketCapCount); const unsigned int tagCountAt = outp.size(); outp.addSize(2); |
