跳转到内容
标准库Zig 0.17.0官方原文
源码std/c/netbsd.zig

第 1 行

std.c.netbsd.___lwp_park60

函数

第 18 行

pub extern "c" fn ___lwp_park60( clock_id: clockid_t, flags: packed struct(u32) { ABSTIME: bool = false, unused: u31 = 0, }, ts: ?*timespec, unpark: lwpid_t, hint: ?*const anyopaque, unpark_hint: ?*const anyopaque, ) c_int

参数

clock_id: clockid_t
flags: packed struct(u32) {
    ABSTIME: bool = false,
    unused: u31 = 0,
}
ts: ?*timespec
unpark: lwpid_t
hint: ?*const anyopaque
unpark_hint: ?*const anyopaque

std.c.netbsd._ksiginfo

容器

第 41 行

字段

signo: std.c.SIG
code: i32
errno: i32
reason: extern union {
    rt: extern struct {
        pid: pid_t,
        uid: uid_t,
        value: sigval_t,
    },
    child: extern struct {
        pid: pid_t,
        uid: uid_t,
        status: i32,
        utime: clock_t,
        stime: clock_t,
    },
    fault: extern struct {
        addr: *allowzero anyopaque,
        trap: i32,
        trap2: i32,
        trap3: i32,
    },
    poll: extern struct {
        band: i32,
        fd: i32,
    },
    syscall: extern struct {
        sysnum: i32,
        retval: [2]i32,
        @"error": i32,
        args: [8]u64,
    },
    ptrace_state: extern struct {
        pe_report_event: i32,
        option: extern union {
            pe_other_pid: pid_t,
            pe_lwp: lwpid_t,
        },
    },
} align(@sizeOf(usize))

std.c.netbsd._lwp_self

函数

第 16 行

pub extern "c" fn _lwp_self() lwpid_t

std.c.netbsd._lwp_unpark

函数

第 30 行

pub extern "c" fn _lwp_unpark(lwp: lwpid_t, hint: ?*const anyopaque) c_int

参数

lwp: lwpid_t
hint: ?*const anyopaque

std.c.netbsd._lwp_unpark_all

函数

第 31 行

pub extern "c" fn _lwp_unpark_all(targets: [*]const lwpid_t, ntargets: usize, hint: ?*const anyopaque) c_int

参数

targets: [*]const lwpid_t
ntargets: usize
hint: ?*const anyopaque

std.c.netbsd.clock_t

别名

第 2 行

别名目标 std.c.clock_t

std.c.netbsd.clockid_t

别名

第 3 行

别名目标 std.c.clockid_t

std.c.netbsd.E

容器

第 86 行

字段

SUCCESS = 0

未发生错误。

PERM = 1
NOENT = 2
SRCH = 3
INTR = 4
IO = 5
NXIO = 6
@"2BIG" = 7
NOEXEC = 8
BADF = 9
CHILD = 10
DEADLK = 11
NOMEM = 12
ACCES = 13
FAULT = 14
NOTBLK = 15
BUSY = 16
EXIST = 17
XDEV = 18
NODEV = 19
NOTDIR = 20
ISDIR = 21
INVAL = 22
NFILE = 23
MFILE = 24
NOTTY = 25
TXTBSY = 26
FBIG = 27
NOSPC = 28
SPIPE = 29
ROFS = 30
MLINK = 31
PIPE = 32
DOM = 33
RANGE = 34
AGAIN = 35
INPROGRESS = 36
ALREADY = 37
NOTSOCK = 38
DESTADDRREQ = 39
MSGSIZE = 40
PROTOTYPE = 41
NOPROTOOPT = 42
PROTONOSUPPORT = 43
SOCKTNOSUPPORT = 44
OPNOTSUPP = 45
PFNOSUPPORT = 46
AFNOSUPPORT = 47
ADDRINUSE = 48
ADDRNOTAVAIL = 49
NETDOWN = 50
NETUNREACH = 51
NETRESET = 52
CONNABORTED = 53
CONNRESET = 54
NOBUFS = 55
ISCONN = 56
NOTCONN = 57
SHUTDOWN = 58
TOOMANYREFS = 59
TIMEDOUT = 60
CONNREFUSED = 61
LOOP = 62
NAMETOOLONG = 63
HOSTDOWN = 64
HOSTUNREACH = 65
NOTEMPTY = 66
PROCLIM = 67
USERS = 68
DQUOT = 69
STALE = 70
REMOTE = 71
BADRPC = 72
RPCMISMATCH = 73
PROGUNAVAIL = 74
PROGMISMATCH = 75
PROCUNAVAIL = 76
NOLCK = 77
NOSYS = 78
FTYPE = 79
AUTH = 80
NEEDAUTH = 81
IDRM = 82
NOMSG = 83
OVERFLOW = 84
ILSEQ = 85
NOTSUP = 86
CANCELED = 87
BADMSG = 88
NODATA = 89
NOSR = 90
NOSTR = 91
TIME = 92
NOATTR = 93
MULTIHOP = 94
NOLINK = 95
PROTO = 96
_

std.c.netbsd.IP

命名空间

第 226 行

std.c.netbsd.IP.ADD_MEMBERSHIP

常量

第 238 行

std.c.netbsd.IP.BINDANY

常量

第 249 行

std.c.netbsd.IP.DEFAULT_MULTICAST_LOOP

常量

第 252 行

std.c.netbsd.IP.DEFAULT_MULTICAST_TTL

常量

第 251 行

std.c.netbsd.IP.DROP_MEMBERSHIP

常量

第 239 行

std.c.netbsd.IP.ERRORMTU

常量

第 243 行

std.c.netbsd.IP.HDRINCL

常量

第 228 行

std.c.netbsd.IP.IPSEC_POLICY

常量

第 244 行

std.c.netbsd.IP.MAX_MEMBERSHIPS

常量

第 253 行

std.c.netbsd.IP.MINTTL

常量

第 246 行

std.c.netbsd.IP.MULTICAST_IF

常量

第 235 行

std.c.netbsd.IP.MULTICAST_LOOP

常量

第 237 行

std.c.netbsd.IP.MULTICAST_TTL

常量

第 236 行

std.c.netbsd.IP.OPTIONS

常量

第 227 行

std.c.netbsd.IP.PKTINFO

常量

第 247 行

std.c.netbsd.IP.PORTALGO

常量

第 240 行

std.c.netbsd.IP.PORTRANGE

常量

第 241 行

std.c.netbsd.IP.PORTRANGE_DEFAULT

常量

第 254 行

std.c.netbsd.IP.PORTRANGE_HIGH

常量

第 255 行

std.c.netbsd.IP.PORTRANGE_LOW

常量

第 256 行

std.c.netbsd.IP.RECVDSTADDR

常量

第 233 行

std.c.netbsd.IP.RECVIF

常量

第 242 行

std.c.netbsd.IP.RECVOPTS

常量

第 231 行

std.c.netbsd.IP.RECVPKTINFO

常量

第 248 行

std.c.netbsd.IP.RECVRETOPTS

常量

第 232 行

std.c.netbsd.IP.RECVTTL

常量

第 245 行

std.c.netbsd.IP.RETOPTS

常量

第 234 行

std.c.netbsd.IP.SENDSRCADDR

别名

第 250 行

别名目标 std.c.netbsd.IP.RECVDSTADDR

std.c.netbsd.IP.TOS

常量

第 229 行

std.c.netbsd.IP.TTL

常量

第 230 行

std.c.netbsd.IPTOS

命名空间

第 313 行

std.c.netbsd.IPTOS.CE

常量

第 365 行

std.c.netbsd.IPTOS.CLASS

函数

第 345 行

pub fn CLASS(t: anytype) @TypeOf(t)

std.c.netbsd.IPTOS.CLASS_CS0

常量

第 335 行

std.c.netbsd.IPTOS.CLASS_CS1

常量

第 336 行

std.c.netbsd.IPTOS.CLASS_CS2

常量

第 337 行

std.c.netbsd.IPTOS.CLASS_CS3

常量

第 338 行

std.c.netbsd.IPTOS.CLASS_CS4

常量

第 339 行

std.c.netbsd.IPTOS.CLASS_CS5

常量

第 340 行

std.c.netbsd.IPTOS.CLASS_CS6

常量

第 341 行

std.c.netbsd.IPTOS.CLASS_CS7

常量

第 342 行

std.c.netbsd.IPTOS.CLASS_DEFAULT

别名

第 343 行

别名目标 std.c.netbsd.IPTOS.CLASS_CS0

std.c.netbsd.IPTOS.CLASS_MASK

常量

第 344 行

std.c.netbsd.IPTOS.DSCP

函数

第 349 行

pub fn DSCP(t: anytype) @TypeOf(t)

std.c.netbsd.IPTOS.DSCP_AF11

常量

第 316 行

std.c.netbsd.IPTOS.DSCP_AF12

常量

第 317 行

std.c.netbsd.IPTOS.DSCP_AF13

常量

第 318 行

std.c.netbsd.IPTOS.DSCP_AF21

常量

第 320 行

std.c.netbsd.IPTOS.DSCP_AF22

常量

第 321 行

std.c.netbsd.IPTOS.DSCP_AF23

常量

第 322 行

std.c.netbsd.IPTOS.DSCP_AF31

常量

第 324 行

std.c.netbsd.IPTOS.DSCP_AF32

常量

第 325 行

std.c.netbsd.IPTOS.DSCP_AF33

常量

第 326 行

std.c.netbsd.IPTOS.DSCP_AF41

常量

第 328 行

std.c.netbsd.IPTOS.DSCP_AF42

常量

第 329 行

std.c.netbsd.IPTOS.DSCP_AF43

常量

第 330 行

std.c.netbsd.IPTOS.DSCP_CS0

常量

第 314 行

std.c.netbsd.IPTOS.DSCP_CS1

常量

第 315 行

std.c.netbsd.IPTOS.DSCP_CS2

常量

第 319 行

std.c.netbsd.IPTOS.DSCP_CS3

常量

第 323 行

std.c.netbsd.IPTOS.DSCP_CS4

常量

第 327 行

std.c.netbsd.IPTOS.DSCP_CS5

常量

第 331 行

std.c.netbsd.IPTOS.DSCP_CS6

常量

第 333 行

std.c.netbsd.IPTOS.DSCP_CS7

常量

第 334 行

std.c.netbsd.IPTOS.DSCP_EF

常量

第 332 行

std.c.netbsd.IPTOS.DSCP_MASK

常量

第 348 行

std.c.netbsd.IPTOS.ECN

函数

第 357 行

pub fn ECN(t: anytype) @TypeOf(t)

std.c.netbsd.IPTOS.ECN_CE

常量

第 355 行

std.c.netbsd.IPTOS.ECN_ECT0

常量

第 354 行

std.c.netbsd.IPTOS.ECN_ECT1

常量

第 353 行

std.c.netbsd.IPTOS.ECN_MASK

常量

第 356 行

std.c.netbsd.IPTOS.ECN_NOT_ECT

常量

第 360 行

std.c.netbsd.IPTOS.ECN_NOTECT

常量

第 352 行

std.c.netbsd.IPTOS.ECT

常量

第 366 行

std.c.netbsd.IPTOS.LOWDELAY

常量

第 361 行

std.c.netbsd.IPTOS.MINCOST

常量

第 364 行

std.c.netbsd.IPTOS.PREC_CRITIC_ECP

常量

第 369 行

std.c.netbsd.IPTOS.PREC_FLASH

常量

第 371 行

std.c.netbsd.IPTOS.PREC_FLASHOVERRIDE

常量

第 370 行

std.c.netbsd.IPTOS.PREC_IMMEDIATE

常量

第 372 行

std.c.netbsd.IPTOS.PREC_INTERNETCONTROL

常量

第 368 行

std.c.netbsd.IPTOS.PREC_NETCONTROL

常量

第 367 行

std.c.netbsd.IPTOS.PREC_PRIORITY

常量

第 373 行

std.c.netbsd.IPTOS.PREC_ROUTINE

常量

第 374 行

std.c.netbsd.IPTOS.RELIABILITY

常量

第 363 行

std.c.netbsd.IPTOS.THROUGHPUT

常量

第 362 行

std.c.netbsd.IPV6

命名空间

第 260 行

std.c.netbsd.IPV6.@"2292DSTOPTS"

常量

第 273 行

std.c.netbsd.IPV6.@"2292HOPLIMIT"

常量

第 270 行

std.c.netbsd.IPV6.@"2292HOPOPTS"

常量

第 272 行

std.c.netbsd.IPV6.@"2292NEXTHOP"

常量

第 271 行

std.c.netbsd.IPV6.@"2292PKTINFO"

常量

第 269 行

std.c.netbsd.IPV6.@"2292PKTOPTIONS"

常量

第 275 行

std.c.netbsd.IPV6.@"2292RTHDR"

常量

第 274 行

std.c.netbsd.IPV6.BINDANY

常量

第 301 行

std.c.netbsd.IPV6.CHECKSUM

常量

第 276 行

std.c.netbsd.IPV6.DEFAULT_MULTICAST_HOPS

常量

第 305 行

std.c.netbsd.IPV6.DEFAULT_MULTICAST_LOOP

常量

第 306 行

std.c.netbsd.IPV6.DONTFRAG

常量

第 299 行

std.c.netbsd.IPV6.DSTOPTS

常量

第 294 行

std.c.netbsd.IPV6.FAITH

常量

第 279 行

std.c.netbsd.IPV6.HOPLIMIT

常量

第 291 行

std.c.netbsd.IPV6.HOPOPTS

常量

第 293 行

std.c.netbsd.IPV6.IPSEC_POLICY

常量

第 278 行

std.c.netbsd.IPV6.JOIN_GROUP

常量

第 265 行

std.c.netbsd.IPV6.LEAVE_GROUP

常量

第 266 行

std.c.netbsd.IPV6.MULTICAST_HOPS

常量

第 263 行

std.c.netbsd.IPV6.MULTICAST_IF

常量

第 262 行

std.c.netbsd.IPV6.MULTICAST_LOOP

常量

第 264 行

std.c.netbsd.IPV6.NEXTHOP

常量

第 292 行

std.c.netbsd.IPV6.OTCLASS

常量

第 297 行

std.c.netbsd.IPV6.PATHMTU

常量

第 289 行

std.c.netbsd.IPV6.PKTINFO

常量

第 290 行

std.c.netbsd.IPV6.PORTALGO

常量

第 268 行

std.c.netbsd.IPV6.PORTRANGE

常量

第 267 行

std.c.netbsd.IPV6.PORTRANGE_DEFAULT

常量

第 307 行

std.c.netbsd.IPV6.PORTRANGE_HIGH

常量

第 308 行

std.c.netbsd.IPV6.PORTRANGE_LOW

常量

第 309 行

std.c.netbsd.IPV6.PREFER_TEMPADDR

常量

第 300 行

std.c.netbsd.IPV6.RECVDSTOPTS

常量

第 285 行

std.c.netbsd.IPV6.RECVHOPLIMIT

常量

第 282 行

std.c.netbsd.IPV6.RECVHOPOPTS

常量

第 284 行

std.c.netbsd.IPV6.RECVPATHMTU

常量

第 288 行

std.c.netbsd.IPV6.RECVPKTINFO

常量

第 281 行

std.c.netbsd.IPV6.RECVRTHDR

常量

第 283 行

std.c.netbsd.IPV6.RECVRTHDRDSTOPTS

常量

第 286 行

std.c.netbsd.IPV6.RECVTCLASS

常量

第 296 行

std.c.netbsd.IPV6.RTHDR

常量

第 295 行

std.c.netbsd.IPV6.RTHDR_LOOSE

常量

第 302 行

std.c.netbsd.IPV6.RTHDR_STRICT

常量

第 303 行

std.c.netbsd.IPV6.RTHDR_TYPE_0

常量

第 304 行

std.c.netbsd.IPV6.RTHDRDSTOPTS

常量

第 280 行

std.c.netbsd.IPV6.TCLASS

常量

第 298 行

std.c.netbsd.IPV6.UNICAST_HOPS

常量

第 261 行

std.c.netbsd.IPV6.USE_MIN_MTU

常量

第 287 行

std.c.netbsd.IPV6.V6ONLY

常量

第 277 行

std.c.netbsd.lwpid_t

类型

第 12 行

std.c.netbsd.pid_t

别名

第 4 行

别名目标 std.c.pid_t

std.c.netbsd.pthread_setname_np

函数

第 14 行

pub extern "c" fn pthread_setname_np(thread: pthread_t, name: [*:0]const u8, arg: ?*anyopaque) c_int

参数

thread: pthread_t
name: [*:0]const u8
arg: ?*anyopaque

std.c.netbsd.pthread_t

别名

第 5 行

别名目标 std.c.pthread_t

std.c.netbsd.ptrace

函数

第 10 行

pub extern "c" fn ptrace(request: c_int, pid: pid_t, addr: ?*anyopaque, data: c_int) c_int

参数

request: c_int
pid: pid_t
addr: ?*anyopaque
data: c_int

std.c.netbsd.sigval_t

别名

第 6 行

别名目标 std.c.sigval_t

std.c.netbsd.std

别名

第 1 行

别名目标 std

std.c.netbsd.TCIFLUSH

常量

第 33 行

std.c.netbsd.TCIOFF

常量

第 38 行

std.c.netbsd.TCIOFLUSH

常量

第 35 行

std.c.netbsd.TCION

常量

第 39 行

std.c.netbsd.TCOFLUSH

常量

第 34 行

std.c.netbsd.TCOOFF

常量

第 36 行

std.c.netbsd.TCOON

常量

第 37 行

std.c.netbsd.TCP

命名空间

第 378 行

std.c.netbsd.TCP.CONGCTL

常量

第 387 行

std.c.netbsd.TCP.INFO

常量

第 385 行

std.c.netbsd.TCP.KEEPCNT

常量

第 383 行

std.c.netbsd.TCP.KEEPIDLE

常量

第 381 行

std.c.netbsd.TCP.KEEPINIT

常量

第 384 行

std.c.netbsd.TCP.KEEPINTVL

常量

第 382 行

std.c.netbsd.TCP.MAXSEG

常量

第 380 行

std.c.netbsd.TCP.MD5SIG

常量

第 386 行

std.c.netbsd.TCP.NODELAY

常量

第 379 行

std.c.netbsd.timespec

别名

第 8 行

别名目标 std.c.timespec

std.c.netbsd.uid_t

别名

第 7 行

别名目标 std.c.uid_t

源码

std/c/netbsd.zig

const std = @import("../std.zig");
const clock_t = std.c.clock_t;
const clockid_t = std.c.clockid_t;
const pid_t = std.c.pid_t;
const pthread_t = std.c.pthread_t;
const sigval_t = std.c.sigval_t;
const uid_t = std.c.uid_t;
const timespec = std.c.timespec;

pub extern "c" fn ptrace(request: c_int, pid: pid_t, addr: ?*anyopaque, data: c_int) c_int;

pub const lwpid_t = i32;

pub extern "c" fn pthread_setname_np(thread: pthread_t, name: [*:0]const u8, arg: ?*anyopaque) c_int;

pub extern "c" fn _lwp_self() lwpid_t;

pub extern "c" fn ___lwp_park60(
    clock_id: clockid_t,
    flags: packed struct(u32) {
        ABSTIME: bool = false,
        unused: u31 = 0,
    },
    ts: ?*timespec,
    unpark: lwpid_t,
    hint: ?*const anyopaque,
    unpark_hint: ?*const anyopaque,
) c_int;

pub extern "c" fn _lwp_unpark(lwp: lwpid_t, hint: ?*const anyopaque) c_int;
pub extern "c" fn _lwp_unpark_all(targets: [*]const lwpid_t, ntargets: usize, hint: ?*const anyopaque) c_int;

pub const TCIFLUSH = 1;
pub const TCOFLUSH = 2;
pub const TCIOFLUSH = 3;
pub const TCOOFF = 1;
pub const TCOON = 2;
pub const TCIOFF = 3;
pub const TCION = 4;

pub const _ksiginfo = extern struct {
    signo: std.c.SIG,
    code: i32,
    errno: i32,
    // 64 位架构会在此插入 4 字节填充,方法是
    // 正确对齐 reason 字段
    reason: extern union {
        rt: extern struct {
            pid: pid_t,
            uid: uid_t,
            value: sigval_t,
        },
        child: extern struct {
            pid: pid_t,
            uid: uid_t,
            status: i32,
            utime: clock_t,
            stime: clock_t,
        },
        fault: extern struct {
            addr: *allowzero anyopaque,
            trap: i32,
            trap2: i32,
            trap3: i32,
        },
        poll: extern struct {
            band: i32,
            fd: i32,
        },
        syscall: extern struct {
            sysnum: i32,
            retval: [2]i32,
            @"error": i32,
            args: [8]u64,
        },
        ptrace_state: extern struct {
            pe_report_event: i32,
            option: extern union {
                pe_other_pid: pid_t,
                pe_lwp: lwpid_t,
            },
        },
    } align(@sizeOf(usize)),
};

pub const E = enum(u16) {
    /// 未发生错误。
    SUCCESS = 0,
    PERM = 1, // 操作不被允许
    NOENT = 2, // 没有此文件或目录
    SRCH = 3, // 无此进程
    INTR = 4, // 系统调用被中断
    IO = 5, // 输入/输出错误
    NXIO = 6, // 设备未配置
    @"2BIG" = 7, // 参数列表过长
    NOEXEC = 8, // 可执行文件格式错误
    BADF = 9, // 文件描述符错误
    CHILD = 10, // 没有子进程
    DEADLK = 11, // 避免资源死锁
    // 11 曾为 AGAIN
    NOMEM = 12, // 无法分配内存
    ACCES = 13, // 权限被拒绝
    FAULT = 14, // 错误的地址
    NOTBLK = 15, // 需要块设备
    BUSY = 16, // 设备忙
    EXIST = 17, // 文件已存在
    XDEV = 18, // 跨设备链接
    NODEV = 19, // 设备不支持此操作
    NOTDIR = 20, // 不是目录
    ISDIR = 21, // 是一个目录
    INVAL = 22, // 参数无效
    NFILE = 23, // 系统中打开的文件过多
    MFILE = 24, // 打开的文件过多
    NOTTY = 25, // 此设备不适用该 ioctl
    TXTBSY = 26, // 文本文件忙
    FBIG = 27, // 文件过大
    NOSPC = 28, // 设备上没有剩余空间
    SPIPE = 29, // 非法寻址
    ROFS = 30, // 只读文件系统
    MLINK = 31, // 链接过多
    PIPE = 32, // 管道破裂

    // 数学软件
    DOM = 33, // 数值参数超出定义域
    RANGE = 34, // 结果过大或过小

    // 非阻塞和中断 I/O
    // 另有:WOULDBLOCK:操作会阻塞
    AGAIN = 35, // 资源暂时不可用
    INPROGRESS = 36, // 操作正在进行中
    ALREADY = 37, // 操作已在进行中

    // IPC/网络软件——参数错误
    NOTSOCK = 38, // 对非套接字执行了套接字操作
    DESTADDRREQ = 39, // 需要目标地址
    MSGSIZE = 40, // 消息过长
    PROTOTYPE = 41, // 套接字的协议类型错误
    NOPROTOOPT = 42, // 协议选项不可用
    PROTONOSUPPORT = 43, // 不支持此协议
    SOCKTNOSUPPORT = 44, // 不支持的套接字类型
    OPNOTSUPP = 45, // 操作不受支持
    PFNOSUPPORT = 46, // 不支持此协议族
    AFNOSUPPORT = 47, // 地址族不受协议族支持
    ADDRINUSE = 48, // 地址已被使用
    ADDRNOTAVAIL = 49, // 无法分配请求的地址

    // 进程间通信或网络软件——运行错误
    NETDOWN = 50, // 网络已关闭
    NETUNREACH = 51, // 网络不可达
    NETRESET = 52, // 网络因重置而断开连接
    CONNABORTED = 53, // 软件导致连接中止
    CONNRESET = 54, // 连接被对端重置
    NOBUFS = 55, // 没有可用的缓冲区空间
    ISCONN = 56, // 套接字已连接
    NOTCONN = 57, // 套接字未连接
    SHUTDOWN = 58, // 套接字关闭后无法发送
    TOOMANYREFS = 59, // 引用过多:无法拼接
    TIMEDOUT = 60, // 操作超时
    CONNREFUSED = 61, // 连接被拒绝

    LOOP = 62, // 遇到过多层符号链接
    NAMETOOLONG = 63, // 文件名过长

    // 应重新排列
    HOSTDOWN = 64, // 主机已关闭
    HOSTUNREACH = 65, // 无到主机的路由
    NOTEMPTY = 66, // 目录非空

    // 配额及杂项
    PROCLIM = 67, // 进程过多
    USERS = 68, // 用户过多
    DQUOT = 69, // 超出磁盘配额

    // 网络文件系统
    STALE = 70, // 失效的 NFS 文件句柄
    REMOTE = 71, // 路径中的远程层级过多
    BADRPC = 72, // RPC 结构错误
    RPCMISMATCH = 73, // RPC 版本错误
    PROGUNAVAIL = 74, // RPC 程序不可用
    PROGMISMATCH = 75, // 程序版本错误
    PROCUNAVAIL = 76, // 程序的过程错误

    NOLCK = 77, // 没有可用的锁
    NOSYS = 78, // 函数未实现

    FTYPE = 79, // 文件类型或格式不合适
    AUTH = 80, // 身份验证错误
    NEEDAUTH = 81, // 需要身份验证器

    // SystemV 进程间通信
    IDRM = 82, // 标识符已移除
    NOMSG = 83, // 没有所需类型的消息
    OVERFLOW = 84, // 值过大,无法存入数据类型

    // 宽字符/多字节字符处理,ISO/IEC 9899/AMD1:1995
    ILSEQ = 85, // 非法字节序列

    // 来自 IEEE Std 1003.1-2001。
    // 基本、实时、线程或线程优先级调度选项的错误。
    NOTSUP = 86, // 不支持

    // 实时选项错误
    CANCELED = 87, // 操作已取消

    // 实时性、XSI STREAMS 选项相关错误
    BADMSG = 88, // 消息错误或已损坏

    // XSI STREAMS 选项错误
    NODATA = 89, // 没有可用消息
    NOSR = 90, // 无 STREAM 资源
    NOSTR = 91, // 不是 STREAM
    TIME = 92, // STREAM ioctl 超时

    // 文件系统扩展属性错误
    NOATTR = 93, // 找不到属性

    // 实时性、XSI STREAMS 选项相关错误
    MULTIHOP = 94, // 尝试进行多跳
    NOLINK = 95, // 链路已断开
    PROTO = 96, // 协议错误

    _,
};

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

// https://github.com/NetBSD/src/blob/2579a44b3da9597de159e42cb1b5db0d382bd511/sys/netinet/tcp.h#L126
pub const TCP = struct {
    pub const NODELAY = 1;
    pub const MAXSEG = 2;
    pub const KEEPIDLE = 3;
    pub const KEEPINTVL = 5;
    pub const KEEPCNT = 6;
    pub const KEEPINIT = 7;
    pub const INFO = 9;
    pub const MD5SIG = 0x10;
    pub const CONGCTL = 0x20;
};