osdep.h revision 7e31ba66
1/*********************************************************** 2 3Copyright 1987, 1998 The Open Group 4 5Permission to use, copy, modify, distribute, and sell this software and its 6documentation for any purpose is hereby granted without fee, provided that 7the above copyright notice appear in all copies and that both that 8copyright notice and this permission notice appear in supporting 9documentation. 10 11The above copyright notice and this permission notice shall be included in 12all copies or substantial portions of the Software. 13 14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 21Except as contained in this notice, the name of The Open Group shall not be 22used in advertising or otherwise to promote the sale, use or other dealings 23in this Software without prior written authorization from The Open Group. 24 25Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. 26 27 All Rights Reserved 28 29Permission to use, copy, modify, and distribute this software and its 30documentation for any purpose and without fee is hereby granted, 31provided that the above copyright notice appear in all copies and that 32both that copyright notice and this permission notice appear in 33supporting documentation, and that the name of Digital not be 34used in advertising or publicity pertaining to distribution of the 35software without specific, written prior permission. 36 37DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 38ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 39DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 40ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 41WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 42ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 43SOFTWARE. 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#include <limits.h> 59#include <stddef.h> 60#include <X11/Xos.h> 61 62/* If EAGAIN and EWOULDBLOCK are distinct errno values, then we check errno 63 * for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX 64 * systems are broken and return EWOULDBLOCK when they should return EAGAIN 65 */ 66#ifndef WIN32 67# if (EAGAIN != EWOULDBLOCK) 68# define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK) 69# else 70# define ETEST(err) (err == EAGAIN) 71# endif 72#else /* WIN32 The socket errorcodes differ from the normal errors */ 73#define ETEST(err) (err == EAGAIN || err == WSAEWOULDBLOCK) 74#endif 75 76#if defined(XDMCP) || defined(HASXDMAUTH) 77typedef Bool (*ValidatorFunc) (ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type); 78typedef Bool (*GeneratorFunc) (ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type); 79typedef Bool (*AddAuthorFunc) (unsigned name_length, const char *name, 80 unsigned data_length, char *data); 81#endif 82 83typedef struct _connectionInput *ConnectionInputPtr; 84typedef struct _connectionOutput *ConnectionOutputPtr; 85 86struct _osComm; 87 88#define AuthInitArgs void 89typedef void (*AuthInitFunc) (AuthInitArgs); 90 91#define AuthAddCArgs unsigned short data_length, const char *data, XID id 92typedef int (*AuthAddCFunc) (AuthAddCArgs); 93 94#define AuthCheckArgs unsigned short data_length, const char *data, ClientPtr client, const char **reason 95typedef XID (*AuthCheckFunc) (AuthCheckArgs); 96 97#define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap 98typedef int (*AuthFromIDFunc) (AuthFromIDArgs); 99 100#define AuthGenCArgs unsigned data_length, const char *data, XID id, unsigned *data_length_return, char **data_return 101typedef XID (*AuthGenCFunc) (AuthGenCArgs); 102 103#define AuthRemCArgs unsigned short data_length, const char *data 104typedef int (*AuthRemCFunc) (AuthRemCArgs); 105 106#define AuthRstCArgs void 107typedef int (*AuthRstCFunc) (AuthRstCArgs); 108 109typedef void (*OsCloseFunc) (ClientPtr); 110 111typedef int (*OsFlushFunc) (ClientPtr who, struct _osComm * oc, char *extraBuf, 112 int extraCount); 113 114typedef struct _osComm { 115 int fd; 116 ConnectionInputPtr input; 117 ConnectionOutputPtr output; 118 XID auth_id; /* authorization id */ 119 CARD32 conn_time; /* timestamp if not established, else 0 */ 120 struct _XtransConnInfo *trans_conn; /* transport connection object */ 121 int flags; 122} OsCommRec, *OsCommPtr; 123 124#define OS_COMM_GRAB_IMPERVIOUS 1 125#define OS_COMM_IGNORED 2 126 127extern int FlushClient(ClientPtr /*who */ , 128 OsCommPtr /*oc */ , 129 const void * /*extraBuf */ , 130 int /*extraCount */ 131 ); 132 133extern void FreeOsBuffers(OsCommPtr /*oc */ 134 ); 135 136void 137CloseDownFileDescriptor(OsCommPtr oc); 138 139#include "dix.h" 140#include "ospoll.h" 141 142extern struct ospoll *server_poll; 143 144Bool 145listen_to_client(ClientPtr client); 146 147extern Bool NewOutputPending; 148 149extern WorkQueuePtr workQueue; 150 151/* in access.c */ 152extern Bool ComputeLocalClient(ClientPtr client); 153 154/* in auth.c */ 155extern void GenerateRandomData(int len, char *buf); 156 157/* in mitauth.c */ 158extern XID MitCheckCookie(AuthCheckArgs); 159extern XID MitGenerateCookie(AuthGenCArgs); 160extern int MitAddCookie(AuthAddCArgs); 161extern int MitFromID(AuthFromIDArgs); 162extern int MitRemoveCookie(AuthRemCArgs); 163extern int MitResetCookie(AuthRstCArgs); 164 165/* in xdmauth.c */ 166#ifdef HASXDMAUTH 167extern XID XdmCheckCookie(AuthCheckArgs); 168extern int XdmAddCookie(AuthAddCArgs); 169extern int XdmFromID(AuthFromIDArgs); 170extern int XdmRemoveCookie(AuthRemCArgs); 171extern int XdmResetCookie(AuthRstCArgs); 172#endif 173 174/* in rpcauth.c */ 175#ifdef SECURE_RPC 176extern void SecureRPCInit(AuthInitArgs); 177extern XID SecureRPCCheck(AuthCheckArgs); 178extern int SecureRPCAdd(AuthAddCArgs); 179extern int SecureRPCFromID(AuthFromIDArgs); 180extern int SecureRPCRemove(AuthRemCArgs); 181extern int SecureRPCReset(AuthRstCArgs); 182#endif 183 184#ifdef XDMCP 185/* in xdmcp.c */ 186extern void XdmcpUseMsg(void); 187extern int XdmcpOptions(int argc, char **argv, int i); 188extern void XdmcpRegisterConnection(int type, const char *address, int addrlen); 189extern void XdmcpRegisterAuthorizations(void); 190extern void XdmcpRegisterAuthorization(const char *name, int namelen); 191extern void XdmcpInit(void); 192extern void XdmcpReset(void); 193extern void XdmcpOpenDisplay(int sock); 194extern void XdmcpCloseDisplay(int sock); 195extern void XdmcpRegisterAuthentication(const char *name, 196 int namelen, 197 const char *data, 198 int datalen, 199 ValidatorFunc Validator, 200 GeneratorFunc Generator, 201 AddAuthorFunc AddAuth); 202 203struct sockaddr_in; 204extern void XdmcpRegisterBroadcastAddress(const struct sockaddr_in *addr); 205#endif 206 207#ifdef HASXDMAUTH 208extern void XdmAuthenticationInit(const char *cookie, int cookie_length); 209#endif 210 211#endif /* _OSDEP_H_ */ 212