Branch data Line data Source code
1 : : // Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
2 : : //
3 : : // Permission to use, copy, modify, and/or distribute this software for any
4 : : // purpose with or without fee is hereby granted, provided that the above
5 : : // copyright notice and this permission notice appear in all copies.
6 : : //
7 : : // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
8 : : // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9 : : // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
10 : : // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11 : : // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
12 : : // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13 : : // PERFORMANCE OF THIS SOFTWARE.
14 : :
15 : : #include <string>
16 : : #include <sstream>
17 : :
18 : : #include <acl/ip_check.h>
19 : :
20 : : #include <asiolink/io_endpoint.h>
21 : : #include <asiolink/io_message.h>
22 : :
23 : : #include <server_common/client.h>
24 : :
25 : : using namespace isc::acl;
26 : : using namespace isc::server_common;
27 : : using namespace isc::asiolink;
28 : :
29 : : struct Client::ClientImpl {
30 : : ClientImpl(const IOMessage& request_message) :
31 : : request_(request_message),
32 [ + - ][ + - ]: 45 : request_src_(request_.getRemoteEndpoint().getSockAddr())
33 : : {}
34 : :
35 : : const IOMessage& request_;
36 : : const IPAddress request_src_;
37 : : };
38 : :
39 : 45 : Client::Client(const IOMessage& request_message) :
40 : 45 : impl_(new ClientImpl(request_message))
41 : 45 : {}
42 : :
43 : 45 : Client::~Client() {
44 : 45 : delete impl_;
45 : 45 : }
46 : :
47 : : const IOEndpoint&
48 : 24 : Client::getRequestSourceEndpoint() const {
49 : 24 : return (impl_->request_.getRemoteEndpoint());
50 : : }
51 : :
52 : : const IPAddress&
53 : 39 : Client::getRequestSourceIPAddress() const {
54 : 39 : return (impl_->request_src_);
55 : : }
56 : :
57 : : std::string
58 : 17 : Client::toText() const {
59 : 34 : std::stringstream ss;
60 [ + - ][ + - ]: 34 : ss << impl_->request_.getRemoteEndpoint().getAddress().toText()
[ + - ]
61 [ + - ][ + - ]: 34 : << '#' << impl_->request_.getRemoteEndpoint().getPort();
62 : 17 : return (ss.str());
63 : : }
64 : :
65 : : std::ostream&
66 : 8 : isc::server_common::operator<<(std::ostream& os, const Client& client) {
67 [ + - ]: 8 : return (os << client.toText());
68 : 154 : }
|