Kea: icmp_endpoint.h Source File

| Kea 3.2.0-git

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
10#include <asiolink/io_endpoint.h>
11
12namespace isc {
13namespace ping_check {
14
19 class ICMPEndpoint : public asiolink::IOEndpoint {
20public:
24
25
30 ICMPEndpoint() :
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
72 virtual asiolink::IOAddress getAddress() const {
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
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic).
Definition io_address.h:53
isc::asiolink::IOEndpoint
The IOEndpoint class is an abstract base class to represent a communication endpoint.
Definition io_endpoint.h:38
isc::ping_check::ICMPEndpoint::ICMPEndpoint
ICMPEndpoint(boost::asio::ip::icmp::endpoint &asio_endpoint)
Copy Constructor from an ASIO ICMP endpoint.
Definition icmp_endpoint.h:50
isc::ping_check::ICMPEndpoint::ICMPEndpoint
ICMPEndpoint()
Default Constructor.
Definition icmp_endpoint.h:30
isc::ping_check::ICMPEndpoint::getASIOEndpoint
const boost::asio::ip::icmp::endpoint & getASIOEndpoint() const
Fetches the underlying ASIO endpoint implementation.
Definition icmp_endpoint.h:110
isc::ping_check::ICMPEndpoint::getAddress
virtual asiolink::IOAddress getAddress() const
Fetches the IP address of the endpoint.
Definition icmp_endpoint.h:72
isc::ping_check::ICMPEndpoint::getASIOEndpoint
boost::asio::ip::icmp::endpoint & getASIOEndpoint()
Fetches the underlying ASIO endpoint implementation.
Definition icmp_endpoint.h:120
isc::ping_check::ICMPEndpoint::getProtocol
virtual short getProtocol() const
Fetches the network protocol of the endpoint.
Definition icmp_endpoint.h:93
isc::ping_check::ICMPEndpoint::ICMPEndpoint
ICMPEndpoint(const asiolink::IOAddress &address)
Constructor from an address.
Definition icmp_endpoint.h:38
isc::ping_check::ICMPEndpoint::getPort
virtual uint16_t getPort() const
Fetches the IP port number of the endpoint.
Definition icmp_endpoint.h:86
isc::ping_check::ICMPEndpoint::getFamily
virtual short getFamily() const
Fetches the network protocol family of the endpoint.
Definition icmp_endpoint.h:100
isc::ping_check::ICMPEndpoint::ICMPEndpoint
ICMPEndpoint(const boost::asio::ip::icmp::endpoint &asio_endpoint)
Constructor from a const ASIO ICMP endpoint.
Definition icmp_endpoint.h:60
isc::ping_check::ICMPEndpoint::getSockAddr
virtual const struct sockaddr & getSockAddr() const
Fetches the IP address of the endpoint in native form.
Definition icmp_endpoint.h:79
isc::ping_check::ICMPEndpoint::~ICMPEndpoint
virtual ~ICMPEndpoint()
The destructor.
Definition icmp_endpoint.h:66
io_endpoint.h
isc::ping_check
Definition config_cache.cc:19
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18