diff --git a/src/inet/linklayer/ethernet/base/EthernetMacBase.cc b/src/inet/linklayer/ethernet/base/EthernetMacBase.cc index 82116347f40e..93b614e2c78a 100644 --- a/src/inet/linklayer/ethernet/base/EthernetMacBase.cc +++ b/src/inet/linklayer/ethernet/base/EthernetMacBase.cc @@ -64,7 +64,10 @@ void EthernetMacBase::initialize(int stage) if (stage == INITSTAGE_LOCAL) { fcsMode = parseFcsMode(par("fcsMode")); allowNonstandardBitrate = par("allowNonstandardBitrate"); - upperLayerSink.reference(gate("upperLayerOut"), true); + DispatchProtocolReq dispatchProtocolReq; + dispatchProtocolReq.setProtocol(&Protocol::ethernetMac); + dispatchProtocolReq.setServicePrimitive(SP_INDICATION); + upperLayerSink.reference(gate("upperLayerOut"), true, &dispatchProtocolReq); physInGate = gate("phys$i"); physOutGate = gate("phys$o"); lowerLayerInGateId = physInGate->getId(); diff --git a/src/inet/linklayer/ethernet/basic/EthernetEncapsulation.cc b/src/inet/linklayer/ethernet/basic/EthernetEncapsulation.cc index 65ff20016108..d1e43db33b1a 100644 --- a/src/inet/linklayer/ethernet/basic/EthernetEncapsulation.cc +++ b/src/inet/linklayer/ethernet/basic/EthernetEncapsulation.cc @@ -66,7 +66,9 @@ void EthernetEncapsulation::initialize(int stage) WATCH(seqNum); totalFromHigherLayer = totalFromMAC = totalPauseSent = 0; interfaceTable.reference(this, "interfaceTableModule", true); - lowerLayerSink.reference(gate("lowerLayerOut"), true); + PacketProtocolTag packetProtocolTag; + packetProtocolTag.setProtocol(&Protocol::ethernetMac); + lowerLayerSink.reference(gate("lowerLayerOut"), true, &packetProtocolTag); upperLayerSink.reference(gate("upperLayerOut"), true); WATCH_PTRSET(upperProtocols); diff --git a/src/inet/networklayer/common/NetworkInterface.cc b/src/inet/networklayer/common/NetworkInterface.cc index a705f176eddd..98ee116c4918 100644 --- a/src/inet/networklayer/common/NetworkInterface.cc +++ b/src/inet/networklayer/common/NetworkInterface.cc @@ -121,8 +121,17 @@ void NetworkInterface::initialize(int stage) else wireless = rxIn == nullptr && txOut == nullptr; + if (hasPar("protocol")) { + const char *protocolName = par("protocol"); + if (*protocolName != '\0') + protocol = Protocol::getProtocol(protocolName); + } + upperLayerInConsumer.reference(upperLayerIn, false, nullptr, 1); - upperLayerOutConsumer.reference(upperLayerOut, false, nullptr, 1); + DispatchProtocolReq dispatchProtocolReq; + dispatchProtocolReq.setProtocol(protocol); + dispatchProtocolReq.setServicePrimitive(SP_INDICATION); + upperLayerOutConsumer.reference(upperLayerOut, false, protocol != nullptr ? &dispatchProtocolReq : nullptr, 1); interfaceTable.reference(this, "interfaceTableModule", false); setInterfaceName(utils::stripnonalnum(getFullName()).c_str()); setCarrier(computeCarrier()); @@ -145,11 +154,6 @@ void NetworkInterface::initialize(int stage) } } else if (stage == INITSTAGE_NETWORK_INTERFACE_CONFIGURATION) { - if (hasPar("protocol")) { - const char *protocolName = par("protocol"); - if (*protocolName != '\0') - protocol = Protocol::getProtocol(protocolName); - } if (hasPar("address")) { const char *address = par("address"); if (!strcmp(address, "auto")) { @@ -719,6 +723,9 @@ cGate *NetworkInterface::lookupModuleInterface(cGate *gate, const std::type_info auto interfaceReq = dynamic_cast(arguments); if (interfaceReq != nullptr && interfaceReq->getInterfaceId() == getInterfaceId()) return findModuleInterface(gate, type, interfaceReq == nullptr ? arguments : nullptr, 1); + auto packetProtocolTag = dynamic_cast(arguments); + if (packetProtocolTag != nullptr && hasPar("protocol") && !strcmp(packetProtocolTag->getProtocol()->getName(), par("protocol"))) + return findModuleInterface(gate, type, packetProtocolTag == nullptr ? arguments : nullptr, 1); } } else if (gate->isName("upperLayerOut")) {