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