Kea 3.1.1
isc::ping_check::ICMPSocket< C > Class Template Reference

The ICMPSocket class is a concrete derived class of IOAsioSocket that represents a ICMP socket. More...

#include <icmp_socket.h>

+ Inheritance diagram for isc::ping_check::ICMPSocket< C >:

Public Types

enum  { MIN_SIZE = 4096 }
 

Public Member Functions

 ICMPSocket (boost::asio::ip::icmp::socket &socket)
 Constructor from an ASIO ICMP socket.
 
 ICMPSocket (const asiolink::IOServicePtr &service)
 Constructor.
 
virtual ~ICMPSocket ()
 Destructor.
 
virtual void asyncReceive (void *data, size_t length, size_t offset, asiolink::IOEndpoint *endpoint, C &callback)
 Receive Asynchronously.
 
virtual void asyncSend (const void *data, size_t length, const asiolink::IOEndpoint *endpoint, C &callback)
 Send Asynchronously.
 
virtual void cancel ()
 Cancel I/O On Socket.
 
virtual void close ()
 Close socket.
 
virtual int getNative () const
 Return file descriptor of underlying socket.
 
virtual int getProtocol () const
 Return protocol of socket.
 
virtual bool isOpen () const
 Indicates if the socket is currently open.
 
virtual bool isOpenSynchronous () const
 Is "open()" synchronous?
 
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 ~IOAsioSocket ()=default
 The destructor.
 
virtual ~IOSocket ()
 The destructor.
 

Static Public Member Functions

static uint16_t calcChecksum (const uint8_t *buf, const uint32_t buf_size)
 Calculates the checksum for the given buffer of data.
 
static IOSocketgetDummyUDPSocket ()
 Return a non-usable "dummy" UDP socket for testing.
 
static IOSocketgetDummyTCPSocket ()
 Return a non-usable "dummy" TCP socket for testing.
 

Additional Inherited Members

 IOAsioSocket ()
 The default constructor.
 
 IOSocket ()
 The default constructor.
 

Detailed Description

template<typename C>
class isc::ping_check::ICMPSocket< C >

The ICMPSocket class is a concrete derived class of IOAsioSocket that represents a ICMP socket.

Parameters
CCallback type

Definition at line 30 of file icmp_socket.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename C>
anonymous enum
Enumerator
MIN_SIZE 

Definition at line 37 of file icmp_socket.h.

Constructor & Destructor Documentation

◆ ICMPSocket() [1/2]

template<typename C>
isc::ping_check::ICMPSocket< C >::ICMPSocket ( boost::asio::ip::icmp::socket & socket)
explicit

Constructor from an ASIO ICMP socket.

Parameters
socketThe ASIO representation of the ICMP socket. It is assumed that the caller will open and close the socket, so these operations are a no-op for that socket.

Definition at line 184 of file icmp_socket.h.

◆ ICMPSocket() [2/2]

template<typename C>
isc::ping_check::ICMPSocket< C >::ICMPSocket ( const asiolink::IOServicePtr & service)
explicit

Constructor.

Used when the ICMPSocket is being asked to manage its own internal socket. In this case, the open() and close() methods are used.

Parameters
serviceI/O Service object used to manage the socket.

Definition at line 191 of file icmp_socket.h.

◆ ~ICMPSocket()

template<typename C>
isc::ping_check::ICMPSocket< C >::~ICMPSocket ( )
virtual

Destructor.

Definition at line 200 of file icmp_socket.h.

Member Function Documentation

◆ asyncReceive()

template<typename C>
void isc::ping_check::ICMPSocket< C >::asyncReceive ( void * data,
size_t length,
size_t offset,
asiolink::IOEndpoint * endpoint,
C & callback )
virtual

Receive Asynchronously.

Calls the underlying socket's async_receive_from() method to read a packet of data from a remote endpoint. Arrival of the data is signalled via a call to the callback function.

Parameters
dataBuffer to receive incoming message
lengthLength of the data buffer
offsetOffset into buffer where data is to be put
endpointSource of the communication
callbackCallback object

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 271 of file icmp_socket.h.

References isc::ping_check::ICMPEndpoint::getASIOEndpoint(), isc::asiolink::IOEndpoint::getProtocol(), isc_throw, and isc_throw_assert.

+ Here is the call graph for this function:

◆ asyncSend()

template<typename C>
void isc::ping_check::ICMPSocket< C >::asyncSend ( const void * data,
size_t length,
const asiolink::IOEndpoint * endpoint,
C & callback )
virtual

Send Asynchronously.

Calls the underlying socket's async_send_to() method to send a packet of data asynchronously to the remote endpoint. The callback will be called on completion.

Parameters
dataData to send
lengthLength of data to send
endpointTarget of the send
callbackCallback object.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 245 of file icmp_socket.h.

References isc::ping_check::ICMPEndpoint::getASIOEndpoint(), isc::asiolink::IOEndpoint::getProtocol(), isc_throw, and isc_throw_assert.

+ Here is the call graph for this function:

◆ calcChecksum()

template<typename C>
uint16_t isc::ping_check::ICMPSocket< C >::calcChecksum ( const uint8_t * buf,
const uint32_t buf_size )
static

Calculates the checksum for the given buffer of data.

Parameters
bufpointer to the data buffer.
buf_sizenumber of bytes in the data buffer.
Returns
calculated checksum of the data as a uint16_t.

Definition at line 336 of file icmp_socket.h.

◆ cancel()

template<typename C>
void isc::ping_check::ICMPSocket< C >::cancel ( )
virtual

Cancel I/O On Socket.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 318 of file icmp_socket.h.

◆ close()

template<typename C>
void isc::ping_check::ICMPSocket< C >::close ( )
virtual

Close socket.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 328 of file icmp_socket.h.

◆ getNative()

template<typename C>
virtual int isc::ping_check::ICMPSocket< C >::getNative ( ) const
inlinevirtual

Return file descriptor of underlying socket.

Returns
socket's native file descriptor as an int.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 62 of file icmp_socket.h.

◆ getProtocol()

template<typename C>
virtual int isc::ping_check::ICMPSocket< C >::getProtocol ( ) const
inlinevirtual

Return protocol of socket.

Returns
Always IPPROTO_ICMP.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 73 of file icmp_socket.h.

◆ isOpen()

template<typename C>
virtual bool isc::ping_check::ICMPSocket< C >::isOpen ( ) const
inlinevirtual

Indicates if the socket is currently open.

Returns
true if socket is open.

Definition at line 88 of file icmp_socket.h.

◆ isOpenSynchronous()

template<typename C>
virtual bool isc::ping_check::ICMPSocket< C >::isOpenSynchronous ( ) const
inlinevirtual

Is "open()" synchronous?

Indicates that the opening of a ICMP socket is synchronous.

Returns
Always true.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 81 of file icmp_socket.h.

◆ open()

template<typename C>
void isc::ping_check::ICMPSocket< C >::open ( const asiolink::IOEndpoint * endpoint,
C & callback )
virtual

Open Socket.

Opens the ICMP socket. This is a synchronous operation.

Parameters
endpointEndpoint to which the socket will send data. This is used to determine the address family that should be used for the underlying socket.
callbackUnused as the operation is synchronous.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 206 of file icmp_socket.h.

References isc::asiolink::IOEndpoint::getFamily(), and MIN_SIZE.

+ Here is the call graph for this function:

◆ processReceivedData()

template<typename C>
bool isc::ping_check::ICMPSocket< C >::processReceivedData ( const void * staging,
size_t length,
size_t & cumulative,
size_t & offset,
size_t & expected,
isc::util::OutputBufferPtr & outbuff )
virtual

Process received data.

See the description of IOAsioSocket::receiveComplete for a complete description of this method.

Parameters
stagingPointer to the start of the staging buffer.
lengthAmount of data in the staging buffer.
cumulativeAmount of data received before the staging buffer is processed.
offsetUnused.
expectedunused.
outbuffOutput buffer. Data in the staging buffer is be copied to this output buffer in the call.
Returns
Always true

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 299 of file icmp_socket.h.


The documentation for this class was generated from the following file: