Skip to main contentModule cidr
Source - Ipv4ToCidr ๐
- Function that converts an IPv4 address string to CIDR notation.
- Ipv6ToCidr ๐
- Function that converts an IPv6 address string to CIDR notation.
- 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.