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 #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) 77 typedef Bool (*ValidatorFunc) (ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type); 78 typedef Bool (*GeneratorFunc) (ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type); 79 typedef Bool (*AddAuthorFunc) (unsigned name_length, const char *name, 80 unsigned data_length, char *data); 81 #endif 82 83 typedef struct _connectionInput *ConnectionInputPtr; 84 typedef struct _connectionOutput *ConnectionOutputPtr; 85 86 struct _osComm; 87 88 #define AuthInitArgs void 89 typedef void (*AuthInitFunc) (AuthInitArgs); 90 91 #define AuthAddCArgs unsigned short data_length, const char *data, XID id 92 typedef int (*AuthAddCFunc) (AuthAddCArgs); 93 94 #define AuthCheckArgs unsigned short data_length, const char *data, ClientPtr client, const char **reason 95 typedef XID (*AuthCheckFunc) (AuthCheckArgs); 96 97 #define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap 98 typedef int (*AuthFromIDFunc) (AuthFromIDArgs); 99 100 #define AuthGenCArgs unsigned data_length, const char *data, XID id, unsigned *data_length_return, char **data_return 101 typedef XID (*AuthGenCFunc) (AuthGenCArgs); 102 103 #define AuthRemCArgs unsigned short data_length, const char *data 104 typedef int (*AuthRemCFunc) (AuthRemCArgs); 105 106 #define AuthRstCArgs void 107 typedef int (*AuthRstCFunc) (AuthRstCArgs); 108 109 typedef void (*OsCloseFunc) (ClientPtr); 110 111 typedef int (*OsFlushFunc) (ClientPtr who, struct _osComm * oc, char *extraBuf, 112 int extraCount); 113 114 typedef 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 127 extern int FlushClient(ClientPtr /*who */ , 128 OsCommPtr /*oc */ , 129 const void * /*extraBuf */ , 130 int /*extraCount */ 131 ); 132 133 extern void FreeOsBuffers(OsCommPtr /*oc */ 134 ); 135 136 void 137 CloseDownFileDescriptor(OsCommPtr oc); 138 139 #include "dix.h" 140 #include "ospoll.h" 141 142 extern struct ospoll *server_poll; 143 144 Bool 145 listen_to_client(ClientPtr client); 146 147 extern Bool NewOutputPending; 148 149 extern WorkQueuePtr workQueue; 150 151 /* in access.c */ 152 extern Bool ComputeLocalClient(ClientPtr client); 153 154 /* in auth.c */ 155 extern void GenerateRandomData(int len, char *buf); 156 157 /* in mitauth.c */ 158 extern XID MitCheckCookie(AuthCheckArgs); 159 extern XID MitGenerateCookie(AuthGenCArgs); 160 extern int MitAddCookie(AuthAddCArgs); 161 extern int MitFromID(AuthFromIDArgs); 162 extern int MitRemoveCookie(AuthRemCArgs); 163 extern int MitResetCookie(AuthRstCArgs); 164 165 /* in xdmauth.c */ 166 #ifdef HASXDMAUTH 167 extern XID XdmCheckCookie(AuthCheckArgs); 168 extern int XdmAddCookie(AuthAddCArgs); 169 extern int XdmFromID(AuthFromIDArgs); 170 extern int XdmRemoveCookie(AuthRemCArgs); 171 extern int XdmResetCookie(AuthRstCArgs); 172 #endif 173 174 /* in rpcauth.c */ 175 #ifdef SECURE_RPC 176 extern void SecureRPCInit(AuthInitArgs); 177 extern XID SecureRPCCheck(AuthCheckArgs); 178 extern int SecureRPCAdd(AuthAddCArgs); 179 extern int SecureRPCFromID(AuthFromIDArgs); 180 extern int SecureRPCRemove(AuthRemCArgs); 181 extern int SecureRPCReset(AuthRstCArgs); 182 #endif 183 184 #ifdef XDMCP 185 /* in xdmcp.c */ 186 extern void XdmcpUseMsg(void); 187 extern int XdmcpOptions(int argc, char **argv, int i); 188 extern void XdmcpRegisterConnection(int type, const char *address, int addrlen); 189 extern void XdmcpRegisterAuthorizations(void); 190 extern void XdmcpRegisterAuthorization(const char *name, int namelen); 191 extern void XdmcpInit(void); 192 extern void XdmcpReset(void); 193 extern void XdmcpOpenDisplay(int sock); 194 extern void XdmcpCloseDisplay(int sock); 195 extern 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 203 struct sockaddr_in; 204 extern void XdmcpRegisterBroadcastAddress(const struct sockaddr_in *addr); 205 #endif 206 207 #ifdef HASXDMAUTH 208 extern void XdmAuthenticationInit(const char *cookie, int cookie_length); 209 #endif 210 211 #endif /* _OSDEP_H_ */ 212