Merge pull request #25195 from blblack/netdefs

std: Add several sockopt-related constants and structs
This commit is contained in:
Andrew Kelley 2025-09-17 21:43:23 -07:00 committed by GitHub
commit d6b4e1918b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 1222 additions and 8 deletions

View file

@ -3991,6 +3991,17 @@ pub const W = switch (native_os) {
}, },
else => void, else => void,
}; };
pub const accept_filter_arg = switch (native_os) {
// https://github.com/freebsd/freebsd-src/blob/2024887abc7d1b931e00fbb0697658e98adf048d/sys/sys/socket.h#L205
// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/sys/socket.h#L164
// https://github.com/NetBSD/src/blob/cad5c68a8524927f65e22ad651de3905382be6e0/sys/sys/socket.h#L188
// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/socket.h#L504
.freebsd, .dragonfly, .netbsd, .macos, .driverkit, .ios, .tvos, .watchos, .visionos => extern struct {
name: [16]u8,
arg: [240]u8,
},
else => void,
};
pub const clock_t = switch (native_os) { pub const clock_t = switch (native_os) {
.linux => linux.clock_t, .linux => linux.clock_t,
.emscripten => emscripten.clock_t, .emscripten => emscripten.clock_t,
@ -4076,6 +4087,35 @@ pub const ifreq = switch (native_os) {
}, },
else => void, else => void,
}; };
pub const in_pktinfo = switch (native_os) {
.linux => linux.in_pktinfo,
// https://github.com/kofemann/opensolaris/blob/80192cd83bf665e708269dae856f9145f7190f74/usr/src/uts/common/netinet/in.h#L1084
// https://github.com/illumos/illumos-gate/blob/608eb926e14f4ba4736b2d59e891335f1cba9e1e/usr/src/uts/common/netinet/in.h#L1132
// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/netinet/in.h#L696
.solaris, .illumos, .driverkit, .ios, .macos, .tvos, .watchos, .visionos => extern struct {
ifindex: u32,
spec_dst: u32,
addr: u32,
},
else => void,
};
pub const in6_pktinfo = switch (native_os) {
.linux => linux.in6_pktinfo,
// https://github.com/freebsd/freebsd-src/blob/9bfbc6826f72eb385bf52f4cde8080bccf7e3ebd/sys/netinet6/in6.h#L547
// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/netinet6/in6.h#L575
// https://github.com/NetBSD/src/blob/80bf25a5691072d4755e84567ccbdf0729370dea/sys/netinet6/in6.h#L468
// https://github.com/openbsd/src/blob/718a31b40d39fc6064de6355eb144e74633133fc/sys/netinet6/in6.h#L365
// https://github.com/kofemann/opensolaris/blob/80192cd83bf665e708269dae856f9145f7190f74/usr/src/uts/common/netinet/in.h#L1093
// https://github.com/illumos/illumos-gate/blob/608eb926e14f4ba4736b2d59e891335f1cba9e1e/usr/src/uts/common/netinet/in.h#L114IP1
// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/netinet6/in6.h#L737
// https://github.com/haiku/haiku/blob/2aab5f5f14aeb3f34c3a3d9a9064cc3c0d914bea/headers/posix/netinet6/in6.h#L63
// https://github.com/SerenityOS/serenity/blob/5bd8af99be0bc4b2e14f361fd7d7590e6bcfa4d6/Kernel/API/POSIX/sys/socket.h#L122
.freebsd, .dragonfly, .netbsd, .openbsd, .solaris, .illumos, .driverkit, .ios, .macos, .tvos, .watchos, .visionos, .haiku, .serenity => extern struct {
addr: [16]u8,
ifindex: u32,
},
else => void,
};
pub const itimerspec = switch (native_os) { pub const itimerspec = switch (native_os) {
.linux => linux.itimerspec, .linux => linux.itimerspec,
.haiku => extern struct { .haiku => extern struct {
@ -4084,6 +4124,37 @@ pub const itimerspec = switch (native_os) {
}, },
else => void, else => void,
}; };
pub const linger = switch (native_os) {
.linux => linux.linger,
// https://github.com/freebsd/freebsd-src/blob/46347b3619757e3d683a87ca03efaf2ae242335f/sys/sys/socket.h#L200
.freebsd,
// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/sys/socket.h#L158
.dragonfly,
// https://github.com/NetBSD/src/blob/80bf25a5691072d4755e84567ccbdf0729370dea/sys/sys/socket.h#L183
.netbsd,
// https://github.com/openbsd/src/blob/718a31b40d39fc6064de6355eb144e74633133fc/sys/sys/socket.h#L126
.openbsd,
// https://github.com/kofemann/opensolaris/blob/80192cd83bf665e708269dae856f9145f7190f74/usr/src/uts/common/sys/socket.h#L214
.solaris,
// https://github.com/illumos/illumos-gate/blob/608eb926e14f4ba4736b2d59e891335f1cba9e1e/usr/src/uts/common/sys/socket.h#L250
.illumos,
// https://github.com/haiku/haiku/blob/2aab5f5f14aeb3f34c3a3d9a9064cc3c0d914bea/headers/posix/sys/socket.h#L87
.haiku,
// https://github.com/SerenityOS/serenity/blob/5bd8af99be0bc4b2e14f361fd7d7590e6bcfa4d6/Kernel/API/POSIX/sys/socket.h#L122
.serenity,
// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/socket.h#L498
.driverkit,
.ios,
.macos,
.tvos,
.watchos,
.visionos,
=> extern struct {
onoff: i32, // non-zero to linger on close
linger: i32, // time to linger in seconds
},
else => void,
};
pub const msghdr = switch (native_os) { pub const msghdr = switch (native_os) {
.linux => linux.msghdr, .linux => linux.msghdr,
.openbsd, .openbsd,
@ -6388,7 +6459,7 @@ pub const IPPROTO = switch (native_os) {
/// dummy for IP /// dummy for IP
pub const IP = 0; pub const IP = 0;
/// IP6 hop-by-hop options /// IP6 hop-by-hop options
pub const HOPOPTS = IP; pub const HOPOPTS = IPPROTO.IP;
/// control message protocol /// control message protocol
pub const ICMP = 1; pub const ICMP = 1;
/// group mgmt protocol /// group mgmt protocol
@ -6470,6 +6541,39 @@ pub const IPPROTO = switch (native_os) {
}, },
else => void, 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) { pub const SOL = switch (native_os) {
.linux => linux.SOL, .linux => linux.SOL,
.emscripten => emscripten.SOL, .emscripten => emscripten.SOL,
@ -6741,6 +6845,62 @@ pub const SOMAXCONN = switch (native_os) {
.freebsd, .dragonfly, .netbsd, .openbsd, .driverkit, .macos, .ios, .tvos, .watchos, .visionos => 128, .freebsd, .dragonfly, .netbsd, .openbsd, .driverkit, .macos, .ios, .tvos, .watchos, .visionos => 128,
else => void, else => void,
}; };
pub const SCM = switch (native_os) {
.linux, .emscripten => linux.SCM,
// https://github.com/kofemann/opensolaris/blob/80192cd83bf665e708269dae856f9145f7190f74/usr/src/uts/common/sys/socket.h#L172
// https://github.com/illumos/illumos-gate/blob/489f6310fe8952e87fc1dce8af87990fcfd90f18/usr/src/uts/common/sys/socket.h#L196
.solaris, .illumos => struct {
pub const RIGHTS = 0x1010;
pub const UCRED = 0x1012;
pub const TIMESTAMP = SO.TIMESTAMP;
},
// https://github.com/haiku/haiku/blob/e3d01e53a25446d5ba4999d0ff6dff29a2418657/headers/posix/sys/socket.h#L156
.haiku => struct {
pub const RIGHTS = 1;
},
// https://github.com/SerenityOS/serenity/blob/c6618f36bf0949bd76177f202659b1f3079e0792/Kernel/API/POSIX/sys/socket.h#L171
.serenity => struct {
pub const TIMESTAMP = 0;
pub const RIGHTS = 1;
},
// https://github.com/freebsd/freebsd-src/blob/614e9b33bf5594d9d09b5d296afa4f3aa6971823/sys/sys/socket.h#L593
.freebsd => struct {
pub const RIGHTS = 1;
pub const TIMESTAMP = 2;
pub const CREDS = 3;
pub const BINTIME = 4;
pub const REALTIME = 5;
pub const MONOTONIC = 6;
pub const TIME_INFO = 7;
pub const CREDS2 = 8;
},
// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/sys/socket.h#L520
.dragonfly => struct {
pub const RIGHTS = 1;
pub const TIMESTAMP = 2;
pub const CREDS = 3;
},
// https://github.com/NetBSD/src/blob/3311177ea898ab8322292ba0e48faa9b2e834cb6/sys/sys/socket.h#L578
.netbsd => struct {
pub const RIGHTS = 0x01;
pub const TIMESTAMP = 0x08;
pub const CREDS = 0x10;
},
// https://github.com/openbsd/src/blob/1b1dd04c9634112eb763374379af99a68ace4328/sys/sys/socket.h#L566
.openbsd => struct {
pub const RIGHTS = 0x01;
pub const TIMESTAMP = 0x04;
},
// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/socket.h#L1114
.driverkit, .macos, .ios, .tvos, .watchos, .visionos => struct {
pub const RIGHTS = 1;
pub const TIMESTAMP = 2;
pub const CREDS = 3;
pub const TIMESTAMP_MONOTONIC = 4;
},
else => void,
};
pub const IFNAMESIZE = switch (native_os) { pub const IFNAMESIZE = switch (native_os) {
.linux => linux.IFNAMESIZE, .linux => linux.IFNAMESIZE,
.emscripten => emscripten.IFNAMESIZE, .emscripten => emscripten.IFNAMESIZE,
@ -11064,7 +11224,6 @@ pub const GETUSTACK = solaris.GETUSTACK;
pub const PORT_ALERT = solaris.PORT_ALERT; pub const PORT_ALERT = solaris.PORT_ALERT;
pub const PORT_SOURCE = solaris.PORT_SOURCE; pub const PORT_SOURCE = solaris.PORT_SOURCE;
pub const POSIX_FADV = solaris.POSIX_FADV; pub const POSIX_FADV = solaris.POSIX_FADV;
pub const SCM = solaris.SCM;
pub const SETCONTEXT = solaris.SETCONTEXT; pub const SETCONTEXT = solaris.SETCONTEXT;
pub const SETUSTACK = solaris.GETUSTACK; pub const SETUSTACK = solaris.GETUSTACK;
pub const SFD = solaris.SFD; pub const SFD = solaris.SFD;

View file

@ -1723,3 +1723,165 @@ pub const MSG = struct {
/// Inherit upcall in sock_accept /// Inherit upcall in sock_accept
pub const USEUPCALL = 0x80000000; 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;
};

View file

@ -184,3 +184,161 @@ pub const POSIX_MADV_RANDOM = 1;
pub const POSIX_MADV_DONTNEED = 4; pub const POSIX_MADV_DONTNEED = 4;
pub const POSIX_MADV_NORMAL = 0; pub const POSIX_MADV_NORMAL = 0;
pub const POSIX_MADV_WILLNEED = 3; 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;
};

View file

@ -394,3 +394,195 @@ pub const E = enum(u16) {
INTEGRITY = 97, // Integrity check failed 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;
};

View file

@ -553,3 +553,50 @@ pub const DirEnt = extern struct {
return @ptrCast(&dirent.name); 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;
};

View file

@ -203,3 +203,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;
};

View file

@ -354,3 +354,139 @@ pub const PTHREAD_STACK_MIN = switch (builtin.cpu.arch) {
.mips64 => 1 << 14, .mips64 => 1 << 14,
else => 1 << 12, 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;
};

View file

@ -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 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; 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;
};

View file

@ -31,12 +31,6 @@ pub const poolid_t = id_t;
pub const zoneid_t = id_t; pub const zoneid_t = id_t;
pub const ctid_t = id_t; pub const ctid_t = id_t;
pub const SCM = struct {
pub const UCRED = 0x1012;
pub const RIGHTS = 0x1010;
pub const TIMESTAMP = SO.TIMESTAMP;
};
pub const fpregset_t = extern union { pub const fpregset_t = extern union {
regs: [130]u32, regs: [130]u32,
chip_state: extern struct { chip_state: extern struct {
@ -369,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 { pub fn IOWR(io_type: u8, nr: u8, comptime IOT: type) i32 {
return ioImpl(.read_write, io_type, nr, IOT); 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;
};

View file

@ -4338,6 +4338,12 @@ pub const SO = if (is_mips) struct {
}; };
pub const SCM = struct { pub const SCM = struct {
// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/socket.h?id=f777d1112ee597d7f7dd3ca232220873a34ad0c8#n178
pub const RIGHTS = 1;
pub const CREDENTIALS = 2;
pub const SECURITY = 3;
pub const PIDFD = 4;
pub const WIFI_STATUS = SO.WIFI_STATUS; pub const WIFI_STATUS = SO.WIFI_STATUS;
pub const TIMESTAMPING_OPT_STATS = 54; pub const TIMESTAMPING_OPT_STATS = 54;
pub const TIMESTAMPING_PKTINFO = 58; pub const TIMESTAMPING_PKTINFO = 58;
@ -4521,6 +4527,52 @@ pub const IPV6 = struct {
pub const FREEBIND = 78; 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
linger: i32, // time to linger in seconds
};
// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/in.h?id=64e844505bc08cde3f346f193cbbbab0096fef54#n250
pub const in_pktinfo = extern struct {
ifindex: i32,
spec_dst: u32,
addr: u32,
};
// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/ipv6.h?id=f24987ef6959a7efaf79bffd265522c3df18d431#n22
pub const in6_pktinfo = extern struct {
addr: [16]u8,
ifindex: i32,
};
/// IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble /// IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
/// and FCS/CRC (frame check sequence). /// and FCS/CRC (frame check sequence).
pub const ETH = struct { pub const ETH = struct {

View file

@ -75,7 +75,10 @@ pub const HOST_NAME_MAX = system.HOST_NAME_MAX;
pub const HW = system.HW; pub const HW = system.HW;
pub const IFNAMESIZE = system.IFNAMESIZE; pub const IFNAMESIZE = system.IFNAMESIZE;
pub const IOV_MAX = system.IOV_MAX; pub const IOV_MAX = system.IOV_MAX;
pub const IP = system.IP;
pub const IPV6 = system.IPV6;
pub const IPPROTO = system.IPPROTO; pub const IPPROTO = system.IPPROTO;
pub const IPTOS = system.IPTOS;
pub const KERN = system.KERN; pub const KERN = system.KERN;
pub const Kevent = system.Kevent; pub const Kevent = system.Kevent;
pub const MADV = system.MADV; pub const MADV = system.MADV;
@ -101,6 +104,7 @@ pub const RR = system.RR;
pub const S = system.S; pub const S = system.S;
pub const SA = system.SA; pub const SA = system.SA;
pub const SC = system.SC; pub const SC = system.SC;
pub const SCM = system.SCM;
pub const SEEK = system.SEEK; pub const SEEK = system.SEEK;
pub const SHUT = system.SHUT; pub const SHUT = system.SHUT;
pub const SIG = system.SIG; pub const SIG = system.SIG;
@ -133,7 +137,10 @@ pub const fd_t = system.fd_t;
pub const file_obj = system.file_obj; pub const file_obj = system.file_obj;
pub const gid_t = system.gid_t; pub const gid_t = system.gid_t;
pub const ifreq = system.ifreq; pub const ifreq = system.ifreq;
pub const in_pktinfo = system.in_pktinfo;
pub const in6_pktinfo = system.in6_pktinfo;
pub const ino_t = system.ino_t; pub const ino_t = system.ino_t;
pub const linger = system.linger;
pub const mcontext_t = system.mcontext_t; pub const mcontext_t = system.mcontext_t;
pub const mode_t = system.mode_t; pub const mode_t = system.mode_t;
pub const msghdr = system.msghdr; pub const msghdr = system.msghdr;