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)
168 : buffer_(buffer), buf_size_(buf_size), data_source_(data_source),
169 put_len_(0), error_code_(), bytes_transferred_(0) {
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();
398 void receiveCompletionHandler(
const bool successful,
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();
520 void sendCompletionHandler(
const bool successful,
536 virtual int getSelectFd();
541 virtual bool ioReady();
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_;
size_t buf_size_
Storage capacity of the buffer.
const UDPEndpointPtr & getDataSource()
Returns the UDP endpoint that provided the transferred data.
size_t getBufferSize() const
Returns the data transfer buffer capacity.
std::function< void(const bool, const UDPCallback *)> UDPCompletionHandler
Defines a function pointer for NameChangeRequest completion handlers.
This file defines abstract classes for exchanging NameChangeRequests.
Provides the ability to receive NameChangeRequests via UDP socket.
static const size_t RECV_BUF_MAX
Defines the maximum size packet that can be received.
Implements the callback class passed into UDPSocket calls.
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.
RawBufferPtr getBuffer() const
Returns the data transfer buffer.
UDPEndpointPtr data_source_
The UDP endpoint that is the origin of the data transferred.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The IOService class is a wrapper for the ASIO io_service class.
size_t getPutLen() const
Returns the number of bytes manually written into the transfer buffer.
Defines the class, WatchSocket.
boost::system::error_code getErrorCode() const
Returns the completed IO layer service outcome status.
The UDPSocket class is a concrete derived class of IOAsioSocket that represents a UDP socket...
void setBytesTransferred(const size_t value)
Sets the number of bytes transferred.
Provides the ability to send NameChangeRequests via UDP socket.
Abstract class for defining application layer send callbacks.
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.
Defines the logger used by the top-level component of kea-lfc.
Container class which stores service invocation related data.
const uint8_t * getData() const
Returns a pointer the data transfer buffer content.
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 setDataSource(UDPEndpointPtr &endpoint)
Sets the data source to the given endpoint.
RawBufferPtr buffer_
A pointer to the data transfer buffer.
size_t getBytesTransferred() const
Returns the number of bytes transferred by the completed IO service.
Abstract interface for sending NameChangeRequests.
The IOAddress class represents an IP addresses (version agnostic)
size_t bytes_transferred_
Stores the number of bytes transferred by completed IO service.
boost::shared_ptr< asiolink::UDPEndpoint > UDPEndpointPtr
Abstract interface for receiving NameChangeRequests.
Abstract class for defining application layer receive callbacks.
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.