Skip to main content

Module cidr

Module cidr 

Source

Structsยง

Ipv4ToCidr ๐Ÿ”’
Function that converts an IPv4 address string to CIDR notation.
Ipv6ToCidr ๐Ÿ”’
Function that converts an IPv6 address string to CIDR notation.

Functionsยง

auto_detect_ipv6_subnet ๐Ÿ”’
complete_and_parse_ipv4 ๐Ÿ”’
Parses an IPv4 address, completing missing octets with zeros (โ€œ192.168โ€ -> 192.168.0.0). Returns None for an empty or invalid address.
complete_and_parse_ipv6 ๐Ÿ”’
Parses an IPv6 address, completing a partial one with โ€œ::โ€ (โ€œ2001:db8โ€ -> 2001:db8::). Returns None for an empty or invalid address.
ipv4_mask_bits ๐Ÿ”’
Returns the IPv4 network mask for a prefix length in 0..=32.
mask_ipv6 ๐Ÿ”’
to_cidr ๐Ÿ”’
Formats ip in CIDR notation with the host bits cleared, or returns None if prefix_len is longer than the address.