scan_ip6(3)
β¨ scan_ip6 β ok bestie, let's talk IPv6 parsing β¨
so this lil guy lives in the Library Functions Manual, section 3 (that's the libowfat crew, iykyk π ). its whole job? taking an IPv6 address written out as text and turning it into actual bytes. periodt.
πΈ NAME πΈ
scan_ip6 β parse an IPv6 number in ASCII representation π¦
π SYNTAX π
#include <libowfat/ip6.h>
int scan_ip6(const char *src,char ip[16]);
π DESCRIPTION π
ok so scan_ip6 parses an IPv6 number in RFC1884 ASCII representation from src and writes the result into ip. she returns the number of bytes she read from src, or 0 if the parsing failed π (yes, zero means it did NOT go well, that's your red flag).
she's lowkey flexible too:
- she accepts upper and lower case hex letters (no judgment, both slay)
- she understands
"::"compression π« - she understands partial IPv4 addresses, like
"::FFFF:129.144.52.38"
and here's the iconic part β to allow transparent usage of IPv4 in IPv6 applications, scan_ip6 also understands IPv4 addresses in dotted-decimal notation and will return an IPv4-mapped IPv6 address. so like, "127.0.0.1" gets parsed as "::FFFF:127.0.0.1" π«Ά
β οΈ but bestie, listen: unlike many other IP parsing routines,scan_ip6does not recognize octal (like0177.0.0.1) or hexadecimal numbers (like0x7f000001) in the IPv4 part. no cap. don't try it. she's not doing that.
π EXAMPLE π
#include <libowfat/str.h>
#include <libowfat/ip6.h>
char buf[]="::1";
char ip[16];
if (scan_ip6(buf,ip) != str_len(buf))
parse_error();
see how she compares the return value to str_len(buf)? that's the vibe check β if they don't match, parse_error() time π
π SEE ALSO π
and that's the whole page, bestie π shoutout to the Library Functions Manual and the scan_ip6(3) section-3 girlies for keeping our IPv6 parsing cute and correct β¨π¦ no thoughts, just bytes π«Ά
π¦ where this page comes from
- alpine 3.24: libowfat-doc 0.34-r0 Β· GPL-2.0-only
- debian bookworm: libowfat-dev 0.32-4 Β· GPL-2.0-only
- debian trixie: libowfat-dev 0.32-5 Β· GPL-2.0-only
- nixos 26.05: libowfat 0.34
- nixpkgs unstable: libowfat 0.34
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- ubuntu noble: libowfat-dev 0.32-4.1build1 Β· GPL-2.0-only
- ubuntu questing: libowfat-dev 0.32-5
- ubuntu resolute: libowfat-dev 0.34-2 Β· GPL-2.0-only
- ubuntu stonking: libowfat-dev 0.34-2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms