fmt_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

✨ NAME ✨

fmt_ip6if β€” bestie, this one writes you a formatted ASCII representation of an IPv6 number πŸ’–


🌸 SYNTAX 🌸

#include <libowfat/ip6.h>

unsigned int fmt_ip6if(char *dest,const char ip[16],uint32 scope_id);

πŸŽ€ DESCRIPTION πŸŽ€

okay so fmt_ip6if takes an IPv6 number from ip, formats it all pretty in ASCII, and drops the result into dest. It hands you back the number of bytes it wrote. cute, right? πŸ’…

It will apply "::" compression to the output β€” no cap, that's the whole point, it keeps things short and iconic ✨

If ip is an IPv4-mapped IPv6 address, fmt_ip6if will output the last 4 bytes as an IPv4 number in dotted-decimal notation. slay 🌈

If dest equals FMT_LEN (i.e. is zero), fmt_ip6if returns the number of bytes it would have written. lowkey a vibe check for sizing πŸ¦‹

🫢 heads up: fmt_ip6 does not append \0.

ip6.h defines the integer IP6_FMT to be big enough to contain every possible fmt_ip6 output plus \0. However, for fmt_ip6if you need to add 1 for the '%' and IF_NAMESIZE from <net/if.h> for the interface name. literally do not forget this part, bestie, or your buffer is gonna be giving πŸ’€


πŸ¦‹ EXAMPLE πŸ¦‹

#include <libowfat/ip6.h>

  char buf[IP6_FMT];
  char ip[16];
  scope_id sid;
  buf[fmt_ip6if(buf,ip,sid)]=0;

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie πŸ’œ this one came straight out of the Library Functions Manual β€” fmt_ip6if(3) β€” so go forth and format those IPv6 numbers, periodt πŸŽ€βœ¨