|
1 /* |
|
2 * Copyright (c) 1989, 1993 |
|
3 * The Regents of the University of California. All rights reserved. |
|
4 * |
|
5 * Redistribution and use in source and binary forms, with or without |
|
6 * modification, are permitted provided that the following conditions |
|
7 * are met: |
|
8 * 1. Redistributions of source code must retain the above copyright |
|
9 * notice, this list of conditions and the following disclaimer. |
|
10 * 2. Redistributions in binary form must reproduce the above copyright |
|
11 * notice, this list of conditions and the following disclaimer in the |
|
12 * documentation and/or other materials provided with the distribution. |
|
13 * 3. Neither the name of the University nor the names of its contributors |
|
14 * may be used to endorse or promote products derived from this software |
|
15 * without specific prior written permission. |
|
16 * |
|
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
|
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
|
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
27 * SUCH DAMAGE. |
|
28 * |
|
29 * @(#)defs.h 8.1 (Berkeley) 6/4/93 |
|
30 */ |
|
31 |
|
32 /* |
|
33 * Telnet server defines |
|
34 */ |
|
35 |
|
36 #ifndef __DEFS_H__ |
|
37 #define __DEFS_H__ |
|
38 |
|
39 #ifndef BSD |
|
40 # define BSD 43 |
|
41 #endif |
|
42 |
|
43 #if defined(PRINTOPTIONS) && defined(DIAGNOSTICS) |
|
44 #define TELOPTS |
|
45 #define TELCMDS |
|
46 #define SLC_NAMES |
|
47 #endif |
|
48 |
|
49 #if !defined(TIOCSCTTY) && defined(TCSETCTTY) |
|
50 # define TIOCSCTTY TCSETCTTY |
|
51 #endif |
|
52 |
|
53 #ifndef TIOCPKT_FLUSHWRITE |
|
54 #define TIOCPKT_FLUSHWRITE 0x02 |
|
55 #endif |
|
56 |
|
57 #ifndef TIOCPKT_NOSTOP |
|
58 #define TIOCPKT_NOSTOP 0x10 |
|
59 #endif |
|
60 |
|
61 #ifndef TIOCPKT_DOSTOP |
|
62 #define TIOCPKT_DOSTOP 0x20 |
|
63 #endif |
|
64 |
|
65 /* |
|
66 * I/O data buffers defines |
|
67 */ |
|
68 #define NETSLOP 64 |
|
69 #ifdef _CRAY |
|
70 #undef BUFSIZ |
|
71 #define BUFSIZ 2048 |
|
72 #endif |
|
73 |
|
74 #define NIACCUM(c) { *netip++ = c; \ |
|
75 ncc++; \ |
|
76 } |
|
77 |
|
78 /* clock manipulations */ |
|
79 #define settimer(x) (clocks.x = ++clocks.system) |
|
80 #define sequenceIs(x,y) (clocks.x < clocks.y) |
|
81 |
|
82 /* |
|
83 * Structures of information for each special character function. |
|
84 */ |
|
85 typedef struct { |
|
86 unsigned char flag; /* the flags for this function */ |
|
87 cc_t val; /* the value of the special character */ |
|
88 } slcent, *Slcent; |
|
89 |
|
90 typedef struct { |
|
91 slcent defset; /* the default settings */ |
|
92 slcent current; /* the current settings */ |
|
93 cc_t *sptr; /* a pointer to the char in */ |
|
94 /* system data structures */ |
|
95 } slcfun, *Slcfun; |
|
96 |
|
97 #ifdef DIAGNOSTICS |
|
98 /* |
|
99 * Diagnostics capabilities |
|
100 */ |
|
101 #define TD_REPORT 0x01 /* Report operations to client */ |
|
102 #define TD_EXERCISE 0x02 /* Exercise client's implementation */ |
|
103 #define TD_NETDATA 0x04 /* Display received data stream */ |
|
104 #define TD_PTYDATA 0x08 /* Display data passed to pty */ |
|
105 #define TD_OPTIONS 0x10 /* Report just telnet options */ |
|
106 #endif /* DIAGNOSTICS */ |
|
107 |
|
108 /* |
|
109 * We keep track of each side of the option negotiation. |
|
110 */ |
|
111 |
|
112 #define MY_STATE_WILL 0x01 |
|
113 #define MY_WANT_STATE_WILL 0x02 |
|
114 #define MY_STATE_DO 0x04 |
|
115 #define MY_WANT_STATE_DO 0x08 |
|
116 |
|
117 /* |
|
118 * Macros to check the current state of things |
|
119 */ |
|
120 |
|
121 #define my_state_is_do(opt) (options[opt]&MY_STATE_DO) |
|
122 #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL) |
|
123 #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO) |
|
124 #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL) |
|
125 |
|
126 #define my_state_is_dont(opt) (!my_state_is_do(opt)) |
|
127 #define my_state_is_wont(opt) (!my_state_is_will(opt)) |
|
128 #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt)) |
|
129 #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt)) |
|
130 |
|
131 #define set_my_state_do(opt) (options[opt] |= MY_STATE_DO) |
|
132 #define set_my_state_will(opt) (options[opt] |= MY_STATE_WILL) |
|
133 #define set_my_want_state_do(opt) (options[opt] |= MY_WANT_STATE_DO) |
|
134 #define set_my_want_state_will(opt) (options[opt] |= MY_WANT_STATE_WILL) |
|
135 |
|
136 #define set_my_state_dont(opt) (options[opt] &= ~MY_STATE_DO) |
|
137 #define set_my_state_wont(opt) (options[opt] &= ~MY_STATE_WILL) |
|
138 #define set_my_want_state_dont(opt) (options[opt] &= ~MY_WANT_STATE_DO) |
|
139 #define set_my_want_state_wont(opt) (options[opt] &= ~MY_WANT_STATE_WILL) |
|
140 |
|
141 /* |
|
142 * Tricky code here. What we want to know is if the MY_STATE_WILL |
|
143 * and MY_WANT_STATE_WILL bits have the same value. Since the two |
|
144 * bits are adjacent, a little arithmatic will show that by adding |
|
145 * in the lower bit, the upper bit will be set if the two bits were |
|
146 * different, and clear if they were the same. |
|
147 */ |
|
148 #define my_will_wont_is_changing(opt) \ |
|
149 ((options[opt]+MY_STATE_WILL) & MY_WANT_STATE_WILL) |
|
150 |
|
151 #define my_do_dont_is_changing(opt) \ |
|
152 ((options[opt]+MY_STATE_DO) & MY_WANT_STATE_DO) |
|
153 |
|
154 /* |
|
155 * Make everything symmetrical |
|
156 */ |
|
157 |
|
158 #define HIS_STATE_WILL MY_STATE_DO |
|
159 #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO |
|
160 #define HIS_STATE_DO MY_STATE_WILL |
|
161 #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL |
|
162 |
|
163 #define his_state_is_do my_state_is_will |
|
164 #define his_state_is_will my_state_is_do |
|
165 #define his_want_state_is_do my_want_state_is_will |
|
166 #define his_want_state_is_will my_want_state_is_do |
|
167 |
|
168 #define his_state_is_dont my_state_is_wont |
|
169 #define his_state_is_wont my_state_is_dont |
|
170 #define his_want_state_is_dont my_want_state_is_wont |
|
171 #define his_want_state_is_wont my_want_state_is_dont |
|
172 |
|
173 #define set_his_state_do set_my_state_will |
|
174 #define set_his_state_will set_my_state_do |
|
175 #define set_his_want_state_do set_my_want_state_will |
|
176 #define set_his_want_state_will set_my_want_state_do |
|
177 |
|
178 #define set_his_state_dont set_my_state_wont |
|
179 #define set_his_state_wont set_my_state_dont |
|
180 #define set_his_want_state_dont set_my_want_state_wont |
|
181 #define set_his_want_state_wont set_my_want_state_dont |
|
182 |
|
183 #define his_will_wont_is_changing my_do_dont_is_changing |
|
184 #define his_do_dont_is_changing my_will_wont_is_changing |
|
185 |
|
186 #endif /* __DEFS_H__ */ |