IP_OPTIONS(2const)
π IP_OPTIONS π
okay bestie, welcome to the IP_OPTIONS(2const) page β yes it's a <pink>2const</pink> situation (a constant-from-a-manpage-adjacent vibe), and we're talking about the options you staple onto every single packet this socket sends out. main character packet energy, no cap π
π LIBRARY
the standard C library, aka libc, aka the -lc you keep forgetting to think about π«Ά
β¨ SYNOPSIS β¨
#include <netinet/in.h> /* Definition of IP* constants */
#include <sys/socket.h>
int setsockopt(int sockfd, IPPROTO_IP, IP_OPTIONS,
const void buf[size], size_t size);
int getsockopt(int sockfd, IPPROTO_IP, IP_OPTIONS,
void buf[size], size_t size);
π¦ DESCRIPTION π¦
so like. set or get the IP options that get sent with every packet flying outta this socket. every single one. devoted. obsessed. π
the arguments are literally just a pointer to a memory buffer holding the options, plus the buffer length. that's it, that's the whole thing.
the setsockopt(2) call sets the IP options associated with a socket. and here's the tea β the maximum option size for IPv4 is 40 bytes. forty. that's the budget, bestie. as for which options are even allowed? go read RFC 791, it's giving homework but it's the real answer π
now for the β¨plot twistβ¨: when the initial connection request packet for a SOCK_STREAM socket contains IP options, the IP options get set automatically to the options from the initial packet β with routing headers reversed. yes, reversed. automatic. iconic behaviour honestly.
incoming packets are not allowed to change options after the connection is established. sorry not sorry, the connection said what it said π
the processing of all incoming source routing options is disabled by default and can be enabled by using the accept_source_route /proc interface. other options like timestamps are still handled though β those ones are fine, they're chill πΈ
for datagram sockets, IP options can be set only by the local user. local only. know your place π
and calling getsockopt(2) with IP_OPTIONS puts the current IP options used for sending into the supplied buffer. so you can peek at what you're actually shipping out. vibe check passed β
π ERRORS
see IPPROTO_IP(2const). see setsockopt(2). see ip(7). that's the whole list, go read those, they got you π«Ά
β HISTORY
Linux 2.0. ancient. elder. still serving. π
π SEE ALSO
and that's the page bestie!! this lil masterpiece lives in Linux man-pages 6.20, dated 2025-11-25 β so if you cite it, you know exactly where it came from. go forth and set your options, 40 bytes max, no cap πβ¨π¦
π¦ 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