scan_ip6if(3)

πŸ“¦
version 0.34 Β· 2 versions
  • 0.34 Β· alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.30 Β· fedora 43, fedora 44, ubuntu jammy
, in alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– 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_ip6if does not recognize octal (like 0177.0.0.1) or hexadecimal numbers (like 0x7f000001) 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. 🌈✨