23 #error "Please do not include this file directly, use pal.h instead" 46 #define PAL_NET_MAX_ADDR_SIZE 32 // check if we can make this more efficient 54 char interfaceName[16];
74 #if PAL_NET_TCP_AND_TLS_SUPPORT 76 PAL_SOCK_STREAM_SERVER = 99,
77 #endif //PAL_NET_TCP_AND_TLS_SUPPORT 84 #if PAL_NET_TCP_AND_TLS_SUPPORT // Socket options below supported only if TCP is supported. 85 PAL_SO_KEEPALIVE = 0x0008,
86 PAL_SO_KEEPIDLE = 0x0009,
87 PAL_SO_KEEPINTVL = 0x0010,
88 #endif //PAL_NET_TCP_AND_TLS_SUPPORT 93 #define PAL_NET_DEFAULT_INTERFACE 0xFFFFFFFF 95 #define PAL_IPV4_ADDRESS_SIZE 4 96 #define PAL_IPV6_ADDRESS_SIZE 16 241 #define PAL_NET_SOCKET_SELECT_MAX_SOCKETS 8 242 #define PAL_NET_SOCKET_SELECT_RX_BIT (1) 243 #define PAL_NET_SOCKET_SELECT_TX_BIT (2) 244 #define PAL_NET_SOCKET_SELECT_ERR_BIT (4) 246 #define PAL_NET_SELECT_IS_RX(socketStatus, index) ((socketStatus[index] & PAL_NET_SOCKET_SELECT_RX_BIT) != 0) 247 #define PAL_NET_SELECT_IS_TX(socketStatus, index) ((socketStatus[index] & PAL_NET_SOCKET_SELECT_TX_BIT) != 0) 248 #define PAL_NET_SELECT_IS_ERR(socketStatus, index) ((socketStatus[index] & PAL_NET_SOCKET_SELECT_ERR_BIT) != 0) 253 typedef void(*palAsyncSocketCallback_t)(void*); 255 #if PAL_NET_TCP_AND_TLS_SUPPORT // The functionality below is supported only if TCP is supported. 257 #if PAL_NET_SERVER_SOCKET_API 264 palStatus_t pal_listen(palSocket_t socket,
int backlog);
277 #endif // PAL_NET_SERVER_SOCKET_API 294 palStatus_t pal_recv(palSocket_t socket,
void* buf,
size_t len,
size_t* recievedDataSize);
303 palStatus_t pal_send(palSocket_t socket,
const void* buf,
size_t len,
size_t* sentDataSize);
306 #endif //PAL_NET_TCP_AND_TLS_SUPPORT 332 #if PAL_NET_DNS_SUPPORT 333 #if (PAL_DNS_API_VERSION == 0) || (PAL_DNS_API_VERSION == 1) 343 #if (PAL_DNS_API_VERSION == 1) 352 typedef void(*palGetAddressInfoAsyncCallback_t)(
const char* hostname,
palSocketAddress_t* address, palSocketLength_t* addressLength,
palStatus_t status,
void* callbackArgument);
364 palStatus_t pal_getAddressInfoAsync(
const char* hostname,
palSocketAddress_t* address, palSocketLength_t* addressLength, palGetAddressInfoAsyncCallback_t callback,
void* callbackArgument);
367 #elif (PAL_DNS_API_VERSION == 2) 368 typedef int32_t palDNSQuery_t;
376 typedef void(*palGetAddressInfoAsyncCallback_t)(
const char* hostname,
palSocketAddress_t* address,
palStatus_t status,
void* callbackArgument);
385 typedef struct pal_asyncAddressInfo
389 palGetAddressInfoAsyncCallback_t callback;
390 void* callbackArgument;
391 palDNSQuery_t *queryHandle;
392 } pal_asyncAddressInfo_t;
403 palStatus_t pal_getAddressInfoAsync(
const char* hostname,
405 palGetAddressInfoAsyncCallback_t callback,
406 void* callbackArgument,
407 palDNSQuery_t* queryHandle);
412 palStatus_t pal_cancelAddressInfoAsync(palDNSQuery_t queryHandle);
414 #error "Please specify the platform PAL_DNS_API_VERSION 0, 1, or 2." 415 #endif // PAL_DNS_API_VERSION 416 #endif // PAL_NET_DNS_SUPPORT 421 #endif //_PAL_SOCKET_H palStatus_t pal_getSockAddrPort(const palSocketAddress_t *address, uint16_t *port)
Get a port from an address data structure.
palStatus_t pal_sendTo(palSocket_t socket, const void *buffer, size_t length, const palSocketAddress_t *to, palSocketLength_t toLength, size_t *bytesSent)
Send a payload to an address using a specific socket.
palStatus_t pal_close(palSocket_t *socket)
Close a network socket.
palStatus_t pal_getSockAddrIPV6Addr(const palSocketAddress_t *address, palIpV6Addr_t ipV6Addr)
Get an IPv6 address from an address data structure.
Definition: pal_network.h:61
palStatus_t pal_registerNetworkInterface(void *networkInterfaceContext, uint32_t *interfaceIndex)
Register a network interface for use with PAL sockets.
struct palNetInterfaceInfo palNetInterfaceInfo_t
uint32_t palSocketLength_t
The length of data.
Definition: pal_network.h:43
palStatus_t pal_getNetInterfaceInfo(uint32_t interfaceNum, palNetInterfaceInfo_t *interfaceInfo)
Get information regarding the socket at the interface index number given. This number is returned whe...
uint8_t palIpV4Addr_t[PAL_IPV4_ADDRESS_SIZE]
Definition: pal_network.h:98
Datagram socket.
Definition: pal_network.h:78
palStatus_t pal_asynchronousSocketWithArgument(palSocketDomain_t domain, palSocketType_t type, bool nonBlockingSocket, uint32_t interfaceNum, palAsyncSocketCallback_t callback, void *callbackArgument, palSocket_t *socket)
Get an asynchronous network socket that passes the provided callbackArgument to a specified callback ...
palStatus_t pal_asynchronousSocket(palSocketDomain_t domain, palSocketType_t type, bool nonBlockingSocket, uint32_t interfaceNum, palAsyncSocketCallback_t callback, palSocket_t *socket)
Get an asynchronous network socket.
palSocketAddress_t address
Definition: pal_network.h:55
palStatus_t pal_isNonBlocking(palSocket_t socket, bool *isNonBlocking)
Check if a socket is non-blocking.
palStatus_t pal_setConnectionStatusCallback(uint32_t interfaceNum, connectionStatusCallback callback, void *client_arg)
Set listener for connection status events.
void * palSocket_t
PAL socket handle type.
Definition: pal_network.h:44
palStatus_t pal_setSocketOptions(palSocket_t socket, int optionName, const void *optionValue, palSocketLength_t optionLength)
Set the value for a socket option on a network socket.
palStatus_t pal_setSockAddrIPV6Addr(palSocketAddress_t *address, palIpV6Addr_t ipV6Addr)
Set an IPv6 address to an address data structure and set the addressType as IPv6. ...
IP version 6.
Definition: pal_network.h:63
unsigned short addressType
Address family for the socket.
Definition: pal_network.h:49
palSocketType_t
Socket types supported by PAL.
Definition: pal_network.h:73
Definition: pal_network.h:53
palNetworkStatus_t
Network status event.
Definition: pal_network.h:67
palStatus_t pal_setSockAddrPort(palSocketAddress_t *address, uint16_t port)
Set a port to an address data structure.
Receive timeout.
Definition: pal_network.h:90
palSocketOptionName_t
Socket options supported by PAL.
Definition: pal_network.h:82
struct palSocketAddress palSocketAddress_t
Address data structure with enough room to support IPV4 and IPV6.
Allow local address reuse.
Definition: pal_network.h:83
uint32_t addressSize
Definition: pal_network.h:56
palStatus_t pal_bind(palSocket_t socket, palSocketAddress_t *myAddress, palSocketLength_t addressLength)
Bind a socket to a local address.
uint8_t palIpV6Addr_t[PAL_IPV6_ADDRESS_SIZE]
Definition: pal_network.h:99
palStatus_t pal_getSockAddrIPV4Addr(const palSocketAddress_t *address, palIpV4Addr_t ipV4Addr)
Get an IPv4 address from an address data structure.
#define PAL_IPV4_ADDRESS_SIZE
Definition: pal_network.h:95
#define PAL_IPV6_ADDRESS_SIZE
Definition: pal_network.h:96
palStatus_t pal_setSockAddrIPV4Addr(palSocketAddress_t *address, palIpV4Addr_t ipV4Addr)
Set an IPv4 address to an address data structure and set addressType as IPv4.
Definition: pal_network.h:69
void(* connectionStatusCallback)(palNetworkStatus_t status, void *client_arg)
Definition: pal_network.h:101
palStatus_t pal_getNumberOfNetInterfaces(uint32_t *numInterfaces)
Get the number of current network interfaces.
void(* palAsyncSocketCallback_t)(void *)
The type of the callback function passed when creating asynchronous sockets.
Definition: pal_network.h:253
#define PAL_NET_MAX_ADDR_SIZE
Definition: pal_network.h:46
Send timeout.
Definition: pal_network.h:89
char addressData[PAL_NET_MAX_ADDR_SIZE]
Address based on the protocol used.
Definition: pal_network.h:50
int32_t palStatus_t
Definition: pal_types.h:49
Internet IP Protocol.
Definition: pal_network.h:62
palStatus_t pal_receiveFrom(palSocket_t socket, void *buffer, size_t length, palSocketAddress_t *from, palSocketLength_t *fromLength, size_t *bytesReceived)
Receive a payload from a specific socket.
palSocketDomain_t
Network domains supported by PAL.
Definition: pal_network.h:60
palStatus_t pal_unregisterNetworkInterface(uint32_t interfaceIndex)
Unregister a network interface.
Definition: pal_network.h:48
Definition: pal_network.h:68