Kea 2.7.4
|
Provides the ability to receive NameChangeRequests via UDP socket. More...
#include <ncr_udp.h>
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< RequestReceiveHandler > | RequestReceiveHandlerPtr |
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. | |
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.
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.
ip_address | is the network address on which to listen |
port | is the UDP port on which to listen |
format | is the wire format of the inbound requests. Currently only JSON is supported |
ncr_recv_handler | the receive handler object to notify when a receive completes. |
reuse_address | enables IP address sharing when true It defaults to false. |
base | class throws NcrListenerError if handler is invalid. |
Definition at line 65 of file ncr_udp.cc.
References receiveCompletionHandler(), and RECV_BUF_MAX.
|
virtual |
Destructor.
Definition at line 82 of file ncr_udp.cc.
References isc::dhcp_ddns::NameChangeListener::stopListening().
|
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.
NcrUDPError | if the open fails. |
Implements isc::dhcp_ddns::NameChangeListener.
Definition at line 129 of file ncr_udp.cc.
References isc_throw.
|
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.
NcrUDPError | if the open fails. |
Implements isc::dhcp_ddns::NameChangeListener.
Definition at line 120 of file ncr_udp.cc.
|
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.
io_service | the IOService which will monitor the socket. |
NcrUDPError | if 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().
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.
successful | boolean indicator that should be true if the socket receive completed without error, false otherwise. |
recv_callback | pointer 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().
|
static |
Defines the maximum size packet that can be received.
Definition at line 320 of file ncr_udp.h.
Referenced by NameChangeUDPListener().