IPV6_RTHDR(2const)
π IPV6_RTHDR(2const) β bestie's guide to extension-header control messages π
okay so this is IPV6_RTHDR(2const), a little family of constants from the Linux manual pages (section 2const, the constant-crew section, iykyk). They're all about one thing and one thing only: telling your socket yes please, hand me the control messages for incoming datagrams that come with extension headers. Six constants, one vibe. Let's get into it π¦
β¨ LIBRARY β¨
Standard C library (libc, -lc). Classic.
πΈ SYNOPSIS πΈ
#include <netinet/in.h> /* Definition of IP* constants */
#include <sys/socket.h>
int setsockopt(int sockfd, IPPROTO_IPV6, IPV6_RTHDR,
const int *enable, sizeof(int));
int setsockopt(int sockfd, IPPROTO_IPV6, IPV6_AUTHHDR,
const int *enable, sizeof(int));
int setsockopt(int sockfd, IPPROTO_IPV6, IPV6_DSTOPTS,
const int *enable, sizeof(int));
int setsockopt(int sockfd, IPPROTO_IPV6, IPV6_HOPOPTS,
const int *enable, sizeof(int));
int setsockopt(int sockfd, IPPROTO_IPV6, IPV6_FLOWINFO,
const int *enable, sizeof(int));
int setsockopt(int sockfd, IPPROTO_IPV6, IPV6_HOPLIMIT,
const int *enable, sizeof(int));
six setsockopt() calls, same shape, six different constants. it's giving "choose your fighter" β¨
π DESCRIPTION π
So the whole point of these bad boys: they set the delivery of control messages for incoming datagrams that contain extension headers, straight from the received packet. You opt in, the kernel slides the goods into your control buffer. Simple, iconic, no cap. π
Here's who delivers what:
IPV6_RTHDRβ delivers the routing header. π£οΈIPV6_AUTHHDRβ delivers the authentication header. πIPV6_DSTOPTSβ delivers the destination options. π¬IPV6_HOPOPTSβ delivers the hop options. πIPV6_FLOWINFOβ delivers an integer containing the flow ID. πIPV6_HOPLIMITβ delivers an integer containing the hop count of the packet. π’
and the best part?? the control messages have the same type as the socket option. no mental gymnastics, no translation layer, just matching types fr fr.
Not me forgetting the reverse direction β because plot twist β all these header options can also be set for outgoing packets by putting the appropriate control message into the control buffer of sendmsg(2). So it works both ways, main character energy in each direction. π«Ά
β οΈ Allowed only forSOCK_DGRAMorSOCK_RAWsockets. Any other socket type? Not invited to the party, sorry bestie. π
π ERRORS π
- See
IPPROTO_IPV6(2const). - See
setsockopt(2). - See
ipv6(7).
(the lore lives in those pages, go read them π)
π SEE ALSO π
okay that's the whole page, you ate that. π this was Linux man-pages 6.20, dated 2025-12-02 β and that's a wrap, 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