|
|
1.1 root 1: /*
2: * Copyright (c) 1989 The Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms are permitted provided
6: * that: (1) source distributions retain this entire copyright notice and
7: * comment, and (2) distributions including binaries display the following
8: * acknowledgement: ``This product includes software developed by the
9: * University of California, Berkeley and its contributors'' in the
10: * documentation or other materials provided with the distribution and in
11: * all advertising materials mentioning features or use of this software.
12: * Neither the name of the University nor the names of its contributors may
13: * be used to endorse or promote products derived from this software without
14: * specific prior written permission.
15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
16: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
17: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18: *
19: * @(#)defs.h 5.8 (Berkeley) 6/28/90
20: */
21:
22: /*
23: * Telnet server defines
24: */
25: #include <sys/types.h>
26: #include <sys/param.h>
27:
28: #ifndef BSD
29: # define BSD 43
30: #endif
31:
32: #if defined(CRAY) && !defined(LINEMODE)
33: # define SYSV_TERMIO
34: # define LINEMODE
35: # define KLUDGELINEMODE
36: # define NO_GETTYTAB
37: # define DIAGNOSTICS
38: # if !defined(UNICOS5)
39: # define BFTPDAEMON
40: # define HAS_IP_TOS
41: # endif
42: #endif /* CRAY */
43: #if defined(UNICOS5) && !defined(NO_SETSID)
44: # define NO_SETSID
45: #endif
46:
47: #if defined(PRINTOPTIONS) && defined(DIAGNOSTICS)
48: #define TELOPTS
49: #define TELCMDS
50: #endif
51:
52: #if defined(SYSV_TERMIO) && !defined(USE_TERMIO)
53: # define USE_TERMIO
54: #endif
55:
56: #include <sys/socket.h>
57: #ifndef CRAY
58: #include <sys/wait.h>
59: #endif /* CRAY */
60: #include <sys/file.h>
61: #include <sys/stat.h>
62: #include <sys/time.h>
63: #ifndef FILIO_H
64: #include <sys/ioctl.h>
65: #else
66: #include <sys/filio.h>
67: #endif
68:
69: #include <netinet/in.h>
70:
71: #include <arpa/telnet.h>
72:
73: #include <stdio.h>
74: #include <signal.h>
75: #include <errno.h>
76: #include <netdb.h>
77: #include <syslog.h>
78: #ifndef LOG_DAEMON
79: #define LOG_DAEMON 0
80: #endif
81: #ifndef LOG_ODELAY
82: #define LOG_ODELAY 0
83: #endif
84: #include <ctype.h>
85: #ifndef NO_STRING_H
86: #include <string.h>
87: #else
88: #include <strings.h>
89: #endif
90:
91: #ifndef USE_TERMIO
92: #include <sgtty.h>
93: #else
94: # ifdef SYSV_TERMIO
95: # include <termio.h>
96: # else
97: # include <termios.h>
98: # endif
99: #endif
100: #if !defined(USE_TERMIO) || defined(NO_CC_T)
101: typedef unsigned char cc_t;
102: #endif
103:
104: #ifdef CRAY
105: #include <sys/fcntl.h>
106: # ifdef CRAY1
107: # include <sys/pty.h>
108: # ifndef FD_ZERO
109: # include <sys/select.h>
110: # endif /* FD_ZERO */
111: # endif /* CRAY1 */
112:
113: #include <memory.h>
114: #endif /* CRAY */
115:
116: #if !defined(TIOCSCTTY) && defined(TCSETCTTY)
117: # define TIOCSCTTY TCSETCTTY
118: #endif
119:
120: #ifndef FD_SET
121: #ifndef HAVE_fd_set
122: typedef struct fd_set { int fds_bits[1]; } fd_set;
123: #endif
124:
125: #define FD_SET(n, p) ((p)->fds_bits[0] |= (1<<(n)))
126: #define FD_CLR(n, p) ((p)->fds_bits[0] &= ~(1<<(n)))
127: #define FD_ISSET(n, p) ((p)->fds_bits[0] & (1<<(n)))
128: #define FD_ZERO(p) ((p)->fds_bits[0] = 0)
129: #endif /* FD_SET */
130:
131: /*
132: * I/O data buffers defines
133: */
134: #define NETSLOP 64
135: #ifdef CRAY
136: #undef BUFSIZ
137: #define BUFSIZ 2048
138: #endif
139:
140: #define NIACCUM(c) { *netip++ = c; \
141: ncc++; \
142: }
143:
144: /* clock manipulations */
145: #define settimer(x) (clocks.x = ++clocks.system)
146: #define sequenceIs(x,y) (clocks.x < clocks.y)
147:
148: /*
149: * Linemode support states, in decreasing order of importance
150: */
151: #define REAL_LINEMODE 0x02
152: #define KLUDGE_LINEMODE 0x01
153: #define NO_LINEMODE 0x00
154:
155: /*
156: * Structures of information for each special character function.
157: */
158: typedef struct {
159: unsigned char flag; /* the flags for this function */
160: cc_t val; /* the value of the special character */
161: } slcent, *Slcent;
162:
163: typedef struct {
164: slcent defset; /* the default settings */
165: slcent current; /* the current settings */
166: cc_t *sptr; /* a pointer to the char in */
167: /* system data structures */
168: } slcfun, *Slcfun;
169:
170: #ifdef DIAGNOSTICS
171: /*
172: * Diagnostics capabilities
173: */
174: #define TD_REPORT 0x01 /* Report operations to client */
175: #define TD_EXERCISE 0x02 /* Exercise client's implementation */
176: #define TD_NETDATA 0x04 /* Display received data stream */
177: #define TD_PTYDATA 0x08 /* Display data passed to pty */
178: #define TD_OPTIONS 0x10 /* Report just telnet options */
179: #endif /* DIAGNOSTICS */
180:
181: /*
182: * We keep track of each side of the option negotiation.
183: */
184:
185: #define MY_STATE_WILL 0x01
186: #define MY_WANT_STATE_WILL 0x02
187: #define MY_STATE_DO 0x04
188: #define MY_WANT_STATE_DO 0x08
189:
190: /*
191: * Macros to check the current state of things
192: */
193:
194: #define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
195: #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
196: #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
197: #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
198:
199: #define my_state_is_dont(opt) (!my_state_is_do(opt))
200: #define my_state_is_wont(opt) (!my_state_is_will(opt))
201: #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
202: #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
203:
204: #define set_my_state_do(opt) (options[opt] |= MY_STATE_DO)
205: #define set_my_state_will(opt) (options[opt] |= MY_STATE_WILL)
206: #define set_my_want_state_do(opt) (options[opt] |= MY_WANT_STATE_DO)
207: #define set_my_want_state_will(opt) (options[opt] |= MY_WANT_STATE_WILL)
208:
209: #define set_my_state_dont(opt) (options[opt] &= ~MY_STATE_DO)
210: #define set_my_state_wont(opt) (options[opt] &= ~MY_STATE_WILL)
211: #define set_my_want_state_dont(opt) (options[opt] &= ~MY_WANT_STATE_DO)
212: #define set_my_want_state_wont(opt) (options[opt] &= ~MY_WANT_STATE_WILL)
213:
214: /*
215: * Tricky code here. What we want to know is if the MY_STATE_WILL
216: * and MY_WANT_STATE_WILL bits have the same value. Since the two
217: * bits are adjacent, a little arithmatic will show that by adding
218: * in the lower bit, the upper bit will be set if the two bits were
219: * different, and clear if they were the same.
220: */
221: #define my_will_wont_is_changing(opt) \
222: ((options[opt]+MY_STATE_WILL) & MY_WANT_STATE_WILL)
223:
224: #define my_do_dont_is_changing(opt) \
225: ((options[opt]+MY_STATE_DO) & MY_WANT_STATE_DO)
226:
227: /*
228: * Make everything symetrical
229: */
230:
231: #define HIS_STATE_WILL MY_STATE_DO
232: #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
233: #define HIS_STATE_DO MY_STATE_WILL
234: #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
235:
236: #define his_state_is_do my_state_is_will
237: #define his_state_is_will my_state_is_do
238: #define his_want_state_is_do my_want_state_is_will
239: #define his_want_state_is_will my_want_state_is_do
240:
241: #define his_state_is_dont my_state_is_wont
242: #define his_state_is_wont my_state_is_dont
243: #define his_want_state_is_dont my_want_state_is_wont
244: #define his_want_state_is_wont my_want_state_is_dont
245:
246: #define set_his_state_do set_my_state_will
247: #define set_his_state_will set_my_state_do
248: #define set_his_want_state_do set_my_want_state_will
249: #define set_his_want_state_will set_my_want_state_do
250:
251: #define set_his_state_dont set_my_state_wont
252: #define set_his_state_wont set_my_state_dont
253: #define set_his_want_state_dont set_my_want_state_wont
254: #define set_his_want_state_wont set_my_want_state_dont
255:
256: #define his_will_wont_is_changing my_do_dont_is_changing
257: #define his_do_dont_is_changing my_will_wont_is_changing
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.