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

Control information for sending/receiving packets over IPv4. More...

#include <IPv4ControlInfo.h>

Inheritance diagram for inet::IPv4ControlInfo:
inet::IPv4ControlInfo_Base inet::INetworkProtocolControlInfo

Public Member Functions

 IPv4ControlInfo ()
 
virtual ~IPv4ControlInfo ()
 
 IPv4ControlInfo (const IPv4ControlInfo &other)
 
IPv4ControlInfooperator= (const IPv4ControlInfo &other)
 
virtual IPv4ControlInfodup () const override
 
virtual int getDiffServCodePoint () const override
 Returns bits 0-5 of the Type of Service field, a value in the 0..63 range. More...
 
virtual void setDiffServCodePoint (int dscp) override
 Sets bits 0-5 of the Type of Service field; expects a value in the 0..63 range. More...
 
virtual int getExplicitCongestionNotification () const override
 Returns bits 6-7 of the Type of Service field, a value in the range 0..3. More...
 
virtual void setExplicitCongestionNotification (int ecn) override
 Sets bits 6-7 of the Type of Service; expects a value in the 0..3 range. More...
 
virtual void setOrigDatagram (IPv4Datagram *d)
 
virtual IPv4DatagramgetOrigDatagram () const
 
virtual IPv4DatagramremoveOrigDatagram ()
 
virtual short getTransportProtocol () const override
 
virtual void setTransportProtocol (short protocol) override
 
virtual L3Address getSourceAddress () const override
 
virtual void setSourceAddress (const L3Address &address) override
 
virtual L3Address getDestinationAddress () const override
 
virtual void setDestinationAddress (const L3Address &address) override
 
virtual int getInterfaceId () const override
 
virtual void setInterfaceId (int interfaceId) override
 
virtual short getHopLimit () const override
 
virtual void setHopLimit (short hopLimit) override
 
- Public Member Functions inherited from inet::IPv4ControlInfo_Base
virtual ~IPv4ControlInfo_Base ()
 
virtual void parsimPack (omnetpp::cCommBuffer *b) const override
 
virtual void parsimUnpack (omnetpp::cCommBuffer *b) override
 
virtual IPv4AddressgetDestAddr ()
 
virtual const IPv4AddressgetDestAddr () const
 
virtual void setDestAddr (const IPv4Address &destAddr)
 
virtual IPv4AddressgetSrcAddr ()
 
virtual const IPv4AddressgetSrcAddr () const
 
virtual void setSrcAddr (const IPv4Address &srcAddr)
 
virtual bool getMulticastLoop () const
 
virtual void setMulticastLoop (bool multicastLoop)
 
virtual short getProtocol () const
 
virtual void setProtocol (short protocol)
 
virtual unsigned char getTypeOfService () const
 
virtual void setTypeOfService (unsigned char typeOfService)
 
virtual short getTimeToLive () const
 
virtual void setTimeToLive (short timeToLive)
 
virtual bool getDontFragment () const
 
virtual void setDontFragment (bool dontFragment)
 
- Public Member Functions inherited from inet::INetworkProtocolControlInfo
virtual ~INetworkProtocolControlInfo ()
 

Protected Attributes

IPv4Datagramdgram
 
- Protected Attributes inherited from inet::IPv4ControlInfo_Base
IPv4Address destAddr
 
IPv4Address srcAddr
 
int interfaceId
 
bool multicastLoop
 
short protocol
 
unsigned char typeOfService
 
short timeToLive
 
bool dontFragment
 

Private Member Functions

void copy (const IPv4ControlInfo &other)
 
void clean ()
 

Additional Inherited Members

- Protected Member Functions inherited from inet::IPv4ControlInfo_Base
bool operator== (const IPv4ControlInfo_Base &)
 
 IPv4ControlInfo_Base ()
 
 IPv4ControlInfo_Base (const IPv4ControlInfo_Base &other)
 
IPv4ControlInfo_Baseoperator= (const IPv4ControlInfo_Base &other)
 

Detailed Description

Control information for sending/receiving packets over IPv4.

See the IPv4ControlInfo.msg file for more info.

Constructor & Destructor Documentation

inet::IPv4ControlInfo::IPv4ControlInfo ( )
inline
43 : IPv4ControlInfo_Base() { dgram = nullptr; }
IPv4Datagram * dgram
Definition: IPv4ControlInfo.h:36
inet::IPv4ControlInfo::~IPv4ControlInfo ( )
virtual
27 {
28  clean();
29 }
void clean()
Definition: IPv4ControlInfo.cc:41
inet::IPv4ControlInfo::IPv4ControlInfo ( const IPv4ControlInfo other)
inline
45 : IPv4ControlInfo_Base(other) { dgram = nullptr; copy(other); }
void copy(const IPv4ControlInfo &other)
Definition: IPv4ControlInfo.cc:51
IPv4Datagram * dgram
Definition: IPv4ControlInfo.h:36

Member Function Documentation

void inet::IPv4ControlInfo::clean ( )
private

Referenced by operator=(), and ~IPv4ControlInfo().

42 {
43 #ifdef WITH_IPv4
44  dropAndDelete(dgram);
45 #else // ifdef WITH_IPv4
46  if (dgram)
47  throw cRuntimeError("INET was compiled without IPv4 support");
48 #endif // ifdef WITH_IPv4
49 }
IPv4Datagram * dgram
Definition: IPv4ControlInfo.h:36
void inet::IPv4ControlInfo::copy ( const IPv4ControlInfo other)
private

Referenced by operator=().

52 {
53  dgram = other.dgram;
54 
55  if (dgram) {
56 #ifdef WITH_IPv4
57  dgram = dgram->dup();
58  take(dgram);
59 #else // ifdef WITH_IPv4
60  throw cRuntimeError(this, "INET was compiled without IPv4 support");
61 #endif // ifdef WITH_IPv4
62  }
63 }
virtual IPv4Datagram * dup() const override
Definition: IPv4Datagram.h:42
IPv4Datagram * dgram
Definition: IPv4ControlInfo.h:36
virtual IPv4ControlInfo* inet::IPv4ControlInfo::dup ( ) const
inlineoverridevirtual

Reimplemented from inet::IPv4ControlInfo_Base.

47 { return new IPv4ControlInfo(*this); }
IPv4ControlInfo()
Definition: IPv4ControlInfo.h:43
virtual L3Address inet::IPv4ControlInfo::getDestinationAddress ( ) const
inlineoverridevirtual

Implements inet::INetworkProtocolControlInfo.

77 { return L3Address(destAddr); }
IPv4Address destAddr
Definition: IPv4ControlInfo_m.h:116
virtual int inet::IPv4ControlInfo::getDiffServCodePoint ( ) const
inlineoverridevirtual

Returns bits 0-5 of the Type of Service field, a value in the 0..63 range.

Implements inet::IPv4ControlInfo_Base.

52 { return getTypeOfService() & 0x3f; }
virtual unsigned char getTypeOfService() const
virtual int inet::IPv4ControlInfo::getExplicitCongestionNotification ( ) const
inlineoverridevirtual

Returns bits 6-7 of the Type of Service field, a value in the range 0..3.

Implements inet::IPv4ControlInfo_Base.

62 { return (getTypeOfService() >> 6) & 0x03; }
virtual unsigned char getTypeOfService() const
virtual short inet::IPv4ControlInfo::getHopLimit ( ) const
inlineoverridevirtual

Implements inet::INetworkProtocolControlInfo.

81 { return getTimeToLive(); }
virtual short getTimeToLive() const
virtual IPv4Datagram* inet::IPv4ControlInfo::getOrigDatagram ( ) const
inlinevirtual
70 { return dgram; }
IPv4Datagram * dgram
Definition: IPv4ControlInfo.h:36
virtual L3Address inet::IPv4ControlInfo::getSourceAddress ( ) const
inlineoverridevirtual

Implements inet::INetworkProtocolControlInfo.

75 { return L3Address(srcAddr); }
IPv4Address srcAddr
Definition: IPv4ControlInfo_m.h:117
virtual short inet::IPv4ControlInfo::getTransportProtocol ( ) const
inlineoverridevirtual
IPv4ControlInfo & inet::IPv4ControlInfo::operator= ( const IPv4ControlInfo other)
32 {
33  if (this == &other)
34  return *this;
35  clean();
37  copy(other);
38  return *this;
39 }
void copy(const IPv4ControlInfo &other)
Definition: IPv4ControlInfo.cc:51
IPv4ControlInfo_Base & operator=(const IPv4ControlInfo_Base &other)
void clean()
Definition: IPv4ControlInfo.cc:41
IPv4Datagram * inet::IPv4ControlInfo::removeOrigDatagram ( )
virtual

Referenced by inet::ICMP::sendErrorMessage().

78 {
79 #ifdef WITH_IPv4
80  if (!dgram)
81  throw cRuntimeError(this, "IPv4ControlInfo::removeOrigDatagram(): no datagram attached "
82  "(already removed, or maybe this IPv4ControlInfo does not come "
83  "from the IPv4 module?)");
84 
85  IPv4Datagram *ret = dgram;
86  drop(dgram);
87  dgram = nullptr;
88  return ret;
89 #else // ifdef WITH_IPv4
90  throw cRuntimeError(this, "INET was compiled without IPv4 support");
91 #endif // ifdef WITH_IPv4
92 }
IPv4Datagram * dgram
Definition: IPv4ControlInfo.h:36
virtual void inet::IPv4ControlInfo::setDestinationAddress ( const L3Address address)
inlineoverridevirtual

Implements inet::INetworkProtocolControlInfo.

78 { destAddr = address.toIPv4(); }
IPv4Address destAddr
Definition: IPv4ControlInfo_m.h:116
virtual void inet::IPv4ControlInfo::setDiffServCodePoint ( int  dscp)
inlineoverridevirtual

Sets bits 0-5 of the Type of Service field; expects a value in the 0..63 range.

Implements inet::IPv4ControlInfo_Base.

57 { setTypeOfService((getTypeOfService() & 0xc0) | (dscp & 0x3f)); }
virtual void setTypeOfService(unsigned char typeOfService)
virtual unsigned char getTypeOfService() const
virtual void inet::IPv4ControlInfo::setExplicitCongestionNotification ( int  ecn)
inlineoverridevirtual

Sets bits 6-7 of the Type of Service; expects a value in the 0..3 range.

Implements inet::IPv4ControlInfo_Base.

67 { setTypeOfService((getTypeOfService() & 0x3f) | ((ecn & 0x3) << 6)); }
virtual void setTypeOfService(unsigned char typeOfService)
virtual unsigned char getTypeOfService() const
virtual void inet::IPv4ControlInfo::setHopLimit ( short  hopLimit)
inlineoverridevirtual

Implements inet::INetworkProtocolControlInfo.

82 { setTimeToLive(hopLimit); }
virtual void setTimeToLive(short timeToLive)
void inet::IPv4ControlInfo::setOrigDatagram ( IPv4Datagram d)
virtual

Referenced by inet::IPv4::decapsulate().

66 {
67 #ifdef WITH_IPv4
68  if (dgram)
69  throw cRuntimeError(this, "IPv4ControlInfo::setOrigDatagram(): a datagram is already attached");
70  dgram = d;
71  take(dgram);
72 #else // ifdef WITH_IPv4
73  throw cRuntimeError(this, "INET was compiled without IPv4 support");
74 #endif // ifdef WITH_IPv4
75 }
IPv4Datagram * dgram
Definition: IPv4ControlInfo.h:36
virtual void inet::IPv4ControlInfo::setSourceAddress ( const L3Address address)
inlineoverridevirtual

Implements inet::INetworkProtocolControlInfo.

76 { srcAddr = address.toIPv4(); }
IPv4Address srcAddr
Definition: IPv4ControlInfo_m.h:117
virtual void inet::IPv4ControlInfo::setTransportProtocol ( short  protocol)
inlineoverridevirtual

Implements inet::INetworkProtocolControlInfo.

virtual void setProtocol(short protocol)
short protocol
Definition: IPv4ControlInfo_m.h:120

Member Data Documentation

IPv4Datagram* inet::IPv4ControlInfo::dgram
protected

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