![]() |
Kea 3.0.0
|
Embodies an ICMP message. More...
#include <icmp_msg.h>
Public Types | |
| enum | ICMPMsgType { ECHO_REPLY = 0 , TARGET_UNREACHABLE = 3 , ECHO_REQUEST = 8 } |
| ICMP message types. More... | |
Public Member Functions | |
| ICMPMsg () | |
| Constructor. | |
| virtual | ~ICMPMsg ()=default |
| Destructor. | |
| uint16_t | getChecksum () const |
| Fetches the checksum. | |
| uint8_t | getCode () const |
| Fetches the ICMP message code. | |
| const isc::asiolink::IOAddress & | getDestination () const |
| Fetches the destination IP address. | |
| uint16_t | getId () const |
| Fetches the message id. | |
| const std::vector< uint8_t > & | getPayload () const |
| Fetches the message payload. | |
| uint16_t | getSequence () const |
| Fetches the message sequence number. | |
| const isc::asiolink::IOAddress & | getSource () const |
| Fetches the source IP address. | |
| uint8_t | getType () const |
| Fetches the ICMP message type (e.g. | |
| ICMPPtr | pack () const |
| Packs the message into an ICMP structure. | |
| void | setChecksum (uint16_t check_sum) |
| Sets the check sum. | |
| void | setCode (uint8_t code) |
| Sets the ICMP code. | |
| void | setDestination (const isc::asiolink::IOAddress &destination) |
| Sets the destination IP address. | |
| void | setId (const uint16_t id) |
| Sets the message id. | |
| void | setPayload (const uint8_t *data, size_t length) |
| Sets the message payload to the given data. | |
| void | setSequence (uint16_t sequence) |
| Sets the message sequence number. | |
| void | setSource (const isc::asiolink::IOAddress &source) |
| Sets the source IP address. | |
| void | setType (uint8_t msg_type) |
| Sets the ICMP message type. | |
Static Public Member Functions | |
| static uint32_t | calcChecksum (const uint8_t *data, size_t length) |
| Calculates the checksum of the given data buffer. | |
| static ICMPMsgPtr | unpack (const uint8_t *wire_data, size_t length) |
| Unpacks an ICMP message from the given wire_data. | |
Static Public Attributes | |
| static constexpr size_t | ICMP_HEADER_SIZE = 8 |
| Size in octets of ICMP message header. | |
Embodies an ICMP message.
Provides functions for marshalling of ICMP protocol messages to and from wire form
Definition at line 35 of file icmp_msg.h.
ICMP message types.
We only define the ones we care about.
| Enumerator | |
|---|---|
| ECHO_REPLY | |
| TARGET_UNREACHABLE | |
| ECHO_REQUEST | |
Definition at line 39 of file icmp_msg.h.
| isc::ping_check::ICMPMsg::ICMPMsg | ( | ) |
|
virtualdefault |
Destructor.
|
static |
Calculates the checksum of the given data buffer.
| data | pointer to data buffer from which to copy |
| length | number of bytes in data buffer |
Definition at line 85 of file icmp_msg.cc.
References isc::util::readUint16().
Referenced by pack().
|
inline |
Fetches the checksum.
Definition at line 105 of file icmp_msg.h.
|
inline |
Fetches the ICMP message code.
Definition at line 91 of file icmp_msg.h.
|
inline |
Fetches the destination IP address.
Definition at line 161 of file icmp_msg.h.
|
inline |
Fetches the message id.
Definition at line 119 of file icmp_msg.h.
|
inline |
Fetches the message payload.
Definition at line 175 of file icmp_msg.h.
|
inline |
Fetches the message sequence number.
Definition at line 133 of file icmp_msg.h.
|
inline |
Fetches the source IP address.
Definition at line 147 of file icmp_msg.h.
|
inline |
Fetches the ICMP message type (e.g.
ECHO_REQUEST, ECHO_REPLY)
Definition at line 77 of file icmp_msg.h.
| ICMPPtr isc::ping_check::ICMPMsg::pack | ( | ) | const |
Packs the message into an ICMP structure.
Definition at line 68 of file icmp_msg.cc.
References calcChecksum().
|
inline |
Sets the check sum.
| check_sum | new value for the check sum |
Definition at line 112 of file icmp_msg.h.
|
inline |
Sets the ICMP code.
| code | new value for the message type |
Definition at line 98 of file icmp_msg.h.
|
inline |
Sets the destination IP address.
| destination | new value for the destination IP address |
Definition at line 168 of file icmp_msg.h.
|
inline |
Sets the message id.
| id | new value for the message id |
Definition at line 126 of file icmp_msg.h.
| void isc::ping_check::ICMPMsg::setPayload | ( | const uint8_t * | data, |
| size_t | length ) |
Sets the message payload to the given data.
| data | pointer to data buffer from which to copy |
| length | number of bytes in data buffer |
Definition at line 80 of file icmp_msg.cc.
|
inline |
Sets the message sequence number.
| sequence | new value for the message sequence number |
Definition at line 140 of file icmp_msg.h.
|
inline |
Sets the source IP address.
| source | new value for the source IP address |
Definition at line 154 of file icmp_msg.h.
|
inline |
Sets the ICMP message type.
| msg_type | new value for the message type |
Definition at line 84 of file icmp_msg.h.
|
static |
Unpacks an ICMP message from the given wire_data.
The wire data is expected to include the IP header followed by an ICMP message.
| wire_data | raw data received from the socket |
| length | number of bytes in the wire_data contents |
| BadValue | if the wire data is invalid |
Definition at line 30 of file icmp_msg.cc.
References ICMPMsg(), ICMP_HEADER_SIZE, and isc_throw.
Referenced by isc::ping_check::PingCheckMgr::handleTargetUnreachable(), and isc::ping_check::PingChannel::socketReadCallback().
|
staticconstexpr |
Size in octets of ICMP message header.
1 (msg type) + 1 (code) + 2 (checksum) + 4 (either unused or used differently basing on the ICMP type and code e.g Identifier and Sequence Number for Echo or Echo Reply Message)
Definition at line 49 of file icmp_msg.h.
Referenced by unpack().