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

Represents a packet with MPLS headers. More...

#include <MPLSPacket.h>

Inheritance diagram for inet::MPLSPacket:

Public Member Functions

 MPLSPacket (const char *name=nullptr)
 
 MPLSPacket (const MPLSPacket &p)
 
virtual MPLSPacketoperator= (const MPLSPacket &p)
 
virtual MPLSPacketdup () const override
 cloning function More...
 
virtual std::string info () const override
 Returns a string with the labels, starting with the top of stack. More...
 
void swapLabel (int newLabel)
 Swap Label operation. More...
 
void pushLabel (int newLabel)
 Pushes new label on the label stack. More...
 
void popLabel ()
 Pops the top label. More...
 
bool hasLabel ()
 Returns true if the label stack is not empty. More...
 
int getTopLabel ()
 Returns the top label. More...
 

Protected Types

typedef std::vector< int > LabelStack
 

Protected Attributes

LabelStack labels
 

Private Member Functions

void copy (const MPLSPacket &other)
 

Detailed Description

Represents a packet with MPLS headers.

Member Typedef Documentation

typedef std::vector<int> inet::MPLSPacket::LabelStack
protected

Constructor & Destructor Documentation

inet::MPLSPacket::MPLSPacket ( const char *  name = nullptr)
23  : cPacket(name)
24 {
25 }
inet::MPLSPacket::MPLSPacket ( const MPLSPacket p)
28  : cPacket(p)
29 {
30  copy(p);
31 }
void copy(const MPLSPacket &other)
Definition: MPLSPacket.h:35

Member Function Documentation

void inet::MPLSPacket::copy ( const MPLSPacket other)
inlineprivate

Referenced by MPLSPacket(), and operator=().

35 { labels = other.labels; }
LabelStack labels
Definition: MPLSPacket.h:32
virtual MPLSPacket* inet::MPLSPacket::dup ( ) const
inlineoverridevirtual

cloning function

48 { return new MPLSPacket(*this); }
MPLSPacket(const char *name=nullptr)
Definition: MPLSPacket.cc:23
int inet::MPLSPacket::getTopLabel ( )
inline

Returns the top label.

Referenced by inet::MPLS::processMPLSPacketFromL2().

78 { return labels.back(); }
LabelStack labels
Definition: MPLSPacket.h:32
bool inet::MPLSPacket::hasLabel ( )
inline

Returns true if the label stack is not empty.

Referenced by inet::MPLS::doStackOps(), inet::MPLS::processMPLSPacketFromL2(), and inet::MPLS::tryLabelAndForwardIPv4Datagram().

73 { return !labels.empty(); }
LabelStack labels
Definition: MPLSPacket.h:32
std::string inet::MPLSPacket::info ( ) const
overridevirtual

Returns a string with the labels, starting with the top of stack.

44 {
45  std::stringstream out;
46  for (int i = (int)labels.size() - 1; i >= 0; i--)
47  out << labels[i] << (i == 0 ? "" : " ");
48  return out.str();
49 }
LabelStack labels
Definition: MPLSPacket.h:32
MPLSPacket & inet::MPLSPacket::operator= ( const MPLSPacket p)
virtual
35 {
36  if (this == &p)
37  return *this;
38  cPacket::operator=(p);
39  copy(p);
40  return *this;
41 }
void copy(const MPLSPacket &other)
Definition: MPLSPacket.h:35
void inet::MPLSPacket::popLabel ( )
inline

Pops the top label.

Referenced by inet::MPLS::doStackOps().

68 { labels.pop_back(); addBitLength(-32); }
LabelStack labels
Definition: MPLSPacket.h:32
void inet::MPLSPacket::pushLabel ( int  newLabel)
inline

Pushes new label on the label stack.

Referenced by inet::MPLS::doStackOps().

63 { labels.push_back(newLabel); addBitLength(32); }
LabelStack labels
Definition: MPLSPacket.h:32
void inet::MPLSPacket::swapLabel ( int  newLabel)
inline

Swap Label operation.

Referenced by inet::MPLS::doStackOps().

58 { labels.back() = newLabel; }
LabelStack labels
Definition: MPLSPacket.h:32

Member Data Documentation

LabelStack inet::MPLSPacket::labels
protected

Referenced by copy(), and info().


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