osdep.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /***********************************************************
  2. Copyright 1987, 1998 The Open Group
  3. Permission to use, copy, modify, distribute, and sell this software and its
  4. documentation for any purpose is hereby granted without fee, provided that
  5. the above copyright notice appear in all copies and that both that
  6. copyright notice and this permission notice appear in supporting
  7. documentation.
  8. The above copyright notice and this permission notice shall be included in
  9. all copies or substantial portions of the Software.
  10. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13. OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  14. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  15. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16. Except as contained in this notice, the name of The Open Group shall not be
  17. used in advertising or otherwise to promote the sale, use or other dealings
  18. in this Software without prior written authorization from The Open Group.
  19. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  20. All Rights Reserved
  21. Permission to use, copy, modify, and distribute this software and its
  22. documentation for any purpose and without fee is hereby granted,
  23. provided that the above copyright notice appear in all copies and that
  24. both that copyright notice and this permission notice appear in
  25. supporting documentation, and that the name of Digital not be
  26. used in advertising or publicity pertaining to distribution of the
  27. software without specific, written prior permission.
  28. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  29. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  30. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  31. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  32. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  33. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  34. SOFTWARE.
  35. ******************************************************************/
  36. #ifdef HAVE_DIX_CONFIG_H
  37. #include <dix-config.h>
  38. #endif
  39. #ifndef _OSDEP_H_
  40. #define _OSDEP_H_ 1
  41. #define BOTIMEOUT 200 /* in milliseconds */
  42. #define BUFSIZE 4096
  43. #define BUFWATERMARK 8192
  44. #ifndef MAXBUFSIZE
  45. #define MAXBUFSIZE (1 << 22)
  46. #endif
  47. #include <X11/Xdmcp.h>
  48. #ifdef _POSIX_SOURCE
  49. #include <limits.h>
  50. #else
  51. #define _POSIX_SOURCE
  52. #include <limits.h>
  53. #undef _POSIX_SOURCE
  54. #endif
  55. #ifndef OPEN_MAX
  56. #include <sys/param.h>
  57. #ifndef OPEN_MAX
  58. #if defined(NOFILE) && !defined(NOFILES_MAX)
  59. #define OPEN_MAX NOFILE
  60. #else
  61. #define OPEN_MAX NOFILES_MAX
  62. #endif
  63. #endif
  64. #endif
  65. #include <X11/Xpoll.h>
  66. /*
  67. * MAXSOCKS is used only for initialising MaxClients when no other method
  68. * like sysconf(_SC_OPEN_MAX) is not supported.
  69. */
  70. #if OPEN_MAX <= 256
  71. #define MAXSOCKS (OPEN_MAX - 1)
  72. #else
  73. #define MAXSOCKS 256
  74. #endif
  75. /* MAXSELECT is the number of fds that select() can handle */
  76. #define MAXSELECT (sizeof(fd_set) * NBBY)
  77. #ifndef HAS_GETDTABLESIZE
  78. #define HAS_GETDTABLESIZE
  79. #endif
  80. #include <stddef.h>
  81. typedef Bool (*ValidatorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
  82. typedef Bool (*GeneratorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
  83. typedef Bool (*AddAuthorFunc)(unsigned name_length, const char *name,
  84. unsigned data_length, char *data);
  85. typedef struct _connectionInput {
  86. struct _connectionInput *next;
  87. char *buffer; /* contains current client input */
  88. char *bufptr; /* pointer to current start of data */
  89. int bufcnt; /* count of bytes in buffer */
  90. int lenLastReq;
  91. int size;
  92. } ConnectionInput, *ConnectionInputPtr;
  93. typedef struct _connectionOutput {
  94. struct _connectionOutput *next;
  95. int size;
  96. unsigned char *buf;
  97. int count;
  98. } ConnectionOutput, *ConnectionOutputPtr;
  99. struct _osComm;
  100. #define AuthInitArgs void
  101. typedef void (*AuthInitFunc) (AuthInitArgs);
  102. #define AuthAddCArgs unsigned short data_length, const char *data, XID id
  103. typedef int (*AuthAddCFunc) (AuthAddCArgs);
  104. #define AuthCheckArgs unsigned short data_length, const char *data, ClientPtr client, const char **reason
  105. typedef XID (*AuthCheckFunc) (AuthCheckArgs);
  106. #define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap
  107. typedef int (*AuthFromIDFunc) (AuthFromIDArgs);
  108. #define AuthGenCArgs unsigned data_length, const char *data, XID id, unsigned *data_length_return, char **data_return
  109. typedef XID (*AuthGenCFunc) (AuthGenCArgs);
  110. #define AuthRemCArgs unsigned short data_length, const char *data
  111. typedef int (*AuthRemCFunc) (AuthRemCArgs);
  112. #define AuthRstCArgs void
  113. typedef int (*AuthRstCFunc) (AuthRstCArgs);
  114. #define AuthToIDArgs unsigned short data_length, char *data
  115. typedef XID (*AuthToIDFunc) (AuthToIDArgs);
  116. typedef void (*OsCloseFunc)(ClientPtr);
  117. typedef int (*OsFlushFunc)(ClientPtr who, struct _osComm * oc, char* extraBuf, int extraCount);
  118. typedef struct _osComm {
  119. int fd;
  120. ConnectionInputPtr input;
  121. ConnectionOutputPtr output;
  122. XID auth_id; /* authorization id */
  123. CARD32 conn_time; /* timestamp if not established, else 0 */
  124. struct _XtransConnInfo *trans_conn; /* transport connection object */
  125. } OsCommRec, *OsCommPtr;
  126. extern int FlushClient(
  127. ClientPtr /*who*/,
  128. OsCommPtr /*oc*/,
  129. const char* /*extraBuf*/,
  130. int /*extraCount*/
  131. );
  132. #include "dix.h"
  133. extern ConnectionInputPtr AllocateInputBuffer(void);
  134. extern ConnectionOutputPtr AllocateOutputBuffer(void);
  135. extern fd_set AllSockets;
  136. extern fd_set AllClients;
  137. extern fd_set LastSelectMask;
  138. extern fd_set WellKnownConnections;
  139. extern fd_set EnabledDevices;
  140. extern fd_set ClientsWithInput;
  141. extern fd_set ClientsWriteBlocked;
  142. extern fd_set OutputPending;
  143. extern fd_set IgnoredClientsWithInput;
  144. extern int *ConnectionTranslation;
  145. extern Bool NewOutputPending;
  146. extern Bool AnyClientsWriteBlocked;
  147. extern Bool CriticalOutputPending;
  148. extern int timesThisConnection;
  149. extern ConnectionInputPtr FreeInputs;
  150. extern ConnectionOutputPtr FreeOutputs;
  151. extern OsCommPtr AvailableInput;
  152. extern WorkQueuePtr workQueue;
  153. /* added by raphael */
  154. #define ffs mffs
  155. extern int mffs(fd_mask);
  156. /* in auth.c */
  157. extern void GenerateRandomData (int len, char *buf);
  158. /* in mitauth.c */
  159. extern XID MitCheckCookie (AuthCheckArgs);
  160. extern XID MitToID (AuthToIDArgs);
  161. extern int MitAddCookie (AuthAddCArgs);
  162. extern int MitFromID (AuthFromIDArgs);
  163. extern int MitRemoveCookie (AuthRemCArgs);
  164. extern int MitResetCookie (AuthRstCArgs);
  165. /* in xdmauth.c */
  166. #ifdef HASXDMAUTH
  167. extern XID XdmCheckCookie (AuthCheckArgs);
  168. extern XID XdmToID (AuthToIDArgs);
  169. extern int XdmAddCookie (AuthAddCArgs);
  170. extern int XdmFromID (AuthFromIDArgs);
  171. extern int XdmRemoveCookie (AuthRemCArgs);
  172. extern int XdmResetCookie (AuthRstCArgs);
  173. #endif
  174. /* in rpcauth.c */
  175. #ifdef SECURE_RPC
  176. extern void SecureRPCInit (AuthInitArgs);
  177. extern XID SecureRPCCheck (AuthCheckArgs);
  178. extern XID SecureRPCToID (AuthToIDArgs);
  179. extern int SecureRPCAdd (AuthAddCArgs);
  180. extern int SecureRPCFromID (AuthFromIDArgs);
  181. extern int SecureRPCRemove (AuthRemCArgs);
  182. extern int SecureRPCReset (AuthRstCArgs);
  183. #endif
  184. /* in secauth.c */
  185. extern XID AuthSecurityCheck (AuthCheckArgs);
  186. /* in xdmcp.c */
  187. extern void XdmcpUseMsg (void);
  188. extern int XdmcpOptions(int argc, char **argv, int i);
  189. extern void XdmcpSetAuthentication (ARRAY8Ptr name);
  190. extern void XdmcpRegisterConnection (
  191. int type,
  192. const char *address,
  193. int addrlen);
  194. extern void XdmcpRegisterAuthorizations (void);
  195. extern void XdmcpRegisterAuthorization (const char *name, int namelen);
  196. extern void XdmcpRegisterDisplayClass (const char *name, int length);
  197. extern void XdmcpInit (void);
  198. extern void XdmcpReset (void);
  199. extern void XdmcpOpenDisplay(int sock);
  200. extern void XdmcpCloseDisplay(int sock);
  201. extern void XdmcpRegisterAuthentication (
  202. const char *name,
  203. int namelen,
  204. const char *data,
  205. int datalen,
  206. ValidatorFunc Validator,
  207. GeneratorFunc Generator,
  208. AddAuthorFunc AddAuth);
  209. extern int XdmcpCheckAuthentication (ARRAY8Ptr Name, ARRAY8Ptr Data, int packet_type);
  210. extern int XdmcpAddAuthorization (ARRAY8Ptr name, ARRAY8Ptr data);
  211. struct sockaddr_in;
  212. extern void XdmcpRegisterBroadcastAddress (const struct sockaddr_in *addr);
  213. #ifdef HASXDMAUTH
  214. extern void XdmAuthenticationInit (const char *cookie, int cookie_length);
  215. #endif
  216. #endif /* _OSDEP_H_ */