IPv4InterfaceData.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2000 Institut fuer Telematik, Universitaet Karlsruhe
00003 // Copyright (C) 2004 Andras Varga
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This program 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.  See the
00013 // GNU Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with this program; if not, see <http://www.gnu.org/licenses/>.
00017 //
00018 
00019 //
00020 //  Author: Andras Varga
00021 //
00022 
00023 #ifndef __IPv4INTERFACEDATA_H
00024 #define __IPv4INTERFACEDATA_H
00025 
00026 #include <vector>
00027 #include <omnetpp.h>
00028 #include "INETDefs.h"
00029 #include "IPAddress.h"
00030 #include "InterfaceEntry.h"
00031 
00032 
00039 class INET_API IPv4InterfaceData : public InterfaceProtocolData
00040 {
00041   public:
00042     typedef std::vector<IPAddress> IPAddressVector;
00043 
00044   protected:
00045     IPAddress inetAddr;  
00046     IPAddress netmask;   
00047     int metric;          
00048     IPAddressVector multicastGroups; 
00049 
00050   protected:
00051     void changed1() {changed(NF_INTERFACE_IPv4CONFIG_CHANGED);}
00052 
00053   private:
00054     // copying not supported: following are private and also left undefined
00055     IPv4InterfaceData(const IPv4InterfaceData& obj);
00056     IPv4InterfaceData& operator=(const IPv4InterfaceData& obj);
00057 
00058   public:
00059     IPv4InterfaceData();
00060     virtual ~IPv4InterfaceData() {}
00061     virtual std::string info() const;
00062     virtual std::string detailedInfo() const;
00063 
00066     IPAddress getIPAddress() const {return inetAddr;}
00067     IPAddress getNetmask() const {return netmask;}
00068     int getMetric() const  {return metric;}
00069     const IPAddressVector& getMulticastGroups() const {return multicastGroups;}
00070     bool isMemberOfMulticastGroup(const IPAddress& multicastAddress) const;
00072 
00075     virtual void setIPAddress(IPAddress a) {inetAddr = a; changed1();}
00076     virtual void setNetmask(IPAddress m) {netmask = m; changed1();}
00077     virtual void setMetric(int m) {metric = m; changed1();}
00078     virtual void setMulticastGroups(const IPAddressVector& v) {multicastGroups = v; changed1();}
00080 };
00081 
00082 #endif
00083