Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 2 | /* |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 3 | * telnet implementation for busybox |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 4 | * |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 5 | * Author: Tomi Ollila <too@iki.fi> |
| 6 | * Copyright (C) 1994-2000 by Tomi Ollila |
| 7 | * |
| 8 | * Created: Thu Apr 7 13:29:41 1994 too |
| 9 | * Last modified: Fri Jun 9 14:34:24 2000 too |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 19 | * General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 24 | * |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 25 | * HISTORY |
| 26 | * Revision 3.1 1994/04/17 11:31:54 too |
| 27 | * initial revision |
| 28 | * Modified 2000/06/13 for inclusion into BusyBox by Erik Andersen |
| 29 | * <andersen@lineo.com> |
Eric Andersen | 7e1273e | 2001-05-07 17:57:45 +0000 | [diff] [blame] | 30 | * Modified 2001/05/07 to add ability to pass TTYPE to remote host by Jim McQuillan |
| 31 | * <jam@ltsp.org> |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 32 | * |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 33 | */ |
| 34 | |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 35 | #include <termios.h> |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 36 | #include <unistd.h> |
| 37 | #include <errno.h> |
| 38 | #include <stdlib.h> |
| 39 | #include <stdarg.h> |
| 40 | #include <string.h> |
| 41 | #include <signal.h> |
| 42 | #include <arpa/telnet.h> |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 43 | #include <sys/types.h> |
| 44 | #include <sys/socket.h> |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 45 | #include <netinet/in.h> |
| 46 | #include <netdb.h> |
Eric Andersen | cbe31da | 2001-02-20 06:14:08 +0000 | [diff] [blame] | 47 | #include "busybox.h" |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 48 | |
Eric Andersen | 0e28e1f | 2002-04-26 07:20:47 +0000 | [diff] [blame] | 49 | #ifdef CONFIG_FEATURE_AUTOWIDTH |
| 50 | # include <sys/ioctl.h> |
| 51 | #endif |
| 52 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 53 | #if 0 |
Mark Whitley | 59ab025 | 2001-01-23 22:30:04 +0000 | [diff] [blame] | 54 | static const int DOTRACE = 1; |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 55 | #endif |
| 56 | |
Pavel Roskin | 616d13b | 2000-07-28 19:38:27 +0000 | [diff] [blame] | 57 | #ifdef DOTRACE |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 58 | #include <arpa/inet.h> /* for inet_ntoa()... */ |
| 59 | #define TRACE(x, y) do { if (x) printf y; } while (0) |
| 60 | #else |
| 61 | #define TRACE(x, y) |
| 62 | #endif |
| 63 | |
| 64 | #if 0 |
| 65 | #define USE_POLL |
| 66 | #include <sys/poll.h> |
| 67 | #else |
| 68 | #include <sys/time.h> |
| 69 | #endif |
| 70 | |
Glenn L McGrath | 78b0e37 | 2001-06-26 02:06:08 +0000 | [diff] [blame] | 71 | #define DATABUFSIZE 128 |
| 72 | #define IACBUFSIZE 128 |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 73 | |
Mark Whitley | 59ab025 | 2001-01-23 22:30:04 +0000 | [diff] [blame] | 74 | static const int CHM_TRY = 0; |
| 75 | static const int CHM_ON = 1; |
| 76 | static const int CHM_OFF = 2; |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 77 | |
Mark Whitley | 59ab025 | 2001-01-23 22:30:04 +0000 | [diff] [blame] | 78 | static const int UF_ECHO = 0x01; |
| 79 | static const int UF_SGA = 0x02; |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 80 | |
Mark Whitley | 59ab025 | 2001-01-23 22:30:04 +0000 | [diff] [blame] | 81 | enum { |
| 82 | TS_0 = 1, |
| 83 | TS_IAC = 2, |
| 84 | TS_OPT = 3, |
| 85 | TS_SUB1 = 4, |
| 86 | TS_SUB2 = 5, |
| 87 | }; |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 88 | |
| 89 | #define WriteCS(fd, str) write(fd, str, sizeof str -1) |
| 90 | |
| 91 | typedef unsigned char byte; |
| 92 | |
| 93 | /* use globals to reduce size ??? */ /* test this hypothesis later */ |
Eric Andersen | 92d2324 | 2001-03-19 23:49:41 +0000 | [diff] [blame] | 94 | static struct Globalvars { |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 95 | int netfd; /* console fd:s are 0 and 1 (and 2) */ |
| 96 | /* same buffer used both for network and console read/write */ |
Glenn L McGrath | 78b0e37 | 2001-06-26 02:06:08 +0000 | [diff] [blame] | 97 | char buf[DATABUFSIZE]; /* allocating so static size is smaller */ |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 98 | byte telstate; /* telnet negotiation state from network input */ |
| 99 | byte telwish; /* DO, DONT, WILL, WONT */ |
| 100 | byte charmode; |
| 101 | byte telflags; |
| 102 | byte gotsig; |
| 103 | /* buffer to handle telnet negotiations */ |
Glenn L McGrath | 78b0e37 | 2001-06-26 02:06:08 +0000 | [diff] [blame] | 104 | char iacbuf[IACBUFSIZE]; |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 105 | short iaclen; /* could even use byte */ |
| 106 | struct termios termios_def; |
| 107 | struct termios termios_raw; |
| 108 | } G; |
| 109 | |
| 110 | #define xUSE_GLOBALVAR_PTR /* xUSE... -> don't use :D (makes smaller code) */ |
| 111 | |
| 112 | #ifdef USE_GLOBALVAR_PTR |
| 113 | struct Globalvars * Gptr; |
| 114 | #define G (*Gptr) |
| 115 | #else |
Eric Andersen | 92d2324 | 2001-03-19 23:49:41 +0000 | [diff] [blame] | 116 | static struct Globalvars G; |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 117 | #endif |
| 118 | |
Eric Andersen | cd8c436 | 2001-11-10 11:22:46 +0000 | [diff] [blame] | 119 | static inline void iacflush(void) |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 120 | { |
| 121 | write(G.netfd, G.iacbuf, G.iaclen); |
| 122 | G.iaclen = 0; |
| 123 | } |
| 124 | |
| 125 | /* Function prototypes */ |
| 126 | static int getport(char * p); |
| 127 | static struct in_addr getserver(char * p); |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 128 | static void setup_sockaddr_in(struct sockaddr_in * addr, int port); |
| 129 | static int remote_connect(struct in_addr addr, int port); |
Eric Andersen | cd8c436 | 2001-11-10 11:22:46 +0000 | [diff] [blame] | 130 | static void rawmode(void); |
| 131 | static void cookmode(void); |
| 132 | static void do_linemode(void); |
| 133 | static void will_charmode(void); |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 134 | static void telopt(byte c); |
| 135 | static int subneg(byte c); |
| 136 | #if 0 |
| 137 | static int local_bind(int port); |
| 138 | #endif |
| 139 | |
| 140 | /* Some globals */ |
| 141 | static int one = 1; |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 142 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 143 | #ifdef CONFIG_FEATURE_TELNET_TTYPE |
Eric Andersen | 7e1273e | 2001-05-07 17:57:45 +0000 | [diff] [blame] | 144 | static char *ttype; |
| 145 | #endif |
| 146 | |
Eric Andersen | 0e28e1f | 2002-04-26 07:20:47 +0000 | [diff] [blame] | 147 | #ifdef CONFIG_FEATURE_AUTOWIDTH |
| 148 | static int win_width, win_height; |
| 149 | #endif |
| 150 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 151 | static void doexit(int ev) |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 152 | { |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 153 | cookmode(); |
| 154 | exit(ev); |
| 155 | } |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 156 | |
Eric Andersen | cd8c436 | 2001-11-10 11:22:46 +0000 | [diff] [blame] | 157 | static void conescape(void) |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 158 | { |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 159 | char b; |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 160 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 161 | if (G.gotsig) /* came from line mode... go raw */ |
| 162 | rawmode(); |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 163 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 164 | WriteCS(1, "\r\nConsole escape. Commands are:\r\n\n" |
| 165 | " l go to line mode\r\n" |
| 166 | " c go to character mode\r\n" |
| 167 | " z suspend telnet\r\n" |
| 168 | " e exit telnet\r\n"); |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 169 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 170 | if (read(0, &b, 1) <= 0) |
| 171 | doexit(1); |
| 172 | |
| 173 | switch (b) |
| 174 | { |
| 175 | case 'l': |
| 176 | if (!G.gotsig) |
| 177 | { |
| 178 | do_linemode(); |
| 179 | goto rrturn; |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 180 | } |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 181 | break; |
| 182 | case 'c': |
| 183 | if (G.gotsig) |
| 184 | { |
| 185 | will_charmode(); |
| 186 | goto rrturn; |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 187 | } |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 188 | break; |
| 189 | case 'z': |
| 190 | cookmode(); |
| 191 | kill(0, SIGTSTP); |
| 192 | rawmode(); |
| 193 | break; |
| 194 | case 'e': |
| 195 | doexit(0); |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 196 | } |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 197 | |
| 198 | WriteCS(1, "continuing...\r\n"); |
| 199 | |
| 200 | if (G.gotsig) |
| 201 | cookmode(); |
| 202 | |
| 203 | rrturn: |
| 204 | G.gotsig = 0; |
| 205 | |
| 206 | } |
Glenn L McGrath | 78b0e37 | 2001-06-26 02:06:08 +0000 | [diff] [blame] | 207 | static void handlenetoutput(int len) |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 208 | { |
| 209 | /* here we could do smart tricks how to handle 0xFF:s in output |
| 210 | * stream like writing twice every sequence of FF:s (thus doing |
| 211 | * many write()s. But I think interactive telnet application does |
| 212 | * not need to be 100% 8-bit clean, so changing every 0xff:s to |
Eric Andersen | 0e28e1f | 2002-04-26 07:20:47 +0000 | [diff] [blame] | 213 | * 0x7f:s |
| 214 | * |
| 215 | * 2002-mar-21, Przemyslaw Czerpak (druzus@polbox.com) |
| 216 | * I don't agree. |
| 217 | * first - I cannot use programs like sz/rz |
| 218 | * second - the 0x0D is sent as one character and if the next |
| 219 | * char is 0x0A then it's eaten by a server side. |
| 220 | * third - whay doy you have to make 'many write()s'? |
| 221 | * I don't understand. |
| 222 | * So I implemented it. It's realy useful for me. I hope that |
| 223 | * others people will find it interesting to. |
| 224 | */ |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 225 | |
Eric Andersen | 0e28e1f | 2002-04-26 07:20:47 +0000 | [diff] [blame] | 226 | int i, j; |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 227 | byte * p = G.buf; |
Eric Andersen | 0e28e1f | 2002-04-26 07:20:47 +0000 | [diff] [blame] | 228 | byte outbuf[4*DATABUFSIZE]; |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 229 | |
Eric Andersen | 0e28e1f | 2002-04-26 07:20:47 +0000 | [diff] [blame] | 230 | for (i = len, j = 0; i > 0; i--, p++) |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 231 | { |
| 232 | if (*p == 0x1d) |
| 233 | { |
| 234 | conescape(); |
| 235 | return; |
| 236 | } |
Eric Andersen | 0e28e1f | 2002-04-26 07:20:47 +0000 | [diff] [blame] | 237 | outbuf[j++] = *p; |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 238 | if (*p == 0xff) |
Eric Andersen | 0e28e1f | 2002-04-26 07:20:47 +0000 | [diff] [blame] | 239 | outbuf[j++] = 0xff; |
| 240 | else if (*p == 0x0d) |
| 241 | outbuf[j++] = 0x00; |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 242 | } |
Eric Andersen | 0e28e1f | 2002-04-26 07:20:47 +0000 | [diff] [blame] | 243 | if (j > 0 ) |
| 244 | write(G.netfd, outbuf, j); |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 245 | } |
| 246 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 247 | |
Glenn L McGrath | 78b0e37 | 2001-06-26 02:06:08 +0000 | [diff] [blame] | 248 | static void handlenetinput(int len) |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 249 | { |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 250 | int i; |
| 251 | int cstart = 0; |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 252 | |
Glenn L McGrath | 78b0e37 | 2001-06-26 02:06:08 +0000 | [diff] [blame] | 253 | for (i = 0; i < len; i++) |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 254 | { |
| 255 | byte c = G.buf[i]; |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 256 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 257 | if (G.telstate == 0) /* most of the time state == 0 */ |
| 258 | { |
| 259 | if (c == IAC) |
| 260 | { |
| 261 | cstart = i; |
| 262 | G.telstate = TS_IAC; |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 263 | } |
| 264 | } |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 265 | else |
| 266 | switch (G.telstate) |
| 267 | { |
| 268 | case TS_0: |
| 269 | if (c == IAC) |
| 270 | G.telstate = TS_IAC; |
| 271 | else |
| 272 | G.buf[cstart++] = c; |
| 273 | break; |
| 274 | |
| 275 | case TS_IAC: |
| 276 | if (c == IAC) /* IAC IAC -> 0xFF */ |
| 277 | { |
| 278 | G.buf[cstart++] = c; |
| 279 | G.telstate = TS_0; |
| 280 | break; |
| 281 | } |
| 282 | /* else */ |
| 283 | switch (c) |
| 284 | { |
| 285 | case SB: |
| 286 | G.telstate = TS_SUB1; |
| 287 | break; |
| 288 | case DO: |
| 289 | case DONT: |
| 290 | case WILL: |
| 291 | case WONT: |
| 292 | G.telwish = c; |
| 293 | G.telstate = TS_OPT; |
| 294 | break; |
| 295 | default: |
| 296 | G.telstate = TS_0; /* DATA MARK must be added later */ |
| 297 | } |
| 298 | break; |
| 299 | case TS_OPT: /* WILL, WONT, DO, DONT */ |
| 300 | telopt(c); |
| 301 | G.telstate = TS_0; |
| 302 | break; |
| 303 | case TS_SUB1: /* Subnegotiation */ |
| 304 | case TS_SUB2: /* Subnegotiation */ |
Matt Kraai | 1f0c436 | 2001-12-20 23:13:26 +0000 | [diff] [blame] | 305 | if (subneg(c)) |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 306 | G.telstate = TS_0; |
| 307 | break; |
| 308 | } |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 309 | } |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 310 | if (G.telstate) |
| 311 | { |
| 312 | if (G.iaclen) iacflush(); |
| 313 | if (G.telstate == TS_0) G.telstate = 0; |
| 314 | |
Glenn L McGrath | 78b0e37 | 2001-06-26 02:06:08 +0000 | [diff] [blame] | 315 | len = cstart; |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 316 | } |
| 317 | |
Glenn L McGrath | 78b0e37 | 2001-06-26 02:06:08 +0000 | [diff] [blame] | 318 | if (len) |
| 319 | write(1, G.buf, len); |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 320 | } |
| 321 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 322 | |
| 323 | /* ******************************* */ |
| 324 | |
| 325 | static inline void putiac(int c) |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 326 | { |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 327 | G.iacbuf[G.iaclen++] = c; |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 328 | } |
| 329 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 330 | |
| 331 | static void putiac2(byte wwdd, byte c) |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 332 | { |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 333 | if (G.iaclen + 3 > IACBUFSIZE) |
| 334 | iacflush(); |
| 335 | |
| 336 | putiac(IAC); |
| 337 | putiac(wwdd); |
| 338 | putiac(c); |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 339 | } |
| 340 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 341 | #if 0 |
| 342 | static void putiac1(byte c) |
| 343 | { |
| 344 | if (G.iaclen + 2 > IACBUFSIZE) |
| 345 | iacflush(); |
| 346 | |
| 347 | putiac(IAC); |
| 348 | putiac(c); |
| 349 | } |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 350 | #endif |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 351 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 352 | #ifdef CONFIG_FEATURE_TELNET_TTYPE |
Eric Andersen | 7e1273e | 2001-05-07 17:57:45 +0000 | [diff] [blame] | 353 | static void putiac_subopt(byte c, char *str) |
| 354 | { |
| 355 | int len = strlen(str) + 6; // ( 2 + 1 + 1 + strlen + 2 ) |
| 356 | |
| 357 | if (G.iaclen + len > IACBUFSIZE) |
| 358 | iacflush(); |
| 359 | |
| 360 | putiac(IAC); |
| 361 | putiac(SB); |
| 362 | putiac(c); |
| 363 | putiac(0); |
| 364 | |
| 365 | while(*str) |
| 366 | putiac(*str++); |
| 367 | |
| 368 | putiac(IAC); |
| 369 | putiac(SE); |
| 370 | } |
| 371 | #endif |
| 372 | |
Eric Andersen | 0e28e1f | 2002-04-26 07:20:47 +0000 | [diff] [blame] | 373 | #ifdef CONFIG_FEATURE_AUTOWIDTH |
| 374 | static void putiac_naws(byte c, int x, int y) |
| 375 | { |
| 376 | if (G.iaclen + 9 > IACBUFSIZE) |
| 377 | iacflush(); |
| 378 | |
| 379 | putiac(IAC); |
| 380 | putiac(SB); |
| 381 | putiac(c); |
| 382 | |
| 383 | putiac((x >> 8) & 0xff); |
| 384 | putiac(x & 0xff); |
| 385 | putiac((y >> 8) & 0xff); |
| 386 | putiac(y & 0xff); |
| 387 | |
| 388 | putiac(IAC); |
| 389 | putiac(SE); |
| 390 | } |
| 391 | #endif |
| 392 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 393 | /* void putiacstring (subneg strings) */ |
| 394 | |
| 395 | /* ******************************* */ |
| 396 | |
Eric Andersen | 3e6ff90 | 2001-03-09 21:24:12 +0000 | [diff] [blame] | 397 | static char const escapecharis[] = "\r\nEscape character is "; |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 398 | |
Eric Andersen | cd8c436 | 2001-11-10 11:22:46 +0000 | [diff] [blame] | 399 | static void setConMode(void) |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 400 | { |
| 401 | if (G.telflags & UF_ECHO) |
| 402 | { |
| 403 | if (G.charmode == CHM_TRY) { |
| 404 | G.charmode = CHM_ON; |
Matt Kraai | 12f417e | 2001-01-18 02:57:08 +0000 | [diff] [blame] | 405 | printf("\r\nEntering character mode%s'^]'.\r\n", escapecharis); |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 406 | rawmode(); |
| 407 | } |
| 408 | } |
| 409 | else |
| 410 | { |
| 411 | if (G.charmode != CHM_OFF) { |
| 412 | G.charmode = CHM_OFF; |
Matt Kraai | 12f417e | 2001-01-18 02:57:08 +0000 | [diff] [blame] | 413 | printf("\r\nEntering line mode%s'^C'.\r\n", escapecharis); |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 414 | cookmode(); |
| 415 | } |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | /* ******************************* */ |
| 420 | |
Eric Andersen | cd8c436 | 2001-11-10 11:22:46 +0000 | [diff] [blame] | 421 | static void will_charmode(void) |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 422 | { |
| 423 | G.charmode = CHM_TRY; |
| 424 | G.telflags |= (UF_ECHO | UF_SGA); |
| 425 | setConMode(); |
| 426 | |
| 427 | putiac2(DO, TELOPT_ECHO); |
| 428 | putiac2(DO, TELOPT_SGA); |
| 429 | iacflush(); |
| 430 | } |
| 431 | |
Eric Andersen | cd8c436 | 2001-11-10 11:22:46 +0000 | [diff] [blame] | 432 | static void do_linemode(void) |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 433 | { |
| 434 | G.charmode = CHM_TRY; |
| 435 | G.telflags &= ~(UF_ECHO | UF_SGA); |
| 436 | setConMode(); |
| 437 | |
| 438 | putiac2(DONT, TELOPT_ECHO); |
| 439 | putiac2(DONT, TELOPT_SGA); |
| 440 | iacflush(); |
| 441 | } |
| 442 | |
| 443 | /* ******************************* */ |
| 444 | |
| 445 | static inline void to_notsup(char c) |
| 446 | { |
| 447 | if (G.telwish == WILL) putiac2(DONT, c); |
| 448 | else if (G.telwish == DO) putiac2(WONT, c); |
| 449 | } |
| 450 | |
Eric Andersen | cd8c436 | 2001-11-10 11:22:46 +0000 | [diff] [blame] | 451 | static inline void to_echo(void) |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 452 | { |
| 453 | /* if server requests ECHO, don't agree */ |
| 454 | if (G.telwish == DO) { putiac2(WONT, TELOPT_ECHO); return; } |
| 455 | else if (G.telwish == DONT) return; |
| 456 | |
| 457 | if (G.telflags & UF_ECHO) |
| 458 | { |
| 459 | if (G.telwish == WILL) |
| 460 | return; |
| 461 | } |
| 462 | else |
| 463 | if (G.telwish == WONT) |
| 464 | return; |
| 465 | |
| 466 | if (G.charmode != CHM_OFF) |
| 467 | G.telflags ^= UF_ECHO; |
| 468 | |
| 469 | if (G.telflags & UF_ECHO) |
| 470 | putiac2(DO, TELOPT_ECHO); |
| 471 | else |
| 472 | putiac2(DONT, TELOPT_ECHO); |
| 473 | |
| 474 | setConMode(); |
| 475 | WriteCS(1, "\r\n"); /* sudden modec */ |
| 476 | } |
| 477 | |
Eric Andersen | cd8c436 | 2001-11-10 11:22:46 +0000 | [diff] [blame] | 478 | static inline void to_sga(void) |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 479 | { |
| 480 | /* daemon always sends will/wont, client do/dont */ |
| 481 | |
| 482 | if (G.telflags & UF_SGA) |
| 483 | { |
| 484 | if (G.telwish == WILL) |
| 485 | return; |
| 486 | } |
| 487 | else |
| 488 | if (G.telwish == WONT) |
| 489 | return; |
| 490 | |
| 491 | if ((G.telflags ^= UF_SGA) & UF_SGA) /* toggle */ |
| 492 | putiac2(DO, TELOPT_SGA); |
| 493 | else |
| 494 | putiac2(DONT, TELOPT_SGA); |
| 495 | |
| 496 | return; |
| 497 | } |
| 498 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 499 | #ifdef CONFIG_FEATURE_TELNET_TTYPE |
Eric Andersen | cd8c436 | 2001-11-10 11:22:46 +0000 | [diff] [blame] | 500 | static inline void to_ttype(void) |
Eric Andersen | 7e1273e | 2001-05-07 17:57:45 +0000 | [diff] [blame] | 501 | { |
| 502 | /* Tell server we will (or won't) do TTYPE */ |
| 503 | |
| 504 | if(ttype) |
| 505 | putiac2(WILL, TELOPT_TTYPE); |
| 506 | else |
| 507 | putiac2(WONT, TELOPT_TTYPE); |
| 508 | |
| 509 | return; |
| 510 | } |
| 511 | #endif |
| 512 | |
Eric Andersen | 0e28e1f | 2002-04-26 07:20:47 +0000 | [diff] [blame] | 513 | #ifdef CONFIG_FEATURE_AUTOWIDTH |
Tim Riker | ed8e036 | 2002-04-26 07:53:39 +0000 | [diff] [blame] | 514 | static inline void to_naws(void) |
Eric Andersen | 0e28e1f | 2002-04-26 07:20:47 +0000 | [diff] [blame] | 515 | { |
| 516 | /* Tell server we will do NAWS */ |
| 517 | putiac2(WILL, TELOPT_NAWS); |
| 518 | return; |
| 519 | } |
| 520 | #endif |
| 521 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 522 | static void telopt(byte c) |
| 523 | { |
| 524 | switch (c) |
| 525 | { |
Eric Andersen | 4163406 | 2002-04-26 08:44:17 +0000 | [diff] [blame] | 526 | case TELOPT_ECHO: to_echo(); break; |
| 527 | case TELOPT_SGA: to_sga(); break; |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 528 | #ifdef CONFIG_FEATURE_TELNET_TTYPE |
Eric Andersen | 4163406 | 2002-04-26 08:44:17 +0000 | [diff] [blame] | 529 | case TELOPT_TTYPE: to_ttype();break; |
Eric Andersen | 7e1273e | 2001-05-07 17:57:45 +0000 | [diff] [blame] | 530 | #endif |
Eric Andersen | 0e28e1f | 2002-04-26 07:20:47 +0000 | [diff] [blame] | 531 | #ifdef CONFIG_FEATURE_AUTOWIDTH |
Eric Andersen | 4163406 | 2002-04-26 08:44:17 +0000 | [diff] [blame] | 532 | case TELOPT_NAWS: to_naws(); |
Eric Andersen | 0e28e1f | 2002-04-26 07:20:47 +0000 | [diff] [blame] | 533 | putiac_naws(c, win_width, win_height); |
| 534 | break; |
| 535 | #endif |
Eric Andersen | 8db361b | 2002-04-26 08:00:33 +0000 | [diff] [blame] | 536 | default: to_notsup(c); |
| 537 | break; |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 538 | } |
| 539 | } |
| 540 | |
| 541 | |
| 542 | /* ******************************* */ |
| 543 | |
Eric Andersen | 0e28e1f | 2002-04-26 07:20:47 +0000 | [diff] [blame] | 544 | /* subnegotiation -- ignore all (except TTYPE,NAWS) */ |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 545 | |
| 546 | static int subneg(byte c) |
| 547 | { |
| 548 | switch (G.telstate) |
| 549 | { |
| 550 | case TS_SUB1: |
| 551 | if (c == IAC) |
| 552 | G.telstate = TS_SUB2; |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 553 | #ifdef CONFIG_FEATURE_TELNET_TTYPE |
Eric Andersen | 7e1273e | 2001-05-07 17:57:45 +0000 | [diff] [blame] | 554 | else |
| 555 | if (c == TELOPT_TTYPE) |
| 556 | putiac_subopt(TELOPT_TTYPE,ttype); |
| 557 | #endif |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 558 | break; |
| 559 | case TS_SUB2: |
| 560 | if (c == SE) |
| 561 | return TRUE; |
| 562 | G.telstate = TS_SUB1; |
| 563 | /* break; */ |
| 564 | } |
| 565 | return FALSE; |
| 566 | } |
| 567 | |
| 568 | /* ******************************* */ |
| 569 | |
| 570 | static void fgotsig(int sig) |
| 571 | { |
| 572 | G.gotsig = sig; |
| 573 | } |
| 574 | |
| 575 | |
Eric Andersen | cd8c436 | 2001-11-10 11:22:46 +0000 | [diff] [blame] | 576 | static void rawmode(void) |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 577 | { |
| 578 | tcsetattr(0, TCSADRAIN, &G.termios_raw); |
| 579 | } |
| 580 | |
Eric Andersen | cd8c436 | 2001-11-10 11:22:46 +0000 | [diff] [blame] | 581 | static void cookmode(void) |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 582 | { |
| 583 | tcsetattr(0, TCSADRAIN, &G.termios_def); |
| 584 | } |
| 585 | |
| 586 | extern int telnet_main(int argc, char** argv) |
| 587 | { |
| 588 | struct in_addr host; |
| 589 | int port; |
Glenn L McGrath | 78b0e37 | 2001-06-26 02:06:08 +0000 | [diff] [blame] | 590 | int len; |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 591 | #ifdef USE_POLL |
| 592 | struct pollfd ufds[2]; |
| 593 | #else |
| 594 | fd_set readfds; |
| 595 | int maxfd; |
| 596 | #endif |
| 597 | |
Eric Andersen | 0e28e1f | 2002-04-26 07:20:47 +0000 | [diff] [blame] | 598 | #ifdef CONFIG_FEATURE_AUTOWIDTH |
| 599 | struct winsize winp; |
| 600 | if( ioctl(0, TIOCGWINSZ, &winp) == 0 ) { |
| 601 | win_width = winp.ws_col; |
| 602 | win_height = winp.ws_row; |
| 603 | } |
| 604 | #endif |
| 605 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 606 | #ifdef CONFIG_FEATURE_TELNET_TTYPE |
Eric Andersen | 7e1273e | 2001-05-07 17:57:45 +0000 | [diff] [blame] | 607 | ttype = getenv("TERM"); |
| 608 | #endif |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 609 | |
| 610 | memset(&G, 0, sizeof G); |
| 611 | |
| 612 | if (tcgetattr(0, &G.termios_def) < 0) |
| 613 | exit(1); |
| 614 | |
| 615 | G.termios_raw = G.termios_def; |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 616 | cfmakeraw(&G.termios_raw); |
| 617 | |
Eric Andersen | 67991cf | 2001-02-14 21:23:06 +0000 | [diff] [blame] | 618 | if (argc < 2) show_usage(); |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 619 | port = (argc > 2)? getport(argv[2]): 23; |
| 620 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 621 | host = getserver(argv[1]); |
| 622 | |
| 623 | G.netfd = remote_connect(host, port); |
| 624 | |
| 625 | signal(SIGINT, fgotsig); |
| 626 | |
| 627 | #ifdef USE_POLL |
| 628 | ufds[0].fd = 0; ufds[1].fd = G.netfd; |
| 629 | ufds[0].events = ufds[1].events = POLLIN; |
| 630 | #else |
| 631 | FD_ZERO(&readfds); |
| 632 | FD_SET(0, &readfds); |
| 633 | FD_SET(G.netfd, &readfds); |
| 634 | maxfd = G.netfd + 1; |
| 635 | #endif |
| 636 | |
| 637 | while (1) |
| 638 | { |
| 639 | #ifndef USE_POLL |
| 640 | fd_set rfds = readfds; |
| 641 | |
| 642 | switch (select(maxfd, &rfds, NULL, NULL, NULL)) |
| 643 | #else |
| 644 | switch (poll(ufds, 2, -1)) |
| 645 | #endif |
| 646 | { |
| 647 | case 0: |
| 648 | /* timeout */ |
| 649 | case -1: |
| 650 | /* error, ignore and/or log something, bay go to loop */ |
| 651 | if (G.gotsig) |
| 652 | conescape(); |
| 653 | else |
| 654 | sleep(1); |
| 655 | break; |
| 656 | default: |
| 657 | |
| 658 | #ifdef USE_POLL |
| 659 | if (ufds[0].revents) /* well, should check POLLIN, but ... */ |
| 660 | #else |
| 661 | if (FD_ISSET(0, &rfds)) |
| 662 | #endif |
| 663 | { |
Glenn L McGrath | 78b0e37 | 2001-06-26 02:06:08 +0000 | [diff] [blame] | 664 | len = read(0, G.buf, DATABUFSIZE); |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 665 | |
Glenn L McGrath | 78b0e37 | 2001-06-26 02:06:08 +0000 | [diff] [blame] | 666 | if (len <= 0) |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 667 | doexit(0); |
| 668 | |
Glenn L McGrath | 78b0e37 | 2001-06-26 02:06:08 +0000 | [diff] [blame] | 669 | TRACE(0, ("Read con: %d\n", len)); |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 670 | |
Glenn L McGrath | 78b0e37 | 2001-06-26 02:06:08 +0000 | [diff] [blame] | 671 | handlenetoutput(len); |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | #ifdef USE_POLL |
| 675 | if (ufds[1].revents) /* well, should check POLLIN, but ... */ |
| 676 | #else |
| 677 | if (FD_ISSET(G.netfd, &rfds)) |
| 678 | #endif |
| 679 | { |
Glenn L McGrath | 78b0e37 | 2001-06-26 02:06:08 +0000 | [diff] [blame] | 680 | len = read(G.netfd, G.buf, DATABUFSIZE); |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 681 | |
Glenn L McGrath | 78b0e37 | 2001-06-26 02:06:08 +0000 | [diff] [blame] | 682 | if (len <= 0) |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 683 | { |
| 684 | WriteCS(1, "Connection closed by foreign host.\r\n"); |
| 685 | doexit(1); |
| 686 | } |
Glenn L McGrath | 78b0e37 | 2001-06-26 02:06:08 +0000 | [diff] [blame] | 687 | TRACE(0, ("Read netfd (%d): %d\n", G.netfd, len)); |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 688 | |
Glenn L McGrath | 78b0e37 | 2001-06-26 02:06:08 +0000 | [diff] [blame] | 689 | handlenetinput(len); |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 690 | } |
| 691 | } |
| 692 | } |
| 693 | } |
| 694 | |
| 695 | static int getport(char * p) |
| 696 | { |
| 697 | unsigned int port = atoi(p); |
| 698 | |
| 699 | if ((unsigned)(port - 1 ) > 65534) |
| 700 | { |
Matt Kraai | dd19c69 | 2001-01-31 19:00:21 +0000 | [diff] [blame] | 701 | error_msg_and_die("%s: bad port number", p); |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 702 | } |
| 703 | return port; |
| 704 | } |
| 705 | |
| 706 | static struct in_addr getserver(char * host) |
| 707 | { |
| 708 | struct in_addr addr; |
Matt Kraai | c55b8d4 | 2001-05-16 15:40:51 +0000 | [diff] [blame] | 709 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 710 | struct hostent * he; |
Matt Kraai | c55b8d4 | 2001-05-16 15:40:51 +0000 | [diff] [blame] | 711 | he = xgethostbyname(host); |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 712 | memcpy(&addr, he->h_addr, sizeof addr); |
| 713 | |
| 714 | TRACE(1, ("addr: %s\n", inet_ntoa(addr))); |
Matt Kraai | c55b8d4 | 2001-05-16 15:40:51 +0000 | [diff] [blame] | 715 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 716 | return addr; |
Matt Kraai | c55b8d4 | 2001-05-16 15:40:51 +0000 | [diff] [blame] | 717 | } |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 718 | |
Eric Andersen | cd8c436 | 2001-11-10 11:22:46 +0000 | [diff] [blame] | 719 | static int create_socket(void) |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 720 | { |
| 721 | return socket(AF_INET, SOCK_STREAM, 0); |
| 722 | } |
| 723 | |
| 724 | static void setup_sockaddr_in(struct sockaddr_in * addr, int port) |
| 725 | { |
Eric Andersen | 8b96032 | 2001-03-17 05:43:39 +0000 | [diff] [blame] | 726 | memset(addr, 0, sizeof(struct sockaddr_in)); |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 727 | addr->sin_family = AF_INET; |
| 728 | addr->sin_port = htons(port); |
| 729 | } |
| 730 | |
| 731 | #if 0 |
| 732 | static int local_bind(int port) |
| 733 | { |
| 734 | struct sockaddr_in s_addr; |
| 735 | int s = create_socket(); |
| 736 | |
| 737 | setup_sockaddr_in(&s_addr, port); |
| 738 | |
| 739 | setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof one); |
| 740 | |
| 741 | if (bind(s, &s_addr, sizeof s_addr) < 0) |
| 742 | { |
| 743 | char * e = sys_errlist[errno]; |
| 744 | syserrorexit("bind"); |
| 745 | exit(1); |
| 746 | } |
| 747 | listen(s, 1); |
| 748 | |
| 749 | return s; |
| 750 | } |
| 751 | #endif |
| 752 | |
| 753 | static int remote_connect(struct in_addr addr, int port) |
| 754 | { |
| 755 | struct sockaddr_in s_addr; |
| 756 | int s = create_socket(); |
| 757 | |
| 758 | setup_sockaddr_in(&s_addr, port); |
| 759 | s_addr.sin_addr = addr; |
| 760 | |
| 761 | setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof one); |
| 762 | |
| 763 | if (connect(s, (struct sockaddr *)&s_addr, sizeof s_addr) < 0) |
| 764 | { |
Matt Kraai | 1fa1ade | 2000-12-18 03:57:16 +0000 | [diff] [blame] | 765 | perror_msg_and_die("Unable to connect to remote host"); |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 766 | } |
| 767 | return s; |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 768 | } |
| 769 | |
| 770 | /* |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 771 | Local Variables: |
| 772 | c-file-style: "linux" |
| 773 | c-basic-offset: 4 |
| 774 | tab-width: 4 |
| 775 | End: |
| 776 | */ |