src/node/ipv4-header.h
author Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
Tue, 01 Jul 2008 10:52:11 -0700
changeset 3363 33d1ca2e4ba4
parent 3235 c2f34dac1b9e
permissions -rw-r--r--
bug 236: add optional support for tcp and udp checksum.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2005 INRIA
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 *
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 *
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 *
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 *
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 */
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
#ifndef IPV4_HEADER_H
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#define IPV4_HEADER_H
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
#include "ns3/header.h"
524
082ffdd8fbd7 move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 463
diff changeset
    25
#include "ns3/ipv4-address.h"
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
namespace ns3 {
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    28
/**
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    29
 * \brief Packet header for IPv4
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    30
 */
1126
06484dd65e76 add GetUid methods to all headers and trailers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
    31
class Ipv4Header : public Header 
06484dd65e76 add GetUid methods to all headers and trailers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
    32
{
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
public:
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    34
  /**
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    35
   * \brief Construct a null IPv4 header
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    36
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
  Ipv4Header ();
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    38
  /**
3235
c2f34dac1b9e add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3234
diff changeset
    39
   * \brief Enable checksum calculation for this header.
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    40
   */
3235
c2f34dac1b9e add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3234
diff changeset
    41
  void EnableChecksum (void);
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    42
  /**
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
    43
   * \param size the size of the payload in bytes
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    44
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
  void SetPayloadSize (uint16_t size);
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    46
  /**
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
    47
   * \param identification the Identification field of IPv4 packets.
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
    48
   *
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
    49
   * By default, set to zero.
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    50
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
  void SetIdentification (uint16_t identification);
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    52
  /**
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
    53
   * \param tos the 8 bits of Ipv4 TOS.
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    54
   */
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    55
  void SetTos (uint8_t tos);
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    56
  /**
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
    57
   * This packet is not the last packet of a fragmented ipv4 packet.
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    58
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    59
  void SetMoreFragments (void);
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    60
  /**
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
    61
   * This packet is the last packet of a fragmented ipv4 packet.
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    62
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    63
  void SetLastFragment (void);
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    64
  /**
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
    65
   * Don't fragment this packet: if you need to anyway, drop it.
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    66
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
  void SetDontFragment (void);
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    68
  /**
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
    69
   * If you need to fragment this packet, you can do it.
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    70
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
  void SetMayFragment (void);
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    72
  /**
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
    73
   * \param offset the ipv4 fragment offset
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    74
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
  void SetFragmentOffset (uint16_t offset);
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    76
  /**
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
    77
   * \param ttl the ipv4 TTL
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    78
   */
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    79
  void SetTtl (uint8_t ttl);
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    80
  /**
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
    81
   * \param num the ipv4 protocol field
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    82
   */
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    83
  void SetProtocol (uint8_t num);
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    84
  /**
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
    85
   * \param source the source of this packet
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    86
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    87
  void SetSource (Ipv4Address source);
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    88
  /**
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
    89
   * \param destination the destination of this packet.
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    90
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
  void SetDestination (Ipv4Address destination);
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    92
  /**
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
    93
   * \returns the size of the payload in bytes
632
1e419ebb4012 Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 524
diff changeset
    94
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
  uint16_t GetPayloadSize (void) const;
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
    96
  /**
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
    97
   * \returns the identification field of this packet.
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
    98
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    99
  uint16_t GetIdentification (void) const;
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   100
  /**
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   101
   * \returns the TOS field of this packet.
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   102
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   103
  uint8_t GetTos (void) const;
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   104
  /**
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   105
   * \returns true if this is the last fragment of a packet, false otherwise.
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   106
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   107
  bool IsLastFragment (void) const;
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   108
  /**
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   109
   * \returns true if this is this packet can be fragmented.
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   110
   */  
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   111
  bool IsDontFragment (void) const;
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   112
  /**
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   113
   * \returns the offset of this fragment.
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   114
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   115
  uint16_t GetFragmentOffset (void) const;
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   116
  /**
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   117
   * \returns the TTL field of this packet
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   118
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
  uint8_t GetTtl (void) const;
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   120
  /**
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   121
   * \returns the protocol field of this packet
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   122
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   123
  uint8_t GetProtocol (void) const;
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   124
  /**
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   125
   * \returns the source address of this packet
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   126
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   127
  Ipv4Address GetSource (void) const;
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   128
  /**
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   129
   * \returns the destination address of this packet
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   130
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   131
  Ipv4Address GetDestination (void) const;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   132
  
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   133
  /**
3234
aabbcb2cba71 Add ipv4 header checksum support.
Florian Westphal <fw@strlen.de>
parents: 3216
diff changeset
   134
   * \returns true if the ipv4 checksum is correct, false otherwise.
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   135
   *
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   136
   * If Ipv4Header::EnableChecksums has not been called prior to
3235
c2f34dac1b9e add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3234
diff changeset
   137
   * deserializing this header, this method will always return true.
640
028db47a657f beautify the dox output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 632
diff changeset
   138
   */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   139
  bool IsChecksumOk (void) const;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   140
2646
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   141
  static TypeId GetTypeId (void);
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   142
  virtual TypeId GetInstanceTypeId (void) const;
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   143
  virtual void Print (std::ostream &os) const;
2643
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1232
diff changeset
   144
  virtual uint32_t GetSerializedSize (void) const;
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1232
diff changeset
   145
  virtual void Serialize (Buffer::Iterator start) const;
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1232
diff changeset
   146
  virtual uint32_t Deserialize (Buffer::Iterator start);
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   147
private:
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   148
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   149
  enum FlagsE {
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   150
    DONT_FRAGMENT = (1<<0),
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   151
    MORE_FRAGMENTS = (1<<1)
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   152
  };
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   153
3235
c2f34dac1b9e add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3234
diff changeset
   154
  bool m_calcChecksum;
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   155
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   156
  uint16_t m_payloadSize;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   157
  uint16_t m_identification;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   158
  uint32_t m_tos : 8;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   159
  uint32_t m_ttl : 8;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   160
  uint32_t m_protocol : 8;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   161
  uint32_t m_flags : 3;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   162
  uint16_t m_fragmentOffset : 13;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   163
  Ipv4Address m_source;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   164
  Ipv4Address m_destination;
3363
33d1ca2e4ba4 bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3235
diff changeset
   165
  uint16_t m_checksum;
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   166
  bool m_goodChecksum;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   167
};
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   168
1232
2e8c3f8bb77f remove Chunk base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1151
diff changeset
   169
} // namespace ns3
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   170
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   171
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   172
#endif /* IPV4_HEADER_H */