Network Address Functions and Operators
Network Address Functions and Operators
The IP network address types, cidr
and inet
, support the usual comparison operators shown in Table 8.1 as well as the specialized operators and functions shown in Table 8.35 and Table 8.36.
Any cidr
value can be cast to inet
implicitly; therefore, the operators and functions shown below as operating on inet
also work on cidr
values. (Where there are separate functions for inet
and cidr
, it is because the behavior should be different for the two cases.) Also, it is permitted to cast an inet
value to cidr
. When this is done, any bits to the right of the netmask are silently zeroed to create a valid cidr
value.
Table IP Address Operators
Operator Description Example(s) |
---|
Is subnet strictly contained by subnet? This operator, and the next four, test for subnet inclusion. They consider only the network parts of the two addresses (ignoring any bits to the right of the netmasks) and determine whether one network is identical to or a subnet of the other.
|
Is subnet contained by or equal to subnet?
|
Does subnet strictly contain subnet?
|
Does subnet contain or equal subnet?
|
Does either subnet contain or equal the other?
|
Computes bitwise NOT.
|
Computes bitwise AND.
|
Computes bitwise OR.
|
Adds an offset to an address.
|
Adds an offset to an address.
|
Subtracts an offset from an address.
|
Computes the difference of two addresses.
|
Table IP Address Functions
Function Description Example(s) |
---|
Creates an abbreviated display format as text. (The result is the same as the
|
Computes the broadcast address for the address's network.
|
Returns the address's family: |
Returns the IP address as text, ignoring the netmask.
|
Computes the host mask for the address's network.
|
Tests whether the addresses belong to the same IP family.
|
Returns the netmask length in bits.
|
Computes the network mask for the address's network.
|
Sets the netmask length for an
|
Returns the unabbreviated IP address and netmask length as text. (This has the same result as an explicit cast to
|
abbrev
, host
, and text
functions are primarily intended to offer alternative display formats for IP addresses.