]>
git.saurik.com Git - apple/network_cmds.git/blob - telnetd.tproj/defs.h
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.0 (the 'License'). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
25 * Copyright (c) 1989, 1993
26 * The Regents of the University of California. All rights reserved.
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that the following conditions
31 * 1. Redistributions of source code must retain the above copyright
32 * notice, this list of conditions and the following disclaimer.
33 * 2. Redistributions in binary form must reproduce the above copyright
34 * notice, this list of conditions and the following disclaimer in the
35 * documentation and/or other materials provided with the distribution.
36 * 3. All advertising materials mentioning features or use of this software
37 * must display the following acknowledgement:
38 * This product includes software developed by the University of
39 * California, Berkeley and its contributors.
40 * 4. Neither the name of the University nor the names of its contributors
41 * may be used to endorse or promote products derived from this software
42 * without specific prior written permission.
44 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
45 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
48 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
50 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 * @(#)defs.h 8.1 (Berkeley) 6/4/93
60 * Telnet server defines
62 #include <sys/types.h>
63 #include <sys/param.h>
69 #if defined(CRAY) && !defined(LINEMODE)
72 # define KLUDGELINEMODE
74 # if defined(UNICOS50) && !defined(UNICOS5)
77 # if !defined(UNICOS5)
82 #if defined(UNICOS5) && !defined(NO_SETSID)
86 #if defined(PRINTOPTIONS) && defined(DIAGNOSTICS)
92 #if defined(SYSV_TERMIO) && !defined(USE_TERMIO)
96 #include <sys/socket.h>
101 #include <sys/file.h>
102 #include <sys/stat.h>
103 #include <sys/time.h>
105 #include <sys/ioctl.h>
107 #include <sys/filio.h>
110 #include <netinet/in.h>
112 #include <arpa/telnet.h>
142 # include <sys/termios.h>
144 # include <termios.h>
148 #if !defined(USE_TERMIO) || defined(NO_CC_T)
149 typedef unsigned char cc_t
;
156 #ifndef _POSIX_VDISABLE
158 # define _POSIX_VDISABLE VDISABLE
160 # define _POSIX_VDISABLE ((unsigned char)'\377')
167 # include <sys/pty.h>
169 # include <sys/select.h>
170 # endif /* FD_ZERO */
177 #include <sys/ptyio.h>
180 #if !defined(TIOCSCTTY) && defined(TCSETCTTY)
181 # define TIOCSCTTY TCSETCTTY
186 typedef struct fd_set
{ int fds_bits
[1]; } fd_set
;
189 #define FD_SET(n, p) ((p)->fds_bits[0] |= (1<<(n)))
190 #define FD_CLR(n, p) ((p)->fds_bits[0] &= ~(1<<(n)))
191 #define FD_ISSET(n, p) ((p)->fds_bits[0] & (1<<(n)))
192 #define FD_ZERO(p) ((p)->fds_bits[0] = 0)
196 * I/O data buffers defines
204 #define NIACCUM(c) { *netip++ = c; \
208 /* clock manipulations */
209 #define settimer(x) (clocks.x = ++clocks.system)
210 #define sequenceIs(x,y) (clocks.x < clocks.y)
213 * Linemode support states, in decreasing order of importance
215 #define REAL_LINEMODE 0x04
216 #define KLUDGE_OK 0x03
217 #define NO_AUTOKLUDGE 0x02
218 #define KLUDGE_LINEMODE 0x01
219 #define NO_LINEMODE 0x00
222 * Structures of information for each special character function.
225 unsigned char flag
; /* the flags for this function */
226 cc_t val
; /* the value of the special character */
230 slcent defset
; /* the default settings */
231 slcent current
; /* the current settings */
232 cc_t
*sptr
; /* a pointer to the char in */
233 /* system data structures */
238 * Diagnostics capabilities
240 #define TD_REPORT 0x01 /* Report operations to client */
241 #define TD_EXERCISE 0x02 /* Exercise client's implementation */
242 #define TD_NETDATA 0x04 /* Display received data stream */
243 #define TD_PTYDATA 0x08 /* Display data passed to pty */
244 #define TD_OPTIONS 0x10 /* Report just telnet options */
245 #endif /* DIAGNOSTICS */
248 * We keep track of each side of the option negotiation.
251 #define MY_STATE_WILL 0x01
252 #define MY_WANT_STATE_WILL 0x02
253 #define MY_STATE_DO 0x04
254 #define MY_WANT_STATE_DO 0x08
257 * Macros to check the current state of things
260 #define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
261 #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
262 #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
263 #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
265 #define my_state_is_dont(opt) (!my_state_is_do(opt))
266 #define my_state_is_wont(opt) (!my_state_is_will(opt))
267 #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
268 #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
270 #define set_my_state_do(opt) (options[opt] |= MY_STATE_DO)
271 #define set_my_state_will(opt) (options[opt] |= MY_STATE_WILL)
272 #define set_my_want_state_do(opt) (options[opt] |= MY_WANT_STATE_DO)
273 #define set_my_want_state_will(opt) (options[opt] |= MY_WANT_STATE_WILL)
275 #define set_my_state_dont(opt) (options[opt] &= ~MY_STATE_DO)
276 #define set_my_state_wont(opt) (options[opt] &= ~MY_STATE_WILL)
277 #define set_my_want_state_dont(opt) (options[opt] &= ~MY_WANT_STATE_DO)
278 #define set_my_want_state_wont(opt) (options[opt] &= ~MY_WANT_STATE_WILL)
281 * Tricky code here. What we want to know is if the MY_STATE_WILL
282 * and MY_WANT_STATE_WILL bits have the same value. Since the two
283 * bits are adjacent, a little arithmatic will show that by adding
284 * in the lower bit, the upper bit will be set if the two bits were
285 * different, and clear if they were the same.
287 #define my_will_wont_is_changing(opt) \
288 ((options[opt]+MY_STATE_WILL) & MY_WANT_STATE_WILL)
290 #define my_do_dont_is_changing(opt) \
291 ((options[opt]+MY_STATE_DO) & MY_WANT_STATE_DO)
294 * Make everything symetrical
297 #define HIS_STATE_WILL MY_STATE_DO
298 #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
299 #define HIS_STATE_DO MY_STATE_WILL
300 #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
302 #define his_state_is_do my_state_is_will
303 #define his_state_is_will my_state_is_do
304 #define his_want_state_is_do my_want_state_is_will
305 #define his_want_state_is_will my_want_state_is_do
307 #define his_state_is_dont my_state_is_wont
308 #define his_state_is_wont my_state_is_dont
309 #define his_want_state_is_dont my_want_state_is_wont
310 #define his_want_state_is_wont my_want_state_is_dont
312 #define set_his_state_do set_my_state_will
313 #define set_his_state_will set_my_state_do
314 #define set_his_want_state_do set_my_want_state_will
315 #define set_his_want_state_will set_my_want_state_do
317 #define set_his_state_dont set_my_state_wont
318 #define set_his_state_wont set_my_state_dont
319 #define set_his_want_state_dont set_my_want_state_wont
320 #define set_his_want_state_wont set_my_want_state_dont
322 #define his_will_wont_is_changing my_do_dont_is_changing
323 #define his_do_dont_is_changing my_will_wont_is_changing