10#include <netinet/in.h> 
   11#include <sys/socket.h> 
   33    explicit ICMPSocket(
const ICMPSocket&);
 
   34    ICMPSocket& operator=(
const ICMPSocket&);
 
   46    explicit ICMPSocket(boost::asio::ip::icmp::socket& socket);
 
   63#if BOOST_VERSION < 106600 
   64        return (socket_.native());
 
   66        return (socket_.native_handle());
 
 
   74        return (IPPROTO_ICMP);
 
 
  145                                     size_t& cumulative, 
size_t& offset,
 
  161    static uint16_t 
calcChecksum(
const uint8_t* buf, 
const uint32_t buf_size);
 
  172    std::unique_ptr<boost::asio::ip::icmp::socket> socket_ptr_;
 
  175    boost::asio::ip::icmp::socket& socket_;
 
 
  184ICMPSocket<C>::ICMPSocket(boost::asio::ip::icmp::socket& socket) :
 
  185    socket_ptr_(), socket_(socket), isopen_(true) {
 
 
  192    io_service_(io_service),
 
  193    socket_ptr_(new boost::asio::ip::icmp::socket(io_service_->getInternalIOService())),
 
  194    socket_(*socket_ptr_), isopen_(false) {
 
 
  205template <
typename C> 
void 
  215            socket_.open(boost::asio::ip::icmp::v4());
 
  217            socket_.open(boost::asio::ip::icmp::v6());
 
  222        boost::asio::ip::icmp::socket::send_buffer_size snd_size;
 
  223        socket_.get_option(snd_size);
 
  226            socket_.set_option(snd_size);
 
  229        boost::asio::ip::icmp::socket::receive_buffer_size rcv_size;
 
  230        socket_.get_option(rcv_size);
 
  233            socket_.set_option(rcv_size);
 
  236        boost::asio::socket_base::do_not_route option(
false);
 
  237        socket_.set_option(option);
 
 
  244template <
typename C> 
void 
  259        socket_.async_send_to(boost::asio::buffer(
data, length),
 
  263            "attempt to send on a ICMP socket that is not open");
 
 
  270template <
typename C> 
void 
  280        if (offset >= length) {
 
  282                                      "ICMP receive buffer");
 
  284        void* buffer_start = 
static_cast<void*
>(
static_cast<uint8_t*
>(
data) + offset);
 
  287        socket_.async_receive_from(boost::asio::buffer(buffer_start, length - offset),
 
  291            "attempt to receive from a ICMP socket that is not open");
 
 
  298template <
typename C> 
bool 
  300                                   size_t& cumulative, 
size_t& offset,
 
  309    outbuff->writeData(staging, length);
 
 
  317template <
typename C> 
void 
  327template <
typename C> 
void 
  329    if (isopen_ && socket_ptr_) {
 
 
  335template <
typename C> uint16_t
 
  339    for (i = 0; i < (buf_size & ~1U); i += 2) {
 
  340        uint16_t chunk = buf[i] << 8 | buf[i + 1];
 
 
I/O Socket with asynchronous operations.
The IOEndpoint class is an abstract base class to represent a communication endpoint.
virtual short getFamily() const =0
Returns the address family of the endpoint.
virtual short getProtocol() const =0
Returns the protocol number of the endpoint (TCP, UDP...)
The ICMPEndpoint class is a concrete derived class of IOEndpoint that represents an endpoint of a ICM...
const boost::asio::ip::icmp::endpoint & getASIOEndpoint() const
Fetches the underlying ASIO endpoint implementation.
virtual void close()
Close socket.
virtual void cancel()
Cancel I/O On Socket.
ICMPSocket(const asiolink::IOServicePtr &service)
Constructor.
virtual void open(const asiolink::IOEndpoint *endpoint, C &callback)
Open Socket.
virtual bool processReceivedData(const void *staging, size_t length, size_t &cumulative, size_t &offset, size_t &expected, isc::util::OutputBufferPtr &outbuff)
Process received data.
virtual int getProtocol() const
Return protocol of socket.
static uint16_t calcChecksum(const uint8_t *buf, const uint32_t buf_size)
Calculates the checksum for the given buffer of data.
virtual void asyncReceive(void *data, size_t length, size_t offset, asiolink::IOEndpoint *endpoint, C &callback)
Receive Asynchronously.
virtual bool isOpenSynchronous() const
Is "open()" synchronous?
ICMPSocket(boost::asio::ip::icmp::socket &socket)
Constructor from an ASIO ICMP socket.
virtual ~ICMPSocket()
Destructor.
virtual bool isOpen() const
Indicates if the socket is currently open.
virtual void asyncSend(const void *data, size_t length, const asiolink::IOEndpoint *endpoint, C &callback)
Send Asynchronously.
virtual int getNative() const
Return file descriptor of underlying socket.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define isc_throw_assert(expr)
Replacement for assert() that throws if the expression is false.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
boost::shared_ptr< OutputBuffer > OutputBufferPtr
Type of pointers to output buffers.
Defines the logger used by the top-level component of kea-lfc.