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 | Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
|
---|
26 |
|
---|
27 | All Rights Reserved
|
---|
28 |
|
---|
29 | Permission to use, copy, modify, and distribute this software and its
|
---|
30 | documentation for any purpose and without fee is hereby granted,
|
---|
31 | provided that the above copyright notice appear in all copies and that
|
---|
32 | both that copyright notice and this permission notice appear in
|
---|
33 | supporting documentation, and that the name of Digital not be
|
---|
34 | used in advertising or publicity pertaining to distribution of the
|
---|
35 | software without specific, written prior permission.
|
---|
36 |
|
---|
37 | DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
---|
38 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
---|
39 | DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
---|
40 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
---|
41 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
---|
42 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
---|
43 | SOFTWARE.
|
---|
44 |
|
---|
45 | ******************************************************************/
|
---|
46 |
|
---|
47 | #ifdef HAVE_DIX_CONFIG_H
|
---|
48 | #include <dix-config.h>
|
---|
49 | #endif
|
---|
50 |
|
---|
51 | #ifndef _OSDEP_H_
|
---|
52 | #define _OSDEP_H_ 1
|
---|
53 |
|
---|
54 | #if defined(XDMCP) || defined(HASXDMAUTH)
|
---|
55 | #include <X11/Xdmcp.h>
|
---|
56 | #endif
|
---|
57 |
|
---|
58 | #ifdef _POSIX_SOURCE
|
---|
59 | #include <limits.h>
|
---|
60 | #else
|
---|
61 | #define _POSIX_SOURCE
|
---|
62 | #include <limits.h>
|
---|
63 | #undef _POSIX_SOURCE
|
---|
64 | #endif
|
---|
65 |
|
---|
66 | #ifndef OPEN_MAX
|
---|
67 | #ifdef SVR4
|
---|
68 | #define OPEN_MAX 256
|
---|
69 | #else
|
---|
70 | #include <sys/param.h>
|
---|
71 | #ifndef OPEN_MAX
|
---|
72 | #if defined(NOFILE) && !defined(NOFILES_MAX)
|
---|
73 | #define OPEN_MAX NOFILE
|
---|
74 | #else
|
---|
75 | #if !defined(WIN32)
|
---|
76 | #define OPEN_MAX NOFILES_MAX
|
---|
77 | #else
|
---|
78 | #define OPEN_MAX 256
|
---|
79 | #endif
|
---|
80 | #endif
|
---|
81 | #endif
|
---|
82 | #endif
|
---|
83 | #endif
|
---|
84 |
|
---|
85 | #include <X11/Xpoll.h>
|
---|
86 |
|
---|
87 | /*
|
---|
88 | * MAXSOCKS is used only for initialising MaxClients when no other method
|
---|
89 | * like sysconf(_SC_OPEN_MAX) is not supported.
|
---|
90 | */
|
---|
91 |
|
---|
92 | #if OPEN_MAX <= 256
|
---|
93 | #define MAXSOCKS (OPEN_MAX - 1)
|
---|
94 | #else
|
---|
95 | #define MAXSOCKS 256
|
---|
96 | #endif
|
---|
97 |
|
---|
98 | /* MAXSELECT is the number of fds that select() can handle */
|
---|
99 | #define MAXSELECT (sizeof(fd_set) * NBBY)
|
---|
100 |
|
---|
101 | #include <stddef.h>
|
---|
102 |
|
---|
103 | #if defined(XDMCP) || defined(HASXDMAUTH)
|
---|
104 | typedef Bool (*ValidatorFunc) (ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
|
---|
105 | typedef Bool (*GeneratorFunc) (ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
|
---|
106 | typedef Bool (*AddAuthorFunc) (unsigned name_length, const char *name,
|
---|
107 | unsigned data_length, char *data);
|
---|
108 | #endif
|
---|
109 |
|
---|
110 | typedef struct _connectionInput {
|
---|
111 | struct _connectionInput *next;
|
---|
112 | char *buffer; /* contains current client input */
|
---|
113 | char *bufptr; /* pointer to current start of data */
|
---|
114 | int bufcnt; /* count of bytes in buffer */
|
---|
115 | int lenLastReq;
|
---|
116 | int size;
|
---|
117 | unsigned int ignoreBytes; /* bytes to ignore before the next request */
|
---|
118 | } ConnectionInput, *ConnectionInputPtr;
|
---|
119 |
|
---|
120 | typedef struct _connectionOutput {
|
---|
121 | struct _connectionOutput *next;
|
---|
122 | int size;
|
---|
123 | unsigned char *buf;
|
---|
124 | int count;
|
---|
125 | } ConnectionOutput, *ConnectionOutputPtr;
|
---|
126 |
|
---|
127 | struct _osComm;
|
---|
128 |
|
---|
129 | #define AuthInitArgs void
|
---|
130 | typedef void (*AuthInitFunc) (AuthInitArgs);
|
---|
131 |
|
---|
132 | #define AuthAddCArgs unsigned short data_length, const char *data, XID id
|
---|
133 | typedef int (*AuthAddCFunc) (AuthAddCArgs);
|
---|
134 |
|
---|
135 | #define AuthCheckArgs unsigned short data_length, const char *data, ClientPtr client, const char **reason
|
---|
136 | typedef XID (*AuthCheckFunc) (AuthCheckArgs);
|
---|
137 |
|
---|
138 | #define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap
|
---|
139 | typedef int (*AuthFromIDFunc) (AuthFromIDArgs);
|
---|
140 |
|
---|
141 | #define AuthGenCArgs unsigned data_length, const char *data, XID id, unsigned *data_length_return, char **data_return
|
---|
142 | typedef XID (*AuthGenCFunc) (AuthGenCArgs);
|
---|
143 |
|
---|
144 | #define AuthRemCArgs unsigned short data_length, const char *data
|
---|
145 | typedef int (*AuthRemCFunc) (AuthRemCArgs);
|
---|
146 |
|
---|
147 | #define AuthRstCArgs void
|
---|
148 | typedef int (*AuthRstCFunc) (AuthRstCArgs);
|
---|
149 |
|
---|
150 | #define AuthToIDArgs unsigned short data_length, char *data
|
---|
151 | typedef XID (*AuthToIDFunc) (AuthToIDArgs);
|
---|
152 |
|
---|
153 | typedef void (*OsCloseFunc) (ClientPtr);
|
---|
154 |
|
---|
155 | typedef int (*OsFlushFunc) (ClientPtr who, struct _osComm * oc, char *extraBuf,
|
---|
156 | int extraCount);
|
---|
157 |
|
---|
158 | typedef struct _osComm {
|
---|
159 | int fd;
|
---|
160 | ConnectionInputPtr input;
|
---|
161 | ConnectionOutputPtr output;
|
---|
162 | XID auth_id; /* authorization id */
|
---|
163 | CARD32 conn_time; /* timestamp if not established, else 0 */
|
---|
164 | struct _XtransConnInfo *trans_conn; /* transport connection object */
|
---|
165 | Bool local_client;
|
---|
166 | } OsCommRec, *OsCommPtr;
|
---|
167 |
|
---|
168 | extern int FlushClient(ClientPtr /*who */ ,
|
---|
169 | OsCommPtr /*oc */ ,
|
---|
170 | const void * /*extraBuf */ ,
|
---|
171 | int /*extraCount */
|
---|
172 | );
|
---|
173 |
|
---|
174 | extern void FreeOsBuffers(OsCommPtr /*oc */
|
---|
175 | );
|
---|
176 |
|
---|
177 | #include "dix.h"
|
---|
178 |
|
---|
179 | extern fd_set AllSockets;
|
---|
180 | extern fd_set AllClients;
|
---|
181 | extern fd_set LastSelectMask;
|
---|
182 | extern fd_set WellKnownConnections;
|
---|
183 | extern fd_set EnabledDevices;
|
---|
184 | extern fd_set ClientsWithInput;
|
---|
185 | extern fd_set ClientsWriteBlocked;
|
---|
186 | extern fd_set OutputPending;
|
---|
187 | extern fd_set IgnoredClientsWithInput;
|
---|
188 |
|
---|
189 | #ifndef WIN32
|
---|
190 | extern int *ConnectionTranslation;
|
---|
191 | #else
|
---|
192 | extern int GetConnectionTranslation(int conn);
|
---|
193 | extern void SetConnectionTranslation(int conn, int client);
|
---|
194 | extern void ClearConnectionTranslation(void);
|
---|
195 | #endif
|
---|
196 |
|
---|
197 | extern Bool NewOutputPending;
|
---|
198 | extern Bool AnyClientsWriteBlocked;
|
---|
199 |
|
---|
200 | extern WorkQueuePtr workQueue;
|
---|
201 |
|
---|
202 | /* in WaitFor.c */
|
---|
203 | #ifdef WIN32
|
---|
204 | typedef long int fd_mask;
|
---|
205 | #endif
|
---|
206 | #define ffs mffs
|
---|
207 | extern int mffs(fd_mask);
|
---|
208 |
|
---|
209 | /* in access.c */
|
---|
210 | extern Bool ComputeLocalClient(ClientPtr client);
|
---|
211 |
|
---|
212 | /* in auth.c */
|
---|
213 | extern void GenerateRandomData(int len, char *buf);
|
---|
214 |
|
---|
215 | /* in mitauth.c */
|
---|
216 | extern XID MitCheckCookie(AuthCheckArgs);
|
---|
217 | extern XID MitGenerateCookie(AuthGenCArgs);
|
---|
218 | extern XID MitToID(AuthToIDArgs);
|
---|
219 | extern int MitAddCookie(AuthAddCArgs);
|
---|
220 | extern int MitFromID(AuthFromIDArgs);
|
---|
221 | extern int MitRemoveCookie(AuthRemCArgs);
|
---|
222 | extern int MitResetCookie(AuthRstCArgs);
|
---|
223 |
|
---|
224 | /* in xdmauth.c */
|
---|
225 | #ifdef HASXDMAUTH
|
---|
226 | extern XID XdmCheckCookie(AuthCheckArgs);
|
---|
227 | extern XID XdmToID(AuthToIDArgs);
|
---|
228 | extern int XdmAddCookie(AuthAddCArgs);
|
---|
229 | extern int XdmFromID(AuthFromIDArgs);
|
---|
230 | extern int XdmRemoveCookie(AuthRemCArgs);
|
---|
231 | extern int XdmResetCookie(AuthRstCArgs);
|
---|
232 | #endif
|
---|
233 |
|
---|
234 | /* in rpcauth.c */
|
---|
235 | #ifdef SECURE_RPC
|
---|
236 | extern void SecureRPCInit(AuthInitArgs);
|
---|
237 | extern XID SecureRPCCheck(AuthCheckArgs);
|
---|
238 | extern XID SecureRPCToID(AuthToIDArgs);
|
---|
239 | extern int SecureRPCAdd(AuthAddCArgs);
|
---|
240 | extern int SecureRPCFromID(AuthFromIDArgs);
|
---|
241 | extern int SecureRPCRemove(AuthRemCArgs);
|
---|
242 | extern int SecureRPCReset(AuthRstCArgs);
|
---|
243 | #endif
|
---|
244 |
|
---|
245 | #ifdef XDMCP
|
---|
246 | /* in xdmcp.c */
|
---|
247 | extern void XdmcpUseMsg(void);
|
---|
248 | extern int XdmcpOptions(int argc, char **argv, int i);
|
---|
249 | extern void XdmcpRegisterConnection(int type, const char *address, int addrlen);
|
---|
250 | extern void XdmcpRegisterAuthorizations(void);
|
---|
251 | extern void XdmcpRegisterAuthorization(const char *name, int namelen);
|
---|
252 | extern void XdmcpInit(void);
|
---|
253 | extern void XdmcpReset(void);
|
---|
254 | extern void XdmcpOpenDisplay(int sock);
|
---|
255 | extern void XdmcpCloseDisplay(int sock);
|
---|
256 | extern void XdmcpRegisterAuthentication(const char *name,
|
---|
257 | int namelen,
|
---|
258 | const char *data,
|
---|
259 | int datalen,
|
---|
260 | ValidatorFunc Validator,
|
---|
261 | GeneratorFunc Generator,
|
---|
262 | AddAuthorFunc AddAuth);
|
---|
263 |
|
---|
264 | struct sockaddr_in;
|
---|
265 | extern void XdmcpRegisterBroadcastAddress(const struct sockaddr_in *addr);
|
---|
266 | #endif
|
---|
267 |
|
---|
268 | #ifdef HASXDMAUTH
|
---|
269 | extern void XdmAuthenticationInit(const char *cookie, int cookie_length);
|
---|
270 | #endif
|
---|
271 |
|
---|
272 | #endif /* _OSDEP_H_ */
|
---|