author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Thu, 03 May 2007 14:39:37 +0200 | |
changeset 521 | e540282f8462 |
parent 499 | 8a469663f7ea |
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" |
|
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
|
24 |
#include "ns3/composite-trace-resolver.h" |
242 | 25 |
|
26 |
#include "arp-ipv4-interface.h" |
|
521
e540282f8462
remove Node::GetArp
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
499
diff
changeset
|
27 |
#include "i-arp-private.h" |
242 | 28 |
#include "node.h" |
29 |
#include "net-device.h" |
|
293
007bc9e735f3
remove Ipv4L3Protocol class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
30 |
#include "ipv4.h" |
242 | 31 |
|
32 |
namespace ns3 { |
|
33 |
||
34 |
ArpIpv4Interface::ArpIpv4Interface (Node *node, NetDevice *device) |
|
35 |
: Ipv4Interface (device), |
|
36 |
m_node (node) |
|
487
04c5878c0a61
apply ref/unref rules consistently for Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
474
diff
changeset
|
37 |
{ |
04c5878c0a61
apply ref/unref rules consistently for Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
474
diff
changeset
|
38 |
m_node->Ref (); |
04c5878c0a61
apply ref/unref rules consistently for Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
474
diff
changeset
|
39 |
} |
242 | 40 |
ArpIpv4Interface::~ArpIpv4Interface () |
487
04c5878c0a61
apply ref/unref rules consistently for Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
474
diff
changeset
|
41 |
{ |
04c5878c0a61
apply ref/unref rules consistently for Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
474
diff
changeset
|
42 |
m_node->Unref (); |
04c5878c0a61
apply ref/unref rules consistently for Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
474
diff
changeset
|
43 |
} |
242 | 44 |
|
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 |
TraceResolver * |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
303
diff
changeset
|
46 |
ArpIpv4Interface::DoCreateTraceResolver (TraceContext const &context) |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
303
diff
changeset
|
47 |
{ |
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 |
CompositeTraceResolver *resolver = new CompositeTraceResolver (context); |
474
7457c2a417ba
manage NetDevice objects with refcounts
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
446
diff
changeset
|
49 |
if (PeekDevice () != 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
|
50 |
{ |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
303
diff
changeset
|
51 |
resolver->Add ("netdevice", |
474
7457c2a417ba
manage NetDevice objects with refcounts
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
446
diff
changeset
|
52 |
MakeCallback (&NetDevice::CreateTraceResolver, PeekDevice ()), |
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
|
53 |
ArpIpv4Interface::NETDEVICE); |
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 |
} |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
303
diff
changeset
|
55 |
|
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
303
diff
changeset
|
56 |
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
|
57 |
} |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
303
diff
changeset
|
58 |
|
242 | 59 |
void |
60 |
ArpIpv4Interface::SendTo (Packet p, Ipv4Address dest) |
|
61 |
{ |
|
474
7457c2a417ba
manage NetDevice objects with refcounts
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
446
diff
changeset
|
62 |
NS_ASSERT (PeekDevice () != 0); |
7457c2a417ba
manage NetDevice objects with refcounts
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
446
diff
changeset
|
63 |
if (PeekDevice ()->NeedsArp ()) |
242 | 64 |
{ |
521
e540282f8462
remove Node::GetArp
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
499
diff
changeset
|
65 |
IArpPrivate * arp = m_node->QueryInterface<IArpPrivate> (IArpPrivate::iid); |
446
ceecc7397053
use NetDevice::NeedsArp where needed
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
66 |
MacAddress hardwareDestination; |
474
7457c2a417ba
manage NetDevice objects with refcounts
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
446
diff
changeset
|
67 |
bool found = arp->Lookup (p, dest, PeekDevice (), &hardwareDestination); |
446
ceecc7397053
use NetDevice::NeedsArp where needed
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
68 |
if (found) |
ceecc7397053
use NetDevice::NeedsArp where needed
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
69 |
{ |
474
7457c2a417ba
manage NetDevice objects with refcounts
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
446
diff
changeset
|
70 |
PeekDevice ()->Send (p, hardwareDestination, Ipv4::PROT_NUMBER); |
446
ceecc7397053
use NetDevice::NeedsArp where needed
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
71 |
} |
499
8a469663f7ea
implement properly the refcounting rules for the capability getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
72 |
arp->Unref (); |
446
ceecc7397053
use NetDevice::NeedsArp where needed
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
73 |
} |
ceecc7397053
use NetDevice::NeedsArp where needed
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
74 |
else |
ceecc7397053
use NetDevice::NeedsArp where needed
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
75 |
{ |
474
7457c2a417ba
manage NetDevice objects with refcounts
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
446
diff
changeset
|
76 |
PeekDevice ()->Send (p, PeekDevice ()->GetBroadcast (), Ipv4::PROT_NUMBER); |
242 | 77 |
} |
78 |
} |
|
79 |
||
80 |
}//namespace ns3 |