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