added new IPv4Address class
authorReinhard Pfau <Reinhard.Pfau@gmx.de>
Sun, 26 Apr 2009 21:13:50 +0000 (23:13 +0200)
committerReinhard Pfau <Reinhard.Pfau@gmx.de>
Sun, 26 Apr 2009 21:13:50 +0000 (23:13 +0200)
utils/asyncio_system_tools.cpp
utils/asyncio_system_tools.hpp

index 649cd84..e505473 100644 (file)
@@ -30,6 +30,8 @@ on this file might be covered by the GNU General Public License.
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <netinet/in.h>
+
 
 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
index 5a4fb81..69c4a04 100644 (file)
@@ -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 \<Reinhard.Pfau@gmx.de\>
+ *
  * @copyright &copy; Copyright 2009 by Intra2net AG
+ * @contact Intra2net Opensource Team \<opensource@intra2net.com\>
  */
 
 
@@ -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