From: Guilherme Maciel Ferreira Date: Sat, 27 Aug 2011 15:59:57 +0000 (-0300) Subject: Improved IcmpPacket documentation X-Git-Tag: v1.2~66 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=31febc2c78f19fe8dedabb41b999e49efc4f3901;p=pingcheck Improved IcmpPacket documentation --- diff --git a/src/icmp/icmppacket.cpp b/src/icmp/icmppacket.cpp index 841082c..4268dab 100644 --- a/src/icmp/icmppacket.cpp +++ b/src/icmp/icmppacket.cpp @@ -14,6 +14,9 @@ using boost::asio::ip::address; // IcmpPacket //----------------------------------------------------------------------------- +/** + * @brief Default constructor. + */ IcmpPacket::IcmpPacket() : IpHeader(), IcmpPayloadHeader(), @@ -21,6 +24,12 @@ IcmpPacket::IcmpPacket() : { } +/** + * @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 @@ -31,25 +40,54 @@ IcmpPacket::IcmpPacket( { } +/** + * @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, diff --git a/src/icmp/icmppacket.h b/src/icmp/icmppacket.h index 8a2d96a..dfe9445 100644 --- a/src/icmp/icmppacket.h +++ b/src/icmp/icmppacket.h @@ -22,45 +22,49 @@ //----------------------------------------------------------------------------- // 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: @@ -92,11 +96,11 @@ 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; };