00001
00002
00003
00004
00005
00006
00007
00008 #ifndef IBRCOMMON_NETINTERFACE_H
00009 #define IBRCOMMON_NETINTERFACE_H
00010
00011 #include <netinet/in.h>
00012 #include <iostream>
00013
00014 namespace ibrcommon
00015 {
00016 class NetInterface
00017 {
00018 public:
00019 NetInterface(std::string interface);
00020 virtual ~NetInterface();
00021
00022 std::string getInterface() const;
00023 std::string getAddress() const;
00024 std::string getBroadcast() const;
00025
00026
00027 void getAddress(struct in_addr *ret) const;
00028 void getBroadcast(struct in_addr *ret) const;
00029
00030 bool operator<(const NetInterface&) const;
00031 bool operator==(const NetInterface&) const;
00032
00033 private:
00034 static void getAddress(std::string interface, struct in_addr *ret);
00035 static void getBroadcast(std::string interface, struct in_addr *ret);
00036
00037 static std::string getAddress(std::string interface);
00038 static std::string getBroadcast(std::string interface);
00039
00040 std::string _interface;
00041
00042 };
00043 }
00044
00045 #endif
00046