Back to index

glibc  2.9
ioctls.h
Go to the documentation of this file.
00001 /*-
00002  * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 4. Neither the name of the University nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  *
00029  *     @(#)ioctl.h   7.19 (Berkeley) 6/26/91
00030  */
00031 
00032 #ifndef       _IOCTLS_H_
00033 #define       _IOCTLS_H_
00034 
00035 #define       TIOCGSIZE     TIOCGWINSZ
00036 #define       TIOCSSIZE     TIOCSWINSZ
00037 
00038 /*
00039  * Ioctl's have the command encoded in the lower word, and the size of
00040  * any in or out parameters in the upper word.  The high 3 bits of the
00041  * upper word are used to encode the in/out status of the parameter.
00042  */
00043 #define       IOCPARM_MASK  0x1fff        /* parameter length, at most 13 bits */
00044 #define       IOCPARM_LEN(x)       (((x) >> 16) & IOCPARM_MASK)
00045 #define       IOCBASECMD(x) ((x) & ~IOCPARM_MASK)
00046 #define       IOCGROUP(x)   (((x) >> 8) & 0xff)
00047 
00048 #define       IOCPARM_MAX   NBPG          /* max size of ioctl, mult. of NBPG */
00049 #define       IOC_VOID      0x20000000    /* no parameters */
00050 #define       IOC_OUT              0x40000000    /* copy out parameters */
00051 #define       IOC_IN        0x80000000    /* copy in parameters */
00052 #define       IOC_INOUT     (IOC_IN|IOC_OUT)
00053 #define       IOC_DIRMASK   0xe0000000    /* mask for IN/OUT/VOID */
00054 
00055 #define _IOC(inout,group,num,len) \
00056        (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num))
00057 #define       _IO(g,n)      _IOC(IOC_VOID,       (g), (n), 0)
00058 #define       _IOR(g,n,t)   _IOC(IOC_OUT, (g), (n), sizeof(t))
00059 #define       _IOW(g,n,t)   _IOC(IOC_IN,  (g), (n), sizeof(t))
00060 /* this should be _IORW, but stdio got there first */
00061 #define       _IOWR(g,n,t)  _IOC(IOC_INOUT,      (g), (n), sizeof(t))
00062 
00063 #define       TIOCMODG      _IOR('t', 3, int)    /* get modem control state */
00064 #define       TIOCMODS      _IOW('t', 4, int)    /* set modem control state */
00065 #define              TIOCM_LE      0001          /* line enable */
00066 #define              TIOCM_DTR     0002          /* data terminal ready */
00067 #define              TIOCM_RTS     0004          /* request to send */
00068 #define              TIOCM_ST      0010          /* secondary transmit */
00069 #define              TIOCM_SR      0020          /* secondary receive */
00070 #define              TIOCM_CTS     0040          /* clear to send */
00071 #define              TIOCM_CAR     0100          /* carrier detect */
00072 #define              TIOCM_CD      TIOCM_CAR
00073 #define              TIOCM_RNG     0200          /* ring */
00074 #define              TIOCM_RI      TIOCM_RNG
00075 #define              TIOCM_DSR     0400          /* data set ready */
00076                                           /* 8-10 compat */
00077 #define       TIOCEXCL      _IO('t', 13)         /* set exclusive use of tty */
00078 #define       TIOCNXCL      _IO('t', 14)         /* reset exclusive use of tty */
00079                                           /* 15 unused */
00080 #define       TIOCFLUSH     _IOW('t', 16, int)   /* flush buffers */
00081                                           /* 17-18 compat */
00082 #define       TIOCGETA      _IOR('t', 19, struct termios) /* get termios struct */
00083 #define       TIOCSETA      _IOW('t', 20, struct termios) /* set termios struct */
00084 #define       TIOCSETAW     _IOW('t', 21, struct termios) /* drain output, set */
00085 #define       TIOCSETAF     _IOW('t', 22, struct termios) /* drn out, fls in, set */
00086 #define       TIOCGETD      _IOR('t', 26, int)   /* get line discipline */
00087 #define       TIOCSETD      _IOW('t', 27, int)   /* set line discipline */
00088                                           /* 127-124 compat */
00089 #define       TIOCSBRK      _IO('t', 123)        /* set break bit */
00090 #define       TIOCCBRK      _IO('t', 122)        /* clear break bit */
00091 #define       TIOCSDTR      _IO('t', 121)        /* set data terminal ready */
00092 #define       TIOCCDTR      _IO('t', 120)        /* clear data terminal ready */
00093 #define       TIOCGPGRP     _IOR('t', 119, int)  /* get pgrp of tty */
00094 #define       TIOCSPGRP     _IOW('t', 118, int)  /* set pgrp of tty */
00095                                           /* 117-116 compat */
00096 #define       TIOCOUTQ      _IOR('t', 115, int)  /* output queue size */
00097 #define       TIOCSTI              _IOW('t', 114, char) /* simulate terminal input */
00098 #define       TIOCNOTTY     _IO('t', 113)        /* void tty association */
00099 #define       TIOCPKT              _IOW('t', 112, int)  /* pty: set/clear packet mode */
00100 #define              TIOCPKT_DATA         0x00   /* data packet */
00101 #define              TIOCPKT_FLUSHREAD    0x01   /* flush packet */
00102 #define              TIOCPKT_FLUSHWRITE   0x02   /* flush packet */
00103 #define              TIOCPKT_STOP         0x04   /* stop output */
00104 #define              TIOCPKT_START        0x08   /* start output */
00105 #define              TIOCPKT_NOSTOP              0x10   /* no more ^S, ^Q */
00106 #define              TIOCPKT_DOSTOP              0x20   /* now do ^S ^Q */
00107 #define              TIOCPKT_IOCTL        0x40   /* state change of pty driver */
00108 #define       TIOCSTOP      _IO('t', 111)        /* stop output, like ^S */
00109 #define       TIOCSTART     _IO('t', 110)        /* start output, like ^Q */
00110 #define       TIOCMSET      _IOW('t', 109, int)  /* set all modem bits */
00111 #define       TIOCMBIS      _IOW('t', 108, int)  /* bis modem bits */
00112 #define       TIOCMBIC      _IOW('t', 107, int)  /* bic modem bits */
00113 #define       TIOCMGET      _IOR('t', 106, int)  /* get all modem bits */
00114 #define       TIOCREMOTE    _IOW('t', 105, int)  /* remote input editing */
00115 #define       TIOCGWINSZ    _IOR('t', 104, struct winsize)     /* get window size */
00116 #define       TIOCSWINSZ    _IOW('t', 103, struct winsize)     /* set window size */
00117 #define       TIOCUCNTL     _IOW('t', 102, int)  /* pty: set/clr usr cntl mode */
00118 #define              UIOCCMD(n)    _IO('u', n)          /* usr cntl op "n" */
00119 #define       TIOCCONS      _IOW('t', 98, int)          /* become virtual console */
00120 #define       TIOCSCTTY     _IO('t', 97)         /* become controlling tty */
00121 #define       TIOCEXT              _IOW('t', 96, int)   /* pty: external processing */
00122 #define       TIOCSIG              _IO('t', 95)         /* pty: generate signal */
00123 #define TIOCDRAIN    _IO('t', 94)         /* wait till output drained */
00124 
00125 #define TTYDISC             0             /* termios tty line discipline */
00126 #define       TABLDISC      3             /* tablet discipline */
00127 #define       SLIPDISC      4             /* serial IP discipline */
00128 
00129 
00130 #define       FIOCLEX              _IO('f', 1)          /* set close on exec on fd */
00131 #define       FIONCLEX      _IO('f', 2)          /* remove close on exec */
00132 #define       FIONREAD      _IOR('f', 127, int)  /* get # bytes to read */
00133 #define       FIONBIO              _IOW('f', 126, int)  /* set/clear non-blocking i/o */
00134 #define       FIOASYNC      _IOW('f', 125, int)  /* set/clear async i/o */
00135 #define       FIOSETOWN     _IOW('f', 124, int)  /* set owner */
00136 #define       FIOGETOWN     _IOR('f', 123, int)  /* get owner */
00137 
00138 /* socket i/o controls */
00139 #define       SIOCSHIWAT    _IOW('s',  0, int)          /* set high watermark */
00140 #define       SIOCGHIWAT    _IOR('s',  1, int)          /* get high watermark */
00141 #define       SIOCSLOWAT    _IOW('s',  2, int)          /* set low watermark */
00142 #define       SIOCGLOWAT    _IOR('s',  3, int)          /* get low watermark */
00143 #define       SIOCATMARK    _IOR('s',  7, int)          /* at oob mark? */
00144 #define       SIOCSPGRP     _IOW('s',  8, int)          /* set process group */
00145 #define       SIOCGPGRP     _IOR('s',  9, int)          /* get process group */
00146 
00147 #define       SIOCADDRT     _IOW('r', 10, struct ortentry)     /* add route */
00148 #define       SIOCDELRT     _IOW('r', 11, struct ortentry)     /* delete route */
00149 
00150 #define       SIOCSIFADDR   _IOW('i', 12, struct ifreq) /* set ifnet address */
00151 #define       OSIOCGIFADDR  _IOWR('i',13, struct ifreq) /* get ifnet address */
00152 #define       SIOCGIFADDR   _IOWR('i',33, struct ifreq) /* get ifnet address */
00153 #define       SIOCSIFDSTADDR       _IOW('i', 14, struct ifreq) /* set p-p address */
00154 #define       OSIOCGIFDSTADDR      _IOWR('i',15, struct ifreq) /* get p-p address */
00155 #define       SIOCGIFDSTADDR       _IOWR('i',34, struct ifreq) /* get p-p address */
00156 #define       SIOCSIFFLAGS  _IOW('i', 16, struct ifreq) /* set ifnet flags */
00157 #define       SIOCGIFFLAGS  _IOWR('i',17, struct ifreq) /* get ifnet flags */
00158 #define       OSIOCGIFBRDADDR      _IOWR('i',18, struct ifreq) /* get broadcast addr */
00159 #define       SIOCGIFBRDADDR       _IOWR('i',35, struct ifreq) /* get broadcast addr */
00160 #define       SIOCSIFBRDADDR       _IOW('i',19, struct ifreq)  /* set broadcast addr */
00161 #define       OSIOCGIFCONF  _IOWR('i',20, struct ifconf)       /* get ifnet list */
00162 #define       SIOCGIFCONF   _IOWR('i',36, struct ifconf)       /* get ifnet list */
00163 #define       OSIOCGIFNETMASK      _IOWR('i',21, struct ifreq) /* get net addr mask */
00164 #define       SIOCGIFNETMASK       _IOWR('i',37, struct ifreq) /* get net addr mask */
00165 #define       SIOCSIFNETMASK       _IOW('i',22, struct ifreq)  /* set net addr mask */
00166 #define       SIOCGIFMETRIC _IOWR('i',23, struct ifreq) /* get IF metric */
00167 #define       SIOCSIFMETRIC _IOW('i',24, struct ifreq)  /* set IF metric */
00168 #define       SIOCDIFADDR   _IOW('i',25, struct ifreq)  /* delete IF addr */
00169 #define       SIOCAIFADDR   _IOW('i',26, struct ifaliasreq)    /* add/chg IF alias */
00170 
00171 #define       SIOCSARP      _IOW('i', 30, struct arpreq)       /* set arp entry */
00172 #define       OSIOCGARP     _IOWR('i',31, struct arpreq)       /* get arp entry */
00173 #define       SIOCGARP      _IOWR('i',38, struct arpreq)       /* get arp entry */
00174 #define       SIOCDARP      _IOW('i', 32, struct arpreq)       /* delete arp entry */
00175 
00176 
00177 /* Compatibility with 4.3 BSD terminal driver.
00178    From 4.4 <sys/ioctl_compat.h>.  */
00179 
00180 #ifdef USE_OLD_TTY
00181 # undef  TIOCGETD
00182 # define TIOCGETD    _IOR('t', 0, int)    /* get line discipline */
00183 # undef  TIOCSETD
00184 # define TIOCSETD    _IOW('t', 1, int)    /* set line discipline */
00185 #else
00186 # define OTIOCGETD   _IOR('t', 0, int)    /* get line discipline */
00187 # define OTIOCSETD   _IOW('t', 1, int)    /* set line discipline */
00188 #endif
00189 #define       TIOCHPCL      _IO('t', 2)          /* hang up on last close */
00190 #define       TIOCGETP      _IOR('t', 8,struct sgttyb)/* get parameters -- gtty */
00191 #define       TIOCSETP      _IOW('t', 9,struct sgttyb)/* set parameters -- stty */
00192 #define       TIOCSETN      _IOW('t',10,struct sgttyb)/* as above, but no flushtty*/
00193 #define       TIOCSETC      _IOW('t',17,struct tchars)/* set special characters */
00194 #define       TIOCGETC      _IOR('t',18,struct tchars)/* get special characters */
00195 #define              TANDEM        0x00000001    /* send stopc on out q full */
00196 #define              CBREAK        0x00000002    /* half-cooked mode */
00197 #define              LCASE         0x00000004    /* simulate lower case */
00198 #define              ECHO          0x00000008    /* echo input */
00199 #define              CRMOD         0x00000010    /* map \r to \r\n on output */
00200 #define              RAW           0x00000020    /* no i/o processing */
00201 #define              ODDP          0x00000040    /* get/send odd parity */
00202 #define              EVENP         0x00000080    /* get/send even parity */
00203 #define              ANYP          0x000000c0    /* get any parity/send none */
00204 #define              NLDELAY              0x00000300    /* \n delay */
00205 #define                     NL0    0x00000000
00206 #define                     NL1    0x00000100    /* tty 37 */
00207 #define                     NL2    0x00000200    /* vt05 */
00208 #define                     NL3    0x00000300
00209 #define              TBDELAY              0x00000c00    /* horizontal tab delay */
00210 #define                     TAB0   0x00000000
00211 #define                     TAB1   0x00000400    /* tty 37 */
00212 #define                     TAB2   0x00000800
00213 #define              XTABS         0x00000c00    /* expand tabs on output */
00214 #define              CRDELAY              0x00003000    /* \r delay */
00215 #define                     CR0    0x00000000
00216 #define                     CR1    0x00001000    /* tn 300 */
00217 #define                     CR2    0x00002000    /* tty 37 */
00218 #define                     CR3    0x00003000    /* concept 100 */
00219 #define              VTDELAY              0x00004000    /* vertical tab delay */
00220 #define                     FF0    0x00000000
00221 #define                     FF1    0x00004000    /* tty 37 */
00222 #define              BSDELAY              0x00008000    /* \b delay */
00223 #define                     BS0    0x00000000
00224 #define                     BS1    0x00008000
00225 #define              ALLDELAY      (NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY)
00226 #define              CRTBS         0x00010000    /* do backspacing for crt */
00227 #define              PRTERA        0x00020000    /* \ ... / erase */
00228 #define              CRTERA        0x00040000    /* " \b " to wipe out char */
00229 #define              TILDE         0x00080000    /* hazeltine tilde kludge */
00230 #define              MDMBUF        0x00100000    /*start/stop output on carrier*/
00231 #define              LITOUT        0x00200000    /* literal output */
00232 #define              TOSTOP        0x00400000    /*SIGSTOP on background output*/
00233 #define              FLUSHO        0x00800000    /* flush output to terminal */
00234 #define              NOHANG        0x01000000    /* (no-op) was no SIGHUP on carrier drop */
00235 #define              L001000              0x02000000
00236 #define              CRTKIL        0x04000000    /* kill line with " \b " */
00237 #define              PASS8         0x08000000
00238 #define              CTLECH        0x10000000    /* echo control chars as ^X */
00239 #define              PENDIN        0x20000000    /* tp->t_rawq needs reread */
00240 #define              DECCTQ        0x40000000    /* only ^Q starts after ^S */
00241 #define              NOFLSH        0x80000000    /* no output flush on signal */
00242 #define       TIOCLBIS      _IOW('t', 127, int)  /* bis local mode bits */
00243 #define       TIOCLBIC      _IOW('t', 126, int)  /* bic local mode bits */
00244 #define       TIOCLSET      _IOW('t', 125, int)  /* set entire local mode word */
00245 #define       TIOCLGET      _IOR('t', 124, int)  /* get local modes */
00246 #define              LCRTBS        (CRTBS>>16)
00247 #define              LPRTERA              (PRTERA>>16)
00248 #define              LCRTERA              (CRTERA>>16)
00249 #define              LTILDE        (TILDE>>16)
00250 #define              LMDMBUF              (MDMBUF>>16)
00251 #define              LLITOUT              (LITOUT>>16)
00252 #define              LTOSTOP              (TOSTOP>>16)
00253 #define              LFLUSHO              (FLUSHO>>16)
00254 #define              LNOHANG              (NOHANG>>16)
00255 #define              LCRTKIL              (CRTKIL>>16)
00256 #define              LPASS8        (PASS8>>16)
00257 #define              LCTLECH              (CTLECH>>16)
00258 #define              LPENDIN              (PENDIN>>16)
00259 #define              LDECCTQ              (DECCTQ>>16)
00260 #define              LNOFLSH              (NOFLSH>>16)
00261 #define       TIOCSLTC      _IOW('t',117,struct ltchars)/* set local special chars*/
00262 #define       TIOCGLTC      _IOR('t',116,struct ltchars)/* get local special chars*/
00263 #define OTIOCCONS    _IO('t', 98)  /* for hp300 -- sans int arg */
00264 #define       OTTYDISC      0
00265 #define       NETLDISC      1
00266 #define       NTTYDISC      2
00267 
00268 /* From 4.4 <sys/ttydev.h>.   */
00269 #ifdef USE_OLD_TTY
00270 #define B0    0
00271 #define B50   1
00272 #define B75   2
00273 #define B110  3
00274 #define B134  4
00275 #define B150  5
00276 #define B200  6
00277 #define B300  7
00278 #define B600  8
00279 #define B1200 9
00280 #define       B1800  10
00281 #define B2400 11
00282 #define B4800 12
00283 #define B9600 13
00284 #define EXTA  14
00285 #define EXTB  15
00286 #endif /* USE_OLD_TTY */
00287 
00288 #endif /* !_IOCTLS_H_ */