From: Reinhard Pfau Date: Sun, 26 Apr 2009 21:13:50 +0000 (+0200) Subject: added new IPv4Address class X-Git-Tag: v0.3~31 X-Git-Url: http://developer.intra2net.com/git/?p=libasyncio;a=commitdiff_plain;h=17f28a25ba65ec900c191a01b5ce42d2266d89c7 added new IPv4Address class --- diff --git a/utils/asyncio_system_tools.cpp b/utils/asyncio_system_tools.cpp index 649cd84..e505473 100644 --- a/utils/asyncio_system_tools.cpp +++ b/utils/asyncio_system_tools.cpp @@ -30,6 +30,8 @@ on this file might be covered by the GNU General Public License. #include #include #include +#include + namespace AsyncIo { @@ -93,6 +95,30 @@ bool unlink( const std::string& path ) +/* + * IPv4 + */ + +IPv4Address::IPv4Address( ) +: m_address( 0u ) +, m_valid( false ) +{ +} + + +IPv4Address::IPv4Address(uint32_t _address) +: m_address( _address ) +, m_valid( true ) +{ +} + + +uint32_t IPv4Address::get_address_nbo() const +{ + return htonl( m_address ); +} + + } // end of namespace Utils }// end of namespace AsyncIo diff --git a/utils/asyncio_system_tools.hpp b/utils/asyncio_system_tools.hpp index 5a4fb81..69c4a04 100644 --- a/utils/asyncio_system_tools.hpp +++ b/utils/asyncio_system_tools.hpp @@ -22,7 +22,9 @@ on this file might be covered by the GNU General Public License. * @brief some functions to wrap some system functions * * @author Reinhard Pfau \ + * * @copyright © Copyright 2009 by Intra2net AG + * @contact Intra2net Opensource Team \ */ @@ -100,6 +102,29 @@ class FileStat }; // end of FileStat +/* + * IPv4 support + */ + +class IPv4Address +{ + public: + IPv4Address(); + IPv4Address( uint32_t _address ); + + bool is_valid() const {return m_valid;} + + uint32_t get_address() const { return m_address; } + + uint32_t get_address_nbo() const; + + private: + + uint32_t m_address; + bool m_valid; +}; // end of IPv4Address + + } // end of namespace Utils } // end of namespace AsyncIo