1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
3 * Copyright (c) 2007-2008 Louis Pasteur University
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
24 #include "ns3/header.h"
25 #include "ns3/ipv6-address.h"
31 * \brief Packet header for IPv6
33 class Ipv6Header : public Header
38 * \brief IPv6 next-header value
42 IPV6_EXT_HOP_BY_HOP=0,
48 IPV6_EXT_FRAGMENTATION=44,
49 IPV6_EXT_CONFIDENTIALITY=50,
50 IPV6_EXT_AUTHENTIFICATION,
55 IPV6_EXT_MOBILITY=135,
60 * \brief Get the type identifier.
61 * \return type identifier
63 static TypeId GetTypeId (void);
66 * \brief Return the instance type identifier.
67 * \return instance type ID
69 virtual TypeId GetInstanceTypeId (void) const;
77 * \brief Set the "Traffic class" field.
78 * \param traffic the 8-bit value
80 void SetTrafficClass (uint8_t traffic);
83 * \brief Get the "Traffic class" field.
84 * \return the traffic value
86 uint8_t GetTrafficClass (void) const;
89 * \brief Set the "Flow label" field.
90 * \param flow the 20-bit value
92 void SetFlowLabel (uint32_t flow);
95 * \brief Get the "Flow label" field.
96 * \return the flow label value
98 uint32_t GetFlowLabel (void) const;
101 * \brief Set the "Payload length" field.
102 * \param len the length of the payload in bytes
104 void SetPayloadLength (uint16_t len);
107 * \brief Get the "Payload length" field.
108 * \return the payload length
110 uint16_t GetPayloadLength (void) const;
113 * \brief Set the "Next header" field.
114 * \param next the next header number
116 void SetNextHeader (uint8_t next);
119 * \brief Get the next header.
120 * \return the next header number
122 uint8_t GetNextHeader (void) const;
125 * \brief Set the "Hop limit" field (TTL).
126 * \param limit the 8-bit value
128 void SetHopLimit (uint8_t limit);
131 * \brief Get the "Hop limit" field (TTL).
132 * \return the hop limit value
134 uint8_t GetHopLimit (void) const;
137 * \brief Set the "Source address" field.
138 * \param src the source address
140 void SetSourceAddress (Ipv6Address src);
143 * \brief Get the "Source address" field.
144 * \return the source address
146 Ipv6Address GetSourceAddress (void) const;
149 * \brief Set the "Destination address" field.
150 * \param dst the destination address
152 void SetDestinationAddress (Ipv6Address dst);
155 * \brief Get the "Destination address" field.
156 * \return the destination address
158 Ipv6Address GetDestinationAddress (void) const;
161 * \brief Get the name.
164 std::string GetName (void) const;
167 * \brief Print some informations about the packet.
168 * \param os output stream
169 * \return info about this packet
171 virtual void Print (std::ostream& os) const;
174 * \brief Get the serialized size of the packet.
177 virtual uint32_t GetSerializedSize (void) const;
180 * \brief Serialize the packet.
181 * \param start Buffer iterator
183 virtual void Serialize (Buffer::Iterator start) const;
186 * \brief Deserialize the packet.
187 * \param start Buffer iterator
188 * \return size of the packet
190 virtual uint32_t Deserialize (Buffer::Iterator start);
194 * \brief The version (always equal to 6).
196 uint32_t m_version : 4;
198 * \brief The traffic class.
200 uint32_t m_trafficClass : 8;
203 * \brief The flow label.
204 * \note This is 20-bit value.
206 uint32_t m_flowLabel : 20;
209 * \brief The payload length.
211 uint16_t m_payloadLength;
214 * \brief The Next header number.
216 uint8_t m_nextHeader;
219 * \brief The Hop limit value.
224 * \brief The source address.
226 Ipv6Address m_sourceAddress;
229 * \brief The destination address.
231 Ipv6Address m_destinationAddress;
234 } /* namespace ns3 */
236 #endif /* IPV6_HEADER_H */