From dfd89091eb16f77eb27c7c6017bcf3898f0ee8c9 Mon Sep 17 00:00:00 2001 From: Guilherme Maciel Ferreira Date: Sat, 27 Aug 2011 11:37:03 -0300 Subject: [PATCH] Message headers now have their wire format in Doxygen --- src/icmp/icmpheader.h | 35 ++++++++++++---------- src/ip/ipv4header.h | 70 +++++++++++++++++++++++-------------------- src/ip/pseudoipv4header.h | 50 ++++++++++++++++++------------ src/tcp/tcpheader.h | 73 +++++++++++++++++++++++---------------------- 4 files changed, 123 insertions(+), 105 deletions(-) diff --git a/src/icmp/icmpheader.h b/src/icmp/icmpheader.h index 7552375..d4dd221 100644 --- a/src/icmp/icmpheader.h +++ b/src/icmp/icmpheader.h @@ -20,22 +20,25 @@ //----------------------------------------------------------------------------- // IcmpHeader //----------------------------------------------------------------------------- -// -// ICMP Generic Header Format -// -// 0 8 16 31 -// +---------------+---------------+------------------------------+ --- -// | | | | ^ -// | type | code | checksum | 4 bytes -// | | | | v -// +---------------+---------------+------------------------------+ --- -// | | -// | specific to each message | -// | | -// +-------------------------------+------------------------------+ -// -//----------------------------------------------------------------------------- +/** + * @brief This class represents the ICMP Packet Header. + * + * The ICMP Generic Header Format is: + * + * @code + * 0 8 16 31 + * +---------------+---------------+------------------------------+ --- + * | | | | ^ + * | type | code | checksum | 4 bytes + * | | | | v + * +---------------+---------------+------------------------------+ --- + * | | + * | specific to each message | + * | | + * +-------------------------------+------------------------------+ + * @endcode + */ class IcmpHeader { public: @@ -77,7 +80,7 @@ public: ); private: - /// changeable pointer to different ICMP messages types + /// Changeable pointer to different ICMP messages types. boost::shared_ptr MessageFormat; }; diff --git a/src/ip/ipv4header.h b/src/ip/ipv4header.h index f7811c5..0dbab02 100644 --- a/src/ip/ipv4header.h +++ b/src/ip/ipv4header.h @@ -16,40 +16,44 @@ //----------------------------------------------------------------------------- // Ipv4Header //----------------------------------------------------------------------------- -// IPv4 header 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 | 20 bytes -// | | | | | -// +---------------+---------------+------------------------------+ | -// | | | -// | source IPv4 address | | -// | | | -// +--------------------------------------------------------------+ | -// | | | -// | destination IPv4 address | | -// | | v -// +--------------------------------------------------------------+ --- -// | | ^ -// | | | -// / options (if any) / 0 - 40 -// / / bytes -// | | | -// | | v -// +--------------------------------------------------------------+ --- -// -//----------------------------------------------------------------------------- +/** + * @brief This class represents the IP version 4 Packet Header. + * + * The IPv4 header 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 | 20 bytes + * | | | | | + * +---------------+---------------+------------------------------+ | + * | | | + * | source IPv4 address | | + * | | | + * +--------------------------------------------------------------+ | + * | | | + * | destination IPv4 address | | + * | | v + * +--------------------------------------------------------------+ --- + * | | ^ + * | | | + * / options (if any) / 0 - 40 + * / / bytes + * | | | + * | | v + * +--------------------------------------------------------------+ --- + * @endcode + */ class Ipv4Header { public: diff --git a/src/ip/pseudoipv4header.h b/src/ip/pseudoipv4header.h index 52745b1..6238059 100644 --- a/src/ip/pseudoipv4header.h +++ b/src/ip/pseudoipv4header.h @@ -24,33 +24,43 @@ on this file might be covered by the GNU General Public License. //----------------------------------------------------------------------------- // PseudoIpv4Header //----------------------------------------------------------------------------- -// Pseudo IPv4 header format used by TCP and UDP checksums: -// -// 0 8 16 31 -// +--------------------------------------------------------------+ --- -// | | ^ -// | source IPv4 address | | -// | | | -// +--------------------------------------------------------------+ | -// | | | -// | destination IPv4 address | 12 bytes -// | | | -// +---------------+---------------+------------------------------+ | -// | | | | | -// | zero | protocol | header length | | -// | | | | v -// +---------------+---------------+------------------------------+ --- -// -//----------------------------------------------------------------------------- +/** + * @brief This class represents a Pseudo IP header used to compute checksum of + * transport level protocols. + * + * Pseudo IPv4 header format used by TCP and UDP checksums: + * + * @code + * 0 8 16 31 + * +--------------------------------------------------------------+ --- + * | | ^ + * | source IPv4 address | | + * | | | + * +--------------------------------------------------------------+ | + * | | | + * | destination IPv4 address | 12 bytes + * | | | + * +---------------+---------------+------------------------------+ | + * | | | | | + * | zero | protocol | header length | | + * | | | | v + * +---------------+---------------+------------------------------+ --- + * @endcode + */ class PseudoIpv4Header { public: + /// Source IPv4 address uint32_t source_address; + /// Destination IPv4 address uint32_t destination_address; + /// Zero uint8_t zero_byte; - uint8_t protocol; // protocol - uint16_t header_length; // TCP or UDP header length + /// Transport layer protocol + uint8_t protocol; + /// TCP or UDP header length + uint16_t header_length; }; #endif /* PSEUDO_IPV4_HEADER_H */ diff --git a/src/tcp/tcpheader.h b/src/tcp/tcpheader.h index 2c2fa52..a25ac19 100644 --- a/src/tcp/tcpheader.h +++ b/src/tcp/tcpheader.h @@ -30,43 +30,44 @@ on this file might be covered by the GNU General Public License. //----------------------------------------------------------------------------- // TcpHeader //----------------------------------------------------------------------------- -// -// TCP Segment header. -// -// The wire format of a TCP header is: -// -// 0 4 8 16 24 31 -// +-------------------------------+------------------------------+ --- -// | | | ^ -// | source port | destination port | | -// | | | | -// +--------------------------------------------------------------+ | -// | | | -// | sequence number | | -// | | | -// +--------------------------------------------------------------+ | -// | | | -// | acknowledgment number (if ACK set) | 20 bytes -// | | | -// +-------+-------+-+-+-+-+-+-+-+-+------------------------------+ | -// | data | reser-|C|E|U|A|P|R|S|F| | | -// |offset | ved |W|C|R|C|S|S|Y|I| window size | | -// | | |R|E|G|K|H|T|N|N| | | -// +---------------+-+-+-+-+-+-+-+-+------------------------------+ | -// | | | | -// | checksum | urgent pointer (if URG set) | | -// | | | v -// +-----------------------------------------------+--------------+ --- -// | | | ^ -// | | | | -// | options (if Data Offset > 5) | padding / 0 - 40 -// | | / bytes -// | | | | -// | | | v -// +-----------------------------------------------+--------------+ --- -// -//----------------------------------------------------------------------------- +/** + * @brief This class represents the TCP Segment Header. + * + * The wire format of a TCP header is: + * + * @code + * 0 4 8 16 24 31 + * +-------------------------------+------------------------------+ --- + * | | | ^ + * | source port | destination port | | + * | | | | + * +--------------------------------------------------------------+ | + * | | | + * | sequence number | | + * | | | + * +--------------------------------------------------------------+ | + * | | | + * | acknowledgment number (if ACK set) | 20 bytes + * | | | + * +-------+-------+-+-+-+-+-+-+-+-+------------------------------+ | + * | data | reser-|C|E|U|A|P|R|S|F| | | + * |offset | ved |W|C|R|C|S|S|Y|I| window size | | + * | | |R|E|G|K|H|T|N|N| | | + * +---------------+-+-+-+-+-+-+-+-+------------------------------+ | + * | | | | + * | checksum | urgent pointer (if URG set) | | + * | | | v + * +-----------------------------------------------+--------------+ --- + * | | | ^ + * | | | | + * | options (if Data Offset > 5) | padding / 0 - 40 + * | | / bytes + * | | | | + * | | | v + * +-----------------------------------------------+--------------+ --- + * @endcode + */ class TcpHeader { public: -- 1.7.1