authorgravatar for bblack@wikimedia.orgBrandon Black <bblack@wikimedia.org> 2025-09-09 16:47:32-05:00
committergravatar for bblack@wikimedia.orgBrandon Black <bblack@wikimedia.org> 2025-09-09 17:01:20-05:00
log799569752793351402f636f9b0c76c43bea97806
treef0e753fc5a5bc4bbb7f6d6768cc88e76833cf5ca
parent0e45b9d5db6cd92578d1a1da13ff2c036603ff91

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.

11 files changed, 1066 insertions(+), 1 deletions(-)

lib/std/c.zig+34-1
......@@ -6459,7 +6459,7 @@ pub const IPPROTO = switch (native_os) {
64596459 /// dummy for IP
64606460 pub const IP = 0;
64616461 /// IP6 hop-by-hop options
6462 pub const HOPOPTS = IP;
6462 pub const HOPOPTS = IPPROTO.IP;
64636463 /// control message protocol
64646464 pub const ICMP = 1;
64656465 /// group mgmt protocol
......@@ -6541,6 +6541,39 @@ pub const IPPROTO = switch (native_os) {
65416541 },
65426542 else => void,
65436543};
6544pub const IP = switch (native_os) {
6545 .linux => linux.IP,
6546 .freebsd => freebsd.IP,
6547 .dragonfly => dragonfly.IP,
6548 .netbsd => netbsd.IP,
6549 .openbsd => openbsd.IP,
6550 .solaris, .illumos => solaris.IP,
6551 .haiku => haiku.IP,
6552 .serenity => serenity.IP,
6553 else => void,
6554};
6555pub const IPV6 = switch (native_os) {
6556 .linux => linux.IPV6,
6557 .freebsd => freebsd.IPV6,
6558 .dragonfly => dragonfly.IPV6,
6559 .netbsd => netbsd.IPV6,
6560 .openbsd => openbsd.IPV6,
6561 .solaris, .illumos => solaris.IPV6,
6562 .haiku => haiku.IPV6,
6563 .serenity => serenity.IPV6,
6564 else => void,
6565};
6566pub const IPTOS = switch (native_os) {
6567 .linux => linux.IPTOS,
6568 .freebsd => freebsd.IPTOS,
6569 .dragonfly => dragonfly.IPTOS,
6570 .netbsd => netbsd.IPTOS,
6571 .openbsd => openbsd.IPTOS,
6572 .solaris, .illumos => solaris.IPTOS,
6573 .haiku => haiku.IPTOS,
6574 .serenity => serenity.IPTOS,
6575 else => void,
6576};
65446577pub const SOL = switch (native_os) {
65456578 .linux => linux.SOL,
65466579 .emscripten => emscripten.SOL,
lib/std/c/darwin.zig+162
......@@ -1724,3 +1724,165 @@ pub const MSG = struct {
17241724 /// Inherit upcall in sock_accept
17251725 pub const USEUPCALL = 0x80000000;
17261726};
1727
1728// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/netinet/in.h#L454
1729pub const IP = struct {
1730 pub const OPTIONS = 1;
1731 pub const HDRINCL = 2;
1732 pub const TOS = 3;
1733 pub const TTL = 4;
1734 pub const RECVOPTS = 5;
1735 pub const RECVRETOPTS = 6;
1736 pub const RECVDSTADDR = 7;
1737 pub const RETOPTS = 8;
1738 pub const MULTICAST_IF = 9;
1739 pub const MULTICAST_TTL = 10;
1740 pub const MULTICAST_LOOP = 11;
1741 pub const ADD_MEMBERSHIP = 12;
1742 pub const DROP_MEMBERSHIP = 13;
1743 pub const MULTICAST_VIF = 14;
1744 pub const RSVP_ON = 15;
1745 pub const RSVP_OFF = 16;
1746 pub const RSVP_VIF_ON = 17;
1747 pub const RSVP_VIF_OFF = 18;
1748 pub const PORTRANGE = 19;
1749 pub const RECVIF = 20;
1750 pub const IPSEC_POLICY = 21;
1751 pub const FAITH = 22;
1752 pub const STRIPHDR = 23;
1753 pub const RECVTTL = 24;
1754 pub const BOUND_IF = 25;
1755 pub const PKTINFO = 26;
1756 pub const RECVPKTINFO = PKTINFO;
1757 pub const RECVTOS = 27;
1758 pub const DONTFRAG = 28;
1759 pub const FW_ADD = 40;
1760 pub const FW_DEL = 41;
1761 pub const FW_FLUSH = 42;
1762 pub const FW_ZERO = 43;
1763 pub const FW_GET = 44;
1764 pub const FW_RESETLOG = 45;
1765 pub const OLD_FW_ADD = 50;
1766 pub const OLD_FW_DEL = 51;
1767 pub const OLD_FW_FLUSH = 52;
1768 pub const OLD_FW_ZERO = 53;
1769 pub const OLD_FW_GET = 54;
1770 pub const OLD_FW_RESETLOG = 56;
1771 pub const DUMMYNET_CONFIGURE = 60;
1772 pub const DUMMYNET_DEL = 61;
1773 pub const DUMMYNET_FLUSH = 62;
1774 pub const DUMMYNET_GET = 64;
1775 pub const TRAFFIC_MGT_BACKGROUND = 65;
1776 pub const MULTICAST_IFINDEX = 66;
1777 pub const ADD_SOURCE_MEMBERSHIP = 70;
1778 pub const DROP_SOURCE_MEMBERSHIP = 71;
1779 pub const BLOCK_SOURCE = 72;
1780 pub const UNBLOCK_SOURCE = 73;
1781 pub const MSFILTER = 74;
1782 // Same namespace, but these are arguments rather than option names
1783 pub const DEFAULT_MULTICAST_TTL = 1;
1784 pub const DEFAULT_MULTICAST_LOOP = 1;
1785 pub const MIN_MEMBERSHIPS = 31;
1786 pub const MAX_MEMBERSHIPS = 4095;
1787 pub const MAX_GROUP_SRC_FILTER = 512;
1788 pub const MAX_SOCK_SRC_FILTER = 128;
1789 pub const MAX_SOCK_MUTE_FILTER = 128;
1790 pub const PORTRANGE_DEFAULT = 0;
1791 pub const PORTRANGE_HIGH = 1;
1792 pub const PORTRANGE_LOW = 2;
1793};
1794
1795// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/netinet6/in6.h#L521
1796pub const IPV6 = struct {
1797 pub const UNICAST_HOPS = 4;
1798 pub const MULTICAST_IF = 9;
1799 pub const MULTICAST_HOPS = 10;
1800 pub const MULTICAST_LOOP = 11;
1801 pub const JOIN_GROUP = 12;
1802 pub const LEAVE_GROUP = 13;
1803 pub const PORTRANGE = 14;
1804 pub const @"2292PKTINFO" = 19;
1805 pub const @"2292HOPLIMIT" = 20;
1806 pub const @"2292NEXTHOP" = 21;
1807 pub const @"2292HOPOPTS" = 22;
1808 pub const @"2292DSTOPTS" = 23;
1809 pub const @"2292RTHDR" = 24;
1810 pub const @"2292PKTOPTIONS" = 25;
1811 pub const CHECKSUM = 26;
1812 pub const V6ONLY = 27;
1813 pub const BINDV6ONLY = V6ONLY;
1814 pub const IPSEC_POLICY = 28;
1815 pub const FAITH = 29;
1816 pub const FW_ADD = 30;
1817 pub const FW_DEL = 31;
1818 pub const FW_FLUSH = 32;
1819 pub const FW_ZERO = 33;
1820 pub const FW_GET = 34;
1821 pub const RECVTCLASS = 35;
1822 pub const TCLASS = 36;
1823 pub const RTHDRDSTOPTS = 57;
1824 pub const RECVPKTINFO = 61;
1825 pub const RECVHOPLIMIT = 37;
1826 pub const RECVRTHDR = 38;
1827 pub const RECVHOPOPTS = 39;
1828 pub const RECVDSTOPTS = 40;
1829 pub const RECVRTHDRDSTOPTS = 41;
1830 pub const USE_MIN_MTU = 42;
1831 pub const RECVPATHMTU = 43;
1832 pub const PATHMTU = 44;
1833 pub const REACHCONF = 45;
1834 pub const @"3542PKTINFO" = 46;
1835 pub const @"3542HOPLIMIT" = 47;
1836 pub const @"3542NEXTHOP" = 48;
1837 pub const @"3542HOPOPTS" = 49;
1838 pub const @"3542DSTOPTS" = 50;
1839 pub const @"3542RTHDR" = 51;
1840 pub const PKTINFO = @"3542PKTINFO";
1841 pub const HOPLIMIT = @"3542HOPLIMIT";
1842 pub const NEXTHOP = @"3542NEXTHOP";
1843 pub const HOPOPTS = @"3542HOPOPTS";
1844 pub const DSTOPTS = @"3542DSTOPTS";
1845 pub const RTHDR = @"3542RTHDR";
1846 pub const AUTOFLOWLABEL = 59;
1847 pub const DONTFRAG = 62;
1848 pub const PREFER_TEMPADDR = 63;
1849 pub const MSFILTER = 74;
1850 pub const BOUND_IF = 125;
1851 // Same namespace, but these are arguments rather than option names
1852 pub const RTHDR_LOOSE = 0;
1853 pub const RTHDR_STRICT = 1;
1854 pub const RTHDR_TYPE_0 = 0;
1855 pub const DEFAULT_MULTICAST_HOPS = 1;
1856 pub const DEFAULT_MULTICAST_LOOP = 1;
1857 pub const MIN_MEMBERSHIPS = 31;
1858 pub const MAX_MEMBERSHIPS = 4095;
1859 pub const MAX_GROUP_SRC_FILTER = 512;
1860 pub const MAX_SOCK_SRC_FILTER = 128;
1861 pub const PORTRANGE_DEFAULT = 0;
1862 pub const PORTRANGE_HIGH = 1;
1863 pub const PORTRANGE_LOW = 2;
1864};
1865
1866// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/netinet/ip.h#L129
1867pub const IPTOS = struct {
1868 pub const LOWDELAY = 0x10;
1869 pub const THROUGHPUT = 0x08;
1870 pub const RELIABILITY = 0x04;
1871 pub const MINCOST = 0x02;
1872 pub const CE = 0x01;
1873 pub const ECT = 0x02;
1874 pub const DSCP_SHIFT = 2;
1875 pub const ECN_NOTECT = 0x00;
1876 pub const ECN_ECT1 = 0x01;
1877 pub const ECN_ECT0 = 0x02;
1878 pub const ECN_CE = 0x03;
1879 pub const ECN_MASK = 0x03;
1880 pub const PREC_NETCONTROL = 0xe0;
1881 pub const PREC_INTERNETCONTROL = 0xc0;
1882 pub const PREC_CRITIC_ECP = 0xa0;
1883 pub const PREC_FLASHOVERRIDE = 0x80;
1884 pub const PREC_FLASH = 0x60;
1885 pub const PREC_IMMEDIATE = 0x40;
1886 pub const PREC_PRIORITY = 0x20;
1887 pub const PREC_ROUTINE = 0x00;
1888};
lib/std/c/dragonfly.zig+158
......@@ -182,3 +182,161 @@ pub const POSIX_MADV_RANDOM = 1;
182182pub const POSIX_MADV_DONTNEED = 4;
183183pub const POSIX_MADV_NORMAL = 0;
184184pub const POSIX_MADV_WILLNEED = 3;
185
186// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/netinet/ip.h#L94
187pub const IP = struct {
188 pub const OPTIONS = 1;
189 pub const HDRINCL = 2;
190 pub const TOS = 3;
191 pub const TTL = 4;
192 pub const RECVOPTS = 5;
193 pub const RECVRETOPTS = 6;
194 pub const RECVDSTADDR = 7;
195 pub const SENDSRCADDR = RECVDSTADDR;
196 pub const RETOPTS = 8;
197 pub const MULTICAST_IF = 9;
198 pub const MULTICAST_TTL = 10;
199 pub const MULTICAST_LOOP = 11;
200 pub const ADD_MEMBERSHIP = 12;
201 pub const DROP_MEMBERSHIP = 13;
202 pub const MULTICAST_VIF = 14;
203 pub const RSVP_ON = 15;
204 pub const RSVP_OFF = 16;
205 pub const RSVP_VIF_ON = 17;
206 pub const RSVP_VIF_OFF = 18;
207 pub const PORTRANGE = 19;
208 pub const RECVIF = 20;
209 pub const FW_TBL_CREATE = 40;
210 pub const FW_TBL_DESTROY = 41;
211 pub const FW_TBL_ADD = 42;
212 pub const FW_TBL_DEL = 43;
213 pub const FW_TBL_FLUSH = 44;
214 pub const FW_TBL_GET = 45;
215 pub const FW_TBL_ZERO = 46;
216 pub const FW_TBL_EXPIRE = 47;
217 pub const FW_X = 49;
218 pub const FW_ADD = 50;
219 pub const FW_DEL = 51;
220 pub const FW_FLUSH = 52;
221 pub const FW_ZERO = 53;
222 pub const FW_GET = 54;
223 pub const FW_RESETLOG = 55;
224 pub const DUMMYNET_CONFIGURE = 60;
225 pub const DUMMYNET_DEL = 61;
226 pub const DUMMYNET_FLUSH = 62;
227 pub const DUMMYNET_GET = 64;
228 pub const RECVTTL = 65;
229 pub const MINTTL = 66;
230 pub const RECVTOS = 68;
231 // Same namespace, but these are arguments rather than option names
232 pub const DEFAULT_MULTICAST_TTL = 1;
233 pub const DEFAULT_MULTICAST_LOOP = 1;
234 pub const MAX_MEMBERSHIPS = 20;
235 pub const PORTRANGE_DEFAULT = 0;
236 pub const PORTRANGE_HIGH = 1;
237 pub const PORTRANGE_LOW = 2;
238};
239
240// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/netinet6/in6.h#L448
241pub const IPV6 = struct {
242 pub const UNICAST_HOPS = 4;
243 pub const MULTICAST_IF = 9;
244 pub const MULTICAST_HOPS = 10;
245 pub const MULTICAST_LOOP = 11;
246 pub const JOIN_GROUP = 12;
247 pub const LEAVE_GROUP = 13;
248 pub const PORTRANGE = 14;
249 pub const @"2292PKTINFO" = 19;
250 pub const @"2292HOPLIMIT" = 20;
251 pub const @"2292NEXTHOP" = 21;
252 pub const @"2292HOPOPTS" = 22;
253 pub const @"2292DSTOPTS" = 23;
254 pub const @"2292RTHDR" = 24;
255 pub const @"2292PKTOPTIONS" = 25;
256 pub const CHECKSUM = 26;
257 pub const V6ONLY = 27;
258 pub const BINDV6ONLY = V6ONLY;
259 pub const FW_ADD = 30;
260 pub const FW_DEL = 31;
261 pub const FW_FLUSH = 32;
262 pub const FW_ZERO = 33;
263 pub const FW_GET = 34;
264 pub const RTHDRDSTOPTS = 35;
265 pub const RECVPKTINFO = 36;
266 pub const RECVHOPLIMIT = 37;
267 pub const RECVRTHDR = 38;
268 pub const RECVHOPOPTS = 39;
269 pub const RECVDSTOPTS = 40;
270 pub const RECVRTHDRDSTOPTS = 41;
271 pub const USE_MIN_MTU = 42;
272 pub const RECVPATHMTU = 43;
273 pub const PATHMTU = 44;
274 pub const REACHCONF = 45;
275 pub const PKTINFO = 46;
276 pub const HOPLIMIT = 47;
277 pub const NEXTHOP = 48;
278 pub const HOPOPTS = 49;
279 pub const DSTOPTS = 50;
280 pub const RTHDR = 51;
281 pub const PKTOPTIONS = 52;
282 pub const RECVTCLASS = 57;
283 pub const AUTOFLOWLABEL = 59;
284 pub const TCLASS = 61;
285 pub const DONTFRAG = 62;
286 pub const PREFER_TEMPADDR = 63;
287 pub const MSFILTER = 74;
288 // Same namespace, but these are arguments rather than option names
289 pub const RTHDR_LOOSE = 0;
290 pub const RTHDR_STRICT = 1;
291 pub const RTHDR_TYPE_0 = 0;
292 pub const DEFAULT_MULTICAST_HOPS = 1;
293 pub const DEFAULT_MULTICAST_LOOP = 1;
294 pub const PORTRANGE_DEFAULT = 0;
295 pub const PORTRANGE_HIGH = 1;
296 pub const PORTRANGE_LOW = 2;
297};
298
299// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/netinet/ip.h#L94
300pub const IPTOS = struct {
301 pub const LOWDELAY = 0x10;
302 pub const THROUGHPUT = 0x08;
303 pub const RELIABILITY = 0x04;
304 pub const MINCOST = 0x02;
305 pub const CE = 0x01;
306 pub const ECT = 0x02;
307 pub const PREC_ROUTINE = DSCP_CS0;
308 pub const PREC_PRIORITY = DSCP_CS1;
309 pub const PREC_IMMEDIATE = DSCP_CS2;
310 pub const PREC_FLASH = DSCP_CS3;
311 pub const PREC_FLASHOVERRIDE = DSCP_CS4;
312 pub const PREC_CRITIC_ECP = DSCP_CS5;
313 pub const PREC_INTERNETCONTROL = DSCP_CS6;
314 pub const PREC_NETCONTROL = DSCP_CS7;
315 pub const DSCP_CS0 = 0x00;
316 pub const DSCP_CS1 = 0x20;
317 pub const DSCP_AF11 = 0x28;
318 pub const DSCP_AF12 = 0x30;
319 pub const DSCP_AF13 = 0x38;
320 pub const DSCP_CS2 = 0x40;
321 pub const DSCP_AF21 = 0x48;
322 pub const DSCP_AF22 = 0x50;
323 pub const DSCP_AF23 = 0x58;
324 pub const DSCP_CS3 = 0x60;
325 pub const DSCP_AF31 = 0x68;
326 pub const DSCP_AF32 = 0x70;
327 pub const DSCP_AF33 = 0x78;
328 pub const DSCP_CS4 = 0x80;
329 pub const DSCP_AF41 = 0x88;
330 pub const DSCP_AF42 = 0x90;
331 pub const DSCP_AF43 = 0x98;
332 pub const DSCP_CS5 = 0xa0;
333 pub const DSCP_VA = 0xb0;
334 pub const DSCP_EF = 0xb8;
335 pub const DSCP_CS6 = 0xc0;
336 pub const DSCP_CS7 = 0xe0;
337 pub const ECN_NOTECT = 0x00;
338 pub const ECN_ECT1 = 0x01;
339 pub const ECN_ECT0 = 0x02;
340 pub const ECN_CE = 0x03;
341 pub const ECN_MASK = 0x03;
342};
lib/std/c/freebsd.zig+192
......@@ -391,3 +391,195 @@ pub const E = enum(u16) {
391391 INTEGRITY = 97, // Integrity check failed
392392 _,
393393};
394
395// https://github.com/freebsd/freebsd-src/blob/9bfbc6826f72eb385bf52f4cde8080bccf7e3ebd/sys/netinet/in.h#L436
396pub const IP = struct {
397 pub const OPTIONS = 1;
398 pub const HDRINCL = 2;
399 pub const TOS = 3;
400 pub const TTL = 4;
401 pub const RECVOPTS = 5;
402 pub const RECVRETOPTS = 6;
403 pub const RECVDSTADDR = 7;
404 pub const SENDSRCADDR = RECVDSTADDR;
405 pub const RETOPTS = 8;
406 pub const MULTICAST_IF = 9;
407 pub const MULTICAST_TTL = 10;
408 pub const MULTICAST_LOOP = 11;
409 pub const ADD_MEMBERSHIP = 12;
410 pub const DROP_MEMBERSHIP = 13;
411 pub const MULTICAST_VIF = 14;
412 pub const RSVP_ON = 15;
413 pub const RSVP_OFF = 16;
414 pub const RSVP_VIF_ON = 17;
415 pub const RSVP_VIF_OFF = 18;
416 pub const PORTRANGE = 19;
417 pub const RECVIF = 20;
418 pub const IPSEC_POLICY = 21;
419 pub const ONESBCAST = 23;
420 pub const BINDANY = 24;
421 pub const ORIGDSTADDR = 27;
422 pub const RECVORIGDSTADDR = ORIGDSTADDR;
423 pub const FW_TABLE_ADD = 40;
424 pub const FW_TABLE_DEL = 41;
425 pub const FW_TABLE_FLUSH = 42;
426 pub const FW_TABLE_GETSIZE = 43;
427 pub const FW_TABLE_LIST = 44;
428 pub const FW3 = 48;
429 pub const DUMMYNET3 = 49;
430 pub const FW_ADD = 50;
431 pub const FW_DEL = 51;
432 pub const FW_FLUSH = 52;
433 pub const FW_ZERO = 53;
434 pub const FW_GET = 54;
435 pub const FW_RESETLOG = 55;
436 pub const FW_NAT_CFG = 56;
437 pub const FW_NAT_DEL = 57;
438 pub const FW_NAT_GET_CONFIG = 58;
439 pub const FW_NAT_GET_LOG = 59;
440 pub const DUMMYNET_CONFIGURE = 60;
441 pub const DUMMYNET_DEL = 61;
442 pub const DUMMYNET_FLUSH = 62;
443 pub const DUMMYNET_GET = 64;
444 pub const RECVTTL = 65;
445 pub const MINTTL = 66;
446 pub const DONTFRAG = 67;
447 pub const RECVTOS = 68;
448 pub const ADD_SOURCE_MEMBERSHIP = 70;
449 pub const DROP_SOURCE_MEMBERSHIP = 71;
450 pub const BLOCK_SOURCE = 72;
451 pub const UNBLOCK_SOURCE = 73;
452 pub const MSFILTER = 74;
453 pub const VLAN_PCP = 75;
454 pub const FLOWID = 90;
455 pub const FLOWTYPE = 91;
456 pub const RSSBUCKETID = 92;
457 pub const RECVFLOWID = 93;
458 pub const RECVRSSBUCKETID = 94;
459 // Same namespace, but these are arguments rather than option names
460 pub const DEFAULT_MULTICAST_TTL = 1;
461 pub const DEFAULT_MULTICAST_LOOP = 1;
462 pub const MAX_MEMBERSHIPS = 4095;
463 pub const MAX_GROUP_SRC_FILTER = 512;
464 pub const MAX_SOCK_SRC_FILTER = 128;
465 pub const MAX_SOCK_MUTE_FILTER = 128;
466 pub const PORTRANGE_DEFAULT = 0;
467 pub const PORTRANGE_HIGH = 1;
468 pub const PORTRANGE_LOW = 2;
469};
470
471// https://github.com/freebsd/freebsd-src/blob/9bfbc6826f72eb385bf52f4cde8080bccf7e3ebd/sys/netinet6/in6.h#L402
472pub const IPV6 = struct {
473 pub const UNICAST_HOPS = 4;
474 pub const MULTICAST_IF = 9;
475 pub const MULTICAST_HOPS = 10;
476 pub const MULTICAST_LOOP = 11;
477 pub const JOIN_GROUP = 12;
478 pub const LEAVE_GROUP = 13;
479 pub const PORTRANGE = 14;
480 pub const @"2292PKTINFO" = 19;
481 pub const @"2292HOPLIMIT" = 20;
482 pub const @"2292NEXTHOP" = 21;
483 pub const @"2292HOPOPTS" = 22;
484 pub const @"2292DSTOPTS" = 23;
485 pub const @"2292RTHDR" = 24;
486 pub const @"2292PKTOPTIONS" = 25;
487 pub const CHECKSUM = 26;
488 pub const V6ONLY = 27;
489 pub const BINDV6ONLY = V6ONLY;
490 pub const IPSEC_POLICY = 28;
491 pub const FW_ADD = 30;
492 pub const FW_DEL = 31;
493 pub const FW_FLUSH = 32;
494 pub const FW_ZERO = 33;
495 pub const FW_GET = 34;
496 pub const RTHDRDSTOPTS = 35;
497 pub const RECVPKTINFO = 36;
498 pub const RECVHOPLIMIT = 37;
499 pub const RECVRTHDR = 38;
500 pub const RECVHOPOPTS = 39;
501 pub const RECVDSTOPTS = 40;
502 pub const RECVRTHDRDSTOPTS = 41;
503 pub const USE_MIN_MTU = 42;
504 pub const RECVPATHMTU = 43;
505 pub const PATHMTU = 44;
506 pub const REACHCONF = 45;
507 pub const PKTINFO = 46;
508 pub const HOPLIMIT = 47;
509 pub const NEXTHOP = 48;
510 pub const HOPOPTS = 49;
511 pub const DSTOPTS = 50;
512 pub const RTHDR = 51;
513 pub const PKTOPTIONS = 52;
514 pub const RECVTCLASS = 57;
515 pub const AUTOFLOWLABEL = 59;
516 pub const TCLASS = 61;
517 pub const DONTFRAG = 62;
518 pub const PREFER_TEMPADDR = 63;
519 pub const BINDANY = 64;
520 pub const FLOWID = 67;
521 pub const FLOWTYPE = 68;
522 pub const RSSBUCKETID = 69;
523 pub const RECVFLOWID = 70;
524 pub const RECVRSSBUCKETID = 71;
525 pub const ORIGDSTADDR = 72;
526 pub const RECVORIGDSTADDR = ORIGDSTADDR;
527 pub const MSFILTER = 74;
528 pub const VLAN_PCP = 75;
529 // Same namespace, but these are arguments rather than option names
530 pub const RTHDR_LOOSE = 0;
531 pub const RTHDR_STRICT = 1;
532 pub const RTHDR_TYPE_0 = 0;
533 pub const DEFAULT_MULTICAST_HOPS = 1;
534 pub const DEFAULT_MULTICAST_LOOP = 1;
535 pub const MAX_MEMBERSHIPS = 4095;
536 pub const MAX_GROUP_SRC_FILTER = 512;
537 pub const MAX_SOCK_SRC_FILTER = 128;
538 pub const PORTRANGE_DEFAULT = 0;
539 pub const PORTRANGE_HIGH = 1;
540 pub const PORTRANGE_LOW = 2;
541};
542
543// https://github.com/freebsd/freebsd-src/blob/9bfbc6826f72eb385bf52f4cde8080bccf7e3ebd/sys/netinet/ip.h#L77
544pub const IPTOS = struct {
545 pub const LOWDELAY = 0x10;
546 pub const THROUGHPUT = 0x08;
547 pub const RELIABILITY = 0x04;
548 pub const MINCOST = DSCP_CS0;
549 pub const PREC_ROUTINE = DSCP_CS0;
550 pub const PREC_PRIORITY = DSCP_CS1;
551 pub const PREC_IMMEDIATE = DSCP_CS2;
552 pub const PREC_FLASH = DSCP_CS3;
553 pub const PREC_FLASHOVERRIDE = DSCP_CS4;
554 pub const PREC_CRITIC_ECP = DSCP_CS5;
555 pub const PREC_INTERNETCONTROL = DSCP_CS6;
556 pub const PREC_NETCONTROL = DSCP_CS7;
557 pub const DSCP_OFFSET = 2;
558 pub const DSCP_CS0 = 0x00;
559 pub const DSCP_CS1 = 0x20;
560 pub const DSCP_AF11 = 0x28;
561 pub const DSCP_AF12 = 0x30;
562 pub const DSCP_AF13 = 0x38;
563 pub const DSCP_CS2 = 0x40;
564 pub const DSCP_AF21 = 0x48;
565 pub const DSCP_AF22 = 0x50;
566 pub const DSCP_AF23 = 0x58;
567 pub const DSCP_CS3 = 0x60;
568 pub const DSCP_AF31 = 0x68;
569 pub const DSCP_AF32 = 0x70;
570 pub const DSCP_AF33 = 0x78;
571 pub const DSCP_CS4 = 0x80;
572 pub const DSCP_AF41 = 0x88;
573 pub const DSCP_AF42 = 0x90;
574 pub const DSCP_AF43 = 0x98;
575 pub const DSCP_CS5 = 0xa0;
576 pub const DSCP_VA = 0xb0;
577 pub const DSCP_EF = 0xb8;
578 pub const DSCP_CS6 = 0xc0;
579 pub const DSCP_CS7 = 0xe0;
580 pub const ECN_NOTECT = 0x00;
581 pub const ECN_ECT1 = 0x01;
582 pub const ECN_ECT0 = 0x02;
583 pub const ECN_CE = 0x03;
584 pub const ECN_MASK = 0x03;
585};
lib/std/c/haiku.zig+47
......@@ -553,3 +553,50 @@ pub const DirEnt = extern struct {
553553 return @ptrCast(&dirent.name);
554554 }
555555};
556
557// https://github.com/haiku/haiku/blob/2aab5f5f14aeb3f34c3a3d9a9064cc3c0d914bea/headers/posix/netinet/in.h#L122
558pub const IP = struct {
559 pub const OPTIONS = 1;
560 pub const HDRINCL = 2;
561 pub const TOS = 3;
562 pub const TTL = 4;
563 pub const RECVOPTS = 5;
564 pub const RECVRETOPTS = 6;
565 pub const RECVDSTADDR = 7;
566 pub const RETOPTS = 8;
567 pub const MULTICAST_IF = 9;
568 pub const MULTICAST_TTL = 10;
569 pub const MULTICAST_LOOP = 11;
570 pub const ADD_MEMBERSHIP = 12;
571 pub const DROP_MEMBERSHIP = 13;
572 pub const BLOCK_SOURCE = 14;
573 pub const UNBLOCK_SOURCE = 15;
574 pub const ADD_SOURCE_MEMBERSHIP = 16;
575 pub const DROP_SOURCE_MEMBERSHIP = 17;
576 pub const DONTFRAG = 38;
577};
578
579// https://github.com/haiku/haiku/blob/2aab5f5f14aeb3f34c3a3d9a9064cc3c0d914bea/headers/posix/netinet/in.h#L150
580pub const IPV6 = struct {
581 pub const MULTICAST_IF = 24;
582 pub const MULTICAST_HOPS = 25;
583 pub const MULTICAST_LOOP = 26;
584 pub const UNICAST_HOPS = 27;
585 pub const JOIN_GROUP = 28;
586 pub const LEAVE_GROUP = 29;
587 pub const V6ONLY = 30;
588 pub const PKTINFO = 31;
589 pub const RECVPKTINFO = 32;
590 pub const HOPLIMIT = 33;
591 pub const RECVHOPLIMIT = 34;
592 pub const HOPOPTS = 35;
593 pub const DSTOPTS = 36;
594 pub const RTHDR = 37;
595};
596
597// https://github.com/haiku/haiku/blob/2aab5f5f14aeb3f34c3a3d9a9064cc3c0d914bea/headers/posix/netinet/ip.h#L36
598pub const IPTOS = struct {
599 pub const RELIABILITY = 0x04;
600 pub const THROUGHPUT = 0x08;
601 pub const LOWDELAY = 0x10;
602};
lib/std/c/netbsd.zig+152
......@@ -201,3 +201,155 @@ pub const E = enum(u16) {
201201
202202 _,
203203};
204
205// https://github.com/NetBSD/src/blob/80bf25a5691072d4755e84567ccbdf0729370dea/sys/netinet/in.h#L276
206pub const IP = struct {
207 pub const OPTIONS = 1;
208 pub const HDRINCL = 2;
209 pub const TOS = 3;
210 pub const TTL = 4;
211 pub const RECVOPTS = 5;
212 pub const RECVRETOPTS = 6;
213 pub const RECVDSTADDR = 7;
214 pub const RETOPTS = 8;
215 pub const MULTICAST_IF = 9;
216 pub const MULTICAST_TTL = 10;
217 pub const MULTICAST_LOOP = 11;
218 pub const ADD_MEMBERSHIP = 12;
219 pub const DROP_MEMBERSHIP = 13;
220 pub const PORTALGO = 18;
221 pub const PORTRANGE = 19;
222 pub const RECVIF = 20;
223 pub const ERRORMTU = 21;
224 pub const IPSEC_POLICY = 22;
225 pub const RECVTTL = 23;
226 pub const MINTTL = 24;
227 pub const PKTINFO = 25;
228 pub const RECVPKTINFO = 26;
229 pub const BINDANY = 27;
230 pub const SENDSRCADDR = RECVDSTADDR;
231 pub const DEFAULT_MULTICAST_TTL = 1;
232 pub const DEFAULT_MULTICAST_LOOP = 1;
233 pub const MAX_MEMBERSHIPS = 20;
234 pub const PORTRANGE_DEFAULT = 0;
235 pub const PORTRANGE_HIGH = 1;
236 pub const PORTRANGE_LOW = 2;
237};
238
239// https://github.com/NetBSD/src/blob/80bf25a5691072d4755e84567ccbdf0729370dea/sys/netinet6/in6.h#L370
240pub const IPV6 = struct {
241 pub const UNICAST_HOPS = 4;
242 pub const MULTICAST_IF = 9;
243 pub const MULTICAST_HOPS = 10;
244 pub const MULTICAST_LOOP = 11;
245 pub const JOIN_GROUP = 12;
246 pub const LEAVE_GROUP = 13;
247 pub const PORTRANGE = 14;
248 pub const PORTALGO = 17;
249 pub const @"2292PKTINFO" = 19;
250 pub const @"2292HOPLIMIT" = 20;
251 pub const @"2292NEXTHOP" = 21;
252 pub const @"2292HOPOPTS" = 22;
253 pub const @"2292DSTOPTS" = 23;
254 pub const @"2292RTHDR" = 24;
255 pub const @"2292PKTOPTIONS" = 25;
256 pub const CHECKSUM = 26;
257 pub const V6ONLY = 27;
258 pub const IPSEC_POLICY = 28;
259 pub const FAITH = 29;
260 pub const RTHDRDSTOPTS = 35;
261 pub const RECVPKTINFO = 36;
262 pub const RECVHOPLIMIT = 37;
263 pub const RECVRTHDR = 38;
264 pub const RECVHOPOPTS = 39;
265 pub const RECVDSTOPTS = 40;
266 pub const RECVRTHDRDSTOPTS = 41;
267 pub const USE_MIN_MTU = 42;
268 pub const RECVPATHMTU = 43;
269 pub const PATHMTU = 44;
270 pub const PKTINFO = 46;
271 pub const HOPLIMIT = 47;
272 pub const NEXTHOP = 48;
273 pub const HOPOPTS = 49;
274 pub const DSTOPTS = 50;
275 pub const RTHDR = 51;
276 pub const RECVTCLASS = 57;
277 pub const OTCLASS = 58;
278 pub const TCLASS = 61;
279 pub const DONTFRAG = 62;
280 pub const PREFER_TEMPADDR = 63;
281 pub const BINDANY = 64;
282 pub const RTHDR_LOOSE = 0;
283 pub const RTHDR_STRICT = 1;
284 pub const RTHDR_TYPE_0 = 0;
285 pub const DEFAULT_MULTICAST_HOPS = 1;
286 pub const DEFAULT_MULTICAST_LOOP = 1;
287 pub const PORTRANGE_DEFAULT = 0;
288 pub const PORTRANGE_HIGH = 1;
289 pub const PORTRANGE_LOW = 2;
290};
291
292// https://github.com/NetBSD/src/blob/80bf25a5691072d4755e84567ccbdf0729370dea/sys/netinet/ip.h#L140
293pub const IPTOS = struct {
294 pub const DSCP_CS0 = 0x00;
295 pub const DSCP_CS1 = 0x20;
296 pub const DSCP_AF11 = 0x28;
297 pub const DSCP_AF12 = 0x30;
298 pub const DSCP_AF13 = 0x38;
299 pub const DSCP_CS2 = 0x40;
300 pub const DSCP_AF21 = 0x48;
301 pub const DSCP_AF22 = 0x50;
302 pub const DSCP_AF23 = 0x58;
303 pub const DSCP_CS3 = 0x60;
304 pub const DSCP_AF31 = 0x68;
305 pub const DSCP_AF32 = 0x70;
306 pub const DSCP_AF33 = 0x78;
307 pub const DSCP_CS4 = 0x80;
308 pub const DSCP_AF41 = 0x88;
309 pub const DSCP_AF42 = 0x90;
310 pub const DSCP_AF43 = 0x98;
311 pub const DSCP_CS5 = 0xa0;
312 pub const DSCP_EF = 0xb8;
313 pub const DSCP_CS6 = 0xc0;
314 pub const DSCP_CS7 = 0xe0;
315 pub const CLASS_CS0 = 0x00;
316 pub const CLASS_CS1 = 0x20;
317 pub const CLASS_CS2 = 0x40;
318 pub const CLASS_CS3 = 0x60;
319 pub const CLASS_CS4 = 0x80;
320 pub const CLASS_CS5 = 0xa0;
321 pub const CLASS_CS6 = 0xc0;
322 pub const CLASS_CS7 = 0xe0;
323 pub const CLASS_DEFAULT = CLASS_CS0;
324 pub const CLASS_MASK = 0xe0;
325 pub fn CLASS(t: anytype) @TypeOf(t) {
326 return t & CLASS_MASK;
327 }
328 pub const DSCP_MASK = 0xfc;
329 pub fn DSCP(t: anytype) @TypeOf(t) {
330 return t & DSCP_MASK;
331 }
332 pub const ECN_NOTECT = 0x00;
333 pub const ECN_ECT1 = 0x01;
334 pub const ECN_ECT0 = 0x02;
335 pub const ECN_CE = 0x03;
336 pub const ECN_MASK = 0x03;
337 pub fn ECN(t: anytype) @TypeOf(t) {
338 return t & ECN_MASK;
339 }
340 pub const ECN_NOT_ECT = 0x00;
341 pub const LOWDELAY = 0x10;
342 pub const THROUGHPUT = 0x08;
343 pub const RELIABILITY = 0x04;
344 pub const MINCOST = 0x02;
345 pub const CE = 0x01;
346 pub const ECT = 0x02;
347 pub const PREC_NETCONTROL = 0xe0;
348 pub const PREC_INTERNETCONTROL = 0xc0;
349 pub const PREC_CRITIC_ECP = 0xa0;
350 pub const PREC_FLASHOVERRIDE = 0x80;
351 pub const PREC_FLASH = 0x60;
352 pub const PREC_IMMEDIATE = 0x40;
353 pub const PREC_PRIORITY = 0x20;
354 pub const PREC_ROUTINE = 0x00;
355};
lib/std/c/openbsd.zig+136
......@@ -351,3 +351,139 @@ pub const PTHREAD_STACK_MIN = switch (builtin.cpu.arch) {
351351 .mips64 => 1 << 14,
352352 else => 1 << 12,
353353};
354
355// https://github.com/openbsd/src/blob/718a31b40d39fc6064de6355eb144e74633133fc/sys/netinet/in.h#L283
356pub const IP = struct {
357 pub const OPTIONS = 1;
358 pub const HDRINCL = 2;
359 pub const TOS = 3;
360 pub const TTL = 4;
361 pub const RECVOPTS = 5;
362 pub const RECVRETOPTS = 6;
363 pub const RECVDSTADDR = 7;
364 pub const RETOPTS = 8;
365 pub const MULTICAST_IF = 9;
366 pub const MULTICAST_TTL = 10;
367 pub const MULTICAST_LOOP = 11;
368 pub const ADD_MEMBERSHIP = 12;
369 pub const DROP_MEMBERSHIP = 13;
370 pub const PORTRANGE = 19;
371 pub const AUTH_LEVEL = 20;
372 pub const ESP_TRANS_LEVEL = 21;
373 pub const ESP_NETWORK_LEVEL = 22;
374 pub const IPSEC_LOCAL_ID = 23;
375 pub const IPSEC_REMOTE_ID = 24;
376 pub const IPSEC_LOCAL_CRED = 25;
377 pub const IPSEC_REMOTE_CRED = 26;
378 pub const IPSEC_LOCAL_AUTH = 27;
379 pub const IPSEC_REMOTE_AUTH = 28;
380 pub const IPCOMP_LEVEL = 29;
381 pub const RECVIF = 30;
382 pub const RECVTTL = 31;
383 pub const MINTTL = 32;
384 pub const RECVDSTPORT = 33;
385 pub const PIPEX = 34;
386 pub const RECVRTABLE = 35;
387 pub const IPSECFLOWINFO = 36;
388 pub const IPDEFTTL = 37;
389 pub const SENDSRCADDR = RECVDSTADDR;
390 pub const RTABLE = 0x1021;
391 pub const DEFAULT_MULTICAST_TTL = 1;
392 pub const DEFAULT_MULTICAST_LOOP = 1;
393 pub const MIN_MEMBERSHIPS = 15;
394 pub const MAX_MEMBERSHIPS = 4095;
395 pub const PORTRANGE_DEFAULT = 0;
396 pub const PORTRANGE_HIGH = 1;
397 pub const PORTRANGE_LOW = 2;
398};
399
400// https://github.com/openbsd/src/blob/718a31b40d39fc6064de6355eb144e74633133fc/sys/netinet6/in6.h#L284
401pub const IPV6 = struct {
402 pub const UNICAST_HOPS = 4;
403 pub const MULTICAST_IF = 9;
404 pub const MULTICAST_HOPS = 10;
405 pub const MULTICAST_LOOP = 11;
406 pub const JOIN_GROUP = 12;
407 pub const LEAVE_GROUP = 13;
408 pub const PORTRANGE = 14;
409 pub const CHECKSUM = 26;
410 pub const V6ONLY = 27;
411 pub const RTHDRDSTOPTS = 35;
412 pub const RECVPKTINFO = 36;
413 pub const RECVHOPLIMIT = 37;
414 pub const RECVRTHDR = 38;
415 pub const RECVHOPOPTS = 39;
416 pub const RECVDSTOPTS = 40;
417 pub const USE_MIN_MTU = 42;
418 pub const RECVPATHMTU = 43;
419 pub const PATHMTU = 44;
420 pub const PKTINFO = 46;
421 pub const HOPLIMIT = 47;
422 pub const NEXTHOP = 48;
423 pub const HOPOPTS = 49;
424 pub const DSTOPTS = 50;
425 pub const RTHDR = 51;
426 pub const AUTH_LEVEL = 53;
427 pub const ESP_TRANS_LEVEL = 54;
428 pub const ESP_NETWORK_LEVEL = 55;
429 pub const RECVTCLASS = 57;
430 pub const AUTOFLOWLABEL = 59;
431 pub const IPCOMP_LEVEL = 60;
432 pub const TCLASS = 61;
433 pub const DONTFRAG = 62;
434 pub const PIPEX = 63;
435 pub const RECVDSTPORT = 64;
436 pub const MINHOPCOUNT = 65;
437 pub const RTABLE = 0x1021;
438 pub const RTHDR_LOOSE = 0;
439 pub const RTHDR_TYPE_0 = 0;
440 pub const DEFAULT_MULTICAST_HOPS = 1;
441 pub const DEFAULT_MULTICAST_LOOP = 1;
442 pub const PORTRANGE_DEFAULT = 0;
443 pub const PORTRANGE_HIGH = 1;
444 pub const PORTRANGE_LOW = 2;
445};
446
447// https://github.com/openbsd/src/blob/718a31b40d39fc6064de6355eb144e74633133fc/sys/netinet/ip.h#L73
448pub const IPTOS = struct {
449 pub const LOWDELAY = 0x10;
450 pub const THROUGHPUT = 0x08;
451 pub const RELIABILITY = 0x04;
452 pub const CE = 0x01;
453 pub const ECT = 0x02;
454 pub const PREC_NETCONTROL = 0xe0;
455 pub const PREC_INTERNETCONTROL = 0xc0;
456 pub const PREC_CRITIC_ECP = 0xa0;
457 pub const PREC_FLASHOVERRIDE = 0x80;
458 pub const PREC_FLASH = 0x60;
459 pub const PREC_IMMEDIATE = 0x40;
460 pub const PREC_PRIORITY = 0x20;
461 pub const PREC_ROUTINE = 0x00;
462 pub const DSCP_CS0 = 0x00;
463 pub const DSCP_LE = 0x04;
464 pub const DSCP_CS1 = 0x20;
465 pub const DSCP_AF11 = 0x28;
466 pub const DSCP_AF12 = 0x30;
467 pub const DSCP_AF13 = 0x38;
468 pub const DSCP_CS2 = 0x40;
469 pub const DSCP_AF21 = 0x48;
470 pub const DSCP_AF22 = 0x50;
471 pub const DSCP_AF23 = 0x58;
472 pub const DSCP_CS3 = 0x60;
473 pub const DSCP_AF31 = 0x68;
474 pub const DSCP_AF32 = 0x70;
475 pub const DSCP_AF33 = 0x78;
476 pub const DSCP_CS4 = 0x80;
477 pub const DSCP_AF41 = 0x88;
478 pub const DSCP_AF42 = 0x90;
479 pub const DSCP_AF43 = 0x98;
480 pub const DSCP_CS5 = 0xa0;
481 pub const DSCP_EF = 0xb8;
482 pub const DSCP_CS6 = 0xc0;
483 pub const DSCP_CS7 = 0xe0;
484 pub const ECN_NOTECT = 0x00;
485 pub const ECN_ECT1 = 0x01;
486 pub const ECN_ECT0 = 0x02;
487 pub const ECN_CE = 0x03;
488 pub const ECN_MASK = 0x03;
489};
lib/std/c/serenity.zig+40
......@@ -71,3 +71,43 @@ pub extern "c" fn serenity_open(path: [*]const u8, path_length: usize, options:
7171
7272pub 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;
7373pub 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;
74
75// https://github.com/SerenityOS/serenity/blob/5bd8af99be0bc4b2e14f361fd7d7590e6bcfa4d6/Kernel/API/POSIX/netinet/in.h#L29
76pub const IP = struct {
77 pub const TOS = 1;
78 pub const TTL = 2;
79 pub const MULTICAST_LOOP = 3;
80 pub const ADD_MEMBERSHIP = 4;
81 pub const DROP_MEMBERSHIP = 5;
82 pub const MULTICAST_IF = 6;
83 pub const MULTICAST_TTL = 7;
84 pub const BLOCK_SOURCE = 8;
85 pub const ADD_SOURCE_MEMBERSHIP = 7;
86 pub const DROP_SOURCE_MEMBERSHIP = 8;
87 pub const UNBLOCK_SOURCE = 9;
88 pub const OPTIONS = 10;
89};
90
91// https://github.com/SerenityOS/serenity/blob/5bd8af99be0bc4b2e14f361fd7d7590e6bcfa4d6/Kernel/API/POSIX/netinet/in.h#L81
92pub const IPV6 = struct {
93 pub const UNICAST_HOPS = 1;
94 pub const MULTICAST_HOPS = 2;
95 pub const MULTICAST_LOOP = 3;
96 pub const MULTICAST_IF = 4;
97 pub const ADD_MEMBERSHIP = 5;
98 pub const DROP_MEMBERSHIP = 6;
99 pub const V6ONLY = 9;
100 pub const JOIN_GROUP = 5;
101 pub const LEAVE_GROUP = 6;
102 pub const RECVPKTINFO = 10;
103 pub const PKTINFO = 11;
104 pub const RECVHOPLIMIT = 12;
105 pub const HOPLIMIT = 13;
106};
107
108// https://github.com/SerenityOS/serenity/blob/5bd8af99be0bc4b2e14f361fd7d7590e6bcfa4d6/Kernel/API/POSIX/netinet/in.h#L40
109pub const IPTOS = struct {
110 pub const LOWDELAY = 16;
111 pub const THROUGHPUT = 8;
112 pub const RELIABILITY = 4;
113};
lib/std/c/solaris.zig+115
......@@ -363,3 +363,118 @@ pub fn IOW(io_type: u8, nr: u8, comptime IOT: type) i32 {
363363pub fn IOWR(io_type: u8, nr: u8, comptime IOT: type) i32 {
364364 return ioImpl(.read_write, io_type, nr, IOT);
365365}
366
367// https://github.com/illumos/illumos-gate/blob/608eb926e14f4ba4736b2d59e891335f1cba9e1e/usr/src/uts/common/netinet/in.h#L1141
368// (old OpenSolaris is very similar, it's just missing a few more-modern ones, and probably modern Solaris has those)
369pub const IP = struct {
370 pub const OPTIONS = 1;
371 pub const HDRINCL = 2;
372 pub const TOS = 3;
373 pub const TTL = 4;
374 pub const RECVOPTS = 0x5;
375 pub const RECVRETOPTS = 0x6;
376 pub const RECVDSTADDR = 0x7;
377 pub const RETOPTS = 0x8;
378 pub const RECVIF = 0x9;
379 pub const RECVSLLA = 0xa;
380 pub const RECVTTL = 0xb;
381 pub const RECVTOS = 0xc;
382 pub const MULTICAST_IF = 0x10;
383 pub const MULTICAST_TTL = 0x11;
384 pub const MULTICAST_LOOP = 0x12;
385 pub const ADD_MEMBERSHIP = 0x13;
386 pub const DROP_MEMBERSHIP = 0x14;
387 pub const BLOCK_SOURCE = 0x15;
388 pub const UNBLOCK_SOURCE = 0x16;
389 pub const ADD_SOURCE_MEMBERSHIP = 0x17;
390 pub const DROP_SOURCE_MEMBERSHIP = 0x18;
391 pub const NEXTHOP = 0x19;
392 pub const PKTINFO = 0x1a;
393 pub const RECVPKTINFO = 0x1a;
394 pub const DONTFRAG = 0x1b;
395 pub const MINTTL = 0x1c;
396 pub const SEC_OPT = 0x22;
397 pub const BOUND_IF = 0x41;
398 pub const UNSPEC_SRC = 0x42;
399 pub const BROADCAST_TTL = 0x43;
400 pub const DHCPINIT_IF = 0x45;
401 pub const REUSEADDR = 0x104;
402 pub const DONTROUTE = 0x105;
403 pub const BROADCAST = 0x106;
404 // Same namespace, but these are arguments rather than option names
405 pub const DEFAULT_MULTICAST_TTL = 1;
406 pub const DEFAULT_MULTICAST_LOOP = 1;
407};
408
409// https://github.com/illumos/illumos-gate/blob/608eb926e14f4ba4736b2d59e891335f1cba9e1e/usr/src/uts/common/netinet/in.h#L1192
410// (old OpenSolaris is very similar, it's just missing a few more-modern ones, and probably modern Solaris has those)
411pub const IPV6 = struct {
412 pub const UNICAST_HOPS = 0x5;
413 pub const MULTICAST_IF = 0x6;
414 pub const MULTICAST_HOPS = 0x7;
415 pub const MULTICAST_LOOP = 0x8;
416 pub const JOIN_GROUP = 0x9;
417 pub const LEAVE_GROUP = 0xa;
418 pub const ADD_MEMBERSHIP = 0x9;
419 pub const DROP_MEMBERSHIP = 0xa;
420 pub const PKTINFO = 0xb;
421 pub const HOPLIMIT = 0xc;
422 pub const NEXTHOP = 0xd;
423 pub const HOPOPTS = 0xe;
424 pub const DSTOPTS = 0xf;
425 pub const RTHDR = 0x10;
426 pub const RTHDRDSTOPTS = 0x11;
427 pub const RECVPKTINFO = 0x12;
428 pub const RECVHOPLIMIT = 0x13;
429 pub const RECVHOPOPTS = 0x14;
430 pub const OLD_RECVDSTOPTS = 0x15;
431 pub const RECVRTHDR = 0x16;
432 pub const RECVRTHDRDSTOPTS = 0x17;
433 pub const CHECKSUM = 0x18;
434 pub const RECVTCLASS = 0x19;
435 pub const USE_MIN_MTU = 0x20;
436 pub const DONTFRAG = 0x21;
437 pub const SEC_OPT = 0x22;
438 pub const SRC_PREFERENCES = 0x23;
439 pub const RECVPATHMTU = 0x24;
440 pub const PATHMTU = 0x25;
441 pub const TCLASS = 0x26;
442 pub const V6ONLY = 0x27;
443 pub const RECVDSTOPTS = 0x28;
444 pub const MINHOPCOUNT = 0x2f;
445 pub const BOUND_IF = 0x41;
446 pub const UNSPEC_SRC = 0x42;
447 // Same namespace, but these are arguments rather than option names
448 pub const RTHDR_TYPE_0 = 0;
449 pub const PREFER_SRC_HOME = 0x01;
450 pub const PREFER_SRC_COA = 0x02;
451 pub const PREFER_SRC_PUBLIC = 0x04;
452 pub const PREFER_SRC_TMP = 0x08;
453 pub const PREFER_SRC_NONCGA = 0x10;
454 pub const PREFER_SRC_CGA = 0x20;
455 pub const PREFER_SRC_MIPMASK = PREFER_SRC_HOME | PREFER_SRC_COA;
456 pub const PREFER_SRC_MIPDEFAULT = PREFER_SRC_HOME;
457 pub const PREFER_SRC_TMPMASK = PREFER_SRC_PUBLIC | PREFER_SRC_TMP;
458 pub const PREFER_SRC_TMPDEFAULT = PREFER_SRC_PUBLIC;
459 pub const PREFER_SRC_CGAMASK = PREFER_SRC_NONCGA | PREFER_SRC_CGA;
460 pub const PREFER_SRC_CGADEFAULT = PREFER_SRC_NONCGA;
461 pub const PREFER_SRC_MASK = PREFER_SRC_MIPMASK | PREFER_SRC_TMPMASK | PREFER_SRC_CGAMASK;
462 pub const PREFER_SRC_DEFAULT = PREFER_SRC_MIPDEFAULT | PREFER_SRC_TMPDEFAULT | PREFER_SRC_CGADEFAULT;
463};
464
465// https://github.com/illumos/illumos-gate/blob/608eb926e14f4ba4736b2d59e891335f1cba9e1e/usr/src/uts/common/netinet/ip.h#L64
466pub const IPTOS = struct {
467 pub const LOWDELAY = 0x10;
468 pub const THROUGHPUT = 0x08;
469 pub const RELIABILITY = 0x04;
470 pub const ECT = 0x02;
471 pub const CE = 0x01;
472 pub const PREC_NETCONTROL = 0xe0;
473 pub const PREC_INTERNETCONTROL = 0xc0;
474 pub const PREC_CRITIC_ECP = 0xa0;
475 pub const PREC_FLASHOVERRIDE = 0x80;
476 pub const PREC_FLASH = 0x60;
477 pub const PREC_IMMEDIATE = 0x40;
478 pub const PREC_PRIORITY = 0x20;
479 pub const PREC_ROUTINE = 0x00;
480};
lib/std/os/linux.zig+27
......@@ -4524,6 +4524,33 @@ pub const IPV6 = struct {
45244524 pub const FREEBIND = 78;
45254525};
45264526
4527// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/ip.h?id=64e844505bc08cde3f346f193cbbbab0096fef54#n24
4528pub const IPTOS = struct {
4529 pub const TOS_MASK = 0x1e;
4530 pub fn TOS(t: anytype) @TypeOf(t) {
4531 return t & TOS_MASK;
4532 }
4533
4534 pub const MINCOST = 0x02;
4535 pub const RELIABILITY = 0x04;
4536 pub const THROUGHPUT = 0x08;
4537 pub const LOWDELAY = 0x10;
4538
4539 pub const PREC_MASK = 0xe0;
4540 pub fn PREC(t: anytype) @TypeOf(t) {
4541 return t & PREC_MASK;
4542 }
4543
4544 pub const PREC_ROUTINE = 0x00;
4545 pub const PREC_PRIORITY = 0x20;
4546 pub const PREC_IMMEDIATE = 0x40;
4547 pub const PREC_FLASH = 0x60;
4548 pub const PREC_FLASHOVERRIDE = 0x80;
4549 pub const PREC_CRITIC_ECP = 0xa0;
4550 pub const PREC_INTERNETCONTROL = 0xc0;
4551 pub const PREC_NETCONTROL = 0xe0;
4552};
4553
45274554// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/socket.h?id=b1e904999542ad6764eafa54545f1c55776006d1#n43
45284555pub const linger = extern struct {
45294556 onoff: i32, // non-zero to linger on close
lib/std/posix.zig+3
......@@ -75,7 +75,10 @@ pub const HOST_NAME_MAX = system.HOST_NAME_MAX;
7575pub const HW = system.HW;
7676pub const IFNAMESIZE = system.IFNAMESIZE;
7777pub const IOV_MAX = system.IOV_MAX;
78pub const IP = system.IP;
79pub const IPV6 = system.IPV6;
7880pub const IPPROTO = system.IPPROTO;
81pub const IPTOS = system.IPTOS;
7982pub const KERN = system.KERN;
8083pub const Kevent = system.Kevent;
8184pub const MADV = system.MADV;