summaryrefslogtreecommitdiff
path: root/networkAddress.cpp
diff options
context:
space:
mode:
authorOthmar Gsenger <otti@anytun.org>2008-02-27 19:53:34 +0000
committerOthmar Gsenger <otti@anytun.org>2008-02-27 19:53:34 +0000
commitff454b083ca534ef8a21db99a209bd494eaa72b6 (patch)
tree8c93b8ad45efdc712493ffb714b91e14d38ee25f /networkAddress.cpp
parentadded networkAddress operators (diff)
added networkprefix auto detectio9n of network address
Diffstat (limited to 'networkAddress.cpp')
-rw-r--r--networkAddress.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/networkAddress.cpp b/networkAddress.cpp
index 2d53f75..3db7238 100644
--- a/networkAddress.cpp
+++ b/networkAddress.cpp
@@ -155,3 +155,23 @@ NetworkAddress NetworkAddress::operator&(const NetworkAddress &right) const
}
return false;
}
+
+NetworkAddress NetworkAddress::operator&=(const NetworkAddress &right)
+{
+ if (network_address_type_!=right.network_address_type_)
+ throw std::runtime_error("network_address_types did not match");
+ if (network_address_type_==ipv4)
+ {
+ ipv4_address_.s_addr &= right.ipv4_address_.s_addr;
+ return *this;
+ } else if (network_address_type_==ipv6) {
+ for(int i=0;i<4;i++)
+ ipv6_address_.s6_addr32[i]&=right.ipv6_address_.s6_addr32[i];
+ return *this;
+ } else if (network_address_type_==ethernet) {
+ //TODO
+ } else {
+ //TODO
+ }
+ return false;
+}