scan_ip6if(3)
π scan_ip6if(3) β like, the manual page, but make it make sense π
okay bestie, welcome to the scan_ip6if(3) page from the Library Functions Manual πΈ this is the one that takes an IPv6 number and an interface off a string and hands you back the goods. sit down, hydrate, let's go π«Ά
β¨ NAME β¨
scan_ip6 β parse an IPv6 number and interface in ASCII representation
β¨ SYNTAX β¨
no cap, this is literally the whole thing you gotta write:
#include <libowfat/ip6.h>
int scan_ip6if(const char *src,char ip[16],uint32* scope_id);
β¨ DESCRIPTION β¨
so scan_ip6if reads an IPv6 number from src β in RFC1884 ASCII representation, periodt β and writes the result into ip. that's the main character job π
but wait, there's more. if that IPv6 number is followed by a percent sign, scan_ip6if grabs the word that comes right after it, tries to parse that as a network interface, and writes the result to scope_id. cute, right? π
it returns the number of bytes read from src, or 0 if the parsing failed. zero means it didn't eat, and not in the good way π
here's the range it has: scan_ip6if accepts upper and lower case hex letters, it understands "::" compression, and it gets partial IPv4 addresses like in "::FFFF:129.144.52.38". iconic behaviour fr fr β¨
and because we want IPv4 to slide into IPv6 applications transparently, scan_ip6if also understands IPv4 addresses in dotted-decimal notation and will return an IPv4-mapped IPv6 address. so like, "127.0.0.1" will be parsed as "::FFFF:127.0.0.1". π¦
lowkey important: unlike many other IP parsing routines,scan_ip6ifdoes not recognize octal (like0177.0.0.1) or hexadecimal numbers (like0x7f000001) in the IPv4 part. it's not doing all that. π
β¨ EXAMPLE β¨
here's the vibe check, verbatim:
#include <libowfat/str.h>
#include <libowfat/ip6.h>
char buf[]="::1%lo";
char ip[16];
uint32 scope_id;
if (scan_ip6if(buf,ip,&scope_id) != str_len(buf))
parse_error();
β¨ SEE ALSO β¨
go read these next, bestie, they're all in the friend group π:
and that's the whole page, no notes π this was scan_ip6if(3) from the Library Functions Manual β section 3, the library functions section, the one we live in. mwah. go parse something. πβ¨
π¦ 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