jpayne@69: /* jpayne@69: * Copyright 1989 Network Computing Devices, Inc., Mountain View, California. jpayne@69: * jpayne@69: * Permission to use, copy, modify, and distribute this software and its jpayne@69: * documentation for any purpose and without fee is hereby granted, provided jpayne@69: * that the above copyright notice appear in all copies and that both that jpayne@69: * copyright notice and this permission notice appear in supporting jpayne@69: * documentation, and that the name of N.C.D. not be used in advertising or jpayne@69: * publicity pertaining to distribution of the software without specific, jpayne@69: * written prior permission. N.C.D. makes no representations about the jpayne@69: * suitability of this software for any purpose. It is provided "as is" jpayne@69: * without express or implied warranty. jpayne@69: * jpayne@69: */ jpayne@69: jpayne@69: #ifndef _XDMCP_H_ jpayne@69: #define _XDMCP_H_ jpayne@69: jpayne@69: #include jpayne@69: jpayne@69: #include jpayne@69: jpayne@69: _XFUNCPROTOBEGIN jpayne@69: jpayne@69: #define XDM_PROTOCOL_VERSION 1 jpayne@69: #define XDM_UDP_PORT 177 jpayne@69: jpayne@69: /* IANA has assigned FF0X:0:0:0:0:0:0:12B as the permanently assigned jpayne@69: * multicast addresses for XDMCP, where X in the prefix may be replaced jpayne@69: * by any valid scope identifier, such as 1 for Node-Local, 2 for Link-Local, jpayne@69: * 5 for Site-Local, and so on. We set the default here to the Link-Local jpayne@69: * version to most closely match the old IPv4 subnet broadcast behavior. jpayne@69: * Both xdm and X -query allow specifying a different address if a different jpayne@69: * scope is defined. jpayne@69: */ jpayne@69: #define XDM_DEFAULT_MCAST_ADDR6 "ff02:0:0:0:0:0:0:12b" jpayne@69: jpayne@69: #define XDM_MAX_MSGLEN 8192 jpayne@69: #define XDM_MIN_RTX 2 jpayne@69: #define XDM_MAX_RTX 32 jpayne@69: #define XDM_RTX_LIMIT 7 jpayne@69: #define XDM_KA_RTX_LIMIT 4 jpayne@69: #define XDM_DEF_DORMANCY (3 * 60) /* 3 minutes */ jpayne@69: #define XDM_MAX_DORMANCY (24 * 60 * 60) /* 24 hours */ jpayne@69: jpayne@69: typedef enum { jpayne@69: BROADCAST_QUERY = 1, QUERY, INDIRECT_QUERY, FORWARD_QUERY, jpayne@69: WILLING, UNWILLING, REQUEST, ACCEPT, DECLINE, MANAGE, REFUSE, jpayne@69: FAILED, KEEPALIVE, ALIVE jpayne@69: } xdmOpCode; jpayne@69: jpayne@69: typedef enum { jpayne@69: XDM_QUERY, XDM_BROADCAST, XDM_INDIRECT, XDM_COLLECT_QUERY, jpayne@69: XDM_COLLECT_BROADCAST_QUERY, XDM_COLLECT_INDIRECT_QUERY, jpayne@69: XDM_START_CONNECTION, XDM_AWAIT_REQUEST_RESPONSE, jpayne@69: XDM_AWAIT_MANAGE_RESPONSE, XDM_MANAGE, XDM_RUN_SESSION, XDM_OFF, jpayne@69: XDM_AWAIT_USER_INPUT, XDM_KEEPALIVE, XDM_AWAIT_ALIVE_RESPONSE, jpayne@69: #if defined(IPv6) && defined(AF_INET6) jpayne@69: XDM_MULTICAST, XDM_COLLECT_MULTICAST_QUERY, jpayne@69: #endif jpayne@69: XDM_KEEP_ME_LAST jpayne@69: } xdmcp_states; jpayne@69: jpayne@69: #ifdef NOTDEF jpayne@69: /* table of hosts */ jpayne@69: jpayne@69: #define XDM_MAX_STR_LEN 21 jpayne@69: #define XDM_MAX_HOSTS 20 jpayne@69: struct xdm_host_table { jpayne@69: struct sockaddr_in sockaddr; jpayne@69: char name[XDM_MAX_STR_LEN]; jpayne@69: char status[XDM_MAX_STR_LEN]; jpayne@69: }; jpayne@69: #endif /* NOTDEF */ jpayne@69: jpayne@69: typedef CARD8 *CARD8Ptr; jpayne@69: typedef CARD16 *CARD16Ptr; jpayne@69: typedef CARD32 *CARD32Ptr; jpayne@69: jpayne@69: typedef struct _ARRAY8 { jpayne@69: CARD16 length; jpayne@69: CARD8Ptr data; jpayne@69: } ARRAY8, *ARRAY8Ptr; jpayne@69: jpayne@69: typedef struct _ARRAY16 { jpayne@69: CARD8 length; jpayne@69: CARD16Ptr data; jpayne@69: } ARRAY16, *ARRAY16Ptr; jpayne@69: jpayne@69: typedef struct _ARRAY32 { jpayne@69: CARD8 length; jpayne@69: CARD32Ptr data; jpayne@69: } ARRAY32, *ARRAY32Ptr; jpayne@69: jpayne@69: typedef struct _ARRAYofARRAY8 { jpayne@69: CARD8 length; jpayne@69: ARRAY8Ptr data; jpayne@69: } ARRAYofARRAY8, *ARRAYofARRAY8Ptr; jpayne@69: jpayne@69: typedef struct _XdmcpHeader { jpayne@69: CARD16 version, opcode, length; jpayne@69: } XdmcpHeader, *XdmcpHeaderPtr; jpayne@69: jpayne@69: typedef struct _XdmcpBuffer { jpayne@69: BYTE *data; jpayne@69: int size; /* size of buffer pointed by to data */ jpayne@69: int pointer; /* current index into data */ jpayne@69: int count; /* bytes read from network into data */ jpayne@69: } XdmcpBuffer, *XdmcpBufferPtr; jpayne@69: jpayne@69: typedef struct _XdmAuthKey { jpayne@69: BYTE data[8]; jpayne@69: } XdmAuthKeyRec, *XdmAuthKeyPtr; jpayne@69: jpayne@69: jpayne@69: /* implementation-independent network address structure. jpayne@69: Equiv to sockaddr* for sockets. */ jpayne@69: jpayne@69: typedef char *XdmcpNetaddr; jpayne@69: jpayne@69: #ifndef __has_attribute jpayne@69: # define __has_attribute(x) 0 /* Compatibility with older compilers */ jpayne@69: #endif jpayne@69: jpayne@69: #if __has_attribute(access) jpayne@69: # define XDM_ACCESS_ATTRIBUTE(X) __attribute__((access X)) jpayne@69: #else jpayne@69: # define XDM_ACCESS_ATTRIBUTE(X) jpayne@69: #endif jpayne@69: jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2)) jpayne@69: extern int XdmcpWriteARRAY16(XdmcpBufferPtr buffer, const ARRAY16Ptr array); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2)) jpayne@69: extern int XdmcpWriteARRAY32(XdmcpBufferPtr buffer, const ARRAY32Ptr array); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2)) jpayne@69: extern int XdmcpWriteARRAY8(XdmcpBufferPtr buffer, const ARRAY8Ptr array); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2)) jpayne@69: extern int XdmcpWriteARRAYofARRAY8(XdmcpBufferPtr buffer, const ARRAYofARRAY8Ptr array); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) jpayne@69: extern int XdmcpWriteCARD16(XdmcpBufferPtr buffer, unsigned value); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) jpayne@69: extern int XdmcpWriteCARD32(XdmcpBufferPtr buffer, unsigned value); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) jpayne@69: extern int XdmcpWriteCARD8(XdmcpBufferPtr buffer, unsigned value); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2)) jpayne@69: extern int XdmcpWriteHeader(XdmcpBufferPtr buffer, const XdmcpHeaderPtr header); jpayne@69: jpayne@69: XDM_ACCESS_ATTRIBUTE((read_only, 2)) jpayne@69: extern int XdmcpFlush(int fd, XdmcpBufferPtr buffer, XdmcpNetaddr to, int tolen); jpayne@69: jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2)) jpayne@69: extern int XdmcpReadARRAY16(XdmcpBufferPtr buffer, ARRAY16Ptr array); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2)) jpayne@69: extern int XdmcpReadARRAY32(XdmcpBufferPtr buffer, ARRAY32Ptr array); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2)) jpayne@69: extern int XdmcpReadARRAY8(XdmcpBufferPtr buffer, ARRAY8Ptr array); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2)) jpayne@69: extern int XdmcpReadARRAYofARRAY8(XdmcpBufferPtr buffer, ARRAYofARRAY8Ptr array); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2)) jpayne@69: extern int XdmcpReadCARD16(XdmcpBufferPtr buffer, CARD16Ptr valuep); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2)) jpayne@69: extern int XdmcpReadCARD32(XdmcpBufferPtr buffer, CARD32Ptr valuep); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2)) jpayne@69: extern int XdmcpReadCARD8(XdmcpBufferPtr buffer, CARD8Ptr valuep); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2)) jpayne@69: extern int XdmcpReadHeader(XdmcpBufferPtr buffer, XdmcpHeaderPtr header); jpayne@69: jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 2)) jpayne@69: extern int XdmcpFill(int fd, XdmcpBufferPtr buffer, XdmcpNetaddr from, int *fromlen); jpayne@69: jpayne@69: XDM_ACCESS_ATTRIBUTE((read_only, 1)) jpayne@69: extern int XdmcpReadRemaining(const XdmcpBufferPtr buffer); jpayne@69: jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) jpayne@69: extern void XdmcpDisposeARRAY8(ARRAY8Ptr array); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) jpayne@69: extern void XdmcpDisposeARRAY16(ARRAY16Ptr array); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) jpayne@69: extern void XdmcpDisposeARRAY32(ARRAY32Ptr array); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) jpayne@69: extern void XdmcpDisposeARRAYofARRAY8(ARRAYofARRAY8Ptr array); jpayne@69: jpayne@69: XDM_ACCESS_ATTRIBUTE((read_only, 1)) XDM_ACCESS_ATTRIBUTE((write_only, 2)) jpayne@69: extern int XdmcpCopyARRAY8(const ARRAY8Ptr src, ARRAY8Ptr dst); jpayne@69: jpayne@69: XDM_ACCESS_ATTRIBUTE((read_only, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2)) jpayne@69: extern int XdmcpARRAY8Equal(const ARRAY8Ptr array1, const ARRAY8Ptr array2); jpayne@69: jpayne@69: XDM_ACCESS_ATTRIBUTE((write_only, 1)) jpayne@69: extern void XdmcpGenerateKey (XdmAuthKeyPtr key); jpayne@69: extern void XdmcpIncrementKey (XdmAuthKeyPtr key); jpayne@69: extern void XdmcpDecrementKey (XdmAuthKeyPtr key); jpayne@69: #ifdef HASXDMAUTH jpayne@69: extern void XdmcpWrap(unsigned char *input, unsigned char *wrapper, unsigned char *output, int bytes); jpayne@69: extern void XdmcpUnwrap(unsigned char *input, unsigned char *wrapper, unsigned char *output, int bytes); jpayne@69: #endif jpayne@69: jpayne@69: #ifndef TRUE jpayne@69: #define TRUE 1 jpayne@69: #define FALSE 0 jpayne@69: #endif jpayne@69: jpayne@69: XDM_ACCESS_ATTRIBUTE((read_only, 1)) XDM_ACCESS_ATTRIBUTE((read_only, 2)) jpayne@69: extern int XdmcpCompareKeys (const XdmAuthKeyPtr a, const XdmAuthKeyPtr b); jpayne@69: jpayne@69: XDM_ACCESS_ATTRIBUTE((write_only, 1)) jpayne@69: extern int XdmcpAllocARRAY16 (ARRAY16Ptr array, int length); jpayne@69: XDM_ACCESS_ATTRIBUTE((write_only, 1)) jpayne@69: extern int XdmcpAllocARRAY32 (ARRAY32Ptr array, int length); jpayne@69: XDM_ACCESS_ATTRIBUTE((write_only, 1)) jpayne@69: extern int XdmcpAllocARRAY8 (ARRAY8Ptr array, int length); jpayne@69: XDM_ACCESS_ATTRIBUTE((write_only, 1)) jpayne@69: extern int XdmcpAllocARRAYofARRAY8 (ARRAYofARRAY8Ptr array, int length); jpayne@69: jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) jpayne@69: extern int XdmcpReallocARRAY16 (ARRAY16Ptr array, int length); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) jpayne@69: extern int XdmcpReallocARRAY32 (ARRAY32Ptr array, int length); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) jpayne@69: extern int XdmcpReallocARRAY8 (ARRAY8Ptr array, int length); jpayne@69: XDM_ACCESS_ATTRIBUTE((read_write, 1)) jpayne@69: extern int XdmcpReallocARRAYofARRAY8 (ARRAYofARRAY8Ptr array, int length); jpayne@69: jpayne@69: _XFUNCPROTOEND jpayne@69: jpayne@69: #endif /* _XDMCP_H_ */