IPV6_ADDRFORM(2const)

πŸ“¦
version 6.20 Β· 4 versions
, in arch rolling, nixpkgs unstable

πŸ’« IPV6_ADDRFORM(2const) πŸ’«

okay bestie, gather round, because this one is such a glow-up story ✨ it's a page from the <pink>2const</pink> section of the Linux man-pages, so like, a little constant thing that lives its life inside other calls πŸŽ€


🌸 NAME 🌸

IPV6_ADDRFORM β€” turn an AF_INET6 socket into a socket of a different address family πŸ’…

like... a socket rebrand, no cap.

πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc) 🫢 the classic, the icon, the one you already linked.

✨ SYNOPSIS ✨

#include <netinet/in.h>  /* Definition of IP* constants */
#include <sys/socket.h>

int setsockopt(int sockfd, IPPROTO_IPV6, IPV6_ADDRFORM,
               &(const int){AF_INET}, sizeof(int));

okay so you're calling setsockopt(2) πŸ‘‘ β€” it's not its own function, it's a vibe you pass into setsockopt. You slide IPPROTO_IPV6 in as the level, IPV6_ADDRFORM as the option name, and then the actual value is that sneaky little compound literal &(const int){AF_INET} with sizeof(int) as the length 🌈 very "trust the process" of it.

πŸ¦‹ DESCRIPTION πŸ¦‹

So. IPV6_ADDRFORM turns an AF_INET6 socket into a socket of a different address family. it's giving... metamorphosis 🧚 like a caterpillar but the caterpillar is an IPv6 socket and the butterfly is an IPv4 socket.

Right now, only AF_INET is supported for that πŸ’– just the one. That's the whole menu. Chef's choice.

And β€” this is the important part, don't skip it πŸ™ˆ β€” it's only allowed for IPv6 sockets that are connected and bound to a v4-mapped-on-v6 address. Both. Simultaneously. No shortcuts, bestie, the vibe check is strict here.

Now, why would you even do this? Main character reason: it's useful to pass v4-mapped sockets as file descriptors to programs that have literally no idea how to deal with the IPv6 API 😭 like handing your friend a snack in a wrapper they actually recognize. They never even have to know the IPv6 lore existed. iconic behavior honestly.

πŸ’€ ERRORS πŸ’€

the errors live elsewhere, babe β€” go check setsockopt(2) and ipv6(7) πŸ‘‘

like genuinely, this page is not the one holding the error list, so don't come for me, go read those two πŸ“

πŸ”₯ SEE ALSO πŸ”₯


and that's the tea πŸŽ€ this whole page is from Linux man-pages 6.20, dated 2025-12-02 β€” so if you're quoting it in the group chat, cite your source, periodt πŸ’…βœ¨πŸ«Ά

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms