Kea 2.7.6
udp_endpoint.h
Go to the documentation of this file.
1// Copyright (C) 2011-2024 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef UDP_ENDPOINT_H
8#define UDP_ENDPOINT_H 1
9
10#ifndef BOOST_ASIO_HPP
11#error "asio.hpp must be included before including this, see asiolink.h as to why"
12#endif
13
15
16namespace isc {
17namespace asiolink {
18
23class UDPEndpoint : public IOEndpoint {
24public:
28
29
35 asio_endpoint_placeholder_(new boost::asio::ip::udp::endpoint()),
36 asio_endpoint_(*asio_endpoint_placeholder_)
37 {}
38
43 UDPEndpoint(const IOAddress& address, const unsigned short port) :
44 asio_endpoint_placeholder_(
45 new boost::asio::ip::udp::endpoint(boost::asio::ip::address::from_string(address.toText()),
46 port)),
47 asio_endpoint_(*asio_endpoint_placeholder_)
48 {}
49
56 UDPEndpoint(boost::asio::ip::udp::endpoint& asio_endpoint) :
57 asio_endpoint_placeholder_(NULL), asio_endpoint_(asio_endpoint)
58 {}
59
66 UDPEndpoint(const boost::asio::ip::udp::endpoint& asio_endpoint) :
67 asio_endpoint_placeholder_(new boost::asio::ip::udp::endpoint(asio_endpoint)),
68 asio_endpoint_(*asio_endpoint_placeholder_)
69 {}
70
72 virtual ~UDPEndpoint() { delete asio_endpoint_placeholder_; }
74
75 virtual IOAddress getAddress() const {
76 return (asio_endpoint_.address());
77 }
78
79 virtual const struct sockaddr& getSockAddr() const {
80 return (*asio_endpoint_.data());
81 }
82
83 virtual uint16_t getPort() const {
84 return (asio_endpoint_.port());
85 }
86
87 virtual short getProtocol() const {
88 return (asio_endpoint_.protocol().protocol());
89 }
90
91 virtual short getFamily() const {
92 return (asio_endpoint_.protocol().family());
93 }
94
95 // This is not part of the exposed IOEndpoint API but allows
96 // direct access to the ASIO implementation of the endpoint
97 inline const boost::asio::ip::udp::endpoint& getASIOEndpoint() const {
98 return (asio_endpoint_);
99 }
100 inline boost::asio::ip::udp::endpoint& getASIOEndpoint() {
101 return (asio_endpoint_);
102 }
103
104private:
105 boost::asio::ip::udp::endpoint* asio_endpoint_placeholder_;
106 boost::asio::ip::udp::endpoint& asio_endpoint_;
107};
108
109} // namespace asiolink
110} // namespace isc
111#endif // UDP_ENDPOINT_H
Defines the logger used by the top-level component of kea-lfc.