Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __INET_LIBTABLE_H
00017 #define __INET_LIBTABLE_H
00018
00019 #include <omnetpp.h>
00020 #include <vector>
00021 #include <string>
00022 #include "ConstType.h"
00023 #include "IPAddress.h"
00024 #include "IPDatagram.h"
00025
00026
00027 #define PUSH_OPER 0
00028 #define SWAP_OPER 1
00029 #define POP_OPER 2
00030
00034 struct LabelOp
00035 {
00036 int label;
00037 int optcode;
00038 };
00039
00040 typedef std::vector<LabelOp> LabelOpVector;
00041
00045 class INET_API LIBTable: public cSimpleModule
00046 {
00047 public:
00048 struct LIBEntry
00049 {
00050 int inLabel;
00051 std::string inInterface;
00052
00053 LabelOpVector outLabel;
00054 std::string outInterface;
00055
00056
00057 int color;
00058 };
00059
00060 protected:
00061 IPAddress routerId;
00062 int maxLabel;
00063 std::vector<LIBEntry> lib;
00064
00065 protected:
00066 virtual void initialize(int stage);
00067 virtual int numInitStages() const {return 5;}
00068 virtual void handleMessage(cMessage *msg);
00069
00070
00071 virtual void readTableFromXML(const cXMLElement* libtable);
00072
00073 public:
00074
00075 virtual bool resolveLabel(std::string inInterface, int inLabel,
00076 LabelOpVector& outLabel, std::string& outInterface, int& color);
00077
00078 virtual int installLibEntry(int inLabel, std::string inInterface, const LabelOpVector& outLabel,
00079 std::string outInterface, int color);
00080
00081 virtual void removeLibEntry(int inLabel);
00082
00083
00084 static LabelOpVector pushLabel(int label);
00085 static LabelOpVector swapLabel(int label);
00086 static LabelOpVector popLabel();
00087 };
00088
00089 std::ostream & operator<<(std::ostream & os, const LIBTable::LIBEntry & lib);
00090 std::ostream & operator<<(std::ostream & os, const LabelOpVector& label);
00091
00092 #endif
00093