cidr::parsers

Function inet_addr

source
pub fn inet_addr(s: &str) -> Option<Ipv4Addr>
Expand description

Parse “loose” IPv4 address similar to POSIX inet_addr

This also accepts inputs that are not 4 decimal represented octects separated by dots.

  • Allows less than 4 numbers separated by dots; the last number is interpreted as an 32-bit (no dot), 24-bit (1 dot), 16-bit (2 dots) number. Other numbers still must be octets (i.e. 8 bit)
  • Allows hexadecimal (“0x” or “0X” prefix) and octal (“0” prefix) numbers in all places.

See https://pubs.opengroup.org/onlinepubs/9699919799/functions/inet_addr.html