197 int gateIndex = mplsPacket->getArrivalGate()->getIndex();
199 std::string senderInterface = ie->getName();
200 ASSERT(mplsPacket->hasLabel());
201 int oldLabel = mplsPacket->getTopLabel();
203 EV_INFO <<
"Received " << mplsPacket <<
" from L2, label=" << oldLabel <<
" inInterface=" << senderInterface << endl;
205 if (oldLabel == -1) {
208 EV_INFO <<
": decapsulating and sending up\n";
210 IPv4Datagram *ipdatagram = check_and_cast<IPv4Datagram *>(mplsPacket->decapsulate());
212 send(ipdatagram,
"netwOut", gateIndex);
217 std::string outInterface;
220 bool found =
lt->
resolveLabel(senderInterface, oldLabel, outLabel, outInterface, color);
222 EV_INFO <<
"discarding packet, incoming label not resolved" << endl;
232 if (mplsPacket->hasLabel()) {
235 EV_INFO <<
"forwarding packet to " << outInterface << endl;
237 if (mplsPacket->hasPar(
"color")) {
238 mplsPacket->par(
"color") = color;
241 mplsPacket->addPar(
"color") = color;
251 EV_INFO <<
"decapsulating IPv4 datagram" << endl;
253 IPv4Datagram *nativeIP = check_and_cast<IPv4Datagram *>(mplsPacket->decapsulate());
256 if (outgoingPort != -1) {
260 send(nativeIP,
"netwOut", gateIndex);
IInterfaceTable * ift
Definition: MPLS.h:46
std::vector< LabelOp > LabelOpVector
Definition: LIBTable.h:44
virtual InterfaceEntry * getInterfaceByName(const char *name) const =0
Returns an interface given by its name.
virtual InterfaceEntry * getInterfaceByNetworkLayerGateIndex(int index)=0
Returns an interface given by its getNetworkLayerGateIndex().
LIBTable * lt
Definition: MPLS.h:45
virtual void doStackOps(MPLSPacket *mplsPacket, const LabelOpVector &outLabel)
Definition: MPLS.cc:144
virtual bool resolveLabel(std::string inInterface, int inLabel, LabelOpVector &outLabel, std::string &outInterface, int &color)
Definition: LIBTable.cc:43
virtual void sendToL2(cMessage *msg, int gateIndex)
Definition: MPLS.cc:64