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