src/node/ipv6-header.h
author vincent@clarinet.u-strasbg.fr
Fri Nov 07 11:36:15 2008 -0800 (2008-11-07)
changeset 3852 9cf7ad0cac85
child 3857 6ed8e59690b2
permissions -rw-r--r--
Initial IPv6 capability
vincent@3852
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
vincent@3852
     2
/*
vincent@3852
     3
 * Copyright (c) 2007-2008 Louis Pasteur University
vincent@3852
     4
 *
vincent@3852
     5
 * This program is free software; you can redistribute it and/or modify
vincent@3852
     6
 * it under the terms of the GNU General Public License version 2 as
vincent@3852
     7
 * published by the Free Software Foundation;
vincent@3852
     8
 *
vincent@3852
     9
 * This program is distributed in the hope that it will be useful,
vincent@3852
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
vincent@3852
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
vincent@3852
    12
 * GNU General Public License for more details.
vincent@3852
    13
 *
vincent@3852
    14
 * You should have received a copy of the GNU General Public License
vincent@3852
    15
 * along with this program; if not, write to the Free Software
vincent@3852
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
vincent@3852
    17
 *
vincent@3852
    18
 * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
vincent@3852
    19
 */
vincent@3852
    20
vincent@3852
    21
#ifndef IPV6_HEADER_H
vincent@3852
    22
#define IPV6_HEADER_H
vincent@3852
    23
vincent@3852
    24
#include "ns3/header.h"
vincent@3852
    25
#include "ns3/ipv6-address.h"
vincent@3852
    26
vincent@3852
    27
namespace ns3 {
vincent@3852
    28
vincent@3852
    29
/**
vincent@3852
    30
 * \class Ipv6Header
vincent@3852
    31
 * \brief Packet header for IPv6
vincent@3852
    32
 */
vincent@3852
    33
class Ipv6Header : public Header
vincent@3852
    34
{
vincent@3852
    35
  public:
vincent@3852
    36
    /**
vincent@3852
    37
     * \enum NextHeader_e
vincent@3852
    38
     * \brief IPv6 next-header value
vincent@3852
    39
     */
vincent@3852
    40
    enum NextHeader_e
vincent@3852
    41
    {
vincent@3852
    42
      IPV6_EXT_HOP_BY_HOP=0,
vincent@3852
    43
      IPV6_IPV4=4,
vincent@3852
    44
      IPV6_TCP=6,
vincent@3852
    45
      IPV6_UDP=17,
vincent@3852
    46
      IPV6_IPV6=41,
vincent@3852
    47
      IPV6_EXT_ROUTING=43,
vincent@3852
    48
      IPV6_EXT_FRAGMENTATION=44,
vincent@3852
    49
      IPV6_EXT_CONFIDENTIALITY=50,
vincent@3852
    50
      IPV6_EXT_AUTHENTIFICATION,
vincent@3852
    51
      IPV6_ICMPV6=58,
vincent@3852
    52
      IPV6_EXT_END,
vincent@3852
    53
      IPV6_EXT_DESTINATION,
vincent@3852
    54
      IPV6_SCTP=135,
vincent@3852
    55
      IPV6_EXT_MOBILITY=135,
vincent@3852
    56
      IPV6_UDP_LITE,
vincent@3852
    57
    };
vincent@3852
    58
vincent@3852
    59
    /**
vincent@3852
    60
     * \brief Get the type identifier.
vincent@3852
    61
     * \return type identifier
vincent@3852
    62
     */
vincent@3852
    63
    static TypeId GetTypeId (void);
vincent@3852
    64
vincent@3852
    65
    /**
vincent@3852
    66
     * \brief Return the instance type identifier.
vincent@3852
    67
     * \return instance type ID
vincent@3852
    68
     */
vincent@3852
    69
    virtual TypeId GetInstanceTypeId (void) const;
vincent@3852
    70
vincent@3852
    71
    /**
vincent@3852
    72
     * \brief Constructor.
vincent@3852
    73
     */
vincent@3852
    74
    Ipv6Header (void);
vincent@3852
    75
vincent@3852
    76
    /**
vincent@3852
    77
     * \brief Set the "Traffic class" field.
vincent@3852
    78
     * \param traffic the 8-bit value
vincent@3852
    79
     */
vincent@3852
    80
    void SetTrafficClass (uint8_t traffic);
vincent@3852
    81
vincent@3852
    82
    /**
vincent@3852
    83
     * \brief Get the "Traffic class" field.
vincent@3852
    84
     * \return the traffic value
vincent@3852
    85
     */
vincent@3852
    86
    uint8_t GetTrafficClass (void) const;
vincent@3852
    87
vincent@3852
    88
    /**
vincent@3852
    89
     * \brief Set the "Flow label" field.
vincent@3852
    90
     * \param flow the 20-bit value
vincent@3852
    91
     */
vincent@3852
    92
    void SetFlowLabel (uint32_t flow);
vincent@3852
    93
vincent@3852
    94
    /**
vincent@3852
    95
     * \brief Get the "Flow label" field.
vincent@3852
    96
     * \return the flow label value
vincent@3852
    97
     */
vincent@3852
    98
    uint32_t GetFlowLabel (void) const;
vincent@3852
    99
vincent@3852
   100
    /**
vincent@3852
   101
     * \brief Set the "Payload length" field.
vincent@3852
   102
     * \param len the length of the payload in bytes
vincent@3852
   103
     */
vincent@3852
   104
    void SetPayloadLength (uint16_t len);
vincent@3852
   105
vincent@3852
   106
    /**
vincent@3852
   107
     * \brief Get the "Payload length" field.
vincent@3852
   108
     * \return the payload length
vincent@3852
   109
     */
vincent@3852
   110
    uint16_t GetPayloadLength (void) const;
vincent@3852
   111
vincent@3852
   112
    /**
vincent@3852
   113
     * \brief Set the "Next header" field.
vincent@3852
   114
     * \param next the next header number
vincent@3852
   115
     */
vincent@3852
   116
    void SetNextHeader (uint8_t next);
vincent@3852
   117
vincent@3852
   118
    /**
vincent@3852
   119
     * \brief Get the next header.
vincent@3852
   120
     * \return the next header number
vincent@3852
   121
     */
vincent@3852
   122
    uint8_t GetNextHeader (void) const;
vincent@3852
   123
vincent@3852
   124
    /**
vincent@3852
   125
     * \brief Set the "Hop limit" field (TTL).
vincent@3852
   126
     * \param limit the 8-bit value
vincent@3852
   127
     */
vincent@3852
   128
    void SetHopLimit (uint8_t limit);
vincent@3852
   129
vincent@3852
   130
    /**
vincent@3852
   131
     * \brief Get the "Hop limit" field (TTL).
vincent@3852
   132
     * \return the hop limit value
vincent@3852
   133
     */
vincent@3852
   134
    uint8_t GetHopLimit (void) const;
vincent@3852
   135
vincent@3852
   136
    /**
vincent@3852
   137
     * \brief Set the "Source address" field.
vincent@3852
   138
     * \param src the source address
vincent@3852
   139
     */
vincent@3852
   140
    void SetSourceAddress (Ipv6Address src);
vincent@3852
   141
vincent@3852
   142
    /**
vincent@3852
   143
     * \brief Get the "Source address" field.
vincent@3852
   144
     * \return the source address
vincent@3852
   145
     */
vincent@3852
   146
    Ipv6Address GetSourceAddress (void) const;
vincent@3852
   147
vincent@3852
   148
    /**
vincent@3852
   149
     * \brief Set the "Destination address" field.
vincent@3852
   150
     * \param dst the destination address
vincent@3852
   151
     */
vincent@3852
   152
    void SetDestinationAddress (Ipv6Address dst);
vincent@3852
   153
vincent@3852
   154
    /**
vincent@3852
   155
     * \brief Get the "Destination address" field.
vincent@3852
   156
     * \return the destination address
vincent@3852
   157
     */
vincent@3852
   158
    Ipv6Address GetDestinationAddress (void) const;
vincent@3852
   159
vincent@3852
   160
    /**
vincent@3852
   161
     * \brief Get the name.
vincent@3852
   162
     * \return the name
vincent@3852
   163
     */
vincent@3852
   164
    std::string GetName (void) const;
vincent@3852
   165
vincent@3852
   166
    /**
vincent@3852
   167
     * \brief Print some informations about the packet.
vincent@3852
   168
     * \param os output stream
vincent@3852
   169
     * \return info about this packet
vincent@3852
   170
     */
vincent@3852
   171
    virtual void Print (std::ostream& os) const;
vincent@3852
   172
vincent@3852
   173
    /**
vincent@3852
   174
     * \brief Get the serialized size of the packet.
vincent@3852
   175
     * \return size
vincent@3852
   176
     */
vincent@3852
   177
    virtual uint32_t GetSerializedSize (void) const;
vincent@3852
   178
vincent@3852
   179
    /**
vincent@3852
   180
     * \brief Serialize the packet.
vincent@3852
   181
     * \param start Buffer iterator
vincent@3852
   182
     */
vincent@3852
   183
    virtual void Serialize (Buffer::Iterator start) const;
vincent@3852
   184
vincent@3852
   185
    /**
vincent@3852
   186
     * \brief Deserialize the packet.
vincent@3852
   187
     * \param start Buffer iterator
vincent@3852
   188
     * \return size of the packet
vincent@3852
   189
     */
vincent@3852
   190
    virtual uint32_t Deserialize (Buffer::Iterator start);
vincent@3852
   191
vincent@3852
   192
  private:
vincent@3852
   193
    /**
vincent@3852
   194
     * \brief The version (always equal to 6).
vincent@3852
   195
     */
vincent@3852
   196
    uint32_t m_version : 4;
vincent@3852
   197
    /**
vincent@3852
   198
     * \brief The traffic class.
vincent@3852
   199
     */
vincent@3852
   200
    uint32_t m_trafficClass : 8;
vincent@3852
   201
vincent@3852
   202
    /**
vincent@3852
   203
     * \brief The flow label.
vincent@3852
   204
     * \note This is 20-bit value.
vincent@3852
   205
     */
vincent@3852
   206
    uint32_t m_flowLabel : 20;
vincent@3852
   207
vincent@3852
   208
    /**
vincent@3852
   209
     * \brief The payload length.
vincent@3852
   210
     */
vincent@3852
   211
    uint16_t m_payloadLength;
vincent@3852
   212
vincent@3852
   213
    /**
vincent@3852
   214
     * \brief The Next header number.
vincent@3852
   215
     */
vincent@3852
   216
    uint8_t m_nextHeader;
vincent@3852
   217
vincent@3852
   218
    /**
vincent@3852
   219
     * \brief The Hop limit value.
vincent@3852
   220
     */
vincent@3852
   221
    uint8_t m_hopLimit;
vincent@3852
   222
vincent@3852
   223
    /**
vincent@3852
   224
     * \brief The source address.
vincent@3852
   225
     */
vincent@3852
   226
    Ipv6Address m_sourceAddress;
vincent@3852
   227
vincent@3852
   228
    /**
vincent@3852
   229
     * \brief The destination address.
vincent@3852
   230
     */
vincent@3852
   231
    Ipv6Address m_destinationAddress;
vincent@3852
   232
};
vincent@3852
   233
vincent@3852
   234
} /* namespace ns3 */
vincent@3852
   235
vincent@3852
   236
#endif /* IPV6_HEADER_H */
vincent@3852
   237