Commit 7995697527

Brandon Black <bblack@wikimedia.org>
2025-09-09 23:47:32
std: add IP, IPV6, IPTOS sockopt constants
Because these lists are very long in several cases and quite varied, I opted to place them in the existing c/foo.zig files. There are many other sets of network-related constants like this to add over time across all the OSes. For now I picked these because I needed a few constants from each of these namespaces for my own project, so I tried to flesh out these namespaces completely as best I could, at least for basic sockopt purposes. Note windows has some of these already defined in ws2_32 as individual constants rather than contained in a namespacing struct. I'm not sure what to do with that in the long run (break it and namespace them?), but this doesn't change the status quo for windows in any case.
1 parent 0e45b9d
lib/std/c/darwin.zig
@@ -1724,3 +1724,165 @@ pub const MSG = struct {
     /// Inherit upcall in sock_accept
     pub const USEUPCALL = 0x80000000;
 };
+
+// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/netinet/in.h#L454
+pub const IP = struct {
+    pub const OPTIONS = 1;
+    pub const HDRINCL = 2;
+    pub const TOS = 3;
+    pub const TTL = 4;
+    pub const RECVOPTS = 5;
+    pub const RECVRETOPTS = 6;
+    pub const RECVDSTADDR = 7;
+    pub const RETOPTS = 8;
+    pub const MULTICAST_IF = 9;
+    pub const MULTICAST_TTL = 10;
+    pub const MULTICAST_LOOP = 11;
+    pub const ADD_MEMBERSHIP = 12;
+    pub const DROP_MEMBERSHIP = 13;
+    pub const MULTICAST_VIF = 14;
+    pub const RSVP_ON = 15;
+    pub const RSVP_OFF = 16;
+    pub const RSVP_VIF_ON = 17;
+    pub const RSVP_VIF_OFF = 18;
+    pub const PORTRANGE = 19;
+    pub const RECVIF = 20;
+    pub const IPSEC_POLICY = 21;
+    pub const FAITH = 22;
+    pub const STRIPHDR = 23;
+    pub const RECVTTL = 24;
+    pub const BOUND_IF = 25;
+    pub const PKTINFO = 26;
+    pub const RECVPKTINFO = PKTINFO;
+    pub const RECVTOS = 27;
+    pub const DONTFRAG = 28;
+    pub const FW_ADD = 40;
+    pub const FW_DEL = 41;
+    pub const FW_FLUSH = 42;
+    pub const FW_ZERO = 43;
+    pub const FW_GET = 44;
+    pub const FW_RESETLOG = 45;
+    pub const OLD_FW_ADD = 50;
+    pub const OLD_FW_DEL = 51;
+    pub const OLD_FW_FLUSH = 52;
+    pub const OLD_FW_ZERO = 53;
+    pub const OLD_FW_GET = 54;
+    pub const OLD_FW_RESETLOG = 56;
+    pub const DUMMYNET_CONFIGURE = 60;
+    pub const DUMMYNET_DEL = 61;
+    pub const DUMMYNET_FLUSH = 62;
+    pub const DUMMYNET_GET = 64;
+    pub const TRAFFIC_MGT_BACKGROUND = 65;
+    pub const MULTICAST_IFINDEX = 66;
+    pub const ADD_SOURCE_MEMBERSHIP = 70;
+    pub const DROP_SOURCE_MEMBERSHIP = 71;
+    pub const BLOCK_SOURCE = 72;
+    pub const UNBLOCK_SOURCE = 73;
+    pub const MSFILTER = 74;
+    // Same namespace, but these are arguments rather than option names
+    pub const DEFAULT_MULTICAST_TTL = 1;
+    pub const DEFAULT_MULTICAST_LOOP = 1;
+    pub const MIN_MEMBERSHIPS = 31;
+    pub const MAX_MEMBERSHIPS = 4095;
+    pub const MAX_GROUP_SRC_FILTER = 512;
+    pub const MAX_SOCK_SRC_FILTER = 128;
+    pub const MAX_SOCK_MUTE_FILTER = 128;
+    pub const PORTRANGE_DEFAULT = 0;
+    pub const PORTRANGE_HIGH = 1;
+    pub const PORTRANGE_LOW = 2;
+};
+
+// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/netinet6/in6.h#L521
+pub const IPV6 = struct {
+    pub const UNICAST_HOPS = 4;
+    pub const MULTICAST_IF = 9;
+    pub const MULTICAST_HOPS = 10;
+    pub const MULTICAST_LOOP = 11;
+    pub const JOIN_GROUP = 12;
+    pub const LEAVE_GROUP = 13;
+    pub const PORTRANGE = 14;
+    pub const @"2292PKTINFO" = 19;
+    pub const @"2292HOPLIMIT" = 20;
+    pub const @"2292NEXTHOP" = 21;
+    pub const @"2292HOPOPTS" = 22;
+    pub const @"2292DSTOPTS" = 23;
+    pub const @"2292RTHDR" = 24;
+    pub const @"2292PKTOPTIONS" = 25;
+    pub const CHECKSUM = 26;
+    pub const V6ONLY = 27;
+    pub const BINDV6ONLY = V6ONLY;
+    pub const IPSEC_POLICY = 28;
+    pub const FAITH = 29;
+    pub const FW_ADD = 30;
+    pub const FW_DEL = 31;
+    pub const FW_FLUSH = 32;
+    pub const FW_ZERO = 33;
+    pub const FW_GET = 34;
+    pub const RECVTCLASS = 35;
+    pub const TCLASS = 36;
+    pub const RTHDRDSTOPTS = 57;
+    pub const RECVPKTINFO = 61;
+    pub const RECVHOPLIMIT = 37;
+    pub const RECVRTHDR = 38;
+    pub const RECVHOPOPTS = 39;
+    pub const RECVDSTOPTS = 40;
+    pub const RECVRTHDRDSTOPTS = 41;
+    pub const USE_MIN_MTU = 42;
+    pub const RECVPATHMTU = 43;
+    pub const PATHMTU = 44;
+    pub const REACHCONF = 45;
+    pub const @"3542PKTINFO" = 46;
+    pub const @"3542HOPLIMIT" = 47;
+    pub const @"3542NEXTHOP" = 48;
+    pub const @"3542HOPOPTS" = 49;
+    pub const @"3542DSTOPTS" = 50;
+    pub const @"3542RTHDR" = 51;
+    pub const PKTINFO = @"3542PKTINFO";
+    pub const HOPLIMIT = @"3542HOPLIMIT";
+    pub const NEXTHOP = @"3542NEXTHOP";
+    pub const HOPOPTS = @"3542HOPOPTS";
+    pub const DSTOPTS = @"3542DSTOPTS";
+    pub const RTHDR = @"3542RTHDR";
+    pub const AUTOFLOWLABEL = 59;
+    pub const DONTFRAG = 62;
+    pub const PREFER_TEMPADDR = 63;
+    pub const MSFILTER = 74;
+    pub const BOUND_IF = 125;
+    // Same namespace, but these are arguments rather than option names
+    pub const RTHDR_LOOSE = 0;
+    pub const RTHDR_STRICT = 1;
+    pub const RTHDR_TYPE_0 = 0;
+    pub const DEFAULT_MULTICAST_HOPS = 1;
+    pub const DEFAULT_MULTICAST_LOOP = 1;
+    pub const MIN_MEMBERSHIPS = 31;
+    pub const MAX_MEMBERSHIPS = 4095;
+    pub const MAX_GROUP_SRC_FILTER = 512;
+    pub const MAX_SOCK_SRC_FILTER = 128;
+    pub const PORTRANGE_DEFAULT = 0;
+    pub const PORTRANGE_HIGH = 1;
+    pub const PORTRANGE_LOW = 2;
+};
+
+// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/netinet/ip.h#L129
+pub const IPTOS = struct {
+    pub const LOWDELAY = 0x10;
+    pub const THROUGHPUT = 0x08;
+    pub const RELIABILITY = 0x04;
+    pub const MINCOST = 0x02;
+    pub const CE = 0x01;
+    pub const ECT = 0x02;
+    pub const DSCP_SHIFT = 2;
+    pub const ECN_NOTECT = 0x00;
+    pub const ECN_ECT1 = 0x01;
+    pub const ECN_ECT0 = 0x02;
+    pub const ECN_CE = 0x03;
+    pub const ECN_MASK = 0x03;
+    pub const PREC_NETCONTROL = 0xe0;
+    pub const PREC_INTERNETCONTROL = 0xc0;
+    pub const PREC_CRITIC_ECP = 0xa0;
+    pub const PREC_FLASHOVERRIDE = 0x80;
+    pub const PREC_FLASH = 0x60;
+    pub const PREC_IMMEDIATE = 0x40;
+    pub const PREC_PRIORITY = 0x20;
+    pub const PREC_ROUTINE = 0x00;
+};
lib/std/c/dragonfly.zig
@@ -182,3 +182,161 @@ pub const POSIX_MADV_RANDOM = 1;
 pub const POSIX_MADV_DONTNEED = 4;
 pub const POSIX_MADV_NORMAL = 0;
 pub const POSIX_MADV_WILLNEED = 3;
+
+// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/netinet/ip.h#L94
+pub const IP = struct {
+    pub const OPTIONS = 1;
+    pub const HDRINCL = 2;
+    pub const TOS = 3;
+    pub const TTL = 4;
+    pub const RECVOPTS = 5;
+    pub const RECVRETOPTS = 6;
+    pub const RECVDSTADDR = 7;
+    pub const SENDSRCADDR = RECVDSTADDR;
+    pub const RETOPTS = 8;
+    pub const MULTICAST_IF = 9;
+    pub const MULTICAST_TTL = 10;
+    pub const MULTICAST_LOOP = 11;
+    pub const ADD_MEMBERSHIP = 12;
+    pub const DROP_MEMBERSHIP = 13;
+    pub const MULTICAST_VIF = 14;
+    pub const RSVP_ON = 15;
+    pub const RSVP_OFF = 16;
+    pub const RSVP_VIF_ON = 17;
+    pub const RSVP_VIF_OFF = 18;
+    pub const PORTRANGE = 19;
+    pub const RECVIF = 20;
+    pub const FW_TBL_CREATE = 40;
+    pub const FW_TBL_DESTROY = 41;
+    pub const FW_TBL_ADD = 42;
+    pub const FW_TBL_DEL = 43;
+    pub const FW_TBL_FLUSH = 44;
+    pub const FW_TBL_GET = 45;
+    pub const FW_TBL_ZERO = 46;
+    pub const FW_TBL_EXPIRE = 47;
+    pub const FW_X = 49;
+    pub const FW_ADD = 50;
+    pub const FW_DEL = 51;
+    pub const FW_FLUSH = 52;
+    pub const FW_ZERO = 53;
+    pub const FW_GET = 54;
+    pub const FW_RESETLOG = 55;
+    pub const DUMMYNET_CONFIGURE = 60;
+    pub const DUMMYNET_DEL = 61;
+    pub const DUMMYNET_FLUSH = 62;
+    pub const DUMMYNET_GET = 64;
+    pub const RECVTTL = 65;
+    pub const MINTTL = 66;
+    pub const RECVTOS = 68;
+    // Same namespace, but these are arguments rather than option names
+    pub const DEFAULT_MULTICAST_TTL = 1;
+    pub const DEFAULT_MULTICAST_LOOP = 1;
+    pub const MAX_MEMBERSHIPS = 20;
+    pub const PORTRANGE_DEFAULT = 0;
+    pub const PORTRANGE_HIGH = 1;
+    pub const PORTRANGE_LOW = 2;
+};
+
+// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/netinet6/in6.h#L448
+pub const IPV6 = struct {
+    pub const UNICAST_HOPS = 4;
+    pub const MULTICAST_IF = 9;
+    pub const MULTICAST_HOPS = 10;
+    pub const MULTICAST_LOOP = 11;
+    pub const JOIN_GROUP = 12;
+    pub const LEAVE_GROUP = 13;
+    pub const PORTRANGE = 14;
+    pub const @"2292PKTINFO" = 19;
+    pub const @"2292HOPLIMIT" = 20;
+    pub const @"2292NEXTHOP" = 21;
+    pub const @"2292HOPOPTS" = 22;
+    pub const @"2292DSTOPTS" = 23;
+    pub const @"2292RTHDR" = 24;
+    pub const @"2292PKTOPTIONS" = 25;
+    pub const CHECKSUM = 26;
+    pub const V6ONLY = 27;
+    pub const BINDV6ONLY = V6ONLY;
+    pub const FW_ADD = 30;
+    pub const FW_DEL = 31;
+    pub const FW_FLUSH = 32;
+    pub const FW_ZERO = 33;
+    pub const FW_GET = 34;
+    pub const RTHDRDSTOPTS = 35;
+    pub const RECVPKTINFO = 36;
+    pub const RECVHOPLIMIT = 37;
+    pub const RECVRTHDR = 38;
+    pub const RECVHOPOPTS = 39;
+    pub const RECVDSTOPTS = 40;
+    pub const RECVRTHDRDSTOPTS = 41;
+    pub const USE_MIN_MTU = 42;
+    pub const RECVPATHMTU = 43;
+    pub const PATHMTU = 44;
+    pub const REACHCONF = 45;
+    pub const PKTINFO = 46;
+    pub const HOPLIMIT = 47;
+    pub const NEXTHOP = 48;
+    pub const HOPOPTS = 49;
+    pub const DSTOPTS = 50;
+    pub const RTHDR = 51;
+    pub const PKTOPTIONS = 52;
+    pub const RECVTCLASS = 57;
+    pub const AUTOFLOWLABEL = 59;
+    pub const TCLASS = 61;
+    pub const DONTFRAG = 62;
+    pub const PREFER_TEMPADDR = 63;
+    pub const MSFILTER = 74;
+    // Same namespace, but these are arguments rather than option names
+    pub const RTHDR_LOOSE = 0;
+    pub const RTHDR_STRICT = 1;
+    pub const RTHDR_TYPE_0 = 0;
+    pub const DEFAULT_MULTICAST_HOPS = 1;
+    pub const DEFAULT_MULTICAST_LOOP = 1;
+    pub const PORTRANGE_DEFAULT = 0;
+    pub const PORTRANGE_HIGH = 1;
+    pub const PORTRANGE_LOW = 2;
+};
+
+// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/netinet/ip.h#L94
+pub const IPTOS = struct {
+    pub const LOWDELAY = 0x10;
+    pub const THROUGHPUT = 0x08;
+    pub const RELIABILITY = 0x04;
+    pub const MINCOST = 0x02;
+    pub const CE = 0x01;
+    pub const ECT = 0x02;
+    pub const PREC_ROUTINE = DSCP_CS0;
+    pub const PREC_PRIORITY = DSCP_CS1;
+    pub const PREC_IMMEDIATE = DSCP_CS2;
+    pub const PREC_FLASH = DSCP_CS3;
+    pub const PREC_FLASHOVERRIDE = DSCP_CS4;
+    pub const PREC_CRITIC_ECP = DSCP_CS5;
+    pub const PREC_INTERNETCONTROL = DSCP_CS6;
+    pub const PREC_NETCONTROL = DSCP_CS7;
+    pub const DSCP_CS0 = 0x00;
+    pub const DSCP_CS1 = 0x20;
+    pub const DSCP_AF11 = 0x28;
+    pub const DSCP_AF12 = 0x30;
+    pub const DSCP_AF13 = 0x38;
+    pub const DSCP_CS2 = 0x40;
+    pub const DSCP_AF21 = 0x48;
+    pub const DSCP_AF22 = 0x50;
+    pub const DSCP_AF23 = 0x58;
+    pub const DSCP_CS3 = 0x60;
+    pub const DSCP_AF31 = 0x68;
+    pub const DSCP_AF32 = 0x70;
+    pub const DSCP_AF33 = 0x78;
+    pub const DSCP_CS4 = 0x80;
+    pub const DSCP_AF41 = 0x88;
+    pub const DSCP_AF42 = 0x90;
+    pub const DSCP_AF43 = 0x98;
+    pub const DSCP_CS5 = 0xa0;
+    pub const DSCP_VA = 0xb0;
+    pub const DSCP_EF = 0xb8;
+    pub const DSCP_CS6 = 0xc0;
+    pub const DSCP_CS7 = 0xe0;
+    pub const ECN_NOTECT = 0x00;
+    pub const ECN_ECT1 = 0x01;
+    pub const ECN_ECT0 = 0x02;
+    pub const ECN_CE = 0x03;
+    pub const ECN_MASK = 0x03;
+};
lib/std/c/freebsd.zig
@@ -391,3 +391,195 @@ pub const E = enum(u16) {
     INTEGRITY = 97, // Integrity check failed
     _,
 };
+
+// https://github.com/freebsd/freebsd-src/blob/9bfbc6826f72eb385bf52f4cde8080bccf7e3ebd/sys/netinet/in.h#L436
+pub const IP = struct {
+    pub const OPTIONS = 1;
+    pub const HDRINCL = 2;
+    pub const TOS = 3;
+    pub const TTL = 4;
+    pub const RECVOPTS = 5;
+    pub const RECVRETOPTS = 6;
+    pub const RECVDSTADDR = 7;
+    pub const SENDSRCADDR = RECVDSTADDR;
+    pub const RETOPTS = 8;
+    pub const MULTICAST_IF = 9;
+    pub const MULTICAST_TTL = 10;
+    pub const MULTICAST_LOOP = 11;
+    pub const ADD_MEMBERSHIP = 12;
+    pub const DROP_MEMBERSHIP = 13;
+    pub const MULTICAST_VIF = 14;
+    pub const RSVP_ON = 15;
+    pub const RSVP_OFF = 16;
+    pub const RSVP_VIF_ON = 17;
+    pub const RSVP_VIF_OFF = 18;
+    pub const PORTRANGE = 19;
+    pub const RECVIF = 20;
+    pub const IPSEC_POLICY = 21;
+    pub const ONESBCAST = 23;
+    pub const BINDANY = 24;
+    pub const ORIGDSTADDR = 27;
+    pub const RECVORIGDSTADDR = ORIGDSTADDR;
+    pub const FW_TABLE_ADD = 40;
+    pub const FW_TABLE_DEL = 41;
+    pub const FW_TABLE_FLUSH = 42;
+    pub const FW_TABLE_GETSIZE = 43;
+    pub const FW_TABLE_LIST = 44;
+    pub const FW3 = 48;
+    pub const DUMMYNET3 = 49;
+    pub const FW_ADD = 50;
+    pub const FW_DEL = 51;
+    pub const FW_FLUSH = 52;
+    pub const FW_ZERO = 53;
+    pub const FW_GET = 54;
+    pub const FW_RESETLOG = 55;
+    pub const FW_NAT_CFG = 56;
+    pub const FW_NAT_DEL = 57;
+    pub const FW_NAT_GET_CONFIG = 58;
+    pub const FW_NAT_GET_LOG = 59;
+    pub const DUMMYNET_CONFIGURE = 60;
+    pub const DUMMYNET_DEL = 61;
+    pub const DUMMYNET_FLUSH = 62;
+    pub const DUMMYNET_GET = 64;
+    pub const RECVTTL = 65;
+    pub const MINTTL = 66;
+    pub const DONTFRAG = 67;
+    pub const RECVTOS = 68;
+    pub const ADD_SOURCE_MEMBERSHIP = 70;
+    pub const DROP_SOURCE_MEMBERSHIP = 71;
+    pub const BLOCK_SOURCE = 72;
+    pub const UNBLOCK_SOURCE = 73;
+    pub const MSFILTER = 74;
+    pub const VLAN_PCP = 75;
+    pub const FLOWID = 90;
+    pub const FLOWTYPE = 91;
+    pub const RSSBUCKETID = 92;
+    pub const RECVFLOWID = 93;
+    pub const RECVRSSBUCKETID = 94;
+    // Same namespace, but these are arguments rather than option names
+    pub const DEFAULT_MULTICAST_TTL = 1;
+    pub const DEFAULT_MULTICAST_LOOP = 1;
+    pub const MAX_MEMBERSHIPS = 4095;
+    pub const MAX_GROUP_SRC_FILTER = 512;
+    pub const MAX_SOCK_SRC_FILTER = 128;
+    pub const MAX_SOCK_MUTE_FILTER = 128;
+    pub const PORTRANGE_DEFAULT = 0;
+    pub const PORTRANGE_HIGH = 1;
+    pub const PORTRANGE_LOW = 2;
+};
+
+// https://github.com/freebsd/freebsd-src/blob/9bfbc6826f72eb385bf52f4cde8080bccf7e3ebd/sys/netinet6/in6.h#L402
+pub const IPV6 = struct {
+    pub const UNICAST_HOPS = 4;
+    pub const MULTICAST_IF = 9;
+    pub const MULTICAST_HOPS = 10;
+    pub const MULTICAST_LOOP = 11;
+    pub const JOIN_GROUP = 12;
+    pub const LEAVE_GROUP = 13;
+    pub const PORTRANGE = 14;
+    pub const @"2292PKTINFO" = 19;
+    pub const @"2292HOPLIMIT" = 20;
+    pub const @"2292NEXTHOP" = 21;
+    pub const @"2292HOPOPTS" = 22;
+    pub const @"2292DSTOPTS" = 23;
+    pub const @"2292RTHDR" = 24;
+    pub const @"2292PKTOPTIONS" = 25;
+    pub const CHECKSUM = 26;
+    pub const V6ONLY = 27;
+    pub const BINDV6ONLY = V6ONLY;
+    pub const IPSEC_POLICY = 28;
+    pub const FW_ADD = 30;
+    pub const FW_DEL = 31;
+    pub const FW_FLUSH = 32;
+    pub const FW_ZERO = 33;
+    pub const FW_GET = 34;
+    pub const RTHDRDSTOPTS = 35;
+    pub const RECVPKTINFO = 36;
+    pub const RECVHOPLIMIT = 37;
+    pub const RECVRTHDR = 38;
+    pub const RECVHOPOPTS = 39;
+    pub const RECVDSTOPTS = 40;
+    pub const RECVRTHDRDSTOPTS = 41;
+    pub const USE_MIN_MTU = 42;
+    pub const RECVPATHMTU = 43;
+    pub const PATHMTU = 44;
+    pub const REACHCONF = 45;
+    pub const PKTINFO = 46;
+    pub const HOPLIMIT = 47;
+    pub const NEXTHOP = 48;
+    pub const HOPOPTS = 49;
+    pub const DSTOPTS = 50;
+    pub const RTHDR = 51;
+    pub const PKTOPTIONS = 52;
+    pub const RECVTCLASS = 57;
+    pub const AUTOFLOWLABEL = 59;
+    pub const TCLASS = 61;
+    pub const DONTFRAG = 62;
+    pub const PREFER_TEMPADDR = 63;
+    pub const BINDANY = 64;
+    pub const FLOWID = 67;
+    pub const FLOWTYPE = 68;
+    pub const RSSBUCKETID = 69;
+    pub const RECVFLOWID = 70;
+    pub const RECVRSSBUCKETID = 71;
+    pub const ORIGDSTADDR = 72;
+    pub const RECVORIGDSTADDR = ORIGDSTADDR;
+    pub const MSFILTER = 74;
+    pub const VLAN_PCP = 75;
+    // Same namespace, but these are arguments rather than option names
+    pub const RTHDR_LOOSE = 0;
+    pub const RTHDR_STRICT = 1;
+    pub const RTHDR_TYPE_0 = 0;
+    pub const DEFAULT_MULTICAST_HOPS = 1;
+    pub const DEFAULT_MULTICAST_LOOP = 1;
+    pub const MAX_MEMBERSHIPS = 4095;
+    pub const MAX_GROUP_SRC_FILTER = 512;
+    pub const MAX_SOCK_SRC_FILTER = 128;
+    pub const PORTRANGE_DEFAULT = 0;
+    pub const PORTRANGE_HIGH = 1;
+    pub const PORTRANGE_LOW = 2;
+};
+
+// https://github.com/freebsd/freebsd-src/blob/9bfbc6826f72eb385bf52f4cde8080bccf7e3ebd/sys/netinet/ip.h#L77
+pub const IPTOS = struct {
+    pub const LOWDELAY = 0x10;
+    pub const THROUGHPUT = 0x08;
+    pub const RELIABILITY = 0x04;
+    pub const MINCOST = DSCP_CS0;
+    pub const PREC_ROUTINE = DSCP_CS0;
+    pub const PREC_PRIORITY = DSCP_CS1;
+    pub const PREC_IMMEDIATE = DSCP_CS2;
+    pub const PREC_FLASH = DSCP_CS3;
+    pub const PREC_FLASHOVERRIDE = DSCP_CS4;
+    pub const PREC_CRITIC_ECP = DSCP_CS5;
+    pub const PREC_INTERNETCONTROL = DSCP_CS6;
+    pub const PREC_NETCONTROL = DSCP_CS7;
+    pub const DSCP_OFFSET = 2;
+    pub const DSCP_CS0 = 0x00;
+    pub const DSCP_CS1 = 0x20;
+    pub const DSCP_AF11 = 0x28;
+    pub const DSCP_AF12 = 0x30;
+    pub const DSCP_AF13 = 0x38;
+    pub const DSCP_CS2 = 0x40;
+    pub const DSCP_AF21 = 0x48;
+    pub const DSCP_AF22 = 0x50;
+    pub const DSCP_AF23 = 0x58;
+    pub const DSCP_CS3 = 0x60;
+    pub const DSCP_AF31 = 0x68;
+    pub const DSCP_AF32 = 0x70;
+    pub const DSCP_AF33 = 0x78;
+    pub const DSCP_CS4 = 0x80;
+    pub const DSCP_AF41 = 0x88;
+    pub const DSCP_AF42 = 0x90;
+    pub const DSCP_AF43 = 0x98;
+    pub const DSCP_CS5 = 0xa0;
+    pub const DSCP_VA = 0xb0;
+    pub const DSCP_EF = 0xb8;
+    pub const DSCP_CS6 = 0xc0;
+    pub const DSCP_CS7 = 0xe0;
+    pub const ECN_NOTECT = 0x00;
+    pub const ECN_ECT1 = 0x01;
+    pub const ECN_ECT0 = 0x02;
+    pub const ECN_CE = 0x03;
+    pub const ECN_MASK = 0x03;
+};
lib/std/c/haiku.zig
@@ -553,3 +553,50 @@ pub const DirEnt = extern struct {
         return @ptrCast(&dirent.name);
     }
 };
+
+// https://github.com/haiku/haiku/blob/2aab5f5f14aeb3f34c3a3d9a9064cc3c0d914bea/headers/posix/netinet/in.h#L122
+pub const IP = struct {
+    pub const OPTIONS = 1;
+    pub const HDRINCL = 2;
+    pub const TOS = 3;
+    pub const TTL = 4;
+    pub const RECVOPTS = 5;
+    pub const RECVRETOPTS = 6;
+    pub const RECVDSTADDR = 7;
+    pub const RETOPTS = 8;
+    pub const MULTICAST_IF = 9;
+    pub const MULTICAST_TTL = 10;
+    pub const MULTICAST_LOOP = 11;
+    pub const ADD_MEMBERSHIP = 12;
+    pub const DROP_MEMBERSHIP = 13;
+    pub const BLOCK_SOURCE = 14;
+    pub const UNBLOCK_SOURCE = 15;
+    pub const ADD_SOURCE_MEMBERSHIP = 16;
+    pub const DROP_SOURCE_MEMBERSHIP = 17;
+    pub const DONTFRAG = 38;
+};
+
+// https://github.com/haiku/haiku/blob/2aab5f5f14aeb3f34c3a3d9a9064cc3c0d914bea/headers/posix/netinet/in.h#L150
+pub const IPV6 = struct {
+    pub const MULTICAST_IF = 24;
+    pub const MULTICAST_HOPS = 25;
+    pub const MULTICAST_LOOP = 26;
+    pub const UNICAST_HOPS = 27;
+    pub const JOIN_GROUP = 28;
+    pub const LEAVE_GROUP = 29;
+    pub const V6ONLY = 30;
+    pub const PKTINFO = 31;
+    pub const RECVPKTINFO = 32;
+    pub const HOPLIMIT = 33;
+    pub const RECVHOPLIMIT = 34;
+    pub const HOPOPTS = 35;
+    pub const DSTOPTS = 36;
+    pub const RTHDR = 37;
+};
+
+// https://github.com/haiku/haiku/blob/2aab5f5f14aeb3f34c3a3d9a9064cc3c0d914bea/headers/posix/netinet/ip.h#L36
+pub const IPTOS = struct {
+    pub const RELIABILITY = 0x04;
+    pub const THROUGHPUT = 0x08;
+    pub const LOWDELAY = 0x10;
+};
lib/std/c/netbsd.zig
@@ -201,3 +201,155 @@ pub const E = enum(u16) {
 
     _,
 };
+
+// https://github.com/NetBSD/src/blob/80bf25a5691072d4755e84567ccbdf0729370dea/sys/netinet/in.h#L276
+pub const IP = struct {
+    pub const OPTIONS = 1;
+    pub const HDRINCL = 2;
+    pub const TOS = 3;
+    pub const TTL = 4;
+    pub const RECVOPTS = 5;
+    pub const RECVRETOPTS = 6;
+    pub const RECVDSTADDR = 7;
+    pub const RETOPTS = 8;
+    pub const MULTICAST_IF = 9;
+    pub const MULTICAST_TTL = 10;
+    pub const MULTICAST_LOOP = 11;
+    pub const ADD_MEMBERSHIP = 12;
+    pub const DROP_MEMBERSHIP = 13;
+    pub const PORTALGO = 18;
+    pub const PORTRANGE = 19;
+    pub const RECVIF = 20;
+    pub const ERRORMTU = 21;
+    pub const IPSEC_POLICY = 22;
+    pub const RECVTTL = 23;
+    pub const MINTTL = 24;
+    pub const PKTINFO = 25;
+    pub const RECVPKTINFO = 26;
+    pub const BINDANY = 27;
+    pub const SENDSRCADDR = RECVDSTADDR;
+    pub const DEFAULT_MULTICAST_TTL = 1;
+    pub const DEFAULT_MULTICAST_LOOP = 1;
+    pub const MAX_MEMBERSHIPS = 20;
+    pub const PORTRANGE_DEFAULT = 0;
+    pub const PORTRANGE_HIGH = 1;
+    pub const PORTRANGE_LOW = 2;
+};
+
+// https://github.com/NetBSD/src/blob/80bf25a5691072d4755e84567ccbdf0729370dea/sys/netinet6/in6.h#L370
+pub const IPV6 = struct {
+    pub const UNICAST_HOPS = 4;
+    pub const MULTICAST_IF = 9;
+    pub const MULTICAST_HOPS = 10;
+    pub const MULTICAST_LOOP = 11;
+    pub const JOIN_GROUP = 12;
+    pub const LEAVE_GROUP = 13;
+    pub const PORTRANGE = 14;
+    pub const PORTALGO = 17;
+    pub const @"2292PKTINFO" = 19;
+    pub const @"2292HOPLIMIT" = 20;
+    pub const @"2292NEXTHOP" = 21;
+    pub const @"2292HOPOPTS" = 22;
+    pub const @"2292DSTOPTS" = 23;
+    pub const @"2292RTHDR" = 24;
+    pub const @"2292PKTOPTIONS" = 25;
+    pub const CHECKSUM = 26;
+    pub const V6ONLY = 27;
+    pub const IPSEC_POLICY = 28;
+    pub const FAITH = 29;
+    pub const RTHDRDSTOPTS = 35;
+    pub const RECVPKTINFO = 36;
+    pub const RECVHOPLIMIT = 37;
+    pub const RECVRTHDR = 38;
+    pub const RECVHOPOPTS = 39;
+    pub const RECVDSTOPTS = 40;
+    pub const RECVRTHDRDSTOPTS = 41;
+    pub const USE_MIN_MTU = 42;
+    pub const RECVPATHMTU = 43;
+    pub const PATHMTU = 44;
+    pub const PKTINFO = 46;
+    pub const HOPLIMIT = 47;
+    pub const NEXTHOP = 48;
+    pub const HOPOPTS = 49;
+    pub const DSTOPTS = 50;
+    pub const RTHDR = 51;
+    pub const RECVTCLASS = 57;
+    pub const OTCLASS = 58;
+    pub const TCLASS = 61;
+    pub const DONTFRAG = 62;
+    pub const PREFER_TEMPADDR = 63;
+    pub const BINDANY = 64;
+    pub const RTHDR_LOOSE = 0;
+    pub const RTHDR_STRICT = 1;
+    pub const RTHDR_TYPE_0 = 0;
+    pub const DEFAULT_MULTICAST_HOPS = 1;
+    pub const DEFAULT_MULTICAST_LOOP = 1;
+    pub const PORTRANGE_DEFAULT = 0;
+    pub const PORTRANGE_HIGH = 1;
+    pub const PORTRANGE_LOW = 2;
+};
+
+// https://github.com/NetBSD/src/blob/80bf25a5691072d4755e84567ccbdf0729370dea/sys/netinet/ip.h#L140
+pub const IPTOS = struct {
+    pub const DSCP_CS0 = 0x00;
+    pub const DSCP_CS1 = 0x20;
+    pub const DSCP_AF11 = 0x28;
+    pub const DSCP_AF12 = 0x30;
+    pub const DSCP_AF13 = 0x38;
+    pub const DSCP_CS2 = 0x40;
+    pub const DSCP_AF21 = 0x48;
+    pub const DSCP_AF22 = 0x50;
+    pub const DSCP_AF23 = 0x58;
+    pub const DSCP_CS3 = 0x60;
+    pub const DSCP_AF31 = 0x68;
+    pub const DSCP_AF32 = 0x70;
+    pub const DSCP_AF33 = 0x78;
+    pub const DSCP_CS4 = 0x80;
+    pub const DSCP_AF41 = 0x88;
+    pub const DSCP_AF42 = 0x90;
+    pub const DSCP_AF43 = 0x98;
+    pub const DSCP_CS5 = 0xa0;
+    pub const DSCP_EF = 0xb8;
+    pub const DSCP_CS6 = 0xc0;
+    pub const DSCP_CS7 = 0xe0;
+    pub const CLASS_CS0 = 0x00;
+    pub const CLASS_CS1 = 0x20;
+    pub const CLASS_CS2 = 0x40;
+    pub const CLASS_CS3 = 0x60;
+    pub const CLASS_CS4 = 0x80;
+    pub const CLASS_CS5 = 0xa0;
+    pub const CLASS_CS6 = 0xc0;
+    pub const CLASS_CS7 = 0xe0;
+    pub const CLASS_DEFAULT = CLASS_CS0;
+    pub const CLASS_MASK = 0xe0;
+    pub fn CLASS(t: anytype) @TypeOf(t) {
+        return t & CLASS_MASK;
+    }
+    pub const DSCP_MASK = 0xfc;
+    pub fn DSCP(t: anytype) @TypeOf(t) {
+        return t & DSCP_MASK;
+    }
+    pub const ECN_NOTECT = 0x00;
+    pub const ECN_ECT1 = 0x01;
+    pub const ECN_ECT0 = 0x02;
+    pub const ECN_CE = 0x03;
+    pub const ECN_MASK = 0x03;
+    pub fn ECN(t: anytype) @TypeOf(t) {
+        return t & ECN_MASK;
+    }
+    pub const ECN_NOT_ECT = 0x00;
+    pub const LOWDELAY = 0x10;
+    pub const THROUGHPUT = 0x08;
+    pub const RELIABILITY = 0x04;
+    pub const MINCOST = 0x02;
+    pub const CE = 0x01;
+    pub const ECT = 0x02;
+    pub const PREC_NETCONTROL = 0xe0;
+    pub const PREC_INTERNETCONTROL = 0xc0;
+    pub const PREC_CRITIC_ECP = 0xa0;
+    pub const PREC_FLASHOVERRIDE = 0x80;
+    pub const PREC_FLASH = 0x60;
+    pub const PREC_IMMEDIATE = 0x40;
+    pub const PREC_PRIORITY = 0x20;
+    pub const PREC_ROUTINE = 0x00;
+};
lib/std/c/openbsd.zig
@@ -351,3 +351,139 @@ pub const PTHREAD_STACK_MIN = switch (builtin.cpu.arch) {
     .mips64 => 1 << 14,
     else => 1 << 12,
 };
+
+// https://github.com/openbsd/src/blob/718a31b40d39fc6064de6355eb144e74633133fc/sys/netinet/in.h#L283
+pub const IP = struct {
+    pub const OPTIONS = 1;
+    pub const HDRINCL = 2;
+    pub const TOS = 3;
+    pub const TTL = 4;
+    pub const RECVOPTS = 5;
+    pub const RECVRETOPTS = 6;
+    pub const RECVDSTADDR = 7;
+    pub const RETOPTS = 8;
+    pub const MULTICAST_IF = 9;
+    pub const MULTICAST_TTL = 10;
+    pub const MULTICAST_LOOP = 11;
+    pub const ADD_MEMBERSHIP = 12;
+    pub const DROP_MEMBERSHIP = 13;
+    pub const PORTRANGE = 19;
+    pub const AUTH_LEVEL = 20;
+    pub const ESP_TRANS_LEVEL = 21;
+    pub const ESP_NETWORK_LEVEL = 22;
+    pub const IPSEC_LOCAL_ID = 23;
+    pub const IPSEC_REMOTE_ID = 24;
+    pub const IPSEC_LOCAL_CRED = 25;
+    pub const IPSEC_REMOTE_CRED = 26;
+    pub const IPSEC_LOCAL_AUTH = 27;
+    pub const IPSEC_REMOTE_AUTH = 28;
+    pub const IPCOMP_LEVEL = 29;
+    pub const RECVIF = 30;
+    pub const RECVTTL = 31;
+    pub const MINTTL = 32;
+    pub const RECVDSTPORT = 33;
+    pub const PIPEX = 34;
+    pub const RECVRTABLE = 35;
+    pub const IPSECFLOWINFO = 36;
+    pub const IPDEFTTL = 37;
+    pub const SENDSRCADDR = RECVDSTADDR;
+    pub const RTABLE = 0x1021;
+    pub const DEFAULT_MULTICAST_TTL = 1;
+    pub const DEFAULT_MULTICAST_LOOP = 1;
+    pub const MIN_MEMBERSHIPS = 15;
+    pub const MAX_MEMBERSHIPS = 4095;
+    pub const PORTRANGE_DEFAULT = 0;
+    pub const PORTRANGE_HIGH = 1;
+    pub const PORTRANGE_LOW = 2;
+};
+
+// https://github.com/openbsd/src/blob/718a31b40d39fc6064de6355eb144e74633133fc/sys/netinet6/in6.h#L284
+pub const IPV6 = struct {
+    pub const UNICAST_HOPS = 4;
+    pub const MULTICAST_IF = 9;
+    pub const MULTICAST_HOPS = 10;
+    pub const MULTICAST_LOOP = 11;
+    pub const JOIN_GROUP = 12;
+    pub const LEAVE_GROUP = 13;
+    pub const PORTRANGE = 14;
+    pub const CHECKSUM = 26;
+    pub const V6ONLY = 27;
+    pub const RTHDRDSTOPTS = 35;
+    pub const RECVPKTINFO = 36;
+    pub const RECVHOPLIMIT = 37;
+    pub const RECVRTHDR = 38;
+    pub const RECVHOPOPTS = 39;
+    pub const RECVDSTOPTS = 40;
+    pub const USE_MIN_MTU = 42;
+    pub const RECVPATHMTU = 43;
+    pub const PATHMTU = 44;
+    pub const PKTINFO = 46;
+    pub const HOPLIMIT = 47;
+    pub const NEXTHOP = 48;
+    pub const HOPOPTS = 49;
+    pub const DSTOPTS = 50;
+    pub const RTHDR = 51;
+    pub const AUTH_LEVEL = 53;
+    pub const ESP_TRANS_LEVEL = 54;
+    pub const ESP_NETWORK_LEVEL = 55;
+    pub const RECVTCLASS = 57;
+    pub const AUTOFLOWLABEL = 59;
+    pub const IPCOMP_LEVEL = 60;
+    pub const TCLASS = 61;
+    pub const DONTFRAG = 62;
+    pub const PIPEX = 63;
+    pub const RECVDSTPORT = 64;
+    pub const MINHOPCOUNT = 65;
+    pub const RTABLE = 0x1021;
+    pub const RTHDR_LOOSE = 0;
+    pub const RTHDR_TYPE_0 = 0;
+    pub const DEFAULT_MULTICAST_HOPS = 1;
+    pub const DEFAULT_MULTICAST_LOOP = 1;
+    pub const PORTRANGE_DEFAULT = 0;
+    pub const PORTRANGE_HIGH = 1;
+    pub const PORTRANGE_LOW = 2;
+};
+
+// https://github.com/openbsd/src/blob/718a31b40d39fc6064de6355eb144e74633133fc/sys/netinet/ip.h#L73
+pub const IPTOS = struct {
+    pub const LOWDELAY = 0x10;
+    pub const THROUGHPUT = 0x08;
+    pub const RELIABILITY = 0x04;
+    pub const CE = 0x01;
+    pub const ECT = 0x02;
+    pub const PREC_NETCONTROL = 0xe0;
+    pub const PREC_INTERNETCONTROL = 0xc0;
+    pub const PREC_CRITIC_ECP = 0xa0;
+    pub const PREC_FLASHOVERRIDE = 0x80;
+    pub const PREC_FLASH = 0x60;
+    pub const PREC_IMMEDIATE = 0x40;
+    pub const PREC_PRIORITY = 0x20;
+    pub const PREC_ROUTINE = 0x00;
+    pub const DSCP_CS0 = 0x00;
+    pub const DSCP_LE = 0x04;
+    pub const DSCP_CS1 = 0x20;
+    pub const DSCP_AF11 = 0x28;
+    pub const DSCP_AF12 = 0x30;
+    pub const DSCP_AF13 = 0x38;
+    pub const DSCP_CS2 = 0x40;
+    pub const DSCP_AF21 = 0x48;
+    pub const DSCP_AF22 = 0x50;
+    pub const DSCP_AF23 = 0x58;
+    pub const DSCP_CS3 = 0x60;
+    pub const DSCP_AF31 = 0x68;
+    pub const DSCP_AF32 = 0x70;
+    pub const DSCP_AF33 = 0x78;
+    pub const DSCP_CS4 = 0x80;
+    pub const DSCP_AF41 = 0x88;
+    pub const DSCP_AF42 = 0x90;
+    pub const DSCP_AF43 = 0x98;
+    pub const DSCP_CS5 = 0xa0;
+    pub const DSCP_EF = 0xb8;
+    pub const DSCP_CS6 = 0xc0;
+    pub const DSCP_CS7 = 0xe0;
+    pub const ECN_NOTECT = 0x00;
+    pub const ECN_ECT1 = 0x01;
+    pub const ECN_ECT0 = 0x02;
+    pub const ECN_CE = 0x03;
+    pub const ECN_MASK = 0x03;
+};
lib/std/c/serenity.zig
@@ -71,3 +71,43 @@ pub extern "c" fn serenity_open(path: [*]const u8, path_length: usize, options:
 
 pub extern "c" fn getkeymap(name_buffer: [*]u8, name_buffer_size: usize, map: [*]u32, shift_map: [*]u32, alt_map: [*]u32, altgr_map: [*]u32, shift_altgr_map: [*]u32) c_int;
 pub extern "c" fn setkeymap(name: [*]const u8, map: [*]const u32, shift_map: [*]const u32, alt_map: [*]const u32, altgr_map: [*]const u32, shift_altgr_map: [*]const u32) c_int;
+
+// https://github.com/SerenityOS/serenity/blob/5bd8af99be0bc4b2e14f361fd7d7590e6bcfa4d6/Kernel/API/POSIX/netinet/in.h#L29
+pub const IP = struct {
+    pub const TOS = 1;
+    pub const TTL = 2;
+    pub const MULTICAST_LOOP = 3;
+    pub const ADD_MEMBERSHIP = 4;
+    pub const DROP_MEMBERSHIP = 5;
+    pub const MULTICAST_IF = 6;
+    pub const MULTICAST_TTL = 7;
+    pub const BLOCK_SOURCE = 8;
+    pub const ADD_SOURCE_MEMBERSHIP = 7;
+    pub const DROP_SOURCE_MEMBERSHIP = 8;
+    pub const UNBLOCK_SOURCE = 9;
+    pub const OPTIONS = 10;
+};
+
+//  https://github.com/SerenityOS/serenity/blob/5bd8af99be0bc4b2e14f361fd7d7590e6bcfa4d6/Kernel/API/POSIX/netinet/in.h#L81
+pub const IPV6 = struct {
+    pub const UNICAST_HOPS = 1;
+    pub const MULTICAST_HOPS = 2;
+    pub const MULTICAST_LOOP = 3;
+    pub const MULTICAST_IF = 4;
+    pub const ADD_MEMBERSHIP = 5;
+    pub const DROP_MEMBERSHIP = 6;
+    pub const V6ONLY = 9;
+    pub const JOIN_GROUP = 5;
+    pub const LEAVE_GROUP = 6;
+    pub const RECVPKTINFO = 10;
+    pub const PKTINFO = 11;
+    pub const RECVHOPLIMIT = 12;
+    pub const HOPLIMIT = 13;
+};
+
+// https://github.com/SerenityOS/serenity/blob/5bd8af99be0bc4b2e14f361fd7d7590e6bcfa4d6/Kernel/API/POSIX/netinet/in.h#L40
+pub const IPTOS = struct {
+    pub const LOWDELAY = 16;
+    pub const THROUGHPUT = 8;
+    pub const RELIABILITY = 4;
+};
lib/std/c/solaris.zig
@@ -363,3 +363,118 @@ pub fn IOW(io_type: u8, nr: u8, comptime IOT: type) i32 {
 pub fn IOWR(io_type: u8, nr: u8, comptime IOT: type) i32 {
     return ioImpl(.read_write, io_type, nr, IOT);
 }
+
+// https://github.com/illumos/illumos-gate/blob/608eb926e14f4ba4736b2d59e891335f1cba9e1e/usr/src/uts/common/netinet/in.h#L1141
+// (old OpenSolaris is very similar, it's just missing a few more-modern ones, and probably modern Solaris has those)
+pub const IP = struct {
+    pub const OPTIONS = 1;
+    pub const HDRINCL = 2;
+    pub const TOS = 3;
+    pub const TTL = 4;
+    pub const RECVOPTS = 0x5;
+    pub const RECVRETOPTS = 0x6;
+    pub const RECVDSTADDR = 0x7;
+    pub const RETOPTS = 0x8;
+    pub const RECVIF = 0x9;
+    pub const RECVSLLA = 0xa;
+    pub const RECVTTL = 0xb;
+    pub const RECVTOS = 0xc;
+    pub const MULTICAST_IF = 0x10;
+    pub const MULTICAST_TTL = 0x11;
+    pub const MULTICAST_LOOP = 0x12;
+    pub const ADD_MEMBERSHIP = 0x13;
+    pub const DROP_MEMBERSHIP = 0x14;
+    pub const BLOCK_SOURCE = 0x15;
+    pub const UNBLOCK_SOURCE = 0x16;
+    pub const ADD_SOURCE_MEMBERSHIP = 0x17;
+    pub const DROP_SOURCE_MEMBERSHIP = 0x18;
+    pub const NEXTHOP = 0x19;
+    pub const PKTINFO = 0x1a;
+    pub const RECVPKTINFO = 0x1a;
+    pub const DONTFRAG = 0x1b;
+    pub const MINTTL = 0x1c;
+    pub const SEC_OPT = 0x22;
+    pub const BOUND_IF = 0x41;
+    pub const UNSPEC_SRC = 0x42;
+    pub const BROADCAST_TTL = 0x43;
+    pub const DHCPINIT_IF = 0x45;
+    pub const REUSEADDR = 0x104;
+    pub const DONTROUTE = 0x105;
+    pub const BROADCAST = 0x106;
+    // Same namespace, but these are arguments rather than option names
+    pub const DEFAULT_MULTICAST_TTL = 1;
+    pub const DEFAULT_MULTICAST_LOOP = 1;
+};
+
+// https://github.com/illumos/illumos-gate/blob/608eb926e14f4ba4736b2d59e891335f1cba9e1e/usr/src/uts/common/netinet/in.h#L1192
+// (old OpenSolaris is very similar, it's just missing a few more-modern ones, and probably modern Solaris has those)
+pub const IPV6 = struct {
+    pub const UNICAST_HOPS = 0x5;
+    pub const MULTICAST_IF = 0x6;
+    pub const MULTICAST_HOPS = 0x7;
+    pub const MULTICAST_LOOP = 0x8;
+    pub const JOIN_GROUP = 0x9;
+    pub const LEAVE_GROUP = 0xa;
+    pub const ADD_MEMBERSHIP = 0x9;
+    pub const DROP_MEMBERSHIP = 0xa;
+    pub const PKTINFO = 0xb;
+    pub const HOPLIMIT = 0xc;
+    pub const NEXTHOP = 0xd;
+    pub const HOPOPTS = 0xe;
+    pub const DSTOPTS = 0xf;
+    pub const RTHDR = 0x10;
+    pub const RTHDRDSTOPTS = 0x11;
+    pub const RECVPKTINFO = 0x12;
+    pub const RECVHOPLIMIT = 0x13;
+    pub const RECVHOPOPTS = 0x14;
+    pub const OLD_RECVDSTOPTS = 0x15;
+    pub const RECVRTHDR = 0x16;
+    pub const RECVRTHDRDSTOPTS = 0x17;
+    pub const CHECKSUM = 0x18;
+    pub const RECVTCLASS = 0x19;
+    pub const USE_MIN_MTU = 0x20;
+    pub const DONTFRAG = 0x21;
+    pub const SEC_OPT = 0x22;
+    pub const SRC_PREFERENCES = 0x23;
+    pub const RECVPATHMTU = 0x24;
+    pub const PATHMTU = 0x25;
+    pub const TCLASS = 0x26;
+    pub const V6ONLY = 0x27;
+    pub const RECVDSTOPTS = 0x28;
+    pub const MINHOPCOUNT = 0x2f;
+    pub const BOUND_IF = 0x41;
+    pub const UNSPEC_SRC = 0x42;
+    // Same namespace, but these are arguments rather than option names
+    pub const RTHDR_TYPE_0 = 0;
+    pub const PREFER_SRC_HOME = 0x01;
+    pub const PREFER_SRC_COA = 0x02;
+    pub const PREFER_SRC_PUBLIC = 0x04;
+    pub const PREFER_SRC_TMP = 0x08;
+    pub const PREFER_SRC_NONCGA = 0x10;
+    pub const PREFER_SRC_CGA = 0x20;
+    pub const PREFER_SRC_MIPMASK = PREFER_SRC_HOME | PREFER_SRC_COA;
+    pub const PREFER_SRC_MIPDEFAULT = PREFER_SRC_HOME;
+    pub const PREFER_SRC_TMPMASK = PREFER_SRC_PUBLIC | PREFER_SRC_TMP;
+    pub const PREFER_SRC_TMPDEFAULT = PREFER_SRC_PUBLIC;
+    pub const PREFER_SRC_CGAMASK = PREFER_SRC_NONCGA | PREFER_SRC_CGA;
+    pub const PREFER_SRC_CGADEFAULT = PREFER_SRC_NONCGA;
+    pub const PREFER_SRC_MASK = PREFER_SRC_MIPMASK | PREFER_SRC_TMPMASK | PREFER_SRC_CGAMASK;
+    pub const PREFER_SRC_DEFAULT = PREFER_SRC_MIPDEFAULT | PREFER_SRC_TMPDEFAULT | PREFER_SRC_CGADEFAULT;
+};
+
+// https://github.com/illumos/illumos-gate/blob/608eb926e14f4ba4736b2d59e891335f1cba9e1e/usr/src/uts/common/netinet/ip.h#L64
+pub const IPTOS = struct {
+    pub const LOWDELAY = 0x10;
+    pub const THROUGHPUT = 0x08;
+    pub const RELIABILITY = 0x04;
+    pub const ECT = 0x02;
+    pub const CE = 0x01;
+    pub const PREC_NETCONTROL = 0xe0;
+    pub const PREC_INTERNETCONTROL = 0xc0;
+    pub const PREC_CRITIC_ECP = 0xa0;
+    pub const PREC_FLASHOVERRIDE = 0x80;
+    pub const PREC_FLASH = 0x60;
+    pub const PREC_IMMEDIATE = 0x40;
+    pub const PREC_PRIORITY = 0x20;
+    pub const PREC_ROUTINE = 0x00;
+};
lib/std/os/linux.zig
@@ -4524,6 +4524,33 @@ pub const IPV6 = struct {
     pub const FREEBIND = 78;
 };
 
+// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/ip.h?id=64e844505bc08cde3f346f193cbbbab0096fef54#n24
+pub const IPTOS = struct {
+    pub const TOS_MASK = 0x1e;
+    pub fn TOS(t: anytype) @TypeOf(t) {
+        return t & TOS_MASK;
+    }
+
+    pub const MINCOST = 0x02;
+    pub const RELIABILITY = 0x04;
+    pub const THROUGHPUT = 0x08;
+    pub const LOWDELAY = 0x10;
+
+    pub const PREC_MASK = 0xe0;
+    pub fn PREC(t: anytype) @TypeOf(t) {
+        return t & PREC_MASK;
+    }
+
+    pub const PREC_ROUTINE = 0x00;
+    pub const PREC_PRIORITY = 0x20;
+    pub const PREC_IMMEDIATE = 0x40;
+    pub const PREC_FLASH = 0x60;
+    pub const PREC_FLASHOVERRIDE = 0x80;
+    pub const PREC_CRITIC_ECP = 0xa0;
+    pub const PREC_INTERNETCONTROL = 0xc0;
+    pub const PREC_NETCONTROL = 0xe0;
+};
+
 // https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/socket.h?id=b1e904999542ad6764eafa54545f1c55776006d1#n43
 pub const linger = extern struct {
     onoff: i32, // non-zero to linger on close
lib/std/c.zig
@@ -6459,7 +6459,7 @@ pub const IPPROTO = switch (native_os) {
         /// dummy for IP
         pub const IP = 0;
         /// IP6 hop-by-hop options
-        pub const HOPOPTS = IP;
+        pub const HOPOPTS = IPPROTO.IP;
         /// control message protocol
         pub const ICMP = 1;
         /// group mgmt protocol
@@ -6541,6 +6541,39 @@ pub const IPPROTO = switch (native_os) {
     },
     else => void,
 };
+pub const IP = switch (native_os) {
+    .linux => linux.IP,
+    .freebsd => freebsd.IP,
+    .dragonfly => dragonfly.IP,
+    .netbsd => netbsd.IP,
+    .openbsd => openbsd.IP,
+    .solaris, .illumos => solaris.IP,
+    .haiku => haiku.IP,
+    .serenity => serenity.IP,
+    else => void,
+};
+pub const IPV6 = switch (native_os) {
+    .linux => linux.IPV6,
+    .freebsd => freebsd.IPV6,
+    .dragonfly => dragonfly.IPV6,
+    .netbsd => netbsd.IPV6,
+    .openbsd => openbsd.IPV6,
+    .solaris, .illumos => solaris.IPV6,
+    .haiku => haiku.IPV6,
+    .serenity => serenity.IPV6,
+    else => void,
+};
+pub const IPTOS = switch (native_os) {
+    .linux => linux.IPTOS,
+    .freebsd => freebsd.IPTOS,
+    .dragonfly => dragonfly.IPTOS,
+    .netbsd => netbsd.IPTOS,
+    .openbsd => openbsd.IPTOS,
+    .solaris, .illumos => solaris.IPTOS,
+    .haiku => haiku.IPTOS,
+    .serenity => serenity.IPTOS,
+    else => void,
+};
 pub const SOL = switch (native_os) {
     .linux => linux.SOL,
     .emscripten => emscripten.SOL,
lib/std/posix.zig
@@ -75,7 +75,10 @@ pub const HOST_NAME_MAX = system.HOST_NAME_MAX;
 pub const HW = system.HW;
 pub const IFNAMESIZE = system.IFNAMESIZE;
 pub const IOV_MAX = system.IOV_MAX;
+pub const IP = system.IP;
+pub const IPV6 = system.IPV6;
 pub const IPPROTO = system.IPPROTO;
+pub const IPTOS = system.IPTOS;
 pub const KERN = system.KERN;
 pub const Kevent = system.Kevent;
 pub const MADV = system.MADV;