20 #include "objfw-defs.h" 22 #ifndef OF_HAVE_SOCKETS 23 # error No sockets available! 29 #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) 33 #ifdef OF_HAVE_SYS_SOCKET_H 34 # include <sys/socket.h> 36 #ifdef OF_HAVE_NETINET_IN_H 37 # include <netinet/in.h> 39 #ifdef OF_HAVE_NETINET_TCP_H 40 # include <netinet/tcp.h> 42 #ifdef OF_HAVE_SYS_UN_H 45 #ifdef OF_HAVE_AFUNIX_H 48 #ifdef OF_HAVE_NETIPX_IPX_H 49 # include <netipx/ipx.h> 51 #if defined(OF_HAVE_NETAT_APPLETALK_H) 52 # include <netat/appletalk.h> 53 #elif defined(OF_HAVE_NETATALK_AT_H) 54 # include <netatalk/at.h> 59 # include <ws2tcpip.h> 63 # ifdef OF_HAVE_APPLETALK 64 # include <atalkwsh.h> 78 OF_ASSUME_NONNULL_BEGIN
83 typedef int OFSocketHandle;
84 static const OFSocketHandle OFInvalidSocketHandle = -1;
86 typedef SOCKET OFSocketHandle;
87 static const OFSocketHandle OFInvalidSocketHandle = INVALID_SOCKET;
91 typedef short sa_family_t;
95 typedef u8 sa_family_t;
99 typedef long socklen_t;
100 typedef u_char sa_family_t;
101 typedef u_short in_port_t;
125 struct sockaddr_in6 {
126 sa_family_t sin6_family;
128 uint32_t sin6_flowinfo;
132 uint32_t sin6_scope_id;
136 #if !defined(OF_HAVE_UNIX_SOCKETS) && !defined(OF_MORPHOS) && !defined(OF_MINT) 138 sa_family_t sun_family;
144 # define IPX_NODE_LEN 6 146 #if !defined(OF_HAVE_IPX) 147 struct sockaddr_ipx {
148 sa_family_t sipx_family;
149 uint32_t sipx_network;
150 unsigned char sipx_node[IPX_NODE_LEN];
154 #elif defined(OF_WINDOWS) 155 # define IPX_NODE_LEN 6 156 # define sipx_family sa_family 157 # define sipx_network sa_netnum 158 # define sipx_node sa_nodenum 159 # define sipx_port sa_socket 160 #elif defined(OF_FREEBSD) 161 # define sipx_network sipx_addr.x_net.c_net 162 # define sipx_node sipx_addr.x_host.c_host 165 #ifndef OF_HAVE_APPLETALK 167 sa_family_t sat_family;
174 # define sat_port sat_socket 176 # define sat_net sat_addr.s_net 177 # define sat_node sat_addr.s_node 193 struct sockaddr_in in;
194 struct sockaddr_in6 in6;
195 struct sockaddr_un un;
196 struct sockaddr_ipx ipx;
197 struct sockaddr_at at;
198 #ifdef OF_HAVE_SOCKADDR_STORAGE 203 struct sockaddr_storage storage;
260 const unsigned char node[_Nonnull IPX_NODE_LEN], uint16_t port);
272 uint8_t node, uint8_t port);
364 const unsigned char node[_Nonnull IPX_NODE_LEN]);
373 unsigned char node[_Nonnull IPX_NODE_LEN]);
446 extern bool _OFSocketInit(
void) OF_VISIBILITY_HIDDEN;
447 #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS) 448 extern void _OFSocketDeinit(
void) OF_VISIBILITY_HIDDEN;
450 extern int _OFSocketErrNo(
void) OF_VISIBILITY_HIDDEN;
451 #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) 452 extern int _OFGetSockName(OFSocketHandle sock,
struct sockaddr *restrict addr,
453 socklen_t *restrict addrLen) OF_VISIBILITY_HIDDEN;
456 #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS) 457 extern OFTLSKey _OFSocketBaseKey OF_VISIBILITY_HIDDEN;
459 extern OFTLSKey _OFSocketInterfaceKey OF_VISIBILITY_HIDDEN;
466 OF_ASSUME_NONNULL_END
void OFSocketAddressSetIPXPort(OFSocketAddress *address, uint16_t port)
Sets the IPX port of the specified OFSocketAddress.
Definition: OFSocket.m:1119
void OFSocketAddressSetAppleTalkNode(OFSocketAddress *address, uint8_t node)
Sets the AppleTalk node of the specified OFSocketAddress.
Definition: OFSocket.m:1163
OFString * OFSocketAddressDescription(const OFSocketAddress *address)
Returns a description for the specified OFSocketAddress.
Definition: OFSocket.m:999
Definition: OFSocket.h:115
Definition: OFSocket.h:109
Definition: OFSocket.h:111
OFSocketAddress OFSocketAddressParseIP(OFString *IP, uint16_t port)
Parses the specified IP (either v4 or v6) and port into an OFSocketAddress.
Definition: OFSocket.m:569
OFSocketAddress OFSocketAddressMakeIPX(uint32_t network, const unsigned char node[IPX_NODE_LEN], uint16_t port)
Creates an IPX address for the specified network, node and port.
Definition: OFSocket.m:615
void OFSocketAddressSetIPXNetwork(OFSocketAddress *address, uint32_t network)
Sets the IPX network of the specified OFSocketAddress.
Definition: OFSocket.m:1075
OFSocketAddress OFSocketAddressMakeUNIX(OFString *path)
Creates a UNIX socket address from the specified path.
Definition: OFSocket.m:583
uint16_t OFSocketAddressAppleTalkNetwork(const OFSocketAddress *address)
Returns the AppleTalk network of the specified OFSocketAddress.
Definition: OFSocket.m:1150
Definition: OFSocket.h:113
A struct which represents a host / port pair for a socket.
Definition: OFSocket.h:186
Definition: OFSocket.h:117
A class for handling strings.
Definition: OFString.h:138
uint8_t OFSocketAddressAppleTalkPort(const OFSocketAddress *address)
Returns the AppleTalk port of the specified OFSocketAddress.
Definition: OFSocket.m:1190
OFSocketAddress OFSocketAddressMakeAppleTalk(uint16_t network, uint8_t node, uint8_t port)
Creates an AppleTalk address for the specified network, node and port.
Definition: OFSocket.m:639
void OFSocketAddressSetIPPort(OFSocketAddress *address, uint16_t port)
Sets the IP port of the specified OFSocketAddress.
Definition: OFSocket.m:1028
void OFSocketAddressSetAppleTalkNetwork(OFSocketAddress *address, uint16_t network)
Sets the AppleTalk network of the specified OFSocketAddress.
Definition: OFSocket.m:1137
void OFSocketAddressSetIPXNode(OFSocketAddress *address, const unsigned char node[IPX_NODE_LEN])
Sets the IPX node of the specified OFSocketAddress.
Definition: OFSocket.m:1099
bool OFSocketAddressEqual(const OFSocketAddress *address1, const OFSocketAddress *address2)
Compares two OFSocketAddress for equality.
Definition: OFSocket.m:664
void OFSocketAddressSetAppleTalkPort(OFSocketAddress *address, uint8_t port)
Sets the AppleTalk port of the specified OFSocketAddress.
Definition: OFSocket.m:1181
OFSocketAddress OFSocketAddressParseIPv6(OFString *IP, uint16_t port)
Parses the specified IPv6 and port into an OFSocketAddress.
Definition: OFSocket.m:470
OFSocketAddress OFSocketAddressParseIPv4(OFString *IP, uint16_t port)
Parses the specified IPv4 and port into an OFSocketAddress.
Definition: OFSocket.m:368
uint16_t OFSocketAddressIPXPort(const OFSocketAddress *address)
Returns the IPX port of the specified OFSocketAddress.
Definition: OFSocket.m:1128
OFString * OFSocketAddressUNIXPath(const OFSocketAddress *address)
Gets the UNIX socket path of the specified OFSocketAddress.
Definition: OFSocket.m:1056
Definition: OFSocket.h:121
uint8_t OFSocketAddressAppleTalkNode(const OFSocketAddress *address)
Gets the AppleTalk node of the specified OFSocketAddress.
Definition: OFSocket.m:1172
uint32_t OFSocketAddressIPXNetwork(const OFSocketAddress *address)
Returns the IPX network of the specified OFSocketAddress.
Definition: OFSocket.m:1086
OFSocketAddressFamily
A socket address family.
Definition: OFSocket.h:107
OFString * OFSocketAddressString(const OFSocketAddress *address)
Converts the specified OFSocketAddress to a string.
Definition: OFSocket.m:980
void OFSocketAddressGetIPXNode(const OFSocketAddress *address, unsigned char node[IPX_NODE_LEN])
Gets the IPX node of the specified OFSocketAddress.
Definition: OFSocket.m:1109
uint16_t OFSocketAddressIPPort(const OFSocketAddress *address)
Returns the IP port of the specified OFSocketAddress.
Definition: OFSocket.m:1043
Definition: OFSocket.h:119
unsigned long OFSocketAddressHash(const OFSocketAddress *address)
Returns the hash for the specified OFSocketAddress.
Definition: OFSocket.m:771