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.
25 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
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.
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
45 ******************************************************************/
47 #ifdef HAVE_DIX_CONFIG_H
48 #include <dix-config.h>
54 #if defined(XDMCP) || defined(HASXDMAUTH)
55 #include <X11/Xdmcp.h>
70 #include <sys/param.h>
72 #if defined(NOFILE) && !defined(NOFILES_MAX)
73 #define OPEN_MAX NOFILE
76 #define OPEN_MAX NOFILES_MAX
85 #include <X11/Xpoll.h>
88 * MAXSOCKS is used only for initialising MaxClients when no other method
89 * like sysconf(_SC_OPEN_MAX) is not supported.
93 #define MAXSOCKS (OPEN_MAX - 1)
98 /* MAXSELECT is the number of fds that select() can handle */
99 #define MAXSELECT (sizeof(fd_set) * NBBY)
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
);
110 typedef struct _connectionInput
*ConnectionInputPtr
;
111 typedef struct _connectionOutput
*ConnectionOutputPtr
;
115 #define AuthInitArgs void
116 typedef void (*AuthInitFunc
) (AuthInitArgs
);
118 #define AuthAddCArgs unsigned short data_length, const char *data, XID id
119 typedef int (*AuthAddCFunc
) (AuthAddCArgs
);
121 #define AuthCheckArgs unsigned short data_length, const char *data, ClientPtr client, const char **reason
122 typedef XID (*AuthCheckFunc
) (AuthCheckArgs
);
124 #define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap
125 typedef int (*AuthFromIDFunc
) (AuthFromIDArgs
);
127 #define AuthGenCArgs unsigned data_length, const char *data, XID id, unsigned *data_length_return, char **data_return
128 typedef XID (*AuthGenCFunc
) (AuthGenCArgs
);
130 #define AuthRemCArgs unsigned short data_length, const char *data
131 typedef int (*AuthRemCFunc
) (AuthRemCArgs
);
133 #define AuthRstCArgs void
134 typedef int (*AuthRstCFunc
) (AuthRstCArgs
);
136 #define AuthToIDArgs unsigned short data_length, char *data
137 typedef XID (*AuthToIDFunc
) (AuthToIDArgs
);
139 typedef void (*OsCloseFunc
) (ClientPtr
);
141 typedef int (*OsFlushFunc
) (ClientPtr who
, struct _osComm
* oc
, char *extraBuf
,
144 typedef struct _osComm
{
146 ConnectionInputPtr input
;
147 ConnectionOutputPtr output
;
148 XID auth_id
; /* authorization id */
149 CARD32 conn_time
; /* timestamp if not established, else 0 */
150 struct _XtransConnInfo
*trans_conn
; /* transport connection object */
151 } OsCommRec
, *OsCommPtr
;
153 extern int FlushClient(ClientPtr
/*who */ ,
155 const void * /*extraBuf */ ,
159 extern void FreeOsBuffers(OsCommPtr
/*oc */
164 extern fd_set AllSockets
;
165 extern fd_set AllClients
;
166 extern fd_set LastSelectMask
;
167 extern fd_set WellKnownConnections
;
168 extern fd_set EnabledDevices
;
169 extern fd_set ClientsWithInput
;
170 extern fd_set ClientsWriteBlocked
;
171 extern fd_set OutputPending
;
172 extern fd_set IgnoredClientsWithInput
;
175 extern int *ConnectionTranslation
;
177 extern int GetConnectionTranslation(int conn
);
178 extern void SetConnectionTranslation(int conn
, int client
);
179 extern void ClearConnectionTranslation(void);
182 extern Bool NewOutputPending
;
183 extern Bool AnyClientsWriteBlocked
;
185 extern WorkQueuePtr workQueue
;
189 typedef long int fd_mask
;
192 extern int mffs(fd_mask
);
195 extern Bool
ComputeLocalClient(ClientPtr client
);
198 extern void GenerateRandomData(int len
, char *buf
);
201 extern XID
MitCheckCookie(AuthCheckArgs
);
202 extern XID
MitGenerateCookie(AuthGenCArgs
);
203 extern XID
MitToID(AuthToIDArgs
);
204 extern int MitAddCookie(AuthAddCArgs
);
205 extern int MitFromID(AuthFromIDArgs
);
206 extern int MitRemoveCookie(AuthRemCArgs
);
207 extern int MitResetCookie(AuthRstCArgs
);
211 extern XID
XdmCheckCookie(AuthCheckArgs
);
212 extern XID
XdmToID(AuthToIDArgs
);
213 extern int XdmAddCookie(AuthAddCArgs
);
214 extern int XdmFromID(AuthFromIDArgs
);
215 extern int XdmRemoveCookie(AuthRemCArgs
);
216 extern int XdmResetCookie(AuthRstCArgs
);
221 extern void SecureRPCInit(AuthInitArgs
);
222 extern XID
SecureRPCCheck(AuthCheckArgs
);
223 extern XID
SecureRPCToID(AuthToIDArgs
);
224 extern int SecureRPCAdd(AuthAddCArgs
);
225 extern int SecureRPCFromID(AuthFromIDArgs
);
226 extern int SecureRPCRemove(AuthRemCArgs
);
227 extern int SecureRPCReset(AuthRstCArgs
);
232 extern void XdmcpUseMsg(void);
233 extern int XdmcpOptions(int argc
, char **argv
, int i
);
234 extern void XdmcpRegisterConnection(int type
, const char *address
, int addrlen
);
235 extern void XdmcpRegisterAuthorizations(void);
236 extern void XdmcpRegisterAuthorization(const char *name
, int namelen
);
237 extern void XdmcpInit(void);
238 extern void XdmcpReset(void);
239 extern void XdmcpOpenDisplay(int sock
);
240 extern void XdmcpCloseDisplay(int sock
);
241 extern void XdmcpRegisterAuthentication(const char *name
,
245 ValidatorFunc Validator
,
246 GeneratorFunc Generator
,
247 AddAuthorFunc AddAuth
);
250 extern void XdmcpRegisterBroadcastAddress(const struct sockaddr_in
*addr
);
254 extern void XdmAuthenticationInit(const char *cookie
, int cookie_length
);
257 #endif /* _OSDEP_H_ */