| Kea 3.0.2-git

io_endpoint.h
Go to the documentation of this file.
1// Copyright (C) 2010-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 IO_ENDPOINT_H
8#define IO_ENDPOINT_H 1
9
10// IMPORTANT NOTE: only very few ASIO headers files can be included in
11// this file. In particular, asio.hpp should never be included here.
12// See the description of the namespace below.
13
14#include <functional>
15#include <string>
16
17#include <exceptions/exceptions.h>
18#include <asiolink/io_address.h>
19
20# include <ostream>
21
22#include <unistd.h> // for some network system calls
23
24#include <sys/socket.h> // for sockaddr
25
26 namespace isc {
27 namespace asiolink {
28
38 class IOEndpoint {
44
45 private:
46 IOEndpoint(const IOEndpoint& source);
47 IOEndpoint& operator=(const IOEndpoint& source);
48 protected:
53 IOEndpoint() {}
54 public:
56 virtual ~IOEndpoint() {}
58
79 virtual IOAddress getAddress() const = 0;
80
82 virtual uint16_t getPort() const = 0;
83
85 virtual short getProtocol() const = 0;
86
88 virtual short getFamily() const = 0;
89
126 virtual const struct sockaddr& getSockAddr() const = 0;
127
128 bool operator==(const IOEndpoint& other) const;
129 bool operator!=(const IOEndpoint& other) const;
130
151 static const IOEndpoint* create(const int protocol,
152 const IOAddress& address,
153 const unsigned short port);
154};
155
176std::ostream& operator<<(std::ostream& os, const IOEndpoint& endpoint);
177} // namespace asiolink
178} // namespace isc
179#endif // IO_ENDPOINT_H
180
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic).
Definition io_address.h:45
isc::asiolink::IOEndpoint
The IOEndpoint class is an abstract base class to represent a communication endpoint.
Definition io_endpoint.h:38
isc::asiolink::IOEndpoint::operator!=
bool operator!=(const IOEndpoint &other) const
Definition io_endpoint.cc:50
isc::asiolink::IOEndpoint::create
static const IOEndpoint * create(const int protocol, const IOAddress &address, const unsigned short port)
A polymorphic factory of endpoint from address and port.
Definition io_endpoint.cc:28
isc::asiolink::IOEndpoint::IOEndpoint
IOEndpoint()
The default constructor.
Definition io_endpoint.h:53
isc::asiolink::IOEndpoint::getFamily
virtual short getFamily() const =0
Returns the address family of the endpoint.
isc::asiolink::IOEndpoint::getAddress
virtual IOAddress getAddress() const =0
Returns the address of the endpoint.
isc::asiolink::IOEndpoint::~IOEndpoint
virtual ~IOEndpoint()
The destructor.
Definition io_endpoint.h:56
isc::asiolink::IOEndpoint::getSockAddr
virtual const struct sockaddr & getSockAddr() const =0
Returns the address of the endpoint in the form of sockaddr structure.
isc::asiolink::IOEndpoint::operator==
bool operator==(const IOEndpoint &other) const
Definition io_endpoint.cc:42
isc::asiolink::IOEndpoint::getProtocol
virtual short getProtocol() const =0
Returns the protocol number of the endpoint (TCP, UDP...).
isc::asiolink::IOEndpoint::getPort
virtual uint16_t getPort() const =0
Returns the port of the endpoint.
exceptions.h
io_address.h
isc::asiolink
Definition addr_utilities.cc:170
isc::asiolink::operator<<
std::ostream & operator<<(std::ostream &os, const IOAddress &address)
Insert the IOAddress as a string into stream.
Definition io_address.cc:131
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148