1 /***********************************************************
3 Copyright 1987, 1998 The Open Group
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
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
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.
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.
26 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
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.
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
46 ******************************************************************/
48 #ifdef HAVE_DIX_CONFIG_H
49 #include <dix-config.h>
55 #define BOTIMEOUT 200 /* in milliseconds */
57 #define BUFWATERMARK 8192
59 #include <X11/Xdmcp.h>
61 #ifndef sgi /* SGI defines OPEN_MAX in a useless way */
70 #else /* X_NOT_POSIX */
76 #endif /* X_NOT_POSIX */
80 #define NOFILES_MAX 256
86 #include <sys/param.h>
88 #if defined(NOFILE) && !defined(NOFILES_MAX)
89 #define OPEN_MAX NOFILE
92 #define OPEN_MAX NOFILES_MAX
101 #include <X11/Xpoll.h>
104 * MAXSOCKS is used only for initialising MaxClients when no other method
105 * like sysconf(_SC_OPEN_MAX) is not supported.
109 #define MAXSOCKS (OPEN_MAX - 1)
114 /* MAXSELECT is the number of fds that select() can handle */
115 #define MAXSELECT (sizeof(fd_set) * NBBY)
117 #ifndef HAS_GETDTABLESIZE
118 #if !defined(hpux) && !defined(SVR4) && !defined(SYSV)
119 #define HAS_GETDTABLESIZE
125 typedef Bool (*ValidatorFunc
)(ARRAY8Ptr Auth
, ARRAY8Ptr Data
, int packet_type
);
126 typedef Bool (*GeneratorFunc
)(ARRAY8Ptr Auth
, ARRAY8Ptr Data
, int packet_type
);
127 typedef Bool (*AddAuthorFunc
)(unsigned name_length
, char *name
, unsigned data_length
, char *data
);
129 typedef struct _connectionInput
{
130 struct _connectionInput
*next
;
131 char *buffer
; /* contains current client input */
132 char *bufptr
; /* pointer to current start of data */
133 int bufcnt
; /* count of bytes in buffer */
136 } ConnectionInput
, *ConnectionInputPtr
;
138 typedef struct _connectionOutput
{
139 struct _connectionOutput
*next
;
143 } ConnectionOutput
, *ConnectionOutputPtr
;
147 #define AuthInitArgs void
148 typedef void (*AuthInitFunc
) (AuthInitArgs
);
150 #define AuthAddCArgs unsigned short data_length, char *data, XID id
151 typedef int (*AuthAddCFunc
) (AuthAddCArgs
);
153 #define AuthCheckArgs unsigned short data_length, char *data, ClientPtr client, char **reason
154 typedef XID (*AuthCheckFunc
) (AuthCheckArgs
);
156 #define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap
157 typedef int (*AuthFromIDFunc
) (AuthFromIDArgs
);
159 #define AuthGenCArgs unsigned data_length, char *data, XID id, unsigned *data_length_return, char **data_return
160 typedef XID (*AuthGenCFunc
) (AuthGenCArgs
);
162 #define AuthRemCArgs unsigned short data_length, char *data
163 typedef int (*AuthRemCFunc
) (AuthRemCArgs
);
165 #define AuthRstCArgs void
166 typedef int (*AuthRstCFunc
) (AuthRstCArgs
);
168 #define AuthToIDArgs unsigned short data_length, char *data
169 typedef XID (*AuthToIDFunc
) (AuthToIDArgs
);
171 typedef void (*OsCloseFunc
)(ClientPtr
);
173 typedef int (*OsFlushFunc
)(ClientPtr who
, struct _osComm
* oc
, char* extraBuf
, int extraCount
);
175 typedef struct _osComm
{
177 ConnectionInputPtr input
;
178 ConnectionOutputPtr output
;
179 XID auth_id
; /* authorization id */
180 CARD32 conn_time
; /* timestamp if not established, else 0 */
181 struct _XtransConnInfo
*trans_conn
; /* transport connection object */
182 } OsCommRec
, *OsCommPtr
;
184 extern int FlushClient(
191 extern void FreeOsBuffers(
197 extern fd_set AllSockets
;
198 extern fd_set AllClients
;
199 extern fd_set LastSelectMask
;
200 extern fd_set WellKnownConnections
;
201 extern fd_set EnabledDevices
;
202 extern fd_set ClientsWithInput
;
203 extern fd_set ClientsWriteBlocked
;
204 extern fd_set OutputPending
;
205 extern fd_set IgnoredClientsWithInput
;
208 extern int *ConnectionTranslation
;
210 extern int GetConnectionTranslation(int conn
);
211 extern void SetConnectionTranslation(int conn
, int client
);
212 extern void ClearConnectionTranslation();
215 extern Bool NewOutputPending
;
216 extern Bool AnyClientsWriteBlocked
;
218 extern WorkQueuePtr workQueue
;
220 /* added by raphael */
222 typedef long int fd_mask
;
225 extern int mffs(fd_mask
);
228 extern void GenerateRandomData (int len
, char *buf
);
231 extern XID
MitCheckCookie (AuthCheckArgs
);
232 extern XID
MitGenerateCookie (AuthGenCArgs
);
233 extern XID
MitToID (AuthToIDArgs
);
234 extern int MitAddCookie (AuthAddCArgs
);
235 extern int MitFromID (AuthFromIDArgs
);
236 extern int MitRemoveCookie (AuthRemCArgs
);
237 extern int MitResetCookie (AuthRstCArgs
);
241 extern XID
XdmCheckCookie (AuthCheckArgs
);
242 extern XID
XdmToID (AuthToIDArgs
);
243 extern int XdmAddCookie (AuthAddCArgs
);
244 extern int XdmFromID (AuthFromIDArgs
);
245 extern int XdmRemoveCookie (AuthRemCArgs
);
246 extern int XdmResetCookie (AuthRstCArgs
);
251 extern void SecureRPCInit (AuthInitArgs
);
252 extern XID
SecureRPCCheck (AuthCheckArgs
);
253 extern XID
SecureRPCToID (AuthToIDArgs
);
254 extern int SecureRPCAdd (AuthAddCArgs
);
255 extern int SecureRPCFromID (AuthFromIDArgs
);
256 extern int SecureRPCRemove (AuthRemCArgs
);
257 extern int SecureRPCReset (AuthRstCArgs
);
261 extern XID
AuthSecurityCheck (AuthCheckArgs
);
264 extern void XdmcpUseMsg (void);
265 extern int XdmcpOptions(int argc
, char **argv
, int i
);
266 extern void XdmcpRegisterConnection (
270 extern void XdmcpRegisterAuthorizations (void);
271 extern void XdmcpRegisterAuthorization (char *name
, int namelen
);
272 extern void XdmcpInit (void);
273 extern void XdmcpReset (void);
274 extern void XdmcpOpenDisplay(int sock
);
275 extern void XdmcpCloseDisplay(int sock
);
276 extern void XdmcpRegisterAuthentication (
281 ValidatorFunc Validator
,
282 GeneratorFunc Generator
,
283 AddAuthorFunc AddAuth
);
286 extern void XdmcpRegisterBroadcastAddress (struct sockaddr_in
*addr
);
289 extern void XdmAuthenticationInit (char *cookie
, int cookie_length
);
292 #endif /* _OSDEP_H_ */