Basic RPC stuff in Packet and PacketDecoder for RPC service support.

This commit is contained in:
Adam Ierymenko 2013-07-23 22:46:04 -07:00
parent 10fc164fcb
commit 668c428051
6 changed files with 30 additions and 6 deletions

View File

@ -13,10 +13,7 @@ STRIP=strip
#STRIP=echo
CXXFLAGS=$(CFLAGS) -fno-rtti
# We statically link against libcrypto since Apple has apparently decided
# to deprecate it and may remove it in future OS releases.
LIBS=ext/bin/libcrypto/mac-x86_combined/libcrypto.a
LIBS=-lcrypto
include objects.mk

View File

@ -237,7 +237,7 @@ void NodeConfig::_CBcontrolPacketHandler(UdpSocket *sock,void *arg,const InetAdd
sock->send(remoteAddr,p->data(),p->size(),-1);
}
} catch ( ... ) {
TRACE("exception handling control bus packet from %s",remoteAddr.toString.c_str());
TRACE("exception handling control bus packet from %s",remoteAddr.toString().c_str());
}
}

View File

@ -42,6 +42,7 @@ const char *Packet::verbString(Verb v)
case VERB_FRAME: return "FRAME";
case VERB_MULTICAST_FRAME: return "MULTICAST_FRAME";
case VERB_MULTICAST_LIKE: return "MULTICAST_LIKE";
case VERB_RPC: return "RPC";
}
return "(unknown)";
}

View File

@ -463,7 +463,26 @@ public:
*
* No OK or ERROR is generated.
*/
VERB_MULTICAST_FRAME = 9
VERB_MULTICAST_FRAME = 9,
/* Call a plugin via RPC:
* <[1] length of function name>
* <[...] function name>
* [<[2] length of argument>]
* [<[...] argument>]
* [... additional length/argument pairs ...]
*
* This generates ERROR_NOT_FOUND if the specified function was not
* found. Otherwise it generates an OK message. The OK message has
* the same format as the request, except arguments are replaced
* by results.
*
* This can be used to implement simple RPC. No retransmission or
* other guarantees are made, so it behaves like UDP-based RPC
* protocols. Plugins are typically run by supernodes and are used
* to implement network lookup and other services.
*/
VERB_RPC = 10
};
/**

View File

@ -102,6 +102,8 @@ bool PacketDecoder::tryDecode(const RuntimeEnvironment *_r)
return _doMULTICAST_LIKE(_r,peer);
case Packet::VERB_MULTICAST_FRAME:
return _doMULTICAST_FRAME(_r,peer);
case Packet::VERB_RPC:
return _doRPC(_r,peer);
default:
// This might be something from a new or old version of the protocol.
// Technically it passed HMAC so the packet is still valid, but we
@ -538,4 +540,8 @@ bool PacketDecoder::_doMULTICAST_FRAME(const RuntimeEnvironment *_r,const Shared
return true;
}
bool PacketDecoder::_doRPC(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
{
}
} // namespace ZeroTier

View File

@ -122,6 +122,7 @@ private:
bool _doFRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
bool _doMULTICAST_LIKE(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
bool _doMULTICAST_FRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
bool _doRPC(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
uint64_t _receiveTime;
Demarc::Port _localPort;