IPV6_RTHDR(2const)

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

πŸ’– 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 for SOCK_DGRAM or SOCK_RAW sockets. Any other socket type? Not invited to the party, sorry bestie. 😭

πŸ™ˆ ERRORS πŸ™ˆ

(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