diff --git a/examples/ipv6/fragmentation-ipv6.cc b/examples/ipv6/fragmentation-ipv6.cc index 8160ca190..dd1aef847 100644 --- a/examples/ipv6/fragmentation-ipv6.cc +++ b/examples/ipv6/fragmentation-ipv6.cc @@ -54,9 +54,9 @@ public: */ inline void AddAddress (Ptr& n, uint32_t interface, Ipv6Address address) { - Ptr ipv6 = n->GetObject (); - ipv6->AddAddress (interface, address); - } + Ptr ipv6 = n->GetObject (); + ipv6->AddAddress (interface, address); + } /** * \brief Print the routing table. @@ -64,27 +64,27 @@ public: */ inline void PrintRoutingTable (Ptr& n) { - Ptr routing = 0; - Ipv6StaticRoutingHelper routingHelper; - Ptr ipv6 = n->GetObject (); - uint32_t nbRoutes = 0; - Ipv6RoutingTableEntry route; + Ptr routing = 0; + Ipv6StaticRoutingHelper routingHelper; + Ptr ipv6 = n->GetObject (); + uint32_t nbRoutes = 0; + Ipv6RoutingTableEntry route; - routing = routingHelper.GetStaticRouting (ipv6); + routing = routingHelper.GetStaticRouting (ipv6); - std::cout << "Routing table of " << n << " : " << std::endl; - std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" << "Prefix to use" << std::endl; + std::cout << "Routing table of " << n << " : " << std::endl; + std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" << "Prefix to use" << std::endl; - nbRoutes = routing->GetNRoutes (); - for (uint32_t i = 0 ; i < nbRoutes ; i++) - { - route = routing->GetRoute (i); - std::cout << route.GetDest () << "\t" - << route.GetGateway () << "\t" - << route.GetInterface () << "\t" - << route.GetPrefixToUse () << "\t" - << std::endl; - } + nbRoutes = routing->GetNRoutes (); + for (uint32_t i = 0 ; i < nbRoutes ; i++) + { + route = routing->GetRoute (i); + std::cout << route.GetDest () << "\t" + << route.GetGateway () << "\t" + << route.GetInterface () << "\t" + << route.GetPrefixToUse () << "\t" + << std::endl; + } } }; diff --git a/examples/ipv6/icmpv6-redirect.cc b/examples/ipv6/icmpv6-redirect.cc index fe0f33a05..0c139be11 100644 --- a/examples/ipv6/icmpv6-redirect.cc +++ b/examples/ipv6/icmpv6-redirect.cc @@ -57,26 +57,26 @@ NS_LOG_COMPONENT_DEFINE ("Icmpv6RedirectExample"); */ class StackHelper { - public: - /** - * \brief Print the routing table. - * \param n the node - */ - inline void PrintRoutingTable (Ptr& n) - { - Ptr routing = 0; - Ipv6StaticRoutingHelper routingHelper; - Ptr ipv6 = n->GetObject (); - uint32_t nbRoutes = 0; - Ipv6RoutingTableEntry route; +public: + /** + * \brief Print the routing table. + * \param n the node + */ + inline void PrintRoutingTable (Ptr& n) + { + Ptr routing = 0; + Ipv6StaticRoutingHelper routingHelper; + Ptr ipv6 = n->GetObject (); + uint32_t nbRoutes = 0; + Ipv6RoutingTableEntry route; - routing = routingHelper.GetStaticRouting (ipv6); + routing = routingHelper.GetStaticRouting (ipv6); - std::cout << "Routing table of " << n << " : " << std::endl; - std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" << "Prefix to use" << std::endl; + std::cout << "Routing table of " << n << " : " << std::endl; + std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" << "Prefix to use" << std::endl; - nbRoutes = routing->GetNRoutes (); - for(uint32_t i = 0 ; i < nbRoutes ; i++) + nbRoutes = routing->GetNRoutes (); + for(uint32_t i = 0 ; i < nbRoutes ; i++) { route = routing->GetRoute (i); std::cout << route.GetDest () << "\t" @@ -85,27 +85,26 @@ class StackHelper << route.GetPrefixToUse () << "\t" << std::endl; } - } + } - /** - * \brief Add an host route. - * \param n node - * \param dst destination address - * \param nextHop next hop for destination - * \param interface output interface - */ - inline void AddHostRouteTo (Ptr& n, Ipv6Address dst, Ipv6Address nextHop, uint32_t interface) - { - Ptr routing = 0; - Ipv6StaticRoutingHelper routingHelper; - Ptr ipv6 = n->GetObject (); + /** + * \brief Add an host route. + * \param n node + * \param dst destination address + * \param nextHop next hop for destination + * \param interface output interface + */ + inline void AddHostRouteTo (Ptr& n, Ipv6Address dst, Ipv6Address nextHop, uint32_t interface) + { + Ptr routing = 0; + Ipv6StaticRoutingHelper routingHelper; + Ptr ipv6 = n->GetObject (); - routing = routingHelper.GetStaticRouting (ipv6); - routing->AddHostRouteTo (dst, nextHop, interface); - } + routing = routingHelper.GetStaticRouting (ipv6); + routing->AddHostRouteTo (dst, nextHop, interface); + } }; - int main (int argc, char **argv) { #if 0 @@ -131,7 +130,7 @@ int main (int argc, char **argv) NodeContainer all(sta1, r1, r2, sta2); StackHelper stackHelper; - + InternetStackHelper internetv6; internetv6.Install (all); @@ -155,7 +154,7 @@ int main (int argc, char **argv) iic2.SetRouter (0, true); stackHelper.AddHostRouteTo (r1, iic2.GetAddress (1, 1), iic1.GetAddress (2, 1), iic1.GetInterfaceIndex (1)); - + Simulator::Schedule(Seconds(0.0), &StackHelper::PrintRoutingTable, &stackHelper, r1); Simulator::Schedule(Seconds(3.0), &StackHelper::PrintRoutingTable, &stackHelper, sta1); diff --git a/examples/ipv6/ping6.cc b/examples/ipv6/ping6.cc index 56ff13f95..0b5d89ec0 100644 --- a/examples/ipv6/ping6.cc +++ b/examples/ipv6/ping6.cc @@ -54,7 +54,7 @@ int main (int argc, char **argv) CommandLine cmd; cmd.Parse (argc, argv); - + NS_LOG_INFO ("Create nodes."); NodeContainer n; n.Create (4); @@ -84,10 +84,10 @@ int main (int argc, char **argv) Time interPacketInterval = Seconds (1.); Ping6Helper ping6; -/* - ping6.SetLocal (i.GetAddress (0, 1)); - ping6.SetRemote (i.GetAddress (1, 1)); -*/ + /* + ping6.SetLocal (i.GetAddress (0, 1)); + ping6.SetRemote (i.GetAddress (1, 1)); + */ ping6.SetIfIndex (i.GetInterfaceIndex (0)); ping6.SetRemote (Ipv6Address::GetAllNodesMulticast ()); diff --git a/examples/ipv6/radvd-two-prefix.cc b/examples/ipv6/radvd-two-prefix.cc index bea674c40..2d5e6fde3 100644 --- a/examples/ipv6/radvd-two-prefix.cc +++ b/examples/ipv6/radvd-two-prefix.cc @@ -52,38 +52,38 @@ NS_LOG_COMPONENT_DEFINE ("RadvdExample"); */ class StackHelper { - public: - /** - * \brief Add an address to a IPv6 node. - * \param n node - * \param interface interface index - * \param address IPv6 address to add - */ - inline void AddAddress (Ptr& n, uint32_t interface, Ipv6Address address) - { - Ptr ipv6 = n->GetObject (); - ipv6->AddAddress (interface, address); - } +public: + /** + * \brief Add an address to a IPv6 node. + * \param n node + * \param interface interface index + * \param address IPv6 address to add + */ + inline void AddAddress (Ptr& n, uint32_t interface, Ipv6Address address) + { + Ptr ipv6 = n->GetObject (); + ipv6->AddAddress (interface, address); + } - /** - * \brief Print the routing table. - * \param n the node - */ - inline void PrintRoutingTable (Ptr& n) - { - Ptr routing = 0; - Ipv6StaticRoutingHelper routingHelper; - Ptr ipv6 = n->GetObject (); - uint32_t nbRoutes = 0; - Ipv6RoutingTableEntry route; + /** + * \brief Print the routing table. + * \param n the node + */ + inline void PrintRoutingTable (Ptr& n) + { + Ptr routing = 0; + Ipv6StaticRoutingHelper routingHelper; + Ptr ipv6 = n->GetObject (); + uint32_t nbRoutes = 0; + Ipv6RoutingTableEntry route; - routing = routingHelper.GetStaticRouting (ipv6); + routing = routingHelper.GetStaticRouting (ipv6); - std::cout << "Routing table of " << n << " : " << std::endl; - std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" << "Prefix to use" << std::endl; + std::cout << "Routing table of " << n << " : " << std::endl; + std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" << "Prefix to use" << std::endl; - nbRoutes = routing->GetNRoutes (); - for (uint32_t i = 0 ; i < nbRoutes ; i++) + nbRoutes = routing->GetNRoutes (); + for (uint32_t i = 0 ; i < nbRoutes ; i++) { route = routing->GetRoute (i); std::cout << route.GetDest () << "\t" @@ -92,7 +92,7 @@ class StackHelper << route.GetPrefixToUse () << "\t" << std::endl; } - } + } }; int main (int argc, char** argv) @@ -107,32 +107,32 @@ int main (int argc, char** argv) LogComponentEnable ("Ping6Application", LOG_LEVEL_ALL); #endif - CommandLine cmd; + CommandLine cmd; cmd.Parse (argc, argv); - - NS_LOG_INFO ("Create nodes."); - Ptr n0 = CreateObject (); - Ptr r = CreateObject (); - Ptr n1 = CreateObject (); - NodeContainer net1 (n0, r); - NodeContainer net2 (r, n1); - NodeContainer all (n0, r, n1); + NS_LOG_INFO ("Create nodes."); + Ptr n0 = CreateObject (); + Ptr r = CreateObject (); + Ptr n1 = CreateObject (); + + NodeContainer net1 (n0, r); + NodeContainer net2 (r, n1); + NodeContainer all (n0, r, n1); StackHelper stackHelper; - NS_LOG_INFO ("Create IPv6 Internet Stack"); + NS_LOG_INFO ("Create IPv6 Internet Stack"); InternetStackHelper internetv6; internetv6.Install (all); NS_LOG_INFO ("Create channels."); - CsmaHelper csma; + CsmaHelper csma; csma.SetChannelAttribute ("DataRate", DataRateValue (5000000)); csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); - NetDeviceContainer d1 = csma.Install (net1); /* n0 - R */ - NetDeviceContainer d2 = csma.Install (net2); /* R - n1 */ + NetDeviceContainer d1 = csma.Install (net1); /* n0 - R */ + NetDeviceContainer d2 = csma.Install (net2); /* R - n1 */ - NS_LOG_INFO ("Create networks and assign IPv6 Addresses."); - Ipv6AddressHelper ipv6; + NS_LOG_INFO ("Create networks and assign IPv6 Addresses."); + Ipv6AddressHelper ipv6; /* first subnet */ ipv6.NewNetwork (Ipv6Address ("2001:1::"), 64); @@ -208,7 +208,7 @@ int main (int argc, char** argv) /* at the end, RA addresses and routes should be cleared */ Simulator::Schedule (Seconds (10.0), &StackHelper::PrintRoutingTable, &stackHelper, n0); - std::ofstream ascii; + std::ofstream ascii; ascii.open ("radvd-two-prefix.tr"); CsmaHelper::EnablePcapAll (std::string ("radvd-two-prefix"), true); CsmaHelper::EnableAsciiAll (ascii); diff --git a/examples/ipv6/radvd.cc b/examples/ipv6/radvd.cc index dbe05ff87..2c4d52ca4 100644 --- a/examples/ipv6/radvd.cc +++ b/examples/ipv6/radvd.cc @@ -56,31 +56,31 @@ int main (int argc, char** argv) LogComponentEnable ("Ping6Application", LOG_LEVEL_ALL); #endif - CommandLine cmd; + CommandLine cmd; cmd.Parse (argc, argv); - - NS_LOG_INFO ("Create nodes."); - Ptr n0 = CreateObject (); - Ptr r = CreateObject (); - Ptr n1 = CreateObject (); - NodeContainer net1 (n0, r); - NodeContainer net2 (r, n1); - NodeContainer all (n0, r, n1); + NS_LOG_INFO ("Create nodes."); + Ptr n0 = CreateObject (); + Ptr r = CreateObject (); + Ptr n1 = CreateObject (); - NS_LOG_INFO ("Create IPv6 Internet Stack"); + NodeContainer net1 (n0, r); + NodeContainer net2 (r, n1); + NodeContainer all (n0, r, n1); + + NS_LOG_INFO ("Create IPv6 Internet Stack"); InternetStackHelper internetv6; internetv6.Install (all); NS_LOG_INFO ("Create channels."); - CsmaHelper csma; + CsmaHelper csma; csma.SetChannelAttribute ("DataRate", DataRateValue (5000000)); csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); - NetDeviceContainer d1 = csma.Install (net1); /* n0 - R */ - NetDeviceContainer d2 = csma.Install (net2); /* R - n1 */ + NetDeviceContainer d1 = csma.Install (net1); /* n0 - R */ + NetDeviceContainer d2 = csma.Install (net2); /* R - n1 */ - NS_LOG_INFO ("Create networks and assign IPv6 Addresses."); - Ipv6AddressHelper ipv6; + NS_LOG_INFO ("Create networks and assign IPv6 Addresses."); + Ipv6AddressHelper ipv6; /* first subnet */ ipv6.NewNetwork (Ipv6Address ("2001:1::"), 64); @@ -143,7 +143,7 @@ int main (int argc, char** argv) apps.Start (Seconds (2.0)); apps.Stop (Seconds (7.0)); - std::ofstream ascii; + std::ofstream ascii; ascii.open ("radvd.tr"); CsmaHelper::EnablePcapAll (std::string ("radvd"), true); CsmaHelper::EnableAsciiAll (ascii); diff --git a/examples/routing/simple-routing-ping6.cc b/examples/routing/simple-routing-ping6.cc index 5b643e2e0..df14a122b 100644 --- a/examples/routing/simple-routing-ping6.cc +++ b/examples/routing/simple-routing-ping6.cc @@ -45,39 +45,39 @@ NS_LOG_COMPONENT_DEFINE ("SimpleRoutingPing6Example"); */ class StackHelper { - public: +public: - /** - * \brief Add an address to a IPv6 node. - * \param n node - * \param interface interface index - * \param address IPv6 address to add - */ - inline void AddAddress (Ptr& n, uint32_t interface, Ipv6Address address) - { - Ptr ipv6 = n->GetObject (); - ipv6->AddAddress (interface, address); - } + /** + * \brief Add an address to a IPv6 node. + * \param n node + * \param interface interface index + * \param address IPv6 address to add + */ + inline void AddAddress (Ptr& n, uint32_t interface, Ipv6Address address) + { + Ptr ipv6 = n->GetObject (); + ipv6->AddAddress (interface, address); + } - /** - * \brief Print the routing table. - * \param n the node - */ - inline void PrintRoutingTable (Ptr& n) - { - Ptr routing = 0; - Ipv6StaticRoutingHelper routingHelper; - Ptr ipv6 = n->GetObject (); - uint32_t nbRoutes = 0; - Ipv6RoutingTableEntry route; + /** + * \brief Print the routing table. + * \param n the node + */ + inline void PrintRoutingTable (Ptr& n) + { + Ptr routing = 0; + Ipv6StaticRoutingHelper routingHelper; + Ptr ipv6 = n->GetObject (); + uint32_t nbRoutes = 0; + Ipv6RoutingTableEntry route; - routing = routingHelper.GetStaticRouting (ipv6); + routing = routingHelper.GetStaticRouting (ipv6); - std::cout << "Routing table of " << n << " : " << std::endl; - std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" << "Prefix to use" << std::endl; + std::cout << "Routing table of " << n << " : " << std::endl; + std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" << "Prefix to use" << std::endl; - nbRoutes = routing->GetNRoutes (); - for (uint32_t i = 0 ; i < nbRoutes ; i++) + nbRoutes = routing->GetNRoutes (); + for (uint32_t i = 0 ; i < nbRoutes ; i++) { route = routing->GetRoute (i); std::cout << route.GetDest () << "\t" @@ -86,7 +86,7 @@ class StackHelper << route.GetPrefixToUse () << "\t" << std::endl; } - } + } }; int main (int argc, char** argv) @@ -99,38 +99,38 @@ int main (int argc, char** argv) LogComponentEnable ("Ping6Application", LOG_LEVEL_ALL); #endif - CommandLine cmd; + CommandLine cmd; cmd.Parse (argc, argv); StackHelper stackHelper; - - NS_LOG_INFO ("Create nodes."); - Ptr n0 = CreateObject (); - Ptr r = CreateObject (); - Ptr n1 = CreateObject (); - NodeContainer net1 (n0, r); - NodeContainer net2 (r, n1); - NodeContainer all (n0, r, n1); + NS_LOG_INFO ("Create nodes."); + Ptr n0 = CreateObject (); + Ptr r = CreateObject (); + Ptr n1 = CreateObject (); - NS_LOG_INFO ("Create IPv6 Internet Stack"); + NodeContainer net1 (n0, r); + NodeContainer net2 (r, n1); + NodeContainer all (n0, r, n1); + + NS_LOG_INFO ("Create IPv6 Internet Stack"); InternetStackHelper internetv6; internetv6.Install (all); NS_LOG_INFO ("Create channels."); - CsmaHelper csma; + CsmaHelper csma; csma.SetChannelAttribute ("DataRate", DataRateValue (5000000)); csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); - NetDeviceContainer d1 = csma.Install (net1); - NetDeviceContainer d2 = csma.Install (net2); + NetDeviceContainer d1 = csma.Install (net1); + NetDeviceContainer d2 = csma.Install (net2); - NS_LOG_INFO ("Create networks and assign IPv6 Addresses."); - Ipv6AddressHelper ipv6; - ipv6.NewNetwork (Ipv6Address ("2001:1::"), 64); - Ipv6InterfaceContainer i1 = ipv6.Assign (d1); + NS_LOG_INFO ("Create networks and assign IPv6 Addresses."); + Ipv6AddressHelper ipv6; + ipv6.NewNetwork (Ipv6Address ("2001:1::"), 64); + Ipv6InterfaceContainer i1 = ipv6.Assign (d1); i1.SetRouter (1, true); - ipv6.NewNetwork (Ipv6Address ("2001:2::"), 64); - Ipv6InterfaceContainer i2 = ipv6.Assign (d2); + ipv6.NewNetwork (Ipv6Address ("2001:2::"), 64); + Ipv6InterfaceContainer i2 = ipv6.Assign (d2); i2.SetRouter (0, true); stackHelper.PrintRoutingTable(n0); @@ -151,7 +151,7 @@ int main (int argc, char** argv) apps.Start (Seconds (2.0)); apps.Stop (Seconds (20.0)); - std::ofstream ascii; + std::ofstream ascii; ascii.open ("simple-routing-ping6.tr"); CsmaHelper::EnablePcapAll (std::string ("simple-routing-ping6"), true); CsmaHelper::EnableAsciiAll (ascii); diff --git a/src/applications/ping6/ping6.cc b/src/applications/ping6/ping6.cc index e00e4e821..c17fe7934 100644 --- a/src/applications/ping6/ping6.cc +++ b/src/applications/ping6/ping6.cc @@ -48,30 +48,30 @@ TypeId Ping6::GetTypeId () .SetParent() .AddConstructor() .AddAttribute ("MaxPackets", - "The maximum number of packets the application will send", - UintegerValue (100), - MakeUintegerAccessor (&Ping6::m_count), - MakeUintegerChecker()) + "The maximum number of packets the application will send", + UintegerValue (100), + MakeUintegerAccessor (&Ping6::m_count), + MakeUintegerChecker()) .AddAttribute ("Interval", - "The time to wait between packets", - TimeValue (Seconds (1.0)), - MakeTimeAccessor (&Ping6::m_interval), - MakeTimeChecker ()) + "The time to wait between packets", + TimeValue (Seconds (1.0)), + MakeTimeAccessor (&Ping6::m_interval), + MakeTimeChecker ()) .AddAttribute ("RemoteIpv6", - "The Ipv6Address of the outbound packets", - Ipv6AddressValue (), - MakeIpv6AddressAccessor (&Ping6::m_peerAddress), - MakeIpv6AddressChecker ()) + "The Ipv6Address of the outbound packets", + Ipv6AddressValue (), + MakeIpv6AddressAccessor (&Ping6::m_peerAddress), + MakeIpv6AddressChecker ()) .AddAttribute ("LocalIpv6", - "Local Ipv6Address of the sender", - Ipv6AddressValue (), - MakeIpv6AddressAccessor (&Ping6::m_localAddress), - MakeIpv6AddressChecker ()) + "Local Ipv6Address of the sender", + Ipv6AddressValue (), + MakeIpv6AddressAccessor (&Ping6::m_localAddress), + MakeIpv6AddressChecker ()) .AddAttribute ("PacketSize", - "Size of packets generated", - UintegerValue (100), - MakeUintegerAccessor (&Ping6::m_size), - MakeUintegerChecker()) + "Size of packets generated", + UintegerValue (100), + MakeUintegerAccessor (&Ping6::m_size), + MakeUintegerChecker()) ; return tid; } @@ -102,17 +102,17 @@ void Ping6::StartApplication () NS_LOG_FUNCTION_NOARGS (); if (!m_socket) - { - TypeId tid = TypeId::LookupByName ("ns3::Ipv6RawSocketFactory"); - m_socket = Socket::CreateSocket (GetNode (), tid); + { + TypeId tid = TypeId::LookupByName ("ns3::Ipv6RawSocketFactory"); + m_socket = Socket::CreateSocket (GetNode (), tid); - NS_ASSERT (m_socket); + NS_ASSERT (m_socket); - m_socket->Bind (Inet6SocketAddress (m_localAddress, 0)); - m_socket->Connect (Inet6SocketAddress (m_peerAddress, 0)); - m_socket->SetAttribute ("Protocol", UintegerValue (Ipv6Header::IPV6_ICMPV6)); - m_socket->SetRecvCallback (MakeCallback (&Ping6::HandleRead, this)); - } + m_socket->Bind (Inet6SocketAddress (m_localAddress, 0)); + m_socket->Connect (Inet6SocketAddress (m_peerAddress, 0)); + m_socket->SetAttribute ("Protocol", UintegerValue (Ipv6Header::IPV6_ICMPV6)); + m_socket->SetRecvCallback (MakeCallback (&Ping6::HandleRead, this)); + } ScheduleTransmit (Seconds (0.)); } @@ -134,9 +134,9 @@ void Ping6::StopApplication () NS_LOG_FUNCTION_NOARGS (); if (m_socket) - { - m_socket->SetRecvCallback (MakeNullCallback >()); - } + { + m_socket->SetRecvCallback (MakeNullCallback >()); + } Simulator::Cancel (m_sendEvent); } @@ -167,16 +167,16 @@ void Ping6::Send () Ptr ipv6 = GetNode ()->GetObject (); if (m_ifIndex > 0) - { - /* hack to have ifIndex in Ipv6RawSocketImpl - * maybe add a SetIfIndex in Ipv6RawSocketImpl directly - */ - src = GetNode ()->GetObject ()->GetAddress (m_ifIndex, 0).GetAddress (); - } + { + /* hack to have ifIndex in Ipv6RawSocketImpl + * maybe add a SetIfIndex in Ipv6RawSocketImpl directly + */ + src = GetNode ()->GetObject ()->GetAddress (m_ifIndex, 0).GetAddress (); + } else - { - src = m_localAddress; - } + { + src = m_localAddress; + } NS_ASSERT_MSG (m_size >= 4, "ICMPv6 echo request payload size must be >= 4"); data[0] = 0xDE; @@ -191,7 +191,7 @@ void Ping6::Send () req.SetId (0xBEEF); req.SetSeq (m_seq); m_seq++; - + /* we do not calculate pseudo header checksum here, because we are not sure about * source IPv6 address. Checksum is calculated in Ipv6RawSocketImpl. */ @@ -201,16 +201,16 @@ void Ping6::Send () /* use Loose Routing (routing type 0) */ if (m_routers.size ()) - { - Ipv6ExtensionLooseRoutingHeader routingHeader; - routingHeader.SetNextHeader (Ipv6Header::IPV6_ICMPV6); - routingHeader.SetLength (m_routers.size () * 16 + 8); - routingHeader.SetTypeRouting (0); - routingHeader.SetSegmentsLeft (m_routers.size ()); - routingHeader.SetRoutersAddress (m_routers); - p->AddHeader (routingHeader); - m_socket->SetAttribute ("Protocol", UintegerValue (Ipv6Header::IPV6_EXT_ROUTING)); - } + { + Ipv6ExtensionLooseRoutingHeader routingHeader; + routingHeader.SetNextHeader (Ipv6Header::IPV6_ICMPV6); + routingHeader.SetLength (m_routers.size () * 16 + 8); + routingHeader.SetTypeRouting (0); + routingHeader.SetSegmentsLeft (m_routers.size ()); + routingHeader.SetRoutersAddress (m_routers); + p->AddHeader (routingHeader); + m_socket->SetAttribute ("Protocol", UintegerValue (Ipv6Header::IPV6_EXT_ROUTING)); + } m_socket->Send (p, 0); ++m_sent; @@ -218,9 +218,9 @@ void Ping6::Send () NS_LOG_INFO ("Sent " << p->GetSize () << " bytes to " << m_peerAddress); if (m_sent < m_count) - { - ScheduleTransmit (m_interval); - } + { + ScheduleTransmit (m_interval); + } } void Ping6::HandleRead (Ptr socket) @@ -230,28 +230,28 @@ void Ping6::HandleRead (Ptr socket) Ptr packet=0; Address from; while (packet = socket->RecvFrom (from)) - { - if (Inet6SocketAddress::IsMatchingType (from)) { - Ipv6Header hdr; - Icmpv6Echo reply (0); - Inet6SocketAddress address = Inet6SocketAddress::ConvertFrom (from); + if (Inet6SocketAddress::IsMatchingType (from)) + { + Ipv6Header hdr; + Icmpv6Echo reply (0); + Inet6SocketAddress address = Inet6SocketAddress::ConvertFrom (from); - packet->RemoveHeader (hdr); + packet->RemoveHeader (hdr); - switch (*packet->PeekData ()) - { - case Icmpv6Header::ICMPV6_ECHO_REPLY: - packet->RemoveHeader (reply); + switch (*packet->PeekData ()) + { + case Icmpv6Header::ICMPV6_ECHO_REPLY: + packet->RemoveHeader (reply); - NS_LOG_INFO ("Received Echo Reply size = " << std::dec << packet->GetSize () << " bytes from " << address.GetIpv6 () << " id = " << (uint16_t)reply.GetId () << " seq = " << (uint16_t)reply.GetSeq ()); - break; - default: - /* other type, discard */ - break; - } + NS_LOG_INFO ("Received Echo Reply size = " << std::dec << packet->GetSize () << " bytes from " << address.GetIpv6 () << " id = " << (uint16_t)reply.GetId () << " seq = " << (uint16_t)reply.GetSeq ()); + break; + default: + /* other type, discard */ + break; + } + } } - } } } /* namespace ns3 */ diff --git a/src/applications/ping6/ping6.h b/src/applications/ping6/ping6.h index 49b9d6954..52107106a 100644 --- a/src/applications/ping6/ping6.h +++ b/src/applications/ping6/ping6.h @@ -44,142 +44,142 @@ class Socket; */ class Ping6 : public Application { - public: - /** - * \brief Get the type ID. - * \return type ID - */ - static TypeId GetTypeId (); +public: + /** + * \brief Get the type ID. + * \return type ID + */ + static TypeId GetTypeId (); - /** - * \brief Constructor. - */ - Ping6 (); + /** + * \brief Constructor. + */ + Ping6 (); - /** - * \brief Destructor. - */ - virtual ~Ping6 (); + /** + * \brief Destructor. + */ + virtual ~Ping6 (); - /** - * \brief Set the local address. - * \param ipv6 the local IPv6 address - */ - void SetLocal (Ipv6Address ipv6); + /** + * \brief Set the local address. + * \param ipv6 the local IPv6 address + */ + void SetLocal (Ipv6Address ipv6); - /** - * \brief Set the remote peer. - * \param ipv6 IPv6 address of the peer - */ - void SetRemote (Ipv6Address ipv6); + /** + * \brief Set the remote peer. + * \param ipv6 IPv6 address of the peer + */ + void SetRemote (Ipv6Address ipv6); - /** - * \brief Set the out interface index. - * This is to send to link-local (unicast or multicast) address - * when a node has multiple interfaces. - * \param ifIndex interface index - */ - void SetIfIndex (uint32_t ifIndex); + /** + * \brief Set the out interface index. + * This is to send to link-local (unicast or multicast) address + * when a node has multiple interfaces. + * \param ifIndex interface index + */ + void SetIfIndex (uint32_t ifIndex); - /** - * \brief Set routers for routing type 0 (loose routing). - * \param routers routers addresses - */ - void SetRouters(std::vector routers); + /** + * \brief Set routers for routing type 0 (loose routing). + * \param routers routers addresses + */ + void SetRouters(std::vector routers); - protected: - /** - * \brief Dispose this object; - */ - virtual void DoDispose (); +protected: + /** + * \brief Dispose this object; + */ + virtual void DoDispose (); - private: - /** - * \brief Start the application. - */ - virtual void StartApplication (); +private: + /** + * \brief Start the application. + */ + virtual void StartApplication (); - /** - * \brief Stop the application. - */ - virtual void StopApplication (); + /** + * \brief Stop the application. + */ + virtual void StopApplication (); - /** - * \brief Schedule sending a packet. - * \param dt interval between packet - */ - void ScheduleTransmit (Time dt); + /** + * \brief Schedule sending a packet. + * \param dt interval between packet + */ + void ScheduleTransmit (Time dt); - /** - * \brief Send a packet. - */ - void Send (); + /** + * \brief Send a packet. + */ + void Send (); - /** - * \brief Receive method. - * \param socket socket that receive a packet - */ - void HandleRead (Ptr socket); + /** + * \brief Receive method. + * \param socket socket that receive a packet + */ + void HandleRead (Ptr socket); - /** - * \brief Peer IPv6 address. - */ - Ipv6Address m_address; + /** + * \brief Peer IPv6 address. + */ + Ipv6Address m_address; - /** - * \brief Number of "Echo request" packets that will be sent. - */ - uint32_t m_count; + /** + * \brief Number of "Echo request" packets that will be sent. + */ + uint32_t m_count; - /** - * \brief Number of packets sent. - */ - uint32_t m_sent; + /** + * \brief Number of packets sent. + */ + uint32_t m_sent; - /** - * \brief Size of the packet. - */ - uint32_t m_size; + /** + * \brief Size of the packet. + */ + uint32_t m_size; - /** - * \brief Intervall between packets sent. - */ - Time m_interval; + /** + * \brief Intervall between packets sent. + */ + Time m_interval; - /** - * \brief Local address. - */ - Ipv6Address m_localAddress; + /** + * \brief Local address. + */ + Ipv6Address m_localAddress; - /** - * \brief Peer address. - */ - Ipv6Address m_peerAddress; + /** + * \brief Peer address. + */ + Ipv6Address m_peerAddress; - /** - * \brief Local socket. - */ - Ptr m_socket; + /** + * \brief Local socket. + */ + Ptr m_socket; - /** - * \brief Sequence number. - */ - uint16_t m_seq; + /** + * \brief Sequence number. + */ + uint16_t m_seq; - /** - * \brief Event ID. - */ - EventId m_sendEvent; + /** + * \brief Event ID. + */ + EventId m_sendEvent; - /** - * \brief Out interface (i.e. for link-local communication). - */ - uint32_t m_ifIndex; + /** + * \brief Out interface (i.e. for link-local communication). + */ + uint32_t m_ifIndex; - /** - * \brief Routers addresses for routing type 0. - */ - std::vector m_routers; + /** + * \brief Routers addresses for routing type 0. + */ + std::vector m_routers; }; } /* namespace ns3 */ diff --git a/src/applications/radvd/radvd-interface.h b/src/applications/radvd/radvd-interface.h index 046c9b6e4..3bf4ee95f 100644 --- a/src/applications/radvd/radvd-interface.h +++ b/src/applications/radvd/radvd-interface.h @@ -35,384 +35,384 @@ namespace ns3 */ class RadvdInterface : public SimpleRefCount { - public: - /** - * \brief Constructor. - * \param interface interface index - */ - RadvdInterface (uint32_t interface); +public: + /** + * \brief Constructor. + * \param interface interface index + */ + RadvdInterface (uint32_t interface); - /** - * \brief Constructor. - * \param interface interface index - * \param maxRtrAdvInterval maximum RA interval (ms) - * \param minRtrAdvInterval minimum RA interval (ms) - */ - RadvdInterface (uint32_t interface, uint32_t maxRtrAdvInterval, uint32_t minRtrAdvInterval); + /** + * \brief Constructor. + * \param interface interface index + * \param maxRtrAdvInterval maximum RA interval (ms) + * \param minRtrAdvInterval minimum RA interval (ms) + */ + RadvdInterface (uint32_t interface, uint32_t maxRtrAdvInterval, uint32_t minRtrAdvInterval); - /** - * \brief Destructor. - */ - ~RadvdInterface (); + /** + * \brief Destructor. + */ + ~RadvdInterface (); - /** - * \brief Get interface index for this configuration. - * \return interface index - */ - uint32_t GetInterface () const; + /** + * \brief Get interface index for this configuration. + * \return interface index + */ + uint32_t GetInterface () const; - /** - * \brief Get list of prefixes advertised for this interface. - * \return list of IPv6 prefixes - */ - std::list > GetPrefixes () const; + /** + * \brief Get list of prefixes advertised for this interface. + * \return list of IPv6 prefixes + */ + std::list > GetPrefixes () const; - /** - * \brief Add a prefix to advertise on interface. - * \param routerPrefix prefix to advertise - */ - void AddPrefix (Ptr routerPrefix); - - /** - * \brief Is send advert enabled (periodic RA and reply to RS) ? - * \return send advert flag - */ - bool IsSendAdvert () const; - - /** - * \brief Set send advert flag. - * \param sendAdvert value - */ - void SetSendAdvert (bool sendAdvert); + /** + * \brief Add a prefix to advertise on interface. + * \param routerPrefix prefix to advertise + */ + void AddPrefix (Ptr routerPrefix); - /** - * \brief Get maximum RA interval. - * \return RA interval (ms) - */ - uint32_t GetMaxRtrAdvInterval () const; + /** + * \brief Is send advert enabled (periodic RA and reply to RS) ? + * \return send advert flag + */ + bool IsSendAdvert () const; - /** - * \brief Get maximum RA interval. - * \param maxRtrAdvInterval RA interval (ms) - */ - void SetMaxRtrAdvInterval (uint32_t maxRtrAdvInterval); + /** + * \brief Set send advert flag. + * \param sendAdvert value + */ + void SetSendAdvert (bool sendAdvert); - /** - * \brief Get minimum RA interval - * \return RA interval (ms) - */ - uint32_t GetMinRtrAdvInterval () const; - - /** - * \brief Get minimum RA interval - * \param minRtrAdvInterval RA interval (ms). - */ - void SetMinRtrAdvInterval (uint32_t minRtrAdvInterval); + /** + * \brief Get maximum RA interval. + * \return RA interval (ms) + */ + uint32_t GetMaxRtrAdvInterval () const; - /** - * \brief Get minimum delay between RAs. - * \return minimum delay (ms) - */ - uint32_t GetMinDelayBetweenRAs () const; - - /** - * \brief Set minimum delay between RAs. - * \param minDelayBetweenRAs minimum delay (ms) - */ - void SetMinDelayBetweenRAs (uint32_t minDelayBetweenRAs); + /** + * \brief Get maximum RA interval. + * \param maxRtrAdvInterval RA interval (ms) + */ + void SetMaxRtrAdvInterval (uint32_t maxRtrAdvInterval); - /** - * \brief Is managed flag enabled ? - * \return managed flag - */ - bool IsManagedFlag () const; - - /** - * \brief Set managed flag - * \param managedFlag value - */ - void SetManagedFlag (bool managedFlag); + /** + * \brief Get minimum RA interval + * \return RA interval (ms) + */ + uint32_t GetMinRtrAdvInterval () const; - /** - * \brief Is "other config" flag enabled ? - * \return other config flag - */ - bool IsOtherConfigFlag () const; - - /** - * \brief Set "other config" flag - * \param otherConfigFlag value - */ - void SetOtherConfigFlag (bool otherConfigFlag); + /** + * \brief Get minimum RA interval + * \param minRtrAdvInterval RA interval (ms). + */ + void SetMinRtrAdvInterval (uint32_t minRtrAdvInterval); - /** - * \brief Get link MTU. - * \return link MTU - */ - uint32_t GetLinkMtu () const; - - /** - * \brief Set link MTU. - * \param linkMtu link MTU - */ - void SetLinkMtu (uint32_t linkMtu); + /** + * \brief Get minimum delay between RAs. + * \return minimum delay (ms) + */ + uint32_t GetMinDelayBetweenRAs () const; - /** - * \brief Get reachable time. - * \return reachable time - */ - uint32_t GetReachableTime () const; - - /** - * \brief Set reachable time. - * \param reachableTime reachable time - */ - void SetReachableTime (uint32_t reachableTime); + /** + * \brief Set minimum delay between RAs. + * \param minDelayBetweenRAs minimum delay (ms) + */ + void SetMinDelayBetweenRAs (uint32_t minDelayBetweenRAs); - /** - * \brief Get default lifetime. - * \return default lifetime - */ - uint32_t GetDefaultLifeTime () const; - - /** - * \brief Set default lifetime. - * \param defaultLifeTime default lifetime - */ - void SetDefaultLifeTime (uint32_t defaultLifeTime); + /** + * \brief Is managed flag enabled ? + * \return managed flag + */ + bool IsManagedFlag () const; - /** - * \brief Get retransmission timer. - * \return retransmission timer - */ - uint32_t GetRetransTimer () const; - - /** - * \brief Set retransmission timer. - * \param retransTimer retransmission timer - */ - void SetRetransTimer (uint32_t retransTimer); + /** + * \brief Set managed flag + * \param managedFlag value + */ + void SetManagedFlag (bool managedFlag); - /** - * \brief Get current hop limit. - * \return current hop limit for the link - */ - uint8_t GetCurHopLimit () const; - - /** - * \brief Set current hop limit. - * \param curHopLimit current hop limit for the link - */ - void SetCurHopLimit (uint8_t curHopLimit); + /** + * \brief Is "other config" flag enabled ? + * \return other config flag + */ + bool IsOtherConfigFlag () const; - /** - * \brief Get default preference. - * \return default preference - */ - uint8_t GetDefaultPreference () const; - - /** - * \brief Set default preference. - * \param defaultPreference default preference - */ - void SetDefaultPreference (uint8_t defaultPreference); + /** + * \brief Set "other config" flag + * \param otherConfigFlag value + */ + void SetOtherConfigFlag (bool otherConfigFlag); - /** - * \brief Is source LLA option should be included in RA ? - * \return true if source address is added in RA, false otherwise - */ - bool IsSourceLLAddress () const; - - /** - * \brief Set flag to add or not LLA to RA. - * \param sourceLLAddress value - */ - void SetSourceLLAddress (bool sourceLLAddress); + /** + * \brief Get link MTU. + * \return link MTU + */ + uint32_t GetLinkMtu () const; - /** - * \brief Is "home agent" flag enabled ? - * \return "home agent" flag - */ - bool IsHomeAgentFlag () const; - - /** - * \brief Set "home agent" flag. - * \param homeAgentFlag value - */ - void SetHomeAgentFlag (bool homeAgentFlag); + /** + * \brief Set link MTU. + * \param linkMtu link MTU + */ + void SetLinkMtu (uint32_t linkMtu); - /** - * \brief Is Home Agent Information option should be included in RA ? - * \return true if HA information option is added in RA, false otherwise - */ - bool IsHomeAgentInfo () const; - - /** - * \brief Set flag to add or not HA information option to RA. - * \param homeAgentFlag value - */ - void SetHomeAgentInfo (bool homeAgentFlag); - - /** - * \brief Get home agent lifetime. - * \return home agent lifetime - */ - uint32_t GetHomeAgentLifeTime () const; - - /** - * \brief Set home agent lifetime. - * \param homeAgentLifeTime home agent lifetime - */ - void SetHomeAgentLifeTime (uint32_t homeAgentLifeTime); - - /** - * \brief Get home agent preference. - * \return home agent preference - */ - uint32_t GetHomeAgentPreference () const; - - /** - * \brief Set home agent preference. - * \param homeAgentPreference home agent preference - */ - void SetHomeAgentPreference (uint32_t homeAgentPreference); + /** + * \brief Get reachable time. + * \return reachable time + */ + uint32_t GetReachableTime () const; - /** - * \brief Is "mobile router support" flag enabled ? - * \return "mobile router support" flag - */ - bool IsMobRtrSupportFlag () const; - - /** - * \brief Set "mobile router support" flag. - * \param mobRtrSupportFlag value - */ - void SetMobRtrSupportFlag (bool mobRtrSupportFlag); - - /** - * \brief Is advertisement interval option should be included in RA ? - * \return true if advertisement interval option is added in RA, false otherwise - */ - bool IsIntervalOpt () const; - - /** - * \brief Set flag to add or not advertisement interval to RA. - * \param intervalOpt value - */ - void SetIntervalOpt (bool intervalOpt); + /** + * \brief Set reachable time. + * \param reachableTime reachable time + */ + void SetReachableTime (uint32_t reachableTime); - private: - typedef std::list > RadvdPrefixList; - typedef std::list >::iterator RadvdPrefixListI; + /** + * \brief Get default lifetime. + * \return default lifetime + */ + uint32_t GetDefaultLifeTime () const; - /** - * \brief Interface to advertise RA. - */ - uint32_t m_interface; + /** + * \brief Set default lifetime. + * \param defaultLifeTime default lifetime + */ + void SetDefaultLifeTime (uint32_t defaultLifeTime); - /** - * \brief List of prefixes to advertise. - */ - RadvdPrefixList m_prefixes; + /** + * \brief Get retransmission timer. + * \return retransmission timer + */ + uint32_t GetRetransTimer () const; - /** - * \brief Flag whether or not router sends periodic RA and respond to RS. - */ - bool m_sendAdvert; + /** + * \brief Set retransmission timer. + * \param retransTimer retransmission timer + */ + void SetRetransTimer (uint32_t retransTimer); - /** - * \brief Maximum RA interval in milliseconds. - */ - uint32_t m_maxRtrAdvInterval; + /** + * \brief Get current hop limit. + * \return current hop limit for the link + */ + uint8_t GetCurHopLimit () const; - /** - * \brief Minimum RA interval in milliseconds. - */ - uint32_t m_minRtrAdvInterval; + /** + * \brief Set current hop limit. + * \param curHopLimit current hop limit for the link + */ + void SetCurHopLimit (uint8_t curHopLimit); - /** - * \brief Minimum delay between RA in milliseconds. - */ - uint32_t m_minDelayBetweenRAs; + /** + * \brief Get default preference. + * \return default preference + */ + uint8_t GetDefaultPreference () const; - /** - * \brief Managed flag. If true host use the stateful protocol for address autoconfiguration. - */ - bool m_managedFlag; + /** + * \brief Set default preference. + * \param defaultPreference default preference + */ + void SetDefaultPreference (uint8_t defaultPreference); - /** - * \brief Other configuration flag. If true host use stateful protocol for other (non-address) information. - */ - bool m_otherConfigFlag; + /** + * \brief Is source LLA option should be included in RA ? + * \return true if source address is added in RA, false otherwise + */ + bool IsSourceLLAddress () const; - /** - * \brief Link MTU to use. - */ - uint32_t m_linkMtu; + /** + * \brief Set flag to add or not LLA to RA. + * \param sourceLLAddress value + */ + void SetSourceLLAddress (bool sourceLLAddress); - /** - * \brief Reachable time in milliseconds. - */ - uint32_t m_reachableTime; + /** + * \brief Is "home agent" flag enabled ? + * \return "home agent" flag + */ + bool IsHomeAgentFlag () const; - /** - * \brief Retransmission timer in milliseconds. - */ - uint32_t m_retransTimer; + /** + * \brief Set "home agent" flag. + * \param homeAgentFlag value + */ + void SetHomeAgentFlag (bool homeAgentFlag); - /** - * \brief Current hop limit (TTL). - */ - uint32_t m_curHopLimit; + /** + * \brief Is Home Agent Information option should be included in RA ? + * \return true if HA information option is added in RA, false otherwise + */ + bool IsHomeAgentInfo () const; - /** - * \brief Default life time in seconds. - */ - uint32_t m_defaultLifeTime; + /** + * \brief Set flag to add or not HA information option to RA. + * \param homeAgentFlag value + */ + void SetHomeAgentInfo (bool homeAgentFlag); - /** - * \brief Preference associated with default router. - * 0 = low - * 1 = medium - * 2 = high - */ - uint8_t m_defaultPreference; + /** + * \brief Get home agent lifetime. + * \return home agent lifetime + */ + uint32_t GetHomeAgentLifeTime () const; - /** - * \brief Flag to add link-layer address in RA. - */ - bool m_sourceLLAddress; + /** + * \brief Set home agent lifetime. + * \param homeAgentLifeTime home agent lifetime + */ + void SetHomeAgentLifeTime (uint32_t homeAgentLifeTime); - /** - * \brief Flag to add HA (home agent) flag in RA. - */ - bool m_homeAgentFlag; + /** + * \brief Get home agent preference. + * \return home agent preference + */ + uint32_t GetHomeAgentPreference () const; - /** - * \brief Flag to add Home Agent Information option (Mobile IPv6). - * Currently not implemented. - */ - bool m_homeAgentInfo; + /** + * \brief Set home agent preference. + * \param homeAgentPreference home agent preference + */ + void SetHomeAgentPreference (uint32_t homeAgentPreference); - /** - * \brief Home agent lifetime in seconds. Ignored if home agent info is not set. - */ - uint32_t m_homeAgentLifeTime; + /** + * \brief Is "mobile router support" flag enabled ? + * \return "mobile router support" flag + */ + bool IsMobRtrSupportFlag () const; - /** - * \brief Home agent preference. Ignored if home agent info is not set. - */ - uint32_t m_homeAgentPreference; + /** + * \brief Set "mobile router support" flag. + * \param mobRtrSupportFlag value + */ + void SetMobRtrSupportFlag (bool mobRtrSupportFlag); - /** - * \brief Flag for HA to signals it supports Mobile Router registrations (NEMO Basic). - */ - bool m_mobRtrSupportFlag; + /** + * \brief Is advertisement interval option should be included in RA ? + * \return true if advertisement interval option is added in RA, false otherwise + */ + bool IsIntervalOpt () const; - /** - * \brief Flag to add Advertisement Interval option in RA. - */ - bool m_intervalOpt; + /** + * \brief Set flag to add or not advertisement interval to RA. + * \param intervalOpt value + */ + void SetIntervalOpt (bool intervalOpt); + +private: + typedef std::list > RadvdPrefixList; + typedef std::list >::iterator RadvdPrefixListI; + + /** + * \brief Interface to advertise RA. + */ + uint32_t m_interface; + + /** + * \brief List of prefixes to advertise. + */ + RadvdPrefixList m_prefixes; + + /** + * \brief Flag whether or not router sends periodic RA and respond to RS. + */ + bool m_sendAdvert; + + /** + * \brief Maximum RA interval in milliseconds. + */ + uint32_t m_maxRtrAdvInterval; + + /** + * \brief Minimum RA interval in milliseconds. + */ + uint32_t m_minRtrAdvInterval; + + /** + * \brief Minimum delay between RA in milliseconds. + */ + uint32_t m_minDelayBetweenRAs; + + /** + * \brief Managed flag. If true host use the stateful protocol for address autoconfiguration. + */ + bool m_managedFlag; + + /** + * \brief Other configuration flag. If true host use stateful protocol for other (non-address) information. + */ + bool m_otherConfigFlag; + + /** + * \brief Link MTU to use. + */ + uint32_t m_linkMtu; + + /** + * \brief Reachable time in milliseconds. + */ + uint32_t m_reachableTime; + + /** + * \brief Retransmission timer in milliseconds. + */ + uint32_t m_retransTimer; + + /** + * \brief Current hop limit (TTL). + */ + uint32_t m_curHopLimit; + + /** + * \brief Default life time in seconds. + */ + uint32_t m_defaultLifeTime; + + /** + * \brief Preference associated with default router. + * 0 = low + * 1 = medium + * 2 = high + */ + uint8_t m_defaultPreference; + + /** + * \brief Flag to add link-layer address in RA. + */ + bool m_sourceLLAddress; + + /** + * \brief Flag to add HA (home agent) flag in RA. + */ + bool m_homeAgentFlag; + + /** + * \brief Flag to add Home Agent Information option (Mobile IPv6). + * Currently not implemented. + */ + bool m_homeAgentInfo; + + /** + * \brief Home agent lifetime in seconds. Ignored if home agent info is not set. + */ + uint32_t m_homeAgentLifeTime; + + /** + * \brief Home agent preference. Ignored if home agent info is not set. + */ + uint32_t m_homeAgentPreference; + + /** + * \brief Flag for HA to signals it supports Mobile Router registrations (NEMO Basic). + */ + bool m_mobRtrSupportFlag; + + /** + * \brief Flag to add Advertisement Interval option in RA. + */ + bool m_intervalOpt; }; } /* namespace ns3 */ diff --git a/src/applications/radvd/radvd-prefix.h b/src/applications/radvd/radvd-prefix.h index 70b02806a..feaaaa254 100644 --- a/src/applications/radvd/radvd-prefix.h +++ b/src/applications/radvd/radvd-prefix.h @@ -36,144 +36,144 @@ namespace ns3 */ class RadvdPrefix : public SimpleRefCount { - public: - /** - * \brief Constructor. - * \param network network prefix advertised - * \param prefixLength prefix length ( 0 < x <= 128) - * \param preferredLifeTime preferred life time in seconds (default 7 days) - * \param validLifeTime valid life time in seconds (default 30 days) - * \param onLinkFlag on link flag - * \param autonomousFlag autonomous link flag - * \param routerAddrFlag router address flag (for Mobile IPv6) - */ - RadvdPrefix (Ipv6Address network, uint8_t prefixLength, uint32_t preferredLifeTime = 604800, uint32_t validLifeTime = 2592000, bool onLinkFlag = true, bool autonomousFlag = true, bool routerAddrFlag = false); +public: + /** + * \brief Constructor. + * \param network network prefix advertised + * \param prefixLength prefix length ( 0 < x <= 128) + * \param preferredLifeTime preferred life time in seconds (default 7 days) + * \param validLifeTime valid life time in seconds (default 30 days) + * \param onLinkFlag on link flag + * \param autonomousFlag autonomous link flag + * \param routerAddrFlag router address flag (for Mobile IPv6) + */ + RadvdPrefix (Ipv6Address network, uint8_t prefixLength, uint32_t preferredLifeTime = 604800, uint32_t validLifeTime = 2592000, bool onLinkFlag = true, bool autonomousFlag = true, bool routerAddrFlag = false); - /** - * \brief Destructor. - */ - ~RadvdPrefix (); + /** + * \brief Destructor. + */ + ~RadvdPrefix (); - /** - * \brief Get network prefix. - * \return network prefix - */ - Ipv6Address GetNetwork () const; + /** + * \brief Get network prefix. + * \return network prefix + */ + Ipv6Address GetNetwork () const; - /** - * \brief Set network prefix. - * \param network network prefix - */ - void SetNetwork (Ipv6Address network); + /** + * \brief Set network prefix. + * \param network network prefix + */ + void SetNetwork (Ipv6Address network); - /** - * \brief Get prefix length. - * \return prefix length - */ - uint8_t GetPrefixLength () const; + /** + * \brief Get prefix length. + * \return prefix length + */ + uint8_t GetPrefixLength () const; - /** - * \brief Set prefix length. - * \param prefixLength prefix length - */ - void SetPrefixLength (uint8_t prefixLength); + /** + * \brief Set prefix length. + * \param prefixLength prefix length + */ + void SetPrefixLength (uint8_t prefixLength); - /** - * \brief Get preferred lifetime. - * \return lifetime - */ - uint32_t GetPreferredLifeTime () const; + /** + * \brief Get preferred lifetime. + * \return lifetime + */ + uint32_t GetPreferredLifeTime () const; - /** - * \brief Set preferred lifetime. - * \param preferredLifeTime lifetime - */ - void SetPreferredLifeTime (uint32_t preferredLifeTime); + /** + * \brief Set preferred lifetime. + * \param preferredLifeTime lifetime + */ + void SetPreferredLifeTime (uint32_t preferredLifeTime); - /** - * \brief Get valid lifetime. - * \return lifetime - */ - uint32_t GetValidLifeTime () const; + /** + * \brief Get valid lifetime. + * \return lifetime + */ + uint32_t GetValidLifeTime () const; - /** - * \brief Set valid lifetime. - * \param validLifeTime lifetime - */ - void SetValidLifeTime (uint32_t validLifeTime); + /** + * \brief Set valid lifetime. + * \param validLifeTime lifetime + */ + void SetValidLifeTime (uint32_t validLifeTime); - /** - * \brief Is on-link flag ? - * \return true if on-link is activated, false otherwise - */ - bool IsOnLinkFlag () const; + /** + * \brief Is on-link flag ? + * \return true if on-link is activated, false otherwise + */ + bool IsOnLinkFlag () const; - /** - * \brief Set on-link flag. - * \param onLinkFlag value - */ - void SetOnLinkFlag (bool onLinkFlag); + /** + * \brief Set on-link flag. + * \param onLinkFlag value + */ + void SetOnLinkFlag (bool onLinkFlag); - /** - * \brief Is autonomous flag ? - * \return true if autonomous is activated, false otherwise - */ - bool IsAutonomousFlag () const; + /** + * \brief Is autonomous flag ? + * \return true if autonomous is activated, false otherwise + */ + bool IsAutonomousFlag () const; - /** - * \brief Set autonomous flag. - * \param autonomousFlag value - */ - void SetAutonomousFlag (bool autonomousFlag); + /** + * \brief Set autonomous flag. + * \param autonomousFlag value + */ + void SetAutonomousFlag (bool autonomousFlag); - /** - * \brief Is router address flag ? - * \return true if router address is activated, false otherwise - */ - bool IsRouterAddrFlag () const; + /** + * \brief Is router address flag ? + * \return true if router address is activated, false otherwise + */ + bool IsRouterAddrFlag () const; - /** - * \brief Set router address flag. - * \param routerAddrFlag value - */ - void SetRouterAddrFlag (bool routerAddrFlag); + /** + * \brief Set router address flag. + * \param routerAddrFlag value + */ + void SetRouterAddrFlag (bool routerAddrFlag); - private: - /** - * \brief Network prefix. - */ - Ipv6Address m_network; +private: + /** + * \brief Network prefix. + */ + Ipv6Address m_network; - /** - * \brief Prefix length. - */ - uint8_t m_prefixLength; + /** + * \brief Prefix length. + */ + uint8_t m_prefixLength; - /** - * \brief Preferred time. - */ - uint32_t m_preferredLifeTime; + /** + * \brief Preferred time. + */ + uint32_t m_preferredLifeTime; - /** - * \brief Valid time. - */ - uint32_t m_validLifeTime; + /** + * \brief Valid time. + */ + uint32_t m_validLifeTime; - /** - * \brief On link flag, indicates that this prefix can be used for on-link determination. - */ - bool m_onLinkFlag; + /** + * \brief On link flag, indicates that this prefix can be used for on-link determination. + */ + bool m_onLinkFlag; - /** - * \brief Autonomous flag, it is used for autonomous address configuration (RFC 2462). - */ - bool m_autonomousFlag; + /** + * \brief Autonomous flag, it is used for autonomous address configuration (RFC 2462). + */ + bool m_autonomousFlag; - /** - * \brief Router address flag, indicates that router address is sent instead - * of network prefix as is required by Mobile IPv6. - */ - bool m_routerAddrFlag; + /** + * \brief Router address flag, indicates that router address is sent instead + * of network prefix as is required by Mobile IPv6. + */ + bool m_routerAddrFlag; }; } /* namespace ns3 */ diff --git a/src/applications/radvd/radvd.cc b/src/applications/radvd/radvd.cc index 848111ff2..e568c123b 100644 --- a/src/applications/radvd/radvd.cc +++ b/src/applications/radvd/radvd.cc @@ -48,10 +48,10 @@ TypeId Radvd::GetTypeId () static TypeId tid = TypeId ("ns3::Radvd") .SetParent () .AddConstructor () - ; + ; return tid; } - + Radvd::Radvd () { NS_LOG_FUNCTION_NOARGS (); @@ -61,9 +61,9 @@ Radvd::~Radvd () { NS_LOG_FUNCTION_NOARGS (); for (RadvdInterfaceListI it = m_configurations.begin () ; it != m_configurations.end () ; ++it) - { - *it = 0; - } + { + *it = 0; + } m_configurations.clear (); m_socket = 0; } @@ -79,23 +79,23 @@ void Radvd::StartApplication () NS_LOG_FUNCTION_NOARGS (); if (!m_socket) - { - TypeId tid = TypeId::LookupByName ("ns3::Ipv6RawSocketFactory"); - m_socket = Socket::CreateSocket (GetNode (), tid); + { + TypeId tid = TypeId::LookupByName ("ns3::Ipv6RawSocketFactory"); + m_socket = Socket::CreateSocket (GetNode (), tid); - NS_ASSERT (m_socket); + NS_ASSERT (m_socket); -/* m_socket->Bind (Inet6SocketAddress (m_localAddress, 0)); */ -/* m_socket->Connect (Inet6SocketAddress (Ipv6Address::GetAllNodesMulticast (), 0)); */ - m_socket->SetAttribute ("Protocol", UintegerValue (Ipv6Header::IPV6_ICMPV6)); - m_socket->SetRecvCallback (MakeCallback (&Radvd::HandleRead, this)); - } + /* m_socket->Bind (Inet6SocketAddress (m_localAddress, 0)); */ + /* m_socket->Connect (Inet6SocketAddress (Ipv6Address::GetAllNodesMulticast (), 0)); */ + m_socket->SetAttribute ("Protocol", UintegerValue (Ipv6Header::IPV6_ICMPV6)); + m_socket->SetRecvCallback (MakeCallback (&Radvd::HandleRead, this)); + } for (RadvdInterfaceListCI it = m_configurations.begin () ; it != m_configurations.end () ; it++) - { - m_eventIds[(*it)->GetInterface ()] = EventId (); - ScheduleTransmit (Seconds (0.), (*it), m_eventIds[(*it)->GetInterface ()], Ipv6Address::GetAllNodesMulticast (), true); - } + { + m_eventIds[(*it)->GetInterface ()] = EventId (); + ScheduleTransmit (Seconds (0.), (*it), m_eventIds[(*it)->GetInterface ()], Ipv6Address::GetAllNodesMulticast (), true); + } } void Radvd::StopApplication () @@ -103,14 +103,14 @@ void Radvd::StopApplication () NS_LOG_FUNCTION_NOARGS (); if (m_socket) - { - m_socket->SetRecvCallback (MakeNullCallback > ()); - } + { + m_socket->SetRecvCallback (MakeNullCallback > ()); + } for (EventIdMapI it = m_eventIds.begin () ; it != m_eventIds.end () ; ++it) - { - Simulator::Cancel ((*it).second); - } + { + Simulator::Cancel ((*it).second); + } m_eventIds.clear (); } @@ -135,9 +135,9 @@ void Radvd::Send (Ptr config, Ipv6Address dst, bool reschedule) Icmpv6OptionPrefixInformation prefixHdr; if (m_eventIds.size () == 0) - { - return; - } + { + return; + } std::list > prefixes = config->GetPrefixes (); Ptr p = Create (); @@ -151,52 +151,52 @@ void Radvd::Send (Ptr config, Ipv6Address dst, bool reschedule) raHdr.SetLifeTime (config->GetDefaultLifeTime ()); raHdr.SetReachableTime (config->GetReachableTime ()); raHdr.SetRetransmissionTime (config->GetRetransTimer ()); - + if (config->IsSourceLLAddress ()) - { - /* Get L2 address from NetDevice */ - Address addr = ipv6->GetNetDevice (config->GetInterface ())->GetAddress (); - llaHdr = Icmpv6OptionLinkLayerAddress (true, addr); - p->AddHeader (llaHdr); - } + { + /* Get L2 address from NetDevice */ + Address addr = ipv6->GetNetDevice (config->GetInterface ())->GetAddress (); + llaHdr = Icmpv6OptionLinkLayerAddress (true, addr); + p->AddHeader (llaHdr); + } if (config->GetLinkMtu ()) - { - NS_ASSERT (config->GetLinkMtu () >= 1280); - mtuHdr = Icmpv6OptionMtu (config->GetLinkMtu ()); - p->AddHeader (mtuHdr); - } + { + NS_ASSERT (config->GetLinkMtu () >= 1280); + mtuHdr = Icmpv6OptionMtu (config->GetLinkMtu ()); + p->AddHeader (mtuHdr); + } /* add list of prefixes */ for (std::list >::const_iterator jt = prefixes.begin () ; jt != prefixes.end () ; jt++) - { - uint8_t flags = 0; - prefixHdr = Icmpv6OptionPrefixInformation (); - prefixHdr.SetPrefix ((*jt)->GetNetwork ()); - prefixHdr.SetPrefixLength ((*jt)->GetPrefixLength ()); - prefixHdr.SetValidTime ((*jt)->GetValidLifeTime ()); - prefixHdr.SetPreferredTime ((*jt)->GetPreferredLifeTime ()); - - if ((*jt)->IsOnLinkFlag ()) { - flags += 1 << 7; - } - - if ((*jt)->IsAutonomousFlag ()) - { - flags += 1 << 6; - } + uint8_t flags = 0; + prefixHdr = Icmpv6OptionPrefixInformation (); + prefixHdr.SetPrefix ((*jt)->GetNetwork ()); + prefixHdr.SetPrefixLength ((*jt)->GetPrefixLength ()); + prefixHdr.SetValidTime ((*jt)->GetValidLifeTime ()); + prefixHdr.SetPreferredTime ((*jt)->GetPreferredLifeTime ()); - if ((*jt)->IsRouterAddrFlag ()) - { - flags += 1 << 5; + if ((*jt)->IsOnLinkFlag ()) + { + flags += 1 << 7; + } + + if ((*jt)->IsAutonomousFlag ()) + { + flags += 1 << 6; + } + + if ((*jt)->IsRouterAddrFlag ()) + { + flags += 1 << 5; + } + + prefixHdr.SetFlags (flags); + + p->AddHeader (prefixHdr); } - prefixHdr.SetFlags (flags); - - p->AddHeader (prefixHdr); - } - Ipv6Address src = ipv6->GetAddress (config->GetInterface (), 0).GetAddress (); m_socket->Bind (Inet6SocketAddress (src, 0)); m_socket->Connect (Inet6SocketAddress (dst, 0)); @@ -220,13 +220,13 @@ void Radvd::Send (Ptr config, Ipv6Address dst, bool reschedule) m_socket->Send (p, 0); if (reschedule) - { - UniformVariable rnd; - uint64_t delay = static_cast (rnd.GetValue (config->GetMinRtrAdvInterval (), config->GetMaxRtrAdvInterval ()) + 0.5); - NS_LOG_INFO ("Reschedule in " << delay); - Time t = MilliSeconds (delay); - ScheduleTransmit (t, config, m_eventIds[config->GetInterface ()], Ipv6Address::GetAllNodesMulticast (), reschedule); - } + { + UniformVariable rnd; + uint64_t delay = static_cast (rnd.GetValue (config->GetMinRtrAdvInterval (), config->GetMaxRtrAdvInterval ()) + 0.5); + NS_LOG_INFO ("Reschedule in " << delay); + Time t = MilliSeconds (delay); + ScheduleTransmit (t, config, m_eventIds[config->GetInterface ()], Ipv6Address::GetAllNodesMulticast (), reschedule); + } } void Radvd::HandleRead (Ptr socket) @@ -236,45 +236,45 @@ void Radvd::HandleRead (Ptr socket) Address from; while (packet = socket->RecvFrom (from)) - { - if (Inet6SocketAddress::IsMatchingType (from)) { - Ipv6Header hdr; - Icmpv6RS rsHdr; - Inet6SocketAddress address = Inet6SocketAddress::ConvertFrom (from); - uint64_t delay = 0; - UniformVariable rnd; - Time t; + if (Inet6SocketAddress::IsMatchingType (from)) + { + Ipv6Header hdr; + Icmpv6RS rsHdr; + Inet6SocketAddress address = Inet6SocketAddress::ConvertFrom (from); + uint64_t delay = 0; + UniformVariable rnd; + Time t; - packet->RemoveHeader (hdr); - switch (*packet->PeekData ()) - { - case Icmpv6Header::ICMPV6_ND_ROUTER_SOLICITATION: - packet->RemoveHeader (rsHdr); - NS_LOG_INFO ("Received ICMPv6 Router Solicitation from " << hdr.GetSourceAddress () << " code = " << (uint32_t)rsHdr.GetCode ()); - - /* XXX advertise just prefix(es) for the interface not all */ - for (RadvdInterfaceListCI it = m_configurations.begin () ; it != m_configurations.end () ; it++) - { - /* calculate minimum delay between RA */ - delay = static_cast (rnd.GetValue (0, MAX_RA_DELAY_TIME) + 0.5); - t = Simulator::Now () + MilliSeconds (delay); /* absolute time of solicited RA */ - - /* if our solicited RA is before the next periodic RA, we schedule it */ - if (t.GetTimeStep () < static_cast (m_eventIds[(*it)->GetInterface ()].GetTs ())) + packet->RemoveHeader (hdr); + switch (*packet->PeekData ()) { - NS_LOG_INFO ("schedule new RA"); - EventId ei; - - ScheduleTransmit (MilliSeconds (delay), (*it), ei, address.GetIpv6 (), false); + case Icmpv6Header::ICMPV6_ND_ROUTER_SOLICITATION: + packet->RemoveHeader (rsHdr); + NS_LOG_INFO ("Received ICMPv6 Router Solicitation from " << hdr.GetSourceAddress () << " code = " << (uint32_t)rsHdr.GetCode ()); + + /* XXX advertise just prefix(es) for the interface not all */ + for (RadvdInterfaceListCI it = m_configurations.begin () ; it != m_configurations.end () ; it++) + { + /* calculate minimum delay between RA */ + delay = static_cast (rnd.GetValue (0, MAX_RA_DELAY_TIME) + 0.5); + t = Simulator::Now () + MilliSeconds (delay); /* absolute time of solicited RA */ + + /* if our solicited RA is before the next periodic RA, we schedule it */ + if (t.GetTimeStep () < static_cast (m_eventIds[(*it)->GetInterface ()].GetTs ())) + { + NS_LOG_INFO ("schedule new RA"); + EventId ei; + + ScheduleTransmit (MilliSeconds (delay), (*it), ei, address.GetIpv6 (), false); + } + } + break; + default: + break; } - } - break; - default: - break; - } + } } - } } } /* namespace ns3 */ diff --git a/src/applications/radvd/radvd.h b/src/applications/radvd/radvd.h index c301c636c..53161ae75 100644 --- a/src/applications/radvd/radvd.h +++ b/src/applications/radvd/radvd.h @@ -45,97 +45,97 @@ namespace ns3 */ class Radvd : public Application { - public: - /** - * \brief Get the type ID. - * \return type ID - */ - static TypeId GetTypeId (void); +public: + /** + * \brief Get the type ID. + * \return type ID + */ + static TypeId GetTypeId (void); - /** - * \brief Constructor. - */ - Radvd (); + /** + * \brief Constructor. + */ + Radvd (); - /** - * \brief Destructor. - */ - virtual ~Radvd (); + /** + * \brief Destructor. + */ + virtual ~Radvd (); - /** - * \brief Default value for maximum delay of RA (ms) - */ - static const uint32_t MAX_RA_DELAY_TIME = 500; + /** + * \brief Default value for maximum delay of RA (ms) + */ + static const uint32_t MAX_RA_DELAY_TIME = 500; - /** - * \brief Add configuration for an interface; - * \param routerInterface configuration - */ - void AddConfiguration (Ptr routerInterface); + /** + * \brief Add configuration for an interface; + * \param routerInterface configuration + */ + void AddConfiguration (Ptr routerInterface); - protected: - /** - * \brief Dispose the instance. - */ - virtual void DoDispose (); - - private: - typedef std::list > RadvdInterfaceList; - typedef std::list >::iterator RadvdInterfaceListI; - typedef std::list >::const_iterator RadvdInterfaceListCI; +protected: + /** + * \brief Dispose the instance. + */ + virtual void DoDispose (); - typedef std::map EventIdMap; - typedef std::map::iterator EventIdMapI; - typedef std::map::const_iterator EventIdMapCI; +private: + typedef std::list > RadvdInterfaceList; + typedef std::list >::iterator RadvdInterfaceListI; + typedef std::list >::const_iterator RadvdInterfaceListCI; - /** - * \brief Start the application. - */ - virtual void StartApplication (); + typedef std::map EventIdMap; + typedef std::map::iterator EventIdMapI; + typedef std::map::const_iterator EventIdMapCI; - /** - * \brief Stop the application. - */ - virtual void StopApplication (); + /** + * \brief Start the application. + */ + virtual void StartApplication (); - /** - * \brief Schedule sending a packet. - * \param dt interval between packet - * \param config interface configuration - * \param eventId event ID associated - * \param dst IPv6 destination address - * \param reschedule if true another send will be reschedule (periodic) - */ - void ScheduleTransmit (Time dt, Ptr config, EventId& eventId, Ipv6Address dst = Ipv6Address::GetAllNodesMulticast (), bool reschedule = false); + /** + * \brief Stop the application. + */ + virtual void StopApplication (); - /** - * \brief Send a packet. - * \param config interface configuration - * \param dst destination address (default ff02::1) - * \param reschedule if true another send will be reschedule (periodic) - */ - void Send (Ptr config, Ipv6Address dst = Ipv6Address::GetAllNodesMulticast (), bool reschedule = false); + /** + * \brief Schedule sending a packet. + * \param dt interval between packet + * \param config interface configuration + * \param eventId event ID associated + * \param dst IPv6 destination address + * \param reschedule if true another send will be reschedule (periodic) + */ + void ScheduleTransmit (Time dt, Ptr config, EventId& eventId, Ipv6Address dst = Ipv6Address::GetAllNodesMulticast (), bool reschedule = false); - /** - * \brief Handle received packet, especially router solicitation - * \param socket socket to read data from - */ - void HandleRead (Ptr socket); + /** + * \brief Send a packet. + * \param config interface configuration + * \param dst destination address (default ff02::1) + * \param reschedule if true another send will be reschedule (periodic) + */ + void Send (Ptr config, Ipv6Address dst = Ipv6Address::GetAllNodesMulticast (), bool reschedule = false); - /** - * \brief Raw socket to send RA. - */ - Ptr m_socket; + /** + * \brief Handle received packet, especially router solicitation + * \param socket socket to read data from + */ + void HandleRead (Ptr socket); - /** - * \brief List of configuration for interface. - */ - RadvdInterfaceList m_configurations; + /** + * \brief Raw socket to send RA. + */ + Ptr m_socket; - /** - * \brief Event ID map. - */ - EventIdMap m_eventIds; + /** + * \brief List of configuration for interface. + */ + RadvdInterfaceList m_configurations; + + /** + * \brief Event ID map. + */ + EventIdMap m_eventIds; }; } /* namespace ns3 */ diff --git a/src/helper/ipv6-address-helper.cc b/src/helper/ipv6-address-helper.cc index d13ba1800..41903719f 100644 --- a/src/helper/ipv6-address-helper.cc +++ b/src/helper/ipv6-address-helper.cc @@ -45,12 +45,12 @@ Ipv6Address Ipv6AddressHelper::NewAddress (Address addr) NS_LOG_FUNCTION (this << addr); switch (addr.GetLength ()) - { + { case 6: return Ipv6Address::MakeAutoconfiguredAddress (Mac48Address::ConvertFrom (addr), m_network); default: return Ipv6Address ("::"); - } + } /* never reached */ return Ipv6Address ("::"); } @@ -69,31 +69,31 @@ Ipv6InterfaceContainer Ipv6AddressHelper::Assign (const NetDeviceContainer &c) Ipv6InterfaceContainer retval; for (uint32_t i = 0; i < c.GetN (); ++i) - { - Ptr device = c.Get (i); - - Ptr node = device->GetNode (); - NS_ASSERT_MSG (node, "Ipv6AddressHelper::Allocate (): Bad node"); - - Ptr ipv6 = node->GetObject (); - NS_ASSERT_MSG (ipv6, "Ipv6AddressHelper::Allocate (): Bad ipv6"); - int32_t ifIndex = 0; - - ifIndex = ipv6->GetInterfaceForDevice (device); - if (ifIndex == -1) { - ifIndex = ipv6->AddInterface (device); + Ptr device = c.Get (i); + + Ptr node = device->GetNode (); + NS_ASSERT_MSG (node, "Ipv6AddressHelper::Allocate (): Bad node"); + + Ptr ipv6 = node->GetObject (); + NS_ASSERT_MSG (ipv6, "Ipv6AddressHelper::Allocate (): Bad ipv6"); + int32_t ifIndex = 0; + + ifIndex = ipv6->GetInterfaceForDevice (device); + if (ifIndex == -1) + { + ifIndex = ipv6->AddInterface (device); + } + NS_ASSERT_MSG (ifIndex >= 0, "Ipv6AddressHelper::Allocate (): " + "Interface index not found"); + + Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (NewAddress (device->GetAddress ()), m_prefix); + ipv6->SetMetric (ifIndex, 1); + ipv6->SetUp (ifIndex); + ipv6->AddAddress (ifIndex, ipv6Addr); + + retval.Add (ipv6, ifIndex); } - NS_ASSERT_MSG (ifIndex >= 0, "Ipv6AddressHelper::Allocate (): " - "Interface index not found"); - - Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (NewAddress (device->GetAddress ()), m_prefix); - ipv6->SetMetric (ifIndex, 1); - ipv6->SetUp (ifIndex); - ipv6->AddAddress (ifIndex, ipv6Addr); - - retval.Add (ipv6, ifIndex); - } return retval; } @@ -102,34 +102,34 @@ Ipv6InterfaceContainer Ipv6AddressHelper::Assign (const NetDeviceContainer &c, s NS_LOG_FUNCTION_NOARGS (); Ipv6InterfaceContainer retval; for (uint32_t i = 0; i < c.GetN (); ++i) - { - Ptr device = c.Get (i); - - Ptr node = device->GetNode (); - NS_ASSERT_MSG (node, "Ipv6AddressHelper::Allocate (): Bad node"); - - Ptr ipv6 = node->GetObject (); - NS_ASSERT_MSG (ipv6, "Ipv6AddressHelper::Allocate (): Bad ipv6"); - - int32_t ifIndex = ipv6->GetInterfaceForDevice (device); - if (ifIndex == -1) { - ifIndex = ipv6->AddInterface (device); + Ptr device = c.Get (i); + + Ptr node = device->GetNode (); + NS_ASSERT_MSG (node, "Ipv6AddressHelper::Allocate (): Bad node"); + + Ptr ipv6 = node->GetObject (); + NS_ASSERT_MSG (ipv6, "Ipv6AddressHelper::Allocate (): Bad ipv6"); + + int32_t ifIndex = ipv6->GetInterfaceForDevice (device); + if (ifIndex == -1) + { + ifIndex = ipv6->AddInterface (device); + } + NS_ASSERT_MSG (ifIndex >= 0, "Ipv6AddressHelper::Allocate (): " + "Interface index not found"); + + ipv6->SetMetric (ifIndex, 1); + ipv6->SetUp (ifIndex); + + if (withConfiguration.at (i)) + { + Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (NewAddress (device->GetAddress ()), m_prefix); + ipv6->AddAddress (ifIndex, ipv6Addr); + } + + retval.Add (ipv6, ifIndex); } - NS_ASSERT_MSG (ifIndex >= 0, "Ipv6AddressHelper::Allocate (): " - "Interface index not found"); - - ipv6->SetMetric (ifIndex, 1); - ipv6->SetUp (ifIndex); - - if (withConfiguration.at (i)) - { - Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (NewAddress (device->GetAddress ()), m_prefix); - ipv6->AddAddress (ifIndex, ipv6Addr); - } - - retval.Add (ipv6, ifIndex); - } return retval; } @@ -138,28 +138,28 @@ Ipv6InterfaceContainer Ipv6AddressHelper::AssignWithoutAddress (const NetDeviceC NS_LOG_FUNCTION_NOARGS (); Ipv6InterfaceContainer retval; for (uint32_t i = 0; i < c.GetN (); ++i) - { - Ptr device = c.Get (i); - - Ptr node = device->GetNode (); - NS_ASSERT_MSG (node, "Ipv6AddressHelper::Allocate (): Bad node"); - - Ptr ipv6 = node->GetObject (); - NS_ASSERT_MSG (ipv6, "Ipv6AddressHelper::Allocate (): Bad ipv6"); - - int32_t ifIndex = ipv6->GetInterfaceForDevice (device); - if (ifIndex == -1) { - ifIndex = ipv6->AddInterface (device); + Ptr device = c.Get (i); + + Ptr node = device->GetNode (); + NS_ASSERT_MSG (node, "Ipv6AddressHelper::Allocate (): Bad node"); + + Ptr ipv6 = node->GetObject (); + NS_ASSERT_MSG (ipv6, "Ipv6AddressHelper::Allocate (): Bad ipv6"); + + int32_t ifIndex = ipv6->GetInterfaceForDevice (device); + if (ifIndex == -1) + { + ifIndex = ipv6->AddInterface (device); + } + NS_ASSERT_MSG (ifIndex >= 0, "Ipv6AddressHelper::Allocate (): " + "Interface index not found"); + + ipv6->SetMetric (ifIndex, 1); + ipv6->SetUp (ifIndex); + + retval.Add (ipv6, ifIndex); } - NS_ASSERT_MSG (ifIndex >= 0, "Ipv6AddressHelper::Allocate (): " - "Interface index not found"); - - ipv6->SetMetric (ifIndex, 1); - ipv6->SetUp (ifIndex); - - retval.Add (ipv6, ifIndex); - } return retval; } diff --git a/src/helper/ipv6-address-helper.h b/src/helper/ipv6-address-helper.h index e7fd2129a..9b33d51ae 100644 --- a/src/helper/ipv6-address-helper.h +++ b/src/helper/ipv6-address-helper.h @@ -37,60 +37,60 @@ namespace ns3 */ class Ipv6AddressHelper { - public: - /** - * \brief Constructor. - */ - Ipv6AddressHelper (); +public: + /** + * \brief Constructor. + */ + Ipv6AddressHelper (); - /** - * \brief Allocate a new network. - * \param network The IPv6 network - * \param prefix The prefix - */ - void NewNetwork (Ipv6Address network, Ipv6Prefix prefix); + /** + * \brief Allocate a new network. + * \param network The IPv6 network + * \param prefix The prefix + */ + void NewNetwork (Ipv6Address network, Ipv6Prefix prefix); - /** - * \brief Allocate a new address. - * \param addr L2 address (currenty only ethernet address is supported) - * \return newly created Ipv6Address - */ - Ipv6Address NewAddress (Address addr); + /** + * \brief Allocate a new address. + * \param addr L2 address (currenty only ethernet address is supported) + * \return newly created Ipv6Address + */ + Ipv6Address NewAddress (Address addr); - /** - * \brief Allocate an Ipv6InterfaceContainer. - * \param c netdevice container - * \return newly created Ipv6InterfaceContainer - */ - Ipv6InterfaceContainer Assign (const NetDeviceContainer &c); + /** + * \brief Allocate an Ipv6InterfaceContainer. + * \param c netdevice container + * \return newly created Ipv6InterfaceContainer + */ + Ipv6InterfaceContainer Assign (const NetDeviceContainer &c); - /** - * \brief Allocate an Ipv6InterfaceContainer. - * \param c netdevice container - * \param withConfiguration true : interface statically configured, false : no static configuration - * \return newly created Ipv6InterfaceContainer - */ - Ipv6InterfaceContainer Assign (const NetDeviceContainer &c, std::vector withConfiguration); + /** + * \brief Allocate an Ipv6InterfaceContainer. + * \param c netdevice container + * \param withConfiguration true : interface statically configured, false : no static configuration + * \return newly created Ipv6InterfaceContainer + */ + Ipv6InterfaceContainer Assign (const NetDeviceContainer &c, std::vector withConfiguration); - /** - * \brief Allocate an Ipv6InterfaceContainer without static IPv6 configuration. - * \param c netdevice container - * \return newly created Ipv6InterfaceContainer - */ - Ipv6InterfaceContainer AssignWithoutAddress (const NetDeviceContainer &c); + /** + * \brief Allocate an Ipv6InterfaceContainer without static IPv6 configuration. + * \param c netdevice container + * \return newly created Ipv6InterfaceContainer + */ + Ipv6InterfaceContainer AssignWithoutAddress (const NetDeviceContainer &c); - private: - /** - * \internal - * \brief The IPv6 network. - */ - Ipv6Address m_network; +private: + /** + * \internal + * \brief The IPv6 network. + */ + Ipv6Address m_network; - /** - * \internal - * \brief IPv6 The prefix (mask). - */ - Ipv6Prefix m_prefix; + /** + * \internal + * \brief IPv6 The prefix (mask). + */ + Ipv6Prefix m_prefix; }; } /* namespace ns3 */ diff --git a/src/helper/ipv6-interface-container.cc b/src/helper/ipv6-interface-container.cc index 1ab219936..25cc36166 100644 --- a/src/helper/ipv6-interface-container.cc +++ b/src/helper/ipv6-interface-container.cc @@ -62,9 +62,9 @@ void Ipv6InterfaceContainer::Add (std::string ipv6Name, uint32_t interface) void Ipv6InterfaceContainer::Add (Ipv6InterfaceContainer& c) { for (InterfaceVector::const_iterator it = c.m_interfaces.begin () ; it != c.m_interfaces.end () ; it++) - { - m_interfaces.push_back (*it); - } + { + m_interfaces.push_back (*it); + } } void Ipv6InterfaceContainer::SetRouter (uint32_t i, bool router) @@ -73,24 +73,24 @@ void Ipv6InterfaceContainer::SetRouter (uint32_t i, bool router) ipv6->SetForwarding (m_interfaces[i].second, router); if (router) - { - uint32_t other; - /* assume first global address is index 1 (0 is link-local) */ - Ipv6Address routerAddress = ipv6->GetAddress (m_interfaces[i].second, 1).GetAddress (); - - for (other = 0 ; other < m_interfaces.size () ; other++) { - if (other != i) - { - Ptr routing = 0; - Ipv6StaticRoutingHelper routingHelper; + uint32_t other; + /* assume first global address is index 1 (0 is link-local) */ + Ipv6Address routerAddress = ipv6->GetAddress (m_interfaces[i].second, 1).GetAddress (); - ipv6 = m_interfaces[other].first; - routing = routingHelper.GetStaticRouting (ipv6); - routing->SetDefaultRoute (routerAddress, m_interfaces[other].second); - } + for (other = 0 ; other < m_interfaces.size () ; other++) + { + if (other != i) + { + Ptr routing = 0; + Ipv6StaticRoutingHelper routingHelper; + + ipv6 = m_interfaces[other].first; + routing = routingHelper.GetStaticRouting (ipv6); + routing->SetDefaultRoute (routerAddress, m_interfaces[other].second); + } + } } - } } void Ipv6InterfaceContainer::SetDefaultRoute (uint32_t i, uint32_t router) diff --git a/src/helper/ipv6-interface-container.h b/src/helper/ipv6-interface-container.h index ac043e39b..686246c09 100644 --- a/src/helper/ipv6-interface-container.h +++ b/src/helper/ipv6-interface-container.h @@ -37,75 +37,75 @@ namespace ns3 */ class Ipv6InterfaceContainer { - public: - /** - * \brief Constructor. - */ - Ipv6InterfaceContainer (); +public: + /** + * \brief Constructor. + */ + Ipv6InterfaceContainer (); - /** - * \brief Get the number of interfaces. - * \return the number of interfaces stored in this Ipv6InterfaceContainer. - */ - uint32_t GetN (void) const; + /** + * \brief Get the number of interfaces. + * \return the number of interfaces stored in this Ipv6InterfaceContainer. + */ + uint32_t GetN (void) const; - /** - * \brief Get the interface index for the specified node index. - * \param i index of the node - * \return interface index - */ - uint32_t GetInterfaceIndex (uint32_t i) const; + /** + * \brief Get the interface index for the specified node index. + * \param i index of the node + * \return interface index + */ + uint32_t GetInterfaceIndex (uint32_t i) const; - /** - * \brief Get the address for the specified index. - * \param i interface index - * \param j address index, generally index 0 is the link-local address - * \return IPv6 address - */ - Ipv6Address GetAddress (uint32_t i, uint32_t j) const; + /** + * \brief Get the address for the specified index. + * \param i interface index + * \param j address index, generally index 0 is the link-local address + * \return IPv6 address + */ + Ipv6Address GetAddress (uint32_t i, uint32_t j) const; - /** - * \brief Add a couple IPv6/interface. - * \param ipv6 IPv6 address - * \param interface interface index - */ - void Add (Ptr ipv6, uint32_t interface); + /** + * \brief Add a couple IPv6/interface. + * \param ipv6 IPv6 address + * \param interface interface index + */ + void Add (Ptr ipv6, uint32_t interface); - /** - * \brief Fusion with another Ipv6InterfaceContainer. - * \param c container - */ - void Add (Ipv6InterfaceContainer& c); + /** + * \brief Fusion with another Ipv6InterfaceContainer. + * \param c container + */ + void Add (Ipv6InterfaceContainer& c); - /** - * \brief Add a couple of name/interface. - * \param ipv6Name name of a node - * \param interface interface index to add - */ - void Add (std::string ipv6Name, uint32_t interface); + /** + * \brief Add a couple of name/interface. + * \param ipv6Name name of a node + * \param interface interface index to add + */ + void Add (std::string ipv6Name, uint32_t interface); - /** - * \brief Set the state of the stack (act as a router or not) for the specified index. - * \param i index - * \param router true : is a router, false : is an host - */ - void SetRouter (uint32_t i, bool router); + /** + * \brief Set the state of the stack (act as a router or not) for the specified index. + * \param i index + * \param router true : is a router, false : is an host + */ + void SetRouter (uint32_t i, bool router); - /** - * \brief Set the default route for the specified index. - * \param i index - * \param router the default router - */ - void SetDefaultRoute (uint32_t i, uint32_t router); + /** + * \brief Set the default route for the specified index. + * \param i index + * \param router the default router + */ + void SetDefaultRoute (uint32_t i, uint32_t router); - private: - typedef std::vector, uint32_t> > InterfaceVector; +private: + typedef std::vector, uint32_t> > InterfaceVector; - /** - * \internal - * \brief List of IPv6 stack and interfaces index. - */ - InterfaceVector m_interfaces; + /** + * \internal + * \brief List of IPv6 stack and interfaces index. + */ + InterfaceVector m_interfaces; }; } /* namespace ns3 */ diff --git a/src/helper/ipv6-list-routing-helper.h b/src/helper/ipv6-list-routing-helper.h index 7bc181b6d..5bf6a28b7 100644 --- a/src/helper/ipv6-list-routing-helper.h +++ b/src/helper/ipv6-list-routing-helper.h @@ -45,7 +45,7 @@ public: /** * \internal - * Destroy an Ipv6 Ipv6ListRoutingHelper. + * \brief Destroy an Ipv6 Ipv6ListRoutingHelper. */ virtual ~Ipv6ListRoutingHelper (); diff --git a/src/helper/ipv6-routing-helper.h b/src/helper/ipv6-routing-helper.h index be6b1700b..1a670d025 100644 --- a/src/helper/ipv6-routing-helper.h +++ b/src/helper/ipv6-routing-helper.h @@ -43,7 +43,7 @@ public: /** * \internal - * Destroy an Ipv6 Ipv6RoutingHelper. + * \brief Destroy an Ipv6 Ipv6RoutingHelper. */ virtual ~Ipv6RoutingHelper (); diff --git a/src/helper/ping6-helper.cc b/src/helper/ping6-helper.cc index 86b90c49b..84467f0c4 100644 --- a/src/helper/ping6-helper.cc +++ b/src/helper/ping6-helper.cc @@ -51,16 +51,16 @@ ApplicationContainer Ping6Helper::Install (NodeContainer c) { ApplicationContainer apps; for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) - { - Ptr node = *i; - Ptr client = m_factory.Create (); - client->SetLocal (m_localIp); - client->SetRemote (m_remoteIp); - client->SetIfIndex (m_ifIndex); - client->SetRouters (m_routers); - node->AddApplication (client); - apps.Add (client); - } + { + Ptr node = *i; + Ptr client = m_factory.Create (); + client->SetLocal (m_localIp); + client->SetRemote (m_remoteIp); + client->SetIfIndex (m_ifIndex); + client->SetRouters (m_routers); + node->AddApplication (client); + apps.Add (client); + } return apps; } diff --git a/src/helper/ping6-helper.h b/src/helper/ping6-helper.h index e6ebef17d..3fed2aa7b 100644 --- a/src/helper/ping6-helper.h +++ b/src/helper/ping6-helper.h @@ -37,78 +37,78 @@ namespace ns3 { */ class Ping6Helper { - public: - /** - * \brief Constructor. - */ - Ping6Helper (); +public: + /** + * \brief Constructor. + */ + Ping6Helper (); - /** - * \brief Set the local IPv6 address. - * \param ip local IPv6 address - */ - void SetLocal (Ipv6Address ip); + /** + * \brief Set the local IPv6 address. + * \param ip local IPv6 address + */ + void SetLocal (Ipv6Address ip); - /** - * \brief Set the remote IPv6 address. - * \param ip remote IPv6 address - */ - void SetRemote (Ipv6Address ip); + /** + * \brief Set the remote IPv6 address. + * \param ip remote IPv6 address + */ + void SetRemote (Ipv6Address ip); - /** - * \brief Set some attributes. - * \param name attribute name - * \param value attribute value - */ - void SetAttribute (std::string name, const AttributeValue& value); + /** + * \brief Set some attributes. + * \param name attribute name + * \param value attribute value + */ + void SetAttribute (std::string name, const AttributeValue& value); - /** - * \brief Install the application in Nodes. - * \param c list of Nodes - * \return application container - */ - ApplicationContainer Install (NodeContainer c); + /** + * \brief Install the application in Nodes. + * \param c list of Nodes + * \return application container + */ + ApplicationContainer Install (NodeContainer c); - /** - * \brief Set the out interface index. - * This is to send to link-local (unicast or multicast) address - * when a node has multiple interfaces. - * \param ifIndex interface index - */ - void SetIfIndex (uint32_t ifIndex); + /** + * \brief Set the out interface index. + * This is to send to link-local (unicast or multicast) address + * when a node has multiple interfaces. + * \param ifIndex interface index + */ + void SetIfIndex (uint32_t ifIndex); - /** - * \brief Set routers addresses for routing type 0. - * \param routers routers addresses - */ - void SetRoutersAddress(std::vector routers); - - private: - /** - * \brief An object factory. - */ - ObjectFactory m_factory; + /** + * \brief Set routers addresses for routing type 0. + * \param routers routers addresses + */ + void SetRoutersAddress(std::vector routers); - /** - * \brief The local IPv6 address. - */ - Ipv6Address m_localIp; +private: + /** + * \brief An object factory. + */ + ObjectFactory m_factory; - /** - * \brief The remote IPv6 address. - */ - Ipv6Address m_remoteIp; + /** + * \brief The local IPv6 address. + */ + Ipv6Address m_localIp; - /** - * \brief Out interface index. - */ - uint32_t m_ifIndex; + /** + * \brief The remote IPv6 address. + */ + Ipv6Address m_remoteIp; - /** - * \brief Routers addresses. - */ - std::vector m_routers; + /** + * \brief Out interface index. + */ + uint32_t m_ifIndex; + + /** + * \brief Routers addresses. + */ + std::vector m_routers; }; } /* namespace ns3 */ diff --git a/src/internet-stack/icmpv6-header.cc b/src/internet-stack/icmpv6-header.cc index afee64aec..b624585f5 100644 --- a/src/internet-stack/icmpv6-header.cc +++ b/src/internet-stack/icmpv6-header.cc @@ -124,13 +124,13 @@ void Icmpv6Header::Serialize (Buffer::Iterator start) const #endif if (m_calcChecksum) - { - i = start; - uint16_t checksum = i.CalculateIpChecksum (i.GetSize (), m_checksum); - i = start; - i.Next (2); - i.WriteU16 (checksum); - } + { + i = start; + uint16_t checksum = i.CalculateIpChecksum (i.GetSize (), m_checksum); + i = start; + i.Next (2); + i.WriteU16 (checksum); + } } void Icmpv6Header::CalculatePseudoHeaderChecksum (Ipv6Address src, Ipv6Address dst, uint16_t length, uint8_t protocol) @@ -192,7 +192,7 @@ Icmpv6NS::Icmpv6NS (Ipv6Address target) /* test */ /* m_reserved = 0xdeadbeef; - */ + */ } Icmpv6NS::~Icmpv6NS () @@ -244,13 +244,13 @@ void Icmpv6NS::Serialize (Buffer::Iterator start) const i.Write (buff_target, 16); if (m_calcChecksum) - { - i = start; - checksum = i.CalculateIpChecksum (i.GetSize (), m_checksum); - i = start; - i.Next (2); - i.WriteU16 (checksum); - } + { + i = start; + checksum = i.CalculateIpChecksum (i.GetSize (), m_checksum); + i = start; + i.Next (2); + i.WriteU16 (checksum); + } } uint32_t Icmpv6NS::Deserialize (Buffer::Iterator start) @@ -371,32 +371,32 @@ void Icmpv6NA::Serialize (Buffer::Iterator start) const i.WriteU16 (0); if (m_flagR) - { - reserved |= (uint32_t)(1 << 31); - } + { + reserved |= (uint32_t)(1 << 31); + } if (m_flagS) - { - reserved |= (uint32_t)(1<< 30); - } + { + reserved |= (uint32_t)(1<< 30); + } if (m_flagO) - { - reserved |= (uint32_t)(1<< 29); - } + { + reserved |= (uint32_t)(1<< 29); + } i.WriteHtonU32 (reserved); m_target.Serialize (buff_target); i.Write (buff_target, 16); if (m_calcChecksum) - { - i = start; - checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ()); - i = start; - i.Next (2); - i.WriteU16 (checksum); - } + { + i = start; + checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ()); + i = start; + i.Next (2); + i.WriteU16 (checksum); + } } uint32_t Icmpv6NA::Deserialize (Buffer::Iterator start) @@ -414,19 +414,19 @@ uint32_t Icmpv6NA::Deserialize (Buffer::Iterator start) m_flagO = false; if (m_reserved & (1 << 31)) - { - m_flagR = true; - } + { + m_flagR = true; + } if (m_reserved & (1 << 30)) - { - m_flagS = true; - } + { + m_flagS = true; + } if (m_reserved & (1 << 29)) - { - m_flagO = true; - } + { + m_flagO = true; + } i.Read (buf, 16); m_target.Set (buf); @@ -570,19 +570,19 @@ void Icmpv6RA::Serialize (Buffer::Iterator start) const i.WriteU8 (m_curHopLimit); if (m_flagM) - { - flags |= (uint8_t)(1<< 7); - } + { + flags |= (uint8_t)(1<< 7); + } if (m_flagO) - { - flags |= (uint8_t)(1<< 6); - } + { + flags |= (uint8_t)(1<< 6); + } if (m_flagH) - { - flags |= (uint8_t)(1<< 5); - } + { + flags |= (uint8_t)(1<< 5); + } i.WriteU8 (flags); i.WriteHtonU16 (GetLifeTime ()); i.WriteHtonU32 (GetReachableTime ()); @@ -610,19 +610,19 @@ uint32_t Icmpv6RA::Deserialize (Buffer::Iterator start) m_flagH = false; if (m_flags & (1 << 7)) - { - m_flagM = true; - } + { + m_flagM = true; + } if (m_flags & (1 << 6)) - { - m_flagO = true; - } + { + m_flagO = true; + } if (m_flags & (1 << 5)) - { - m_flagH = true; - } + { + m_flagH = true; + } SetLifeTime (i.ReadNtohU16 ()); SetReachableTime (i.ReadNtohU32 ()); SetRetransmissionTime (i.ReadNtohU32 ()); @@ -689,14 +689,14 @@ void Icmpv6RS::Serialize (Buffer::Iterator start) const i.WriteHtonU32 (m_reserved); if (m_calcChecksum) - { - i = start; - checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ()); - - i = start; - i.Next (2); - i.WriteU16 (checksum); - } + { + i = start; + checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ()); + + i = start; + i.Next (2); + i.WriteU16 (checksum); + } } uint32_t Icmpv6RS::Deserialize (Buffer::Iterator start) @@ -800,14 +800,14 @@ void Icmpv6Redirection::Serialize (Buffer::Iterator start) const i.Write (buff, 16); if (m_calcChecksum) - { - i = start; - checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ()); + { + i = start; + checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ()); - i = start; - i.Next (2); - i.WriteU16 (checksum); - } + i = start; + i.Next (2); + i.WriteU16 (checksum); + } } uint32_t Icmpv6Redirection::Deserialize (Buffer::Iterator start) @@ -912,13 +912,13 @@ void Icmpv6Echo::Serialize (Buffer::Iterator start) const i.WriteHtonU16 (m_seq); if (m_calcChecksum) - { - i = start; - checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ()); - i = start; - i.Next (2); - i.WriteU16 (checksum); - } + { + i = start; + checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ()); + i = start; + i.Next (2); + i.WriteU16 (checksum); + } } uint32_t Icmpv6Echo::Deserialize (Buffer::Iterator start) @@ -1215,7 +1215,7 @@ TypeId Icmpv6ParameterError::GetInstanceTypeId () const Icmpv6ParameterError::Icmpv6ParameterError () : m_packet (0), - m_ptr (0) + m_ptr (0) { SetType (ICMPV6_ERROR_PARAMETER_ERROR); } diff --git a/src/internet-stack/icmpv6-header.h b/src/internet-stack/icmpv6-header.h index 786ac4ca1..ff9363848 100644 --- a/src/internet-stack/icmpv6-header.h +++ b/src/internet-stack/icmpv6-header.h @@ -36,202 +36,202 @@ namespace ns3 */ class Icmpv6Header : public Header { - public: - /** - * \enum Type_e - * \brief ICMPv6 type code. - */ - enum Type_e - { - ICMPV6_ERROR_DESTINATION_UNREACHABLE = 1, - ICMPV6_ERROR_PACKET_TOO_BIG, - ICMPV6_ERROR_TIME_EXCEEDED, - ICMPV6_ERROR_PARAMETER_ERROR, - ICMPV6_ECHO_REQUEST = 128, - ICMPV6_ECHO_REPLY, - ICMPV6_SUBSCRIBE_REQUEST, - ICMPV6_SUBSCRIBE_REPORT, - ICMPV6_SUBSCRIVE_END, - ICMPV6_ND_ROUTER_SOLICITATION, - ICMPV6_ND_ROUTER_ADVERTISEMENT, - ICMPV6_ND_NEIGHBOR_SOLICITATION, - ICMPV6_ND_NEIGHBOR_ADVERTISEMENT, - ICMPV6_ND_REDIRECTION, - ICMPV6_ROUTER_RENUMBER, - ICMPV6_INFORMATION_REQUEST, - ICMPV6_INFORMATION_RESPONSE, - ICMPV6_INVERSE_ND_SOLICITATION, - ICMPV6_INVERSE_ND_ADVERSTISEMENT, - ICMPV6_MLDV2_SUBSCRIBE_REPORT, - ICMPV6_MOBILITY_HA_DISCOVER_REQUEST, - ICMPV6_MOBILITY_HA_DISCOVER_RESPONSE, - ICMPV6_MOBILITY_MOBILE_PREFIX_SOLICITATION, - ICMPV6_SECURE_ND_CERTIFICATE_PATH_SOLICITATION, - ICMPV6_SECURE_ND_CERTIFICATE_PATH_ADVERTISEMENT, - ICMPV6_EXPERIMENTAL_MOBILITY - }; +public: + /** + * \enum Type_e + * \brief ICMPv6 type code. + */ + enum Type_e + { + ICMPV6_ERROR_DESTINATION_UNREACHABLE = 1, + ICMPV6_ERROR_PACKET_TOO_BIG, + ICMPV6_ERROR_TIME_EXCEEDED, + ICMPV6_ERROR_PARAMETER_ERROR, + ICMPV6_ECHO_REQUEST = 128, + ICMPV6_ECHO_REPLY, + ICMPV6_SUBSCRIBE_REQUEST, + ICMPV6_SUBSCRIBE_REPORT, + ICMPV6_SUBSCRIVE_END, + ICMPV6_ND_ROUTER_SOLICITATION, + ICMPV6_ND_ROUTER_ADVERTISEMENT, + ICMPV6_ND_NEIGHBOR_SOLICITATION, + ICMPV6_ND_NEIGHBOR_ADVERTISEMENT, + ICMPV6_ND_REDIRECTION, + ICMPV6_ROUTER_RENUMBER, + ICMPV6_INFORMATION_REQUEST, + ICMPV6_INFORMATION_RESPONSE, + ICMPV6_INVERSE_ND_SOLICITATION, + ICMPV6_INVERSE_ND_ADVERSTISEMENT, + ICMPV6_MLDV2_SUBSCRIBE_REPORT, + ICMPV6_MOBILITY_HA_DISCOVER_REQUEST, + ICMPV6_MOBILITY_HA_DISCOVER_RESPONSE, + ICMPV6_MOBILITY_MOBILE_PREFIX_SOLICITATION, + ICMPV6_SECURE_ND_CERTIFICATE_PATH_SOLICITATION, + ICMPV6_SECURE_ND_CERTIFICATE_PATH_ADVERTISEMENT, + ICMPV6_EXPERIMENTAL_MOBILITY + }; - /** - * \enum OptionType_e - * \brief ICMPv6 Option type code. - */ - enum OptionType_e - { - ICMPV6_OPT_LINK_LAYER_SOURCE = 1, - ICMPV6_OPT_LINK_LAYER_TARGET, - ICMPV6_OPT_PREFIX, - ICMPV6_OPT_REDIRECTED, - ICMPV6_OPT_MTU - }; + /** + * \enum OptionType_e + * \brief ICMPv6 Option type code. + */ + enum OptionType_e + { + ICMPV6_OPT_LINK_LAYER_SOURCE = 1, + ICMPV6_OPT_LINK_LAYER_TARGET, + ICMPV6_OPT_PREFIX, + ICMPV6_OPT_REDIRECTED, + ICMPV6_OPT_MTU + }; - /** - * \enum ErrorDestinationUnreachable_e - * \brief ICMPv6 error code : Destination Unreachable - */ - enum ErrorDestinationUnreachable_e - { - ICMPV6_NO_ROUTE = 0, - ICMPV6_ADM_PROHIBITED, - ICMPV6_NOT_NEIGHBOUR, - ICMPV6_ADDR_UNREACHABLE, - ICMPV6_PORT_UNREACHABLE - }; + /** + * \enum ErrorDestinationUnreachable_e + * \brief ICMPv6 error code : Destination Unreachable + */ + enum ErrorDestinationUnreachable_e + { + ICMPV6_NO_ROUTE = 0, + ICMPV6_ADM_PROHIBITED, + ICMPV6_NOT_NEIGHBOUR, + ICMPV6_ADDR_UNREACHABLE, + ICMPV6_PORT_UNREACHABLE + }; - /** - * \enum ErrorTimeExceeded_e - * \brief ICMPv6 error code : Time Exceeded - */ - enum ErrorTimeExceeded_e - { - ICMPV6_HOPLIMIT = 0, - ICMPV6_FRAGTIME - }; + /** + * \enum ErrorTimeExceeded_e + * \brief ICMPv6 error code : Time Exceeded + */ + enum ErrorTimeExceeded_e + { + ICMPV6_HOPLIMIT = 0, + ICMPV6_FRAGTIME + }; - /** - * \enum ErrorParameterError_e - * \brief ICMPv6 error code : Parameter Error - */ - enum ErrorParameterError_e - { - ICMPV6_MALFORMED_HEADER = 0, - ICMPV6_UNKNOWN_NEXT_HEADER, - ICMPV6_UNKNOWN_OPTION - }; + /** + * \enum ErrorParameterError_e + * \brief ICMPv6 error code : Parameter Error + */ + enum ErrorParameterError_e + { + ICMPV6_MALFORMED_HEADER = 0, + ICMPV6_UNKNOWN_NEXT_HEADER, + ICMPV6_UNKNOWN_OPTION + }; - /** - * \brief Get the UID of this class. - * \return UID - */ - static TypeId GetTypeId (); + /** + * \brief Get the UID of this class. + * \return UID + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Constructor. - */ - Icmpv6Header (); + /** + * \brief Constructor. + */ + Icmpv6Header (); - /** - * \brief Destructor. - */ - virtual ~Icmpv6Header (); + /** + * \brief Destructor. + */ + virtual ~Icmpv6Header (); - /** - * \brief Get the type field. - * \return type of ICMPv6 message - */ - uint8_t GetType () const; + /** + * \brief Get the type field. + * \return type of ICMPv6 message + */ + uint8_t GetType () const; - /** - * \brief Set the type. - * \param type type to set - */ - void SetType (uint8_t type); + /** + * \brief Set the type. + * \param type type to set + */ + void SetType (uint8_t type); - /** - * \brief Get the code field. - * \return code of ICMPv6 message - */ - uint8_t GetCode () const; + /** + * \brief Get the code field. + * \return code of ICMPv6 message + */ + uint8_t GetCode () const; - /** - * \brief Set the code field. - * \param code code to set - */ - void SetCode (uint8_t code); + /** + * \brief Set the code field. + * \param code code to set + */ + void SetCode (uint8_t code); - /** - * \brief Get the checksum. - * \return checksum - */ - uint16_t GetChecksum () const; + /** + * \brief Get the checksum. + * \return checksum + */ + uint16_t GetChecksum () const; - /** - * \brief Set the checksum. - * \param checksum to set - */ - void SetChecksum (uint16_t checksum); - - /** - * \brief Print informations. - * \param os output stream - */ - virtual void Print (std::ostream& os) const; + /** + * \brief Set the checksum. + * \param checksum to set + */ + void SetChecksum (uint16_t checksum); - /** - * \brief Get the serialized size. - * \return serialized size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Print informations. + * \param os output stream + */ + virtual void Print (std::ostream& os) const; - /** - * \brief Serialize the packet. - * \param start start offset - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Get the serialized size. + * \return serialized size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Deserialize the packet. - * \param start start offset - * \return length of packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Serialize the packet. + * \param start start offset + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Calculate pseudo header checksum for IPv6. - * \param src source address - * \param dst destination address - * \param length length - * \param protocol the protocol number to use in the - * underlying IPv6 packet. - */ - void CalculatePseudoHeaderChecksum (Ipv6Address src, Ipv6Address dst, uint16_t length, uint8_t protocol); + /** + * \brief Deserialize the packet. + * \param start start offset + * \return length of packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - protected: - /** - * \brief Checksum enable or not. - */ - bool m_calcChecksum; + /** + * \brief Calculate pseudo header checksum for IPv6. + * \param src source address + * \param dst destination address + * \param length length + * \param protocol the protocol number to use in the + * underlying IPv6 packet. + */ + void CalculatePseudoHeaderChecksum (Ipv6Address src, Ipv6Address dst, uint16_t length, uint8_t protocol); - /** - * \brief The checksum. - */ - uint16_t m_checksum; - - private: - /** - * \brief The type. - */ - uint8_t m_type; +protected: + /** + * \brief Checksum enable or not. + */ + bool m_calcChecksum; - /** - * \brief The code. - */ - uint8_t m_code; + /** + * \brief The checksum. + */ + uint16_t m_checksum; + +private: + /** + * \brief The type. + */ + uint8_t m_type; + + /** + * \brief The code. + */ + uint8_t m_code; }; /** @@ -240,88 +240,88 @@ class Icmpv6Header : public Header */ class Icmpv6OptionHeader : public Header { - public: - /** - * \brief Get the UID of this class. - * \return UID - */ - static TypeId GetTypeId (); +public: + /** + * \brief Get the UID of this class. + * \return UID + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Constructor. - */ - Icmpv6OptionHeader (); + /** + * \brief Constructor. + */ + Icmpv6OptionHeader (); - /** - * \brief Destructor. - */ - virtual ~Icmpv6OptionHeader (); + /** + * \brief Destructor. + */ + virtual ~Icmpv6OptionHeader (); - /** - * \brief Get the type of the option. - * \return type - */ - uint8_t GetType () const; + /** + * \brief Get the type of the option. + * \return type + */ + uint8_t GetType () const; - /** - * \brief Set the type of the option. - * \param type the type to set - */ - void SetType (uint8_t type); + /** + * \brief Set the type of the option. + * \param type the type to set + */ + void SetType (uint8_t type); - /** - * \brief Get the length of the option in 8 bytes unit. - * \return length of the option - */ - uint8_t GetLength () const; + /** + * \brief Get the length of the option in 8 bytes unit. + * \return length of the option + */ + uint8_t GetLength () const; - /** - * \brief Set the length of the option. - * \param len length value to set - */ - void SetLength (uint8_t len); + /** + * \brief Set the length of the option. + * \param len length value to set + */ + void SetLength (uint8_t len); - /** - * \brief Print informations. - * \param os output stream - */ - virtual void Print (std::ostream& os) const; + /** + * \brief Print informations. + * \param os output stream + */ + virtual void Print (std::ostream& os) const; - /** - * \brief Get the serialized size. - * \return serialized size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size. + * \return serialized size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start start offset - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start start offset + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start start offset - * \return length of packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start start offset + * \return length of packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: - /** - * \brief The type. - */ - uint8_t m_type; +private: + /** + * \brief The type. + */ + uint8_t m_type; - /** - * \brief The length. - */ - uint8_t m_len; + /** + * \brief The length. + */ + uint8_t m_len; }; /** @@ -330,95 +330,95 @@ class Icmpv6OptionHeader : public Header */ class Icmpv6NS : public Icmpv6Header { - public: - /** - * \brief Constructor. - * \param target target IPv6 address - */ - Icmpv6NS (Ipv6Address target); +public: + /** + * \brief Constructor. + * \param target target IPv6 address + */ + Icmpv6NS (Ipv6Address target); - /** - * \brief Constructor. - */ - Icmpv6NS (); + /** + * \brief Constructor. + */ + Icmpv6NS (); - /** - * \brief Destructor. - */ - virtual ~Icmpv6NS (); + /** + * \brief Destructor. + */ + virtual ~Icmpv6NS (); - /** - * \brief Get the UID of this class. - * \return UID - */ - static TypeId GetTypeId (); + /** + * \brief Get the UID of this class. + * \return UID + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Get the reserved field. - * \return reserved value - */ - uint32_t GetReserved () const; + /** + * \brief Get the reserved field. + * \return reserved value + */ + uint32_t GetReserved () const; - /** - * \brief Set the reserved field. - * \param reserved the reserved value - */ - void SetReserved (uint32_t reserved); + /** + * \brief Set the reserved field. + * \param reserved the reserved value + */ + void SetReserved (uint32_t reserved); - /** - * \brief Get the IPv6 target field. - * \return IPv6 address - */ - Ipv6Address GetIpv6Target () const; + /** + * \brief Get the IPv6 target field. + * \return IPv6 address + */ + Ipv6Address GetIpv6Target () const; - /** - * \brief Set the IPv6 target field. - * \param target IPv6 address - */ - void SetIpv6Target (Ipv6Address target); + /** + * \brief Set the IPv6 target field. + * \param target IPv6 address + */ + void SetIpv6Target (Ipv6Address target); - /** - * \brief Print informations. - * \param os output stream - */ - virtual void Print (std::ostream& os) const; + /** + * \brief Print informations. + * \param os output stream + */ + virtual void Print (std::ostream& os) const; - /** - * \brief Get the serialized size. - * \return serialized size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size. + * \return serialized size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start start offset - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start start offset + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start start offset - * \return length of packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start start offset + * \return length of packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: +private: - /** - * \brief The reserved value. - */ - uint32_t m_reserved; + /** + * \brief The reserved value. + */ + uint32_t m_reserved; - /** - * \brief The IPv6 target address. - */ - Ipv6Address m_target; + /** + * \brief The IPv6 target address. + */ + Ipv6Address m_target; }; /** @@ -427,139 +427,139 @@ class Icmpv6NS : public Icmpv6Header */ class Icmpv6NA : public Icmpv6Header { - public: - /** - * \brief Constructor. - */ - Icmpv6NA (); +public: + /** + * \brief Constructor. + */ + Icmpv6NA (); - /** - * \brief Destructor. - */ - virtual ~Icmpv6NA (); + /** + * \brief Destructor. + */ + virtual ~Icmpv6NA (); - /** - * \brief Get the UID of this class. - * \return UID - */ - static TypeId GetTypeId (); + /** + * \brief Get the UID of this class. + * \return UID + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Get the reserved field. - * \return reserved value - */ - uint32_t GetReserved () const; + /** + * \brief Get the reserved field. + * \return reserved value + */ + uint32_t GetReserved () const; - /** - * \brief Set the reserved field. - * \param reserved the reserved value - */ - void SetReserved (uint32_t reserved); + /** + * \brief Set the reserved field. + * \param reserved the reserved value + */ + void SetReserved (uint32_t reserved); - /** - * \brief Get the IPv6 target field. - * \return IPv6 address - */ - Ipv6Address GetIpv6Target () const; + /** + * \brief Get the IPv6 target field. + * \return IPv6 address + */ + Ipv6Address GetIpv6Target () const; - /** - * \brief Set the IPv6 target field. - * \param target IPv6 address - */ - void SetIpv6Target (Ipv6Address target); + /** + * \brief Set the IPv6 target field. + * \param target IPv6 address + */ + void SetIpv6Target (Ipv6Address target); - /** - * \brief Get the R flag. - * \return R flag - */ - bool GetFlagR () const; + /** + * \brief Get the R flag. + * \return R flag + */ + bool GetFlagR () const; - /** - * \brief Set the R flag. - * \param r value - */ - void SetFlagR (bool r); + /** + * \brief Set the R flag. + * \param r value + */ + void SetFlagR (bool r); - /** - * \brief Get the S flag. - * \return S flag - */ - bool GetFlagS () const; + /** + * \brief Get the S flag. + * \return S flag + */ + bool GetFlagS () const; - /** - * \brief Set the S flag. - * \param s value - */ - void SetFlagS (bool s); + /** + * \brief Set the S flag. + * \param s value + */ + void SetFlagS (bool s); - /** - * \brief Get the O flag. - * \return O flag - */ - bool GetFlagO () const; + /** + * \brief Get the O flag. + * \return O flag + */ + bool GetFlagO () const; - /** - * \brief Set the O flag. - * \param o value - */ - void SetFlagO (bool o); + /** + * \brief Set the O flag. + * \param o value + */ + void SetFlagO (bool o); - /** - * \brief Print informations. - * \param os output stream - */ - virtual void Print (std::ostream& os) const; + /** + * \brief Print informations. + * \param os output stream + */ + virtual void Print (std::ostream& os) const; - /** - * \brief Get the serialized size. - * \return serialized size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size. + * \return serialized size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start start offset - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start start offset + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start start offset - * \return length of packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start start offset + * \return length of packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: - /** - * \brief The R flag. - */ - bool m_flagR; +private: + /** + * \brief The R flag. + */ + bool m_flagR; - /** - * \brief The O flag. - */ - bool m_flagS; + /** + * \brief The O flag. + */ + bool m_flagS; - /** - * \brief The M flag. - */ - bool m_flagO; + /** + * \brief The M flag. + */ + bool m_flagO; - /** - * \brief The reserved value. - */ - uint32_t m_reserved; + /** + * \brief The reserved value. + */ + uint32_t m_reserved; - /** - * \brief The IPv6 target address. - */ - Ipv6Address m_target; + /** + * \brief The IPv6 target address. + */ + Ipv6Address m_target; }; /** @@ -568,190 +568,190 @@ class Icmpv6NA : public Icmpv6Header */ class Icmpv6RA : public Icmpv6Header { - public: - /** - * \brief Constructor. - */ - Icmpv6RA (); +public: + /** + * \brief Constructor. + */ + Icmpv6RA (); - /** - * \brief Destructor. - */ - virtual ~Icmpv6RA (); + /** + * \brief Destructor. + */ + virtual ~Icmpv6RA (); - /** - * \brief Get the UID of this class. - * \return UID - */ - static TypeId GetTypeId (); + /** + * \brief Get the UID of this class. + * \return UID + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Set the IPv6 maximum number of jumps. - * \param m maximum jumps - */ - void SetCurHopLimit (uint8_t m); + /** + * \brief Set the IPv6 maximum number of jumps. + * \param m maximum jumps + */ + void SetCurHopLimit (uint8_t m); - /** - * \brief Get the IPv6 maximum number of jumps. - * \return maximum jumps - */ - uint8_t GetCurHopLimit () const; + /** + * \brief Get the IPv6 maximum number of jumps. + * \return maximum jumps + */ + uint8_t GetCurHopLimit () const; - /** - * \brief Set the node Life time (Neighbor Discovery). - * \param l life time - */ - void SetLifeTime (uint16_t l); + /** + * \brief Set the node Life time (Neighbor Discovery). + * \param l life time + */ + void SetLifeTime (uint16_t l); - /** - * \brief Get the node Life time (Neighbor Discovery). - * \return life time - */ - uint16_t GetLifeTime () const; + /** + * \brief Get the node Life time (Neighbor Discovery). + * \return life time + */ + uint16_t GetLifeTime () const; - /** - * \brief Set the node Reachable time (Neighbor Discovery). - * \param r Reachable time - */ - void SetReachableTime (uint32_t r); + /** + * \brief Set the node Reachable time (Neighbor Discovery). + * \param r Reachable time + */ + void SetReachableTime (uint32_t r); - /** - * \brief Get the node Reachable time (Neighbor Discovery). - * \return reachable time - */ - uint32_t GetReachableTime () const; + /** + * \brief Get the node Reachable time (Neighbor Discovery). + * \return reachable time + */ + uint32_t GetReachableTime () const; - /** - * \brief Set the node Retransmission time (Neighbor Discovery). - * \param r Retransmission time - */ - void SetRetransmissionTime (uint32_t r); + /** + * \brief Set the node Retransmission time (Neighbor Discovery). + * \param r Retransmission time + */ + void SetRetransmissionTime (uint32_t r); - /** - * \brief Get the node Retransmission time (Neighbor Discovery). - * \return retransmission time - */ - uint32_t GetRetransmissionTime () const; + /** + * \brief Get the node Retransmission time (Neighbor Discovery). + * \return retransmission time + */ + uint32_t GetRetransmissionTime () const; - /** - * \brief Get the M flag. - * \return M flag - */ - bool GetFlagM () const; + /** + * \brief Get the M flag. + * \return M flag + */ + bool GetFlagM () const; - /** - * \brief Set the M flag. - * \param m value - */ - void SetFlagM (bool m); + /** + * \brief Set the M flag. + * \param m value + */ + void SetFlagM (bool m); - /** - * \brief Get the O flag. - * \return O flag - */ - bool GetFlagO () const; + /** + * \brief Get the O flag. + * \return O flag + */ + bool GetFlagO () const; - /** - * \brief Set the O flag. - * \param o value - */ - void SetFlagO (bool o); + /** + * \brief Set the O flag. + * \param o value + */ + void SetFlagO (bool o); - /** - * \brief Get the H flag. - * \return H flag - */ - bool GetFlagH () const; + /** + * \brief Get the H flag. + * \return H flag + */ + bool GetFlagH () const; - /** - * \brief Set the H flag. - * \param h value - */ - void SetFlagH (bool h); + /** + * \brief Set the H flag. + * \param h value + */ + void SetFlagH (bool h); - /** - * \brief Print informations. - * \param os output stream - */ - virtual void Print (std::ostream& os) const; + /** + * \brief Print informations. + * \param os output stream + */ + virtual void Print (std::ostream& os) const; - /** - * \brief Getflags. - * \return the flags value - */ - uint8_t GetFlags () const; + /** + * \brief Getflags. + * \return the flags value + */ + uint8_t GetFlags () const; - /** - * \brief Setflags. - * \param f the flags value - */ - void SetFlags (uint8_t f); + /** + * \brief Setflags. + * \param f the flags value + */ + void SetFlags (uint8_t f); - /** - * \brief Get the serialized size. - * \return serialized size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size. + * \return serialized size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start start offset - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start start offset + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start start offset - * \return length of packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start start offset + * \return length of packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: - /** - * \brief The M flag. - */ - bool m_flagM; +private: + /** + * \brief The M flag. + */ + bool m_flagM; - /** - * \brief The O flag. - */ - bool m_flagO; + /** + * \brief The O flag. + */ + bool m_flagO; - /** - * \brief The H flag. - */ - bool m_flagH; + /** + * \brief The H flag. + */ + bool m_flagH; - /** - * \brief The flags field value. - */ - uint8_t m_flags; + /** + * \brief The flags field value. + */ + uint8_t m_flags; - /** - * \brief The lifetime value. - */ - uint16_t m_LifeTime; + /** + * \brief The lifetime value. + */ + uint16_t m_LifeTime; - /** - * \brief The reachable time value. - */ - uint32_t m_ReachableTime; + /** + * \brief The reachable time value. + */ + uint32_t m_ReachableTime; - /** - * \brief The retransmission timer. - */ - uint32_t m_RetransmissionTimer; + /** + * \brief The retransmission timer. + */ + uint32_t m_RetransmissionTimer; - /** - * \brief The max jumps. - */ - uint8_t m_curHopLimit; + /** + * \brief The max jumps. + */ + uint8_t m_curHopLimit; }; /** @@ -760,71 +760,71 @@ class Icmpv6RA : public Icmpv6Header */ class Icmpv6RS : public Icmpv6Header { - public: - /** - * \brief Constructor. - */ - Icmpv6RS (); +public: + /** + * \brief Constructor. + */ + Icmpv6RS (); - /** - * \brief Destructor. - */ - virtual ~Icmpv6RS (); + /** + * \brief Destructor. + */ + virtual ~Icmpv6RS (); - /** - * \brief Get the UID of this class. - * \return UID - */ - static TypeId GetTypeId (); + /** + * \brief Get the UID of this class. + * \return UID + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Get the reserved field. - * \return reserved value - */ - uint32_t GetReserved () const; + /** + * \brief Get the reserved field. + * \return reserved value + */ + uint32_t GetReserved () const; - /** - * \brief Set the reserved field. - * \param reserved the reserved value - */ - void SetReserved (uint32_t reserved); + /** + * \brief Set the reserved field. + * \param reserved the reserved value + */ + void SetReserved (uint32_t reserved); - /** - * \brief Print informations. - * \param os output stream - */ - virtual void Print (std::ostream& os) const; + /** + * \brief Print informations. + * \param os output stream + */ + virtual void Print (std::ostream& os) const; - /** - * \brief Get the serialized size. - * \return serialized size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size. + * \return serialized size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start start offset - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start start offset + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start start offset - * \return length of packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start start offset + * \return length of packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: - /** - * \brief The reserved value. - */ - uint32_t m_reserved; +private: + /** + * \brief The reserved value. + */ + uint32_t m_reserved; }; /** @@ -833,105 +833,105 @@ class Icmpv6RS : public Icmpv6Header */ class Icmpv6Redirection : public Icmpv6Header { - public: - /** - * \brief Constructor. - */ - Icmpv6Redirection (); +public: + /** + * \brief Constructor. + */ + Icmpv6Redirection (); - /** - * \brief Destructor. - */ - virtual ~Icmpv6Redirection (); + /** + * \brief Destructor. + */ + virtual ~Icmpv6Redirection (); - /** - * \brief Get the UID of this class. - * \return UID - */ - static TypeId GetTypeId (); + /** + * \brief Get the UID of this class. + * \return UID + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Get the IPv6 target address. - * \return the IPv6 target address - */ - Ipv6Address GetTarget () const; + /** + * \brief Get the IPv6 target address. + * \return the IPv6 target address + */ + Ipv6Address GetTarget () const; - /** - * \brief Set the IPv6 target address. - * \param target IPv6 target address - */ - void SetTarget (Ipv6Address target); + /** + * \brief Set the IPv6 target address. + * \param target IPv6 target address + */ + void SetTarget (Ipv6Address target); - /** - * \brief Get the IPv6 destination address. - * \return the IPv6 destination address - */ - Ipv6Address GetDestination () const; + /** + * \brief Get the IPv6 destination address. + * \return the IPv6 destination address + */ + Ipv6Address GetDestination () const; - /** - * \brief Set the IPv6 destination address. - * \param destination IPv6 destination address - */ - void SetDestination (Ipv6Address destination); + /** + * \brief Set the IPv6 destination address. + * \param destination IPv6 destination address + */ + void SetDestination (Ipv6Address destination); - /** - * \brief Print informations. - * \param os output stream - */ - virtual void Print (std::ostream& os) const; + /** + * \brief Print informations. + * \param os output stream + */ + virtual void Print (std::ostream& os) const; - /** - * \brief Get the serialized size. - * \return serialized size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size. + * \return serialized size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start start offset - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start start offset + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start start offset - * \return length of packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start start offset + * \return length of packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - /** - * \brief Get the reserved field. - * \return reserved value - */ - uint32_t GetReserved () const; + /** + * \brief Get the reserved field. + * \return reserved value + */ + uint32_t GetReserved () const; - /** - * \brief Set the reserved field. - * \param reserved the reserved value - */ - void SetReserved (uint32_t reserved); + /** + * \brief Set the reserved field. + * \param reserved the reserved value + */ + void SetReserved (uint32_t reserved); - private: - /** - * \brief IPv6 target address. - */ - Ipv6Address m_target; +private: + /** + * \brief IPv6 target address. + */ + Ipv6Address m_target; - /** - * \brief IPv6 destination address. - */ - Ipv6Address m_destination; + /** + * \brief IPv6 destination address. + */ + Ipv6Address m_destination; - /** - * \brief Reserved value. - */ - uint32_t m_reserved; + /** + * \brief Reserved value. + */ + uint32_t m_reserved; }; /** @@ -940,94 +940,94 @@ class Icmpv6Redirection : public Icmpv6Header */ class Icmpv6Echo : public Icmpv6Header { - public: - /** - * \brief Get the UID of this class. - * \return UID - */ - static TypeId GetTypeId (); +public: + /** + * \brief Get the UID of this class. + * \return UID + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Default constructor. - */ - Icmpv6Echo (); + /** + * \brief Default constructor. + */ + Icmpv6Echo (); - /** - * \brief Constructor. - * \param request request or reply message - */ - Icmpv6Echo (bool request); + /** + * \brief Constructor. + * \param request request or reply message + */ + Icmpv6Echo (bool request); - /** - * \brief Destructor. - */ - virtual ~Icmpv6Echo (); + /** + * \brief Destructor. + */ + virtual ~Icmpv6Echo (); - /** - * \brief Get the ID of the packet. - * \return id - */ - uint16_t GetId () const; + /** + * \brief Get the ID of the packet. + * \return id + */ + uint16_t GetId () const; - /** - * \brief Set the ID of the packet. - * \param id id to set - */ - void SetId (uint16_t id); + /** + * \brief Set the ID of the packet. + * \param id id to set + */ + void SetId (uint16_t id); - /** - * \brief Get the sequence number. - * \return sequence number - */ - uint16_t GetSeq () const; + /** + * \brief Get the sequence number. + * \return sequence number + */ + uint16_t GetSeq () const; - /** - * \brief Set the sequence number. - * \param seq sequence to set - */ - void SetSeq (uint16_t seq); + /** + * \brief Set the sequence number. + * \param seq sequence to set + */ + void SetSeq (uint16_t seq); - /** - * \brief Print informations. - * \param os output stream - */ - virtual void Print (std::ostream& os) const; + /** + * \brief Print informations. + * \param os output stream + */ + virtual void Print (std::ostream& os) const; - /** - * \brief Get the serialized size. - * \return serialized size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size. + * \return serialized size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start start offset - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start start offset + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start start offset - * \return length of packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start start offset + * \return length of packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: - /** - * \brief ID of the packet (to distinguish response between many ping program). - */ - uint16_t m_id; +private: + /** + * \brief ID of the packet (to distinguish response between many ping program). + */ + uint16_t m_id; - /** - * \brief Sequence number (to distinguish response). - */ - uint16_t m_seq; + /** + * \brief Sequence number (to distinguish response). + */ + uint16_t m_seq; }; /** @@ -1036,71 +1036,71 @@ class Icmpv6Echo : public Icmpv6Header */ class Icmpv6DestinationUnreachable : public Icmpv6Header { - public: - /** - * \brief Constructor. - */ - Icmpv6DestinationUnreachable (); +public: + /** + * \brief Constructor. + */ + Icmpv6DestinationUnreachable (); - /** - * \brief Destructor. - */ - virtual ~Icmpv6DestinationUnreachable (); + /** + * \brief Destructor. + */ + virtual ~Icmpv6DestinationUnreachable (); - /** - * \brief Get the UID of this class. - * \return UID - */ - static TypeId GetTypeId (); + /** + * \brief Get the UID of this class. + * \return UID + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Get the incorrect packet. - * \return the incorrect packet - */ - Ptr GetPacket () const; + /** + * \brief Get the incorrect packet. + * \return the incorrect packet + */ + Ptr GetPacket () const; - /** - * \brief Set the incorrect packet. - * \param p the incorrect packet - */ - void SetPacket (Ptr p); + /** + * \brief Set the incorrect packet. + * \param p the incorrect packet + */ + void SetPacket (Ptr p); - /** - * \brief Print informations. - * \param os output stream - */ - virtual void Print (std::ostream& os) const; + /** + * \brief Print informations. + * \param os output stream + */ + virtual void Print (std::ostream& os) const; - /** - * \brief Get the serialized size. - * \return serialized size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size. + * \return serialized size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start start offset - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start start offset + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start start offset - * \return length of packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start start offset + * \return length of packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: - /** - * \brief The incorrect Packet. - */ - Ptr m_packet; +private: + /** + * \brief The incorrect Packet. + */ + Ptr m_packet; }; /** @@ -1109,89 +1109,89 @@ class Icmpv6DestinationUnreachable : public Icmpv6Header */ class Icmpv6TooBig : public Icmpv6Header { - public: - /** - * \brief Constructor. - */ - Icmpv6TooBig (); +public: + /** + * \brief Constructor. + */ + Icmpv6TooBig (); - /** - * \brief Destructor. - */ - virtual ~Icmpv6TooBig (); + /** + * \brief Destructor. + */ + virtual ~Icmpv6TooBig (); - /** - * \brief Get the UID of this class. - * \return UID - */ - static TypeId GetTypeId (); + /** + * \brief Get the UID of this class. + * \return UID + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Get the incorrect packet. - * \return the incorrect packet - */ - Ptr GetPacket () const; + /** + * \brief Get the incorrect packet. + * \return the incorrect packet + */ + Ptr GetPacket () const; - /** - * \brief Set the incorrect packet. - * \param p the incorrect packet - */ - void SetPacket (Ptr p); + /** + * \brief Set the incorrect packet. + * \param p the incorrect packet + */ + void SetPacket (Ptr p); - /** - * \brief Get the MTU field. - * \return MTU value - */ - uint32_t GetMtu () const; + /** + * \brief Get the MTU field. + * \return MTU value + */ + uint32_t GetMtu () const; - /** - * \brief Set the MTU. - * \param mtu the MTU - */ - void SetMtu (uint32_t mtu); + /** + * \brief Set the MTU. + * \param mtu the MTU + */ + void SetMtu (uint32_t mtu); - /** - * \brief Print informations. - * \param os output stream - */ - virtual void Print (std::ostream& os) const; + /** + * \brief Print informations. + * \param os output stream + */ + virtual void Print (std::ostream& os) const; - /** - * \brief Get the serialized size. - * \return serialized size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size. + * \return serialized size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start start offset - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start start offset + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start start offset - * \return length of packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start start offset + * \return length of packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: +private: - /** - * \brief the incorrect packet. - */ - Ptr m_packet; + /** + * \brief the incorrect packet. + */ + Ptr m_packet; - /** - * \brief The MTU value. - */ - uint32_t m_mtu; + /** + * \brief The MTU value. + */ + uint32_t m_mtu; }; /** @@ -1200,72 +1200,72 @@ class Icmpv6TooBig : public Icmpv6Header */ class Icmpv6TimeExceeded : public Icmpv6Header { - public: - /** - * \brief Constructor. - */ - Icmpv6TimeExceeded (); +public: + /** + * \brief Constructor. + */ + Icmpv6TimeExceeded (); - /** - * \brief Destructor. - */ - virtual ~Icmpv6TimeExceeded (); + /** + * \brief Destructor. + */ + virtual ~Icmpv6TimeExceeded (); - /** - * \brief Get the UID of this class. - * \return UID - */ - static TypeId GetTypeId (); + /** + * \brief Get the UID of this class. + * \return UID + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Get the incorrect packet. - * \return the incorrect packet - */ - Ptr GetPacket () const; + /** + * \brief Get the incorrect packet. + * \return the incorrect packet + */ + Ptr GetPacket () const; - /** - * \brief Set the incorrect packet. - * \param p the incorrect packet - */ - void SetPacket (Ptr p); + /** + * \brief Set the incorrect packet. + * \param p the incorrect packet + */ + void SetPacket (Ptr p); - /** - * \brief Print informations. - * \param os output stream - */ - virtual void Print (std::ostream& os) const; + /** + * \brief Print informations. + * \param os output stream + */ + virtual void Print (std::ostream& os) const; - /** - * \brief Get the serialized size. - * \return serialized size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size. + * \return serialized size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start start offset - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start start offset + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start start offset - * \return length of packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start start offset + * \return length of packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: +private: - /** - * \brief The incorrect packet. - */ - Ptr m_packet; + /** + * \brief The incorrect packet. + */ + Ptr m_packet; }; /** @@ -1274,89 +1274,89 @@ class Icmpv6TimeExceeded : public Icmpv6Header */ class Icmpv6ParameterError : public Icmpv6Header { - public: - /** - * \brief Constructor. - */ - Icmpv6ParameterError (); +public: + /** + * \brief Constructor. + */ + Icmpv6ParameterError (); - /** - * \brief Destructor. - */ - virtual ~Icmpv6ParameterError (); + /** + * \brief Destructor. + */ + virtual ~Icmpv6ParameterError (); - /** - * \brief Get the UID of this class. - * \return UID - */ - static TypeId GetTypeId (); + /** + * \brief Get the UID of this class. + * \return UID + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Get the incorrect packet. - * \return the incorrect packet - */ - Ptr GetPacket () const; + /** + * \brief Get the incorrect packet. + * \return the incorrect packet + */ + Ptr GetPacket () const; - /** - * \brief Set the incorrect packet. - * \param p the incorrect packet - */ - void SetPacket (Ptr p); + /** + * \brief Set the incorrect packet. + * \param p the incorrect packet + */ + void SetPacket (Ptr p); - /** - * \brief Get the pointer field. - * \return pointer value - */ - uint32_t GetPtr () const; + /** + * \brief Get the pointer field. + * \return pointer value + */ + uint32_t GetPtr () const; - /** - * \brief Set the pointer field. - * \param ptr byte where the error is located in the incorrect packet - */ - void SetPtr (uint32_t ptr); + /** + * \brief Set the pointer field. + * \param ptr byte where the error is located in the incorrect packet + */ + void SetPtr (uint32_t ptr); - /** - * \brief Print informations. - * \param os output stream - */ - virtual void Print (std::ostream& os) const; + /** + * \brief Print informations. + * \param os output stream + */ + virtual void Print (std::ostream& os) const; - /** - * \brief Get the serialized size. - * \return serialized size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size. + * \return serialized size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start start offset - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start start offset + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start start offset - * \return length of packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start start offset + * \return length of packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: +private: - /** - * \brief The incorrect packet. - */ - Ptr m_packet; + /** + * \brief The incorrect packet. + */ + Ptr m_packet; - /** - * \brief The pointer field. - */ - uint32_t m_ptr; + /** + * \brief The pointer field. + */ + uint32_t m_ptr; }; /** @@ -1365,94 +1365,94 @@ class Icmpv6ParameterError : public Icmpv6Header */ class Icmpv6OptionMtu : public Icmpv6OptionHeader { - public: - /** - * \brief Constructor. - */ - Icmpv6OptionMtu (); +public: + /** + * \brief Constructor. + */ + Icmpv6OptionMtu (); - /** - * \brief Constructor. - * \param mtu MTU used. - */ - Icmpv6OptionMtu (uint32_t mtu); + /** + * \brief Constructor. + * \param mtu MTU used. + */ + Icmpv6OptionMtu (uint32_t mtu); - /** - * \brief Destructor. - */ - virtual ~Icmpv6OptionMtu (); + /** + * \brief Destructor. + */ + virtual ~Icmpv6OptionMtu (); - /** - * \brief Get the UID of this class. - * \return UID - */ - static TypeId GetTypeId (); + /** + * \brief Get the UID of this class. + * \return UID + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Get the reserved field. - * \return the reserved value - */ - uint16_t GetReserved () const; + /** + * \brief Get the reserved field. + * \return the reserved value + */ + uint16_t GetReserved () const; - /** - * \brief Set the reserved field. - * \param reserved the reserved value - */ - void SetReserved (uint16_t reserved); + /** + * \brief Set the reserved field. + * \param reserved the reserved value + */ + void SetReserved (uint16_t reserved); - /** - * \brief Get the MTU. - * \return the MTU value - */ - uint32_t GetMtu () const; + /** + * \brief Get the MTU. + * \return the MTU value + */ + uint32_t GetMtu () const; - /** - * \brief Set the MTU. - * \param mtu the MTU to set - */ - void SetMtu (uint32_t mtu); + /** + * \brief Set the MTU. + * \param mtu the MTU to set + */ + void SetMtu (uint32_t mtu); - /** - * \brief Print informations. - * \param os output stream - */ - virtual void Print (std::ostream& os) const; + /** + * \brief Print informations. + * \param os output stream + */ + virtual void Print (std::ostream& os) const; - /** - * \brief Get the serialized size. - * \return serialized size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size. + * \return serialized size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start start offset - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start start offset + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start start offset - * \return length of packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start start offset + * \return length of packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: - /** - * \brief The reserved value - */ - uint16_t m_reserved; +private: + /** + * \brief The reserved value + */ + uint16_t m_reserved; - /** - * \brief The MTU value. - */ - uint32_t m_mtu; + /** + * \brief The MTU value. + */ + uint32_t m_mtu; }; /** @@ -1461,163 +1461,163 @@ class Icmpv6OptionMtu : public Icmpv6OptionHeader */ class Icmpv6OptionPrefixInformation : public Icmpv6OptionHeader { - public: - /** - * \brief Constructor. - */ - Icmpv6OptionPrefixInformation (); +public: + /** + * \brief Constructor. + */ + Icmpv6OptionPrefixInformation (); - /** - * \brief Constructor. - * \param network prefix - * \param prefixlen prefix length - */ - Icmpv6OptionPrefixInformation (Ipv6Address network, uint8_t prefixlen); + /** + * \brief Constructor. + * \param network prefix + * \param prefixlen prefix length + */ + Icmpv6OptionPrefixInformation (Ipv6Address network, uint8_t prefixlen); - /** - * \brief Destructor. - */ - virtual ~Icmpv6OptionPrefixInformation (); + /** + * \brief Destructor. + */ + virtual ~Icmpv6OptionPrefixInformation (); - /** - * \brief Get the UID of this class. - * \return UID - */ - static TypeId GetTypeId (); + /** + * \brief Get the UID of this class. + * \return UID + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Get the prefix length. - * \return prefix length - */ - uint8_t GetPrefixLength () const; + /** + * \brief Get the prefix length. + * \return prefix length + */ + uint8_t GetPrefixLength () const; - /** - * \brief Set the prefix length. - * \param prefixLength the prefix length - */ - void SetPrefixLength (uint8_t prefixLength); + /** + * \brief Set the prefix length. + * \param prefixLength the prefix length + */ + void SetPrefixLength (uint8_t prefixLength); - /** - * \brief Get the flags. - * \return the flags. - */ - uint8_t GetFlags () const; + /** + * \brief Get the flags. + * \return the flags. + */ + uint8_t GetFlags () const; - /** - * \brief Set the flags. - * \param flags the flags to set - */ - void SetFlags (uint8_t flags); + /** + * \brief Set the flags. + * \param flags the flags to set + */ + void SetFlags (uint8_t flags); - /** - * \brief Get the valid time of the information. - * \return valid time - */ - uint32_t GetValidTime () const; + /** + * \brief Get the valid time of the information. + * \return valid time + */ + uint32_t GetValidTime () const; - /** - * \brief Set the valid time of the information. - * \param validTime valid time - */ - void SetValidTime (uint32_t validTime); + /** + * \brief Set the valid time of the information. + * \param validTime valid time + */ + void SetValidTime (uint32_t validTime); - /** - * \brief Get the preferred time of the information. - * \return preferred time - */ - uint32_t GetPreferredTime () const; + /** + * \brief Get the preferred time of the information. + * \return preferred time + */ + uint32_t GetPreferredTime () const; - /** - * \brief Set the preferred time of the information. - * \param preferredTime preferred time - */ - void SetPreferredTime (uint32_t preferredTime); + /** + * \brief Set the preferred time of the information. + * \param preferredTime preferred time + */ + void SetPreferredTime (uint32_t preferredTime); - /** - * \brief Get the reserved field. - * \return the reserved field (should be 0x00000000) - */ - uint32_t GetReserved () const; + /** + * \brief Get the reserved field. + * \return the reserved field (should be 0x00000000) + */ + uint32_t GetReserved () const; - /** - * \brief Set the reserved field (normally it will be 0x00000000). - * \param reserved reserved value - */ - void SetReserved (uint32_t reserved); + /** + * \brief Set the reserved field (normally it will be 0x00000000). + * \param reserved reserved value + */ + void SetReserved (uint32_t reserved); - /** - * \brief Get the IPv6 prefix. - * \return IPv6 prefix - */ - Ipv6Address GetPrefix () const; + /** + * \brief Get the IPv6 prefix. + * \return IPv6 prefix + */ + Ipv6Address GetPrefix () const; - /** - * \brief Set the IPv6 prefix. - * \param prefix the IPv6 prefix - */ - void SetPrefix (Ipv6Address prefix); + /** + * \brief Set the IPv6 prefix. + * \param prefix the IPv6 prefix + */ + void SetPrefix (Ipv6Address prefix); - /** - * \brief Print informations. - * \param os output stream - */ - virtual void Print (std::ostream& os) const; + /** + * \brief Print informations. + * \param os output stream + */ + virtual void Print (std::ostream& os) const; - /** - * \brief Get the serialized size. - * \return serialized size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size. + * \return serialized size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start start offset - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start start offset + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start start offset - * \return length of packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start start offset + * \return length of packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: - /** - * \brief The prefix value. - */ - Ipv6Address m_prefix; +private: + /** + * \brief The prefix value. + */ + Ipv6Address m_prefix; - /** - * \brief The length of the prefix. - */ - uint8_t m_prefixLength; + /** + * \brief The length of the prefix. + */ + uint8_t m_prefixLength; - /** - * \brief The flags. - */ - uint8_t m_flags; + /** + * \brief The flags. + */ + uint8_t m_flags; - /** - * \brief The valid time. - */ - uint32_t m_validTime; + /** + * \brief The valid time. + */ + uint32_t m_validTime; - /** - * \brief The preferred time. - */ - uint32_t m_preferredTime; + /** + * \brief The preferred time. + */ + uint32_t m_preferredTime; - /** - * \brief The reserved field. - */ - uint32_t m_reserved; + /** + * \brief The reserved field. + */ + uint32_t m_reserved; }; /** @@ -1626,84 +1626,84 @@ class Icmpv6OptionPrefixInformation : public Icmpv6OptionHeader */ class Icmpv6OptionLinkLayerAddress : public Icmpv6OptionHeader { - public: - /** - * \brief Constructor. - * \param source source hardware address or target hardware address for the option - */ - Icmpv6OptionLinkLayerAddress (bool source); +public: + /** + * \brief Constructor. + * \param source source hardware address or target hardware address for the option + */ + Icmpv6OptionLinkLayerAddress (bool source); - /** - * \brief Get the UID of this class. - * \return UID - */ - static TypeId GetTypeId (); + /** + * \brief Get the UID of this class. + * \return UID + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId (void) const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId (void) const; - /** - * \brief Constructor. - * \param source source hardware address or target hardware address for the option - * \param addr hardware address - */ - Icmpv6OptionLinkLayerAddress (bool source, Address addr); + /** + * \brief Constructor. + * \param source source hardware address or target hardware address for the option + * \param addr hardware address + */ + Icmpv6OptionLinkLayerAddress (bool source, Address addr); - /** - * \brief Constructor. - */ - Icmpv6OptionLinkLayerAddress (); + /** + * \brief Constructor. + */ + Icmpv6OptionLinkLayerAddress (); - /** - * \brief Destructor. - */ - virtual ~Icmpv6OptionLinkLayerAddress (); + /** + * \brief Destructor. + */ + virtual ~Icmpv6OptionLinkLayerAddress (); - /** - * \brief Get the hardware address. - * \return the hardware address - */ - Address GetAddress () const; + /** + * \brief Get the hardware address. + * \return the hardware address + */ + Address GetAddress () const; - /** - * \brief Set the hardware address. - * \param addr the address to set - */ - void SetAddress (Address addr); + /** + * \brief Set the hardware address. + * \param addr the address to set + */ + void SetAddress (Address addr); - /** - * \brief Print informations. - * \param os output stream - */ - virtual void Print (std::ostream& os) const; + /** + * \brief Print informations. + * \param os output stream + */ + virtual void Print (std::ostream& os) const; - /** - * \brief Get the serialized size. - * \return serialized size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size. + * \return serialized size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start start offset - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start start offset + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start start offset - * \return length of packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start start offset + * \return length of packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: - /** - * \brief The hardware address. - */ - Address m_addr; +private: + /** + * \brief The hardware address. + */ + Address m_addr; }; /** @@ -1712,71 +1712,71 @@ class Icmpv6OptionLinkLayerAddress : public Icmpv6OptionHeader */ class Icmpv6OptionRedirected : public Icmpv6OptionHeader { - public: - /** - * \brief Get the UID of this class. - * \return UID - */ - static TypeId GetTypeId (); +public: + /** + * \brief Get the UID of this class. + * \return UID + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Constructor. - */ - Icmpv6OptionRedirected (); + /** + * \brief Constructor. + */ + Icmpv6OptionRedirected (); - /** - * \brief Destructor. - */ - virtual ~Icmpv6OptionRedirected (); + /** + * \brief Destructor. + */ + virtual ~Icmpv6OptionRedirected (); - /** - * \brief Get the redirected packet. - * \return the redirected packet - */ - Ptr GetPacket () const; + /** + * \brief Get the redirected packet. + * \return the redirected packet + */ + Ptr GetPacket () const; - /** - * \brief Set the redirected packet. - * \param packet the redirected packet - */ - void SetPacket (Ptr packet); + /** + * \brief Set the redirected packet. + * \param packet the redirected packet + */ + void SetPacket (Ptr packet); - /** - * \brief Print informations. - * \param os output stream - */ - virtual void Print (std::ostream& os) const; + /** + * \brief Print informations. + * \param os output stream + */ + virtual void Print (std::ostream& os) const; - /** - * \brief Get the serialized size. - * \return serialized size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size. + * \return serialized size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start start offset - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start start offset + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start start offset - * \return length of packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start start offset + * \return length of packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: - /** - * \brief The redirected packet. - */ - Ptr m_packet; +private: + /** + * \brief The redirected packet. + */ + Ptr m_packet; }; } /* namespace ns3 */ diff --git a/src/internet-stack/icmpv6-l4-protocol.cc b/src/internet-stack/icmpv6-l4-protocol.cc index 924b5d4a0..5b94daf02 100644 --- a/src/internet-stack/icmpv6-l4-protocol.cc +++ b/src/internet-stack/icmpv6-l4-protocol.cc @@ -91,11 +91,11 @@ void Icmpv6L4Protocol::DoDispose () { NS_LOG_FUNCTION_NOARGS (); for (CacheList::const_iterator it = m_cacheList.begin () ; it != m_cacheList.end () ; it++) - { - Ptr cache = *it; - cache->Dispose (); - cache = 0; - } + { + Ptr cache = *it; + cache->Dispose (); + cache = 0; + } m_cacheList.clear (); m_node = 0; @@ -106,20 +106,20 @@ void Icmpv6L4Protocol::NotifyNewAggregate () { NS_LOG_FUNCTION_NOARGS (); if (m_node == 0) - { - Ptr node = this->GetObject (); - if (node != 0) { - Ptr ipv6 = this->GetObject (); - if (ipv6 != 0) - { - this->SetNode (node); - ipv6->Insert (this); - Ptr rawFactory = CreateObject (); - ipv6->AggregateObject (rawFactory); - } + Ptr node = this->GetObject (); + if (node != 0) + { + Ptr ipv6 = this->GetObject (); + if (ipv6 != 0) + { + this->SetNode (node); + ipv6->Insert (this); + Ptr rawFactory = CreateObject (); + ipv6->AggregateObject (rawFactory); + } + } } - } Object::NotifyNewAggregate (); } @@ -161,9 +161,9 @@ void Icmpv6L4Protocol::DoDAD (Ipv6Address target, Ptr interface) NS_ASSERT (ipv6); if(!m_alwaysDad) - { - return; - } + { + return; + } /* TODO : disable multicast loopback to prevent NS probing to be received by the sender */ @@ -181,18 +181,18 @@ enum Ipv6L4Protocol::RxStatus_e Icmpv6L4Protocol::Receive (Ptr packet, I Ptr ipv6 = m_node->GetObject (); switch (*p->PeekData ()) /* very ugly! try to find something better in the future */ - { + { case Icmpv6Header::ICMPV6_ND_ROUTER_SOLICITATION: if (ipv6->IsForwarding (ipv6->GetInterfaceForDevice (interface->GetDevice ()))) - { - HandleRS (p, src, dst, interface); - } + { + HandleRS (p, src, dst, interface); + } break; case Icmpv6Header::ICMPV6_ND_ROUTER_ADVERTISEMENT: if (!ipv6->IsForwarding (ipv6->GetInterfaceForDevice (interface->GetDevice ()))) - { - HandleRA (p, src, dst, interface); - } + { + HandleRA (p, src, dst, interface); + } break; case Icmpv6Header::ICMPV6_ND_NEIGHBOR_SOLICITATION: HandleNS (p, src, dst, interface); @@ -219,7 +219,7 @@ enum Ipv6L4Protocol::RxStatus_e Icmpv6L4Protocol::Receive (Ptr packet, I default: NS_LOG_LOGIC ("Unknown ICMPv6 message type=" << (uint8_t)*p->PeekData ()); break; - } + } return Ipv6L4Protocol::RX_OK; } @@ -256,40 +256,40 @@ void Icmpv6L4Protocol::HandleRA (Ptr packet, Ipv6Address const &src, Ipv p->RemoveHeader (raHeader); while (next == true) - { - type = *p->PeekData (); - - switch (type) { - case Icmpv6Header::ICMPV6_OPT_PREFIX: - p->RemoveHeader (prefixHdr); - ipv6->AddAutoconfiguredAddress (ipv6->GetInterfaceForDevice (interface->GetDevice ()), prefixHdr.GetPrefix (), prefixHdr.GetPrefixLength (), - prefixHdr.GetFlags (), prefixHdr.GetValidTime (), prefixHdr.GetPreferredTime (), src); - break; - case Icmpv6Header::ICMPV6_OPT_MTU: - /* take in account the first MTU option */ - if (!hasMtu) + type = *p->PeekData (); + + switch (type) { - p->RemoveHeader (mtuHdr); - hasMtu = true; - /* XXX case of multiple prefix on single interface */ - /* interface->GetDevice ()->SetMtu (m.GetMtu ()); */ + case Icmpv6Header::ICMPV6_OPT_PREFIX: + p->RemoveHeader (prefixHdr); + ipv6->AddAutoconfiguredAddress (ipv6->GetInterfaceForDevice (interface->GetDevice ()), prefixHdr.GetPrefix (), prefixHdr.GetPrefixLength (), + prefixHdr.GetFlags (), prefixHdr.GetValidTime (), prefixHdr.GetPreferredTime (), src); + break; + case Icmpv6Header::ICMPV6_OPT_MTU: + /* take in account the first MTU option */ + if (!hasMtu) + { + p->RemoveHeader (mtuHdr); + hasMtu = true; + /* XXX case of multiple prefix on single interface */ + /* interface->GetDevice ()->SetMtu (m.GetMtu ()); */ + } + break; + case Icmpv6Header::ICMPV6_OPT_LINK_LAYER_SOURCE: + /* take in account the first LLA option */ + if (!hasLla) + { + p->RemoveHeader (llaHdr); + ReceiveLLA (llaHdr, src, dst, interface); + hasLla = true; + } + break; + default: + /* unknow option, quit */ + next = false; } - break; - case Icmpv6Header::ICMPV6_OPT_LINK_LAYER_SOURCE: - /* take in account the first LLA option */ - if (!hasLla) - { - p->RemoveHeader (llaHdr); - ReceiveLLA (llaHdr, src, dst, interface); - hasLla = true; - } - break; - default: - /* unknow option, quit */ - next = false; } - } } void Icmpv6L4Protocol::ReceiveLLA (Icmpv6OptionLinkLayerAddress lla, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface) @@ -298,63 +298,63 @@ void Icmpv6L4Protocol::ReceiveLLA (Icmpv6OptionLinkLayerAddress lla, Ipv6Address Address hardwareAddress; NdiscCache::Entry* entry = 0; Ptr cache = FindCache (interface->GetDevice ()); - + /* check if we have this address in our cache */ entry = cache->Lookup (src); if (!entry) - { - entry = cache->Add (src); - entry->SetRouter (true); - entry->SetMacAddress (lla.GetAddress ()); - entry->MarkReachable (); - entry->StartReachableTimer (); - } + { + entry = cache->Add (src); + entry->SetRouter (true); + entry->SetMacAddress (lla.GetAddress ()); + entry->MarkReachable (); + entry->StartReachableTimer (); + } else - { - std::list > waiting; - if (entry->IsIncomplete ()) { - entry->StopRetransmitTimer (); - // mark it to reachable - waiting = entry->MarkReachable (lla.GetAddress ()); - entry->StopReachableTimer (); - entry->StartReachableTimer (); - // send out waiting packet - for (std::list >::const_iterator it = waiting.begin (); it != waiting.end (); it++) - { - cache->GetInterface ()->Send (*it, src); - } - entry->ClearWaitingPacket (); - } - else - { - if (entry->GetMacAddress ()!=lla.GetAddress ()) - { - entry->SetMacAddress (lla.GetAddress ()); - entry->MarkStale (); - entry->SetRouter (true); - } - else - { - if (!entry->IsReachable ()) + std::list > waiting; + if (entry->IsIncomplete ()) { - entry->StopProbeTimer (); - entry->StopDelayTimer (); + entry->StopRetransmitTimer (); + // mark it to reachable waiting = entry->MarkReachable (lla.GetAddress ()); - if (entry->IsProbe ()) - { - for (std::list >::const_iterator it = waiting.begin (); it != waiting.end (); it++) + entry->StopReachableTimer (); + entry->StartReachableTimer (); + // send out waiting packet + for (std::list >::const_iterator it = waiting.begin (); it != waiting.end (); it++) { cache->GetInterface ()->Send (*it, src); } - } - entry->StopReachableTimer (); - entry->StartReachableTimer (); - } - } + entry->ClearWaitingPacket (); + } + else + { + if (entry->GetMacAddress ()!=lla.GetAddress ()) + { + entry->SetMacAddress (lla.GetAddress ()); + entry->MarkStale (); + entry->SetRouter (true); + } + else + { + if (!entry->IsReachable ()) + { + entry->StopProbeTimer (); + entry->StopDelayTimer (); + waiting = entry->MarkReachable (lla.GetAddress ()); + if (entry->IsProbe ()) + { + for (std::list >::const_iterator it = waiting.begin (); it != waiting.end (); it++) + { + cache->GetInterface ()->Send (*it, src); + } + } + entry->StopReachableTimer (); + entry->StartReachableTimer (); + } + } + } } - } } void Icmpv6L4Protocol::HandleRS (Ptr packet, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface) @@ -369,28 +369,28 @@ void Icmpv6L4Protocol::HandleRS (Ptr packet, Ipv6Address const &src, Ipv Ptr cache = FindCache (interface->GetDevice ()); if (src != Ipv6Address::GetAny ()) - { - /* XXX search all options following the RS header */ - /* test if the next option is SourceLinkLayerAddress */ - if (*packet->PeekData () != Icmpv6Header::ICMPV6_OPT_LINK_LAYER_SOURCE) { - return; - } - packet->RemoveHeader (lla); - NS_LOG_LOGIC ("Cache updated by RS"); + /* XXX search all options following the RS header */ + /* test if the next option is SourceLinkLayerAddress */ + if (*packet->PeekData () != Icmpv6Header::ICMPV6_OPT_LINK_LAYER_SOURCE) + { + return; + } + packet->RemoveHeader (lla); + NS_LOG_LOGIC ("Cache updated by RS"); - entry = cache->Lookup (src); - if (!entry) - { - entry = cache->Add (src); - entry->SetRouter (false); - entry->MarkStale (lla.GetAddress ()); + entry = cache->Lookup (src); + if (!entry) + { + entry = cache->Add (src); + entry->SetRouter (false); + entry->MarkStale (lla.GetAddress ()); + } + else if (entry->GetMacAddress () != lla.GetAddress ()) + { + entry->MarkStale (lla.GetAddress ()); + } } - else if (entry->GetMacAddress () != lla.GetAddress ()) - { - entry->MarkStale (lla.GetAddress ()); - } - } } void Icmpv6L4Protocol::HandleNS (Ptr packet, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface) @@ -407,28 +407,28 @@ void Icmpv6L4Protocol::HandleNS (Ptr packet, Ipv6Address const &src, Ipv Ipv6Address target = nsHeader.GetIpv6Target (); for (i = 0 ; i < nb ; i++) - { - ifaddr = interface->GetAddress (i); - - if (ifaddr.GetAddress () == target) { - found = true; - break; + ifaddr = interface->GetAddress (i); + + if (ifaddr.GetAddress () == target) + { + found = true; + break; + } } - } if (!found) - { - NS_LOG_LOGIC ("Not a NS for us"); - return; - } + { + NS_LOG_LOGIC ("Not a NS for us"); + return; + } if (packet->GetUid () == ifaddr.GetNsDadUid ()) - { - /* don't process our own DAD probe */ - NS_LOG_LOGIC ("Hey we receive our DAD probe!"); - return; - } + { + /* don't process our own DAD probe */ + NS_LOG_LOGIC ("Hey we receive our DAD probe!"); + return; + } Icmpv6OptionLinkLayerAddress lla (1); Address hardwareAddress; @@ -439,42 +439,42 @@ void Icmpv6L4Protocol::HandleNS (Ptr packet, Ipv6Address const &src, Ipv /* XXX search all options following the NS header */ if (src != Ipv6Address::GetAny ()) - { - if (*packet->PeekData () != Icmpv6Header::ICMPV6_OPT_LINK_LAYER_SOURCE) { - return; - } + if (*packet->PeekData () != Icmpv6Header::ICMPV6_OPT_LINK_LAYER_SOURCE) + { + return; + } - /* Get LLA */ - packet->RemoveHeader (lla); + /* Get LLA */ + packet->RemoveHeader (lla); - entry = cache->Lookup (src); - if (!entry) - { - entry = cache->Add (src); - entry->SetRouter (false); - entry->MarkStale (lla.GetAddress ()); - } - else if (entry->GetMacAddress () != lla.GetAddress ()) - { - entry->MarkStale (lla.GetAddress ()); - } + entry = cache->Lookup (src); + if (!entry) + { + entry = cache->Add (src); + entry->SetRouter (false); + entry->MarkStale (lla.GetAddress ()); + } + else if (entry->GetMacAddress () != lla.GetAddress ()) + { + entry->MarkStale (lla.GetAddress ()); + } - flags = 3; /* S + O flags */ - } + flags = 3; /* S + O flags */ + } else - { - /* it means someone do a DAD */ - flags = 1; /* O flag */ - } + { + /* it means someone do a DAD */ + flags = 1; /* O flag */ + } /* send a NA to src */ Ptr ipv6 = m_node->GetObject (); if (ipv6->IsForwarding (ipv6->GetInterfaceForDevice (interface->GetDevice ()))) - { - flags += 4; /* R flag */ - } + { + flags += 4; /* R flag */ + } hardwareAddress = interface->GetDevice ()->GetAddress (); Ptr p = ForgeNA (target.IsLinkLocal () ? interface->GetLinkLocalAddress ().GetAddress () : ifaddr.GetAddress (), src.IsAny () ? Ipv6Address::GetAllNodesMulticast () : src, &hardwareAddress, flags ); @@ -541,119 +541,119 @@ void Icmpv6L4Protocol::HandleNA (Ptr packet, Ipv6Address const &src, Ipv entry = cache->Lookup (target); if (!entry) - { - /* ouch!! we are victim of a DAD */ - Ipv6InterfaceAddress ifaddr; - bool found = false; - uint32_t i = 0; - uint32_t nb = 0; - - for (i = 0 ; i < nb ; i++) { - if (ifaddr.GetAddress () == target) - { - found = true; - break; - } - } + /* ouch!! we are victim of a DAD */ + Ipv6InterfaceAddress ifaddr; + bool found = false; + uint32_t i = 0; + uint32_t nb = 0; - if (found) - { - if (ifaddr.GetState () == Ipv6InterfaceAddress::TENTATIVE || ifaddr.GetState () == Ipv6InterfaceAddress::TENTATIVE_OPTIMISTIC) - { - interface->SetState (ifaddr.GetAddress (), Ipv6InterfaceAddress::INVALID); - } + for (i = 0 ; i < nb ; i++) + { + if (ifaddr.GetAddress () == target) + { + found = true; + break; + } + } + + if (found) + { + if (ifaddr.GetState () == Ipv6InterfaceAddress::TENTATIVE || ifaddr.GetState () == Ipv6InterfaceAddress::TENTATIVE_OPTIMISTIC) + { + interface->SetState (ifaddr.GetAddress (), Ipv6InterfaceAddress::INVALID); + } + } + /* we have not initiated any communication with the target so... discard the NA */ + return; } - /* we have not initiated any communication with the target so... discard the NA */ - return; - } /* XXX search all options following the NA header */ /* Get LLA */ if (*packet->PeekData () != Icmpv6Header::ICMPV6_OPT_LINK_LAYER_TARGET) - { - return; - } + { + return; + } packet->RemoveHeader (lla); if (entry->IsIncomplete ()) - { - /* we receive a NA so stop the retransmission timer */ - entry->StopRetransmitTimer (); + { + /* we receive a NA so stop the retransmission timer */ + entry->StopRetransmitTimer (); - if (naHeader.GetFlagS ()) - { - /* mark it to reachable */ - waiting = entry->MarkReachable (lla.GetAddress ()); - entry->StopReachableTimer (); - entry->StartReachableTimer (); - /* send out waiting packet */ - for (std::list >::const_iterator it = waiting.begin (); it != waiting.end (); it++) - { - cache->GetInterface ()->Send (*it, src); - } - entry->ClearWaitingPacket (); - } - else - { - entry->MarkStale (lla.GetAddress ()); - } - - if (naHeader.GetFlagR ()) - { - entry->SetRouter (true); - } - } - else - { - /* we receive a NA so stop the probe timer or delay timer if any */ - entry->StopProbeTimer (); - entry->StopDelayTimer (); - - /* if the Flag O is clear and mac address differs from the cache */ - if (!naHeader.GetFlagO () && lla.GetAddress ()!=entry->GetMacAddress ()) - { - if (entry->IsReachable ()) - { - entry->MarkStale (); - } - return; - } - else - { - if ((!naHeader.GetFlagO () && lla.GetAddress () == entry->GetMacAddress ()) || naHeader.GetFlagO ()) /* XXX lake "no target link-layer address option supplied" */ - { - entry->SetMacAddress (lla.GetAddress ()); - - if (naHeader.GetFlagS ()) + if (naHeader.GetFlagS ()) { - if (!entry->IsReachable ()) - { - if (entry->IsProbe ()) - { - waiting = entry->MarkReachable (lla.GetAddress ()); - for (std::list >::const_iterator it = waiting.begin (); it != waiting.end (); it++) - { - cache->GetInterface ()->Send (*it, src); - } - entry->ClearWaitingPacket (); - } - else - { - entry->MarkReachable (lla.GetAddress ()); - } - } + /* mark it to reachable */ + waiting = entry->MarkReachable (lla.GetAddress ()); entry->StopReachableTimer (); entry->StartReachableTimer (); + /* send out waiting packet */ + for (std::list >::const_iterator it = waiting.begin (); it != waiting.end (); it++) + { + cache->GetInterface ()->Send (*it, src); + } + entry->ClearWaitingPacket (); } - else if (lla.GetAddress ()!=entry->GetMacAddress ()) + else { - entry->MarkStale (); + entry->MarkStale (lla.GetAddress ()); + } + + if (naHeader.GetFlagR ()) + { + entry->SetRouter (true); + } + } + else + { + /* we receive a NA so stop the probe timer or delay timer if any */ + entry->StopProbeTimer (); + entry->StopDelayTimer (); + + /* if the Flag O is clear and mac address differs from the cache */ + if (!naHeader.GetFlagO () && lla.GetAddress ()!=entry->GetMacAddress ()) + { + if (entry->IsReachable ()) + { + entry->MarkStale (); + } + return; + } + else + { + if ((!naHeader.GetFlagO () && lla.GetAddress () == entry->GetMacAddress ()) || naHeader.GetFlagO ()) /* XXX lake "no target link-layer address option supplied" */ + { + entry->SetMacAddress (lla.GetAddress ()); + + if (naHeader.GetFlagS ()) + { + if (!entry->IsReachable ()) + { + if (entry->IsProbe ()) + { + waiting = entry->MarkReachable (lla.GetAddress ()); + for (std::list >::const_iterator it = waiting.begin (); it != waiting.end (); it++) + { + cache->GetInterface ()->Send (*it, src); + } + entry->ClearWaitingPacket (); + } + else + { + entry->MarkReachable (lla.GetAddress ()); + } + } + entry->StopReachableTimer (); + entry->StartReachableTimer (); + } + else if (lla.GetAddress ()!=entry->GetMacAddress ()) + { + entry->MarkStale (); + } + entry->SetRouter (naHeader.GetFlagR ()); + } } - entry->SetRouter (naHeader.GetFlagR ()); - } } - } } void Icmpv6L4Protocol::HandleRedirection (Ptr packet, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface) @@ -668,10 +668,10 @@ void Icmpv6L4Protocol::HandleRedirection (Ptr packet, Ipv6Address const /* little ugly try to find a better way */ if (*p->PeekData () == Icmpv6Header::ICMPV6_OPT_LINK_LAYER_TARGET) - { - hasLla = true; - p->RemoveHeader (llOptionHeader); - } + { + hasLla = true; + p->RemoveHeader (llOptionHeader); + } Icmpv6OptionRedirected redirectedOptionHeader; p->RemoveHeader (redirectedOptionHeader); @@ -680,50 +680,50 @@ void Icmpv6L4Protocol::HandleRedirection (Ptr packet, Ipv6Address const Ipv6Address redirDestination = redirectionHeader.GetDestination (); if (hasLla) - { - /* update the cache if needed */ - NdiscCache::Entry* entry = 0; - Ptr cache = FindCache (interface->GetDevice ()); + { + /* update the cache if needed */ + NdiscCache::Entry* entry = 0; + Ptr cache = FindCache (interface->GetDevice ()); - entry = cache->Lookup (redirTarget); - if (!entry) - { - entry = cache->Add (redirTarget); - /* destination and target different => necessarily a router */ - entry->SetRouter (!redirTarget.IsEqual (redirDestination) ? true : false); - entry->SetMacAddress (llOptionHeader.GetAddress ()); - entry->MarkStale (); - } - else - { - if (entry->IsIncomplete () || entry->GetMacAddress () != llOptionHeader.GetAddress ()) - { - /* update entry to STALE */ - if (entry->GetMacAddress ()!=llOptionHeader.GetAddress ()) + entry = cache->Lookup (redirTarget); + if (!entry) { + entry = cache->Add (redirTarget); + /* destination and target different => necessarily a router */ + entry->SetRouter (!redirTarget.IsEqual (redirDestination) ? true : false); entry->SetMacAddress (llOptionHeader.GetAddress ()); entry->MarkStale (); } - } else - { - /* stay unchanged */ - } + { + if (entry->IsIncomplete () || entry->GetMacAddress () != llOptionHeader.GetAddress ()) + { + /* update entry to STALE */ + if (entry->GetMacAddress ()!=llOptionHeader.GetAddress ()) + { + entry->SetMacAddress (llOptionHeader.GetAddress ()); + entry->MarkStale (); + } + } + else + { + /* stay unchanged */ + } + } } - } /* add redirection in routing table */ Ptr ipv6 = m_node->GetObject (); if (redirTarget.IsEqual (redirDestination)) - { - ipv6->GetRoutingProtocol ()->NotifyAddRoute (redirDestination, Ipv6Prefix (128), Ipv6Address ("::"), ipv6->GetInterfaceForAddress (dst)); - } + { + ipv6->GetRoutingProtocol ()->NotifyAddRoute (redirDestination, Ipv6Prefix (128), Ipv6Address ("::"), ipv6->GetInterfaceForAddress (dst)); + } else - { - uint32_t ifIndex = ipv6->GetInterfaceForAddress (dst); - ipv6->GetRoutingProtocol ()->NotifyAddRoute (redirDestination, Ipv6Prefix (128), redirTarget, ifIndex); - } + { + uint32_t ifIndex = ipv6->GetInterfaceForAddress (dst); + ipv6->GetRoutingProtocol ()->NotifyAddRoute (redirDestination, Ipv6Prefix (128), redirTarget, ifIndex); + } } void Icmpv6L4Protocol::SendMessage (Ptr packet, Ipv6Address src, Ipv6Address dst, uint8_t ttl) @@ -748,25 +748,25 @@ void Icmpv6L4Protocol::SendMessage (Ptr packet, Ipv6Address dst, Icmpv6H Socket::SocketErrno err; Ptr route; Ptr oif (0); //specify non-zero if bound to a source address - + header.SetDestinationAddress (dst); route = ipv6->GetRoutingProtocol ()->RouteOutput (packet, header, oif, err); - - if (route != 0) - { - NS_LOG_LOGIC ("Route exists"); - tag.SetTtl (ttl); - packet->AddPacketTag (tag); - Ipv6Address src = route->GetSource (); - icmpv6Hdr.CalculatePseudoHeaderChecksum (src, dst, packet->GetSize () + icmpv6Hdr.GetSerializedSize (), PROT_NUMBER); - packet->AddHeader (icmpv6Hdr); - ipv6->Send (packet, src, dst, PROT_NUMBER, route); - } + if (route != 0) + { + NS_LOG_LOGIC ("Route exists"); + tag.SetTtl (ttl); + packet->AddPacketTag (tag); + Ipv6Address src = route->GetSource (); + + icmpv6Hdr.CalculatePseudoHeaderChecksum (src, dst, packet->GetSize () + icmpv6Hdr.GetSerializedSize (), PROT_NUMBER); + packet->AddHeader (icmpv6Hdr); + ipv6->Send (packet, src, dst, PROT_NUMBER, route); + } else - { - NS_LOG_WARN ("drop icmp message"); - } + { + NS_LOG_WARN ("drop icmp message"); + } } void Icmpv6L4Protocol::SendNA (Ipv6Address src, Ipv6Address dst, Address* hardwareAddress, uint8_t flags) @@ -780,17 +780,17 @@ void Icmpv6L4Protocol::SendNA (Ipv6Address src, Ipv6Address dst, Address* hardwa na.SetIpv6Target (src); if ((flags & 1)) - { - na.SetFlagO (true); - } + { + na.SetFlagO (true); + } if ((flags & 2) && src != Ipv6Address::GetAny ()) - { - na.SetFlagS (true); - } + { + na.SetFlagS (true); + } if ((flags & 4)) - { - na.SetFlagR (true); - } + { + na.SetFlagR (true); + } p->AddHeader (llOption); na.CalculatePseudoHeaderChecksum (src, dst, p->GetSize () + na.GetSerializedSize (), PROT_NUMBER); @@ -823,9 +823,9 @@ void Icmpv6L4Protocol::SendNS (Ipv6Address src, Ipv6Address dst, Ipv6Address tar /* if the source is unspec, multicast the NA to all-nodes multicast */ if (src == Ipv6Address::GetAny ()) - { - dst = Ipv6Address::GetAllNodesMulticast (); - } + { + dst = Ipv6Address::GetAllNodesMulticast (); + } NS_LOG_LOGIC ("Send NS ( from " << src << " to " << dst << " target " << target <<")"); @@ -844,9 +844,9 @@ void Icmpv6L4Protocol::SendRS (Ipv6Address src, Ipv6Address dst, Address hardwa /* if the source is unspec, multicast the NA to all-nodes multicast */ if (src != Ipv6Address::GetAny ()) - { - p->AddHeader (llOption); - } + { + p->AddHeader (llOption); + } NS_LOG_LOGIC ("Send RS ( from " << src << " to " << dst << ")"); @@ -866,14 +866,14 @@ void Icmpv6L4Protocol::SendErrorDestinationUnreachable (Ptr malformedPac /* 48 = sizeof IPv6 header + sizeof ICMPv6 error header */ if (malformedPacketSize <= 1280 - 48) - { - header.SetPacket (malformedPacket); - } + { + header.SetPacket (malformedPacket); + } else - { - Ptr fragment = malformedPacket->CreateFragment (0, 1280 - 48); - header.SetPacket (fragment); - } + { + Ptr fragment = malformedPacket->CreateFragment (0, 1280 - 48); + header.SetPacket (fragment); + } header.SetCode (code); SendMessage (p, dst, header, 255); @@ -890,14 +890,14 @@ void Icmpv6L4Protocol::SendErrorTooBig (Ptr malformedPacket, Ipv6Address /* 48 = sizeof IPv6 header + sizeof ICMPv6 error header */ if (malformedPacketSize <= 1280 - 48) - { - header.SetPacket (malformedPacket); - } + { + header.SetPacket (malformedPacket); + } else - { - Ptr fragment = malformedPacket->CreateFragment (0, 1280 - 48); - header.SetPacket (fragment); - } + { + Ptr fragment = malformedPacket->CreateFragment (0, 1280 - 48); + header.SetPacket (fragment); + } header.SetCode (0); header.SetMtu (mtu); @@ -915,14 +915,14 @@ void Icmpv6L4Protocol::SendErrorTimeExceeded (Ptr malformedPacket, Ipv6A /* 48 = sizeof IPv6 header + sizeof ICMPv6 error header */ if (malformedPacketSize <= 1280 - 48) - { - header.SetPacket (malformedPacket); - } + { + header.SetPacket (malformedPacket); + } else - { - Ptr fragment = malformedPacket->CreateFragment (0, 1280 - 48); - header.SetPacket (fragment); - } + { + Ptr fragment = malformedPacket->CreateFragment (0, 1280 - 48); + header.SetPacket (fragment); + } header.SetCode (code); SendMessage (p, dst, header, 255); @@ -939,14 +939,14 @@ void Icmpv6L4Protocol::SendErrorParameterError (Ptr malformedPacket, Ipv /* 48 = sizeof IPv6 header + sizeof ICMPv6 error header */ if (malformedPacketSize <= 1280 -48 ) - { - header.SetPacket (malformedPacket); - } + { + header.SetPacket (malformedPacket); + } else - { - Ptr fragment = malformedPacket->CreateFragment (0, 1280 - 48); - header.SetPacket (fragment); - } + { + Ptr fragment = malformedPacket->CreateFragment (0, 1280 - 48); + header.SetPacket (fragment); + } header.SetCode (code); header.SetPtr (ptr); @@ -966,34 +966,34 @@ void Icmpv6L4Protocol::SendRedirection (Ptr redirectedPacket, Ipv6Addres Icmpv6OptionRedirected redirectedOptionHeader; if ((redirectedPacketSize % 8) != 0) - { - Ptr pad = Create (8 - (redirectedPacketSize % 8)); - redirectedPacket->AddAtEnd (pad); - } + { + Ptr pad = Create (8 - (redirectedPacketSize % 8)); + redirectedPacket->AddAtEnd (pad); + } if (redirHardwareTarget.GetLength ()) - { - llOption.SetAddress (redirHardwareTarget); - llaSize = llOption.GetSerializedSize (); - } + { + llOption.SetAddress (redirHardwareTarget); + llaSize = llOption.GetSerializedSize (); + } /* 56 = sizeof IPv6 header + sizeof ICMPv6 error header + sizeof redirected option */ if (redirectedPacketSize <= (1280 - 56 - llaSize)) - { - redirectedOptionHeader.SetPacket (redirectedPacket); - } + { + redirectedOptionHeader.SetPacket (redirectedPacket); + } else - { - Ptr fragment = redirectedPacket->CreateFragment (0, 1280 - 56 - llaSize); - redirectedOptionHeader.SetPacket (fragment); - } + { + Ptr fragment = redirectedPacket->CreateFragment (0, 1280 - 56 - llaSize); + redirectedOptionHeader.SetPacket (fragment); + } p->AddHeader (redirectedOptionHeader); if (llaSize) - { - p->AddHeader (llOption); - } + { + p->AddHeader (llOption); + } Icmpv6Redirection redirectionHeader; redirectionHeader.SetTarget (redirTarget); @@ -1017,17 +1017,17 @@ Ptr Icmpv6L4Protocol::ForgeNA (Ipv6Address src, Ipv6Address dst, Address na.SetIpv6Target (src); if ((flags & 1)) - { - na.SetFlagO (true); - } + { + na.SetFlagO (true); + } if ((flags & 2) && src != Ipv6Address::GetAny ()) - { - na.SetFlagS (true); - } + { + na.SetFlagS (true); + } if ((flags & 4)) - { - na.SetFlagR (true); - } + { + na.SetFlagR (true); + } na.CalculatePseudoHeaderChecksum (src, dst, p->GetSize () + na.GetSerializedSize (), PROT_NUMBER); p->AddHeader (na); @@ -1037,7 +1037,7 @@ Ptr Icmpv6L4Protocol::ForgeNA (Ipv6Address src, Ipv6Address dst, Address ipHeader.SetNextHeader (PROT_NUMBER); ipHeader.SetPayloadLength (p->GetSize ()); ipHeader.SetHopLimit (255); - + p->AddHeader (ipHeader); return p; @@ -1053,9 +1053,9 @@ Ptr Icmpv6L4Protocol::ForgeNS (Ipv6Address src, Ipv6Address dst, Ipv6Add /* if the source is unspec, multicast the NA to all-nodes multicast */ if (src == Ipv6Address::GetAny ()) - { - dst = Ipv6Address::GetAllNodesMulticast (); - } + { + dst = Ipv6Address::GetAllNodesMulticast (); + } NS_LOG_LOGIC ("Send NS ( from " << src << " to " << dst << " target " << target <<")"); @@ -1079,12 +1079,12 @@ Ptr Icmpv6L4Protocol::FindCache (Ptr device) NS_LOG_FUNCTION (this << device); for (CacheList::const_iterator i = m_cacheList.begin () ; i != m_cacheList.end () ; i++) - { - if ((*i)->GetDevice () == device) { - return *i; + if ((*i)->GetDevice () == device) + { + return *i; + } } - } NS_ASSERT (false); /* quiet compiler */ @@ -1094,7 +1094,7 @@ Ptr Icmpv6L4Protocol::FindCache (Ptr device) Ptr Icmpv6L4Protocol::CreateCache (Ptr device, Ptr interface) { Ptr cache = CreateObject (); - + cache->SetDevice (device, interface); device->AddLinkChangeCallback (MakeCallback (&NdiscCache::Flush, cache)); m_cacheList.push_back (cache); @@ -1106,10 +1106,10 @@ bool Icmpv6L4Protocol::Lookup (Ipv6Address dst, Ptr device, PtrLookup (dst); } @@ -1119,68 +1119,68 @@ bool Icmpv6L4Protocol::Lookup (Ptr p, Ipv6Address dst, Ptr de NS_LOG_FUNCTION (this << p << dst << device << hardwareDestination); if (!cache) - { - /* try to find the cache */ - cache = FindCache (device); - } + { + /* try to find the cache */ + cache = FindCache (device); + } NdiscCache::Entry* entry = cache->Lookup (dst); if (entry) - { - if (entry->IsReachable () || entry->IsDelay ()) { - /* XXX check reachability time */ - /* send packet */ - *hardwareDestination = entry->GetMacAddress (); - return true; + if (entry->IsReachable () || entry->IsDelay ()) + { + /* XXX check reachability time */ + /* send packet */ + *hardwareDestination = entry->GetMacAddress (); + return true; + } + else if (entry->IsStale ()) + { + /* start delay timer */ + entry->StartDelayTimer (); + entry->MarkDelay (); + *hardwareDestination = entry->GetMacAddress (); + return true; + } + else /* PROBE */ + { + /* queue packet */ + entry->AddWaitingPacket (p); + return false; + } } - else if (entry->IsStale ()) - { - /* start delay timer */ - entry->StartDelayTimer (); - entry->MarkDelay (); - *hardwareDestination = entry->GetMacAddress (); - return true; - } - else /* PROBE */ - { - /* queue packet */ - entry->AddWaitingPacket (p); - return false; - } - } else - { - /* we contact this node for the first time - * add it to the cache and send an NS - */ - Ipv6Address addr; - NdiscCache::Entry* entry = cache->Add (dst); - entry->MarkIncomplete (p); - entry->SetRouter (false); + { + /* we contact this node for the first time + * add it to the cache and send an NS + */ + Ipv6Address addr; + NdiscCache::Entry* entry = cache->Add (dst); + entry->MarkIncomplete (p); + entry->SetRouter (false); - if (dst.IsLinkLocal ()) - { - addr = cache->GetInterface ()->GetLinkLocalAddress ().GetAddress (); - } - else if (cache->GetInterface ()->GetNAddresses () == 1) /* an interface have at least one address (link-local) */ - { - /* try to resolve global address without having global address so return! */ - cache->Remove (entry); + if (dst.IsLinkLocal ()) + { + addr = cache->GetInterface ()->GetLinkLocalAddress ().GetAddress (); + } + else if (cache->GetInterface ()->GetNAddresses () == 1) /* an interface have at least one address (link-local) */ + { + /* try to resolve global address without having global address so return! */ + cache->Remove (entry); + return false; + } + else + { + /* find source address that match destination */ + addr = cache->GetInterface ()->GetAddressMatchingDestination (dst).GetAddress (); + } + + SendNS (addr, Ipv6Address::MakeSolicitedAddress (dst), dst, cache->GetDevice ()->GetAddress ()); + + /* start retransmit timer */ + entry->StartRetransmitTimer (); return false; } - else - { - /* find source address that match destination */ - addr = cache->GetInterface ()->GetAddressMatchingDestination (dst).GetAddress (); - } - - SendNS (addr, Ipv6Address::MakeSolicitedAddress (dst), dst, cache->GetDevice ()->GetAddress ()); - - /* start retransmit timer */ - entry->StartRetransmitTimer (); - return false; - } return false; } @@ -1193,39 +1193,39 @@ void Icmpv6L4Protocol::FunctionDadTimeout (Ptr icmpv6, Ipv6Int bool found = false; uint32_t i = 0; uint32_t nb = interface->GetNAddresses (); - - for (i = 0 ; i < nb ; i++) - { - ifaddr = interface->GetAddress (i); - if (ifaddr.GetAddress () == addr) + for (i = 0 ; i < nb ; i++) { - found = true; - break; + ifaddr = interface->GetAddress (i); + + if (ifaddr.GetAddress () == addr) + { + found = true; + break; + } } - } /* for the moment, this function is always called, if we was victim of a DAD the address is INVALID * and we do not set it to PREFERRED */ if (found && ifaddr.GetState () != Ipv6InterfaceAddress::INVALID) - { - interface->SetState (ifaddr.GetAddress (), Ipv6InterfaceAddress::PREFERRED); - NS_LOG_LOGIC ("DAD OK, interface in state PREFERRED"); - - /* send an RS if our interface is not forwarding (router) and if address is a link-local ones - * (because we will send RS with it) - */ - Ptr ipv6 = icmpv6->m_node->GetObject (); - - if (!ipv6->IsForwarding (ipv6->GetInterfaceForDevice (interface->GetDevice ())) && addr.IsLinkLocal ()) { - /* XXX because all nodes start at the same time, there will be many of RS arround 1 second of simulation time - * TODO Add random delays before sending RS + interface->SetState (ifaddr.GetAddress (), Ipv6InterfaceAddress::PREFERRED); + NS_LOG_LOGIC ("DAD OK, interface in state PREFERRED"); + + /* send an RS if our interface is not forwarding (router) and if address is a link-local ones + * (because we will send RS with it) */ - Simulator::Schedule (Seconds (0.0), &Icmpv6L4Protocol::SendRS, PeekPointer (icmpv6), ifaddr.GetAddress (), Ipv6Address::GetAllRoutersMulticast (), interface->GetDevice ()->GetAddress ()); + Ptr ipv6 = icmpv6->m_node->GetObject (); + + if (!ipv6->IsForwarding (ipv6->GetInterfaceForDevice (interface->GetDevice ())) && addr.IsLinkLocal ()) + { + /* XXX because all nodes start at the same time, there will be many of RS arround 1 second of simulation time + * TODO Add random delays before sending RS + */ + Simulator::Schedule (Seconds (0.0), &Icmpv6L4Protocol::SendRS, PeekPointer (icmpv6), ifaddr.GetAddress (), Ipv6Address::GetAllRoutersMulticast (), interface->GetDevice ()->GetAddress ()); + } } - } } } /* namespace ns3 */ diff --git a/src/internet-stack/icmpv6-l4-protocol.h b/src/internet-stack/icmpv6-l4-protocol.h index c1fb1ceab..5a3b62520 100644 --- a/src/internet-stack/icmpv6-l4-protocol.h +++ b/src/internet-stack/icmpv6-l4-protocol.h @@ -31,7 +31,7 @@ namespace ns3 { - + class NetDevice; class Node; class Packet; @@ -44,445 +44,445 @@ class NdiscCache; */ class Icmpv6L4Protocol : public Ipv6L4Protocol { - public: - /** - * \brief Interface ID - */ - static TypeId GetTypeId (); +public: + /** + * \brief Interface ID + */ + static TypeId GetTypeId (); - /** - * \brief ICMPv6 protocol number (58). - */ - static const uint8_t PROT_NUMBER; + /** + * \brief ICMPv6 protocol number (58). + */ + static const uint8_t PROT_NUMBER; - /** - * \brief Neighbor Discovery router constants : max initial RA initial interval. - */ - static const uint8_t MAX_INITIAL_RTR_ADVERT_INTERVAL; + /** + * \brief Neighbor Discovery router constants : max initial RA initial interval. + */ + static const uint8_t MAX_INITIAL_RTR_ADVERT_INTERVAL; - /** - * \brief Neighbor Discovery router constants : max initial RA transmission. - */ - static const uint8_t MAX_INITIAL_RTR_ADVERTISEMENTS; + /** + * \brief Neighbor Discovery router constants : max initial RA transmission. + */ + static const uint8_t MAX_INITIAL_RTR_ADVERTISEMENTS; - /** - * \brief Neighbor Discovery router constants : max final RA transmission. - */ - static const uint8_t MAX_FINAL_RTR_ADVERTISEMENTS; + /** + * \brief Neighbor Discovery router constants : max final RA transmission. + */ + static const uint8_t MAX_FINAL_RTR_ADVERTISEMENTS; - /** - * \brief Neighbor Discovery router constants : min delay between RA. - */ - static const uint8_t MIN_DELAY_BETWEEN_RAS; + /** + * \brief Neighbor Discovery router constants : min delay between RA. + */ + static const uint8_t MIN_DELAY_BETWEEN_RAS; - /** - * \brief Neighbor Discovery router constants : max delay between RA. - */ - static const uint32_t MAX_RA_DELAY_TIME; + /** + * \brief Neighbor Discovery router constants : max delay between RA. + */ + static const uint32_t MAX_RA_DELAY_TIME; - /** - * \brief Neighbor Discovery host constants : max RS delay. - */ - static const uint8_t MAX_RTR_SOLICITATION_DELAY; + /** + * \brief Neighbor Discovery host constants : max RS delay. + */ + static const uint8_t MAX_RTR_SOLICITATION_DELAY; - /** - * \brief Neighbor Discovery host constants : RS interval. - */ - static const uint8_t RTR_SOLICITATION_INTERVAL; + /** + * \brief Neighbor Discovery host constants : RS interval. + */ + static const uint8_t RTR_SOLICITATION_INTERVAL; - /** - * \brief Neighbor Discovery host constants : max RS transmission. - */ - static const uint8_t MAX_RTR_SOLICITATIONS; + /** + * \brief Neighbor Discovery host constants : max RS transmission. + */ + static const uint8_t MAX_RTR_SOLICITATIONS; - /** - * \brief Neighbor Discovery node constants : max multicast solicitations. - */ - static const uint8_t MAX_MULTICAST_SOLICIT; + /** + * \brief Neighbor Discovery node constants : max multicast solicitations. + */ + static const uint8_t MAX_MULTICAST_SOLICIT; - /** - * \brief Neighbor Discovery node constants : max unicast solicitations. - */ - static const uint8_t MAX_UNICAST_SOLICIT; + /** + * \brief Neighbor Discovery node constants : max unicast solicitations. + */ + static const uint8_t MAX_UNICAST_SOLICIT; - /** - * \brief Neighbor Discovery node constants : max anycast delay. - */ - static const uint8_t MAX_ANYCAST_DELAY_TIME; + /** + * \brief Neighbor Discovery node constants : max anycast delay. + */ + static const uint8_t MAX_ANYCAST_DELAY_TIME; - /** - * \brief Neighbor Discovery node constants : max NA transmission. - */ - static const uint8_t MAX_NEIGHBOR_ADVERTISEMENT; + /** + * \brief Neighbor Discovery node constants : max NA transmission. + */ + static const uint8_t MAX_NEIGHBOR_ADVERTISEMENT; - /** - * \brief Neighbor Discovery node constants : reachable time. - */ - static const uint32_t REACHABLE_TIME; + /** + * \brief Neighbor Discovery node constants : reachable time. + */ + static const uint32_t REACHABLE_TIME; - /** - * \brief Neighbor Discovery node constants : retransmission timer. - */ - static const uint32_t RETRANS_TIMER; + /** + * \brief Neighbor Discovery node constants : retransmission timer. + */ + static const uint32_t RETRANS_TIMER; - /** - * \brief Neighbor Discovery node constants : delay for the first probe. - */ - static const uint8_t DELAY_FIRST_PROBE_TIME; + /** + * \brief Neighbor Discovery node constants : delay for the first probe. + */ + static const uint8_t DELAY_FIRST_PROBE_TIME; - /** - * \brief Neighbor Discovery node constants : min random factor. - */ - static const double MIN_RANDOM_FACTOR; + /** + * \brief Neighbor Discovery node constants : min random factor. + */ + static const double MIN_RANDOM_FACTOR; - /** - * \brief Neighbor Discovery node constants : max random factor. - */ - static const double MAX_RANDOM_FACTOR; + /** + * \brief Neighbor Discovery node constants : max random factor. + */ + static const double MAX_RANDOM_FACTOR; - /** - * \brief Get ICMPv6 protocol number. - * \return protocol number - */ - static uint16_t GetStaticProtocolNumber (); + /** + * \brief Get ICMPv6 protocol number. + * \return protocol number + */ + static uint16_t GetStaticProtocolNumber (); - /** - * \brief Constructor. - */ - Icmpv6L4Protocol (); + /** + * \brief Constructor. + */ + Icmpv6L4Protocol (); - /** - * \brief Destructor. - */ - virtual ~Icmpv6L4Protocol (); + /** + * \brief Destructor. + */ + virtual ~Icmpv6L4Protocol (); - /** - * \brief Set the node. - * \param node the node to set - */ - void SetNode (Ptr node); + /** + * \brief Set the node. + * \param node the node to set + */ + void SetNode (Ptr node); - /** - * \brief This method is called by AddAgregate and completes the aggregation - * by setting the node in the ICMPv6 stack and adding ICMPv6 factory to - * IPv6 stack connected to the node. - */ - void NotifyNewAggregate (); + /** + * \brief This method is called by AddAgregate and completes the aggregation + * by setting the node in the ICMPv6 stack and adding ICMPv6 factory to + * IPv6 stack connected to the node. + */ + void NotifyNewAggregate (); - /** - * \brief Get the protocol number. - * \return protocol number - */ - virtual int GetProtocolNumber () const; + /** + * \brief Get the protocol number. + * \return protocol number + */ + virtual int GetProtocolNumber () const; - /** - * \brief Get the version of the protocol. - * \return version - */ - virtual int GetVersion () const; + /** + * \brief Get the version of the protocol. + * \return version + */ + virtual int GetVersion () const; - /** - * \brief Send a packet via ICMPv6, note that packet already contains ICMPv6 header. - * \param packet the packet to send which contains ICMPv6 header - * \param src source address - * \param dst destination address - * \param ttl next hop limit - */ - void SendMessage (Ptr packet, Ipv6Address src, Ipv6Address dst, uint8_t ttl); + /** + * \brief Send a packet via ICMPv6, note that packet already contains ICMPv6 header. + * \param packet the packet to send which contains ICMPv6 header + * \param src source address + * \param dst destination address + * \param ttl next hop limit + */ + void SendMessage (Ptr packet, Ipv6Address src, Ipv6Address dst, uint8_t ttl); - /** - * \brief Send a packet via ICMPv6. - * \param packet the packet to send - * \param dst destination address - * \param icmpv6Hdr ICMPv6 header (needed to calculate checksum - * after source address is determined by routing stuff - * \param ttl next hop limit - */ - void SendMessage (Ptr packet, Ipv6Address dst, Icmpv6Header& icmpv6Hdr, uint8_t ttl); - - /** - * \brief Do the Duplication Address Detection (DAD). - * \param target target address - * \param interface interface - */ - void DoDAD (Ipv6Address target, Ptr interface); + /** + * \brief Send a packet via ICMPv6. + * \param packet the packet to send + * \param dst destination address + * \param icmpv6Hdr ICMPv6 header (needed to calculate checksum + * after source address is determined by routing stuff + * \param ttl next hop limit + */ + void SendMessage (Ptr packet, Ipv6Address dst, Icmpv6Header& icmpv6Hdr, uint8_t ttl); - /** - * \brief Send a Neighbor Adverstisement. - * \param src source IPv6 address - * \param dst destination IPv6 address - * \param hardwareAddress our MAC address - * \param flags to set (4 = flag R, 2 = flag S, 3 = flag O) - */ - void SendNA (Ipv6Address src, Ipv6Address dst, Address* hardwareAddress, uint8_t flags); + /** + * \brief Do the Duplication Address Detection (DAD). + * \param target target address + * \param interface interface + */ + void DoDAD (Ipv6Address target, Ptr interface); - /** - * \brief Send a Echo Reply. - * \param src source IPv6 address - * \param dst destination IPv6 address - * \param id id of the packet - * \param seq sequence number - * \param data auxiliary data - */ - void SendEchoReply (Ipv6Address src, Ipv6Address dst, uint16_t id, uint16_t seq, Ptr data); + /** + * \brief Send a Neighbor Adverstisement. + * \param src source IPv6 address + * \param dst destination IPv6 address + * \param hardwareAddress our MAC address + * \param flags to set (4 = flag R, 2 = flag S, 3 = flag O) + */ + void SendNA (Ipv6Address src, Ipv6Address dst, Address* hardwareAddress, uint8_t flags); - /** - * \brief Send a Neighbor Solicitation. - * \param src source IPv6 address - * \param dst destination IPv6 addresss - * \param target target IPv6 address - * \param hardwareAddress our mac address - */ - void SendNS (Ipv6Address src, Ipv6Address dst, Ipv6Address target, Address hardwareAddress); + /** + * \brief Send a Echo Reply. + * \param src source IPv6 address + * \param dst destination IPv6 address + * \param id id of the packet + * \param seq sequence number + * \param data auxiliary data + */ + void SendEchoReply (Ipv6Address src, Ipv6Address dst, uint16_t id, uint16_t seq, Ptr data); - /** - * \brief Send an error Destination Unreachable. - * \param malformedPacket the malformed packet - * \param dst destination IPv6 address - * \param code code of the error - */ - void SendErrorDestinationUnreachable (Ptr malformedPacket, Ipv6Address dst, uint8_t code); + /** + * \brief Send a Neighbor Solicitation. + * \param src source IPv6 address + * \param dst destination IPv6 addresss + * \param target target IPv6 address + * \param hardwareAddress our mac address + */ + void SendNS (Ipv6Address src, Ipv6Address dst, Ipv6Address target, Address hardwareAddress); - /** - * \brief Send an error Too Big. - * \param malformedPacket the malformed packet - * \param dst destination IPv6 address - * \param mtu the mtu - */ - void SendErrorTooBig (Ptr malformedPacket, Ipv6Address dst, uint32_t mtu); + /** + * \brief Send an error Destination Unreachable. + * \param malformedPacket the malformed packet + * \param dst destination IPv6 address + * \param code code of the error + */ + void SendErrorDestinationUnreachable (Ptr malformedPacket, Ipv6Address dst, uint8_t code); - /** - * \brief Send an error Time Exceeded. - * \param malformedPacket the malformed packet - * \param dst destination IPv6 address - * \param code code of the error - */ - void SendErrorTimeExceeded (Ptr malformedPacket, Ipv6Address dst, uint8_t code); + /** + * \brief Send an error Too Big. + * \param malformedPacket the malformed packet + * \param dst destination IPv6 address + * \param mtu the mtu + */ + void SendErrorTooBig (Ptr malformedPacket, Ipv6Address dst, uint32_t mtu); - /** - * \brief Send an error Parameter Error. - * \param malformedPacket the malformed packet - * \param dst destination IPv6 address - * \param code code of the error - * \param ptr byte of p where the error is located - */ - void SendErrorParameterError (Ptr malformedPacket, Ipv6Address dst, uint8_t code, uint32_t ptr); + /** + * \brief Send an error Time Exceeded. + * \param malformedPacket the malformed packet + * \param dst destination IPv6 address + * \param code code of the error + */ + void SendErrorTimeExceeded (Ptr malformedPacket, Ipv6Address dst, uint8_t code); - /** - * \brief Send an ICMPv6 Redirection. - * \param redirectedPacket the redirected packet - * \param dst destination IPv6 address - * \param redirTarget IPv6 target address for Icmpv6Redirection - * \param redirDestination IPv6 destination address for Icmpv6Redirection - * \param redirHardwareTarget L2 target address for Icmpv6OptionRdirected - */ - void SendRedirection (Ptr redirectedPacket, Ipv6Address dst, Ipv6Address redirTarget, Ipv6Address redirDestination, Address redirHardwareTarget); + /** + * \brief Send an error Parameter Error. + * \param malformedPacket the malformed packet + * \param dst destination IPv6 address + * \param code code of the error + * \param ptr byte of p where the error is located + */ + void SendErrorParameterError (Ptr malformedPacket, Ipv6Address dst, uint8_t code, uint32_t ptr); - /** - * \brief Forge a Neighbor Solicitation. - * \param src source IPv6 address - * \param dst destination IPv6 addresss - * \param target target IPv6 address - * \param hardwareAddress our mac address - * \return NS packet (with IPv6 header) - */ - Ptr ForgeNS (Ipv6Address src, Ipv6Address dst, Ipv6Address target, Address hardwareAddress); + /** + * \brief Send an ICMPv6 Redirection. + * \param redirectedPacket the redirected packet + * \param dst destination IPv6 address + * \param redirTarget IPv6 target address for Icmpv6Redirection + * \param redirDestination IPv6 destination address for Icmpv6Redirection + * \param redirHardwareTarget L2 target address for Icmpv6OptionRdirected + */ + void SendRedirection (Ptr redirectedPacket, Ipv6Address dst, Ipv6Address redirTarget, Ipv6Address redirDestination, Address redirHardwareTarget); - /** - * \brief Forge a Neighbor Advertisement. - * \param src source IPv6 address - * \param dst destination IPv6 addresss - * \param hardwareAddress our mac address - * \param flags flags (bitfield => R (4), S (2), O (1)) - * \return NA packet (with IPv6 header) - */ - Ptr ForgeNA (Ipv6Address src, Ipv6Address dst, Address* hardwareAddress, uint8_t flags); + /** + * \brief Forge a Neighbor Solicitation. + * \param src source IPv6 address + * \param dst destination IPv6 addresss + * \param target target IPv6 address + * \param hardwareAddress our mac address + * \return NS packet (with IPv6 header) + */ + Ptr ForgeNS (Ipv6Address src, Ipv6Address dst, Ipv6Address target, Address hardwareAddress); - /** - * \brief Forge a Router Solicitation. - * \param src source IPv6 address - * \param dst destination IPv6 addresss - * \param hardwareAddress our mac address - * \return RS packet (with IPv6 header) - */ - Ptr ForgeRS (Ipv6Address src, Ipv6Address dst, Address hardwareAddress); + /** + * \brief Forge a Neighbor Advertisement. + * \param src source IPv6 address + * \param dst destination IPv6 addresss + * \param hardwareAddress our mac address + * \param flags flags (bitfield => R (4), S (2), O (1)) + * \return NA packet (with IPv6 header) + */ + Ptr ForgeNA (Ipv6Address src, Ipv6Address dst, Address* hardwareAddress, uint8_t flags); - /** - * \brief Forge an Echo Request. - * \param src source address - * \param dst destination address - * \param id ID of the packet - * \param seq sequence number - * \param data the data - * \return Echo Request packet (without IPv6 header) - */ - Ptr ForgeEchoRequest (Ipv6Address src, Ipv6Address dst, uint16_t id, uint16_t seq, Ptr data); + /** + * \brief Forge a Router Solicitation. + * \param src source IPv6 address + * \param dst destination IPv6 addresss + * \param hardwareAddress our mac address + * \return RS packet (with IPv6 header) + */ + Ptr ForgeRS (Ipv6Address src, Ipv6Address dst, Address hardwareAddress); - /** - * \brief Receive method. - * \param p the packet - * \param src source address - * \param dst destination address - * \param interface the interface from which the packet is coming - */ - virtual enum Ipv6L4Protocol::RxStatus_e Receive (Ptr p, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface); + /** + * \brief Forge an Echo Request. + * \param src source address + * \param dst destination address + * \param id ID of the packet + * \param seq sequence number + * \param data the data + * \return Echo Request packet (without IPv6 header) + */ + Ptr ForgeEchoRequest (Ipv6Address src, Ipv6Address dst, uint16_t id, uint16_t seq, Ptr data); - /** - * \brief Do the Duplication Address Detection. - * It consists in sending a NS with our IPv6 as target. If - * we received a NA with matched target address, we could not use the address, - * else the address pass from TENTATIVE to PERMANENT. - * \param addr IPv6 address to test - * \param interface interface - */ - void DoDad (Ipv6Address addr, Ptr interface); + /** + * \brief Receive method. + * \param p the packet + * \param src source address + * \param dst destination address + * \param interface the interface from which the packet is coming + */ + virtual enum Ipv6L4Protocol::RxStatus_e Receive (Ptr p, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface); - /** - * \brief Function called when DAD timeout. - * \param icmpv6 Icmpv6L4Protocol instance - * \param interface the interface - * \param addr the IPv6 address - */ - static void FunctionDadTimeout (Ptr icmpv6, Ipv6Interface* interface, Ipv6Address addr); + /** + * \brief Do the Duplication Address Detection. + * It consists in sending a NS with our IPv6 as target. If + * we received a NA with matched target address, we could not use the address, + * else the address pass from TENTATIVE to PERMANENT. + * \param addr IPv6 address to test + * \param interface interface + */ + void DoDad (Ipv6Address addr, Ptr interface); - /** - * \brief Lookup in the ND cache for the IPv6 address - * \param dst destination address - * \param device device - * \param cache the neighbor cache - * \param hardwareDestination hardware address - * \note Unlike other Lookup method, it does not send NS request! - */ - bool Lookup (Ipv6Address dst, Ptr device, Ptr cache, Address* hardwareDestination); + /** + * \brief Function called when DAD timeout. + * \param icmpv6 Icmpv6L4Protocol instance + * \param interface the interface + * \param addr the IPv6 address + */ + static void FunctionDadTimeout (Ptr icmpv6, Ipv6Interface* interface, Ipv6Address addr); - /** - * \brief Lookup in the ND cache for the IPv6 address (similar as ARP protocol). - * - * It also send NS request to target and store the waiting packet. - * \param p the packet - * \param dst destination address - * \param device device - * \param cache the neighbor cache - * \param hardwareDestination hardware address - * \return true if the address is in the ND cache, the hardwareDestination is updated. - */ - bool Lookup (Ptr p, Ipv6Address dst, Ptr device, Ptr cache, Address* hardwareDestination); + /** + * \brief Lookup in the ND cache for the IPv6 address + * \param dst destination address + * \param device device + * \param cache the neighbor cache + * \param hardwareDestination hardware address + * \note Unlike other Lookup method, it does not send NS request! + */ + bool Lookup (Ipv6Address dst, Ptr device, Ptr cache, Address* hardwareDestination); - /** - * \brief Send a Router Solicitation. - * \param src link-local source address - * \param dst destination address (usealy ff02::2 i.e all-routers) - * \param hardwareAddress link-layer address (SHOULD be included if src is not :: - */ - void SendRS (Ipv6Address src, Ipv6Address dst, Address hardwareAddress); + /** + * \brief Lookup in the ND cache for the IPv6 address (similar as ARP protocol). + * + * It also send NS request to target and store the waiting packet. + * \param p the packet + * \param dst destination address + * \param device device + * \param cache the neighbor cache + * \param hardwareDestination hardware address + * \return true if the address is in the ND cache, the hardwareDestination is updated. + */ + bool Lookup (Ptr p, Ipv6Address dst, Ptr device, Ptr cache, Address* hardwareDestination); - /** - * \brief Create a neighbor cache. - * \param device thet NetDevice - * \param interface the IPv6 interface - * \return a smart pointer of NdCache or 0 if problem - */ - Ptr CreateCache (Ptr device, Ptr interface); + /** + * \brief Send a Router Solicitation. + * \param src link-local source address + * \param dst destination address (usealy ff02::2 i.e all-routers) + * \param hardwareAddress link-layer address (SHOULD be included if src is not :: + */ + void SendRS (Ipv6Address src, Ipv6Address dst, Address hardwareAddress); - /** - * \brief Is the node must do DAD. - * \return true if node has to do DAD. - */ - bool IsAlwaysDad () const; + /** + * \brief Create a neighbor cache. + * \param device thet NetDevice + * \param interface the IPv6 interface + * \return a smart pointer of NdCache or 0 if problem + */ + Ptr CreateCache (Ptr device, Ptr interface); - protected: - /** - * \brief Dispose this object. - */ - virtual void DoDispose (); + /** + * \brief Is the node must do DAD. + * \return true if node has to do DAD. + */ + bool IsAlwaysDad () const; - private: +protected: + /** + * \brief Dispose this object. + */ + virtual void DoDispose (); - typedef std::list > CacheList; +private: - /** - * \brief The node. - */ - Ptr m_node; + typedef std::list > CacheList; - /** - * \brief A list of cache by device. - */ - CacheList m_cacheList; + /** + * \brief The node. + */ + Ptr m_node; - /** - * \brief Always do DAD ? - */ - bool m_alwaysDad; + /** + * \brief A list of cache by device. + */ + CacheList m_cacheList; - /** - * \brief Receive Neighbor Solicitation method. - * \param p the packet - * \param src source address - * \param dst destination address - * \param interface the interface from which the packet is coming - */ - void HandleNS (Ptr p, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface); + /** + * \brief Always do DAD ? + */ + bool m_alwaysDad; - /** - * \brief Receive Router Solicitation method. - * \param p the packet - * \param src source address - * \param dst destination address - * \param interface the interface from which the packet is coming - */ - void HandleRS (Ptr p, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface); + /** + * \brief Receive Neighbor Solicitation method. + * \param p the packet + * \param src source address + * \param dst destination address + * \param interface the interface from which the packet is coming + */ + void HandleNS (Ptr p, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface); - /** - * \brief Receive Router Advertisement method. - * \param p the packet - * \param src source address - * \param dst destination address - * \param interface the interface from which the packet is coming - */ - void HandleRA (Ptr p, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface); + /** + * \brief Receive Router Solicitation method. + * \param p the packet + * \param src source address + * \param dst destination address + * \param interface the interface from which the packet is coming + */ + void HandleRS (Ptr p, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface); - /** - * \brief Receive Echo Request method. - * \param p the packet - * \param src source address - * \param dst destination address - * \param interface the interface from which the packet is coming - */ - void HandleEchoRequest (Ptr p, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface); + /** + * \brief Receive Router Advertisement method. + * \param p the packet + * \param src source address + * \param dst destination address + * \param interface the interface from which the packet is coming + */ + void HandleRA (Ptr p, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface); - /** - * \brief Receive Neighbor Advertisement method. - * \param p the packet - * \param src source address - * \param dst destination address - * \param interface the interface from which the packet is coming - */ - void HandleNA (Ptr p, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface); + /** + * \brief Receive Echo Request method. + * \param p the packet + * \param src source address + * \param dst destination address + * \param interface the interface from which the packet is coming + */ + void HandleEchoRequest (Ptr p, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface); - /** - * \brief Receive Redirection method. - * \param p the packet - * \param src source address - * \param dst destination address - * \param interface the interface from which the packet is coming - */ - void HandleRedirection (Ptr p, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface); + /** + * \brief Receive Neighbor Advertisement method. + * \param p the packet + * \param src source address + * \param dst destination address + * \param interface the interface from which the packet is coming + */ + void HandleNA (Ptr p, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface); - /** - * \brief Link layer address option processing. - * \param lla LLA option - * \param src source address - * \param dst destination address - * \param interface the interface from which the packet is coming - */ - void ReceiveLLA (Icmpv6OptionLinkLayerAddress lla, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface); + /** + * \brief Receive Redirection method. + * \param p the packet + * \param src source address + * \param dst destination address + * \param interface the interface from which the packet is coming + */ + void HandleRedirection (Ptr p, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface); - /** - * \brief Get the cache corresponding to the device. - * \param device the device - */ - Ptr FindCache (Ptr device); + /** + * \brief Link layer address option processing. + * \param lla LLA option + * \param src source address + * \param dst destination address + * \param interface the interface from which the packet is coming + */ + void ReceiveLLA (Icmpv6OptionLinkLayerAddress lla, Ipv6Address const &src, Ipv6Address const &dst, Ptr interface); + + /** + * \brief Get the cache corresponding to the device. + * \param device the device + */ + Ptr FindCache (Ptr device); }; } /* namespace ns3 */ diff --git a/src/internet-stack/ipv6-autoconfigured-prefix.cc b/src/internet-stack/ipv6-autoconfigured-prefix.cc index 7bbe16405..fa2e389ff 100644 --- a/src/internet-stack/ipv6-autoconfigured-prefix.cc +++ b/src/internet-stack/ipv6-autoconfigured-prefix.cc @@ -28,173 +28,174 @@ NS_LOG_COMPONENT_DEFINE ("Ipv6AutoconfiguredPrefix"); namespace ns3 { - uint32_t Ipv6AutoconfiguredPrefix::m_prefixId = 0; - Ipv6AutoconfiguredPrefix::Ipv6AutoconfiguredPrefix (Ptr node, uint32_t interface, Ipv6Address prefix, Ipv6Prefix mask, uint32_t preferredLifeTime, uint32_t validLifeTime, Ipv6Address router) - { - m_node = node; - m_interface = interface; - m_validLifeTime = validLifeTime; - m_preferredLifeTime = preferredLifeTime; - m_id = m_prefixId; - m_prefixId ++; - m_preferred = false; - m_valid = false; - m_prefix = prefix; - m_mask = mask; - m_defaultGatewayRouter = router; - } +uint32_t Ipv6AutoconfiguredPrefix::m_prefixId = 0; - Ipv6AutoconfiguredPrefix::~Ipv6AutoconfiguredPrefix () - { - } +Ipv6AutoconfiguredPrefix::Ipv6AutoconfiguredPrefix (Ptr node, uint32_t interface, Ipv6Address prefix, Ipv6Prefix mask, uint32_t preferredLifeTime, uint32_t validLifeTime, Ipv6Address router) +{ + m_node = node; + m_interface = interface; + m_validLifeTime = validLifeTime; + m_preferredLifeTime = preferredLifeTime; + m_id = m_prefixId; + m_prefixId ++; + m_preferred = false; + m_valid = false; + m_prefix = prefix; + m_mask = mask; + m_defaultGatewayRouter = router; +} - void Ipv6AutoconfiguredPrefix::SetDefaultGatewayRouter (Ipv6Address router) - { - m_defaultGatewayRouter = router; - } +Ipv6AutoconfiguredPrefix::~Ipv6AutoconfiguredPrefix () +{ +} - Ipv6Address Ipv6AutoconfiguredPrefix::GetDefaultGatewayRouter () const - { - return m_defaultGatewayRouter; - } +void Ipv6AutoconfiguredPrefix::SetDefaultGatewayRouter (Ipv6Address router) +{ + m_defaultGatewayRouter = router; +} - void Ipv6AutoconfiguredPrefix::SetInterface (uint32_t interface) - { - m_interface = interface; - } +Ipv6Address Ipv6AutoconfiguredPrefix::GetDefaultGatewayRouter () const +{ + return m_defaultGatewayRouter; +} - uint32_t Ipv6AutoconfiguredPrefix::GetInterface () const - { - return m_interface; - } +void Ipv6AutoconfiguredPrefix::SetInterface (uint32_t interface) +{ + m_interface = interface; +} - void Ipv6AutoconfiguredPrefix::SetPreferredLifeTime (uint32_t t) - { - m_preferredLifeTime = t; - } +uint32_t Ipv6AutoconfiguredPrefix::GetInterface () const +{ + return m_interface; +} - uint32_t Ipv6AutoconfiguredPrefix::GetPreferredLifeTime () const - { - return m_preferredLifeTime; - } +void Ipv6AutoconfiguredPrefix::SetPreferredLifeTime (uint32_t t) +{ + m_preferredLifeTime = t; +} - void Ipv6AutoconfiguredPrefix::SetValidLifeTime (uint32_t t) - { - m_validLifeTime = t; - } +uint32_t Ipv6AutoconfiguredPrefix::GetPreferredLifeTime () const +{ + return m_preferredLifeTime; +} - uint32_t Ipv6AutoconfiguredPrefix::GetValidLifeTime () const - { - return m_validLifeTime; - } +void Ipv6AutoconfiguredPrefix::SetValidLifeTime (uint32_t t) +{ + m_validLifeTime = t; +} - void Ipv6AutoconfiguredPrefix::MarkPreferredTime () - { - m_preferred = true; - } +uint32_t Ipv6AutoconfiguredPrefix::GetValidLifeTime () const +{ + return m_validLifeTime; +} - void Ipv6AutoconfiguredPrefix::MarkValidTime () - { - m_preferred = false; - m_valid = true; - } +void Ipv6AutoconfiguredPrefix::MarkPreferredTime () +{ + m_preferred = true; +} - void Ipv6AutoconfiguredPrefix::FunctionPreferredTimeout () - { - NS_LOG_INFO ("Preferred Time expired for " << m_prefix); - m_preferred = false; - MarkValidTime (); - StartValidTimer (); - } +void Ipv6AutoconfiguredPrefix::MarkValidTime () +{ + m_preferred = false; + m_valid = true; +} - void Ipv6AutoconfiguredPrefix::FunctionValidTimeout () - { - NS_LOG_INFO ("Valid Time expired for " << m_prefix); - m_valid = false; - RemoveMe (); - } +void Ipv6AutoconfiguredPrefix::FunctionPreferredTimeout () +{ + NS_LOG_INFO ("Preferred Time expired for " << m_prefix); + m_preferred = false; + MarkValidTime (); + StartValidTimer (); +} - void Ipv6AutoconfiguredPrefix::StartPreferredTimer () - { - NS_LOG_INFO ("Start PreferredTimer for " << m_prefix); - m_preferredTimer.SetFunction (&Ipv6AutoconfiguredPrefix::FunctionPreferredTimeout, this); - m_preferredTimer.SetDelay (Seconds (m_preferredLifeTime)); - m_preferredTimer.Schedule (); - } +void Ipv6AutoconfiguredPrefix::FunctionValidTimeout () +{ + NS_LOG_INFO ("Valid Time expired for " << m_prefix); + m_valid = false; + RemoveMe (); +} - void Ipv6AutoconfiguredPrefix::StartValidTimer () - { - NS_LOG_INFO ("Start ValidTimer for " << m_prefix); - m_validTimer.SetFunction (&Ipv6AutoconfiguredPrefix::FunctionValidTimeout, this); - m_validTimer.SetDelay (Seconds (m_validLifeTime - m_preferredLifeTime)); - m_validTimer.Schedule (); - } +void Ipv6AutoconfiguredPrefix::StartPreferredTimer () +{ + NS_LOG_INFO ("Start PreferredTimer for " << m_prefix); + m_preferredTimer.SetFunction (&Ipv6AutoconfiguredPrefix::FunctionPreferredTimeout, this); + m_preferredTimer.SetDelay (Seconds (m_preferredLifeTime)); + m_preferredTimer.Schedule (); +} - void Ipv6AutoconfiguredPrefix::StopPreferredTimer () - { - NS_LOG_INFO ("Stop PreferredTimer for " << m_prefix); - m_preferredTimer.Cancel (); - } +void Ipv6AutoconfiguredPrefix::StartValidTimer () +{ + NS_LOG_INFO ("Start ValidTimer for " << m_prefix); + m_validTimer.SetFunction (&Ipv6AutoconfiguredPrefix::FunctionValidTimeout, this); + m_validTimer.SetDelay (Seconds (m_validLifeTime - m_preferredLifeTime)); + m_validTimer.Schedule (); +} - void Ipv6AutoconfiguredPrefix::StopValidTimer () - { - NS_LOG_INFO ("Stop ValidTimer for " << m_prefix); - m_validTimer.Cancel (); - } +void Ipv6AutoconfiguredPrefix::StopPreferredTimer () +{ + NS_LOG_INFO ("Stop PreferredTimer for " << m_prefix); + m_preferredTimer.Cancel (); +} - void Ipv6AutoconfiguredPrefix::RemoveMe () - { - NS_LOG_INFO ("The prefix " << m_prefix << " will be removed on interface " << m_interface); - Ptr ipv6 = m_node->GetObject (); - ipv6->RemoveAutoconfiguredAddress (m_interface, m_prefix, m_mask, m_defaultGatewayRouter); - } +void Ipv6AutoconfiguredPrefix::StopValidTimer () +{ + NS_LOG_INFO ("Stop ValidTimer for " << m_prefix); + m_validTimer.Cancel (); +} - void Ipv6AutoconfiguredPrefix::SetPreferred () - { - m_preferred = true; - } +void Ipv6AutoconfiguredPrefix::RemoveMe () +{ + NS_LOG_INFO ("The prefix " << m_prefix << " will be removed on interface " << m_interface); + Ptr ipv6 = m_node->GetObject (); + ipv6->RemoveAutoconfiguredAddress (m_interface, m_prefix, m_mask, m_defaultGatewayRouter); +} - void Ipv6AutoconfiguredPrefix::SetValid () - { - m_preferred = false; - m_valid = true; - } +void Ipv6AutoconfiguredPrefix::SetPreferred () +{ + m_preferred = true; +} - uint32_t Ipv6AutoconfiguredPrefix::GetId () const - { - return m_id; - } +void Ipv6AutoconfiguredPrefix::SetValid () +{ + m_preferred = false; + m_valid = true; +} - bool Ipv6AutoconfiguredPrefix::IsPreferred () const - { - return m_preferred; - } +uint32_t Ipv6AutoconfiguredPrefix::GetId () const +{ + return m_id; +} - bool Ipv6AutoconfiguredPrefix::IsValid () const - { - return m_valid; - } +bool Ipv6AutoconfiguredPrefix::IsPreferred () const +{ + return m_preferred; +} - Ipv6Address Ipv6AutoconfiguredPrefix::GetPrefix () const - { - return m_prefix; - } +bool Ipv6AutoconfiguredPrefix::IsValid () const +{ + return m_valid; +} - void Ipv6AutoconfiguredPrefix::SetPrefix (Ipv6Address prefix) - { - m_prefix = prefix; - } +Ipv6Address Ipv6AutoconfiguredPrefix::GetPrefix () const +{ + return m_prefix; +} - Ipv6Prefix Ipv6AutoconfiguredPrefix::GetMask () const - { - return m_mask; - } +void Ipv6AutoconfiguredPrefix::SetPrefix (Ipv6Address prefix) +{ + m_prefix = prefix; +} - void Ipv6AutoconfiguredPrefix::SetMask (Ipv6Prefix mask) - { - m_mask = mask; - } +Ipv6Prefix Ipv6AutoconfiguredPrefix::GetMask () const +{ + return m_mask; +} + +void Ipv6AutoconfiguredPrefix::SetMask (Ipv6Prefix mask) +{ + m_mask = mask; +} } /* namespace ns3 */ diff --git a/src/internet-stack/ipv6-autoconfigured-prefix.h b/src/internet-stack/ipv6-autoconfigured-prefix.h index 85d81e57e..f69a10ca6 100644 --- a/src/internet-stack/ipv6-autoconfigured-prefix.h +++ b/src/internet-stack/ipv6-autoconfigured-prefix.h @@ -39,239 +39,239 @@ namespace ns3 */ class Ipv6AutoconfiguredPrefix : public Object { - public: - /** - * \brief Constructor. - * \param node node - * \param interface interface index - * \param prefix IPv6 address - * \param mask bitmask prefix - * \param preferredLifeTime the preferred life time - * \param validLifeTime the valid life time - * \param router if it the prefix that configure the default gateway - */ - Ipv6AutoconfiguredPrefix (Ptr node, uint32_t interface, Ipv6Address prefix, Ipv6Prefix mask, uint32_t preferredLifeTime, uint32_t validLifeTime, Ipv6Address router = Ipv6Address ("::")); +public: + /** + * \brief Constructor. + * \param node node + * \param interface interface index + * \param prefix IPv6 address + * \param mask bitmask prefix + * \param preferredLifeTime the preferred life time + * \param validLifeTime the valid life time + * \param router if it the prefix that configure the default gateway + */ + Ipv6AutoconfiguredPrefix (Ptr node, uint32_t interface, Ipv6Address prefix, Ipv6Prefix mask, uint32_t preferredLifeTime, uint32_t validLifeTime, Ipv6Address router = Ipv6Address ("::")); - /** - * \brief Destructor. - */ - ~Ipv6AutoconfiguredPrefix (); + /** + * \brief Destructor. + */ + ~Ipv6AutoconfiguredPrefix (); - /** - * \brief Set the default gateway router. - * \param router IPv6 link-local address of the default router - */ - void SetDefaultGatewayRouter (Ipv6Address router); + /** + * \brief Set the default gateway router. + * \param router IPv6 link-local address of the default router + */ + void SetDefaultGatewayRouter (Ipv6Address router); - /** - * \brief Get the default gateway address. - * \return IPv6 link-local address of the default router - */ - Ipv6Address GetDefaultGatewayRouter () const; + /** + * \brief Get the default gateway address. + * \return IPv6 link-local address of the default router + */ + Ipv6Address GetDefaultGatewayRouter () const; - /** - * \brief Get the interface index. - * \return interface index - */ - uint32_t GetInterface () const; + /** + * \brief Get the interface index. + * \return interface index + */ + uint32_t GetInterface () const; - /** - * \brief Set the interface. - * \param interface interface index to set - */ - void SetInterface (uint32_t interface); + /** + * \brief Set the interface. + * \param interface interface index to set + */ + void SetInterface (uint32_t interface); - /** - * \brief Get the prefix preferred life time. - * \return preferred life time - */ - uint32_t GetPreferredLifeTime () const; + /** + * \brief Get the prefix preferred life time. + * \return preferred life time + */ + uint32_t GetPreferredLifeTime () const; - /** - * \brief Set the prefix preferred life time. - * \param p the prefix preferred life time - */ - void SetPreferredLifeTime (uint32_t p); + /** + * \brief Set the prefix preferred life time. + * \param p the prefix preferred life time + */ + void SetPreferredLifeTime (uint32_t p); - /** - * \brief Get the prefix valid life time. - * \return valid life time - */ - uint32_t GetValidLifeTime (void) const; + /** + * \brief Get the prefix valid life time. + * \return valid life time + */ + uint32_t GetValidLifeTime (void) const; - /** - * \brief Set the prefix valid life time. - * \param v the prefix valid life time - */ - void SetValidLifeTime (uint32_t v); + /** + * \brief Set the prefix valid life time. + * \param v the prefix valid life time + */ + void SetValidLifeTime (uint32_t v); - /** - * \brief Test if the prefix is preferred. - * \return true if prefix is in preferred state, false otherwise - */ - bool IsPreferred () const; + /** + * \brief Test if the prefix is preferred. + * \return true if prefix is in preferred state, false otherwise + */ + bool IsPreferred () const; - /** - * \brief Test if the prefix is valid. - * \return true if prefix is in valid state, false otherwise - */ - bool IsValid () const; + /** + * \brief Test if the prefix is valid. + * \return true if prefix is in valid state, false otherwise + */ + bool IsValid () const; - /** - * \brief Set the prefix as preferred. - */ - void SetPreferred (); + /** + * \brief Set the prefix as preferred. + */ + void SetPreferred (); - /** - * \brief Set the prefix as valid. - */ - void SetValid (); + /** + * \brief Set the prefix as valid. + */ + void SetValid (); - /** - * \brief Start the preferred timer. - */ - void StartPreferredTimer (); + /** + * \brief Start the preferred timer. + */ + void StartPreferredTimer (); - /** - * \brief Start the valid timer. - */ - void StartValidTimer (); + /** + * \brief Start the valid timer. + */ + void StartValidTimer (); - /** - * \brief Stop the preferred timer. - */ - void StopPreferredTimer (); + /** + * \brief Stop the preferred timer. + */ + void StopPreferredTimer (); - /** - * \brief Stop the valid timer. - */ - void StopValidTimer (); + /** + * \brief Stop the valid timer. + */ + void StopValidTimer (); - /** - * \brief Set the prefix as preferred. - */ - void MarkPreferredTime (); + /** + * \brief Set the prefix as preferred. + */ + void MarkPreferredTime (); - /** - * \brief Set the prefix as valid. - */ - void MarkValidTime (); + /** + * \brief Set the prefix as valid. + */ + void MarkValidTime (); - /** - * \brief Signal that the preferred time expired and start the valid timer. - */ - void FunctionPreferredTimeout (); + /** + * \brief Signal that the preferred time expired and start the valid timer. + */ + void FunctionPreferredTimeout (); - /** - * \brief Signal that the valid time expired. - */ - void FunctionValidTimeout (); + /** + * \brief Signal that the valid time expired. + */ + void FunctionValidTimeout (); - /** - * \brief Remove this prefix from the prefix list. - */ - void RemoveMe (); + /** + * \brief Remove this prefix from the prefix list. + */ + void RemoveMe (); - /** - * \brief Get the prefix identifier. - * \return id of the prefix. - */ - uint32_t GetId () const; + /** + * \brief Get the prefix identifier. + * \return id of the prefix. + */ + uint32_t GetId () const; - /** - * \brief Get the prefix address. - * \return prefix address - */ - Ipv6Address GetPrefix () const; + /** + * \brief Get the prefix address. + * \return prefix address + */ + Ipv6Address GetPrefix () const; - /** - * \brief Set the prefix address. - * \param prefix prefix address to set - */ - void SetPrefix (Ipv6Address prefix); + /** + * \brief Set the prefix address. + * \param prefix prefix address to set + */ + void SetPrefix (Ipv6Address prefix); - /** - * \brief Get the bitmask prefix. - * \return bitmask prefix - */ - Ipv6Prefix GetMask () const; + /** + * \brief Get the bitmask prefix. + * \return bitmask prefix + */ + Ipv6Prefix GetMask () const; - /** - * \brief Set the bitmask prefix. - * \param mask prefix - */ - void SetMask (Ipv6Prefix mask); + /** + * \brief Set the bitmask prefix. + * \param mask prefix + */ + void SetMask (Ipv6Prefix mask); - private: - /** - * \brief a static identifier. - */ - static uint32_t m_prefixId; +private: + /** + * \brief a static identifier. + */ + static uint32_t m_prefixId; - /** - * \brief the identifier of this prefix. - */ - uint32_t m_id; + /** + * \brief the identifier of this prefix. + */ + uint32_t m_id; - /** - * \brief The node. - */ - Ptr m_node; + /** + * \brief The node. + */ + Ptr m_node; - /** - * \brief The prefix IP6 address. - */ - Ipv6Address m_prefix; + /** + * \brief The prefix IP6 address. + */ + Ipv6Address m_prefix; - /** - * \brief The prefix bitmask (length). - */ - Ipv6Prefix m_mask; + /** + * \brief The prefix bitmask (length). + */ + Ipv6Prefix m_mask; - /** - * \brief Default gateway router. - * - * If the RA received also configured the default gateway, - * this variable has the link-local address. Otherwise this - * is "::" - */ - Ipv6Address m_defaultGatewayRouter; + /** + * \brief Default gateway router. + * + * If the RA received also configured the default gateway, + * this variable has the link-local address. Otherwise this + * is "::" + */ + Ipv6Address m_defaultGatewayRouter; - /** - * \brief The interface index (which is stored the address - * corresponding of the prefix). - */ - uint32_t m_interface; + /** + * \brief The interface index (which is stored the address + * corresponding of the prefix). + */ + uint32_t m_interface; - /** - * \brief the valid life time. - */ - uint32_t m_validLifeTime; + /** + * \brief the valid life time. + */ + uint32_t m_validLifeTime; - /** - * \brief the preferred life time. - */ - uint32_t m_preferredLifeTime; + /** + * \brief the preferred life time. + */ + uint32_t m_preferredLifeTime; - /** - * \brief true if the prefix is preferred. - */ - bool m_preferred; + /** + * \brief true if the prefix is preferred. + */ + bool m_preferred; - /** - * \brief true if the prefix is valid. - */ - bool m_valid; + /** + * \brief true if the prefix is valid. + */ + bool m_valid; - /** - * \brief the timer for preferred life time. - */ - Timer m_preferredTimer; + /** + * \brief the timer for preferred life time. + */ + Timer m_preferredTimer; - /** - * \brief the timer for valid life time. - */ - Timer m_validTimer; + /** + * \brief the timer for valid life time. + */ + Timer m_validTimer; }; } /* namespace ns3 */ diff --git a/src/internet-stack/ipv6-end-point-demux.cc b/src/internet-stack/ipv6-end-point-demux.cc index 4cdbe0a56..c579e48c0 100644 --- a/src/internet-stack/ipv6-end-point-demux.cc +++ b/src/internet-stack/ipv6-end-point-demux.cc @@ -37,10 +37,10 @@ Ipv6EndPointDemux::~Ipv6EndPointDemux () { NS_LOG_FUNCTION_NOARGS (); for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++) - { - Ipv6EndPoint *endPoint = *i; - delete endPoint; - } + { + Ipv6EndPoint *endPoint = *i; + delete endPoint; + } m_endPoints.clear (); } @@ -48,12 +48,12 @@ bool Ipv6EndPointDemux::LookupPortLocal (uint16_t port) { NS_LOG_FUNCTION (this << port); for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++) - { - if ((*i)->GetLocalPort () == port) { - return true; + if ((*i)->GetLocalPort () == port) + { + return true; + } } - } return false; } @@ -61,13 +61,13 @@ bool Ipv6EndPointDemux::LookupLocal (Ipv6Address addr, uint16_t port) { NS_LOG_FUNCTION (this << addr << port); for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++) - { - if ((*i)->GetLocalPort () == port && - (*i)->GetLocalAddress () == addr) { - return true; + if ((*i)->GetLocalPort () == port && + (*i)->GetLocalAddress () == addr) + { + return true; + } } - } return false; } @@ -76,10 +76,10 @@ Ipv6EndPoint* Ipv6EndPointDemux::Allocate () NS_LOG_FUNCTION_NOARGS (); uint16_t port = AllocateEphemeralPort (); if (port == 0) - { - NS_LOG_WARN ("Ephemeral port allocation failed."); - return 0; - } + { + NS_LOG_WARN ("Ephemeral port allocation failed."); + return 0; + } Ipv6EndPoint *endPoint = new Ipv6EndPoint (Ipv6Address::GetAny (), port); m_endPoints.push_back (endPoint); NS_LOG_DEBUG ("Now have >>" << m_endPoints.size () << "<< endpoints."); @@ -91,10 +91,10 @@ Ipv6EndPoint* Ipv6EndPointDemux::Allocate (Ipv6Address address) NS_LOG_FUNCTION (this << address); uint16_t port = AllocateEphemeralPort (); if (port == 0) - { - NS_LOG_WARN ("Ephemeral port allocation failed."); - return 0; - } + { + NS_LOG_WARN ("Ephemeral port allocation failed."); + return 0; + } Ipv6EndPoint *endPoint = new Ipv6EndPoint (address, port); m_endPoints.push_back (endPoint); NS_LOG_DEBUG ("Now have >>" << m_endPoints.size () << "<< endpoints."); @@ -112,10 +112,10 @@ Ipv6EndPoint* Ipv6EndPointDemux::Allocate (Ipv6Address address, uint16_t port) { NS_LOG_FUNCTION (this << address << port); if (LookupLocal (address, port)) - { - NS_LOG_WARN ("Duplicate address/port; failing."); - return 0; - } + { + NS_LOG_WARN ("Duplicate address/port; failing."); + return 0; + } Ipv6EndPoint *endPoint = new Ipv6EndPoint (address, port); m_endPoints.push_back (endPoint); NS_LOG_DEBUG ("Now have >>" << m_endPoints.size () << "<< endpoints."); @@ -123,21 +123,21 @@ Ipv6EndPoint* Ipv6EndPointDemux::Allocate (Ipv6Address address, uint16_t port) } Ipv6EndPoint* Ipv6EndPointDemux::Allocate (Ipv6Address localAddress, uint16_t localPort, - Ipv6Address peerAddress, uint16_t peerPort) + Ipv6Address peerAddress, uint16_t peerPort) { NS_LOG_FUNCTION (this << localAddress << localPort << peerAddress << peerPort); for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++) - { - if ((*i)->GetLocalPort () == localPort && - (*i)->GetLocalAddress () == localAddress && - (*i)->GetPeerPort () == peerPort && - (*i)->GetPeerAddress () == peerAddress) { - NS_LOG_WARN ("No way we can allocate this end-point."); - /* no way we can allocate this end-point. */ - return 0; + if ((*i)->GetLocalPort () == localPort && + (*i)->GetLocalAddress () == localAddress && + (*i)->GetPeerPort () == peerPort && + (*i)->GetPeerAddress () == peerAddress) + { + NS_LOG_WARN ("No way we can allocate this end-point."); + /* no way we can allocate this end-point. */ + return 0; + } } - } Ipv6EndPoint *endPoint = new Ipv6EndPoint (localAddress, localPort); endPoint->SetPeer (peerAddress, peerPort); m_endPoints.push_back (endPoint); @@ -151,14 +151,14 @@ void Ipv6EndPointDemux::DeAllocate (Ipv6EndPoint *endPoint) { NS_LOG_FUNCTION_NOARGS (); for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++) - { - if (*i == endPoint) { - delete endPoint; - m_endPoints.erase (i); - break; + if (*i == endPoint) + { + delete endPoint; + m_endPoints.erase (i); + break; + } } - } } /* @@ -179,69 +179,69 @@ Ipv6EndPointDemux::EndPoints Ipv6EndPointDemux::Lookup (Ipv6Address daddr, uint1 NS_LOG_DEBUG ("Looking up endpoint for destination address " << daddr); for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++) - { - Ipv6EndPoint* endP = *i; - NS_LOG_DEBUG ("Looking at endpoint dport=" << endP->GetLocalPort () - << " daddr=" << endP->GetLocalAddress () - << " sport=" << endP->GetPeerPort () - << " saddr=" << endP->GetPeerAddress ()); - if (endP->GetLocalPort () != dport) { - NS_LOG_LOGIC ("Skipping endpoint " << &endP - << " because endpoint dport " - << endP->GetLocalPort () - << " does not match packet dport " << dport); - continue; - } + Ipv6EndPoint* endP = *i; + NS_LOG_DEBUG ("Looking at endpoint dport=" << endP->GetLocalPort () + << " daddr=" << endP->GetLocalAddress () + << " sport=" << endP->GetPeerPort () + << " saddr=" << endP->GetPeerAddress ()); + if (endP->GetLocalPort () != dport) + { + NS_LOG_LOGIC ("Skipping endpoint " << &endP + << " because endpoint dport " + << endP->GetLocalPort () + << " does not match packet dport " << dport); + continue; + } -/* Ipv6Address incomingInterfaceAddr = incomingInterface->GetAddress (); */ - NS_LOG_DEBUG ("dest addr " << daddr); + /* Ipv6Address incomingInterfaceAddr = incomingInterface->GetAddress (); */ + NS_LOG_DEBUG ("dest addr " << daddr); - bool localAddressMatchesWildCard = endP->GetLocalAddress () == Ipv6Address::GetAny (); - bool localAddressMatchesExact = endP->GetLocalAddress () == daddr; - bool localAddressMatchesAllRouters = endP->GetLocalAddress () == Ipv6Address::GetAllRoutersMulticast (); + bool localAddressMatchesWildCard = endP->GetLocalAddress () == Ipv6Address::GetAny (); + bool localAddressMatchesExact = endP->GetLocalAddress () == daddr; + bool localAddressMatchesAllRouters = endP->GetLocalAddress () == Ipv6Address::GetAllRoutersMulticast (); - /* if no match here, keep looking */ - if (!(localAddressMatchesExact || localAddressMatchesWildCard)) - continue; - bool remotePeerMatchesExact = endP->GetPeerPort () == sport; - bool remotePeerMatchesWildCard = endP->GetPeerPort () == 0; - bool remoteAddressMatchesExact = endP->GetPeerAddress () == saddr; - bool remoteAddressMatchesWildCard = endP->GetPeerAddress () == Ipv6Address::GetAny (); + /* if no match here, keep looking */ + if (!(localAddressMatchesExact || localAddressMatchesWildCard)) + continue; + bool remotePeerMatchesExact = endP->GetPeerPort () == sport; + bool remotePeerMatchesWildCard = endP->GetPeerPort () == 0; + bool remoteAddressMatchesExact = endP->GetPeerAddress () == saddr; + bool remoteAddressMatchesWildCard = endP->GetPeerAddress () == Ipv6Address::GetAny (); - /* If remote does not match either with exact or wildcard,i - skip this one */ - if (!(remotePeerMatchesExact || remotePeerMatchesWildCard)) - continue; - if (!(remoteAddressMatchesExact || remoteAddressMatchesWildCard)) - continue; + /* If remote does not match either with exact or wildcard,i + skip this one */ + if (!(remotePeerMatchesExact || remotePeerMatchesWildCard)) + continue; + if (!(remoteAddressMatchesExact || remoteAddressMatchesWildCard)) + continue; - /* Now figure out which return list to add this one to */ - if (localAddressMatchesWildCard && - remotePeerMatchesWildCard && - remoteAddressMatchesWildCard) - { /* Only local port matches exactly */ - retval1.push_back (endP); + /* Now figure out which return list to add this one to */ + if (localAddressMatchesWildCard && + remotePeerMatchesWildCard && + remoteAddressMatchesWildCard) + { /* Only local port matches exactly */ + retval1.push_back (endP); + } + if ((localAddressMatchesExact || (localAddressMatchesAllRouters))&& + remotePeerMatchesWildCard && + remoteAddressMatchesWildCard) + { /* Only local port and local address matches exactly */ + retval2.push_back (endP); + } + if (localAddressMatchesWildCard && + remotePeerMatchesExact && + remoteAddressMatchesExact) + { /* All but local address */ + retval3.push_back (endP); + } + if (localAddressMatchesExact && + remotePeerMatchesExact && + remoteAddressMatchesExact) + { /* All 4 match */ + retval4.push_back (endP); + } } - if ((localAddressMatchesExact || (localAddressMatchesAllRouters))&& - remotePeerMatchesWildCard && - remoteAddressMatchesWildCard) - { /* Only local port and local address matches exactly */ - retval2.push_back (endP); - } - if (localAddressMatchesWildCard && - remotePeerMatchesExact && - remoteAddressMatchesExact) - { /* All but local address */ - retval3.push_back (endP); - } - if (localAddressMatchesExact && - remotePeerMatchesExact && - remoteAddressMatchesExact) - { /* All 4 match */ - retval4.push_back (endP); - } - } /* Here we find the most exact match */ if (!retval4.empty ()) return retval4; @@ -256,37 +256,37 @@ Ipv6EndPoint* Ipv6EndPointDemux::SimpleLookup (Ipv6Address dst, uint16_t dport, Ipv6EndPoint *generic = 0; for (EndPointsI i = m_endPoints.begin () ; i != m_endPoints.end () ; i++) - { - uint32_t tmp = 0; - - if ((*i)->GetLocalPort () != dport) { - continue; - } + uint32_t tmp = 0; - if ((*i)->GetLocalAddress () == dst && (*i)->GetPeerPort () == sport && - (*i)->GetPeerAddress () == src) - { - /* this is an exact match. */ - return *i; - } + if ((*i)->GetLocalPort () != dport) + { + continue; + } - if ((*i)->GetLocalAddress () == Ipv6Address::GetAny ()) - { - tmp ++; - } + if ((*i)->GetLocalAddress () == dst && (*i)->GetPeerPort () == sport && + (*i)->GetPeerAddress () == src) + { + /* this is an exact match. */ + return *i; + } - if ((*i)->GetPeerAddress () == Ipv6Address::GetAny ()) - { - tmp ++; - } + if ((*i)->GetLocalAddress () == Ipv6Address::GetAny ()) + { + tmp ++; + } - if (tmp < genericity) - { - generic = (*i); - genericity = tmp; + if ((*i)->GetPeerAddress () == Ipv6Address::GetAny ()) + { + tmp ++; + } + + if (tmp < genericity) + { + generic = (*i); + genericity = tmp; + } } - } return generic; } @@ -295,17 +295,17 @@ uint16_t Ipv6EndPointDemux::AllocateEphemeralPort () NS_LOG_FUNCTION_NOARGS (); uint16_t port = m_ephemeral; do - { - port++; - if (port == 65535) { - port = 49152; - } - if (!LookupPortLocal (port)) - { - return port; - } - } while (port != m_ephemeral); + port++; + if (port == 65535) + { + port = 49152; + } + if (!LookupPortLocal (port)) + { + return port; + } + } while (port != m_ephemeral); return 0; } diff --git a/src/internet-stack/ipv6-end-point-demux.h b/src/internet-stack/ipv6-end-point-demux.h index 00e3bbe24..b02de0d3d 100644 --- a/src/internet-stack/ipv6-end-point-demux.h +++ b/src/internet-stack/ipv6-end-point-demux.h @@ -37,122 +37,122 @@ class Ipv6EndPoint; */ class Ipv6EndPointDemux { - public: - typedef std::listEndPoints; - typedef std::list::iterator EndPointsI; +public: + typedef std::listEndPoints; + typedef std::list::iterator EndPointsI; - /** - * \brief Constructor. - */ - Ipv6EndPointDemux (); + /** + * \brief Constructor. + */ + Ipv6EndPointDemux (); - /** - * \brief Destructor. - */ - ~Ipv6EndPointDemux (); + /** + * \brief Destructor. + */ + ~Ipv6EndPointDemux (); - /** - * \brief Lookup for port local. - * \param port port to test - * \return true if a port local is in EndPoints, false otherwise - */ - bool LookupPortLocal (uint16_t port); + /** + * \brief Lookup for port local. + * \param port port to test + * \return true if a port local is in EndPoints, false otherwise + */ + bool LookupPortLocal (uint16_t port); - /** - * \brief Lookup for address and port. - * \param addr address to test - * \param port port to test - * \return true if there is a match in EndPoints, false otherwise - */ - bool LookupLocal (Ipv6Address addr, uint16_t port); + /** + * \brief Lookup for address and port. + * \param addr address to test + * \param port port to test + * \return true if there is a match in EndPoints, false otherwise + */ + bool LookupLocal (Ipv6Address addr, uint16_t port); - /** - * \brief lookup for a match with all the parameters. - * \param dst destination address to test - * \param dport destination port to test - * \param src source address to test - * \param sport source port to test - * \param incomingInterface the incoming interface - * \return list en IPv6EndPoints (could be 0 element) - */ - EndPoints Lookup (Ipv6Address dst, uint16_t dport, Ipv6Address src, uint16_t sport, Ptr incomingInterface); + /** + * \brief lookup for a match with all the parameters. + * \param dst destination address to test + * \param dport destination port to test + * \param src source address to test + * \param sport source port to test + * \param incomingInterface the incoming interface + * \return list en IPv6EndPoints (could be 0 element) + */ + EndPoints Lookup (Ipv6Address dst, uint16_t dport, Ipv6Address src, uint16_t sport, Ptr incomingInterface); - /** - * \brief Simple lookup for a four-tuple match. - * \param dst destination address to test - * \param dport destination port to test - * \param src source address to test - * \param sport source port to test - * \return match or 0 if not found - */ - Ipv6EndPoint* SimpleLookup (Ipv6Address dst, uint16_t dport, Ipv6Address src, uint16_t sport); + /** + * \brief Simple lookup for a four-tuple match. + * \param dst destination address to test + * \param dport destination port to test + * \param src source address to test + * \param sport source port to test + * \return match or 0 if not found + */ + Ipv6EndPoint* SimpleLookup (Ipv6Address dst, uint16_t dport, Ipv6Address src, uint16_t sport); - /** - * \brief Allocate a Ipv6EndPoint. - * \return an empty Ipv6EndPoint instance - */ - Ipv6EndPoint *Allocate (void); + /** + * \brief Allocate a Ipv6EndPoint. + * \return an empty Ipv6EndPoint instance + */ + Ipv6EndPoint *Allocate (void); - /** - * \brief Allocate a Ipv6EndPoint. - * \param address IPv6 address - * \return an Ipv6EndPoint instance - */ - Ipv6EndPoint *Allocate (Ipv6Address address); + /** + * \brief Allocate a Ipv6EndPoint. + * \param address IPv6 address + * \return an Ipv6EndPoint instance + */ + Ipv6EndPoint *Allocate (Ipv6Address address); - /** - * \brief Allocate a Ipv6EndPoint. - * \param port local port - * \return an Ipv6EndPoint instance - */ - Ipv6EndPoint *Allocate (uint16_t port); + /** + * \brief Allocate a Ipv6EndPoint. + * \param port local port + * \return an Ipv6EndPoint instance + */ + Ipv6EndPoint *Allocate (uint16_t port); - /** - * \brief Allocate a Ipv6EndPoint. - * \param address local address - * \param port local port - * \return an Ipv6EndPoint instance - */ - Ipv6EndPoint *Allocate (Ipv6Address address, uint16_t port); + /** + * \brief Allocate a Ipv6EndPoint. + * \param address local address + * \param port local port + * \return an Ipv6EndPoint instance + */ + Ipv6EndPoint *Allocate (Ipv6Address address, uint16_t port); - /** - * \brief Allocate a Ipv6EndPoint. - * \param localAddress local address - * \param localPort local port - * \param peerAddress peer address - * \param peerPort peer port - * \return an Ipv6EndPoint instance - */ - Ipv6EndPoint *Allocate (Ipv6Address localAddress, uint16_t localPort, Ipv6Address peerAddress, uint16_t peerPort); + /** + * \brief Allocate a Ipv6EndPoint. + * \param localAddress local address + * \param localPort local port + * \param peerAddress peer address + * \param peerPort peer port + * \return an Ipv6EndPoint instance + */ + Ipv6EndPoint *Allocate (Ipv6Address localAddress, uint16_t localPort, Ipv6Address peerAddress, uint16_t peerPort); - /** - * \brief Remove a end point. - * \param endPoint the end point to remove - */ - void DeAllocate (Ipv6EndPoint *endPoint); + /** + * \brief Remove a end point. + * \param endPoint the end point to remove + */ + void DeAllocate (Ipv6EndPoint *endPoint); - /** - * \brief Get the entire list of end points registered. - * \return list of Ipv6EndPoint - */ - EndPoints GetEndPoints () const; + /** + * \brief Get the entire list of end points registered. + * \return list of Ipv6EndPoint + */ + EndPoints GetEndPoints () const; - private: - /** - * \brief Allocate a ephemeral port. - * \return a port - */ - uint16_t AllocateEphemeralPort (); +private: + /** + * \brief Allocate a ephemeral port. + * \return a port + */ + uint16_t AllocateEphemeralPort (); - /** - * \brief The ephemeral port. - */ - uint16_t m_ephemeral; + /** + * \brief The ephemeral port. + */ + uint16_t m_ephemeral; - /** - * \brief A list of IPv6 end points. - */ - EndPoints m_endPoints; + /** + * \brief A list of IPv6 end points. + */ + EndPoints m_endPoints; }; } /* namespace ns3 */ diff --git a/src/internet-stack/ipv6-extension-header.cc b/src/internet-stack/ipv6-extension-header.cc index 555a54dd8..e39972f5f 100644 --- a/src/internet-stack/ipv6-extension-header.cc +++ b/src/internet-stack/ipv6-extension-header.cc @@ -45,7 +45,7 @@ TypeId Ipv6ExtensionHeader::GetInstanceTypeId () const } Ipv6ExtensionHeader::Ipv6ExtensionHeader () -: m_nextHeader (0), + : m_nextHeader (0), m_length (0), m_data (0) { @@ -121,7 +121,7 @@ uint32_t Ipv6ExtensionHeader::Deserialize (Buffer::Iterator start) } OptionField::OptionField (uint32_t optionsOffset) -: m_optionData (0), + : m_optionData (0), m_optionsOffset (optionsOffset) { } @@ -325,7 +325,7 @@ TypeId Ipv6ExtensionFragmentHeader::GetInstanceTypeId () const } Ipv6ExtensionFragmentHeader::Ipv6ExtensionFragmentHeader () -: m_offset (0), + : m_offset (0), m_identification (0) { } @@ -416,7 +416,7 @@ TypeId Ipv6ExtensionRoutingHeader::GetInstanceTypeId () const } Ipv6ExtensionRoutingHeader::Ipv6ExtensionRoutingHeader () -: m_typeRouting (0), + : m_typeRouting (0), m_segmentsLeft (0) { } @@ -495,7 +495,7 @@ TypeId Ipv6ExtensionLooseRoutingHeader::GetInstanceTypeId () const } Ipv6ExtensionLooseRoutingHeader::Ipv6ExtensionLooseRoutingHeader () -: m_routersAddress (0) + : m_routersAddress (0) { } diff --git a/src/internet-stack/ipv6-extension-header.h b/src/internet-stack/ipv6-extension-header.h index 38d2a61b6..e7b53c602 100644 --- a/src/internet-stack/ipv6-extension-header.h +++ b/src/internet-stack/ipv6-extension-header.h @@ -38,94 +38,94 @@ namespace ns3 */ class Ipv6ExtensionHeader : public Header { - public: - /** - * \brief Get the type identificator. - * \return type identificator - */ - static TypeId GetTypeId (); +public: + /** + * \brief Get the type identificator. + * \return type identificator + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Constructor. - */ - Ipv6ExtensionHeader (); + /** + * \brief Constructor. + */ + Ipv6ExtensionHeader (); - /** - * \brief Destructor. - */ - virtual ~Ipv6ExtensionHeader (); + /** + * \brief Destructor. + */ + virtual ~Ipv6ExtensionHeader (); - /** - * \brief Set the "Next header" field. - * \param nextHeader the next header number - */ - void SetNextHeader (uint8_t nextHeader); + /** + * \brief Set the "Next header" field. + * \param nextHeader the next header number + */ + void SetNextHeader (uint8_t nextHeader); - /** - * \brief Get the next header. - * \return the next header number - */ - uint8_t GetNextHeader () const; + /** + * \brief Get the next header. + * \return the next header number + */ + uint8_t GetNextHeader () const; - /** - * brief Set the length of the extension. - * \param length the length of the extension in bytes - */ - void SetLength (uint16_t length); + /** + * brief Set the length of the extension. + * \param length the length of the extension in bytes + */ + void SetLength (uint16_t length); - /** - * \brief Get the length of the extension. - * \return the length of the extension - */ - uint16_t GetLength () const; + /** + * \brief Get the length of the extension. + * \return the length of the extension + */ + uint16_t GetLength () const; - /** - * \brief Print some informations about the packet. - * \param os output stream - * \return info about this packet - */ - virtual void Print (std::ostream &os) const; + /** + * \brief Print some informations about the packet. + * \param os output stream + * \return info about this packet + */ + virtual void Print (std::ostream &os) const; - /** - * \brief Get the serialized size of the packet. - * \return size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size of the packet. + * \return size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start Buffer iterator - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start Buffer iterator + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start Buffer iterator - * \return size of the packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start Buffer iterator + * \return size of the packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: - /** - * \brief The "next header" field. - */ - uint8_t m_nextHeader; +private: + /** + * \brief The "next header" field. + */ + uint8_t m_nextHeader; - /** - * \brief The "length" field. - */ - uint8_t m_length; + /** + * \brief The "length" field. + */ + uint8_t m_length; - /** - * \brief The data of the extension. - */ - Buffer m_data; + /** + * \brief The data of the extension. + */ + Buffer m_data; }; /** @@ -140,74 +140,74 @@ class Ipv6ExtensionHeader : public Header */ class OptionField { - public: - /** - * \brief Constructor. - * \param optionsOffset option offset - */ - OptionField (uint32_t optionsOffset); - - /** - * \brief Destructor. - */ - ~OptionField (); +public: + /** + * \brief Constructor. + * \param optionsOffset option offset + */ + OptionField (uint32_t optionsOffset); - /** - * \brief Get the serialized size of the packet. - * \return size - */ - uint32_t GetSerializedSize () const; + /** + * \brief Destructor. + */ + ~OptionField (); - /** - * \brief Serialize all added options. - * \param start Buffer iterator - */ - void Serialize (Buffer::Iterator start) const; + /** + * \brief Get the serialized size of the packet. + * \return size + */ + uint32_t GetSerializedSize () const; - /** - * \brief Deserialize the packet. - * \param start Buffer iterator - * \param length length - * \return size of the packet - */ - uint32_t Deserialize (Buffer::Iterator start, uint32_t length); + /** + * \brief Serialize all added options. + * \param start Buffer iterator + */ + void Serialize (Buffer::Iterator start) const; - /** - * \brief Serialize the option, prepending pad1 or padn option as necessary - * \param option the option header to serialize - */ - void AddOption (Ipv6OptionHeader const& option); + /** + * \brief Deserialize the packet. + * \param start Buffer iterator + * \param length length + * \return size of the packet + */ + uint32_t Deserialize (Buffer::Iterator start, uint32_t length); - /** - * \brief Get the offset where the options begin, measured from the start of - * the extension header. - * \return the offset from the start of the extension header - */ - uint32_t GetOptionsOffset (); + /** + * \brief Serialize the option, prepending pad1 or padn option as necessary + * \param option the option header to serialize + */ + void AddOption (Ipv6OptionHeader const& option); - /** - * \brief Get the buffer. - * \return buffer - */ - Buffer GetOptionBuffer (); + /** + * \brief Get the offset where the options begin, measured from the start of + * the extension header. + * \return the offset from the start of the extension header + */ + uint32_t GetOptionsOffset (); - private: + /** + * \brief Get the buffer. + * \return buffer + */ + Buffer GetOptionBuffer (); - /** - * \brief Calculate padding. - * \param alignment alignment - */ - uint32_t CalculatePad (Ipv6OptionHeader::Alignment alignment) const; +private: - /** - * \brief Data payload. - */ - Buffer m_optionData; + /** + * \brief Calculate padding. + * \param alignment alignment + */ + uint32_t CalculatePad (Ipv6OptionHeader::Alignment alignment) const; - /** - * \brief Offset. - */ - uint32_t m_optionsOffset; + /** + * \brief Data payload. + */ + Buffer m_optionData; + + /** + * \brief Offset. + */ + uint32_t m_optionsOffset; }; /** @@ -216,54 +216,54 @@ class OptionField */ class Ipv6ExtensionHopByHopHeader : public Ipv6ExtensionHeader, public OptionField { - public: - /** - * \brief Get the type identificator. - * \return type identificator - */ - static TypeId GetTypeId (); +public: + /** + * \brief Get the type identificator. + * \return type identificator + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Constructor. - */ - Ipv6ExtensionHopByHopHeader (); + /** + * \brief Constructor. + */ + Ipv6ExtensionHopByHopHeader (); - /** - * \brief Destructor. - */ - virtual ~Ipv6ExtensionHopByHopHeader (); + /** + * \brief Destructor. + */ + virtual ~Ipv6ExtensionHopByHopHeader (); - /** - * \brief Print some informations about the packet. - * \param os output stream - * \return info about this packet - */ - virtual void Print (std::ostream &os) const; + /** + * \brief Print some informations about the packet. + * \param os output stream + * \return info about this packet + */ + virtual void Print (std::ostream &os) const; - /** - * \brief Get the serialized size of the packet. - * \return size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size of the packet. + * \return size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start Buffer iterator - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start Buffer iterator + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start Buffer iterator - * \return size of the packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start Buffer iterator + * \return size of the packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); }; /** @@ -272,54 +272,54 @@ class Ipv6ExtensionHopByHopHeader : public Ipv6ExtensionHeader, public OptionFie */ class Ipv6ExtensionDestinationHeader : public Ipv6ExtensionHeader, public OptionField { - public: - /** - * \brief Get the type identificator. - * \return type identificator - */ - static TypeId GetTypeId (); +public: + /** + * \brief Get the type identificator. + * \return type identificator + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Constructor. - */ - Ipv6ExtensionDestinationHeader (); + /** + * \brief Constructor. + */ + Ipv6ExtensionDestinationHeader (); - /** - * \brief Destructor. - */ - virtual ~Ipv6ExtensionDestinationHeader (); + /** + * \brief Destructor. + */ + virtual ~Ipv6ExtensionDestinationHeader (); - /** - * \brief Print some informations about the packet. - * \param os output stream - * \return info about this packet - */ - virtual void Print (std::ostream &os) const; + /** + * \brief Print some informations about the packet. + * \param os output stream + * \return info about this packet + */ + virtual void Print (std::ostream &os) const; - /** - * \brief Get the serialized size of the packet. - * \return size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size of the packet. + * \return size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start Buffer iterator - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start Buffer iterator + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start Buffer iterator - * \return size of the packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start Buffer iterator + * \return size of the packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); }; /** @@ -328,101 +328,101 @@ class Ipv6ExtensionDestinationHeader : public Ipv6ExtensionHeader, public Option */ class Ipv6ExtensionFragmentHeader : public Ipv6ExtensionHeader { - public: - /** - * \brief Get the type identificator. - * \return type identificator - */ - static TypeId GetTypeId (); +public: + /** + * \brief Get the type identificator. + * \return type identificator + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Constructor. - */ - Ipv6ExtensionFragmentHeader (); + /** + * \brief Constructor. + */ + Ipv6ExtensionFragmentHeader (); - /** - * \brief Destructor. - */ - virtual ~Ipv6ExtensionFragmentHeader (); + /** + * \brief Destructor. + */ + virtual ~Ipv6ExtensionFragmentHeader (); - /** - * \brief Set the "Offset" field. - * \param offset the offset of the fragment - */ - void SetOffset (uint16_t offset); + /** + * \brief Set the "Offset" field. + * \param offset the offset of the fragment + */ + void SetOffset (uint16_t offset); - /** - * \brief Get the field "Offset". - * \return the offset of the fragment - */ - uint16_t GetOffset () const; + /** + * \brief Get the field "Offset". + * \return the offset of the fragment + */ + uint16_t GetOffset () const; - /** - * \brief Set the status of "More Fragment" bit. - * \param moreFragment the bit "More Fragment" - */ - void SetMoreFragment (bool moreFragment); + /** + * \brief Set the status of "More Fragment" bit. + * \param moreFragment the bit "More Fragment" + */ + void SetMoreFragment (bool moreFragment); - /** - * \brief Get the status of "More Fragment" bit. - * \return the status of "More Fragment" bit. - */ - bool GetMoreFragment () const; + /** + * \brief Get the status of "More Fragment" bit. + * \return the status of "More Fragment" bit. + */ + bool GetMoreFragment () const; - /** - * \brief Set the "Identification" field. - * \param identification the identifier of the fragment - */ - void SetIdentification (uint32_t identification); + /** + * \brief Set the "Identification" field. + * \param identification the identifier of the fragment + */ + void SetIdentification (uint32_t identification); - /** - * \brief Get the field "Identification". - * \return the identifier of the fragment - */ - uint32_t GetIdentification () const; + /** + * \brief Get the field "Identification". + * \return the identifier of the fragment + */ + uint32_t GetIdentification () const; - /** - * \brief Print some informations about the packet. - * \param os output stream - * \return info about this packet - */ - virtual void Print (std::ostream &os) const; + /** + * \brief Print some informations about the packet. + * \param os output stream + * \return info about this packet + */ + virtual void Print (std::ostream &os) const; - /** - * \brief Get the serialized size of the packet. - * \return size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size of the packet. + * \return size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start Buffer iterator - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start Buffer iterator + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start Buffer iterator - * \return size of the packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start Buffer iterator + * \return size of the packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: - /** - * \brief Offset of the fragment and More Fragment bit. - */ - uint16_t m_offset; +private: + /** + * \brief Offset of the fragment and More Fragment bit. + */ + uint16_t m_offset; - /** - * \brief Identifier of the packet. - */ - uint32_t m_identification; + /** + * \brief Identifier of the packet. + */ + uint32_t m_identification; }; /** @@ -431,89 +431,89 @@ class Ipv6ExtensionFragmentHeader : public Ipv6ExtensionHeader */ class Ipv6ExtensionRoutingHeader : public Ipv6ExtensionHeader { - public: - /** - * \brief Get the type identificator. - * \return type identificator - */ - static TypeId GetTypeId (); +public: + /** + * \brief Get the type identificator. + * \return type identificator + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Constructor. - */ - Ipv6ExtensionRoutingHeader (); + /** + * \brief Constructor. + */ + Ipv6ExtensionRoutingHeader (); - /** - * \brief Destructor. - */ - virtual ~Ipv6ExtensionRoutingHeader (); + /** + * \brief Destructor. + */ + virtual ~Ipv6ExtensionRoutingHeader (); - /** - * \brief Set the "Type of Routing" field. - * \param typeRouting the type of routing - */ - void SetTypeRouting (uint8_t typeRouting); + /** + * \brief Set the "Type of Routing" field. + * \param typeRouting the type of routing + */ + void SetTypeRouting (uint8_t typeRouting); - /** - * \brief Get the field "Type of Routing". - * \return the type of routing - */ - uint8_t GetTypeRouting () const; + /** + * \brief Get the field "Type of Routing". + * \return the type of routing + */ + uint8_t GetTypeRouting () const; - /** - * \brief Set the "Segments left" field. - * \param segmentsLeft the number of segments left - */ - void SetSegmentsLeft (uint8_t segmentsLeft); + /** + * \brief Set the "Segments left" field. + * \param segmentsLeft the number of segments left + */ + void SetSegmentsLeft (uint8_t segmentsLeft); - /** - * \brief Get the field "Segments left". - * \return the number of segments left - */ - uint8_t GetSegmentsLeft () const; + /** + * \brief Get the field "Segments left". + * \return the number of segments left + */ + uint8_t GetSegmentsLeft () const; - /** - * \brief Print some informations about the packet. - * \param os output stream - * \return info about this packet - */ - virtual void Print (std::ostream &os) const; + /** + * \brief Print some informations about the packet. + * \param os output stream + * \return info about this packet + */ + virtual void Print (std::ostream &os) const; - /** - * \brief Get the serialized size of the packet. - * \return size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size of the packet. + * \return size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start Buffer iterator - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start Buffer iterator + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start Buffer iterator - * \return size of the packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start Buffer iterator + * \return size of the packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: - /** - * \brief Type of routing. - */ - uint8_t m_typeRouting; +private: + /** + * \brief Type of routing. + */ + uint8_t m_typeRouting; - /** - * \brief Number of left segments. - */ - uint8_t m_segmentsLeft; + /** + * \brief Number of left segments. + */ + uint8_t m_segmentsLeft; }; /** @@ -522,97 +522,97 @@ class Ipv6ExtensionRoutingHeader : public Ipv6ExtensionHeader */ class Ipv6ExtensionLooseRoutingHeader : public Ipv6ExtensionRoutingHeader { - public: - /** - * \brief Get the type identificator. - * \return type identificator - */ - static TypeId GetTypeId (); +public: + /** + * \brief Get the type identificator. + * \return type identificator + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Constructor. - */ - Ipv6ExtensionLooseRoutingHeader (); + /** + * \brief Constructor. + */ + Ipv6ExtensionLooseRoutingHeader (); - /** - * \brief Destructor. - */ - virtual ~Ipv6ExtensionLooseRoutingHeader (); + /** + * \brief Destructor. + */ + virtual ~Ipv6ExtensionLooseRoutingHeader (); - /** - * \brief Set the number of routers' address. - * \param n the number of routers' address - */ - void SetNumberAddress (uint8_t n); + /** + * \brief Set the number of routers' address. + * \param n the number of routers' address + */ + void SetNumberAddress (uint8_t n); - /** - * \brief Set the vector of routers' address - * \param routersAddress the vector of routers's address - */ - void SetRoutersAddress (std::vector routersAddress); + /** + * \brief Set the vector of routers' address + * \param routersAddress the vector of routers's address + */ + void SetRoutersAddress (std::vector routersAddress); - /** - * \brief Get the vector of routers' address - * \return the vector of routers' address - */ - std::vector GetRoutersAddress () const; + /** + * \brief Get the vector of routers' address + * \return the vector of routers' address + */ + std::vector GetRoutersAddress () const; - /** - * \brief Set a Router IPv6 Address. - * \param index the index of the IPv6 Address - * \param addr the new IPv6 Address - */ - void SetRouterAddress (uint8_t index, Ipv6Address addr); + /** + * \brief Set a Router IPv6 Address. + * \param index the index of the IPv6 Address + * \param addr the new IPv6 Address + */ + void SetRouterAddress (uint8_t index, Ipv6Address addr); - /** - * \brief Get a Router IPv6 Address. - * \param index the index of the IPv6 Address - * \return the router IPv6 Address - */ - Ipv6Address GetRouterAddress (uint8_t index) const; + /** + * \brief Get a Router IPv6 Address. + * \param index the index of the IPv6 Address + * \return the router IPv6 Address + */ + Ipv6Address GetRouterAddress (uint8_t index) const; - /** - * \brief Print some informations about the packet. - * \param os output stream - * \return info about this packet - */ - virtual void Print (std::ostream &os) const; + /** + * \brief Print some informations about the packet. + * \param os output stream + * \return info about this packet + */ + virtual void Print (std::ostream &os) const; - /** - * \brief Get the serialized size of the packet. - * \return size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size of the packet. + * \return size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start Buffer iterator - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start Buffer iterator + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start Buffer iterator - * \return size of the packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start Buffer iterator + * \return size of the packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: - /** - * \brief A vector of IPv6 Address. - */ - typedef std::vector VectorIpv6Address_t; +private: + /** + * \brief A vector of IPv6 Address. + */ + typedef std::vector VectorIpv6Address_t; - /** - * \brief The vector of Routers' IPv6 Address. - */ - VectorIpv6Address_t m_routersAddress; + /** + * \brief The vector of Routers' IPv6 Address. + */ + VectorIpv6Address_t m_routersAddress; }; /** @@ -621,54 +621,54 @@ class Ipv6ExtensionLooseRoutingHeader : public Ipv6ExtensionRoutingHeader */ class Ipv6ExtensionESPHeader : public Ipv6ExtensionHeader { - public: - /** - * \brief Get the type identificator. - * \return type identificator - */ - static TypeId GetTypeId (); +public: + /** + * \brief Get the type identificator. + * \return type identificator + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Constructor. - */ - Ipv6ExtensionESPHeader (); + /** + * \brief Constructor. + */ + Ipv6ExtensionESPHeader (); - /** - * \brief Destructor. - */ - virtual ~Ipv6ExtensionESPHeader (); + /** + * \brief Destructor. + */ + virtual ~Ipv6ExtensionESPHeader (); - /** - * \brief Print some informations about the packet. - * \param os output stream - * \return info about this packet - */ - virtual void Print (std::ostream &os) const; + /** + * \brief Print some informations about the packet. + * \param os output stream + * \return info about this packet + */ + virtual void Print (std::ostream &os) const; - /** - * \brief Get the serialized size of the packet. - * \return size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size of the packet. + * \return size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start Buffer iterator - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start Buffer iterator + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start Buffer iterator - * \return size of the packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start Buffer iterator + * \return size of the packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); }; /** @@ -677,54 +677,54 @@ class Ipv6ExtensionESPHeader : public Ipv6ExtensionHeader */ class Ipv6ExtensionAHHeader : public Ipv6ExtensionHeader { - public: - /** - * \brief Get the type identificator. - * \return type identificator - */ - static TypeId GetTypeId (); +public: + /** + * \brief Get the type identificator. + * \return type identificator + */ + static TypeId GetTypeId (); - /** - * \brief Get the instance type ID. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId () const; + /** + * \brief Get the instance type ID. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId () const; - /** - * \brief Constructor. - */ - Ipv6ExtensionAHHeader (); + /** + * \brief Constructor. + */ + Ipv6ExtensionAHHeader (); - /** - * \brief Destructor. - */ - virtual ~Ipv6ExtensionAHHeader (); + /** + * \brief Destructor. + */ + virtual ~Ipv6ExtensionAHHeader (); - /** - * \brief Print some informations about the packet. - * \param os output stream - * \return info about this packet - */ - virtual void Print (std::ostream &os) const; + /** + * \brief Print some informations about the packet. + * \param os output stream + * \return info about this packet + */ + virtual void Print (std::ostream &os) const; - /** - * \brief Get the serialized size of the packet. - * \return size - */ - virtual uint32_t GetSerializedSize () const; + /** + * \brief Get the serialized size of the packet. + * \return size + */ + virtual uint32_t GetSerializedSize () const; - /** - * \brief Serialize the packet. - * \param start Buffer iterator - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start Buffer iterator + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start Buffer iterator - * \return size of the packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start Buffer iterator + * \return size of the packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); }; } // namespace ns3 diff --git a/src/internet-stack/ipv6-extension.cc b/src/internet-stack/ipv6-extension.cc index 6a6dc8df5..f6f83bc2e 100644 --- a/src/internet-stack/ipv6-extension.cc +++ b/src/internet-stack/ipv6-extension.cc @@ -523,7 +523,7 @@ void Ipv6ExtensionFragment::GetFragments (Ptr packet, uint32_t maxFragme } Ipv6ExtensionFragment::Fragments::Fragments () -: m_moreFragment (0) + : m_moreFragment (0) { } diff --git a/src/internet-stack/ipv6-interface.cc b/src/internet-stack/ipv6-interface.cc index d2a08c3aa..b21a026ca 100644 --- a/src/internet-stack/ipv6-interface.cc +++ b/src/internet-stack/ipv6-interface.cc @@ -70,31 +70,31 @@ void Ipv6Interface::DoDispose () void Ipv6Interface::DoSetup () { NS_LOG_FUNCTION_NOARGS (); - + if (m_node == 0 || m_device == 0) - { - return; - } - + { + return; + } + /* set up link-local address */ if (!DynamicCast (m_device)) /* no autoconf for ip6-localhost */ - { - Address addr = GetDevice ()->GetAddress (); + { + Address addr = GetDevice ()->GetAddress (); - if (Mac48Address::IsMatchingType (addr)) - { - Ipv6InterfaceAddress ifaddr = Ipv6InterfaceAddress (Ipv6Address::MakeAutoconfiguredLinkLocalAddress (Mac48Address::ConvertFrom (addr)), Ipv6Prefix (64)); - AddAddress (ifaddr); + if (Mac48Address::IsMatchingType (addr)) + { + Ipv6InterfaceAddress ifaddr = Ipv6InterfaceAddress (Ipv6Address::MakeAutoconfiguredLinkLocalAddress (Mac48Address::ConvertFrom (addr)), Ipv6Prefix (64)); + AddAddress (ifaddr); + } + else + { + NS_ASSERT_MSG (false, "IPv6 autoconf for this kind of address not implemented."); + } } - else - { - NS_ASSERT_MSG (false, "IPv6 autoconf for this kind of address not implemented."); - } - } else - { - return; /* no NDISC cache for ip6-localhost */ - } + { + return; /* no NDISC cache for ip6-localhost */ + } Ptr icmpv6 = m_node->GetObject ()->GetIcmpv6 (); m_ndCache = icmpv6->CreateCache (m_device, this); @@ -149,9 +149,9 @@ void Ipv6Interface::SetUp () NS_LOG_FUNCTION_NOARGS (); if (m_ifup) - { - return; - } + { + return; + } m_ifup = true; } @@ -181,30 +181,30 @@ bool Ipv6Interface::AddAddress (Ipv6InterfaceAddress iface) /* DAD handling */ if (!addr.IsAny ()) - { - for (Ipv6InterfaceAddressListCI it = m_addresses.begin () ; it != m_addresses.end () ; ++it) { - if ((*it).GetAddress () == addr) - { - return false; - } - } + for (Ipv6InterfaceAddressListCI it = m_addresses.begin () ; it != m_addresses.end () ; ++it) + { + if ((*it).GetAddress () == addr) + { + return false; + } + } - m_addresses.push_back (iface); - - if (!addr.IsAny () || !addr.IsLocalhost ()) - { - /* DAD handling */ - Ptr icmpv6 = m_node->GetObject ()->GetIcmpv6 (); + m_addresses.push_back (iface); - if (icmpv6 && icmpv6->IsAlwaysDad ()) - { - Simulator::Schedule (Seconds (0.), &Icmpv6L4Protocol::DoDAD, icmpv6, addr, this); - Simulator::Schedule (Seconds (1.), &Icmpv6L4Protocol::FunctionDadTimeout, icmpv6, this, addr); - } + if (!addr.IsAny () || !addr.IsLocalhost ()) + { + /* DAD handling */ + Ptr icmpv6 = m_node->GetObject ()->GetIcmpv6 (); + + if (icmpv6 && icmpv6->IsAlwaysDad ()) + { + Simulator::Schedule (Seconds (0.), &Icmpv6L4Protocol::DoDAD, icmpv6, addr, this); + Simulator::Schedule (Seconds (1.), &Icmpv6L4Protocol::FunctionDadTimeout, icmpv6, this, addr); + } + } + return true; } - return true; - } /* bad address */ return false; @@ -216,12 +216,12 @@ Ipv6InterfaceAddress Ipv6Interface::GetLinkLocalAddress () const NS_LOG_FUNCTION_NOARGS (); for (Ipv6InterfaceAddressListCI it = m_addresses.begin () ; it != m_addresses.end () ; ++it) - { - if ((*it).GetAddress ().IsLinkLocal ()) { - return (*it); + if ((*it).GetAddress ().IsLinkLocal ()) + { + return (*it); + } } - } NS_ASSERT_MSG (false, "No link-local address on interface " << this); Ipv6InterfaceAddress addr; return addr; /* quiet compiler */ @@ -233,16 +233,16 @@ Ipv6InterfaceAddress Ipv6Interface::GetAddress (uint32_t index) const uint32_t i = 0; if (m_addresses.size () > index) - { - for (Ipv6InterfaceAddressListCI it = m_addresses.begin () ; it != m_addresses.end () ; ++it) { - if (i == index) - { - return (*it); - } - i++; + for (Ipv6InterfaceAddressListCI it = m_addresses.begin () ; it != m_addresses.end () ; ++it) + { + if (i == index) + { + return (*it); + } + i++; + } } - } NS_ASSERT_MSG (false, "Address " << index << " not found"); Ipv6InterfaceAddress addr; @@ -261,22 +261,22 @@ Ipv6InterfaceAddress Ipv6Interface::RemoveAddress (uint32_t index) uint32_t i = 0; if (m_addresses.size () < index) - { - NS_ASSERT_MSG (false, "Try to remove index that don't exist in Ipv6Interface::RemoveAddress"); - } - - for (Ipv6InterfaceAddressListI it = m_addresses.begin () ; it != m_addresses.end () ; ++it) - { - if (i == index) { - Ipv6InterfaceAddress iface = (*it); - m_addresses.erase (it); - return iface; + NS_ASSERT_MSG (false, "Try to remove index that don't exist in Ipv6Interface::RemoveAddress"); + } + + for (Ipv6InterfaceAddressListI it = m_addresses.begin () ; it != m_addresses.end () ; ++it) + { + if (i == index) + { + Ipv6InterfaceAddress iface = (*it); + m_addresses.erase (it); + return iface; + } + + i++; } - i++; - } - NS_ASSERT_MSG (false, "Address " << index << " not found"); Ipv6InterfaceAddress addr; return addr; /* quiet compiler */ @@ -285,18 +285,18 @@ Ipv6InterfaceAddress Ipv6Interface::RemoveAddress (uint32_t index) Ipv6InterfaceAddress Ipv6Interface::GetAddressMatchingDestination (Ipv6Address dst) { NS_LOG_FUNCTION (this << dst); - + for (Ipv6InterfaceAddressList::const_iterator it = m_addresses.begin () ; it != m_addresses.end () ; ++it) - { - Ipv6InterfaceAddress ifaddr = (*it); - - if (ifaddr.GetPrefix ().IsMatch (ifaddr.GetAddress (), dst)) { - return ifaddr; - } - } + Ipv6InterfaceAddress ifaddr = (*it); -/* NS_ASSERT_MSG (false, "Not matching address."); */ + if (ifaddr.GetPrefix ().IsMatch (ifaddr.GetAddress (), dst)) + { + return ifaddr; + } + } + + /* NS_ASSERT_MSG (false, "Not matching address."); */ Ipv6InterfaceAddress ret; return ret; /* quiet compiler */ } @@ -307,69 +307,69 @@ void Ipv6Interface::Send (Ptr p, Ipv6Address dest) Ptr ipv6 = m_node->GetObject (); if (!IsUp ()) - { - return; - } - + { + return; + } + /* check if destination is localhost (::1) */ if (DynamicCast (m_device)) - { - /* XXX additional checks needed here (such as whether multicast - * goes to loopback)? - */ - m_device->Send (p, m_device->GetBroadcast (), Ipv6L3Protocol::PROT_NUMBER); - return; - } + { + /* XXX additional checks needed here (such as whether multicast + * goes to loopback)? + */ + m_device->Send (p, m_device->GetBroadcast (), Ipv6L3Protocol::PROT_NUMBER); + return; + } /* check if destination is for one of our interface */ for (Ipv6InterfaceAddressListCI it = m_addresses.begin () ; it != m_addresses.end () ; ++it) - { - if (dest == (*it).GetAddress ()) { - ipv6->Receive (m_device, p, Ipv6L3Protocol::PROT_NUMBER, - m_device->GetBroadcast (), - m_device->GetBroadcast (), - NetDevice::PACKET_HOST // note: linux uses PACKET_LOOPBACK here - ); - return; + if (dest == (*it).GetAddress ()) + { + ipv6->Receive (m_device, p, Ipv6L3Protocol::PROT_NUMBER, + m_device->GetBroadcast (), + m_device->GetBroadcast (), + NetDevice::PACKET_HOST // note: linux uses PACKET_LOOPBACK here + ); + return; + } } - } /* other address */ if (m_device->NeedsArp ()) - { - NS_LOG_LOGIC ("Needs ARP" << " " << dest); - Ptr icmpv6 = ipv6->GetIcmpv6 (); - Address hardwareDestination; - bool found = false; - - NS_ASSERT (icmpv6); - - if (dest.IsMulticast ()) { - NS_LOG_LOGIC ("IsMulticast"); - NS_ASSERT_MSG (m_device->IsMulticast (), "Ipv6Interface::SendTo (): Sending multicast packet over non-multicast device"); + NS_LOG_LOGIC ("Needs ARP" << " " << dest); + Ptr icmpv6 = ipv6->GetIcmpv6 (); + Address hardwareDestination; + bool found = false; - hardwareDestination = m_device->GetMulticast (dest); - found = true; - } - else - { - NS_LOG_LOGIC ("NDISC Lookup"); - found = icmpv6->Lookup (p, dest, GetDevice (), m_ndCache, &hardwareDestination); - } + NS_ASSERT (icmpv6); - if (found) - { - NS_LOG_LOGIC ("Address Resolved. Send."); - m_device ->Send (p, hardwareDestination, Ipv6L3Protocol::PROT_NUMBER); + if (dest.IsMulticast ()) + { + NS_LOG_LOGIC ("IsMulticast"); + NS_ASSERT_MSG (m_device->IsMulticast (), "Ipv6Interface::SendTo (): Sending multicast packet over non-multicast device"); + + hardwareDestination = m_device->GetMulticast (dest); + found = true; + } + else + { + NS_LOG_LOGIC ("NDISC Lookup"); + found = icmpv6->Lookup (p, dest, GetDevice (), m_ndCache, &hardwareDestination); + } + + if (found) + { + NS_LOG_LOGIC ("Address Resolved. Send."); + m_device ->Send (p, hardwareDestination, Ipv6L3Protocol::PROT_NUMBER); + } } - } else - { - NS_LOG_LOGIC ("Doesn't need ARP"); - m_device->Send (p, m_device->GetBroadcast (), Ipv6L3Protocol::PROT_NUMBER); - } + { + NS_LOG_LOGIC ("Doesn't need ARP"); + m_device->Send (p, m_device->GetBroadcast (), Ipv6L3Protocol::PROT_NUMBER); + } } void Ipv6Interface::SetCurHopLimit (uint8_t curHopLimit) @@ -425,13 +425,13 @@ void Ipv6Interface::SetState (Ipv6Address address, Ipv6InterfaceAddress::State_e NS_LOG_FUNCTION (this << address << state); for (Ipv6InterfaceAddressListI it = m_addresses.begin () ; it != m_addresses.end () ; ++it) - { - if ((*it).GetAddress () == address) { - (*it).SetState (state); - return; + if ((*it).GetAddress () == address) + { + (*it).SetState (state); + return; + } } - } /* not found, maybe address has expired */ } @@ -440,13 +440,13 @@ void Ipv6Interface::SetNsDadUid (Ipv6Address address, uint32_t uid) NS_LOG_FUNCTION (this << address << uid); for (Ipv6InterfaceAddressListI it = m_addresses.begin () ; it != m_addresses.end () ; ++it) - { - if ((*it).GetAddress () == address) { - (*it).SetNsDadUid (uid); - return; + if ((*it).GetAddress () == address) + { + (*it).SetNsDadUid (uid); + return; + } } - } /* not found, maybe address has expired */ } diff --git a/src/internet-stack/ipv6-interface.h b/src/internet-stack/ipv6-interface.h index e1a73ee3d..af46d76a4 100644 --- a/src/internet-stack/ipv6-interface.h +++ b/src/internet-stack/ipv6-interface.h @@ -48,271 +48,271 @@ class NdiscCache; */ class Ipv6Interface : public Object { - public: - /** - * \brief Get the type ID - * \return type ID - */ - static TypeId GetTypeId (); +public: + /** + * \brief Get the type ID + * \return type ID + */ + static TypeId GetTypeId (); - /** - * \brief Constructs an Ipv6Interface. - */ - Ipv6Interface (); + /** + * \brief Constructs an Ipv6Interface. + */ + Ipv6Interface (); - /** - * \brief Destructor. - */ - virtual ~Ipv6Interface (); + /** + * \brief Destructor. + */ + virtual ~Ipv6Interface (); - /** - * \brief Set node associated with interface. - * \param node node - */ - void SetNode (Ptr node); + /** + * \brief Set node associated with interface. + * \param node node + */ + void SetNode (Ptr node); - /** - * \brief Set the NetDevice. - * \param device NetDevice - */ - void SetDevice (Ptr device); + /** + * \brief Set the NetDevice. + * \param device NetDevice + */ + void SetDevice (Ptr device); - /** - * \brief Get the NetDevice. - * \return the NetDevice associated with this interface - */ - virtual Ptr GetDevice () const; + /** + * \brief Get the NetDevice. + * \return the NetDevice associated with this interface + */ + virtual Ptr GetDevice () const; - /** - * \brief Set the metric. - * \param metric configured routing metric (cost) of this interface - */ - void SetMetric (uint16_t metric); + /** + * \brief Set the metric. + * \param metric configured routing metric (cost) of this interface + */ + void SetMetric (uint16_t metric); - /** - * \brief Get the metric - * \return the metric - */ - uint16_t GetMetric () const; + /** + * \brief Get the metric + * \return the metric + */ + uint16_t GetMetric () const; - /** - * \brief Is the interface UP ? - * \return true if interface is enabled, false otherwise. - */ - bool IsUp () const; + /** + * \brief Is the interface UP ? + * \return true if interface is enabled, false otherwise. + */ + bool IsUp () const; - /** - * \brief Is the interface DOWN ? - * \return true if interface is disabled, false otherwise. - */ - bool IsDown () const; + /** + * \brief Is the interface DOWN ? + * \return true if interface is disabled, false otherwise. + */ + bool IsDown () const; - /** - * \brief Enable this interface. - */ - void SetUp (); + /** + * \brief Enable this interface. + */ + void SetUp (); - /** - * \brief Disable this interface. - */ - void SetDown (); + /** + * \brief Disable this interface. + */ + void SetDown (); - /** - * \brief If the interface allows forwarding packets. - * \return true if forwarding is enabled, false otherwise - */ - bool IsForwarding () const; + /** + * \brief If the interface allows forwarding packets. + * \return true if forwarding is enabled, false otherwise + */ + bool IsForwarding () const; - /** - * \brief Set forwarding enabled or not. - * \param forward forwarding state - */ - void SetForwarding (bool forward); + /** + * \brief Set forwarding enabled or not. + * \param forward forwarding state + */ + void SetForwarding (bool forward); - /** - * \brief Set the current hop limit. - * \param curHopLimit the value to set - */ - void SetCurHopLimit (uint8_t curHopLimit); + /** + * \brief Set the current hop limit. + * \param curHopLimit the value to set + */ + void SetCurHopLimit (uint8_t curHopLimit); - /** - * \brief Get the current hop limit value. - * \return current hop limit - */ - uint8_t GetCurHopLimit () const; + /** + * \brief Get the current hop limit value. + * \return current hop limit + */ + uint8_t GetCurHopLimit () const; - /** - * \brief Set the base reachable time. - * \param baseReachableTime the value to set - */ - void SetBaseReachableTime (uint16_t baseReachableTime); + /** + * \brief Set the base reachable time. + * \param baseReachableTime the value to set + */ + void SetBaseReachableTime (uint16_t baseReachableTime); - /** - * \brief Get the base reachable time. - * \return base reachable time - */ - uint16_t GetBaseReachableTime () const; + /** + * \brief Get the base reachable time. + * \return base reachable time + */ + uint16_t GetBaseReachableTime () const; - /** - * \brief Set the reachable time. - * \param reachableTime value to set - */ - void SetReachableTime (uint16_t reachableTime); + /** + * \brief Set the reachable time. + * \param reachableTime value to set + */ + void SetReachableTime (uint16_t reachableTime); - /** - * \brief Get the reachable time. - * \return reachable time - */ - uint16_t GetReachableTime () const; + /** + * \brief Get the reachable time. + * \return reachable time + */ + uint16_t GetReachableTime () const; - /** - * \brief Set the retransmission timer. - * \param retransTimer value to set - */ - void SetRetransTimer (uint16_t retransTimer); + /** + * \brief Set the retransmission timer. + * \param retransTimer value to set + */ + void SetRetransTimer (uint16_t retransTimer); - /** - * \brief Get the retransmission timer. - * \return retransmission timer - */ - uint16_t GetRetransTimer () const; + /** + * \brief Get the retransmission timer. + * \return retransmission timer + */ + uint16_t GetRetransTimer () const; - /** - * \brief Send a packet through this interface. - * \param p packet to send - * \param dest next hop address of packet. - * - * \note This method will eventually call the private SendTo - * method which must be implemented by subclasses. - */ - void Send (Ptr p, Ipv6Address dest); + /** + * \brief Send a packet through this interface. + * \param p packet to send + * \param dest next hop address of packet. + * + * \note This method will eventually call the private SendTo + * method which must be implemented by subclasses. + */ + void Send (Ptr p, Ipv6Address dest); - /** - * \brief Add an IPv6 address. - * \param iface address to add - * \return true if address was added, false otherwise - */ - bool AddAddress (Ipv6InterfaceAddress iface); - - /** - * \brief Get link-local address from IPv6 interface. - * \return link-local Ipv6InterfaceAddress, assert if not found - */ - Ipv6InterfaceAddress GetLinkLocalAddress () const; + /** + * \brief Add an IPv6 address. + * \param iface address to add + * \return true if address was added, false otherwise + */ + bool AddAddress (Ipv6InterfaceAddress iface); - /** - * \brief Get an address from IPv6 interface. - * \param index index - * \return Ipv6InterfaceAddress address whose index is i - */ - Ipv6InterfaceAddress GetAddress (uint32_t index) const; + /** + * \brief Get link-local address from IPv6 interface. + * \return link-local Ipv6InterfaceAddress, assert if not found + */ + Ipv6InterfaceAddress GetLinkLocalAddress () const; - /** - * \brief Get an address which is in the same network prefix as destination. - * \param dst destination address - * \return Corresponding Ipv6InterfaceAddress or assert if not found - */ - Ipv6InterfaceAddress GetAddressMatchingDestination (Ipv6Address dst); + /** + * \brief Get an address from IPv6 interface. + * \param index index + * \return Ipv6InterfaceAddress address whose index is i + */ + Ipv6InterfaceAddress GetAddress (uint32_t index) const; - /** - * \brief Get number of addresses on this IPv6 interface. - * \return number of address - */ - uint32_t GetNAddresses (void) const; - - /** - * \brief Remove an address from interface. - * \param index index to remove - * \return Ipv6InterfaceAddress address whose index is index - */ - Ipv6InterfaceAddress RemoveAddress (uint32_t index); - - /** - * \brief Update state of an interface address. - * \param address IPv6 address - * \param state new state - */ - void SetState (Ipv6Address address, Ipv6InterfaceAddress::State_e state); + /** + * \brief Get an address which is in the same network prefix as destination. + * \param dst destination address + * \return Corresponding Ipv6InterfaceAddress or assert if not found + */ + Ipv6InterfaceAddress GetAddressMatchingDestination (Ipv6Address dst); - /** - * \brief Update NS DAD packet UID of an interface address. - * \param address IPv6 address - * \param uid packet UID - */ - void SetNsDadUid (Ipv6Address address, uint32_t uid); + /** + * \brief Get number of addresses on this IPv6 interface. + * \return number of address + */ + uint32_t GetNAddresses (void) const; - protected: - /** - * \brief Dispose this object. - */ - virtual void DoDispose (); + /** + * \brief Remove an address from interface. + * \param index index to remove + * \return Ipv6InterfaceAddress address whose index is index + */ + Ipv6InterfaceAddress RemoveAddress (uint32_t index); - private: - typedef std::list Ipv6InterfaceAddressList; - typedef std::list::iterator Ipv6InterfaceAddressListI; - typedef std::list::const_iterator Ipv6InterfaceAddressListCI; + /** + * \brief Update state of an interface address. + * \param address IPv6 address + * \param state new state + */ + void SetState (Ipv6Address address, Ipv6InterfaceAddress::State_e state); - /** - * \brief Initialize interface. - */ - void DoSetup (); + /** + * \brief Update NS DAD packet UID of an interface address. + * \param address IPv6 address + * \param uid packet UID + */ + void SetNsDadUid (Ipv6Address address, uint32_t uid); - /** - * \brief The addresses assigned to this interface. - */ - Ipv6InterfaceAddressList m_addresses; +protected: + /** + * \brief Dispose this object. + */ + virtual void DoDispose (); - /** - * \brief The state of this interface. - */ - bool m_ifup; +private: + typedef std::list Ipv6InterfaceAddressList; + typedef std::list::iterator Ipv6InterfaceAddressListI; + typedef std::list::const_iterator Ipv6InterfaceAddressListCI; - /** - * \brief Forwarding state. - */ - bool m_forwarding; + /** + * \brief Initialize interface. + */ + void DoSetup (); - /** - * \brief The metric. - */ - uint16_t m_metric; + /** + * \brief The addresses assigned to this interface. + */ + Ipv6InterfaceAddressList m_addresses; - /** - * \brief Node associated with this interface. - */ - Ptr m_node; + /** + * \brief The state of this interface. + */ + bool m_ifup; - /** - * \brief NetDevice associated with this interface. - */ - Ptr m_device; + /** + * \brief Forwarding state. + */ + bool m_forwarding; - /** - * \brief Neighbor cache. - */ - Ptr m_ndCache; + /** + * \brief The metric. + */ + uint16_t m_metric; - /** - * \brief Current hop limit. - */ - uint8_t m_curHopLimit; + /** + * \brief Node associated with this interface. + */ + Ptr m_node; - /** - * \brief Base value used for computing the random reachable time value (in millisecond). - */ - uint16_t m_baseReachableTime; + /** + * \brief NetDevice associated with this interface. + */ + Ptr m_device; - /** - * \brief Reachable time (in millisecond). - * The time a neighbor is considered reachable after receiving a reachability confirmation. - */ - uint16_t m_reachableTime; + /** + * \brief Neighbor cache. + */ + Ptr m_ndCache; - /** - * \brief Retransmission timer (in millisecond). - * Time between retransmission of NS. - */ - uint16_t m_retransTimer; + /** + * \brief Current hop limit. + */ + uint8_t m_curHopLimit; + + /** + * \brief Base value used for computing the random reachable time value (in millisecond). + */ + uint16_t m_baseReachableTime; + + /** + * \brief Reachable time (in millisecond). + * The time a neighbor is considered reachable after receiving a reachability confirmation. + */ + uint16_t m_reachableTime; + + /** + * \brief Retransmission timer (in millisecond). + * Time between retransmission of NS. + */ + uint16_t m_retransTimer; }; } /* namespace ns3 */ diff --git a/src/internet-stack/ipv6-l3-protocol.cc b/src/internet-stack/ipv6-l3-protocol.cc index 595b42432..d1487a5ac 100644 --- a/src/internet-stack/ipv6-l3-protocol.cc +++ b/src/internet-stack/ipv6-l3-protocol.cc @@ -65,7 +65,7 @@ TypeId Ipv6L3Protocol::GetTypeId () MakeObjectVectorAccessor (&Ipv6L3Protocol::m_interfaces), MakeObjectVectorChecker ()) .AddTraceSource ("Tx", "Send IPv6 packet to outgoing interface.", - MakeTraceSourceAccessor (&Ipv6L3Protocol::m_txTrace)) + MakeTraceSourceAccessor (&Ipv6L3Protocol::m_txTrace)) .AddTraceSource ("Rx", "Receive IPv6 packet from incoming interface.", MakeTraceSourceAccessor (&Ipv6L3Protocol::m_rxTrace)) .AddTraceSource ("Drop", "Drop IPv6 packet", @@ -88,35 +88,35 @@ Ipv6L3Protocol::~Ipv6L3Protocol () void Ipv6L3Protocol::DoDispose () { NS_LOG_FUNCTION_NOARGS (); - + /* clear protocol and interface list */ for (L4List_t::iterator it = m_protocols.begin () ; it != m_protocols.end () ; ++it) - { - *it = 0; - } + { + *it = 0; + } m_protocols.clear (); /* remove interfaces */ for (Ipv6InterfaceList::iterator it = m_interfaces.begin () ; it != m_interfaces.end (); ++it) - { - *it = 0; - } + { + *it = 0; + } m_interfaces.clear (); /* remove raw sockets */ for (SocketList::iterator it = m_sockets.begin () ; it != m_sockets.end () ; ++it) - { - *it = 0; - } + { + *it = 0; + } m_sockets.clear (); /* remove list of prefix */ for (Ipv6AutoconfiguredPrefixListI it = m_prefixes.begin () ; it != m_prefixes.end () ; ++it) - { - (*it)->StopValidTimer (); - (*it)->StopPreferredTimer (); - (*it) = 0; - } + { + (*it)->StopValidTimer (); + (*it)->StopPreferredTimer (); + (*it) = 0; + } m_prefixes.clear (); m_node = 0; @@ -142,7 +142,7 @@ uint32_t Ipv6L3Protocol::AddInterface (Ptr device) NS_LOG_FUNCTION (this << device); Ptr node = GetObject (); Ptr interface = CreateObject (); - + node->RegisterProtocolHandler (MakeCallback (&Ipv6L3Protocol::Receive, this), Ipv6L3Protocol::PROT_NUMBER, device); interface->SetNode (m_node); interface->SetDevice (device); @@ -164,15 +164,15 @@ Ptr Ipv6L3Protocol::GetInterface (uint32_t index) const { NS_LOG_FUNCTION (this << index); uint32_t tmp = 0; - + for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin () ; it != m_interfaces.end () ; it++) - { - if (index == tmp) { - return *it; + if (index == tmp) + { + return *it; + } + tmp++; } - tmp++; - } return 0; } @@ -188,19 +188,19 @@ int32_t Ipv6L3Protocol::GetInterfaceForAddress (Ipv6Address address) const int32_t index = 0; for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin () ; it != m_interfaces.end () ; it++) - { - uint32_t j = 0; - uint32_t max = (*it)->GetNAddresses (); - - for (j = 0 ; j < max ; j++) { - if ((*it)->GetAddress (j).GetAddress () == address) - { - return index; - } + uint32_t j = 0; + uint32_t max = (*it)->GetNAddresses (); + + for (j = 0 ; j < max ; j++) + { + if ((*it)->GetAddress (j).GetAddress () == address) + { + return index; + } + } + index++; } - index++; - } return -1; } @@ -210,17 +210,17 @@ int32_t Ipv6L3Protocol::GetInterfaceForPrefix (Ipv6Address address, Ipv6Prefix m int32_t index = 0; for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin () ; it != m_interfaces.end () ; it++) - { - uint32_t j = 0; - for (j = 0 ; j < (*it)->GetNAddresses () ; j++) { - if ((*it)->GetAddress (j).GetAddress ().CombinePrefix (mask) == address.CombinePrefix (mask)) - { - return index; - } + uint32_t j = 0; + for (j = 0 ; j < (*it)->GetNAddresses () ; j++) + { + if ((*it)->GetAddress (j).GetAddress ().CombinePrefix (mask) == address.CombinePrefix (mask)) + { + return index; + } + } + index++; } - index++; - } return -1; } @@ -236,13 +236,13 @@ int32_t Ipv6L3Protocol::GetInterfaceForDevice (Ptr device) cons int32_t index = 0; for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin () ; it != m_interfaces.end () ; it++) - { - if ((*it)->GetDevice () == device) { - return index; + if ((*it)->GetDevice () == device) + { + return index; + } + index++; } - index++; - } return -1; } @@ -254,44 +254,44 @@ void Ipv6L3Protocol::AddAutoconfiguredAddress (uint32_t interface, Ipv6Address n Address addr = GetInterface (interface)->GetDevice ()->GetAddress (); if (flags & (1<< 6)) /* auto flag */ - { - /* XXX : add other L2 address case */ - if (Mac48Address::IsMatchingType (addr)) { - address = Ipv6InterfaceAddress (Ipv6Address::MakeAutoconfiguredAddress (Mac48Address::ConvertFrom (addr), network)); + /* XXX : add other L2 address case */ + if (Mac48Address::IsMatchingType (addr)) + { + address = Ipv6InterfaceAddress (Ipv6Address::MakeAutoconfiguredAddress (Mac48Address::ConvertFrom (addr), network)); + } + else + { + NS_FATAL_ERROR ("Unknown method to make autoconfigured address for this kind of device."); + return; + } + + /* see if we have already the prefix */ + for (Ipv6AutoconfiguredPrefixListI it = m_prefixes.begin () ; it != m_prefixes.end () ; ++it) + { + if ((*it)->GetInterface () == interface && (*it)->GetPrefix () == network && (*it)->GetMask () == mask) + { + (*it)->StopPreferredTimer (); + (*it)->StopValidTimer (); + (*it)->StartPreferredTimer (); + return; + } + } + + /* no prefix found, add autoconfigured address and the prefix */ + NS_LOG_INFO ("Autoconfigured address is :" << address.GetAddress ()); + AddAddress (interface, address); + + /* add default router + * if a previous default route exists, the new ones is simply added + */ + GetRoutingProtocol ()->NotifyAddRoute (Ipv6Address::GetAny (), Ipv6Prefix ((uint8_t)0), defaultRouter, interface, network); + + Ptr aPrefix = CreateObject (m_node, interface, network, mask, preferredTime, validTime, defaultRouter); + aPrefix->StartPreferredTimer (); + + m_prefixes.push_back (aPrefix); } - else - { - NS_FATAL_ERROR ("Unknown method to make autoconfigured address for this kind of device."); - return; - } - - /* see if we have already the prefix */ - for (Ipv6AutoconfiguredPrefixListI it = m_prefixes.begin () ; it != m_prefixes.end () ; ++it) - { - if ((*it)->GetInterface () == interface && (*it)->GetPrefix () == network && (*it)->GetMask () == mask) - { - (*it)->StopPreferredTimer (); - (*it)->StopValidTimer (); - (*it)->StartPreferredTimer (); - return; - } - } - - /* no prefix found, add autoconfigured address and the prefix */ - NS_LOG_INFO ("Autoconfigured address is :" << address.GetAddress ()); - AddAddress (interface, address); - - /* add default router - * if a previous default route exists, the new ones is simply added - */ - GetRoutingProtocol ()->NotifyAddRoute (Ipv6Address::GetAny (), Ipv6Prefix ((uint8_t)0), defaultRouter, interface, network); - - Ptr aPrefix = CreateObject (m_node, interface, network, mask, preferredTime, validTime, defaultRouter); - aPrefix->StartPreferredTimer (); - - m_prefixes.push_back (aPrefix); - } } void Ipv6L3Protocol::RemoveAutoconfiguredAddress (uint32_t interface, Ipv6Address network, Ipv6Prefix mask, Ipv6Address defaultRouter) @@ -304,24 +304,24 @@ void Ipv6L3Protocol::RemoveAutoconfiguredAddress (uint32_t interface, Ipv6Addres Ipv6Address toFound = Ipv6Address::MakeAutoconfiguredAddress (Mac48Address::ConvertFrom (addr), network); for (i = 0 ; i < max ; i++) - { - if (iface->GetAddress (i).GetAddress () == toFound) { - RemoveAddress (interface, i); - break; + if (iface->GetAddress (i).GetAddress () == toFound) + { + RemoveAddress (interface, i); + break; + } } - } /* remove from list of autoconfigured address */ for (Ipv6AutoconfiguredPrefixListI it = m_prefixes.begin () ; it != m_prefixes.end () ; ++it) - { - if ((*it)->GetInterface () == interface && (*it)->GetPrefix () == network && (*it)->GetMask () == mask) { - *it = 0; - m_prefixes.erase (it); - break; + if ((*it)->GetInterface () == interface && (*it)->GetPrefix () == network && (*it)->GetMask () == mask) + { + *it = 0; + m_prefixes.erase (it); + break; + } } - } GetRoutingProtocol ()->NotifyRemoveRoute (Ipv6Address::GetAny (), Ipv6Prefix ((uint8_t)0), defaultRouter, interface, network); } @@ -333,9 +333,9 @@ bool Ipv6L3Protocol::AddAddress (uint32_t i, Ipv6InterfaceAddress address) bool ret = interface->AddAddress (address); if (m_routingProtocol != 0) - { - m_routingProtocol->NotifyAddAddress (i, address); - } + { + m_routingProtocol->NotifyAddAddress (i, address); + } return ret; } @@ -358,15 +358,15 @@ bool Ipv6L3Protocol::RemoveAddress (uint32_t i, uint32_t addressIndex) NS_LOG_FUNCTION (this << i << addressIndex); Ptr interface = GetInterface (i); Ipv6InterfaceAddress address = interface->RemoveAddress (addressIndex); - + if (address != Ipv6InterfaceAddress ()) - { - if (m_routingProtocol != 0) { - m_routingProtocol->NotifyRemoveAddress (i, address); + if (m_routingProtocol != 0) + { + m_routingProtocol->NotifyRemoveAddress (i, address); + } + return true; } - return true; - } return false; } @@ -402,26 +402,26 @@ void Ipv6L3Protocol::SetUp (uint32_t i) { NS_LOG_FUNCTION (this << i); Ptr interface = GetInterface (i); - + interface->SetUp (); - + if (m_routingProtocol != 0) - { - m_routingProtocol->NotifyInterfaceUp (i); - } + { + m_routingProtocol->NotifyInterfaceUp (i); + } } void Ipv6L3Protocol::SetDown (uint32_t i) { NS_LOG_FUNCTION (this << i); Ptr interface = GetInterface (i); - + interface->SetDown (); - + if (m_routingProtocol != 0) - { - m_routingProtocol->NotifyInterfaceDown (i); - } + { + m_routingProtocol->NotifyInterfaceDown (i); + } } void Ipv6L3Protocol::SetupLoopback () @@ -433,18 +433,18 @@ void Ipv6L3Protocol::SetupLoopback () /* see if we have already an loopback NetDevice */ for (i = 0 ; i < m_node->GetNDevices () ; i++) - { - if (device = DynamicCast (m_node->GetDevice (i))) { - break; + if (device = DynamicCast (m_node->GetDevice (i))) + { + break; + } } - } if (device == 0) - { - device = CreateObject (); - m_node->AddDevice (device); - } + { + device = CreateObject (); + m_node->AddDevice (device); + } interface->SetDevice (device); interface->SetNode (m_node); @@ -454,11 +454,11 @@ void Ipv6L3Protocol::SetupLoopback () Ptr node = GetObject (); node->RegisterProtocolHandler (MakeCallback (&Ipv6L3Protocol::Receive, this), Ipv6L3Protocol::PROT_NUMBER, device); interface->SetUp (); - + if (m_routingProtocol != 0) - { - m_routingProtocol->NotifyInterfaceUp (index); - } + { + m_routingProtocol->NotifyInterfaceUp (index); + } } bool Ipv6L3Protocol::IsForwarding (uint32_t i) const @@ -483,9 +483,9 @@ void Ipv6L3Protocol::SetIpForward (bool forward) m_ipForward = forward; for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin () ; it != m_interfaces.end (); it++) - { - (*it)->SetForwarding (forward); - } + { + (*it)->SetForwarding (forward); + } } bool Ipv6L3Protocol::GetIpForward () const @@ -499,15 +499,15 @@ void Ipv6L3Protocol::NotifyNewAggregate () NS_LOG_FUNCTION_NOARGS (); if (m_node == 0) - { - Ptr node = this->GetObject (); - // verify that it's a valid node and that - // the node has not been set before - if (node != 0) { - this->SetNode (node); + Ptr node = this->GetObject (); + // verify that it's a valid node and that + // the node has not been set before + if (node != 0) + { + this->SetNode (node); + } } - } Object::NotifyNewAggregate (); } @@ -536,12 +536,12 @@ Ptr Ipv6L3Protocol::GetProtocol (int protocolNumber) const NS_LOG_FUNCTION (this << protocolNumber); for (L4List_t::const_iterator i = m_protocols.begin () ; i != m_protocols.end () ; ++i) - { - if ((*i)->GetProtocolNumber () == protocolNumber) { - return *i; + if ((*i)->GetProtocolNumber () == protocolNumber) + { + return *i; + } } - } return 0; } @@ -557,30 +557,30 @@ Ptr Ipv6L3Protocol::CreateRawSocket () void Ipv6L3Protocol::DeleteRawSocket (Ptr socket) { NS_LOG_FUNCTION (this << socket); - + for (SocketList::iterator it = m_sockets.begin () ; it != m_sockets.end () ; ++it) - { - if ((*it) == socket) { - m_sockets.erase (it); - return; + if ((*it) == socket) + { + m_sockets.erase (it); + return; + } } - } } Ptr Ipv6L3Protocol::GetIcmpv6 () const { NS_LOG_FUNCTION_NOARGS (); Ptr protocol = GetProtocol (Icmpv6L4Protocol::GetStaticProtocolNumber ()); - + if (protocol) - { - return protocol->GetObject (); - } + { + return protocol->GetObject (); + } else - { - return 0; - } + { + return 0; + } } void Ipv6L3Protocol::SetDefaultTtl (uint8_t ttl) @@ -596,11 +596,11 @@ void Ipv6L3Protocol::Send (Ptr packet, Ipv6Address source, Ipv6Address d uint8_t ttl = m_defaultTtl; SocketIpTtlTag tag; bool found = packet->RemovePacketTag (tag); - + if (found) - { - ttl = tag.GetTtl (); - } + { + ttl = tag.GetTtl (); + } /* Handle 3 cases: * 1) Packet is passed in with a route entry @@ -610,22 +610,22 @@ void Ipv6L3Protocol::Send (Ptr packet, Ipv6Address source, Ipv6Address d /* 1) */ if (route && route->GetGateway () != Ipv6Address::GetZero ()) - { - NS_LOG_LOGIC ("Ipv6L3Protocol::Send case 1: passed in with a route"); - hdr = BuildHeader (source, destination, protocol, packet->GetSize (), ttl); - SendRealOut (route, packet, hdr); - return; - } - + { + NS_LOG_LOGIC ("Ipv6L3Protocol::Send case 1: passed in with a route"); + hdr = BuildHeader (source, destination, protocol, packet->GetSize (), ttl); + SendRealOut (route, packet, hdr); + return; + } + /* 2) */ if (route && route->GetGateway () == Ipv6Address::GetZero ()) - { - NS_LOG_LOGIC ("Ipv6L3Protocol::Send case 1: probably sent to machine on same IPv6 network"); - /* NS_FATAL_ERROR ("This case is not yet implemented"); */ - hdr = BuildHeader (source, destination, protocol, packet->GetSize (), ttl); - SendRealOut (route, packet, hdr); - return; - } + { + NS_LOG_LOGIC ("Ipv6L3Protocol::Send case 1: probably sent to machine on same IPv6 network"); + /* NS_FATAL_ERROR ("This case is not yet implemented"); */ + hdr = BuildHeader (source, destination, protocol, packet->GetSize (), ttl); + SendRealOut (route, packet, hdr); + return; + } /* 3) */ NS_LOG_LOGIC ("Ipv6L3Protocol::Send case 3: passed in with no route " << destination); @@ -642,23 +642,23 @@ void Ipv6L3Protocol::Send (Ptr packet, Ipv6Address source, Ipv6Address d destination.IsAllRoutersMulticast() || destination.IsAllHostsMulticast() || destination.IsSolicitedMulticast()) - { - int32_t index = GetInterfaceForAddress (source); - NS_ASSERT (index >= 0); - oif = GetNetDevice(index); - } + { + int32_t index = GetInterfaceForAddress (source); + NS_ASSERT (index >= 0); + oif = GetNetDevice(index); + } newRoute = m_routingProtocol->RouteOutput (packet, hdr, oif, err); if (newRoute) - { - SendRealOut (newRoute, packet, hdr); - } + { + SendRealOut (newRoute, packet, hdr); + } else - { - NS_LOG_WARN ("No route to host, drop!"); - m_dropTrace (hdr, packet, DROP_NO_ROUTE, GetInterfaceForDevice(oif)); - } + { + NS_LOG_WARN ("No route to host, drop!"); + m_dropTrace (hdr, packet, DROP_NO_ROUTE, GetInterfaceForDevice(oif)); + } } void Ipv6L3Protocol::Receive (Ptr device, Ptr p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType) @@ -668,39 +668,39 @@ void Ipv6L3Protocol::Receive (Ptr device, Ptr p, uint16 uint32_t interface = 0; Ptr packet = p->Copy (); Ptr ipv6Interface = 0; - - for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin () ; it != m_interfaces.end () ; it++) - { - ipv6Interface = *it; - if (ipv6Interface->GetDevice () == device) + for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin () ; it != m_interfaces.end () ; it++) { - if (ipv6Interface->IsUp ()) - { - m_rxTrace (packet, interface); - break; - } - else - { - NS_LOG_LOGIC ("Dropping received packet-- interface is down"); - Ipv6Header hdr; - packet->RemoveHeader (hdr); - m_dropTrace (hdr, packet, DROP_INTERFACE_DOWN, interface); - return; - } + ipv6Interface = *it; + + if (ipv6Interface->GetDevice () == device) + { + if (ipv6Interface->IsUp ()) + { + m_rxTrace (packet, interface); + break; + } + else + { + NS_LOG_LOGIC ("Dropping received packet-- interface is down"); + Ipv6Header hdr; + packet->RemoveHeader (hdr); + m_dropTrace (hdr, packet, DROP_INTERFACE_DOWN, interface); + return; + } + } + interface++; } - interface++; - } Ipv6Header hdr; packet->RemoveHeader (hdr); /* forward up to IPv6 raw sockets */ for (SocketList::iterator it = m_sockets.begin () ; it != m_sockets.end () ; ++it) - { - Ptr socket = *it; - socket->ForwardUp (packet, hdr, device); - } + { + Ptr socket = *it; + socket->ForwardUp (packet, hdr, device); + } Ptr ipv6ExtensionDemux = m_node->GetObject(); Ptr ipv6Extension = 0; @@ -708,25 +708,25 @@ void Ipv6L3Protocol::Receive (Ptr device, Ptr p, uint16 bool isDropped = false; if (nextHeader == Ipv6Header::IPV6_EXT_HOP_BY_HOP) - { - ipv6Extension = ipv6ExtensionDemux->GetExtension (nextHeader); - - if (ipv6Extension) { - ipv6Extension->Process (packet, 0, hdr, hdr.GetDestinationAddress (), (uint8_t *)0, isDropped); - } + ipv6Extension = ipv6ExtensionDemux->GetExtension (nextHeader); - if (isDropped) - { - return; + if (ipv6Extension) + { + ipv6Extension->Process (packet, 0, hdr, hdr.GetDestinationAddress (), (uint8_t *)0, isDropped); + } + + if (isDropped) + { + return; + } } - } m_routingProtocol->RouteInput (packet, hdr, device, - MakeCallback (&Ipv6L3Protocol::IpForward, this), - MakeCallback (&Ipv6L3Protocol::IpMulticastForward, this), - MakeCallback (&Ipv6L3Protocol::LocalDeliver, this), - MakeCallback (&Ipv6L3Protocol::RouteInputError, this) + MakeCallback (&Ipv6L3Protocol::IpForward, this), + MakeCallback (&Ipv6L3Protocol::IpMulticastForward, this), + MakeCallback (&Ipv6L3Protocol::LocalDeliver, this), + MakeCallback (&Ipv6L3Protocol::RouteInputError, this) ); } @@ -735,15 +735,15 @@ void Ipv6L3Protocol::SendRealOut (Ptr route, Ptr packet, Ipv6 NS_LOG_FUNCTION (this << route << packet << ipHeader); if (!route) - { - NS_LOG_LOGIC ("No route to host, drop!."); - return; - } + { + NS_LOG_LOGIC ("No route to host, drop!."); + return; + } Ptr dev = route->GetOutputDevice (); int32_t interface = GetInterfaceForDevice (dev); NS_ASSERT (interface >= 0); - + Ptr outInterface = GetInterface (interface); NS_LOG_LOGIC ("Send via NetDevice ifIndex " << dev->GetIfIndex () << " Ipv6InterfaceIndex " << interface); @@ -751,113 +751,113 @@ void Ipv6L3Protocol::SendRealOut (Ptr route, Ptr packet, Ipv6 std::list > fragments; if (packet->GetSize () > (size_t)(dev->GetMtu () + 40)) /* 40 => size of IPv6 header */ - { - // Router => drop - if (m_ipForward) { - return; + // Router => drop + if (m_ipForward) + { + return; + } + + Ptr ipv6ExtensionDemux = m_node->GetObject (); + + packet->AddHeader (ipHeader); + + // To get specific method GetFragments from Ipv6ExtensionFragmentation + Ipv6ExtensionFragment *ipv6Fragment = dynamic_cast(PeekPointer (ipv6ExtensionDemux->GetExtension (Ipv6Header::IPV6_EXT_FRAGMENTATION))); + ipv6Fragment->GetFragments (packet, outInterface->GetDevice ()->GetMtu (), fragments); } - Ptr ipv6ExtensionDemux = m_node->GetObject (); - - packet->AddHeader (ipHeader); - - // To get specific method GetFragments from Ipv6ExtensionFragmentation - Ipv6ExtensionFragment *ipv6Fragment = dynamic_cast(PeekPointer (ipv6ExtensionDemux->GetExtension (Ipv6Header::IPV6_EXT_FRAGMENTATION))); - ipv6Fragment->GetFragments (packet, outInterface->GetDevice ()->GetMtu (), fragments); - } - if (!route->GetGateway ().IsEqual (Ipv6Address::GetAny ())) - { - if (outInterface->IsUp ()) { - NS_LOG_LOGIC ("Send to gateway " << route->GetGateway ()); - - if (fragments.size () != 0) - { - std::ostringstream oss; - - /* IPv6 header is already added in fragments */ - for (std::list >::const_iterator it = fragments.begin (); it != fragments.end (); it++) + if (outInterface->IsUp ()) { - m_txTrace (*it, interface); - outInterface->Send (*it, route->GetGateway ()); + NS_LOG_LOGIC ("Send to gateway " << route->GetGateway ()); + + if (fragments.size () != 0) + { + std::ostringstream oss; + + /* IPv6 header is already added in fragments */ + for (std::list >::const_iterator it = fragments.begin (); it != fragments.end (); it++) + { + m_txTrace (*it, interface); + outInterface->Send (*it, route->GetGateway ()); + } + } + else + { + packet->AddHeader (ipHeader); + m_txTrace (packet, interface); + outInterface->Send (packet, route->GetGateway ()); + } } - } else - { - packet->AddHeader (ipHeader); - m_txTrace (packet, interface); - outInterface->Send (packet, route->GetGateway ()); - } + { + NS_LOG_LOGIC ("Dropping-- outgoing interface is down: " << route->GetGateway ()); + m_dropTrace (ipHeader, packet, DROP_INTERFACE_DOWN, interface); + } } - else - { - NS_LOG_LOGIC ("Dropping-- outgoing interface is down: " << route->GetGateway ()); - m_dropTrace (ipHeader, packet, DROP_INTERFACE_DOWN, interface); - } - } else - { - if (outInterface->IsUp ()) { - NS_LOG_LOGIC ("Send to destination " << ipHeader.GetDestinationAddress ()); - - if (fragments.size () != 0) - { - std::ostringstream oss; - - /* IPv6 header is already added in fragments */ - for (std::list >::const_iterator it = fragments.begin (); it != fragments.end (); it++) + if (outInterface->IsUp ()) { - m_txTrace (*it, interface); - outInterface->Send (*it, ipHeader.GetDestinationAddress ()); + NS_LOG_LOGIC ("Send to destination " << ipHeader.GetDestinationAddress ()); + + if (fragments.size () != 0) + { + std::ostringstream oss; + + /* IPv6 header is already added in fragments */ + for (std::list >::const_iterator it = fragments.begin (); it != fragments.end (); it++) + { + m_txTrace (*it, interface); + outInterface->Send (*it, ipHeader.GetDestinationAddress ()); + } + } + else + { + packet->AddHeader (ipHeader); + m_txTrace (packet, interface); + outInterface->Send (packet, ipHeader.GetDestinationAddress ()); + } } - } else - { - packet->AddHeader (ipHeader); - m_txTrace (packet, interface); - outInterface->Send (packet, ipHeader.GetDestinationAddress ()); - } + { + NS_LOG_LOGIC ("Dropping-- outgoing interface is down: " << ipHeader.GetDestinationAddress ()); + m_dropTrace (ipHeader, packet, DROP_INTERFACE_DOWN, interface); + } } - else - { - NS_LOG_LOGIC ("Dropping-- outgoing interface is down: " << ipHeader.GetDestinationAddress ()); - m_dropTrace (ipHeader, packet, DROP_INTERFACE_DOWN, interface); - } - } } void Ipv6L3Protocol::IpForward (Ptr rtentry, Ptr p, const Ipv6Header& header) { NS_LOG_FUNCTION (this << rtentry << p << header); NS_LOG_LOGIC ("Forwarding logic for node: " << m_node->GetId ()); - + // Forwarding Ipv6Header ipHeader = header; Ptr packet = p->Copy (); ipHeader.SetHopLimit (ipHeader.GetHopLimit () - 1); if (ipHeader.GetSourceAddress ().IsLinkLocal ()) - { - /* no forward for link-local address */ - return; - } - - if (ipHeader.GetHopLimit () == 0) - { - NS_LOG_WARN ("TTL exceeded. Drop."); - m_dropTrace (ipHeader, packet, DROP_TTL_EXPIRED, 0); - // Do not reply to ICMPv6 or to multicast IPv6 address - if (ipHeader.GetNextHeader () != Icmpv6L4Protocol::PROT_NUMBER && - ipHeader.GetDestinationAddress ().IsMulticast () == false) { - packet->AddHeader (ipHeader); - GetIcmpv6 ()->SendErrorTimeExceeded (packet, ipHeader.GetSourceAddress (), Icmpv6Header::ICMPV6_HOPLIMIT); + /* no forward for link-local address */ + return; + } + + if (ipHeader.GetHopLimit () == 0) + { + NS_LOG_WARN ("TTL exceeded. Drop."); + m_dropTrace (ipHeader, packet, DROP_TTL_EXPIRED, 0); + // Do not reply to ICMPv6 or to multicast IPv6 address + if (ipHeader.GetNextHeader () != Icmpv6L4Protocol::PROT_NUMBER && + ipHeader.GetDestinationAddress ().IsMulticast () == false) + { + packet->AddHeader (ipHeader); + GetIcmpv6 ()->SendErrorTimeExceeded (packet, ipHeader.GetSourceAddress (), Icmpv6Header::ICMPV6_HOPLIMIT); + } + return; } - return; - } /* ICMPv6 Redirect */ @@ -867,32 +867,32 @@ void Ipv6L3Protocol::IpForward (Ptr rtentry, Ptr p, con */ if ((!rtentry->GetGateway ().IsAny () && rtentry->GetGateway ().CombinePrefix (Ipv6Prefix (64)) == header.GetSourceAddress ().CombinePrefix (Ipv6Prefix (64))) || (rtentry->GetDestination ().CombinePrefix (Ipv6Prefix (64)) == header.GetSourceAddress ().CombinePrefix (Ipv6Prefix (64)))) - { - NS_LOG_LOGIC ("ICMPv6 redirect!"); - Ptr icmpv6 = GetIcmpv6 (); - Address hardwareTarget; - Ipv6Address dst = header.GetDestinationAddress (); - Ipv6Address src = header.GetSourceAddress (); - Ipv6Address target = rtentry->GetGateway (); - Ptr copy = p->Copy (); - - if (target.IsAny ()) { - target = dst; + NS_LOG_LOGIC ("ICMPv6 redirect!"); + Ptr icmpv6 = GetIcmpv6 (); + Address hardwareTarget; + Ipv6Address dst = header.GetDestinationAddress (); + Ipv6Address src = header.GetSourceAddress (); + Ipv6Address target = rtentry->GetGateway (); + Ptr copy = p->Copy (); + + if (target.IsAny ()) + { + target = dst; + } + + copy->AddHeader (header); + + if (icmpv6->Lookup (target, rtentry->GetOutputDevice (), 0, &hardwareTarget)) + { + icmpv6->SendRedirection (copy, src, target, dst, hardwareTarget); + } + else + { + icmpv6->SendRedirection (copy, src, target, dst, Address ()); + } } - copy->AddHeader (header); - - if (icmpv6->Lookup (target, rtentry->GetOutputDevice (), 0, &hardwareTarget)) - { - icmpv6->SendRedirection (copy, src, target, dst, hardwareTarget); - } - else - { - icmpv6->SendRedirection (copy, src, target, dst, Address ()); - } - } - SendRealOut (rtentry, packet, ipHeader); } @@ -904,29 +904,29 @@ void Ipv6L3Protocol::IpMulticastForward (Ptr mrtentry, PtrGetOutputTtl (i) < Ipv6MulticastRoute::MAX_TTL) { - Ptr packet = p->Copy (); - Ipv6Header h = header; - h.SetHopLimit (header.GetHopLimit () - 1); - if (h.GetHopLimit () == 0) - { - NS_LOG_WARN ("TTL exceeded. Drop."); - m_dropTrace (header, packet, DROP_TTL_EXPIRED, i); - return; - } + if (mrtentry->GetOutputTtl (i) < Ipv6MulticastRoute::MAX_TTL) + { + Ptr packet = p->Copy (); + Ipv6Header h = header; + h.SetHopLimit (header.GetHopLimit () - 1); + if (h.GetHopLimit () == 0) + { + NS_LOG_WARN ("TTL exceeded. Drop."); + m_dropTrace (header, packet, DROP_TTL_EXPIRED, i); + return; + } - NS_LOG_LOGIC ("Forward multicast via interface " << i); - Ptr rtentry = Create (); - rtentry->SetSource (h.GetSourceAddress ()); - rtentry->SetDestination (h.GetDestinationAddress ()); - rtentry->SetGateway (Ipv6Address::GetAny ()); - rtentry->SetOutputDevice (GetNetDevice (i)); - SendRealOut (rtentry, packet, h); - return; + NS_LOG_LOGIC ("Forward multicast via interface " << i); + Ptr rtentry = Create (); + rtentry->SetSource (h.GetSourceAddress ()); + rtentry->SetDestination (h.GetDestinationAddress ()); + rtentry->SetGateway (Ipv6Address::GetAny ()); + rtentry->SetOutputDevice (GetNetDevice (i)); + SendRealOut (rtentry, packet, h); + return; + } } - } } void Ipv6L3Protocol::LocalDeliver (Ptr packet, Ipv6Header const& ip, uint32_t iif) @@ -944,76 +944,76 @@ void Ipv6L3Protocol::LocalDeliver (Ptr packet, Ipv6Header const& i /* process hop-by-hop extension first if exists */ if (nextHeader == Ipv6Header::IPV6_EXT_HOP_BY_HOP) - { - const uint8_t *buff = p->PeekData (); + { + const uint8_t *buff = p->PeekData (); - nextHeader = *buff; - nextHeaderPosition = *(buff + 1); - } + nextHeader = *buff; + nextHeaderPosition = *(buff + 1); + } /* process all the extensions found and the layer 4 protocol */ do { - /* it return 0 for non-extension (i.e. layer 4 protocol) */ - ipv6Extension = ipv6ExtensionDemux->GetExtension (nextHeader); + /* it return 0 for non-extension (i.e. layer 4 protocol) */ + ipv6Extension = ipv6ExtensionDemux->GetExtension (nextHeader); - if (ipv6Extension) - { - nextHeaderPosition += ipv6Extension->Process (p, nextHeaderPosition, ip, dst, &nextHeader, isDropped); - - if (isDropped) - { - return; - } - } - else - { - protocol = GetProtocol (nextHeader); - // For ICMPv6 Error packets - Ptr malformedPacket = packet->Copy (); - malformedPacket->AddHeader (ip); - - if (!protocol) - { - NS_LOG_LOGIC ("Unknown Next Header. Drop!"); - - if (nextHeaderPosition == 0) + if (ipv6Extension) { - GetIcmpv6 ()->SendErrorParameterError (malformedPacket, dst, Icmpv6Header::ICMPV6_UNKNOWN_NEXT_HEADER, 40); + nextHeaderPosition += ipv6Extension->Process (p, nextHeaderPosition, ip, dst, &nextHeader, isDropped); + + if (isDropped) + { + return; + } } - else - { - GetIcmpv6 ()->SendErrorParameterError (malformedPacket, dst, Icmpv6Header::ICMPV6_UNKNOWN_NEXT_HEADER, ip.GetSerializedSize () + nextHeaderPosition); - } - m_dropTrace (ip, p, DROP_UNKNOWN_PROTOCOL, iif); - break; - } else - { - p->RemoveAtStart (nextHeaderPosition); - /* protocol->Receive (p, src, dst, incomingInterface); */ - - /* L4 protocol */ - Ptr copy = p->Copy (); - enum Ipv6L4Protocol::RxStatus_e status = protocol->Receive (p, ip.GetSourceAddress (), ip.GetDestinationAddress (), GetInterface (iif)); - - switch (status) { - case Ipv6L4Protocol::RX_OK: - break; - case Ipv6L4Protocol::RX_CSUM_FAILED: - break; - case Ipv6L4Protocol::RX_ENDPOINT_UNREACH: - if (ip.GetDestinationAddress ().IsMulticast ()) - { - /* do not rely on multicast address */ - break; - } + protocol = GetProtocol (nextHeader); + // For ICMPv6 Error packets + Ptr malformedPacket = packet->Copy (); + malformedPacket->AddHeader (ip); - copy->AddHeader (ip); - GetIcmpv6 ()->SendErrorDestinationUnreachable (copy, ip.GetSourceAddress (), Icmpv6Header::ICMPV6_PORT_UNREACHABLE); + if (!protocol) + { + NS_LOG_LOGIC ("Unknown Next Header. Drop!"); + + if (nextHeaderPosition == 0) + { + GetIcmpv6 ()->SendErrorParameterError (malformedPacket, dst, Icmpv6Header::ICMPV6_UNKNOWN_NEXT_HEADER, 40); + } + else + { + GetIcmpv6 ()->SendErrorParameterError (malformedPacket, dst, Icmpv6Header::ICMPV6_UNKNOWN_NEXT_HEADER, ip.GetSerializedSize () + nextHeaderPosition); + } + m_dropTrace (ip, p, DROP_UNKNOWN_PROTOCOL, iif); + break; + } + else + { + p->RemoveAtStart (nextHeaderPosition); + /* protocol->Receive (p, src, dst, incomingInterface); */ + + /* L4 protocol */ + Ptr copy = p->Copy (); + enum Ipv6L4Protocol::RxStatus_e status = protocol->Receive (p, ip.GetSourceAddress (), ip.GetDestinationAddress (), GetInterface (iif)); + + switch (status) + { + case Ipv6L4Protocol::RX_OK: + break; + case Ipv6L4Protocol::RX_CSUM_FAILED: + break; + case Ipv6L4Protocol::RX_ENDPOINT_UNREACH: + if (ip.GetDestinationAddress ().IsMulticast ()) + { + /* do not rely on multicast address */ + break; + } + + copy->AddHeader (ip); + GetIcmpv6 ()->SendErrorDestinationUnreachable (copy, ip.GetSourceAddress (), Icmpv6Header::ICMPV6_PORT_UNREACHABLE); + } + } } - } - } } while (ipv6Extension); } diff --git a/src/internet-stack/ipv6-l3-protocol.h b/src/internet-stack/ipv6-l3-protocol.h index 5f0208d8c..d5bf5d189 100644 --- a/src/internet-stack/ipv6-l3-protocol.h +++ b/src/internet-stack/ipv6-l3-protocol.h @@ -57,461 +57,461 @@ class Ipv6AutoconfiguredPrefix; */ class Ipv6L3Protocol : public Ipv6 { - public: - /** - * \brief Get the type ID of this class. - * \return type ID - */ - static TypeId GetTypeId (); +public: + /** + * \brief Get the type ID of this class. + * \return type ID + */ + static TypeId GetTypeId (); - /** - * \brief The protocol number for IPv6 (0x86DD). - */ - static const uint16_t PROT_NUMBER; + /** + * \brief The protocol number for IPv6 (0x86DD). + */ + static const uint16_t PROT_NUMBER; - /** - * \enum DropReason - * \brief Reason why a packet has been dropped. - */ - enum DropReason - { - DROP_TTL_EXPIRED = 1, /**< Packet TTL has expired */ - DROP_NO_ROUTE, /**< No route to host */ - DROP_INTERFACE_DOWN, /**< Interface is down so can not send packet */ - DROP_ROUTE_ERROR, /**< Route error */ - DROP_UNKNOWN_PROTOCOL, /**< Unkown L4 protocol */ - }; - - /** - * \brief Constructor. - */ - Ipv6L3Protocol (); + /** + * \enum DropReason + * \brief Reason why a packet has been dropped. + */ + enum DropReason + { + DROP_TTL_EXPIRED = 1, /**< Packet TTL has expired */ + DROP_NO_ROUTE, /**< No route to host */ + DROP_INTERFACE_DOWN, /**< Interface is down so can not send packet */ + DROP_ROUTE_ERROR, /**< Route error */ + DROP_UNKNOWN_PROTOCOL, /**< Unkown L4 protocol */ + }; - /** - * \brief Destructor. - */ - virtual ~Ipv6L3Protocol (); - - /** - * \brief Set node for this stack. - * \param node node to set - */ - void SetNode (Ptr node); + /** + * \brief Constructor. + */ + Ipv6L3Protocol (); - /** - * \brief Add an L4 protocol. - * \param protocol L4 protocol - */ - void Insert (Ptr protocol); + /** + * \brief Destructor. + */ + virtual ~Ipv6L3Protocol (); - /** - * \brief Remove an L4 protocol. - * \param protocol L4 protocol to remove - */ - void Remove (Ptr protocol); + /** + * \brief Set node for this stack. + * \param node node to set + */ + void SetNode (Ptr node); - /** - * \brief Get L4 protocol by protocol number. - * \param protocolNumber protocol number - * \return corresponding Ipv6L4Protocol or 0 if not found - */ - Ptr GetProtocol (int protocolNumber) const; + /** + * \brief Add an L4 protocol. + * \param protocol L4 protocol + */ + void Insert (Ptr protocol); - /** - * \brief Create raw IPv6 socket. - * \return newly raw socket - */ - Ptr CreateRawSocket (); + /** + * \brief Remove an L4 protocol. + * \param protocol L4 protocol to remove + */ + void Remove (Ptr protocol); - /** - * \brief Remove raw IPv6 socket. - * \param socket socket to remove - */ - void DeleteRawSocket (Ptr socket); + /** + * \brief Get L4 protocol by protocol number. + * \param protocolNumber protocol number + * \return corresponding Ipv6L4Protocol or 0 if not found + */ + Ptr GetProtocol (int protocolNumber) const; - /** - * \brief Set the default TTL. - * \param ttl TTL to set - */ - void SetDefaultTtl (uint8_t ttl); + /** + * \brief Create raw IPv6 socket. + * \return newly raw socket + */ + Ptr CreateRawSocket (); - /** - * \brief Receive method when a packet arrive in the stack. - * This method removes IPv6 header and forward up to L4 protocol. - * - * \param device network device - * \param p the packet - * \param protocol next header value - * \param from address of the correspondant - * \param to address of the destination - * \param packetType type of the packet - */ - void Receive (Ptr device, Ptr p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType); + /** + * \brief Remove raw IPv6 socket. + * \param socket socket to remove + */ + void DeleteRawSocket (Ptr socket); - /** - * \brief Higher-level layers call this method to send a packet - * down the stack to the MAC and PHY layers. - * - * \param packet packet to send - * \param source source address of packet - * \param destination address of packet - * \param protocol number of packet - * \param route route to take - */ - void Send (Ptr packet, Ipv6Address source, Ipv6Address destination, uint8_t protocol, Ptr route); - - /** - * \brief Set routing protocol for this stack. - * \param routingProtocol IPv6 routing protocol to set - */ - void SetRoutingProtocol (Ptr routingProtocol); + /** + * \brief Set the default TTL. + * \param ttl TTL to set + */ + void SetDefaultTtl (uint8_t ttl); - /** - * \brief Get current routing protocol used. - * \return routing protocol - */ - Ptr GetRoutingProtocol () const; + /** + * \brief Receive method when a packet arrive in the stack. + * This method removes IPv6 header and forward up to L4 protocol. + * + * \param device network device + * \param p the packet + * \param protocol next header value + * \param from address of the correspondant + * \param to address of the destination + * \param packetType type of the packet + */ + void Receive (Ptr device, Ptr p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType); - /** - * \brief Add IPv6 interface for a device. - * \param device net device - * \return interface index - */ - uint32_t AddInterface (Ptr device); + /** + * \brief Higher-level layers call this method to send a packet + * down the stack to the MAC and PHY layers. + * + * \param packet packet to send + * \param source source address of packet + * \param destination address of packet + * \param protocol number of packet + * \param route route to take + */ + void Send (Ptr packet, Ipv6Address source, Ipv6Address destination, uint8_t protocol, Ptr route); - /** - * \brief Get an interface. - * \param i interface index - * \return IPv6 interface pointer - */ - Ptr GetInterface (uint32_t i) const; - - /** - * \brief Get current number of interface on this stack. - * \return number of interface registered - */ - uint32_t GetNInterfaces () const; + /** + * \brief Set routing protocol for this stack. + * \param routingProtocol IPv6 routing protocol to set + */ + void SetRoutingProtocol (Ptr routingProtocol); - /** - * \brief Get interface index which has specified IPv6 address - * \param addr IPv6 address - * \return interface index or -1 if not found - */ - int32_t GetInterfaceForAddress (Ipv6Address addr) const; + /** + * \brief Get current routing protocol used. + * \return routing protocol + */ + Ptr GetRoutingProtocol () const; - /** - * \brief Get interface index which match specified address/prefix. - * \param addr IPv6 address - * \param mask IPv6 prefix (mask) - * \return interface index or -1 if not found - */ - int32_t GetInterfaceForPrefix (Ipv6Address addr, Ipv6Prefix mask) const; + /** + * \brief Add IPv6 interface for a device. + * \param device net device + * \return interface index + */ + uint32_t AddInterface (Ptr device); - /** - * \brief Get interface index which is on a specified net device. - * \param device net device - */ - int32_t GetInterfaceForDevice (Ptr device) const; + /** + * \brief Get an interface. + * \param i interface index + * \return IPv6 interface pointer + */ + Ptr GetInterface (uint32_t i) const; - /** - * \brief Add an address on interface. - * \param i interface index - * \param address to add - */ - bool AddAddress (uint32_t i, Ipv6InterfaceAddress address); + /** + * \brief Get current number of interface on this stack. + * \return number of interface registered + */ + uint32_t GetNInterfaces () const; - /** - * \brief Get an address. - * \param interfaceIndex interface index - * \param addressIndex address index on the interface - * \return Ipv6InterfaceAddress or assert if not found - */ - Ipv6InterfaceAddress GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) const; + /** + * \brief Get interface index which has specified IPv6 address + * \param addr IPv6 address + * \return interface index or -1 if not found + */ + int32_t GetInterfaceForAddress (Ipv6Address addr) const; - /** - * \brief Get number of address for an interface. - * \param interface interface index - * \return number of address - */ - uint32_t GetNAddresses (uint32_t interface) const; + /** + * \brief Get interface index which match specified address/prefix. + * \param addr IPv6 address + * \param mask IPv6 prefix (mask) + * \return interface index or -1 if not found + */ + int32_t GetInterfaceForPrefix (Ipv6Address addr, Ipv6Prefix mask) const; - /** - * \brief Remove an address from an interface. - * \param interfaceIndex interface index - * \param addressIndex address index on the interface - */ - bool RemoveAddress (uint32_t interfaceIndex, uint32_t addressIndex); - - /** - * \brief Set metric for an interface. - * \param i index - * \param metric - */ - void SetMetric (uint32_t i, uint16_t metric); + /** + * \brief Get interface index which is on a specified net device. + * \param device net device + */ + int32_t GetInterfaceForDevice (Ptr device) const; - /** - * \brief Get metric for an interface. - * \param i index - * \return metric - */ - uint16_t GetMetric (uint32_t i) const; + /** + * \brief Add an address on interface. + * \param i interface index + * \param address to add + */ + bool AddAddress (uint32_t i, Ipv6InterfaceAddress address); - /** - * \brief Get MTU for an interface. - * \param i index - * \return MTU - */ - uint16_t GetMtu (uint32_t i) const; + /** + * \brief Get an address. + * \param interfaceIndex interface index + * \param addressIndex address index on the interface + * \return Ipv6InterfaceAddress or assert if not found + */ + Ipv6InterfaceAddress GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) const; - /** - * \brief Is specified interface up ? - * \param i interface index - */ - bool IsUp (uint32_t i) const; + /** + * \brief Get number of address for an interface. + * \param interface interface index + * \return number of address + */ + uint32_t GetNAddresses (uint32_t interface) const; - /** - * \brief Set an interface up. - * \param i interface index - */ - void SetUp (uint32_t i); + /** + * \brief Remove an address from an interface. + * \param interfaceIndex interface index + * \param addressIndex address index on the interface + */ + bool RemoveAddress (uint32_t interfaceIndex, uint32_t addressIndex); - /** - * \brief set an interface down. - * \param i interface index - */ - void SetDown (uint32_t i); + /** + * \brief Set metric for an interface. + * \param i index + * \param metric + */ + void SetMetric (uint32_t i, uint16_t metric); - /** - * \brief Is interface allows forwarding ? - * \param i interface index - */ - bool IsForwarding (uint32_t i) const; + /** + * \brief Get metric for an interface. + * \param i index + * \return metric + */ + uint16_t GetMetric (uint32_t i) const; - /** - * \brief Enable or disable forwarding on interface - * \param i interface index - * \param val true = enable forwarding, false = disable - */ - void SetForwarding (uint32_t i, bool val); + /** + * \brief Get MTU for an interface. + * \param i index + * \return MTU + */ + uint16_t GetMtu (uint32_t i) const; - /** - * \brief Get device by index. - * \param i device index on this stack - * \return NetDevice pointer - */ - Ptr GetNetDevice (uint32_t i); - - /** - * \brief Get ICMPv6 protocol. - * \return Icmpv6L4Protocol pointer - */ - Ptr GetIcmpv6 () const; + /** + * \brief Is specified interface up ? + * \param i interface index + */ + bool IsUp (uint32_t i) const; - /** - * \brief Add an autoconfigured address with RA information. - * \param interface interface index - * \param network network prefix - * \param mask network mask - * \param flags flags of the prefix information option (home agent, ...) - * \param validTime valid time of the prefix - * \param preferredTime preferred time of the prefix - * \param defaultRouter default router address - */ - void AddAutoconfiguredAddress (uint32_t interface, Ipv6Address network, Ipv6Prefix mask, uint8_t flags, uint32_t validTime, uint32_t preferredTime, Ipv6Address defaultRouter = Ipv6Address::GetZero ()); + /** + * \brief Set an interface up. + * \param i interface index + */ + void SetUp (uint32_t i); - /** - * \brief Remove an autoconfigured address. - * - * Typically it is used when an autoconfigured address expires. - * \param interface interface index - * \param network network prefix - * \param mask network mask - * \param defaultRouter gateway - */ - void RemoveAutoconfiguredAddress (uint32_t interface, Ipv6Address network, Ipv6Prefix mask, Ipv6Address defaultRouter); + /** + * \brief set an interface down. + * \param i interface index + */ + void SetDown (uint32_t i); - /** - * \brief Register the IPv6 Extensions. - */ - virtual void RegisterExtensions (); + /** + * \brief Is interface allows forwarding ? + * \param i interface index + */ + bool IsForwarding (uint32_t i) const; - /** - * \brief Register the IPv6 Options. - */ - virtual void RegisterOptions (); + /** + * \brief Enable or disable forwarding on interface + * \param i interface index + * \param val true = enable forwarding, false = disable + */ + void SetForwarding (uint32_t i, bool val); - protected: - /** - * \brief Dispose object. - */ - virtual void DoDispose (); + /** + * \brief Get device by index. + * \param i device index on this stack + * \return NetDevice pointer + */ + Ptr GetNetDevice (uint32_t i); - /** - * \brief Notify other components connected to the node that a new stack member is now connected. - * - * This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together. - */ - virtual void NotifyNewAggregate (); + /** + * \brief Get ICMPv6 protocol. + * \return Icmpv6L4Protocol pointer + */ + Ptr GetIcmpv6 () const; - private: - /* for unit-tests */ - friend class Ipv6L3ProtocolTestCase; - friend class Ipv6ExtensionLooseRouting; + /** + * \brief Add an autoconfigured address with RA information. + * \param interface interface index + * \param network network prefix + * \param mask network mask + * \param flags flags of the prefix information option (home agent, ...) + * \param validTime valid time of the prefix + * \param preferredTime preferred time of the prefix + * \param defaultRouter default router address + */ + void AddAutoconfiguredAddress (uint32_t interface, Ipv6Address network, Ipv6Prefix mask, uint8_t flags, uint32_t validTime, uint32_t preferredTime, Ipv6Address defaultRouter = Ipv6Address::GetZero ()); - typedef std::list > Ipv6InterfaceList; - typedef std::list > SocketList; - typedef std::list > L4List_t; + /** + * \brief Remove an autoconfigured address. + * + * Typically it is used when an autoconfigured address expires. + * \param interface interface index + * \param network network prefix + * \param mask network mask + * \param defaultRouter gateway + */ + void RemoveAutoconfiguredAddress (uint32_t interface, Ipv6Address network, Ipv6Prefix mask, Ipv6Address defaultRouter); - typedef std::list< Ptr > Ipv6AutoconfiguredPrefixList; - typedef std::list< Ptr >::iterator Ipv6AutoconfiguredPrefixListI; + /** + * \brief Register the IPv6 Extensions. + */ + virtual void RegisterExtensions (); - /** - * \brief Callback to trace TX (transmission) packets. - */ - TracedCallback, uint32_t> m_txTrace; - - /** - * \brief Callback to trace RX (reception) packets. - */ - TracedCallback, uint32_t> m_rxTrace; - - /** - * \brief Callback to trace drop packets. - */ - TracedCallback, DropReason, uint32_t> m_dropTrace; + /** + * \brief Register the IPv6 Options. + */ + virtual void RegisterOptions (); - /** - * \brief Copy constructor. - * \param o object to copy - */ - Ipv6L3Protocol (const Ipv6L3Protocol& o); - - /** - * \brief Copy constructor. - * \param o object to copy - */ - Ipv6L3Protocol &operator = (const Ipv6L3Protocol& o); +protected: + /** + * \brief Dispose object. + */ + virtual void DoDispose (); - /** - * \brief Construct an IPv6 header. - * \param src source IPv6 address - * \param dst destination IPv6 address - * \param protocol L4 protocol - * \param payloadSize payload size - * \param ttl TTL - * \return newly created IPv6 header - */ - Ipv6Header BuildHeader (Ipv6Address src, Ipv6Address dst, uint8_t protocol, - uint16_t payloadSize, uint8_t ttl); + /** + * \brief Notify other components connected to the node that a new stack member is now connected. + * + * This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together. + */ + virtual void NotifyNewAggregate (); - /** - * \brief Send packet with route. - * \param route route - * \param packet packet to send - * \param ipHeader IPv6 header to add to the packet - */ - void SendRealOut (Ptr route, Ptr packet, Ipv6Header const& ipHeader); +private: + /* for unit-tests */ + friend class Ipv6L3ProtocolTestCase; + friend class Ipv6ExtensionLooseRouting; - /** - * \brief Forward a packet. - * \param rtentry route - * \param p packet to forward - * \param header IPv6 header to add to the packet - */ - void IpForward (Ptr rtentry, Ptr p, const Ipv6Header& header); + typedef std::list > Ipv6InterfaceList; + typedef std::list > SocketList; + typedef std::list > L4List_t; - /** - * \brief Forward a packet in multicast. - * \param mrtentry route - * \param p packet to forward - * \param header IPv6 header to add to the packet - */ - void IpMulticastForward (Ptr mrtentry, Ptr p, const Ipv6Header& header); + typedef std::list< Ptr > Ipv6AutoconfiguredPrefixList; + typedef std::list< Ptr >::iterator Ipv6AutoconfiguredPrefixListI; - /** - * \brief Deliver a packet. - * \param p packet delivered - * \param ip IPv6 header - * \param iif input interface packet was received - */ - void LocalDeliver (Ptr p, Ipv6Header const& ip, uint32_t iif); - - /** - * \brief Fallback when no route is found. - * \param p packet - * \param ipHeader IPv6 header - * \param sockErrno error number - */ - void RouteInputError (Ptr p, const Ipv6Header& ipHeader, Socket::SocketErrno sockErrno); + /** + * \brief Callback to trace TX (transmission) packets. + */ + TracedCallback, uint32_t> m_txTrace; - /** - * \brief Add an IPv6 interface to the stack. - * \param interface interface to add - * \return index of newly added interface - */ - uint32_t AddIpv6Interface (Ptr interface); + /** + * \brief Callback to trace RX (reception) packets. + */ + TracedCallback, uint32_t> m_rxTrace; - /** - * \brief Setup loopback interface. - */ - void SetupLoopback (); + /** + * \brief Callback to trace drop packets. + */ + TracedCallback, DropReason, uint32_t> m_dropTrace; - /** - * \brief Set IPv6 forwarding state. - * \param forward IPv6 forwarding enabled or not - */ - virtual void SetIpForward (bool forward); + /** + * \brief Copy constructor. + * \param o object to copy + */ + Ipv6L3Protocol (const Ipv6L3Protocol& o); - /** - * \brief Get IPv6 forwarding state. - * \return forwarding state (enabled or not) - */ - virtual bool GetIpForward () const; + /** + * \brief Copy constructor. + * \param o object to copy + */ + Ipv6L3Protocol &operator = (const Ipv6L3Protocol& o); - /** - * \brief Node attached to stack. - */ - Ptr m_node; + /** + * \brief Construct an IPv6 header. + * \param src source IPv6 address + * \param dst destination IPv6 address + * \param protocol L4 protocol + * \param payloadSize payload size + * \param ttl TTL + * \return newly created IPv6 header + */ + Ipv6Header BuildHeader (Ipv6Address src, Ipv6Address dst, uint8_t protocol, + uint16_t payloadSize, uint8_t ttl); - /** - * \brief Forwarding packets (i.e. router mode) state. - */ - bool m_ipForward; + /** + * \brief Send packet with route. + * \param route route + * \param packet packet to send + * \param ipHeader IPv6 header to add to the packet + */ + void SendRealOut (Ptr route, Ptr packet, Ipv6Header const& ipHeader); - /** - * \brief List of transport protocol. - */ - L4List_t m_protocols; + /** + * \brief Forward a packet. + * \param rtentry route + * \param p packet to forward + * \param header IPv6 header to add to the packet + */ + void IpForward (Ptr rtentry, Ptr p, const Ipv6Header& header); - /** - * \brief List of IPv6 interfaces. - */ - Ipv6InterfaceList m_interfaces; + /** + * \brief Forward a packet in multicast. + * \param mrtentry route + * \param p packet to forward + * \param header IPv6 header to add to the packet + */ + void IpMulticastForward (Ptr mrtentry, Ptr p, const Ipv6Header& header); - /** - * \brief Number of IPv6 interfaces managed by the stack. - */ - uint32_t m_nInterfaces; + /** + * \brief Deliver a packet. + * \param p packet delivered + * \param ip IPv6 header + * \param iif input interface packet was received + */ + void LocalDeliver (Ptr p, Ipv6Header const& ip, uint32_t iif); - /** - * \brief Default TTL for outgoing packets. - */ - uint8_t m_defaultTtl; + /** + * \brief Fallback when no route is found. + * \param p packet + * \param ipHeader IPv6 header + * \param sockErrno error number + */ + void RouteInputError (Ptr p, const Ipv6Header& ipHeader, Socket::SocketErrno sockErrno); - /** - * \brief Routing protocol. - */ - Ptr m_routingProtocol; + /** + * \brief Add an IPv6 interface to the stack. + * \param interface interface to add + * \return index of newly added interface + */ + uint32_t AddIpv6Interface (Ptr interface); - /** - * \brief List of IPv6 raw sockets. - */ - SocketList m_sockets; + /** + * \brief Setup loopback interface. + */ + void SetupLoopback (); - /** - * \brief List of IPv6 prefix received from RA. - */ - Ipv6AutoconfiguredPrefixList m_prefixes; + /** + * \brief Set IPv6 forwarding state. + * \param forward IPv6 forwarding enabled or not + */ + virtual void SetIpForward (bool forward); + + /** + * \brief Get IPv6 forwarding state. + * \return forwarding state (enabled or not) + */ + virtual bool GetIpForward () const; + + /** + * \brief Node attached to stack. + */ + Ptr m_node; + + /** + * \brief Forwarding packets (i.e. router mode) state. + */ + bool m_ipForward; + + /** + * \brief List of transport protocol. + */ + L4List_t m_protocols; + + /** + * \brief List of IPv6 interfaces. + */ + Ipv6InterfaceList m_interfaces; + + /** + * \brief Number of IPv6 interfaces managed by the stack. + */ + uint32_t m_nInterfaces; + + /** + * \brief Default TTL for outgoing packets. + */ + uint8_t m_defaultTtl; + + /** + * \brief Routing protocol. + */ + Ptr m_routingProtocol; + + /** + * \brief List of IPv6 raw sockets. + */ + SocketList m_sockets; + + /** + * \brief List of IPv6 prefix received from RA. + */ + Ipv6AutoconfiguredPrefixList m_prefixes; }; } /* namespace ns3 */ diff --git a/src/internet-stack/ipv6-l4-protocol.h b/src/internet-stack/ipv6-l4-protocol.h index 095dfa3ca..14d279ad8 100644 --- a/src/internet-stack/ipv6-l4-protocol.h +++ b/src/internet-stack/ipv6-l4-protocol.h @@ -37,69 +37,69 @@ class Ipv6Interface; */ class Ipv6L4Protocol : public Object { - public: - /** - * \enum RxStatus_e - * \brief Status of receive. - */ - enum RxStatus_e - { - RX_OK, /**< Receive OK */ - RX_CSUM_FAILED, /**< Checksum of layer 4 protocol failed */ - RX_ENDPOINT_UNREACH /**< Destination unreachable */ - }; +public: + /** + * \enum RxStatus_e + * \brief Status of receive. + */ + enum RxStatus_e + { + RX_OK, /**< Receive OK */ + RX_CSUM_FAILED, /**< Checksum of layer 4 protocol failed */ + RX_ENDPOINT_UNREACH /**< Destination unreachable */ + }; - /** - * \brief Get the type identifier. - * \return type identifier - */ - static TypeId GetTypeId (void); + /** + * \brief Get the type identifier. + * \return type identifier + */ + static TypeId GetTypeId (void); - /** - * \brief Destructor. - */ - virtual ~Ipv6L4Protocol (); + /** + * \brief Destructor. + */ + virtual ~Ipv6L4Protocol (); - /** - * \brief Get the protocol number. - * \return protocol number - */ - virtual int GetProtocolNumber () const = 0; + /** + * \brief Get the protocol number. + * \return protocol number + */ + virtual int GetProtocolNumber () const = 0; - /** - * \brief Receive method. - * - * Called from lower-level layers to send the packet up - * in the stack. - * \param p packet to forward up - * \param src source address of packet received - * \param dst address of packet received - * \param incomingInterface the Ipv6Interface on which the packet arrived - * \return status (OK, destination unreachable or checksum failed) - */ - virtual enum RxStatus_e Receive (Ptr p, Ipv6Address const &src, - Ipv6Address const &dst, - Ptr incomingInterface) = 0; + /** + * \brief Receive method. + * + * Called from lower-level layers to send the packet up + * in the stack. + * \param p packet to forward up + * \param src source address of packet received + * \param dst address of packet received + * \param incomingInterface the Ipv6Interface on which the packet arrived + * \return status (OK, destination unreachable or checksum failed) + */ + virtual enum RxStatus_e Receive (Ptr p, Ipv6Address const &src, + Ipv6Address const &dst, + Ptr incomingInterface) = 0; - /** - * \brief ICMPv6 receive method. - * \param icmpSource the source address of the ICMPv6 message - * \param icmpTtl the ttl of the ICMPv6 message - * \param icmpType the 'type' field of the ICMPv6 message - * \param icmpCode the 'code' field of the ICMPv6 message - * \param icmpInfo extra information dependent on the ICMPv6 message - * generated by Icmpv6L4Protocol - * \param payloadSource the source address of the packet which triggered - * the ICMPv6 message - * \param payloadDestination the destination address of the packet which - * triggered the ICMPv6 message. - * \param payload the first 8 bytes of the UDP header of the packet - * which triggered the ICMPv6 message. - */ - virtual void ReceiveIcmp (Ipv6Address icmpSource, uint8_t icmpTtl, - uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo, - Ipv6Address payloadSource, Ipv6Address payloadDestination, - const uint8_t* payload); + /** + * \brief ICMPv6 receive method. + * \param icmpSource the source address of the ICMPv6 message + * \param icmpTtl the ttl of the ICMPv6 message + * \param icmpType the 'type' field of the ICMPv6 message + * \param icmpCode the 'code' field of the ICMPv6 message + * \param icmpInfo extra information dependent on the ICMPv6 message + * generated by Icmpv6L4Protocol + * \param payloadSource the source address of the packet which triggered + * the ICMPv6 message + * \param payloadDestination the destination address of the packet which + * triggered the ICMPv6 message. + * \param payload the first 8 bytes of the UDP header of the packet + * which triggered the ICMPv6 message. + */ + virtual void ReceiveIcmp (Ipv6Address icmpSource, uint8_t icmpTtl, + uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo, + Ipv6Address payloadSource, Ipv6Address payloadDestination, + const uint8_t* payload); }; diff --git a/src/internet-stack/ipv6-option-header.cc b/src/internet-stack/ipv6-option-header.cc index 05f124482..681606eec 100644 --- a/src/internet-stack/ipv6-option-header.cc +++ b/src/internet-stack/ipv6-option-header.cc @@ -45,7 +45,7 @@ TypeId Ipv6OptionHeader::GetInstanceTypeId () const } Ipv6OptionHeader::Ipv6OptionHeader () -: m_type (0), + : m_type (0), m_length (0) { } @@ -315,7 +315,7 @@ TypeId Ipv6OptionRouterAlertHeader::GetInstanceTypeId () const } Ipv6OptionRouterAlertHeader::Ipv6OptionRouterAlertHeader () -: m_value (0) + : m_value (0) { SetLength (2); } diff --git a/src/internet-stack/ipv6-raw-socket-impl.cc b/src/internet-stack/ipv6-raw-socket-impl.cc index 1fdf58324..5dd0f7f4b 100644 --- a/src/internet-stack/ipv6-raw-socket-impl.cc +++ b/src/internet-stack/ipv6-raw-socket-impl.cc @@ -44,15 +44,15 @@ TypeId Ipv6RawSocketImpl::GetTypeId () static TypeId tid = TypeId ("ns3::Ipv6RawSocketImpl") .SetParent () .AddAttribute ("Protocol", "Protocol number to match.", - UintegerValue (0), - MakeUintegerAccessor (&Ipv6RawSocketImpl::m_protocol), - MakeUintegerChecker ()) + UintegerValue (0), + MakeUintegerAccessor (&Ipv6RawSocketImpl::m_protocol), + MakeUintegerChecker ()) .AddAttribute ("IcmpFilter", "Any ICMPv6 header whose type field matches a bit in this filter is dropped.", - UintegerValue (0), - MakeUintegerAccessor (&Ipv6RawSocketImpl::m_icmpFilter), - MakeUintegerChecker ()) + UintegerValue (0), + MakeUintegerAccessor (&Ipv6RawSocketImpl::m_icmpFilter), + MakeUintegerChecker ()) ; - return tid; + return tid; } Ipv6RawSocketImpl::Ipv6RawSocketImpl () @@ -100,10 +100,10 @@ int Ipv6RawSocketImpl::Bind (const Address& address) NS_LOG_FUNCTION (this << address); if (!Inet6SocketAddress::IsMatchingType (address)) - { - m_err = Socket::ERROR_INVAL; - return -1; - } + { + m_err = Socket::ERROR_INVAL; + return -1; + } Inet6SocketAddress ad = Inet6SocketAddress::ConvertFrom (address); m_src = ad.GetIpv6 (); return 0; @@ -127,11 +127,11 @@ int Ipv6RawSocketImpl::Close () { NS_LOG_FUNCTION_NOARGS (); Ptr ipv6 = m_node->GetObject (); - + if (ipv6) - { - ipv6->DeleteRawSocket (this); - } + { + ipv6->DeleteRawSocket (this); + } return 0; } @@ -152,12 +152,12 @@ int Ipv6RawSocketImpl::ShutdownRecv () int Ipv6RawSocketImpl::Connect (const Address& address) { NS_LOG_FUNCTION (this << address); - + if (!Inet6SocketAddress::IsMatchingType (address)) - { - m_err = Socket::ERROR_INVAL; - return -1; - } + { + m_err = Socket::ERROR_INVAL; + return -1; + } Inet6SocketAddress ad = Inet6SocketAddress::ConvertFrom (address); m_dst = ad.GetIpv6 (); @@ -183,61 +183,61 @@ int Ipv6RawSocketImpl::SendTo (Ptr p, uint32_t flags, const Address& toA NS_LOG_FUNCTION (this << p << flags << toAddress); if (!Inet6SocketAddress::IsMatchingType (toAddress)) - { - m_err = Socket::ERROR_INVAL; - return -1; - } + { + m_err = Socket::ERROR_INVAL; + return -1; + } if (m_shutdownSend) - { - return 0; - } + { + return 0; + } Inet6SocketAddress ad = Inet6SocketAddress::ConvertFrom (toAddress); Ptr ipv6 = m_node->GetObject (); Ipv6Address dst = ad.GetIpv6 (); if (ipv6->GetRoutingProtocol ()) - { - Ipv6Header hdr; - hdr.SetDestinationAddress (dst); - SocketErrno err = ERROR_NOTERROR; - Ptr route = 0; - Ptr oif (0); /*specify non-zero if bound to a source address */ - - if (!m_src.IsAny ()) { - int32_t index = ipv6->GetInterfaceForAddress (m_src); - NS_ASSERT (index >= 0); - oif = ipv6->GetNetDevice (index); - } + Ipv6Header hdr; + hdr.SetDestinationAddress (dst); + SocketErrno err = ERROR_NOTERROR; + Ptr route = 0; + Ptr oif (0); /*specify non-zero if bound to a source address */ - route = ipv6->GetRoutingProtocol ()->RouteOutput (p, hdr, oif, err); - - if (route) - { - NS_LOG_LOGIC ("Route exists"); - if (m_protocol == Icmpv6L4Protocol::GetStaticProtocolNumber ()) - { - /* calculate checksum here for ICMPv6 echo request (sent by ping6) - * as we cannot determine source IPv6 address at application level - */ - if (*p->PeekData () == Icmpv6Header::ICMPV6_ECHO_REQUEST) + if (!m_src.IsAny ()) { - Icmpv6Echo hdr (1); - p->RemoveHeader (hdr); - hdr.CalculatePseudoHeaderChecksum (route->GetSource (), dst, p->GetSize () + hdr.GetSerializedSize (), Icmpv6L4Protocol::GetStaticProtocolNumber ()); - p->AddHeader (hdr); + int32_t index = ipv6->GetInterfaceForAddress (m_src); + NS_ASSERT (index >= 0); + oif = ipv6->GetNetDevice (index); } - } - ipv6->Send (p, route->GetSource (), dst, m_protocol, route); + route = ipv6->GetRoutingProtocol ()->RouteOutput (p, hdr, oif, err); + + if (route) + { + NS_LOG_LOGIC ("Route exists"); + if (m_protocol == Icmpv6L4Protocol::GetStaticProtocolNumber ()) + { + /* calculate checksum here for ICMPv6 echo request (sent by ping6) + * as we cannot determine source IPv6 address at application level + */ + if (*p->PeekData () == Icmpv6Header::ICMPV6_ECHO_REQUEST) + { + Icmpv6Echo hdr (1); + p->RemoveHeader (hdr); + hdr.CalculatePseudoHeaderChecksum (route->GetSource (), dst, p->GetSize () + hdr.GetSerializedSize (), Icmpv6L4Protocol::GetStaticProtocolNumber ()); + p->AddHeader (hdr); + } + } + + ipv6->Send (p, route->GetSource (), dst, m_protocol, route); + } + else + { + NS_LOG_DEBUG ("No route, dropped!"); + } } - else - { - NS_LOG_DEBUG ("No route, dropped!"); - } - } return 0; } @@ -251,24 +251,24 @@ Ptr Ipv6RawSocketImpl::Recv (uint32_t maxSize, uint32_t flags) Ptr Ipv6RawSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags, Address& fromAddress) { NS_LOG_FUNCTION (this << maxSize << flags << fromAddress); - + if (m_data.empty ()) - { - return 0; - } + { + return 0; + } /* get packet */ struct Data data = m_data.front (); m_data.pop_front (); if (data.packet->GetSize () > maxSize) - { - Ptr first = data.packet->CreateFragment (0, maxSize); - data.packet->RemoveAtStart (maxSize); - m_data.push_front (data); - return first; - } - + { + Ptr first = data.packet->CreateFragment (0, maxSize); + data.packet->RemoveAtStart (maxSize); + m_data.push_front (data); + return first; + } + fromAddress = Inet6SocketAddress (data.fromIp, data.fromProtocol); return data.packet; } @@ -285,9 +285,9 @@ uint32_t Ipv6RawSocketImpl::GetRxAvailable () const uint32_t rx = 0; for (std::list::const_iterator it = m_data.begin () ; it != m_data.end () ; ++it) - { - rx+= (it->packet)->GetSize (); - } + { + rx+= (it->packet)->GetSize (); + } return rx; } @@ -297,39 +297,39 @@ bool Ipv6RawSocketImpl::ForwardUp (Ptr p, Ipv6Header hdr, Ptr copy = p->Copy (); - - if (m_protocol == Icmpv6L4Protocol::GetStaticProtocolNumber ()) + (m_dst == Ipv6Address::GetAny () || hdr.GetSourceAddress () == m_dst) && + hdr.GetNextHeader () == m_protocol) { - /* filter */ - Icmpv6Header icmpHeader; - copy->PeekHeader (icmpHeader); - uint8_t type = icmpHeader.GetType (); + Ptr copy = p->Copy (); - if ((1 << type) & m_icmpFilter) - { - /* packet filtered */ - return false; - } + if (m_protocol == Icmpv6L4Protocol::GetStaticProtocolNumber ()) + { + /* filter */ + Icmpv6Header icmpHeader; + copy->PeekHeader (icmpHeader); + uint8_t type = icmpHeader.GetType (); + + if ((1 << type) & m_icmpFilter) + { + /* packet filtered */ + return false; + } + } + + copy->AddHeader (hdr); + struct Data data; + data.packet = copy; + data.fromIp = hdr.GetSourceAddress (); + data.fromProtocol = hdr.GetNextHeader (); + m_data.push_back (data); + NotifyDataRecv (); + return true; } - - copy->AddHeader (hdr); - struct Data data; - data.packet = copy; - data.fromIp = hdr.GetSourceAddress (); - data.fromProtocol = hdr.GetNextHeader (); - m_data.push_back (data); - NotifyDataRecv (); - return true; - } return false; } diff --git a/src/internet-stack/ipv6-raw-socket-impl.h b/src/internet-stack/ipv6-raw-socket-impl.h index 6f30948cf..fe53d5411 100644 --- a/src/internet-stack/ipv6-raw-socket-impl.h +++ b/src/internet-stack/ipv6-raw-socket-impl.h @@ -29,7 +29,7 @@ namespace ns3 { - + class NetDevice; class Node; @@ -39,214 +39,214 @@ class Node; */ class Ipv6RawSocketImpl : public Socket { - public: - /** - * \brief Get the type ID of this class. - * \return type ID - */ - static TypeId GetTypeId (); +public: + /** + * \brief Get the type ID of this class. + * \return type ID + */ + static TypeId GetTypeId (); - /** - * \brief Constructor. - */ - Ipv6RawSocketImpl (); - - /** - * \brief Destructor. - */ - virtual ~Ipv6RawSocketImpl (); + /** + * \brief Constructor. + */ + Ipv6RawSocketImpl (); - /** - * \brief Set the node. - * \param node node to set - */ - void SetNode (Ptr node); + /** + * \brief Destructor. + */ + virtual ~Ipv6RawSocketImpl (); - /** - * \brief Get last error number. - * \return error number - */ - virtual enum Socket::SocketErrno GetErrno () const; + /** + * \brief Set the node. + * \param node node to set + */ + void SetNode (Ptr node); - /** - * \brief Get node. - * \return node associated with this raw socket. - */ - virtual Ptr GetNode () const; + /** + * \brief Get last error number. + * \return error number + */ + virtual enum Socket::SocketErrno GetErrno () const; - /** - * \brief Bind the socket to address. - * \param address bind to this address - * \return 0 if success, -1 otherwise - */ - virtual int Bind (const Address& address); + /** + * \brief Get node. + * \return node associated with this raw socket. + */ + virtual Ptr GetNode () const; - /** - * \brief Bind socket. - * \return 0 if success, -1 otherwise - */ - virtual int Bind (); + /** + * \brief Bind the socket to address. + * \param address bind to this address + * \return 0 if success, -1 otherwise + */ + virtual int Bind (const Address& address); - /** - * \brief Get socket address. - * \param address socket address if method success - * \return 0 if success, -1 otherwise - */ - virtual int GetSockName (Address& address) const; + /** + * \brief Bind socket. + * \return 0 if success, -1 otherwise + */ + virtual int Bind (); - /** - * \brief Close the socket. - * \return 0 if success, -1 otherwise - */ - virtual int Close (); + /** + * \brief Get socket address. + * \param address socket address if method success + * \return 0 if success, -1 otherwise + */ + virtual int GetSockName (Address& address) const; - /** - * \brief Shutdown send capability. - * \return 0 if success, -1 otherwise - */ - virtual int ShutdownSend (); + /** + * \brief Close the socket. + * \return 0 if success, -1 otherwise + */ + virtual int Close (); - /** - * \brief Shutdown receive capability. - * \return 0 if success, -1 otherwise - */ - virtual int ShutdownRecv (); - - /** - * \brief Connect to address. - * \param address address - * \return 0 if success, -1 otherwise - */ - virtual int Connect (const Address& address); + /** + * \brief Shutdown send capability. + * \return 0 if success, -1 otherwise + */ + virtual int ShutdownSend (); - /** - * \brief Listen. - * \return 0 if success, -1 otherwise - */ - virtual int Listen (); + /** + * \brief Shutdown receive capability. + * \return 0 if success, -1 otherwise + */ + virtual int ShutdownRecv (); - /** - * \brief Get TX size available. - * \return TX size - */ - virtual uint32_t GetTxAvailable () const; + /** + * \brief Connect to address. + * \param address address + * \return 0 if success, -1 otherwise + */ + virtual int Connect (const Address& address); - /** - * \brief Get RX size available. - * \return RX size - */ - virtual uint32_t GetRxAvailable () const; + /** + * \brief Listen. + * \return 0 if success, -1 otherwise + */ + virtual int Listen (); - /** - * \brief Send a packet. - * \param p packet to send - * \param flags additionnal flags - * \return 0 if success, -1 otherwise - */ - virtual int Send (Ptr p, uint32_t flags); - - /** - * \brief Send a packet. - * \param p packet to send - * \param flags additionnal flags - * \param toAddress destination address - * \return 0 if success, -1 otherwise - */ - virtual int SendTo (Ptr p, uint32_t flags, const Address& toAddress); + /** + * \brief Get TX size available. + * \return TX size + */ + virtual uint32_t GetTxAvailable () const; - /** - * \brief Receive packet. - * \param maxSize maximum size - * \param flags additionnal flags - * \return packet received - */ - virtual Ptr Recv (uint32_t maxSize, uint32_t flags); - - /** - * \brief Receive packet. - * \param maxSize maximum size - * \param flags additionnal flags - * \param fromAddress source address - * \return packet received - */ - virtual Ptr RecvFrom (uint32_t maxSize, uint32_t flags, Address& fromAddress); - - /** - * \brief Set protocol field. - * \param protocol protocol to set - */ - void SetProtocol (uint16_t protocol); - - /** - * \brief Forward up to receive method. - * \param p packet - * \param hdr IPv6 header - * \param device device - * \return true if forwarded, false otherwise - */ - bool ForwardUp (Ptr p, Ipv6Header hdr, Ptr device); + /** + * \brief Get RX size available. + * \return RX size + */ + virtual uint32_t GetRxAvailable () const; - private: - /** - * \struct Data - * \brief IPv6 raw data and additionnal information. - */ - struct Data + /** + * \brief Send a packet. + * \param p packet to send + * \param flags additionnal flags + * \return 0 if success, -1 otherwise + */ + virtual int Send (Ptr p, uint32_t flags); + + /** + * \brief Send a packet. + * \param p packet to send + * \param flags additionnal flags + * \param toAddress destination address + * \return 0 if success, -1 otherwise + */ + virtual int SendTo (Ptr p, uint32_t flags, const Address& toAddress); + + /** + * \brief Receive packet. + * \param maxSize maximum size + * \param flags additionnal flags + * \return packet received + */ + virtual Ptr Recv (uint32_t maxSize, uint32_t flags); + + /** + * \brief Receive packet. + * \param maxSize maximum size + * \param flags additionnal flags + * \param fromAddress source address + * \return packet received + */ + virtual Ptr RecvFrom (uint32_t maxSize, uint32_t flags, Address& fromAddress); + + /** + * \brief Set protocol field. + * \param protocol protocol to set + */ + void SetProtocol (uint16_t protocol); + + /** + * \brief Forward up to receive method. + * \param p packet + * \param hdr IPv6 header + * \param device device + * \return true if forwarded, false otherwise + */ + bool ForwardUp (Ptr p, Ipv6Header hdr, Ptr device); + +private: + /** + * \struct Data + * \brief IPv6 raw data and additionnal information. + */ + struct Data { Ptr packet; /**< Packet data */ Ipv6Address fromIp; /**< Source address */ uint16_t fromProtocol; /**< Protocol used */ }; - /** - * \brief Dispose object. - */ - virtual void DoDispose (); + /** + * \brief Dispose object. + */ + virtual void DoDispose (); - /** - * \brief Last error number. - */ - enum Socket::SocketErrno m_err; - - /** - * \brief Node. - */ - Ptr m_node; + /** + * \brief Last error number. + */ + enum Socket::SocketErrno m_err; - /** - * \brief Source address. - */ - Ipv6Address m_src; + /** + * \brief Node. + */ + Ptr m_node; - /** - * \brief Destination address. - */ - Ipv6Address m_dst; + /** + * \brief Source address. + */ + Ipv6Address m_src; - /** - * \brief Protocol. - */ - uint16_t m_protocol; + /** + * \brief Destination address. + */ + Ipv6Address m_dst; - /** - * \brief Packet waiting to be processed. - */ - std::list m_data; + /** + * \brief Protocol. + */ + uint16_t m_protocol; - /** - * \brief Flag to shutdown send capability. - */ - bool m_shutdownSend; - - /** - * \brief Flag to shutdown receive capability. - */ - bool m_shutdownRecv; + /** + * \brief Packet waiting to be processed. + */ + std::list m_data; - /** - * \brief ICMPv6 filter. - */ - uint32_t m_icmpFilter; + /** + * \brief Flag to shutdown send capability. + */ + bool m_shutdownSend; + + /** + * \brief Flag to shutdown receive capability. + */ + bool m_shutdownRecv; + + /** + * \brief ICMPv6 filter. + */ + uint32_t m_icmpFilter; }; } /* namespace ns3 */ diff --git a/src/internet-stack/ndisc-cache.cc b/src/internet-stack/ndisc-cache.cc index 22950b0b6..246874064 100644 --- a/src/internet-stack/ndisc-cache.cc +++ b/src/internet-stack/ndisc-cache.cc @@ -37,10 +37,10 @@ TypeId NdiscCache::GetTypeId () static TypeId tid = TypeId ("ns3::NdiscCache") .SetParent () .AddAttribute ("UnresolvedQueueSize", - "Size of the queue for packets pending an NA reply.", - UintegerValue (DEFAULT_UNRES_QLEN), - MakeUintegerAccessor (&NdiscCache::m_unresQlen), - MakeUintegerChecker ()) + "Size of the queue for packets pending an NA reply.", + UintegerValue (DEFAULT_UNRES_QLEN), + MakeUintegerAccessor (&NdiscCache::m_unresQlen), + MakeUintegerChecker ()) ; return tid; } @@ -89,10 +89,10 @@ NdiscCache::Entry* NdiscCache::Lookup (Ipv6Address dst) NS_LOG_FUNCTION (this << dst); if (m_ndCache.find (dst) != m_ndCache.end ()) - { - NdiscCache::Entry* entry = m_ndCache[dst]; - return entry; - } + { + NdiscCache::Entry* entry = m_ndCache[dst]; + return entry; + } return 0; } @@ -110,27 +110,27 @@ NdiscCache::Entry* NdiscCache::Add (Ipv6Address to) void NdiscCache::Remove (NdiscCache::Entry* entry) { NS_LOG_FUNCTION_NOARGS (); - + for (CacheI i = m_ndCache.begin () ; i != m_ndCache.end () ; i++) - { - if ((*i).second == entry) { - m_ndCache.erase (i); - entry->ClearWaitingPacket (); - delete entry; - return; + if ((*i).second == entry) + { + m_ndCache.erase (i); + entry->ClearWaitingPacket (); + delete entry; + return; + } } - } } void NdiscCache::Flush () { NS_LOG_FUNCTION_NOARGS (); - + for (CacheI i = m_ndCache.begin () ; i != m_ndCache.end () ; i++) - { - delete (*i).second; /* delete the pointer NdiscCache::Entry */ - } + { + delete (*i).second; /* delete the pointer NdiscCache::Entry */ + } m_ndCache.erase (m_ndCache.begin (), m_ndCache.end ()); } @@ -178,11 +178,11 @@ void NdiscCache::Entry::AddWaitingPacket (Ptr p) NS_LOG_FUNCTION (this << p); if (m_waiting.size () >= m_ndCache->GetUnresQlen ()) - { - /* we store only m_unresQlen packet => first packet in first packet remove */ - /* XXX report packet as 'dropped' */ - m_waiting.remove (0); - } + { + /* we store only m_unresQlen packet => first packet in first packet remove */ + /* XXX report packet as 'dropped' */ + m_waiting.remove (0); + } m_waiting.push_back (p); } @@ -207,42 +207,42 @@ void NdiscCache::Entry::FunctionRetransmitTimeout () /* determine source address */ if (m_ipv6Address.IsLinkLocal ()) - { - addr = m_ndCache->GetInterface ()->GetLinkLocalAddress ().GetAddress ();; - } - else if (!m_ipv6Address.IsAny ()) - { - addr = m_ndCache->GetInterface ()->GetAddressMatchingDestination (m_ipv6Address).GetAddress (); - - if (addr.IsAny ()) /* maybe address has expired */ { - /* delete the entry */ - m_ndCache->Remove (this); - return; + addr = m_ndCache->GetInterface ()->GetLinkLocalAddress ().GetAddress ();; + } + else if (!m_ipv6Address.IsAny ()) + { + addr = m_ndCache->GetInterface ()->GetAddressMatchingDestination (m_ipv6Address).GetAddress (); + + if (addr.IsAny ()) /* maybe address has expired */ + { + /* delete the entry */ + m_ndCache->Remove (this); + return; + } } - } if (GetNSRetransmit () < icmpv6->MAX_MULTICAST_SOLICIT) - { - IncNSRetransmit (); - - icmpv6->SendNS (addr, Ipv6Address::MakeSolicitedAddress (m_ipv6Address), m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ()); - /* arm the timer again */ - StartRetransmitTimer (); - } - else - { - Ptr malformedPacket = m_waiting.front (); - if (malformedPacket == 0) { - malformedPacket = Create (); - } + IncNSRetransmit (); - icmpv6->SendErrorDestinationUnreachable (malformedPacket, addr, Icmpv6Header::ICMPV6_ADDR_UNREACHABLE); - - /* delete the entry */ - m_ndCache->Remove (this); - } + icmpv6->SendNS (addr, Ipv6Address::MakeSolicitedAddress (m_ipv6Address), m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ()); + /* arm the timer again */ + StartRetransmitTimer (); + } + else + { + Ptr malformedPacket = m_waiting.front (); + if (malformedPacket == 0) + { + malformedPacket = Create (); + } + + icmpv6->SendErrorDestinationUnreachable (malformedPacket, addr, Icmpv6Header::ICMPV6_ADDR_UNREACHABLE); + + /* delete the entry */ + m_ndCache->Remove (this); + } } void NdiscCache::Entry::FunctionDelayTimeout () @@ -255,24 +255,24 @@ void NdiscCache::Entry::FunctionDelayTimeout () this->MarkProbe (); if (m_ipv6Address.IsLinkLocal ()) - { - addr = m_ndCache->GetInterface ()->GetLinkLocalAddress ().GetAddress (); - } - else if (!m_ipv6Address.IsAny ()) - { - addr = m_ndCache->GetInterface ()->GetAddressMatchingDestination (m_ipv6Address).GetAddress (); - if (addr.IsAny ()) /* maybe address has expired */ { - /* delete the entry */ - m_ndCache->Remove (this); + addr = m_ndCache->GetInterface ()->GetLinkLocalAddress ().GetAddress (); + } + else if (!m_ipv6Address.IsAny ()) + { + addr = m_ndCache->GetInterface ()->GetAddressMatchingDestination (m_ipv6Address).GetAddress (); + if (addr.IsAny ()) /* maybe address has expired */ + { + /* delete the entry */ + m_ndCache->Remove (this); + return; + } + } + else + { + /* should not happen */ return; } - } - else - { - /* should not happen */ - return; - } Ptr p = icmpv6->ForgeNS (addr, m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ()); m_ndCache->GetDevice ()->Send (p, this->GetMacAddress (), Ipv6L3Protocol::PROT_NUMBER); @@ -289,42 +289,42 @@ void NdiscCache::Entry::FunctionProbeTimeout () Ptr icmpv6 = ipv6->GetIcmpv6 (); if (GetNSRetransmit () < icmpv6->MAX_UNICAST_SOLICIT) - { - Ipv6Address addr; - - if (m_ipv6Address.IsLinkLocal ()) { - addr = m_ndCache->GetInterface ()->GetLinkLocalAddress ().GetAddress (); - } - else if (!m_ipv6Address.IsAny ()) - { - addr = m_ndCache->GetInterface ()->GetAddressMatchingDestination (m_ipv6Address).GetAddress (); - if (addr.IsAny ()) /* maybe address has expired */ - { - /* delete the entry */ - m_ndCache->Remove (this); - return; - } - } - else - { - /* should not happen */ - return; - } + Ipv6Address addr; - IncNSRetransmit (); - /* icmpv6->SendNS (m_ndCache->GetInterface ()->GetLinkLocalAddress (), m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ()); */ - Ptr p = icmpv6->ForgeNS (addr, m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ()); - m_ndCache->GetDevice ()->Send (p, this->GetMacAddress (), Ipv6L3Protocol::PROT_NUMBER); + if (m_ipv6Address.IsLinkLocal ()) + { + addr = m_ndCache->GetInterface ()->GetLinkLocalAddress ().GetAddress (); + } + else if (!m_ipv6Address.IsAny ()) + { + addr = m_ndCache->GetInterface ()->GetAddressMatchingDestination (m_ipv6Address).GetAddress (); + if (addr.IsAny ()) /* maybe address has expired */ + { + /* delete the entry */ + m_ndCache->Remove (this); + return; + } + } + else + { + /* should not happen */ + return; + } - /* arm the timer again */ - StartProbeTimer (); - } + IncNSRetransmit (); + /* icmpv6->SendNS (m_ndCache->GetInterface ()->GetLinkLocalAddress (), m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ()); */ + Ptr p = icmpv6->ForgeNS (addr, m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ()); + m_ndCache->GetDevice ()->Send (p, this->GetMacAddress (), Ipv6L3Protocol::PROT_NUMBER); + + /* arm the timer again */ + StartProbeTimer (); + } else - { - /* delete the entry */ - m_ndCache->Remove (this); - } + { + /* delete the entry */ + m_ndCache->Remove (this); + } } void NdiscCache::Entry::SetIpv6Address (Ipv6Address ipv6Address) @@ -428,9 +428,9 @@ void NdiscCache::Entry::MarkIncomplete (Ptr p) m_state = INCOMPLETE; if (p) - { - m_waiting.push_back (p); - } + { + m_waiting.push_back (p); + } } std::list > NdiscCache::Entry::MarkReachable (Address mac) diff --git a/src/internet-stack/ndisc-cache.h b/src/internet-stack/ndisc-cache.h index 569be145a..d2d19fd3f 100644 --- a/src/internet-stack/ndisc-cache.h +++ b/src/internet-stack/ndisc-cache.h @@ -45,412 +45,412 @@ class Ipv6Interface; */ class NdiscCache : public Object { +public: + class Entry; + + /** + * \brief Get the type ID + * \return type ID + */ + static TypeId GetTypeId (); + + /** + * \brief Default value for unres qlen. + */ + static const uint32_t DEFAULT_UNRES_QLEN = 3; + + /** + * \brief Constructor. + */ + NdiscCache (); + + /** + * \brief Destructor. + */ + ~NdiscCache (); + + /** + * \brief Get the NetDevice associated with this cache. + * \return NetDevice + */ + Ptr GetDevice () const; + + /** + * \brief Get the Ipv6Interface associated with this cache. + */ + Ptr GetInterface () const; + + /** + * \brief Lookup in the cache. + * \param dst destination address + * \return the entry if found, 0 otherwise + */ + NdiscCache::Entry* Lookup (Ipv6Address dst); + + /** + * \brief Add an entry. + * \param to address to add + * \return an new Entry + */ + NdiscCache::Entry* Add (Ipv6Address to); + + /** + * \brief Delete an entry. + * \param entry pointer to delete from the list. + */ + void Remove (NdiscCache::Entry* entry); + + /** + * \brief Flush the cache. + */ + void Flush (); + + /** + * \brief Set the max number of waiting packet. + * \param unresQlen value to set + */ + void SetUnresQlen (uint32_t unresQlen); + + /** + * \brief Get the max number of waiting packet. + * \return max number + */ + uint32_t GetUnresQlen (); + + /** + * \brief Set the device and interface. + * \param device the device + * \param interface the IPv6 interface + */ + void SetDevice (Ptr device, Ptr interface); + + /** + * \class Entry + * \brief A record that holds information about an NdiscCache entry. + */ + class Entry + { public: - class Entry; - - /** - * \brief Get the type ID - * \return type ID - */ - static TypeId GetTypeId (); - - /** - * \brief Default value for unres qlen. - */ - static const uint32_t DEFAULT_UNRES_QLEN = 3; - /** * \brief Constructor. + * \param nd The NdiscCache this entry belongs to. */ - NdiscCache (); + Entry (NdiscCache* nd); /** - * \brief Destructor. + * \brief Changes the state to this entry to INCOMPLETE. + * \param p packet that wait to be sent */ - ~NdiscCache (); + void MarkIncomplete (Ptr p); /** - * \brief Get the NetDevice associated with this cache. - * \return NetDevice + * \brief Changes the state to this entry to REACHABLE. + * \param mac MAC address + * \return the list of packet waiting */ - Ptr GetDevice () const; + std::list > MarkReachable (Address mac); /** - * \brief Get the Ipv6Interface associated with this cache. + * \brief Changes the state to this entry to PROBE. */ - Ptr GetInterface () const; + void MarkProbe (); /** - * \brief Lookup in the cache. - * \param dst destination address - * \return the entry if found, 0 otherwise + * \brief Changes the state to this entry to STALE. + * \param mac L2 address + * \return the list of packet waiting */ - NdiscCache::Entry* Lookup (Ipv6Address dst); + std::list > MarkStale (Address mac); /** - * \brief Add an entry. - * \param to address to add - * \return an new Entry + * \brief Changes the state to this entry to STALE. */ - NdiscCache::Entry* Add (Ipv6Address to); + void MarkStale (); /** - * \brief Delete an entry. - * \param entry pointer to delete from the list. + * \brief Changes the state to this entry to REACHABLE. */ - void Remove (NdiscCache::Entry* entry); + void MarkReachable (); /** - * \brief Flush the cache. + * \brief Change the state to this entry to DELAY. */ - void Flush (); + void MarkDelay (); /** - * \brief Set the max number of waiting packet. - * \param unresQlen value to set + * \brief Add a packet (or replace old value) in the queue. + * \param p packet to add */ - void SetUnresQlen (uint32_t unresQlen); + void AddWaitingPacket (Ptr p); /** - * \brief Get the max number of waiting packet. - * \return max number + * \brief Clear the waiting packet list. */ - uint32_t GetUnresQlen (); + void ClearWaitingPacket (); /** - * \brief Set the device and interface. - * \param device the device - * \param interface the IPv6 interface + * \brief Is the entry STALE + * \return true if the entry is in STALE state, false otherwise */ - void SetDevice (Ptr device, Ptr interface); + bool IsStale () const; /** - * \class Entry - * \brief A record that holds information about an NdiscCache entry. + * \brief Is the entry REACHABLE + * \return true if the entry is in REACHABLE state, false otherwise */ - class Entry - { - public: - /** - * \brief Constructor. - * \param nd The NdiscCache this entry belongs to. - */ - Entry (NdiscCache* nd); + bool IsReachable () const; - /** - * \brief Changes the state to this entry to INCOMPLETE. - * \param p packet that wait to be sent - */ - void MarkIncomplete (Ptr p); + /** + * \brief Is the entry DELAY + * \return true if the entry is in DELAY state, false otherwise + */ + bool IsDelay () const; - /** - * \brief Changes the state to this entry to REACHABLE. - * \param mac MAC address - * \return the list of packet waiting - */ - std::list > MarkReachable (Address mac); + /** + * \brief Is the entry INCOMPLETE + * \return true if the entry is in INCOMPLETE state, false otherwise + */ + bool IsIncomplete () const; - /** - * \brief Changes the state to this entry to PROBE. - */ - void MarkProbe (); + /** + * \brief Is the entry PROBE + * \return true if the entry is in PROBE state, false otherwise + */ + bool IsProbe () const; - /** - * \brief Changes the state to this entry to STALE. - * \param mac L2 address - * \return the list of packet waiting - */ - std::list > MarkStale (Address mac); + /** + * \brief Get the MAC address of this entry. + * \return the L2 address + */ + Address GetMacAddress () const; - /** - * \brief Changes the state to this entry to STALE. - */ - void MarkStale (); + /** + * \brief Set the MAC address of this entry. + * \param mac the MAC address to set + */ + void SetMacAddress (Address mac); - /** - * \brief Changes the state to this entry to REACHABLE. - */ - void MarkReachable (); + /** + * \brief If the entry is a host or a router. + * \return true if the node is a router, 0 if it is a host + */ + bool IsRouter () const; - /** - * \brief Change the state to this entry to DELAY. - */ - void MarkDelay (); + /** + * \brief Set the node type. + * \param router true is a router, false means a host + */ + void SetRouter (bool router); - /** - * \brief Add a packet (or replace old value) in the queue. - * \param p packet to add - */ - void AddWaitingPacket (Ptr p); + /** + * \brief Get the number of NS retransmit. + * \return number of NS that have been retransmit + */ + uint8_t GetNSRetransmit () const; - /** - * \brief Clear the waiting packet list. - */ - void ClearWaitingPacket (); + /** + * \brief Increment NS retransmit. + */ + void IncNSRetransmit (); - /** - * \brief Is the entry STALE - * \return true if the entry is in STALE state, false otherwise - */ - bool IsStale () const; + /** + * \brief Reset NS retransmit (=0). + */ + void ResetNSRetransmit (); - /** - * \brief Is the entry REACHABLE - * \return true if the entry is in REACHABLE state, false otherwise - */ - bool IsReachable () const; + /** + * \brief Get the time of last reachability confirmation. + * \return time + */ + Time GetLastReachabilityConfirmation () const; - /** - * \brief Is the entry DELAY - * \return true if the entry is in DELAY state, false otherwise - */ - bool IsDelay () const; + /** + * \brief Update the time of last reachability confirmation. + */ + void UpdateLastReachabilityconfirmation (); - /** - * \brief Is the entry INCOMPLETE - * \return true if the entry is in INCOMPLETE state, false otherwise - */ - bool IsIncomplete () const; + /** + * \brief Start the reachable timer. + */ + void StartReachableTimer (); - /** - * \brief Is the entry PROBE - * \return true if the entry is in PROBE state, false otherwise - */ - bool IsProbe () const; + /** + * \brief Stop the reachable timer. + */ + void StopReachableTimer (); - /** - * \brief Get the MAC address of this entry. - * \return the L2 address - */ - Address GetMacAddress () const; + /** + * \brief Start retransmit timer. + */ + void StartRetransmitTimer (); - /** - * \brief Set the MAC address of this entry. - * \param mac the MAC address to set - */ - void SetMacAddress (Address mac); + /** + * \brief Stop retransmit timer. + */ + void StopRetransmitTimer (); - /** - * \brief If the entry is a host or a router. - * \return true if the node is a router, 0 if it is a host - */ - bool IsRouter () const; + /** + * \brief Start probe timer. + */ + void StartProbeTimer (); - /** - * \brief Set the node type. - * \param router true is a router, false means a host - */ - void SetRouter (bool router); + /** + * \brief Stop probe timer. + */ + void StopProbeTimer (); - /** - * \brief Get the number of NS retransmit. - * \return number of NS that have been retransmit - */ - uint8_t GetNSRetransmit () const; + /** + * \brief Start delay timer. + */ + void StartDelayTimer (); - /** - * \brief Increment NS retransmit. - */ - void IncNSRetransmit (); + /** + * \brief Stop delay timer. + */ + void StopDelayTimer (); - /** - * \brief Reset NS retransmit (=0). - */ - void ResetNSRetransmit (); + /** + * \brief Function called when reachable timer timeout. + */ + void FunctionReachableTimeout (); - /** - * \brief Get the time of last reachability confirmation. - * \return time - */ - Time GetLastReachabilityConfirmation () const; + /** + * \brief Function called when retransmit timer timeout. + * It verify that the NS retransmit has reached the max so discard the entry + * otherwise it retransmit a NS. + */ + void FunctionRetransmitTimeout (); - /** - * \brief Update the time of last reachability confirmation. - */ - void UpdateLastReachabilityconfirmation (); + /** + * \brief Function called when probe timer timeout. + */ + void FunctionProbeTimeout (); - /** - * \brief Start the reachable timer. - */ - void StartReachableTimer (); + /** + * \brief Function called when delay timer timeout. + */ + void FunctionDelayTimeout (); - /** - * \brief Stop the reachable timer. - */ - void StopReachableTimer (); - - /** - * \brief Start retransmit timer. - */ - void StartRetransmitTimer (); - - /** - * \brief Stop retransmit timer. - */ - void StopRetransmitTimer (); - - /** - * \brief Start probe timer. - */ - void StartProbeTimer (); - - /** - * \brief Stop probe timer. - */ - void StopProbeTimer (); - - /** - * \brief Start delay timer. - */ - void StartDelayTimer (); - - /** - * \brief Stop delay timer. - */ - void StopDelayTimer (); - - /** - * \brief Function called when reachable timer timeout. - */ - void FunctionReachableTimeout (); - - /** - * \brief Function called when retransmit timer timeout. - * It verify that the NS retransmit has reached the max so discard the entry - * otherwise it retransmit a NS. - */ - void FunctionRetransmitTimeout (); - - /** - * \brief Function called when probe timer timeout. - */ - void FunctionProbeTimeout (); - - /** - * \brief Function called when delay timer timeout. - */ - void FunctionDelayTimeout (); - - /** - * \brief Set the IPv6 address. - * \param ipv6Address IPv6 address - */ - void SetIpv6Address (Ipv6Address ipv6Address); - - private: - /** - * \brief The IPv6 address. - */ - Ipv6Address m_ipv6Address; - - /** - * \brief The Entry state enumeration. - */ - enum NdiscCacheEntryState_e - { - INCOMPLETE, /**< No mapping between IPv6 and L2 addresses */ - REACHABLE, /**< Mapping exists between IPv6 and L2 addresses */ - STALE, /**< Mapping is stale */ - DELAY, /**< Try to wait contact from remote host */ - PROBE /**< Try to contact IPv6 address to know again its L2 address */ - }; - - /** - * \brief The state of the entry. - */ - NdiscCacheEntryState_e m_state; - - /** - * \brief the NdiscCache associated. - */ - NdiscCache* m_ndCache; - - /** - * \brief The MAC address. - */ - Address m_macAddress; - - /** - * \brief The list of packet waiting. - */ - std::list > m_waiting; - - /** - * \brief Type of node (router or host). - */ - bool m_router; - - /** - * \brief Reachable timer (used for NUD in REACHABLE state). - */ - Timer m_reachableTimer; - - /** - * \brief Retransmission timer (used for NUD in INCOMPLETE state). - */ - Timer m_retransTimer; - - /** - * \brief Probe timer (used for NUD in PROBE state). - */ - Timer m_probeTimer; - - /** - * \brief Delay timer (used for NUD when in DELAY state). - */ - Timer m_delayTimer; - - /** - * \brief Last time we see a reachability confirmation. - */ - Time m_lastReachabilityConfirmation; - - /** - * \brief Number of NS retransmission. - */ - uint8_t m_nsRetransmit; - }; + /** + * \brief Set the IPv6 address. + * \param ipv6Address IPv6 address + */ + void SetIpv6Address (Ipv6Address ipv6Address); private: - typedef sgi::hash_map Cache; - typedef sgi::hash_map::iterator CacheI; + /** + * \brief The IPv6 address. + */ + Ipv6Address m_ipv6Address; /** - * \brief Copy constructor. - * \param a cache to copy + * \brief The Entry state enumeration. */ - NdiscCache (NdiscCache const &a); - - /** - * \brief Equal operator. - * \param a cache to copy - */ - NdiscCache& operator= (NdiscCache const &a); + enum NdiscCacheEntryState_e + { + INCOMPLETE, /**< No mapping between IPv6 and L2 addresses */ + REACHABLE, /**< Mapping exists between IPv6 and L2 addresses */ + STALE, /**< Mapping is stale */ + DELAY, /**< Try to wait contact from remote host */ + PROBE /**< Try to contact IPv6 address to know again its L2 address */ + }; /** - * \brief Dispose this object. + * \brief The state of the entry. */ - void DoDispose (); + NdiscCacheEntryState_e m_state; /** - * \brief The NetDevice. + * \brief the NdiscCache associated. */ - Ptr m_device; + NdiscCache* m_ndCache; /** - * \brief the interface. + * \brief The MAC address. */ - Ptr m_interface; + Address m_macAddress; /** - * \brief A list of Entry. + * \brief The list of packet waiting. */ - Cache m_ndCache; + std::list > m_waiting; /** - * \brief Max number of packet stored in m_waiting. + * \brief Type of node (router or host). */ - uint32_t m_unresQlen; + bool m_router; + + /** + * \brief Reachable timer (used for NUD in REACHABLE state). + */ + Timer m_reachableTimer; + + /** + * \brief Retransmission timer (used for NUD in INCOMPLETE state). + */ + Timer m_retransTimer; + + /** + * \brief Probe timer (used for NUD in PROBE state). + */ + Timer m_probeTimer; + + /** + * \brief Delay timer (used for NUD when in DELAY state). + */ + Timer m_delayTimer; + + /** + * \brief Last time we see a reachability confirmation. + */ + Time m_lastReachabilityConfirmation; + + /** + * \brief Number of NS retransmission. + */ + uint8_t m_nsRetransmit; + }; + +private: + typedef sgi::hash_map Cache; + typedef sgi::hash_map::iterator CacheI; + + /** + * \brief Copy constructor. + * \param a cache to copy + */ + NdiscCache (NdiscCache const &a); + + /** + * \brief Equal operator. + * \param a cache to copy + */ + NdiscCache& operator= (NdiscCache const &a); + + /** + * \brief Dispose this object. + */ + void DoDispose (); + + /** + * \brief The NetDevice. + */ + Ptr m_device; + + /** + * \brief the interface. + */ + Ptr m_interface; + + /** + * \brief A list of Entry. + */ + Cache m_ndCache; + + /** + * \brief Max number of packet stored in m_waiting. + */ + uint32_t m_unresQlen; }; } /* namespace ns3 */ diff --git a/src/node/inet6-socket-address.h b/src/node/inet6-socket-address.h index 0e022486b..12a1aa291 100644 --- a/src/node/inet6-socket-address.h +++ b/src/node/inet6-socket-address.h @@ -35,105 +35,105 @@ namespace ns3 { */ class Inet6SocketAddress { - public: - /** - * \brief Constructor. - * \param ipv6 the IPv6 address - * \param port the port - */ - Inet6SocketAddress (Ipv6Address ipv6, uint16_t port); +public: + /** + * \brief Constructor. + * \param ipv6 the IPv6 address + * \param port the port + */ + Inet6SocketAddress (Ipv6Address ipv6, uint16_t port); - /** - * \brief Constructor (the port is set to zero). - * \param ipv6 the IPv6 address - */ - Inet6SocketAddress (Ipv6Address ipv6); + /** + * \brief Constructor (the port is set to zero). + * \param ipv6 the IPv6 address + */ + Inet6SocketAddress (Ipv6Address ipv6); - /** - * \brief Constructor (the address is set to "any"). - * \param port the port - */ - Inet6SocketAddress (uint16_t port); + /** + * \brief Constructor (the address is set to "any"). + * \param port the port + */ + Inet6SocketAddress (uint16_t port); - /** - * \brief Constructor. - * \param ipv6 string which represents an IPv6 address - * \param port the port - */ - Inet6SocketAddress (const char* ipv6, uint16_t port); + /** + * \brief Constructor. + * \param ipv6 string which represents an IPv6 address + * \param port the port + */ + Inet6SocketAddress (const char* ipv6, uint16_t port); - /** - * \brief Constructor. - * \param ipv6 string which represents an IPv6 address - */ - Inet6SocketAddress (const char* ipv6); + /** + * \brief Constructor. + * \param ipv6 string which represents an IPv6 address + */ + Inet6SocketAddress (const char* ipv6); - /** - * \brief Get the port. - * \return the port - */ - uint16_t GetPort (void) const; + /** + * \brief Get the port. + * \return the port + */ + uint16_t GetPort (void) const; - /** - * \brief Set the port - * \param port the port - */ - void SetPort (uint16_t port); + /** + * \brief Set the port + * \param port the port + */ + void SetPort (uint16_t port); - /** - * \brief Get the IPv6 address. - * \return the IPv6 address - */ - Ipv6Address GetIpv6 (void) const; + /** + * \brief Get the IPv6 address. + * \return the IPv6 address + */ + Ipv6Address GetIpv6 (void) const; - /** - * \brief Set the IPv6 address. - * \param ipv6 the address - */ - void SetIpv6 (Ipv6Address ipv6); + /** + * \brief Set the IPv6 address. + * \param ipv6 the address + */ + void SetIpv6 (Ipv6Address ipv6); - /** - * \brief If the address match. - * \param addr the address to test - * \return true if the address match, false otherwise - */ - static bool IsMatchingType (const Address &addr); + /** + * \brief If the address match. + * \param addr the address to test + * \return true if the address match, false otherwise + */ + static bool IsMatchingType (const Address &addr); - /** - * \brief Get an Address instance which represents this - * Inet6SocketAddress instance. - */ - operator Address (void) const; + /** + * \brief Get an Address instance which represents this + * Inet6SocketAddress instance. + */ + operator Address (void) const; - /** - * \brief Convert the address to a InetSocketAddress. - * \param addr the address to convert - * \return an Inet6SocketAddress instance corresponding to address - */ - static Inet6SocketAddress ConvertFrom (const Address &addr); + /** + * \brief Convert the address to a InetSocketAddress. + * \param addr the address to convert + * \return an Inet6SocketAddress instance corresponding to address + */ + static Inet6SocketAddress ConvertFrom (const Address &addr); - private: - /** - * \brief Convert to Address. - * \return Address instance - */ - Address ConvertTo (void) const; +private: + /** + * \brief Convert to Address. + * \return Address instance + */ + Address ConvertTo (void) const; - /** - * \brief Get the type. - * \return the type of Inet6SocketAddress - */ - static uint8_t GetType (void); + /** + * \brief Get the type. + * \return the type of Inet6SocketAddress + */ + static uint8_t GetType (void); - /** - * \brief The IPv6 address. - */ - Ipv6Address m_ipv6; + /** + * \brief The IPv6 address. + */ + Ipv6Address m_ipv6; - /** - * \brief The port. - */ - uint16_t m_port; + /** + * \brief The port. + */ + uint16_t m_port; }; } /* namespace ns3 */ diff --git a/src/node/ipv6-address.cc b/src/node/ipv6-address.cc index 02e259066..31e5438f7 100644 --- a/src/node/ipv6-address.cc +++ b/src/node/ipv6-address.cc @@ -46,17 +46,17 @@ extern "C" static uint32_t lookuphash (unsigned char* k, uint32_t length, uint32_t level) { #define mix(a, b, c) \ -({ \ - (a) -= (b); (a) -= (c); (a) ^= ((c) >> 13); \ - (b) -= (c); (b) -= (a); (b) ^= ((a) << 8); \ - (c) -= (a); (c) -= (b); (c) ^= ((b) >> 13); \ - (a) -= (b); (a) -= (c); (a) ^= ((c) >> 12); \ - (b) -= (c); (b) -= (a); (b) ^= ((a) << 16); \ - (c) -= (a); (c) -= (b); (c) ^= ((b) >> 5); \ - (a) -= (b); (a) -= (c); (a) ^= ((c) >> 3); \ - (b) -= (c); (b) -= (a); (b) ^= ((a) << 10); \ - (c) -= (a); (c) -= (b); (c) ^= ((b) >> 15); \ -}) + ({ \ + (a) -= (b); (a) -= (c); (a) ^= ((c) >> 13); \ + (b) -= (c); (b) -= (a); (b) ^= ((a) << 8); \ + (c) -= (a); (c) -= (b); (c) ^= ((b) >> 13); \ + (a) -= (b); (a) -= (c); (a) ^= ((c) >> 12); \ + (b) -= (c); (b) -= (a); (b) ^= ((a) << 16); \ + (c) -= (a); (c) -= (b); (c) ^= ((b) >> 5); \ + (a) -= (b); (a) -= (c); (a) ^= ((c) >> 3); \ + (b) -= (c); (b) -= (a); (b) ^= ((a) << 10); \ + (c) -= (a); (c) -= (b); (c) ^= ((b) >> 15); \ + }) typedef uint32_t ub4; /* unsigned 4-byte quantities */ typedef unsigned char ub1; /* unsigned 1-byte quantities */ @@ -72,19 +72,19 @@ static uint32_t lookuphash (unsigned char* k, uint32_t length, uint32_t level) /* handle most of the key */ while (len >= 12) - { - a += (k[0] + ((ub4)k[1] << 8) + ((ub4)k[2] << 16) + ((ub4)k[3] << 24)); - b += (k[4] + ((ub4)k[5] << 8) + ((ub4)k[6] << 16) + ((ub4)k[7] << 24)); - c += (k[8] + ((ub4)k[9] << 8) + ((ub4)k[10] << 16) + ((ub4)k[11] << 24)); - mix (a, b, c); - k += 12; - len -= 12; - } + { + a += (k[0] + ((ub4)k[1] << 8) + ((ub4)k[2] << 16) + ((ub4)k[3] << 24)); + b += (k[4] + ((ub4)k[5] << 8) + ((ub4)k[6] << 16) + ((ub4)k[7] << 24)); + c += (k[8] + ((ub4)k[9] << 8) + ((ub4)k[10] << 16) + ((ub4)k[11] << 24)); + mix (a, b, c); + k += 12; + len -= 12; + } /* handle the last 11 bytes */ c += length; switch (len) /* all the case statements fall through */ - { + { case 11: c += ((ub4)k[10] << 24); case 10: c += ((ub4)k[9] << 16); case 9 : c += ((ub4)k[8] << 8); /* the first byte of c is reserved for the length */ @@ -96,10 +96,10 @@ static uint32_t lookuphash (unsigned char* k, uint32_t length, uint32_t level) case 3 : a += ((ub4)k[2] << 16); case 2 : a += ((ub4)k[1] << 8); case 1 : a += k[0]; - /* case 0: nothing left to add */ - } + /* case 0: nothing left to add */ + } mix (a, b, c); - + #undef mix /* report the result */ @@ -135,109 +135,109 @@ static bool AsciiToIpv6Host (const char *address, uint8_t addr[16]) /* Leading :: requires some special handling. */ if (*address == ':') - { - if (*++address != ':') { - return (0); + if (*++address != ':') + { + return (0); + } } - } curtok = address; while ((ch = *address++) != '\0') - { - const char *pch = 0; - - if ((pch = strchr ((xdigits = xdigits_l), ch)) == 0) { - pch = strchr ((xdigits = xdigits_u), ch); - } + const char *pch = 0; - if (pch != 0) - { - val <<= 4; - val |= (pch - xdigits); + if ((pch = strchr ((xdigits = xdigits_l), ch)) == 0) + { + pch = strchr ((xdigits = xdigits_u), ch); + } - if (++seen_xdigits > 4) - { - return (0); - } - continue; - } - if (ch == ':') - { - curtok = address; + if (pch != 0) + { + val <<= 4; + val |= (pch - xdigits); - if (!seen_xdigits) - { - if (colonp) - return (0); - colonp = tp; - continue; - } + if (++seen_xdigits > 4) + { + return (0); + } + continue; + } + if (ch == ':') + { + curtok = address; - if (tp + 2 > endp) - { - return (0); - } + if (!seen_xdigits) + { + if (colonp) + return (0); + colonp = tp; + continue; + } - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - seen_xdigits = 0; - val = 0; - continue; - } + if (tp + 2 > endp) + { + return (0); + } - /* TODO Handle IPv4 mapped address (2001::192.168.0.1) */ + *tp++ = (unsigned char) (val >> 8) & 0xff; + *tp++ = (unsigned char) val & 0xff; + seen_xdigits = 0; + val = 0; + continue; + } + + /* TODO Handle IPv4 mapped address (2001::192.168.0.1) */ #if 0 - if (ch == '.' && ((tp + 4 /*NS_INADDRSZ*/) <= endp) && - inet_pton4(curtok, tp) > 0) - { - tp += 4 /*NS_INADDRSZ*/; - seen_xdigits = 0; - break;/* '\0' was seen by inet_pton4(). */ - } + if (ch == '.' && ((tp + 4 /*NS_INADDRSZ*/) <= endp) && + inet_pton4(curtok, tp) > 0) + { + tp += 4 /*NS_INADDRSZ*/; + seen_xdigits = 0; + break;/* '\0' was seen by inet_pton4(). */ + } #endif - return (0); - } + return (0); + } if (seen_xdigits) - { - if (tp + 2 > endp) { - return (0); + if (tp + 2 > endp) + { + return (0); + } + *tp++ = (unsigned char) (val >> 8) & 0xff; + *tp++ = (unsigned char) val & 0xff; } - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - } if (colonp != 0) - { - /* - * Since some memmove ()'s erroneously fail to handle - * overlapping regions, we'll do the shift by hand. - */ - const int n = tp - colonp; - int i = 0; + { + /* + * Since some memmove ()'s erroneously fail to handle + * overlapping regions, we'll do the shift by hand. + */ + const int n = tp - colonp; + int i = 0; - if (tp == endp) + if (tp == endp) + { + return (0); + } + + for (i = 1; i <= n; i++) + { + endp[- i] = colonp[n - i]; + colonp[n - i] = 0; + } + + tp = endp; + } + + if (tp != endp) { return (0); } - for (i = 1; i <= n; i++) - { - endp[- i] = colonp[n - i]; - colonp[n - i] = 0; - } - - tp = endp; - } - - if (tp != endp) - { - return (0); - } - memcpy (addr, tmp, 16); return (1); } @@ -386,9 +386,9 @@ bool Ipv6Address::IsLocalhost () const bool Ipv6Address::IsMulticast () const { if (m_address[0] == 0xff) - { - return true; - } + { + return true; + } return false; } @@ -404,9 +404,9 @@ Ipv6Address Ipv6Address::CombinePrefix (Ipv6Prefix const& prefix) /* a little bit ugly... */ for (i = 0 ; i < 16 ; i++) - { - addr[i] = addr[i] & pref[i]; - } + { + addr[i] = addr[i] & pref[i]; + } ipv6.Set (addr); return ipv6; } @@ -421,9 +421,9 @@ bool Ipv6Address::IsSolicitedMulticast () const buf[1] == 0x02 && buf[11] == 0x01 && buf[12] == 0xff) - { - return true; - } + { + return true; + } return false; } @@ -533,18 +533,18 @@ bool Ipv6Address::IsLinkLocal () const { Ipv6Address linkLocal ("fe80::0"); if (!IsMulticast () && ((Ipv6Address*)this)->CombinePrefix (Ipv6Prefix (64)) == linkLocal) - { - return true; - } + { + return true; + } return false; } bool Ipv6Address::IsEqual (const Ipv6Address& other) const { if (!memcmp (m_address, other.m_address, 16)) - { - return true; - } + { + return true; + } return false; } @@ -593,18 +593,18 @@ Ipv6Prefix::Ipv6Prefix (uint8_t prefix) memset (m_prefix, 0xff, nb); if (mod) - { - m_prefix[nb] = 0xff << (8-mod); - } + { + m_prefix[nb] = 0xff << (8-mod); + } if (nb < 16) - { - nb++; - for (i = nb; i < 16 ; i++) { - m_prefix[i] = 0x00; + nb++; + for (i = nb; i < 16 ; i++) + { + m_prefix[i] = 0x00; + } } - } } Ipv6Prefix::Ipv6Prefix (Ipv6Prefix const& prefix) @@ -633,12 +633,12 @@ bool Ipv6Prefix::IsMatch (Ipv6Address a, Ipv6Address b) const /* a little bit ugly... */ for (i = 0 ; i < 16 ; i++) - { - if ((addrA[i] & m_prefix[i]) != (addrB[i] & m_prefix[i])) { - return false; + if ((addrA[i] & m_prefix[i]) != (addrB[i] & m_prefix[i])) + { + return false; + } } - } return true; } @@ -691,15 +691,15 @@ uint8_t Ipv6Prefix::GetPrefixLength () const uint8_t prefixLength = 0; for(i = 0 ; i < 16 ; i++) - { - uint8_t mask = m_prefix[i]; - - while(mask != 0) { - mask = mask << 1; - prefixLength++; + uint8_t mask = m_prefix[i]; + + while(mask != 0) + { + mask = mask << 1; + prefixLength++; + } } - } return prefixLength; } @@ -707,9 +707,9 @@ uint8_t Ipv6Prefix::GetPrefixLength () const bool Ipv6Prefix::IsEqual (const Ipv6Prefix& other) const { if (!memcmp (m_prefix, other.m_prefix, 16)) - { - return true; - } + { + return true; + } return false; } diff --git a/src/node/ipv6-address.h b/src/node/ipv6-address.h index 291d1dbe5..67c67fb25 100644 --- a/src/node/ipv6-address.h +++ b/src/node/ipv6-address.h @@ -43,253 +43,253 @@ class Mac48Address; */ class Ipv6Address { - public : - /** - * \brief Default constructor. - */ - Ipv6Address (); +public : + /** + * \brief Default constructor. + */ + Ipv6Address (); - /** - * \brief Constructs an Ipv6Address by parsing the input C-string. - * \param address the C-string containing the IPv6 address (e.g. 2001:660:4701::1). - */ - Ipv6Address (char const* address); + /** + * \brief Constructs an Ipv6Address by parsing the input C-string. + * \param address the C-string containing the IPv6 address (e.g. 2001:660:4701::1). + */ + Ipv6Address (char const* address); - /** - * \brief Constructs an Ipv6Address by using the input 16 bytes. - * \param address the 128-bit address - * \warning the parameter must point on a 16 bytes integer array! - */ - Ipv6Address (uint8_t address[16]); + /** + * \brief Constructs an Ipv6Address by using the input 16 bytes. + * \param address the 128-bit address + * \warning the parameter must point on a 16 bytes integer array! + */ + Ipv6Address (uint8_t address[16]); - /** - * \brief Copy constructor. - * \param addr Ipv6Address object - */ - Ipv6Address (Ipv6Address const & addr); + /** + * \brief Copy constructor. + * \param addr Ipv6Address object + */ + Ipv6Address (Ipv6Address const & addr); - /** - * \brief Copy constructor. - * \param addr Ipv6Address pointer - */ - Ipv6Address (Ipv6Address const* addr); + /** + * \brief Copy constructor. + * \param addr Ipv6Address pointer + */ + Ipv6Address (Ipv6Address const* addr); - /** - * \brief Destructor. - */ - ~Ipv6Address (); + /** + * \brief Destructor. + */ + ~Ipv6Address (); - /** - * \brief Sets an Ipv6Address by parsing the input C-string. - * \param address the C-string containing the IPv6 address (e.g. 2001:660:4701::1). - */ - void Set (char const* address); + /** + * \brief Sets an Ipv6Address by parsing the input C-string. + * \param address the C-string containing the IPv6 address (e.g. 2001:660:4701::1). + */ + void Set (char const* address); - /** - * \brief Set an Ipv6Address by using the input 16 bytes. - * - * \param address the 128-bit address - * \warning the parameter must point on a 16 bytes integer array! - */ - void Set (uint8_t address[16]); + /** + * \brief Set an Ipv6Address by using the input 16 bytes. + * + * \param address the 128-bit address + * \warning the parameter must point on a 16 bytes integer array! + */ + void Set (uint8_t address[16]); - /** - * \brief Comparison operation between two Ipv6Addresses. - * - * \param other the IPv6 address to which to compare thisaddress - * \return true if the addresses are equal, false otherwise - */ - bool IsEqual (const Ipv6Address& other) const; + /** + * \brief Comparison operation between two Ipv6Addresses. + * + * \param other the IPv6 address to which to compare thisaddress + * \return true if the addresses are equal, false otherwise + */ + bool IsEqual (const Ipv6Address& other) const; - /** - * \brief Serialize this address to a 16-byte buffer. - * \param buf the output buffer to which this address gets overwritter with this - * Ipv6Address - */ - void Serialize (uint8_t buf[16]) const; + /** + * \brief Serialize this address to a 16-byte buffer. + * \param buf the output buffer to which this address gets overwritter with this + * Ipv6Address + */ + void Serialize (uint8_t buf[16]) const; - /** - * \brief Deserialize this address. - * \param buf buffer to read address from - * \return an Ipv6Address - */ - static Ipv6Address Deserialize (const uint8_t buf[16]); + /** + * \brief Deserialize this address. + * \param buf buffer to read address from + * \return an Ipv6Address + */ + static Ipv6Address Deserialize (const uint8_t buf[16]); - /** - * \brief Make the solicited IPv6 address. - * \param addr the IPv6 address - * \return Solicited IPv6 address - */ - static Ipv6Address MakeSolicitedAddress (Ipv6Address addr); + /** + * \brief Make the solicited IPv6 address. + * \param addr the IPv6 address + * \return Solicited IPv6 address + */ + static Ipv6Address MakeSolicitedAddress (Ipv6Address addr); - /** - * \brief Make the autoconfigured IPv6 address with Mac48Address. - * \param addr the MAC address (48 bits). - * \param prefix the IPv6 prefix - * \return autoconfigured IPv6 address - */ - static Ipv6Address MakeAutoconfiguredAddress (Mac48Address addr, Ipv6Address prefix); + /** + * \brief Make the autoconfigured IPv6 address with Mac48Address. + * \param addr the MAC address (48 bits). + * \param prefix the IPv6 prefix + * \return autoconfigured IPv6 address + */ + static Ipv6Address MakeAutoconfiguredAddress (Mac48Address addr, Ipv6Address prefix); - /** - * \brief Make the autoconfigured link-local IPv6 address with Mac48Address. - * \param mac the MAC address (48 bits). - * \return autoconfigured link-local IPv6 address - */ - static Ipv6Address MakeAutoconfiguredLinkLocalAddress (Mac48Address mac); + /** + * \brief Make the autoconfigured link-local IPv6 address with Mac48Address. + * \param mac the MAC address (48 bits). + * \return autoconfigured link-local IPv6 address + */ + static Ipv6Address MakeAutoconfiguredLinkLocalAddress (Mac48Address mac); - /** - * \brief Print this address to the given output stream. - * - * The print format is in the typical "2001:660:4701::1". - * \param os the output stream to which this Ipv6Address is printed - */ - void Print (std::ostream& os) const; + /** + * \brief Print this address to the given output stream. + * + * The print format is in the typical "2001:660:4701::1". + * \param os the output stream to which this Ipv6Address is printed + */ + void Print (std::ostream& os) const; - /** - * \brief If the IPv6 address is localhost (::1). - * \return true if localhost, false otherwise - */ - bool IsLocalhost () const; + /** + * \brief If the IPv6 address is localhost (::1). + * \return true if localhost, false otherwise + */ + bool IsLocalhost () const; - /** - * \brief If the IPv6 address is multicast (ff00::/8). - * \return true if multicast, false otherwise - */ - bool IsMulticast () const; + /** + * \brief If the IPv6 address is multicast (ff00::/8). + * \return true if multicast, false otherwise + */ + bool IsMulticast () const; - /** - * \brief If the IPv6 address is "all nodes multicast" (ff02::1/8). - * \return true if "all nodes multicast", false otherwise - */ - bool IsAllNodesMulticast () const; + /** + * \brief If the IPv6 address is "all nodes multicast" (ff02::1/8). + * \return true if "all nodes multicast", false otherwise + */ + bool IsAllNodesMulticast () const; - /** - * \brief If the IPv6 address is "all routers multicast" (ff02::2/8). - * \return true if "all routers multicast", false otherwise - */ - bool IsAllRoutersMulticast () const; + /** + * \brief If the IPv6 address is "all routers multicast" (ff02::2/8). + * \return true if "all routers multicast", false otherwise + */ + bool IsAllRoutersMulticast () const; - /** - * \brief If the IPv6 address is "all hosts multicast" (ff02::3/8). - * \return true if "all hosts multicast", false otherwise - */ - bool IsAllHostsMulticast () const; + /** + * \brief If the IPv6 address is "all hosts multicast" (ff02::3/8). + * \return true if "all hosts multicast", false otherwise + */ + bool IsAllHostsMulticast () const; - /** - * \brief If the IPv6 address is a link-local address (fe80::/64). - * \return true if the address is link-local, false otherwise - */ - bool IsLinkLocal () const; + /** + * \brief If the IPv6 address is a link-local address (fe80::/64). + * \return true if the address is link-local, false otherwise + */ + bool IsLinkLocal () const; - /** - * \brief If the IPv6 address is a Solicited multicast address. - * \return true if it is, false otherwise - */ - bool IsSolicitedMulticast () const; + /** + * \brief If the IPv6 address is a Solicited multicast address. + * \return true if it is, false otherwise + */ + bool IsSolicitedMulticast () const; - /** - * \brief If the IPv6 address is the "Any" address. - * \return true if it is, false otherwise - */ - bool IsAny () const; + /** + * \brief If the IPv6 address is the "Any" address. + * \return true if it is, false otherwise + */ + bool IsAny () const; - /** - * \brief Combine this address with a prefix. - * \param prefix a IPv6 prefix - * \return an IPv6 address that is this address combined - * (bitwise AND) with a prefix, yielding an IPv6 network address. - */ - Ipv6Address CombinePrefix (Ipv6Prefix const & prefix); + /** + * \brief Combine this address with a prefix. + * \param prefix a IPv6 prefix + * \return an IPv6 address that is this address combined + * (bitwise AND) with a prefix, yielding an IPv6 network address. + */ + Ipv6Address CombinePrefix (Ipv6Prefix const & prefix); - /** - * \brief If the Address matches the type. - * \param address other address - * \return true if the type matches, false otherwise - */ - static bool IsMatchingType (const Address& address); + /** + * \brief If the Address matches the type. + * \param address other address + * \return true if the type matches, false otherwise + */ + static bool IsMatchingType (const Address& address); - /** - * \brief Convert to Address object - */ - operator Address () const; + /** + * \brief Convert to Address object + */ + operator Address () const; - /** - * \brief Convert the Address object into an Ipv6Address ones. - * \param address address to convert - * \return an Ipv6Address - */ - static Ipv6Address ConvertFrom (const Address& address); + /** + * \brief Convert the Address object into an Ipv6Address ones. + * \param address address to convert + * \return an Ipv6Address + */ + static Ipv6Address ConvertFrom (const Address& address); - /** - * \brief Get the 0 (::) Ipv6Address. - * \return the :: Ipv6Address representation - */ - static Ipv6Address GetZero (); + /** + * \brief Get the 0 (::) Ipv6Address. + * \return the :: Ipv6Address representation + */ + static Ipv6Address GetZero (); - /** - * \brief Get the "any" (::) Ipv6Address. - * \return the "any" (::) Ipv6Address - */ - static Ipv6Address GetAny (); + /** + * \brief Get the "any" (::) Ipv6Address. + * \return the "any" (::) Ipv6Address + */ + static Ipv6Address GetAny (); - /** - * \brief Get the "all nodes multicast" address. - * \return the "ff02::2/8" Ipv6Address representation - */ - static Ipv6Address GetAllNodesMulticast (); + /** + * \brief Get the "all nodes multicast" address. + * \return the "ff02::2/8" Ipv6Address representation + */ + static Ipv6Address GetAllNodesMulticast (); - /** - * \brief Get the "all routers multicast" address. - * \return the "ff02::2/8" Ipv6Address representation - */ - static Ipv6Address GetAllRoutersMulticast (); + /** + * \brief Get the "all routers multicast" address. + * \return the "ff02::2/8" Ipv6Address representation + */ + static Ipv6Address GetAllRoutersMulticast (); - /** - * \brief Get the "all hosts multicast" address. - * \return the "ff02::3/8" Ipv6Address representation - */ - static Ipv6Address GetAllHostsMulticast (); + /** + * \brief Get the "all hosts multicast" address. + * \return the "ff02::3/8" Ipv6Address representation + */ + static Ipv6Address GetAllHostsMulticast (); - /** - * \brief Get the loopback address. - * \return the "::1/128" Ipv6Address representation. - */ - static Ipv6Address GetLoopback (); + /** + * \brief Get the loopback address. + * \return the "::1/128" Ipv6Address representation. + */ + static Ipv6Address GetLoopback (); - /** - * \brief Get the "all-1" IPv6 address (ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff). - * \return all-1 Ipv6Address representation - */ - static Ipv6Address GetOnes (); + /** + * \brief Get the "all-1" IPv6 address (ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff). + * \return all-1 Ipv6Address representation + */ + static Ipv6Address GetOnes (); - /** - * \brief Get the bytes corresponding to the address. - * \param buf buffer to store the data - * \return bytes of the address - */ - void GetBytes (uint8_t buf[16]) const; + /** + * \brief Get the bytes corresponding to the address. + * \param buf buffer to store the data + * \return bytes of the address + */ + void GetBytes (uint8_t buf[16]) const; - private: - /** - * \brief convert the IPv6Address object to an Address object. - * \return the Address object corresponding to this object. - */ - Address ConvertTo (void) const; +private: + /** + * \brief convert the IPv6Address object to an Address object. + * \return the Address object corresponding to this object. + */ + Address ConvertTo (void) const; - /** - * \brief Return the Type of address. - * \return type of address - */ - static uint8_t GetType (void); + /** + * \brief Return the Type of address. + * \return type of address + */ + static uint8_t GetType (void); - /** - * \brief The address representation on 128 bits (16 bytes). - */ - uint8_t m_address[16]; + /** + * \brief The address representation on 128 bits (16 bytes). + */ + uint8_t m_address[16]; - friend bool operator == (Ipv6Address const &a, Ipv6Address const &b); - friend bool operator != (Ipv6Address const &a, Ipv6Address const &b); - friend bool operator < (Ipv6Address const &a, Ipv6Address const &b); + friend bool operator == (Ipv6Address const &a, Ipv6Address const &b); + friend bool operator != (Ipv6Address const &a, Ipv6Address const &b); + friend bool operator < (Ipv6Address const &a, Ipv6Address const &b); }; /** @@ -300,106 +300,106 @@ class Ipv6Address */ class Ipv6Prefix { - public: - /** - * \brief Default constructor. - */ - Ipv6Prefix (); +public: + /** + * \brief Default constructor. + */ + Ipv6Prefix (); - /** - * \brief Constructs an Ipv6Prefix by using the input 16 bytes. - * \param prefix the 128-bit prefix - */ - Ipv6Prefix (uint8_t prefix[16]); + /** + * \brief Constructs an Ipv6Prefix by using the input 16 bytes. + * \param prefix the 128-bit prefix + */ + Ipv6Prefix (uint8_t prefix[16]); - /** - * \brief Constructs an Ipv6Prefix by using the input string. - * \param prefix the 128-bit prefix - */ - Ipv6Prefix (char const* prefix); + /** + * \brief Constructs an Ipv6Prefix by using the input string. + * \param prefix the 128-bit prefix + */ + Ipv6Prefix (char const* prefix); - /** - * \brief Constructs an Ipv6Prefix by using the input number of bits. - * \param prefix number of bits of the prefix (0 - 128) - * \note A valid number of bits is between 0 and 128). - */ - Ipv6Prefix (uint8_t prefix); + /** + * \brief Constructs an Ipv6Prefix by using the input number of bits. + * \param prefix number of bits of the prefix (0 - 128) + * \note A valid number of bits is between 0 and 128). + */ + Ipv6Prefix (uint8_t prefix); - /** - * \brief Copy constructor. - * \param prefix Ipv6Prefix object - */ - Ipv6Prefix (Ipv6Prefix const& prefix); + /** + * \brief Copy constructor. + * \param prefix Ipv6Prefix object + */ + Ipv6Prefix (Ipv6Prefix const& prefix); - /** - * \brief Copy constructor. - * \param prefix Ipv6Prefix pointer - */ - Ipv6Prefix (Ipv6Prefix const* prefix); + /** + * \brief Copy constructor. + * \param prefix Ipv6Prefix pointer + */ + Ipv6Prefix (Ipv6Prefix const* prefix); - /** - * \brief Destructor. - */ - ~Ipv6Prefix (); + /** + * \brief Destructor. + */ + ~Ipv6Prefix (); - /** - * \brief If the Address match the type. - * \param a a first address - * \param b a second address - * \return true if the type match, false otherwise - */ - bool IsMatch (Ipv6Address a, Ipv6Address b) const; + /** + * \brief If the Address match the type. + * \param a a first address + * \param b a second address + * \return true if the type match, false otherwise + */ + bool IsMatch (Ipv6Address a, Ipv6Address b) const; - /** - * \brief Get the bytes corresponding to the prefix. - * \param buf buffer to store the data - */ - void GetBytes (uint8_t buf[16]) const; + /** + * \brief Get the bytes corresponding to the prefix. + * \param buf buffer to store the data + */ + void GetBytes (uint8_t buf[16]) const; - /** - * \brief Get prefix length. - * \return prefix length - */ - uint8_t GetPrefixLength () const; + /** + * \brief Get prefix length. + * \return prefix length + */ + uint8_t GetPrefixLength () const; - /** - * \brief Comparison operation between two Ipv6Prefix. - * \param other the IPv6 prefix to which to compare this prefix - * \return true if the prefixes are equal, false otherwise - */ - bool IsEqual (const Ipv6Prefix& other) const; + /** + * \brief Comparison operation between two Ipv6Prefix. + * \param other the IPv6 prefix to which to compare this prefix + * \return true if the prefixes are equal, false otherwise + */ + bool IsEqual (const Ipv6Prefix& other) const; - /** - * \brief Print this address to the given output stream. - * - * The print format is in the typicall "2001:660:4701::1". - * \param os the output stream to which this Ipv6Address is printed - */ - void Print (std::ostream &os) const; + /** + * \brief Print this address to the given output stream. + * + * The print format is in the typicall "2001:660:4701::1". + * \param os the output stream to which this Ipv6Address is printed + */ + void Print (std::ostream &os) const; - /** - * \brief Get the loopback prefix ( /128). - * \return a Ipv6Prefix corresponding to loopback prefix - */ - static Ipv6Prefix GetLoopback (); + /** + * \brief Get the loopback prefix ( /128). + * \return a Ipv6Prefix corresponding to loopback prefix + */ + static Ipv6Prefix GetLoopback (); - /** - * \brief Get the "all-1" IPv6 mask (ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff). - * \return /128 Ipv6Prefix representation - */ - static Ipv6Prefix GetOnes (); + /** + * \brief Get the "all-1" IPv6 mask (ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff). + * \return /128 Ipv6Prefix representation + */ + static Ipv6Prefix GetOnes (); - /** - * \brief Get the zero prefix ( /0). - * \return an Ipv6Prefix - */ - static Ipv6Prefix GetZero (); + /** + * \brief Get the zero prefix ( /0). + * \return an Ipv6Prefix + */ + static Ipv6Prefix GetZero (); - private: - /** - * \brief The prefix representation. - */ - uint8_t m_prefix[16]; +private: + /** + * \brief The prefix representation. + */ + uint8_t m_prefix[16]; }; /** @@ -440,12 +440,12 @@ inline bool operator < (const Ipv6Address& a, const Ipv6Address& b) */ class Ipv6AddressHash : public std::unary_function { - public: - /** - * \brief Unary operator to hash IPv6 address. - * \param x IPv6 address to hash - */ - size_t operator () (Ipv6Address const &x) const; +public: + /** + * \brief Unary operator to hash IPv6 address. + * \param x IPv6 address to hash + */ + size_t operator () (Ipv6Address const &x) const; }; bool operator == (Ipv6Prefix const &a, Ipv6Prefix const &b); diff --git a/src/node/ipv6-header.h b/src/node/ipv6-header.h index a2b226dad..197cefd75 100644 --- a/src/node/ipv6-header.h +++ b/src/node/ipv6-header.h @@ -32,197 +32,197 @@ namespace ns3 { */ class Ipv6Header : public Header { - public: - /** - * \enum NextHeader_e - * \brief IPv6 next-header value - */ - enum NextHeader_e - { - IPV6_EXT_HOP_BY_HOP = 0, - IPV6_IPV4 = 4, - IPV6_TCP = 6, - IPV6_UDP = 17, - IPV6_IPV6 = 41, - IPV6_EXT_ROUTING = 43, - IPV6_EXT_FRAGMENTATION = 44, - IPV6_EXT_CONFIDENTIALITY = 50, - IPV6_EXT_AUTHENTIFICATION = 51, - IPV6_ICMPV6 = 58, - IPV6_EXT_END = 59, - IPV6_EXT_DESTINATION = 60, - IPV6_SCTP = 135, - IPV6_EXT_MOBILITY = 135, - IPV6_UDP_LITE = 136, - }; +public: + /** + * \enum NextHeader_e + * \brief IPv6 next-header value + */ + enum NextHeader_e + { + IPV6_EXT_HOP_BY_HOP = 0, + IPV6_IPV4 = 4, + IPV6_TCP = 6, + IPV6_UDP = 17, + IPV6_IPV6 = 41, + IPV6_EXT_ROUTING = 43, + IPV6_EXT_FRAGMENTATION = 44, + IPV6_EXT_CONFIDENTIALITY = 50, + IPV6_EXT_AUTHENTIFICATION = 51, + IPV6_ICMPV6 = 58, + IPV6_EXT_END = 59, + IPV6_EXT_DESTINATION = 60, + IPV6_SCTP = 135, + IPV6_EXT_MOBILITY = 135, + IPV6_UDP_LITE = 136, + }; - /** - * \brief Get the type identifier. - * \return type identifier - */ - static TypeId GetTypeId (void); + /** + * \brief Get the type identifier. + * \return type identifier + */ + static TypeId GetTypeId (void); - /** - * \brief Return the instance type identifier. - * \return instance type ID - */ - virtual TypeId GetInstanceTypeId (void) const; + /** + * \brief Return the instance type identifier. + * \return instance type ID + */ + virtual TypeId GetInstanceTypeId (void) const; - /** - * \brief Constructor. - */ - Ipv6Header (void); + /** + * \brief Constructor. + */ + Ipv6Header (void); - /** - * \brief Set the "Traffic class" field. - * \param traffic the 8-bit value - */ - void SetTrafficClass (uint8_t traffic); + /** + * \brief Set the "Traffic class" field. + * \param traffic the 8-bit value + */ + void SetTrafficClass (uint8_t traffic); - /** - * \brief Get the "Traffic class" field. - * \return the traffic value - */ - uint8_t GetTrafficClass (void) const; + /** + * \brief Get the "Traffic class" field. + * \return the traffic value + */ + uint8_t GetTrafficClass (void) const; - /** - * \brief Set the "Flow label" field. - * \param flow the 20-bit value - */ - void SetFlowLabel (uint32_t flow); + /** + * \brief Set the "Flow label" field. + * \param flow the 20-bit value + */ + void SetFlowLabel (uint32_t flow); - /** - * \brief Get the "Flow label" field. - * \return the flow label value - */ - uint32_t GetFlowLabel (void) const; + /** + * \brief Get the "Flow label" field. + * \return the flow label value + */ + uint32_t GetFlowLabel (void) const; - /** - * \brief Set the "Payload length" field. - * \param len the length of the payload in bytes - */ - void SetPayloadLength (uint16_t len); + /** + * \brief Set the "Payload length" field. + * \param len the length of the payload in bytes + */ + void SetPayloadLength (uint16_t len); - /** - * \brief Get the "Payload length" field. - * \return the payload length - */ - uint16_t GetPayloadLength (void) const; + /** + * \brief Get the "Payload length" field. + * \return the payload length + */ + uint16_t GetPayloadLength (void) const; - /** - * \brief Set the "Next header" field. - * \param next the next header number - */ - void SetNextHeader (uint8_t next); + /** + * \brief Set the "Next header" field. + * \param next the next header number + */ + void SetNextHeader (uint8_t next); - /** - * \brief Get the next header. - * \return the next header number - */ - uint8_t GetNextHeader (void) const; + /** + * \brief Get the next header. + * \return the next header number + */ + uint8_t GetNextHeader (void) const; - /** - * \brief Set the "Hop limit" field (TTL). - * \param limit the 8-bit value - */ - void SetHopLimit (uint8_t limit); + /** + * \brief Set the "Hop limit" field (TTL). + * \param limit the 8-bit value + */ + void SetHopLimit (uint8_t limit); - /** - * \brief Get the "Hop limit" field (TTL). - * \return the hop limit value - */ - uint8_t GetHopLimit (void) const; + /** + * \brief Get the "Hop limit" field (TTL). + * \return the hop limit value + */ + uint8_t GetHopLimit (void) const; - /** - * \brief Set the "Source address" field. - * \param src the source address - */ - void SetSourceAddress (Ipv6Address src); + /** + * \brief Set the "Source address" field. + * \param src the source address + */ + void SetSourceAddress (Ipv6Address src); - /** - * \brief Get the "Source address" field. - * \return the source address - */ - Ipv6Address GetSourceAddress (void) const; + /** + * \brief Get the "Source address" field. + * \return the source address + */ + Ipv6Address GetSourceAddress (void) const; - /** - * \brief Set the "Destination address" field. - * \param dst the destination address - */ - void SetDestinationAddress (Ipv6Address dst); + /** + * \brief Set the "Destination address" field. + * \param dst the destination address + */ + void SetDestinationAddress (Ipv6Address dst); - /** - * \brief Get the "Destination address" field. - * \return the destination address - */ - Ipv6Address GetDestinationAddress (void) const; + /** + * \brief Get the "Destination address" field. + * \return the destination address + */ + Ipv6Address GetDestinationAddress (void) const; - /** - * \brief Print some informations about the packet. - * \param os output stream - * \return info about this packet - */ - virtual void Print (std::ostream& os) const; + /** + * \brief Print some informations about the packet. + * \param os output stream + * \return info about this packet + */ + virtual void Print (std::ostream& os) const; - /** - * \brief Get the serialized size of the packet. - * \return size - */ - virtual uint32_t GetSerializedSize (void) const; + /** + * \brief Get the serialized size of the packet. + * \return size + */ + virtual uint32_t GetSerializedSize (void) const; - /** - * \brief Serialize the packet. - * \param start Buffer iterator - */ - virtual void Serialize (Buffer::Iterator start) const; + /** + * \brief Serialize the packet. + * \param start Buffer iterator + */ + virtual void Serialize (Buffer::Iterator start) const; - /** - * \brief Deserialize the packet. - * \param start Buffer iterator - * \return size of the packet - */ - virtual uint32_t Deserialize (Buffer::Iterator start); + /** + * \brief Deserialize the packet. + * \param start Buffer iterator + * \return size of the packet + */ + virtual uint32_t Deserialize (Buffer::Iterator start); - private: - /** - * \brief The version (always equal to 6). - */ - uint32_t m_version : 4; - /** - * \brief The traffic class. - */ - uint32_t m_trafficClass : 8; +private: + /** + * \brief The version (always equal to 6). + */ + uint32_t m_version : 4; + /** + * \brief The traffic class. + */ + uint32_t m_trafficClass : 8; - /** - * \brief The flow label. - * \note This is 20-bit value. - */ - uint32_t m_flowLabel : 20; + /** + * \brief The flow label. + * \note This is 20-bit value. + */ + uint32_t m_flowLabel : 20; - /** - * \brief The payload length. - */ - uint16_t m_payloadLength; + /** + * \brief The payload length. + */ + uint16_t m_payloadLength; - /** - * \brief The Next header number. - */ - uint8_t m_nextHeader; + /** + * \brief The Next header number. + */ + uint8_t m_nextHeader; - /** - * \brief The Hop limit value. - */ - uint8_t m_hopLimit; + /** + * \brief The Hop limit value. + */ + uint8_t m_hopLimit; - /** - * \brief The source address. - */ - Ipv6Address m_sourceAddress; + /** + * \brief The source address. + */ + Ipv6Address m_sourceAddress; - /** - * \brief The destination address. - */ - Ipv6Address m_destinationAddress; + /** + * \brief The destination address. + */ + Ipv6Address m_destinationAddress; }; } /* namespace ns3 */ diff --git a/src/node/ipv6-interface-address.cc b/src/node/ipv6-interface-address.cc index 90393a50b..22f1d298c 100644 --- a/src/node/ipv6-interface-address.cc +++ b/src/node/ipv6-interface-address.cc @@ -83,21 +83,21 @@ void Ipv6InterfaceAddress::SetAddress (Ipv6Address address) m_address = address; if (address.IsLocalhost ()) - { - m_scope = HOST; - /* localhost address is always /128 prefix */ - m_prefix = Ipv6Prefix (128); - } + { + m_scope = HOST; + /* localhost address is always /128 prefix */ + m_prefix = Ipv6Prefix (128); + } if (address.IsLinkLocal ()) - { - m_scope = LINKLOCAL; - /* link-local address is always /64 prefix */ - m_prefix = Ipv6Prefix (64); - } + { + m_scope = LINKLOCAL; + /* link-local address is always /64 prefix */ + m_prefix = Ipv6Prefix (64); + } else - { - m_scope = GLOBAL; - } + { + m_scope = GLOBAL; + } } Ipv6Prefix Ipv6InterfaceAddress::GetPrefix () const diff --git a/src/node/ipv6-interface-address.h b/src/node/ipv6-interface-address.h index 20648da82..45ce60bfc 100644 --- a/src/node/ipv6-interface-address.h +++ b/src/node/ipv6-interface-address.h @@ -35,157 +35,157 @@ namespace ns3 */ class Ipv6InterfaceAddress { - public: - /** - * \enum State_e - * \brief State of an address associated with an interface. - */ - enum State_e - { - TENTATIVE, /**< Address is tentative, no packet can be sent unless DAD finished */ - DEPRECATED, /**< Address is deprecated and should not be used */ - PREFERRED, /**< Preferred address */ - PERMANENT, /**< Permanent address */ - HOMEADDRESS, /**< Address is a HomeAddress */ - TENTATIVE_OPTIMISTIC, /**< Address is tentative but we are optimistic so we can send packet even if DAD is not yet finished */ - INVALID, /**< Invalid state (after a DAD failed) */ - }; +public: + /** + * \enum State_e + * \brief State of an address associated with an interface. + */ + enum State_e + { + TENTATIVE, /**< Address is tentative, no packet can be sent unless DAD finished */ + DEPRECATED, /**< Address is deprecated and should not be used */ + PREFERRED, /**< Preferred address */ + PERMANENT, /**< Permanent address */ + HOMEADDRESS, /**< Address is a HomeAddress */ + TENTATIVE_OPTIMISTIC, /**< Address is tentative but we are optimistic so we can send packet even if DAD is not yet finished */ + INVALID, /**< Invalid state (after a DAD failed) */ + }; - /** - * \enum Scope_e - * \brief Scope of address. - */ - enum Scope_e - { - HOST, /**< Localhost (::1/128) */ - LINKLOCAL, /**< Link-local address (fe80::/64) */ - GLOBAL, /**< Global address (2000::/3) */ - }; + /** + * \enum Scope_e + * \brief Scope of address. + */ + enum Scope_e + { + HOST, /**< Localhost (::1/128) */ + LINKLOCAL, /**< Link-local address (fe80::/64) */ + GLOBAL, /**< Global address (2000::/3) */ + }; - /** - * \brief Default constructor. - */ - Ipv6InterfaceAddress (); + /** + * \brief Default constructor. + */ + Ipv6InterfaceAddress (); - /** - * \brief Constructor. Prefix is 64 by default. - * \param address the IPv6 address to set - */ - Ipv6InterfaceAddress (Ipv6Address address); + /** + * \brief Constructor. Prefix is 64 by default. + * \param address the IPv6 address to set + */ + Ipv6InterfaceAddress (Ipv6Address address); - /** - * \brief Constructor. - * \param address IPv6 address to set - * \param prefix IPv6 prefix - */ - Ipv6InterfaceAddress (Ipv6Address address, Ipv6Prefix prefix); + /** + * \brief Constructor. + * \param address IPv6 address to set + * \param prefix IPv6 prefix + */ + Ipv6InterfaceAddress (Ipv6Address address, Ipv6Prefix prefix); - /** - * \brief Copy constructor. - * \param o object to copy - */ - Ipv6InterfaceAddress (const Ipv6InterfaceAddress& o); - - /** - * \brief Destructor. - */ - ~Ipv6InterfaceAddress (); + /** + * \brief Copy constructor. + * \param o object to copy + */ + Ipv6InterfaceAddress (const Ipv6InterfaceAddress& o); - /** - * \brief Set IPv6 address (and scope). - * \param address IPv6 address to set - */ - void SetAddress (Ipv6Address address); + /** + * \brief Destructor. + */ + ~Ipv6InterfaceAddress (); - /** - * \brief Get the IPv6 address. - * \return IPv6 address - */ - Ipv6Address GetAddress () const; + /** + * \brief Set IPv6 address (and scope). + * \param address IPv6 address to set + */ + void SetAddress (Ipv6Address address); - /** - * \brief Get the IPv6 prefix. - * \return IPv6 prefix - */ - Ipv6Prefix GetPrefix () const; + /** + * \brief Get the IPv6 address. + * \return IPv6 address + */ + Ipv6Address GetAddress () const; - /** - * \brief Set the state. - * \param state the state - */ - void SetState (Ipv6InterfaceAddress::State_e state); + /** + * \brief Get the IPv6 prefix. + * \return IPv6 prefix + */ + Ipv6Prefix GetPrefix () const; - /** - * \brief Get the address state. - * \return address state - */ - Ipv6InterfaceAddress::State_e GetState () const; + /** + * \brief Set the state. + * \param state the state + */ + void SetState (Ipv6InterfaceAddress::State_e state); - /** - * \brief Set the scope. - * \param scope the scope of address - */ - void SetScope (Ipv6InterfaceAddress::Scope_e scope); - - /** - * \brief Get address scope. - * \return scope - */ - Ipv6InterfaceAddress::Scope_e GetScope () const; + /** + * \brief Get the address state. + * \return address state + */ + Ipv6InterfaceAddress::State_e GetState () const; - /** - * \brief Set the latest DAD probe packet UID. - * \param uid packet uid - */ - void SetNsDadUid (uint32_t uid); + /** + * \brief Set the scope. + * \param scope the scope of address + */ + void SetScope (Ipv6InterfaceAddress::Scope_e scope); - /** - * \brief Get the latest DAD probe packet UID. - * \return uid - */ - uint32_t GetNsDadUid () const; + /** + * \brief Get address scope. + * \return scope + */ + Ipv6InterfaceAddress::Scope_e GetScope () const; + + /** + * \brief Set the latest DAD probe packet UID. + * \param uid packet uid + */ + void SetNsDadUid (uint32_t uid); + + /** + * \brief Get the latest DAD probe packet UID. + * \return uid + */ + uint32_t GetNsDadUid () const; #if 0 - /** - * \brief Start the DAD timer. - * \param interface interface - */ - void StartDadTimer (Ptr interface); + /** + * \brief Start the DAD timer. + * \param interface interface + */ + void StartDadTimer (Ptr interface); - /** - * \brief Stop the DAD timer. - */ - void StopDadTimer (); + /** + * \brief Stop the DAD timer. + */ + void StopDadTimer (); #endif - private: - /** - * \brief The IPv6 address. - */ - Ipv6Address m_address; +private: + /** + * \brief The IPv6 address. + */ + Ipv6Address m_address; - /** - * \brief The IPv6 prefix. - */ - Ipv6Prefix m_prefix; + /** + * \brief The IPv6 prefix. + */ + Ipv6Prefix m_prefix; - /** - * \brief State of the address. - */ - State_e m_state; + /** + * \brief State of the address. + */ + State_e m_state; - /** - * \brief Scope of the address. - */ - Scope_e m_scope; + /** + * \brief Scope of the address. + */ + Scope_e m_scope; - friend bool operator == (Ipv6InterfaceAddress const& a, Ipv6InterfaceAddress const& b); - friend bool operator != (Ipv6InterfaceAddress const& a, Ipv6InterfaceAddress const& b); + friend bool operator == (Ipv6InterfaceAddress const& a, Ipv6InterfaceAddress const& b); + friend bool operator != (Ipv6InterfaceAddress const& a, Ipv6InterfaceAddress const& b); - /** - * \brief Last DAD probe packet UID. - */ - uint32_t m_nsDadUid; + /** + * \brief Last DAD probe packet UID. + */ + uint32_t m_nsDadUid; }; std::ostream& operator<< (std::ostream& os, const Ipv6InterfaceAddress &addr); @@ -194,13 +194,13 @@ std::ostream& operator<< (std::ostream& os, const Ipv6InterfaceAddress &addr); inline bool operator == (const Ipv6InterfaceAddress& a, const Ipv6InterfaceAddress& b) { return (a.m_address == b.m_address && a.m_prefix == b.m_prefix && - a.m_state == b.m_state && a.m_scope == b.m_scope); + a.m_state == b.m_state && a.m_scope == b.m_scope); } inline bool operator != (const Ipv6InterfaceAddress& a, const Ipv6InterfaceAddress& b) { return (a.m_address != b.m_address || a.m_prefix != b.m_prefix || - a.m_state != b.m_state || a.m_scope != b.m_scope); + a.m_state != b.m_state || a.m_scope != b.m_scope); } } /* namespace ns3 */ diff --git a/src/node/ipv6-raw-socket-factory.h b/src/node/ipv6-raw-socket-factory.h index 66361fb6e..f9941b480 100644 --- a/src/node/ipv6-raw-socket-factory.h +++ b/src/node/ipv6-raw-socket-factory.h @@ -38,12 +38,12 @@ class Socket; */ class Ipv6RawSocketFactory : public SocketFactory { - public: - /** - * \brief Get the type ID of this class. - * \return type ID - */ - static TypeId GetTypeId (void); +public: + /** + * \brief Get the type ID of this class. + * \return type ID + */ + static TypeId GetTypeId (void); }; } // namespace ns3 diff --git a/src/node/ipv6-route.cc b/src/node/ipv6-route.cc index 573d63452..c4de3fcd5 100644 --- a/src/node/ipv6-route.cc +++ b/src/node/ipv6-route.cc @@ -39,8 +39,7 @@ void Ipv6Route::SetDestination (Ipv6Address dest) m_dest = dest; } -Ipv6Address -Ipv6Route::GetDestination () const +Ipv6Address Ipv6Route::GetDestination () const { return m_dest; } @@ -77,8 +76,8 @@ Ptr Ipv6Route::GetOutputDevice () const std::ostream& operator<< (std::ostream& os, Ipv6Route const& route) { - os << "source=" << route.GetSource () << " dest="<< route.GetDestination () <<" gw=" << route.GetGateway (); - return os; + os << "source=" << route.GetSource () << " dest="<< route.GetDestination () <<" gw=" << route.GetGateway (); + return os; } Ipv6MulticastRoute::Ipv6MulticastRoute () @@ -87,9 +86,9 @@ Ipv6MulticastRoute::Ipv6MulticastRoute () /* Initialize array to MAX_TTL, which means that all interfaces are "off" */ for (uint32_t i = 0; i < MAX_INTERFACES; i++) - { - m_ttls.push_back (initial_ttl); - } + { + m_ttls.push_back (initial_ttl); + } } Ipv6MulticastRoute::~Ipv6MulticastRoute () @@ -138,8 +137,8 @@ uint32_t Ipv6MulticastRoute::GetOutputTtl (uint32_t oif) const std::ostream& operator<< (std::ostream& os, Ipv6MulticastRoute const& route) { - os << "origin=" << route.GetOrigin () << " group="<< route.GetGroup () <<" parent=" << route.GetParent (); - return os; + os << "origin=" << route.GetOrigin () << " group="<< route.GetGroup () <<" parent=" << route.GetParent (); + return os; } } /* namespace ns3 */ diff --git a/src/node/ipv6-route.h b/src/node/ipv6-route.h index c7554f225..e87e6787d 100644 --- a/src/node/ipv6-route.h +++ b/src/node/ipv6-route.h @@ -41,85 +41,85 @@ class NetDevice; */ class Ipv6Route : public SimpleRefCount { - public: - /** - * \brief Constructor. - */ - Ipv6Route (); +public: + /** + * \brief Constructor. + */ + Ipv6Route (); - /** - * \brief Destructor. - */ - virtual ~Ipv6Route (); + /** + * \brief Destructor. + */ + virtual ~Ipv6Route (); - /** - * \brief Set destination address. - * \param dest IPv6 destination address - */ - void SetDestination (Ipv6Address dest); + /** + * \brief Set destination address. + * \param dest IPv6 destination address + */ + void SetDestination (Ipv6Address dest); - /** - * \brief Get destination address. - * \return destination address - */ - Ipv6Address GetDestination () const; + /** + * \brief Get destination address. + * \return destination address + */ + Ipv6Address GetDestination () const; - /** - * \brief Set source address. - * \param src IPv6 source address - */ - void SetSource (Ipv6Address src); + /** + * \brief Set source address. + * \param src IPv6 source address + */ + void SetSource (Ipv6Address src); - /** - * \brief Get source address. - * \return source address - */ - Ipv6Address GetSource () const; + /** + * \brief Get source address. + * \return source address + */ + Ipv6Address GetSource () const; - /** - * \brief Set gateway address. - * \param gw IPv6 gateway address - */ - void SetGateway (Ipv6Address gw); + /** + * \brief Set gateway address. + * \param gw IPv6 gateway address + */ + void SetGateway (Ipv6Address gw); - /** - * \brief Get gateway address. - * \return gateway address - */ - Ipv6Address GetGateway () const; + /** + * \brief Get gateway address. + * \return gateway address + */ + Ipv6Address GetGateway () const; - /** - * \brief Set output device for outgoing packets. - * \param outputDevice output device - */ - void SetOutputDevice (Ptr outputDevice); + /** + * \brief Set output device for outgoing packets. + * \param outputDevice output device + */ + void SetOutputDevice (Ptr outputDevice); - /** - * \brief Get output device. - * \return output device - */ - Ptr GetOutputDevice () const; + /** + * \brief Get output device. + * \return output device + */ + Ptr GetOutputDevice () const; - private: - /** - * \brief Destination address. - */ - Ipv6Address m_dest; +private: + /** + * \brief Destination address. + */ + Ipv6Address m_dest; - /** - * \brief source address. - */ - Ipv6Address m_source; + /** + * \brief source address. + */ + Ipv6Address m_source; - /** - * \brief Gateway address. - */ - Ipv6Address m_gateway; + /** + * \brief Gateway address. + */ + Ipv6Address m_gateway; - /** - * \brief Output device. - */ - Ptr m_outputDevice; + /** + * \brief Output device. + */ + Ptr m_outputDevice; }; std::ostream& operator<< (std::ostream& os, Ipv6Route const& route); @@ -131,97 +131,97 @@ std::ostream& operator<< (std::ostream& os, Ipv6Route const& route); */ class Ipv6MulticastRoute : public SimpleRefCount { - public: - /** - * \brief Maximum number of multicast interfaces on a router. - */ - static const uint32_t MAX_INTERFACES = 16; +public: + /** + * \brief Maximum number of multicast interfaces on a router. + */ + static const uint32_t MAX_INTERFACES = 16; - /** - * \brief Maximum Time-To-Live (TTL). - */ - static const uint32_t MAX_TTL = 255; + /** + * \brief Maximum Time-To-Live (TTL). + */ + static const uint32_t MAX_TTL = 255; - /** - * \brief Constructor. - */ - Ipv6MulticastRoute (); + /** + * \brief Constructor. + */ + Ipv6MulticastRoute (); - /** - * \brief Destructor. - */ - virtual ~Ipv6MulticastRoute (); + /** + * \brief Destructor. + */ + virtual ~Ipv6MulticastRoute (); - /** - * \brief Set IPv6 group. - * \param group Ipv6Address of the multicast group - */ - void SetGroup (const Ipv6Address group); + /** + * \brief Set IPv6 group. + * \param group Ipv6Address of the multicast group + */ + void SetGroup (const Ipv6Address group); - /** - * \brief Get IPv6 group. - * \return Ipv6Address of the multicast group - */ - Ipv6Address GetGroup (void) const; + /** + * \brief Get IPv6 group. + * \return Ipv6Address of the multicast group + */ + Ipv6Address GetGroup (void) const; - /** - * \brief Set origin address. - * \param origin Ipv6Address of the origin address - */ - void SetOrigin (const Ipv6Address origin); + /** + * \brief Set origin address. + * \param origin Ipv6Address of the origin address + */ + void SetOrigin (const Ipv6Address origin); - /** - * \brief Get source address. - * \return Ipv6Address of the origin address - */ - Ipv6Address GetOrigin (void) const; + /** + * \brief Get source address. + * \return Ipv6Address of the origin address + */ + Ipv6Address GetOrigin (void) const; - /** - * \brief Set parent for this route. - * \param iif Parent (input interface) for this route - */ - void SetParent (uint32_t iif); + /** + * \brief Set parent for this route. + * \param iif Parent (input interface) for this route + */ + void SetParent (uint32_t iif); - /** - * \brief Get parent for this route. - * \return Parent (input interface) for this route - */ - uint32_t GetParent (void) const; + /** + * \brief Get parent for this route. + * \return Parent (input interface) for this route + */ + uint32_t GetParent (void) const; - /** - * \brief set output TTL for this route. - * \param oif Outgoing interface index - * \param ttl time-to-live for this route - */ - void SetOutputTtl (uint32_t oif, uint32_t ttl); + /** + * \brief set output TTL for this route. + * \param oif Outgoing interface index + * \param ttl time-to-live for this route + */ + void SetOutputTtl (uint32_t oif, uint32_t ttl); - /** - * \brief Get output TTL for this route. - * \param oif outgoing interface - * \return TTL for this route - */ - uint32_t GetOutputTtl (uint32_t oif) const; + /** + * \brief Get output TTL for this route. + * \param oif outgoing interface + * \return TTL for this route + */ + uint32_t GetOutputTtl (uint32_t oif) const; - private: - /** - * \brief IPv6 group. - */ - Ipv6Address m_group; +private: + /** + * \brief IPv6 group. + */ + Ipv6Address m_group; - /** - * \brief IPv6 origin (source). - */ - Ipv6Address m_origin; + /** + * \brief IPv6 origin (source). + */ + Ipv6Address m_origin; - /** - * \brief Source interface. - */ - uint32_t m_parent; + /** + * \brief Source interface. + */ + uint32_t m_parent; - /** - * \brief TTLs. - */ - std::vector m_ttls; + /** + * \brief TTLs. + */ + std::vector m_ttls; }; std::ostream& operator<< (std::ostream& os, Ipv6MulticastRoute const& route); diff --git a/src/node/ipv6-routing-protocol.h b/src/node/ipv6-routing-protocol.h index 45cc071ba..0dbf188c1 100644 --- a/src/node/ipv6-routing-protocol.h +++ b/src/node/ipv6-routing-protocol.h @@ -59,7 +59,7 @@ public: typedef Callback, Ptr, const Ipv6Header &> MulticastForwardCallback; typedef Callback, const Ipv6Header &, uint32_t > LocalDeliverCallback; typedef Callback, const Ipv6Header &, Socket::SocketErrno > ErrorCallback; - + /** * \brief Query routing cache for an existing route, for an outbound packet * @@ -77,7 +77,7 @@ public: * \returns a code that indicates what happened in the lookup */ virtual Ptr RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, Socket::SocketErrno &sockerr) = 0; - + /** * \brief Route an input packet (to be forwarded or locally delivered) * @@ -100,8 +100,8 @@ public: * forwarding or delivering the packet, false otherwise */ virtual bool RouteInput (Ptr p, const Ipv6Header &header, Ptr idev, - UnicastForwardCallback ucb, MulticastForwardCallback mcb, - LocalDeliverCallback lcb, ErrorCallback ecb) = 0; + UnicastForwardCallback ucb, MulticastForwardCallback mcb, + LocalDeliverCallback lcb, ErrorCallback ecb) = 0; /** * \brief Notify when specified interface goes UP. @@ -111,7 +111,7 @@ public: * \param interface the index of the interface we are being notified about */ virtual void NotifyInterfaceUp (uint32_t interface) = 0; - + /** * \brief Notify when specified interface goes DOWN. * diff --git a/src/routing/list-routing/ipv6-list-routing.cc b/src/routing/list-routing/ipv6-list-routing.cc index e019f8f80..a053038a1 100644 --- a/src/routing/list-routing/ipv6-list-routing.cc +++ b/src/routing/list-routing/ipv6-list-routing.cc @@ -42,7 +42,7 @@ Ipv6ListRouting::GetTypeId (void) Ipv6ListRouting::Ipv6ListRouting () - : m_ipv6 (0) + : m_ipv6 (0) { NS_LOG_FUNCTION_NOARGS (); } @@ -116,16 +116,16 @@ Ipv6ListRouting::RouteInput (Ptr p, const Ipv6Header &header, Ptr< #ifdef NOTYET if (m_ipv6->MulticastCheckGroup (iif, dst)) #endif - if (true) - { - NS_LOG_LOGIC ("Multicast packet for me-- local deliver"); - Ptr packetCopy = p->Copy (); - // Here may want to disable lcb callback in recursive RouteInput - // call below - lcb (packetCopy, header, iif); - // Fall through-- we may also need to forward this - retVal = true; - } + if (true) + { + NS_LOG_LOGIC ("Multicast packet for me-- local deliver"); + Ptr packetCopy = p->Copy (); + // Here may want to disable lcb callback in recursive RouteInput + // call below + lcb (packetCopy, header, iif); + // Fall through-- we may also need to forward this + retVal = true; + } /* do not forward link-local multicast address */ if (dst == Ipv6Address::GetAllNodesMulticast () || dst == Ipv6Address::GetAllRoutersMulticast () || dst == Ipv6Address::GetAllHostsMulticast ()) @@ -134,7 +134,7 @@ Ipv6ListRouting::RouteInput (Ptr p, const Ipv6Header &header, Ptr< } for (Ipv6RoutingProtocolList::const_iterator rprotoIter = - m_routingProtocols.begin (); rprotoIter != m_routingProtocols.end (); + m_routingProtocols.begin (); rprotoIter != m_routingProtocols.end (); rprotoIter++) { NS_LOG_LOGIC ("Multicast packet for me-- trying to forward"); @@ -146,12 +146,12 @@ Ipv6ListRouting::RouteInput (Ptr p, const Ipv6Header &header, Ptr< return retVal; } - // TODO: Configurable option to enable RFC 1222 Strong End System Model - // Right now, we will be permissive and allow a source to send us - // a packet to one of our other interface addresses; that is, the - // destination unicast address does not match one of the iif addresses, - // but we check our other interfaces. This could be an option - // (to remove the outer loop immediately below and just check iif). + // TODO: Configurable option to enable RFC 1222 Strong End System Model + // Right now, we will be permissive and allow a source to send us + // a packet to one of our other interface addresses; that is, the + // destination unicast address does not match one of the iif addresses, + // but we check our other interfaces. This could be an option + // (to remove the outer loop immediately below and just check iif). for (uint32_t j = 0; j < m_ipv6->GetNInterfaces (); j++) { for (uint32_t i = 0; i < m_ipv6->GetNAddresses (j); i++) @@ -183,7 +183,7 @@ Ipv6ListRouting::RouteInput (Ptr p, const Ipv6Header &header, Ptr< } // Next, try to find a route for (Ipv6RoutingProtocolList::const_iterator rprotoIter = - m_routingProtocols.begin (); + m_routingProtocols.begin (); rprotoIter != m_routingProtocols.end (); rprotoIter++) { @@ -201,7 +201,7 @@ Ipv6ListRouting::NotifyInterfaceUp (uint32_t interface) { NS_LOG_FUNCTION (this << interface); for (Ipv6RoutingProtocolList::const_iterator rprotoIter = - m_routingProtocols.begin (); + m_routingProtocols.begin (); rprotoIter != m_routingProtocols.end (); rprotoIter++) { @@ -213,7 +213,7 @@ Ipv6ListRouting::NotifyInterfaceDown (uint32_t interface) { NS_LOG_FUNCTION (this << interface); for (Ipv6RoutingProtocolList::const_iterator rprotoIter = - m_routingProtocols.begin (); + m_routingProtocols.begin (); rprotoIter != m_routingProtocols.end (); rprotoIter++) { @@ -225,7 +225,7 @@ Ipv6ListRouting::NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress addr { NS_LOG_FUNCTION (this << interface << address); for (Ipv6RoutingProtocolList::const_iterator rprotoIter = - m_routingProtocols.begin (); + m_routingProtocols.begin (); rprotoIter != m_routingProtocols.end (); rprotoIter++) { @@ -237,7 +237,7 @@ Ipv6ListRouting::NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress a { NS_LOG_FUNCTION (this << interface << address); for (Ipv6RoutingProtocolList::const_iterator rprotoIter = - m_routingProtocols.begin (); + m_routingProtocols.begin (); rprotoIter != m_routingProtocols.end (); rprotoIter++) { @@ -249,7 +249,7 @@ void Ipv6ListRouting::NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Addr { NS_LOG_FUNCTION (this << dst << mask << nextHop << interface); for (Ipv6RoutingProtocolList::const_iterator rprotoIter = - m_routingProtocols.begin (); + m_routingProtocols.begin (); rprotoIter != m_routingProtocols.end (); rprotoIter++) { @@ -261,7 +261,7 @@ void Ipv6ListRouting::NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6A { NS_LOG_FUNCTION (this << dst << mask << nextHop << interface); for (Ipv6RoutingProtocolList::const_iterator rprotoIter = - m_routingProtocols.begin (); + m_routingProtocols.begin (); rprotoIter != m_routingProtocols.end (); rprotoIter++) { @@ -275,7 +275,7 @@ Ipv6ListRouting::SetIpv6 (Ptr ipv6) NS_LOG_FUNCTION (this << ipv6); NS_ASSERT (m_ipv6 == 0); for (Ipv6RoutingProtocolList::const_iterator rprotoIter = - m_routingProtocols.begin (); + m_routingProtocols.begin (); rprotoIter != m_routingProtocols.end (); rprotoIter++) { @@ -340,113 +340,113 @@ Ipv6ListRouting::Compare (const Ipv6RoutingProtocolEntry& a, const Ipv6RoutingPr namespace ns3 { -class Ipv6ARouting : public Ipv6RoutingProtocol { -public: - Ptr RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, Socket::SocketErrno &sockerr) { return 0;} - bool RouteInput (Ptr p, const Ipv6Header &header, Ptr idev, - UnicastForwardCallback ucb, MulticastForwardCallback mcb, - LocalDeliverCallback lcb, ErrorCallback ecb) {return false;} - void NotifyInterfaceUp (uint32_t interface) {} - void NotifyInterfaceDown (uint32_t interface) {} - void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address) {} - void NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress address) {} - void NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address:: - GetZero ()) {} - void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse) {} - void SetIpv6 (Ptr ipv6) {} -}; + class Ipv6ARouting : public Ipv6RoutingProtocol { + public: + Ptr RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, Socket::SocketErrno &sockerr) { return 0;} + bool RouteInput (Ptr p, const Ipv6Header &header, Ptr idev, + UnicastForwardCallback ucb, MulticastForwardCallback mcb, + LocalDeliverCallback lcb, ErrorCallback ecb) {return false;} + void NotifyInterfaceUp (uint32_t interface) {} + void NotifyInterfaceDown (uint32_t interface) {} + void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address) {} + void NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress address) {} + void NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address:: + GetZero ()) {} + void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse) {} + void SetIpv6 (Ptr ipv6) {} + }; -class Ipv6BRouting : public Ipv6RoutingProtocol { -public: - Ptr RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, Socket::SocketErrno &sockerr) { return 0;} - bool RouteInput (Ptr p, const Ipv6Header &header, Ptr idev, - UnicastForwardCallback ucb, MulticastForwardCallback mcb, - LocalDeliverCallback lcb, ErrorCallback ecb) {return false;} - void NotifyInterfaceUp (uint32_t interface) {} - void NotifyInterfaceDown (uint32_t interface) {} - void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address) {} - void NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress address) {} - void NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address:: - GetZero ()) {} - void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse) {} - void SetIpv6 (Ptr ipv6) {} -}; + class Ipv6BRouting : public Ipv6RoutingProtocol { + public: + Ptr RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, Socket::SocketErrno &sockerr) { return 0;} + bool RouteInput (Ptr p, const Ipv6Header &header, Ptr idev, + UnicastForwardCallback ucb, MulticastForwardCallback mcb, + LocalDeliverCallback lcb, ErrorCallback ecb) {return false;} + void NotifyInterfaceUp (uint32_t interface) {} + void NotifyInterfaceDown (uint32_t interface) {} + void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address) {} + void NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress address) {} + void NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address:: + GetZero ()) {} + void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse) {} + void SetIpv6 (Ptr ipv6) {} + }; -class Ipv6ListRoutingNegativeTestCase : public TestCase -{ -public: - Ipv6ListRoutingNegativeTestCase(); - virtual bool DoRun (void); -}; + class Ipv6ListRoutingNegativeTestCase : public TestCase + { + public: + Ipv6ListRoutingNegativeTestCase(); + virtual bool DoRun (void); + }; -Ipv6ListRoutingNegativeTestCase::Ipv6ListRoutingNegativeTestCase() - : TestCase("Check negative priorities") -{} -bool -Ipv6ListRoutingNegativeTestCase::DoRun (void) -{ - Ptr lr = CreateObject (); - Ptr aRouting = CreateObject (); - Ptr bRouting = CreateObject (); - // The Ipv6BRouting should be added with higher priority (larger integer value) - lr->AddRoutingProtocol (aRouting, -10); - lr->AddRoutingProtocol (bRouting, -5); - int16_t first = 3; - uint32_t num = lr->GetNRoutingProtocols (); - NS_TEST_ASSERT_MSG_EQ (num, 2, "XXX"); - Ptr firstRp = lr->GetRoutingProtocol (0, first); - NS_TEST_ASSERT_MSG_EQ (-5, first, "XXX"); - NS_TEST_ASSERT_MSG_EQ (firstRp, bRouting, "XXX"); + Ipv6ListRoutingNegativeTestCase::Ipv6ListRoutingNegativeTestCase() + : TestCase("Check negative priorities") + {} + bool + Ipv6ListRoutingNegativeTestCase::DoRun (void) + { + Ptr lr = CreateObject (); + Ptr aRouting = CreateObject (); + Ptr bRouting = CreateObject (); + // The Ipv6BRouting should be added with higher priority (larger integer value) + lr->AddRoutingProtocol (aRouting, -10); + lr->AddRoutingProtocol (bRouting, -5); + int16_t first = 3; + uint32_t num = lr->GetNRoutingProtocols (); + NS_TEST_ASSERT_MSG_EQ (num, 2, "XXX"); + Ptr firstRp = lr->GetRoutingProtocol (0, first); + NS_TEST_ASSERT_MSG_EQ (-5, first, "XXX"); + NS_TEST_ASSERT_MSG_EQ (firstRp, bRouting, "XXX"); - // XXX - return false; -} + // XXX + return false; + } -class Ipv6ListRoutingPositiveTestCase : public TestCase -{ -public: - Ipv6ListRoutingPositiveTestCase(); - virtual bool DoRun (void); -}; + class Ipv6ListRoutingPositiveTestCase : public TestCase + { + public: + Ipv6ListRoutingPositiveTestCase(); + virtual bool DoRun (void); + }; -Ipv6ListRoutingPositiveTestCase::Ipv6ListRoutingPositiveTestCase() - : TestCase("Check positive priorities") -{} -bool -Ipv6ListRoutingPositiveTestCase::DoRun (void) -{ - Ptr lr = CreateObject (); - Ptr aRouting = CreateObject (); - Ptr bRouting = CreateObject (); - // The Ipv6ARouting should be added with higher priority (larger integer - // value) and will be fetched first below - lr->AddRoutingProtocol (aRouting, 10); - lr->AddRoutingProtocol (bRouting, 5); - int16_t first = 3; - int16_t second = 3; - uint32_t num = lr->GetNRoutingProtocols (); - NS_TEST_ASSERT_MSG_EQ (num, 2, "XXX"); - Ptr firstRp = lr->GetRoutingProtocol (0, first); - NS_TEST_ASSERT_MSG_EQ (10, first, "XXX"); - NS_TEST_ASSERT_MSG_EQ (firstRp, aRouting, "XXX"); - Ptr secondRp = lr->GetRoutingProtocol (1, second); - NS_TEST_ASSERT_MSG_EQ (5, second, "XXX"); - NS_TEST_ASSERT_MSG_EQ (secondRp, bRouting, "XXX"); - - // XXX - return false; -} + Ipv6ListRoutingPositiveTestCase::Ipv6ListRoutingPositiveTestCase() + : TestCase("Check positive priorities") + {} + bool + Ipv6ListRoutingPositiveTestCase::DoRun (void) + { + Ptr lr = CreateObject (); + Ptr aRouting = CreateObject (); + Ptr bRouting = CreateObject (); + // The Ipv6ARouting should be added with higher priority (larger integer + // value) and will be fetched first below + lr->AddRoutingProtocol (aRouting, 10); + lr->AddRoutingProtocol (bRouting, 5); + int16_t first = 3; + int16_t second = 3; + uint32_t num = lr->GetNRoutingProtocols (); + NS_TEST_ASSERT_MSG_EQ (num, 2, "XXX"); + Ptr firstRp = lr->GetRoutingProtocol (0, first); + NS_TEST_ASSERT_MSG_EQ (10, first, "XXX"); + NS_TEST_ASSERT_MSG_EQ (firstRp, aRouting, "XXX"); + Ptr secondRp = lr->GetRoutingProtocol (1, second); + NS_TEST_ASSERT_MSG_EQ (5, second, "XXX"); + NS_TEST_ASSERT_MSG_EQ (secondRp, bRouting, "XXX"); -static class Ipv6ListRoutingTestSuite : public TestSuite -{ -public: - Ipv6ListRoutingTestSuite() - : TestSuite("ipv6-list-routing", UNIT) - { - AddTestCase(new Ipv6ListRoutingPositiveTestCase()); - AddTestCase(new Ipv6ListRoutingNegativeTestCase()); - } + // XXX + return false; + } -} g_ipv6ListRoutingTestSuite; + static class Ipv6ListRoutingTestSuite : public TestSuite + { + public: + Ipv6ListRoutingTestSuite() + : TestSuite("ipv6-list-routing", UNIT) + { + AddTestCase(new Ipv6ListRoutingPositiveTestCase()); + AddTestCase(new Ipv6ListRoutingNegativeTestCase()); + } + + } g_ipv6ListRoutingTestSuite; } // namespace ns3 diff --git a/src/routing/list-routing/ipv6-list-routing.h b/src/routing/list-routing/ipv6-list-routing.h index 19a842edb..d2fe0373a 100644 --- a/src/routing/list-routing/ipv6-list-routing.h +++ b/src/routing/list-routing/ipv6-list-routing.h @@ -70,13 +70,13 @@ public: * Values may range between -32768 and +32767. */ virtual void AddRoutingProtocol (Ptr routingProtocol, int16_t priority); - + /** * \brief Get the number of routing protocols. * \return number of routing protocols in the list */ virtual uint32_t GetNRoutingProtocols (void) const; - + /** * \brief Get pointer to routing protocol stored at index, * diff --git a/src/routing/static-routing/ipv6-routing-table-entry.cc b/src/routing/static-routing/ipv6-routing-table-entry.cc index c003021c9..ad0b1a486 100644 --- a/src/routing/static-routing/ipv6-routing-table-entry.cc +++ b/src/routing/static-routing/ipv6-routing-table-entry.cc @@ -109,9 +109,9 @@ Ipv6RoutingTableEntry::~Ipv6RoutingTableEntry () bool Ipv6RoutingTableEntry::IsHost () const { if (m_destNetworkPrefix.IsEqual (Ipv6Prefix::GetOnes ())) - { - return true; - } + { + return true; + } return false; } @@ -138,9 +138,9 @@ bool Ipv6RoutingTableEntry::IsNetwork () const bool Ipv6RoutingTableEntry::IsDefault () const { if (m_dest.IsEqual (Ipv6Address::GetZero ())) - { - return true; - } + { + return true; + } return false; } @@ -157,9 +157,9 @@ Ipv6Prefix Ipv6RoutingTableEntry::GetDestNetworkPrefix () const bool Ipv6RoutingTableEntry::IsGateway () const { if (m_gateway.IsEqual (Ipv6Address::GetZero ())) - { - return false; - } + { + return false; + } return true; } @@ -206,44 +206,44 @@ uint32_t Ipv6RoutingTableEntry::GetInterface () const std::ostream& operator<< (std::ostream& os, Ipv6RoutingTableEntry const& route) { if (route.IsDefault ()) - { - NS_ASSERT (route.IsGateway ()); - os << "default out =" << route.GetInterface () << ", next hop =" << route.GetGateway (); - } + { + NS_ASSERT (route.IsGateway ()); + os << "default out =" << route.GetInterface () << ", next hop =" << route.GetGateway (); + } else if (route.IsHost ()) - { - if (route.IsGateway ()) { - os << "host ="<< route.GetDest () << - ", out =" << route.GetInterface () << - ", next hop =" << route.GetGateway (); + if (route.IsGateway ()) + { + os << "host ="<< route.GetDest () << + ", out =" << route.GetInterface () << + ", next hop =" << route.GetGateway (); + } + else + { + os << "host =" << route.GetDest () << + ", out =" << route.GetInterface (); + } } - else - { - os << "host =" << route.GetDest () << - ", out =" << route.GetInterface (); - } - } else if (route.IsNetwork ()) - { - if (route.IsGateway ()) { - os << "network =" << route.GetDestNetwork () << - ", mask =" << route.GetDestNetworkPrefix () << - ",out =" << route.GetInterface () << - ", next hop =" << route.GetGateway (); + if (route.IsGateway ()) + { + os << "network =" << route.GetDestNetwork () << + ", mask =" << route.GetDestNetworkPrefix () << + ",out =" << route.GetInterface () << + ", next hop =" << route.GetGateway (); + } + else + { + os << "network =" << route.GetDestNetwork () << + ", mask =" << route.GetDestNetworkPrefix () << + ",out =" << route.GetInterface (); + } } - else - { - os << "network =" << route.GetDestNetwork () << - ", mask =" << route.GetDestNetworkPrefix () << - ",out =" << route.GetInterface (); - } - } else - { - NS_ASSERT (false); - } + { + NS_ASSERT (false); + } return os; } @@ -320,9 +320,9 @@ std::ostream& operator<< (std::ostream& os, Ipv6MulticastRoutingTableEntry const ", output interfaces ="; for (uint32_t i = 0; i < route.GetNOutputInterfaces (); ++i) - { - os << route.GetOutputInterface (i) << " "; - } + { + os << route.GetOutputInterface (i) << " "; + } return os; } diff --git a/src/routing/static-routing/ipv6-routing-table-entry.h b/src/routing/static-routing/ipv6-routing-table-entry.h index ba20c81b7..88da5729c 100644 --- a/src/routing/static-routing/ipv6-routing-table-entry.h +++ b/src/routing/static-routing/ipv6-routing-table-entry.h @@ -36,227 +36,227 @@ namespace ns3 */ class Ipv6RoutingTableEntry { - public: - /** - * \brief Constructor. - */ - Ipv6RoutingTableEntry (); +public: + /** + * \brief Constructor. + */ + Ipv6RoutingTableEntry (); - /** - * \brief Copy constructor. - * \param route the route to copy - */ - Ipv6RoutingTableEntry (Ipv6RoutingTableEntry const & route); + /** + * \brief Copy constructor. + * \param route the route to copy + */ + Ipv6RoutingTableEntry (Ipv6RoutingTableEntry const & route); - /** - * \brief Copy constructor. - * \param route the route to copy - */ - Ipv6RoutingTableEntry (Ipv6RoutingTableEntry const* route); + /** + * \brief Copy constructor. + * \param route the route to copy + */ + Ipv6RoutingTableEntry (Ipv6RoutingTableEntry const* route); - /** - * \brief Destructor - */ - ~Ipv6RoutingTableEntry (); + /** + * \brief Destructor + */ + ~Ipv6RoutingTableEntry (); - /** - * \brief Is the route entry correspond to a host ? - * \return true if the route is a host, false otherwise - */ - bool IsHost () const; + /** + * \brief Is the route entry correspond to a host ? + * \return true if the route is a host, false otherwise + */ + bool IsHost () const; - /** - * \brief Get the destination. - * \return the IPv6 address of the destination of this route - */ - Ipv6Address GetDest () const; + /** + * \brief Get the destination. + * \return the IPv6 address of the destination of this route + */ + Ipv6Address GetDest () const; - /** - * \brief Get the prefix to use (for multihomed link). - * \return prefix address to use - */ - Ipv6Address GetPrefixToUse () const; + /** + * \brief Get the prefix to use (for multihomed link). + * \return prefix address to use + */ + Ipv6Address GetPrefixToUse () const; - /** - * \brief Set the prefix to use. - * \param prefix prefix to use - */ - void SetPrefixToUse (Ipv6Address prefix); + /** + * \brief Set the prefix to use. + * \param prefix prefix to use + */ + void SetPrefixToUse (Ipv6Address prefix); - /** - * \brief Is the route entry correspond to a network ? - * \return true if the route is a network, false otherwise - */ - bool IsNetwork () const; + /** + * \brief Is the route entry correspond to a network ? + * \return true if the route is a network, false otherwise + */ + bool IsNetwork () const; - /** - * \brief Get the destination network. - * \return the destination network - */ - Ipv6Address GetDestNetwork () const; + /** + * \brief Get the destination network. + * \return the destination network + */ + Ipv6Address GetDestNetwork () const; - /** - * \brief Get the destination prefix. - * \return the destination prefix - */ - Ipv6Prefix GetDestNetworkPrefix () const; + /** + * \brief Get the destination prefix. + * \return the destination prefix + */ + Ipv6Prefix GetDestNetworkPrefix () const; - /** - * \brief Is it the default route ? - * \return true if this route is a default route, false otherwise - */ - bool IsDefault () const; + /** + * \brief Is it the default route ? + * \return true if this route is a default route, false otherwise + */ + bool IsDefault () const; - /** - * \brief Is it the gateway ? - * \return true if this route is a gateway, false otherwise - */ - bool IsGateway () const; + /** + * \brief Is it the gateway ? + * \return true if this route is a gateway, false otherwise + */ + bool IsGateway () const; - /** - * \brief Get the gateway. - * \return the IPv6 address of the gateway - */ - Ipv6Address GetGateway () const; + /** + * \brief Get the gateway. + * \return the IPv6 address of the gateway + */ + Ipv6Address GetGateway () const; - /** - * \brief Get the interface index. - * \return the index of the interface - */ - uint32_t GetInterface () const; + /** + * \brief Get the interface index. + * \return the index of the interface + */ + uint32_t GetInterface () const; - /** - * \brief Create a route to a host. - * \param dest destination address - * \param nextHop next hop address to route the packet - * \param interface interface index - * \param prefixToUse prefix that should be used for source address for this destination - * \return IPv6Route object - */ - static Ipv6RoutingTableEntry CreateHostRouteTo (Ipv6Address dest, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address ()); + /** + * \brief Create a route to a host. + * \param dest destination address + * \param nextHop next hop address to route the packet + * \param interface interface index + * \param prefixToUse prefix that should be used for source address for this destination + * \return IPv6Route object + */ + static Ipv6RoutingTableEntry CreateHostRouteTo (Ipv6Address dest, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address ()); - /** - * \brief Create a route to a host. - * \param dest destination address - * \param interface interface index - * \return IPv6Route object - */ - static Ipv6RoutingTableEntry CreateHostRouteTo (Ipv6Address dest, uint32_t interface); + /** + * \brief Create a route to a host. + * \param dest destination address + * \param interface interface index + * \return IPv6Route object + */ + static Ipv6RoutingTableEntry CreateHostRouteTo (Ipv6Address dest, uint32_t interface); - /** - * \brief Create a route to a network. - * \param network network address - * \param networkPrefix network prefix - * \param nextHop next hop address to route the packet - * \param interface interface index - * \return IPv6Route object - */ - static Ipv6RoutingTableEntry CreateNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface); + /** + * \brief Create a route to a network. + * \param network network address + * \param networkPrefix network prefix + * \param nextHop next hop address to route the packet + * \param interface interface index + * \return IPv6Route object + */ + static Ipv6RoutingTableEntry CreateNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface); - /** - * \brief Create a route to a network. - * \param network network address - * \param networkPrefix network prefix - * \param nextHop next hop address to route the packet - * \param interface interface index - * \param prefixToUse prefix that should be used for source address for this destination - * \return IPv6Route object - */ - static Ipv6RoutingTableEntry CreateNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse); + /** + * \brief Create a route to a network. + * \param network network address + * \param networkPrefix network prefix + * \param nextHop next hop address to route the packet + * \param interface interface index + * \param prefixToUse prefix that should be used for source address for this destination + * \return IPv6Route object + */ + static Ipv6RoutingTableEntry CreateNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse); - /** - * \brief Create a route to a network. - * \param network network address - * \param networkPrefix network prefix - * \param interface interface index - * \return IPv6Route object - */ - static Ipv6RoutingTableEntry CreateNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, uint32_t interface); + /** + * \brief Create a route to a network. + * \param network network address + * \param networkPrefix network prefix + * \param interface interface index + * \return IPv6Route object + */ + static Ipv6RoutingTableEntry CreateNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, uint32_t interface); - /** - * \brief Create a default route. - * \param nextHop next hop address to route the packet - * \param interface interface index - * \return IPv6Route object - */ - static Ipv6RoutingTableEntry CreateDefaultRoute (Ipv6Address nextHop, uint32_t interface); + /** + * \brief Create a default route. + * \param nextHop next hop address to route the packet + * \param interface interface index + * \return IPv6Route object + */ + static Ipv6RoutingTableEntry CreateDefaultRoute (Ipv6Address nextHop, uint32_t interface); - private: - /** - * \brief Constructor. - * \param network network address - * \param prefix network prefix - * \param gateway the gateway - * \param interface the interface index - */ - Ipv6RoutingTableEntry (Ipv6Address network, Ipv6Prefix prefix, Ipv6Address gateway, uint32_t interface); +private: + /** + * \brief Constructor. + * \param network network address + * \param prefix network prefix + * \param gateway the gateway + * \param interface the interface index + */ + Ipv6RoutingTableEntry (Ipv6Address network, Ipv6Prefix prefix, Ipv6Address gateway, uint32_t interface); - /** - * \brief Constructor. - * \param network network address - * \param prefix network prefix - * \param interface the interface index - * \param prefixToUse prefix to use - */ - Ipv6RoutingTableEntry (Ipv6Address network, Ipv6Prefix prefix, uint32_t interface, Ipv6Address prefixToUse); + /** + * \brief Constructor. + * \param network network address + * \param prefix network prefix + * \param interface the interface index + * \param prefixToUse prefix to use + */ + Ipv6RoutingTableEntry (Ipv6Address network, Ipv6Prefix prefix, uint32_t interface, Ipv6Address prefixToUse); - /** - * \brief Constructor. - * \param network network address - * \param prefix network prefix - * \param gateway the gateway - * \param interface the interface index - * \param prefixToUse prefix to use - */ - Ipv6RoutingTableEntry (Ipv6Address network, Ipv6Prefix prefix, Ipv6Address gateway, uint32_t interface, Ipv6Address prefixToUse); + /** + * \brief Constructor. + * \param network network address + * \param prefix network prefix + * \param gateway the gateway + * \param interface the interface index + * \param prefixToUse prefix to use + */ + Ipv6RoutingTableEntry (Ipv6Address network, Ipv6Prefix prefix, Ipv6Address gateway, uint32_t interface, Ipv6Address prefixToUse); - /** - * \brief Constructor. - * \param dest destination address - * \param prefix destiation prefix - * \param interface interface index - */ - Ipv6RoutingTableEntry (Ipv6Address dest, Ipv6Prefix prefix, uint32_t interface); + /** + * \brief Constructor. + * \param dest destination address + * \param prefix destiation prefix + * \param interface interface index + */ + Ipv6RoutingTableEntry (Ipv6Address dest, Ipv6Prefix prefix, uint32_t interface); - /** - * \brief Constructor. - * \param dest destination address - * \param gateway the gateway - * \param interface interface index - */ - Ipv6RoutingTableEntry (Ipv6Address dest, Ipv6Address gateway, uint32_t interface); + /** + * \brief Constructor. + * \param dest destination address + * \param gateway the gateway + * \param interface interface index + */ + Ipv6RoutingTableEntry (Ipv6Address dest, Ipv6Address gateway, uint32_t interface); - /** - * \brief Constructor. - * \param dest destination address - * \param interface interface index - */ - Ipv6RoutingTableEntry (Ipv6Address dest, uint32_t interface); + /** + * \brief Constructor. + * \param dest destination address + * \param interface interface index + */ + Ipv6RoutingTableEntry (Ipv6Address dest, uint32_t interface); - /** - * \brief IPv6 address of the destination. - */ - Ipv6Address m_dest; + /** + * \brief IPv6 address of the destination. + */ + Ipv6Address m_dest; - /** - * \brief IPv6 prefix of the destination - */ - Ipv6Prefix m_destNetworkPrefix; + /** + * \brief IPv6 prefix of the destination + */ + Ipv6Prefix m_destNetworkPrefix; - /** - * \brief IPv6 address of the gateway. - */ - Ipv6Address m_gateway; + /** + * \brief IPv6 address of the gateway. + */ + Ipv6Address m_gateway; - /** - * \brief The interface index. - */ - uint32_t m_interface; + /** + * \brief The interface index. + */ + uint32_t m_interface; - /** - * \brief Prefix to use. - */ - Ipv6Address m_prefixToUse; + /** + * \brief Prefix to use. + */ + Ipv6Address m_prefixToUse; }; @@ -268,100 +268,100 @@ std::ostream& operator<< (std::ostream& os, Ipv6RoutingTableEntry const& route); */ class Ipv6MulticastRoutingTableEntry { - public: - /** - * \brief Constructor. - */ - Ipv6MulticastRoutingTableEntry (); +public: + /** + * \brief Constructor. + */ + Ipv6MulticastRoutingTableEntry (); - /** - * \brief Copy constructor. - * \param route the route to copy - */ - Ipv6MulticastRoutingTableEntry (Ipv6MulticastRoutingTableEntry const & route); + /** + * \brief Copy constructor. + * \param route the route to copy + */ + Ipv6MulticastRoutingTableEntry (Ipv6MulticastRoutingTableEntry const & route); - /** - * \brief Copy constructor. - * \param route the route to copy - */ - Ipv6MulticastRoutingTableEntry (Ipv6MulticastRoutingTableEntry const* route); + /** + * \brief Copy constructor. + * \param route the route to copy + */ + Ipv6MulticastRoutingTableEntry (Ipv6MulticastRoutingTableEntry const* route); - /** - * \brief Get the source of this route - * \return IPv6 address of the source of this route - */ - Ipv6Address GetOrigin () const; + /** + * \brief Get the source of this route + * \return IPv6 address of the source of this route + */ + Ipv6Address GetOrigin () const; - /** - * \brief Get the group. - * \return IPv6 address of the multicast group of this route - */ - Ipv6Address GetGroup () const; + /** + * \brief Get the group. + * \return IPv6 address of the multicast group of this route + */ + Ipv6Address GetGroup () const; - /** - * \brief Get the input interface address. - * \return input interface index - */ - uint32_t GetInputInterface () const; + /** + * \brief Get the input interface address. + * \return input interface index + */ + uint32_t GetInputInterface () const; - /** - * \brief Get the number of output interfaces of this route. - * \return number of output interfaces of this route. - */ - uint32_t GetNOutputInterfaces () const; + /** + * \brief Get the number of output interfaces of this route. + * \return number of output interfaces of this route. + */ + uint32_t GetNOutputInterfaces () const; - /** - * \brief Get a specified output interface. - * \param n index - * \return a specified output interface - */ - uint32_t GetOutputInterface (uint32_t n) const; + /** + * \brief Get a specified output interface. + * \param n index + * \return a specified output interface + */ + uint32_t GetOutputInterface (uint32_t n) const; - /** - * \brief Get all of the output interfaces of this route. - * \return a vector of all output interfaces of this route - */ - std::vector GetOutputInterfaces () const; + /** + * \brief Get all of the output interfaces of this route. + * \return a vector of all output interfaces of this route + */ + std::vector GetOutputInterfaces () const; - /** - * \brief Create a multicast route. - * \param origin IPv6 address of the origin source - * \param group Ipv6Address of the group - * \param inputInterface interface number - * \param outputInterfaces list of output interface number - * \return a multicast route - */ - static Ipv6MulticastRoutingTableEntry CreateMulticastRoute (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface, std::vector outputInterfaces); + /** + * \brief Create a multicast route. + * \param origin IPv6 address of the origin source + * \param group Ipv6Address of the group + * \param inputInterface interface number + * \param outputInterfaces list of output interface number + * \return a multicast route + */ + static Ipv6MulticastRoutingTableEntry CreateMulticastRoute (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface, std::vector outputInterfaces); - private: - /** - * \brief Constructor. - * \param origin IPv6 address of the source - * \param group IPv6 address of the group - * \param inputInterface interface number - * \param outputInterfaces list of output interface number - */ - Ipv6MulticastRoutingTableEntry (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface, std::vector outputInterfaces); +private: + /** + * \brief Constructor. + * \param origin IPv6 address of the source + * \param group IPv6 address of the group + * \param inputInterface interface number + * \param outputInterfaces list of output interface number + */ + Ipv6MulticastRoutingTableEntry (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface, std::vector outputInterfaces); - /** - * \brief The IPv6 address of the source. - */ - Ipv6Address m_origin; + /** + * \brief The IPv6 address of the source. + */ + Ipv6Address m_origin; - /** - * \brief The IPv6 address of the group. - */ - Ipv6Address m_group; + /** + * \brief The IPv6 address of the group. + */ + Ipv6Address m_group; - /** - * \brief The input interface. - */ - uint32_t m_inputInterface; + /** + * \brief The input interface. + */ + uint32_t m_inputInterface; - /** - * \brief The output interfaces. - */ - std::vector m_outputInterfaces; + /** + * \brief The output interfaces. + */ + std::vector m_outputInterfaces; }; std::ostream& operator<< (std::ostream& os, Ipv6MulticastRoutingTableEntry const& route); diff --git a/src/routing/static-routing/ipv6-static-routing.cc b/src/routing/static-routing/ipv6-static-routing.cc index efec14ef6..1ec9ed419 100644 --- a/src/routing/static-routing/ipv6-static-routing.cc +++ b/src/routing/static-routing/ipv6-static-routing.cc @@ -40,8 +40,8 @@ TypeId Ipv6StaticRouting::GetTypeId () return tid; } - Ipv6StaticRouting::Ipv6StaticRouting () -: m_ipv6 (0) +Ipv6StaticRouting::Ipv6StaticRouting () + : m_ipv6 (0) { NS_LOG_FUNCTION_NOARGS (); } @@ -59,16 +59,16 @@ void Ipv6StaticRouting::SetIpv6 (Ptr ipv6) m_ipv6 = ipv6; for (i = 0 ; i < m_ipv6->GetNInterfaces () ; i++) - { - if (m_ipv6->IsUp (i)) { - NotifyInterfaceUp (i); + if (m_ipv6->IsUp (i)) + { + NotifyInterfaceUp (i); + } + else + { + NotifyInterfaceDown (i); + } } - else - { - NotifyInterfaceDown (i); - } - } } void Ipv6StaticRouting::AddHostRouteTo (Ipv6Address dst, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse, uint32_t metric) @@ -143,17 +143,17 @@ Ipv6MulticastRoutingTableEntry Ipv6StaticRouting::GetMulticastRoute (uint32_t in NS_ASSERT_MSG (index < m_multicastRoutes.size (), "Ipv6StaticRouting::GetMulticastRoute () : Index out of range"); if (index < m_multicastRoutes.size ()) - { - uint32_t tmp = 0; - for (MulticastRoutesCI i = m_multicastRoutes.begin () ; i != m_multicastRoutes.end () ; i++) { - if (tmp == index) - { - return *i; - } - tmp++; + uint32_t tmp = 0; + for (MulticastRoutesCI i = m_multicastRoutes.begin () ; i != m_multicastRoutes.end () ; i++) + { + if (tmp == index) + { + return *i; + } + tmp++; + } } - } return 0; } @@ -161,17 +161,17 @@ bool Ipv6StaticRouting::RemoveMulticastRoute (Ipv6Address origin, Ipv6Address gr { NS_LOG_FUNCTION (this << origin << group << inputInterface); for (MulticastRoutesI i = m_multicastRoutes.begin (); i != m_multicastRoutes.end (); i++) - { - Ipv6MulticastRoutingTableEntry *route = *i; - if (origin == route->GetOrigin () && - group == route->GetGroup () && - inputInterface == route->GetInputInterface ()) { - delete *i; - m_multicastRoutes.erase (i); - return true; + Ipv6MulticastRoutingTableEntry *route = *i; + if (origin == route->GetOrigin () && + group == route->GetGroup () && + inputInterface == route->GetInputInterface ()) + { + delete *i; + m_multicastRoutes.erase (i); + return true; + } } - } return false; } @@ -181,15 +181,15 @@ void Ipv6StaticRouting::RemoveMulticastRoute (uint32_t index) uint32_t tmp = 0; for (MulticastRoutesI i = m_multicastRoutes.begin () ; i != m_multicastRoutes.end () ; i++) - { - if (tmp == index) { - delete *i; - m_multicastRoutes.erase (i); - return; + if (tmp == index) + { + delete *i; + m_multicastRoutes.erase (i); + return; + } + tmp++; } - tmp++; - } } bool Ipv6StaticRouting::HasNetworkDest (Ipv6Address network, uint32_t interfaceIndex) @@ -198,16 +198,16 @@ bool Ipv6StaticRouting::HasNetworkDest (Ipv6Address network, uint32_t interfaceI /* in the network table */ for (NetworkRoutesI j = m_networkRoutes.begin () ; j != m_networkRoutes.end () ; j++) - { - Ipv6RoutingTableEntry* rtentry = j->first; - Ipv6Prefix prefix = rtentry->GetDestNetworkPrefix (); - Ipv6Address entry = rtentry->GetDestNetwork (); - - if (prefix.IsMatch (network, entry) && rtentry->GetInterface () == interfaceIndex) { - return true; + Ipv6RoutingTableEntry* rtentry = j->first; + Ipv6Prefix prefix = rtentry->GetDestNetworkPrefix (); + Ipv6Address entry = rtentry->GetDestNetwork (); + + if (prefix.IsMatch (network, entry) && rtentry->GetInterface () == interfaceIndex) + { + return true; + } } - } /* beuh!!! not route at all */ return false; @@ -223,80 +223,80 @@ Ptr Ipv6StaticRouting::LookupStatic (Ipv6Address dst, Ptr /* when sending on link-local multicast, there have to be interface specified */ if (dst == Ipv6Address::GetAllNodesMulticast () || dst.IsSolicitedMulticast () || dst == Ipv6Address::GetAllRoutersMulticast () || dst == Ipv6Address::GetAllHostsMulticast ()) - { - NS_ASSERT_MSG (interface, "Try to send on link-local multicast address, and no interface index is given!"); - rtentry = Create (); - rtentry->SetSource (SourceAddressSelection (m_ipv6->GetInterfaceForDevice (interface), dst)); - rtentry->SetDestination (dst); - rtentry->SetGateway (Ipv6Address::GetZero ()); - rtentry->SetOutputDevice (interface); - return rtentry; - } + { + NS_ASSERT_MSG (interface, "Try to send on link-local multicast address, and no interface index is given!"); + rtentry = Create (); + rtentry->SetSource (SourceAddressSelection (m_ipv6->GetInterfaceForDevice (interface), dst)); + rtentry->SetDestination (dst); + rtentry->SetGateway (Ipv6Address::GetZero ()); + rtentry->SetOutputDevice (interface); + return rtentry; + } for (NetworkRoutesI it = m_networkRoutes.begin () ; it != m_networkRoutes.end () ; it++) - { - Ipv6RoutingTableEntry* j = it->first; - uint32_t metric = it->second; - Ipv6Prefix mask = j->GetDestNetworkPrefix (); - uint16_t maskLen = mask.GetPrefixLength (); - Ipv6Address entry = j->GetDestNetwork (); - - NS_LOG_LOGIC ("Searching for route to " << dst << ", mask length " << maskLen << ", metric " << metric); - - if (mask.IsMatch (dst, entry)) { - NS_LOG_LOGIC ("Found global network route " << j << ", mask length " << maskLen << ", metric " << metric); + Ipv6RoutingTableEntry* j = it->first; + uint32_t metric = it->second; + Ipv6Prefix mask = j->GetDestNetworkPrefix (); + uint16_t maskLen = mask.GetPrefixLength (); + Ipv6Address entry = j->GetDestNetwork (); - /* if interface is given, check the route will output on this interface */ - if (!interface || interface == m_ipv6->GetNetDevice (j->GetInterface ())) - { - if (maskLen < longestMask) - { - NS_LOG_LOGIC ("Previous match longer, skipping"); - continue; - } + NS_LOG_LOGIC ("Searching for route to " << dst << ", mask length " << maskLen << ", metric " << metric); - if (maskLen > longestMask) + if (mask.IsMatch (dst, entry)) { - shortestMetric = 0xffffffff; - } + NS_LOG_LOGIC ("Found global network route " << j << ", mask length " << maskLen << ", metric " << metric); - longestMask = maskLen; - if (metric > shortestMetric) - { - NS_LOG_LOGIC ("Equal mask length, but previous metric shorter, skipping"); - continue; - } + /* if interface is given, check the route will output on this interface */ + if (!interface || interface == m_ipv6->GetNetDevice (j->GetInterface ())) + { + if (maskLen < longestMask) + { + NS_LOG_LOGIC ("Previous match longer, skipping"); + continue; + } - shortestMetric = metric; - Ipv6RoutingTableEntry* route = j; - uint32_t interfaceIdx = route->GetInterface (); - rtentry = Create (); + if (maskLen > longestMask) + { + shortestMetric = 0xffffffff; + } - if (route->GetGateway ().IsAny ()) - { - rtentry->SetSource (SourceAddressSelection (interfaceIdx, route->GetDest ())); - } - else if (route->GetDest ().IsAny ()) /* default route */ - { - rtentry->SetSource (SourceAddressSelection (interfaceIdx, route->GetPrefixToUse ().IsAny () ? route->GetGateway () : route->GetPrefixToUse ())); - } - else - { - rtentry->SetSource (SourceAddressSelection (interfaceIdx, route->GetGateway ())); - } + longestMask = maskLen; + if (metric > shortestMetric) + { + NS_LOG_LOGIC ("Equal mask length, but previous metric shorter, skipping"); + continue; + } - rtentry->SetDestination (route->GetDest ()); - rtentry->SetGateway (route->GetGateway ()); - rtentry->SetOutputDevice (m_ipv6->GetNetDevice (interfaceIdx)); - } + shortestMetric = metric; + Ipv6RoutingTableEntry* route = j; + uint32_t interfaceIdx = route->GetInterface (); + rtentry = Create (); + + if (route->GetGateway ().IsAny ()) + { + rtentry->SetSource (SourceAddressSelection (interfaceIdx, route->GetDest ())); + } + else if (route->GetDest ().IsAny ()) /* default route */ + { + rtentry->SetSource (SourceAddressSelection (interfaceIdx, route->GetPrefixToUse ().IsAny () ? route->GetGateway () : route->GetPrefixToUse ())); + } + else + { + rtentry->SetSource (SourceAddressSelection (interfaceIdx, route->GetGateway ())); + } + + rtentry->SetDestination (route->GetDest ()); + rtentry->SetGateway (route->GetGateway ()); + rtentry->SetOutputDevice (m_ipv6->GetNetDevice (interfaceIdx)); + } + } } - } if(rtentry) - { - NS_LOG_LOGIC ("Matching route via " << rtentry->GetDestination () << " (throught " << rtentry->GetGateway () << ") at the end"); - } + { + NS_LOG_LOGIC ("Matching route via " << rtentry->GetDestination () << " (throught " << rtentry->GetGateway () << ") at the end"); + } return rtentry; } @@ -305,15 +305,15 @@ void Ipv6StaticRouting::DoDispose () NS_LOG_FUNCTION_NOARGS (); for (NetworkRoutesI j = m_networkRoutes.begin () ; j != m_networkRoutes.end () ; j = m_networkRoutes.erase (j)) - { - delete j->first; - } + { + delete j->first; + } m_networkRoutes.clear (); for (MulticastRoutesI i = m_multicastRoutes.begin () ; i != m_multicastRoutes.end () ; i = m_multicastRoutes.erase (i)) - { - delete (*i); - } + { + delete (*i); + } m_multicastRoutes.clear (); m_ipv6 = 0; @@ -326,46 +326,46 @@ Ptr Ipv6StaticRouting::LookupStatic (Ipv6Address origin, Ipv Ptr mrtentry = 0; for (MulticastRoutesI i = m_multicastRoutes.begin () ; i != m_multicastRoutes.end () ; i++) - { - Ipv6MulticastRoutingTableEntry* route = *i; - - /* - We've been passed an origin address, a multicast group address and an - interface index. We have to decide if the current route in the list is - a match. - - The first case is the restrictive case where the origin, group and index - matches. This picks up exact routes during forwarded and exact routes from - the local node (in which case the ifIndex is a wildcard). - */ - - if (origin == route->GetOrigin () && group == route->GetGroup ()) { - /* skipping SSM case */ - NS_LOG_LOGIC ("Find source specific multicast route" << *i); - } + Ipv6MulticastRoutingTableEntry* route = *i; - if (group == route->GetGroup ()) - { - if (interface == Ipv6::IF_ANY || interface == route->GetInputInterface ()) - { - NS_LOG_LOGIC ("Found multicast route" << *i); - mrtentry = Create (); - mrtentry->SetGroup (route->GetGroup ()); - mrtentry->SetOrigin (route->GetOrigin ()); - mrtentry->SetParent (route->GetInputInterface ()); - for (uint32_t j = 0 ; j < route->GetNOutputInterfaces () ; j++) + /* + We've been passed an origin address, a multicast group address and an + interface index. We have to decide if the current route in the list is + a match. + + The first case is the restrictive case where the origin, group and index + matches. This picks up exact routes during forwarded and exact routes from + the local node (in which case the ifIndex is a wildcard). + */ + + if (origin == route->GetOrigin () && group == route->GetGroup ()) { - if (route->GetOutputInterface (j)) - { - NS_LOG_LOGIC ("Setting output interface index " << route->GetOutputInterface (j)); - mrtentry->SetOutputTtl (route->GetOutputInterface (j), Ipv6MulticastRoute::MAX_TTL - 1); - } + /* skipping SSM case */ + NS_LOG_LOGIC ("Find source specific multicast route" << *i); + } + + if (group == route->GetGroup ()) + { + if (interface == Ipv6::IF_ANY || interface == route->GetInputInterface ()) + { + NS_LOG_LOGIC ("Found multicast route" << *i); + mrtentry = Create (); + mrtentry->SetGroup (route->GetGroup ()); + mrtentry->SetOrigin (route->GetOrigin ()); + mrtentry->SetParent (route->GetInputInterface ()); + for (uint32_t j = 0 ; j < route->GetNOutputInterfaces () ; j++) + { + if (route->GetOutputInterface (j)) + { + NS_LOG_LOGIC ("Setting output interface index " << route->GetOutputInterface (j)); + mrtentry->SetOutputTtl (route->GetOutputInterface (j), Ipv6MulticastRoute::MAX_TTL - 1); + } + } + return mrtentry; + } } - return mrtentry; - } } - } return mrtentry; } @@ -382,34 +382,34 @@ Ipv6RoutingTableEntry Ipv6StaticRouting::GetDefaultRoute () Ipv6RoutingTableEntry* result = 0; for (NetworkRoutesI it = m_networkRoutes.begin () ; it != m_networkRoutes.end () ; it++) - { - Ipv6RoutingTableEntry* j = it->first; - uint32_t metric = it->second; - Ipv6Prefix mask = j->GetDestNetworkPrefix (); - uint16_t maskLen = mask.GetPrefixLength (); - Ipv6Address entry = j->GetDestNetwork (); - - if (maskLen) { - continue; - } + Ipv6RoutingTableEntry* j = it->first; + uint32_t metric = it->second; + Ipv6Prefix mask = j->GetDestNetworkPrefix (); + uint16_t maskLen = mask.GetPrefixLength (); + Ipv6Address entry = j->GetDestNetwork (); - if (metric > shortestMetric) - { - continue; + if (maskLen) + { + continue; + } + + if (metric > shortestMetric) + { + continue; + } + shortestMetric = metric; + result = j; } - shortestMetric = metric; - result = j; - } if (result) - { - return result; - } + { + return result; + } else - { - return Ipv6RoutingTableEntry (); - } + { + return Ipv6RoutingTableEntry (); + } } Ipv6RoutingTableEntry Ipv6StaticRouting::GetRoute (uint32_t index) @@ -418,13 +418,13 @@ Ipv6RoutingTableEntry Ipv6StaticRouting::GetRoute (uint32_t index) uint32_t tmp = 0; for (NetworkRoutesI it = m_networkRoutes.begin () ; it != m_networkRoutes.end () ; it++) - { - if (tmp == index) { - return it->first; + if (tmp == index) + { + return it->first; + } + tmp++; } - tmp++; - } NS_ASSERT (false); // quiet compiler. return 0; @@ -436,13 +436,13 @@ uint32_t Ipv6StaticRouting::GetMetric (uint32_t index) uint32_t tmp = 0; for (NetworkRoutesI it = m_networkRoutes.begin () ; it != m_networkRoutes.end () ; it++) - { - if (tmp == index) { - return it->second; + if (tmp == index) + { + return it->second; + } + tmp++; } - tmp++; - } NS_ASSERT (false); // quiet compiler. return 0; @@ -454,15 +454,15 @@ void Ipv6StaticRouting::RemoveRoute (uint32_t index) uint32_t tmp = 0; for (NetworkRoutesI it = m_networkRoutes.begin () ; it != m_networkRoutes.end () ; it++) - { - if (tmp == index) { - delete it->first; - m_networkRoutes.erase (it); - return; + if (tmp == index) + { + delete it->first; + m_networkRoutes.erase (it); + return; + } + tmp++; } - tmp++; - } NS_ASSERT (false); } @@ -471,16 +471,16 @@ void Ipv6StaticRouting::RemoveRoute (Ipv6Address network, Ipv6Prefix prefix, uin NS_LOG_FUNCTION (this << network << prefix << ifIndex); for (NetworkRoutesI it = m_networkRoutes.begin () ; it != m_networkRoutes.end () ; it++) - { - Ipv6RoutingTableEntry* rtentry = it->first; - if (network == rtentry->GetDest () && rtentry->GetInterface () == ifIndex && - rtentry->GetPrefixToUse () == prefixToUse) { - delete it->first; - m_networkRoutes.erase (it); - return; + Ipv6RoutingTableEntry* rtentry = it->first; + if (network == rtentry->GetDest () && rtentry->GetInterface () == ifIndex && + rtentry->GetPrefixToUse () == prefixToUse) + { + delete it->first; + m_networkRoutes.erase (it); + return; + } } - } } Ptr Ipv6StaticRouting::RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, Socket::SocketErrno &sockerr) @@ -490,25 +490,25 @@ Ptr Ipv6StaticRouting::RouteOutput (Ptr p, const Ipv6Header & Ptr rtentry = 0; if (destination.IsMulticast ()) - { - // Note: Multicast routes for outbound packets are stored in the - // normal unicast table. An implication of this is that it is not - // possible to source multicast datagrams on multiple interfaces. - // This is a well-known property of sockets implementation on - // many Unix variants. - // So, we just log it and fall through to LookupStatic () - NS_LOG_LOGIC ("RouteOutput ()::Multicast destination"); - } + { + // Note: Multicast routes for outbound packets are stored in the + // normal unicast table. An implication of this is that it is not + // possible to source multicast datagrams on multiple interfaces. + // This is a well-known property of sockets implementation on + // many Unix variants. + // So, we just log it and fall through to LookupStatic () + NS_LOG_LOGIC ("RouteOutput ()::Multicast destination"); + } rtentry = LookupStatic (destination, oif); if (rtentry) - { - sockerr = Socket::ERROR_NOTERROR; - } + { + sockerr = Socket::ERROR_NOTERROR; + } else - { - sockerr = Socket::ERROR_NOROUTETOHOST; - } + { + sockerr = Socket::ERROR_NOROUTETOHOST; + } return rtentry; } @@ -524,30 +524,30 @@ bool Ipv6StaticRouting::RouteInput (Ptr p, const Ipv6Header &heade Ipv6Address dst = header.GetDestinationAddress (); if (dst.IsMulticast ()) - { - NS_LOG_LOGIC ("Multicast destination"); - Ptr mrtentry = LookupStatic (header.GetSourceAddress (), - header.GetDestinationAddress (), m_ipv6->GetInterfaceForDevice (idev)); - - if (mrtentry) { - NS_LOG_LOGIC ("Multicast route found"); - mcb (mrtentry, p, header); // multicast forwarding callback - return true; - } - else - { - NS_LOG_LOGIC ("Multicast route not found"); - return false; // Let other routing protocols try to handle this - } - } + NS_LOG_LOGIC ("Multicast destination"); + Ptr mrtentry = LookupStatic (header.GetSourceAddress (), + header.GetDestinationAddress (), m_ipv6->GetInterfaceForDevice (idev)); - // TODO: Configurable option to enable RFC 1222 Strong End System Model - // Right now, we will be permissive and allow a source to send us - // a packet to one of our other interface addresses; that is, the - // destination unicast address does not match one of the iif addresses, - // but we check our other interfaces. This could be an option - // (to remove the outer loop immediately below and just check iif). + if (mrtentry) + { + NS_LOG_LOGIC ("Multicast route found"); + mcb (mrtentry, p, header); // multicast forwarding callback + return true; + } + else + { + NS_LOG_LOGIC ("Multicast route not found"); + return false; // Let other routing protocols try to handle this + } + } + + // TODO: Configurable option to enable RFC 1222 Strong End System Model + // Right now, we will be permissive and allow a source to send us + // a packet to one of our other interface addresses; that is, the + // destination unicast address does not match one of the iif addresses, + // but we check our other interfaces. This could be an option + // (to remove the outer loop immediately below and just check iif). for (uint32_t j = 0; j < m_ipv6->GetNInterfaces (); j++) { for (uint32_t i = 0; i < m_ipv6->GetNAddresses (j); i++) @@ -582,37 +582,37 @@ bool Ipv6StaticRouting::RouteInput (Ptr p, const Ipv6Header &heade Ptr rtentry = LookupStatic (header.GetDestinationAddress ()); if (rtentry != 0) - { - NS_LOG_LOGIC ("Found unicast destination- calling unicast callback"); - ucb (rtentry, p, header); // unicast forwarding callback - return true; - } + { + NS_LOG_LOGIC ("Found unicast destination- calling unicast callback"); + ucb (rtentry, p, header); // unicast forwarding callback + return true; + } else - { - NS_LOG_LOGIC ("Did not find unicast destination- returning false"); - return false; // Let other routing protocols try to handle this - } + { + NS_LOG_LOGIC ("Did not find unicast destination- returning false"); + return false; // Let other routing protocols try to handle this + } } void Ipv6StaticRouting::NotifyInterfaceUp (uint32_t i) { for (uint32_t j = 0 ; j < m_ipv6->GetNAddresses (i) ; j++) - { - if (m_ipv6->GetAddress (i, j).GetAddress () != Ipv6Address () && - m_ipv6->GetAddress (i, j).GetPrefix () != Ipv6Prefix ()) { - if (m_ipv6->GetAddress (i, j).GetPrefix () == Ipv6Prefix (128)) - { - /* host route */ - AddHostRouteTo (m_ipv6->GetAddress (i, j).GetAddress (), i); - } - else - { - AddNetworkRouteTo (m_ipv6->GetAddress (i, j).GetAddress ().CombinePrefix (m_ipv6->GetAddress (i, j).GetPrefix ()), - m_ipv6->GetAddress (i, j).GetPrefix (), i); - } + if (m_ipv6->GetAddress (i, j).GetAddress () != Ipv6Address () && + m_ipv6->GetAddress (i, j).GetPrefix () != Ipv6Prefix ()) + { + if (m_ipv6->GetAddress (i, j).GetPrefix () == Ipv6Prefix (128)) + { + /* host route */ + AddHostRouteTo (m_ipv6->GetAddress (i, j).GetAddress (), i); + } + else + { + AddNetworkRouteTo (m_ipv6->GetAddress (i, j).GetAddress ().CombinePrefix (m_ipv6->GetAddress (i, j).GetPrefix ()), + m_ipv6->GetAddress (i, j).GetPrefix (), i); + } + } } - } } void Ipv6StaticRouting::NotifyInterfaceDown (uint32_t i) @@ -623,42 +623,42 @@ void Ipv6StaticRouting::NotifyInterfaceDown (uint32_t i) /* remove all static routes that are going through this interface */ while (j < max) - { - Ipv6RoutingTableEntry route = GetRoute (j); + { + Ipv6RoutingTableEntry route = GetRoute (j); - if (route.GetInterface () == i) - { - RemoveRoute (j); + if (route.GetInterface () == i) + { + RemoveRoute (j); + } + else + { + j++; + } } - else - { - j++; - } - } } void Ipv6StaticRouting::NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address) { if (!m_ipv6->IsUp (interface)) - { - return; - } + { + return; + } Ipv6Address networkAddress = address.GetAddress ().CombinePrefix (address.GetPrefix ()); Ipv6Prefix networkMask = address.GetPrefix (); if (address.GetAddress () != Ipv6Address () && address.GetPrefix () != Ipv6Prefix ()) - { - AddNetworkRouteTo (networkAddress, networkMask, interface); - } + { + AddNetworkRouteTo (networkAddress, networkMask, interface); + } } void Ipv6StaticRouting::NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress address) { if (!m_ipv6->IsUp (interface)) - { - return; - } + { + return; + } Ipv6Address networkAddress = address.GetAddress ().CombinePrefix (address.GetPrefix ()); Ipv6Prefix networkMask = address.GetPrefix (); @@ -666,63 +666,63 @@ void Ipv6StaticRouting::NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAd // Remove all static routes that are going through this interface // which reference this network for (uint32_t j = 0 ; j < GetNRoutes () ; j++) - { - Ipv6RoutingTableEntry route = GetRoute (j); - - if (route.GetInterface () == interface && - route.IsNetwork () && - route.GetDestNetwork () == networkAddress && - route.GetDestNetworkPrefix () == networkMask) { - RemoveRoute (j); + Ipv6RoutingTableEntry route = GetRoute (j); + + if (route.GetInterface () == interface && + route.IsNetwork () && + route.GetDestNetwork () == networkAddress && + route.GetDestNetworkPrefix () == networkMask) + { + RemoveRoute (j); + } } - } } void Ipv6StaticRouting::NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse) { NS_LOG_INFO (this << dst << mask << nextHop << interface << prefixToUse); if (dst != Ipv6Address::GetZero ()) - { - AddNetworkRouteTo (dst, mask, nextHop, interface); - } + { + AddNetworkRouteTo (dst, mask, nextHop, interface); + } else /* default route */ - { - /* this case is mainly used by configuring default route following RA processing, - * in case of multipe prefix in RA, the first will configured default route - */ + { + /* this case is mainly used by configuring default route following RA processing, + * in case of multipe prefix in RA, the first will configured default route + */ - /* for the moment, all default route has the same metric - * so according to the longest prefix algorithm, - * the default route choosen will be the last added - */ - SetDefaultRoute (nextHop, interface, prefixToUse); - } + /* for the moment, all default route has the same metric + * so according to the longest prefix algorithm, + * the default route choosen will be the last added + */ + SetDefaultRoute (nextHop, interface, prefixToUse); + } } void Ipv6StaticRouting::NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse) { NS_LOG_FUNCTION (this << dst << mask << nextHop << interface); if (dst != Ipv6Address::GetZero ()) - { - for (NetworkRoutesI j = m_networkRoutes.begin () ; j != m_networkRoutes.end () ; j++) { - Ipv6RoutingTableEntry* rtentry = j->first; - Ipv6Prefix prefix = rtentry->GetDestNetworkPrefix (); - Ipv6Address entry = rtentry->GetDestNetwork (); + for (NetworkRoutesI j = m_networkRoutes.begin () ; j != m_networkRoutes.end () ; j++) + { + Ipv6RoutingTableEntry* rtentry = j->first; + Ipv6Prefix prefix = rtentry->GetDestNetworkPrefix (); + Ipv6Address entry = rtentry->GetDestNetwork (); - if (dst == entry && prefix == mask && rtentry->GetInterface () == interface) - { - delete j->first; - m_networkRoutes.erase (j); - } + if (dst == entry && prefix == mask && rtentry->GetInterface () == interface) + { + delete j->first; + m_networkRoutes.erase (j); + } + } } - } else - { - /* default route case */ - RemoveRoute (dst, mask, interface, prefixToUse); - } + { + /* default route case */ + RemoveRoute (dst, mask, interface, prefixToUse); + } } Ipv6Address Ipv6StaticRouting::SourceAddressSelection (uint32_t interface, Ipv6Address dest) @@ -734,21 +734,21 @@ Ipv6Address Ipv6StaticRouting::SourceAddressSelection (uint32_t interface, Ipv6A ret = m_ipv6->GetAddress (interface, 0).GetAddress (); if (dest == Ipv6Address::GetAllNodesMulticast () || dest == Ipv6Address::GetAllRoutersMulticast () || dest == Ipv6Address::GetAllHostsMulticast ()) - { - return ret; - } + { + return ret; + } /* useally IPv6 interfaces have one link-local address and one global address */ for (uint32_t i = 1 ; i < m_ipv6->GetNAddresses (interface) ; i++) - { - Ipv6InterfaceAddress test = m_ipv6->GetAddress (interface, i); - - if (test.GetAddress ().CombinePrefix (test.GetPrefix ()) == dest.CombinePrefix (test.GetPrefix ())) { - return test.GetAddress (); + Ipv6InterfaceAddress test = m_ipv6->GetAddress (interface, i); + + if (test.GetAddress ().CombinePrefix (test.GetPrefix ()) == dest.CombinePrefix (test.GetPrefix ())) + { + return test.GetAddress (); + } } - } return ret; } diff --git a/src/routing/static-routing/ipv6-static-routing.h b/src/routing/static-routing/ipv6-static-routing.h index ca8875a9b..1b6df0c65 100644 --- a/src/routing/static-routing/ipv6-static-routing.h +++ b/src/routing/static-routing/ipv6-static-routing.h @@ -55,242 +55,242 @@ class Ipv6MulticastRoutingTableEntry; */ class Ipv6StaticRouting : public Ipv6RoutingProtocol { - public: - /** - * \brief The interface Id associated with this class. - * \return type identifier - */ - static TypeId GetTypeId (); +public: + /** + * \brief The interface Id associated with this class. + * \return type identifier + */ + static TypeId GetTypeId (); - /** - * \brief Constructor. - */ - Ipv6StaticRouting (); + /** + * \brief Constructor. + */ + Ipv6StaticRouting (); - /** - * \brief Destructor. - */ - virtual ~Ipv6StaticRouting (); + /** + * \brief Destructor. + */ + virtual ~Ipv6StaticRouting (); - /** - * \brief Add route to host. - * \param dest destination address - * \param nextHop next hop address to route the packet - * \param interface interface index - * \param prefixToUse prefix that should be used for source address for this destination - * \param metric metric of route in case of multiple routes to same destination - */ - void AddHostRouteTo (Ipv6Address dest, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address ("::"), uint32_t metric = 0); + /** + * \brief Add route to host. + * \param dest destination address + * \param nextHop next hop address to route the packet + * \param interface interface index + * \param prefixToUse prefix that should be used for source address for this destination + * \param metric metric of route in case of multiple routes to same destination + */ + void AddHostRouteTo (Ipv6Address dest, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address ("::"), uint32_t metric = 0); - /** - * \brief Add route to host. - * \param dest destination address. - * \param interface interface index - * \param metric metric of route in case of multiple routes to same destination - */ - void AddHostRouteTo (Ipv6Address dest, uint32_t interface, uint32_t metric = 0); + /** + * \brief Add route to host. + * \param dest destination address. + * \param interface interface index + * \param metric metric of route in case of multiple routes to same destination + */ + void AddHostRouteTo (Ipv6Address dest, uint32_t interface, uint32_t metric = 0); - /** - * \brief Add route to network. - * \param network network address - * \param networkPrefix network prefix* - * \param nextHop next hop address to route the packet - * \param interface interface index - * \param metric metric of route in case of multiple routes to same destination - */ - void AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, uint32_t metric = 0); + /** + * \brief Add route to network. + * \param network network address + * \param networkPrefix network prefix* + * \param nextHop next hop address to route the packet + * \param interface interface index + * \param metric metric of route in case of multiple routes to same destination + */ + void AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, uint32_t metric = 0); - /** - * \brief Add route to network. - * \param network network address - * \param networkPrefix network prefix* - * \param nextHop next hop address to route the packet - * \param interface interface index - * \param prefixToUse prefix that should be used for source address for this destination - * \param metric metric of route in case of multiple routes to same destination - */ - void AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse, uint32_t metric = 0); + /** + * \brief Add route to network. + * \param network network address + * \param networkPrefix network prefix* + * \param nextHop next hop address to route the packet + * \param interface interface index + * \param prefixToUse prefix that should be used for source address for this destination + * \param metric metric of route in case of multiple routes to same destination + */ + void AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse, uint32_t metric = 0); - /** - * \brief Add route to network. - * \param network network address - * \param networkPrefix network prefix - * \param interface interface index - * \param metric metric of route in case of multiple routes to same destination - */ - void AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, uint32_t interface, uint32_t metric = 0); + /** + * \brief Add route to network. + * \param network network address + * \param networkPrefix network prefix + * \param interface interface index + * \param metric metric of route in case of multiple routes to same destination + */ + void AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, uint32_t interface, uint32_t metric = 0); - /** - * \brief Set the default route. - * \param nextHop next hop address to route the packet - * \param interface interface index - * \param prefixToUse prefix to use (i.e for multihoming) - * \param metric metric of route in case of multiple routes to same destination - */ - void SetDefaultRoute (Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address ("::"), uint32_t metric = 0); + /** + * \brief Set the default route. + * \param nextHop next hop address to route the packet + * \param interface interface index + * \param prefixToUse prefix to use (i.e for multihoming) + * \param metric metric of route in case of multiple routes to same destination + */ + void SetDefaultRoute (Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address ("::"), uint32_t metric = 0); - /** - * \brief Get the number or entries in the routing table. - * \return number of entries - */ - uint32_t GetNRoutes (); + /** + * \brief Get the number or entries in the routing table. + * \return number of entries + */ + uint32_t GetNRoutes (); - /** - * \brief Get the default route. - * - * If multiple default routes exist, the one with lowest metric is returned. - * \return default Ipv6Route - */ - Ipv6RoutingTableEntry GetDefaultRoute (); + /** + * \brief Get the default route. + * + * If multiple default routes exist, the one with lowest metric is returned. + * \return default Ipv6Route + */ + Ipv6RoutingTableEntry GetDefaultRoute (); - /** - * \brief Get a specified route. - * \param i index - * \return the route whose index is i - */ - Ipv6RoutingTableEntry GetRoute (uint32_t i); + /** + * \brief Get a specified route. + * \param i index + * \return the route whose index is i + */ + Ipv6RoutingTableEntry GetRoute (uint32_t i); - /** - * \brief Get a metric for route from the static unicast routing table. - * \param index The index (into the routing table) of the route to retrieve. - * \return If route is set, the metric is returned. If not, an infinity metric (0xffffffff) is returned - */ - uint32_t GetMetric (uint32_t index); + /** + * \brief Get a metric for route from the static unicast routing table. + * \param index The index (into the routing table) of the route to retrieve. + * \return If route is set, the metric is returned. If not, an infinity metric (0xffffffff) is returned + */ + uint32_t GetMetric (uint32_t index); - /** - * \brief Remove a route from the routing table. - * \param i index - */ - void RemoveRoute (uint32_t i); + /** + * \brief Remove a route from the routing table. + * \param i index + */ + void RemoveRoute (uint32_t i); - /** - * \brief Remove a route from the routing table. - * \param network IPv6 network - * \param prefix IPv6 prefix - * \param ifIndex interface index - * \param prefixToUse IPv6 prefix to use with this route (multihoming) - */ - void RemoveRoute (Ipv6Address network, Ipv6Prefix prefix, uint32_t ifIndex, Ipv6Address prefixToUse); + /** + * \brief Remove a route from the routing table. + * \param network IPv6 network + * \param prefix IPv6 prefix + * \param ifIndex interface index + * \param prefixToUse IPv6 prefix to use with this route (multihoming) + */ + void RemoveRoute (Ipv6Address network, Ipv6Prefix prefix, uint32_t ifIndex, Ipv6Address prefixToUse); - /** - * \brief Add a multicast route for a given multicast source and group. - * \param origin IPv6 address of the source - * \param group the multicast group address. - * \param inputInterface the interface index - * \param outputInterfaces the list of output interface indices over which the packet - * should be sent (excluding the inputInterface). - */ - void AddMulticastRoute (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface, std::vector outputInterfaces); + /** + * \brief Add a multicast route for a given multicast source and group. + * \param origin IPv6 address of the source + * \param group the multicast group address. + * \param inputInterface the interface index + * \param outputInterfaces the list of output interface indices over which the packet + * should be sent (excluding the inputInterface). + */ + void AddMulticastRoute (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface, std::vector outputInterfaces); - /** - * \brief Set the default multicast route. - * \param outputInterface default output interface - */ - void SetDefaultMulticastRoute (uint32_t outputInterface); + /** + * \brief Set the default multicast route. + * \param outputInterface default output interface + */ + void SetDefaultMulticastRoute (uint32_t outputInterface); - /** - * \brief Get the number of entries in the multicast routing table. - * \return number of entries - */ - uint32_t GetNMulticastRoutes () const; + /** + * \brief Get the number of entries in the multicast routing table. + * \return number of entries + */ + uint32_t GetNMulticastRoutes () const; - /** - * \brief Get the specified multicast route. - * \param i index - * \return the route whose index is i - */ - Ipv6MulticastRoutingTableEntry GetMulticastRoute (uint32_t i) const; + /** + * \brief Get the specified multicast route. + * \param i index + * \return the route whose index is i + */ + Ipv6MulticastRoutingTableEntry GetMulticastRoute (uint32_t i) const; - /** - * \brief Remove a static multicast route. - * \param origin IPv6 address of the source - * \param group the multicast group address. - * \param inputInterface the input interface index - */ - bool RemoveMulticastRoute (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface); + /** + * \brief Remove a static multicast route. + * \param origin IPv6 address of the source + * \param group the multicast group address. + * \param inputInterface the input interface index + */ + bool RemoveMulticastRoute (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface); - /** - * \brief Remove a multicast route. - * \param i index of route to remove - */ - void RemoveMulticastRoute (uint32_t i); + /** + * \brief Remove a multicast route. + * \param i index of route to remove + */ + void RemoveMulticastRoute (uint32_t i); - /** - * \brief If the destination is already present in network destination list. - * \param dest destination address - * \param interfaceIndex interface index - * \return true if dest is already in list, false otherwise - */ - bool HasNetworkDest (Ipv6Address dest, uint32_t interfaceIndex); + /** + * \brief If the destination is already present in network destination list. + * \param dest destination address + * \param interfaceIndex interface index + * \return true if dest is already in list, false otherwise + */ + bool HasNetworkDest (Ipv6Address dest, uint32_t interfaceIndex); - virtual Ptr RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, Socket::SocketErrno &sockerr); + virtual Ptr RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, Socket::SocketErrno &sockerr); - virtual bool RouteInput (Ptr p, const Ipv6Header &header, Ptr idev, - UnicastForwardCallback ucb, MulticastForwardCallback mcb, - LocalDeliverCallback lcb, ErrorCallback ecb); + virtual bool RouteInput (Ptr p, const Ipv6Header &header, Ptr idev, + UnicastForwardCallback ucb, MulticastForwardCallback mcb, + LocalDeliverCallback lcb, ErrorCallback ecb); - virtual void NotifyInterfaceUp (uint32_t interface); - virtual void NotifyInterfaceDown (uint32_t interface); - virtual void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address); - virtual void NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress address); - virtual void NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ()); - virtual void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ()); - virtual void SetIpv6 (Ptr ipv6); + virtual void NotifyInterfaceUp (uint32_t interface); + virtual void NotifyInterfaceDown (uint32_t interface); + virtual void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address); + virtual void NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress address); + virtual void NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ()); + virtual void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ()); + virtual void SetIpv6 (Ptr ipv6); - protected: - /** - * \brief Dispose this object. - */ - void DoDispose (); +protected: + /** + * \brief Dispose this object. + */ + void DoDispose (); - private: - typedef std::list > NetworkRoutes; - typedef std::list >::const_iterator NetworkRoutesCI; - typedef std::list >::iterator NetworkRoutesI; +private: + typedef std::list > NetworkRoutes; + typedef std::list >::const_iterator NetworkRoutesCI; + typedef std::list >::iterator NetworkRoutesI; - typedef std::list MulticastRoutes; - typedef std::list::const_iterator MulticastRoutesCI; - typedef std::list::iterator MulticastRoutesI; + typedef std::list MulticastRoutes; + typedef std::list::const_iterator MulticastRoutesCI; + typedef std::list::iterator MulticastRoutesI; - /** - * \brief Lookup in the forwarding table for destination. - * \param dest destination address - * \param interface output interface if any (put 0 otherwise) - * \return Ipv6Route to route the packet to reach dest address - */ - Ptr LookupStatic (Ipv6Address dest, Ptr = 0); + /** + * \brief Lookup in the forwarding table for destination. + * \param dest destination address + * \param interface output interface if any (put 0 otherwise) + * \return Ipv6Route to route the packet to reach dest address + */ + Ptr LookupStatic (Ipv6Address dest, Ptr = 0); - /** - * \brief Lookup in the multicast forwarding table for destination. - * \param origin source address - * \param group group multicast address - * \param ifIndex interface index - * \return Ipv6MulticastRoute to route the packet to reach dest address - */ - Ptr LookupStatic (Ipv6Address origin, Ipv6Address group, uint32_t ifIndex); + /** + * \brief Lookup in the multicast forwarding table for destination. + * \param origin source address + * \param group group multicast address + * \param ifIndex interface index + * \return Ipv6MulticastRoute to route the packet to reach dest address + */ + Ptr LookupStatic (Ipv6Address origin, Ipv6Address group, uint32_t ifIndex); - /** - * \brief Choose the source address to use with destination address. - * \param interface interface index - * \param dest IPv6 destination address - * \return IPv6 source address to use - */ - Ipv6Address SourceAddressSelection (uint32_t interface, Ipv6Address dest); + /** + * \brief Choose the source address to use with destination address. + * \param interface interface index + * \param dest IPv6 destination address + * \return IPv6 source address to use + */ + Ipv6Address SourceAddressSelection (uint32_t interface, Ipv6Address dest); - /** - * \brief the forwarding table for network. - */ - NetworkRoutes m_networkRoutes; + /** + * \brief the forwarding table for network. + */ + NetworkRoutes m_networkRoutes; - /** - * \brief the forwarding table for multicast. - */ - MulticastRoutes m_multicastRoutes; + /** + * \brief the forwarding table for multicast. + */ + MulticastRoutes m_multicastRoutes; - /** - * \brief Ipv6 reference. - */ - Ptr m_ipv6; + /** + * \brief Ipv6 reference. + */ + Ptr m_ipv6; }; } /* namespace ns3 */