equal
deleted
inserted
replaced
25 #include "ns3/array-trace-resolver.h" |
25 #include "ns3/array-trace-resolver.h" |
26 #include "ns3/callback.h" |
26 #include "ns3/callback.h" |
27 #include "ns3/ipv4-address.h" |
27 #include "ns3/ipv4-address.h" |
28 #include "ns3/ipv4-route.h" |
28 #include "ns3/ipv4-route.h" |
29 #include "ns3/node.h" |
29 #include "ns3/node.h" |
|
30 #include "ns3/net-device.h" |
30 |
31 |
31 #include "ipv4.h" |
32 #include "ipv4.h" |
32 #include "ipv4-l4-protocol.h" |
33 #include "ipv4-l4-protocol.h" |
33 #include "ipv4-header.h" |
34 #include "ipv4-header.h" |
34 #include "ipv4-interface.h" |
35 #include "ipv4-interface.h" |
308 NS_ASSERT (false); |
309 NS_ASSERT (false); |
309 } |
310 } |
310 |
311 |
311 |
312 |
312 uint32_t |
313 uint32_t |
313 Ipv4::AddInterface (NetDevice *device) |
314 Ipv4::AddInterface (Ptr<NetDevice> device) |
314 { |
315 { |
315 Ipv4Interface *interface = new ArpIpv4Interface (m_node, device); |
316 Ipv4Interface *interface = new ArpIpv4Interface (m_node, device); |
316 return AddIpv4Interface (interface); |
317 return AddIpv4Interface (interface); |
317 } |
318 } |
318 uint32_t |
319 uint32_t |
342 { |
343 { |
343 return m_nInterfaces; |
344 return m_nInterfaces; |
344 } |
345 } |
345 |
346 |
346 Ipv4Interface * |
347 Ipv4Interface * |
347 Ipv4::FindInterfaceForDevice (NetDevice const*device) |
348 Ipv4::FindInterfaceForDevice (Ptr<const NetDevice> device) |
348 { |
349 { |
349 for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++) |
350 for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++) |
350 { |
351 { |
351 if ((*i)->PeekDevice () == device) |
352 if ((*i)->GetDevice () == device) |
352 { |
353 { |
353 return *i; |
354 return *i; |
354 } |
355 } |
355 } |
356 } |
356 return 0; |
357 return 0; |
357 } |
358 } |
358 |
359 |
359 void |
360 void |
360 Ipv4::Receive(Packet& packet, NetDevice *device) |
361 Ipv4::Receive(Packet& packet, Ptr<NetDevice> device) |
361 { |
362 { |
362 uint32_t index = 0; |
363 uint32_t index = 0; |
363 for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++) |
364 for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++) |
364 { |
365 { |
365 if ((*i)->PeekDevice () == device) |
366 if ((*i)->GetDevice () == device) |
366 { |
367 { |
367 m_rxTrace (packet, index); |
368 m_rxTrace (packet, index); |
368 break; |
369 break; |
369 } |
370 } |
370 index++; |
371 index++; |
440 } |
441 } |
441 } |
442 } |
442 |
443 |
443 |
444 |
444 bool |
445 bool |
445 Ipv4::Forwarding (Packet const &packet, Ipv4Header &ipHeader, NetDevice *device) |
446 Ipv4::Forwarding (Packet const &packet, Ipv4Header &ipHeader, Ptr<NetDevice> device) |
446 { |
447 { |
447 for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
448 for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
448 i != m_interfaces.end (); i++) |
449 i != m_interfaces.end (); i++) |
449 { |
450 { |
450 if ((*i)->GetAddress ().IsEqual (ipHeader.GetDestination ())) |
451 if ((*i)->GetAddress ().IsEqual (ipHeader.GetDestination ())) |
456 |
457 |
457 for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
458 for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
458 i != m_interfaces.end (); i++) |
459 i != m_interfaces.end (); i++) |
459 { |
460 { |
460 Ipv4Interface *interface = *i; |
461 Ipv4Interface *interface = *i; |
461 if (interface->PeekDevice () == device) |
462 if (interface->GetDevice () == device) |
462 { |
463 { |
463 if (ipHeader.GetDestination ().IsEqual (interface->GetBroadcast ())) |
464 if (ipHeader.GetDestination ().IsEqual (interface->GetBroadcast ())) |
464 { |
465 { |
465 NS_DEBUG ("for me 2"); |
466 NS_DEBUG ("for me 2"); |
466 return false; |
467 return false; |
502 |
503 |
503 |
504 |
504 void |
505 void |
505 Ipv4::ForwardUp (Packet p, Ipv4Header const&ip) |
506 Ipv4::ForwardUp (Packet p, Ipv4Header const&ip) |
506 { |
507 { |
507 Ipv4L4Demux *demux = m_node->QueryInterface<Ipv4L4Demux> (Ipv4L4Demux::iid); |
508 Ptr<Ipv4L4Demux> demux = m_node->QueryInterface<Ipv4L4Demux> (Ipv4L4Demux::iid); |
508 Ipv4L4Protocol *protocol = demux->PeekProtocol (ip.GetProtocol ()); |
509 Ptr<Ipv4L4Protocol> protocol = demux->GetProtocol (ip.GetProtocol ()); |
509 demux->Unref (); |
|
510 protocol->Receive (p, ip.GetSource (), ip.GetDestination ()); |
510 protocol->Receive (p, ip.GetSource (), ip.GetDestination ()); |
511 } |
511 } |
512 |
512 |
513 void |
513 void |
514 Ipv4::SetAddress (uint32_t i, Ipv4Address address) |
514 Ipv4::SetAddress (uint32_t i, Ipv4Address address) |