src/node/internet-node.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 02 May 2007 09:10:19 +0200
changeset 465 7f620ea278f4
parent 451 3fe2c883cb47
child 468 121f7c328e35
permissions -rw-r--r--
merge in raj's dispose early work
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*-
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
//
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
// Copyright (c) 2006 Georgia Tech Research Corporation
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
// All rights reserved.
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
//
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
// This program is free software; you can redistribute it and/or modify
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
// it under the terms of the GNU General Public License version 2 as
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
// published by the Free Software Foundation;
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
//
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
// This program is distributed in the hope that it will be useful,
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
// GNU General Public License for more details.
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
//
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
// You should have received a copy of the GNU General Public License
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
// along with this program; if not, write to the Free Software
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
//
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
// Author: George F. Riley<riley@ece.gatech.edu>
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
//
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
// Implementation of the InternetNode class for ns3.
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
// George F. Riley, Georgia Tech, Fall 2006
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 341
diff changeset
    24
#include "ns3/composite-trace-resolver.h"
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 341
diff changeset
    25
381
83b52d112c99 Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents: 359
diff changeset
    26
#include "application-list.h"
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
#include "l3-demux.h"
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
#include "ipv4-l4-demux.h"
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
#include "internet-node.h"
240
7da682f99bf9 add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 234
diff changeset
    30
#include "udp.h"
7da682f99bf9 add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 234
diff changeset
    31
#include "ipv4.h"
242
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    32
#include "arp.h"
451
3fe2c883cb47 add NetDevice::SetReceiveCallback and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 449
diff changeset
    33
#include "net-device.h"
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
namespace ns3 {
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
359
91b7ad7fa784 OnOffApplication functioning; some Node class cleanup
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    37
static class NodeStackInitializationClass {
91b7ad7fa784 OnOffApplication functioning; some Node class cleanup
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    38
public:
91b7ad7fa784 OnOffApplication functioning; some Node class cleanup
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    39
  NodeStackInitializationClass () {
91b7ad7fa784 OnOffApplication functioning; some Node class cleanup
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    40
    Node::PushNodePrototype (InternetNode ());
91b7ad7fa784 OnOffApplication functioning; some Node class cleanup
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    41
  }
91b7ad7fa784 OnOffApplication functioning; some Node class cleanup
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    42
} node_stack_initialization_class;
91b7ad7fa784 OnOffApplication functioning; some Node class cleanup
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    43
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
InternetNode::InternetNode()
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
{
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
  // Instantiate the capabilities
381
83b52d112c99 Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents: 359
diff changeset
    47
  m_applicationList = new ApplicationList();
241
9004ab4cfe17 add Ipv4 and Udp node capabilities, rework Copy methods to include an extra Node * argument
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 240
diff changeset
    48
  m_l3Demux = new L3Demux(this);
9004ab4cfe17 add Ipv4 and Udp node capabilities, rework Copy methods to include an extra Node * argument
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 240
diff changeset
    49
  m_ipv4L4Demux = new Ipv4L4Demux(this);
293
007bc9e735f3 remove Ipv4L3Protocol class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 251
diff changeset
    50
  m_l3Demux->Insert (Ipv4 (this));
294
aba9a34108d2 remove ArpL3Protocol object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 293
diff changeset
    51
  m_l3Demux->Insert (Arp (this));
295
5fc7ae0d0300 remove UdpIpv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 294
diff changeset
    52
  m_ipv4L4Demux->Insert (Udp (this));
242
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    53
}
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    54
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    55
InternetNode::InternetNode (InternetNode const &o)
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    56
{
381
83b52d112c99 Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents: 359
diff changeset
    57
  m_applicationList = new ApplicationList();
242
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    58
  m_l3Demux = o.m_l3Demux->Copy (this);
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    59
  m_ipv4L4Demux = o.m_ipv4L4Demux->Copy (this);
335
d8b5e567fc50 add operator = to InternetNode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 308
diff changeset
    60
}
d8b5e567fc50 add operator = to InternetNode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 308
diff changeset
    61
InternetNode const &
d8b5e567fc50 add operator = to InternetNode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 308
diff changeset
    62
InternetNode::operator = (InternetNode const &o)
d8b5e567fc50 add operator = to InternetNode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 308
diff changeset
    63
{
381
83b52d112c99 Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents: 359
diff changeset
    64
  delete m_applicationList;
335
d8b5e567fc50 add operator = to InternetNode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 308
diff changeset
    65
  delete m_l3Demux;
d8b5e567fc50 add operator = to InternetNode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 308
diff changeset
    66
  delete m_ipv4L4Demux;
d8b5e567fc50 add operator = to InternetNode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 308
diff changeset
    67
  m_l3Demux = o.m_l3Demux->Copy (this);
d8b5e567fc50 add operator = to InternetNode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 308
diff changeset
    68
  m_ipv4L4Demux = o.m_ipv4L4Demux->Copy (this);
d8b5e567fc50 add operator = to InternetNode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 308
diff changeset
    69
  return *this;
247
fb7375bb43d7 make the sample code compile and link.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
    70
}
fb7375bb43d7 make the sample code compile and link.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
    71
248
a912210e52ac fix memory leaks for simple sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 247
diff changeset
    72
InternetNode::~InternetNode ()
a912210e52ac fix memory leaks for simple sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 247
diff changeset
    73
{
381
83b52d112c99 Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents: 359
diff changeset
    74
  delete m_applicationList;
248
a912210e52ac fix memory leaks for simple sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 247
diff changeset
    75
  delete m_l3Demux;
a912210e52ac fix memory leaks for simple sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 247
diff changeset
    76
  delete m_ipv4L4Demux;
a912210e52ac fix memory leaks for simple sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 247
diff changeset
    77
}
a912210e52ac fix memory leaks for simple sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 247
diff changeset
    78
308
768db459baaa Added tracing support to simple.tcl.cc (Craig)
tomh@ubuntu
parents: 295
diff changeset
    79
  void
768db459baaa Added tracing support to simple.tcl.cc (Craig)
tomh@ubuntu
parents: 295
diff changeset
    80
InternetNode::SetName (std::string name)
768db459baaa Added tracing support to simple.tcl.cc (Craig)
tomh@ubuntu
parents: 295
diff changeset
    81
{
768db459baaa Added tracing support to simple.tcl.cc (Craig)
tomh@ubuntu
parents: 295
diff changeset
    82
  m_name = name;
768db459baaa Added tracing support to simple.tcl.cc (Craig)
tomh@ubuntu
parents: 295
diff changeset
    83
}
768db459baaa Added tracing support to simple.tcl.cc (Craig)
tomh@ubuntu
parents: 295
diff changeset
    84
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    85
// Copy this node
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    86
InternetNode* 
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    87
InternetNode::Copy() const
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    88
{
242
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    89
  InternetNode *copy = new InternetNode (*this);
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    90
   return copy;
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
}
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 341
diff changeset
    93
TraceResolver *
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 341
diff changeset
    94
InternetNode::CreateTraceResolver (TraceContext const &context)
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 341
diff changeset
    95
{
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 341
diff changeset
    96
  CompositeTraceResolver *resolver = new CompositeTraceResolver (context);
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 341
diff changeset
    97
  resolver->Add ("ipv4",
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 341
diff changeset
    98
                 MakeCallback (&Ipv4::CreateTraceResolver, GetIpv4 ()),
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 341
diff changeset
    99
                 InternetNode::IPV4);
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 341
diff changeset
   100
  resolver->Add ("arp",
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 341
diff changeset
   101
                 MakeCallback (&Arp::CreateTraceResolver, GetArp ()),
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 341
diff changeset
   102
                 InternetNode::ARP);
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 341
diff changeset
   103
  resolver->Add ("udp",
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 341
diff changeset
   104
                 MakeCallback (&Udp::CreateTraceResolver, GetUdp ()),
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 341
diff changeset
   105
                 InternetNode::UDP);
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 341
diff changeset
   106
  return resolver;
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 341
diff changeset
   107
}
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 341
diff changeset
   108
465
7f620ea278f4 merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 451
diff changeset
   109
void InternetNode::Dispose()
7f620ea278f4 merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 451
diff changeset
   110
{
7f620ea278f4 merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 451
diff changeset
   111
  for(uint32_t i=0;i<GetNDevices();++i)
7f620ea278f4 merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 451
diff changeset
   112
    GetDevice(i)->Dispose();
7f620ea278f4 merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 451
diff changeset
   113
  
7f620ea278f4 merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 451
diff changeset
   114
}
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   115
381
83b52d112c99 Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents: 359
diff changeset
   116
ApplicationList* 
83b52d112c99 Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents: 359
diff changeset
   117
InternetNode::GetApplicationList() const
83b52d112c99 Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents: 359
diff changeset
   118
{ 
83b52d112c99 Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents: 359
diff changeset
   119
  return m_applicationList;
83b52d112c99 Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents: 359
diff changeset
   120
} 
83b52d112c99 Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents: 359
diff changeset
   121
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   122
L3Demux*     
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   123
InternetNode::GetL3Demux() const
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   124
{
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   125
  return m_l3Demux;
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
}
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   127
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   128
Ipv4L4Demux*     
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   129
InternetNode::GetIpv4L4Demux() const
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   130
{
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   131
  return m_ipv4L4Demux;
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   132
}
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   133
247
fb7375bb43d7 make the sample code compile and link.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   134
Ipv4 *
fb7375bb43d7 make the sample code compile and link.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   135
InternetNode::GetIpv4 (void) const
fb7375bb43d7 make the sample code compile and link.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   136
{
293
007bc9e735f3 remove Ipv4L3Protocol class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 251
diff changeset
   137
  return static_cast<Ipv4*> (m_l3Demux->Lookup (Ipv4::PROT_NUMBER));
247
fb7375bb43d7 make the sample code compile and link.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   138
}
fb7375bb43d7 make the sample code compile and link.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   139
Udp *
fb7375bb43d7 make the sample code compile and link.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   140
InternetNode::GetUdp (void) const
fb7375bb43d7 make the sample code compile and link.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   141
{
295
5fc7ae0d0300 remove UdpIpv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 294
diff changeset
   142
  return static_cast<Udp*> (m_ipv4L4Demux->Lookup (Udp::PROT_NUMBER));
247
fb7375bb43d7 make the sample code compile and link.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   143
}
fb7375bb43d7 make the sample code compile and link.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   144
fb7375bb43d7 make the sample code compile and link.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   145
Arp *
fb7375bb43d7 make the sample code compile and link.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   146
InternetNode::GetArp (void) const
fb7375bb43d7 make the sample code compile and link.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   147
{
294
aba9a34108d2 remove ArpL3Protocol object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 293
diff changeset
   148
  return static_cast<Arp*> (m_l3Demux->Lookup (Arp::PROT_NUMBER));
247
fb7375bb43d7 make the sample code compile and link.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   149
}
fb7375bb43d7 make the sample code compile and link.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   150
447
180117abfb04 add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 444
diff changeset
   151
void 
180117abfb04 add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 444
diff changeset
   152
InternetNode::DoAddDevice (NetDevice *device) const
180117abfb04 add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 444
diff changeset
   153
{
451
3fe2c883cb47 add NetDevice::SetReceiveCallback and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 449
diff changeset
   154
  device->SetReceiveCallback (MakeCallback (&InternetNode::ReceiveFromDevice, this));
3fe2c883cb47 add NetDevice::SetReceiveCallback and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 449
diff changeset
   155
}
3fe2c883cb47 add NetDevice::SetReceiveCallback and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 449
diff changeset
   156
3fe2c883cb47 add NetDevice::SetReceiveCallback and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 449
diff changeset
   157
bool
3fe2c883cb47 add NetDevice::SetReceiveCallback and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 449
diff changeset
   158
InternetNode::ReceiveFromDevice (NetDevice *device, const Packet &p, uint16_t protocolNumber) const
3fe2c883cb47 add NetDevice::SetReceiveCallback and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 449
diff changeset
   159
{
3fe2c883cb47 add NetDevice::SetReceiveCallback and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 449
diff changeset
   160
  L3Protocol *target = GetL3Demux()->Lookup(protocolNumber);
3fe2c883cb47 add NetDevice::SetReceiveCallback and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 449
diff changeset
   161
  if (target != 0) 
3fe2c883cb47 add NetDevice::SetReceiveCallback and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 449
diff changeset
   162
    {
3fe2c883cb47 add NetDevice::SetReceiveCallback and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 449
diff changeset
   163
      Packet packet = p;
3fe2c883cb47 add NetDevice::SetReceiveCallback and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 449
diff changeset
   164
      target->Receive(packet, *device);
3fe2c883cb47 add NetDevice::SetReceiveCallback and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 449
diff changeset
   165
      return true;
3fe2c883cb47 add NetDevice::SetReceiveCallback and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 449
diff changeset
   166
    }
3fe2c883cb47 add NetDevice::SetReceiveCallback and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 449
diff changeset
   167
  return false;
447
180117abfb04 add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 444
diff changeset
   168
}
180117abfb04 add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 444
diff changeset
   169
247
fb7375bb43d7 make the sample code compile and link.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   170
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   171
}//namespace ns3