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

Static Public Attributes

static const size_t SEND_BUF_MAX = NameChangeUDPListener::RECV_BUF_MAX
 Defines the maximum size packet that can be sent.
 
- 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.
 

Additional Inherited Members

- Public Types inherited from isc::dhcp_ddns::NameChangeSender
typedef boost::shared_ptr< RequestSendHandlerRequestSendHandlerPtr
 Defines a smart pointer to an instance of a request send handler.
 
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.
 
- Protected Member Functions inherited from isc::dhcp_ddns::NameChangeSender
virtual void close ()=0
 Abstract method which closes the IO sink.
 
virtual void doSend (NameChangeRequestPtr &ncr)=0
 Initiates an IO layer asynchronous send.
 
SendQueuegetSendQueue ()
 Returns a reference to the send queue.
 
void invokeSendHandler (const NameChangeSender::Result result)
 Calls the NCR send completion handler registered with the sender.
 
virtual void open (const isc::asiolink::IOServicePtr &io_service)=0
 Abstract method which opens the IO sink for transmission.
 
void sendNext ()
 Dequeues and sends the next request on the send queue in a thread safe context.
 
- Protected Attributes inherited from isc::dhcp_ddns::NameChangeSender
asiolink::IOServicePtr io_service_
 Pointer to the IOService currently being used by the sender.
 

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 442 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,
RequestSendHandlerPtr  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 207 of file ncr_udp.cc.

References SEND_BUF_MAX, and sendCompletionHandler().

+ Here is the call graph for this function:

◆ ~NameChangeUDPSender()

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

Destructor.

Definition at line 228 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 274 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 306 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 369 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 379 of file ncr_udp.cc.

◆ open()

void isc::dhcp_ddns::NameChangeUDPSender::open ( const isc::asiolink::IOServicePtr 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 234 of file ncr_udp.cc.

References isc::asiolink::UDPEndpoint::getASIOEndpoint(), isc::dhcp_ddns::NameChangeSender::io_service_, 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 328 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 446 of file ncr_udp.h.

Referenced by NameChangeUDPSender(), and doSend().


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