Kea  2.1.7-git
isc::dhcp_ddns::NameChangeUDPSender Class Reference

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

#include <ncr_udp.h>

+ Inheritance diagram for isc::dhcp_ddns::NameChangeUDPSender:

Public Member Functions

 NameChangeUDPSender (const isc::asiolink::IOAddress &ip_address, const uint32_t port, const isc::asiolink::IOAddress &server_address, const uint32_t server_port, const NameChangeFormat format, RequestSendHandler &ncr_send_handler, const size_t send_que_max=NameChangeSender::MAX_QUEUE_DEFAULT, const bool reuse_address=false)
 Constructor. More...
 
virtual ~NameChangeUDPSender ()
 Destructor. More...
 
virtual void close ()
 Closes the UDPSocket. More...
 
virtual void doSend (NameChangeRequestPtr &ncr)
 Sends a given request asynchronously over the socket. More...
 
virtual int getSelectFd ()
 Returns a file descriptor suitable for use with select. More...
 
virtual bool ioReady ()
 Returns whether or not the sender has IO ready to process. More...
 
virtual void open (isc::asiolink::IOService &io_service)
 Opens a UDP socket using the given IOService. More...
 
void sendCompletionHandler (const bool successful, const UDPCallback *send_callback)
 Implements the NameChangeRequest level send completion handler. More...
 
- Public Member Functions inherited from isc::dhcp_ddns::NameChangeSender
 NameChangeSender (RequestSendHandler &send_handler, size_t send_queue_max=MAX_QUEUE_DEFAULT)
 Constructor. More...
 
virtual ~NameChangeSender ()
 Destructor. More...
 
bool amSending () const
 Returns true if the sender is in send mode, false otherwise. More...
 
void assumeQueue (NameChangeSender &source_sender)
 Move all queued requests from a given sender into the send queue. More...
 
void clearSendQueue ()
 Flushes all entries in the send queue. More...
 
size_t getQueueMaxSize () const
 Returns the maximum number of entries allowed in the send queue. More...
 
size_t getQueueSize () const
 Returns the number of entries currently in the send queue. More...
 
bool isSendInProgress () const
 Returns true when a send is in progress. More...
 
const NameChangeRequestPtrpeekAt (const size_t index) const
 Returns the entry at a given position in the queue. More...
 
virtual void runReadyIO ()
 Processes sender IO events. More...
 
void sendRequest (NameChangeRequestPtr &ncr)
 Queues the given request to be sent. More...
 
void setQueueMaxSize (const size_t new_max)
 Sets the maximum queue size to the given value. More...
 
void skipNext ()
 Removes the request at the front of the send queue. More...
 
void startSending (isc::asiolink::IOService &io_service)
 Prepares the IO for transmission. More...
 
void stopSending ()
 Closes the IO sink and stops send logic. More...
 

Static Public Attributes

static const size_t SEND_BUF_MAX = NameChangeUDPListener::RECV_BUF_MAX
 Defines the maximum size packet that can be sent. More...
 
- Static Public Attributes inherited from isc::dhcp_ddns::NameChangeSender
static const size_t MAX_QUEUE_DEFAULT = 1024
 Defines a default maximum number of entries in the send queue. More...
 

Additional Inherited Members

- Public Types inherited from isc::dhcp_ddns::NameChangeSender
enum  Result { SUCCESS, TIME_OUT, STOPPED, ERROR }
 Defines the outcome of an asynchronous NCR send. More...
 
typedef std::deque< NameChangeRequestPtrSendQueue
 Defines the type used for the request send queue. More...
 
- Protected Member Functions inherited from isc::dhcp_ddns::NameChangeSender
SendQueuegetSendQueue ()
 Returns a reference to the send queue. More...
 
void invokeSendHandler (const NameChangeSender::Result result)
 Calls the NCR send completion handler registered with the sender. More...
 
void sendNext ()
 Dequeues and sends the next request on the send queue in a thread safe context. More...
 

Detailed Description

Provides the ability to send NameChangeRequests via UDP socket.

This class is a derivation of the NameChangeSender which is capable of sending NameChangeRequests through a UDP socket. The caller need only supply network addressing and a RequestSendHandler instance to send NameChangeRequests asynchronously.

Definition at line 441 of file ncr_udp.h.

Constructor & Destructor Documentation

◆ NameChangeUDPSender()

isc::dhcp_ddns::NameChangeUDPSender::NameChangeUDPSender ( const isc::asiolink::IOAddress ip_address,
const uint32_t  port,
const isc::asiolink::IOAddress server_address,
const uint32_t  server_port,
const NameChangeFormat  format,
RequestSendHandler ncr_send_handler,
const size_t  send_que_max = NameChangeSender::MAX_QUEUE_DEFAULT,
const bool  reuse_address = false 
)

Constructor.

Parameters
ip_addressthe IP address from which to send
portthe port from which to send
server_addressthe IP address of the target listener
server_portis the IP port of the target listener
formatis the wire format of the outbound requests.
ncr_send_handlerthe send handler object to notify when when a send completes.
send_que_maxsets the maximum number of entries allowed in the send queue. It defaults to NameChangeSender::MAX_QUEUE_DEFAULT
reuse_addressenables IP address sharing when true It defaults to false.

Definition at line 203 of file ncr_udp.cc.

References SEND_BUF_MAX, and sendCompletionHandler().

Referenced by isc::dhcp_ddns::NameChangeUDPListener::receiveCompletionHandler().

+ Here is the call graph for this function:

◆ ~NameChangeUDPSender()

isc::dhcp_ddns::NameChangeUDPSender::~NameChangeUDPSender ( )
virtual

Destructor.

Definition at line 223 of file ncr_udp.cc.

References isc::dhcp_ddns::NameChangeSender::stopSending().

+ Here is the call graph for this function:

Member Function Documentation

◆ close()

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

Closes the UDPSocket.

It first invokes the socket's cancel method which should stop any pending send 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::NameChangeSender.

Definition at line 265 of file ncr_udp.cc.

References isc_throw.

◆ doSend()

void isc::dhcp_ddns::NameChangeUDPSender::doSend ( NameChangeRequestPtr ncr)
virtual

Sends a given request asynchronously over the socket.

The given NameChangeRequest is converted to wire format and copied into the send callback's transfer buffer. Then the socket's asyncSend() method is called, passing in send_callback_ member's transfer buffer as the send buffer and the send_callback_ itself as the callback object.

Parameters
ncrNameChangeRequest to send.

Implements isc::dhcp_ddns::NameChangeSender.

Definition at line 294 of file ncr_udp.cc.

References isc::util::OutputBuffer::getData(), isc::util::OutputBuffer::getLength(), and SEND_BUF_MAX.

+ Here is the call graph for this function:

◆ getSelectFd()

int isc::dhcp_ddns::NameChangeUDPSender::getSelectFd ( )
virtual

Returns a file descriptor suitable for use with select.

The value returned is an open file descriptor which can be used with select() system call to monitor the sender for IO events. This allows NameChangeUDPSenders to be used in applications which use select, rather than IOService to wait for IO events to occur.

Warning
Attempting other use of this value may lead to unpredictable behavior in the sender.
Returns
Returns an "open" file descriptor
Exceptions
NcrSenderErrorif the sender is not in send mode,

Implements isc::dhcp_ddns::NameChangeSender.

Definition at line 355 of file ncr_udp.cc.

References isc::dhcp_ddns::NameChangeSender::amSending(), and isc_throw.

+ Here is the call graph for this function:

◆ ioReady()

bool isc::dhcp_ddns::NameChangeUDPSender::ioReady ( )
virtual

Returns whether or not the sender has IO ready to process.

Returns
true if the sender has at IO ready, false otherwise.

Implements isc::dhcp_ddns::NameChangeSender.

Definition at line 365 of file ncr_udp.cc.

References isc::dhcp_ddns::dhcp_ddns_logger, isc::dhcp_ddns::DHCP_DDNS_UDP_SENDER_WATCH_SOCKET_CLOSE_ERROR, and LOG_ERROR.

◆ open()

void isc::dhcp_ddns::NameChangeUDPSender::open ( isc::asiolink::IOService io_service)
virtual

Opens a UDP socket using the given IOService.

Creates a NameChangeUDPSocket bound to the sender'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::NameChangeSender.

Definition at line 229 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:

◆ sendCompletionHandler()

void isc::dhcp_ddns::NameChangeUDPSender::sendCompletionHandler ( const bool  successful,
const UDPCallback send_callback 
)

Implements the NameChangeRequest level send completion handler.

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

If the indicator denotes success, then the method will notify the application layer by calling invokeSendHandler() with a success status.

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

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

Definition at line 317 of file ncr_udp.cc.

References isc::dhcp_ddns::dhcp_ddns_logger, isc::dhcp_ddns::DHCP_DDNS_NCR_UDP_CLEAR_READY_ERROR, isc::dhcp_ddns::DHCP_DDNS_NCR_UDP_SEND_CANCELED, isc::dhcp_ddns::DHCP_DDNS_NCR_UDP_SEND_ERROR, isc::dhcp_ddns::NameChangeSender::ERROR, isc::dhcp_ddns::UDPCallback::getErrorCode(), isc::dhcp_ddns::NameChangeSender::invokeSendHandler(), LOG_ERROR, isc::dhcp_ddns::NameChangeSender::STOPPED, and isc::dhcp_ddns::NameChangeSender::SUCCESS.

Referenced by NameChangeUDPSender().

+ Here is the call graph for this function:

Member Data Documentation

◆ SEND_BUF_MAX

const size_t isc::dhcp_ddns::NameChangeUDPSender::SEND_BUF_MAX = NameChangeUDPListener::RECV_BUF_MAX
static

Defines the maximum size packet that can be sent.

Definition at line 445 of file ncr_udp.h.

Referenced by doSend(), and NameChangeUDPSender().


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