Version 1.05

This commit is contained in:
Carsten Larsen
2018-11-24 22:39:18 +01:00
commit 5aae9c2cce
41 changed files with 8505 additions and 0 deletions

View File

@ -0,0 +1,114 @@
/*
* Copyright (c) 2015 Carsten Larsen
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef _SOCKET_AMITCP_H
#define _SOCKET_AMITCP_H
#define AMITCP_BASE_NAME SocketBase
#include "inline/amitcp.h"
#define socket Socket
#define bind Bind
#define listen Listen
#define accept Accept
#define connect Connect
#define send Send
#define sendto SendTo
#define sendmsg SendMsg
#define recv Recv
#define recvfrom RecvFrom
#define recvmsg RecvMsg
#define shutdown Shutdown
#define setsockopt SetSockOpt
#define getsockopt GetSockOpt
#define getsockname GetSockName
#define getpeername GetPeerName
#define inet_addr Inet_Addr
#define inet_network Inet_Network
#define inet_ntoa Inet_NtoA
#define gethostbyname GetHostByName
#define gethostbyaddr GetHostByAddr
#define getnetbyname GetNetByName
#define getnetbyaddr GetNetByAddr
#define getservbyname GetServByName
#define getservbyport GetServByPort
#define getprotobyname GetProtoByName
#define getprotobynumber GetProtoByNumber
#define getdtablesize GetDTableSize
#define gethostname GetHostName
#define gethostid GetHostId
#define vsyslog SyslogA
#define syslog Syslog
#define Accept TCP_Accept
#define Bind TCP_Bind
#define CloseSocket TCP_CloseSocket
#define Connect TCP_Connect
#define Dup2Socket TCP_Dup2Socket
#define Errno TCP_Errno
#define GetDTableSize TCP_GetDTableSize
#define GetHostByAddr TCP_GetHostByAddr
#define GetHostByName TCP_GetHostByName
#define GetHostId TCP_GetHostId
#define GetHostName TCP_GetHostName
#define GetNetByAddr TCP_GetNetByAddr
#define GetNetByName TCP_GetNetByName
#define GetPeerName TCP_GetPeerName
#define GetProtoByName TCP_GetProtoByName
#define GetProtoByNumber TCP_GetProtoByNumber
#define GetServByName TCP_GetServByName
#define GetServByPort TCP_GetServByPort
#define GetSockName TCP_GetSockName
#define GetSockOpt TCP_GetSockOpt
#define GetSocketEvents TCP_GetSocketEvents
#define Inet_Addr TCP_Inet_Addr
#define Inet_LnaOf TCP_Inet_LnaOf
#define Inet_MakeAddr TCP_Inet_MakeAddr
#define Inet_NetOf TCP_Inet_NetOf
#define Inet_Network TCP_Inet_Network
#define Inet_NtoA TCP_Inet_NtoA
#define IoctlSocket TCP_IoctlSocket
#define Listen TCP_Listen
#define ObtainSocket TCP_ObtainSocket
#define Recv TCP_Recv
#define RecvFrom TCP_RecvFrom
#define RecvMsg TCP_RecvMsg
#define ReleaseCopyOfSocket TCP_ReleaseCopyOfSocket
#define ReleaseSocket TCP_ReleaseSocket
#define Send TCP_Send
#define SendMsg TCP_SendMsg
#define SendTo TCP_SendTo
#define SetErrnoPtr TCP_SetErrnoPtr
#define SetSockOpt TCP_SetSockOpt
#define SetSocketSignals TCP_SetSocketSignals
#define ShutDown TCP_ShutDown
#define Socket TCP_Socket
#define SocketBaseTagList TCP_SocketBaseTagList
#define SocketBaseTags TCP_SocketBaseTags
#define SyslogA TCP_SyslogA
#define WaitSelect TCP_WaitSelect
#endif

203
include/inline/amitcp.h Normal file
View File

@ -0,0 +1,203 @@
/* Automatically generated header! Do not edit! */
#ifndef _INLINE_AMITCP_H
#define _INLINE_AMITCP_H
#ifndef __INLINE_MACROS_H
#include <inline/macros.h>
#endif
#ifndef AMITCP_BASE_NAME
#define AMITCP_BASE_NAME lss->lx_BsdSocketBase
#endif
#define TCP_Accept(s, addr, addrlen) \
LP3(0x30, LONG, TCP_Accept, LONG, s, d0, struct sockaddr *, addr, a0, int *, addrlen, a1, \
, AMITCP_BASE_NAME)
#define TCP_Bind(s, name, namelen) \
LP3(0x24, LONG, TCP_Bind, LONG, s, d0, const struct sockaddr *, name, a0, LONG, namelen, d1, \
, AMITCP_BASE_NAME)
#define TCP_CloseSocket(d) \
LP1(0x78, LONG, TCP_CloseSocket, LONG, d, d0, \
, AMITCP_BASE_NAME)
#define TCP_Connect(s, name, namelen) \
LP3(0x36, LONG, TCP_Connect, LONG, s, d0, const struct sockaddr *, name, a0, LONG, namelen, d1, \
, AMITCP_BASE_NAME)
#define TCP_Dup2Socket(fd1, fd2) \
LP2(0x108, LONG, TCP_Dup2Socket, LONG, fd1, d0, LONG, fd2, d1, \
, AMITCP_BASE_NAME)
#define TCP_Errno() \
LP0(0xa2, LONG, TCP_Errno, \
, AMITCP_BASE_NAME)
#define TCP_GetDTableSize() \
LP0(0x8a, LONG, TCP_GetDTableSize, \
, AMITCP_BASE_NAME)
#define TCP_GetHostByAddr(addr, len, type) \
LP3(0xd8, struct hostent *, TCP_GetHostByAddr, const UBYTE *, addr, a0, LONG, len, d0, LONG, type, d1, \
, AMITCP_BASE_NAME)
#define TCP_GetHostByName(name) \
LP1(0xd2, struct hostent *, TCP_GetHostByName, const UBYTE *, name, a0, \
, AMITCP_BASE_NAME)
#define TCP_GetHostId() \
LP0(0x120, ULONG, TCP_GetHostId, \
, AMITCP_BASE_NAME)
#define TCP_GetHostName(hostname, size) \
LP2(0x11a, LONG, TCP_GetHostName, STRPTR, hostname, a0, LONG, size, d0, \
, AMITCP_BASE_NAME)
#define TCP_GetNetByAddr(net, type) \
LP2(0xe4, struct netent *, TCP_GetNetByAddr, LONG, net, d0, LONG, type, d1, \
, AMITCP_BASE_NAME)
#define TCP_GetNetByName(name) \
LP1(0xde, struct netent *, TCP_GetNetByName, const UBYTE *, name, a0, \
, AMITCP_BASE_NAME)
#define TCP_GetPeerName(s, hostname, namelen) \
LP3(0x6c, LONG, TCP_GetPeerName, LONG, s, d0, struct sockaddr *, hostname, a0, int *, namelen, a1, \
, AMITCP_BASE_NAME)
#define TCP_GetProtoByName(name) \
LP1(0xf6, struct protoent *, TCP_GetProtoByName, const UBYTE *, name, a0, \
, AMITCP_BASE_NAME)
#define TCP_GetProtoByNumber(proto) \
LP1(0xfc, struct protoent *, TCP_GetProtoByNumber, LONG, proto, d0, \
, AMITCP_BASE_NAME)
#define TCP_GetServByName(name, proto) \
LP2(0xea, struct servent *, TCP_GetServByName, const UBYTE *, name, a0, const UBYTE *, proto, a1, \
, AMITCP_BASE_NAME)
#define TCP_GetServByPort(port, proto) \
LP2(0xf0, struct servent *, TCP_GetServByPort, LONG, port, d0, const UBYTE *, proto, a0, \
, AMITCP_BASE_NAME)
#define TCP_GetSockName(s, hostname, namelen) \
LP3(0x66, LONG, TCP_GetSockName, LONG, s, d0, struct sockaddr *, hostname, a0, int *, namelen, a1, \
, AMITCP_BASE_NAME)
#define TCP_GetSockOpt(s, level, optname, optval, optlen) \
LP5(0x60, LONG, TCP_GetSockOpt, LONG, s, d0, LONG, level, d1, LONG, optname, d2, void *, optval, a0, int *, optlen, a1, \
, AMITCP_BASE_NAME)
#define TCP_GetSocketEvents(eventmaskp) \
LP1(0x12c, LONG, TCP_GetSocketEvents, ULONG *, eventmaskp, a0, \
, AMITCP_BASE_NAME)
#define TCP_Inet_Addr(cp) \
LP1(0xb4, ULONG, TCP_Inet_Addr, const UBYTE *, cp, a0, \
, AMITCP_BASE_NAME)
#define TCP_Inet_LnaOf(in) \
LP1(0xba, ULONG, TCP_Inet_LnaOf, LONG, in, d0, \
, AMITCP_BASE_NAME)
#define TCP_Inet_MakeAddr(net, host) \
LP2(0xc6, ULONG, TCP_Inet_MakeAddr, ULONG, net, d0, ULONG, host, d1, \
, AMITCP_BASE_NAME)
#define TCP_Inet_NetOf(in) \
LP1(0xc0, ULONG, TCP_Inet_NetOf, LONG, in, d0, \
, AMITCP_BASE_NAME)
#define TCP_Inet_Network(cp) \
LP1(0xcc, ULONG, TCP_Inet_Network, const UBYTE *, cp, a0, \
, AMITCP_BASE_NAME)
#define TCP_Inet_NtoA(in) \
LP1(0xae, char *, TCP_Inet_NtoA, ULONG, in, d0, \
, AMITCP_BASE_NAME)
#define TCP_IoctlSocket(d, request, argp) \
LP3(0x72, LONG, TCP_IoctlSocket, LONG, d, d0, ULONG, request, d1, char *, argp, a0, \
, AMITCP_BASE_NAME)
#define TCP_Listen(s, backlog) \
LP2(0x2a, LONG, TCP_Listen, LONG, s, d0, LONG, backlog, d1, \
, AMITCP_BASE_NAME)
#define TCP_ObtainSocket(id, domain, type, protocol) \
LP4(0x90, LONG, TCP_ObtainSocket, LONG, id, d0, LONG, domain, d1, LONG, type, d2, LONG, protocol, d3, \
, AMITCP_BASE_NAME)
#define TCP_Recv(s, buf, len, flags) \
LP4(0x4e, LONG, TCP_Recv, LONG, s, d0, UBYTE *, buf, a0, LONG, len, d1, LONG, flags, d2, \
, AMITCP_BASE_NAME)
#define TCP_RecvFrom(s, buf, len, flags, from, fromlen) \
LP6(0x48, LONG, TCP_RecvFrom, LONG, s, d0, UBYTE *, buf, a0, LONG, len, d1, LONG, flags, d2, struct sockaddr *, from, a1, int *, fromlen, a2, \
, AMITCP_BASE_NAME)
#define TCP_RecvMsg(s, msg, flags) \
LP3(0x114, LONG, TCP_RecvMsg, LONG, s, d0, struct msghdr *, msg, a0, LONG, flags, d1, \
, AMITCP_BASE_NAME)
#define TCP_ReleaseCopyOfSocket(fd, id) \
LP2(0x9c, LONG, TCP_ReleaseCopyOfSocket, LONG, fd, d0, LONG, id, d1, \
, AMITCP_BASE_NAME)
#define TCP_ReleaseSocket(fd, id) \
LP2(0x96, LONG, TCP_ReleaseSocket, LONG, fd, d0, LONG, id, d1, \
, AMITCP_BASE_NAME)
#define TCP_Send(s, msg, len, flags) \
LP4(0x42, LONG, TCP_Send, LONG, s, d0, const UBYTE *, msg, a0, LONG, len, d1, LONG, flags, d2, \
, AMITCP_BASE_NAME)
#define TCP_SendMsg(s, msg, flags) \
LP3(0x10e, LONG, TCP_SendMsg, LONG, s, d0, const struct msghdr *, msg, a0, LONG, flags, d1, \
, AMITCP_BASE_NAME)
#define TCP_SendTo(s, msg, len, flags, to, tolen) \
LP6(0x3c, LONG, TCP_SendTo, LONG, s, d0, const UBYTE *, msg, a0, LONG, len, d1, LONG, flags, d2, const struct sockaddr *, to, a1, LONG, tolen, d3, \
, AMITCP_BASE_NAME)
#define TCP_SetErrnoPtr(errno_p, size) \
LP2(0xa8, LONG, TCP_SetErrnoPtr, void *, errno_p, a0, LONG, size, d0, \
, AMITCP_BASE_NAME)
#define TCP_SetSockOpt(s, level, optname, optval, optlen) \
LP5(0x5a, LONG, TCP_SetSockOpt, LONG, s, d0, LONG, level, d1, LONG, optname, d2, const void *, optval, a0, LONG, optlen, d3, \
, AMITCP_BASE_NAME)
#define TCP_SetSocketSignals(SIGINTR, SIGIO, SIGURG) \
LP3NR(0x84, TCP_SetSocketSignals, ULONG, SIGINTR, d0, ULONG, SIGIO, d1, ULONG, SIGURG, d2, \
, AMITCP_BASE_NAME)
#define TCP_ShutDown(s, how) \
LP2(0x54, LONG, TCP_ShutDown, LONG, s, d0, LONG, how, d1, \
, AMITCP_BASE_NAME)
#define TCP_Socket(domain, type, protocol) \
LP3(0x1e, LONG, TCP_Socket, LONG, domain, d0, LONG, type, d1, LONG, protocol, d2, \
, AMITCP_BASE_NAME)
#define TCP_SocketBaseTagList(taglist) \
LP1(0x126, LONG, TCP_SocketBaseTagList, struct TagItem *, taglist, a0, \
, AMITCP_BASE_NAME)
#ifndef NO_INLINE_STDARG
#define TCP_SocketBaseTags(tags...) \
({ULONG _tags[] = { tags }; TCP_SocketBaseTagList((struct TagItem *)_tags); })
#endif
#define TCP_SyslogA(level, format, ap) \
LP3NR(0x102, TCP_SyslogA, ULONG, level, d0, const char *, format, a0, va_list, ap, a1, \
, AMITCP_BASE_NAME)
#define TCP_WaitSelect(nfds, readfds, writefds, execptfds, timeout, maskp) \
LP6(0x7e, LONG, TCP_WaitSelect, LONG, nfds, d0, fd_set *, readfds, a0, fd_set *, writefds, a1, fd_set *, execptfds, a2, struct timeval *, timeout, a3, ULONG *, maskp, d1, \
, AMITCP_BASE_NAME)
#endif

231
include/netdb.h Normal file
View File

@ -0,0 +1,231 @@
/*
* $Id$
*
* :ts=8
*
* 'Roadshow' -- Amiga TCP/IP stack
* Copyright (c) 2001-2016 by Olaf Barthel.
* All Rights Reserved.
*
* Amiga specific TCP/IP 'C' header files;
* Freely Distributable
*/
/*
* ++Copyright++ 1980, 1983, 1988, 1993
* -
* Copyright (c) 1980, 1983, 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* -
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies, and that
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
* -
* --Copyright--
*/
/*
* @(#)netdb.h 8.1 (Berkeley) 6/2/93
* $NetBSD: netdb.h,v 1.8 1997/10/13 09:26:06 lukem Exp $
*/
#ifndef _NETDB_H
#define _NETDB_H
/****************************************************************************/
#ifndef _SYS_NETINCLUDE_TYPES_H
#include "sys/netinclude_types.h"
#endif /* _SYS_NETINCLUDE_TYPES_H */
#ifndef _SYS_ERRNO_H
#include "sys/errno.h"
#endif /* _SYS_ERRNO_H */
#ifndef _NETINET_IN_H
#include "netinet/in.h"
#endif /* _NETINET_IN_H */
/****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/****************************************************************************/
#ifdef __GNUC__
#ifdef __PPC__
#pragma pack(2)
#endif
#elif defined(__VBCC__)
#pragma amiga-align
#endif
/****************************************************************************/
/* This used to be in <sys/param.h> */
#define MAXHOSTNAMELEN 256 /* max hostname size */
/*
* Structures returned by network data base library. All addresses are
* supplied in host order, and returned in network order (suitable for
* use in system calls).
*/
struct hostent
{
__STRPTR h_name; /* official name of host */
__STRPTR * h_aliases; /* alias list */
__LONG h_addrtype; /* host address type */
__LONG h_length; /* length of address */
__BYTE ** h_addr_list; /* list of addresses from name server */
#define h_addr h_addr_list[0] /* address, for backward compatiblity */
};
/*
* Assumption here is that a network number
* fits in an unsigned long -- probably a poor one.
*/
struct netent
{
__STRPTR n_name; /* official name of net */
__STRPTR * n_aliases; /* alias list */
__LONG n_addrtype; /* net address type */
in_addr_t n_net; /* network # */
};
struct servent
{
__STRPTR s_name; /* official service name */
__STRPTR * s_aliases; /* alias list */
__LONG s_port; /* port # */
__STRPTR s_proto; /* protocol to use */
};
struct protoent
{
__STRPTR p_name; /* official protocol name */
__STRPTR * p_aliases; /* alias list */
__LONG p_proto; /* protocol # */
};
/*
* Error return codes from gethostbyname() and gethostbyaddr()
* (left in extern int h_errno).
*/
#define NETDB_INTERNAL -1 /* see errno */
#define NETDB_SUCCESS 0 /* no problem */
#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
#define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */
#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
#define NO_DATA 4 /* Valid name, no data record of requested type */
#define NO_ADDRESS NO_DATA /* no address, look for MX record */
/****************************************************************************/
/* Values for getaddrinfo() and getnameinfo() */
#define AI_PASSIVE 1 /* socket address is intended for bind() */
#define AI_CANONNAME 2 /* request for canonical name */
#define AI_NUMERICHOST 4 /* don't ever try hostname lookup */
#define AI_EXT 8 /* enable non-portable extensions */
#define AI_NUMERICSERV 16 /* don't ever try servname lookup */
/* valid flags for addrinfo */
#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV)
#define NI_NUMERICHOST 1 /* return the host address, not the name */
#define NI_NUMERICSERV 2 /* return the service address, not the name */
#define NI_NOFQDN 4 /* return a short name if in the local domain */
#define NI_NAMEREQD 8 /* fail if either host or service name is unknown */
#define NI_DGRAM 16 /* look up datagram service instead of stream */
#define NI_WITHSCOPEID 32 /* KAME hack: attach scopeid to host portion */
#define NI_MAXHOST MAXHOSTNAMELEN /* max host name returned by getnameinfo */
#define NI_MAXSERV 32 /* max serv. name length returned by getnameinfo */
#define EAI_BADFLAGS -1 /* invalid value for ai_flags */
#define EAI_NONAME -2 /* name or service is not known */
#define EAI_AGAIN -3 /* temporary failure in name resolution */
#define EAI_FAIL -4 /* non-recoverable failure in name resolution */
#define EAI_NODATA -5 /* no address associated with name */
#define EAI_FAMILY -6 /* ai_family not supported */
#define EAI_SOCKTYPE -7 /* ai_socktype not supported */
#define EAI_SERVICE -8 /* service not supported for ai_socktype */
#define EAI_ADDRFAMILY -9 /* address family for name not supported */
#define EAI_MEMORY -10 /* memory allocation failure */
#define EAI_SYSTEM -11 /* system error (code indicated in errno) */
#define EAI_BADHINTS -12 /* invalid value for hints */
#define EAI_PROTOCOL -13 /* resolved protocol is unknown */
struct addrinfo {
int ai_flags; /* input flags */
int ai_family; /* protocol family for socket */
int ai_socktype; /* socket type */
int ai_protocol; /* protocol for socket */
socklen_t ai_addrlen; /* length of socket-address */
struct sockaddr *ai_addr; /* socket-address for socket */
char *ai_canonname; /* canonical name for service location (iff req) */
struct addrinfo *ai_next; /* pointer to next in list */
};
/****************************************************************************/
#ifdef __GNUC__
#ifdef __PPC__
#pragma pack()
#endif
#elif defined(__VBCC__)
#pragma default-align
#endif
/****************************************************************************/
#ifdef __cplusplus
}
#endif /* __cplusplus */
/****************************************************************************/
#endif /* !_NETDB_H */

275
include/netinet/in.h Normal file
View File

@ -0,0 +1,275 @@
/*
* :ts=8
*
* 'Roadshow' -- Amiga TCP/IP stack
* Copyright (c) 2001-2016 by Olaf Barthel.
* All Rights Reserved.
*
* Amiga specific TCP/IP 'C' header files;
* Freely Distributable
*/
/*
* Copyright (c) 1982, 1986, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)in.h 8.3 (Berkeley) 1/3/94
*/
#ifndef _NETINET_IN_H
#define _NETINET_IN_H
/****************************************************************************/
#ifndef _SYS_NETINCLUDE_TYPES_H
#include "sys/netinclude_types.h"
#endif /* _SYS_NETINCLUDE_TYPES_H */
#ifndef _SYS_SOCKET_H
#include "sys/socket.h"
#endif /* _SYS_SOCKET_H */
/****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/****************************************************************************/
#ifdef __GNUC__
#ifdef __PPC__
#pragma pack(2)
#endif
#elif defined(__VBCC__)
#pragma amiga-align
#endif
/****************************************************************************/
/*
* Constants and structures defined by the internet system,
* Per RFC 790, September 1981, and numerous additions.
*/
/*
* Data types.
*/
typedef unsigned long in_addr_t;
typedef unsigned short in_port_t;
/*
* Protocols
*/
#define IPPROTO_IP 0 /* dummy for IP */
#define IPPROTO_ICMP 1 /* control message protocol */
#define IPPROTO_IGMP 2 /* group mgmt protocol */
#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
#define IPPROTO_TCP 6 /* tcp */
#define IPPROTO_EGP 8 /* exterior gateway protocol */
#define IPPROTO_PUP 12 /* pup */
#define IPPROTO_UDP 17 /* user datagram protocol */
#define IPPROTO_IDP 22 /* xns idp */
#define IPPROTO_TP 29 /* tp-4 w/ class negotiation */
#define IPPROTO_EON 80 /* ISO cnlp */
#define IPPROTO_ENCAP 98 /* encapsulation header */
#define IPPROTO_RAW 255 /* raw IP packet */
#define IPPROTO_MAX 256
/*
* Local port number conventions:
* Ports < IPPORT_RESERVED are reserved for
* privileged processes (e.g. root).
* Ports > IPPORT_USERRESERVED are reserved
* for servers, not necessarily privileged.
*/
#define IPPORT_RESERVED 1024
#define IPPORT_USERRESERVED 5000
/*
* Internet address (a structure for historical reasons)
*/
struct in_addr {
in_addr_t s_addr;
};
/*
* Definitions of bits in internet address integers.
* On subnets, the decomposition of addresses to host and net parts
* is done according to subnet mask, not the masks here.
*/
#define IN_CLASSA(i) (((__ULONG)(i) & 0x80000000) == 0)
#define IN_CLASSA_NET 0xff000000
#define IN_CLASSA_NSHIFT 24
#define IN_CLASSA_HOST 0x00ffffff
#define IN_CLASSA_MAX 128
#define IN_CLASSB(i) (((__ULONG)(i) & 0xc0000000) == 0x80000000)
#define IN_CLASSB_NET 0xffff0000
#define IN_CLASSB_NSHIFT 16
#define IN_CLASSB_HOST 0x0000ffff
#define IN_CLASSB_MAX 65536
#define IN_CLASSC(i) (((__ULONG)(i) & 0xe0000000) == 0xc0000000)
#define IN_CLASSC_NET 0xffffff00
#define IN_CLASSC_NSHIFT 8
#define IN_CLASSC_HOST 0x000000ff
#define IN_CLASSD(i) (((__ULONG)(i) & 0xf0000000) == 0xe0000000)
#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */
#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */
#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */
#define IN_MULTICAST(i) IN_CLASSD(i)
#define IN_EXPERIMENTAL(i) (((__ULONG)(i) & 0xf0000000) == 0xf0000000)
#define IN_BADCLASS(i) (((__ULONG)(i) & 0xf0000000) == 0xf0000000)
#define INADDR_ANY 0x00000000UL
#define INADDR_BROADCAST 0xffffffffUL /* must be masked */
#define INADDR_NONE 0xffffffff /* -1 return */
#define INADDR_UNSPEC_GROUP 0xe0000000UL /* 224.0.0.0 */
#define INADDR_ALLHOSTS_GROUP 0xe0000001UL /* 224.0.0.1 */
#define INADDR_MAX_LOCAL_GROUP 0xe00000ffUL /* 224.0.0.255 */
#define IN_LOOPBACKNET 127 /* official! */
/*
* Socket address, internet style.
*/
struct sockaddr_in {
__UBYTE sin_len;
sa_family_t sin_family;
in_port_t sin_port;
struct in_addr sin_addr;
__UBYTE sin_zero[8];
};
/*
* Structure used to describe IP options.
* Used to store options internally, to pass them to a process,
* or to restore options retrieved earlier.
* The ip_dst is used for the first-hop gateway when using a source route
* (this gets put into the header proper).
*/
struct ip_opts {
struct in_addr ip_dst; /* first hop, 0 w/o src rt */
__UBYTE ip_options[40]; /* actually variable in size */
};
/*
* Options for use with [gs]etsockopt at the IP level.
* First word of comment is data type; bool is stored in int.
*/
#define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */
#define IP_HDRINCL 2 /* __LONG; header is included with data */
#define IP_TOS 3 /* __LONG; IP type of service and preced. */
#define IP_TTL 4 /* __LONG; IP time to live */
#define IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */
#define IP_RECVRETOPTS 6 /* bool; receive IP opts for response */
#define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/dgram */
#define IP_RETOPTS 8 /* ip_opts; set/get IP options */
#define IP_MULTICAST_IF 9 /* __UBYTE; set/get IP multicast i/f */
#define IP_MULTICAST_TTL 10 /* __UBYTE; set/get IP multicast ttl */
#define IP_MULTICAST_LOOP 11 /* __UBYTE; set/get IP multicast loopback */
#define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */
#define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */
/*
* Defaults and limits for options
*/
#define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */
#define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
#define IP_MAX_MEMBERSHIPS 20 /* per socket; must fit in one mbuf */
/*
* Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
*/
struct ip_mreq {
struct in_addr imr_multiaddr; /* IP multicast address of group */
struct in_addr imr_interface; /* local IP address of interface */
};
/*
* Definitions for inet sysctl operations.
*
* Third level is protocol number.
* Fourth level is desired variable within that protocol.
*/
#define IPPROTO_MAXID (IPPROTO_IDP + 1) /* don't list to IPPROTO_MAX */
/*
* Names for IP sysctl objects
*/
#define IPCTL_FORWARDING 1 /* act as router */
#define IPCTL_SENDREDIRECTS 2 /* may send redirects when forwarding */
#define IPCTL_DEFTTL 3 /* default TTL */
#ifdef notyet
#define IPCTL_DEFMTU 4 /* default MTU */
#endif
#define IPCTL_MAXID 5
/****************************************************************************/
/*
* Macros for network/external number representation conversion.
*/
#define ntohl(x) (x)
#define ntohs(x) (x)
#define htonl(x) (x)
#define htons(x) (x)
#define NTOHL(x) (x)
#define NTOHS(x) (x)
#define HTONL(x) (x)
#define HTONS(x) (x)
/****************************************************************************/
#ifdef __GNUC__
#ifdef __PPC__
#pragma pack()
#endif
#elif defined(__VBCC__)
#pragma default-align
#endif
/****************************************************************************/
#ifdef __cplusplus
}
#endif /* __cplusplus */
/****************************************************************************/
#endif /* _NETINET_IN_H */

189
include/sys/errno.h Normal file
View File

@ -0,0 +1,189 @@
/*
* :ts=8
*
* 'Roadshow' -- Amiga TCP/IP stack
* Copyright (c) 2001-2016 by Olaf Barthel.
* All Rights Reserved.
*
* Amiga specific TCP/IP 'C' header files;
* Freely Distributable
*/
/*
* Copyright (c) 1982, 1986, 1989, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)errno.h 8.5 (Berkeley) 1/21/94
*/
#ifndef _SYS_ERRNO_H
#define _SYS_ERRNO_H
/****************************************************************************/
/* NOTE: the global 'extern int errno;' declaration below may conflict with
what your 'C' runtime library uses for its own 'errno' declaration.
While you should not need to #include this header file, and use
your 'C' runtime library version instead, it is sometimes not
possible to do without the error codes defined in this file. If
this is the case, define the preprocessor symbol __NO_NETINCLUDE_ERRNO
before you include this header file. */
/****************************************************************************/
#ifndef __NO_NETINCLUDE_ERRNO
extern int errno; /* global error number */
#endif /* __NO_NETINCLUDE_ERRNO */
/****************************************************************************/
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
#define EIO 5 /* Input/output error */
#define ENXIO 6 /* Device not configured */
#define E2BIG 7 /* Argument list too long */
#define ENOEXEC 8 /* Exec format error */
#define EBADF 9 /* Bad file descriptor */
#define ECHILD 10 /* No child processes */
#define EDEADLK 11 /* Resource deadlock avoided */
/* 11 was EAGAIN */
#define ENOMEM 12 /* Cannot allocate memory */
#define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */
#ifndef _POSIX_SOURCE
#define ENOTBLK 15 /* Block device required */
#endif
#define EBUSY 16 /* Device busy */
#define EEXIST 17 /* File exists */
#define EXDEV 18 /* Cross-device link */
#define ENODEV 19 /* Operation not supported by device */
#define ENOTDIR 20 /* Not a directory */
#define EISDIR 21 /* Is a directory */
#define EINVAL 22 /* Invalid argument */
#define ENFILE 23 /* Too many open files in system */
#define EMFILE 24 /* Too many open files */
#define ENOTTY 25 /* Inappropriate ioctl for device */
#ifndef _POSIX_SOURCE
#define ETXTBSY 26 /* Text file busy */
#endif
#define EFBIG 27 /* File too large */
#define ENOSPC 28 /* No space left on device */
#define ESPIPE 29 /* Illegal seek */
#define EROFS 30 /* Read-only file system */
#define EMLINK 31 /* Too many links */
#define EPIPE 32 /* Broken pipe */
/* math software */
#define EDOM 33 /* Numerical argument out of domain */
#define ERANGE 34 /* Result too large */
/* non-blocking and interrupt i/o */
#define EAGAIN 35 /* Resource temporarily unavailable */
#ifndef _POSIX_SOURCE
#define EWOULDBLOCK EAGAIN /* Operation would block */
#define EINPROGRESS 36 /* Operation now in progress */
#define EALREADY 37 /* Operation already in progress */
/* ipc/network software -- argument errors */
#define ENOTSOCK 38 /* Socket operation on non-socket */
#define EDESTADDRREQ 39 /* Destination address required */
#define EMSGSIZE 40 /* Message too long */
#define EPROTOTYPE 41 /* Protocol wrong type for socket */
#define ENOPROTOOPT 42 /* Protocol not available */
#define EPROTONOSUPPORT 43 /* Protocol not supported */
#define ESOCKTNOSUPPORT 44 /* Socket type not supported */
#define EOPNOTSUPP 45 /* Operation not supported */
#define EPFNOSUPPORT 46 /* Protocol family not supported */
#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */
#define EADDRINUSE 48 /* Address already in use */
#define EADDRNOTAVAIL 49 /* Can't assign requested address */
/* ipc/network software -- operational errors */
#define ENETDOWN 50 /* Network is down */
#define ENETUNREACH 51 /* Network is unreachable */
#define ENETRESET 52 /* Network dropped connection on reset */
#define ECONNABORTED 53 /* Software caused connection abort */
#define ECONNRESET 54 /* Connection reset by peer */
#define ENOBUFS 55 /* No buffer space available */
#define EISCONN 56 /* Socket is already connected */
#define ENOTCONN 57 /* Socket is not connected */
#define ESHUTDOWN 58 /* Can't send after socket shutdown */
#define ETOOMANYREFS 59 /* Too many references: can't splice */
#define ETIMEDOUT 60 /* Operation timed out */
#define ECONNREFUSED 61 /* Connection refused */
#define ELOOP 62 /* Too many levels of symbolic links */
#endif /* _POSIX_SOURCE */
#define ENAMETOOLONG 63 /* File name too long */
/* should be rearranged */
#ifndef _POSIX_SOURCE
#define EHOSTDOWN 64 /* Host is down */
#define EHOSTUNREACH 65 /* No route to host */
#endif /* _POSIX_SOURCE */
#define ENOTEMPTY 66 /* Directory not empty */
/* quotas & mush */
#ifndef _POSIX_SOURCE
#define EPROCLIM 67 /* Too many processes */
#define EUSERS 68 /* Too many users */
#define EDQUOT 69 /* Disc quota exceeded */
/* Network File System */
#define ESTALE 70 /* Stale NFS file handle */
#define EREMOTE 71 /* Too many levels of remote in path */
#define EBADRPC 72 /* RPC struct is bad */
#define ERPCMISMATCH 73 /* RPC version wrong */
#define EPROGUNAVAIL 74 /* RPC prog. not avail */
#define EPROGMISMATCH 75 /* Program version wrong */
#define EPROCUNAVAIL 76 /* Bad procedure for program */
#endif /* _POSIX_SOURCE */
#define ENOLCK 77 /* No locks available */
#define ENOSYS 78 /* Function not implemented */
#ifndef _POSIX_SOURCE
#define EFTYPE 79 /* Inappropriate file type or format */
#define EAUTH 80 /* Authentication error */
#define ENEEDAUTH 81 /* Need authenticator */
#define ELAST 81 /* Must be equal largest errno */
#endif /* _POSIX_SOURCE */
/****************************************************************************/
#endif /* _SYS_ERRNO_H */

View File

@ -0,0 +1,64 @@
/*
* :ts=8
*
* 'Roadshow' -- Amiga TCP/IP stack
* Copyright (c) 2001-2016 by Olaf Barthel.
* All Rights Reserved.
*
* Amiga specific TCP/IP 'C' header files;
* Freely Distributable
*/
#ifndef _SYS_NETINCLUDE_TYPES_H
#define _SYS_NETINCLUDE_TYPES_H
/****************************************************************************/
/* The type definitions below mirror those in <exec/types.h>, which may
clash with local type definitions. Hence, replacements are used which
are rather unlikely to cause similar conflicts. Note that the definition
of the __TEXT and __STRPTR types currently support only SAS/C and the
GNU 'C' compiler. */
/****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/****************************************************************************/
typedef long __LONG; /* signed 32-bit quantity */
typedef unsigned long __ULONG; /* unsigned 32-bit quantity */
typedef short __WORD; /* signed 16-bit quantity */
typedef unsigned short __UWORD; /* unsigned 16-bit quantity */
typedef signed char __BYTE; /* signed 8-bit quantity */
typedef unsigned char __UBYTE; /* unsigned 8-bit quantity */
/****************************************************************************/
typedef void * __APTR; /* 32-bit untyped pointer */
/****************************************************************************/
#if (defined(__GNUC__) && defined(__CHAR_UNSIGNED__)) || (defined(__SASC) && defined(_UNSCHAR))
typedef char * __STRPTR; /* string pointer (NULL terminated) */
#else
typedef unsigned char * __STRPTR; /* string pointer (NULL terminated) */
#endif
#if (defined(__GNUC__) && defined(__CHAR_UNSIGNED__)) || (defined(__SASC) && defined(_UNSCHAR))
typedef char __TEXT; /* Non-negative character */
#else
typedef unsigned char __TEXT; /* Non-negative character */
#endif
/****************************************************************************/
#ifdef __cplusplus
}
#endif
/****************************************************************************/
#endif /* !_SYS_NETINCLUDE_TYPES_H */

421
include/sys/socket.h Normal file
View File

@ -0,0 +1,421 @@
/*
* :ts=8
*
* 'Roadshow' -- Amiga TCP/IP stack
* Copyright (c) 2001-2016 by Olaf Barthel.
* All Rights Reserved.
*
* Amiga specific TCP/IP 'C' header files;
* Freely Distributable
*/
/*
* Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)socket.h 8.6 (Berkeley) 5/3/95
*/
#ifndef _SYS_SOCKET_H
#define _SYS_SOCKET_H
/****************************************************************************/
/* NOTE: the 'struct timeval' structure definition differs slightly between
the AmigaOS usage (as defined in <devices/timer.h>) and the POSIX
usage (as defined in <sys/time.h>. By default, this header file
will include <devices/timer.h> under the assumption that there
will be no problem as a result of that. However, if there are
compilation issues, you might want to define the 'struct timeval'
separately and disable the inclusion of <devices/timer.h>,
which can be achieved by defining the preprocessor symbol
__NO_NETINCLUDE_TIMEVAL before you include this header file. */
/****************************************************************************/
#ifndef _SYS_NETINCLUDE_TYPES_H
#include <sys/netinclude_types.h>
#endif /* _SYS_NETINCLUDE_TYPES_H */
/****************************************************************************/
/*
* We might reference memmove() and memset() below, which is why
* we need to make sure that both are declared somewhere.
*/
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
/****************************************************************************/
/* 'struct iovec', as used in a 'struct msghdr' is defined in <sys/uio.h>. */
#ifndef _SYS_UIO_H
#include <sys/uio.h>
#endif /* _SYS_UIO_H */
/****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/****************************************************************************/
#ifdef __GNUC__
#ifdef __PPC__
#pragma pack(2)
#endif
#elif defined(__VBCC__)
#pragma amiga-align
#endif
/****************************************************************************/
/*
* Definitions related to sockets: types, address families, options.
*/
/*
* Data types.
*/
typedef unsigned char sa_family_t;
typedef unsigned long socklen_t;
/*
* Types
*/
#define SOCK_STREAM 1 /* stream socket */
#define SOCK_DGRAM 2 /* datagram socket */
#define SOCK_RAW 3 /* raw-protocol interface */
#define SOCK_RDM 4 /* reliably-delivered message */
#define SOCK_SEQPACKET 5 /* sequenced packet stream */
/*
* Option flags per-socket.
*/
#define SO_DEBUG 0x0001 /* turn on debugging info recording */
#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
#define SO_REUSEADDR 0x0004 /* allow local address reuse */
#define SO_KEEPALIVE 0x0008 /* keep connections alive */
#define SO_DONTROUTE 0x0010 /* just use interface addresses */
#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
#define SO_LINGER 0x0080 /* linger on close if data present */
#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */
/*
* Additional options, not kept in so_options.
*/
#define SO_SNDBUF 0x1001 /* send buffer size */
#define SO_RCVBUF 0x1002 /* receive buffer size */
#define SO_SNDLOWAT 0x1003 /* send low-water mark */
#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
#define SO_SNDTIMEO 0x1005 /* send timeout */
#define SO_RCVTIMEO 0x1006 /* receive timeout */
#define SO_ERROR 0x1007 /* get error status and clear */
#define SO_TYPE 0x1008 /* get socket type */
/* This is a private option which is used exclusively
* by this Amiga TCP/IP stack implementation and should not
* be used by user code.
*/
#define SO_EVENTMASK 0x2001
/*
* Structure used for manipulating linger option.
*/
struct linger {
__LONG l_onoff; /* option on/off */
__LONG l_linger; /* linger time in seconds */
};
/*
* Level number for (get/set)sockopt() to apply to socket itself.
*/
#define SOL_SOCKET 0xffff /* options for socket level */
/*
* Address families.
*/
#define AF_UNSPEC 0 /* unspecified */
#define AF_LOCAL 1 /* local to host (pipes, portals) */
#define AF_UNIX AF_LOCAL /* backward compatibility */
#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
#define AF_IMPLINK 3 /* arpanet imp addresses */
#define AF_PUP 4 /* pup protocols: e.g. BSP */
#define AF_CHAOS 5 /* mit CHAOS protocols */
#define AF_NS 6 /* XEROX NS protocols */
#define AF_ISO 7 /* ISO protocols */
#define AF_OSI AF_ISO
#define AF_ECMA 8 /* european computer manufacturers */
#define AF_DATAKIT 9 /* datakit protocols */
#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
#define AF_SNA 11 /* IBM SNA */
#define AF_DECnet 12 /* DECnet */
#define AF_DLI 13 /* DEC Direct data link interface */
#define AF_LAT 14 /* LAT */
#define AF_HYLINK 15 /* NSC Hyperchannel */
#define AF_APPLETALK 16 /* Apple Talk */
#define AF_ROUTE 17 /* Internal Routing Protocol */
#define AF_LINK 18 /* Link layer interface */
#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
#define AF_COIP 20 /* connection-oriented IP, aka ST II */
#define AF_CNT 21 /* Computer Network Technology */
#define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */
#define AF_IPX 23 /* Novell Internet Protocol */
#define AF_SIP 24 /* Simple Internet Protocol */
#define pseudo_AF_PIP 25 /* Help Identify PIP packets */
#define AF_MAX 26
/*
* Structure used by kernel to store most
* addresses.
*/
struct sockaddr {
__UBYTE sa_len; /* total length */
sa_family_t sa_family; /* address family */
__UBYTE sa_data[14]; /* actually longer; address value */
};
/*
* Structure used by kernel to pass protocol
* information in raw sockets.
*/
struct sockproto {
__UWORD sp_family; /* address family */
__UWORD sp_protocol; /* protocol */
};
/*
* Protocol families, same as address families for now.
*/
#define PF_UNSPEC AF_UNSPEC
#define PF_LOCAL AF_LOCAL
#define PF_UNIX PF_LOCAL /* backward compatibility */
#define PF_INET AF_INET
#define PF_IMPLINK AF_IMPLINK
#define PF_PUP AF_PUP
#define PF_CHAOS AF_CHAOS
#define PF_NS AF_NS
#define PF_ISO AF_ISO
#define PF_OSI AF_ISO
#define PF_ECMA AF_ECMA
#define PF_DATAKIT AF_DATAKIT
#define PF_CCITT AF_CCITT
#define PF_SNA AF_SNA
#define PF_DECnet AF_DECnet
#define PF_DLI AF_DLI
#define PF_LAT AF_LAT
#define PF_HYLINK AF_HYLINK
#define PF_APPLETALK AF_APPLETALK
#define PF_ROUTE AF_ROUTE
#define PF_LINK AF_LINK
#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
#define PF_COIP AF_COIP
#define PF_CNT AF_CNT
#define PF_SIP AF_SIP
#define PF_IPX AF_IPX /* same format as AF_NS */
#define PF_RTIP pseudo_AF_FTIP /* same format as AF_INET */
#define PF_PIP pseudo_AF_PIP
#define PF_MAX AF_MAX
/*
* Definitions for network related sysctl, CTL_NET.
*
* Second level is protocol family.
* Third level is protocol number.
*
* Further levels are defined by the individual families below.
*/
#define NET_MAXID AF_MAX
/*
* PF_ROUTE - Routing table
*
* Three additional levels are defined:
* Fourth: address family, 0 is wildcard
* Fifth: type of info, defined below
* Sixth: flag(s) to mask with for NET_RT_FLAGS
*/
#define NET_RT_DUMP 1 /* dump; may limit to a.f. */
#define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */
#define NET_RT_IFLIST 3 /* survey interface list */
#define NET_RT_MAXID 4
/*
* Maximum queue length specifiable by listen.
*/
#define SOMAXCONN 5
/*
* Message header for recvmsg and sendmsg calls.
* Used value-result for recvmsg, value only for sendmsg.
*/
struct msghdr {
__APTR msg_name; /* optional address */
socklen_t msg_namelen; /* size of address */
struct iovec * msg_iov; /* scatter/gather array */
__ULONG msg_iovlen; /* # elements in msg_iov */
__APTR msg_control; /* ancillary data, see below */
socklen_t msg_controllen; /* ancillary data buffer len */
__LONG msg_flags; /* flags on received message */
};
#define MSG_OOB 0x1 /* process out-of-band data */
#define MSG_PEEK 0x2 /* peek at incoming message */
#define MSG_DONTROUTE 0x4 /* send without using routing tables */
#define MSG_EOR 0x8 /* data completes record */
#define MSG_TRUNC 0x10 /* data discarded before delivery */
#define MSG_CTRUNC 0x20 /* control data lost before delivery */
#define MSG_WAITALL 0x40 /* wait for full request or error */
#define MSG_DONTWAIT 0x80 /* this message should be nonblocking */
/*
* Header for ancillary data objects in msg_control buffer.
* Used for additional information with/about a datagram
* not expressible by flags. The format is a sequence
* of message elements headed by cmsghdr structures.
*/
struct cmsghdr {
socklen_t cmsg_len; /* data byte count, including hdr */
__LONG cmsg_level; /* originating protocol */
__LONG cmsg_type; /* protocol-specific type */
/* followed by __UBYTE cmsg_data[]; */
};
/* given pointer to struct cmsghdr, return pointer to data */
#define CMSG_DATA(cmsg) ((__UBYTE *)((cmsg) + 1))
/* given pointer to struct cmsghdr, return pointer to next cmsghdr */
#define CMSG_NXTHDR(mhdr, cmsg) \
(((__APTR)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
(mhdr)->msg_control + (mhdr)->msg_controllen) ? \
(struct cmsghdr *)NULL : \
(struct cmsghdr *)((__APTR)(cmsg) + ALIGN((cmsg)->cmsg_len)))
#define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control)
/* "Socket"-level control message types: */
#define SCM_RIGHTS 0x01 /* access rights (array of __LONG) */
/*
* The following comes from the original <sys/types.h> header file,
* which has been retired in favour of the <sys/netinclude_types.h>
* type definitions. What remains are the macros in support of the
* "select()" call and those for endian-neutral operations.
*/
/****************************************************************************/
/*
* In case the select() data structures and macros are already
* defined by somebody else...
*/
#ifndef FD_SET
#define NBBY 8 /* number of bits in a byte */
/*
* Select uses bit masks of file descriptors in longs. These macros
* manipulate such bit fields (the filesystem macros use chars).
* FD_SETSIZE may be defined by the user, but the default here should
* be enough for most uses.
*/
#ifndef FD_SETSIZE
#define FD_SETSIZE 256
#endif
typedef unsigned long fd_mask;
#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
#ifndef howmany
#define howmany(x, y) (((x) + ((y) - 1)) / (y))
#endif
typedef struct fd_set {
fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
} fd_set;
#define FD_SET(n, p) ((void)(((unsigned long)n) < FD_SETSIZE ? (p)->fds_bits[((unsigned long)n)/NFDBITS] |= (1 << (((unsigned long)n) % NFDBITS)) : 0))
#define FD_CLR(n, p) ((void)(((unsigned long)n) < FD_SETSIZE ? (p)->fds_bits[((unsigned long)n)/NFDBITS] &= ~(1 << (((unsigned long)n) % NFDBITS)) : 0))
#define FD_ISSET(n, p) (((unsigned long)n) < FD_SETSIZE && ((p)->fds_bits[((unsigned long)n)/NFDBITS] & (1 << (((unsigned long)n) % NFDBITS))))
#define FD_COPY(f, t) ((void)memmove((t), (f), sizeof(*(f))))
#define FD_ZERO(p) ((void)memset((p), 0, sizeof(*(p))))
#endif /* FD_SET */
/****************************************************************************/
#ifdef __GNUC__
#ifdef __PPC__
#pragma pack()
#endif
#elif defined(__VBCC__)
#pragma default-align
#endif
/****************************************************************************/
#ifdef __cplusplus
}
#endif /* __cplusplus */
/****************************************************************************/
#ifndef __NO_NETINCLUDE_TIMEVAL
/*
* This is for compatibility with POSIX-like 'timeval' structures
* which are remarkably similar to the Amiga 'timeval' except for
* the structure member names...
*/
#ifndef DEVICES_TIMER_H
#include <devices/timer.h>
#endif /* DEVICES_TIMER_H */
#ifndef tv_sec
#define tv_sec tv_secs
#endif /* tv_sec */
#ifndef tv_usec
#define tv_usec tv_micro
#endif /* tv_usec */
#endif /* __NO_NETINCLUDE_TIMEVAL */
/****************************************************************************/
#endif /* !_SYS_SOCKET_H_ */