Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:32

0001 /*
0002  * Copyright 1989 Network Computing Devices, Inc., Mountain View, California.
0003  *
0004  * Permission to use, copy, modify, and distribute this software and its
0005  * documentation for any purpose and without fee is hereby granted, provided
0006  * that the above copyright notice appear in all copies and that both that
0007  * copyright notice and this permission notice appear in supporting
0008  * documentation, and that the name of N.C.D. not be used in advertising or
0009  * publicity pertaining to distribution of the software without specific,
0010  * written prior permission.  N.C.D. makes no representations about the
0011  * suitability of this software for any purpose.  It is provided "as is"
0012  * without express or implied warranty.
0013  *
0014  */
0015 
0016 #ifndef _XDMCP_H_
0017 #define _XDMCP_H_
0018 
0019 #include <X11/Xmd.h>
0020 
0021 #include <X11/Xfuncproto.h>
0022 
0023 _XFUNCPROTOBEGIN
0024 
0025 #define XDM_PROTOCOL_VERSION    1
0026 #define XDM_UDP_PORT        177
0027 
0028 /* IANA has assigned FF0X:0:0:0:0:0:0:12B as the permanently assigned
0029  * multicast addresses for XDMCP, where X in the prefix may be replaced
0030  * by any valid scope identifier, such as 1 for Node-Local, 2 for Link-Local,
0031  * 5 for Site-Local, and so on.  We set the default here to the Link-Local
0032  * version to most closely match the old IPv4 subnet broadcast behavior.
0033  * Both xdm and X -query allow specifying a different address if a different
0034  * scope is defined.
0035  */
0036 #define XDM_DEFAULT_MCAST_ADDR6 "ff02:0:0:0:0:0:0:12b"
0037 
0038 #define XDM_MAX_MSGLEN      8192
0039 #define XDM_MIN_RTX     2
0040 #define XDM_MAX_RTX     32
0041 #define XDM_RTX_LIMIT       7
0042 #define XDM_KA_RTX_LIMIT    4
0043 #define XDM_DEF_DORMANCY    (3 * 60)    /* 3 minutes */
0044 #define XDM_MAX_DORMANCY    (24 * 60 * 60)  /* 24 hours */
0045 
0046 typedef enum {
0047     BROADCAST_QUERY = 1, QUERY, INDIRECT_QUERY, FORWARD_QUERY,
0048     WILLING, UNWILLING, REQUEST, ACCEPT, DECLINE, MANAGE, REFUSE,
0049     FAILED, KEEPALIVE, ALIVE
0050 } xdmOpCode;
0051 
0052 typedef enum {
0053     XDM_QUERY, XDM_BROADCAST, XDM_INDIRECT, XDM_COLLECT_QUERY,
0054     XDM_COLLECT_BROADCAST_QUERY, XDM_COLLECT_INDIRECT_QUERY,
0055     XDM_START_CONNECTION, XDM_AWAIT_REQUEST_RESPONSE,
0056     XDM_AWAIT_MANAGE_RESPONSE, XDM_MANAGE, XDM_RUN_SESSION, XDM_OFF,
0057     XDM_AWAIT_USER_INPUT, XDM_KEEPALIVE, XDM_AWAIT_ALIVE_RESPONSE,
0058 #if defined(IPv6) && defined(AF_INET6)
0059     XDM_MULTICAST, XDM_COLLECT_MULTICAST_QUERY,
0060 #endif
0061     XDM_KEEP_ME_LAST
0062 } xdmcp_states;
0063 
0064 #ifdef NOTDEF
0065 /* table of hosts */
0066 
0067 #define XDM_MAX_STR_LEN 21
0068 #define XDM_MAX_HOSTS 20
0069 struct xdm_host_table {
0070   struct sockaddr_in sockaddr;
0071   char name[XDM_MAX_STR_LEN];
0072   char status[XDM_MAX_STR_LEN];
0073 };
0074 #endif /* NOTDEF */
0075 
0076 typedef CARD8   *CARD8Ptr;
0077 typedef CARD16  *CARD16Ptr;
0078 typedef CARD32  *CARD32Ptr;
0079 
0080 typedef struct _ARRAY8 {
0081     CARD16  length;
0082     CARD8Ptr    data;
0083 } ARRAY8, *ARRAY8Ptr;
0084 
0085 typedef struct _ARRAY16 {
0086     CARD8   length;
0087     CARD16Ptr   data;
0088 } ARRAY16, *ARRAY16Ptr;
0089 
0090 typedef struct _ARRAY32 {
0091     CARD8   length;
0092     CARD32Ptr   data;
0093 } ARRAY32, *ARRAY32Ptr;
0094 
0095 typedef struct _ARRAYofARRAY8 {
0096     CARD8   length;
0097     ARRAY8Ptr   data;
0098 } ARRAYofARRAY8, *ARRAYofARRAY8Ptr;
0099 
0100 typedef struct _XdmcpHeader {
0101     CARD16  version, opcode, length;
0102 } XdmcpHeader, *XdmcpHeaderPtr;
0103 
0104 typedef struct _XdmcpBuffer {
0105     BYTE    *data;
0106     int     size;       /* size of buffer pointed by to data */
0107     int     pointer;        /* current index into data */
0108     int     count;      /* bytes read from network into data */
0109 } XdmcpBuffer, *XdmcpBufferPtr;
0110 
0111 typedef struct _XdmAuthKey {
0112     BYTE    data[8];
0113 } XdmAuthKeyRec, *XdmAuthKeyPtr;
0114 
0115 
0116 /* implementation-independent network address structure.
0117    Equiv to sockaddr* for sockets. */
0118 
0119 typedef char *XdmcpNetaddr;
0120 
0121 #ifndef __has_attribute
0122 # define __has_attribute(x) 0  /* Compatibility with older compilers */
0123 #endif
0124 
0125 #if __has_attribute(access)
0126 # define XDM_ACCESS_ATTRIBUTE(X) __attribute__((access X))
0127 #else
0128 # define XDM_ACCESS_ATTRIBUTE(X)
0129 #endif
0130 
0131 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2))
0132 extern int XdmcpWriteARRAY16(XdmcpBufferPtr buffer, const ARRAY16Ptr array);
0133 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2))
0134 extern int XdmcpWriteARRAY32(XdmcpBufferPtr buffer, const ARRAY32Ptr array);
0135 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2))
0136 extern int XdmcpWriteARRAY8(XdmcpBufferPtr buffer, const ARRAY8Ptr array);
0137 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2))
0138 extern int XdmcpWriteARRAYofARRAY8(XdmcpBufferPtr buffer, const ARRAYofARRAY8Ptr array);
0139 XDM_ACCESS_ATTRIBUTE((read_write, 1))
0140 extern int XdmcpWriteCARD16(XdmcpBufferPtr buffer, unsigned value);
0141 XDM_ACCESS_ATTRIBUTE((read_write, 1))
0142 extern int XdmcpWriteCARD32(XdmcpBufferPtr buffer, unsigned value);
0143 XDM_ACCESS_ATTRIBUTE((read_write, 1))
0144 extern int XdmcpWriteCARD8(XdmcpBufferPtr buffer, unsigned value);
0145 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2))
0146 extern int XdmcpWriteHeader(XdmcpBufferPtr  buffer, const XdmcpHeaderPtr  header);
0147 
0148 XDM_ACCESS_ATTRIBUTE((read_only, 2))
0149 extern int XdmcpFlush(int fd, XdmcpBufferPtr buffer, XdmcpNetaddr to, int tolen);
0150 
0151 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2))
0152 extern int XdmcpReadARRAY16(XdmcpBufferPtr buffer, ARRAY16Ptr array);
0153 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2))
0154 extern int XdmcpReadARRAY32(XdmcpBufferPtr buffer, ARRAY32Ptr array);
0155 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2))
0156 extern int XdmcpReadARRAY8(XdmcpBufferPtr buffer, ARRAY8Ptr array);
0157 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2))
0158 extern int XdmcpReadARRAYofARRAY8(XdmcpBufferPtr buffer, ARRAYofARRAY8Ptr array);
0159 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2))
0160 extern int XdmcpReadCARD16(XdmcpBufferPtr buffer, CARD16Ptr valuep);
0161 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2))
0162 extern int XdmcpReadCARD32(XdmcpBufferPtr buffer, CARD32Ptr valuep);
0163 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2))
0164 extern int XdmcpReadCARD8(XdmcpBufferPtr buffer, CARD8Ptr valuep);
0165 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2))
0166 extern int XdmcpReadHeader(XdmcpBufferPtr buffer, XdmcpHeaderPtr header);
0167 
0168 XDM_ACCESS_ATTRIBUTE((read_write, 2))
0169 extern int XdmcpFill(int fd, XdmcpBufferPtr buffer, XdmcpNetaddr from, int *fromlen);
0170 
0171 XDM_ACCESS_ATTRIBUTE((read_only, 1))
0172 extern int XdmcpReadRemaining(const XdmcpBufferPtr buffer);
0173 
0174 XDM_ACCESS_ATTRIBUTE((read_write, 1))
0175 extern void XdmcpDisposeARRAY8(ARRAY8Ptr array);
0176 XDM_ACCESS_ATTRIBUTE((read_write, 1))
0177 extern void XdmcpDisposeARRAY16(ARRAY16Ptr array);
0178 XDM_ACCESS_ATTRIBUTE((read_write, 1))
0179 extern void XdmcpDisposeARRAY32(ARRAY32Ptr array);
0180 XDM_ACCESS_ATTRIBUTE((read_write, 1))
0181 extern void XdmcpDisposeARRAYofARRAY8(ARRAYofARRAY8Ptr array);
0182 
0183 XDM_ACCESS_ATTRIBUTE((read_only, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2))
0184 extern int XdmcpCopyARRAY8(const ARRAY8Ptr src, ARRAY8Ptr dst);
0185 
0186 XDM_ACCESS_ATTRIBUTE((read_only, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2))
0187 extern int XdmcpARRAY8Equal(const ARRAY8Ptr array1, const ARRAY8Ptr array2);
0188 
0189 XDM_ACCESS_ATTRIBUTE((write_only, 1))
0190 extern void XdmcpGenerateKey (XdmAuthKeyPtr key);
0191 extern void XdmcpIncrementKey (XdmAuthKeyPtr key);
0192 extern void XdmcpDecrementKey (XdmAuthKeyPtr key);
0193 #ifdef HASXDMAUTH
0194 extern void XdmcpWrap(unsigned char *input, unsigned char *wrapper, unsigned char *output, int bytes);
0195 extern void XdmcpUnwrap(unsigned char *input, unsigned char *wrapper, unsigned char *output, int bytes);
0196 #endif
0197 
0198 #ifndef TRUE
0199 #define TRUE    1
0200 #define FALSE   0
0201 #endif
0202 
0203 XDM_ACCESS_ATTRIBUTE((read_only, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2))
0204 extern int XdmcpCompareKeys (const XdmAuthKeyPtr a, const XdmAuthKeyPtr b);
0205 
0206 XDM_ACCESS_ATTRIBUTE((write_only, 1))
0207 extern int XdmcpAllocARRAY16 (ARRAY16Ptr array, int length);
0208 XDM_ACCESS_ATTRIBUTE((write_only, 1))
0209 extern int XdmcpAllocARRAY32 (ARRAY32Ptr array, int length);
0210 XDM_ACCESS_ATTRIBUTE((write_only, 1))
0211 extern int XdmcpAllocARRAY8 (ARRAY8Ptr array, int length);
0212 XDM_ACCESS_ATTRIBUTE((write_only, 1))
0213 extern int XdmcpAllocARRAYofARRAY8 (ARRAYofARRAY8Ptr array, int length);
0214 
0215 XDM_ACCESS_ATTRIBUTE((read_write, 1))
0216 extern int XdmcpReallocARRAY16 (ARRAY16Ptr array, int length);
0217 XDM_ACCESS_ATTRIBUTE((read_write, 1))
0218 extern int XdmcpReallocARRAY32 (ARRAY32Ptr array, int length);
0219 XDM_ACCESS_ATTRIBUTE((read_write, 1))
0220 extern int XdmcpReallocARRAY8 (ARRAY8Ptr array, int length);
0221 XDM_ACCESS_ATTRIBUTE((read_write, 1))
0222 extern int XdmcpReallocARRAYofARRAY8 (ARRAYofARRAY8Ptr array, int length);
0223 
0224 _XFUNCPROTOEND
0225 
0226 #endif /* _XDMCP_H_ */