IPV6_ADDRFORM(2const)
π« 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 π₯
IPPROTO_IPV6(2const)πsetsockopt(2)πΈipv6(7)β
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