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 |
|
---|
59 | #if defined(XDMCP) || defined(HASXDMAUTH)
|
---|
60 | #include <X11/Xdmcp.h>
|
---|
61 | #endif
|
---|
62 |
|
---|
63 | #ifdef _POSIX_SOURCE
|
---|
64 | #include <limits.h>
|
---|
65 | #else
|
---|
66 | #define _POSIX_SOURCE
|
---|
67 | #include <limits.h>
|
---|
68 | #undef _POSIX_SOURCE
|
---|
69 | #endif
|
---|
70 |
|
---|
71 | #ifndef OPEN_MAX
|
---|
72 | #ifdef SVR4
|
---|
73 | #define OPEN_MAX 256
|
---|
74 | #else
|
---|
75 | #include <sys/param.h>
|
---|
76 | #ifndef OPEN_MAX
|
---|
77 | #if defined(NOFILE) && !defined(NOFILES_MAX)
|
---|
78 | #define OPEN_MAX NOFILE
|
---|
79 | #else
|
---|
80 | #if !defined(WIN32)
|
---|
81 | #define OPEN_MAX NOFILES_MAX
|
---|
82 | #else
|
---|
83 | #define OPEN_MAX 256
|
---|
84 | #endif
|
---|
85 | #endif
|
---|
86 | #endif
|
---|
87 | #endif
|
---|
88 | #endif
|
---|
89 |
|
---|
90 | #include <X11/Xpoll.h>
|
---|
91 |
|
---|
92 | /*
|
---|
93 | * MAXSOCKS is used only for initialising MaxClients when no other method
|
---|
94 | * like sysconf(_SC_OPEN_MAX) is not supported.
|
---|
95 | */
|
---|
96 |
|
---|
97 | #if OPEN_MAX <= 256
|
---|
98 | #define MAXSOCKS (OPEN_MAX - 1)
|
---|
99 | #else
|
---|
100 | #define MAXSOCKS 256
|
---|
101 | #endif
|
---|
102 |
|
---|
103 | /* MAXSELECT is the number of fds that select() can handle */
|
---|
104 | #define MAXSELECT (sizeof(fd_set) * NBBY)
|
---|
105 |
|
---|
106 | #ifndef HAS_GETDTABLESIZE
|
---|
107 | #if !defined(SVR4) && !defined(SYSV)
|
---|
108 | #define HAS_GETDTABLESIZE
|
---|
109 | #endif
|
---|
110 | #endif
|
---|
111 |
|
---|
112 | #include <stddef.h>
|
---|
113 |
|
---|
114 | #if defined(XDMCP) || defined(HASXDMAUTH)
|
---|
115 | typedef Bool (*ValidatorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
|
---|
116 | typedef Bool (*GeneratorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
|
---|
117 | typedef Bool (*AddAuthorFunc)(unsigned name_length, char *name, unsigned data_length, char *data);
|
---|
118 | #endif
|
---|
119 |
|
---|
120 | typedef struct _connectionInput {
|
---|
121 | struct _connectionInput *next;
|
---|
122 | char *buffer; /* contains current client input */
|
---|
123 | char *bufptr; /* pointer to current start of data */
|
---|
124 | int bufcnt; /* count of bytes in buffer */
|
---|
125 | int lenLastReq;
|
---|
126 | int size;
|
---|
127 | } ConnectionInput, *ConnectionInputPtr;
|
---|
128 |
|
---|
129 | typedef struct _connectionOutput {
|
---|
130 | struct _connectionOutput *next;
|
---|
131 | int size;
|
---|
132 | unsigned char *buf;
|
---|
133 | int count;
|
---|
134 | } ConnectionOutput, *ConnectionOutputPtr;
|
---|
135 |
|
---|
136 | struct _osComm;
|
---|
137 |
|
---|
138 | #define AuthInitArgs void
|
---|
139 | typedef void (*AuthInitFunc) (AuthInitArgs);
|
---|
140 |
|
---|
141 | #define AuthAddCArgs unsigned short data_length, char *data, XID id
|
---|
142 | typedef int (*AuthAddCFunc) (AuthAddCArgs);
|
---|
143 |
|
---|
144 | #define AuthCheckArgs unsigned short data_length, char *data, ClientPtr client, char **reason
|
---|
145 | typedef XID (*AuthCheckFunc) (AuthCheckArgs);
|
---|
146 |
|
---|
147 | #define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap
|
---|
148 | typedef int (*AuthFromIDFunc) (AuthFromIDArgs);
|
---|
149 |
|
---|
150 | #define AuthGenCArgs unsigned data_length, char *data, XID id, unsigned *data_length_return, char **data_return
|
---|
151 | typedef XID (*AuthGenCFunc) (AuthGenCArgs);
|
---|
152 |
|
---|
153 | #define AuthRemCArgs unsigned short data_length, char *data
|
---|
154 | typedef int (*AuthRemCFunc) (AuthRemCArgs);
|
---|
155 |
|
---|
156 | #define AuthRstCArgs void
|
---|
157 | typedef int (*AuthRstCFunc) (AuthRstCArgs);
|
---|
158 |
|
---|
159 | #define AuthToIDArgs unsigned short data_length, char *data
|
---|
160 | typedef XID (*AuthToIDFunc) (AuthToIDArgs);
|
---|
161 |
|
---|
162 | typedef void (*OsCloseFunc)(ClientPtr);
|
---|
163 |
|
---|
164 | typedef int (*OsFlushFunc)(ClientPtr who, struct _osComm * oc, char* extraBuf, int extraCount);
|
---|
165 |
|
---|
166 | typedef struct _osComm {
|
---|
167 | int fd;
|
---|
168 | ConnectionInputPtr input;
|
---|
169 | ConnectionOutputPtr output;
|
---|
170 | XID auth_id; /* authorization id */
|
---|
171 | CARD32 conn_time; /* timestamp if not established, else 0 */
|
---|
172 | struct _XtransConnInfo *trans_conn; /* transport connection object */
|
---|
173 | } OsCommRec, *OsCommPtr;
|
---|
174 |
|
---|
175 | extern int FlushClient(
|
---|
176 | ClientPtr /*who*/,
|
---|
177 | OsCommPtr /*oc*/,
|
---|
178 | const void * /*extraBuf*/,
|
---|
179 | int /*extraCount*/
|
---|
180 | );
|
---|
181 |
|
---|
182 | extern void FreeOsBuffers(
|
---|
183 | OsCommPtr /*oc*/
|
---|
184 | );
|
---|
185 |
|
---|
186 | #include "dix.h"
|
---|
187 |
|
---|
188 | extern fd_set AllSockets;
|
---|
189 | extern fd_set AllClients;
|
---|
190 | extern fd_set LastSelectMask;
|
---|
191 | extern fd_set WellKnownConnections;
|
---|
192 | extern fd_set EnabledDevices;
|
---|
193 | extern fd_set ClientsWithInput;
|
---|
194 | extern fd_set ClientsWriteBlocked;
|
---|
195 | extern fd_set OutputPending;
|
---|
196 | extern fd_set IgnoredClientsWithInput;
|
---|
197 |
|
---|
198 | #ifndef WIN32
|
---|
199 | extern int *ConnectionTranslation;
|
---|
200 | #else
|
---|
201 | extern int GetConnectionTranslation(int conn);
|
---|
202 | extern void SetConnectionTranslation(int conn, int client);
|
---|
203 | extern void ClearConnectionTranslation();
|
---|
204 | #endif
|
---|
205 |
|
---|
206 | extern Bool NewOutputPending;
|
---|
207 | extern Bool AnyClientsWriteBlocked;
|
---|
208 |
|
---|
209 | extern WorkQueuePtr workQueue;
|
---|
210 |
|
---|
211 | /* in WaitFor.c */
|
---|
212 | #ifdef WIN32
|
---|
213 | typedef long int fd_mask;
|
---|
214 | #endif
|
---|
215 | #define ffs mffs
|
---|
216 | extern int mffs(fd_mask);
|
---|
217 |
|
---|
218 | /* in auth.c */
|
---|
219 | extern void GenerateRandomData (int len, char *buf);
|
---|
220 |
|
---|
221 | /* in mitauth.c */
|
---|
222 | extern XID MitCheckCookie (AuthCheckArgs);
|
---|
223 | extern XID MitGenerateCookie (AuthGenCArgs);
|
---|
224 | extern XID MitToID (AuthToIDArgs);
|
---|
225 | extern int MitAddCookie (AuthAddCArgs);
|
---|
226 | extern int MitFromID (AuthFromIDArgs);
|
---|
227 | extern int MitRemoveCookie (AuthRemCArgs);
|
---|
228 | extern int MitResetCookie (AuthRstCArgs);
|
---|
229 |
|
---|
230 | /* in xdmauth.c */
|
---|
231 | #ifdef HASXDMAUTH
|
---|
232 | extern XID XdmCheckCookie (AuthCheckArgs);
|
---|
233 | extern XID XdmToID (AuthToIDArgs);
|
---|
234 | extern int XdmAddCookie (AuthAddCArgs);
|
---|
235 | extern int XdmFromID (AuthFromIDArgs);
|
---|
236 | extern int XdmRemoveCookie (AuthRemCArgs);
|
---|
237 | extern int XdmResetCookie (AuthRstCArgs);
|
---|
238 | #endif
|
---|
239 |
|
---|
240 | /* in rpcauth.c */
|
---|
241 | #ifdef SECURE_RPC
|
---|
242 | extern void SecureRPCInit (AuthInitArgs);
|
---|
243 | extern XID SecureRPCCheck (AuthCheckArgs);
|
---|
244 | extern XID SecureRPCToID (AuthToIDArgs);
|
---|
245 | extern int SecureRPCAdd (AuthAddCArgs);
|
---|
246 | extern int SecureRPCFromID (AuthFromIDArgs);
|
---|
247 | extern int SecureRPCRemove (AuthRemCArgs);
|
---|
248 | extern int SecureRPCReset (AuthRstCArgs);
|
---|
249 | #endif
|
---|
250 |
|
---|
251 | #ifdef XDMCP
|
---|
252 | /* in xdmcp.c */
|
---|
253 | extern void XdmcpUseMsg (void);
|
---|
254 | extern int XdmcpOptions(int argc, char **argv, int i);
|
---|
255 | extern void XdmcpRegisterConnection (
|
---|
256 | int type,
|
---|
257 | char *address,
|
---|
258 | int addrlen);
|
---|
259 | extern void XdmcpRegisterAuthorizations (void);
|
---|
260 | extern void XdmcpRegisterAuthorization (char *name, int namelen);
|
---|
261 | extern void XdmcpInit (void);
|
---|
262 | extern void XdmcpReset (void);
|
---|
263 | extern void XdmcpOpenDisplay(int sock);
|
---|
264 | extern void XdmcpCloseDisplay(int sock);
|
---|
265 | extern void XdmcpRegisterAuthentication (
|
---|
266 | char *name,
|
---|
267 | int namelen,
|
---|
268 | char *data,
|
---|
269 | int datalen,
|
---|
270 | ValidatorFunc Validator,
|
---|
271 | GeneratorFunc Generator,
|
---|
272 | AddAuthorFunc AddAuth);
|
---|
273 |
|
---|
274 | struct sockaddr_in;
|
---|
275 | extern void XdmcpRegisterBroadcastAddress (struct sockaddr_in *addr);
|
---|
276 | #endif
|
---|
277 |
|
---|
278 | #ifdef HASXDMAUTH
|
---|
279 | extern void XdmAuthenticationInit (char *cookie, int cookie_length);
|
---|
280 | #endif
|
---|
281 |
|
---|
282 | #endif /* _OSDEP_H_ */
|
---|