|
INET Framework for OMNeT++/OMNEST
|
This class implements the corresponding module.
More...
#include <MessageDispatcher.h>
|
| virtual void | handleRegisterInterface (const NetworkInterface &interface, cGate *out, cGate *in) override |
| |
| virtual void | handleRegisterService (const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive) override |
| |
| virtual void | handleRegisterAnyService (cGate *gate, ServicePrimitive servicePrimitive) override |
| |
| virtual void | handleRegisterProtocol (const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive) override |
| |
| virtual void | handleRegisterAnyProtocol (cGate *gate, ServicePrimitive servicePrimitive) override |
| |
| virtual void | handleRegisterServiceGroup (const ProtocolGroup &protocolGroup, cGate *gate, ServicePrimitive servicePrimitive) override |
| |
| virtual void | handleRegisterProtocolGroup (const ProtocolGroup &protocolGroup, cGate *gate, ServicePrimitive servicePrimitive) override |
| |
|
| virtual void | initialize (int stage) override |
| |
| virtual void | arrived (cMessage *message, cGate *gate, const SendOptions &options, simtime_t time) override |
| |
| virtual cGate * | handlePacket (Packet *packet, cGate *inGate) |
| |
| virtual cGate * | handleMessage (Message *request, cGate *inGate) |
| |
This class implements the corresponding module.
See module documentation for more details.
◆ arrived()
| void inet::MessageDispatcher::arrived |
( |
cMessage * |
message, |
|
|
cGate * |
gate, |
|
|
const SendOptions & |
options, |
|
|
simtime_t |
time |
|
) |
| |
|
overrideprotectedvirtual |
40 cGate *outGate =
nullptr;
41 if (message->isPacket()) {
42 auto packet = check_and_cast<Packet *>(message);
44 #ifdef INET_WITH_QUEUEING
45 handlePacketProcessed(packet);
46 #endif // #ifdef INET_WITH_QUEUEING
49 outGate =
handleMessage(check_and_cast<Message *>(message), inGate);
50 outGate->deliver(message, options, time);
51 #ifdef INET_WITH_QUEUEING
52 updateDisplayString();
53 #endif // #ifdef INET_WITH_QUEUEING
◆ handleMessage()
| cGate * inet::MessageDispatcher::handleMessage |
( |
Message * |
request, |
|
|
cGate * |
inGate |
|
) |
| |
|
protectedvirtual |
207 const auto& socketReq = message->findTag<SocketReq>();
208 if (socketReq !=
nullptr) {
209 int socketReqId = socketReq->getSocketId();
213 else if (it->first != socketReqId)
214 throw cRuntimeError(
"handleMessage(): Socket is already registered: socketId = %d, current gateIndex = %d, new gateIndex = %d, pathStartGate = %s, pathEndGate = %s", socketReqId, it->second, inGate->getIndex(), inGate->getPathStartGate()->getFullPath().c_str(), inGate->getPathEndGate()->getFullPath().c_str());
216 const auto& socketInd = message->findTag<SocketInd>();
217 if (socketInd !=
nullptr) {
218 int socketId = socketInd->getSocketId();
221 auto outGate = gate(
"out", it->second);
226 throw cRuntimeError(
"handleMessage(): Unknown socket: socketId = %d, pathStartGate = %s, pathEndGate = %s", socketId, inGate->getPathStartGate()->getFullPath().c_str(), inGate->getPathEndGate()->getFullPath().c_str());
229 if (dispatchProtocolReq !=
nullptr) {
230 auto servicePrimitive = dispatchProtocolReq->getServicePrimitive();
234 auto protocol = dispatchProtocolReq->getProtocol();
238 auto outGate = gate(
"out", it->second);
245 auto outGate = gate(
"out", it->second);
250 throw cRuntimeError(
"handleMessage(): Unknown protocol: protocolId = %d, protocolName = %s, servicePrimitive = REQUEST, pathStartGate = %s, pathEndGate = %s",
protocol->getId(),
protocol->getName(), inGate->getPathStartGate()->getFullPath().c_str(), inGate->getPathEndGate()->getFullPath().c_str());
256 auto outGate = gate(
"out", it->second);
263 auto outGate = gate(
"out", it->second);
268 throw cRuntimeError(
"handleMessage(): Unknown protocol: protocolId = %d, protocolName = %s, servicePrimitive = INDICATION, pathStartGate = %s, pathEndGate = %s",
protocol->getId(),
protocol->getName(), inGate->getPathStartGate()->getFullPath().c_str(), inGate->getPathEndGate()->getFullPath().c_str());
272 throw cRuntimeError(
"handleMessage(): Unknown service primitive: servicePrimitive = %d, pathStartGate = %s, pathEndGate = %s",
static_cast<int>(servicePrimitive), inGate->getPathStartGate()->getFullPath().c_str(), inGate->getPathEndGate()->getFullPath().c_str());
274 const auto& interfaceReq = message->findTag<
InterfaceReq>();
275 if (interfaceReq !=
nullptr) {
276 int interfaceId = interfaceReq->getInterfaceId();
279 auto outGate = gate(
"out", it->second);
284 throw cRuntimeError(
"handleMessage(): Unknown interface: interfaceId = %d, pathStartGate = %s, pathEndGate = %s", interfaceId, inGate->getPathStartGate()->getFullPath().c_str(), inGate->getPathEndGate()->getFullPath().c_str());
286 throw cRuntimeError(
"handleMessage(): Unknown message: %s(%s), pathStartGate = %s, pathEndGate = %s", message->getName(), message->getClassName(), inGate->getPathStartGate()->getFullPath().c_str(), inGate->getPathEndGate()->getFullPath().c_str());
Referenced by arrived().
◆ handlePacket()
| cGate * inet::MessageDispatcher::handlePacket |
( |
Packet * |
packet, |
|
|
cGate * |
inGate |
|
) |
| |
|
protectedvirtual |
127 const auto& socketInd = packet->findTag<SocketInd>();
128 if (socketInd !=
nullptr) {
129 int socketId = socketInd->getSocketId();
132 auto outGate = gate(
"out", it->second);
137 throw cRuntimeError(
"handlePacket(): Unknown socket: socketId = %d, pathStartGate = %s, pathEndGate = %s", socketId, inGate->getPathStartGate()->getFullPath().c_str(), inGate->getPathEndGate()->getFullPath().c_str());
140 if (dispatchProtocolReq !=
nullptr) {
142 auto servicePrimitive = dispatchProtocolReq->getServicePrimitive();
145 if (packetProtocolTag !=
nullptr && dispatchProtocolReq->getProtocol() == packetProtocolTag->getProtocol())
150 auto protocol = dispatchProtocolReq->getProtocol();
154 auto outGate = gate(
"out", it->second);
161 auto outGate = gate(
"out", it->second);
166 throw cRuntimeError(
"handlePacket(): Unknown protocol: protocolId = %d, protocolName = %s, servicePrimitive = REQUEST, pathStartGate = %s, pathEndGate = %s",
protocol->getId(),
protocol->getName(), inGate->getPathStartGate()->getFullPath().c_str(), inGate->getPathEndGate()->getFullPath().c_str());
172 auto outGate = gate(
"out", it->second);
179 auto outGate = gate(
"out", it->second);
184 throw cRuntimeError(
"handlePacket(): Unknown protocol: protocolId = %d, protocolName = %s, servicePrimitive = INDICATION, pathStartGate = %s, pathEndGate = %s",
protocol->getId(),
protocol->getName(), inGate->getPathStartGate()->getFullPath().c_str(), inGate->getPathEndGate()->getFullPath().c_str());
188 throw cRuntimeError(
"handlePacket(): Unknown service primitive: servicePrimitive = %d, pathStartGate = %s, pathEndGate = %s",
static_cast<int>(servicePrimitive), inGate->getPathStartGate()->getFullPath().c_str(), inGate->getPathEndGate()->getFullPath().c_str());
190 const auto& interfaceReq = packet->findTag<
InterfaceReq>();
191 if (interfaceReq !=
nullptr) {
192 int interfaceId = interfaceReq->getInterfaceId();
195 auto outGate = gate(
"out", it->second);
200 throw cRuntimeError(
"handlePacket(): Unknown interface: interfaceId = %d, pathStartGate = %s, pathEndGate = %s", interfaceId, inGate->getPathStartGate()->getFullPath().c_str(), inGate->getPathEndGate()->getFullPath().c_str());
202 throw cRuntimeError(
"handlePacket(): Unknown packet: %s(%s), pathStartGate = %s, pathEndGate = %s", packet->getName(), packet->getClassName(), inGate->getPathStartGate()->getFullPath().c_str(), inGate->getPathEndGate()->getFullPath().c_str());
Referenced by arrived().
◆ handleRegisterAnyProtocol()
| void inet::MessageDispatcher::handleRegisterAnyProtocol |
( |
cGate * |
gate, |
|
|
ServicePrimitive |
servicePrimitive |
|
) |
| |
|
overridevirtual |
Reimplemented from inet::DefaultProtocolRegistrationListener.
378 auto key =
Key(-1, servicePrimitive);
381 if (it->second !=
g->getIndex())
382 throw cRuntimeError(
"handleRegisterAnyProtocol(): any protocol is already registered: servicePrimitive = %d, pathStartGate = %s, pathEndGate = %s",
static_cast<int>(servicePrimitive),
g->getPathStartGate()->getFullPath().c_str(),
g->getPathEndGate()->getFullPath().c_str());
387 auto gateName =
g->getType() == cGate::INPUT ?
"out" :
"in";
388 int size = gateSize(gateName);
389 for (
int i = 0; i < size; i++)
◆ handleRegisterAnyService()
| void inet::MessageDispatcher::handleRegisterAnyService |
( |
cGate * |
gate, |
|
|
ServicePrimitive |
servicePrimitive |
|
) |
| |
|
overridevirtual |
Reimplemented from inet::DefaultProtocolRegistrationListener.
324 auto key =
Key(-1, servicePrimitive);
327 if (it->second !=
g->getIndex())
328 throw cRuntimeError(
"handleRegisterAnyService(): any service is already registered: servicePrimitive = %d, pathStartGate = %s, pathEndGate = %s",
static_cast<int>(servicePrimitive),
g->getPathStartGate()->getFullPath().c_str(),
g->getPathEndGate()->getFullPath().c_str());
333 auto gateName =
g->getType() == cGate::INPUT ?
"out" :
"in";
334 int size = gateSize(gateName);
335 for (
int i = 0; i < size; i++)
◆ handleRegisterInterface()
| void inet::MessageDispatcher::handleRegisterInterface |
( |
const NetworkInterface & |
interface, |
|
|
cGate * |
out, |
|
|
cGate * |
in |
|
) |
| |
|
overridevirtual |
Implements inet::IInterfaceRegistrationListener.
403 if (it->second != out->getIndex())
404 throw cRuntimeError(
"handleRegisterInterface(): interface is already registered: interfaceId = %d, interfaceName = %s, pathStartGate = %s, pathEndGate = %s", interface.getInterfaceId(), interface.str().c_str(), out->getPathStartGate()->getFullPath().c_str(), out->getPathEndGate()->getFullPath().c_str());
408 int size = gateSize(
"out");
409 for (
int i = 0; i < size; i++)
410 if (i != in->getIndex())
◆ handleRegisterProtocol()
| void inet::MessageDispatcher::handleRegisterProtocol |
( |
const Protocol & |
protocol, |
|
|
cGate * |
gate, |
|
|
ServicePrimitive |
servicePrimitive |
|
) |
| |
|
overridevirtual |
Reimplemented from inet::DefaultProtocolRegistrationListener.
348 throw cRuntimeError(
"handleRegisterProtocol(): cannot register protocol while another registration is being done");
353 auto key =
Key(
protocol.getId(), servicePrimitive);
356 if (it->second !=
g->getIndex())
357 throw cRuntimeError(
"handleRegisterProtocol(): protocol is already registered: protocolId = %d, protocolName = %s, servicePrimitive = %d, pathStartGate = %s, pathEndGate = %s",
protocol.getId(),
protocol.str().c_str(),
static_cast<int>(servicePrimitive),
g->getPathStartGate()->getFullPath().c_str(),
g->getPathEndGate()->getFullPath().c_str());
362 auto gateName =
g->getType() == cGate::INPUT ?
"out" :
"in";
363 int size = gateSize(gateName);
364 for (
int i = 0; i < size; i++)
◆ handleRegisterService()
| void inet::MessageDispatcher::handleRegisterService |
( |
const Protocol & |
protocol, |
|
|
cGate * |
gate, |
|
|
ServicePrimitive |
servicePrimitive |
|
) |
| |
|
overridevirtual |
Reimplemented from inet::DefaultProtocolRegistrationListener.
294 throw cRuntimeError(
"handleRegisterService(): cannot register protocol while another registration is being done");
299 auto key =
Key(
protocol.getId(), servicePrimitive);
302 if (it->second !=
g->getIndex())
303 throw cRuntimeError(
"handleRegisterService(): service is already registered: protocolId = %d, protocolName = %s, servicePrimitive = %d, pathStartGate = %s, pathEndGate = %s",
protocol.getId(),
protocol.str().c_str(),
static_cast<int>(servicePrimitive),
g->getPathStartGate()->getFullPath().c_str(),
g->getPathEndGate()->getFullPath().c_str());
308 auto gateName =
g->getType() == cGate::INPUT ?
"out" :
"in";
309 int size = gateSize(gateName);
310 for (
int i = 0; i < size; i++)
◆ initialize()
| void inet::MessageDispatcher::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
24 #ifdef INET_WITH_QUEUEING
26 #endif // #ifdef INET_WITH_QUEUEING
◆ forwardProtocolRegistration
| bool inet::MessageDispatcher::forwardProtocolRegistration |
|
protected |
◆ forwardServiceRegistration
| bool inet::MessageDispatcher::forwardServiceRegistration |
|
protected |
◆ interfaceIdToGateIndex
| std::map<int, int> inet::MessageDispatcher::interfaceIdToGateIndex |
|
protected |
◆ protocolToGateIndex
| std::map<Key, int> inet::MessageDispatcher::protocolToGateIndex |
|
protected |
◆ registeringAny
| bool inet::MessageDispatcher::registeringAny = false |
|
protected |
◆ registeringProtocol
| const Protocol* inet::MessageDispatcher::registeringProtocol = nullptr |
|
protected |
◆ serviceToGateIndex
| std::map<Key, int> inet::MessageDispatcher::serviceToGateIndex |
|
protected |
◆ socketIdToGateIndex
| std::map<int, int> inet::MessageDispatcher::socketIdToGateIndex |
|
protected |
The documentation for this class was generated from the following files:
virtual void initialize(int stage) override
Definition: PacketProcessorBase.cc:16
bool forwardProtocolRegistration
Definition: MessageDispatcher.h:57
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down protocol
Definition: IUdp-gates.txt:25
bool registeringAny
Definition: MessageDispatcher.h:64
void registerAnyProtocol(cGate *gate, ServicePrimitive servicePrimitive)
Definition: IProtocolRegistrationListener.cc:129
removed InterfaceReq
Definition: IUdp-gates.txt:11
ServicePrimitive
Enum generated from inet/common/ProtocolTag.msg:53 by opp_msgtool.
Definition: ProtocolTag_m.h:172
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
const Protocol * registeringProtocol
Definition: MessageDispatcher.h:63
void registerAnyService(cGate *gate, ServicePrimitive servicePrimitive)
Definition: IProtocolRegistrationListener.cc:60
virtual cGate * handleMessage(Message *request, cGate *inGate)
Definition: MessageDispatcher.cc:205
void registerService(const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive)
Registers a service primitive (SDU processing) at the given gate.
Definition: IProtocolRegistrationListener.cc:14
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
virtual cGate * handlePacket(Packet *packet, cGate *inGate)
Definition: MessageDispatcher.cc:125
milli< kg >::type g
Definition: Units.h:1071
#define EV_FIELD(...)
Definition: INETDefs.h:112
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
std::map< Key, int > protocolToGateIndex
Definition: MessageDispatcher.h:62
bool forwardServiceRegistration
Definition: MessageDispatcher.h:56
std::map< Key, int > serviceToGateIndex
Definition: MessageDispatcher.h:61
@ SP_INDICATION
Definition: ProtocolTag_m.h:175
std::map< int, int > socketIdToGateIndex
Definition: MessageDispatcher.h:59
#define Enter_Method(...)
Definition: SelfDoc.h:71
void registerInterface(const NetworkInterface &interface, cGate *in, cGate *out)
Definition: IInterfaceRegistrationListener.cc:12
void * Key
Definition: Macho.h:327
void registerProtocol(const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive)
Registers a protocol primitive (PDU processing) at the given gate.
Definition: IProtocolRegistrationListener.cc:83
#define EV_ENDL
Definition: INETDefs.h:114
@ SP_REQUEST
Definition: ProtocolTag_m.h:174
std::map< int, int > interfaceIdToGateIndex
Definition: MessageDispatcher.h:60