INET Framework for OMNeT++/OMNEST
inet::sctp::SctpUdpHook Class Reference

#include <SctpUdpHook.h>

Inheritance diagram for inet::sctp::SctpUdpHook:
inet::NetfilterBase::HookBase inet::INetfilter::IHook

Public Member Functions

 SctpUdpHook ()
 
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
 

Constructor & Destructor Documentation

◆ SctpUdpHook()

inet::sctp::SctpUdpHook::SctpUdpHook ( )
inline
21 {}

Member Function Documentation

◆ datagramForwardHook()

virtual Result inet::sctp::SctpUdpHook::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.

25 { return ACCEPT; }

◆ datagramLocalInHook()

virtual Result inet::sctp::SctpUdpHook::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.

27 { return ACCEPT; }

◆ datagramLocalOutHook()

virtual Result inet::sctp::SctpUdpHook::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.

28 { return ACCEPT; }

◆ datagramPostRoutingHook()

virtual Result inet::sctp::SctpUdpHook::datagramPostRoutingHook ( Packet datagram)
inlineoverridevirtual

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

Implements inet::INetfilter::IHook.

26 { return ACCEPT; }

◆ datagramPreRoutingHook()

INetfilter::IHook::Result inet::sctp::SctpUdpHook::datagramPreRoutingHook ( Packet datagram)
overridevirtual

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.

27 {
28  Enter_Method("datagramPreRoutingHook");
29 
30  EV_INFO << "SctpUdpHook::datagramPreRoutingHook\n";
31  EV_INFO << "Packet: " << packet << endl;
32 // auto networkProtocol = packet->getMandatoryTag<PacketProtocolTag>()->getProtocol();
33  const auto& networkHeader = getNetworkProtocolHeader(packet);
34  EV_INFO << "Protocol is " << networkHeader->getProtocol()->getId() << endl;
35  if (networkHeader->getProtocol() == &Protocol::udp) {
36  EV_INFO << "Protocol is udp\n";
37  const auto& ipv4Header = removeNetworkProtocolHeader<Ipv4Header>(packet);
38  EV_INFO << "network header removed. packet now " << packet << endl;
39  auto udpHeader = packet->peekAtFront<UdpHeader>();
40  EV_INFO << "udp header removed. packet now " << packet << endl;
41  EV_INFO << "dest port " << udpHeader->getDestPort() << endl;
42  if (udpHeader->getDestPort() == SCTP_UDP_PORT) {
43  packet->removeAtFront<UdpHeader>();
44  ipv4Header->setProtocolId(IP_PROT_SCTP);
45  }
46  insertNetworkProtocolHeader(packet, Protocol::ipv4, ipv4Header);
47  packet->addTagIfAbsent<PacketProtocolTag>()->setProtocol(&Protocol::sctp);
48  packet->addTagIfAbsent<DispatchProtocolReq>()->setProtocol(&Protocol::sctp);
49  EV_INFO << "Packet mit Network: " << packet << endl;
50  }
51  else {
52  EV_INFO << "Protocol is " << networkHeader->getProtocol()->getId() << endl;
53  }
54  return ACCEPT;
55 }

The documentation for this class was generated from the following files:
inet::Protocol::ipv4
static const Protocol ipv4
Definition: Protocol.h:93
DispatchProtocolReq
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
SCTP_UDP_PORT
#define SCTP_UDP_PORT
Definition: Sctp.h:31
inet::insertNetworkProtocolHeader
void insertNetworkProtocolHeader(Packet *packet, const Protocol &protocol, const Ptr< NetworkHeaderBase > &header)
Definition: L3Tools.cc:70
PacketProtocolTag
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
inet::IP_PROT_SCTP
@ IP_PROT_SCTP
Definition: IpProtocolId_m.h:108
inet::getNetworkProtocolHeader
const Ptr< const NetworkHeaderBase > getNetworkProtocolHeader(Packet *packet)
Definition: L3Tools.cc:43
inet::Protocol::udp
static const Protocol udp
Definition: Protocol.h:117
inet::Protocol::sctp
static const Protocol sctp
Definition: Protocol.h:108
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