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

Static Public Attributes

static const size_t RECV_BUF_MAX
 Defines the maximum size packet that can be received. More...
 

Additional Inherited Members

- Public Types inherited from isc::dhcp_ddns::NameChangeListener
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. More...
 
void receiveNext ()
 Initiates an asynchronous receive. More...
 

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 319 of file ncr_udp.h.

Constructor & Destructor Documentation

isc::dhcp_ddns::NameChangeUDPListener::NameChangeUDPListener ( const isc::asiolink::IOAddress ip_address,
const uint32_t  port,
const NameChangeFormat  format,
RequestReceiveHandler 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 66 of file ncr_udp.cc.

References receiveCompletionHandler(), and RECV_BUF_MAX.

+ Here is the call graph for this function:

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

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 126 of file ncr_udp.cc.

References isc_throw.

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 117 of file ncr_udp.cc.

void isc::dhcp_ddns::NameChangeUDPListener::open ( isc::asiolink::IOService 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::asiolink::IOService::get_io_service(), isc::asiolink::UDPEndpoint::getASIOEndpoint(), isc_throw, and isc::asiolink::IOAddress::isV4().

+ Here is the call graph for this function:

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 152 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::dhcp_ddns::NameChangeListener::invokeRecvHandler(), LOG_DEBUG, LOG_ERROR, isc::dhcp_ddns::NameChangeListener::receiveNext(), isc::dhcp_ddns::NameChangeListener::STOPPED, isc::dhcp_ddns::NameChangeListener::SUCCESS, and isc::Exception::what().

Referenced by NameChangeUDPListener().

+ Here is the call graph for this function:

Member Data Documentation

const size_t isc::dhcp_ddns::NameChangeUDPListener::RECV_BUF_MAX
static
Initial value:

Defines the maximum size packet that can be received.

Definition at line 322 of file ncr_udp.h.

Referenced by NameChangeUDPListener().


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