Public Member Functions | Protected Types | Protected Attributes

MPLSPacket Class Reference

#include <MPLSPacket.h>

List of all members.

Public Member Functions

 MPLSPacket (const char *name=NULL)
 MPLSPacket (const MPLSPacket &p)
virtual MPLSPacketoperator= (const MPLSPacket &p)
virtual MPLSPacketdup () const
virtual std::string info () const
void swapLabel (int newLabel)
void pushLabel (int newLabel)
void popLabel ()
bool hasLabel ()
int getTopLabel ()

Protected Types

typedef std::vector< int > LabelStack

Protected Attributes

LabelStack labels

Detailed Description

Represents a packet with MPLS headers

Definition at line 26 of file MPLSPacket.h.


Member Typedef Documentation

typedef std::vector<int> MPLSPacket::LabelStack [protected]

Definition at line 29 of file MPLSPacket.h.


Constructor & Destructor Documentation

MPLSPacket::MPLSPacket ( const char *  name = NULL  ) 

Definition at line 21 of file MPLSPacket.cc.

                                       : cPacket(name)
{
}

MPLSPacket::MPLSPacket ( const MPLSPacket p  ) 

Definition at line 25 of file MPLSPacket.cc.

{
    setName(p.getName());
    operator=(p);
}


Member Function Documentation

virtual MPLSPacket* MPLSPacket::dup (  )  const [inline, virtual]

cloning function

Definition at line 43 of file MPLSPacket.h.

{return new MPLSPacket(*this);}

int MPLSPacket::getTopLabel (  )  [inline]

Returns the top label

Definition at line 73 of file MPLSPacket.h.

Referenced by MPLS::processMPLSPacketFromL2().

{return labels.back();}

bool MPLSPacket::hasLabel (  )  [inline]

Returns true if the label stack is not empty

Definition at line 68 of file MPLSPacket.h.

Referenced by MPLS::doStackOps(), MPLS::processMPLSPacketFromL2(), and MPLS::tryLabelAndForwardIPDatagram().

{return !labels.empty();}

std::string MPLSPacket::info (  )  const [virtual]

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

Definition at line 39 of file MPLSPacket.cc.

{
    std::stringstream out;
    for (int i = (int)labels.size()-1; i >= 0; i--)
        out << labels[i] << (i==0?"":" ");
    return out.str();
}

MPLSPacket & MPLSPacket::operator= ( const MPLSPacket p  )  [virtual]

Definition at line 32 of file MPLSPacket.cc.

Referenced by MPLSPacket().

{
    cPacket::operator=(p);
    labels = p.labels;
    return *this;
}

void MPLSPacket::popLabel (  )  [inline]

Pops the top label

Definition at line 63 of file MPLSPacket.h.

Referenced by MPLS::doStackOps().

{labels.pop_back();addBitLength(-32);}

void MPLSPacket::pushLabel ( int  newLabel  )  [inline]

Pushes new label on the label stack

Definition at line 58 of file MPLSPacket.h.

Referenced by MPLS::doStackOps().

{labels.push_back(newLabel);addBitLength(32);}

void MPLSPacket::swapLabel ( int  newLabel  )  [inline]

Swap Label operation

Definition at line 53 of file MPLSPacket.h.

Referenced by MPLS::doStackOps().

{labels.back()=newLabel;}


Member Data Documentation

Definition at line 30 of file MPLSPacket.h.

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


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