1 use crate::prelude::*; 2 use crate::Ioctl; 3 4 s! { 5 pub struct termios2 { 6 pub c_iflag: crate::tcflag_t, 7 pub c_oflag: crate::tcflag_t, 8 pub c_cflag: crate::tcflag_t, 9 pub c_lflag: crate::tcflag_t, 10 pub c_line: crate::cc_t, 11 pub c_cc: [crate::cc_t; 23], 12 pub c_ispeed: crate::speed_t, 13 pub c_ospeed: crate::speed_t, 14 } 15 } 16 17 // arch/mips/include/uapi/asm/socket.h 18 pub const SOL_SOCKET: c_int = 0xffff; 19 20 // Defined in unix/linux_like/mod.rs 21 // pub const SO_DEBUG: c_int = 0x0001; 22 pub const SO_REUSEADDR: c_int = 0x0004; 23 pub const SO_KEEPALIVE: c_int = 0x0008; 24 pub const SO_DONTROUTE: c_int = 0x0010; 25 pub const SO_BROADCAST: c_int = 0x0020; 26 pub const SO_LINGER: c_int = 0x0080; 27 pub const SO_OOBINLINE: c_int = 0x0100; 28 pub const SO_REUSEPORT: c_int = 0x0200; 29 pub const SO_TYPE: c_int = 0x1008; 30 // pub const SO_STYLE: c_int = SO_TYPE; 31 pub const SO_ERROR: c_int = 0x1007; 32 pub const SO_SNDBUF: c_int = 0x1001; 33 pub const SO_RCVBUF: c_int = 0x1002; 34 pub const SO_SNDLOWAT: c_int = 0x1003; 35 pub const SO_RCVLOWAT: c_int = 0x1004; 36 // NOTE: These definitions are now being renamed with _OLD postfix, 37 // but CI haven't support them yet. 38 // Some related consts could be found in b32.rs and b64.rs 39 const SO_SNDTIMEO_OLD: c_int = 0x1005; 40 const SO_RCVTIMEO_OLD: c_int = 0x1006; 41 cfg_if! { 42 if #[cfg(linux_time_bits64)] { 43 pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW; 44 pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW; 45 } else { 46 pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_OLD; 47 pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_OLD; 48 } 49 } 50 pub const SO_ACCEPTCONN: c_int = 0x1009; 51 pub const SO_PROTOCOL: c_int = 0x1028; 52 pub const SO_DOMAIN: c_int = 0x1029; 53 54 pub const SO_NO_CHECK: c_int = 11; 55 pub const SO_PRIORITY: c_int = 12; 56 pub const SO_BSDCOMPAT: c_int = 14; 57 pub const SO_PASSCRED: c_int = 17; 58 pub const SO_PEERCRED: c_int = 18; 59 pub const SO_SECURITY_AUTHENTICATION: c_int = 22; 60 pub const SO_SECURITY_ENCRYPTION_TRANSPORT: c_int = 23; 61 pub const SO_SECURITY_ENCRYPTION_NETWORK: c_int = 24; 62 pub const SO_BINDTODEVICE: c_int = 25; 63 pub const SO_ATTACH_FILTER: c_int = 26; 64 pub const SO_DETACH_FILTER: c_int = 27; 65 pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER; 66 pub const SO_PEERNAME: c_int = 28; 67 pub const SO_PEERSEC: c_int = 30; 68 pub const SO_SNDBUFFORCE: c_int = 31; 69 pub const SO_RCVBUFFORCE: c_int = 33; 70 pub const SO_PASSSEC: c_int = 34; 71 pub const SO_MARK: c_int = 36; 72 pub const SO_RXQ_OVFL: c_int = 40; 73 pub const SO_WIFI_STATUS: c_int = 41; 74 pub const SCM_WIFI_STATUS: c_int = SO_WIFI_STATUS; 75 pub const SO_PEEK_OFF: c_int = 42; 76 pub const SO_NOFCS: c_int = 43; 77 pub const SO_LOCK_FILTER: c_int = 44; 78 pub const SO_SELECT_ERR_QUEUE: c_int = 45; 79 pub const SO_BUSY_POLL: c_int = 46; 80 pub const SO_MAX_PACING_RATE: c_int = 47; 81 pub const SO_BPF_EXTENSIONS: c_int = 48; 82 pub const SO_INCOMING_CPU: c_int = 49; 83 pub const SO_ATTACH_BPF: c_int = 50; 84 pub const SO_DETACH_BPF: c_int = SO_DETACH_FILTER; 85 pub const SO_ATTACH_REUSEPORT_CBPF: c_int = 51; 86 pub const SO_ATTACH_REUSEPORT_EBPF: c_int = 52; 87 pub const SO_CNX_ADVICE: c_int = 53; 88 pub const SCM_TIMESTAMPING_OPT_STATS: c_int = 54; 89 pub const SO_MEMINFO: c_int = 55; 90 pub const SO_INCOMING_NAPI_ID: c_int = 56; 91 pub const SO_COOKIE: c_int = 57; 92 pub const SCM_TIMESTAMPING_PKTINFO: c_int = 58; 93 pub const SO_PEERGROUPS: c_int = 59; 94 pub const SO_ZEROCOPY: c_int = 60; 95 pub const SO_TXTIME: c_int = 61; 96 pub const SCM_TXTIME: c_int = SO_TXTIME; 97 pub const SO_BINDTOIFINDEX: c_int = 62; 98 // NOTE: These definitions are now being renamed with _OLD postfix, 99 // but CI haven't support them yet. 100 // Some related consts could be found in b32.rs and b64.rs 101 const SO_TIMESTAMP_OLD: c_int = 29; 102 const SO_RCVTIMEO_NEW: c_int = 66; 103 const SO_SNDTIMEO_NEW: c_int = 67; 104 const SO_TIMESTAMPNS_OLD: c_int = 35; 105 const SO_TIMESTAMPING_OLD: c_int = 37; 106 const SO_TIMESTAMP_NEW: c_int = 63; 107 const SO_TIMESTAMPNS_NEW: c_int = 64; 108 const SO_TIMESTAMPING_NEW: c_int = 65; 109 cfg_if! { 110 if #[cfg(linux_time_bits64)] { 111 pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW; 112 pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW; 113 pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW; 114 } else { 115 pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD; 116 pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD; 117 pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD; 118 } 119 } 120 // pub const SO_DETACH_REUSEPORT_BPF: c_int = 68; 121 pub const SO_PREFER_BUSY_POLL: c_int = 69; 122 pub const SO_BUSY_POLL_BUDGET: c_int = 70; 123 pub const SO_NETNS_COOKIE: c_int = 71; 124 pub const SO_BUF_LOCK: c_int = 72; 125 pub const SO_RESERVE_MEM: c_int = 73; 126 pub const SO_TXREHASH: c_int = 74; 127 pub const SO_RCVMARK: c_int = 75; 128 pub const SO_PASSPIDFD: c_int = 76; 129 pub const SO_PEERPIDFD: c_int = 77; 130 pub const SO_DEVMEM_LINEAR: c_int = 78; 131 pub const SO_DEVMEM_DMABUF: c_int = 79; 132 pub const SO_DEVMEM_DONTNEED: c_int = 80; 133 134 pub const FICLONE: c_ulong = 0x80049409; 135 pub const FICLONERANGE: c_ulong = 0x8020940D; 136 137 // Defined in unix/linux_like/mod.rs 138 // pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; 139 pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS; 140 pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING; 141 142 pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR; 143 pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF; 144 145 // Ioctl Constants 146 147 pub const TCGETS: Ioctl = 0x540d; 148 pub const TCSETS: Ioctl = 0x540e; 149 pub const TCSETSW: Ioctl = 0x540f; 150 pub const TCSETSF: Ioctl = 0x5410; 151 pub const TCGETA: Ioctl = 0x5401; 152 pub const TCSETA: Ioctl = 0x5402; 153 pub const TCSETAW: Ioctl = 0x5403; 154 pub const TCSETAF: Ioctl = 0x5404; 155 pub const TCSBRK: Ioctl = 0x5405; 156 pub const TCXONC: Ioctl = 0x5406; 157 pub const TCFLSH: Ioctl = 0x5407; 158 pub const TIOCEXCL: Ioctl = 0x740d; 159 pub const TIOCNXCL: Ioctl = 0x740e; 160 pub const TIOCSCTTY: Ioctl = 0x5480; 161 pub const TIOCGPGRP: Ioctl = 0x40047477; 162 pub const TIOCSPGRP: Ioctl = 0x80047476; 163 pub const TIOCOUTQ: Ioctl = 0x7472; 164 pub const TIOCSTI: Ioctl = 0x5472; 165 pub const TIOCGWINSZ: Ioctl = 0x40087468; 166 pub const TIOCSWINSZ: Ioctl = 0x80087467; 167 pub const TIOCMGET: Ioctl = 0x741d; 168 pub const TIOCMBIS: Ioctl = 0x741b; 169 pub const TIOCMBIC: Ioctl = 0x741c; 170 pub const TIOCMSET: Ioctl = 0x741a; 171 pub const TIOCGSOFTCAR: Ioctl = 0x5481; 172 pub const TIOCSSOFTCAR: Ioctl = 0x5482; 173 pub const FIONREAD: Ioctl = 0x467f; 174 pub const TIOCINQ: Ioctl = FIONREAD; 175 pub const TIOCLINUX: Ioctl = 0x5483; 176 pub const TIOCCONS: Ioctl = 0x80047478; 177 pub const TIOCGSERIAL: Ioctl = 0x5484; 178 pub const TIOCSSERIAL: Ioctl = 0x5485; 179 pub const TIOCPKT: Ioctl = 0x5470; 180 pub const FIONBIO: Ioctl = 0x667e; 181 pub const TIOCNOTTY: Ioctl = 0x5471; 182 pub const TIOCSETD: Ioctl = 0x7401; 183 pub const TIOCGETD: Ioctl = 0x7400; 184 pub const TCSBRKP: Ioctl = 0x5486; 185 pub const TIOCSBRK: Ioctl = 0x5427; 186 pub const TIOCCBRK: Ioctl = 0x5428; 187 pub const TIOCGSID: Ioctl = 0x7416; 188 pub const TCGETS2: Ioctl = 0x4030542a; 189 pub const TCSETS2: Ioctl = 0x8030542b; 190 pub const TCSETSW2: Ioctl = 0x8030542c; 191 pub const TCSETSF2: Ioctl = 0x8030542d; 192 pub const TIOCGPTN: Ioctl = 0x40045430; 193 pub const TIOCSPTLCK: Ioctl = 0x80045431; 194 pub const TIOCGDEV: Ioctl = 0x40045432; 195 pub const TIOCSIG: Ioctl = 0x80045436; 196 pub const TIOCVHANGUP: Ioctl = 0x5437; 197 pub const TIOCGPKT: Ioctl = 0x40045438; 198 pub const TIOCGPTLCK: Ioctl = 0x40045439; 199 pub const TIOCGEXCL: Ioctl = 0x40045440; 200 pub const TIOCGPTPEER: Ioctl = 0x20005441; 201 //pub const TIOCGISO7816: Ioctl = 0x40285442; 202 //pub const TIOCSISO7816: Ioctl = 0xc0285443; 203 pub const FIONCLEX: Ioctl = 0x6602; 204 pub const FIOCLEX: Ioctl = 0x6601; 205 pub const FIOASYNC: Ioctl = 0x667d; 206 pub const TIOCSERCONFIG: Ioctl = 0x5488; 207 pub const TIOCSERGWILD: Ioctl = 0x5489; 208 pub const TIOCSERSWILD: Ioctl = 0x548a; 209 pub const TIOCGLCKTRMIOS: Ioctl = 0x548b; 210 pub const TIOCSLCKTRMIOS: Ioctl = 0x548c; 211 pub const TIOCSERGSTRUCT: Ioctl = 0x548d; 212 pub const TIOCSERGETLSR: Ioctl = 0x548e; 213 pub const TIOCSERGETMULTI: Ioctl = 0x548f; 214 pub const TIOCSERSETMULTI: Ioctl = 0x5490; 215 pub const TIOCMIWAIT: Ioctl = 0x5491; 216 pub const TIOCGICOUNT: Ioctl = 0x5492; 217 pub const FIOQSIZE: Ioctl = 0x667f; 218 pub const TIOCSLTC: Ioctl = 0x7475; 219 pub const TIOCGETP: Ioctl = 0x7408; 220 pub const TIOCSETP: Ioctl = 0x7409; 221 pub const TIOCSETN: Ioctl = 0x740a; 222 pub const BLKIOMIN: Ioctl = 0x20001278; 223 pub const BLKIOOPT: Ioctl = 0x20001279; 224 pub const BLKSSZGET: Ioctl = 0x20001268; 225 pub const BLKPBSZGET: Ioctl = 0x2000127B; 226 // linux/if_tun.h 227 pub const TUNSETNOCSUM: Ioctl = 0x800454c8; 228 pub const TUNSETDEBUG: Ioctl = 0x800454c9; 229 pub const TUNSETIFF: Ioctl = 0x800454ca; 230 pub const TUNSETPERSIST: Ioctl = 0x800454cb; 231 pub const TUNSETOWNER: Ioctl = 0x800454cc; 232 pub const TUNSETLINK: Ioctl = 0x800454cd; 233 pub const TUNSETGROUP: Ioctl = 0x800454ce; 234 pub const TUNGETFEATURES: Ioctl = 0x400454cf; 235 pub const TUNSETOFFLOAD: Ioctl = 0x800454d0; 236 pub const TUNSETTXFILTER: Ioctl = 0x800454d1; 237 pub const TUNGETIFF: Ioctl = 0x400454d2; 238 pub const TUNGETSNDBUF: Ioctl = 0x400454d3; 239 pub const TUNSETSNDBUF: Ioctl = 0x800454d4; 240 pub const TUNGETVNETHDRSZ: Ioctl = 0x400454d7; 241 pub const TUNSETVNETHDRSZ: Ioctl = 0x800454d8; 242 pub const TUNSETQUEUE: Ioctl = 0x800454d9; 243 pub const TUNSETIFINDEX: Ioctl = 0x800454da; 244 pub const TUNSETVNETLE: Ioctl = 0x800454dc; 245 pub const TUNGETVNETLE: Ioctl = 0x400454dd; 246 /* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on 247 * little-endian hosts. Not all kernel configurations support them, but all 248 * configurations that support SET also support GET. 249 */ 250 pub const TUNSETVNETBE: Ioctl = 0x800454de; 251 pub const TUNGETVNETBE: Ioctl = 0x400454df; 252 pub const TUNSETSTEERINGEBPF: Ioctl = 0x400454e0; 253 pub const TUNSETFILTEREBPF: Ioctl = 0x400454e1; 254 255 cfg_if! { 256 // Those type are constructed using the _IOC macro 257 // DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN 258 // where D stands for direction (either None (00), Read (01) or Write (11)) 259 // where S stands for size (int, long, struct...) 260 // where T stands for type ('f','v','X'...) 261 // where N stands for NR (NumbeR) 262 if #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] { 263 pub const FS_IOC_GETFLAGS: Ioctl = 0x40046601; 264 pub const FS_IOC_SETFLAGS: Ioctl = 0x80046602; 265 pub const FS_IOC_GETVERSION: Ioctl = 0x40047601; 266 pub const FS_IOC_SETVERSION: Ioctl = 0x80047602; 267 pub const FS_IOC32_GETFLAGS: Ioctl = 0x40046601; 268 pub const FS_IOC32_SETFLAGS: Ioctl = 0x80046602; 269 pub const FS_IOC32_GETVERSION: Ioctl = 0x40047601; 270 pub const FS_IOC32_SETVERSION: Ioctl = 0x80047602; 271 pub const TUNATTACHFILTER: Ioctl = 0x800854d5; 272 pub const TUNDETACHFILTER: Ioctl = 0x800854d6; 273 pub const TUNGETFILTER: Ioctl = 0x400854db; 274 } else if #[cfg(any(target_arch = "mips64", target_arch = "mips64r6"))] { 275 pub const FS_IOC_GETFLAGS: Ioctl = 0x40086601; 276 pub const FS_IOC_SETFLAGS: Ioctl = 0x80086602; 277 pub const FS_IOC_GETVERSION: Ioctl = 0x40087601; 278 pub const FS_IOC_SETVERSION: Ioctl = 0x80087602; 279 pub const FS_IOC32_GETFLAGS: Ioctl = 0x40046601; 280 pub const FS_IOC32_SETFLAGS: Ioctl = 0x80046602; 281 pub const FS_IOC32_GETVERSION: Ioctl = 0x40047601; 282 pub const FS_IOC32_SETVERSION: Ioctl = 0x80047602; 283 pub const TUNATTACHFILTER: Ioctl = 0x801054d5; 284 pub const TUNDETACHFILTER: Ioctl = 0x801054d6; 285 pub const TUNGETFILTER: Ioctl = 0x401054db; 286 } 287 } 288 289 cfg_if! { 290 if #[cfg(target_env = "musl")] { 291 pub const TIOCGRS485: Ioctl = 0x4020542e; 292 pub const TIOCSRS485: Ioctl = 0xc020542f; 293 } 294 } 295 296 pub const TIOCM_LE: c_int = 0x001; 297 pub const TIOCM_DTR: c_int = 0x002; 298 pub const TIOCM_RTS: c_int = 0x004; 299 pub const TIOCM_ST: c_int = 0x010; 300 pub const TIOCM_SR: c_int = 0x020; 301 pub const TIOCM_CTS: c_int = 0x040; 302 pub const TIOCM_CAR: c_int = 0x100; 303 pub const TIOCM_CD: c_int = TIOCM_CAR; 304 pub const TIOCM_RNG: c_int = 0x200; 305 pub const TIOCM_RI: c_int = TIOCM_RNG; 306 pub const TIOCM_DSR: c_int = 0x400; 307 308 pub const BOTHER: crate::speed_t = 0o010000; 309 pub const IBSHIFT: crate::tcflag_t = 16; 310 311 // RLIMIT Constants 312 313 cfg_if! { 314 if #[cfg(any(target_env = "gnu", target_env = "uclibc"))] { 315 pub const RLIMIT_CPU: crate::__rlimit_resource_t = 0; 316 pub const RLIMIT_FSIZE: crate::__rlimit_resource_t = 1; 317 pub const RLIMIT_DATA: crate::__rlimit_resource_t = 2; 318 pub const RLIMIT_STACK: crate::__rlimit_resource_t = 3; 319 pub const RLIMIT_CORE: crate::__rlimit_resource_t = 4; 320 pub const RLIMIT_NOFILE: crate::__rlimit_resource_t = 5; 321 pub const RLIMIT_AS: crate::__rlimit_resource_t = 6; 322 pub const RLIMIT_RSS: crate::__rlimit_resource_t = 7; 323 pub const RLIMIT_NPROC: crate::__rlimit_resource_t = 8; 324 pub const RLIMIT_MEMLOCK: crate::__rlimit_resource_t = 9; 325 pub const RLIMIT_LOCKS: crate::__rlimit_resource_t = 10; 326 pub const RLIMIT_SIGPENDING: crate::__rlimit_resource_t = 11; 327 pub const RLIMIT_MSGQUEUE: crate::__rlimit_resource_t = 12; 328 pub const RLIMIT_NICE: crate::__rlimit_resource_t = 13; 329 pub const RLIMIT_RTPRIO: crate::__rlimit_resource_t = 14; 330 pub const RLIMIT_RTTIME: crate::__rlimit_resource_t = 15; 331 #[allow(deprecated)] 332 #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] 333 pub const RLIMIT_NLIMITS: crate::__rlimit_resource_t = RLIM_NLIMITS; 334 } else if #[cfg(target_env = "musl")] { 335 pub const RLIMIT_CPU: c_int = 0; 336 pub const RLIMIT_FSIZE: c_int = 1; 337 pub const RLIMIT_DATA: c_int = 2; 338 pub const RLIMIT_STACK: c_int = 3; 339 pub const RLIMIT_CORE: c_int = 4; 340 pub const RLIMIT_NOFILE: c_int = 5; 341 pub const RLIMIT_AS: c_int = 6; 342 pub const RLIMIT_RSS: c_int = 7; 343 pub const RLIMIT_NPROC: c_int = 8; 344 pub const RLIMIT_MEMLOCK: c_int = 9; 345 pub const RLIMIT_LOCKS: c_int = 10; 346 pub const RLIMIT_SIGPENDING: c_int = 11; 347 pub const RLIMIT_MSGQUEUE: c_int = 12; 348 pub const RLIMIT_NICE: c_int = 13; 349 pub const RLIMIT_RTPRIO: c_int = 14; 350 pub const RLIMIT_RTTIME: c_int = 15; 351 #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] 352 pub const RLIM_NLIMITS: c_int = 15; 353 #[allow(deprecated)] 354 #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] 355 pub const RLIMIT_NLIMITS: c_int = RLIM_NLIMITS; 356 pub const RLIM_INFINITY: crate::rlim_t = !0; 357 } 358 } 359 360 cfg_if! { 361 if #[cfg(target_env = "gnu")] { 362 #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] 363 pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 16; 364 } else if #[cfg(target_env = "uclibc")] { 365 #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] 366 pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 15; 367 } 368 } 369 370 cfg_if! { 371 if #[cfg( 372 any(target_arch = "mips64", target_arch = "mips64r6"), 373 any(target_env = "gnu", target_env = "uclibc") 374 )] { 375 pub const RLIM_INFINITY: crate::rlim_t = !0; 376 } 377 } 378 379 cfg_if! { 380 if #[cfg(all( 381 any(target_arch = "mips", target_arch = "mips32r6"), 382 any( 383 all(target_env = "uclibc", linux_time_bits64), 384 all( 385 target_env = "gnu", 386 any(linux_time_bits64, gnu_file_offset_bits64) 387 ) 388 ) 389 ))] { 390 pub const RLIM_INFINITY: crate::rlim_t = !0; 391 } else if #[cfg(all( 392 any(target_arch = "mips", target_arch = "mips32r6"), 393 any(target_env = "uclibc", target_env = "gnu"), 394 not(linux_time_bits64) 395 ))] { 396 pub const RLIM_INFINITY: crate::rlim_t = 0x7fffffff; 397 } 398 } 399