62 if (msg->isSelfMessage()) {
65 if (rpcMessage != NULL) {
76 if (rpcMessage != NULL) {
126 cModule *mod = getParentModule();
129 mod = mod->getParentModule();
131 throw cRuntimeError(
"BaseRpc::initRpc: "
132 "Module type contains no NeighborCache!");
136 mod = getParentModule();
140 mod = mod->getParentModule();
142 throw cRuntimeError(
"BaseRpc::initRpc: CryptoModule not found!");
161 for (RpcStates::iterator i =
rpcStates.begin();
163 cancelAndDelete(i->second.callMsg);
164 cancelAndDelete(i->second.timeoutMsg);
165 delete i->second.dest;
166 i->second.dest = NULL;
167 delete i->second.context;
168 i->second.context = NULL;
178 cPolymorphic* context,
188 nonce = intuniform(1, 2147483647);
192 switch (transportType) {
208 throw cRuntimeError(
"BaseRpc::sendRpcMessage(): "
209 "Unknown RpcTransportType!");
213 if (rpcListener == NULL)
236 throw cRuntimeError(
"RPC nonce collision");
251 assert(!msg->getEncapsulatedPacket() || !msg->getEncapsulatedPacket()->getControlInfo());
261 std::vector<TransportAddress> sourceRoute;
262 sourceRoute.push_back(dest);
265 sourceRoute.insert(sourceRoute.begin(), dest.
getSourceRoute().rend(),
268 sourceRoute.back().clearSourceRoute();
271 sourceRoute, destKey, msg);
284 cancelAndDelete(state.
callMsg);
297 if (rpCall != NULL) {
310 bool rpcHandled =
true;
313 EV <<
"[BaseRpc::internalHandleRpcMessage() @ " <<
thisNode.
getIp()
315 <<
" Error: RPC '" << msg->getFullName()<<
"' was not handled"
327 EV <<
"[BaseRpc::internalHandleRpcMessage() @ " <<
thisNode.
getIp()
329 <<
" RPC: Nonce Unknown"
340 if (msg->isSelfMessage() &&
348 std::vector<TransportAddress> sourceRoute;
349 sourceRoute.push_back(*state.
dest);
351 sourceRoute.insert(sourceRoute.begin(),
355 sourceRoute.back().clearSourceRoute();
362 dynamic_cast<BaseCallMessage*>
370 scheduleAt(simTime() + state.
rto, msg);
376 EV <<
"[BaseRpc::internalHandleRpcMessage() @ " <<
thisNode.
getIp()
379 <<
" timeout (" << state.
callMsg->getName() <<
")"
415 if (stateHandle != NULL &&
418 EV <<
"[BaseRpc::internalHandleRpcMessage() @ "
421 <<
" Dropping RPC: Invalid source key"
432 simtime_t rtt = simTime() - state.
timeSent;
445 if (ncsArraySize > 0) {
446 std::vector<double> tempCoords(ncsArraySize);
447 for (uint8_t i = 0; i < ncsArraySize; i++) {
475 delete response->removeControlInfo();
502 cPolymorphic* context,
503 int rpcId, simtime_t rtt)
515 cPolymorphic* context,
539 if (call == NULL || response == NULL) {
540 throw cRuntimeError(
"call or response = NULL!");
545 std::vector<double> nodeCoord =
549 for (uint32_t i = 0; i < nodeCoord.size(); i++) {
568 if (dynamic_cast<OverlayCtrlInfo*>(call->getControlInfo())) {
573 delete call->removeControlInfo();
578 std::vector<TransportAddress> sourceRoute;
587 if (sourceRoute.size() == 0) {
589 sourceRoute.push_back(dest);
593 routingType, sourceRoute,
595 delete overlayCtrlInfo;
610 if (overlayCtrlInfo &&
613 static_cast<CompType>(overlayCtrlInfo->
getSrcComp()),
614 *destNode, *destKey, call, response);
623 const std::vector<TransportAddress>& sourceRoute,
627 switch (transportType) {
634 sourceRoute, routingType);
639 if (destCompGate == NULL) {
640 throw cRuntimeError(
"BaseRpc::sendRpcMessageWithTransport():"
641 " INTERNAL_RPC to unknown RpcCompType!");
647 message->setControlInfo(overlayCtrlInfo);
648 sendDirect(message, destCompGate);
652 throw cRuntimeError(
"BaseRpc::sendRpcMessageWithTransport: "
653 "invalid transportType!");
660 int rpcId, simtime_t rtt)
665 cPolymorphic* context,
int rpcId)
671 std::string pongName(call->getName());
672 if (pongName ==
"PING")
675 pongName =
"PONG: [ ";
676 pongName += call->getName();
683 response->getByteLength());
689 cPolymorphic* context,
int rpcId, simtime_t rtt)
696 cPolymorphic* context,
703 int retries, cPolymorphic* context,
714 return sendUdpRpcCall(dest, call, context, timeout, retries, rpcId,