1 | /***********************************************************
|
---|
2 |
|
---|
3 | Copyright 1987, 1998 The Open Group
|
---|
4 |
|
---|
5 | Permission to use, copy, modify, distribute, and sell this software and its
|
---|
6 | documentation for any purpose is hereby granted without fee, provided that
|
---|
7 | the above copyright notice appear in all copies and that both that
|
---|
8 | copyright notice and this permission notice appear in supporting
|
---|
9 | documentation.
|
---|
10 |
|
---|
11 | The above copyright notice and this permission notice shall be included in
|
---|
12 | all copies or substantial portions of the Software.
|
---|
13 |
|
---|
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
---|
17 | OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
---|
18 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
---|
19 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
20 |
|
---|
21 | Except as contained in this notice, the name of The Open Group shall not be
|
---|
22 | used in advertising or otherwise to promote the sale, use or other dealings
|
---|
23 | in this Software without prior written authorization from The Open Group.
|
---|
24 |
|
---|
25 |
|
---|
26 | Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
|
---|
27 |
|
---|
28 | All Rights Reserved
|
---|
29 |
|
---|
30 | Permission to use, copy, modify, and distribute this software and its
|
---|
31 | documentation for any purpose and without fee is hereby granted,
|
---|
32 | provided that the above copyright notice appear in all copies and that
|
---|
33 | both that copyright notice and this permission notice appear in
|
---|
34 | supporting documentation, and that the name of Digital not be
|
---|
35 | used in advertising or publicity pertaining to distribution of the
|
---|
36 | software without specific, written prior permission.
|
---|
37 |
|
---|
38 | DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
---|
39 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
---|
40 | DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
---|
41 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
---|
42 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
---|
43 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
---|
44 | SOFTWARE.
|
---|
45 |
|
---|
46 | ******************************************************************/
|
---|
47 |
|
---|
48 | #ifdef HAVE_DIX_CONFIG_H
|
---|
49 | #include <dix-config.h>
|
---|
50 | #endif
|
---|
51 |
|
---|
52 | #ifndef _OSDEP_H_
|
---|
53 | #define _OSDEP_H_ 1
|
---|
54 |
|
---|
55 | #define BOTIMEOUT 200 /* in milliseconds */
|
---|
56 | #define BUFSIZE 4096
|
---|
57 | #define BUFWATERMARK 8192
|
---|
58 | #ifndef MAXBUFSIZE
|
---|
59 | #define MAXBUFSIZE (1 << 22)
|
---|
60 | #endif
|
---|
61 |
|
---|
62 | #include <X11/Xdmcp.h>
|
---|
63 |
|
---|
64 | #ifndef sgi /* SGI defines OPEN_MAX in a useless way */
|
---|
65 | #ifndef X_NOT_POSIX
|
---|
66 | #ifdef _POSIX_SOURCE
|
---|
67 | #include <limits.h>
|
---|
68 | #else
|
---|
69 | #define _POSIX_SOURCE
|
---|
70 | #include <limits.h>
|
---|
71 | #undef _POSIX_SOURCE
|
---|
72 | #endif
|
---|
73 | #else /* X_NOT_POSIX */
|
---|
74 | #ifdef WIN32
|
---|
75 | #define _POSIX_
|
---|
76 | #include <limits.h>
|
---|
77 | #undef _POSIX_
|
---|
78 | #endif
|
---|
79 | #endif /* X_NOT_POSIX */
|
---|
80 | #endif
|
---|
81 |
|
---|
82 | #ifdef __QNX__
|
---|
83 | #define NOFILES_MAX 256
|
---|
84 | #endif
|
---|
85 | #ifndef OPEN_MAX
|
---|
86 | #ifdef SVR4
|
---|
87 | #define OPEN_MAX 256
|
---|
88 | #else
|
---|
89 | #include <sys/param.h>
|
---|
90 | #ifndef OPEN_MAX
|
---|
91 | #if defined(NOFILE) && !defined(NOFILES_MAX)
|
---|
92 | #define OPEN_MAX NOFILE
|
---|
93 | #else
|
---|
94 | #if !defined(__UNIXOS2__) && !defined(WIN32)
|
---|
95 | #define OPEN_MAX NOFILES_MAX
|
---|
96 | #else
|
---|
97 | #define OPEN_MAX 256
|
---|
98 | #endif
|
---|
99 | #endif
|
---|
100 | #endif
|
---|
101 | #endif
|
---|
102 | #endif
|
---|
103 |
|
---|
104 | #include <X11/Xpoll.h>
|
---|
105 |
|
---|
106 | /*
|
---|
107 | * MAXSOCKS is used only for initialising MaxClients when no other method
|
---|
108 | * like sysconf(_SC_OPEN_MAX) is not supported.
|
---|
109 | */
|
---|
110 |
|
---|
111 | #if OPEN_MAX <= 256
|
---|
112 | #define MAXSOCKS (OPEN_MAX - 1)
|
---|
113 | #else
|
---|
114 | #define MAXSOCKS 256
|
---|
115 | #endif
|
---|
116 |
|
---|
117 | /* MAXSELECT is the number of fds that select() can handle */
|
---|
118 | #define MAXSELECT (sizeof(fd_set) * NBBY)
|
---|
119 |
|
---|
120 | #ifndef HAS_GETDTABLESIZE
|
---|
121 | #if !defined(hpux) && !defined(SVR4) && !defined(SYSV)
|
---|
122 | #define HAS_GETDTABLESIZE
|
---|
123 | #endif
|
---|
124 | #endif
|
---|
125 |
|
---|
126 | #include <stddef.h>
|
---|
127 |
|
---|
128 | typedef Bool (*ValidatorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
|
---|
129 | typedef Bool (*GeneratorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
|
---|
130 | typedef Bool (*AddAuthorFunc)(unsigned name_length, char *name, unsigned data_length, char *data);
|
---|
131 |
|
---|
132 | typedef struct _connectionInput {
|
---|
133 | struct _connectionInput *next;
|
---|
134 | char *buffer; /* contains current client input */
|
---|
135 | char *bufptr; /* pointer to current start of data */
|
---|
136 | int bufcnt; /* count of bytes in buffer */
|
---|
137 | int lenLastReq;
|
---|
138 | int size;
|
---|
139 | } ConnectionInput, *ConnectionInputPtr;
|
---|
140 |
|
---|
141 | typedef struct _connectionOutput {
|
---|
142 | struct _connectionOutput *next;
|
---|
143 | int size;
|
---|
144 | unsigned char *buf;
|
---|
145 | int count;
|
---|
146 | } ConnectionOutput, *ConnectionOutputPtr;
|
---|
147 |
|
---|
148 | #ifdef K5AUTH
|
---|
149 | typedef struct _k5_state {
|
---|
150 | int stageno; /* current stage of auth protocol */
|
---|
151 | pointer srvcreds; /* server credentials */
|
---|
152 | pointer srvname; /* server principal name */
|
---|
153 | pointer ktname; /* key table: principal-key pairs */
|
---|
154 | pointer skey; /* session key */
|
---|
155 | } k5_state;
|
---|
156 | #endif
|
---|
157 |
|
---|
158 | struct _osComm;
|
---|
159 |
|
---|
160 | #define AuthInitArgs void
|
---|
161 | typedef void (*AuthInitFunc) (AuthInitArgs);
|
---|
162 |
|
---|
163 | #define AuthAddCArgs unsigned short data_length, char *data, XID id
|
---|
164 | typedef int (*AuthAddCFunc) (AuthAddCArgs);
|
---|
165 |
|
---|
166 | #define AuthCheckArgs unsigned short data_length, char *data, ClientPtr client, char **reason
|
---|
167 | typedef XID (*AuthCheckFunc) (AuthCheckArgs);
|
---|
168 |
|
---|
169 | #define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap
|
---|
170 | typedef int (*AuthFromIDFunc) (AuthFromIDArgs);
|
---|
171 |
|
---|
172 | #define AuthGenCArgs unsigned data_length, char *data, XID id, unsigned *data_length_return, char **data_return
|
---|
173 | typedef XID (*AuthGenCFunc) (AuthGenCArgs);
|
---|
174 |
|
---|
175 | #define AuthRemCArgs unsigned short data_length, char *data
|
---|
176 | typedef int (*AuthRemCFunc) (AuthRemCArgs);
|
---|
177 |
|
---|
178 | #define AuthRstCArgs void
|
---|
179 | typedef int (*AuthRstCFunc) (AuthRstCArgs);
|
---|
180 |
|
---|
181 | #define AuthToIDArgs unsigned short data_length, char *data
|
---|
182 | typedef XID (*AuthToIDFunc) (AuthToIDArgs);
|
---|
183 |
|
---|
184 | typedef void (*OsCloseFunc)(ClientPtr);
|
---|
185 |
|
---|
186 | typedef int (*OsFlushFunc)(ClientPtr who, struct _osComm * oc, char* extraBuf, int extraCount);
|
---|
187 |
|
---|
188 | typedef struct _osComm {
|
---|
189 | int fd;
|
---|
190 | ConnectionInputPtr input;
|
---|
191 | ConnectionOutputPtr output;
|
---|
192 | XID auth_id; /* authorization id */
|
---|
193 | #ifdef K5AUTH
|
---|
194 | k5_state authstate; /* state of setup auth conversation */
|
---|
195 | #endif
|
---|
196 | CARD32 conn_time; /* timestamp if not established, else 0 */
|
---|
197 | struct _XtransConnInfo *trans_conn; /* transport connection object */
|
---|
198 | } OsCommRec, *OsCommPtr;
|
---|
199 |
|
---|
200 | extern int FlushClient(
|
---|
201 | ClientPtr /*who*/,
|
---|
202 | OsCommPtr /*oc*/,
|
---|
203 | char* /*extraBuf*/,
|
---|
204 | int /*extraCount*/
|
---|
205 | );
|
---|
206 |
|
---|
207 | extern void FreeOsBuffers(
|
---|
208 | OsCommPtr /*oc*/
|
---|
209 | );
|
---|
210 |
|
---|
211 | #include "dix.h"
|
---|
212 |
|
---|
213 | extern ConnectionInputPtr AllocateInputBuffer(void);
|
---|
214 |
|
---|
215 | extern ConnectionOutputPtr AllocateOutputBuffer(void);
|
---|
216 |
|
---|
217 | extern fd_set AllSockets;
|
---|
218 | extern fd_set AllClients;
|
---|
219 | extern fd_set LastSelectMask;
|
---|
220 | extern fd_set WellKnownConnections;
|
---|
221 | extern fd_set EnabledDevices;
|
---|
222 | extern fd_set ClientsWithInput;
|
---|
223 | extern fd_set ClientsWriteBlocked;
|
---|
224 | extern fd_set OutputPending;
|
---|
225 | extern fd_set IgnoredClientsWithInput;
|
---|
226 |
|
---|
227 | #ifndef WIN32
|
---|
228 | extern int *ConnectionTranslation;
|
---|
229 | #else
|
---|
230 | extern int GetConnectionTranslation(int conn);
|
---|
231 | extern void SetConnectionTranslation(int conn, int client);
|
---|
232 | extern void ClearConnectionTranslation();
|
---|
233 | #endif
|
---|
234 |
|
---|
235 | extern Bool NewOutputPending;
|
---|
236 | extern Bool AnyClientsWriteBlocked;
|
---|
237 | extern Bool CriticalOutputPending;
|
---|
238 |
|
---|
239 | extern int timesThisConnection;
|
---|
240 | extern ConnectionInputPtr FreeInputs;
|
---|
241 | extern ConnectionOutputPtr FreeOutputs;
|
---|
242 | extern OsCommPtr AvailableInput;
|
---|
243 |
|
---|
244 | extern WorkQueuePtr workQueue;
|
---|
245 |
|
---|
246 | /* added by raphael */
|
---|
247 | #ifdef WIN32
|
---|
248 | typedef long int fd_mask;
|
---|
249 | #endif
|
---|
250 | #define ffs mffs
|
---|
251 | extern int mffs(fd_mask);
|
---|
252 |
|
---|
253 | /* in auth.c */
|
---|
254 | extern void GenerateRandomData (int len, char *buf);
|
---|
255 |
|
---|
256 | /* in mitauth.c */
|
---|
257 | extern XID MitCheckCookie (AuthCheckArgs);
|
---|
258 | extern XID MitGenerateCookie (AuthGenCArgs);
|
---|
259 | extern XID MitToID (AuthToIDArgs);
|
---|
260 | extern int MitAddCookie (AuthAddCArgs);
|
---|
261 | extern int MitFromID (AuthFromIDArgs);
|
---|
262 | extern int MitRemoveCookie (AuthRemCArgs);
|
---|
263 | extern int MitResetCookie (AuthRstCArgs);
|
---|
264 |
|
---|
265 | /* in xdmauth.c */
|
---|
266 | #ifdef HASXDMAUTH
|
---|
267 | extern XID XdmCheckCookie (AuthCheckArgs);
|
---|
268 | extern XID XdmToID (AuthToIDArgs);
|
---|
269 | extern int XdmAddCookie (AuthAddCArgs);
|
---|
270 | extern int XdmFromID (AuthFromIDArgs);
|
---|
271 | extern int XdmRemoveCookie (AuthRemCArgs);
|
---|
272 | extern int XdmResetCookie (AuthRstCArgs);
|
---|
273 | #endif
|
---|
274 |
|
---|
275 | /* in rpcauth.c */
|
---|
276 | #ifdef SECURE_RPC
|
---|
277 | extern void SecureRPCInit (AuthInitArgs);
|
---|
278 | extern XID SecureRPCCheck (AuthCheckArgs);
|
---|
279 | extern XID SecureRPCToID (AuthToIDArgs);
|
---|
280 | extern int SecureRPCAdd (AuthAddCArgs);
|
---|
281 | extern int SecureRPCFromID (AuthFromIDArgs);
|
---|
282 | extern int SecureRPCRemove (AuthRemCArgs);
|
---|
283 | extern int SecureRPCReset (AuthRstCArgs);
|
---|
284 | #endif
|
---|
285 |
|
---|
286 | /* in k5auth.c */
|
---|
287 | #ifdef K5AUTH
|
---|
288 | extern XID K5Check (AuthCheckArgs);
|
---|
289 | extern XID K5ToID (AuthToIDArgs);
|
---|
290 | extern int K5Add (AuthAddCArgs);
|
---|
291 | extern int K5FromID (AuthFromIDArgs);
|
---|
292 | extern int K5Remove (AuthRemCArgs);
|
---|
293 | extern int K5Reset (AuthRstCArgs);
|
---|
294 | #endif
|
---|
295 |
|
---|
296 | /* in secauth.c */
|
---|
297 | extern XID AuthSecurityCheck (AuthCheckArgs);
|
---|
298 |
|
---|
299 | /* in xdmcp.c */
|
---|
300 | extern void XdmcpUseMsg (void);
|
---|
301 | extern int XdmcpOptions(int argc, char **argv, int i);
|
---|
302 | extern void XdmcpSetAuthentication (ARRAY8Ptr name);
|
---|
303 | extern void XdmcpRegisterConnection (
|
---|
304 | int type,
|
---|
305 | char *address,
|
---|
306 | int addrlen);
|
---|
307 | extern void XdmcpRegisterAuthorizations (void);
|
---|
308 | extern void XdmcpRegisterAuthorization (char *name, int namelen);
|
---|
309 | extern void XdmcpRegisterDisplayClass (char *name, int length);
|
---|
310 | extern void XdmcpInit (void);
|
---|
311 | extern void XdmcpReset (void);
|
---|
312 | extern void XdmcpOpenDisplay(int sock);
|
---|
313 | extern void XdmcpCloseDisplay(int sock);
|
---|
314 | extern void XdmcpRegisterAuthentication (
|
---|
315 | char *name,
|
---|
316 | int namelen,
|
---|
317 | char *data,
|
---|
318 | int datalen,
|
---|
319 | ValidatorFunc Validator,
|
---|
320 | GeneratorFunc Generator,
|
---|
321 | AddAuthorFunc AddAuth);
|
---|
322 | extern int XdmcpCheckAuthentication (ARRAY8Ptr Name, ARRAY8Ptr Data, int packet_type);
|
---|
323 | extern int XdmcpAddAuthorization (ARRAY8Ptr name, ARRAY8Ptr data);
|
---|
324 |
|
---|
325 | struct sockaddr_in;
|
---|
326 | extern void XdmcpRegisterBroadcastAddress (struct sockaddr_in *addr);
|
---|
327 |
|
---|
328 | #ifdef HASXDMAUTH
|
---|
329 | extern void XdmAuthenticationInit (char *cookie, int cookie_length);
|
---|
330 | #endif
|
---|
331 |
|
---|
332 | #endif /* _OSDEP_H_ */
|
---|