From 79e36350a12d8dec04485089e4114100d1075b10 Mon Sep 17 00:00:00 2001
From: Markus Brueckner
Date: Fri, 25 Jan 2013 16:48:19 +0100
Subject: [PATCH 1/5] - added: IP Option Router Alert handling in IPv4
---
src/applications/generic/IPvXTrafGen.cc | 2 ++
src/applications/generic/IPvXTrafGen.h | 1 +
src/applications/generic/IPvXTrafGen.ned | 1 +
src/networklayer/common/IRouterAlertHandler.h | 15 +++++++++++
.../common/IRouterAlertHandler.ned | 26 +++++++++++++++++++
src/networklayer/contract/IPv4ControlInfo.msg | 1 +
src/networklayer/ipv4/IPv4.cc | 20 +++++++++++++-
src/networklayer/ipv4/IPv4.ned | 2 ++
src/nodes/inet/NetworkLayer.ned | 20 ++++++++++----
src/nodes/inet/NodeBase.ned | 14 +++++-----
10 files changed, 89 insertions(+), 13 deletions(-)
create mode 100644 src/networklayer/common/IRouterAlertHandler.h
create mode 100644 src/networklayer/common/IRouterAlertHandler.ned
diff --git a/src/applications/generic/IPvXTrafGen.cc b/src/applications/generic/IPvXTrafGen.cc
index e449f5d1522..5241e5b4c3d 100644
--- a/src/applications/generic/IPvXTrafGen.cc
+++ b/src/applications/generic/IPvXTrafGen.cc
@@ -45,6 +45,7 @@ void IPvXTrafGen::initialize(int stage)
stopTime = par("stopTime");
if (stopTime != 0 && stopTime <= startTime)
error("Invalid startTime/stopTime parameters");
+ optionCode = par("optionCode");
const char *destAddrs = par("destAddresses");
cStringTokenizer tokenizer(destAddrs);
@@ -92,6 +93,7 @@ void IPvXTrafGen::sendPacket()
IPv4ControlInfo *controlInfo = new IPv4ControlInfo();
controlInfo->setDestAddr(destAddr.get4());
controlInfo->setProtocol(protocol);
+ controlInfo->setOptions(optionCode);
payload->setControlInfo(controlInfo);
gate = "ipOut";
}
diff --git a/src/applications/generic/IPvXTrafGen.h b/src/applications/generic/IPvXTrafGen.h
index 01374c6c087..df7315482bd 100644
--- a/src/applications/generic/IPvXTrafGen.h
+++ b/src/applications/generic/IPvXTrafGen.h
@@ -39,6 +39,7 @@ class INET_API IPvXTrafGen : public IPvXTrafSink
simtime_t stopTime;
std::vector destAddresses;
cPar *packetLengthPar; // volatile packetLength parameter
+ int optionCode;
static int counter; // counter for generating a global number for each packet
diff --git a/src/applications/generic/IPvXTrafGen.ned b/src/applications/generic/IPvXTrafGen.ned
index 6fb50293f3d..fe7a18ed00f 100644
--- a/src/applications/generic/IPvXTrafGen.ned
+++ b/src/applications/generic/IPvXTrafGen.ned
@@ -41,6 +41,7 @@ simple IPvXTrafGen like IIPvXTrafficGenerator
int protocol; // value for ~IPv4ControlInfo / ~IPv6ControlInfo protocol field
volatile int packetLength @unit("B"); // packet length in bytes
string destAddresses = default(""); // list of destination addresses, separated by spaces
+ int optionCode = default(0); // the IPv4 option code header
@display("i=block/source");
@signal[sentPk](type=cPacket);
@signal[rcvdPk](type=cPacket);
diff --git a/src/networklayer/common/IRouterAlertHandler.h b/src/networklayer/common/IRouterAlertHandler.h
new file mode 100644
index 00000000000..da5e1644847
--- /dev/null
+++ b/src/networklayer/common/IRouterAlertHandler.h
@@ -0,0 +1,15 @@
+/*
+ * IRouterAlertHandler.h
+ *
+ * Created on: Jan 25, 2013
+ * Author: Markus Brueckner
+ */
+
+#ifndef IROUTERALERTHANDLER_H_
+#define IROUTERALERTHANDLER_H_
+
+class IRouterAlertHandler : public cSimpleModule
+{
+};
+
+#endif /* IROUTERALERTHANDLER_H_ */
diff --git a/src/networklayer/common/IRouterAlertHandler.ned b/src/networklayer/common/IRouterAlertHandler.ned
new file mode 100644
index 00000000000..781d68987bc
--- /dev/null
+++ b/src/networklayer/common/IRouterAlertHandler.ned
@@ -0,0 +1,26 @@
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see http://www.gnu.org/licenses/.
+//
+
+package inet.networklayer.common;
+
+// generic router alert handler interface
+moduleinterface IRouterAlertHandler
+{
+ parameters:
+ @display("i=block/control_s");
+ gates:
+ input routerAlertIn @labels(IPv4Datagram,IPv6Datagram);
+ output routerAlertReturn @labels(IPv4Datagram,IPv6Datagram);
+}
\ No newline at end of file
diff --git a/src/networklayer/contract/IPv4ControlInfo.msg b/src/networklayer/contract/IPv4ControlInfo.msg
index 69c09fc12ea..a8b21f6240c 100644
--- a/src/networklayer/contract/IPv4ControlInfo.msg
+++ b/src/networklayer/contract/IPv4ControlInfo.msg
@@ -74,6 +74,7 @@ class IPv4ControlInfo
abstract int explicitCongestionNotification; // maps to bits 6-7 of trafficClass
short timeToLive; // maximum hop count
bool dontFragment; // "don't fragment" bit
+ int options; // The "options" header field
// The following fields are used in the DSR protocol; TODO revise
IPv4Address nextHopAddr; // next hop address (DSR)
diff --git a/src/networklayer/ipv4/IPv4.cc b/src/networklayer/ipv4/IPv4.cc
index 3b3068b8673..a08f54c0514 100644
--- a/src/networklayer/ipv4/IPv4.cc
+++ b/src/networklayer/ipv4/IPv4.cc
@@ -160,6 +160,22 @@ void IPv4::handlePacketFromNetwork(IPv4Datagram *datagram, InterfaceEntry *fromI
EV << "Received datagram `" << datagram->getName() << "' with dest=" << destAddr << "\n";
+ // handle router alert option field -> This ist handled only on intermediate routers and not on the endpoints
+ // also the packet is not handled again if it returns from the router alert handler
+ if ((!datagram->getArrivalGate()->isName("routerAlertReturn")) && !(rt->isLocalAddress(destAddr)) && datagram->getOptionCode() == IPOPTION_ROUTER_ALERT) // FIXME If the option code handling is changed to support multiple options, we have to change this here too
+ {
+ // send the datagram to the router alert gate
+ cGate *rout = gate("routerAlertOut");
+ if (rout != 0 && rout->isConnected()) {
+ send(datagram, rout);
+ // bail out of the handling. The packet has to be re-injected by the Option handler, when needed
+ return; // FIXME maybe implement without return?
+ }
+ else {
+ EV << "Router alert option set, but no handler connected. Ignoring.\n";
+ }
+ }
+
if (fromIE->isLoopback())
{
reassembleAndDeliver(datagram);
@@ -763,7 +779,9 @@ IPv4Datagram *IPv4::encapsulate(cPacket *transportPacket, IPv4ControlInfo *contr
datagram->setTimeToLive(ttl);
datagram->setTransportProtocol(controlInfo->getProtocol());
- // setting IPv4 options is currently not supported
+ if (controlInfo->getOptions() != 0) {
+ datagram->setOptionCode(controlInfo->getOptions()); // FIXME will only work so long as only one option header is supported
+ }
return datagram;
}
diff --git a/src/networklayer/ipv4/IPv4.ned b/src/networklayer/ipv4/IPv4.ned
index 4b532568bce..07ca5021edf 100644
--- a/src/networklayer/ipv4/IPv4.ned
+++ b/src/networklayer/ipv4/IPv4.ned
@@ -96,4 +96,6 @@ simple IPv4
output transportOut[] @labels(IPv4ControlInfo/up,TCPSegment,UDPPacket);
input queueIn[] @labels(IPv4Datagram);
output queueOut @labels(IPv4Datagram);
+ output routerAlertOut @labels(IPv4Datagram);
+ input routerAlertReturn @labels(IPv4Datagram);
}
diff --git a/src/nodes/inet/NetworkLayer.ned b/src/nodes/inet/NetworkLayer.ned
index d3068860cdc..83f0aeae297 100644
--- a/src/nodes/inet/NetworkLayer.ned
+++ b/src/nodes/inet/NetworkLayer.ned
@@ -18,11 +18,12 @@
package inet.nodes.inet;
-import inet.networklayer.ipv4.IPv4;
-import inet.networklayer.ipv4.IIGMP;
-import inet.networklayer.ipv4.ICMP;
-import inet.networklayer.ipv4.ErrorHandling;
import inet.networklayer.arp.ARP;
+import inet.networklayer.common.IRouterAlertHandler;
+import inet.networklayer.ipv4.ErrorHandling;
+import inet.networklayer.ipv4.ICMP;
+import inet.networklayer.ipv4.IIGMP;
+import inet.networklayer.ipv4.IPv4;
//
@@ -36,6 +37,7 @@ module NetworkLayer
@display("i=block/fork");
bool proxyARP = default(true);
string igmpType = default("IGMPv2");
+ string routerAlertHandlerType = default("");
gates:
input ifIn[] @labels(IPv4Datagram);
input tcpIn @labels(TCPSegment,IPv4ControlInfo/down);
@@ -56,6 +58,7 @@ module NetworkLayer
output manetOut;
output igmpOut;
+
submodules:
ip: IPv4 {
parameters:
@@ -85,7 +88,9 @@ module NetworkLayer
parameters:
@display("p=239,63");
}
-
+ routerAlertHandler: like IRouterAlertHandler if routerAlertHandlerType != "" {
+ @display("p=294,103");
+ }
connections allowunconnected:
// transport Layer
ip.transportOut[0] --> { @display("m=n"); } --> tcpOut;
@@ -132,5 +137,10 @@ module NetworkLayer
for i=0..sizeof(ifOut)-1 {
arp.nicOut[i] --> { @display("m=s"); } --> ifOut[i];
}
+
+ if routerAlertHandlerType != "" {
+ ip.routerAlertOut --> routerAlertHandler.routerAlertIn;
+ routerAlertHandler.routerAlertReturn --> ip.routerAlertReturn;
+ }
}
diff --git a/src/nodes/inet/NodeBase.ned b/src/nodes/inet/NodeBase.ned
index 7406d39070a..25568a02cde 100644
--- a/src/nodes/inet/NodeBase.ned
+++ b/src/nodes/inet/NodeBase.ned
@@ -17,14 +17,14 @@
package inet.nodes.inet;
-import inet.util.PcapRecorder;
-import inet.networklayer.ipv4.RoutingTable;
-import inet.networklayer.common.InterfaceTable;
-import inet.mobility.IMobility;
-import inet.linklayer.IWirelessNic;
-import inet.linklayer.IWiredNic;
-import inet.linklayer.IExternalNic;
import inet.base.NotificationBoard;
+import inet.linklayer.IExternalNic;
+import inet.linklayer.IWiredNic;
+import inet.linklayer.IWirelessNic;
+import inet.mobility.IMobility;
+import inet.networklayer.common.InterfaceTable;
+import inet.networklayer.ipv4.RoutingTable;
+import inet.util.PcapRecorder;
//
From 1fd8829347591ebd9c3b5aa790fc5e97c0f7bd19 Mon Sep 17 00:00:00 2001
From: Markus Brueckner
Date: Wed, 30 Jan 2013 10:57:32 +0100
Subject: [PATCH 2/5] - fixed: moved address resolution to sendPacket() in
IPvxTrafGen to enable correct function with IPv6 auto-configured networks
---
src/applications/generic/IPvXTrafGen.cc | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/src/applications/generic/IPvXTrafGen.cc b/src/applications/generic/IPvXTrafGen.cc
index 5241e5b4c3d..dbe6450f7ae 100644
--- a/src/applications/generic/IPvXTrafGen.cc
+++ b/src/applications/generic/IPvXTrafGen.cc
@@ -47,12 +47,6 @@ void IPvXTrafGen::initialize(int stage)
error("Invalid startTime/stopTime parameters");
optionCode = par("optionCode");
- const char *destAddrs = par("destAddresses");
- cStringTokenizer tokenizer(destAddrs);
- const char *token;
- while ((token = tokenizer.nextToken()) != NULL)
- destAddresses.push_back(IPvXAddressResolver().resolve(token));
-
packetLengthPar = &par("packetLength");
counter = 0;
@@ -60,9 +54,6 @@ void IPvXTrafGen::initialize(int stage)
numSent = 0;
WATCH(numSent);
- if (destAddresses.empty())
- return;
-
if (numPackets > 0)
{
cMessage *timer = new cMessage("sendTimer");
@@ -81,6 +72,22 @@ void IPvXTrafGen::sendPacket()
char msgName[32];
sprintf(msgName, "appData-%d", counter++);
+ // lazy initialization of the destination addresses
+ if (destAddresses.size() == 0)
+ {
+ const char *destAddrs = par("destAddresses");
+ cStringTokenizer tokenizer(destAddrs);
+ const char *token;
+ while ((token = tokenizer.nextToken()) != NULL)
+ destAddresses.push_back(IPvXAddressResolver().resolve(token));
+ }
+
+ if (destAddresses.size() == 0)
+ {
+ EV << "IPvXTrafGen: Destination address array is empty. Cannot send any data.\n";
+ return;
+ }
+
cPacket *payload = new cPacket(msgName);
payload->setByteLength(packetLengthPar->longValue());
From 63aca7beb3b11aeb76bb2149fe009216bb6f0a5e Mon Sep 17 00:00:00 2001
From: Markus Brueckner
Date: Wed, 30 Jan 2013 17:01:18 +0100
Subject: [PATCH 3/5] - added: IPv6 router alert support - changed: IPv6TrafGen
configuration options for router alert support
---
src/applications/generic/IPvXTrafGen.cc | 17 +++++++-
src/applications/generic/IPvXTrafGen.h | 1 -
src/applications/generic/IPvXTrafGen.ned | 2 +-
src/networklayer/ipv6/IPv6.cc | 26 +++++++++++++
src/networklayer/ipv6/IPv6.ned | 3 ++
src/networklayer/ipv6/IPv6ExtensionHeaders.cc | 39 +++++++++++++++++++
src/networklayer/ipv6/IPv6ExtensionHeaders.h | 13 +++++++
.../ipv6/IPv6ExtensionHeaders.msg | 18 +++++++++
src/nodes/ipv6/NetworkLayer6.ned | 21 +++++++---
9 files changed, 130 insertions(+), 10 deletions(-)
diff --git a/src/applications/generic/IPvXTrafGen.cc b/src/applications/generic/IPvXTrafGen.cc
index dbe6450f7ae..ce143a77706 100644
--- a/src/applications/generic/IPvXTrafGen.cc
+++ b/src/applications/generic/IPvXTrafGen.cc
@@ -22,6 +22,8 @@
#include "IPvXAddressResolver.h"
#include "IPv4ControlInfo.h"
#include "IPv6ControlInfo.h"
+#include "IPv6ExtensionHeaders.h"
+#include "IPv4Datagram.h"
Define_Module(IPvXTrafGen);
@@ -45,7 +47,6 @@ void IPvXTrafGen::initialize(int stage)
stopTime = par("stopTime");
if (stopTime != 0 && stopTime <= startTime)
error("Invalid startTime/stopTime parameters");
- optionCode = par("optionCode");
packetLengthPar = &par("packetLength");
@@ -100,7 +101,11 @@ void IPvXTrafGen::sendPacket()
IPv4ControlInfo *controlInfo = new IPv4ControlInfo();
controlInfo->setDestAddr(destAddr.get4());
controlInfo->setProtocol(protocol);
- controlInfo->setOptions(optionCode);
+ if (par("routerAlert").boolValue() == true)
+ {
+ controlInfo->setOptions(IPOPTION_ROUTER_ALERT);
+ }
+ controlInfo->setOptions(148);
payload->setControlInfo(controlInfo);
gate = "ipOut";
}
@@ -110,6 +115,14 @@ void IPvXTrafGen::sendPacket()
IPv6ControlInfo *controlInfo = new IPv6ControlInfo();
controlInfo->setDestAddr(destAddr.get6());
controlInfo->setProtocol(protocol);
+ if (par("routerAlert").boolValue() == true)
+ {
+ // TODO how do we do this extension header handling elegantly?
+ IPv6HopByHopOptionsHeader *hdr = new IPv6HopByHopOptionsHeader();
+ hdr->setOptionsArraySize(1);
+ hdr->setOptions(0, new IPv6OptionRouterAlert());
+ controlInfo->addExtensionHeader(hdr);
+ }
payload->setControlInfo(controlInfo);
gate = "ipv6Out";
}
diff --git a/src/applications/generic/IPvXTrafGen.h b/src/applications/generic/IPvXTrafGen.h
index df7315482bd..01374c6c087 100644
--- a/src/applications/generic/IPvXTrafGen.h
+++ b/src/applications/generic/IPvXTrafGen.h
@@ -39,7 +39,6 @@ class INET_API IPvXTrafGen : public IPvXTrafSink
simtime_t stopTime;
std::vector destAddresses;
cPar *packetLengthPar; // volatile packetLength parameter
- int optionCode;
static int counter; // counter for generating a global number for each packet
diff --git a/src/applications/generic/IPvXTrafGen.ned b/src/applications/generic/IPvXTrafGen.ned
index fe7a18ed00f..4f45af3c1c0 100644
--- a/src/applications/generic/IPvXTrafGen.ned
+++ b/src/applications/generic/IPvXTrafGen.ned
@@ -41,7 +41,7 @@ simple IPvXTrafGen like IIPvXTrafficGenerator
int protocol; // value for ~IPv4ControlInfo / ~IPv6ControlInfo protocol field
volatile int packetLength @unit("B"); // packet length in bytes
string destAddresses = default(""); // list of destination addresses, separated by spaces
- int optionCode = default(0); // the IPv4 option code header
+ bool routerAlert = default(false); // set the router alert header option
@display("i=block/source");
@signal[sentPk](type=cPacket);
@signal[rcvdPk](type=cPacket);
diff --git a/src/networklayer/ipv6/IPv6.cc b/src/networklayer/ipv6/IPv6.cc
index eed526c3fff..5f9840bc445 100644
--- a/src/networklayer/ipv6/IPv6.cc
+++ b/src/networklayer/ipv6/IPv6.cc
@@ -145,6 +145,32 @@ void IPv6::handleDatagramFromNetwork(IPv6Datagram *datagram)
// 2. The Ethernet or PPP frame is dropped by the link-layer if there is a transmission error.
ASSERT(!datagram->hasBitError());
+ if (!rt->isLocalAddress(datagram->getDestAddress()))
+ {
+ // handle router alert options, if set
+ cGate *rout = gate("routerAlertOut");
+ // only check if we have a handler and this datagram wasn't returned from it already
+ if (rout && rout->isConnected() && !(datagram->arrivedOn("routerAlertReturn")))
+ {
+ for (int i = datagram->getExtensionHeaderArraySize() - 1; i >= 0; --i)
+ {
+ // check whether the router alert extension header is set
+ IPv6ExtensionHeaderPtr extHdr = datagram->getExtensionHeader(i);
+ if (extHdr->getExtensionType() == IP_PROT_IPv6EXT_HOP) {
+ // check whether the router alert option is set
+ IPv6HopByHopOptionsHeader *optHdr = check_and_cast(extHdr);
+ for (int hi = optHdr->getOptionsArraySize() - 1 ; hi >= 0; --hi) {
+ if (optHdr->getOptions(hi)->getOptionType() == 5) { // FIXME implement symbolic constant
+ // we have router alert set -> hand it over to the router alert handler
+ send(datagram, rout);
+ return; // TODO break out here without using return?
+ }
+ }
+ }
+ }
+ }
+ }
+
// remove control info
delete datagram->removeControlInfo();
diff --git a/src/networklayer/ipv6/IPv6.ned b/src/networklayer/ipv6/IPv6.ned
index 9a4e086248b..dc25042a899 100644
--- a/src/networklayer/ipv6/IPv6.ned
+++ b/src/networklayer/ipv6/IPv6.ned
@@ -97,5 +97,8 @@ simple IPv6
//the following gates are added by Zarrar Yousaf on 19.06.07
input xMIPv6In;
output xMIPv6Out;
+ // gates for handling IPv6 Router Alert options
+ input routerAlertReturn @labels(IPv6Datagram);
+ output routerAlertOut @labels(IPv6Datagram);
}
diff --git a/src/networklayer/ipv6/IPv6ExtensionHeaders.cc b/src/networklayer/ipv6/IPv6ExtensionHeaders.cc
index 9e8bf186aae..bc1cf470c1a 100644
--- a/src/networklayer/ipv6/IPv6ExtensionHeaders.cc
+++ b/src/networklayer/ipv6/IPv6ExtensionHeaders.cc
@@ -23,3 +23,42 @@ void IPv6RoutingHeader::setAddressArraySize(unsigned int size)
IPv6RoutingHeader_Base::setAddressArraySize(size);
byteLength_var = 8 + 16 * size;
}
+
+void IPv6HopByHopOptionsHeader::clean()
+{
+ // clean away the options
+ for (int i = getOptionsArraySize()-1; i >= 0; --i)
+ {
+ delete getOptions(i);
+ }
+}
+
+void IPv6HopByHopOptionsHeader::copy(const IPv6HopByHopOptionsHeader& other)
+{
+ if (getOptionsArraySize() > 0)
+ {
+ clean();
+ }
+ setOptionsArraySize(other.getOptionsArraySize());
+ for (int i = other.getOptionsArraySize()-1; i >= 0; --i)
+ {
+ setOptions(i, other.getOptions(i)->dup());
+ }
+}
+
+IPv6HopByHopOptionsHeader::~IPv6HopByHopOptionsHeader()
+{
+ clean();
+}
+
+IPv6HopByHopOptionsHeader::IPv6HopByHopOptionsHeader(const IPv6HopByHopOptionsHeader &other)
+{
+ setOptionsArraySize(0);
+ copy(other);
+}
+
+IPv6HopByHopOptionsHeader& IPv6HopByHopOptionsHeader::operator=(const IPv6HopByHopOptionsHeader& other)
+{
+ copy(other);
+ return *this;
+}
diff --git a/src/networklayer/ipv6/IPv6ExtensionHeaders.h b/src/networklayer/ipv6/IPv6ExtensionHeaders.h
index cbe6d6fe9f3..22fa512ed5d 100644
--- a/src/networklayer/ipv6/IPv6ExtensionHeaders.h
+++ b/src/networklayer/ipv6/IPv6ExtensionHeaders.h
@@ -32,4 +32,17 @@ class IPv6RoutingHeader : public IPv6RoutingHeader_Base
virtual void setAddressArraySize(unsigned int size);
};
+class IPv6HopByHopOptionsHeader : public IPv6HopByHopOptionsHeader_Base
+{
+ private:
+ void clean();
+ void copy(const IPv6HopByHopOptionsHeader& other);
+ public:
+ IPv6HopByHopOptionsHeader() : IPv6HopByHopOptionsHeader_Base() {}
+ ~IPv6HopByHopOptionsHeader();
+ IPv6HopByHopOptionsHeader(const IPv6HopByHopOptionsHeader& other);
+ IPv6HopByHopOptionsHeader& operator=(const IPv6HopByHopOptionsHeader& other);
+ virtual IPv6HopByHopOptionsHeader *dup() const {return new IPv6HopByHopOptionsHeader(*this);}
+ // ADD CODE HERE to redefine and implement pure virtual functions from IPv6HopByHopOptionsHeader_Base
+};
#endif // __INET_IPV6EXTENSIONHEADERS_H_
diff --git a/src/networklayer/ipv6/IPv6ExtensionHeaders.msg b/src/networklayer/ipv6/IPv6ExtensionHeaders.msg
index c1960cc2569..9994188dfaa 100644
--- a/src/networklayer/ipv6/IPv6ExtensionHeaders.msg
+++ b/src/networklayer/ipv6/IPv6ExtensionHeaders.msg
@@ -23,6 +23,8 @@ cplusplus {{
#include "IPProtocolId_m.h"
#define IPv6_FRAGMENT_HEADER_LENGTH 8
+class IPv6Option;
+typedef IPv6Option *IPv6OptionPtr;
}}
@@ -30,6 +32,20 @@ class noncobject IPv6Address;
class noncobject IPv6ExtensionHeader;
+class noncobject IPv6OptionPtr;
+
+class IPv6Option
+{
+ unsigned char optionType;
+ unsigned char optionLength;
+}
+
+class IPv6OptionRouterAlert extends IPv6Option
+{
+ optionType = 5; // FIXME use symbolic constant
+ optionLength = 2;
+}
+
//
// Hop-by-Hop Options Header.
// RFC 2460 Section 4.3
@@ -37,8 +53,10 @@ class noncobject IPv6ExtensionHeader;
//
class IPv6HopByHopOptionsHeader extends IPv6ExtensionHeader
{
+ @customize(true);
extensionType = IP_PROT_IPv6EXT_HOP;
byteLength = 8; // FIXME verify
+ IPv6OptionPtr options[];
}
//
diff --git a/src/nodes/ipv6/NetworkLayer6.ned b/src/nodes/ipv6/NetworkLayer6.ned
index 8508baeb66a..57e6208c2ee 100644
--- a/src/nodes/ipv6/NetworkLayer6.ned
+++ b/src/nodes/ipv6/NetworkLayer6.ned
@@ -19,13 +19,13 @@
//
package inet.nodes.ipv6;
-import inet.networklayer.ipv6.IPv6ErrorHandling;
-import inet.networklayer.ipv6.IPv6;
-import inet.networklayer.icmpv6.IPv6NeighbourDiscovery;
-import inet.networklayer.icmpv6.ICMPv6;
-import inet.networklayer.IxMIPv6Support;
import inet.networklayer.IIPv6Tunneling;
-import inet.base.IHook;
+import inet.networklayer.IxMIPv6Support;
+import inet.networklayer.common.IRouterAlertHandler;
+import inet.networklayer.icmpv6.ICMPv6;
+import inet.networklayer.icmpv6.IPv6NeighbourDiscovery;
+import inet.networklayer.ipv6.IPv6;
+import inet.networklayer.ipv6.IPv6ErrorHandling;
//
@@ -38,6 +38,7 @@ module NetworkLayer6
{
parameters:
bool xMIPv6Support = default(false);
+ string routerAlertHandlerType = default("");
@display("i=block/fork");
gates:
input ifIn[] @labels(IPv6Datagram);
@@ -85,6 +86,9 @@ module NetworkLayer6
parameters:
@display("p=44,79");
}
+ routerAlertHandler: like IRouterAlertHandler if routerAlertHandlerType != "" {
+ @display("p=189,254");
+ }
connections allowunconnected: // FIXME remove 'nocheck'!
// IPv6 to transport Layer
ipv6.transportOut[0] --> { @display("m=n"); } --> tcpOut;
@@ -138,5 +142,10 @@ module NetworkLayer6
for i=0..sizeof(ifOut)-1 {
ipv6.queueOut[i] --> { @display("m=s"); } --> ifOut[i];
}
+
+ if routerAlertHandlerType != "" {
+ ipv6.routerAlertOut --> routerAlertHandler.routerAlertIn;
+ routerAlertHandler.routerAlertReturn --> ipv6.routerAlertReturn;
+ }
}
From 5cc8b207eaf020a1264fde1710afb71d565d3090 Mon Sep 17 00:00:00 2001
From: Markus Brueckner
Date: Thu, 31 Jan 2013 11:06:18 +0100
Subject: [PATCH 4/5] - fixed: added documentation and license information
---
src/networklayer/common/IRouterAlertHandler.h | 26 ++++++++++++++-----
.../common/IRouterAlertHandler.ned | 9 +++++++
src/networklayer/ipv4/IPv4.ned | 10 ++++++-
src/networklayer/ipv6/IPv6.ned | 11 +++++++-
4 files changed, 48 insertions(+), 8 deletions(-)
diff --git a/src/networklayer/common/IRouterAlertHandler.h b/src/networklayer/common/IRouterAlertHandler.h
index da5e1644847..ef4a566ccc5 100644
--- a/src/networklayer/common/IRouterAlertHandler.h
+++ b/src/networklayer/common/IRouterAlertHandler.h
@@ -1,13 +1,27 @@
-/*
- * IRouterAlertHandler.h
- *
- * Created on: Jan 25, 2013
- * Author: Markus Brueckner
- */
+//
+// Copyright (C) 2013 Markus Brueckner
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see http://www.gnu.org/licenses/.
+//
#ifndef IROUTERALERTHANDLER_H_
#define IROUTERALERTHANDLER_H_
+/**
+ * Base class for all router alert handlers. See the NED file for more
+ * information.
+ */
class IRouterAlertHandler : public cSimpleModule
{
};
diff --git a/src/networklayer/common/IRouterAlertHandler.ned b/src/networklayer/common/IRouterAlertHandler.ned
index 781d68987bc..dc0142662a0 100644
--- a/src/networklayer/common/IRouterAlertHandler.ned
+++ b/src/networklayer/common/IRouterAlertHandler.ned
@@ -1,4 +1,6 @@
//
+// Copyright (C) 2013 Markus Brueckner
+//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
@@ -16,6 +18,13 @@
package inet.networklayer.common;
// generic router alert handler interface
+// This interface can be sub-classed by modules interested in intercepting
+// IPv4 and IPv6 packets with the Router Alert option set. The interface
+// offers two gates: one for receiving packets from the network layer (routerAlertIn)
+// and one for re-injecting packets into the network layer (routerAlertReturn).
+// Packets arriving at routerAlertIn are handed over to the module completely.
+// If the packets are to be sent onwards along the normal routing path, they
+// have to be re-injected via the routerAlertReturn gate.
moduleinterface IRouterAlertHandler
{
parameters:
diff --git a/src/networklayer/ipv4/IPv4.ned b/src/networklayer/ipv4/IPv4.ned
index 07ca5021edf..8940f0fc7c1 100644
--- a/src/networklayer/ipv4/IPv4.ned
+++ b/src/networklayer/ipv4/IPv4.ned
@@ -77,7 +77,15 @@ package inet.networklayer.ipv4;
// method which determines processing time for a packet, or (2) use a
// different base class.
//
-// @see ~RoutingTable, ~IPv4ControlInfo, ~IPv4RoutingDecision, ~ARP
+// Packet interception
+//
+// Implementers interested in intercepting packets that pass through the IP layer
+// can hook a ~IRouterAlertHandler-like module to the routerAlertOut gate. The
+// IP module will then hand over all packets carrying the router alert option field
+// to this module for detailled processing. In order to carry on with normal routing,
+// packets must be returned using the routerAlertReturn gate.
+//
+// @see ~RoutingTable, ~IPv4ControlInfo, ~IPv4RoutingDecision, ~ARP, ~IRouterAlertHandler
//
// @author Andras Varga
//
diff --git a/src/networklayer/ipv6/IPv6.ned b/src/networklayer/ipv6/IPv6.ned
index dc25042a899..c3f5c6a359c 100644
--- a/src/networklayer/ipv6/IPv6.ned
+++ b/src/networklayer/ipv6/IPv6.ned
@@ -70,7 +70,16 @@ package inet.networklayer.ipv6;
// datagrams are processed in order. The processing time is determined by the
// procDelay module parameter.
//
-// @see ~RoutingTable6, ~IPv6ControlInfo, ~IPv6NeighbourDiscovery, ~ICMPv6
+// Packet interception
+//
+// Implementers interested in intercepting packets that pass through the IP layer
+// can hook a ~IRouterAlertHandler-like module to the routerAlertOut gate. The
+// IP module will then hand over all packets carrying the router alert option field
+// in the HopByHopExtensionHeader to this module for detailled processing.
+// In order to carry on with normal routing, packets must be returned using
+// the routerAlertReturn gate.
+//
+// @see ~RoutingTable6, ~IPv6ControlInfo, ~IPv6NeighbourDiscovery, ~ICMPv6, ~IRouterAlertHandler
//
// @author Andras Varga
//
From c287c146a33b422116e400b1dfc5535a48a7b718 Mon Sep 17 00:00:00 2001
From: Markus Brueckner
Date: Thu, 31 Jan 2013 11:09:07 +0100
Subject: [PATCH 5/5] - fixed: added some more documentation to the network
layer modules
---
.cproject | 4 +---
src/nodes/inet/NetworkLayer.ned | 3 +++
src/nodes/ipv6/NetworkLayer6.ned | 3 +++
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/.cproject b/.cproject
index c5ef986fc19..b03b5224933 100644
--- a/.cproject
+++ b/.cproject
@@ -1,7 +1,5 @@
-
-
-
+
diff --git a/src/nodes/inet/NetworkLayer.ned b/src/nodes/inet/NetworkLayer.ned
index 83f0aeae297..cb40399ddf8 100644
--- a/src/nodes/inet/NetworkLayer.ned
+++ b/src/nodes/inet/NetworkLayer.ned
@@ -37,6 +37,9 @@ module NetworkLayer
@display("i=block/fork");
bool proxyARP = default(true);
string igmpType = default("IGMPv2");
+ // router alert handler type. Put here a string naming the type of router alert handler
+ // module that you want to use (if any). The network layer will then instantiate and
+ // connect the respective module automatically.
string routerAlertHandlerType = default("");
gates:
input ifIn[] @labels(IPv4Datagram);
diff --git a/src/nodes/ipv6/NetworkLayer6.ned b/src/nodes/ipv6/NetworkLayer6.ned
index 57e6208c2ee..245ec7cc339 100644
--- a/src/nodes/ipv6/NetworkLayer6.ned
+++ b/src/nodes/ipv6/NetworkLayer6.ned
@@ -38,6 +38,9 @@ module NetworkLayer6
{
parameters:
bool xMIPv6Support = default(false);
+ // router alert handler type. Put here a string naming the type of router alert handler
+ // module that you want to use (if any). The network layer will then instantiate and
+ // connect the respective module automatically.
string routerAlertHandlerType = default("");
@display("i=block/fork");
gates: