Kea 2.7.5
|
Provides the ability to send NameChangeRequests via UDP socket. More...
#include <ncr_udp.h>
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. | |
bool | isSendInProgress () const |
Returns true when a send is in progress. | |
const NameChangeRequestPtr & | peekAt (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< RequestSendHandler > | RequestSendHandlerPtr |
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< NameChangeRequestPtr > | SendQueue |
Defines the type used for the request send queue. | |
Protected Member Functions inherited from isc::dhcp_ddns::NameChangeSender | |
SendQueue & | getSendQueue () |
Returns a reference to the send queue. | |
void | invokeSendHandler (const NameChangeSender::Result result) |
Calls the NCR send completion handler registered with the sender. | |
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. | |
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.
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.
ip_address | the IP address from which to send |
port | the port from which to send |
server_address | the IP address of the target listener |
server_port | is the IP port of the target listener |
format | is the wire format of the outbound requests. |
ncr_send_handler | the send handler object to notify when when a send completes. |
send_que_max | sets the maximum number of entries allowed in the send queue. It defaults to NameChangeSender::MAX_QUEUE_DEFAULT |
reuse_address | enables IP address sharing when true It defaults to false. |
Definition at line 207 of file ncr_udp.cc.
References SEND_BUF_MAX, and sendCompletionHandler().
|
virtual |
Destructor.
Definition at line 228 of file ncr_udp.cc.
References isc::dhcp_ddns::NameChangeSender::stopSending().
|
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.
NcrUDPError | if the open fails. |
Implements isc::dhcp_ddns::NameChangeSender.
Definition at line 274 of file ncr_udp.cc.
References isc_throw.
|
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.
ncr | NameChangeRequest to send. |
Implements isc::dhcp_ddns::NameChangeSender.
Definition at line 306 of file ncr_udp.cc.
References SEND_BUF_MAX.
|
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.
NcrSenderError | if 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.
|
virtual |
Returns whether or not the sender has IO ready to process.
Implements isc::dhcp_ddns::NameChangeSender.
Definition at line 379 of file ncr_udp.cc.
|
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.
io_service | the IOService which will monitor the socket. |
NcrUDPError | if the open fails. |
Implements isc::dhcp_ddns::NameChangeSender.
Definition at line 234 of file ncr_udp.cc.
References isc::dhcp_ddns::NameChangeSender::io_service_, isc_throw, and isc::asiolink::IOAddress::isV4().
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.
successful | boolean indicator that should be true if the socket send completed without error, false otherwise. |
send_callback | pointer 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::NameChangeSender::invokeSendHandler(), LOG_ERROR, isc::dhcp_ddns::NameChangeSender::STOPPED, and isc::dhcp_ddns::NameChangeSender::SUCCESS.
Referenced by NameChangeUDPSender().
|
static |
Defines the maximum size packet that can be sent.
Definition at line 446 of file ncr_udp.h.
Referenced by NameChangeUDPSender(), and doSend().