InetCidr

Classless Inter-Domain Routing (CIDR) that is compatible with :inet and supports both IPv4 and IPv6

Source

Summary

address_count(ip, len)

The number of IP addresses included in the CIDR block

bit_count(arg1)

The number of bits in the address family (32 for IPv4 and 128 for IPv6)

contains?(arg1, arg2)

Returns true if the CIDR block contains the IP address, false otherwise

parse(cidr_string, adjust \\ false)

Parses a string containing either an IPv4 or IPv6 CIDR block using the notation like 192.168.0.0/16 or 2001:abcd::/32. It returns a tuple with the start address, end address and cidr length

parse_address!(prefix)

Convenience function that takes an IPv4 or IPv6 address as a string and returns the address. It raises an exception if the string does not contain a valid ip address

to_string(arg1)

Prints the CIDR block to a string such that it can be parsed back to a CIDR block by this module

v4?(arg1)

Returns true if the value passed in is an IPv4 address, false otherwise

v6?(arg1)

Returns true if the value passed in is an IPv6 address, false otherwise

Functions

address_count(ip, len)

The number of IP addresses included in the CIDR block.

Source
bit_count(arg1)

The number of bits in the address family (32 for IPv4 and 128 for IPv6)

Source
contains?(arg1, arg2)

Returns true if the CIDR block contains the IP address, false otherwise.

Source
parse(cidr_string, adjust \\ false)

Parses a string containing either an IPv4 or IPv6 CIDR block using the notation like 192.168.0.0/16 or 2001:abcd::/32. It returns a tuple with the start address, end address and cidr length.

You can optionally pass true as the second argument to adjust the start ip address if it is not consistent with the cidr length. For example, 192.168.0.0/0 would be adjusted to have a start ip of 0.0.0.0 instead of 192.168.0.0. The default behavior is to be more strict and raise an exception when this occurs.

Source
parse_address!(prefix)

Convenience function that takes an IPv4 or IPv6 address as a string and returns the address. It raises an exception if the string does not contain a valid ip address.

Source
to_string(arg1)

Prints the CIDR block to a string such that it can be parsed back to a CIDR block by this module.

Source
v4?(arg1)

Returns true if the value passed in is an IPv4 address, false otherwise.

Source
v6?(arg1)

Returns true if the value passed in is an IPv6 address, false otherwise.

Source