author | Pavel Boyko <boyko@iitp.ru> |
Tue, 17 Mar 2009 10:56:45 +0300 | |
changeset 4817 | 1257e4b82e17 |
parent 4815 | 4d5befafc0a5 |
child 4841 | 702fa974e205 |
permissions | -rw-r--r-- |
4793 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2008,2009 IITP RAS |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
4793 | 7 |
* published by the Free Software Foundation; |
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 |
* |
|
18 |
* Author: Kirill Andreev <andreev@iitp.ru> |
|
4817
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4815
diff
changeset
|
19 |
* Pavel Boyko <boyko@iitp.ru> |
4793 | 20 |
*/ |
21 |
||
22 |
||
23 |
#include "ns3/node.h" |
|
24 |
#include "ns3/channel.h" |
|
25 |
#include "ns3/packet.h" |
|
26 |
#include "ns3/log.h" |
|
27 |
#include "ns3/boolean.h" |
|
28 |
#include "ns3/simulator.h" |
|
4817
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4815
diff
changeset
|
29 |
#include "ns3/mesh-point-device.h" |
4793 | 30 |
|
4815 | 31 |
NS_LOG_COMPONENT_DEFINE ("MeshPointDevice"); |
4793 | 32 |
|
33 |
namespace ns3 { |
|
34 |
||
4815 | 35 |
NS_OBJECT_ENSURE_REGISTERED (MeshPointDevice); |
4793 | 36 |
|
37 |
TypeId |
|
4815 | 38 |
MeshPointDevice::GetTypeId () |
4793 | 39 |
{ |
4815 | 40 |
static TypeId tid = TypeId ("ns3::MeshPointDevice") |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
41 |
.SetParent<NetDevice> () |
4815 | 42 |
.AddConstructor<MeshPointDevice> () |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
43 |
; |
4815 | 44 |
// TODO Add station-level attributes here |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
45 |
return tid; |
4793 | 46 |
} |
47 |
||
4815 | 48 |
MeshPointDevice::MeshPointDevice () : m_ifIndex(0), m_mtu(1500) |
4793 | 49 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
50 |
NS_LOG_FUNCTION_NOARGS (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
51 |
m_channel = CreateObject<BridgeChannel> (); |
4793 | 52 |
} |
53 |
||
4815 | 54 |
MeshPointDevice::~MeshPointDevice() |
4793 | 55 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
56 |
NS_LOG_FUNCTION_NOARGS (); |
4793 | 57 |
} |
58 |
||
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
59 |
void |
4815 | 60 |
MeshPointDevice::DoDispose () |
4793 | 61 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
62 |
NS_LOG_FUNCTION_NOARGS (); |
4815 | 63 |
for (std::vector< Ptr<NetDevice> >::iterator iter = m_ifaces.begin (); iter != m_ifaces.end (); iter++) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
64 |
*iter = 0; |
4815 | 65 |
m_ifaces.clear (); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
66 |
m_node = 0; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
67 |
NetDevice::DoDispose (); |
4793 | 68 |
|
69 |
} |
|
70 |
||
4815 | 71 |
//----------------------------------------------------------------------------- |
72 |
// NetDevice interface implementation |
|
73 |
//----------------------------------------------------------------------------- |
|
74 |
||
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
75 |
void |
4815 | 76 |
MeshPointDevice::ReceiveFromDevice (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet, uint16_t protocol, |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
77 |
Address const &src, Address const &dst, PacketType packetType) |
4793 | 78 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
79 |
NS_LOG_FUNCTION_NOARGS (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
80 |
NS_LOG_DEBUG ("UID is " << packet->GetUid ()); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
81 |
const Mac48Address src48 = Mac48Address::ConvertFrom (src); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
82 |
const Mac48Address dst48 = Mac48Address::ConvertFrom (dst); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
83 |
if (!m_promiscRxCallback.IsNull ()) |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
84 |
m_promiscRxCallback (this, packet, protocol, src, dst, packetType); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
85 |
switch (packetType) |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
86 |
{ |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
87 |
case PACKET_HOST: |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
88 |
if (dst48 == m_address) |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
89 |
m_rxCallback (this, packet, protocol, src); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
90 |
break; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
91 |
case PACKET_BROADCAST: |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
92 |
case PACKET_MULTICAST: |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
93 |
m_rxCallback (this, packet, protocol, src); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
94 |
case PACKET_OTHERHOST: |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
95 |
Forward (incomingPort, packet->Copy(), protocol, src48, dst48); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
96 |
break; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
97 |
} |
4793 | 98 |
} |
99 |
||
100 |
void |
|
4815 | 101 |
MeshPointDevice::Forward (Ptr<NetDevice> inport, Ptr<Packet> packet, |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
102 |
uint16_t protocol, const Mac48Address src, const Mac48Address dst) |
4793 | 103 |
{ |
4815 | 104 |
// pass through routing protocol |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
105 |
m_requestRoute(inport->GetIfIndex(), src, dst, packet, protocol, m_myResponse); |
4793 | 106 |
} |
107 |
||
108 |
void |
|
4815 | 109 |
MeshPointDevice::SetName(const std::string name) |
4793 | 110 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
111 |
NS_LOG_FUNCTION_NOARGS (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
112 |
m_name = name; |
4793 | 113 |
} |
114 |
||
115 |
std::string |
|
4815 | 116 |
MeshPointDevice::GetName() const |
117 |
{ |
|
118 |
NS_LOG_FUNCTION_NOARGS (); |
|
119 |
return m_name; |
|
120 |
} |
|
4793 | 121 |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
122 |
void |
4815 | 123 |
MeshPointDevice::SetIfIndex(const uint32_t index) |
4793 | 124 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
125 |
NS_LOG_FUNCTION_NOARGS (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
126 |
m_ifIndex = index; |
4793 | 127 |
} |
128 |
||
129 |
uint32_t |
|
4815 | 130 |
MeshPointDevice::GetIfIndex() const |
131 |
{ |
|
132 |
NS_LOG_FUNCTION_NOARGS (); |
|
133 |
return m_ifIndex; |
|
134 |
} |
|
4793 | 135 |
|
136 |
Ptr<Channel> |
|
4815 | 137 |
MeshPointDevice::GetChannel () const |
138 |
{ |
|
139 |
NS_LOG_FUNCTION_NOARGS (); |
|
140 |
return m_channel; |
|
141 |
} |
|
4793 | 142 |
|
143 |
Address |
|
4815 | 144 |
MeshPointDevice::GetAddress () const |
145 |
{ |
|
146 |
NS_LOG_FUNCTION_NOARGS (); |
|
147 |
return m_address; |
|
148 |
} |
|
4793 | 149 |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
150 |
bool |
4815 | 151 |
MeshPointDevice::SetMtu (const uint16_t mtu) |
4793 | 152 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
153 |
NS_LOG_FUNCTION_NOARGS (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
154 |
m_mtu = mtu; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
155 |
return true; |
4793 | 156 |
} |
157 |
||
158 |
uint16_t |
|
4815 | 159 |
MeshPointDevice::GetMtu () const |
160 |
{ |
|
161 |
NS_LOG_FUNCTION_NOARGS (); |
|
162 |
return m_mtu; |
|
163 |
} |
|
164 |
||
165 |
bool |
|
166 |
MeshPointDevice::IsLinkUp () const |
|
167 |
{ |
|
168 |
NS_LOG_FUNCTION_NOARGS (); |
|
169 |
return true; |
|
170 |
} |
|
171 |
||
172 |
void |
|
173 |
MeshPointDevice::SetLinkChangeCallback (Callback<void> callback) |
|
174 |
{ |
|
175 |
// do nothing |
|
176 |
} |
|
177 |
||
178 |
bool |
|
179 |
MeshPointDevice::IsBroadcast () const |
|
180 |
{ |
|
181 |
NS_LOG_FUNCTION_NOARGS (); |
|
182 |
return true; |
|
183 |
} |
|
184 |
||
185 |
Address |
|
186 |
MeshPointDevice::GetBroadcast () const |
|
187 |
{ |
|
188 |
NS_LOG_FUNCTION_NOARGS (); |
|
189 |
return Mac48Address ("ff:ff:ff:ff:ff:ff"); |
|
190 |
} |
|
191 |
||
192 |
bool |
|
193 |
MeshPointDevice::IsMulticast () const |
|
194 |
{ |
|
195 |
NS_LOG_FUNCTION_NOARGS (); |
|
196 |
return true; |
|
197 |
} |
|
198 |
||
199 |
Address |
|
200 |
MeshPointDevice::GetMulticast (Ipv4Address multicastGroup) const |
|
201 |
{ |
|
202 |
NS_LOG_FUNCTION (this << multicastGroup); |
|
203 |
Mac48Address multicast = Mac48Address::GetMulticast (multicastGroup); |
|
204 |
return multicast; |
|
205 |
} |
|
206 |
||
207 |
bool |
|
208 |
MeshPointDevice::IsPointToPoint () const |
|
209 |
{ |
|
210 |
NS_LOG_FUNCTION_NOARGS (); |
|
211 |
return false; |
|
212 |
} |
|
213 |
||
214 |
bool |
|
215 |
MeshPointDevice::IsBridge () const |
|
216 |
{ |
|
217 |
NS_LOG_FUNCTION_NOARGS (); |
|
218 |
return false; |
|
219 |
} |
|
4793 | 220 |
|
221 |
||
222 |
bool |
|
4815 | 223 |
MeshPointDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) |
4793 | 224 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
225 |
const Mac48Address dst48 = Mac48Address::ConvertFrom (dest); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
226 |
return m_requestRoute(m_ifIndex, m_address, dst48, packet, protocolNumber, m_myResponse); |
4793 | 227 |
} |
228 |
||
229 |
bool |
|
4815 | 230 |
MeshPointDevice::SendFrom (Ptr<Packet> packet, const Address& src, const Address& dest, uint16_t protocolNumber) |
4793 | 231 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
232 |
const Mac48Address src48 = Mac48Address::ConvertFrom (src); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
233 |
const Mac48Address dst48 = Mac48Address::ConvertFrom (dest); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
234 |
return m_requestRoute(m_ifIndex, src48, dst48, packet, protocolNumber, m_myResponse); |
4793 | 235 |
} |
236 |
||
237 |
Ptr<Node> |
|
4815 | 238 |
MeshPointDevice::GetNode () const |
239 |
{ |
|
240 |
NS_LOG_FUNCTION_NOARGS (); |
|
241 |
return m_node; |
|
242 |
} |
|
4793 | 243 |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
244 |
void |
4815 | 245 |
MeshPointDevice::SetNode (Ptr<Node> node) |
4793 | 246 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
247 |
NS_LOG_FUNCTION_NOARGS (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
248 |
m_node = node; |
4793 | 249 |
} |
250 |
||
251 |
bool |
|
4815 | 252 |
MeshPointDevice::NeedsArp () const |
253 |
{ |
|
254 |
NS_LOG_FUNCTION_NOARGS (); |
|
255 |
return true; |
|
256 |
} |
|
4793 | 257 |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
258 |
void |
4815 | 259 |
MeshPointDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb) |
4793 | 260 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
261 |
NS_LOG_FUNCTION_NOARGS (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
262 |
m_rxCallback = cb; |
4793 | 263 |
} |
264 |
||
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
265 |
void |
4815 | 266 |
MeshPointDevice::SetPromiscReceiveCallback (NetDevice::PromiscReceiveCallback cb) |
4793 | 267 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
268 |
NS_LOG_FUNCTION_NOARGS (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
269 |
m_promiscRxCallback = cb; |
4793 | 270 |
} |
271 |
||
272 |
bool |
|
4815 | 273 |
MeshPointDevice::SupportsSendFrom () const |
274 |
{ |
|
275 |
NS_LOG_FUNCTION_NOARGS (); |
|
276 |
return true; |
|
277 |
} |
|
4793 | 278 |
|
279 |
Address |
|
4815 | 280 |
MeshPointDevice::GetMulticast (Ipv6Address addr) const |
281 |
{ |
|
282 |
NS_LOG_FUNCTION (this << addr); |
|
283 |
return Mac48Address::GetMulticast (addr); |
|
284 |
} |
|
4793 | 285 |
|
4815 | 286 |
//----------------------------------------------------------------------------- |
287 |
// Interfaces |
|
288 |
//----------------------------------------------------------------------------- |
|
289 |
uint32_t |
|
290 |
MeshPointDevice::GetNInterfaces () const |
|
4793 | 291 |
{ |
4815 | 292 |
NS_LOG_FUNCTION_NOARGS (); |
293 |
return m_ifaces.size (); |
|
294 |
} |
|
295 |
||
296 |
Ptr<NetDevice> |
|
297 |
MeshPointDevice::GetInterface (uint32_t n) const |
|
298 |
{ |
|
299 |
NS_ASSERT(m_ifaces.size () > n); |
|
300 |
return m_ifaces[n]; |
|
4793 | 301 |
} |
302 |
||
303 |
void |
|
4815 | 304 |
MeshPointDevice::AddInterface (Ptr<NetDevice> iface) |
305 |
{ |
|
306 |
NS_LOG_FUNCTION_NOARGS (); |
|
307 |
||
308 |
NS_ASSERT (iface != this); |
|
309 |
if (!Mac48Address::IsMatchingType (iface->GetAddress ())) |
|
310 |
NS_FATAL_ERROR ("Device does not support eui 48 addresses: cannot be added to bridge."); |
|
311 |
if (!iface->SupportsSendFrom ()) |
|
312 |
NS_FATAL_ERROR ("Device does not support SendFrom: cannot be added to bridge."); |
|
313 |
m_address = Mac48Address::ConvertFrom (iface->GetAddress ()); |
|
314 |
||
315 |
NS_LOG_DEBUG ("RegisterProtocolHandler for " << iface->GetName ()); |
|
316 |
m_node->RegisterProtocolHandler (MakeCallback (&MeshPointDevice::ReceiveFromDevice, this), |
|
317 |
0, iface, /*promiscuous = */true); |
|
318 |
||
319 |
m_ifaces.push_back (iface); |
|
320 |
m_channel->AddChannel (iface->GetChannel ()); |
|
321 |
} |
|
322 |
||
323 |
//----------------------------------------------------------------------------- |
|
324 |
// Protocols |
|
325 |
//----------------------------------------------------------------------------- |
|
326 |
||
4817
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4815
diff
changeset
|
327 |
void |
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4815
diff
changeset
|
328 |
MeshPointDevice::SetRoutingProtocol(Ptr<MeshL2RoutingProtocol> protocol) |
4815 | 329 |
{ |
330 |
NS_LOG_FUNCTION_NOARGS (); |
|
331 |
||
4817
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4815
diff
changeset
|
332 |
NS_ASSERT_MSG(PeekPointer(protocol->GetMeshPoint()) == this, "Routing protocol must be installed on mesh point to be usefull."); |
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4815
diff
changeset
|
333 |
|
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4815
diff
changeset
|
334 |
m_requestRoute = MakeCallback(&MeshL2RoutingProtocol::RequestRoute, protocol); |
4815 | 335 |
m_myResponse = MakeCallback(&MeshPointDevice::DoSend, this); |
4817
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4815
diff
changeset
|
336 |
|
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4815
diff
changeset
|
337 |
return; |
4815 | 338 |
} |
339 |
||
340 |
void |
|
341 |
MeshPointDevice::DoSend(bool success, Ptr<Packet> packet, Mac48Address src, Mac48Address dst, uint16_t protocol, uint32_t outIface) |
|
4793 | 342 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
343 |
if (!success) |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
344 |
{ |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
345 |
NS_LOG_UNCOND("Resolve failed"); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
346 |
//TODO: SendError callback |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
347 |
return; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
348 |
} |
4815 | 349 |
|
350 |
// Ok, now I know the route, just SendFrom |
|
351 |
||
352 |
if (outIface != 0xffffffff) |
|
353 |
GetInterface(outIface)->SendFrom(packet, src, dst, protocol); |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
354 |
else |
4815 | 355 |
for (std::vector<Ptr<NetDevice> >::iterator i = m_ifaces.begin(); i != m_ifaces.end(); i++) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
356 |
(*i) -> SendFrom(packet, src, dst, protocol); |
4793 | 357 |
} |
358 |
||
359 |
} // namespace ns3 |