jpayne@69
|
1 /*
|
jpayne@69
|
2 * Copyright 1989 Network Computing Devices, Inc., Mountain View, California.
|
jpayne@69
|
3 *
|
jpayne@69
|
4 * Permission to use, copy, modify, and distribute this software and its
|
jpayne@69
|
5 * documentation for any purpose and without fee is hereby granted, provided
|
jpayne@69
|
6 * that the above copyright notice appear in all copies and that both that
|
jpayne@69
|
7 * copyright notice and this permission notice appear in supporting
|
jpayne@69
|
8 * documentation, and that the name of N.C.D. not be used in advertising or
|
jpayne@69
|
9 * publicity pertaining to distribution of the software without specific,
|
jpayne@69
|
10 * written prior permission. N.C.D. makes no representations about the
|
jpayne@69
|
11 * suitability of this software for any purpose. It is provided "as is"
|
jpayne@69
|
12 * without express or implied warranty.
|
jpayne@69
|
13 *
|
jpayne@69
|
14 */
|
jpayne@69
|
15
|
jpayne@69
|
16 #ifndef _XDMCP_H_
|
jpayne@69
|
17 #define _XDMCP_H_
|
jpayne@69
|
18
|
jpayne@69
|
19 #include <X11/Xmd.h>
|
jpayne@69
|
20
|
jpayne@69
|
21 #include <X11/Xfuncproto.h>
|
jpayne@69
|
22
|
jpayne@69
|
23 _XFUNCPROTOBEGIN
|
jpayne@69
|
24
|
jpayne@69
|
25 #define XDM_PROTOCOL_VERSION 1
|
jpayne@69
|
26 #define XDM_UDP_PORT 177
|
jpayne@69
|
27
|
jpayne@69
|
28 /* IANA has assigned FF0X:0:0:0:0:0:0:12B as the permanently assigned
|
jpayne@69
|
29 * multicast addresses for XDMCP, where X in the prefix may be replaced
|
jpayne@69
|
30 * by any valid scope identifier, such as 1 for Node-Local, 2 for Link-Local,
|
jpayne@69
|
31 * 5 for Site-Local, and so on. We set the default here to the Link-Local
|
jpayne@69
|
32 * version to most closely match the old IPv4 subnet broadcast behavior.
|
jpayne@69
|
33 * Both xdm and X -query allow specifying a different address if a different
|
jpayne@69
|
34 * scope is defined.
|
jpayne@69
|
35 */
|
jpayne@69
|
36 #define XDM_DEFAULT_MCAST_ADDR6 "ff02:0:0:0:0:0:0:12b"
|
jpayne@69
|
37
|
jpayne@69
|
38 #define XDM_MAX_MSGLEN 8192
|
jpayne@69
|
39 #define XDM_MIN_RTX 2
|
jpayne@69
|
40 #define XDM_MAX_RTX 32
|
jpayne@69
|
41 #define XDM_RTX_LIMIT 7
|
jpayne@69
|
42 #define XDM_KA_RTX_LIMIT 4
|
jpayne@69
|
43 #define XDM_DEF_DORMANCY (3 * 60) /* 3 minutes */
|
jpayne@69
|
44 #define XDM_MAX_DORMANCY (24 * 60 * 60) /* 24 hours */
|
jpayne@69
|
45
|
jpayne@69
|
46 typedef enum {
|
jpayne@69
|
47 BROADCAST_QUERY = 1, QUERY, INDIRECT_QUERY, FORWARD_QUERY,
|
jpayne@69
|
48 WILLING, UNWILLING, REQUEST, ACCEPT, DECLINE, MANAGE, REFUSE,
|
jpayne@69
|
49 FAILED, KEEPALIVE, ALIVE
|
jpayne@69
|
50 } xdmOpCode;
|
jpayne@69
|
51
|
jpayne@69
|
52 typedef enum {
|
jpayne@69
|
53 XDM_QUERY, XDM_BROADCAST, XDM_INDIRECT, XDM_COLLECT_QUERY,
|
jpayne@69
|
54 XDM_COLLECT_BROADCAST_QUERY, XDM_COLLECT_INDIRECT_QUERY,
|
jpayne@69
|
55 XDM_START_CONNECTION, XDM_AWAIT_REQUEST_RESPONSE,
|
jpayne@69
|
56 XDM_AWAIT_MANAGE_RESPONSE, XDM_MANAGE, XDM_RUN_SESSION, XDM_OFF,
|
jpayne@69
|
57 XDM_AWAIT_USER_INPUT, XDM_KEEPALIVE, XDM_AWAIT_ALIVE_RESPONSE,
|
jpayne@69
|
58 #if defined(IPv6) && defined(AF_INET6)
|
jpayne@69
|
59 XDM_MULTICAST, XDM_COLLECT_MULTICAST_QUERY,
|
jpayne@69
|
60 #endif
|
jpayne@69
|
61 XDM_KEEP_ME_LAST
|
jpayne@69
|
62 } xdmcp_states;
|
jpayne@69
|
63
|
jpayne@69
|
64 #ifdef NOTDEF
|
jpayne@69
|
65 /* table of hosts */
|
jpayne@69
|
66
|
jpayne@69
|
67 #define XDM_MAX_STR_LEN 21
|
jpayne@69
|
68 #define XDM_MAX_HOSTS 20
|
jpayne@69
|
69 struct xdm_host_table {
|
jpayne@69
|
70 struct sockaddr_in sockaddr;
|
jpayne@69
|
71 char name[XDM_MAX_STR_LEN];
|
jpayne@69
|
72 char status[XDM_MAX_STR_LEN];
|
jpayne@69
|
73 };
|
jpayne@69
|
74 #endif /* NOTDEF */
|
jpayne@69
|
75
|
jpayne@69
|
76 typedef CARD8 *CARD8Ptr;
|
jpayne@69
|
77 typedef CARD16 *CARD16Ptr;
|
jpayne@69
|
78 typedef CARD32 *CARD32Ptr;
|
jpayne@69
|
79
|
jpayne@69
|
80 typedef struct _ARRAY8 {
|
jpayne@69
|
81 CARD16 length;
|
jpayne@69
|
82 CARD8Ptr data;
|
jpayne@69
|
83 } ARRAY8, *ARRAY8Ptr;
|
jpayne@69
|
84
|
jpayne@69
|
85 typedef struct _ARRAY16 {
|
jpayne@69
|
86 CARD8 length;
|
jpayne@69
|
87 CARD16Ptr data;
|
jpayne@69
|
88 } ARRAY16, *ARRAY16Ptr;
|
jpayne@69
|
89
|
jpayne@69
|
90 typedef struct _ARRAY32 {
|
jpayne@69
|
91 CARD8 length;
|
jpayne@69
|
92 CARD32Ptr data;
|
jpayne@69
|
93 } ARRAY32, *ARRAY32Ptr;
|
jpayne@69
|
94
|
jpayne@69
|
95 typedef struct _ARRAYofARRAY8 {
|
jpayne@69
|
96 CARD8 length;
|
jpayne@69
|
97 ARRAY8Ptr data;
|
jpayne@69
|
98 } ARRAYofARRAY8, *ARRAYofARRAY8Ptr;
|
jpayne@69
|
99
|
jpayne@69
|
100 typedef struct _XdmcpHeader {
|
jpayne@69
|
101 CARD16 version, opcode, length;
|
jpayne@69
|
102 } XdmcpHeader, *XdmcpHeaderPtr;
|
jpayne@69
|
103
|
jpayne@69
|
104 typedef struct _XdmcpBuffer {
|
jpayne@69
|
105 BYTE *data;
|
jpayne@69
|
106 int size; /* size of buffer pointed by to data */
|
jpayne@69
|
107 int pointer; /* current index into data */
|
jpayne@69
|
108 int count; /* bytes read from network into data */
|
jpayne@69
|
109 } XdmcpBuffer, *XdmcpBufferPtr;
|
jpayne@69
|
110
|
jpayne@69
|
111 typedef struct _XdmAuthKey {
|
jpayne@69
|
112 BYTE data[8];
|
jpayne@69
|
113 } XdmAuthKeyRec, *XdmAuthKeyPtr;
|
jpayne@69
|
114
|
jpayne@69
|
115
|
jpayne@69
|
116 /* implementation-independent network address structure.
|
jpayne@69
|
117 Equiv to sockaddr* for sockets. */
|
jpayne@69
|
118
|
jpayne@69
|
119 typedef char *XdmcpNetaddr;
|
jpayne@69
|
120
|
jpayne@69
|
121 #ifndef __has_attribute
|
jpayne@69
|
122 # define __has_attribute(x) 0 /* Compatibility with older compilers */
|
jpayne@69
|
123 #endif
|
jpayne@69
|
124
|
jpayne@69
|
125 #if __has_attribute(access)
|
jpayne@69
|
126 # define XDM_ACCESS_ATTRIBUTE(X) __attribute__((access X))
|
jpayne@69
|
127 #else
|
jpayne@69
|
128 # define XDM_ACCESS_ATTRIBUTE(X)
|
jpayne@69
|
129 #endif
|
jpayne@69
|
130
|
jpayne@69
|
131 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2))
|
jpayne@69
|
132 extern int XdmcpWriteARRAY16(XdmcpBufferPtr buffer, const ARRAY16Ptr array);
|
jpayne@69
|
133 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2))
|
jpayne@69
|
134 extern int XdmcpWriteARRAY32(XdmcpBufferPtr buffer, const ARRAY32Ptr array);
|
jpayne@69
|
135 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2))
|
jpayne@69
|
136 extern int XdmcpWriteARRAY8(XdmcpBufferPtr buffer, const ARRAY8Ptr array);
|
jpayne@69
|
137 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2))
|
jpayne@69
|
138 extern int XdmcpWriteARRAYofARRAY8(XdmcpBufferPtr buffer, const ARRAYofARRAY8Ptr array);
|
jpayne@69
|
139 XDM_ACCESS_ATTRIBUTE((read_write, 1))
|
jpayne@69
|
140 extern int XdmcpWriteCARD16(XdmcpBufferPtr buffer, unsigned value);
|
jpayne@69
|
141 XDM_ACCESS_ATTRIBUTE((read_write, 1))
|
jpayne@69
|
142 extern int XdmcpWriteCARD32(XdmcpBufferPtr buffer, unsigned value);
|
jpayne@69
|
143 XDM_ACCESS_ATTRIBUTE((read_write, 1))
|
jpayne@69
|
144 extern int XdmcpWriteCARD8(XdmcpBufferPtr buffer, unsigned value);
|
jpayne@69
|
145 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2))
|
jpayne@69
|
146 extern int XdmcpWriteHeader(XdmcpBufferPtr buffer, const XdmcpHeaderPtr header);
|
jpayne@69
|
147
|
jpayne@69
|
148 XDM_ACCESS_ATTRIBUTE((read_only, 2))
|
jpayne@69
|
149 extern int XdmcpFlush(int fd, XdmcpBufferPtr buffer, XdmcpNetaddr to, int tolen);
|
jpayne@69
|
150
|
jpayne@69
|
151 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2))
|
jpayne@69
|
152 extern int XdmcpReadARRAY16(XdmcpBufferPtr buffer, ARRAY16Ptr array);
|
jpayne@69
|
153 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2))
|
jpayne@69
|
154 extern int XdmcpReadARRAY32(XdmcpBufferPtr buffer, ARRAY32Ptr array);
|
jpayne@69
|
155 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2))
|
jpayne@69
|
156 extern int XdmcpReadARRAY8(XdmcpBufferPtr buffer, ARRAY8Ptr array);
|
jpayne@69
|
157 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2))
|
jpayne@69
|
158 extern int XdmcpReadARRAYofARRAY8(XdmcpBufferPtr buffer, ARRAYofARRAY8Ptr array);
|
jpayne@69
|
159 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2))
|
jpayne@69
|
160 extern int XdmcpReadCARD16(XdmcpBufferPtr buffer, CARD16Ptr valuep);
|
jpayne@69
|
161 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2))
|
jpayne@69
|
162 extern int XdmcpReadCARD32(XdmcpBufferPtr buffer, CARD32Ptr valuep);
|
jpayne@69
|
163 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2))
|
jpayne@69
|
164 extern int XdmcpReadCARD8(XdmcpBufferPtr buffer, CARD8Ptr valuep);
|
jpayne@69
|
165 XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2))
|
jpayne@69
|
166 extern int XdmcpReadHeader(XdmcpBufferPtr buffer, XdmcpHeaderPtr header);
|
jpayne@69
|
167
|
jpayne@69
|
168 XDM_ACCESS_ATTRIBUTE((read_write, 2))
|
jpayne@69
|
169 extern int XdmcpFill(int fd, XdmcpBufferPtr buffer, XdmcpNetaddr from, int *fromlen);
|
jpayne@69
|
170
|
jpayne@69
|
171 XDM_ACCESS_ATTRIBUTE((read_only, 1))
|
jpayne@69
|
172 extern int XdmcpReadRemaining(const XdmcpBufferPtr buffer);
|
jpayne@69
|
173
|
jpayne@69
|
174 XDM_ACCESS_ATTRIBUTE((read_write, 1))
|
jpayne@69
|
175 extern void XdmcpDisposeARRAY8(ARRAY8Ptr array);
|
jpayne@69
|
176 XDM_ACCESS_ATTRIBUTE((read_write, 1))
|
jpayne@69
|
177 extern void XdmcpDisposeARRAY16(ARRAY16Ptr array);
|
jpayne@69
|
178 XDM_ACCESS_ATTRIBUTE((read_write, 1))
|
jpayne@69
|
179 extern void XdmcpDisposeARRAY32(ARRAY32Ptr array);
|
jpayne@69
|
180 XDM_ACCESS_ATTRIBUTE((read_write, 1))
|
jpayne@69
|
181 extern void XdmcpDisposeARRAYofARRAY8(ARRAYofARRAY8Ptr array);
|
jpayne@69
|
182
|
jpayne@69
|
183 XDM_ACCESS_ATTRIBUTE((read_only, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2))
|
jpayne@69
|
184 extern int XdmcpCopyARRAY8(const ARRAY8Ptr src, ARRAY8Ptr dst);
|
jpayne@69
|
185
|
jpayne@69
|
186 XDM_ACCESS_ATTRIBUTE((read_only, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2))
|
jpayne@69
|
187 extern int XdmcpARRAY8Equal(const ARRAY8Ptr array1, const ARRAY8Ptr array2);
|
jpayne@69
|
188
|
jpayne@69
|
189 XDM_ACCESS_ATTRIBUTE((write_only, 1))
|
jpayne@69
|
190 extern void XdmcpGenerateKey (XdmAuthKeyPtr key);
|
jpayne@69
|
191 extern void XdmcpIncrementKey (XdmAuthKeyPtr key);
|
jpayne@69
|
192 extern void XdmcpDecrementKey (XdmAuthKeyPtr key);
|
jpayne@69
|
193 #ifdef HASXDMAUTH
|
jpayne@69
|
194 extern void XdmcpWrap(unsigned char *input, unsigned char *wrapper, unsigned char *output, int bytes);
|
jpayne@69
|
195 extern void XdmcpUnwrap(unsigned char *input, unsigned char *wrapper, unsigned char *output, int bytes);
|
jpayne@69
|
196 #endif
|
jpayne@69
|
197
|
jpayne@69
|
198 #ifndef TRUE
|
jpayne@69
|
199 #define TRUE 1
|
jpayne@69
|
200 #define FALSE 0
|
jpayne@69
|
201 #endif
|
jpayne@69
|
202
|
jpayne@69
|
203 XDM_ACCESS_ATTRIBUTE((read_only, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2))
|
jpayne@69
|
204 extern int XdmcpCompareKeys (const XdmAuthKeyPtr a, const XdmAuthKeyPtr b);
|
jpayne@69
|
205
|
jpayne@69
|
206 XDM_ACCESS_ATTRIBUTE((write_only, 1))
|
jpayne@69
|
207 extern int XdmcpAllocARRAY16 (ARRAY16Ptr array, int length);
|
jpayne@69
|
208 XDM_ACCESS_ATTRIBUTE((write_only, 1))
|
jpayne@69
|
209 extern int XdmcpAllocARRAY32 (ARRAY32Ptr array, int length);
|
jpayne@69
|
210 XDM_ACCESS_ATTRIBUTE((write_only, 1))
|
jpayne@69
|
211 extern int XdmcpAllocARRAY8 (ARRAY8Ptr array, int length);
|
jpayne@69
|
212 XDM_ACCESS_ATTRIBUTE((write_only, 1))
|
jpayne@69
|
213 extern int XdmcpAllocARRAYofARRAY8 (ARRAYofARRAY8Ptr array, int length);
|
jpayne@69
|
214
|
jpayne@69
|
215 XDM_ACCESS_ATTRIBUTE((read_write, 1))
|
jpayne@69
|
216 extern int XdmcpReallocARRAY16 (ARRAY16Ptr array, int length);
|
jpayne@69
|
217 XDM_ACCESS_ATTRIBUTE((read_write, 1))
|
jpayne@69
|
218 extern int XdmcpReallocARRAY32 (ARRAY32Ptr array, int length);
|
jpayne@69
|
219 XDM_ACCESS_ATTRIBUTE((read_write, 1))
|
jpayne@69
|
220 extern int XdmcpReallocARRAY8 (ARRAY8Ptr array, int length);
|
jpayne@69
|
221 XDM_ACCESS_ATTRIBUTE((read_write, 1))
|
jpayne@69
|
222 extern int XdmcpReallocARRAYofARRAY8 (ARRAYofARRAY8Ptr array, int length);
|
jpayne@69
|
223
|
jpayne@69
|
224 _XFUNCPROTOEND
|
jpayne@69
|
225
|
jpayne@69
|
226 #endif /* _XDMCP_H_ */
|