Warning: This file is not a C or C++ file. It does not have highlighting.

1/* Copyright (C) 1992-2024 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
17
18#ifndef __BITS_IOCTLS_H
19#define __BITS_IOCTLS_H 1
20
21#if !defined _HURD_IOCTL_H && !defined _SYS_IOCTL_H
22# error "Never use <bits/ioctls.h> directly; include <hurd/ioctl.h> instead."
23#endif
24
25/* These macros are also defined in <bits/termios.h> (with numerically
26 identical values) but this serves to shut up cpp's complaining. */
27
28#ifdef __USE_MISC
29#ifdef NL0
30# undef NL0
31#endif
32#ifdef NL1
33# undef NL1
34#endif
35#ifdef TAB0
36# undef TAB0
37#endif
38#ifdef TAB1
39# undef TAB1
40#endif
41#ifdef TAB2
42# undef TAB2
43#endif
44#ifdef CR0
45# undef CR0
46#endif
47#ifdef CR1
48# undef CR1
49#endif
50#ifdef CR2
51# undef CR2
52#endif
53#ifdef CR3
54# undef CR3
55#endif
56#ifdef FF0
57# undef FF0
58#endif
59#ifdef FF1
60# undef FF1
61#endif
62#ifdef BS0
63# undef BS0
64#endif
65#ifdef BS1
66# undef BS1
67#endif
68#ifdef MDMBUF
69# undef MDMBUF
70#endif
71#ifdef ECHO
72# undef ECHO
73#endif
74#ifdef TOSTOP
75# undef TOSTOP
76#endif
77#ifdef FLUSHO
78# undef FLUSHO
79#endif
80#ifdef PENDIN
81# undef PENDIN
82#endif
83#ifdef NOFLSH
84# undef NOFLSH
85#endif
86#endif
87
88/* Hurd ioctl request are made up of several fields:
89
90 10987654321098765432109876543210
91 IOt0t1t2cc0c0cc1c1cc2ggggccccccc
92
93 bits [31,30]: inout direction (enum __ioctl_dir)
94 bits [29,11]: type encoding as follows; zero count indicates omitted datum
95 [29,28]: datum #0 type (enum __ioctl_datum)
96 [27,26]: datum #1 type (enum __ioctl_datum)
97 [24,25]: datum #2 type (enum __ioctl_datum)
98 [23,19]: datum #0 count [0,31]
99 [18,14]: datum #1 count [0,31]
100 [13,11]: datum #2 count [0,3]
101 bits [07,10]: group (letter - 'f': ['f','v'])
102 bits [00,06]: command [0,127]
103
104 The following macros construct and dissect these fields. */
105
106enum __ioctl_dir
107 {
108 IOC_VOID = 0, /* No parameters. */
109 IOC_OUT = 1, /* Data is written into the user's buffer. */
110 IOC_IN = 2, /* Data is read from the user's buffer. */
111 IOC_INOUT = (IOC_IN|IOC_OUT)
112 };
113
114enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 };
115
116/* Construct an ioctl from constructed type plus other fields. */
117#define _IOC(inout, group, num, type) \
118 ((num) | ((((group) - 'f') | ((type) | (inout) << 19) << 4) << 7))
119
120/* Dissect an ioctl into its component fields. */
121#define _IOC_INOUT(request) (((unsigned int) (request) >> 30) & IOC_INOUT)
122#define _IOC_GROUP(request) ('f' + (((unsigned int) (request) >> 7) & 0xf))
123#define _IOC_COMMAND(request) ((unsigned int) (request) & 0x7f)
124#define _IOC_TYPE(request) (((unsigned int) (request) >> 11) & 0x7ffff)
125#define _IOC_NOTYPE(request) ((unsigned int) (request) & 0x3ff)
126
127/* Construct a type information field from
128 the broken-out type and count fields. */
129#define _IOT(t0, c0, t1, c1, t2, c2) \
130 ((c2) | (((c1) | ((c0) | ((t2) | ((t1) | (t0) << 2) << 2) << 5) << 5) << 3))
131
132/* Dissect a type information field into the type and count fields. */
133#define _IOT_TYPE0(type) (((unsigned int) (type) >> 17) & 3)
134#define _IOT_TYPE1(type) (((unsigned int) (type) >> 15) & 3)
135#define _IOT_TYPE2(type) (((unsigned int) (type) >> 13) & 3)
136#define _IOT_COUNT0(type) (((unsigned int) (type) >> 8) & 0x1f)
137#define _IOT_COUNT1(type) (((unsigned int) (type) >> 3) & 0x1f)
138#define _IOT_COUNT2(type) (((unsigned int) (type) >> 0) & 7)
139
140/* Construct an ioctl from all the broken-out fields. */
141#define _IOCT(inout, group, num, t0, c0, t1, c1, t2, c2) \
142 _IOC ((inout), (group), (num), _IOT ((t0), (c0), (t1), (c1), (t2), (c2)))
143
144/* Construct an individual type field for TYPE. */
145#define _IOTS(type) \
146 (sizeof (type) == 8 ? IOC_64 : (enum __ioctl_datum) (sizeof (type) >> 1))
147
148/* Construct a type information field for
149 a single argument of the scalar TYPE. */
150#define _IOT_SIMPLE(type) _IOT (_IOTS (type), 1, 0, 0, 0, 0)
151
152/* Basic C types. */
153#define _IOT__IOTBASE_char _IOT_SIMPLE (char)
154#define _IOT__IOTBASE_short _IOT_SIMPLE (short)
155#define _IOT__IOTBASE_int _IOT_SIMPLE (int)
156#define _IOT__IOTBASE_long _IOT_SIMPLE (long)
157#define _IOT_char _IOT_SIMPLE (char)
158#define _IOT_short _IOT_SIMPLE (short)
159#define _IOT_int _IOT_SIMPLE (int)
160#define _IOT_long _IOT_SIMPLE (long)
161
162#define _IOT__IOTBASE_int8_t _IOT_SIMPLE (int8_t)
163#define _IOT__IOTBASE_uint8_t _IOT_SIMPLE (uint8_t)
164#define _IOT__IOTBASE_int16_t _IOT_SIMPLE (int16_t)
165#define _IOT__IOTBASE_uint16_t _IOT_SIMPLE (uint16_t)
166#define _IOT__IOTBASE_int32_t _IOT_SIMPLE (int32_t)
167#define _IOT__IOTBASE_uint32_t _IOT_SIMPLE (uint32_t)
168#define _IOT__IOTBASE_int64_t _IOT_SIMPLE (int64_t)
169#define _IOT__IOTBASE_uint64_t _IOT_SIMPLE (uint64_t)
170
171#define _IOT__IOTBASE_size_t _IOT_SIMPLE (size_t)
172#define _IOT__IOTBASE_ssize_t _IOT_SIMPLE (ssize_t)
173
174
175/* Standard flavors of ioctls.
176 _IOT_foobar is defined either in this file,
177 or where struct foobar is defined. */
178#define _IO(g, n) _IOC (IOC_VOID, (g), (n), 0)
179#define _IOIW(g, n, t) _IOC (IOC_VOID, (g), (n), _IOC_ENCODE_TYPE (t))
180#define _IOR(g, n, t) _IOC (IOC_OUT, (g), (n), _IOC_ENCODE_TYPE (t))
181#define _IOW(g, n, t) _IOC (IOC_IN, (g), (n), _IOC_ENCODE_TYPE (t))
182#define _IOWR(g, n, t) _IOC (IOC_INOUT, (g), (n), _IOC_ENCODE_TYPE (t))
183
184/* These macros do some preprocessor gymnastics to turn a TYPESPEC of
185 `struct foobar' into the identifier `_IOT_foobar', which is generally
186 defined using `_IOT' (above) in whatever file defines `struct foobar'.
187 For a TYPESPEC that does not begin with `struct' produces a different
188 identifier: `int' produces `_IOT__IOTBASE_int'. These identifiers
189 are defined for the basic C types above. */
190#define _IOC_ENCODE_TYPE(typespec) _IOC_ENCODE_TYPE_1(_IOTBASE_##typespec)
191#define _IOTBASE_struct
192#define _IOC_ENCODE_TYPE_1(typespec) _IOC_ENCODE_TYPE_2(typespec)
193#define _IOC_ENCODE_TYPE_2(typespec) _IOT_##typespec
194
195/* Also, ignore signedness. */
196#define _IOTBASE_unsigned
197#define _IOTBASE_signed
198
199
200/* ioctls verbatim from 4.4 <sys/ioctl.h>. */
201
202#define TIOCMODG _IOR('t', 3, int) /* get modem control state */
203#define TIOCMODS _IOW('t', 4, int) /* set modem control state */
204#define TIOCM_LE 0001 /* line enable */
205#define TIOCM_DTR 0002 /* data terminal ready */
206#define TIOCM_RTS 0004 /* request to send */
207#define TIOCM_ST 0010 /* secondary transmit */
208#define TIOCM_SR 0020 /* secondary receive */
209#define TIOCM_CTS 0040 /* clear to send */
210#define TIOCM_CAR 0100 /* carrier detect */
211#define TIOCM_CD TIOCM_CAR
212#define TIOCM_RNG 0200 /* ring */
213#define TIOCM_RI TIOCM_RNG
214#define TIOCM_DSR 0400 /* data set ready */
215 /* 8-10 compat */
216#define TIOCEXCL _IO('t', 13) /* set exclusive use of tty */
217#define TIOCNXCL _IO('t', 14) /* reset exclusive use of tty */
218 /* 15 unused */
219#define TIOCFLUSH _IOW('t', 16, int) /* flush buffers */
220 /* 17-18 compat */
221#define TIOCGETA _IOR('t', 19, struct termios) /* get termios struct */
222#define TIOCSETA _IOW('t', 20, struct termios) /* set termios struct */
223#define TIOCSETAW _IOW('t', 21, struct termios) /* drain output, set */
224#define TIOCSETAF _IOW('t', 22, struct termios) /* drn out, fls in, set */
225#define TIOCGETD _IOR('t', 26, int) /* get line discipline */
226#define TIOCSETD _IOW('t', 27, int) /* set line discipline */
227 /* 127-124 compat */
228#define TIOCSBRK _IO('t', 123) /* set break bit */
229#define TIOCCBRK _IO('t', 122) /* clear break bit */
230#define TIOCSDTR _IO('t', 121) /* set data terminal ready */
231#define TIOCCDTR _IO('t', 120) /* clear data terminal ready */
232#define TIOCGPGRP _IOR('t', 119, int) /* get pgrp of tty */
233#define TIOCSPGRP _IOW('t', 118, int) /* set pgrp of tty */
234 /* 117-116 compat */
235#define TIOCOUTQ _IOR('t', 115, int) /* output queue size */
236#define TIOCSTI _IOW('t', 114, char) /* simulate terminal input */
237#define TIOCNOTTY _IO('t', 113) /* void tty association */
238#define TIOCPKT _IOW('t', 112, int) /* pty: set/clear packet mode */
239#define TIOCPKT_DATA 0x00 /* data packet */
240#define TIOCPKT_FLUSHREAD 0x01 /* flush packet */
241#define TIOCPKT_FLUSHWRITE 0x02 /* flush packet */
242#define TIOCPKT_STOP 0x04 /* stop output */
243#define TIOCPKT_START 0x08 /* start output */
244#define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */
245#define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */
246#define TIOCPKT_IOCTL 0x40 /* state change of pty driver */
247#define TIOCSTOP _IO('t', 111) /* stop output, like ^S */
248#define TIOCSTART _IO('t', 110) /* start output, like ^Q */
249#define TIOCMSET _IOW('t', 109, int) /* set all modem bits */
250#define TIOCMBIS _IOW('t', 108, int) /* bis modem bits */
251#define TIOCMBIC _IOW('t', 107, int) /* bic modem bits */
252#define TIOCMGET _IOR('t', 106, int) /* get all modem bits */
253#define TIOCREMOTE _IOW('t', 105, int) /* remote input editing */
254#define TIOCGWINSZ _IOR('t', 104, struct winsize) /* get window size */
255#define TIOCSWINSZ _IOW('t', 103, struct winsize) /* set window size */
256#define TIOCUCNTL _IOW('t', 102, int) /* pty: set/clr usr cntl mode */
257#define UIOCCMD(n) _IO('u', n) /* usr cntl op "n" */
258#define TIOCCONS _IOW('t', 98, int) /* become virtual console */
259#define TIOCSCTTY _IO('t', 97) /* become controlling tty */
260#define TIOCEXT _IOW('t', 96, int) /* pty: external processing */
261#define TIOCSIG _IO('t', 95) /* pty: generate signal */
262#define TIOCDRAIN _IO('t', 94) /* wait till output drained */
263
264#define TTYDISC 0 /* termios tty line discipline */
265#define TABLDISC 3 /* tablet discipline */
266#define SLIPDISC 4 /* serial IP discipline */
267
268
269#define FIOCLEX _IO('f', 1) /* set close on exec on fd */
270#define FIONCLEX _IO('f', 2) /* remove close on exec */
271#define FIONREAD _IOR('f', 127, int) /* get # bytes to read */
272#define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */
273#define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */
274#define FIOSETOWN _IOW('f', 124, int) /* set owner */
275#define FIOGETOWN _IOR('f', 123, int) /* get owner */
276
277/* socket i/o controls */
278#define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */
279#define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */
280#define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */
281#define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */
282#define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */
283#define SIOCSPGRP _IOW('s', 8, int) /* set process group */
284#define SIOCGPGRP _IOR('s', 9, int) /* get process group */
285
286#define SIOCADDRT _IOW('r', 10, struct ifrtreq) /* add route */
287#define SIOCDELRT _IOW('r', 11, struct ifrtreq) /* delete route */
288
289#define SIOCSIFADDR _IOW('i', 12, struct ifreq) /* set ifnet address */
290#define OSIOCGIFADDR _IOWR('i',13, struct ifreq) /* get ifnet address */
291#define SIOCGIFADDR _IOWR('i',33, struct ifreq) /* get ifnet address */
292#define SIOCGIFHWADDR _IOWR('i',39, struct ifreq) /* get hwaddress */
293#define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */
294#define OSIOCGIFDSTADDR _IOWR('i',15, struct ifreq) /* get p-p address */
295#define SIOCGIFDSTADDR _IOWR('i',34, struct ifreq) /* get p-p address */
296#define SIOCSIFFLAGS _IOW('i', 16, struct ifreq_short)/* set ifnet flags */
297#define SIOCGIFFLAGS _IOWR('i',17, struct ifreq_short)/* get ifnet flags */
298#define OSIOCGIFBRDADDR _IOWR('i',18, struct ifreq) /* get broadcast addr */
299#define SIOCGIFBRDADDR _IOWR('i',35, struct ifreq) /* get broadcast addr */
300#define SIOCSIFBRDADDR _IOW('i',19, struct ifreq) /* set broadcast addr */
301#define OSIOCGIFCONF _IOWR('i',20, struct ifconf) /* get ifnet list */
302#define SIOCGIFCONF _IOWR('i',36, struct ifconf) /* get ifnet list */
303#define OSIOCGIFNETMASK _IOWR('i',21, struct ifreq) /* get net addr mask */
304#define SIOCGIFNETMASK _IOWR('i',37, struct ifreq) /* get net addr mask */
305#define SIOCSIFNETMASK _IOW('i',22, struct ifreq) /* set net addr mask */
306#define SIOCGIFMETRIC _IOWR('i',23, struct ifreq_int) /* get IF metric */
307#define SIOCSIFMETRIC _IOW('i',24, struct ifreq_int) /* set IF metric */
308#define SIOCDIFADDR _IOW('i',25, struct ifreq) /* delete IF addr */
309#define SIOCAIFADDR _IOW('i',26, struct ifaliasreq) /* add/chg IF alias */
310
311#define SIOCSARP _IOW('i', 30, struct arpreq) /* set arp entry */
312#define OSIOCGARP _IOWR('i',31, struct arpreq) /* get arp entry */
313#define SIOCGARP _IOWR('i',38, struct arpreq) /* get arp entry */
314#define SIOCDARP _IOW('i', 32, struct arpreq) /* delete arp entry */
315
316#define SIOCGIFMTU _IOWR('i', 51, struct ifreq_int)/* get IF mtu */
317#define SIOCSIFMTU _IOW('i', 52, struct ifreq_int) /* set IF mtu */
318
319#define SIOCGIFINDEX _IOWR('i', 90, struct ifreq_int)/* get IF index */
320#define SIOCGIFNAME _IOWR('i', 91, struct ifreq_int)/* set IF name */
321
322
323/* Compatibility with 4.3 BSD terminal driver.
324 From 4.4 <sys/ioctl_compat.h>. */
325
326#ifdef __USE_MISC
327#ifdef USE_OLD_TTY
328# undef TIOCGETD
329# define TIOCGETD _IOR('t', 0, int) /* get line discipline */
330# undef TIOCSETD
331# define TIOCSETD _IOW('t', 1, int) /* set line discipline */
332#else
333# define OTIOCGETD _IOR('t', 0, int) /* get line discipline */
334# define OTIOCSETD _IOW('t', 1, int) /* set line discipline */
335#endif
336#define TIOCHPCL _IO('t', 2) /* hang up on last close */
337#define TIOCGETP _IOR('t', 8,struct sgttyb)/* get parameters -- gtty */
338#define TIOCSETP _IOW('t', 9,struct sgttyb)/* set parameters -- stty */
339#define TIOCSETN _IOW('t',10,struct sgttyb)/* as above, but no flushtty*/
340#define TIOCSETC _IOW('t',17,struct tchars)/* set special characters */
341#define TIOCGETC _IOR('t',18,struct tchars)/* get special characters */
342#define TANDEM 0x00000001 /* send stopc on out q full */
343#define CBREAK 0x00000002 /* half-cooked mode */
344#define LCASE 0x00000004 /* simulate lower case */
345#define ECHO 0x00000008 /* echo input */
346#define CRMOD 0x00000010 /* map \r to \r\n on output */
347#define RAW 0x00000020 /* no i/o processing */
348#define ODDP 0x00000040 /* get/send odd parity */
349#define EVENP 0x00000080 /* get/send even parity */
350#define ANYP 0x000000c0 /* get any parity/send none */
351#define NLDELAY 0x00000300 /* \n delay */
352#define NL0 0x00000000
353#define NL1 0x00000100 /* tty 37 */
354#define NL2 0x00000200 /* vt05 */
355#define NL3 0x00000300
356#define TBDELAY 0x00000c00 /* horizontal tab delay */
357#define TAB0 0x00000000
358#define TAB1 0x00000400 /* tty 37 */
359#define TAB2 0x00000800
360#define XTABS 0x00000c00 /* expand tabs on output */
361#define CRDELAY 0x00003000 /* \r delay */
362#define CR0 0x00000000
363#define CR1 0x00001000 /* tn 300 */
364#define CR2 0x00002000 /* tty 37 */
365#define CR3 0x00003000 /* concept 100 */
366#define VTDELAY 0x00004000 /* vertical tab delay */
367#define FF0 0x00000000
368#define FF1 0x00004000 /* tty 37 */
369#define BSDELAY 0x00008000 /* \b delay */
370#define BS0 0x00000000
371#define BS1 0x00008000
372#define ALLDELAY (NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY)
373#define CRTBS 0x00010000 /* do backspacing for crt */
374#define PRTERA 0x00020000 /* \ ... / erase */
375#define CRTERA 0x00040000 /* " \b " to wipe out char */
376#define TILDE 0x00080000 /* hazeltine tilde kludge */
377#define MDMBUF 0x00100000 /*start/stop output on carrier*/
378#define LITOUT 0x00200000 /* literal output */
379#define TOSTOP 0x00400000 /*SIGSTOP on background output*/
380#define FLUSHO 0x00800000 /* flush output to terminal */
381#define NOHANG 0x01000000 /* (no-op) was no SIGHUP on carrier drop */
382#define L001000 0x02000000
383#define CRTKIL 0x04000000 /* kill line with " \b " */
384#define PASS8 0x08000000
385#define CTLECH 0x10000000 /* echo control chars as ^X */
386#define PENDIN 0x20000000 /* tp->t_rawq needs reread */
387#define DECCTQ 0x40000000 /* only ^Q starts after ^S */
388#define NOFLSH 0x80000000 /* no output flush on signal */
389#define TIOCLBIS _IOW('t', 127, int) /* bis local mode bits */
390#define TIOCLBIC _IOW('t', 126, int) /* bic local mode bits */
391#define TIOCLSET _IOW('t', 125, int) /* set entire local mode word */
392#define TIOCLGET _IOR('t', 124, int) /* get local modes */
393#define LCRTBS (CRTBS>>16)
394#define LPRTERA (PRTERA>>16)
395#define LCRTERA (CRTERA>>16)
396#define LTILDE (TILDE>>16)
397#define LMDMBUF (MDMBUF>>16)
398#define LLITOUT (LITOUT>>16)
399#define LTOSTOP (TOSTOP>>16)
400#define LFLUSHO (FLUSHO>>16)
401#define LNOHANG (NOHANG>>16)
402#define LCRTKIL (CRTKIL>>16)
403#define LPASS8 (PASS8>>16)
404#define LCTLECH (CTLECH>>16)
405#define LPENDIN (PENDIN>>16)
406#define LDECCTQ (DECCTQ>>16)
407#define LNOFLSH (NOFLSH>>16)
408#define TIOCSLTC _IOW('t',117,struct ltchars)/* set local special chars*/
409#define TIOCGLTC _IOR('t',116,struct ltchars)/* get local special chars*/
410#define OTIOCCONS _IO('t', 98) /* for hp300 -- sans int arg */
411#define OTTYDISC 0
412#define NETLDISC 1
413#define NTTYDISC 2
414
415/* From 4.4 <sys/ttydev.h>. */
416#ifdef USE_OLD_TTY
417# define B0 0
418# define B50 1
419# define B75 2
420# define B110 3
421# define B134 4
422# define B150 5
423# define B200 6
424# define B300 7
425# define B600 8
426# define B1200 9
427# define B1800 10
428# define B2400 11
429# define B4800 12
430# define B9600 13
431# define EXTA 14
432# define EXTB 15
433#endif /* USE_OLD_TTY */
434#endif
435
436#endif /* bits/ioctls.h */
437

Warning: This file is not a C or C++ file. It does not have highlighting.

source code of glibc/sysdeps/mach/hurd/bits/ioctls.h