INET Framework for OMNeT++/OMNEST
RIPRouting.h
Go to the documentation of this file.
00001 
00024 #ifndef HLIDAC_RIPROUTING
00025 #define HLIDAC_RIPROUTING
00026 
00027 #include <omnetpp.h>
00028 #include "UDPAppBase.h"
00029 #include "RIPRouting.h"
00030 #include "RIPPacket_m.h"
00031 #include "RIPTimer_m.h"
00032 #include "RoutingTableAccess.h"
00033 #include "IRoutingTable.h"
00034 #include "IPRoute.h"
00035 #include "UDPControlInfo_m.h"
00036 #include "OSPFcommon.h"
00037 #include "IInterfaceTable.h"
00038 #include "InterfaceTableAccess.h"
00039 #include "ICMPMessage_m.h"
00040 #include "NotificationBoard.h"
00041 #include "NotifierConsts.h"
00042 #include "InterfaceStateManager.h"
00043 
00044 class IPv4InterfaceData;
00045 
00051 struct RIPinterface
00052 {
00053         int                             intID;          
00054         IPvXAddress     addr;           
00055         IPvXAddress     mask;           
00056         bool                            broadcast;      
00057         bool                            loopback;       
00058         bool                            passive;        
00059         InterfaceEntry*entry;          
00060 };
00061 
00066 struct RIPRouteTimer
00067 {
00068         IPRoute *       route;            
00069         RIPTimer *      timer;            
00070 };
00071 
00076 struct RIPRouteTwins
00077 {
00078         IPRoute *       route1;           
00079         IPRoute *       route2;           
00080 };
00081 
00088 struct RIPRedistribution
00089 {
00090         char *          protocol;         
00091         int                     metric;           
00092         bool                    redistrinute;     
00093 };
00094 
00095 class RIPRouting: public UDPAppBase, protected INotifiable
00096 {
00097    private:
00098         std::vector<RIPRouteTimer>      routeTimer;    
00099       std::vector<IPAddress>    network;       
00100       std::vector<RIPinterface>         ripIft;        
00101       std::vector<IPRoute *>            intDown;       
00102       std::vector<RIPRouteTwins> routeTwins;    
00103       RIPTimer *                                                triggerTimer;  
00104       IRoutingTable             *rt;           
00105       IInterfaceTable           *ift;          
00106       NotificationBoard                         *nb;           
00107       UDPControlInfo            *udpCtrl;      
00108       int                       localPort;     
00109       int                       destPort;      
00110       const char *                                      hostname;      
00111       RIPRedistribution                         redistr;       
00113       // zpracovaní RIP zpráv
00114       void processPacket(cMessage *msg);
00115       void processRequest(RIPPacket *msg);
00116       void processResponse(RIPPacket *msg);
00117 
00118       // odesílání a tvorba RIP zpráv
00119       void sendPacket(int command, IPAddress destAddr);
00120       RIPPacket* createPacket(int command, InterfaceEntry * entry);
00121       std::vector<RouteEntry> fillNetworks(InterfaceEntry * entry);
00122 
00123       // nacteni konfigurace, redistribuce, notifikace
00124       bool LoadConfigFromXML(const char * filename);
00125       std::vector<RouteEntry> getOSPFRoutes();
00126       void receiveChangeNotification(int category, const cPolymorphic *details);
00127 
00128       // pomocné metody
00129       void sendTrigger();
00130       bool checkTwin(IPRoute * entryRT);
00131       RIPTimer * updateTimer(int type, RIPRouteTimer * entry);
00132       int getRouteRT (RIPTimer *timer);
00133       int getTimerRT (IPRoute *route);
00134       void insertIft(InterfaceEntry * entryIFT);
00135 
00136    protected:
00137       virtual int numInitStages() const  {return 4;}
00138       virtual void handleMessage(cMessage *msg);
00139       virtual void initialize(int stage);
00140 
00141    public:
00142       virtual ~RIPRouting();
00143 };
00144 
00145 #endif