1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/node/ipv6-header.h Fri Nov 07 11:36:15 2008 -0800
1.3 @@ -0,0 +1,237 @@
1.4 +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
1.5 +/*
1.6 + * Copyright (c) 2007-2008 Louis Pasteur University
1.7 + *
1.8 + * This program is free software; you can redistribute it and/or modify
1.9 + * it under the terms of the GNU General Public License version 2 as
1.10 + * published by the Free Software Foundation;
1.11 + *
1.12 + * This program is distributed in the hope that it will be useful,
1.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.15 + * GNU General Public License for more details.
1.16 + *
1.17 + * You should have received a copy of the GNU General Public License
1.18 + * along with this program; if not, write to the Free Software
1.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1.20 + *
1.21 + * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
1.22 + */
1.23 +
1.24 +#ifndef IPV6_HEADER_H
1.25 +#define IPV6_HEADER_H
1.26 +
1.27 +#include "ns3/header.h"
1.28 +#include "ns3/ipv6-address.h"
1.29 +
1.30 +namespace ns3 {
1.31 +
1.32 +/**
1.33 + * \class Ipv6Header
1.34 + * \brief Packet header for IPv6
1.35 + */
1.36 +class Ipv6Header : public Header
1.37 +{
1.38 + public:
1.39 + /**
1.40 + * \enum NextHeader_e
1.41 + * \brief IPv6 next-header value
1.42 + */
1.43 + enum NextHeader_e
1.44 + {
1.45 + IPV6_EXT_HOP_BY_HOP=0,
1.46 + IPV6_IPV4=4,
1.47 + IPV6_TCP=6,
1.48 + IPV6_UDP=17,
1.49 + IPV6_IPV6=41,
1.50 + IPV6_EXT_ROUTING=43,
1.51 + IPV6_EXT_FRAGMENTATION=44,
1.52 + IPV6_EXT_CONFIDENTIALITY=50,
1.53 + IPV6_EXT_AUTHENTIFICATION,
1.54 + IPV6_ICMPV6=58,
1.55 + IPV6_EXT_END,
1.56 + IPV6_EXT_DESTINATION,
1.57 + IPV6_SCTP=135,
1.58 + IPV6_EXT_MOBILITY=135,
1.59 + IPV6_UDP_LITE,
1.60 + };
1.61 +
1.62 + /**
1.63 + * \brief Get the type identifier.
1.64 + * \return type identifier
1.65 + */
1.66 + static TypeId GetTypeId (void);
1.67 +
1.68 + /**
1.69 + * \brief Return the instance type identifier.
1.70 + * \return instance type ID
1.71 + */
1.72 + virtual TypeId GetInstanceTypeId (void) const;
1.73 +
1.74 + /**
1.75 + * \brief Constructor.
1.76 + */
1.77 + Ipv6Header (void);
1.78 +
1.79 + /**
1.80 + * \brief Set the "Traffic class" field.
1.81 + * \param traffic the 8-bit value
1.82 + */
1.83 + void SetTrafficClass (uint8_t traffic);
1.84 +
1.85 + /**
1.86 + * \brief Get the "Traffic class" field.
1.87 + * \return the traffic value
1.88 + */
1.89 + uint8_t GetTrafficClass (void) const;
1.90 +
1.91 + /**
1.92 + * \brief Set the "Flow label" field.
1.93 + * \param flow the 20-bit value
1.94 + */
1.95 + void SetFlowLabel (uint32_t flow);
1.96 +
1.97 + /**
1.98 + * \brief Get the "Flow label" field.
1.99 + * \return the flow label value
1.100 + */
1.101 + uint32_t GetFlowLabel (void) const;
1.102 +
1.103 + /**
1.104 + * \brief Set the "Payload length" field.
1.105 + * \param len the length of the payload in bytes
1.106 + */
1.107 + void SetPayloadLength (uint16_t len);
1.108 +
1.109 + /**
1.110 + * \brief Get the "Payload length" field.
1.111 + * \return the payload length
1.112 + */
1.113 + uint16_t GetPayloadLength (void) const;
1.114 +
1.115 + /**
1.116 + * \brief Set the "Next header" field.
1.117 + * \param next the next header number
1.118 + */
1.119 + void SetNextHeader (uint8_t next);
1.120 +
1.121 + /**
1.122 + * \brief Get the next header.
1.123 + * \return the next header number
1.124 + */
1.125 + uint8_t GetNextHeader (void) const;
1.126 +
1.127 + /**
1.128 + * \brief Set the "Hop limit" field (TTL).
1.129 + * \param limit the 8-bit value
1.130 + */
1.131 + void SetHopLimit (uint8_t limit);
1.132 +
1.133 + /**
1.134 + * \brief Get the "Hop limit" field (TTL).
1.135 + * \return the hop limit value
1.136 + */
1.137 + uint8_t GetHopLimit (void) const;
1.138 +
1.139 + /**
1.140 + * \brief Set the "Source address" field.
1.141 + * \param src the source address
1.142 + */
1.143 + void SetSourceAddress (Ipv6Address src);
1.144 +
1.145 + /**
1.146 + * \brief Get the "Source address" field.
1.147 + * \return the source address
1.148 + */
1.149 + Ipv6Address GetSourceAddress (void) const;
1.150 +
1.151 + /**
1.152 + * \brief Set the "Destination address" field.
1.153 + * \param dst the destination address
1.154 + */
1.155 + void SetDestinationAddress (Ipv6Address dst);
1.156 +
1.157 + /**
1.158 + * \brief Get the "Destination address" field.
1.159 + * \return the destination address
1.160 + */
1.161 + Ipv6Address GetDestinationAddress (void) const;
1.162 +
1.163 + /**
1.164 + * \brief Get the name.
1.165 + * \return the name
1.166 + */
1.167 + std::string GetName (void) const;
1.168 +
1.169 + /**
1.170 + * \brief Print some informations about the packet.
1.171 + * \param os output stream
1.172 + * \return info about this packet
1.173 + */
1.174 + virtual void Print (std::ostream& os) const;
1.175 +
1.176 + /**
1.177 + * \brief Get the serialized size of the packet.
1.178 + * \return size
1.179 + */
1.180 + virtual uint32_t GetSerializedSize (void) const;
1.181 +
1.182 + /**
1.183 + * \brief Serialize the packet.
1.184 + * \param start Buffer iterator
1.185 + */
1.186 + virtual void Serialize (Buffer::Iterator start) const;
1.187 +
1.188 + /**
1.189 + * \brief Deserialize the packet.
1.190 + * \param start Buffer iterator
1.191 + * \return size of the packet
1.192 + */
1.193 + virtual uint32_t Deserialize (Buffer::Iterator start);
1.194 +
1.195 + private:
1.196 + /**
1.197 + * \brief The version (always equal to 6).
1.198 + */
1.199 + uint32_t m_version : 4;
1.200 + /**
1.201 + * \brief The traffic class.
1.202 + */
1.203 + uint32_t m_trafficClass : 8;
1.204 +
1.205 + /**
1.206 + * \brief The flow label.
1.207 + * \note This is 20-bit value.
1.208 + */
1.209 + uint32_t m_flowLabel : 20;
1.210 +
1.211 + /**
1.212 + * \brief The payload length.
1.213 + */
1.214 + uint16_t m_payloadLength;
1.215 +
1.216 + /**
1.217 + * \brief The Next header number.
1.218 + */
1.219 + uint8_t m_nextHeader;
1.220 +
1.221 + /**
1.222 + * \brief The Hop limit value.
1.223 + */
1.224 + uint8_t m_hopLimit;
1.225 +
1.226 + /**
1.227 + * \brief The source address.
1.228 + */
1.229 + Ipv6Address m_sourceAddress;
1.230 +
1.231 + /**
1.232 + * \brief The destination address.
1.233 + */
1.234 + Ipv6Address m_destinationAddress;
1.235 +};
1.236 +
1.237 +} /* namespace ns3 */
1.238 +
1.239 +#endif /* IPV6_HEADER_H */
1.240 +