nis-util
1.0.D108
|
00001 // 00002 // nis-util - NIS Administration Utilities 00003 // Copyright (C) 2001, 2008, 2009, 2012 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 2 of the License, or (at 00008 // 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 GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 00019 #ifndef LIB_SPACE_ETHERS_H 00020 #define LIB_SPACE_ETHERS_H 00021 00022 #include <boost/shared_ptr.hpp> 00023 00024 #include <netinet/ether.h> 00025 #include <lib/space.h> 00026 00031 class space_ethers: 00032 public space 00033 { 00034 public: 00035 typedef boost::shared_ptr<space_ethers> pointer; 00036 00040 virtual ~space_ethers(); 00041 00042 protected: 00050 space_ethers(const rcstring &filename); 00051 00052 public: 00060 static pointer create(const rcstring &filename); 00061 00066 class record 00067 { 00068 public: 00069 typedef boost::shared_ptr<record> pointer; 00070 00071 ~record(); 00072 00073 static pointer create(const source_location &locn, 00074 const rcstring &mac_address, const rcstring &name, 00075 const rcstring &ip_address); 00076 00083 rcstring representation(void) const; 00084 00085 bool operator<(const record &rhs) const; 00086 bool operator<=(const record &rhs) const; 00087 bool operator>(const record &rhs) const; 00088 bool operator>=(const record &rhs) const; 00089 00090 const source_location &get_source_location(void) const { return locn; } 00091 rcstring get_mac_address(void) const { return mac_address; } 00092 rcstring get_name(void) const { return name; } 00093 rcstring get_ip_address(void) const { return ip_address; } 00094 00095 private: 00096 record(const source_location &locn, const rcstring &mac_address, 00097 const rcstring &name, const rcstring &ip_address); 00098 00099 source_location locn; 00100 00101 rcstring mac_address; 00102 00103 rcstring name; 00104 00105 ether_addr mac_address_binary; 00106 00107 rcstring ip_address; 00108 00109 int compare(const record &rhs) const; 00110 }; 00111 00124 record::pointer get(void); 00125 00126 private: 00130 record::pointer last_rp; 00131 00135 space_ethers(); 00136 00140 space_ethers(const space_ethers &); 00141 00145 space_ethers &operator=(const space_ethers &); 00146 }; 00147 00148 // vim: set ts=8 sw=4 et : 00149 #endif // LIB_SPACE_ETHERS_H