author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Mon, 27 Aug 2007 15:07:39 +0200 | |
changeset 1365 | 4ae411ac425f |
parent 1341 | f685d4bf320f |
child 1412 | 9ce52d4f530b |
permissions | -rw-r--r-- |
242 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2006 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 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
|
20 |
*/ |
|
21 |
#include "ns3/packet.h" |
|
287
692ddac3794c
convert old TRACE code to use new NS_DEBUG macro
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
286
diff
changeset
|
22 |
#include "ns3/debug.h" |
729
b5e744285e92
rename i-node to node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
23 |
#include "ns3/node.h" |
524
082ffdd8fbd7
move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
522
diff
changeset
|
24 |
#include "ns3/net-device.h" |
082ffdd8fbd7
move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
522
diff
changeset
|
25 |
|
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1167
diff
changeset
|
26 |
#include "ipv4-l3-protocol.h" |
735
a3e48148c3ac
arp.h -> arp-l3-protocol.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
27 |
#include "arp-l3-protocol.h" |
242 | 28 |
#include "arp-header.h" |
29 |
#include "arp-cache.h" |
|
30 |
#include "ipv4-interface.h" |
|
31 |
||
736
a27d6bd2c291
Arp -> ArpL3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
735
diff
changeset
|
32 |
NS_DEBUG_COMPONENT_DEFINE ("ArpL3Protocol"); |
242 | 33 |
|
34 |
namespace ns3 { |
|
35 |
||
1177
c7bf3cf186ac
remove now-unused ArpPrivate class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1176
diff
changeset
|
36 |
const InterfaceId ArpL3Protocol::iid = MakeInterfaceId ("ArpL3Protocol", Object::iid); |
736
a27d6bd2c291
Arp -> ArpL3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
735
diff
changeset
|
37 |
const uint16_t ArpL3Protocol::PROT_NUMBER = 0x0806; |
294
aba9a34108d2
remove ArpL3Protocol object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
287
diff
changeset
|
38 |
|
736
a27d6bd2c291
Arp -> ArpL3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
735
diff
changeset
|
39 |
ArpL3Protocol::ArpL3Protocol (Ptr<Node> node) |
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1167
diff
changeset
|
40 |
: m_node (node) |
1178
a40440a4b2fa
forgot to set the interface id
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1177
diff
changeset
|
41 |
{ |
a40440a4b2fa
forgot to set the interface id
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1177
diff
changeset
|
42 |
SetInterfaceId (ArpL3Protocol::iid); |
a40440a4b2fa
forgot to set the interface id
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1177
diff
changeset
|
43 |
} |
242 | 44 |
|
736
a27d6bd2c291
Arp -> ArpL3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
735
diff
changeset
|
45 |
ArpL3Protocol::~ArpL3Protocol () |
552
b5f29caf9d8c
convert Arp code to use Ptr<Node> instead of Node *
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
551
diff
changeset
|
46 |
{} |
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
47 |
|
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
48 |
void |
736
a27d6bd2c291
Arp -> ArpL3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
735
diff
changeset
|
49 |
ArpL3Protocol::DoDispose (void) |
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
50 |
{ |
248
a912210e52ac
fix memory leaks for simple sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
51 |
for (CacheList::const_iterator i = m_cacheList.begin (); i != m_cacheList.end (); i++) |
a912210e52ac
fix memory leaks for simple sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
52 |
{ |
a912210e52ac
fix memory leaks for simple sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
53 |
delete *i; |
a912210e52ac
fix memory leaks for simple sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
54 |
} |
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
55 |
m_cacheList.clear (); |
552
b5f29caf9d8c
convert Arp code to use Ptr<Node> instead of Node *
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
551
diff
changeset
|
56 |
m_node = 0; |
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1167
diff
changeset
|
57 |
Object::DoDispose (); |
248
a912210e52ac
fix memory leaks for simple sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
58 |
} |
a912210e52ac
fix memory leaks for simple sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
59 |
|
242 | 60 |
ArpCache * |
736
a27d6bd2c291
Arp -> ArpL3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
735
diff
changeset
|
61 |
ArpL3Protocol::FindCache (Ptr<NetDevice> device) |
242 | 62 |
{ |
63 |
for (CacheList::const_iterator i = m_cacheList.begin (); i != m_cacheList.end (); i++) |
|
64 |
{ |
|
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
552
diff
changeset
|
65 |
if ((*i)->GetDevice () == device) |
242 | 66 |
{ |
67 |
return *i; |
|
68 |
} |
|
69 |
} |
|
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1167
diff
changeset
|
70 |
Ptr<Ipv4L3Protocol> ipv4 = m_node->QueryInterface<Ipv4L3Protocol> (Ipv4L3Protocol::iid); |
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
|
71 |
Ptr<Ipv4Interface> interface = ipv4->FindInterfaceForDevice (device); |
242 | 72 |
ArpCache * cache = new ArpCache (device, interface); |
286
57e6a2006962
convert use of <cassert> to "ns3/assert.h"
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
261
diff
changeset
|
73 |
NS_ASSERT (device->IsBroadcast ()); |
242 | 74 |
device->SetLinkChangeCallback (MakeCallback (&ArpCache::Flush, cache)); |
75 |
m_cacheList.push_back (cache); |
|
76 |
return cache; |
|
77 |
} |
|
78 |
||
79 |
void |
|
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1178
diff
changeset
|
80 |
ArpL3Protocol::Receive(Ptr<NetDevice> device, const Packet& p, uint16_t protocol, const Address &from) |
242 | 81 |
{ |
474
7457c2a417ba
manage NetDevice objects with refcounts
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
463
diff
changeset
|
82 |
ArpCache *cache = FindCache (device); |
242 | 83 |
ArpHeader arp; |
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1167
diff
changeset
|
84 |
Packet packet = p; |
463
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
85 |
packet.RemoveHeader (arp); |
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:
746
diff
changeset
|
86 |
|
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:
746
diff
changeset
|
87 |
NS_DEBUG ("ARP: received "<< (arp.IsRequest ()? "request" : "reply") << |
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:
746
diff
changeset
|
88 |
" node="<<m_node->GetId ()<<", got request from " << |
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:
746
diff
changeset
|
89 |
arp.GetSourceIpv4Address () << " for address " << |
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:
746
diff
changeset
|
90 |
arp.GetDestinationIpv4Address () << "; we have address " << |
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:
746
diff
changeset
|
91 |
cache->GetInterface ()->GetAddress ()); |
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:
746
diff
changeset
|
92 |
|
242 | 93 |
if (arp.IsRequest () && |
94 |
arp.GetDestinationIpv4Address () == cache->GetInterface ()->GetAddress ()) |
|
95 |
{ |
|
321
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
96 |
NS_DEBUG ("node="<<m_node->GetId () <<", got request from " << |
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
97 |
arp.GetSourceIpv4Address () << " -- send reply"); |
242 | 98 |
SendArpReply (cache, arp.GetSourceIpv4Address (), |
99 |
arp.GetSourceHardwareAddress ()); |
|
100 |
} |
|
101 |
else if (arp.IsReply () && |
|
102 |
arp.GetDestinationIpv4Address ().IsEqual (cache->GetInterface ()->GetAddress ()) && |
|
1161
bb72baff8b26
replace MacAddress by Address
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
746
diff
changeset
|
103 |
arp.GetDestinationHardwareAddress () == device->GetAddress ()) |
242 | 104 |
{ |
105 |
Ipv4Address from = arp.GetSourceIpv4Address (); |
|
106 |
ArpCache::Entry *entry = cache->Lookup (from); |
|
107 |
if (entry != 0) |
|
108 |
{ |
|
109 |
if (entry->IsWaitReply ()) |
|
110 |
{ |
|
321
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
111 |
NS_DEBUG ("node="<<m_node->GetId ()<<", got reply from " << |
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
112 |
arp.GetSourceIpv4Address () |
242 | 113 |
<< " for waiting entry -- flush"); |
1161
bb72baff8b26
replace MacAddress by Address
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
746
diff
changeset
|
114 |
Address from_mac = arp.GetSourceHardwareAddress (); |
242 | 115 |
Packet waiting = entry->MarkAlive (from_mac); |
116 |
cache->GetInterface ()->Send (waiting, arp.GetSourceIpv4Address ()); |
|
117 |
} |
|
118 |
else |
|
119 |
{ |
|
120 |
// ignore this reply which might well be an attempt |
|
121 |
// at poisening my arp cache. |
|
321
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
122 |
NS_DEBUG ("node="<<m_node->GetId ()<<", got reply from " << |
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
123 |
arp.GetSourceIpv4Address () << |
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
124 |
" for non-waiting entry -- drop"); |
242 | 125 |
// XXX report packet as dropped. |
126 |
} |
|
127 |
} |
|
128 |
else |
|
129 |
{ |
|
321
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
130 |
NS_DEBUG ("node="<<m_node->GetId ()<<", got reply for unknown entry -- drop"); |
242 | 131 |
// XXX report packet as dropped. |
132 |
} |
|
133 |
} |
|
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:
746
diff
changeset
|
134 |
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:
746
diff
changeset
|
135 |
{ |
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:
746
diff
changeset
|
136 |
NS_DEBUG ("node="<<m_node->GetId ()<<", got request from " << |
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:
746
diff
changeset
|
137 |
arp.GetSourceIpv4Address () << " for unknown address " << |
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:
746
diff
changeset
|
138 |
arp.GetDestinationIpv4Address () << " -- drop"); |
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:
746
diff
changeset
|
139 |
} |
242 | 140 |
} |
141 |
bool |
|
736
a27d6bd2c291
Arp -> ArpL3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
735
diff
changeset
|
142 |
ArpL3Protocol::Lookup (Packet &packet, Ipv4Address destination, |
1161
bb72baff8b26
replace MacAddress by Address
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
746
diff
changeset
|
143 |
Ptr<NetDevice> device, |
bb72baff8b26
replace MacAddress by Address
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
746
diff
changeset
|
144 |
Address *hardwareDestination) |
242 | 145 |
{ |
146 |
ArpCache *cache = FindCache (device); |
|
147 |
ArpCache::Entry *entry = cache->Lookup (destination); |
|
148 |
if (entry != 0) |
|
149 |
{ |
|
150 |
if (entry->IsExpired ()) |
|
151 |
{ |
|
152 |
if (entry->IsDead ()) |
|
153 |
{ |
|
321
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
154 |
NS_DEBUG ("node="<<m_node->GetId ()<< |
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
155 |
", dead entry for " << destination << " expired -- send arp request"); |
242 | 156 |
entry->MarkWaitReply (packet); |
157 |
SendArpRequest (cache, destination); |
|
158 |
} |
|
159 |
else if (entry->IsAlive ()) |
|
160 |
{ |
|
321
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
161 |
NS_DEBUG ("node="<<m_node->GetId ()<< |
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
162 |
", alive entry for " << destination << " expired -- send arp request"); |
242 | 163 |
entry->MarkWaitReply (packet); |
164 |
SendArpRequest (cache, destination); |
|
165 |
} |
|
166 |
else if (entry->IsWaitReply ()) |
|
167 |
{ |
|
321
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
168 |
NS_DEBUG ("node="<<m_node->GetId ()<< |
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
169 |
", wait reply for " << destination << " expired -- drop"); |
242 | 170 |
entry->MarkDead (); |
171 |
// XXX report packet as 'dropped' |
|
172 |
} |
|
173 |
} |
|
174 |
else |
|
175 |
{ |
|
176 |
if (entry->IsDead ()) |
|
177 |
{ |
|
321
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
178 |
NS_DEBUG ("node="<<m_node->GetId ()<< |
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
179 |
", dead entry for " << destination << " valid -- drop"); |
242 | 180 |
// XXX report packet as 'dropped' |
181 |
} |
|
182 |
else if (entry->IsAlive ()) |
|
183 |
{ |
|
321
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
184 |
NS_DEBUG ("node="<<m_node->GetId ()<< |
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
185 |
", alive entry for " << destination << " valid -- send"); |
242 | 186 |
*hardwareDestination = entry->GetMacAddress (); |
187 |
return true; |
|
188 |
} |
|
189 |
else if (entry->IsWaitReply ()) |
|
190 |
{ |
|
321
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
191 |
NS_DEBUG ("node="<<m_node->GetId ()<< |
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
192 |
", wait reply for " << destination << " valid -- drop previous"); |
242 | 193 |
Packet old = entry->UpdateWaitReply (packet); |
194 |
// XXX report 'old' packet as 'dropped' |
|
195 |
} |
|
196 |
} |
|
197 |
||
198 |
} |
|
199 |
else |
|
200 |
{ |
|
201 |
// This is our first attempt to transmit data to this destination. |
|
321
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
202 |
NS_DEBUG ("node="<<m_node->GetId ()<< |
452a9cdad112
improve arp debugging output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
303
diff
changeset
|
203 |
", no entry for " << destination << " -- send arp request"); |
242 | 204 |
entry = cache->Add (destination); |
205 |
entry->MarkWaitReply (packet); |
|
206 |
SendArpRequest (cache, destination); |
|
207 |
} |
|
208 |
return false; |
|
209 |
} |
|
210 |
||
211 |
void |
|
736
a27d6bd2c291
Arp -> ArpL3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
735
diff
changeset
|
212 |
ArpL3Protocol::SendArpRequest (ArpCache const *cache, Ipv4Address to) |
242 | 213 |
{ |
214 |
ArpHeader arp; |
|
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:
746
diff
changeset
|
215 |
NS_DEBUG ("ARP: sending request from node "<<m_node->GetId ()<< |
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:
746
diff
changeset
|
216 |
" || src: " << cache->GetDevice ()->GetAddress () << |
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:
746
diff
changeset
|
217 |
" / " << cache->GetInterface ()->GetAddress () << |
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:
746
diff
changeset
|
218 |
" || dst: " << cache->GetDevice ()->GetBroadcast () << |
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:
746
diff
changeset
|
219 |
" / " << to); |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
552
diff
changeset
|
220 |
arp.SetRequest (cache->GetDevice ()->GetAddress (), |
242 | 221 |
cache->GetInterface ()->GetAddress (), |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
552
diff
changeset
|
222 |
cache->GetDevice ()->GetBroadcast (), |
242 | 223 |
to); |
224 |
Packet packet; |
|
463
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
225 |
packet.AddHeader (arp); |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
552
diff
changeset
|
226 |
cache->GetDevice ()->Send (packet, cache->GetDevice ()->GetBroadcast (), PROT_NUMBER); |
242 | 227 |
} |
228 |
||
229 |
void |
|
1161
bb72baff8b26
replace MacAddress by Address
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
746
diff
changeset
|
230 |
ArpL3Protocol::SendArpReply (ArpCache const *cache, Ipv4Address toIp, Address toMac) |
242 | 231 |
{ |
232 |
ArpHeader arp; |
|
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:
746
diff
changeset
|
233 |
NS_DEBUG ("ARP: sending reply from node "<<m_node->GetId ()<< |
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:
746
diff
changeset
|
234 |
"|| src: " << cache->GetDevice ()->GetAddress () << |
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:
746
diff
changeset
|
235 |
" / " << cache->GetInterface ()->GetAddress () << |
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:
746
diff
changeset
|
236 |
" || dst: " << toMac << " / " << toIp); |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
552
diff
changeset
|
237 |
arp.SetReply (cache->GetDevice ()->GetAddress (), |
242 | 238 |
cache->GetInterface ()->GetAddress (), |
239 |
toMac, toIp); |
|
240 |
Packet packet; |
|
463
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
241 |
packet.AddHeader (arp); |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
552
diff
changeset
|
242 |
cache->GetDevice ()->Send (packet, toMac, PROT_NUMBER); |
242 | 243 |
} |
244 |
||
245 |
}//namespace ns3 |