/* The software in this package is distributed under the GNU General Public License version 2 (with a special exception described below). A copy of GNU General Public License (GPL) is included in this distribution, in the file COPYING.GPL. As a special exception, if other files instantiate templates or use macros or inline functions from this file, or you compile this file and link it with other works to produce a work based on this file, this file does not by itself cause the resulting work to be covered by the GNU General Public License. However the source code for this file must still be made available in accordance with section (3) of the GNU General Public License. This exception does not invalidate any other reasons why a work based on this file might be covered by the GNU General Public License. */ #ifndef HOST_ADDRESS_H #define HOST_ADDRESS_H #include #include #include #include #include #include #include "dns/timetolive.h" //----------------------------------------------------------------------------- // HostAddress //----------------------------------------------------------------------------- class HostAddress { public: HostAddress(); HostAddress( const boost::asio::ip::address &ip, uint32_t ttl ); ~HostAddress(); boost::asio::ip::address get_ip() const; void set_ip( const boost::asio::ip::address &ip ); TimeToLive get_ttl() const; void set_ttl( const TimeToLive &ttl ); // return false if this HostAddress was default-constructed, so does not // actually point to an ip (ip is probably 0.0.0.0) bool is_valid() const; private: /// IP address of the host boost::asio::ip::address Ip; /// time-to-live of the host IP TimeToLive Ttl; /// serialization: needs to be implemented here or will not compile // since there is no serialize in ip::address nor ptime, // need to save in other formats here friend class boost::serialization::access; template void save(Archive & ar, const unsigned int version) const { std::string ip_str = Ip.to_string(); ar & BOOST_SERIALIZATION_NVP(ip_str); ar & BOOST_SERIALIZATION_NVP(Ttl); } template void load(Archive & ar, const unsigned int version) { std::string ip_str; ar & BOOST_SERIALIZATION_NVP(ip_str); ar & BOOST_SERIALIZATION_NVP(Ttl); Ip = boost::asio::ip::address::from_string(ip_str); } BOOST_SERIALIZATION_SPLIT_MEMBER() }; //----------------------------------------------------------------------------- // HostAddressList //----------------------------------------------------------------------------- typedef std::list HostAddressList; #endif // HOST_ADDRESS_H