Kea: isc::asiolink::UDPEndpoint Class Reference

| Kea 2.2.0

List of all members
isc::asiolink::UDPEndpoint Class Reference

The `UDPEndpoint` class is a concrete derived class of `IOEndpoint` that represents an endpoint of a UDP packet. More...

`#include <udp_endpoint.h>`

Inheritance diagram for isc::asiolink::UDPEndpoint:
[legend]

## Constructors and Destructor.
| UDPEndpoint ()
| Default Constructor. More...
| UDPEndpoint (const IOAddress &address, const unsigned short port)
| Constructor from a pair of address and port. More...
| UDPEndpoint (boost::asio::ip::udp::endpoint &asio_endpoint)
| Constructor from an ASIO UDP endpoint. More...
| UDPEndpoint (const boost::asio::ip::udp::endpoint &asio_endpoint)
| Constructor from an ASIO UDP endpoint. More...
virtual | ~UDPEndpoint ()
| The destructor. More...
virtual IOAddress | getAddress () const
| Returns the address of the endpoint. More...
virtual const struct sockaddr & | getSockAddr () const
| Returns the address of the endpoint in the form of sockaddr structure. More...
virtual uint16_t | getPort () const
| Returns the port of the endpoint. More...
virtual short | getProtocol () const
| Returns the protocol number of the endpoint (TCP, UDP...) More...
virtual short | getFamily () const
| Returns the address family of the endpoint. More...
const boost::asio::ip::udp::endpoint & | getASIOEndpoint () const
boost::asio::ip::udp::endpoint & | getASIOEndpoint ()

## Additional Inherited Members
Public Member Functions inherited from isc::asiolink::IOEndpoint
virtual | ~IOEndpoint ()
| The destructor. More...
bool | operator== (const IOEndpoint &other) const
bool | operator!= (const IOEndpoint &other) const
Static Public Member Functions inherited from isc::asiolink::IOEndpoint
static const IOEndpoint * | create (const int protocol, const IOAddress &address, const unsigned short port)
| A polymorphic factory of endpoint from address and port. More...
Protected Member Functions inherited from isc::asiolink::IOEndpoint
| IOEndpoint ()
| The default constructor. More...

## Detailed Description

The `UDPEndpoint` class is a concrete derived class of `IOEndpoint` that represents an endpoint of a UDP packet.

Other notes about `TCPEndpoint` applies to this class, too.

Definition at line 23 of file udp_endpoint.h.

## Constructor & Destructor Documentation

## ◆ UDPEndpoint() [1/4]

isc::asiolink::UDPEndpoint::UDPEndpoint | ( |  | ) |
| inline

Default Constructor.

Creates an internal endpoint. This is expected to be set by some external call.

Definition at line 34 of file udp_endpoint.h.

## ◆ UDPEndpoint() [2/4]

isc::asiolink::UDPEndpoint::UDPEndpoint | ( | const IOAddress & | address,
|  | const unsigned short | port
| ) |  |
| inline

Constructor from a pair of address and port.

Parameters

  address | The IP address of the endpoint.
  port | The UDP port number of the endpoint.

Definition at line 43 of file udp_endpoint.h.

## ◆ UDPEndpoint() [3/4]

isc::asiolink::UDPEndpoint::UDPEndpoint | ( | boost::asio::ip::udp::endpoint & | asio_endpoint | ) |
| inline

Constructor from an ASIO UDP endpoint.

This constructor is designed to be an efficient wrapper for the corresponding ASIO class, `udp::endpoint`.

Parameters

  asio_endpoint | The ASIO representation of the UDP endpoint.

Definition at line 56 of file udp_endpoint.h.

## ◆ UDPEndpoint() [4/4]

isc::asiolink::UDPEndpoint::UDPEndpoint | ( | const boost::asio::ip::udp::endpoint & | asio_endpoint | ) |
| inline

Constructor from an ASIO UDP endpoint.

This constructor is designed to be an efficient wrapper for the corresponding ASIO class, `udp::endpoint`.

Parameters

  asio_endpoint | The ASIO representation of the TCP endpoint.

Definition at line 66 of file udp_endpoint.h.

## ◆ ~UDPEndpoint()

virtual isc::asiolink::UDPEndpoint::~UDPEndpoint | ( |  | ) |
| inlinevirtual

The destructor.

Definition at line 72 of file udp_endpoint.h.

## Member Function Documentation

## ◆ getAddress()

virtual IOAddress isc::asiolink::UDPEndpoint::getAddress | ( |  | ) | const
| inlinevirtual

Returns the address of the endpoint.

This method returns an IOAddress object corresponding to `this` endpoint.

Note that the return value is a real object, not a reference or a pointer.

This is aligned with the interface of the ASIO counterpart: the `address()` method of `ip::xxx::endpoint` classes returns an `ip::address` object.

This also means handling the address of an endpoint using this method can be expensive. If the address information is necessary in a performance sensitive context and there's a more efficient interface for that purpose, it's probably better to avoid using this method.

This method never throws an exception.

Returns
  A copy of `IOAddress` object corresponding to the endpoint.

Implements isc::asiolink::IOEndpoint.

Definition at line 75 of file udp_endpoint.h.

## ◆ getASIOEndpoint() [1/2]

boost::asio::ip::udp::endpoint & isc::asiolink::UDPEndpoint::getASIOEndpoint | ( |  | ) |
| inline

Definition at line 100 of file udp_endpoint.h.

## ◆ getASIOEndpoint() [2/2]

const boost::asio::ip::udp::endpoint & isc::asiolink::UDPEndpoint::getASIOEndpoint | ( |  | ) | const
| inline

Definition at line 97 of file udp_endpoint.h.

Referenced by isc::asiolink::UDPSocket< C >::asyncReceive(), isc::asiolink::UDPSocket< C >::asyncSend(), isc::dhcp_ddns::NameChangeUDPListener::open(), and isc::dhcp_ddns::NameChangeUDPSender::open().

## ◆ getFamily()

virtual short isc::asiolink::UDPEndpoint::getFamily | ( |  | ) | const
| inlinevirtual

Returns the address family of the endpoint.

Implements isc::asiolink::IOEndpoint.

Definition at line 91 of file udp_endpoint.h.

## ◆ getPort()

virtual uint16_t isc::asiolink::UDPEndpoint::getPort | ( |  | ) | const
| inlinevirtual

Returns the port of the endpoint.

Implements isc::asiolink::IOEndpoint.

Definition at line 83 of file udp_endpoint.h.

## ◆ getProtocol()

virtual short isc::asiolink::UDPEndpoint::getProtocol | ( |  | ) | const
| inlinevirtual

Returns the protocol number of the endpoint (TCP, UDP...)

Implements isc::asiolink::IOEndpoint.

Definition at line 87 of file udp_endpoint.h.

## ◆ getSockAddr()

virtual const struct sockaddr & isc::asiolink::UDPEndpoint::getSockAddr | ( |  | ) | const
| inlinevirtual

Returns the address of the endpoint in the form of sockaddr structure.

The actual instance referenced by the returned value of this method is of per address family structure: For IPv4 (AF_INET), it's `sockaddr_in`; for IPv6 (AF_INET6), it's `sockaddr_in6`. The corresponding port and address members of the underlying structure will be set in the network byte order.

This method is "redundant" in that all information to construct the `sockaddr` is available via the other "get" methods. It is still defined for performance sensitive applications that need to get the address information, such as for address based access control at a high throughput. Internally it is implemented with minimum overhead such as data copy (this is another reason why this method returns a reference).

As a tradeoff, this method is more fragile; it assumes that the underlying ASIO implementation stores the address information in the form of `sockaddr` and it can be accessed in an efficient way. This is the case as of this writing, but if the underlying implementation changes this method may become much slower or its interface may have to be changed, too.

It is therefore discouraged for normal applications to use this method. Unless the application is very performance sensitive, it should use the other "get" method to retrieve specific information of the endpoint.

The returned reference is only valid while the corresponding `IOEndpoint` is valid. Once it's destructed the reference will become invalid.

Exceptions

  None |

Returns
  Reference to a `sockaddr` structure corresponding to the endpoint.

Implements isc::asiolink::IOEndpoint.

Definition at line 79 of file udp_endpoint.h.

The documentation for this class was generated from the following file:

- udp_endpoint.h