From dfe7129d43d49c59e5bad43306b7bdc7bb7e70ba Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Sun, 7 Feb 2016 22:24:16 +0100 Subject: [PATCH] network: Add IsLocalhost and IsAny to Ipv4Address --- src/network/bindings/modulegen__gcc_ILP32.py | 10 ++++++++++ src/network/bindings/modulegen__gcc_LP64.py | 10 ++++++++++ src/network/utils/ipv4-address.cc | 14 ++++++++++++++ src/network/utils/ipv4-address.h | 8 ++++++++ 4 files changed, 42 insertions(+) diff --git a/src/network/bindings/modulegen__gcc_ILP32.py b/src/network/bindings/modulegen__gcc_ILP32.py index 553a7250f..6ca40d036 100644 --- a/src/network/bindings/modulegen__gcc_ILP32.py +++ b/src/network/bindings/modulegen__gcc_ILP32.py @@ -1848,6 +1848,11 @@ def register_Ns3Ipv4Address_methods(root_module, cls): 'ns3::Ipv4Address', [], is_static=True) + ## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsAny() const [member function] + cls.add_method('IsAny', + 'bool', + [], + is_const=True) ## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsBroadcast() const [member function] cls.add_method('IsBroadcast', 'bool', @@ -1863,6 +1868,11 @@ def register_Ns3Ipv4Address_methods(root_module, cls): 'bool', [], is_const=True) + ## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsLocalhost() const [member function] + cls.add_method('IsLocalhost', + 'bool', + [], + is_const=True) ## ipv4-address.h (module 'network'): static bool ns3::Ipv4Address::IsMatchingType(ns3::Address const & address) [member function] cls.add_method('IsMatchingType', 'bool', diff --git a/src/network/bindings/modulegen__gcc_LP64.py b/src/network/bindings/modulegen__gcc_LP64.py index 553a7250f..6ca40d036 100644 --- a/src/network/bindings/modulegen__gcc_LP64.py +++ b/src/network/bindings/modulegen__gcc_LP64.py @@ -1848,6 +1848,11 @@ def register_Ns3Ipv4Address_methods(root_module, cls): 'ns3::Ipv4Address', [], is_static=True) + ## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsAny() const [member function] + cls.add_method('IsAny', + 'bool', + [], + is_const=True) ## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsBroadcast() const [member function] cls.add_method('IsBroadcast', 'bool', @@ -1863,6 +1868,11 @@ def register_Ns3Ipv4Address_methods(root_module, cls): 'bool', [], is_const=True) + ## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsLocalhost() const [member function] + cls.add_method('IsLocalhost', + 'bool', + [], + is_const=True) ## ipv4-address.h (module 'network'): static bool ns3::Ipv4Address::IsMatchingType(ns3::Address const & address) [member function] cls.add_method('IsMatchingType', 'bool', diff --git a/src/network/utils/ipv4-address.cc b/src/network/utils/ipv4-address.cc index 3e4797eb3..18d9ae429 100644 --- a/src/network/utils/ipv4-address.cc +++ b/src/network/utils/ipv4-address.cc @@ -264,6 +264,20 @@ Ipv4Address::IsSubnetDirectedBroadcast (Ipv4Mask const &mask) const return ( (Get () | mask.GetInverse ()) == Get () ); } +bool +Ipv4Address::IsAny (void) const +{ + NS_LOG_FUNCTION (this); + return (m_address == 0x00000000U); +} + +bool +Ipv4Address::IsLocalhost (void) const +{ + NS_LOG_FUNCTION (this); + return (m_address == 0x7f000001U); +} + bool Ipv4Address::IsBroadcast (void) const { diff --git a/src/network/utils/ipv4-address.h b/src/network/utils/ipv4-address.h index 9ecf4e5f2..da6f936fa 100644 --- a/src/network/utils/ipv4-address.h +++ b/src/network/utils/ipv4-address.h @@ -105,6 +105,14 @@ public: * \param os The output stream to which this Ipv4Address is printed */ void Print (std::ostream &os) const; + /** + * \return true if address is 0.0.0.0; false otherwise + */ + bool IsAny (void) const; + /** + * \return true if address is 127.0.0.1; false otherwise + */ + bool IsLocalhost (void) const; /** * \return true if address is 255.255.255.255; false otherwise */