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*)>
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_);
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_;
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The IOAddress class represents an IP addresses (version agnostic)
The IOService class is a wrapper for the ASIO io_service class.
The UDPSocket class is a concrete derived class of IOAsioSocket that represents a UDP socket.
Abstract class for defining application layer receive callbacks.
Abstract interface for receiving NameChangeRequests.
Abstract class for defining application layer send callbacks.
Abstract interface for sending NameChangeRequests.
static const size_t MAX_QUEUE_DEFAULT
Defines a default maximum number of entries in the send queue.
Provides the ability to receive NameChangeRequests via UDP socket.
virtual void close()
Closes the UDPSocket.
virtual ~NameChangeUDPListener()
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.
void receiveCompletionHandler(const bool successful, const UDPCallback *recv_callback)
Implements the NameChangeRequest level receive completion handler.
void doReceive()
Initiates an asynchronous read on the socket.
NameChangeUDPListener(const isc::asiolink::IOAddress &ip_address, const uint32_t port, const NameChangeFormat format, RequestReceiveHandler &ncr_recv_handler, const bool reuse_address=false)
Constructor.
Provides the ability to send NameChangeRequests via UDP socket.
void sendCompletionHandler(const bool successful, const UDPCallback *send_callback)
Implements the NameChangeRequest level send completion handler.
virtual void open(isc::asiolink::IOService &io_service)
Opens a UDP socket using the given IOService.
virtual bool ioReady()
Returns whether or not the sender has IO ready to process.
static const size_t SEND_BUF_MAX
Defines the maximum size packet that can be sent.
virtual int getSelectFd()
Returns a file descriptor suitable for use with select.
virtual void close()
Closes the UDPSocket.
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.
virtual void doSend(NameChangeRequestPtr &ncr)
Sends a given request asynchronously over the socket.
virtual ~NameChangeUDPSender()
Destructor.
Thrown when a UDP level exception occurs.
NcrUDPError(const char *file, size_t line, const char *what)
Implements the callback class passed into UDPSocket calls.
size_t getBytesTransferred() const
Returns the number of bytes transferred by the completed IO service.
void setDataSource(UDPEndpointPtr &endpoint)
Sets the data source to the given endpoint.
void setErrorCode(const boost::system::error_code value)
Sets the completed IO layer service outcome status.
size_t getBufferSize() const
Returns the data transfer buffer capacity.
RawBufferPtr getBuffer() const
Returns the data transfer buffer.
void putData(const uint8_t *src, size_t len)
Copies data into the data transfer buffer.
UDPCallback(RawBufferPtr &buffer, const size_t buf_size, UDPEndpointPtr &data_source, const UDPCompletionHandler &handler)
Used as the callback object for UDPSocket services.
const UDPEndpointPtr & getDataSource()
Returns the UDP endpoint that provided the transferred data.
const uint8_t * getData() const
Returns a pointer the data transfer buffer content.
void setBytesTransferred(const size_t value)
Sets the number of bytes transferred.
size_t getPutLen() const
Returns the number of bytes manually written into the transfer buffer.
void operator()(const boost::system::error_code error_code, const size_t bytes_transferred)
Operator that will be invoked by the asiolink layer.
boost::system::error_code getErrorCode() const
Returns the completed IO layer service outcome status.
NameChangeFormat
Defines the list of data wire formats supported.
std::function< void(const bool, const UDPCallback *)> UDPCompletionHandler
Defines a function pointer for NameChangeRequest completion handlers.
isc::asiolink::UDPSocket< UDPCallback > NameChangeUDPSocket
Convenience type for UDP socket based listener.
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
boost::shared_array< uint8_t > RawBufferPtr
Defines a dynamically allocated shared array.
boost::shared_ptr< asiolink::UDPEndpoint > UDPEndpointPtr
std::string format(const std::string &format, const std::vector< std::string > &args)
Apply Formatting.
boost::shared_ptr< WatchSocket > WatchSocketPtr
Defines a smart pointer to an instance of a WatchSocket.
Defines the logger used by the top-level component of kea-lfc.
This file defines abstract classes for exchanging NameChangeRequests.
Container class which stores service invocation related data.
boost::system::error_code error_code_
Stores the IO layer result code of the completed IO service.
size_t put_len_
Stores this size of the data within the buffer when written there manually.
RawBufferPtr buffer_
A pointer to the data transfer buffer.
size_t buf_size_
Storage capacity of the buffer.
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.
size_t bytes_transferred_
Stores the number of bytes transferred by completed IO service.
Defines the class, WatchSocket.