// IcmpPacket
//-----------------------------------------------------------------------------
+/**
+ * @brief Default constructor.
+ */
IcmpPacket::IcmpPacket() :
IpHeader(),
IcmpPayloadHeader(),
{
}
+/**
+ * @brief Parameterized constructor.
+ *
+ * @param icmp_header The ICMP header.
+ * @param icmp_data The ICMP payload data.
+ */
IcmpPacket::IcmpPacket(
const IcmpHeader &icmp_header,
const IcmpData &icmp_data
{
}
+/**
+ * @brief Destructor.
+ */
IcmpPacket::~IcmpPacket()
{
}
+/**
+ * @brief Obtain the IP header.
+ *
+ * @return The IP header object.
+ */
Ipv4Header IcmpPacket::get_ip_header() const
{
return IpHeader;
}
+/**
+ * @brief Obtain the ICMP header.
+ *
+ * @return The ICMP header object.
+ */
IcmpHeader IcmpPacket::get_icmp_header() const
{
return IcmpPayloadHeader;
}
+/**
+ * @brief Obtain the ICMP payload data.
+ *
+ * @return The ICMP data.
+ */
IcmpData IcmpPacket::get_icmp_data() const
{
return IcmpPayloadData;
}
+/**
+ * @brief Check if this object matches with all the parameters.
+ *
+ * @param type The type of ICMP message.
+ * @param identifier The identifier.
+ * @param sequence_number The sequence number.
+ * @param source_address The source address.
+ *
+ * @return @c true if this matches all the parameters, or @c false if at least
+ * one does not match.
+ */
bool IcmpPacket::match(
const IcmpType type,
const uint16_t identifier,
//-----------------------------------------------------------------------------
// IcmpPacket
//-----------------------------------------------------------------------------
-// ICMP packet/message format:
-//
-// 0 8 16 31
-// +-------+-------+---------------+------------------------------+ ---
-// | | | | | ^
-// |version|header | type of | total length in bytes | |
-// | (4) | length| service | | |
-// +-------+-------+---------------+-+-+-+------------------------+ |
-// | | | | | | |
-// | identification |0|D|M| fragment offset | |
-// | | |F|F| | |
-// +---------------+---------------+-+-+-+------------------------+ |
-// | | | | |
-// | time to live | protocol | header checksum | IPv4 Header
-// | | | | 20 bytes
-// +---------------+---------------+------------------------------+ |
-// | | |
-// | source IPv4 address | |
-// | | |
-// +--------------------------------------------------------------+ |
-// | | |
-// | destination IPv4 address | |
-// | | v
-// +---------------+---------------+------------------------------+ ---
-// | | | | ^
-// | type | code | checksum | |
-// | | | | |
-// +---------------+---------------+------------------------------+ |
-// | | | ICMP Payload
-// | identifier | sequence number | (header +
-// | | | data)
-// +-------------------------------+------------------------------+ 8+ bytes
-// | | |
-// | data (optional) | |
-// | | v
-// +-------------------------------+------------------------------+ ---
-//
-//-----------------------------------------------------------------------------
+/**
+ * @brief This class represents the ICMP Packet.
+ *
+ * The ICMP Packet format is:
+ *
+ * @code
+ * 0 8 16 31
+ * +-------+-------+---------------+------------------------------+ ---
+ * | | | | | ^
+ * |version|header | type of | total length in bytes | |
+ * | (4) | length| service | | |
+ * +-------+-------+---------------+-+-+-+------------------------+ |
+ * | | | | | | |
+ * | identification |0|D|M| fragment offset | |
+ * | | |F|F| | |
+ * +---------------+---------------+-+-+-+------------------------+ |
+ * | | | | |
+ * | time to live | protocol | header checksum | IPv4 Header
+ * | | | | 20 bytes
+ * +---------------+---------------+------------------------------+ |
+ * | | |
+ * | source IPv4 address | |
+ * | | |
+ * +--------------------------------------------------------------+ |
+ * | | |
+ * | destination IPv4 address | |
+ * | | v
+ * +---------------+---------------+------------------------------+ ---
+ * | | | | ^
+ * | type | code | checksum | |
+ * | | | | |
+ * +---------------+---------------+------------------------------+ |
+ * | | | ICMP Payload
+ * | identifier | sequence number | (header +
+ * | | | data)
+ * +-------------------------------+------------------------------+ 8+ bytes
+ * | | |
+ * | data (optional) | |
+ * | | v
+ * +-------------------------------+------------------------------+ ---
+ * @endcode
+ */
class IcmpPacket
{
public:
);
private:
- /// the IP header object
+ /// The IP header.
Ipv4Header IpHeader;
- /// the ICMP header
+ /// The ICMP packet header.
IcmpHeader IcmpPayloadHeader;
- /// the ICMP data
+ /// The ICMP packet payload (data).
IcmpData IcmpPayloadData;
};