MPLSPacket.h

Go to the documentation of this file.
00001 //
00002 // (C) 2005 Vojtech Janota
00003 // (C) 2003 Xuan Thang Nguyen
00004 //
00005 // This library is free software, you can redistribute it
00006 // and/or modify
00007 // it under  the terms of the GNU Lesser General Public License
00008 // as published by the Free Software Foundation;
00009 // either version 2 of the License, or any later version.
00010 // The library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00013 // See the GNU Lesser General Public License for more details.
00014 //
00015 
00016 #ifndef __INET_MPLSPACKET_H
00017 #define __INET_MPLSPACKET_H
00018 
00019 #include <stack>
00020 #include <omnetpp.h>
00021 #include "INETDefs.h"
00022 
00026 class INET_API MPLSPacket: public cPacket
00027 {
00028   protected:
00029     typedef std::vector<int> LabelStack; // note: last element is the top of stack
00030     LabelStack labels;
00031 
00032   public:
00033     /* constructors*/
00034     MPLSPacket(const char *name=NULL);
00035     MPLSPacket(const MPLSPacket &p);
00036 
00037     /* assignment operator*/
00038     virtual MPLSPacket& operator=(const MPLSPacket& p);
00039 
00043     virtual MPLSPacket *dup() const {return new MPLSPacket(*this);}
00044 
00048     virtual std::string info() const;
00049 
00053     inline void swapLabel(int newLabel)  {labels.back()=newLabel;}
00054 
00058     inline void pushLabel(int newLabel)  {labels.push_back(newLabel);addBitLength(32);}
00059 
00063     inline void popLabel()  {labels.pop_back();addBitLength(-32);}
00064 
00068     inline bool hasLabel()  {return !labels.empty();}
00069 
00073     inline int getTopLabel()  {return labels.back();}
00074 };
00075 
00076 #endif
00077 
00078