Deprecate IsEqual for Ipv[4,6]Address, Ipv6Prefix, and Ipv4Mask

This commit is contained in:
Tommaso Pecorella
2020-02-15 19:22:05 +01:00
parent 6a27f55505
commit 8b91e2fbe9
13 changed files with 87 additions and 32 deletions

View File

@@ -436,15 +436,6 @@ std::istream & operator >> (std::istream &is, Ipv4Mask &mask)
return is;
}
bool operator == (Ipv4Mask const &a, Ipv4Mask const &b)
{
return a.IsEqual (b);
}
bool operator != (Ipv4Mask const &a, Ipv4Mask const &b)
{
return !a.IsEqual (b);
}
ATTRIBUTE_HELPER_CPP (Ipv4Address);
ATTRIBUTE_HELPER_CPP (Ipv4Mask);

View File

@@ -25,6 +25,7 @@
#include <ostream>
#include "ns3/address.h"
#include "ns3/attribute-helper.h"
#include "ns3/deprecated.h"
namespace ns3 {
@@ -77,9 +78,13 @@ public:
void Set (char const *address);
/**
* \brief Comparison operation between two Ipv4Addresses
*
* \deprecated Use the == operator (same functionality)
*
* \param other address to which to compare this address
* \return True if the addresses are equal. False otherwise.
*/
NS_DEPRECATED_3_31
bool IsEqual (const Ipv4Address &other) const
{
return m_address == other.m_address;
@@ -279,9 +284,13 @@ public:
*/
bool IsMatch (Ipv4Address a, Ipv4Address b) const;
/**
*
* \deprecated Use the == operator (same functionality)
*
* \param other a mask to compare
* \return true if the mask equals the mask passed as input parameter
*/
NS_DEPRECATED_3_31
bool IsEqual (Ipv4Mask other) const;
/**
* Get the host-order 32-bit IP mask
@@ -322,6 +331,25 @@ public:
*/
static Ipv4Mask GetOnes (void);
/**
* \brief Equal to operator.
*
* \param a the first operand.
* \param b the first operand.
* \returns true if the operands are equal.
*/
friend bool operator == (Ipv4Mask const &a, Ipv4Mask const &b);
/**
* \brief Not equal to operator.
*
* \param a the first operand.
* \param b the first operand.
* \returns true if the operands are not equal.
*/
friend bool operator != (Ipv4Mask const &a, Ipv4Mask const &b);
private:
uint32_t m_mask; //!< IP mask
};
@@ -418,7 +446,11 @@ public:
* \param b the first operand
* \returns true if the operands are equal
*/
bool operator == (Ipv4Mask const &a, Ipv4Mask const &b);
inline bool operator == (Ipv4Mask const &a, Ipv4Mask const &b)
{
return (a.m_mask == b.m_mask);
}
/**
* \brief Not equal to operator.
*
@@ -426,7 +458,11 @@ bool operator == (Ipv4Mask const &a, Ipv4Mask const &b);
* \param b the first operand
* \returns true if the operands are not equal
*/
bool operator != (Ipv4Mask const &a, Ipv4Mask const &b);
inline bool operator != (Ipv4Mask const &a, Ipv4Mask const &b)
{
return (a.m_mask != b.m_mask);
}
} // namespace ns3

View File

@@ -729,7 +729,7 @@ bool Ipv6Address::IsIpv4MappedAddress () const
return (false);
}
Ipv6Address Ipv6Address::CombinePrefix (Ipv6Prefix const& prefix)
Ipv6Address Ipv6Address::CombinePrefix (Ipv6Prefix const& prefix) const
{
NS_LOG_FUNCTION (this << prefix);
Ipv6Address ipv6;
@@ -811,6 +811,16 @@ bool Ipv6Address::IsDocumentation () const
return false;
}
bool Ipv6Address::HasPrefix (Ipv6Prefix const& prefix) const
{
NS_LOG_FUNCTION (this << prefix);
Ipv6Address masked = CombinePrefix (prefix);
Ipv6Address reference = Ipv6Address::GetOnes ().CombinePrefix (prefix);
return (masked == reference);
}
bool Ipv6Address::IsMatchingType (const Address& address)
{

View File

@@ -101,9 +101,12 @@ public:
/**
* \brief Comparison operation between two Ipv6Addresses.
*
* \param other the IPv6 address to which to compare thisaddress
* \deprecated Use the == operator (same functionality)
*
* \param other the IPv6 address to which to compare this address
* \return true if the addresses are equal, false otherwise
*/
NS_DEPRECATED_3_31
bool IsEqual (const Ipv6Address& other) const;
/**
@@ -311,13 +314,20 @@ public:
*/
bool IsDocumentation () const;
/**
* \brief Compares an address and a prefix.
* \param prefix the prefix to compare with
* \return true if the address has the given prefix
*/
bool HasPrefix (Ipv6Prefix const& prefix) 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);
Ipv6Address CombinePrefix (Ipv6Prefix const & prefix) const;
/**
* \brief If the Address matches the type.
@@ -536,19 +546,23 @@ public:
* \brief Set prefix length.
* \param prefixLength the prefix length
*/
void SetPrefixLength (uint8_t prefixLength);
void SetPrefixLength (uint8_t prefixLength);
/**
* \brief Get the minimum prefix length, i.e., 128 - the length of the largest sequence trailing zeroes.
* \return minimum prefix length
*/
uint8_t GetMinimumPrefixLength () const;
uint8_t GetMinimumPrefixLength () const;
/**
* \brief Comparison operation between two Ipv6Prefix.
*
* \deprecated Use the == operator (same functionality)
*
* \param other the IPv6 prefix to which to compare this prefix
* \return true if the prefixes are equal, false otherwise
*/
NS_DEPRECATED_3_31
bool IsEqual (const Ipv6Prefix& other) const;
/**