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_NETINET_SCTP_H 43 # include <netinet/sctp.h> 45 #ifdef OF_HAVE_SYS_UN_H 48 #ifdef OF_HAVE_AFUNIX_H 51 #ifdef OF_HAVE_NETIPX_IPX_H 52 # include <netipx/ipx.h> 54 #if defined(OF_HAVE_NETAT_APPLETALK_H) 55 # include <netat/appletalk.h> 56 #elif defined(OF_HAVE_NETATALK_AT_H) 57 # include <netatalk/at.h> 62 # include <ws2tcpip.h> 66 # ifdef OF_HAVE_APPLETALK 67 # include <atalkwsh.h> 81 OF_ASSUME_NONNULL_BEGIN
86 typedef int OFSocketHandle;
87 static const OFSocketHandle OFInvalidSocketHandle = -1;
89 typedef SOCKET OFSocketHandle;
90 static const OFSocketHandle OFInvalidSocketHandle = INVALID_SOCKET;
94 typedef short sa_family_t;
98 typedef u8 sa_family_t;
102 typedef long socklen_t;
103 typedef u_char sa_family_t;
104 typedef u_short in_port_t;
128 struct sockaddr_in6 {
129 sa_family_t sin6_family;
131 uint32_t sin6_flowinfo;
135 uint32_t sin6_scope_id;
139 #if !defined(OF_HAVE_UNIX_SOCKETS) && !defined(OF_MORPHOS) && !defined(OF_MINT) 141 sa_family_t sun_family;
147 # define IPX_NODE_LEN 6 149 #if !defined(OF_HAVE_IPX) 150 struct sockaddr_ipx {
151 sa_family_t sipx_family;
152 uint32_t sipx_network;
153 unsigned char sipx_node[IPX_NODE_LEN];
157 #elif defined(OF_WINDOWS) 158 # define IPX_NODE_LEN 6 159 # define sipx_family sa_family 160 # define sipx_network sa_netnum 161 # define sipx_node sa_nodenum 162 # define sipx_port sa_socket 163 #elif defined(OF_FREEBSD) 164 # define sipx_network sipx_addr.x_net.c_net 165 # define sipx_node sipx_addr.x_host.c_host 168 #ifndef OF_HAVE_APPLETALK 170 sa_family_t sat_family;
177 # define sat_port sat_socket 179 # define sat_net sat_addr.s_net 180 # define sat_node sat_addr.s_node 196 struct sockaddr_in in;
197 struct sockaddr_in6 in6;
198 struct sockaddr_un un;
199 struct sockaddr_ipx ipx;
200 struct sockaddr_at at;
201 #ifdef OF_HAVE_SOCKADDR_STORAGE 206 struct sockaddr_storage storage;
263 const unsigned char node[_Nonnull IPX_NODE_LEN], uint16_t port);
275 uint8_t node, uint8_t port);
367 const unsigned char node[_Nonnull IPX_NODE_LEN]);
376 unsigned char node[_Nonnull IPX_NODE_LEN]);
452 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:998
Definition: OFSocket.h:118
Definition: OFSocket.h:112
Definition: OFSocket.h:114
OFSocketAddress OFSocketAddressParseIP(OFString *IP, uint16_t port)
Parses the specified IP (either v4 or v6) and port into an OFSocketAddress.
Definition: OFSocket.m:568
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:614
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:582
uint16_t OFSocketAddressAppleTalkNetwork(const OFSocketAddress *address)
Returns the AppleTalk network of the specified OFSocketAddress.
Definition: OFSocket.m:1150
Definition: OFSocket.h:116
A struct which represents a host / port pair for a socket.
Definition: OFSocket.h:189
Definition: OFSocket.h:120
A class for handling strings.
Definition: OFString.h:142
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:638
void OFSocketAddressSetIPPort(OFSocketAddress *address, uint16_t port)
Sets the IP port of the specified OFSocketAddress.
Definition: OFSocket.m:1027
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:663
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:469
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:1055
Definition: OFSocket.h:124
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:110
OFString * OFSocketAddressString(const OFSocketAddress *address)
Converts the specified OFSocketAddress to a string.
Definition: OFSocket.m:979
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:1042
Definition: OFSocket.h:122
unsigned long OFSocketAddressHash(const OFSocketAddress *address)
Returns the hash for the specified OFSocketAddress.
Definition: OFSocket.m:770