7 #ifndef NCR_UDP_LISTENER_H
8 #define NCR_UDP_LISTENER_H
111 #include <boost/shared_array.hpp>
119 namespace dhcp_ddns {
130 typedef std::function<void(const bool, const UDPCallback*)>
166 Data(RawBufferPtr& buffer,
const size_t buf_size,
167 UDPEndpointPtr& data_source)
209 UDPCallback (RawBufferPtr& buffer,
const size_t buf_size,
210 UDPEndpointPtr& data_source,
211 const UDPCompletionHandler& handler);
222 void operator ()(
const boost::system::error_code error_code,
223 const size_t bytes_transferred);
232 return (data_->bytes_transferred_);
239 data_->bytes_transferred_ = value;
244 return (data_->error_code_);
251 data_->error_code_ = value;
256 return (data_->buffer_);
261 return (data_->buf_size_);
266 return (data_->buffer_.get());
282 void putData(
const uint8_t* src,
size_t len);
287 return (data_->put_len_);
294 data_->data_source_ = endpoint;
299 return (data_->data_source_);
304 UDPCompletionHandler handler_;
307 boost::shared_ptr<Data> data_;
341 const bool reuse_address =
false);
363 virtual void close();
411 boost::shared_ptr<boost::asio::ip::udp::socket> asio_socket_;
414 boost::shared_ptr<NameChangeUDPSocket> socket_;
417 boost::shared_ptr<UDPCallback> recv_callback_;
467 const bool reuse_address =
false);
491 virtual void close();
549 void closeWatchSocket();
561 uint32_t server_port_;
567 boost::shared_ptr<boost::asio::ip::udp::socket> asio_socket_;
570 boost::shared_ptr<NameChangeUDPSocket> socket_;
573 boost::shared_ptr<isc::asiolink::UDPEndpoint> server_endpoint_;
576 boost::shared_ptr<UDPCallback> send_callback_;
virtual ~NameChangeUDPListener()
Destructor.
size_t buf_size_
Storage capacity of the buffer.
const UDPEndpointPtr & getDataSource()
Returns the UDP endpoint that provided the transferred data.
void doReceive()
Initiates an asynchronous read on the socket.
std::function< void(const bool, const UDPCallback *)> UDPCompletionHandler
Defines a function pointer for NameChangeRequest completion handlers.
This file defines abstract classes for exchanging NameChangeRequests.
static const size_t SEND_BUF_MAX
Defines the maximum size packet that can be sent.
Provides the ability to receive NameChangeRequests via UDP socket.
virtual ~NameChangeUDPSender()
Destructor.
static const size_t RECV_BUF_MAX
Defines the maximum size packet that can be received.
virtual void open(isc::asiolink::IOService &io_service)
Opens a UDP socket using the given IOService.
Implements the callback class passed into UDPSocket calls.
virtual void close()
Closes the UDPSocket.
size_t put_len_
Stores this size of the data within the buffer when written there manually.
NameChangeFormat
Defines the list of data wire formats supported.
boost::shared_ptr< WatchSocket > WatchSocketPtr
Defines a smart pointer to an instance of a WatchSocket.
NcrUDPError(const char *file, size_t line, const char *what)
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
Data(RawBufferPtr &buffer, const size_t buf_size, UDPEndpointPtr &data_source)
Constructor.
UDPEndpointPtr data_source_
The UDP endpoint that is the origin of the data transferred.
UDPCallback(RawBufferPtr &buffer, const size_t buf_size, UDPEndpointPtr &data_source, const UDPCompletionHandler &handler)
Used as the callback object for UDPSocket services.
void sendCompletionHandler(const bool successful, const UDPCallback *send_callback)
Implements the NameChangeRequest level send completion handler.
The IOService class is a wrapper for the ASIO io_service class.
Defines the class, WatchSocket.
size_t getBufferSize() const
Returns the data transfer buffer capacity.
void receiveCompletionHandler(const bool successful, const UDPCallback *recv_callback)
Implements the NameChangeRequest level receive completion handler.
void operator()(const boost::system::error_code error_code, const size_t bytes_transferred)
Operator that will be invoked by the asiolink layer.
virtual bool ioReady()
Returns whether or not the sender has IO ready to process.
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.
The UDPSocket class is a concrete derived class of IOAsioSocket that represents a UDP socket...
virtual void close()
Closes the UDPSocket.
void setBytesTransferred(const size_t value)
Sets the number of bytes transferred.
Provides the ability to send NameChangeRequests via UDP socket.
virtual void open(isc::asiolink::IOService &io_service)
Opens a UDP socket using the given IOService.
NameChangeUDPListener(const isc::asiolink::IOAddress &ip_address, const uint32_t port, const NameChangeFormat format, RequestReceiveHandler &ncr_recv_handler, const bool reuse_address=false)
Constructor.
Abstract class for defining application layer send callbacks.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
boost::system::error_code error_code_
Stores the IO layer result code of the completed IO service.
Thrown when a UDP level exception occurs.
void setErrorCode(const boost::system::error_code value)
Sets the completed IO layer service outcome status.
This is a base class for exceptions thrown from the DNS library module.
virtual int getSelectFd()
Returns a file descriptor suitable for use with select.
Defines the logger used by the top-level component of kea-dhcp-ddns.
Container class which stores service invocation related data.
boost::shared_array< uint8_t > RawBufferPtr
Defines a dynamically allocated shared array.
isc::asiolink::UDPSocket< UDPCallback > NameChangeUDPSocket
Convenience type for UDP socket based listener.
void putData(const uint8_t *src, size_t len)
Copies data into the data transfer buffer.
void setDataSource(UDPEndpointPtr &endpoint)
Sets the data source to the given endpoint.
RawBufferPtr getBuffer() const
Returns the data transfer buffer.
RawBufferPtr buffer_
A pointer to the data transfer buffer.
Abstract interface for sending NameChangeRequests.
virtual void doSend(NameChangeRequestPtr &ncr)
Sends a given request asynchronously over the socket.
boost::system::error_code getErrorCode() const
Returns the completed IO layer service outcome status.
The IOAddress class represents an IP addresses (version agnostic)
size_t bytes_transferred_
Stores the number of bytes transferred by completed IO service.
const uint8_t * getData() const
Returns a pointer the data transfer buffer content.
boost::shared_ptr< asiolink::UDPEndpoint > UDPEndpointPtr
Abstract interface for receiving NameChangeRequests.
Abstract class for defining application layer receive callbacks.
size_t getPutLen() const
Returns the number of bytes manually written into the transfer buffer.
static const size_t MAX_QUEUE_DEFAULT
Defines a default maximum number of entries in the send queue.
std::string format(const std::string &format, const std::vector< std::string > &args)
Apply Formatting.
size_t getBytesTransferred() const
Returns the number of bytes transferred by the completed IO service.