/*- * Copyright (c) 2017-2021 Carsten Sonne 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 NET_H_INCLUDED #define NET_H_INCLUDED #ifndef ENOTSOCK #define ENOTSOCK 38 #endif #ifndef EDESTADDRREQ #define EDESTADDRREQ 39 #endif #ifndef EMSGSIZE #define EMSGSIZE 40 #endif #ifndef EPROTOTYPE #define EPROTOTYPE 41 #endif #ifndef ENOPROTOOPT #define ENOPROTOOPT 42 #endif #ifndef EPROTONOSUPPORT #define EPROTONOSUPPORT 43 #endif #ifndef ESOCKTNOSUPPORT #define ESOCKTNOSUPPORT 44 #endif #ifndef EOPNOTSUPP #define EOPNOTSUPP 45 #endif #ifndef EPFNOSUPPORT #define EPFNOSUPPORT 46 #endif #ifndef EAFNOSUPPORT #define EAFNOSUPPORT 47 #endif #ifndef EADDRINUSE #define EADDRINUSE 48 #endif #ifndef EADDRNOTAVAIL #define EADDRNOTAVAIL 49 #endif #ifndef ENETDOWN #define ENETDOWN 50 #endif #ifndef ENETUNREACH #define ENETUNREACH 51 #endif #ifndef ENETRESET #define ENETRESET 52 #endif #ifndef ECONNABORTED #define ECONNABORTED 53 #endif #ifndef ECONNRESET #define ECONNRESET 54 #endif #ifndef ENOBUFS #define ENOBUFS 55 #endif #ifndef EISCONN #define EISCONN 56 #endif #ifndef ENOTCONN #define ENOTCONN 57 #endif #ifndef ESHUTDOWN #define ESHUTDOWN 58 #endif #ifndef ETOOMANYREFS #define ETOOMANYREFS 59 #endif #ifndef ETIMEDOUT #define ETIMEDOUT 60 #endif #ifndef ECONNREFUSED #define ECONNREFUSED 61 #endif #ifndef EHOSTDOWN #define EHOSTDOWN 64 #endif #ifndef EHOSTUNREACH #define EHOSTUNREACH 65 #endif int OpenSocketLibrary(void); void CloseSocketLibrary(void); const char *GetErrorText(void); const char *GetHostErrorText(void); int GetErrorNo(void); int GetHostErrorNo(void); extern struct Library *SocketBase; /*TODO: Use Roadshow getaddrinfo() if available #define getaddrinfo_roadshow(hostname, servname, hints, res) ({ \ CONST_STRPTR _getaddrinfo_hostname = (hostname); \ CONST_STRPTR _getaddrinfo_servname = (servname); \ const struct addrinfo * _getaddrinfo_hints = (hints); \ struct addrinfo ** _getaddrinfo_res = (res); \ LONG _getaddrinfo__re = \ ({ \ register struct Library * const __getaddrinfo__bn __asm("a6") = (struct Library *) (BSDSOCKET_BASE_NAME); register int _d1 __asm("d1"); register int _a0 __asm("a0"); register int _a1 __asm("a1");\ register LONG __getaddrinfo__re __asm("d0"); \ register CONST_STRPTR __getaddrinfo_hostname __asm("a0") = (_getaddrinfo_hostname); \ register CONST_STRPTR __getaddrinfo_servname __asm("a1") = (_getaddrinfo_servname); \ register const struct addrinfo * __getaddrinfo_hints __asm("a2") = (_getaddrinfo_hints); \ register struct addrinfo ** __getaddrinfo_res __asm("a3") = (_getaddrinfo_res); \ __asm volatile ("jsr a6@(-810:W)" \ : "=r" (_d1), "=r" (_a0), "=r" (_a1), "=r"(__getaddrinfo__re) \ : "r"(__getaddrinfo__bn), "r"(__getaddrinfo_hostname), "r"(__getaddrinfo_servname), "r"(__getaddrinfo_hints), "r"(__getaddrinfo_res) \ : "fp0", "fp1", "cc", "memory"); \ __getaddrinfo__re; \ }); \ _getaddrinfo__re; \ }) */ #endif