1 use crate::prelude::*;
2 use crate::Ioctl;
3 
4 // arch/powerpc/include/uapi/asm/socket.h
5 
6 pub const SOL_SOCKET: c_int = 1;
7 
8 // Defined in unix/linux_like/mod.rs
9 // pub const SO_DEBUG: c_int = 1;
10 pub const SO_REUSEADDR: c_int = 2;
11 pub const SO_TYPE: c_int = 3;
12 pub const SO_ERROR: c_int = 4;
13 pub const SO_DONTROUTE: c_int = 5;
14 pub const SO_BROADCAST: c_int = 6;
15 pub const SO_SNDBUF: c_int = 7;
16 pub const SO_RCVBUF: c_int = 8;
17 pub const SO_KEEPALIVE: c_int = 9;
18 pub const SO_OOBINLINE: c_int = 10;
19 pub const SO_NO_CHECK: c_int = 11;
20 pub const SO_PRIORITY: c_int = 12;
21 pub const SO_LINGER: c_int = 13;
22 pub const SO_BSDCOMPAT: c_int = 14;
23 pub const SO_REUSEPORT: c_int = 15;
24 // powerpc only differs in these
25 pub const SO_RCVLOWAT: c_int = 16;
26 pub const SO_SNDLOWAT: c_int = 17;
27 cfg_if! {
28     if #[cfg(linux_time_bits64)] {
29         pub const SO_SNDTIMEO: c_int = 67;
30         pub const SO_RCVTIMEO: c_int = 66;
31     } else {
32         pub const SO_SNDTIMEO: c_int = 19;
33         pub const SO_RCVTIMEO: c_int = 18;
34     }
35 }
36 // pub const SO_RCVTIMEO_OLD: c_int = 18;
37 // pub const SO_SNDTIMEO_OLD: c_int = 19;
38 pub const SO_PASSCRED: c_int = 20;
39 pub const SO_PEERCRED: c_int = 21;
40 // end
41 pub const SO_SECURITY_AUTHENTICATION: c_int = 22;
42 pub const SO_SECURITY_ENCRYPTION_TRANSPORT: c_int = 23;
43 pub const SO_SECURITY_ENCRYPTION_NETWORK: c_int = 24;
44 pub const SO_BINDTODEVICE: c_int = 25;
45 pub const SO_ATTACH_FILTER: c_int = 26;
46 pub const SO_DETACH_FILTER: c_int = 27;
47 pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER;
48 pub const SO_PEERNAME: c_int = 28;
49 cfg_if! {
50     if #[cfg(linux_time_bits64)] {
51         pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW;
52         pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW;
53         pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW;
54     } else {
55         pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD;
56         pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD;
57         pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD;
58     }
59 }
60 const SO_TIMESTAMP_OLD: c_int = 29;
61 const SO_TIMESTAMPNS_OLD: c_int = 35;
62 const SO_TIMESTAMPING_OLD: c_int = 37;
63 pub const SO_ACCEPTCONN: c_int = 30;
64 pub const SO_PEERSEC: c_int = 31;
65 pub const SO_SNDBUFFORCE: c_int = 32;
66 pub const SO_RCVBUFFORCE: c_int = 33;
67 pub const SO_PASSSEC: c_int = 34;
68 pub const SO_MARK: c_int = 36;
69 pub const SO_PROTOCOL: c_int = 38;
70 pub const SO_DOMAIN: c_int = 39;
71 pub const SO_RXQ_OVFL: c_int = 40;
72 pub const SO_WIFI_STATUS: c_int = 41;
73 pub const SCM_WIFI_STATUS: c_int = SO_WIFI_STATUS;
74 pub const SO_PEEK_OFF: c_int = 42;
75 pub const SO_NOFCS: c_int = 43;
76 pub const SO_LOCK_FILTER: c_int = 44;
77 pub const SO_SELECT_ERR_QUEUE: c_int = 45;
78 pub const SO_BUSY_POLL: c_int = 46;
79 pub const SO_MAX_PACING_RATE: c_int = 47;
80 pub const SO_BPF_EXTENSIONS: c_int = 48;
81 pub const SO_INCOMING_CPU: c_int = 49;
82 pub const SO_ATTACH_BPF: c_int = 50;
83 pub const SO_DETACH_BPF: c_int = SO_DETACH_FILTER;
84 pub const SO_ATTACH_REUSEPORT_CBPF: c_int = 51;
85 pub const SO_ATTACH_REUSEPORT_EBPF: c_int = 52;
86 pub const SO_CNX_ADVICE: c_int = 53;
87 pub const SCM_TIMESTAMPING_OPT_STATS: c_int = 54;
88 pub const SO_MEMINFO: c_int = 55;
89 pub const SO_INCOMING_NAPI_ID: c_int = 56;
90 pub const SO_COOKIE: c_int = 57;
91 pub const SCM_TIMESTAMPING_PKTINFO: c_int = 58;
92 pub const SO_PEERGROUPS: c_int = 59;
93 pub const SO_ZEROCOPY: c_int = 60;
94 pub const SO_TXTIME: c_int = 61;
95 pub const SCM_TXTIME: c_int = SO_TXTIME;
96 pub const SO_BINDTOIFINDEX: c_int = 62;
97 const SO_TIMESTAMP_NEW: c_int = 63;
98 const SO_TIMESTAMPNS_NEW: c_int = 64;
99 const SO_TIMESTAMPING_NEW: c_int = 65;
100 const SO_RCVTIMEO_NEW: c_int = 66;
101 const SO_SNDTIMEO_NEW: c_int = 67;
102 // pub const SO_DETACH_REUSEPORT_BPF: c_int = 68;
103 pub const SO_PREFER_BUSY_POLL: c_int = 69;
104 pub const SO_BUSY_POLL_BUDGET: c_int = 70;
105 pub const SO_NETNS_COOKIE: c_int = 71;
106 pub const SO_BUF_LOCK: c_int = 72;
107 pub const SO_RESERVE_MEM: c_int = 73;
108 pub const SO_TXREHASH: c_int = 74;
109 pub const SO_RCVMARK: c_int = 75;
110 pub const SO_PASSPIDFD: c_int = 76;
111 pub const SO_PEERPIDFD: c_int = 77;
112 pub const SO_DEVMEM_LINEAR: c_int = 78;
113 pub const SO_DEVMEM_DMABUF: c_int = 79;
114 pub const SO_DEVMEM_DONTNEED: c_int = 80;
115 
116 pub const FICLONE: c_ulong = 0x80049409;
117 pub const FICLONERANGE: c_ulong = 0x8020940D;
118 
119 // Defined in unix/linux_like/mod.rs
120 // pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP;
121 pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS;
122 pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING;
123 
124 pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR;
125 pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF;
126 
127 // Ioctl Constants
128 
129 cfg_if! {
130     if #[cfg(target_env = "gnu")] {
131         pub const TCGETS: Ioctl = 0x403c7413;
132         pub const TCSETS: Ioctl = 0x803c7414;
133         pub const TCSETSW: Ioctl = 0x803c7415;
134         pub const TCSETSF: Ioctl = 0x803c7416;
135     } else if #[cfg(target_env = "musl")] {
136         pub const TCGETS: Ioctl = 0x402c7413;
137         pub const TCSETS: Ioctl = 0x802c7414;
138         pub const TCSETSW: Ioctl = 0x802c7415;
139         pub const TCSETSF: Ioctl = 0x802c7416;
140     }
141 }
142 
143 pub const TCGETA: Ioctl = 0x40147417;
144 pub const TCSETA: Ioctl = 0x80147418;
145 pub const TCSETAW: Ioctl = 0x80147419;
146 pub const TCSETAF: Ioctl = 0x8014741C;
147 pub const TCSBRK: Ioctl = 0x2000741D;
148 pub const TCXONC: Ioctl = 0x2000741E;
149 pub const TCFLSH: Ioctl = 0x2000741F;
150 pub const TIOCEXCL: Ioctl = 0x540C;
151 pub const TIOCNXCL: Ioctl = 0x540D;
152 pub const TIOCSCTTY: Ioctl = 0x540E;
153 pub const TIOCGPGRP: Ioctl = 0x40047477;
154 pub const TIOCSPGRP: Ioctl = 0x80047476;
155 pub const TIOCOUTQ: Ioctl = 0x40047473;
156 pub const TIOCSTI: Ioctl = 0x5412;
157 pub const TIOCGWINSZ: Ioctl = 0x40087468;
158 pub const TIOCSWINSZ: Ioctl = 0x80087467;
159 pub const TIOCMGET: Ioctl = 0x5415;
160 pub const TIOCMBIS: Ioctl = 0x5416;
161 pub const TIOCMBIC: Ioctl = 0x5417;
162 pub const TIOCMSET: Ioctl = 0x5418;
163 pub const TIOCGSOFTCAR: Ioctl = 0x5419;
164 pub const TIOCSSOFTCAR: Ioctl = 0x541A;
165 pub const FIONREAD: Ioctl = 0x4004667F;
166 pub const TIOCINQ: Ioctl = FIONREAD;
167 pub const TIOCLINUX: Ioctl = 0x541C;
168 pub const TIOCCONS: Ioctl = 0x541D;
169 pub const TIOCGSERIAL: Ioctl = 0x541E;
170 pub const TIOCSSERIAL: Ioctl = 0x541F;
171 pub const TIOCPKT: Ioctl = 0x5420;
172 pub const FIONBIO: Ioctl = 0x8004667e;
173 pub const TIOCNOTTY: Ioctl = 0x5422;
174 pub const TIOCSETD: Ioctl = 0x5423;
175 pub const TIOCGETD: Ioctl = 0x5424;
176 pub const TCSBRKP: Ioctl = 0x5425;
177 pub const TIOCSBRK: Ioctl = 0x5427;
178 pub const TIOCCBRK: Ioctl = 0x5428;
179 pub const TIOCGSID: Ioctl = 0x5429;
180 pub const TIOCGRS485: Ioctl = 0x542e;
181 pub const TIOCSRS485: Ioctl = 0x542f;
182 pub const TIOCGPTN: Ioctl = 0x40045430;
183 pub const TIOCSPTLCK: Ioctl = 0x80045431;
184 pub const TIOCGDEV: Ioctl = 0x40045432;
185 pub const TIOCSIG: Ioctl = 0x80045436;
186 pub const TIOCVHANGUP: Ioctl = 0x5437;
187 pub const TIOCGPKT: Ioctl = 0x40045438;
188 pub const TIOCGPTLCK: Ioctl = 0x40045439;
189 pub const TIOCGEXCL: Ioctl = 0x40045440;
190 pub const TIOCGPTPEER: Ioctl = 0x20005441;
191 //pub const TIOCGISO7816: Ioctl = 0x40285442;
192 //pub const TIOCSISO7816: Ioctl = 0xc0285443;
193 pub const FIONCLEX: Ioctl = 0x20006602;
194 pub const FIOCLEX: Ioctl = 0x20006601;
195 pub const FIOASYNC: Ioctl = 0x8004667d;
196 pub const TIOCSERCONFIG: Ioctl = 0x5453;
197 pub const TIOCSERGWILD: Ioctl = 0x5454;
198 pub const TIOCSERSWILD: Ioctl = 0x5455;
199 pub const TIOCGLCKTRMIOS: Ioctl = 0x5456;
200 pub const TIOCSLCKTRMIOS: Ioctl = 0x5457;
201 pub const TIOCSERGSTRUCT: Ioctl = 0x5458;
202 pub const TIOCSERGETLSR: Ioctl = 0x5459;
203 pub const TIOCSERGETMULTI: Ioctl = 0x545A;
204 pub const TIOCSERSETMULTI: Ioctl = 0x545B;
205 pub const TIOCMIWAIT: Ioctl = 0x545C;
206 pub const TIOCGICOUNT: Ioctl = 0x545D;
207 pub const BLKIOMIN: Ioctl = 0x20001278;
208 pub const BLKIOOPT: Ioctl = 0x20001279;
209 pub const BLKSSZGET: Ioctl = 0x20001268;
210 pub const BLKPBSZGET: Ioctl = 0x2000127B;
211 //pub const FIOQSIZE: Ioctl = 0x40086680;
212 // linux/if_tun.h
213 pub const TUNSETNOCSUM: Ioctl = 0x800454c8;
214 pub const TUNSETDEBUG: Ioctl = 0x800454c9;
215 pub const TUNSETIFF: Ioctl = 0x800454ca;
216 pub const TUNSETPERSIST: Ioctl = 0x800454cb;
217 pub const TUNSETOWNER: Ioctl = 0x800454cc;
218 pub const TUNSETLINK: Ioctl = 0x800454cd;
219 pub const TUNSETGROUP: Ioctl = 0x800454ce;
220 pub const TUNGETFEATURES: Ioctl = 0x400454cf;
221 pub const TUNSETOFFLOAD: Ioctl = 0x800454d0;
222 pub const TUNSETTXFILTER: Ioctl = 0x800454d1;
223 pub const TUNGETIFF: Ioctl = 0x400454d2;
224 pub const TUNGETSNDBUF: Ioctl = 0x400454d3;
225 pub const TUNSETSNDBUF: Ioctl = 0x800454d4;
226 pub const TUNGETVNETHDRSZ: Ioctl = 0x400454d7;
227 pub const TUNSETVNETHDRSZ: Ioctl = 0x800454d8;
228 pub const TUNSETQUEUE: Ioctl = 0x800454d9;
229 pub const TUNSETIFINDEX: Ioctl = 0x800454da;
230 pub const TUNSETVNETLE: Ioctl = 0x800454dc;
231 pub const TUNGETVNETLE: Ioctl = 0x400454dd;
232 /* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on
233  * little-endian hosts. Not all kernel configurations support them, but all
234  * configurations that support SET also support GET.
235  */
236 pub const TUNSETVNETBE: Ioctl = 0x800454de;
237 pub const TUNGETVNETBE: Ioctl = 0x400454df;
238 pub const TUNSETSTEERINGEBPF: Ioctl = 0x400454e0;
239 pub const TUNSETFILTEREBPF: Ioctl = 0x400454e1;
240 
241 cfg_if! {
242     // Those type are constructed using the _IOC macro
243     // DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN
244     // where D stands for direction (either None (00), Read (01) or Write (11))
245     // where S stands for size (int, long, struct...)
246     // where T stands for type ('f','v','X'...)
247     // where N stands for NR (NumbeR)
248     if #[cfg(target_arch = "powerpc")] {
249         pub const FS_IOC_GETFLAGS: Ioctl = 0x40046601;
250         pub const FS_IOC_SETFLAGS: Ioctl = 0x80046602;
251         pub const FS_IOC_GETVERSION: Ioctl = 0x40047601;
252         pub const FS_IOC_SETVERSION: Ioctl = 0x80047602;
253         pub const FS_IOC32_GETFLAGS: Ioctl = 0x40046601;
254         pub const FS_IOC32_SETFLAGS: Ioctl = 0x80046602;
255         pub const FS_IOC32_GETVERSION: Ioctl = 0x40047601;
256         pub const FS_IOC32_SETVERSION: Ioctl = 0x80047602;
257         pub const TUNATTACHFILTER: Ioctl = 0x800854d5;
258         pub const TUNDETACHFILTER: Ioctl = 0x800854d6;
259         pub const TUNGETFILTER: Ioctl = 0x400854db;
260     } else if #[cfg(target_arch = "powerpc64")] {
261         pub const FS_IOC_GETFLAGS: Ioctl = 0x40086601;
262         pub const FS_IOC_SETFLAGS: Ioctl = 0x80086602;
263         pub const FS_IOC_GETVERSION: Ioctl = 0x40087601;
264         pub const FS_IOC_SETVERSION: Ioctl = 0x80087602;
265         pub const FS_IOC32_GETFLAGS: Ioctl = 0x40046601;
266         pub const FS_IOC32_SETFLAGS: Ioctl = 0x80046602;
267         pub const FS_IOC32_GETVERSION: Ioctl = 0x40047601;
268         pub const FS_IOC32_SETVERSION: Ioctl = 0x80047602;
269         pub const TUNATTACHFILTER: Ioctl = 0x801054d5;
270         pub const TUNDETACHFILTER: Ioctl = 0x801054d6;
271         pub const TUNGETFILTER: Ioctl = 0x401054db;
272     }
273 }
274 
275 pub const TIOCM_LE: c_int = 0x001;
276 pub const TIOCM_DTR: c_int = 0x002;
277 pub const TIOCM_RTS: c_int = 0x004;
278 pub const TIOCM_ST: c_int = 0x008;
279 pub const TIOCM_SR: c_int = 0x010;
280 pub const TIOCM_CTS: c_int = 0x020;
281 pub const TIOCM_CAR: c_int = 0x040;
282 pub const TIOCM_CD: c_int = TIOCM_CAR;
283 pub const TIOCM_RNG: c_int = 0x080;
284 pub const TIOCM_RI: c_int = TIOCM_RNG;
285 pub const TIOCM_DSR: c_int = 0x100;
286 
287 pub const BOTHER: crate::speed_t = 0o0037;
288 pub const IBSHIFT: crate::tcflag_t = 16;
289 
290 // RLIMIT Constants
291 
292 cfg_if! {
293     if #[cfg(target_env = "gnu")] {
294         pub const RLIMIT_CPU: crate::__rlimit_resource_t = 0;
295         pub const RLIMIT_FSIZE: crate::__rlimit_resource_t = 1;
296         pub const RLIMIT_DATA: crate::__rlimit_resource_t = 2;
297         pub const RLIMIT_STACK: crate::__rlimit_resource_t = 3;
298         pub const RLIMIT_CORE: crate::__rlimit_resource_t = 4;
299         pub const RLIMIT_RSS: crate::__rlimit_resource_t = 5;
300         pub const RLIMIT_NPROC: crate::__rlimit_resource_t = 6;
301         pub const RLIMIT_NOFILE: crate::__rlimit_resource_t = 7;
302         pub const RLIMIT_MEMLOCK: crate::__rlimit_resource_t = 8;
303         pub const RLIMIT_AS: crate::__rlimit_resource_t = 9;
304         pub const RLIMIT_LOCKS: crate::__rlimit_resource_t = 10;
305         pub const RLIMIT_SIGPENDING: crate::__rlimit_resource_t = 11;
306         pub const RLIMIT_MSGQUEUE: crate::__rlimit_resource_t = 12;
307         pub const RLIMIT_NICE: crate::__rlimit_resource_t = 13;
308         pub const RLIMIT_RTPRIO: crate::__rlimit_resource_t = 14;
309         pub const RLIMIT_RTTIME: crate::__rlimit_resource_t = 15;
310         #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
311         pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 16;
312         #[allow(deprecated)]
313         #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
314         pub const RLIMIT_NLIMITS: crate::__rlimit_resource_t = RLIM_NLIMITS;
315     } else if #[cfg(target_env = "musl")] {
316         pub const RLIMIT_CPU: c_int = 0;
317         pub const RLIMIT_FSIZE: c_int = 1;
318         pub const RLIMIT_DATA: c_int = 2;
319         pub const RLIMIT_STACK: c_int = 3;
320         pub const RLIMIT_CORE: c_int = 4;
321         pub const RLIMIT_RSS: c_int = 5;
322         pub const RLIMIT_NPROC: c_int = 6;
323         pub const RLIMIT_NOFILE: c_int = 7;
324         pub const RLIMIT_MEMLOCK: c_int = 8;
325         pub const RLIMIT_AS: c_int = 9;
326         pub const RLIMIT_LOCKS: c_int = 10;
327         pub const RLIMIT_SIGPENDING: c_int = 11;
328         pub const RLIMIT_MSGQUEUE: c_int = 12;
329         pub const RLIMIT_NICE: c_int = 13;
330         pub const RLIMIT_RTPRIO: c_int = 14;
331         pub const RLIMIT_RTTIME: c_int = 15;
332         #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
333         pub const RLIM_NLIMITS: c_int = 15;
334         #[allow(deprecated)]
335         #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
336         pub const RLIMIT_NLIMITS: c_int = RLIM_NLIMITS;
337     }
338 }
339 pub const RLIM_INFINITY: crate::rlim_t = !0;
340