Kea 2.7.4
isc::dhcp_ddns::NameChangeUDPListener Class Reference

Provides the ability to receive NameChangeRequests via UDP socket. More...

#include <ncr_udp.h>

+ Inheritance diagram for isc::dhcp_ddns::NameChangeUDPListener:

Public Member Functions

 NameChangeUDPListener (const isc::asiolink::IOAddress &ip_address, const uint32_t port, const NameChangeFormat format, RequestReceiveHandlerPtr ncr_recv_handler, const bool reuse_address=false)
 Constructor.
 
virtual ~NameChangeUDPListener ()
 Destructor.
 
virtual void close ()
 Closes the UDPSocket.
 
void doReceive ()
 Initiates an asynchronous read on the socket.
 
virtual void open (const isc::asiolink::IOServicePtr &io_service)
 Opens a UDP socket using the given IOService.
 
void receiveCompletionHandler (const bool successful, const UDPCallback *recv_callback)
 Implements the NameChangeRequest level receive completion handler.
 
- Public Member Functions inherited from isc::dhcp_ddns::NameChangeListener
 NameChangeListener (RequestReceiveHandlerPtr recv_handler)
 Constructor.
 
virtual ~NameChangeListener ()
 Destructor.
 
bool amListening () const
 Returns true if the listener is listening, false otherwise.
 
bool isIoPending () const
 Returns true if the listener has an IO call in progress.
 
void startListening (const isc::asiolink::IOServicePtr &io_service)
 Prepares the IO for reception and initiates the first receive.
 
void stopListening ()
 Closes the IO source and stops listen logic.
 

Static Public Attributes

static const size_t RECV_BUF_MAX = isc::asiolink::UDPSocket<UDPCallback>::MIN_SIZE
 Defines the maximum size packet that can be received.
 

Additional Inherited Members

- Public Types inherited from isc::dhcp_ddns::NameChangeListener
typedef boost::shared_ptr< RequestReceiveHandlerRequestReceiveHandlerPtr
 Defines a smart pointer to an instance of a request receive handler.
 
enum  Result { SUCCESS , TIME_OUT , STOPPED , ERROR }
 Defines the outcome of an asynchronous NCR receive. More...
 
- Protected Member Functions inherited from isc::dhcp_ddns::NameChangeListener
void invokeRecvHandler (const Result result, NameChangeRequestPtr &ncr)
 Calls the NCR receive handler registered with the listener.
 
void receiveNext ()
 Initiates an asynchronous receive.
 

Detailed Description

Provides the ability to receive NameChangeRequests via UDP socket.

This class is a derivation of the NameChangeListener which is capable of receiving NameChangeRequests through a UDP socket. The caller need only supply network addressing and a RequestReceiveHandler instance to receive NameChangeRequests asynchronously.

Definition at line 317 of file ncr_udp.h.

Constructor & Destructor Documentation

◆ NameChangeUDPListener()

isc::dhcp_ddns::NameChangeUDPListener::NameChangeUDPListener ( const isc::asiolink::IOAddress & ip_address,
const uint32_t port,
const NameChangeFormat format,
RequestReceiveHandlerPtr ncr_recv_handler,
const bool reuse_address = false )

Constructor.

Parameters
ip_addressis the network address on which to listen
portis the UDP port on which to listen
formatis the wire format of the inbound requests. Currently only JSON is supported
ncr_recv_handlerthe receive handler object to notify when a receive completes.
reuse_addressenables IP address sharing when true It defaults to false.
Exceptions
baseclass throws NcrListenerError if handler is invalid.

Definition at line 65 of file ncr_udp.cc.

References receiveCompletionHandler(), and RECV_BUF_MAX.

+ Here is the call graph for this function:

◆ ~NameChangeUDPListener()

isc::dhcp_ddns::NameChangeUDPListener::~NameChangeUDPListener ( )
virtual

Destructor.

Definition at line 82 of file ncr_udp.cc.

References isc::dhcp_ddns::NameChangeListener::stopListening().

+ Here is the call graph for this function:

Member Function Documentation

◆ close()

void isc::dhcp_ddns::NameChangeUDPListener::close ( )
virtual

Closes the UDPSocket.

It first invokes the socket's cancel method which should stop any pending read and remove the socket callback from the IOService. It then calls the socket's close method to actually close the socket.

Exceptions
NcrUDPErrorif the open fails.

Implements isc::dhcp_ddns::NameChangeListener.

Definition at line 129 of file ncr_udp.cc.

References isc_throw.

◆ doReceive()

void isc::dhcp_ddns::NameChangeUDPListener::doReceive ( )
virtual

Initiates an asynchronous read on the socket.

Invokes the asyncReceive() method on the socket passing in the recv_callback_ member's transfer buffer as the receive buffer, and recv_callback_ itself as the callback object.

Exceptions
NcrUDPErrorif the open fails.

Implements isc::dhcp_ddns::NameChangeListener.

Definition at line 120 of file ncr_udp.cc.

◆ open()

void isc::dhcp_ddns::NameChangeUDPListener::open ( const isc::asiolink::IOServicePtr & io_service)
virtual

Opens a UDP socket using the given IOService.

Creates a NameChangeUDPSocket bound to the listener's ip address and port, that is monitored by the given IOService instance.

Parameters
io_servicethe IOService which will monitor the socket.
Exceptions
NcrUDPErrorif the open fails.

Implements isc::dhcp_ddns::NameChangeListener.

Definition at line 88 of file ncr_udp.cc.

References isc_throw, and isc::asiolink::IOAddress::isV4().

+ Here is the call graph for this function:

◆ receiveCompletionHandler()

void isc::dhcp_ddns::NameChangeUDPListener::receiveCompletionHandler ( const bool successful,
const UDPCallback * recv_callback )

Implements the NameChangeRequest level receive completion handler.

This method is invoked by the UPDCallback operator() implementation, passing in the boolean success indicator and pointer to itself.

If the indicator denotes success, then the method will attempt to to construct a NameChangeRequest from the received data. If the construction was successful, it will send the new NCR to the application layer by calling invokeRecvHandler() with a success status and a pointer to the new NCR.

If the buffer contains invalid data such that construction fails, the method will log the failure and then call doReceive() to start a initiate the next receive.

If the indicator denotes failure the method will log the failure and notify the application layer by calling invokeRecvHandler() with an error status and an empty pointer.

Parameters
successfulboolean indicator that should be true if the socket receive completed without error, false otherwise.
recv_callbackpointer to the callback instance which handled the socket receive completion.

Definition at line 159 of file ncr_udp.cc.

References isc::log::DBGLVL_TRACE_BASIC, isc::dhcp_ddns::DHCP_DDNS_INVALID_NCR, isc::dhcp_ddns::dhcp_ddns_logger, isc::dhcp_ddns::DHCP_DDNS_NCR_UDP_RECV_CANCELED, isc::dhcp_ddns::DHCP_DDNS_NCR_UDP_RECV_ERROR, isc::dhcp_ddns::NameChangeListener::ERROR, isc::dhcp_ddns::NameChangeRequest::fromFormat(), isc::dhcp_ddns::UDPCallback::getBytesTransferred(), isc::dhcp_ddns::UDPCallback::getData(), isc::dhcp_ddns::UDPCallback::getErrorCode(), isc::stats::StatsMgr::instance(), isc::dhcp_ddns::NameChangeListener::invokeRecvHandler(), LOG_DEBUG, LOG_ERROR, isc::dhcp_ddns::NameChangeListener::receiveNext(), isc::dhcp_ddns::NameChangeListener::STOPPED, and isc::dhcp_ddns::NameChangeListener::SUCCESS.

Referenced by NameChangeUDPListener().

+ Here is the call graph for this function:

Member Data Documentation

◆ RECV_BUF_MAX

const size_t isc::dhcp_ddns::NameChangeUDPListener::RECV_BUF_MAX = isc::asiolink::UDPSocket<UDPCallback>::MIN_SIZE
static

Defines the maximum size packet that can be received.

Definition at line 320 of file ncr_udp.h.

Referenced by NameChangeUDPListener().


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