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

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

#include <IPv6ControlInfo.h>

Inheritance diagram for inet::IPv6ControlInfo:
inet::IPv6ControlInfo_Base inet::INetworkProtocolControlInfo

Public Member Functions

 IPv6ControlInfo ()
 
virtual ~IPv6ControlInfo ()
 
 IPv6ControlInfo (const IPv6ControlInfo &other)
 
IPv6ControlInfooperator= (const IPv6ControlInfo &other)
 
virtual IPv6ControlInfodup () const override
 
virtual void setOrigDatagram (IPv6Datagram *d)
 
virtual IPv6DatagramgetOrigDatagram () const
 
virtual IPv6DatagramremoveOrigDatagram ()
 
virtual int getDiffServCodePoint () const override
 Returns bits 0-5 of the Traffic Class field, a value in the 0..63 range. More...
 
virtual void setDiffServCodePoint (int dscp) override
 Sets bits 0-5 of the Traffic Class field; expects a value in the 0..63 range. More...
 
virtual int getExplicitCongestionNotification () const override
 Returns bits 6-7 of the Traffic Class field, a value in the range 0..3. More...
 
virtual void setExplicitCongestionNotification (int ecn) override
 Sets bits 6-7 of the Traffic Class field; expects a value in the 0..3 range. More...
 
virtual unsigned int getExtensionHeaderArraySize () const override
 Returns the number of extension headers in this datagram. More...
 
virtual void setExtensionHeaderArraySize (unsigned int size) override
 Generated but unused method, should not be called. More...
 
virtual IPv6ExtensionHeaderPtrgetExtensionHeader (unsigned int k) override
 Returns the kth extension header in this datagram. More...
 
virtual void setExtensionHeader (unsigned int k, const IPv6ExtensionHeaderPtr &extensionHeader_var) override
 Generated but unused method, should not be called. More...
 
virtual void addExtensionHeader (IPv6ExtensionHeader *eh, int atPos=-1)
 Adds an extension header to the datagram, at the given position. More...
 
IPv6ExtensionHeaderremoveFirstExtensionHeader ()
 Remove the first extension header and return it. More...
 
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::IPv6ControlInfo_Base
virtual ~IPv6ControlInfo_Base ()
 
virtual void parsimPack (omnetpp::cCommBuffer *b) const override
 
virtual void parsimUnpack (omnetpp::cCommBuffer *b) override
 
virtual short getProtocol () const
 
virtual void setProtocol (short protocol)
 
virtual IPv6AddressgetDestAddr ()
 
virtual const IPv6AddressgetDestAddr () const
 
virtual void setDestAddr (const IPv6Address &destAddr)
 
virtual IPv6AddressgetSrcAddr ()
 
virtual const IPv6AddressgetSrcAddr () const
 
virtual void setSrcAddr (const IPv6Address &srcAddr)
 
virtual unsigned char getTrafficClass () const
 
virtual void setTrafficClass (unsigned char trafficClass)
 
virtual bool getMulticastLoop () const
 
virtual void setMulticastLoop (bool multicastLoop)
 
virtual const IPv6ExtensionHeaderPtrgetExtensionHeader (unsigned int k) const
 
- Public Member Functions inherited from inet::INetworkProtocolControlInfo
virtual ~INetworkProtocolControlInfo ()
 

Protected Types

typedef std::vector< IPv6ExtensionHeader * > ExtensionHeaders
 

Protected Attributes

IPv6Datagramdgram
 
ExtensionHeaders extensionHeaders
 
- Protected Attributes inherited from inet::IPv6ControlInfo_Base
short protocol
 
IPv6Address destAddr
 
IPv6Address srcAddr
 
unsigned char trafficClass
 
short hopLimit
 
int interfaceId
 
bool multicastLoop
 

Private Member Functions

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

Additional Inherited Members

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

Detailed Description

Control information for sending/receiving packets over IPv6.

See the IPv6ControlInfo.msg file for more info.

Member Typedef Documentation

Constructor & Destructor Documentation

inet::IPv6ControlInfo::IPv6ControlInfo ( )
inline
46 : IPv6ControlInfo_Base() { dgram = nullptr; }
IPv6Datagram * dgram
Definition: IPv6ControlInfo.h:37
inet::IPv6ControlInfo::~IPv6ControlInfo ( )
virtual
64 {
65  clean();
66 }
void clean()
Definition: IPv6ControlInfo.cc:50
inet::IPv6ControlInfo::IPv6ControlInfo ( const IPv6ControlInfo other)
inline
48 : IPv6ControlInfo_Base(other) { copy(other); }
void copy(const IPv6ControlInfo &other)
Definition: IPv6ControlInfo.cc:26

Member Function Documentation

void inet::IPv6ControlInfo::addExtensionHeader ( IPv6ExtensionHeader eh,
int  atPos = -1 
)
virtual

Adds an extension header to the datagram, at the given position.

The default (atPos==-1) is to add the header at the end.

Referenced by inet::IPv6Tunneling::encapsulateDatagram().

120 {
121 #ifdef WITH_IPv6
122  ASSERT(eh);
123  if (atPos < 0 || (ExtensionHeaders::size_type)atPos >= extensionHeaders.size()) {
124  extensionHeaders.push_back(eh);
125  return;
126  }
127 
128  // insert at position atPos, shift up the rest of the array
129  extensionHeaders.insert(extensionHeaders.begin() + atPos, eh);
130 #else // ifdef WITH_IPv6
131  throw cRuntimeError(this, "INET was compiled without IPv6 support");
132 #endif // ifdef WITH_IPv6
133 }
ExtensionHeaders extensionHeaders
Definition: IPv6ControlInfo.h:39
void inet::IPv6ControlInfo::clean ( )
private

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

51 {
52 #ifdef WITH_IPv6
53  dropAndDelete(dgram);
54 
55  while (!extensionHeaders.empty()) {
56  IPv6ExtensionHeader *eh = extensionHeaders.back();
57  extensionHeaders.pop_back();
58  delete eh;
59  }
60 #endif // ifdef WITH_IPv6
61 }
IPv6Datagram * dgram
Definition: IPv6ControlInfo.h:37
ExtensionHeaders extensionHeaders
Definition: IPv6ControlInfo.h:39
void inet::IPv6ControlInfo::copy ( const IPv6ControlInfo other)
private

Referenced by operator=().

27 {
28 #ifdef WITH_IPv6
29  dgram = other.dgram;
30  if (dgram) {
31  dgram = dgram->dup();
32  take(dgram);
33  }
34 
35  for (const auto & elem : other.extensionHeaders)
36  extensionHeaders.push_back((elem)->dup());
37 #endif // ifdef WITH_IPv6
38 }
IPv6Datagram * dgram
Definition: IPv6ControlInfo.h:37
virtual IPv6ControlInfo * dup() const override
Definition: IPv6ControlInfo.h:50
ExtensionHeaders extensionHeaders
Definition: IPv6ControlInfo.h:39
virtual IPv6Datagram * dup() const override
Definition: IPv6Datagram.h:49
virtual IPv6ControlInfo* inet::IPv6ControlInfo::dup ( ) const
inlineoverridevirtual

Reimplemented from inet::IPv6ControlInfo_Base.

Referenced by copy().

50 { return new IPv6ControlInfo(*this); }
IPv6ControlInfo()
Definition: IPv6ControlInfo.h:46
virtual L3Address inet::IPv6ControlInfo::getDestinationAddress ( ) const
inlineoverridevirtual

Implements inet::INetworkProtocolControlInfo.

107 { return L3Address(destAddr); }
IPv6Address destAddr
Definition: IPv6ControlInfo_m.h:120
virtual int inet::IPv6ControlInfo::getDiffServCodePoint ( ) const
inlineoverridevirtual

Returns bits 0-5 of the Traffic Class field, a value in the 0..63 range.

Implements inet::IPv6ControlInfo_Base.

59 { return getTrafficClass() & 0x3f; }
virtual unsigned char getTrafficClass() const
virtual int inet::IPv6ControlInfo::getExplicitCongestionNotification ( ) const
inlineoverridevirtual

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

Implements inet::IPv6ControlInfo_Base.

69 { return (getTrafficClass() >> 6) & 0x03; }
virtual unsigned char getTrafficClass() const
IPv6ExtensionHeaderPtr & inet::IPv6ControlInfo::getExtensionHeader ( unsigned int  k)
overridevirtual

Returns the kth extension header in this datagram.

Implements inet::IPv6ControlInfo_Base.

109 {
110  ASSERT(k < extensionHeaders.size());
111  return extensionHeaders[k];
112 }
ExtensionHeaders extensionHeaders
Definition: IPv6ControlInfo.h:39
const double k
Definition: QAM16Modulation.cc:24
unsigned int inet::IPv6ControlInfo::getExtensionHeaderArraySize ( ) const
overridevirtual

Returns the number of extension headers in this datagram.

Implements inet::IPv6ControlInfo_Base.

Referenced by inet::IPv6::encapsulate().

99 {
100  return extensionHeaders.size();
101 }
ExtensionHeaders extensionHeaders
Definition: IPv6ControlInfo.h:39
virtual IPv6Datagram* inet::IPv6ControlInfo::getOrigDatagram ( ) const
inlinevirtual
53 { return dgram; }
IPv6Datagram * dgram
Definition: IPv6ControlInfo.h:37
virtual L3Address inet::IPv6ControlInfo::getSourceAddress ( ) const
inlineoverridevirtual

Implements inet::INetworkProtocolControlInfo.

105 { return L3Address(srcAddr); }
IPv6Address srcAddr
Definition: IPv6ControlInfo_m.h:121
virtual short inet::IPv6ControlInfo::getTransportProtocol ( ) const
inlineoverridevirtual
IPv6ControlInfo & inet::IPv6ControlInfo::operator= ( const IPv6ControlInfo other)
41 {
42  if (this == &other)
43  return *this;
44  clean();
46  copy(other);
47  return *this;
48 }
void copy(const IPv6ControlInfo &other)
Definition: IPv6ControlInfo.cc:26
IPv6ControlInfo_Base & operator=(const IPv6ControlInfo_Base &other)
void clean()
Definition: IPv6ControlInfo.cc:50
IPv6ExtensionHeader * inet::IPv6ControlInfo::removeFirstExtensionHeader ( )

Remove the first extension header and return it.

Referenced by inet::IPv6::encapsulate().

136 {
137  if (extensionHeaders.empty())
138  return nullptr;
139 
140 #ifdef WITH_IPv6
141  auto first = extensionHeaders.begin();
142  IPv6ExtensionHeader *ret = *first;
143  extensionHeaders.erase(first);
144  return ret;
145 #else // ifdef WITH_IPv6
146  throw cRuntimeError(this, "INET was compiled without IPv6 support");
147 #endif // ifdef WITH_IPv6
148 }
ExtensionHeaders extensionHeaders
Definition: IPv6ControlInfo.h:39
IPv6Datagram * inet::IPv6ControlInfo::removeOrigDatagram ( )
virtual

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

82 {
83 #ifdef WITH_IPv6
84  if (!dgram)
85  throw cRuntimeError(this, "IPv6ControlInfo::removeOrigDatagram(): no datagram attached "
86  "(already removed, or maybe this IPv6ControlInfo does not come "
87  "from the IPv6 module?)");
88 
89  IPv6Datagram *ret = dgram;
90  drop(dgram);
91  dgram = nullptr;
92  return ret;
93 #else // ifdef WITH_IPv6
94  throw cRuntimeError(this, "INET was compiled without IPv6 support");
95 #endif // ifdef WITH_IPv6
96 }
IPv6Datagram * dgram
Definition: IPv6ControlInfo.h:37
virtual void inet::IPv6ControlInfo::setDestinationAddress ( const L3Address address)
inlineoverridevirtual

Implements inet::INetworkProtocolControlInfo.

108 { destAddr = address.toIPv6(); }
IPv6Address destAddr
Definition: IPv6ControlInfo_m.h:120
virtual void inet::IPv6ControlInfo::setDiffServCodePoint ( int  dscp)
inlineoverridevirtual

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

Implements inet::IPv6ControlInfo_Base.

64 { setTrafficClass((getTrafficClass() & 0xc0) | (dscp & 0x3f)); }
virtual void setTrafficClass(unsigned char trafficClass)
virtual unsigned char getTrafficClass() const
virtual void inet::IPv6ControlInfo::setExplicitCongestionNotification ( int  ecn)
inlineoverridevirtual

Sets bits 6-7 of the Traffic Class field; expects a value in the 0..3 range.

Implements inet::IPv6ControlInfo_Base.

74 { setTrafficClass((getTrafficClass() & 0x3f) | ((ecn & 0x3) << 6)); }
virtual void setTrafficClass(unsigned char trafficClass)
virtual unsigned char getTrafficClass() const
void inet::IPv6ControlInfo::setExtensionHeader ( unsigned int  k,
const IPv6ExtensionHeaderPtr extensionHeader_var 
)
overridevirtual

Generated but unused method, should not be called.

Implements inet::IPv6ControlInfo_Base.

115 {
116  throw cRuntimeError(this, "setExtensionHeader() not supported, use addExtensionHeader()");
117 }
void inet::IPv6ControlInfo::setExtensionHeaderArraySize ( unsigned int  size)
overridevirtual

Generated but unused method, should not be called.

Implements inet::IPv6ControlInfo_Base.

104 {
105  throw cRuntimeError(this, "setExtensionHeaderArraySize() not supported, use addExtensionHeader()");
106 }
virtual void inet::IPv6ControlInfo::setHopLimit ( short  hopLimit)
inlineoverridevirtual
virtual void inet::IPv6ControlInfo::setInterfaceId ( int  interfaceId)
inlineoverridevirtual
void inet::IPv6ControlInfo::setOrigDatagram ( IPv6Datagram d)
virtual

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

69 {
70 #ifdef WITH_IPv6
71  if (dgram)
72  throw cRuntimeError(this, "IPv6ControlInfo::setOrigDatagram(): a datagram is already attached");
73 
74  dgram = d;
75  take(dgram);
76 #else // ifdef WITH_IPv6
77  throw cRuntimeError("INET was compiled without IPv6 support");
78 #endif // ifdef WITH_IPv6
79 }
IPv6Datagram * dgram
Definition: IPv6ControlInfo.h:37
virtual void inet::IPv6ControlInfo::setSourceAddress ( const L3Address address)
inlineoverridevirtual

Implements inet::INetworkProtocolControlInfo.

106 { srcAddr = address.toIPv6(); }
IPv6Address srcAddr
Definition: IPv6ControlInfo_m.h:121
virtual void inet::IPv6ControlInfo::setTransportProtocol ( short  protocol)
inlineoverridevirtual

Implements inet::INetworkProtocolControlInfo.

virtual void setProtocol(short protocol)
short protocol
Definition: IPv6ControlInfo_m.h:119

Member Data Documentation

IPv6Datagram* inet::IPv6ControlInfo::dgram
protected

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