diff --git a/src/internet/bindings/modulegen__gcc_ILP32.py b/src/internet/bindings/modulegen__gcc_ILP32.py index ae8752c47..b9d247f88 100644 --- a/src/internet/bindings/modulegen__gcc_ILP32.py +++ b/src/internet/bindings/modulegen__gcc_ILP32.py @@ -3236,6 +3236,11 @@ def register_Ns3Ipv6InterfaceAddress_methods(root_module, cls): 'ns3::Ipv6InterfaceAddress::State_e', [], is_const=True) + ## ipv6-interface-address.h (module 'internet'): bool ns3::Ipv6InterfaceAddress::IsInSameSubnet(ns3::Ipv6Address b) const [member function] + cls.add_method('IsInSameSubnet', + 'bool', + [param('ns3::Ipv6Address', 'b')], + is_const=True) ## ipv6-interface-address.h (module 'internet'): void ns3::Ipv6InterfaceAddress::SetAddress(ns3::Ipv6Address address) [member function] cls.add_method('SetAddress', 'void', @@ -5090,7 +5095,6 @@ def register_Ns3Empty_methods(root_module, cls): return def register_Ns3Int64x64_t_methods(root_module, cls): - cls.add_binary_comparison_operator('<=') cls.add_binary_comparison_operator('!=') cls.add_inplace_numeric_operator('+=', param('ns3::int64x64_t const &', u'right')) cls.add_binary_numeric_operator('*', root_module['ns3::int64x64_t'], root_module['ns3::int64x64_t'], param('ns3::int64x64_t const &', u'right')) @@ -5104,6 +5108,7 @@ def register_Ns3Int64x64_t_methods(root_module, cls): cls.add_inplace_numeric_operator('-=', param('ns3::int64x64_t const &', u'right')) cls.add_inplace_numeric_operator('/=', param('ns3::int64x64_t const &', u'right')) cls.add_output_stream_operator() + cls.add_binary_comparison_operator('<=') cls.add_binary_comparison_operator('==') cls.add_binary_comparison_operator('>=') ## int64x64-double.h (module 'core'): ns3::int64x64_t::int64x64_t() [constructor] @@ -9515,7 +9520,6 @@ def register_Ns3TcpWestwood_methods(root_module, cls): return def register_Ns3Time_methods(root_module, cls): - cls.add_binary_comparison_operator('<=') cls.add_binary_comparison_operator('!=') cls.add_inplace_numeric_operator('+=', param('ns3::Time const &', u'right')) cls.add_binary_numeric_operator('*', root_module['ns3::Time'], root_module['ns3::Time'], param('int64_t const &', u'right')) @@ -9526,6 +9530,7 @@ def register_Ns3Time_methods(root_module, cls): cls.add_binary_comparison_operator('>') cls.add_inplace_numeric_operator('-=', param('ns3::Time const &', u'right')) cls.add_output_stream_operator() + cls.add_binary_comparison_operator('<=') cls.add_binary_comparison_operator('==') cls.add_binary_comparison_operator('>=') ## nstime.h (module 'core'): ns3::Time::Time() [constructor] @@ -12413,6 +12418,11 @@ def register_Ns3Ipv6_methods(root_module, cls): 'void', [param('uint32_t', 'interface')], is_pure_virtual=True, is_virtual=True) + ## ipv6.h (module 'internet'): ns3::Ipv6Address ns3::Ipv6::SourceAddressSelection(uint32_t interface, ns3::Ipv6Address dest) [member function] + cls.add_method('SourceAddressSelection', + 'ns3::Ipv6Address', + [param('uint32_t', 'interface'), param('ns3::Ipv6Address', 'dest')], + is_pure_virtual=True, is_virtual=True) ## ipv6.h (module 'internet'): ns3::Ipv6::IF_ANY [variable] cls.add_static_attribute('IF_ANY', 'uint32_t const', is_const=True) ## ipv6.h (module 'internet'): bool ns3::Ipv6::GetIpForward() const [member function] @@ -13281,6 +13291,11 @@ def register_Ns3Ipv6L3Protocol_methods(root_module, cls): 'void', [param('uint32_t', 'i'), param('bool', 'val')], is_virtual=True) + ## ipv6-l3-protocol.h (module 'internet'): ns3::Ipv6Address ns3::Ipv6L3Protocol::SourceAddressSelection(uint32_t interface, ns3::Ipv6Address dest) [member function] + cls.add_method('SourceAddressSelection', + 'ns3::Ipv6Address', + [param('uint32_t', 'interface'), param('ns3::Ipv6Address', 'dest')], + is_virtual=True) ## ipv6-l3-protocol.h (module 'internet'): ns3::Ptr ns3::Ipv6L3Protocol::GetNetDevice(uint32_t i) [member function] cls.add_method('GetNetDevice', 'ns3::Ptr< ns3::NetDevice >', @@ -14573,10 +14588,10 @@ def register_Ns3Packet_methods(root_module, cls): 'uint32_t', [param('uint8_t *', 'buffer'), param('uint32_t', 'maxSize')], is_const=True) - ## packet.h (module 'network'): void ns3::Packet::SetNixVector(ns3::Ptr arg0) [member function] + ## packet.h (module 'network'): void ns3::Packet::SetNixVector(ns3::Ptr nixVector) [member function] cls.add_method('SetNixVector', 'void', - [param('ns3::Ptr< ns3::NixVector >', 'arg0')]) + [param('ns3::Ptr< ns3::NixVector >', 'nixVector')]) return def register_Ns3ParetoRandomVariable_methods(root_module, cls): diff --git a/src/internet/bindings/modulegen__gcc_LP64.py b/src/internet/bindings/modulegen__gcc_LP64.py index ae8752c47..b9d247f88 100644 --- a/src/internet/bindings/modulegen__gcc_LP64.py +++ b/src/internet/bindings/modulegen__gcc_LP64.py @@ -3236,6 +3236,11 @@ def register_Ns3Ipv6InterfaceAddress_methods(root_module, cls): 'ns3::Ipv6InterfaceAddress::State_e', [], is_const=True) + ## ipv6-interface-address.h (module 'internet'): bool ns3::Ipv6InterfaceAddress::IsInSameSubnet(ns3::Ipv6Address b) const [member function] + cls.add_method('IsInSameSubnet', + 'bool', + [param('ns3::Ipv6Address', 'b')], + is_const=True) ## ipv6-interface-address.h (module 'internet'): void ns3::Ipv6InterfaceAddress::SetAddress(ns3::Ipv6Address address) [member function] cls.add_method('SetAddress', 'void', @@ -5090,7 +5095,6 @@ def register_Ns3Empty_methods(root_module, cls): return def register_Ns3Int64x64_t_methods(root_module, cls): - cls.add_binary_comparison_operator('<=') cls.add_binary_comparison_operator('!=') cls.add_inplace_numeric_operator('+=', param('ns3::int64x64_t const &', u'right')) cls.add_binary_numeric_operator('*', root_module['ns3::int64x64_t'], root_module['ns3::int64x64_t'], param('ns3::int64x64_t const &', u'right')) @@ -5104,6 +5108,7 @@ def register_Ns3Int64x64_t_methods(root_module, cls): cls.add_inplace_numeric_operator('-=', param('ns3::int64x64_t const &', u'right')) cls.add_inplace_numeric_operator('/=', param('ns3::int64x64_t const &', u'right')) cls.add_output_stream_operator() + cls.add_binary_comparison_operator('<=') cls.add_binary_comparison_operator('==') cls.add_binary_comparison_operator('>=') ## int64x64-double.h (module 'core'): ns3::int64x64_t::int64x64_t() [constructor] @@ -9515,7 +9520,6 @@ def register_Ns3TcpWestwood_methods(root_module, cls): return def register_Ns3Time_methods(root_module, cls): - cls.add_binary_comparison_operator('<=') cls.add_binary_comparison_operator('!=') cls.add_inplace_numeric_operator('+=', param('ns3::Time const &', u'right')) cls.add_binary_numeric_operator('*', root_module['ns3::Time'], root_module['ns3::Time'], param('int64_t const &', u'right')) @@ -9526,6 +9530,7 @@ def register_Ns3Time_methods(root_module, cls): cls.add_binary_comparison_operator('>') cls.add_inplace_numeric_operator('-=', param('ns3::Time const &', u'right')) cls.add_output_stream_operator() + cls.add_binary_comparison_operator('<=') cls.add_binary_comparison_operator('==') cls.add_binary_comparison_operator('>=') ## nstime.h (module 'core'): ns3::Time::Time() [constructor] @@ -12413,6 +12418,11 @@ def register_Ns3Ipv6_methods(root_module, cls): 'void', [param('uint32_t', 'interface')], is_pure_virtual=True, is_virtual=True) + ## ipv6.h (module 'internet'): ns3::Ipv6Address ns3::Ipv6::SourceAddressSelection(uint32_t interface, ns3::Ipv6Address dest) [member function] + cls.add_method('SourceAddressSelection', + 'ns3::Ipv6Address', + [param('uint32_t', 'interface'), param('ns3::Ipv6Address', 'dest')], + is_pure_virtual=True, is_virtual=True) ## ipv6.h (module 'internet'): ns3::Ipv6::IF_ANY [variable] cls.add_static_attribute('IF_ANY', 'uint32_t const', is_const=True) ## ipv6.h (module 'internet'): bool ns3::Ipv6::GetIpForward() const [member function] @@ -13281,6 +13291,11 @@ def register_Ns3Ipv6L3Protocol_methods(root_module, cls): 'void', [param('uint32_t', 'i'), param('bool', 'val')], is_virtual=True) + ## ipv6-l3-protocol.h (module 'internet'): ns3::Ipv6Address ns3::Ipv6L3Protocol::SourceAddressSelection(uint32_t interface, ns3::Ipv6Address dest) [member function] + cls.add_method('SourceAddressSelection', + 'ns3::Ipv6Address', + [param('uint32_t', 'interface'), param('ns3::Ipv6Address', 'dest')], + is_virtual=True) ## ipv6-l3-protocol.h (module 'internet'): ns3::Ptr ns3::Ipv6L3Protocol::GetNetDevice(uint32_t i) [member function] cls.add_method('GetNetDevice', 'ns3::Ptr< ns3::NetDevice >', @@ -14573,10 +14588,10 @@ def register_Ns3Packet_methods(root_module, cls): 'uint32_t', [param('uint8_t *', 'buffer'), param('uint32_t', 'maxSize')], is_const=True) - ## packet.h (module 'network'): void ns3::Packet::SetNixVector(ns3::Ptr arg0) [member function] + ## packet.h (module 'network'): void ns3::Packet::SetNixVector(ns3::Ptr nixVector) [member function] cls.add_method('SetNixVector', 'void', - [param('ns3::Ptr< ns3::NixVector >', 'arg0')]) + [param('ns3::Ptr< ns3::NixVector >', 'nixVector')]) return def register_Ns3ParetoRandomVariable_methods(root_module, cls): diff --git a/src/internet/model/ipv6-l3-protocol.cc b/src/internet/model/ipv6-l3-protocol.cc index 54bf5367a..530b9ad90 100644 --- a/src/internet/model/ipv6-l3-protocol.cc +++ b/src/internet/model/ipv6-l3-protocol.cc @@ -570,6 +570,45 @@ void Ipv6L3Protocol::SetForwarding (uint32_t i, bool val) interface->SetForwarding (val); } +Ipv6Address Ipv6L3Protocol::SourceAddressSelection (uint32_t interface, Ipv6Address dest) +{ + NS_LOG_FUNCTION (this << interface << dest); + Ipv6Address ret; + + if (dest.IsLinkLocal () || dest.IsLinkLocalMulticast ()) + { + for (uint32_t i = 0; i < GetNAddresses (interface); i++) + { + Ipv6InterfaceAddress test = GetAddress (interface, i); + if (test.GetScope () == Ipv6InterfaceAddress::LINKLOCAL) + { + return test.GetAddress (); + } + } + NS_ASSERT_MSG (false, "No link-local address found on interface " << interface); + } + + for (uint32_t i = 0; i < GetNAddresses (interface); i++) + { + Ipv6InterfaceAddress test = GetAddress (interface, i); + + if (test.GetScope () == Ipv6InterfaceAddress::GLOBAL) + { + if (test.IsInSameSubnet (dest)) + { + return test.GetAddress (); + } + else + { + ret = test.GetAddress (); + } + } + } + + // no specific match found. Use a global address (any useful is fine). + return ret; +} + void Ipv6L3Protocol::SetIpForward (bool forward) { NS_LOG_FUNCTION (this << forward); diff --git a/src/internet/model/ipv6-l3-protocol.h b/src/internet/model/ipv6-l3-protocol.h index fbc3fa7ea..ddb8491f4 100644 --- a/src/internet/model/ipv6-l3-protocol.h +++ b/src/internet/model/ipv6-l3-protocol.h @@ -323,6 +323,8 @@ public: */ void SetForwarding (uint32_t i, bool val); + Ipv6Address SourceAddressSelection (uint32_t interface, Ipv6Address dest); + /** * \brief Get device by index. * \param i device index on this stack diff --git a/src/internet/model/ipv6-static-routing.cc b/src/internet/model/ipv6-static-routing.cc index 19fae9754..9770408e3 100644 --- a/src/internet/model/ipv6-static-routing.cc +++ b/src/internet/model/ipv6-static-routing.cc @@ -290,7 +290,7 @@ Ptr Ipv6StaticRouting::LookupStatic (Ipv6Address dst, Ptr { 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->SetSource (m_ipv6->SourceAddressSelection (m_ipv6->GetInterfaceForDevice (interface), dst)); rtentry->SetDestination (dst); rtentry->SetGateway (Ipv6Address::GetZero ()); rtentry->SetOutputDevice (interface); @@ -339,15 +339,15 @@ Ptr Ipv6StaticRouting::LookupStatic (Ipv6Address dst, Ptr if (route->GetGateway ().IsAny ()) { - rtentry->SetSource (SourceAddressSelection (interfaceIdx, route->GetDest ())); + rtentry->SetSource (m_ipv6->SourceAddressSelection (interfaceIdx, route->GetDest ())); } else if (route->GetDest ().IsAny ()) /* default route */ { - rtentry->SetSource (SourceAddressSelection (interfaceIdx, route->GetPrefixToUse ().IsAny () ? dst : route->GetPrefixToUse ())); + rtentry->SetSource (m_ipv6->SourceAddressSelection (interfaceIdx, route->GetPrefixToUse ().IsAny () ? dst : route->GetPrefixToUse ())); } else { - rtentry->SetSource (SourceAddressSelection (interfaceIdx, route->GetGateway ())); + rtentry->SetSource (m_ipv6->SourceAddressSelection (interfaceIdx, route->GetGateway ())); } rtentry->SetDestination (route->GetDest ()); @@ -359,7 +359,7 @@ Ptr Ipv6StaticRouting::LookupStatic (Ipv6Address dst, Ptr if (rtentry) { - NS_LOG_LOGIC ("Matching route via " << rtentry->GetDestination () << " (throught " << rtentry->GetGateway () << ") at the end"); + NS_LOG_LOGIC ("Matching route via " << rtentry->GetDestination () << " (Through " << rtentry->GetGateway () << ") at the end"); } return rtentry; } @@ -793,44 +793,5 @@ void Ipv6StaticRouting::NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv } } -Ipv6Address Ipv6StaticRouting::SourceAddressSelection (uint32_t interface, Ipv6Address dest) -{ - NS_LOG_FUNCTION (this << interface << dest); - Ipv6Address ret; - - if (dest.IsLinkLocal () || dest.IsLinkLocalMulticast ()) - { - for (uint32_t i = 0; i < m_ipv6->GetNAddresses (interface); i++) - { - Ipv6InterfaceAddress test = m_ipv6->GetAddress (interface, i); - if (test.GetScope () == Ipv6InterfaceAddress::LINKLOCAL) - { - return test.GetAddress (); - } - } - NS_ASSERT_MSG (false, "No link-local address found on interface " << interface); - } - - for (uint32_t i = 0; i < m_ipv6->GetNAddresses (interface); i++) - { - Ipv6InterfaceAddress test = m_ipv6->GetAddress (interface, i); - - if (test.GetScope () == Ipv6InterfaceAddress::GLOBAL) - { - if (test.IsInSameSubnet (dest)) - { - return test.GetAddress (); - } - else - { - ret = test.GetAddress (); - } - } - } - - // no specific match found. Use a global address (any useful is fine). - return ret; -} - } /* namespace ns3 */ diff --git a/src/internet/model/ipv6-static-routing.h b/src/internet/model/ipv6-static-routing.h index 39db9133b..06a952539 100644 --- a/src/internet/model/ipv6-static-routing.h +++ b/src/internet/model/ipv6-static-routing.h @@ -292,14 +292,6 @@ private: */ 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 the forwarding table for network. */ diff --git a/src/internet/model/ipv6.h b/src/internet/model/ipv6.h index 6bf542be7..3c3251035 100644 --- a/src/internet/model/ipv6.h +++ b/src/internet/model/ipv6.h @@ -304,6 +304,14 @@ public: */ virtual void SetForwarding (uint32_t interface, bool val) = 0; + /** + * \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 + */ + virtual Ipv6Address SourceAddressSelection (uint32_t interface, Ipv6Address dest) = 0; + /** * \brief Get L4 protocol by protocol number. * \param protocolNumber protocol number