Documentation for IPv6 header.
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 15 Nov 2011 23:42:27 +0000 (21:42 -0200)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 15 Nov 2011 23:42:27 +0000 (21:42 -0200)
src/ip/ipv6header.cpp
src/ip/ipv6header.h

index b0f34bd..6b521fa 100644 (file)
@@ -22,45 +22,105 @@ using boost::scoped_array;
 
 static const size_t Ipv6HeaderSizeInBytes = 40;
 
+/**
+ * @brief Default constructor.
+ */
 Ipv6Header::Ipv6Header() :
     Payload( Ipv6HeaderSizeInBytes )
 {
 }
 
+/**
+ * @brief Get the IP version.
+ *
+ * The Version field keeps track of which version of the protocol the
+ * packet belongs to.
+ *
+ * @return The 4-bits representing the Version field.
+ */
 uint8_t Ipv6Header::get_version() const
 {
     return ( Payload[ 0 ] >> 4 ) & 0x0F;
 }
 
-uint8_t Ipv6Header::get_traffic_class() const
+/**
+ * @brief Get the Differentiated Services, originally called Traffic Class.
+ *
+ * The Differentiated Services field is used to provide QoS.
+ *
+ * @return The 8-bits representing the Differentiated Services.
+ */
+uint8_t Ipv6Header::get_differentiated_services() const
 {
     uint16_t first_word = static_cast<uint16_t>( (Payload[ 0 ] << 8) | Payload[ 1 ] );
-    uint8_t traffic_class = static_cast<uint8_t>( (first_word & 0x0FF0) >> 4 );
+    uint8_t differentiated_services = static_cast<uint8_t>( (first_word & 0x0FF0) >> 4 );
 
-    return traffic_class;
+    return differentiated_services;
 }
 
+/**
+ * @brief Get the Flow Label field.
+ *
+ * The Flow Label field provides a way for a source and destination to mark
+ * groups of packets that have the same requirements and should be treated in
+ * the same way by the network.
+ *
+ * @return The 32-bits representing the Flow Label.
+ */
 uint32_t Ipv6Header::get_flow_label() const
 {
     uint32_t flow_label = Payload.decode32( 0, 3 );
     return ( flow_label & 0xFFFFF );
 }
 
+/**
+ * @brief Get the Payload Length field.
+ *
+ * This field tells how many bytes follow the 40-byte fixed length IPv6 header.
+ *
+ * @return The 16-bits representing the amount of bytes that follow the IPv6
+ * header, at most 65,535 bytes.
+ */
 uint16_t Ipv6Header::get_payload_length() const
 {
     return Payload.decode16( 4, 5 );
 }
 
+/**
+ * @brief Get the Next Header field.
+ *
+ * The Next Header field tells which of the extension headers, if any, follow
+ * this one. If this header is the last IP header, this field tells which
+ * transport protocol handler (e.g. TCP, UDP) to pass the packet to.
+ *
+ * @return An 8-bits number identifying the next header that follows this one.
+ */
 uint8_t Ipv6Header::get_next_header() const
 {
     return Payload[ 6 ];
 }
 
+/**
+ * @brief Get the Hop Limit field.
+ *
+ * The Hop Limit field is used to keep packets from living forever, it is
+ * decremented at each router the packet pass.
+ *
+ * @return An 8-bits number representing the amount of hops left before
+ * discarding this packet.
+ */
 uint8_t Ipv6Header::get_hop_limit() const
 {
     return Payload[ 7 ];
 }
 
+/**
+ * @brief Get the source address.
+ *
+ * The Source Address field indicates the source network host address.
+ *
+ * @brief The source address.
+ */
 address_v6 Ipv6Header::get_source_address() const
 {
     address_v6::bytes_type address; // 16 bytes
@@ -78,6 +138,13 @@ address_v6 Ipv6Header::get_source_address() const
     return address_v6( address );
 }
 
+/**
+ * @brief Get the destination address.
+ *
+ * The Destination Address field indicates the destination network host address.
+ *
+ * @return The destination address.
+ */
 address_v6 Ipv6Header::get_destination_address() const
 {
     address_v6::bytes_type address; // 16 bytes
index f71d752..5628a47 100644 (file)
@@ -67,7 +67,7 @@ public:
     Ipv6Header();
 
     uint8_t get_version() const;
-    uint8_t get_traffic_class() const;
+    uint8_t get_differentiated_services() const;
     uint32_t get_flow_label() const;
 
     uint16_t get_payload_length() const;