home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Headers / bsd / sys / ioctl.h < prev    next >
Text File  |  1993-10-19  |  16KB  |  391 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1987 Carnegie-Mellon University
  4.  * All rights reserved.  The CMU software License Agreement specifies
  5.  * the terms and conditions for use and redistribution.
  6.  */
  7.  
  8. /*
  9.  * HISTORY
  10.  *  7-Jan-93  Mac Gillon (mgillon) at NeXT
  11.  *    Integrated POSIX support
  12.  *
  13.  * 04-Dec-89  Mike DeMoney (mike) at NeXT
  14.  *  Added PASS8OUT for cooked EUC support
  15.  *
  16.  * 27-Feb-88  John Seamons (jks) at NeXT
  17.  *    Changed macros to conform to ANSI C.
  18.  *
  19.  * 13-Feb-88  John Seamons (jks) at NeXT
  20.  *    NeXT: enable 4.2 manifest TIOCSCONS.
  21.  *
  22.  * 30-Jan-87  Mike Accetta (mja) at Carnegie-Mellon University
  23.  *    CS_RPAUSE: Added FIOCNOSPC definition.
  24.  *    [ V5.1(F1) ]
  25.  *
  26.  * 24-Dec-86  Bill Bolosky (bolosky) at Carnegie-Mellon University
  27.  *    romp: Added TIOCCONS ioctl for RT console silliness.
  28.  *
  29.  *  5-Aug-86  Jonathan J. Chew (jjc) at Carnegie-Mellon University
  30.  *    Added for Sun:
  31.  *    1) Added mouse and keyboard disciplines for Sun
  32.  *
  33.  * 25-Jan-86  Avadis Tevanian (avie) at Carnegie-Mellon University
  34.  *    Upgraded to 4.3.
  35.  *
  36.  * 10-Jul-85  Robert V Baron (rvb) at Carnegie-Mellon University
  37.  *    Added SIOCBROAD to enable udp broadcast.
  38.  */
  39.  
  40. /*
  41.  * Copyright (c) 1982, 1986 Regents of the University of California.
  42.  * All rights reserved.  The Berkeley software License Agreement
  43.  * specifies the terms and conditions for redistribution.
  44.  *
  45.  *    @(#)ioctl.h    7.1 (Berkeley) 6/4/86
  46.  */
  47.  
  48. /*
  49.  * Some of the Posix support comes from this:
  50.  */
  51. /*-
  52.  * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
  53.  * All rights reserved.
  54.  *
  55.  * Redistribution and use in source and binary forms, with or without
  56.  * modification, are permitted provided that the following conditions
  57.  * are met:
  58.  * 1. Redistributions of source code must retain the above copyright
  59.  *    notice, this list of conditions and the following disclaimer.
  60.  * 2. Redistributions in binary form must reproduce the above copyright
  61.  *    notice, this list of conditions and the following disclaimer in the
  62.  *    documentation and/or other materials provided with the distribution.
  63.  * 3. All advertising materials mentioning features or use of this software
  64.  *    must display the following acknowledgement:
  65.  *    This product includes software developed by the University of
  66.  *    California, Berkeley and its contributors.
  67.  * 4. Neither the name of the University nor the names of its contributors
  68.  *    may be used to endorse or promote products derived from this software
  69.  *    without specific prior written permission.
  70.  *
  71.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  72.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  73.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  74.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  75.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  76.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  77.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  78.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  79.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  80.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  81.  * SUCH DAMAGE.
  82.  *
  83.  *    @(#)ioctl.h    7.19 (Berkeley) 6/26/91
  84.  */
  85.  
  86. /*
  87.  * Ioctl definitions
  88.  */
  89. #ifndef    _IOCTL_
  90. #define    _IOCTL_
  91. #import <sys/ttychars.h>
  92. #import <sys/ttydev.h>
  93.  
  94. struct tchars {
  95.     char    t_intrc;    /* interrupt */
  96.     char    t_quitc;    /* quit */
  97.     char    t_startc;    /* start output */
  98.     char    t_stopc;    /* stop output */
  99.     char    t_eofc;        /* end-of-file */
  100.     char    t_brkc;        /* input delimiter (like nl) */
  101. };
  102. struct ltchars {
  103.     char    t_suspc;    /* stop process signal */
  104.     char    t_dsuspc;    /* delayed stop process signal */
  105.     char    t_rprntc;    /* reprint line */
  106.     char    t_flushc;    /* flush output (toggles) */
  107.     char    t_werasc;    /* word erase */
  108.     char    t_lnextc;    /* literal next character */
  109. };
  110.  
  111. /*
  112.  * Structure for TIOCGETP and TIOCSETP ioctls.
  113.  */
  114.  
  115. #ifndef _SGTTYB_
  116. #define    _SGTTYB_
  117. struct sgttyb {
  118.     char    sg_ispeed;        /* input speed */
  119.     char    sg_ospeed;        /* output speed */
  120.     char    sg_erase;        /* erase character */
  121.     char    sg_kill;        /* kill character */
  122.     short    sg_flags;        /* mode flags */
  123. };
  124. #endif    _SGTTYB_
  125.  
  126. /*
  127.  * Window/terminal size structure.
  128.  * This information is stored by the kernel
  129.  * in order to provide a consistent interface,
  130.  * but is not used by the kernel.
  131.  *
  132.  * Type must be "unsigned short" so that types.h not required.
  133.  */
  134. struct winsize {
  135.     unsigned short    ws_row;            /* rows, in characters */
  136.     unsigned short    ws_col;            /* columns, in characters */
  137.     unsigned short    ws_xpixel;        /* horizontal size, pixels */
  138.     unsigned short    ws_ypixel;        /* vertical size, pixels */
  139. };
  140.  
  141. /*
  142.  * Pun for SUN.
  143.  */
  144. struct ttysize {
  145.     unsigned short    ts_lines;
  146.     unsigned short    ts_cols;
  147.     unsigned short    ts_xxx;
  148.     unsigned short    ts_yyy;
  149. };
  150. #define    TIOCGSIZE    TIOCGWINSZ
  151. #define    TIOCSSIZE    TIOCSWINSZ
  152.  
  153. #ifndef _IO
  154. /*
  155.  * Ioctl's have the command encoded in the lower word,
  156.  * and the size of any in or out parameters in the upper
  157.  * word.  The high 2 bits of the upper word are used
  158.  * to encode the in/out status of the parameter; for now
  159.  * we restrict parameters to at most 128 bytes.
  160.  */
  161. #define    IOCPARM_MASK    0x7f        /* parameters must be < 128 bytes */
  162. #define    IOC_VOID    0x20000000    /* no parameters */
  163. #define    IOC_OUT        0x40000000    /* copy out parameters */
  164. #define    IOC_IN        0x80000000    /* copy in parameters */
  165. #define    IOC_INOUT    (IOC_IN|IOC_OUT)
  166. /* the 0x20000000 is so we can distinguish new ioctl's from old */
  167. #define    _IO(x,y)    (IOC_VOID|(x<<8)|y)
  168. #define    _IOR(x,y,t)    (IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
  169. #define    _IOW(x,y,t)    (IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
  170. /* this should be _IORW, but stdio got there first */
  171. #define    _IOWR(x,y,t)    (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
  172. #endif    _IO
  173.  
  174. /*
  175.  * tty ioctl commands
  176.  */
  177. #define    TIOCGETD    _IOR('t', 0, int)        /* get line discipline */
  178. #define    TIOCSETD    _IOW('t', 1, int)        /* set line discipline */
  179. #define    TIOCHPCL    _IO('t', 2)        /* hang up on last close */
  180. #define    TIOCMODG    _IOR('t', 3, int)        /* get modem control state */
  181. #define    TIOCMODS    _IOW('t', 4, int)        /* set modem control state */
  182. #define        TIOCM_LE    0001        /* line enable */
  183. #define        TIOCM_DTR    0002        /* data terminal ready */
  184. #define        TIOCM_RTS    0004        /* request to send */
  185. #define        TIOCM_ST    0010        /* secondary transmit */
  186. #define        TIOCM_SR    0020        /* secondary receive */
  187. #define        TIOCM_CTS    0040        /* clear to send */
  188. #define        TIOCM_CAR    0100        /* carrier detect */
  189. #define        TIOCM_CD    TIOCM_CAR
  190. #define        TIOCM_RNG    0200        /* ring */
  191. #define        TIOCM_RI    TIOCM_RNG
  192. #define        TIOCM_DSR    0400        /* data set ready */
  193. #define    TIOCGETP    _IOR('t', 8,struct sgttyb)/* get parameters -- gtty */
  194. #define    TIOCSETP    _IOW('t', 9,struct sgttyb)/* set parameters -- stty */
  195. #define    TIOCSETN    _IOW('t',10,struct sgttyb)/* as above, but no flushtty */
  196. #define    TIOCEXCL    _IO('t', 13)        /* set exclusive use of tty */
  197. #define    TIOCNXCL    _IO('t', 14)        /* reset exclusive use of tty */
  198. #define    TIOCFLUSH    _IOW('t', 16, int)    /* flush buffers */
  199. #define    TIOCSETC    _IOW('t',17,struct tchars)/* set special characters */
  200. #define    TIOCGETC    _IOR('t',18,struct tchars)/* get special characters */
  201. #define        TANDEM        0x00000001    /* send stopc on out q full */
  202. #define        CBREAK        0x00000002    /* half-cooked mode */
  203. #define        LCASE        0x00000004    /* simulate lower case */
  204. #define        ECHO        0x00000008    /* echo input */
  205. #define        CRMOD        0x00000010    /* map \r to \r\n on output */
  206. #define        RAW        0x00000020    /* no i/o processing */
  207. #define        ODDP        0x00000040    /* get/send odd parity */
  208. #define        EVENP        0x00000080    /* get/send even parity */
  209. #define        ANYP        0x000000c0    /* get any parity/send even */
  210. #define        NLDELAY        0x00000300    /* \n delay */
  211. #define            NL0    0x00000000
  212. #define            NL1    0x00000100    /* tty 37 */
  213. #define            NL2    0x00000200    /* vt05 */
  214. #define            NL3    0x00000300
  215. #define        TBDELAY        0x00000c00    /* horizontal tab delay */
  216. #define            TAB0    0x00000000
  217. #define            TAB1    0x00000400    /* tty 37 */
  218. #define            TAB2    0x00000800
  219. #define        XTABS        0x00000c00    /* expand tabs on output */
  220. #define        CRDELAY        0x00003000    /* \r delay */
  221. #define            CR0    0x00000000
  222. #define            CR1    0x00001000    /* tn 300 */
  223. #define            CR2    0x00002000    /* tty 37 */
  224. #define            CR3    0x00003000    /* concept 100 */
  225. #define        VTDELAY        0x00004000    /* vertical tab delay */
  226. #define            FF0    0x00000000
  227. #define            FF1    0x00004000    /* tty 37 */
  228. #define        BSDELAY        0x00008000    /* \b delay */
  229. #define            BS0    0x00000000
  230. #define            BS1    0x00008000
  231. #define        ALLDELAY    (NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY)
  232. #define        CRTBS        0x00010000    /* do backspacing for crt */
  233. #define        PRTERA        0x00020000    /* \ ... / erase */
  234. #define        CRTERA        0x00040000    /* " \b " to wipe out char */
  235. #if    NeXT
  236. #define        EUCBKSP        0x00080000    /* EUC backspace processing */
  237. #else    NeXT
  238. #define        TILDE        0x00080000    /* hazeltine tilde kludge */
  239. #endif    NeXT
  240. #define        MDMBUF        0x00100000    /* start/stop output on carrier intr */
  241. #define        LITOUT        0x00200000    /* literal output */
  242. #define        TOSTOP        0x00400000    /* SIGSTOP on background output */
  243. #define        FLUSHO        0x00800000    /* flush output to terminal */
  244. #define        NOHANG        0x01000000    /* no SIGHUP on carrier drop */
  245. #define        PASS8OUT    0x02000000    /* 8 bit no parity for cooked output */
  246. #define        CRTKIL        0x04000000    /* kill line with " \b " */
  247. #define        PASS8        0x08000000    /* 8 bit no parity for cooked input */
  248. #define        CTLECH        0x10000000    /* echo control chars as ^X */
  249. #define        PENDIN        0x20000000    /* tp->t_rawq needs reread */
  250. #define        DECCTQ        0x40000000    /* only ^Q starts after ^S */
  251. #define        NOFLSH        0x80000000    /* no output flush on signal */
  252. /* locals, from 127 down */
  253. #define    TIOCLBIS    _IOW('t', 127, int)    /* bis local mode bits */
  254. #define    TIOCLBIC    _IOW('t', 126, int)    /* bic local mode bits */
  255. #define    TIOCLSET    _IOW('t', 125, int)    /* set entire local mode word */
  256. #define    TIOCLGET    _IOR('t', 124, int)    /* get local modes */
  257. #define        LCRTBS        (CRTBS>>16)
  258. #define        LPRTERA        (PRTERA>>16)
  259. #define        LCRTERA        (CRTERA>>16)
  260. #if    NeXT
  261. #define        LEUCBKSP    (EUCBKSP>>16)
  262. #else    NeXT
  263. #define        LTILDE        (TILDE>>16)
  264. #endif    NeXT
  265. #define        LMDMBUF        (MDMBUF>>16)
  266. #define        LLITOUT        (LITOUT>>16)
  267. #define        LTOSTOP        (TOSTOP>>16)
  268. #define        LFLUSHO        (FLUSHO>>16)
  269. #define        LNOHANG        (NOHANG>>16)
  270. #define        LPASS8OUT    (PASS8OUT>>16)
  271. #define        LCRTKIL        (CRTKIL>>16)
  272. #define        LPASS8        (PASS8>>16)
  273. #define        LCTLECH        (CTLECH>>16)
  274. #define        LPENDIN        (PENDIN>>16)
  275. #define        LDECCTQ        (DECCTQ>>16)
  276. #define        LNOFLSH        (NOFLSH>>16)
  277. #define    TIOCSBRK    _IO('t', 123)        /* set break bit */
  278. #define    TIOCCBRK    _IO('t', 122)        /* clear break bit */
  279. #define    TIOCSDTR    _IO('t', 121)        /* set data terminal ready */
  280. #define    TIOCCDTR    _IO('t', 120)        /* clear data terminal ready */
  281. #define    TIOCGPGRP    _IOR('t', 119, int)    /* get pgrp of tty */
  282. #define    TIOCSPGRP    _IOW('t', 118, int)    /* set pgrp of tty */
  283. #define    TIOCSLTC    _IOW('t',117,struct ltchars)/* set local special chars */
  284. #define    TIOCGLTC    _IOR('t',116,struct ltchars)/* get local special chars */
  285. #define    TIOCOUTQ    _IOR('t', 115, int)    /* output queue size */
  286. #define    TIOCSTI        _IOW('t', 114, char)    /* simulate terminal input */
  287. #define    TIOCNOTTY    _IO('t', 113)        /* void tty association */
  288. #define    TIOCPKT        _IOW('t', 112, int)    /* pty: set/clear packet mode */
  289. #define        TIOCPKT_DATA        0x00    /* data packet */
  290. #define        TIOCPKT_FLUSHREAD    0x01    /* flush packet */
  291. #define        TIOCPKT_FLUSHWRITE    0x02    /* flush packet */
  292. #define        TIOCPKT_STOP        0x04    /* stop output */
  293. #define        TIOCPKT_START        0x08    /* start output */
  294. #define        TIOCPKT_NOSTOP        0x10    /* no more ^S, ^Q */
  295. #define        TIOCPKT_DOSTOP        0x20    /* now do ^S ^Q */
  296. #define        TIOCPKT_IOCTL        0x40    /* pty driver state change */
  297. #define    TIOCSTOP    _IO('t', 111)        /* stop output, like ^S */
  298. #define    TIOCSTART    _IO('t', 110)        /* start output, like ^Q */
  299. #define    TIOCMSET    _IOW('t', 109, int)    /* set all modem bits */
  300. #define    TIOCMBIS    _IOW('t', 108, int)    /* bis modem bits */
  301. #define    TIOCMBIC    _IOW('t', 107, int)    /* bic modem bits */
  302. #define    TIOCMGET    _IOR('t', 106, int)    /* get all modem bits */
  303. #define    TIOCREMOTE    _IOW('t', 105, int)    /* remote input editing */
  304. #define    TIOCSCONS    _IO('t', 104)        /* 4.2 compatibility */
  305.  
  306. #define    TIOCGWINSZ    _IOR('t', 104, struct winsize)    /* get window size */
  307. #define    TIOCSWINSZ    _IOW('t', 103, struct winsize)    /* set window size */
  308. #define    TIOCUCNTL    _IOW('t', 102, int)    /* pty: set/clr usr cntl mode */
  309.  
  310. #define        UIOCCMD(n)    _IO('u', n)        /* usr cntl op "n" */
  311. #define    TIOCCONS    _IO('t', 98)        /* become virtual console */
  312. #define    TIOCEXT        _IOW('t', 97, int)    /* pty: external processing */
  313. #define    TIOCGSTATE    _IOR('t', 96, int)    /* pty: get internal state */
  314. #define    TIOCSIG        _IO('t', 95)        /* pty: generate signal */
  315.  
  316. /*
  317.  * Posix support
  318.  */
  319. #import <sys/termios.h>
  320. #define TIOCGETA    _IOR('t', 19, struct termios) /* get termios struct */
  321. #define TIOCSETA    _IOW('t', 20, struct termios) /* set termios struct */
  322. #define TIOCSETAW    _IOW('t', 21, struct termios) /* drain output, set */
  323. #define TIOCSETAF    _IOW('t', 22, struct termios) /* drn out, fls in, set */
  324. #define TIOCDRAIN    _IO('t', 94)        /* wait till output drained */
  325.  
  326. #define    OTTYDISC    0        /* old, v7 std tty driver */
  327. #define    NETLDISC    1        /* line discip for berk net */
  328. #define    NTTYDISC    2        /* new tty discipline */
  329. #define    TABLDISC    3        /* tablet discipline */
  330. #define    SLIPDISC    4        /* serial IP discipline */
  331. #define    PPPDISC        5        /* Point-to-Point Protocol */
  332.  
  333. #define    FIOCLEX        _IO('f', 1)        /* set exclusive use on fd */
  334. #define    FIONCLEX    _IO('f', 2)        /* remove exclusive use */
  335. #define    FIOCDIROK    _IOW('f', 104, int)
  336. /* CS_RPAUSE */
  337. /* Disk space resource pause per-file control */
  338. #define    FIOCNOSPC    _IOWR('f', 106, int)
  339. #define    FIOCNOSPC_SAME    0            /* no change */
  340. #define    FIOCNOSPC_ERROR    1            /* prohibit pause */
  341. #define    FIOCNOSPC_PAUSE    2            /* allow pause */
  342. /* CS_RPAUSE */
  343. /* another local */
  344. #define    FIONREAD    _IOR('f', 127, int)    /* get # bytes to read */
  345. #define    FIONBIO        _IOW('f', 126, int)    /* set/clear non-blocking i/o */
  346. #define    FIOASYNC    _IOW('f', 125, int)    /* set/clear async i/o */
  347. #define    FIOSETOWN    _IOW('f', 124, int)    /* set owner */
  348. #define    FIOGETOWN    _IOR('f', 123, int)    /* get owner */
  349.  
  350. /* socket i/o controls */
  351. #define    SIOCSHIWAT    _IOW('s',  0, int)        /* set high watermark */
  352. #define    SIOCGHIWAT    _IOR('s',  1, int)        /* get high watermark */
  353. #define    SIOCSLOWAT    _IOW('s',  2, int)        /* set low watermark */
  354. #define    SIOCGLOWAT    _IOR('s',  3, int)        /* get low watermark */
  355. #define    SIOCATMARK    _IOR('s',  7, int)        /* at oob mark? */
  356. #define    SIOCSPGRP    _IOW('s',  8, int)        /* set process group */
  357. #define    SIOCGPGRP    _IOR('s',  9, int)        /* get process group */
  358.  
  359. #define    SIOCADDRT    _IOW('r', 10, struct rtentry)    /* add route */
  360. #define    SIOCDELRT    _IOW('r', 11, struct rtentry)    /* delete route */
  361.  
  362. #define    SIOCSIFADDR    _IOW('i', 12, struct ifreq)    /* set ifnet address */
  363. #define    SIOCGIFADDR    _IOWR('i',13, struct ifreq)    /* get ifnet address */
  364. #define    SIOCSIFDSTADDR    _IOW('i', 14, struct ifreq)    /* set p-p address */
  365. #define    SIOCGIFDSTADDR    _IOWR('i',15, struct ifreq)    /* get p-p address */
  366. #define    SIOCSIFFLAGS    _IOW('i', 16, struct ifreq)    /* set ifnet flags */
  367. #define    SIOCGIFFLAGS    _IOWR('i',17, struct ifreq)    /* get ifnet flags */
  368. #define    SIOCGIFBRDADDR    _IOWR('i',18, struct ifreq)    /* get broadcast addr */
  369. #define    SIOCSIFBRDADDR    _IOW('i',19, struct ifreq)    /* set broadcast addr */
  370. #define    SIOCGIFCONF    _IOWR('i',20, struct ifconf)    /* get ifnet list */
  371. #define    SIOCGIFNETMASK    _IOWR('i',21, struct ifreq)    /* get net addr mask */
  372. #define    SIOCSIFNETMASK    _IOW('i',22, struct ifreq)    /* set net addr mask */
  373. #define    SIOCGIFMETRIC    _IOWR('i',23, struct ifreq)    /* get IF metric */
  374. #define    SIOCSIFMETRIC    _IOW('i',24, struct ifreq)    /* set IF metric */
  375.  
  376. #define    SIOCSARP    _IOW('i', 30, struct arpreq)    /* set arp entry */
  377. #define    SIOCGARP    _IOWR('i',31, struct arpreq)    /* get arp entry */
  378. #define    SIOCDARP    _IOW('i', 32, struct arpreq)    /* delete arp entry */
  379. #define    SIOCAUTOADDR    _IOWR('i', 33, struct ifreq)    /* autoconf addr */
  380. #define SIOCAUTONETMASK    _IOW('i', 34, struct ifreq)    /* autoconf netmask */
  381. #define    SIOCSIFMTU    _IOW('i',127, struct ifreq)    /* set ifnet mtu */
  382. #define    SIOCGIFMTU    _IOWR('i',126, struct ifreq)    /* get ifnet mtu */
  383. #define    SIOCSIFASYNCMAP    _IOW('i',125, struct ifreq)    /* set ppp asyncmap */
  384. #define    SIOCGIFASYNCMAP    _IOWR('i',124, struct ifreq)    /* get ppp asyncmap */
  385.  
  386. #define SIOCBROAD    _IO('s', 255)            /* enable broadcast */
  387.  
  388. #endif    _IOCTL_
  389.  
  390.  
  391.