00001 #ifndef CASTOR_NET_NETINTERFACE_H 00002 #define CASTOR_NET_NETINTERFACE_H 1 00003 00004 #include <set> 00005 #include <vector> 00006 #include <string> 00007 #include <sstream> 00008 #include <boost/smart_ptr.hpp> 00009 00010 #include "NetAddress.h" 00011 00012 namespace castor { namespace net { 00013 00014 class NetInterface; 00015 00016 typedef boost::shared_ptr<NetInterface> NetInterfacePtr; 00017 typedef std::vector<NetInterfacePtr> NetInterfacePtrList; 00018 00019 class NetInterface { 00020 00021 protected: 00022 00023 std::string name; 00024 NetAddressPtrSet addresses; 00025 NetAddressPtrSet addressesb; 00026 00027 public: 00028 00029 NetInterface(const std::string name); 00030 NetInterface(const NetInterface ©); 00031 00032 std::string getName() const; 00033 NetAddressPtrSet getAddresses() const; 00034 NetAddressPtrSet getBroadcastAddresses() const; 00035 00036 void addAddress(const NetAddress &address); 00037 void addBroadcastAddress(const NetAddress &address); 00038 00039 bool contains(const NetAddress &address); 00040 bool matches(const NetAddress &address); 00041 00042 static NetInterfacePtr getDefaultRoute(); 00043 static NetInterfacePtr getDefaultRoute6(); 00044 00045 static NetInterfacePtrList getInterfaces(); 00046 00047 std::string str() const; 00048 00049 friend bool operator<(const NetInterface &one, const NetInterface &other); 00050 }; 00051 00052 } } 00053 00054 #endif /* CASTOR_NET_NETINTERFACE_H */ 00055