summaryrefslogtreecommitdiff
path: root/src/common/ip.hpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2013-09-08 19:43:28 -0700
committerBen Longbons <b.r.longbons@gmail.com>2013-09-09 19:29:31 -0700
commita5861a4c81bb616b7fba2028cf9ee31f890357c5 (patch)
tree0a7aedad97d70b6194eb57a7de39857d015685a3 /src/common/ip.hpp
parent367e76ba89bde0e3fb6c4ae0e64cd3927e0db2f2 (diff)
downloadtmwa-a5861a4c81bb616b7fba2028cf9ee31f890357c5.tar.gz
tmwa-a5861a4c81bb616b7fba2028cf9ee31f890357c5.tar.bz2
tmwa-a5861a4c81bb616b7fba2028cf9ee31f890357c5.tar.xz
tmwa-a5861a4c81bb616b7fba2028cf9ee31f890357c5.zip
Use IP4 classes and rename conf variables
Diffstat (limited to 'src/common/ip.hpp')
-rw-r--r--src/common/ip.hpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/common/ip.hpp b/src/common/ip.hpp
index e67056c..aceb765 100644
--- a/src/common/ip.hpp
+++ b/src/common/ip.hpp
@@ -21,6 +21,8 @@
#include "sanity.hpp"
+#include <netinet/in.h>
+
#include "extract.hpp"
#include "strings.hpp"
@@ -53,6 +55,17 @@ public:
IP4Address(const uint8_t (&a)[4])
: _addr{a[0], a[1], a[2], a[3]}
{}
+ explicit
+ IP4Address(struct in_addr addr)
+ {
+ static_assert(sizeof(addr) == sizeof(_addr), "4 bytes");
+ *this = IP4Address(reinterpret_cast<const uint8_t (&)[4]>(addr));
+ }
+ explicit
+ operator struct in_addr() const
+ {
+ return reinterpret_cast<const struct in_addr&>(_addr);
+ }
constexpr friend
IP4Address operator & (IP4Address l, IP4Address r)