IPRoute.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2008 Andras Varga
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program 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.  See the
00012 // GNU Lesser General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU Lesser General Public License
00015 // along with this program; if not, see <http://www.gnu.org/licenses/>.
00016 //
00017 
00018 #ifndef __INET_IPROUTE_H
00019 #define __INET_IPROUTE_H
00020 
00021 #include <vector>
00022 #include <omnetpp.h>
00023 #include "INETDefs.h"
00024 #include "IPAddress.h"
00025 
00026 class InterfaceEntry;
00027 
00033 class INET_API IPRoute : public cPolymorphic
00034 {
00035   public:
00037     enum RouteType
00038     {
00039         DIRECT,  
00040         REMOTE   
00041     };
00042 
00044     enum RouteSource
00045     {
00046         MANUAL,       
00047         IFACENETMASK, 
00048         RIP,          
00049         OSPF,         
00050         BGP,          
00051         ZEBRA,        
00052     };
00053 
00054   protected:
00055     IPAddress host;     
00056     IPAddress netmask;  
00057     IPAddress gateway;  
00058     InterfaceEntry *interfacePtr; 
00059     RouteType type;     
00060     RouteSource source; 
00061     int metric;         
00062 
00063   private:
00064     // copying not supported: following are private and also left undefined
00065     IPRoute(const IPRoute& obj);
00066     IPRoute& operator=(const IPRoute& obj);
00067 
00068   public:
00069     IPRoute();
00070     virtual ~IPRoute() {}
00071     virtual std::string info() const;
00072     virtual std::string detailedInfo() const;
00073 
00074     void setHost(IPAddress host)  {this->host = host;}
00075     void setNetmask(IPAddress netmask)  {this->netmask = netmask;}
00076     void setGateway(IPAddress gateway)  {this->gateway = gateway;}
00077     void setInterface(InterfaceEntry *interfacePtr)  {this->interfacePtr = interfacePtr;}
00078     void setType(RouteType type)  {this->type = type;}
00079     void setSource(RouteSource source)  {this->source = source;}
00080     void setMetric(int metric)  {this->metric = metric;}
00081 
00083     IPAddress getHost() const {return host;}
00084 
00086     IPAddress getNetmask() const {return netmask;}
00087 
00089     IPAddress getGateway() const {return gateway;}
00090 
00092     InterfaceEntry *getInterface() const {return interfacePtr;}
00093 
00095     const char *getInterfaceName() const;
00096 
00098     RouteType getType() const {return type;}
00099 
00101     RouteSource getSource() const {return source;}
00102 
00104     int getMetric() const {return metric;}
00105 };
00106 
00107 #endif
00108