From: Alexandra Ellwood Date: Thu, 27 May 1999 19:12:37 +0000 (+0000) Subject: Updated header files to use OT Sockets library X-Git-Tag: krb5-1.1-beta1~131 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6b4e372342368efb5abb9a0fb22ba461ed1f5dac;p=krb5.git Updated header files to use OT Sockets library git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11473 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/include/krb5/macsock.h b/src/include/krb5/macsock.h index 089a5c213..c34f54b6b 100644 --- a/src/include/krb5/macsock.h +++ b/src/include/krb5/macsock.h @@ -22,6 +22,10 @@ #ifndef macsock_h #define macsock_h +#include +#include +#include + /* Handle ANSI C versus traditional C */ #ifndef __STDC__ #define const @@ -42,192 +46,52 @@ /* 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; -}; +/*#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 */ +/* Socket functions as defined by SocketsLib */ +#define closesocket socket_close +#define connect socket_connect +#define bind socket_bind -/* - * 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 -#define sa_family sin_family - - -/* The socket data structure itself. */ -struct socket { - short fMacTCPRef; /* refnum of MacTCP driver */ - short fType; /* UDP == SOCK_DGRAM or TCP == SOCK_STREAM Socket */ - unsigned long fStream; /* MacTCP socket/stream */ - struct sockaddr_in connect_addr; /* Address from connect call */ -# define UDPbuflen 4096 -# define TCPbuflen (8*1024) -// char fRecvBuf[UDPbuflen]; /* receive buffer area */ - char fRecvBuf[TCPbuflen]; /* receive buffer area */ -}; - -typedef struct socket *SOCKET; +#define sendto socket_sendto +#define send socket_send +#define recvfrom socket_recvfrom +#define recv socket_recv -/* - * 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 */ -}; +#define select socket_select -/* - * 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 */ -}; - -#ifndef __MWERKS__ -/* Timeout values */ -struct timeval { - long tv_sec; /* Seconds */ - long tv_usec; /* Microseconds */ -}; -#endif +#define getsockname socket_getsockname +#define getpeername socket_getpeername -/* 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 PF_INET AF_INET -#define INADDR_ANY ((unsigned long)0) /* Internet addr: any host */ -#define SOCK_STREAM 3 /* Stream socket type */ - - -/* 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)); - -/* Send a packet to a connected UDP peer. */ -extern int -send PROTOTYPE ((SOCKET theUDP, const char *buf, const int len, int flags)); - -/* 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)); - -/* Receive a packet from a connected UDP peer. */ -extern int -recv PROTOTYPE ((SOCKET theUDP, char *buf, int len, int flags)); - -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)); - -extern struct hostent * -getmyipaddr PROTOTYPE ((void)); - -extern int -getsockname PROTOTYPE((SOCKET, struct sockaddr_in *, int *)); - -extern int -getpeername PROTOTYPE((SOCKET, struct sockaddr_in *, int *)); - -/* 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) +#define SOCKET_READ socket_read +#define SOCKET_WRITE socket_write +typedef int SOCKET; /* * Compatability with WinSock calls on MS-Windows... */ -#define INVALID_SOCKET ((SOCKET)~0) -#define SOCKET_ERROR (-1) -#define WSAGetLastError() (errno) -#define WSASetLastError(x) (errno = (x)) + +#define SOCKET_INITIALIZE() () +#define SOCKET_CLEANUP() + +#define INVALID_SOCKET (-1L) +#define SOCKET_ERROR (-1) +#define SOCKET_EINTR EINTR +#define WSAECONNABORTED kECONNABORTEDErr + +#define MAXHOSTNAMELEN MAXHOSTNAMESIZE + +#define SOCKET_NFDS(f) (FD_SETSIZE) /* select()'s first arg is maxed out */ + +#define WSAGetLastError() (GetMITLibError()) +#define WSASetLastError(x) (SetMITLibError(x)) +#define SOCKET_ERRNO (GetMITLibError()) +#define SOCKET_SET_ERRNO(x) (SetMITLibError(x)) + +#define local_addr_fallback_kludge() (0) + -extern int errno; #endif /* macsock_h */ diff --git a/src/include/port-sockets.h b/src/include/port-sockets.h index ec065e894..efb2c9444 100644 --- a/src/include/port-sockets.h +++ b/src/include/port-sockets.h @@ -25,20 +25,8 @@ int win_socket_initialize(); #ifdef HAVE_MACSOCK_H /* Sockets stuff differs on Mac */ #include "macsock.h" /* Macintosh sockets emulation library */ - -/* Some of our own infrastructure where the WinSock stuff was too hairy - to dump into a clean Unix program... */ - -#define SOCKET_INITIALIZE() (WSAStartup(0x0101, (WSADATA *)0)) -#define SOCKET_CLEANUP() (WSACleanup()) -#define SOCKET_ERRNO (WSAGetLastError()) -#define SOCKET_SET_ERRNO(x) (WSASetLastError(x)) -#define SOCKET_NFDS(f) (0) /* select()'s first arg is ignored */ -#define SOCKET_READ(fd, b, l) (recv(fd, b, l, 0)) -#define SOCKET_WRITE(fd, b, l) (send(fd, b, l, 0)) -#define SOCKET_EINTR WSAEINTR - #else /* ! HAVE_MACSOCK_H */ /* Sockets stuff for Unix machines */ + #include #include /* For struct sockaddr_in and in_addr */ #include /* For inet_ntoa */ diff --git a/src/include/win-mac.h b/src/include/win-mac.h index 1c77f83c9..f5f93c9b4 100644 --- a/src/include/win-mac.h +++ b/src/include/win-mac.h @@ -240,7 +240,7 @@ HINSTANCE get_lib_instance(void); #define HAVE_SRAND #define NO_PASSWORD #define HAVE_LABS -#define ENOMEM 12 +/*#define ENOMEM 12*/ #define ANSI_STDIO #ifndef _SIZET typedef unsigned long size_t; diff --git a/src/mac/libraries/KerberosHeaders.h b/src/mac/libraries/KerberosHeaders.h index 7c84d5538..1a07404ba 100644 --- a/src/mac/libraries/KerberosHeaders.h +++ b/src/mac/libraries/KerberosHeaders.h @@ -11,10 +11,8 @@ */ #define KRB5 1 -#define macintosh #define SIZEOF_INT 4 #define SIZEOF_SHORT 2 -/*#define ENOMEM -1*/ #define HAVE_SRAND #define NO_PASSWORD #define HAVE_LABS @@ -22,6 +20,7 @@ #include #include +#include #define PROVIDE_RSA_MD4 #define PROVIDE_RSA_MD5 @@ -36,65 +35,12 @@ #define NO_SYS_TYPES_H #define NO_SYS_STAT_H - -/* - * Rename various socket type operations to avoid cluttering the namespace - */ -#define socket krb5_socket -#define closesocket krb5_closesocket -#define connect krb5_connect -#define bind krb5_bind -#define send krb5_send -#define recv krb5_recv -#define sendto krb5_sendto -#define select krb5_select -#define recvfrom krb5_recvfrom -#define inet_ntoa krb5_inet_ntoa -#define gethostbyname krb5_gethostbyname -#define gethostbyaddr krb5_gethostbyaddr -#define gethostname krb5_gethostname -#define getsockname krb5_getsockname -#define getmyipaddr krb5_getmyipaddr - -#define OpenOurRF krb5_OpenOurRF -#define OpenResolver krb5_OpenResolver -#define CloseResolver krb5_CloseResolver -#define StrToAddr krb5_StrToAddr -#define AddrToStr krb5_AddrToStr -#define EnumCache krb5_EnumCache -#define AddrToName krb5_AddrToName -#define dnr krb5_dnr -#define codeHndl krb5_codeHndl - -typedef int datum; +#define HAVE_STDLIB_H 1 //jfm need to reimplement #define mktemp(a) enum { -ENOENT = -43, -EPERM, -EACCES, -EISDIR, -ENOTDIR, -ELOOP, -ETXTBSY, -EBUSY, -EROFS, -EINVAL, -EEXIST, -EFAULT, -EBADF, -ENAMETOOLONG, -EWOULDBLOCK, -EDQUOT, -ENOSPC, -EIO, -ENFILE, -EMFILE, -ENXIO +EROFS = 30, +ENFILE = 23 }; -#define HAVE_STRFTIME 1 -#define MAXPATHLEN 255 -#define HAVE_SYSLOG_H 1 -#define HAVE_STDLIB_H 1