SimpleClassifier.h

Go to the documentation of this file.
00001 //
00002 // (C) 2005 Vojtech Janota
00003 //
00004 // This library is free software, you can redistribute it
00005 // and/or modify
00006 // it under  the terms of the GNU Lesser General Public License
00007 // as published by the Free Software Foundation;
00008 // either version 2 of the License, or any later version.
00009 // The library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00012 // See the GNU Lesser General Public License for more details.
00013 //
00014 
00015 #ifndef __INET_SIMPLECLASSIFIER_H
00016 #define __INET_SIMPLECLASSIFIER_H
00017 
00018 #include <omnetpp.h>
00019 #include <vector>
00020 #include <string>
00021 #include "ConstType.h"
00022 #include "IPAddress.h"
00023 #include "IPDatagram.h"
00024 #include "IScriptable.h"
00025 #include "IRSVPClassifier.h"
00026 #include "LIBTable.h"
00027 #include "IntServ.h"
00028 
00029 class RSVP;
00030 
00034 class INET_API SimpleClassifier: public cSimpleModule, public IScriptable, public IRSVPClassifier
00035 {
00036   public:
00037     struct FECEntry
00038     {
00039         int id;
00040 
00041         IPAddress src;
00042         IPAddress dest;
00043 
00044         SessionObj_t session;
00045         SenderTemplateObj_t sender;
00046 
00047         int inLabel;
00048     };
00049 
00050   protected:
00051     IPAddress routerId;
00052     int maxLabel;
00053 
00054     std::vector<FECEntry> bindings;
00055     LIBTable *lt;
00056     RSVP *rsvp;
00057 
00058   public:
00059     SimpleClassifier() {}
00060 
00061   protected:
00062     virtual void initialize(int stage);
00063     virtual int numInitStages() const  {return 5;}
00064     virtual void handleMessage(cMessage *msg);
00065 
00066     // IScriptable implementation
00067     virtual void processCommand(const cXMLElement& node);
00068 
00069     // IRSVPClassifier implementation
00070     virtual bool lookupLabel(IPDatagram *ipdatagram, LabelOpVector& outLabel, std::string& outInterface, int& color);
00071     virtual void bind(const SessionObj_t& session, const SenderTemplateObj_t& sender, int inLabel);
00072 
00073   protected:
00074     virtual void readTableFromXML(const cXMLElement *fectable);
00075     virtual void readItemFromXML(const cXMLElement *fec);
00076     std::vector<FECEntry>::iterator findFEC(int fecid);
00077 };
00078 
00079 #endif
00080