Kea 3.1.1
icmp_endpoint.h
Go to the documentation of this file.
1// Copyright (C) 2023-2025 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 ICMP_ENDPOINT_H
8#define ICMP_ENDPOINT_H 1
9
11
12namespace isc {
13namespace ping_check {
14
20public:
24
25
31 asio_endpoint_placeholder_(new boost::asio::ip::icmp::endpoint()),
32 asio_endpoint_(*asio_endpoint_placeholder_)
33 {}
34
38 explicit ICMPEndpoint(const asiolink::IOAddress& address) :
39 asio_endpoint_placeholder_(
40 new boost::asio::ip::icmp::endpoint(boost::asio::ip::make_address(address.toText()), 0)),
41 asio_endpoint_(*asio_endpoint_placeholder_)
42 {}
43
50 explicit ICMPEndpoint(boost::asio::ip::icmp::endpoint& asio_endpoint) :
51 asio_endpoint_placeholder_(0), asio_endpoint_(asio_endpoint)
52 {}
53
60 explicit ICMPEndpoint(const boost::asio::ip::icmp::endpoint& asio_endpoint) :
61 asio_endpoint_placeholder_(new boost::asio::ip::icmp::endpoint(asio_endpoint)),
62 asio_endpoint_(*asio_endpoint_placeholder_)
63 {}
64
66 virtual ~ICMPEndpoint() { delete asio_endpoint_placeholder_; }
68
73 return (asio_endpoint_.address());
74 }
75
79 virtual const struct sockaddr& getSockAddr() const {
80 return (*asio_endpoint_.data());
81 }
82
86 virtual uint16_t getPort() const {
87 return (asio_endpoint_.port());
88 }
89
93 virtual short getProtocol() const {
94 return (asio_endpoint_.protocol().protocol());
95 }
96
100 virtual short getFamily() const {
101 return (asio_endpoint_.protocol().family());
102 }
103
110 inline const boost::asio::ip::icmp::endpoint& getASIOEndpoint() const {
111 return (asio_endpoint_);
112 }
113
120 inline boost::asio::ip::icmp::endpoint& getASIOEndpoint() {
121 return (asio_endpoint_);
122 }
123
124private:
126 boost::asio::ip::icmp::endpoint* asio_endpoint_placeholder_;
127
129 boost::asio::ip::icmp::endpoint& asio_endpoint_;
130};
131
132} // namespace ping_check
133} // namespace isc
134#endif // ICMP_ENDPOINT_H
ICMPEndpoint(boost::asio::ip::icmp::endpoint &asio_endpoint)
Copy Constructor from an ASIO ICMP endpoint.
ICMPEndpoint()
Default Constructor.
const boost::asio::ip::icmp::endpoint & getASIOEndpoint() const
Fetches the underlying ASIO endpoint implementation.
virtual asiolink::IOAddress getAddress() const
Fetches the IP address of the endpoint.
boost::asio::ip::icmp::endpoint & getASIOEndpoint()
Fetches the underlying ASIO endpoint implementation.
virtual short getProtocol() const
Fetches the network protocol of the endpoint.
ICMPEndpoint(const asiolink::IOAddress &address)
Constructor from an address.
virtual uint16_t getPort() const
Fetches the IP port number of the endpoint.
virtual short getFamily() const
Fetches the network protocol family of the endpoint.
ICMPEndpoint(const boost::asio::ip::icmp::endpoint &asio_endpoint)
Constructor from a const ASIO ICMP endpoint.
virtual const struct sockaddr & getSockAddr() const
Fetches the IP address of the endpoint in native form.
virtual ~ICMPEndpoint()
The destructor.
Defines the logger used by the top-level component of kea-lfc.