mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-18 18:56:24 +00:00
Last steps before test: parse OK(MULTICAST_GATHER) and OK(MULTICAST_FRAME)
This commit is contained in:
parent
49dc47ff38
commit
1109046782
@ -323,9 +323,18 @@ bool IncomingPacket::_doOK(const RuntimeEnvironment *RR,const SharedPtr<Peer> &p
|
||||
} break;
|
||||
|
||||
case Packet::VERB_MULTICAST_GATHER: {
|
||||
uint64_t nwid = at<uint64_t>(ZT_PROTO_VERB_MULTICAST_GATHER__OK__IDX_NETWORK_ID);
|
||||
MulticastGroup mg(MAC(field(ZT_PROTO_VERB_MULTICAST_GATHER__OK__IDX_MAC,6),6),at<uint32_t>(ZT_PROTO_VERB_MULTICAST_GATHER__OK__IDX_ADI));
|
||||
_parseGatherResults(RR,peer,nwid,mg,ZT_PROTO_VERB_MULTICAST_GATHER__OK__IDX_GATHER_RESULTS);
|
||||
} break;
|
||||
|
||||
case Packet::VERB_MULTICAST_FRAME: {
|
||||
unsigned int flags = (*this)[ZT_PROTO_VERB_MULTICAST_FRAME__OK__IDX_FLAGS];
|
||||
if ((flags & 0x01) != 0) {
|
||||
uint64_t nwid = at<uint64_t>(ZT_PROTO_VERB_MULTICAST_FRAME__OK__IDX_NETWORK_ID);
|
||||
MulticastGroup mg(MAC(field(ZT_PROTO_VERB_MULTICAST_FRAME__OK__IDX_MAC,6),6),at<uint32_t>(ZT_PROTO_VERB_MULTICAST_FRAME__OK__IDX_ADI));
|
||||
_parseGatherResults(RR,peer,nwid,mg,ZT_PROTO_VERB_MULTICAST_FRAME__OK__IDX_GATHER_RESULTS);
|
||||
}
|
||||
} break;
|
||||
|
||||
default: break;
|
||||
@ -1022,4 +1031,22 @@ void IncomingPacket::_sendErrorNeedCertificate(const RuntimeEnvironment *RR,cons
|
||||
_fromSock->send(_remoteAddress,outp.data(),outp.size());
|
||||
}
|
||||
|
||||
void IncomingPacket::_parseGatherResults(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer,uint64_t nwid,const MulticastGroup &mg,unsigned int offset)
|
||||
{
|
||||
//unsigned int totalKnown = at<uint32_t>(offset);
|
||||
unsigned int count = at<uint16_t>(offset + 4);
|
||||
const unsigned char *p = (const unsigned char *)data() + offset + 6;
|
||||
const unsigned char *e = (const unsigned char *)data() + size();
|
||||
Address atmp;
|
||||
uint64_t now = Utils::now();
|
||||
for(unsigned int i=0;i<count;++i) {
|
||||
const unsigned char *n = p + ZT_ADDRESS_LENGTH;
|
||||
if (n > e)
|
||||
break;
|
||||
atmp.setTo(p,ZT_ADDRESS_LENGTH);
|
||||
RR->mc->add(now,nwid,mg,peer->address(),atmp);
|
||||
p = n;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ZeroTier
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "Utils.hpp"
|
||||
#include "SharedPtr.hpp"
|
||||
#include "AtomicCounter.hpp"
|
||||
#include "MulticastGroup.hpp"
|
||||
#include "Peer.hpp"
|
||||
#include "Socket.hpp"
|
||||
|
||||
@ -129,6 +130,9 @@ private:
|
||||
// Send an ERROR_NEED_MEMBERSHIP_CERTIFICATE to a peer indicating that an updated cert is needed to join
|
||||
void _sendErrorNeedCertificate(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer,uint64_t nwid);
|
||||
|
||||
// Parse gather results for OK(MULTICAST_GATHER) and OK(MULTICAST_FRAME)
|
||||
void _parseGatherResults(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer,uint64_t nwid,const MulticastGroup &mg,unsigned int offset);
|
||||
|
||||
uint64_t _receiveTime;
|
||||
SharedPtr<Socket> _fromSock;
|
||||
InetAddress _remoteAddress;
|
||||
|
@ -252,8 +252,10 @@ void Multicaster::_add(uint64_t now,uint64_t nwid,MulticastGroupStatus &gs,const
|
||||
// Update timestamp and learnedFrom if existing
|
||||
for(std::vector<MulticastGroupMember>::iterator m(gs.members.begin());m!=gs.members.end();++m) {
|
||||
if (m->address == member) {
|
||||
// learnedFrom is NULL (zero) if we've learned this directly via MULTICAST_LIKE, at which
|
||||
// point this becomes a first-order connection.
|
||||
if (m->learnedFrom)
|
||||
m->learnedFrom = learnedFrom; // only update with indirect learnedFrom if we've never directly learned from this peer
|
||||
m->learnedFrom = learnedFrom;
|
||||
m->timestamp = now;
|
||||
return;
|
||||
}
|
||||
|
@ -292,6 +292,17 @@
|
||||
#define ZT_PROTO_VERB_NETWORK_CONFIG_REQUEST__OK__IDX_DICT_LEN (ZT_PROTO_VERB_NETWORK_CONFIG_REQUEST__OK__IDX_NETWORK_ID + 8)
|
||||
#define ZT_PROTO_VERB_NETWORK_CONFIG_REQUEST__OK__IDX_DICT (ZT_PROTO_VERB_NETWORK_CONFIG_REQUEST__OK__IDX_DICT_LEN + 2)
|
||||
|
||||
#define ZT_PROTO_VERB_MULTICAST_GATHER__OK__IDX_NETWORK_ID (ZT_PROTO_VERB_OK_IDX_PAYLOAD)
|
||||
#define ZT_PROTO_VERB_MULTICAST_GATHER__OK__IDX_MAC (ZT_PROTO_VERB_MULTICAST_GATHER__OK__IDX_NETWORK_ID + 8)
|
||||
#define ZT_PROTO_VERB_MULTICAST_GATHER__OK__IDX_ADI (ZT_PROTO_VERB_MULTICAST_GATHER__OK__IDX_MAC + 6)
|
||||
#define ZT_PROTO_VERB_MULTICAST_GATHER__OK__IDX_GATHER_RESULTS (ZT_PROTO_VERB_MULTICAST_GATHER__OK__IDX_ADI + 4)
|
||||
|
||||
#define ZT_PROTO_VERB_MULTICAST_FRAME__OK__IDX_NETWORK_ID (ZT_PROTO_VERB_OK_IDX_PAYLOAD)
|
||||
#define ZT_PROTO_VERB_MULTICAST_FRAME__OK__IDX_MAC (ZT_PROTO_VERB_MULTICAST_FRAME__OK__IDX_NETWORK_ID + 8)
|
||||
#define ZT_PROTO_VERB_MULTICAST_FRAME__OK__IDX_ADI (ZT_PROTO_VERB_MULTICAST_FRAME__OK__IDX_MAC + 6)
|
||||
#define ZT_PROTO_VERB_MULTICAST_FRAME__OK__IDX_FLAGS (ZT_PROTO_VERB_MULTICAST_FRAME__OK__IDX_ADI + 4)
|
||||
#define ZT_PROTO_VERB_MULTICAST_FRAME__OK__IDX_GATHER_RESULTS (ZT_PROTO_VERB_MULTICAST_FRAME__OK__IDX_FLAGS + 1)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
namespace ZeroTier {
|
||||
|
Loading…
Reference in New Issue
Block a user