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

#include <Udp.h>

Inheritance diagram for inet::UdpCrcInsertionHook:
inet::NetfilterBase::HookBase inet::INetfilter::IHook

Public Member Functions

virtual Result datagramPreRoutingHook (Packet *packet) override
 This is the first hook called by the network protocol before it routes a datagram that was received from the lower layer. More...
 
virtual Result datagramForwardHook (Packet *packet) override
 This is the second hook called by the network protocol before it sends a datagram to the lower layer. More...
 
virtual Result datagramPostRoutingHook (Packet *packet) override
 This is the last hook called by the network protocol before it sends a datagram to the lower layer. More...
 
virtual Result datagramLocalInHook (Packet *packet) override
 This is the last hook called by the network protocol before it sends a datagram to the upper layer. More...
 
virtual Result datagramLocalOutHook (Packet *packet) override
 This is the first hook called by the network protocol before it routes a datagram that was received from the upper layer. More...
 
- Public Member Functions inherited from inet::NetfilterBase::HookBase
virtual ~HookBase ()
 
void registeredTo (INetfilter *nf)
 
void unregisteredFrom (INetfilter *nf)
 
bool isRegisteredHook (INetfilter *nf)
 
- Public Member Functions inherited from inet::INetfilter::IHook
virtual ~IHook ()
 

Additional Inherited Members

- Public Types inherited from inet::INetfilter::IHook
enum  Type {
  PREROUTING, LOCALIN, FORWARD, POSTROUTING,
  LOCALOUT
}
 
enum  Result { ACCEPT, DROP, QUEUE, STOLEN }
 
- Protected Attributes inherited from inet::NetfilterBase::HookBase
std::vector< INetfilter * > netfilters
 

Member Function Documentation

◆ datagramForwardHook()

virtual Result inet::UdpCrcInsertionHook::datagramForwardHook ( Packet datagram)
inlineoverridevirtual

This is the second hook called by the network protocol before it sends a datagram to the lower layer.

This is done after the datagramPreRoutingHook or the datagramLocalInHook is called and the datagram is routed.

Implements inet::INetfilter::IHook.

44 { return ACCEPT; }

◆ datagramLocalInHook()

virtual Result inet::UdpCrcInsertionHook::datagramLocalInHook ( Packet datagram)
inlineoverridevirtual

This is the last hook called by the network protocol before it sends a datagram to the upper layer.

This is done after the datagramPreRoutingHook is called and the datagram is routed.

Implements inet::INetfilter::IHook.

46 { return ACCEPT; }

◆ datagramLocalOutHook()

virtual Result inet::UdpCrcInsertionHook::datagramLocalOutHook ( Packet datagram)
inlineoverridevirtual

This is the first hook called by the network protocol before it routes a datagram that was received from the upper layer.

The nextHopAddress is ignored when the outputNetworkInterface is a nullptr. After this is done

Implements inet::INetfilter::IHook.

47 { return ACCEPT; }

◆ datagramPostRoutingHook()

INetfilter::IHook::Result inet::UdpCrcInsertionHook::datagramPostRoutingHook ( Packet datagram)
overridevirtual

This is the last hook called by the network protocol before it sends a datagram to the lower layer.

Implements inet::INetfilter::IHook.

1469 {
1470  Enter_Method("datagramPostRoutingHook");
1471 
1472  if (packet->findTag<InterfaceInd>())
1473  return ACCEPT; // FORWARD
1474 
1475  auto networkProtocol = packet->getTag<PacketProtocolTag>()->getProtocol();
1476  const auto& networkHeader = getNetworkProtocolHeader(packet);
1477  if (networkHeader->getProtocol() == &Protocol::udp) {
1478  ASSERT(!networkHeader->isFragment());
1479  packet->eraseAtFront(networkHeader->getChunkLength());
1480  auto udpHeader = packet->removeAtFront<UdpHeader>();
1481  ASSERT(udpHeader->getCrcMode() == CRC_COMPUTED);
1482  const L3Address& srcAddress = networkHeader->getSourceAddress();
1483  const L3Address& destAddress = networkHeader->getDestinationAddress();
1484  Udp::insertCrc(networkProtocol, srcAddress, destAddress, udpHeader, packet);
1485  packet->insertAtFront(udpHeader);
1486  packet->insertAtFront(networkHeader);
1487  }
1488 
1489  return ACCEPT;
1490 }

◆ datagramPreRoutingHook()

virtual Result inet::UdpCrcInsertionHook::datagramPreRoutingHook ( Packet datagram)
inlineoverridevirtual

This is the first hook called by the network protocol before it routes a datagram that was received from the lower layer.

The nextHopAddress is ignored when the outputNetworkInterface is nullptr.

Implements inet::INetfilter::IHook.

43 { return ACCEPT; }

The documentation for this class was generated from the following files:
inet::CRC_COMPUTED
@ CRC_COMPUTED
Definition: CrcMode_m.h:59
PacketProtocolTag
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
inet::Udp::insertCrc
static void insertCrc(const Protocol *networkProtocol, const L3Address &srcAddress, const L3Address &destAddress, const Ptr< UdpHeader > &udpHeader, Packet *udpPayload)
Definition: Udp.cc:809
inet::getNetworkProtocolHeader
const Ptr< const NetworkHeaderBase > getNetworkProtocolHeader(Packet *packet)
Definition: L3Tools.cc:43
inet::Protocol::udp
static const Protocol udp
Definition: Protocol.h:117
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
inet::INetfilter::IHook::ACCEPT
@ ACCEPT
allows the datagram to pass to the next hook
Definition: INetfilter.h:40