author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Tue, 28 Aug 2007 14:33:53 +0200 | |
changeset 1383 | 12f30b7defb4 |
parent 1341 | f685d4bf320f |
child 1386 | f2ee41c3e788 |
permissions | -rw-r--r-- |
242 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2007 INRIA |
|
4 |
* All rights reserved. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or modify |
|
7 |
* it under the terms of the GNU General Public License version 2 as |
|
8 |
* published by the Free Software Foundation; |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 |
* |
|
19 |
* Authors: |
|
20 |
* Mathieu Lacage <mathieu.lacage@sophia.inria.fr>, |
|
21 |
*/ |
|
22 |
||
23 |
#include "ns3/packet.h" |
|
933
df68dad55087
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
745
diff
changeset
|
24 |
#include "ns3/debug.h" |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
303
diff
changeset
|
25 |
#include "ns3/composite-trace-resolver.h" |
729
b5e744285e92
rename i-node to node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
26 |
#include "ns3/node.h" |
524
082ffdd8fbd7
move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
521
diff
changeset
|
27 |
#include "ns3/net-device.h" |
1161
bb72baff8b26
replace MacAddress by Address
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
745
diff
changeset
|
28 |
#include "ns3/address.h" |
242 | 29 |
|
30 |
#include "arp-ipv4-interface.h" |
|
733
fb1882e7d785
rename ipv4.h to ipv4-l3-protocol.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
31 |
#include "ipv4-l3-protocol.h" |
1177
c7bf3cf186ac
remove now-unused ArpPrivate class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1167
diff
changeset
|
32 |
#include "arp-l3-protocol.h" |
242 | 33 |
|
34 |
namespace ns3 { |
|
35 |
||
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
36 |
ArpIpv4Interface::ArpIpv4Interface (Ptr<Node> node, Ptr<NetDevice> device) |
242 | 37 |
: Ipv4Interface (device), |
38 |
m_node (node) |
|
553
eb9d614accf0
convert more code to use Ptr<Node> instead of Node *
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
524
diff
changeset
|
39 |
{} |
242 | 40 |
ArpIpv4Interface::~ArpIpv4Interface () |
553
eb9d614accf0
convert more code to use Ptr<Node> instead of Node *
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
524
diff
changeset
|
41 |
{} |
242 | 42 |
|
1333
c0d66de933e9
convert TraceResolver * to Ptr<TraceResolver>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1325
diff
changeset
|
43 |
Ptr<TraceResolver> |
1383 | 44 |
ArpIpv4Interface::GetTraceResolver (void) const |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
303
diff
changeset
|
45 |
{ |
1333
c0d66de933e9
convert TraceResolver * to Ptr<TraceResolver>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1325
diff
changeset
|
46 |
Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> (); |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
553
diff
changeset
|
47 |
if (GetDevice () != 0) |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
303
diff
changeset
|
48 |
{ |
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1333
diff
changeset
|
49 |
resolver->AddChild ("netdevice", GetDevice ()); |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
303
diff
changeset
|
50 |
} |
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1333
diff
changeset
|
51 |
resolver->SetParent (Ipv4Interface::GetTraceResolver ()); |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
303
diff
changeset
|
52 |
return resolver; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
303
diff
changeset
|
53 |
} |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
303
diff
changeset
|
54 |
|
242 | 55 |
void |
56 |
ArpIpv4Interface::SendTo (Packet p, Ipv4Address dest) |
|
57 |
{ |
|
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
553
diff
changeset
|
58 |
NS_ASSERT (GetDevice () != 0); |
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
553
diff
changeset
|
59 |
if (GetDevice ()->NeedsArp ()) |
242 | 60 |
{ |
1177
c7bf3cf186ac
remove now-unused ArpPrivate class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1167
diff
changeset
|
61 |
Ptr<ArpL3Protocol> arp = m_node->QueryInterface<ArpL3Protocol> (ArpL3Protocol::iid); |
1161
bb72baff8b26
replace MacAddress by Address
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
745
diff
changeset
|
62 |
Address hardwareDestination; |
933
df68dad55087
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
745
diff
changeset
|
63 |
bool found; |
df68dad55087
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
745
diff
changeset
|
64 |
|
df68dad55087
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
745
diff
changeset
|
65 |
if (dest.IsBroadcast ()) |
df68dad55087
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
745
diff
changeset
|
66 |
{ |
1177
c7bf3cf186ac
remove now-unused ArpPrivate class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1167
diff
changeset
|
67 |
hardwareDestination = GetDevice ()->GetBroadcast (); |
c7bf3cf186ac
remove now-unused ArpPrivate class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1167
diff
changeset
|
68 |
found = true; |
933
df68dad55087
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
745
diff
changeset
|
69 |
} |
df68dad55087
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
745
diff
changeset
|
70 |
else |
df68dad55087
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
745
diff
changeset
|
71 |
{ |
df68dad55087
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
745
diff
changeset
|
72 |
found = arp->Lookup (p, dest, GetDevice (), &hardwareDestination); |
df68dad55087
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
745
diff
changeset
|
73 |
} |
df68dad55087
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
745
diff
changeset
|
74 |
|
446
ceecc7397053
use NetDevice::NeedsArp where needed
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
75 |
if (found) |
ceecc7397053
use NetDevice::NeedsArp where needed
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
76 |
{ |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
77 |
GetDevice ()->Send (p, hardwareDestination, Ipv4L3Protocol::PROT_NUMBER); |
446
ceecc7397053
use NetDevice::NeedsArp where needed
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
78 |
} |
ceecc7397053
use NetDevice::NeedsArp where needed
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
79 |
} |
ceecc7397053
use NetDevice::NeedsArp where needed
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
80 |
else |
ceecc7397053
use NetDevice::NeedsArp where needed
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
81 |
{ |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
82 |
GetDevice ()->Send (p, GetDevice ()->GetBroadcast (), Ipv4L3Protocol::PROT_NUMBER); |
242 | 83 |
} |
84 |
} |
|
85 |
||
86 |
}//namespace ns3 |