From: John Gilmore Date: Fri, 17 Mar 1995 05:03:27 +0000 (+0000) Subject: * configure.in: Replace nonstandard CHECK_STDARG with X-Git-Tag: krb5-1.0-beta5~548 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3386d1496d8d9b9f021ce6af9a00d1aee794fc46;p=krb5.git * configure.in: Replace nonstandard CHECK_STDARG with AC_CHECK_HEADERS. Also check for header file macsock.h, which is a dummy test -- it's false on Unix and PC's, but on the Mac we hand-configure it to be true, to indicate that we want Mac socket support rather than Unix socket support. * base-defs.h, k5-config.h: Use HAVE_STDARG_H, not STDARG_PROTOTYPES. * k5-config.h (NEED_SOCKETS): Add new section which brings in socket include files for the appropriate compilation environment (Mac or Unix; Windows already did this). * macsock.h: New include file, derived from Cygnus Network Security Mac K4 release, for simulating sockets under MacTCP. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5140 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/include/krb5/ChangeLog b/src/include/krb5/ChangeLog index 261e2f732..ed74292a1 100644 --- a/src/include/krb5/ChangeLog +++ b/src/include/krb5/ChangeLog @@ -1,3 +1,17 @@ +Thu Mar 16 20:58:22 1995 John Gilmore (gnu at toad.com) + + * configure.in: Replace nonstandard CHECK_STDARG with + AC_CHECK_HEADERS. Also check for header file macsock.h, which + is a dummy test -- it's false on Unix and PC's, but on the Mac + we hand-configure it to be true, to indicate that we want Mac + socket support rather than Unix socket support. + * base-defs.h, k5-config.h: Use HAVE_STDARG_H, not STDARG_PROTOTYPES. + * k5-config.h (NEED_SOCKETS): Add new section which brings in + socket include files for the appropriate compilation environment + (Mac or Unix; Windows already did this). + * macsock.h: New include file, derived from Cygnus Network Security + Mac K4 release, for simulating sockets under MacTCP. + Thu Mar 16 12:12:17 1995 Keith Vetter (keithv@fusion.com) * k5-config.h: PC change, getting sys_nerr and sys_errlist to work. diff --git a/src/include/krb5/base-defs.h b/src/include/krb5/base-defs.h index eb2f5cfc1..dd86413d6 100644 --- a/src/include/krb5/base-defs.h +++ b/src/include/krb5/base-defs.h @@ -79,7 +79,7 @@ typedef char const * krb5_const_pointer; #if defined(__STDC__) || defined(KRB5_PROVIDE_PROTOTYPES) #define PROTOTYPE(x) x -#if defined(__STDC__) || defined(STDARG_PROTOTYPES) +#if defined(__STDC__) || defined(HAVE_STDARG_H) #define STDARG_P(x) x #else #define STDARG_P(x) () diff --git a/src/include/krb5/configure.in b/src/include/krb5/configure.in index afbf44b52..81ca5f806 100644 --- a/src/include/krb5/configure.in +++ b/src/include/krb5/configure.in @@ -47,7 +47,8 @@ AC_CHECK_HEADERS(sys/types.h) AC_CHECK_HEADERS(sys/file.h) AC_CHECK_HEADERS(sys/param.h) AC_CHECK_HEADERS(sys/stat.h) -CHECK_STDARG +AC_CHECK_HEADERS(macsock.h) +AC_CHECK_HEADERS(stdarg.h) AC_FUNC_CHECK([setvbuf],AC_DEFINE(HAS_SETVBUF)) dnl check for ANSI stdio, esp "b" option to fopen(). This (unfortunately) diff --git a/src/include/krb5/k5-config.h b/src/include/krb5/k5-config.h index d89361500..868c3b99b 100644 --- a/src/include/krb5/k5-config.h +++ b/src/include/krb5/k5-config.h @@ -54,7 +54,7 @@ #define HAS_ANSI_VOLATILE #define HAS_VOID_TYPE #define KRB5_PROVIDE_PROTOTYPES -#define STDARG_PROTOTYPES +#define HAVE_STDARG_H #ifndef _SIZE_T_DEFINED typedef unsigned int size_t; @@ -213,7 +213,26 @@ typedef unsigned char u_char; #define labs(x) abs(x) #endif + +#ifdef NEED_SOCKETS +/* If this source file requires it, define struct sockaddr_in + (and possibly other things related to network I/O). */ + +#ifdef HAVE_MACSOCK_H /* Sockets stuff differs on Mac */ +#include "macsock.h" /* Macintosh sockets emulation library */ + +#else /* HAVE_MACSOCK_H */ /* Sockets stuff for Unix machines */ + +#include /* For struct sockaddr_in and in_addr */ +#include /* For inet_ntoa */ +#include /* For struct hostent, gethostbyname, etc */ +#include /* For MAXHOSTNAMELEN */ +#include /* For SOCK_*, AF_*, etc */ +#include /* For struct timeval */ + +#endif /* HAVE_MACSOCK_H */ +#endif /* NEED_SOCKETS */ + #endif /* _MSDOS */ #endif /* KRB5_CONFIG__ */ - diff --git a/src/include/krb5/macsock.h b/src/include/krb5/macsock.h new file mode 100644 index 000000000..5c5ee976d --- /dev/null +++ b/src/include/krb5/macsock.h @@ -0,0 +1,197 @@ +/* + * Mac interface compatible with WinSock and Unix Sockets. + * + * Implemented by John Gilmore, Cygnus Support, June 1994. + * + * Derived from: + * + Interface into the UDP class. + Written by Timothy Miller for Brown University. + + This class is extremely sketchy and not meant for general use. + It's only here because I need a machine independant interface + for UDP for internal use by kerberos. If you need to use udp to + do anything serious, be my guest and rewrite this! (Just be + sure to update the kerberos files send_to_kdc.cp and + time_stuff.cp if you change the interface.) + * + * This interface only implements a warped subset of sockets, suitable only + * for a Kerberos client's communication with its Key Distribution Centers. + */ + +/* Handle ANSI C versus traditional C */ +#ifndef __STDC__ +#define const +#define volatile +#define signed +#define PROTOTYPE(p) () +#else +#define PROTOTYPE(p) p +#endif + +/* The socket data structure itself. */ +struct socket { + short fMacTCPRef; /* refnum of MacTCP driver */ + unsigned long fStream; /* MacTCP socket/stream */ +# define UDPbuflen 4096 + char fRecvBuf[UDPbuflen]; /* receive buffer area */ +}; + +typedef struct socket *SOCKET; + +#define WORD short +#define LOBYTE(x) ((x) & 0xFF) +#define HIBYTE(x) (((x) >> 8) & 0xFF) + +/* Error codes */ +/* FIXME -- picked at random */ +#define WSAVERNOTSUPPORTED 14563 /* WinSock version not supported */ +#define EMSGSIZE 14567 /* Received packet truncated */ +#define WSAEINTR 14568 /* Interrupted system call */ +#define ECONNABORTED 14569 /* Interrupted system call */ + + +/* Struct for initializing the socket library */ +struct WSAData { + WORD wVersion; + WORD wHighVersion; +#define WSADESCRIPTION_LEN 256 + char szDescription[WSADESCRIPTION_LEN+1]; +#define WSASYSSTATUS_LEN 256 + char szSystemStatus[WSASYSSTATUS_LEN+1]; + unsigned short iMaxSockets; + unsigned short iMaxUdpDg; + char *lpVendorInfo; +}; + +typedef struct WSAData WSADATA; + +/* + * Internet address. New code should use only the s_addr field. + */ +struct in_addr { + unsigned long s_addr; +}; + + +/* + * Socket address, internet style. + */ +struct sockaddr_in { + short sin_family; + unsigned short sin_port; + struct in_addr sin_addr; + char sin_zero[8]; +}; + +/* Socket address, other styles */ +#define sockaddr sockaddr_in + +/* + * Host name<->address mapping entries + */ +struct hostent { + char *h_name; /* official name of host */ + char **h_aliases; /* alias list */ + int h_addrtype; /* address type */ + int h_length; /* length of address */ + char **h_addr_list; /* list of addresses from name server */ +#define h_addr h_addr_list[0] /* address, for backward compatiblity */ +}; + +/* + * Service name<->port mapping + */ +struct servent { + char *s_name; /* official service name */ + char **s_aliases; /* alias list */ + int s_port; /* port # */ + char *s_proto; /* protocol to use */ +}; + +/* Timeout values */ +struct timeval { + long tv_sec; /* Seconds */ + long tv_usec; /* Microseconds */ +}; + +/* True Kludge version of select argument fd_set's */ +typedef int fd_set; +#define FD_ZERO(x) 0 +#define FD_CLEAR(x) /* nothing */ +#define FD_SET(fd,x) /* nothing */ +#define FD_ISSET(fd, x) 1 + +/* Other misc constants */ +#define MAXHOSTNAMELEN 512 /* Why be stingy? */ +#define SOCK_DGRAM 2 /* Datagram socket type */ +#define AF_INET 2 /* Internet address family */ +#define INADDR_ANY ((unsigned long)0) /* Internet addr: any host */ + +/* Start using sockets */ +extern int +WSAStartup PROTOTYPE ((WORD version, struct WSAData *)); + +/* Finish using sockets */ +extern int +WSACleanup PROTOTYPE ((void)); + +/* Get a particular socket */ +extern SOCKET +socket PROTOTYPE ((int af, int type, int protocol)); + +/* Finish using a particular socket. */ +extern int +closesocket PROTOTYPE ((SOCKET theUDP)); + +/* Bind a socket to a particular address. + In our case, this is just a no-op for bug-compatability with + the FTP Software WINSOCK library. */ +extern int +bind PROTOTYPE ((SOCKET s, const struct sockaddr *name, int namelen)); + +/* Send a packet to a UDP peer. */ +extern int +sendto PROTOTYPE ((SOCKET theUDP, const char *buf, const int len, int flags, + const struct sockaddr *to, int tolen)); + +/* Select for sockets that are ready for I/O. + This version just remembers the timeout for a future receive... + It always reports that one socket is ready for I/O. */ +extern int +select PROTOTYPE ((int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, const struct timeval *timeout)); + +/* Receive a packet from a UDP peer. */ +extern int +recvfrom PROTOTYPE ((SOCKET theUDP, char *buf, int len, int flags, + struct sockaddr *from, int *fromlen)); + +extern char * +inet_ntoa PROTOTYPE ((struct in_addr ina)); + +extern struct hostent * +gethostbyname PROTOTYPE ((char *)); + +extern struct hostent * +gethostbyaddr PROTOTYPE ((char *addr, int len, int type)); + +/* Bypass a few other functions we don't really need. */ + +#define getservbyname(name,prot) 0 + +/* Macs operate in network byte order (big-endian). */ +#define htonl(x) (x) +#define htons(x) (x) +#define ntohl(x) (x) +#define ntohs(x) (x) + +/* + * Compatability with WinSock calls on MS-Windows... + */ +#define INVALID_SOCKET ((SOCKET)~0) +#define SOCKET_ERROR (-1) +#define WSAGetLastError(x) (errno) +#define WSASetLastError(x) (errno = (x)) + +extern int errno;