Wire up VERB_USER_MESSAGE in core.

This commit is contained in:
Adam Ierymenko 2017-01-09 15:55:07 -08:00
parent dbd577c6b0
commit d5528e4e9a
6 changed files with 99 additions and 3 deletions

View file

@ -473,6 +473,20 @@ void Node::clearLocalInterfaceAddresses()
_directPaths.clear();
}
int Node::sendUserMessage(uint64_t dest,uint64_t typeId,const void *data,unsigned int len)
{
try {
Packet outp(Address(dest),RR->identity.address(),Packet::VERB_USER_MESSAGE);
outp.append(typeId);
outp.append(data,len);
outp.compress();
RR->sw->send(outp,true);
return 1;
} catch ( ... ) {
return 0;
}
}
void Node::setRole(uint64_t ztAddress,ZT_PeerRole role)
{
RR->topology->setUpstream(Address(ztAddress),(role == ZT_PEER_ROLE_UPSTREAM));
@ -992,6 +1006,15 @@ void ZT_Node_clearLocalInterfaceAddresses(ZT_Node *node)
} catch ( ... ) {}
}
int ZT_Node_sendUserMessage(ZT_Node *node,uint64_t dest,uint64_t typeId,const void *data,unsigned int len)
{
try {
return reinterpret_cast<ZeroTier::Node *>(node)->sendUserMessage(dest,typeId,data,len);
} catch ( ... ) {
return 0;
}
}
void ZT_Node_setRole(ZT_Node *node,uint64_t ztAddress,ZT_PeerRole role)
{
try {