diff options
author | Othmar Gsenger <otti@anytun.org> | 2008-12-22 01:38:19 +0000 |
---|---|---|
committer | Othmar Gsenger <otti@anytun.org> | 2008-12-22 01:38:19 +0000 |
commit | dd37bc54dae219e4d1975f014ec36c221ec4db20 (patch) | |
tree | 38e7f427b0ae736841f4193935e39aae500a16dd /src/networkAddress.cpp | |
parent | added route option to anytun (diff) |
new routing system
supports ipv4 and ipv6 routing with subnetting
Diffstat (limited to 'src/networkAddress.cpp')
-rw-r--r-- | src/networkAddress.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/networkAddress.cpp b/src/networkAddress.cpp index 49ae704..f922c00 100644 --- a/src/networkAddress.cpp +++ b/src/networkAddress.cpp @@ -119,6 +119,28 @@ std::string NetworkAddress::toString() const return std::string(""); } +ipv4_bytes_type NetworkAddress::to_bytes_v4() const +{ + return ipv4_address_.to_bytes(); +} + +ipv6_bytes_type NetworkAddress::to_bytes_v6() const +{ + return ipv6_address_.to_bytes(); +} + +ethernet_bytes_type NetworkAddress::to_bytes_ethernet() const +{ + boost::array<unsigned char,6> result; + u_int64_t ether=ethernet_address_; + for (int i = 0; i < 6; i++) + { + result[i] = (unsigned char) (ether && 0xff); + ether >>= 8; + } + return result; +} + bool NetworkAddress::operator<(const NetworkAddress &right) const { if (network_address_type_!=right.network_address_type_) |