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