ipaddr
IP Address Parsing and Manipulation
Functions
| Function | Description |
|---|---|
ip_from_octets | Build IP from 4 octets. |
ip_octet | Get octet n (0=first/MSB, 3=last/LSB). |
ip_parse | Parse “a.b.c.d” string to integer. |
ip_write_int | Internal: write integer digits to buffer, return length. |
ip_format | Format integer IP to “a.b.c.d” string. Returns length. |
ip_is_private | Is this a private (RFC 1918) address? |
ip_is_loopback | Is this a loopback address? |
ip_is_multicast | Is this a multicast address? |
ip_mask | Internal: create subnet mask from prefix length. |
ip_network | Network address for addr/prefix. |
ip_broadcast | Broadcast address for addr/prefix. |
ip_in_subnet | Check if addr is within network/prefix. |
ip_to_sockaddr | Write struct sockaddr_in (16 bytes) to dst for use with connect/bind. AF_INET… |
Details
ip_from_octets
fn ip_from_octets(a: i64, b: i64, c: i64, d: i64) -> i64Build IP from 4 octets.
ip_octet
fn ip_octet(addr: i64, n: i64) -> i64Get octet n (0=first/MSB, 3=last/LSB).
ip_parse
fn ip_parse(src: &i8, len: i64) -> i64Parse “a.b.c.d” string to integer.
ip_write_int
fn ip_write_int(val: i64, dst: &i8, off: i64) -> i64Internal: write integer digits to buffer, return length.
ip_format
fn ip_format(addr: i64, dst: &i8) -> i64Format integer IP to “a.b.c.d” string. Returns length.
ip_is_private
fn ip_is_private(addr: i64) -> i64Is this a private (RFC 1918) address?
ip_is_loopback
fn ip_is_loopback(addr: i64) -> i64Is this a loopback address?
ip_is_multicast
fn ip_is_multicast(addr: i64) -> i64Is this a multicast address?
ip_mask
fn ip_mask(prefix: i64) -> i64Internal: create subnet mask from prefix length.
ip_network
fn ip_network(addr: i64, prefix: i64) -> i64Network address for addr/prefix.
ip_broadcast
fn ip_broadcast(addr: i64, prefix: i64) -> i64Broadcast address for addr/prefix.
ip_in_subnet
fn ip_in_subnet(addr: i64, net: i64, prefix: i64) -> i64Check if addr is within network/prefix.
ip_to_sockaddr
fn ip_to_sockaddr(addr: i64, port: i64, dst: &i8) -> i64Write struct sockaddr_in (16 bytes) to dst for use with connect/bind. AF_INET=2, port in network byte order.