INET Framework for OMNeT++/OMNEST
inet::IPv6 Class Reference

IPv6 implementation. More...

#include <IPv6.h>

Inheritance diagram for inet::IPv6:
inet::QueueBase inet::ILifecycle inet::INetfilter inet::INetworkProtocol inet::AbstractQueue

Classes

class  QueuedDatagramForHook
 Represents an IPv4Datagram, queued by a Hook. More...
 
class  ScheduledDatagram
 

Public Member Functions

 IPv6 ()
 
 ~IPv6 ()
 
virtual void registerHook (int priority, IHook *hook) override
 Adds the provided hook to the list of registered hooks that will be called by the network layer when it processes datagrams. More...
 
virtual void unregisterHook (int priority, IHook *hook) override
 Removes the provided hook from the list of registered hooks. More...
 
virtual void dropQueuedDatagram (const INetworkDatagram *daragram) override
 Requests the network layer to drop the datagram, because it's no longer needed. More...
 
virtual void reinjectQueuedDatagram (const INetworkDatagram *datagram) override
 Requests the network layer to restart the processing of the datagram. More...
 
- Public Member Functions inherited from inet::QueueBase
 QueueBase ()
 
- Public Member Functions inherited from inet::AbstractQueue
 AbstractQueue ()
 
virtual ~AbstractQueue ()
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 
- Public Member Functions inherited from inet::INetfilter
virtual ~INetfilter ()
 
- Public Member Functions inherited from inet::INetworkProtocol
virtual ~INetworkProtocol ()
 

Protected Types

typedef std::multimap< int, IHook * > HookList
 
typedef std::list< QueuedDatagramForHookDatagramQueueForHooks
 

Protected Member Functions

virtual InterfaceEntrygetSourceInterfaceFrom (cPacket *msg)
 
virtual void refreshDisplay () const override
 
virtual IPv6Datagramencapsulate (cPacket *transportPacket, IPv6ControlInfo *ctrlInfo)
 Encapsulate packet coming from higher layers into IPv6Datagram. More...
 
virtual void preroutingFinish (IPv6Datagram *datagram, const InterfaceEntry *fromIE, const InterfaceEntry *destIE, IPv6Address nextHopAddr)
 
virtual void handleMessageFromHL (cPacket *msg)
 Handle messages (typically packets to be send in IPv6) from transport or ICMP. More...
 
virtual void datagramLocalOut (IPv6Datagram *datagram, const InterfaceEntry *destIE, IPv6Address requestedNextHopAddress)
 
virtual void handleReceivedICMP (ICMPv6Message *msg)
 Handle incoming ICMP messages. More...
 
virtual void routePacket (IPv6Datagram *datagram, const InterfaceEntry *destIE, IPv6Address requestedNextHopAddress, bool fromHL)
 Performs routing. More...
 
virtual void resolveMACAddressAndSendPacket (IPv6Datagram *datagram, int interfaceID, IPv6Address nextHop, bool fromHL)
 
virtual void routeMulticastPacket (IPv6Datagram *datagram, const InterfaceEntry *destIE, const InterfaceEntry *fromIE, bool fromHL)
 Forwards packets to all multicast destinations, using fragmentAndSend(). More...
 
virtual void fragmentAndSend (IPv6Datagram *datagram, const InterfaceEntry *destIE, const MACAddress &nextHopAddr, bool fromHL)
 Performs fragmentation if needed, and sends the original datagram or the fragments through the specified interface. More...
 
virtual void localDeliver (IPv6Datagram *datagram)
 Perform reassembly of fragmented datagrams, then send them up to the higher layers using sendToHL(). More...
 
virtual cPacket * decapsulate (IPv6Datagram *datagram)
 Decapsulate and return encapsulated packet after attaching IPv6ControlInfo. More...
 
virtual void sendDatagramToOutput (IPv6Datagram *datagram, const InterfaceEntry *destIE, const MACAddress &macAddr)
 Last hoplimit check, then send datagram on the given interface. More...
 
IHook::Result datagramPreRoutingHook (INetworkDatagram *datagram, const InterfaceEntry *inIE, const InterfaceEntry *&outIE, L3Address &nextHopAddr)
 called before a packet arriving from the network is routed More...
 
IHook::Result datagramForwardHook (INetworkDatagram *datagram, const InterfaceEntry *inIE, const InterfaceEntry *&outIE, L3Address &nextHopAddr)
 called before a packet arriving from the network is delivered via the network More...
 
IHook::Result datagramPostRoutingHook (INetworkDatagram *datagram, const InterfaceEntry *inIE, const InterfaceEntry *&outIE, L3Address &nextHopAddr)
 called before a packet is delivered via the network More...
 
IHook::Result datagramLocalInHook (INetworkDatagram *datagram, const InterfaceEntry *inIE)
 called before a packet arriving from the network is delivered locally More...
 
IHook::Result datagramLocalOutHook (INetworkDatagram *datagram, const InterfaceEntry *&outIE, L3Address &nextHopAddr)
 called before a packet arriving locally is delivered More...
 
virtual void initialize (int stage) override
 Initialization. More...
 
virtual int numInitStages () const override
 
virtual void handleMessage (cMessage *msg) override
 Handle message. More...
 
virtual void endService (cPacket *msg) override
 Processing of IPv6 datagrams. More...
 
virtual bool handleOperationStage (LifecycleOperation *operation, int stage, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 
bool determineOutputInterface (const IPv6Address &destAddress, IPv6Address &nextHop, int &interfaceId, IPv6Datagram *datagram, bool fromHL)
 Determines the correct interface for the specified destination address. More...
 
bool processExtensionHeaders (IPv6Datagram *datagram)
 Process the extension headers of the datagram. More...
 
- Protected Member Functions inherited from inet::QueueBase
virtual void initialize () override
 
virtual void arrival (cPacket *msg) override
 Functions to (re)define behaviour. More...
 
virtual cPacket * arrivalWhenIdle (cPacket *msg) override
 Called when a message arrives at the module when the queue is empty. More...
 
virtual simtime_t startService (cPacket *msg) override
 Called when a message starts service, and should return the service time. More...
 
- Protected Member Functions inherited from inet::AbstractQueue
virtual cPacket * cancelService ()
 If a message is under service, aborts its service and returns the message. More...
 

Protected Attributes

IInterfaceTableift = nullptr
 
IPv6RoutingTablert = nullptr
 
IPv6NeighbourDiscoverynd = nullptr
 
ICMPv6icmp = nullptr
 
IPv6Tunnelingtunneling = nullptr
 
unsigned int curFragmentId = -1
 
IPv6FragBuf fragbuf
 
simtime_t lastCheckTime
 
ProtocolMapping mapping
 
int numMulticast = 0
 
int numLocalDeliver = 0
 
int numDropped = 0
 
int numUnroutable = 0
 
int numForwarded = 0
 
HookList hooks
 
DatagramQueueForHooks queuedDatagramsForHooks
 
- Protected Attributes inherited from inet::QueueBase
simtime_t delay
 
- Protected Attributes inherited from inet::AbstractQueue
cPacketQueue queue
 The queue. More...
 

Detailed Description

IPv6 implementation.

Member Typedef Documentation

typedef std::multimap<int, IHook *> inet::IPv6::HookList
protected

Constructor & Destructor Documentation

inet::IPv6::IPv6 ( )
47  :
48  curFragmentId(0)
49 {
50 }
unsigned int curFragmentId
Definition: IPv6.h:71
inet::IPv6::~IPv6 ( )
53 {
54 }

Member Function Documentation

INetfilter::IHook::Result inet::IPv6::datagramForwardHook ( INetworkDatagram datagram,
const InterfaceEntry inIE,
const InterfaceEntry *&  outIE,
L3Address nextHopAddr 
)
protected

called before a packet arriving from the network is delivered via the network

1032 {
1033  for (auto & elem : hooks) {
1034  IHook::Result r = elem.second->datagramForwardHook(datagram, inIE, outIE, nextHopAddr);
1035  switch (r) {
1037  break; // continue iteration
1038 
1040  delete datagram;
1041  return r;
1042 
1044  queuedDatagramsForHooks.push_back(QueuedDatagramForHook(dynamic_cast<IPv6Datagram *>(datagram), inIE, outIE, nextHopAddr.toIPv6(), INetfilter::IHook::FORWARD));
1045  return r;
1046 
1048  return r;
1049 
1050  default:
1051  throw cRuntimeError("Unknown Hook::Result value: %d", (int)r);
1052  }
1053  }
1055 }
doesn&#39;t allow the datagram to pass to the next hook, will be deleted
Definition: INetfilter.h:51
allows the datagram to pass to the next hook
Definition: INetfilter.h:50
Result
Definition: INetfilter.h:49
doesn&#39;t allow datagram to pass to next hook, but won&#39;t be deleted
Definition: INetfilter.h:53
DatagramQueueForHooks queuedDatagramsForHooks
Definition: IPv6.h:109
HookList hooks
Definition: IPv6.h:107
Definition: INetfilter.h:44
queues the datagram for later re-injection (e.g. when route discovery completes)
Definition: INetfilter.h:52
INetfilter::IHook::Result inet::IPv6::datagramLocalInHook ( INetworkDatagram datagram,
const InterfaceEntry inIE 
)
protected

called before a packet arriving from the network is delivered locally

1084 {
1085  for (auto & elem : hooks) {
1086  IHook::Result r = elem.second->datagramLocalInHook(datagram, inIE);
1087  switch (r) {
1089  break; // continue iteration
1090 
1092  delete datagram;
1093  return r;
1094 
1096  queuedDatagramsForHooks.push_back(QueuedDatagramForHook(dynamic_cast<IPv6Datagram *>(datagram), inIE, nullptr, IPv6Address::UNSPECIFIED_ADDRESS, INetfilter::IHook::LOCALIN));
1097  return r;
1098 
1100  return r;
1101 
1102  default:
1103  throw cRuntimeError("Unknown Hook::Result value: %d", (int)r);
1104  }
1105  }
1107 }
doesn&#39;t allow the datagram to pass to the next hook, will be deleted
Definition: INetfilter.h:51
Definition: INetfilter.h:43
allows the datagram to pass to the next hook
Definition: INetfilter.h:50
static const IPv6Address UNSPECIFIED_ADDRESS
The unspecified address.
Definition: IPv6Address.h:66
Result
Definition: INetfilter.h:49
doesn&#39;t allow datagram to pass to next hook, but won&#39;t be deleted
Definition: INetfilter.h:53
DatagramQueueForHooks queuedDatagramsForHooks
Definition: IPv6.h:109
HookList hooks
Definition: IPv6.h:107
queues the datagram for later re-injection (e.g. when route discovery completes)
Definition: INetfilter.h:52
void inet::IPv6::datagramLocalOut ( IPv6Datagram datagram,
const InterfaceEntry destIE,
IPv6Address  requestedNextHopAddress 
)
protectedvirtual

Referenced by endService(), handleMessageFromHL(), and reinjectQueuedDatagram().

282 {
283  // route packet
284  if (destIE != nullptr)
285  fragmentAndSend(datagram, destIE, MACAddress::BROADCAST_ADDRESS, true); // FIXME what MAC address to use?
286  else if (!datagram->getDestAddress().isMulticast())
287  routePacket(datagram, destIE, requestedNextHopAddress, true);
288  else
289  routeMulticastPacket(datagram, destIE, nullptr, true);
290 }
virtual void routeMulticastPacket(IPv6Datagram *datagram, const InterfaceEntry *destIE, const InterfaceEntry *fromIE, bool fromHL)
Forwards packets to all multicast destinations, using fragmentAndSend().
Definition: IPv6.cc:431
virtual void routePacket(IPv6Datagram *datagram, const InterfaceEntry *destIE, IPv6Address requestedNextHopAddress, bool fromHL)
Performs routing.
Definition: IPv6.cc:292
virtual void fragmentAndSend(IPv6Datagram *datagram, const InterfaceEntry *destIE, const MACAddress &nextHopAddr, bool fromHL)
Performs fragmentation if needed, and sends the original datagram or the fragments through the specif...
Definition: IPv6.cc:741
static const MACAddress BROADCAST_ADDRESS
The broadcast MAC address, ff:ff:ff:ff:ff:ff.
Definition: MACAddress.h:60
INetfilter::IHook::Result inet::IPv6::datagramLocalOutHook ( INetworkDatagram datagram,
const InterfaceEntry *&  outIE,
L3Address nextHopAddr 
)
protected

called before a packet arriving locally is delivered

Referenced by endService(), and handleMessageFromHL().

1110 {
1111  for (auto & elem : hooks) {
1112  IHook::Result r = elem.second->datagramLocalOutHook(datagram, outIE, nextHopAddr);
1113  switch (r) {
1115  break; // continue iteration
1116 
1118  delete datagram;
1119  return r;
1120 
1122  queuedDatagramsForHooks.push_back(QueuedDatagramForHook(dynamic_cast<IPv6Datagram *>(datagram), nullptr, outIE, nextHopAddr.toIPv6(), INetfilter::IHook::LOCALOUT));
1123  return r;
1124 
1126  return r;
1127 
1128  default:
1129  throw cRuntimeError("Unknown Hook::Result value: %d", (int)r);
1130  }
1131  }
1133 }
doesn&#39;t allow the datagram to pass to the next hook, will be deleted
Definition: INetfilter.h:51
allows the datagram to pass to the next hook
Definition: INetfilter.h:50
Definition: INetfilter.h:46
Result
Definition: INetfilter.h:49
doesn&#39;t allow datagram to pass to next hook, but won&#39;t be deleted
Definition: INetfilter.h:53
DatagramQueueForHooks queuedDatagramsForHooks
Definition: IPv6.h:109
HookList hooks
Definition: IPv6.h:107
queues the datagram for later re-injection (e.g. when route discovery completes)
Definition: INetfilter.h:52
INetfilter::IHook::Result inet::IPv6::datagramPostRoutingHook ( INetworkDatagram datagram,
const InterfaceEntry inIE,
const InterfaceEntry *&  outIE,
L3Address nextHopAddr 
)
protected

called before a packet is delivered via the network

1058 {
1059  for (auto & elem : hooks) {
1060  IHook::Result r = elem.second->datagramPostRoutingHook(datagram, inIE, outIE, nextHopAddr);
1061  switch (r) {
1063  break; // continue iteration
1064 
1066  delete datagram;
1067  return r;
1068 
1070  queuedDatagramsForHooks.push_back(QueuedDatagramForHook(dynamic_cast<IPv6Datagram *>(datagram), inIE, outIE, nextHopAddr.toIPv6(), INetfilter::IHook::POSTROUTING));
1071  return r;
1072 
1074  return r;
1075 
1076  default:
1077  throw cRuntimeError("Unknown Hook::Result value: %d", (int)r);
1078  }
1079  }
1081 }
doesn&#39;t allow the datagram to pass to the next hook, will be deleted
Definition: INetfilter.h:51
allows the datagram to pass to the next hook
Definition: INetfilter.h:50
Definition: INetfilter.h:45
Result
Definition: INetfilter.h:49
doesn&#39;t allow datagram to pass to next hook, but won&#39;t be deleted
Definition: INetfilter.h:53
DatagramQueueForHooks queuedDatagramsForHooks
Definition: IPv6.h:109
HookList hooks
Definition: IPv6.h:107
queues the datagram for later re-injection (e.g. when route discovery completes)
Definition: INetfilter.h:52
INetfilter::IHook::Result inet::IPv6::datagramPreRoutingHook ( INetworkDatagram datagram,
const InterfaceEntry inIE,
const InterfaceEntry *&  outIE,
L3Address nextHopAddr 
)
protected

called before a packet arriving from the network is routed

Referenced by endService().

1006 {
1007  for (auto & elem : hooks) {
1008  IHook::Result r = elem.second->datagramPreRoutingHook(datagram, inIE, outIE, nextHopAddr);
1009  switch (r) {
1011  break; // continue iteration
1012 
1014  delete datagram;
1015  return r;
1016 
1018  queuedDatagramsForHooks.push_back(QueuedDatagramForHook(dynamic_cast<IPv6Datagram *>(datagram), inIE, outIE, nextHopAddr.toIPv6(), INetfilter::IHook::PREROUTING));
1019  return r;
1020 
1022  return r;
1023 
1024  default:
1025  throw cRuntimeError("Unknown Hook::Result value: %d", (int)r);
1026  }
1027  }
1029 }
doesn&#39;t allow the datagram to pass to the next hook, will be deleted
Definition: INetfilter.h:51
Definition: INetfilter.h:42
allows the datagram to pass to the next hook
Definition: INetfilter.h:50
Result
Definition: INetfilter.h:49
doesn&#39;t allow datagram to pass to next hook, but won&#39;t be deleted
Definition: INetfilter.h:53
DatagramQueueForHooks queuedDatagramsForHooks
Definition: IPv6.h:109
HookList hooks
Definition: IPv6.h:107
queues the datagram for later re-injection (e.g. when route discovery completes)
Definition: INetfilter.h:52
cPacket * inet::IPv6::decapsulate ( IPv6Datagram datagram)
protectedvirtual

Decapsulate and return encapsulated packet after attaching IPv6ControlInfo.

Referenced by localDeliver().

672 {
673  // decapsulate transport packet
674  InterfaceEntry *fromIE = getSourceInterfaceFrom(datagram);
675  cPacket *packet = datagram->decapsulate();
676 
677  // create and fill in control info
678  IPv6ControlInfo *controlInfo = new IPv6ControlInfo();
679  controlInfo->setProtocol(datagram->getTransportProtocol());
680  controlInfo->setSrcAddr(datagram->getSrcAddress());
681  controlInfo->setDestAddr(datagram->getDestAddress());
682  controlInfo->setTrafficClass(datagram->getTrafficClass());
683  controlInfo->setHopLimit(datagram->getHopLimit());
684  controlInfo->setInterfaceId(fromIE ? fromIE->getInterfaceId() : -1);
685 
686  // original IP datagram might be needed in upper layers to send back ICMP error message
687  controlInfo->setOrigDatagram(datagram);
688 
689  // attach control info
690  packet->setControlInfo(controlInfo);
691 
692  return packet;
693 }
virtual InterfaceEntry * getSourceInterfaceFrom(cPacket *msg)
Definition: IPv6.cc:217
bool inet::IPv6::determineOutputInterface ( const IPv6Address destAddress,
IPv6Address nextHop,
int &  interfaceId,
IPv6Datagram datagram,
bool  fromHL 
)
protected

Determines the correct interface for the specified destination address.

The nextHop and interfaceId are output parameter.

Referenced by routePacket().

837 {
838  // try destination cache
839  nextHop = rt->lookupDestCache(destAddress, interfaceId);
840 
841  if (interfaceId == -1) {
842  // address not in destination cache: do longest prefix match in routing table
843  EV_INFO << "do longest prefix match in routing table" << endl;
844  const IPv6Route *route = rt->doLongestPrefixMatch(destAddress);
845  EV_INFO << "finished longest prefix match in routing table" << endl;
846  if (!route) {
847  if (rt->isRouter()) {
848  EV_INFO << "unroutable, sending ICMPv6_DESTINATION_UNREACHABLE\n";
849  numUnroutable++;
850  icmp->sendErrorMessage(datagram, ICMPv6_DESTINATION_UNREACHABLE, 0); // FIXME check ICMP 'code'
851  }
852  else { // host
853  EV_INFO << "no match in routing table, passing datagram to Neighbour Discovery module for default router selection\n";
854  IPv6NDControlInfo *ctrl = new IPv6NDControlInfo();
855  ctrl->setFromHL(fromHL);
856  ctrl->setNextHop(nextHop);
857  ctrl->setInterfaceId(interfaceId);
858  datagram->setControlInfo(ctrl);
859  send(datagram, "ndOut");
860  }
861  return false;
862  }
863  interfaceId = route->getInterface() ? route->getInterface()->getInterfaceId() : -1;
864  nextHop = route->getNextHop();
865  if (nextHop.isUnspecified())
866  nextHop = destAddress; // next hop is the host itself
867 
868  // add result into destination cache
869  rt->updateDestCache(destAddress, nextHop, interfaceId, route->getExpiryTime());
870  }
871 
872  return true;
873 }
IPv6RoutingTable * rt
Definition: IPv6.h:64
const IPv6Address & lookupDestCache(const IPv6Address &dest, int &outInterfaceId)
Looks up the given destination address in the Destination Cache, then returns the next-hop address an...
Definition: IPv6RoutingTable.cc:455
Definition: ICMPv6Message_m.h:71
virtual bool isRouter() const
IP forwarding on/off.
Definition: IPv6RoutingTable.h:155
int numUnroutable
Definition: IPv6.h:80
virtual void updateDestCache(const IPv6Address &dest, const IPv6Address &nextHopAddr, int interfaceId, simtime_t expiryTime)
Add or update a destination cache entry.
Definition: IPv6RoutingTable.cc:510
const IPv6Route * doLongestPrefixMatch(const IPv6Address &dest)
Performs longest prefix match in the routing table and returns the resulting route, or nullptr if there was no match.
Definition: IPv6RoutingTable.cc:475
ICMPv6 * icmp
Definition: IPv6.h:66
virtual void sendErrorMessage(IPv6Datagram *datagram, ICMPv6Type type, int code)
This method can be called from other modules to send an ICMPv6 error packet.
Definition: ICMPv6.cc:188
void inet::IPv6::dropQueuedDatagram ( const INetworkDatagram daragram)
overridevirtual

Requests the network layer to drop the datagram, because it's no longer needed.

This function may be used by a reactive routing protocol when it cancels the route discovery process.

Implements inet::INetfilter.

955 {
956  Enter_Method("dropQueuedDatagram()");
957  for (auto iter = queuedDatagramsForHooks.begin(); iter != queuedDatagramsForHooks.end(); iter++) {
958  if (iter->datagram == datagram) {
959  delete datagram;
960  queuedDatagramsForHooks.erase(iter);
961  return;
962  }
963  }
964 }
DatagramQueueForHooks queuedDatagramsForHooks
Definition: IPv6.h:109
IPv6Datagram * inet::IPv6::encapsulate ( cPacket *  transportPacket,
IPv6ControlInfo ctrlInfo 
)
protectedvirtual

Encapsulate packet coming from higher layers into IPv6Datagram.

Referenced by handleMessageFromHL().

696 {
697  IPv6Datagram *datagram = new IPv6Datagram(transportPacket->getName());
698 
699  // set source and destination address
700  IPv6Address dest = controlInfo->getDestAddr();
701  datagram->setDestAddress(dest);
702 
703  IPv6Address src = controlInfo->getSrcAddr();
704 
705  // when source address was given, use it; otherwise it'll get the address
706  // of the outgoing interface after routing
707  if (!src.isUnspecified()) {
708  // if interface parameter does not match existing interface, do not send datagram
709  if (rt->getInterfaceByAddress(src) == nullptr) {
710  delete datagram;
711 #ifndef WITH_xMIPv6
712  throw cRuntimeError("Wrong source address %s in (%s)%s: no interface with such address",
713  src.str().c_str(), transportPacket->getClassName(), transportPacket->getFullName());
714 #else /* WITH_xMIPv6 */
715  return nullptr;
716 #endif /* WITH_xMIPv6 */
717  }
718  datagram->setSrcAddress(src);
719  }
720 
721  // set other fields
722  datagram->setTrafficClass(controlInfo->getTrafficClass());
723  datagram->setHopLimit(controlInfo->getHopLimit() > 0 ? controlInfo->getHopLimit() : 32); //FIXME use iface hop limit instead of 32?
724  datagram->setTransportProtocol(controlInfo->getProtocol());
725 
726  // #### Move extension headers from ctrlInfo to datagram if present
727  while (0 < controlInfo->getExtensionHeaderArraySize()) {
728  IPv6ExtensionHeader *extHeader = controlInfo->removeFirstExtensionHeader();
729  datagram->addExtensionHeader(extHeader);
730  // EV << "Move extension header to datagram." << endl;
731  }
732 
733  datagram->setByteLength(datagram->calculateHeaderByteLength());
734  datagram->encapsulate(transportPacket);
735 
736  // setting IP options is currently not supported
737 
738  return datagram;
739 }
IPv6RoutingTable * rt
Definition: IPv6.h:64
virtual InterfaceEntry * getInterfaceByAddress(const IPv6Address &address) const
Returns an interface given by its address.
Definition: IPv6RoutingTable.cc:403
void inet::IPv6::endService ( cPacket *  msg)
overrideprotectedvirtual

Processing of IPv6 datagrams.

Called when a datagram reaches the front of the queue.

Implements inet::AbstractQueue.

139 {
140 #ifdef WITH_xMIPv6
141  // 28.09.07 - CB
142  // support for rescheduling datagrams which are supposed to be sent over
143  // a tentative address.
144  if (msg->isSelfMessage()) {
145  ScheduledDatagram *sDgram = check_and_cast<ScheduledDatagram *>(msg);
146 
147  // take care of datagram which was supposed to be sent over a tentative address
148  if (sDgram->getIE()->ipv6Data()->isTentativeAddress(sDgram->getSrcAddress())) {
149  // address is still tentative - enqueue again
150  queue.insert(sDgram);
151  }
152  else {
153  // address is not tentative anymore - send out datagram
154  numForwarded++;
155  fragmentAndSend(sDgram->removeDatagram(), sDgram->getIE(), sDgram->getMACAddress(), sDgram->getFromHL());
156  delete sDgram;
157  }
158  }
159  else
160 #endif /* WITH_xMIPv6 */
161 
162  if (msg->getArrivalGate()->isName("transportIn")
163  || (msg->getArrivalGate()->isName("ndIn") && dynamic_cast<IPv6NDMessage *>(msg))
164  || (msg->getArrivalGate()->isName("upperTunnelingIn")) // for tunneling support-CB
165 #ifdef WITH_xMIPv6
166  || (msg->getArrivalGate()->isName("xMIPv6In") && dynamic_cast<MobilityHeader *>(msg)) // Zarrar
167 #endif /* WITH_xMIPv6 */
168  )
169  {
170  // packet from upper layers, tunnel link-layer output or ND: encapsulate and send out
171  handleMessageFromHL(msg);
172  }
173  else if (msg->getArrivalGate()->isName("ndIn") && dynamic_cast<IPv6Datagram *>(msg)) {
174  IPv6Datagram *datagram = static_cast<IPv6Datagram *>(msg);
175  IPv6NDControlInfo *ctrl = check_and_cast<IPv6NDControlInfo *>(msg->removeControlInfo());
176  bool fromHL = ctrl->getFromHL();
177  IPv6Address nextHop = ctrl->getNextHop();
178  int interfaceId = ctrl->getInterfaceId();
179  delete ctrl;
180  resolveMACAddressAndSendPacket(datagram, interfaceId, nextHop, fromHL);
181  }
182  else {
183  // datagram from network or from ND: localDeliver and/or route
184  IPv6Datagram *datagram = check_and_cast<IPv6Datagram *>(msg);
185  bool fromHL = false;
186  if (datagram->getArrivalGate()->isName("ndIn")) {
187  IPv6NDControlInfo *ctrl = check_and_cast<IPv6NDControlInfo *>(msg->removeControlInfo());
188  fromHL = ctrl->getFromHL();
189  IPv6Address nextHop = ctrl->getNextHop();
190  int interfaceId = ctrl->getInterfaceId();
191  delete ctrl;
192  resolveMACAddressAndSendPacket(datagram, interfaceId, nextHop, fromHL);
193  }
194 
195  // Do not handle header biterrors, because
196  // 1. IPv6 header does not contain checksum for the header fields, each field is
197  // validated when they are processed.
198  // 2. The Ethernet or PPP frame is dropped by the link-layer if there is a transmission error.
199  ASSERT(!datagram->hasBitError());
200 
201  const InterfaceEntry *fromIE = getSourceInterfaceFrom(datagram);
202  const InterfaceEntry *destIE = nullptr;
203  L3Address nextHop(IPv6Address::UNSPECIFIED_ADDRESS);
204  if (fromHL) {
205  // remove control info
206  delete datagram->removeControlInfo();
207  if (datagramLocalOutHook(datagram, destIE, nextHop) == INetfilter::IHook::ACCEPT)
208  datagramLocalOut(datagram, destIE, nextHop.toIPv6());
209  }
210  else {
211  if (datagramPreRoutingHook(datagram, fromIE, destIE, nextHop) == INetfilter::IHook::ACCEPT)
212  preroutingFinish(datagram, fromIE, destIE, nextHop.toIPv6());
213  }
214  }
215 }
IHook::Result datagramPreRoutingHook(INetworkDatagram *datagram, const InterfaceEntry *inIE, const InterfaceEntry *&outIE, L3Address &nextHopAddr)
called before a packet arriving from the network is routed
Definition: IPv6.cc:1005
virtual void handleMessageFromHL(cPacket *msg)
Handle messages (typically packets to be send in IPv6) from transport or ICMP.
Definition: IPv6.cc:236
virtual void resolveMACAddressAndSendPacket(IPv6Datagram *datagram, int interfaceID, IPv6Address nextHop, bool fromHL)
Definition: IPv6.cc:387
cPacketQueue queue
The queue.
Definition: AbstractQueue.h:48
virtual void preroutingFinish(IPv6Datagram *datagram, const InterfaceEntry *fromIE, const InterfaceEntry *destIE, IPv6Address nextHopAddr)
Definition: IPv6.cc:223
allows the datagram to pass to the next hook
Definition: INetfilter.h:50
IHook::Result datagramLocalOutHook(INetworkDatagram *datagram, const InterfaceEntry *&outIE, L3Address &nextHopAddr)
called before a packet arriving locally is delivered
Definition: IPv6.cc:1109
static const IPv6Address UNSPECIFIED_ADDRESS
The unspecified address.
Definition: IPv6Address.h:66
virtual InterfaceEntry * getSourceInterfaceFrom(cPacket *msg)
Definition: IPv6.cc:217
int numForwarded
Definition: IPv6.h:81
virtual void datagramLocalOut(IPv6Datagram *datagram, const InterfaceEntry *destIE, IPv6Address requestedNextHopAddress)
Definition: IPv6.cc:281
virtual void fragmentAndSend(IPv6Datagram *datagram, const InterfaceEntry *destIE, const MACAddress &nextHopAddr, bool fromHL)
Performs fragmentation if needed, and sends the original datagram or the fragments through the specif...
Definition: IPv6.cc:741
void inet::IPv6::fragmentAndSend ( IPv6Datagram datagram,
const InterfaceEntry destIE,
const MACAddress nextHopAddr,
bool  fromHL 
)
protectedvirtual

Performs fragmentation if needed, and sends the original datagram or the fragments through the specified interface.

Referenced by datagramLocalOut(), endService(), resolveMACAddressAndSendPacket(), and routeMulticastPacket().

742 {
743  // hop counter check
744  if (datagram->getHopLimit() <= 0) {
745  // drop datagram, destruction responsibility in ICMP
746  EV_INFO << "datagram hopLimit reached zero, sending ICMPv6_TIME_EXCEEDED\n";
747  icmp->sendErrorMessage(datagram, ICMPv6_TIME_EXCEEDED, 0); // FIXME check icmp 'code'
748  return;
749  }
750 
751  // ensure source address is filled
752  if (fromHL && datagram->getSrcAddress().isUnspecified() &&
753  !datagram->getDestAddress().isSolicitedNodeMulticastAddress())
754  {
755  // source address can be unspecified during DAD
756  const IPv6Address& srcAddr = ie->ipv6Data()->getPreferredAddress();
757  ASSERT(!srcAddr.isUnspecified()); // FIXME what if we don't have an address yet?
758  datagram->setSrcAddress(srcAddr);
759  #ifdef WITH_xMIPv6
760  // if the datagram has a tentative address as source we have to reschedule it
761  // as it can not be sent before the address' tentative status is cleared - CB
762  if (ie->ipv6Data()->isTentativeAddress(srcAddr)) {
763  EV_INFO << "Source address is tentative - enqueueing datagram for later resubmission." << endl;
764  ScheduledDatagram *sDgram = new ScheduledDatagram(datagram, ie, nextHopAddr, fromHL);
765  queue.insert(sDgram);
766  return;
767  }
768  #endif /* WITH_xMIPv6 */
769  }
770 
771  int mtu = ie->getMTU();
772 
773  // check if datagram does not require fragmentation
774  if (datagram->getByteLength() <= mtu) {
775  sendDatagramToOutput(datagram, ie, nextHopAddr);
776  return;
777  }
778 
779  // routed datagrams are not fragmented
780  if (!fromHL) {
781  // FIXME check for multicast datagrams, how many ICMP error should be sent
782  icmp->sendErrorMessage(datagram, ICMPv6_PACKET_TOO_BIG, 0); // TODO set MTU
783  return;
784  }
785 
786  // create and send fragments
787  int headerLength = datagram->calculateUnfragmentableHeaderByteLength();
788  int payloadLength = datagram->getByteLength() - headerLength;
789  int fragmentLength = ((mtu - headerLength - IPv6_FRAGMENT_HEADER_LENGTH) / 8) * 8;
790  ASSERT(fragmentLength > 0);
791 
792  int noOfFragments = (payloadLength + fragmentLength - 1) / fragmentLength;
793  EV_INFO << "Breaking datagram into " << noOfFragments << " fragments\n";
794  std::string fragMsgName = datagram->getName();
795  fragMsgName += "-frag";
796 
797  unsigned int identification = curFragmentId++;
798  cPacket *encapsulatedPacket = datagram->decapsulate();
799  for (int offset = 0; offset < payloadLength; offset += fragmentLength) {
800  bool lastFragment = (offset + fragmentLength >= payloadLength);
801  int thisFragmentLength = lastFragment ? payloadLength - offset : fragmentLength;
802 
803  IPv6FragmentHeader *fh = new IPv6FragmentHeader();
804  fh->setIdentification(identification);
805  fh->setFragmentOffset(offset);
806  fh->setMoreFragments(!lastFragment);
807 
808  IPv6Datagram *fragment = datagram->dup();
809  if (offset == 0)
810  fragment->encapsulate(encapsulatedPacket);
811  fragment->setName(fragMsgName.c_str());
812  fragment->addExtensionHeader(fh);
813  fragment->setByteLength(headerLength + fh->getByteLength() + thisFragmentLength);
814 
815  sendDatagramToOutput(fragment, ie, nextHopAddr);
816  }
817 
818  delete datagram;
819 }
Definition: ICMPv6Message_m.h:72
#define IPv6_FRAGMENT_HEADER_LENGTH
Definition: IPv6ExtensionHeaders_m.h:36
unsigned int curFragmentId
Definition: IPv6.h:71
cPacketQueue queue
The queue.
Definition: AbstractQueue.h:48
virtual void sendDatagramToOutput(IPv6Datagram *datagram, const InterfaceEntry *destIE, const MACAddress &macAddr)
Last hoplimit check, then send datagram on the given interface.
Definition: IPv6.cc:821
Definition: ICMPv6Message_m.h:73
ICMPv6 * icmp
Definition: IPv6.h:66
virtual void sendErrorMessage(IPv6Datagram *datagram, ICMPv6Type type, int code)
This method can be called from other modules to send an ICMPv6 error packet.
Definition: ICMPv6.cc:188
InterfaceEntry * inet::IPv6::getSourceInterfaceFrom ( cPacket *  msg)
protectedvirtual

Referenced by decapsulate(), and endService().

218 {
219  cGate *g = msg->getArrivalGate();
220  return g ? ift->getInterfaceByNetworkLayerGateIndex(g->getIndex()) : nullptr;
221 }
virtual InterfaceEntry * getInterfaceByNetworkLayerGateIndex(int index)=0
Returns an interface given by its getNetworkLayerGateIndex().
milli< kg >::type g
Definition: Units.h:900
IInterfaceTable * ift
Definition: IPv6.h:63
void inet::IPv6::handleMessage ( cMessage *  msg)
overrideprotectedvirtual

Handle message.

Reimplemented from inet::AbstractQueue.

124 {
125  if (dynamic_cast<RegisterTransportProtocolCommand *>(msg)) {
126  RegisterTransportProtocolCommand *command = static_cast<RegisterTransportProtocolCommand *>(msg);
127  if (msg->getArrivalGate()->isName("transportIn")) {
128  mapping.addProtocolMapping(command->getProtocol(), msg->getArrivalGate()->getIndex());
129  }
130  else
131  throw cRuntimeError("RegisterTransportProtocolCommand %d arrived invalid gate '%s'", command->getProtocol(), msg->getArrivalGate()->getFullName());
132  delete msg;
133  }
134  else
136 }
void addProtocolMapping(int protocol, int gateIndex)
Definition: ProtocolMap.cc:82
virtual void handleMessage(cMessage *msg) override
Definition: AbstractQueue.cc:43
ProtocolMapping mapping
Definition: IPv6.h:74
void inet::IPv6::handleMessageFromHL ( cPacket *  msg)
protectedvirtual

Handle messages (typically packets to be send in IPv6) from transport or ICMP.

Invokes encapsulate(), then routePacket().

Referenced by endService().

237 {
238  // if no interface exists, do not send datagram
239  if (ift->getNumInterfaces() == 0) {
240  EV_WARN << "No interfaces exist, dropping packet\n";
241  delete msg;
242  return;
243  }
244 
245  IPv6ControlInfo *controlInfo = check_and_cast<IPv6ControlInfo *>(msg->removeControlInfo());
246  // encapsulate upper-layer packet into IPv6Datagram
247  // IPV6_MULTICAST_IF option, but allow interface selection for unicast packets as well
248  const InterfaceEntry *destIE = ift->getInterfaceById(controlInfo->getInterfaceId());
249  IPv6Datagram *datagram = encapsulate(msg, controlInfo);
250  delete controlInfo;
251 
252 #ifdef WITH_xMIPv6
253  if (datagram == nullptr) {
254  EV_WARN << "Encapsulation failed - dropping packet." << endl;
255  delete msg;
256  return;
257  }
258 #endif /* WITH_xMIPv6 */
259 
260  IPv6Address destAddress = datagram->getDestAddress();
261 
262  // check for local delivery
263  if (!destAddress.isMulticast() && rt->isLocalAddress(destAddress)) {
264  EV_INFO << "local delivery\n";
265  if (datagram->getSrcAddress().isUnspecified())
266  datagram->setSrcAddress(destAddress); // allows two apps on the same host to communicate
267 
268  if (destIE && !destIE->isLoopback()) {
269  EV_INFO << "datagram destination address is local, ignoring destination interface specified in the control info\n";
270  destIE = nullptr;
271  }
272  if (!destIE)
273  destIE = ift->getFirstLoopbackInterface();
274  ASSERT(destIE);
275  }
276  L3Address nextHopAddr(IPv6Address::UNSPECIFIED_ADDRESS);
277  if (datagramLocalOutHook(datagram, destIE, nextHopAddr) == INetfilter::IHook::ACCEPT)
278  datagramLocalOut(datagram, destIE, nextHopAddr.toIPv6());
279 }
virtual InterfaceEntry * getInterfaceById(int id) const =0
Returns an interface by its Id.
IPv6RoutingTable * rt
Definition: IPv6.h:64
allows the datagram to pass to the next hook
Definition: INetfilter.h:50
virtual IPv6Datagram * encapsulate(cPacket *transportPacket, IPv6ControlInfo *ctrlInfo)
Encapsulate packet coming from higher layers into IPv6Datagram.
Definition: IPv6.cc:695
IHook::Result datagramLocalOutHook(INetworkDatagram *datagram, const InterfaceEntry *&outIE, L3Address &nextHopAddr)
called before a packet arriving locally is delivered
Definition: IPv6.cc:1109
virtual InterfaceEntry * getFirstLoopbackInterface() const =0
Returns the first interface with the isLoopback flag set.
static const IPv6Address UNSPECIFIED_ADDRESS
The unspecified address.
Definition: IPv6Address.h:66
virtual int getNumInterfaces() const =0
Returns the number of interfaces.
virtual bool isLocalAddress(const IPv6Address &dest) const
Checks if the address is one of the host&#39;s addresses, i.e.
Definition: IPv6RoutingTable.cc:423
virtual void datagramLocalOut(IPv6Datagram *datagram, const InterfaceEntry *destIE, IPv6Address requestedNextHopAddress)
Definition: IPv6.cc:281
IInterfaceTable * ift
Definition: IPv6.h:63
bool inet::IPv6::handleOperationStage ( LifecycleOperation operation,
int  stage,
IDoneCallback doneCallback 
)
overrideprotectedvirtual

Perform one stage of a lifecycle operation.

Processing may be done entirely within this method, or may be a longer process that involves nonzero simulation time or several events, and is triggered by this method call.

Return value: true = "done"; false = "not yet done, will invoke doneCallback when done"

Implements inet::ILifecycle.

932 {
933  throw cRuntimeError("Lifecycle operation support not implemented");
934 }
void inet::IPv6::handleReceivedICMP ( ICMPv6Message msg)
protectedvirtual

Handle incoming ICMP messages.

Referenced by localDeliver().

650 {
651  int type = msg->getType();
652  if (type < 128) {
653  // ICMP errors are delivered to the appropriate higher layer protocols
654  EV_INFO << "ICMPv6 packet: passing it to higher layer\n";
655  IPv6Datagram *bogusPacket = check_and_cast<IPv6Datagram *>(msg->getEncapsulatedPacket());
656  int protocol = bogusPacket->getTransportProtocol();
657  int gateindex = mapping.getOutputGateForProtocol(protocol);
658  send(msg, "transportOut", gateindex);
659  }
660  else {
661  // all others are delivered to ICMP:
662  // ICMPv6_ECHO_REQUEST, ICMPv6_ECHO_REPLY, ICMPv6_MLD_QUERY, ICMPv6_MLD_REPORT,
663  // ICMPv6_MLD_DONE, ICMPv6_ROUTER_SOL, ICMPv6_ROUTER_AD, ICMPv6_NEIGHBOUR_SOL,
664  // ICMPv6_NEIGHBOUR_AD, ICMPv6_MLDv2_REPORT
665  EV_INFO << "ICMPv6 packet: passing it to ICMPv6 module\n";
667  send(msg, "transportOut", gateindex);
668  }
669 }
uint8_t protocol
Definition: TCP_NSC.cc:88
int getOutputGateForProtocol(int protocol) const
find output gate index for protocol ID and returns it.
Definition: ProtocolMap.cc:74
ProtocolMapping mapping
Definition: IPv6.h:74
Definition: IPProtocolId_m.h:87
void inet::IPv6::initialize ( int  stage)
overrideprotectedvirtual

Initialization.

72 {
73  if (stage == INITSTAGE_LOCAL) {
75 
76  ift = getModuleFromPar<IInterfaceTable>(par("interfaceTableModule"), this);
77  rt = getModuleFromPar<IPv6RoutingTable>(par("routingTableModule"), this);
78  nd = getModuleFromPar<IPv6NeighbourDiscovery>(par("ipv6NeighbourDiscoveryModule"), this);
79  icmp = getModuleFromPar<ICMPv6>(par("icmpv6Module"), this);
80  tunneling = getModuleFromPar<IPv6Tunneling>(par("ipv6TunnelingModule"), this);
81 
82  curFragmentId = 0;
83  lastCheckTime = SIMTIME_ZERO;
84  fragbuf.init(icmp);
85 
86  // NetFilter:
87  hooks.clear();
89 
91 
92  WATCH(numMulticast);
93  WATCH(numLocalDeliver);
94  WATCH(numDropped);
95  WATCH(numUnroutable);
96  WATCH(numForwarded);
97  }
98  else if (stage == INITSTAGE_NETWORK_LAYER) {
99  bool isOperational;
100  NodeStatus *nodeStatus = dynamic_cast<NodeStatus *>(findContainingNode(this)->getSubmodule("status"));
101  isOperational = (!nodeStatus) || nodeStatus->getState() == NodeStatus::UP;
102  if (!isOperational)
103  throw cRuntimeError("This module doesn't support starting in node DOWN state");
104  }
105 }
IPv6RoutingTable * rt
Definition: IPv6.h:64
int numMulticast
Definition: IPv6.h:77
void init(ICMPv6 *icmp)
Initialize fragmentation buffer.
Definition: IPv6FragBuf.cc:43
IPv6FragBuf fragbuf
Definition: IPv6.h:72
unsigned int curFragmentId
Definition: IPv6.h:71
int numLocalDeliver
Definition: IPv6.h:78
cModule * findContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:56
Initialization of network-layer protocols, stage 1.
Definition: InitStages.h:72
Local initializations.
Definition: InitStages.h:35
int numUnroutable
Definition: IPv6.h:80
IPv6Tunneling * tunneling
Definition: IPv6.h:68
int numDropped
Definition: IPv6.h:79
DatagramQueueForHooks queuedDatagramsForHooks
Definition: IPv6.h:109
int numForwarded
Definition: IPv6.h:81
virtual void initialize() override
Definition: QueueBase.cc:22
simtime_t lastCheckTime
Definition: IPv6.h:73
IPv6NeighbourDiscovery * nd
Definition: IPv6.h:65
HookList hooks
Definition: IPv6.h:107
ICMPv6 * icmp
Definition: IPv6.h:66
IInterfaceTable * ift
Definition: IPv6.h:63
Definition: NodeStatus.h:40
void inet::IPv6::localDeliver ( IPv6Datagram datagram)
protectedvirtual

Perform reassembly of fragmented datagrams, then send them up to the higher layers using sendToHL().

Referenced by routeMulticastPacket(), and routePacket().

553 {
554  // Defragmentation. skip defragmentation if datagram is not fragmented
555  IPv6FragmentHeader *fh = dynamic_cast<IPv6FragmentHeader *>(datagram->findExtensionHeaderByType(IP_PROT_IPv6EXT_FRAGMENT));
556  if (fh) {
557  EV_DETAIL << "Datagram fragment: offset=" << fh->getFragmentOffset()
558  << ", MORE=" << (fh->getMoreFragments() ? "true" : "false") << ".\n";
559 
560  // erase timed out fragments in fragmentation buffer; check every 10 seconds max
561  if (simTime() >= lastCheckTime + 10) {
562  lastCheckTime = simTime();
564  }
565 
566  datagram = fragbuf.addFragment(datagram, fh, simTime());
567  if (!datagram) {
568  EV_DETAIL << "No complete datagram yet.\n";
569  return;
570  }
571  EV_DETAIL << "This fragment completes the datagram.\n";
572  }
573 
574 #ifdef WITH_xMIPv6
575  // #### 29.08.07 - CB
576  // check for extension headers
577  if (!processExtensionHeaders(datagram)) {
578  // ext. header processing not yet finished
579  // datagram was sent to another module or dropped
580  // -> interrupt local delivery process
581  return;
582  }
583  // #### end CB
584 #endif /* WITH_xMIPv6 */
585 
586  // decapsulate and send on appropriate output gate
587  int protocol = datagram->getTransportProtocol();
588  cPacket *packet = decapsulate(datagram);
589 
590 
591  if (protocol == IP_PROT_IPv6_ICMP && dynamic_cast<IPv6NDMessage *>(packet)) {
592  EV_INFO << "Neigbour Discovery packet: passing it to ND module\n";
593  send(packet, "ndOut");
594  packet = nullptr;
595  }
596 #ifdef WITH_xMIPv6
597  else if (protocol == IP_PROT_IPv6EXT_MOB && dynamic_cast<MobilityHeader *>(packet)) {
598  // added check for MIPv6 support to prevent nodes w/o the
599  // xMIP module from processing related messages, 4.9.07 - CB
600  if (rt->hasMIPv6Support()) {
601  EV_INFO << "MIPv6 packet: passing it to xMIPv6 module\n";
602  send(check_and_cast<MobilityHeader *>(packet), "xMIPv6Out");
603  packet = nullptr;
604  }
605  else {
606  // update 12.9.07 - CB
607  /*RFC3775, 11.3.5
608  Any node that does not recognize the Mobility header will return an
609  ICMP Parameter Problem, Code 1, message to the sender of the packet*/
610  EV_INFO << "No MIPv6 support on this node!\n";
611  IPv6ControlInfo *ctrlInfo = check_and_cast<IPv6ControlInfo *>(packet->removeControlInfo());
613  packet = nullptr;
614  }
615  }
616 #endif /* WITH_xMIPv6 */
617  else if (protocol == IP_PROT_IPv6_ICMP) {
618  handleReceivedICMP(check_and_cast<ICMPv6Message *>(packet));
619  packet = nullptr;
620  } //Added by WEI to forward ICMPv6 msgs to ICMPv6 module.
621  else if (protocol == IP_PROT_IP || protocol == IP_PROT_IPv6) {
622  EV_INFO << "Tunnelled IP datagram\n";
623  send(packet, "upperTunnelingOut");
624  packet = nullptr;
625  }
626  else {
627  int gateindex = mapping.findOutputGateForProtocol(protocol);
628  // check if the transportOut port are connected, otherwise discard the packet
629  if (gateindex >= 0) {
630  cGate *outGate = gate("transportOut", gateindex);
631  if (outGate->isPathOK()) {
632  EV_INFO << "Protocol " << protocol << ", passing up on gate " << gateindex << "\n";
633  //TODO: Indication of forward progress
634  send(packet, outGate);
635  packet = nullptr;
636  return;
637  }
638  }
639 
640  // TODO send ICMP Destination Unreacheable error
641  EV_INFO << "Transport layer gate not connected - dropping packet!\n";
642  IPv6ControlInfo *ctrlInfo = check_and_cast<IPv6ControlInfo *>(packet->removeControlInfo());
644  packet = nullptr;
645  }
646  ASSERT(packet == nullptr);
647 }
IPv6RoutingTable * rt
Definition: IPv6.h:64
Definition: ICMPv6Message_m.h:74
IPv6Datagram * addFragment(IPv6Datagram *datagram, IPv6FragmentHeader *fh, simtime_t now)
Takes a fragment and inserts it into the reassembly buffer.
Definition: IPv6FragBuf.cc:48
uint8_t protocol
Definition: TCP_NSC.cc:88
IPv6FragBuf fragbuf
Definition: IPv6.h:72
void purgeStaleFragments(simtime_t lastupdate)
Throws out all fragments which are incomplete and their last update (last fragment arrival) was befor...
Definition: IPv6FragBuf.cc:142
#define FRAGMENT_TIMEOUT
Definition: IPv6.cc:43
Definition: ICMPv6Message_m.h:149
virtual cPacket * decapsulate(IPv6Datagram *datagram)
Decapsulate and return encapsulated packet after attaching IPv6ControlInfo.
Definition: IPv6.cc:671
int findOutputGateForProtocol(int protocol) const
find output gate index for protocol ID and returns it.
Definition: ProtocolMap.cc:64
Definition: IPProtocolId_m.h:79
virtual void handleReceivedICMP(ICMPv6Message *msg)
Handle incoming ICMP messages.
Definition: IPv6.cc:649
Definition: IPProtocolId_m.h:100
bool hasMIPv6Support()
Can be used to check whether this node supports MIPv6 or not (MN, MR, HA or CN).
Definition: IPv6RoutingTable.h:365
Definition: IPProtocolId_m.h:97
simtime_t lastCheckTime
Definition: IPv6.h:73
Definition: IPProtocolId_m.h:85
bool processExtensionHeaders(IPv6Datagram *datagram)
Process the extension headers of the datagram.
Definition: IPv6.cc:876
ProtocolMapping mapping
Definition: IPv6.h:74
ICMPv6 * icmp
Definition: IPv6.h:66
Definition: IPProtocolId_m.h:87
virtual void sendErrorMessage(IPv6Datagram *datagram, ICMPv6Type type, int code)
This method can be called from other modules to send an ICMPv6 error packet.
Definition: ICMPv6.cc:188
virtual int inet::IPv6::numInitStages ( ) const
inlineoverrideprotectedvirtual
215 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
void inet::IPv6::preroutingFinish ( IPv6Datagram datagram,
const InterfaceEntry fromIE,
const InterfaceEntry destIE,
IPv6Address  nextHopAddr 
)
protectedvirtual

Referenced by endService(), and reinjectQueuedDatagram().

224 {
225  IPv6Address& destAddr = datagram->getDestAddress();
226  // remove control info
227  delete datagram->removeControlInfo();
228 
229  // routepacket
230  if (!destAddr.isMulticast())
231  routePacket(datagram, destIE, nextHopAddr, false);
232  else
233  routeMulticastPacket(datagram, destIE, fromIE, false);
234 }
virtual void routeMulticastPacket(IPv6Datagram *datagram, const InterfaceEntry *destIE, const InterfaceEntry *fromIE, bool fromHL)
Forwards packets to all multicast destinations, using fragmentAndSend().
Definition: IPv6.cc:431
virtual void routePacket(IPv6Datagram *datagram, const InterfaceEntry *destIE, IPv6Address requestedNextHopAddress, bool fromHL)
Performs routing.
Definition: IPv6.cc:292
bool inet::IPv6::processExtensionHeaders ( IPv6Datagram datagram)
protected

Process the extension headers of the datagram.

Returns true if all have been processed successfully and false if errors occured and the packet has to be dropped or if the datagram has been forwarded to another module for further processing.

Referenced by localDeliver().

877 {
878  int noExtHeaders = datagram->getExtensionHeaderArraySize();
879  EV_INFO << noExtHeaders << " extension header(s) for processing..." << endl;
880 
881  // walk through all extension headers
882  for (int i = 0; i < noExtHeaders; i++) {
883  IPv6ExtensionHeader *eh = datagram->removeFirstExtensionHeader();
884 
885  if (dynamic_cast<IPv6RoutingHeader *>(eh)) {
886  IPv6RoutingHeader *rh = (IPv6RoutingHeader *)(eh);
887  EV_DETAIL << "Routing Header with type=" << rh->getRoutingType() << endl;
888 
889  // type 2 routing header should be processed by MIPv6 module
890  // if no MIP support, ignore the header
891  if (rt->hasMIPv6Support() && rh->getRoutingType() == 2) {
892  // for simplicity, we set a context pointer on the datagram
893  datagram->setContextPointer(rh);
894  EV_INFO << "Sending datagram with RH2 to MIPv6 module" << endl;
895  send(datagram, "xMIPv6Out");
896  return false;
897  }
898  else {
899  delete rh;
900  EV_INFO << "Ignoring unknown routing header" << endl;
901  }
902  }
903  else if (dynamic_cast<IPv6DestinationOptionsHeader *>(eh)) {
904  //IPv6DestinationOptionsHeader* doh = (IPv6DestinationOptionsHeader*) (eh);
905  //EV << "object of type=" << typeid(eh).name() << endl;
906 
907  if (rt->hasMIPv6Support() && dynamic_cast<HomeAddressOption *>(eh)) {
908  datagram->setContextPointer(eh);
909  EV_INFO << "Sending datagram with HoA Option to MIPv6 module" << endl;
910  send(datagram, "xMIPv6Out");
911  return false;
912  }
913  else {
914  delete eh;
915  EV_INFO << "Ignoring unknown destination options header" << endl;
916  }
917  }
918  else {
919  delete eh;
920  EV_INFO << "Ignoring unknown extension header" << endl;
921  }
922  }
923 
924  // we have processed no extension headers -> the IPv6 module can continue
925  // working on this datagram
926  return true;
927 }
IPv6RoutingTable * rt
Definition: IPv6.h:64
bool hasMIPv6Support()
Can be used to check whether this node supports MIPv6 or not (MN, MR, HA or CN).
Definition: IPv6RoutingTable.h:365
void inet::IPv6::refreshDisplay ( ) const
overrideprotectedvirtual
108 {
109  char buf[80] = "";
110  if (numForwarded > 0)
111  sprintf(buf + strlen(buf), "fwd:%d ", numForwarded);
112  if (numLocalDeliver > 0)
113  sprintf(buf + strlen(buf), "up:%d ", numLocalDeliver);
114  if (numMulticast > 0)
115  sprintf(buf + strlen(buf), "mcast:%d ", numMulticast);
116  if (numDropped > 0)
117  sprintf(buf + strlen(buf), "DROP:%d ", numDropped);
118  if (numUnroutable > 0)
119  sprintf(buf + strlen(buf), "UNROUTABLE:%d ", numUnroutable);
120  getDisplayString().setTagArg("t", 0, buf);
121 }
int numMulticast
Definition: IPv6.h:77
int numLocalDeliver
Definition: IPv6.h:78
int numUnroutable
Definition: IPv6.h:80
int numDropped
Definition: IPv6.h:79
int numForwarded
Definition: IPv6.h:81
void inet::IPv6::registerHook ( int  priority,
IHook hook 
)
overridevirtual

Adds the provided hook to the list of registered hooks that will be called by the network layer when it processes datagrams.

Implements inet::INetfilter.

938 {
939  Enter_Method("registerHook()");
940  hooks.insert(std::pair<int, INetfilter::IHook *>(priority, hook));
941 }
HookList hooks
Definition: IPv6.h:107
void inet::IPv6::reinjectQueuedDatagram ( const INetworkDatagram datagram)
overridevirtual

Requests the network layer to restart the processing of the datagram.

This function may be used by a reactive routing protocol when it completes the route discovery process.

Implements inet::INetfilter.

967 {
968  Enter_Method("reinjectDatagram()");
969  for (auto iter = queuedDatagramsForHooks.begin(); iter != queuedDatagramsForHooks.end(); iter++) {
970  if (iter->datagram == datagram) {
971  IPv6Datagram *datagram = iter->datagram;
972  switch (iter->hookType) {
974  datagramLocalOut(datagram, iter->outIE, iter->nextHopAddr);
975  break;
976 
978  preroutingFinish(datagram, iter->inIE, iter->outIE, iter->nextHopAddr);
979  break;
980 
982  //fragmentAndSend(datagram, iter->outIE, iter->nextHopAddr);
983  throw cRuntimeError("Re-injection of datagram queued for POSTROUTING hook not implemented");
984  break;
985 
987  //reassembleAndDeliverFinish(datagram);
988  throw cRuntimeError("Re-injection of datagram queued for LOCALIN hook not implemented");
989  break;
990 
992  throw cRuntimeError("Re-injection of datagram queued for FORWARD hook not implemented");
993  break;
994 
995  default:
996  throw cRuntimeError("Unknown hook ID: %d", (int)(iter->hookType));
997  break;
998  }
999  queuedDatagramsForHooks.erase(iter);
1000  return;
1001  }
1002  }
1003 }
Definition: INetfilter.h:42
Definition: INetfilter.h:43
virtual void preroutingFinish(IPv6Datagram *datagram, const InterfaceEntry *fromIE, const InterfaceEntry *destIE, IPv6Address nextHopAddr)
Definition: IPv6.cc:223
Definition: INetfilter.h:45
Definition: INetfilter.h:46
DatagramQueueForHooks queuedDatagramsForHooks
Definition: IPv6.h:109
Definition: INetfilter.h:44
virtual void datagramLocalOut(IPv6Datagram *datagram, const InterfaceEntry *destIE, IPv6Address requestedNextHopAddress)
Definition: IPv6.cc:281
void inet::IPv6::resolveMACAddressAndSendPacket ( IPv6Datagram datagram,
int  interfaceID,
IPv6Address  nextHop,
bool  fromHL 
)
protectedvirtual

Referenced by endService(), and routePacket().

388 {
389  InterfaceEntry *ie = ift->getInterfaceById(interfaceId);
390  ASSERT(ie != nullptr);
391  ASSERT(!nextHop.isUnspecified());
392  IPv6Address destAddress = datagram->getDestAddress();
393  EV_INFO << "next hop for " << destAddress << " is " << nextHop << ", interface " << ie->getName() << "\n";
394 
395 #ifdef WITH_xMIPv6
396  if (rt->isMobileNode()) {
397  // if the source address is the HoA and we have a CoA then drop the packet
398  // (address is topologically incorrect!)
399  if (datagram->getSrcAddress() == ie->ipv6Data()->getMNHomeAddress()
400  && !ie->ipv6Data()->getGlobalAddress(IPv6InterfaceData::CoA).isUnspecified())
401  {
402  EV_WARN << "Using HoA instead of CoA... dropping datagram" << endl;
403  delete datagram;
404  numDropped++;
405  return;
406  }
407  }
408 #endif /* WITH_xMIPv6 */
409 
410  MACAddress macAddr = nd->resolveNeighbour(nextHop, interfaceId); // might initiate NUD
411  if (macAddr.isUnspecified()) {
412  if (!ie->isPointToPoint()) {
413  EV_INFO << "no link-layer address for next hop yet, passing datagram to Neighbour Discovery module\n";
414  IPv6NDControlInfo *ctrl = new IPv6NDControlInfo();
415  ctrl->setFromHL(fromHL);
416  ctrl->setNextHop(nextHop);
417  ctrl->setInterfaceId(interfaceId);
418  datagram->setControlInfo(ctrl);
419  send(datagram, "ndOut");
420  return;
421  }
422  }
423  else
424  EV_DETAIL << "link-layer address: " << macAddr << "\n";
425 
426  // send out datagram
427  numForwarded++;
428  fragmentAndSend(datagram, ie, macAddr, fromHL);
429 }
virtual InterfaceEntry * getInterfaceById(int id) const =0
Returns an interface by its Id.
IPv6RoutingTable * rt
Definition: IPv6.h:64
bool isMobileNode() const
Determine whether a node is a Mobile Node or Correspondent Node: MN if TRUE or else a CN...
Definition: IPv6RoutingTable.h:181
Definition: IPv6InterfaceData.h:211
int numDropped
Definition: IPv6.h:79
const MACAddress & resolveNeighbour(const IPv6Address &nextHop, int interfaceId)
Public method, to be invoked from the IPv6 module to determine link-layer address and the output inte...
Definition: IPv6NeighbourDiscovery.cc:338
int numForwarded
Definition: IPv6.h:81
IPv6NeighbourDiscovery * nd
Definition: IPv6.h:65
virtual void fragmentAndSend(IPv6Datagram *datagram, const InterfaceEntry *destIE, const MACAddress &nextHopAddr, bool fromHL)
Performs fragmentation if needed, and sends the original datagram or the fragments through the specif...
Definition: IPv6.cc:741
IInterfaceTable * ift
Definition: IPv6.h:63
void inet::IPv6::routeMulticastPacket ( IPv6Datagram datagram,
const InterfaceEntry destIE,
const InterfaceEntry fromIE,
bool  fromHL 
)
protectedvirtual

Forwards packets to all multicast destinations, using fragmentAndSend().

Referenced by datagramLocalOut(), and preroutingFinish().

432 {
433  const IPv6Address& destAddr = datagram->getDestAddress();
434 
435  EV_INFO << "destination address " << destAddr << " is multicast, doing multicast routing\n";
436  numMulticast++;
437 
438  // if received from the network...
439  if (fromIE != nullptr) {
440  ASSERT(!fromHL);
441  // deliver locally
442  if (rt->isLocalAddress(destAddr)) {
443  EV_INFO << "local delivery of multicast packet\n";
444  numLocalDeliver++;
445  localDeliver(datagram->dup());
446  }
447 
448  // if datagram arrived from input gate and IP forwarding is off, delete datagram
449  if (!rt->isRouter()) {
450  EV_INFO << "forwarding is off\n";
451  delete datagram;
452  return;
453  }
454 
455  // make sure scope of multicast address is large enough to be forwarded to other links
456  if (destAddr.getMulticastScope() <= 2) {
457  EV_INFO << "multicast dest address is link-local (or smaller) scope\n";
458  delete datagram;
459  return;
460  }
461 
462  // hop counter decrement: only if datagram arrived from network, and will be
463  // sent out to the network (hoplimit check will be done just before sending
464  // out datagram)
465  // TBD: in IPv4, arrange TTL check like this
466  datagram->setHopLimit(datagram->getHopLimit() - 1);
467  }
468 
469  // for now, we just send it out on every interface except on which it came. FIXME better!!!
470  EV_INFO << "sending out datagram on every interface (except incoming one)\n";
471  for (int i = 0; i < ift->getNumInterfaces(); i++) {
472  InterfaceEntry *ie = ift->getInterface(i);
473  if (fromIE != ie && !ie->isLoopback())
474  fragmentAndSend(datagram->dup(), ie, MACAddress::BROADCAST_ADDRESS, fromHL);
475  }
476  delete datagram;
477 
478 /* FIXME implement handling of multicast
479 
480  According to Gopi: "multicast routing table" should map
481  srcAddr+multicastDestAddr to a set of next hops (interface+nexthopAddr)
482  Where srcAddr is the multicast server, and destAddr sort of narrows it down to a given stream
483 
484  // FIXME multicast-->tunneling link (present in original IPSuite) missing from here
485 
486  // DVMRP: process datagram only if sent locally or arrived on the shortest
487  // route (provided routing table already contains srcAddr); otherwise
488  // discard and continue.
489  int inputGateIndex = datagram->getArrivalGate() ? datagram->getArrivalGate()->getIndex() : -1;
490  int shortestPathInputGateIndex = rt->outputGateIndexNo(datagram->getSrcAddress());
491  if (inputGateIndex!=-1 && shortestPathInputGateIndex!=-1 && inputGateIndex!=shortestPathInputGateIndex)
492  {
493  // FIXME count dropped
494  EV << "Packet dropped.\n";
495  delete datagram;
496  return;
497  }
498 
499  // check for local delivery
500  IPv6Address destAddress = datagram->getDestAddress();
501  if (rt->isLocalMulticastAddress(destAddress))
502  {
503  IPv6Datagram *datagramCopy = datagram->dup();
504 
505  // FIXME code from the MPLS model: set packet dest address to routerId (???)
506  datagramCopy->setDestAddress(rt->getRouterId());
507 
508  localDeliver(datagramCopy);
509  }
510 
511  // forward datagram only if IP forward is enabled, or sent locally
512  if (inputGateIndex!=-1 && !rt->isRouter())
513  {
514  delete datagram;
515  return;
516  }
517 
518  MulticastRoutes routes = rt->getMulticastRoutesFor(destAddress);
519  if (routes.size()==0)
520  {
521  // no destination: delete datagram
522  delete datagram;
523  }
524  else
525  {
526  // copy original datagram for multiple destinations
527  for (unsigned int i=0; i<routes.size(); i++)
528  {
529  int outputGateIndex = routes[i].interf->outputGateIndex();
530 
531  // don't forward to input port
532  if (outputGateIndex>=0 && outputGateIndex!=inputGateIndex)
533  {
534  IPv6Datagram *datagramCopy = datagram->dup();
535 
536  // set datagram source address if not yet set
537  if (datagramCopy->getSrcAddress().isUnspecified())
538  datagramCopy->setSrcAddress(ift->interfaceByPortNo(outputGateIndex)->ipv6Data()->getIPAddress());
539 
540  // send
541  IPv6Address nextHopAddr = routes[i].gateway;
542  fragmentAndSend(datagramCopy, outputGateIndex, macAddr, fromHL);
543  }
544  }
545 
546  // only copies sent, delete original datagram
547  delete datagram;
548  }
549  */
550 }
virtual void localDeliver(IPv6Datagram *datagram)
Perform reassembly of fragmented datagrams, then send them up to the higher layers using sendToHL()...
Definition: IPv6.cc:552
IPv6RoutingTable * rt
Definition: IPv6.h:64
int numMulticast
Definition: IPv6.h:77
int numLocalDeliver
Definition: IPv6.h:78
virtual bool isRouter() const
IP forwarding on/off.
Definition: IPv6RoutingTable.h:155
virtual int getNumInterfaces() const =0
Returns the number of interfaces.
virtual bool isLocalAddress(const IPv6Address &dest) const
Checks if the address is one of the host&#39;s addresses, i.e.
Definition: IPv6RoutingTable.cc:423
virtual InterfaceEntry * getInterface(int pos) const =0
Returns the InterfaceEntry specified by an index 0..numInterfaces-1.
virtual void fragmentAndSend(IPv6Datagram *datagram, const InterfaceEntry *destIE, const MACAddress &nextHopAddr, bool fromHL)
Performs fragmentation if needed, and sends the original datagram or the fragments through the specif...
Definition: IPv6.cc:741
IInterfaceTable * ift
Definition: IPv6.h:63
static const MACAddress BROADCAST_ADDRESS
The broadcast MAC address, ff:ff:ff:ff:ff:ff.
Definition: MACAddress.h:60
void inet::IPv6::routePacket ( IPv6Datagram datagram,
const InterfaceEntry destIE,
IPv6Address  requestedNextHopAddress,
bool  fromHL 
)
protectedvirtual

Performs routing.

Based on the routing decision, it dispatches to localDeliver() for local packets, to fragmentAndSend() for forwarded packets, to routeMulticastPacket() for multicast packets, or drops the packet if it's unroutable or forwarding is off.

Referenced by datagramLocalOut(), and preroutingFinish().

293 {
294  // TBD add option handling code here
295  IPv6Address destAddress = datagram->getDestAddress();
296 
297  EV_INFO << "Routing datagram `" << datagram->getName() << "' with dest=" << destAddress << ", requested nexthop is " << requestedNextHopAddress << " on " << (destIE ? destIE->getFullName() : "unspec") << " interface: \n";
298 
299  // local delivery of unicast packets
300  if (rt->isLocalAddress(destAddress)) {
301  if (fromHL)
302  throw cRuntimeError("model error: local unicast packet arrived from HL, but handleMessageFromHL() not detected it");
303  EV_INFO << "local delivery\n";
304 
305  numLocalDeliver++;
306  localDeliver(datagram);
307  return;
308  }
309 
310  if (!fromHL) {
311  // if datagram arrived from input gate and IP forwarding is off, delete datagram
312  //yes but datagrams from the ND module is getting dropped too!-WEI
313  //so we add a 2nd condition
314  // FIXME rewrite code so that condition is cleaner --Andras
315  //if (!rt->isRouter())
316  if (!rt->isRouter() && !(datagram->getArrivalGate()->isName("ndIn"))) {
317  EV_INFO << "forwarding is off, dropping packet\n";
318  numDropped++;
319  delete datagram;
320  return;
321  }
322 
323  // don't forward link-local addresses or weaker
324  if (destAddress.isLinkLocal() || destAddress.isLoopback()) {
325  EV_INFO << "dest address is link-local (or weaker) scope, doesn't get forwarded\n";
326  delete datagram;
327  return;
328  }
329 
330  // hop counter decrement: only if datagram arrived from network, and will be
331  // sent out to the network (hoplimit check will be done just before sending
332  // out datagram)
333  // TBD: in IPv4, arrange TTL check like this
334  datagram->setHopLimit(datagram->getHopLimit() - 1);
335  }
336 
337  // routing
338  int interfaceId = -1;
339  IPv6Address nextHop(requestedNextHopAddress);
340 
341 #ifdef WITH_xMIPv6
342  // tunneling support - CB
343  // check if destination is covered by tunnel lists
344  if ((datagram->getTransportProtocol() != IP_PROT_IPv6) && // if datagram was already tunneled, don't tunnel again
345  (datagram->getExtensionHeaderArraySize() == 0) && // we do not already have extension headers - FIXME: check for RH2 existence
346  ((rt->isMobileNode() && rt->isHomeAddress(datagram->getSrcAddress())) || // for MNs: only if source address is a HoA // 27.08.07 - CB
347  rt->isHomeAgent() || // but always check for tunnel if node is a HA
348  !rt->isMobileNode() // or if it is a correspondent or non-MIP node
349  )
350  )
351  {
352  if (datagram->getTransportProtocol() == IP_PROT_IPv6EXT_MOB)
353  // in case of mobility header we can only search for "real" tunnels
354  // as T2RH or HoA Opt. are not allowed with these messages
355  interfaceId = tunneling->getVIfIndexForDest(destAddress, IPv6Tunneling::NORMAL); // 10.06.08 - CB
356  //getVIfIndexForDestForXSplitTunnel(destAddress);
357  else
358  // otherwise we can search for everything
359  interfaceId = tunneling->getVIfIndexForDest(destAddress);
360  }
361 #else // ifdef WITH_xMIPv6
362  // FIXME this is not the same as the code above (when WITH_xMIPv6 is defined),
363  // so tunneling examples could not work with xMIPv6
364  interfaceId = tunneling->getVIfIndexForDest(destAddress, IPv6Tunneling::NORMAL);
365 #endif /* WITH_xMIPv6 */
366 
367  if (interfaceId == -1 && destIE != nullptr)
368  interfaceId = destIE->getInterfaceId(); // set interfaceId to destIE when not tunneling
369 
370  if (interfaceId > ift->getBiggestInterfaceId()) {
371  // a virtual tunnel interface provides a path to the destination: do tunneling
372  EV_INFO << "tunneling: src addr=" << datagram->getSrcAddress() << ", dest addr=" << destAddress << std::endl;
373  send(datagram, "lowerTunnelingOut");
374  return;
375  }
376 
377  if (interfaceId == -1)
378  if (!determineOutputInterface(destAddress, nextHop, interfaceId, datagram, fromHL))
379  // no interface found; sent to ND or to ICMP for error processing
380  //throw cRuntimeError("No interface found!");//return;
381  return;
382  // don't raise error if sent to ND or ICMP!
383 
384  resolveMACAddressAndSendPacket(datagram, interfaceId, nextHop, fromHL);
385 }
virtual int getBiggestInterfaceId() const =0
Returns the biggest interface Id.
virtual void localDeliver(IPv6Datagram *datagram)
Perform reassembly of fragmented datagrams, then send them up to the higher layers using sendToHL()...
Definition: IPv6.cc:552
IPv6RoutingTable * rt
Definition: IPv6.h:64
bool determineOutputInterface(const IPv6Address &destAddress, IPv6Address &nextHop, int &interfaceId, IPv6Datagram *datagram, bool fromHL)
Determines the correct interface for the specified destination address.
Definition: IPv6.cc:835
virtual void resolveMACAddressAndSendPacket(IPv6Datagram *datagram, int interfaceID, IPv6Address nextHop, bool fromHL)
Definition: IPv6.cc:387
bool isMobileNode() const
Determine whether a node is a Mobile Node or Correspondent Node: MN if TRUE or else a CN...
Definition: IPv6RoutingTable.h:181
Definition: IPv6Tunneling.h:52
int getVIfIndexForDest(const IPv6Address &destAddress)
Returns the virtual interface identifier for the tunnel which has the provided destination as destina...
Definition: IPv6Tunneling.cc:310
bool isHomeAddress(const IPv6Address &addr)
Check whether provided address is a HoA.
Definition: IPv6RoutingTable.cc:776
int numLocalDeliver
Definition: IPv6.h:78
virtual bool isRouter() const
IP forwarding on/off.
Definition: IPv6RoutingTable.h:155
IPv6Tunneling * tunneling
Definition: IPv6.h:68
Definition: IPProtocolId_m.h:100
int numDropped
Definition: IPv6.h:79
virtual bool isLocalAddress(const IPv6Address &dest) const
Checks if the address is one of the host&#39;s addresses, i.e.
Definition: IPv6RoutingTable.cc:423
bool isHomeAgent() const
Determine whether normal Router or Home Agent.
Definition: IPv6RoutingTable.h:170
Definition: IPProtocolId_m.h:85
IInterfaceTable * ift
Definition: IPv6.h:63
void inet::IPv6::sendDatagramToOutput ( IPv6Datagram datagram,
const InterfaceEntry destIE,
const MACAddress macAddr 
)
protectedvirtual

Last hoplimit check, then send datagram on the given interface.

Referenced by fragmentAndSend().

822 {
823  // if link layer uses MAC addresses (basically, not PPP), add control info
824  if (!macAddr.isUnspecified()) {
825  Ieee802Ctrl *controlInfo = new Ieee802Ctrl();
826  controlInfo->setDest(macAddr);
827  controlInfo->setEtherType(ETHERTYPE_IPv6);
828  datagram->setControlInfo(controlInfo);
829  }
830 
831  // send datagram to link layer
832  send(datagram, "queueOut", destIE->getNetworkLayerGateIndex());
833 }
Definition: Ieee802Ctrl_m.h:120
void inet::IPv6::unregisterHook ( int  priority,
IHook hook 
)
overridevirtual

Removes the provided hook from the list of registered hooks.

Implements inet::INetfilter.

944 {
945  Enter_Method("unregisterHook()");
946  for (auto iter = hooks.begin(); iter != hooks.end(); iter++) {
947  if ((iter->first == priority) && (iter->second == hook)) {
948  hooks.erase(iter);
949  return;
950  }
951  }
952 }
HookList hooks
Definition: IPv6.h:107

Member Data Documentation

unsigned int inet::IPv6::curFragmentId = -1
protected

Referenced by fragmentAndSend(), and initialize().

IPv6FragBuf inet::IPv6::fragbuf
protected

Referenced by initialize(), and localDeliver().

ICMPv6* inet::IPv6::icmp = nullptr
protected
simtime_t inet::IPv6::lastCheckTime
protected

Referenced by initialize(), and localDeliver().

ProtocolMapping inet::IPv6::mapping
protected
IPv6NeighbourDiscovery* inet::IPv6::nd = nullptr
protected
int inet::IPv6::numDropped = 0
protected
int inet::IPv6::numForwarded = 0
protected
int inet::IPv6::numLocalDeliver = 0
protected
int inet::IPv6::numMulticast = 0
protected
int inet::IPv6::numUnroutable = 0
protected
IPv6Tunneling* inet::IPv6::tunneling = nullptr
protected

Referenced by initialize(), and routePacket().


The documentation for this class was generated from the following files: