Damien Miller | 5109638 | 2006-03-26 14:30:00 +1100 | [diff] [blame] | 1 | /* $OpenBSD: ttymodes.h,v 1.14 2006/03/25 22:22:43 djm Exp $ */ |
Ben Lindstrom | 05764b9 | 2002-03-05 01:53:02 +0000 | [diff] [blame] | 2 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 3 | /* |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 5 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
| 6 | * All rights reserved |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 7 | * |
Damien Miller | e4340be | 2000-09-16 13:29:08 +1100 | [diff] [blame] | 8 | * As far as I am concerned, the code I have written for this software |
| 9 | * can be used freely for any purpose. Any derived versions of this |
| 10 | * software must be clearly marked as such, and if the derived work is |
| 11 | * incompatible with the protocol description in the RFC file, it must be |
| 12 | * called by a name other than "ssh" or "Secure Shell". |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 13 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 14 | |
Ben Lindstrom | ae8e2d3 | 2001-04-14 23:13:02 +0000 | [diff] [blame] | 15 | /* |
| 16 | * SSH2 tty modes support by Kevin Steves. |
| 17 | * Copyright (c) 2001 Kevin Steves. All rights reserved. |
| 18 | * |
| 19 | * Redistribution and use in source and binary forms, with or without |
| 20 | * modification, are permitted provided that the following conditions |
| 21 | * are met: |
| 22 | * 1. Redistributions of source code must retain the above copyright |
| 23 | * notice, this list of conditions and the following disclaimer. |
| 24 | * 2. Redistributions in binary form must reproduce the above copyright |
| 25 | * notice, this list of conditions and the following disclaimer in the |
| 26 | * documentation and/or other materials provided with the distribution. |
| 27 | * |
| 28 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 29 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 30 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 31 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 33 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 34 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 35 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 36 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 37 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 38 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 39 | |
Ben Lindstrom | ae8e2d3 | 2001-04-14 23:13:02 +0000 | [diff] [blame] | 40 | /* |
| 41 | * SSH1: |
| 42 | * The tty mode description is a stream of bytes. The stream consists of |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 43 | * opcode-arguments pairs. It is terminated by opcode TTY_OP_END (0). |
| 44 | * Opcodes 1-127 have one-byte arguments. Opcodes 128-159 have integer |
| 45 | * arguments. Opcodes 160-255 are not yet defined, and cause parsing to |
| 46 | * stop (they should only be used after any other data). |
| 47 | * |
Ben Lindstrom | ae8e2d3 | 2001-04-14 23:13:02 +0000 | [diff] [blame] | 48 | * SSH2: |
| 49 | * Differences between SSH1 and SSH2 terminal mode encoding include: |
| 50 | * 1. Encoded terminal modes are represented as a string, and a stream |
| 51 | * of bytes within that string. |
| 52 | * 2. Opcode arguments are uint32 (1-159); 160-255 remain undefined. |
| 53 | * 3. The values for TTY_OP_ISPEED and TTY_OP_OSPEED are different; |
| 54 | * 128 and 129 vs. 192 and 193 respectively. |
| 55 | * |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 56 | * The client puts in the stream any modes it knows about, and the |
| 57 | * server ignores any modes it does not know about. This allows some degree |
| 58 | * of machine-independence, at least between systems that use a posix-like |
| 59 | * tty interface. The protocol can support other systems as well, but might |
| 60 | * require reimplementing as mode names would likely be different. |
| 61 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 62 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 63 | /* |
| 64 | * Some constants and prototypes are defined in packet.h; this file |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 65 | * is only intended for including from ttymodes.c. |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 66 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 67 | |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 68 | /* termios macro */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 69 | /* name, op */ |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 70 | TTYCHAR(VINTR, 1) |
| 71 | TTYCHAR(VQUIT, 2) |
| 72 | TTYCHAR(VERASE, 3) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 73 | #if defined(VKILL) |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 74 | TTYCHAR(VKILL, 4) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 75 | #endif /* VKILL */ |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 76 | TTYCHAR(VEOF, 5) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 77 | #if defined(VEOL) |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 78 | TTYCHAR(VEOL, 6) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 79 | #endif /* VEOL */ |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 80 | #ifdef VEOL2 |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 81 | TTYCHAR(VEOL2, 7) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 82 | #endif /* VEOL2 */ |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 83 | TTYCHAR(VSTART, 8) |
| 84 | TTYCHAR(VSTOP, 9) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 85 | #if defined(VSUSP) |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 86 | TTYCHAR(VSUSP, 10) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 87 | #endif /* VSUSP */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 88 | #if defined(VDSUSP) |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 89 | TTYCHAR(VDSUSP, 11) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 90 | #endif /* VDSUSP */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 91 | #if defined(VREPRINT) |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 92 | TTYCHAR(VREPRINT, 12) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 93 | #endif /* VREPRINT */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 94 | #if defined(VWERASE) |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 95 | TTYCHAR(VWERASE, 13) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 96 | #endif /* VWERASE */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 97 | #if defined(VLNEXT) |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 98 | TTYCHAR(VLNEXT, 14) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 99 | #endif /* VLNEXT */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 100 | #if defined(VFLUSH) |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 101 | TTYCHAR(VFLUSH, 15) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 102 | #endif /* VFLUSH */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 103 | #ifdef VSWTCH |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 104 | TTYCHAR(VSWTCH, 16) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 105 | #endif /* VSWTCH */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 106 | #if defined(VSTATUS) |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 107 | TTYCHAR(VSTATUS, 17) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 108 | #endif /* VSTATUS */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 109 | #ifdef VDISCARD |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 110 | TTYCHAR(VDISCARD, 18) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 111 | #endif /* VDISCARD */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 112 | |
| 113 | /* name, field, op */ |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 114 | TTYMODE(IGNPAR, c_iflag, 30) |
| 115 | TTYMODE(PARMRK, c_iflag, 31) |
Darren Tucker | fc95970 | 2004-07-17 16:12:08 +1000 | [diff] [blame] | 116 | TTYMODE(INPCK, c_iflag, 32) |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 117 | TTYMODE(ISTRIP, c_iflag, 33) |
Darren Tucker | fc95970 | 2004-07-17 16:12:08 +1000 | [diff] [blame] | 118 | TTYMODE(INLCR, c_iflag, 34) |
| 119 | TTYMODE(IGNCR, c_iflag, 35) |
| 120 | TTYMODE(ICRNL, c_iflag, 36) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 121 | #if defined(IUCLC) |
Darren Tucker | fc95970 | 2004-07-17 16:12:08 +1000 | [diff] [blame] | 122 | TTYMODE(IUCLC, c_iflag, 37) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 123 | #endif |
Darren Tucker | fc95970 | 2004-07-17 16:12:08 +1000 | [diff] [blame] | 124 | TTYMODE(IXON, c_iflag, 38) |
| 125 | TTYMODE(IXANY, c_iflag, 39) |
| 126 | TTYMODE(IXOFF, c_iflag, 40) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 127 | #ifdef IMAXBEL |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 128 | TTYMODE(IMAXBEL,c_iflag, 41) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 129 | #endif /* IMAXBEL */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 130 | |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 131 | TTYMODE(ISIG, c_lflag, 50) |
| 132 | TTYMODE(ICANON, c_lflag, 51) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 133 | #ifdef XCASE |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 134 | TTYMODE(XCASE, c_lflag, 52) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 135 | #endif |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 136 | TTYMODE(ECHO, c_lflag, 53) |
| 137 | TTYMODE(ECHOE, c_lflag, 54) |
| 138 | TTYMODE(ECHOK, c_lflag, 55) |
| 139 | TTYMODE(ECHONL, c_lflag, 56) |
| 140 | TTYMODE(NOFLSH, c_lflag, 57) |
| 141 | TTYMODE(TOSTOP, c_lflag, 58) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 142 | #ifdef IEXTEN |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 143 | TTYMODE(IEXTEN, c_lflag, 59) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 144 | #endif /* IEXTEN */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 145 | #if defined(ECHOCTL) |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 146 | TTYMODE(ECHOCTL,c_lflag, 60) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 147 | #endif /* ECHOCTL */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 148 | #ifdef ECHOKE |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 149 | TTYMODE(ECHOKE, c_lflag, 61) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 150 | #endif /* ECHOKE */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 151 | #if defined(PENDIN) |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 152 | TTYMODE(PENDIN, c_lflag, 62) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 153 | #endif /* PENDIN */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 154 | |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 155 | TTYMODE(OPOST, c_oflag, 70) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 156 | #if defined(OLCUC) |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 157 | TTYMODE(OLCUC, c_oflag, 71) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 158 | #endif |
Ben Lindstrom | b7ae94d | 2002-06-12 17:32:30 +0000 | [diff] [blame] | 159 | #ifdef ONLCR |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 160 | TTYMODE(ONLCR, c_oflag, 72) |
Ben Lindstrom | b7ae94d | 2002-06-12 17:32:30 +0000 | [diff] [blame] | 161 | #endif |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 162 | #ifdef OCRNL |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 163 | TTYMODE(OCRNL, c_oflag, 73) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 164 | #endif |
| 165 | #ifdef ONOCR |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 166 | TTYMODE(ONOCR, c_oflag, 74) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 167 | #endif |
| 168 | #ifdef ONLRET |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 169 | TTYMODE(ONLRET, c_oflag, 75) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 170 | #endif |
| 171 | |
Ben Lindstrom | 0026154 | 2001-03-10 17:17:28 +0000 | [diff] [blame] | 172 | TTYMODE(CS7, c_cflag, 90) |
| 173 | TTYMODE(CS8, c_cflag, 91) |
| 174 | TTYMODE(PARENB, c_cflag, 92) |
| 175 | TTYMODE(PARODD, c_cflag, 93) |