#ifndef CLIB_SOCKET_PROTOS_H
#define CLIB_SOCKET_PROTOS_H

/*
 * $Id: socket_protos.h,v 1.15 1993/08/05 21:01:58 jraja Exp $
 *
 * Copyright © 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
 *                  Helsinki University of Technology, Finland.
 *                  All rights reserved.
 *
 * Prototypes for AmiTCP/IP bsdsocket.library
 *
 * HISTORY
 * $Log: socket_protos.h,v $
 * Revision 1.15  1993/08/05  21:01:58  jraja
 * Fixed error in Release(CopyOf)Socket()s arguments (were in opposite order).
 *
 * Revision 1.14  1993/06/11  19:12:29  too
 * Changed name of ioctl to IoctlSocket. Added prototype for Dup2Socket()
 *
 * Revision 1.13  1993/06/04  11:38:27  jraja
 * Fixes for the first release.
 *
 * Revision 1.12  1993/05/24  19:35:43  ppessi
 * syslog tagfunc added.
 *
 * Revision 1.11  1993/05/23  17:41:41  ppessi
 * Changed Perror() to PrintNetFault().
 *
 * Revision 1.10  1993/05/20  14:30:58  ppessi
 * Added a few netlib routines.
 *
 * Revision 1.9  1993/05/16  23:57:04  ppessi
 * Added some Netlib functions.
 *
 * Revision 1.8  1993/05/04  13:17:13  jraja
 * Added name to the first argument of recvfrom().
 *
 * Revision 1.7  93/05/04  12:56:56  12:56:56  jraja (Jarno Tapio Rajahalme)
 * Changed SetErrno() to SetErrnoPtr().
 * 
 * Revision 1.6  93/04/29  02:20:06  02:20:06  jraja (Jarno Tapio Rajahalme)
 * Added prototype for rresvport().
 * 
 * Revision 1.5  93/04/27  10:31:07  10:31:07  puhuri (Markus Peuhkuri)
 * Add proto for Syslog().
 * 
 * Revision 1.4  93/04/13  21:52:56  21:52:56  jraja (Jarno Tapio Rajahalme)
 * Removed inclusion of sys/socket.h (not needed).
 * Fixed type (unsigned LONG to ULONG).
 * 
 * Revision 1.3  93/04/06  18:02:58  18:02:58  ppessi (Pekka Pessi)
 * Fixed types. Added arpa/inet functions, netdb functions, async IO funcs.
 * 
 * Revision 1.2  93/04/06  15:25:08  15:25:08  ppessi (Pekka Pessi)
 * *** empty log message ***
 * 
 * Revision 1.1  93/03/22  01:07:40  01:07:40  ppessi (Pekka Pessi)
 * Initial revision
 * 
 */

#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif

#ifndef SYS_TYPES_H
#include <sys/types.h>
#endif

#ifndef SYS_TIME_H
#include <sys/time.h>
#endif

#ifndef SYS_SOCKET_H
#include <sys/socket.h>
#endif

#ifndef IN_H
#include <netinet/in.h>
#endif

#include <stdarg.h>

LONG socket(LONG domain, LONG type, LONG protocol);
LONG bind(LONG s, const struct sockaddr *name, LONG namelen);
LONG listen(LONG s, LONG backlog);
LONG accept(LONG s, struct sockaddr *addr, LONG *addrlen);
LONG connect(LONG s, const struct sockaddr *name, LONG namelen);
LONG sendto(LONG s, char *msg, LONG len, LONG flags, 
	    struct sockaddr *to, LONG tolen);
LONG send(LONG s, const char *msg, LONG len, LONG flags);
LONG recvfrom(LONG s, char *buf, LONG len, LONG flags, 
	      struct sockaddr *from, LONG *fromlen);
LONG recv(LONG s, char *buf, LONG len, LONG flags);
LONG shutdown(LONG s, LONG how);
LONG setsockopt(LONG s, LONG level, LONG optname, char *optval, LONG optlen);
LONG getsockopt(LONG s, LONG level, LONG optname, char *optval, LONG *optlen);
LONG getsockname(LONG s, struct sockaddr *name, LONG *namelen);
LONG getpeername(LONG s, struct sockaddr *name, LONG *namelen);

LONG IoctlSocket(LONG d, ULONG request, char *argp);
LONG CloseSocket(LONG d);
LONG WaitSelect(LONG nfds, fd_set *readfds, fd_set *writefds, fd_set *exeptfds, struct timeval *timeout, ULONG *maskp);

LONG Dup2Socket(LONG fd1, LONG fd2);

LONG SetDTableSize(LONG size);
void SetSocketSignals(ULONG SIGINTR, ULONG SIGIO, ULONG SIGURG);
LONG Errno(void);
void SetErrnoPtr(void *errno_p, LONG size);
LONG ObtainSocket(LONG id, LONG domain, LONG type, LONG protocol);
LONG ReleaseSocket(LONG fd, LONG id);
LONG ReleaseCopyOfSocket(LONG fd, LONG id);

/* Arpa/inet functions */
ULONG inet_addr(const char *);
ULONG inet_network(const char *);
char *Inet_NtoA(ULONG s_addr);
ULONG Inet_MakeAddr(int , int);
ULONG Inet_LnaOf(LONG s_addr);
ULONG Inet_NetOf(LONG s_addr);

/* NetDB functions */
struct hostent  *gethostbyname(const char *name);
struct hostent  *gethostbyaddr(const char *addr, LONG len, LONG type);
struct netent   *getnetbyname(const char *name);
struct netent   *getnetbyaddr(LONG net, LONG type);
struct servent  *getservbyname(const char *name, const char *proto);
struct servent  *getservbyport(LONG port, const char *proto);
struct protoent *getprotobyname(const char *name);
struct protoent *getprotobynumber(LONG proto);

/* Syslog functions */
void syslog(ULONG level, const STRPTR format, ...);
void Syslog(ULONG level, const STRPTR format, LONG *);

/* Netlib Functions */
int getopt(int argc, char **argv, char *opts);
void PrintNetFault(LONG code, const UBYTE *banner);
LONG select(LONG nfds, fd_set *readfds, fd_set *writefds, fd_set *exeptfds, struct timeval *timeout);
char *inet_ntoa(struct in_addr);
struct in_addr inet_makeaddr(int , int);
unsigned long inet_lnaof(struct in_addr);
unsigned long inet_netof(struct in_addr);
#endif /* !CLIB_SOCKET_PROTOS_H */

