Kea
1.9.9-git
|
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, 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 NameChangeRequestPtr & | peekAt (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< NameChangeRequestPtr > | SendQueue |
Defines the type used for the request send queue. More... | |
Protected Member Functions inherited from isc::dhcp_ddns::NameChangeSender | |
SendQueue & | getSendQueue () |
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... | |
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, | ||
RequestSendHandler & | 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 196 of file ncr_udp.cc.
References SEND_BUF_MAX, and sendCompletionHandler().
|
virtual |
Destructor.
Definition at line 216 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 258 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 287 of file ncr_udp.cc.
References isc::util::OutputBuffer::getData(), isc::util::OutputBuffer::getLength(), and 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 349 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 359 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 222 of file ncr_udp.cc.
References isc::asiolink::IOService::get_io_service(), isc::asiolink::UDPEndpoint::getASIOEndpoint(), 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 310 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().
|
static |
Defines the maximum size packet that can be sent.
Definition at line 445 of file ncr_udp.h.
Referenced by doSend(), and NameChangeUDPSender().