|
CX Framework
Cross-platform C utility framework
|
Functions | |
| bool | netAddrFromStr (NetAddr *addr, strref str) |
| bool | netAddrToStr (string *str, const NetAddr *addr) |
Network address functions for IPv4 and IPv6.
| bool netAddrFromStr | ( | NetAddr * | addr, |
| strref | str | ||
| ) |
Parse an IPv4 or IPv6 address string
Accepts a dotted-quad IPv4 literal ("192.168.1.1") or an IPv6 literal ("::1", "fe80::1%eth0"), including "::" compression, an embedded IPv4 tail ("::ffff:10.0.0.1"), and a zone suffix – numeric ("%3") or an interface name resolved through the OS. No port suffix is accepted; the port field is left 0, set addr->port separately.
| addr | Output address structure |
| str | Address string to parse |
Example:
| bool netAddrToStr | ( | string * | str, |
| const NetAddr * | addr | ||
| ) |
Format an address as a string
Writes the host portion only (dotted-quad for IPv4, RFC 5952 compressed form for IPv6, with a numeric zone suffix if the scope is nonzero) – the port is not included.
| str | Output string; overwritten with the formatted address |
| addr | Address to format |
Example: