diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-03-13 15:17:53 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-03-13 15:17:53 -0400 |
| commit | 656ba530d80e67bc7bb9c40e5c2db26a40743a15 (patch) | |
| tree | 767f4d57000922cf122ae965dc825f87c62ec64e /lib/std/os/bits | |
| parent | 96c07674fc2293fa040212ab797c05436dc515b1 (diff) | |
| parent | 3eff77bfb52accbc16eb831753ff4917fc2b4873 (diff) | |
| download | zig-656ba530d80e67bc7bb9c40e5c2db26a40743a15.tar.gz zig-656ba530d80e67bc7bb9c40e5c2db26a40743a15.zip | |
Merge remote-tracking branch 'origin/master' into llvm10
Diffstat (limited to 'lib/std/os/bits')
| -rw-r--r-- | lib/std/os/bits/darwin.zig | 3 | ||||
| -rw-r--r-- | lib/std/os/bits/dragonfly.zig | 4 | ||||
| -rw-r--r-- | lib/std/os/bits/freebsd.zig | 3 | ||||
| -rw-r--r-- | lib/std/os/bits/linux.zig | 18 | ||||
| -rw-r--r-- | lib/std/os/bits/linux/netlink.zig | 498 | ||||
| -rw-r--r-- | lib/std/os/bits/linux/x86_64.zig | 3 | ||||
| -rw-r--r-- | lib/std/os/bits/netbsd.zig | 3 | ||||
| -rw-r--r-- | lib/std/os/bits/wasi.zig | 1 | ||||
| -rw-r--r-- | lib/std/os/bits/windows.zig | 1 |
9 files changed, 523 insertions, 11 deletions
diff --git a/lib/std/os/bits/darwin.zig b/lib/std/os/bits/darwin.zig index fb933c6698..6808af0315 100644 --- a/lib/std/os/bits/darwin.zig +++ b/lib/std/os/bits/darwin.zig @@ -53,6 +53,7 @@ pub const mach_timebase_info_data = extern struct { }; pub const off_t = i64; +pub const ino_t = u64; /// Renamed to Stat to not conflict with the stat function. /// atime, mtime, and ctime have functions to return `timespec`, @@ -64,7 +65,7 @@ pub const Stat = extern struct { dev: i32, mode: u16, nlink: u16, - ino: u64, + ino: ino_t, uid: u32, gid: u32, rdev: i32, diff --git a/lib/std/os/bits/dragonfly.zig b/lib/std/os/bits/dragonfly.zig index c6c23affa7..27b2733b76 100644 --- a/lib/std/os/bits/dragonfly.zig +++ b/lib/std/os/bits/dragonfly.zig @@ -138,8 +138,10 @@ pub const MAP_SIZEALIGN = 262144; pub const PATH_MAX = 1024; +pub const ino_t = c_ulong; + pub const Stat = extern struct { - ino: c_ulong, + ino: ino_t, nlink: c_uint, dev: c_uint, mode: c_ushort, diff --git a/lib/std/os/bits/freebsd.zig b/lib/std/os/bits/freebsd.zig index b7d14934f5..02fe7e75b3 100644 --- a/lib/std/os/bits/freebsd.zig +++ b/lib/std/os/bits/freebsd.zig @@ -98,6 +98,7 @@ pub const msghdr_const = extern struct { }; pub const off_t = i64; +pub const ino_t = u64; /// Renamed to Stat to not conflict with the stat function. /// atime, mtime, and ctime have functions to return `timespec`, @@ -107,7 +108,7 @@ pub const off_t = i64; /// methods to accomplish this. pub const Stat = extern struct { dev: u64, - ino: u64, + ino: ino_t, nlink: usize, mode: u16, diff --git a/lib/std/os/bits/linux.zig b/lib/std/os/bits/linux.zig index c5a9a7d774..2a58c14490 100644 --- a/lib/std/os/bits/linux.zig +++ b/lib/std/os/bits/linux.zig @@ -18,6 +18,8 @@ pub usingnamespace switch (builtin.arch) { else => struct {}, }; +pub usingnamespace @import("linux/netlink.zig"); + const is_mips = builtin.arch.isMIPS(); pub const pid_t = i32; @@ -30,6 +32,10 @@ pub const NAME_MAX = 255; pub const PATH_MAX = 4096; pub const IOV_MAX = 1024; +/// Largest hardware address length +/// e.g. a mac address is a type of hardware address +pub const MAX_ADDR_LEN = 32; + pub const STDIN_FILENO = 0; pub const STDOUT_FILENO = 1; pub const STDERR_FILENO = 2; @@ -1290,12 +1296,12 @@ pub const io_uring_files_update = struct { }; pub const utsname = extern struct { - sysname: [65]u8, - nodename: [65]u8, - release: [65]u8, - version: [65]u8, - machine: [65]u8, - domainname: [65]u8, + sysname: [64:0]u8, + nodename: [64:0]u8, + release: [64:0]u8, + version: [64:0]u8, + machine: [64:0]u8, + domainname: [64:0]u8, }; pub const HOST_NAME_MAX = 64; diff --git a/lib/std/os/bits/linux/netlink.zig b/lib/std/os/bits/linux/netlink.zig new file mode 100644 index 0000000000..b40308d6fc --- /dev/null +++ b/lib/std/os/bits/linux/netlink.zig @@ -0,0 +1,498 @@ +usingnamespace @import("../linux.zig"); + +/// Routing/device hook +pub const NETLINK_ROUTE = 0; + +/// Unused number +pub const NETLINK_UNUSED = 1; + +/// Reserved for user mode socket protocols +pub const NETLINK_USERSOCK = 2; + +/// Unused number, formerly ip_queue +pub const NETLINK_FIREWALL = 3; + +/// socket monitoring +pub const NETLINK_SOCK_DIAG = 4; + +/// netfilter/iptables ULOG +pub const NETLINK_NFLOG = 5; + +/// ipsec +pub const NETLINK_XFRM = 6; + +/// SELinux event notifications +pub const NETLINK_SELINUX = 7; + +/// Open-iSCSI +pub const NETLINK_ISCSI = 8; + +/// auditing +pub const NETLINK_AUDIT = 9; + +pub const NETLINK_FIB_LOOKUP = 10; + +pub const NETLINK_CONNECTOR = 11; + +/// netfilter subsystem +pub const NETLINK_NETFILTER = 12; + +pub const NETLINK_IP6_FW = 13; + +/// DECnet routing messages +pub const NETLINK_DNRTMSG = 14; + +/// Kernel messages to userspace +pub const NETLINK_KOBJECT_UEVENT = 15; + +pub const NETLINK_GENERIC = 16; + +// leave room for NETLINK_DM (DM Events) + +/// SCSI Transports +pub const NETLINK_SCSITRANSPORT = 18; + +pub const NETLINK_ECRYPTFS = 19; + +pub const NETLINK_RDMA = 20; + +/// Crypto layer +pub const NETLINK_CRYPTO = 21; + +/// SMC monitoring +pub const NETLINK_SMC = 22; + +// Flags values + +/// It is request message. +pub const NLM_F_REQUEST = 0x01; + +/// Multipart message, terminated by NLMSG_DONE +pub const NLM_F_MULTI = 0x02; + +/// Reply with ack, with zero or error code +pub const NLM_F_ACK = 0x04; + +/// Echo this request +pub const NLM_F_ECHO = 0x08; + +/// Dump was inconsistent due to sequence change +pub const NLM_F_DUMP_INTR = 0x10; + +/// Dump was filtered as requested +pub const NLM_F_DUMP_FILTERED = 0x20; + +// Modifiers to GET request + +/// specify tree root +pub const NLM_F_ROOT = 0x100; + +/// return all matching +pub const NLM_F_MATCH = 0x200; + +/// atomic GET +pub const NLM_F_ATOMIC = 0x400; +pub const NLM_F_DUMP = NLM_F_ROOT | NLM_F_MATCH; + +// Modifiers to NEW request + +/// Override existing +pub const NLM_F_REPLACE = 0x100; + +/// Do not touch, if it exists +pub const NLM_F_EXCL = 0x200; + +/// Create, if it does not exist +pub const NLM_F_CREATE = 0x400; + +/// Add to end of list +pub const NLM_F_APPEND = 0x800; + +// Modifiers to DELETE request + +/// Do not delete recursively +pub const NLM_F_NONREC = 0x100; + +// Flags for ACK message + +/// request was capped +pub const NLM_F_CAPPED = 0x100; + +/// extended ACK TVLs were included +pub const NLM_F_ACK_TLVS = 0x200; + +pub const NetlinkMessageType = extern enum(u16) { + /// Nothing. + NOOP = 0x1, + + /// Error + ERROR = 0x2, + + /// End of a dump + DONE = 0x3, + + /// Data lost + OVERRUN = 0x4, + + /// < 0x10: reserved control messages + pub const MIN_TYPE = 0x10; + + // rtlink types + + RTM_NEWLINK = 16, + RTM_DELLINK, + RTM_GETLINK, + RTM_SETLINK, + + RTM_NEWADDR = 20, + RTM_DELADDR, + RTM_GETADDR, + + RTM_NEWROUTE = 24, + RTM_DELROUTE, + RTM_GETROUTE, + + RTM_NEWNEIGH = 28, + RTM_DELNEIGH, + RTM_GETNEIGH, + + RTM_NEWRULE = 32, + RTM_DELRULE, + RTM_GETRULE, + + RTM_NEWQDISC = 36, + RTM_DELQDISC, + RTM_GETQDISC, + + RTM_NEWTCLASS = 40, + RTM_DELTCLASS, + RTM_GETTCLASS, + + RTM_NEWTFILTER = 44, + RTM_DELTFILTER, + RTM_GETTFILTER, + + RTM_NEWACTION = 48, + RTM_DELACTION, + RTM_GETACTION, + + RTM_NEWPREFIX = 52, + + RTM_GETMULTICAST = 58, + + RTM_GETANYCAST = 62, + + RTM_NEWNEIGHTBL = 64, + RTM_GETNEIGHTBL = 66, + RTM_SETNEIGHTBL, + + RTM_NEWNDUSEROPT = 68, + + RTM_NEWADDRLABEL = 72, + RTM_DELADDRLABEL, + RTM_GETADDRLABEL, + + RTM_GETDCB = 78, + RTM_SETDCB, + + RTM_NEWNETCONF = 80, + RTM_DELNETCONF, + RTM_GETNETCONF = 82, + + RTM_NEWMDB = 84, + RTM_DELMDB = 85, + RTM_GETMDB = 86, + + RTM_NEWNSID = 88, + RTM_DELNSID = 89, + RTM_GETNSID = 90, + + RTM_NEWSTATS = 92, + RTM_GETSTATS = 94, + + RTM_NEWCACHEREPORT = 96, + + RTM_NEWCHAIN = 100, + RTM_DELCHAIN, + RTM_GETCHAIN, + + RTM_NEWNEXTHOP = 104, + RTM_DELNEXTHOP, + RTM_GETNEXTHOP, + + _, +}; + +/// Netlink socket address +pub const sockaddr_nl = extern struct { + family: sa_family_t = AF_NETLINK, + __pad1: c_ushort = 0, + + /// port ID + pid: u32, + + /// multicast groups mask + groups: u32, +}; + +/// Netlink message header +/// Specified in RFC 3549 Section 2.3.2 +pub const nlmsghdr = extern struct { + /// Length of message including header + len: u32, + + /// Message content + @"type": NetlinkMessageType, + + /// Additional flags + flags: u16, + + /// Sequence number + seq: u32, + + /// Sending process port ID + pid: u32, +}; + +pub const ifinfomsg = extern struct { + family: u8, + __pad1: u8 = 0, + + /// ARPHRD_* + @"type": c_ushort, + + /// Link index + index: c_int, + + /// IFF_* flags + flags: c_uint, + + /// IFF_* change mask + /// is reserved for future use and should be always set to 0xFFFFFFFF. + change: c_uint = 0xFFFFFFFF, +}; + +pub const rtattr = extern struct { + /// Length of option + len: c_ushort, + + /// Type of option + @"type": IFLA, + + pub const ALIGNTO = 4; +}; + +pub const IFLA = extern enum(c_ushort) { + UNSPEC, + ADDRESS, + BROADCAST, + IFNAME, + MTU, + LINK, + QDISC, + STATS, + COST, + PRIORITY, + MASTER, + + /// Wireless Extension event + WIRELESS, + + /// Protocol specific information for a link + PROTINFO, + + TXQLEN, + MAP, + WEIGHT, + OPERSTATE, + LINKMODE, + LINKINFO, + NET_NS_PID, + IFALIAS, + + /// Number of VFs if device is SR-IOV PF + NUM_VF, + + VFINFO_LIST, + STATS64, + VF_PORTS, + PORT_SELF, + AF_SPEC, + + /// Group the device belongs to + GROUP, + + NET_NS_FD, + + /// Extended info mask, VFs, etc + EXT_MASK, + + /// Promiscuity count: > 0 means acts PROMISC + PROMISCUITY, + + NUM_TX_QUEUES, + NUM_RX_QUEUES, + CARRIER, + PHYS_PORT_ID, + CARRIER_CHANGES, + PHYS_SWITCH_ID, + LINK_NETNSID, + PHYS_PORT_NAME, + PROTO_DOWN, + GSO_MAX_SEGS, + GSO_MAX_SIZE, + PAD, + XDP, + EVENT, + + NEW_NETNSID, + IF_NETNSID = 46, + TARGET_NETNSID = 46, // new alias + + CARRIER_UP_COUNT, + CARRIER_DOWN_COUNT, + NEW_IFINDEX, + MIN_MTU, + MAX_MTU, + + _, +}; + +pub const rtnl_link_ifmap = extern struct { + mem_start: u64, + mem_end: u64, + base_addr: u64, + irq: u16, + dma: u8, + port: u8, +}; + +pub const rtnl_link_stats = extern struct { + /// total packets received + rx_packets: u32, + + /// total packets transmitted + tx_packets: u32, + + /// total bytes received + rx_bytes: u32, + + /// total bytes transmitted + tx_bytes: u32, + + /// bad packets received + rx_errors: u32, + + /// packet transmit problems + tx_errors: u32, + + /// no space in linux buffers + rx_dropped: u32, + + /// no space available in linux + tx_dropped: u32, + + /// multicast packets received + multicast: u32, + + collisions: u32, + + // detailed rx_errors + + rx_length_errors: u32, + + /// receiver ring buff overflow + rx_over_errors: u32, + + /// recved pkt with crc error + rx_crc_errors: u32, + + /// recv'd frame alignment error + rx_frame_errors: u32, + + /// recv'r fifo overrun + rx_fifo_errors: u32, + + /// receiver missed packet + rx_missed_errors: u32, + + // detailed tx_errors + tx_aborted_errors: u32, + tx_carrier_errors: u32, + tx_fifo_errors: u32, + tx_heartbeat_errors: u32, + tx_window_errors: u32, + + // for cslip etc + + rx_compressed: u32, + tx_compressed: u32, + + /// dropped, no handler found + rx_nohandler: u32, +}; + +pub const rtnl_link_stats64 = extern struct { + /// total packets received + rx_packets: u64, + + /// total packets transmitted + tx_packets: u64, + + /// total bytes received + rx_bytes: u64, + + /// total bytes transmitted + tx_bytes: u64, + + /// bad packets received + rx_errors: u64, + + /// packet transmit problems + tx_errors: u64, + + /// no space in linux buffers + rx_dropped: u64, + + /// no space available in linux + tx_dropped: u64, + + /// multicast packets received + multicast: u64, + + collisions: u64, + + // detailed rx_errors + + rx_length_errors: u64, + + /// receiver ring buff overflow + rx_over_errors: u64, + + /// recved pkt with crc error + rx_crc_errors: u64, + + /// recv'd frame alignment error + rx_frame_errors: u64, + + /// recv'r fifo overrun + rx_fifo_errors: u64, + + /// receiver missed packet + rx_missed_errors: u64, + + // detailed tx_errors + tx_aborted_errors: u64, + tx_carrier_errors: u64, + tx_fifo_errors: u64, + tx_heartbeat_errors: u64, + tx_window_errors: u64, + + // for cslip etc + + rx_compressed: u64, + tx_compressed: u64, + + /// dropped, no handler found + rx_nohandler: u64, +}; diff --git a/lib/std/os/bits/linux/x86_64.zig b/lib/std/os/bits/linux/x86_64.zig index 608f74e2d3..e92591d94e 100644 --- a/lib/std/os/bits/linux/x86_64.zig +++ b/lib/std/os/bits/linux/x86_64.zig @@ -481,6 +481,7 @@ pub const msghdr_const = extern struct { }; pub const off_t = i64; +pub const ino_t = u64; /// Renamed to Stat to not conflict with the stat function. /// atime, mtime, and ctime have functions to return `timespec`, @@ -490,7 +491,7 @@ pub const off_t = i64; /// methods to accomplish this. pub const Stat = extern struct { dev: u64, - ino: u64, + ino: ino_t, nlink: usize, mode: u32, diff --git a/lib/std/os/bits/netbsd.zig b/lib/std/os/bits/netbsd.zig index 89e0998d6d..735485695a 100644 --- a/lib/std/os/bits/netbsd.zig +++ b/lib/std/os/bits/netbsd.zig @@ -69,6 +69,7 @@ pub const msghdr_const = extern struct { }; pub const off_t = i64; +pub const ino_t = u64; /// Renamed to Stat to not conflict with the stat function. /// atime, mtime, and ctime have functions to return `timespec`, @@ -79,7 +80,7 @@ pub const off_t = i64; pub const Stat = extern struct { dev: u64, mode: u32, - ino: u64, + ino: ino_t, nlink: usize, uid: u32, diff --git a/lib/std/os/bits/wasi.zig b/lib/std/os/bits/wasi.zig index f56e53504e..8fb85e1fcd 100644 --- a/lib/std/os/bits/wasi.zig +++ b/lib/std/os/bits/wasi.zig @@ -178,6 +178,7 @@ pub const FILESTAT_SET_MTIM: fstflags_t = 0x0004; pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008; pub const inode_t = u64; +pub const ino_t = inode_t; pub const linkcount_t = u32; diff --git a/lib/std/os/bits/windows.zig b/lib/std/os/bits/windows.zig index ba2725e0a9..05486c8f7b 100644 --- a/lib/std/os/bits/windows.zig +++ b/lib/std/os/bits/windows.zig @@ -4,6 +4,7 @@ usingnamespace @import("../windows/bits.zig"); const ws2_32 = @import("../windows/ws2_32.zig"); pub const fd_t = HANDLE; +pub const ino_t = LARGE_INTEGER; pub const pid_t = HANDLE; pub const mode_t = u0; |
