Next: Utility functions, Previous: Data structures, Up: Embedding API [Contents][Index]
A network address comprises a family, such as AF_INET
(also known as IPv4), and its bits in network byte order, such as
the bytes 127, 0, 0 and 1 (also known as the IPv4 loopback
address). Many libserveez functions take svz_address_t *
.
Please note: Although svz_address_t
supports1 IPv6, the rest
of libserveez it does not (yet). This means you can freely create and
manipulate address objects with the functions described in this
section, but any attempt to pass to the rest of libserveez an address
with a family other than AF_INET
will immediately abort
the process. When full IPv6 support is in place, this blurb will be
deleted and the list returned by svz_library_features
will
include an appropriate indicator (see Library features).
Return an address object to hold an address in family, represented by bits. family must be one of:
AF_INET
An IPv4 address; bits is in_addr_t *
.
AF_INET6
(if supported by your system) An IPv6 address;
bits is struct in6_addr *
.
The bits are expected in network byte order.
If there are problems, return NULL
.
Return the address family of addr.
Copy the address bits out of addr to dest.
Return 0 on success, -1 if either addr or dest
is NULL
, or the addr family is AF_UNSPEC
.
Return 1 if a and b represent the same address (identical family and bits), otherwise 0.
Format an external representation of addr into buf,
of size bytes. The format depends on the family of
addr. For IPv4, this is numbers-and-dots. For IPv6, it
is “the most appropriate IPv6 network address format for
addr”, according to the manpage of inet_ntop
, the
function that actually does the work.
If buf or addr is NULL
, or size is not
big enough, return NULL
. Otherwise, return buf.
Format an external representation of addr and port
(in network byte order) into buf, of size bytes.
The address xrep (external representation) is done by
svz_pp_address
, q.v. The rest of the formatting depends
on the addr family.
Family | Formatting |
---|---|
AF_INET (IPv4) | xrep:port |
AF_INET6 (IPv6) | [xrep]:port |
If buf or addr is NULL
, or size is not
big enough, return NULL
. Otherwise, return buf.
Return a copy of addr.
Expand to a series of commands. First, if place is
non-NULL
, then svz_free
it. Next, assign to
place a new address object made by calling
svz_address_make
with family and bits.
Expand to a call to svz_pp_address
, passing it
buf and sizeof buf
, in addition to addr.
Expand to a call to svz_pp_addr_port
, passing it
buf and sizeof buf
, in addition to
addr and port.
Next: Utility functions, Previous: Data structures, Up: Embedding API [Contents][Index]