diff options
author | Jelte Jansen <jelte@isc.org> | 2011-02-14 15:58:40 +0100 |
---|---|---|
committer | Jelte Jansen <jelte@isc.org> | 2011-02-14 15:58:40 +0100 |
commit | b9e1f48df9f398d7641f61317a7d969690af1ff2 (patch) | |
tree | 846d1bb03f733f2edb05309cee9ae9da4ec83fdc /src/lib/asiolink/io_address.cc | |
parent | [trac569] remove internal from configure.ac (diff) | |
download | kea-b9e1f48df9f398d7641f61317a7d969690af1ff2.tar.xz kea-b9e1f48df9f398d7641f61317a7d969690af1ff2.zip |
[trac569] rename the original ioxxx files to io_xxx
Diffstat (limited to 'src/lib/asiolink/io_address.cc')
-rw-r--r-- | src/lib/asiolink/io_address.cc | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/lib/asiolink/io_address.cc b/src/lib/asiolink/io_address.cc new file mode 100644 index 0000000000..990524acfb --- /dev/null +++ b/src/lib/asiolink/io_address.cc @@ -0,0 +1,62 @@ +// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +// PERFORMANCE OF THIS SOFTWARE. + +#include <config.h> + +#include <unistd.h> // for some IPC/network system calls +#include <sys/socket.h> +#include <netinet/in.h> + +#include <asio.hpp> + +#include <asiolink/asiolink.h> + +using namespace asio; +using asio::ip::udp; +using asio::ip::tcp; + +using namespace std; + +namespace asiolink { + +// XXX: we cannot simply construct the address in the initialization list, +// because we'd like to throw our own exception on failure. +IOAddress::IOAddress(const string& address_str) { + error_code err; + asio_address_ = ip::address::from_string(address_str, err); + if (err) { + isc_throw(IOError, "Failed to convert string to address '" + << address_str << "': " << err.message()); + } +} + +IOAddress::IOAddress(const ip::address& asio_address) : + asio_address_(asio_address) +{} + +string +IOAddress::toText() const { + return (asio_address_.to_string()); +} + +short +IOAddress::getFamily() const { + if (asio_address_.is_v4()) { + return (AF_INET); + } else { + return (AF_INET6); + } +} + +} |