Browse Source

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

Adam Ierymenko 12 years ago
parent
commit
668c428051
6 changed files with 30 additions and 6 deletions
  1. 1 4
      Makefile.mac
  2. 1 1
      node/NodeConfig.cpp
  3. 1 0
      node/Packet.cpp
  4. 20 1
      node/Packet.hpp
  5. 6 0
      node/PacketDecoder.cpp
  6. 1 0
      node/PacketDecoder.hpp

+ 1 - 4
Makefile.mac

@@ -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
 

+ 1 - 1
node/NodeConfig.cpp

@@ -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());
 	}
 }
 

+ 1 - 0
node/Packet.cpp

@@ -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)";
 }

+ 20 - 1
node/Packet.hpp

@@ -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
 	};
 
 	/**

+ 6 - 0
node/PacketDecoder.cpp

@@ -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

+ 1 - 0
node/PacketDecoder.hpp

@@ -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;