1 /* 2 * Copyright (c) 1982, 1986 Regents of the University of California. 3 * All rights reserved. The Berkeley software License Agreement 4 * specifies the terms and conditions for redistribution. 5 * 6 * @(#)ioctl.h 7.11 (Berkeley) 01/09/90 7 */ 8 9 /* 10 * Ioctl definitions 11 */ 12 #ifndef _IOCTL_ 13 #define _IOCTL_ 14 15 /* 16 * Window/terminal size structure. 17 * This information is stored by the kernel 18 * in order to provide a consistent interface, 19 * but is not used by the kernel. 20 * 21 * Type must be "unsigned short" so that types.h not required. 22 */ 23 struct winsize { 24 unsigned short ws_row; /* rows, in characters */ 25 unsigned short ws_col; /* columns, in characters */ 26 unsigned short ws_xpixel; /* horizontal size, pixels */ 27 unsigned short ws_ypixel; /* vertical size, pixels */ 28 }; 29 30 /* 31 * Pun for SUN. 32 */ 33 struct ttysize { 34 unsigned short ts_lines; 35 unsigned short ts_cols; 36 unsigned short ts_xxx; 37 unsigned short ts_yyy; 38 }; 39 #define TIOCGSIZE TIOCGWINSZ 40 #define TIOCSSIZE TIOCSWINSZ 41 42 #ifndef _IO 43 /* 44 * Ioctl's have the command encoded in the lower word, 45 * and the size of any in or out parameters in the upper 46 * word. The high 3 bits of the upper word are used 47 * to encode the in/out status of the parameter. 48 */ 49 #define IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */ 50 #define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK) 51 #define IOCBASECMD(x) ((x) & ~IOCPARM_MASK) 52 #define IOCGROUP(x) (((x) >> 8) & 0xff) 53 54 #define IOCPARM_MAX NBPG /* max size of ioctl, mult. of NBPG */ 55 #define IOC_VOID 0x20000000 /* no parameters */ 56 #define IOC_OUT 0x40000000 /* copy out parameters */ 57 #define IOC_IN 0x80000000 /* copy in parameters */ 58 #define IOC_INOUT (IOC_IN|IOC_OUT) 59 #define IOC_DIRMASK 0xe0000000 /* mask for IN/OUT/VOID */ 60 61 #define _IOC(inout,group,num,len) \ 62 (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num)) 63 #define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0) 64 #define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t)) 65 #define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t)) 66 /* this should be _IORW, but stdio got there first */ 67 #define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t)) 68 #endif 69 70 71 /* 72 * tty ioctl commands 73 */ 74 /* 0-2 compat */ 75 #define TIOCMODG _IOR('t', 3, int) /* get modem control state */ 76 #define TIOCMODS _IOW('t', 4, int) /* set modem control state */ 77 #define TIOCM_LE 0001 /* line enable */ 78 #define TIOCM_DTR 0002 /* data terminal ready */ 79 #define TIOCM_RTS 0004 /* request to send */ 80 #define TIOCM_ST 0010 /* secondary transmit */ 81 #define TIOCM_SR 0020 /* secondary receive */ 82 #define TIOCM_CTS 0040 /* clear to send */ 83 #define TIOCM_CAR 0100 /* carrier detect */ 84 #define TIOCM_CD TIOCM_CAR 85 #define TIOCM_RNG 0200 /* ring */ 86 #define TIOCM_RI TIOCM_RNG 87 #define TIOCM_DSR 0400 /* data set ready */ 88 /* 8-10 compat */ 89 #define TIOCEXCL _IO('t', 13) /* set exclusive use of tty */ 90 #define TIOCNXCL _IO('t', 14) /* reset exclusive use of tty */ 91 /* 15 unused */ 92 #define TIOCFLUSH _IOW('t', 16, int) /* flush buffers */ 93 /* 17-18 compat */ 94 #define TIOCGETA _IOR('t', 19, struct termios) /* get termios struct */ 95 #define TIOCSETA _IOW('t', 20, struct termios) /* set termios struct */ 96 #define TIOCSETAW _IOW('t', 21, struct termios) /* drain output, set */ 97 #define TIOCSETAF _IOW('t', 22, struct termios) /* drn out, fls in, set */ 98 /*** THESE GO AWAY ***/ 99 #define JUNK_TIOCSETAS _IOW('t', 23, struct termios) /* SETA ign hdw state */ 100 #define JUNK_TIOCSETAWS _IOW('t', 24, struct termios) /* SETAW ign hdw state */ 101 #define JUNK_TIOCSETAFS _IOW('t', 25, struct termios) /* SETAF ign hdw state */ 102 /******************/ 103 #define TIOCGETD _IOR('t', 26, int) /* get line discipline */ 104 #define TIOCSETD _IOW('t', 27, int) /* set line discipline */ 105 /* 127-124 compat */ 106 #define TIOCSBRK _IO('t', 123) /* set break bit */ 107 #define TIOCCBRK _IO('t', 122) /* clear break bit */ 108 #define TIOCSDTR _IO('t', 121) /* set data terminal ready */ 109 #define TIOCCDTR _IO('t', 120) /* clear data terminal ready */ 110 #define TIOCGPGRP _IOR('t', 119, int) /* get pgrp of tty */ 111 #define TIOCSPGRP _IOW('t', 118, int) /* set pgrp of tty */ 112 /* 117-116 compat */ 113 #define TIOCOUTQ _IOR('t', 115, int) /* output queue size */ 114 #define TIOCSTI _IOW('t', 114, char) /* simulate terminal input */ 115 #define TIOCNOTTY _IO('t', 113) /* void tty association */ 116 #define TIOCPKT _IOW('t', 112, int) /* pty: set/clear packet mode */ 117 #define TIOCPKT_DATA 0x00 /* data packet */ 118 #define TIOCPKT_FLUSHREAD 0x01 /* flush packet */ 119 #define TIOCPKT_FLUSHWRITE 0x02 /* flush packet */ 120 #define TIOCPKT_STOP 0x04 /* stop output */ 121 #define TIOCPKT_START 0x08 /* start output */ 122 #define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */ 123 #define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */ 124 #define TIOCSTOP _IO('t', 111) /* stop output, like ^S */ 125 #define TIOCSTART _IO('t', 110) /* start output, like ^Q */ 126 #define TIOCMSET _IOW('t', 109, int) /* set all modem bits */ 127 #define TIOCMBIS _IOW('t', 108, int) /* bis modem bits */ 128 #define TIOCMBIC _IOW('t', 107, int) /* bic modem bits */ 129 #define TIOCMGET _IOR('t', 106, int) /* get all modem bits */ 130 #define TIOCREMOTE _IOW('t', 105, int) /* remote input editing */ 131 #define TIOCGWINSZ _IOR('t', 104, struct winsize) /* get window size */ 132 #define TIOCSWINSZ _IOW('t', 103, struct winsize) /* set window size */ 133 #define TIOCUCNTL _IOW('t', 102, int) /* pty: set/clr usr cntl mode */ 134 #define UIOCCMD(n) _IO('u', n) /* usr cntl op "n" */ 135 #define TIOCCONS _IOW('t', 98, int) /* become virtual console */ 136 #define TIOCSCTTY _IO('t', 97) /* become controlling tty */ 137 138 #define TTYDISC 0 /* termios tty line discipline */ 139 #define TABLDISC 3 /* tablet discipline */ 140 #define SLIPDISC 4 /* serial IP discipline */ 141 142 /* 143 * Compatability with old terminal driver 144 * 145 * Source level -> #define USE_OLD_TTY 146 * Kernel level -> options COMPAT_43 147 */ 148 #if defined(USE_OLD_TTY) || defined(COMPAT_43) 149 #ifdef KERNEL 150 #include "ioctl_compat.h" 151 #else 152 #include <sys/ioctl_compat.h> 153 #endif 154 #endif 155 156 #define FIOCLEX _IO('f', 1) /* set close on exec on fd */ 157 #define FIONCLEX _IO('f', 2) /* remove close on exec */ 158 #define FIONREAD _IOR('f', 127, int) /* get # bytes to read */ 159 #define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */ 160 #define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */ 161 #define FIOSETOWN _IOW('f', 124, int) /* set owner */ 162 #define FIOGETOWN _IOR('f', 123, int) /* get owner */ 163 164 /* socket i/o controls */ 165 #define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */ 166 #define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */ 167 #define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */ 168 #define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */ 169 #define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */ 170 #define SIOCSPGRP _IOW('s', 8, int) /* set process group */ 171 #define SIOCGPGRP _IOR('s', 9, int) /* get process group */ 172 173 #define SIOCADDRT _IOW('r', 10, struct ortentry) /* add route */ 174 #define SIOCDELRT _IOW('r', 11, struct ortentry) /* delete route */ 175 176 #define SIOCSIFADDR _IOW('i', 12, struct ifreq) /* set ifnet address */ 177 #define OSIOCGIFADDR _IOWR('i',13, struct ifreq) /* get ifnet address */ 178 #define SIOCGIFADDR _IOWR('i',33, struct ifreq) /* get ifnet address */ 179 #define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */ 180 #define OSIOCGIFDSTADDR _IOWR('i',15, struct ifreq) /* get p-p address */ 181 #define SIOCGIFDSTADDR _IOWR('i',34, struct ifreq) /* get p-p address */ 182 #define SIOCSIFFLAGS _IOW('i', 16, struct ifreq) /* set ifnet flags */ 183 #define SIOCGIFFLAGS _IOWR('i',17, struct ifreq) /* get ifnet flags */ 184 #define OSIOCGIFBRDADDR _IOWR('i',18, struct ifreq) /* get broadcast addr */ 185 #define SIOCGIFBRDADDR _IOWR('i',35, struct ifreq) /* get broadcast addr */ 186 #define SIOCSIFBRDADDR _IOW('i',19, struct ifreq) /* set broadcast addr */ 187 #define OSIOCGIFCONF _IOWR('i',20, struct ifconf) /* get ifnet list */ 188 #define SIOCGIFCONF _IOWR('i',36, struct ifconf) /* get ifnet list */ 189 #define OSIOCGIFNETMASK _IOWR('i',21, struct ifreq) /* get net addr mask */ 190 #define SIOCGIFNETMASK _IOWR('i',37, struct ifreq) /* get net addr mask */ 191 #define SIOCSIFNETMASK _IOW('i',22, struct ifreq) /* set net addr mask */ 192 #define SIOCGIFMETRIC _IOWR('i',23, struct ifreq) /* get IF metric */ 193 #define SIOCSIFMETRIC _IOW('i',24, struct ifreq) /* set IF metric */ 194 #define SIOCDIFADDR _IOW('i',25, struct ifreq) /* delete IF addr */ 195 #define SIOCAIFADDR _IOW('i',26, struct ifaliasreq) /* add/chg IF alias */ 196 197 #define SIOCSARP _IOW('i', 30, struct arpreq) /* set arp entry */ 198 #define OSIOCGARP _IOWR('i',31, struct arpreq) /* get arp entry */ 199 #define SIOCGARP _IOWR('i',38, struct arpreq) /* get arp entry */ 200 #define SIOCDARP _IOW('i', 32, struct arpreq) /* delete arp entry */ 201 202 #endif 203