sw_ipv4_address
is a data type that represents an IP address.
sw_ipv4_address
sw_ipv4_address_any
()
sw_ipv4_address
sw_ipv4_address_loopback
()
sw_result
sw_ipv4_address_init
(sw_ipv4_address *self)
sw_result
sw_ipv4_address_init_from_saddr
(
sw_ipv4_address *self,
sw_saddr saddr)
sw_ipv4_address
at self
. saddr
is a ulong representing the IP address in a format such that 0x01020304 would lead to an IP address of 1.2.3.4.
sw_result
sw_ipv4_address_init_from_name
(
sw_ipv4_address *self,
const sw_string name)
sw_ipv4_address
at self
. name
is a string representing the IP address in "dot" format: for example, "127.0.0.1".
sw_result
sw_ipv4_address_init_from_address
(
sw_ipv4_address *self,
sw_ipv4_address addr)
sw_ipv4_address
at self
, which is an exact copy of addr
.
sw_result
sw_ipv4_address_init_from_this_host
(sw_ipv4_address *self)
sw_ipv4_address
at self
, containing the IP address of the local host.
If the local host is a multi-address host, the particular IP address is determined randomly.
sw_result
sw_ipv4_address_fina
(sw_ipv4_address self)
self
. Equivalent to a destructor in an object-oriented language. After sw_ipv4_address_fina
has been called, it is safe to free the memory occupied by self
.
sw_bool
sw_ipv4_address_is_any
(sw_ipv4_address self)
self
represents the IN_ADDR_ANY address (all zeros).
sw_saddr
sw_ipv4_address_saddr
(sw_ipv4_address self)
self
.
sw_string
sw_ipv4_address_name
(
sw_ipv4_address self,
sw_string name,
sw_ulong len)
name
an ASCII representation of the IP address contained in self
, in "dot" format: "127.0.0.1".
name
is where to store the string. len
is the number of bytes available at name
, including the null terminator.
Returns name
.
sw_result
sw_ipv4_address_decompose
(
sw_ipv4_address self,
sw_octet *a1,
sw_octet *a2,
sw_octet *a3,
sw_octet *a4)
self
.
sw_bool
sw_ipv4_address_equals
(
sw_ipv4_address self,
sw_ipv4_address addr)
self
and addr
represent the same IP address.