From dd37bc54dae219e4d1975f014ec36c221ec4db20 Mon Sep 17 00:00:00 2001 From: Othmar Gsenger Date: Mon, 22 Dec 2008 01:38:19 +0000 Subject: new routing system supports ipv4 and ipv6 routing with subnetting --- src/networkAddress.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/networkAddress.cpp') 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 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_) -- cgit v1.2.3