src/internet/model/icmpv4.cc
author Natale Patriciello <natale.patriciello@gmail.com>
Fri, 16 Oct 2015 10:43:36 -0700
changeset 11715 e4f633dc1140
parent 11259 ea2f6a3ed14e
permissions -rw-r--r--
Added a GeneralTest class for TCP The class provides a general infrastructure for a TCP-related test, setting up the environment (two sockets connected through SimpleNetDevice over SimpleChannel) and provides the basic management of parameters (like segment size).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7385
10beb0e53130 standardize emacs c++ mode comments
Vedran Mileti? <rivanvx@gmail.com>
parents: 7176
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
4575
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
     2
/*
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
     3
 * Copyright (c) 2008 INRIA
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
     4
 *
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
     7
 * published by the Free Software Foundation;
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
     8
 *
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
    12
 * GNU General Public License for more details.
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
    13
 *
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
    14
 * You should have received a copy of the GNU General Public License
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
    15
 * along with this program; if not, write to the Free Software
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
    17
 *
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
    19
 */
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
    20
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    21
#include "icmpv4.h"
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    22
#include "ns3/packet.h"
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
    23
#include "ns3/log.h"
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
    24
10968
2d29fee2b7b8 [Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10652
diff changeset
    25
namespace ns3 {
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    26
10968
2d29fee2b7b8 [Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10652
diff changeset
    27
NS_LOG_COMPONENT_DEFINE ("Icmpv4Header");
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    28
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    29
/********************************************************
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    30
 *        Icmpv4Header
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    31
 ********************************************************/
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    32
10652
dc18deba4502 [doxygen] Revert r10410, r10411, r10412
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10410
diff changeset
    33
NS_OBJECT_ENSURE_REGISTERED (Icmpv4Header);
6301
58799c1b94b0 register icmpv4 objects
Josh Pelkey <jpelkey@gatech.edu>
parents: 4575
diff changeset
    34
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    35
TypeId 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    36
Icmpv4Header::GetTypeId (void)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    37
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    38
  static TypeId tid = TypeId ("ns3::Icmpv4Header")
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    39
    .SetParent<Header> ()
11259
ea2f6a3ed14e SetGroupName for internet module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10968
diff changeset
    40
    .SetGroupName ("Internet")
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    41
    .AddConstructor<Icmpv4Header> ()
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
    42
  ;
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    43
  return tid;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    44
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    45
Icmpv4Header::Icmpv4Header ()
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    46
  : m_type (0),
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    47
    m_code (0),
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    48
    m_calcChecksum (false)
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
    49
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
    50
  NS_LOG_FUNCTION (this);
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
    51
}
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    52
Icmpv4Header::~Icmpv4Header ()
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
    53
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
    54
  NS_LOG_FUNCTION (this);
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
    55
}
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
    56
void
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    57
Icmpv4Header::EnableChecksum (void)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    58
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
    59
  NS_LOG_FUNCTION (this);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    60
  m_calcChecksum = true;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    61
}
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
    62
TypeId
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    63
Icmpv4Header::GetInstanceTypeId (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    64
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
    65
  NS_LOG_FUNCTION (this);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    66
  return GetTypeId ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    67
}
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
    68
uint32_t
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    69
Icmpv4Header::GetSerializedSize (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    70
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
    71
  NS_LOG_FUNCTION (this);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    72
  return 4;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    73
}
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
    74
void
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    75
Icmpv4Header::Serialize (Buffer::Iterator start) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    76
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
    77
  NS_LOG_FUNCTION (this << &start);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    78
  Buffer::Iterator i = start;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    79
  i.WriteU8 (m_type);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    80
  i.WriteU8 (m_code);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    81
  i.WriteHtonU16 (0);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    82
  if (m_calcChecksum)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    83
    {
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    84
      i = start;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    85
      uint16_t checksum = i.CalculateIpChecksum (i.GetSize ());
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    86
      i = start;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    87
      i.Next (2);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    88
      i.WriteU16 (checksum);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    89
    }
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
    90
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    91
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    92
uint32_t 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    93
Icmpv4Header::Deserialize (Buffer::Iterator start)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    94
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
    95
  NS_LOG_FUNCTION (this << &start);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    96
  m_type = start.ReadU8 ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    97
  m_code = start.ReadU8 ();
7061
15f40cfaf3b3 build fixes for gcc 4.6
Andrey Mazo <mazo@iitp.ru>
parents: 6834
diff changeset
    98
  start.Next (2); // uint16_t checksum = start.ReadNtohU16 ();
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    99
  return 4;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   100
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   101
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   102
Icmpv4Header::Print (std::ostream &os) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   103
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   104
  NS_LOG_FUNCTION (this << &os);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   105
  os << "type=" << (uint32_t)m_type << ", code=" << (uint32_t)m_code;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   106
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   107
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   108
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   109
Icmpv4Header::SetType (uint8_t type)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   110
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   111
  NS_LOG_FUNCTION (this << static_cast<uint32_t> (type));
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   112
  m_type = type;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   113
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   114
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   115
Icmpv4Header::SetCode (uint8_t code)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   116
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   117
  NS_LOG_FUNCTION (this << static_cast<uint32_t> (code));
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   118
  m_code = code;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   119
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   120
uint8_t 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   121
Icmpv4Header::GetType (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   122
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   123
  NS_LOG_FUNCTION (this);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   124
  return m_type;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   125
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   126
uint8_t 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   127
Icmpv4Header::GetCode (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   128
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   129
  NS_LOG_FUNCTION (this); 
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   130
  return m_code;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   131
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   132
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   133
/********************************************************
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   134
 *        Icmpv4Echo
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   135
 ********************************************************/
6301
58799c1b94b0 register icmpv4 objects
Josh Pelkey <jpelkey@gatech.edu>
parents: 4575
diff changeset
   136
10652
dc18deba4502 [doxygen] Revert r10410, r10411, r10412
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10410
diff changeset
   137
NS_OBJECT_ENSURE_REGISTERED (Icmpv4Echo);
6301
58799c1b94b0 register icmpv4 objects
Josh Pelkey <jpelkey@gatech.edu>
parents: 4575
diff changeset
   138
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   139
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   140
Icmpv4Echo::SetIdentifier (uint16_t id)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   141
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   142
  NS_LOG_FUNCTION (this << id); 
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   143
  m_identifier = id;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   144
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   145
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   146
Icmpv4Echo::SetSequenceNumber (uint16_t seq)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   147
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   148
  NS_LOG_FUNCTION (this << seq);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   149
  m_sequence = seq;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   150
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   151
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   152
Icmpv4Echo::SetData (Ptr<const Packet> data)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   153
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   154
  NS_LOG_FUNCTION (this << *data);
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   155
  
4575
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   156
  uint32_t size = data->GetSize ();
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   157
  //
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   158
  // All kinds of optimizations are possible, but let's not get carried away
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   159
  // since this is probably a very uncommon thing in the big picture.
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   160
  //
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   161
  // N.B. Zero is a legal size for the alloc below even though a hardcoded zero
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   162
  // would result in  warning.
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   163
  //
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   164
  if (size != m_dataSize)
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   165
    {
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   166
      delete [] m_data;
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   167
      m_data = new uint8_t[size];
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   168
      m_dataSize = size;
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   169
    }
4521
981e2f0b696b no need to keep around a Ptr<Packet>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   170
  data->CopyData (m_data, size);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   171
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   172
uint16_t 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   173
Icmpv4Echo::GetIdentifier (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   174
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   175
  NS_LOG_FUNCTION (this);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   176
  return m_identifier;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   177
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   178
uint16_t 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   179
Icmpv4Echo::GetSequenceNumber (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   180
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   181
  NS_LOG_FUNCTION (this);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   182
  return m_sequence;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   183
}
4521
981e2f0b696b no need to keep around a Ptr<Packet>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   184
uint32_t
4575
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   185
Icmpv4Echo::GetDataSize (void) const
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   186
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   187
  NS_LOG_FUNCTION (this);
4521
981e2f0b696b no need to keep around a Ptr<Packet>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   188
  return m_dataSize;
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   189
}
4575
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   190
uint32_t
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   191
Icmpv4Echo::GetData (uint8_t payload[]) const
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   192
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   193
  NS_LOG_FUNCTION (this << payload);
4575
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   194
  memcpy (payload, m_data, m_dataSize);
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   195
  return m_dataSize;
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   196
}
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   197
TypeId 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   198
Icmpv4Echo::GetTypeId (void)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   199
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   200
  static TypeId tid = TypeId ("ns3::Icmpv4Echo")
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   201
    .SetParent<Header> ()
11259
ea2f6a3ed14e SetGroupName for internet module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10968
diff changeset
   202
    .SetGroupName ("Internet")
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   203
    .AddConstructor<Icmpv4Echo> ()
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   204
  ;
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   205
  return tid;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   206
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   207
Icmpv4Echo::Icmpv4Echo ()
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   208
  : m_identifier (0),
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   209
    m_sequence (0),
4521
981e2f0b696b no need to keep around a Ptr<Packet>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   210
    m_dataSize (0)
981e2f0b696b no need to keep around a Ptr<Packet>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   211
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   212
  NS_LOG_FUNCTION (this);
4575
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   213
  //
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   214
  // After construction, m_data is always valid until destruction.  This is true
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   215
  // even if m_dataSize is zero.
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   216
  //
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   217
  m_data = new uint8_t[m_dataSize];
4521
981e2f0b696b no need to keep around a Ptr<Packet>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   218
}
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   219
Icmpv4Echo::~Icmpv4Echo ()
4575
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   220
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   221
  NS_LOG_FUNCTION (this);
4575
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   222
  delete [] m_data;
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   223
  m_data = 0;
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   224
  m_dataSize = 0;
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   225
}
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   226
TypeId 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   227
Icmpv4Echo::GetInstanceTypeId (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   228
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   229
  NS_LOG_FUNCTION (this);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   230
  return GetTypeId ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   231
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   232
uint32_t 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   233
Icmpv4Echo::GetSerializedSize (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   234
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   235
  NS_LOG_FUNCTION (this);
4521
981e2f0b696b no need to keep around a Ptr<Packet>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   236
  return 4 + m_dataSize;
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   237
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   238
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   239
Icmpv4Echo::Serialize (Buffer::Iterator start) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   240
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   241
  NS_LOG_FUNCTION (this << &start);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   242
  start.WriteHtonU16 (m_identifier);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   243
  start.WriteHtonU16 (m_sequence);
4521
981e2f0b696b no need to keep around a Ptr<Packet>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   244
  start.Write (m_data, m_dataSize);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   245
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   246
uint32_t 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   247
Icmpv4Echo::Deserialize (Buffer::Iterator start)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   248
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   249
  NS_LOG_FUNCTION (this << &start);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   250
  m_identifier = start.ReadNtohU16 ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   251
  m_sequence = start.ReadNtohU16 ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   252
  NS_ASSERT (start.GetSize () >= 4);
4575
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   253
  uint32_t size = start.GetSize () - 4;
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   254
  if (size != m_dataSize)
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   255
    {
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   256
      delete [] m_data;
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   257
      m_data = new uint8_t[size];
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   258
      m_dataSize = size;
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   259
    }
4521
981e2f0b696b no need to keep around a Ptr<Packet>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   260
  start.Read (m_data, m_dataSize);
4575
ee3191a0b560 variable size buffer for icmpv4 echo header
Craig Dowell <craigdo@ee.washington.edu>
parents: 4521
diff changeset
   261
  return m_dataSize;
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   262
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   263
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   264
Icmpv4Echo::Print (std::ostream &os) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   265
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   266
  NS_LOG_FUNCTION (this << &os);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   267
  os << "identifier=" << m_identifier << ", sequence="  << m_sequence;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   268
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   269
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   270
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   271
/********************************************************
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   272
 *        Icmpv4DestinationUnreachable
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   273
 ********************************************************/
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   274
10652
dc18deba4502 [doxygen] Revert r10410, r10411, r10412
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10410
diff changeset
   275
NS_OBJECT_ENSURE_REGISTERED (Icmpv4DestinationUnreachable);
6301
58799c1b94b0 register icmpv4 objects
Josh Pelkey <jpelkey@gatech.edu>
parents: 4575
diff changeset
   276
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   277
TypeId 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   278
Icmpv4DestinationUnreachable::GetTypeId (void)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   279
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   280
  static TypeId tid = TypeId ("ns3::Icmpv4DestinationUnreachable")
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   281
    .SetParent<Header> ()
11259
ea2f6a3ed14e SetGroupName for internet module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10968
diff changeset
   282
    .SetGroupName ("Internet")
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   283
    .AddConstructor<Icmpv4DestinationUnreachable> ()
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   284
  ;
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   285
  return tid;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   286
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   287
Icmpv4DestinationUnreachable::Icmpv4DestinationUnreachable ()
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   288
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   289
  NS_LOG_FUNCTION (this);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   290
  // make sure that thing is initialized to get initialized bytes
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   291
  // when the ip payload's size is smaller than 8 bytes.
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   292
  for (uint8_t j = 0; j < 8; j++)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   293
    {
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   294
      m_data[j] = 0;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   295
    }
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   296
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   297
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   298
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   299
Icmpv4DestinationUnreachable::SetNextHopMtu (uint16_t mtu)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   300
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   301
  NS_LOG_FUNCTION (this << mtu);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   302
  m_nextHopMtu = mtu;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   303
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   304
uint16_t 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   305
Icmpv4DestinationUnreachable::GetNextHopMtu (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   306
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   307
  NS_LOG_FUNCTION (this);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   308
  return m_nextHopMtu;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   309
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   310
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   311
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   312
Icmpv4DestinationUnreachable::SetData (Ptr<const Packet> data)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   313
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   314
  NS_LOG_FUNCTION (this << *data);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   315
  data->CopyData (m_data, 8);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   316
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   317
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   318
Icmpv4DestinationUnreachable::SetHeader (Ipv4Header header)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   319
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   320
  NS_LOG_FUNCTION (this << header);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   321
  m_header = header;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   322
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   323
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   324
Icmpv4DestinationUnreachable::GetData (uint8_t payload[8]) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   325
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   326
  NS_LOG_FUNCTION (this << payload);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   327
  memcpy (payload, m_data, 8);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   328
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   329
Ipv4Header 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   330
Icmpv4DestinationUnreachable::GetHeader (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   331
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   332
  NS_LOG_FUNCTION (this);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   333
  return m_header;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   334
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   335
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   336
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   337
Icmpv4DestinationUnreachable::~Icmpv4DestinationUnreachable ()
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   338
{
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   339
}
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   340
TypeId
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   341
Icmpv4DestinationUnreachable::GetInstanceTypeId (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   342
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   343
  NS_LOG_FUNCTION (this);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   344
  return GetTypeId ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   345
}
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   346
uint32_t
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   347
Icmpv4DestinationUnreachable::GetSerializedSize (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   348
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   349
  NS_LOG_FUNCTION (this);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   350
  return 4 + m_header.GetSerializedSize () + 8;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   351
}
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   352
void
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   353
Icmpv4DestinationUnreachable::Serialize (Buffer::Iterator start) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   354
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   355
  NS_LOG_FUNCTION (this << &start);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   356
  start.WriteU16 (0);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   357
  start.WriteHtonU16 (m_nextHopMtu);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   358
  uint32_t size = m_header.GetSerializedSize ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   359
  m_header.Serialize (start);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   360
  start.Next (size);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   361
  start.Write (m_data, 8);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   362
}
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   363
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   364
uint32_t 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   365
Icmpv4DestinationUnreachable::Deserialize (Buffer::Iterator start)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   366
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   367
  NS_LOG_FUNCTION (this << &start);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   368
  Buffer::Iterator i = start;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   369
  i.Next (2);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   370
  m_nextHopMtu = i.ReadNtohU16 ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   371
  uint32_t read = m_header.Deserialize (i);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   372
  i.Next (read);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   373
  for (uint8_t j = 0; j < 8; j++)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   374
    {
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   375
      m_data[j] = i.ReadU8 ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   376
    }
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   377
  return i.GetDistanceFrom (start);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   378
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   379
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   380
Icmpv4DestinationUnreachable::Print (std::ostream &os) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   381
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   382
  NS_LOG_FUNCTION (this << &os);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   383
  m_header.Print (os);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   384
  os << " org data=";
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   385
  for (uint8_t i = 0; i < 8; i++)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   386
    {
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   387
      os << (uint32_t) m_data[i];
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   388
      if (i != 8)
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   389
        {
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   390
          os << " ";
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   391
        }
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   392
    }
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   393
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   394
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   395
/********************************************************
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   396
 *        Icmpv4TimeExceeded
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   397
 ********************************************************/
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   398
10652
dc18deba4502 [doxygen] Revert r10410, r10411, r10412
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10410
diff changeset
   399
NS_OBJECT_ENSURE_REGISTERED (Icmpv4TimeExceeded);
6301
58799c1b94b0 register icmpv4 objects
Josh Pelkey <jpelkey@gatech.edu>
parents: 4575
diff changeset
   400
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   401
TypeId 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   402
Icmpv4TimeExceeded::GetTypeId (void)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   403
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   404
  static TypeId tid = TypeId ("ns3::Icmpv4TimeExceeded")
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   405
    .SetParent<Header> ()
11259
ea2f6a3ed14e SetGroupName for internet module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10968
diff changeset
   406
    .SetGroupName ("Internet")
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   407
    .AddConstructor<Icmpv4TimeExceeded> ()
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   408
  ;
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   409
  return tid;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   410
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   411
Icmpv4TimeExceeded::Icmpv4TimeExceeded ()
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   412
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   413
  NS_LOG_FUNCTION (this);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   414
  // make sure that thing is initialized to get initialized bytes
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   415
  // when the ip payload's size is smaller than 8 bytes.
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   416
  for (uint8_t j = 0; j < 8; j++)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   417
    {
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   418
      m_data[j] = 0;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   419
    }
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   420
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   421
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   422
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   423
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   424
Icmpv4TimeExceeded::SetData (Ptr<const Packet> data)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   425
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   426
  NS_LOG_FUNCTION (this << *data);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   427
  data->CopyData (m_data, 8);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   428
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   429
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   430
Icmpv4TimeExceeded::SetHeader (Ipv4Header header)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   431
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   432
  NS_LOG_FUNCTION (this << header);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   433
  m_header = header;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   434
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   435
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   436
Icmpv4TimeExceeded::GetData (uint8_t payload[8]) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   437
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   438
  NS_LOG_FUNCTION (this << payload);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   439
  memcpy (payload, m_data, 8);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   440
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   441
Ipv4Header 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   442
Icmpv4TimeExceeded::GetHeader (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   443
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   444
  NS_LOG_FUNCTION (this);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   445
  return m_header;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   446
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   447
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   448
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   449
Icmpv4TimeExceeded::~Icmpv4TimeExceeded ()
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   450
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   451
  NS_LOG_FUNCTION (this);
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   452
}
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   453
TypeId
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   454
Icmpv4TimeExceeded::GetInstanceTypeId (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   455
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   456
  NS_LOG_FUNCTION (this);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   457
  return GetTypeId ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   458
}
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   459
uint32_t
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   460
Icmpv4TimeExceeded::GetSerializedSize (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   461
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   462
  NS_LOG_FUNCTION (this);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   463
  return 4 + m_header.GetSerializedSize () + 8;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   464
}
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   465
void
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   466
Icmpv4TimeExceeded::Serialize (Buffer::Iterator start) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   467
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   468
  NS_LOG_FUNCTION (this << &start);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   469
  start.WriteU32 (0);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   470
  uint32_t size = m_header.GetSerializedSize ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   471
  m_header.Serialize (start);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   472
  start.Next (size);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   473
  start.Write (m_data, 8);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   474
}
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   475
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   476
uint32_t 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   477
Icmpv4TimeExceeded::Deserialize (Buffer::Iterator start)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   478
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   479
  NS_LOG_FUNCTION (this << &start);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   480
  Buffer::Iterator i = start;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   481
  i.Next (4);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   482
  uint32_t read = m_header.Deserialize (i);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   483
  i.Next (read);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   484
  for (uint8_t j = 0; j < 8; j++)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   485
    {
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   486
      m_data[j] = i.ReadU8 ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   487
    }
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   488
  return i.GetDistanceFrom (start);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   489
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   490
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   491
Icmpv4TimeExceeded::Print (std::ostream &os) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   492
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenkovi? <k.lenkovic@me.com>
parents: 7385
diff changeset
   493
  NS_LOG_FUNCTION (this << &os);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   494
  m_header.Print (os);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   495
  os << " org data=";
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   496
  for (uint8_t i = 0; i < 8; i++)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   497
    {
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   498
      os << (uint32_t) m_data[i];
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   499
      if (i != 8)
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   500
        {
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   501
          os << " ";
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7061
diff changeset
   502
        }
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   503
    }
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   504
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   505
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   506
} // namespace ns3