Google is committed to advancing racial equity for Black communities. See how.

nl::Inet::IPPrefix

#include <src/inet/IPPrefix.h>

Internet protocol address prefix.

Summary

Use objects of the IPPrefix class to represent Internet protocol address prefixes of both IPv4 and IPv6 address families.

Public attributes

IPAddr
An IPv6 or IPv4 address.
Length
uint8_t
Length of the prefix.

Public static attributes

Zero
A distinguished object where the type of IPAddr is kIPAddressType_Any and Length == 0.

Public functions

IsZero(void) const
bool
Compares the prefix with the distinguished Zero value.
MatchAddress(const IPAddress & addr) const
bool
Test if an address matches the prefix.
operator!=(const IPPrefix & other) const
bool
Compares the prefix with another for inequivalence.
operator=(const IPPrefix & other)
Conventional assignment operator.
operator==(const IPPrefix & other) const
bool
Compares the prefix with another for equivalence.

Public attributes

IPAddr

IPAddress IPAddr

An IPv6 or IPv4 address.

Length

uint8_t Length

Length of the prefix.

Note well: this field is public, and it is an invariant of this class that Length <= 32 where the type of IPAddr is kIPAddressType_IPv4 and Length <= 128 where the type of IPAddr is kIPAddressType_IPv6.

Public static attributes

Zero

IPPrefix Zero

A distinguished object where the type of IPAddr is kIPAddressType_Any and Length == 0.

Public functions

IsZero

bool IsZero(
  void
) const 

Compares the prefix with the distinguished Zero value.

Note well: a prefix is not equivalent to Zero if the type of IPAddr is not kIPAddressType_Any.

Details
Returns
true if equivalent to Zero, else false.

MatchAddress

bool MatchAddress(
  const IPAddress & addr
) const 

Test if an address matches the prefix.

Details
Parameters
[in] addr
the address to test.
Returns
true if addr has the prefix, else false.

operator!=

bool operator!=(
  const IPPrefix & other
) const 

Compares the prefix with another for inequivalence.

Note well: two prefixes are not equivalent unless the IPAddr fields are completely equivalent, i.e. all 128 bits must be identical.

Details
Returns
false if equivalent, else false.

operator=

IPPrefix & operator=(
  const IPPrefix & other
)

Conventional assignment operator.

Details
Parameters
[in] other
the prefix to copy.
Returns
a reference to this object.

operator==

bool operator==(
  const IPPrefix & other
) const 

Compares the prefix with another for equivalence.

Note well: two prefixes are not equivalent unless the IPAddr fields are completely equivalent, i.e. all 128 bits must be identical.

Details
Returns
true if equivalent, else false.