PAL
A Platform Abstraction Layer connects the mbed-client with the underlying platform.
|
Macros | |
#define | PAL_SOCKET_OPTION_ERROR (-1) |
Typedefs | |
typedef void(* | palSelectCallbackFunction_t) () |
#define PAL_SOCKET_OPTION_ERROR (-1) |
typedef void(* palSelectCallbackFunction_t) () |
palStatus_t pal_plat_bind | ( | palSocket_t | socket, |
palSocketAddress_t * | myAddress, | ||
palSocketLength_t | addressLength | ||
) |
Bind a given socket to a local address.
[in] | socket | The socket to bind. |
[in] | myAddress | The address to bind to. |
[in] | addressLength | The length of the address passed in myAddress. |
palStatus_t pal_plat_close | ( | palSocket_t * | socket | ) |
Close a network socket. NOTE: recieves palSocket_t* and not palSocket_t so that it can zero the socket to avoid re-use.
[in,out] | socket | Release and zero socket pointed to by given pointer. |
palStatus_t pal_plat_getNetInterfaceInfo | ( | uint32_t | interfaceNum, |
palNetInterfaceInfo_t * | interfaceInfo | ||
) |
Get information regarding the socket at the index/interface number given (this number is returned when registering the socket).
[in] | interfaceNum | The number of the interface to get information for. |
[out] | interfaceInfo | The information for the given interface number. |
palStatus_t pal_plat_getNumberOfNetInterfaces | ( | uint32_t * | numInterfaces | ) |
Get the number of current network interfaces (interfaces that have been registered through).
[out] | numInterfaces | The number of interfaces after a successful call. |
palStatus_t pal_plat_getSocketOptions | ( | palSocket_t | socket, |
palSocketOptionName_t | optionName, | ||
void * | optionValue, | ||
palSocketLength_t * | optionLength | ||
) |
Get options for a given network socket. Only a few options are supported (see palSocketOptionName_t for supported options).
[in] | socket | The socket for which to get options. |
[in] | optionName | The name for which to set the option (see enum PAL_NET_SOCKET_OPTION for supported types). |
[out] | optionValue | The buffer holding the option value returned by the function. |
[in,out] | optionLength | The size of the buffer provided for optionValue when calling the function. After the call, it contains the length of data actually written to the optionValue buffer. |
palStatus_t pal_plat_receiveFrom | ( | palSocket_t | socket, |
void * | buffer, | ||
size_t | length, | ||
palSocketAddress_t * | from, | ||
palSocketLength_t * | fromLength, | ||
size_t * | bytesReceived | ||
) |
Receive a payload from the given socket.
[in] | socket | The socket to receive from [sockets passed to this function should be of type PAL_SOCK_DGRAM (the implementation may support other types as well)]. |
[out] | buffer | The buffer for the payload data. |
[in] | length | The length of the buffer for the payload data. |
[out] | from | The address that sent the payload [optional - if not required pass NULL]. |
[in,out] | fromLength | The length of the 'from' address. When completed, this contains the amount of data actually written to the from address [optional - if not required pass NULL]. |
[out] | bytesReceived | The actual amount of payload data received to the buffer. |
palStatus_t pal_plat_RegisterNetworkInterface | ( | void * | networkInterfaceContext, |
uint32_t * | interfaceIndex | ||
) |
Register a network interface for use with PAL sockets - must be called before other socket functions - most APIs will not work before a single interface is added.
[in] | networkInterfaceContext | The context of the network interface to be added (OS specific. In mbed OS, this is the NetworkInterface object pointer for the network adapter [note: we assume connect has already been called on this]). - if not available use NULL (may not be required on some OSs). |
[out] | interfaceIndex | Contains the index assigned to the interface in case it has been assigned successfully. This index can be used when creating a socket to bind the socket to the interface. |
palStatus_t pal_plat_sendTo | ( | palSocket_t | socket, |
const void * | buffer, | ||
size_t | length, | ||
const palSocketAddress_t * | to, | ||
palSocketLength_t | toLength, | ||
size_t * | bytesSent | ||
) |
Send a payload to the given address using the given socket.
[in] | socket | The socket to use for sending the payload [sockets passed to this function should be of type PAL_SOCK_DGRAM (the implementation may support other types as well)]. |
[in] | buffer | The buffer for the payload data. |
[in] | length | The length of the buffer for the payload data. |
[in] | to | The address to which the payload should be sent. |
[in] | toLength | The length of the 'to' address. |
[out] | bytesSent | The actual amount of payload data sent. |
palStatus_t pal_plat_setSocketOptions | ( | palSocket_t | socket, |
int | optionName, | ||
const void * | optionValue, | ||
palSocketLength_t | optionLength | ||
) |
Set options for a given network socket. Only a few options are supported (see palSocketOptionName_t for supported options).
[in] | socket | The socket for which to get options. |
[in] | optionName | The name for which to set the option (see enum PAL_NET_SOCKET_OPTION for supported types). |
[in] | optionValue | The buffer holding the option value to set for the given option. |
[in] | optionLength | The size of the buffer provided for optionValue. |
palStatus_t pal_plat_socket | ( | palSocketDomain_t | domain, |
palSocketType_t | type, | ||
bool | nonBlockingSocket, | ||
uint32_t | interfaceNum, | ||
palSocket_t * | socket | ||
) |
Get a network socket.
[in] | domain | The domain of the created socket (see palSocketDomain_t for supported types). |
[in] | type | The type of the created socket (see palSocketType_t for supported types). |
[in] | nonBlockingSocket | If true, the socket is non-blocking (with O_NONBLOCK set). |
[in] | interfaceNum | The number of the network interface used for this socket (info in interfaces supported via pal_getNumberOfNetInterfaces and pal_getNetInterfaceInfo ), choose PAL_NET_DEFAULT_INTERFACE for default interface. |
[out] | socket | The socket is returned through this output parameter. |
palStatus_t pal_plat_socketMiniSelect | ( | const palSocket_t | socketsToCheck[PAL_NET_SOCKET_SELECT_MAX_SOCKETS], |
uint32_t | numberOfSockets, | ||
pal_timeVal_t * | timeout, | ||
uint8_t | palSocketStatus[PAL_NET_SOCKET_SELECT_MAX_SOCKETS], | ||
uint32_t * | numberOfSocketsSet | ||
) |
Check if one or more (up to PAL_NET_SOCKET_SELECT_MAX_SOCKETS) sockets has data available for reading/writing/error. The function blocks until data is available for one of the given sockets or the timeout expires. To use the function, set the sockets you want to check in the socketsToCheck array and set a timeout. When it returns the socketStatus output inidcates the status of each socket passed in. Note: The entry in index x in the socketStatus array corresponds to the socket at index x in the sockets to check array.
[in] | socketsToCheck | The array of up to 8 socket handles to check. |
[in] | numberOfSockets | The number of sockets set in the input socketsToCheck array. |
[in] | timeout | The time until timeout if no socket activity is detected. |
[out] | palSocketStatus | Information on each socket in the input array indicating which event was set (none, rx, tx, err). Check for a desired event using macros. |
[out] | numberOfSocketsSet | The total number of sockets set in all three data sets (tx, rx, err) after a completed function. |
palStatus_t pal_plat_socketsInit | ( | void * | context | ) |
PAL network socket API PAL network sockets configurations options: define PAL_NET_TCP_AND_TLS_SUPPORT if TCP is supported by the platform and is required. define PAL_NET_ASYNCHRONOUS_SOCKET_API if asynchronous socket API is supported by the platform. Currently MANDATORY. define PAL_NET_DNS_SUPPORT if DNS name resolution is supported.
Initialize sockets - must be called before other socket functions (is called from PAL init).
[in] | context | Optional context - if not available/applicable use NULL. |
palStatus_t pal_plat_socketsTerminate | ( | void * | context | ) |
Initialize terminate - can be called when sockets are no longer needed to free socket resources allocated by init.
[in] | context | Optional context - if not available use NULL. |
void palSelectCallback0 | ( | ) |
void palSelectCallback1 | ( | ) |
void palSelectCallback2 | ( | ) |
void palSelectCallback3 | ( | ) |
void palSelectCallback4 | ( | ) |
void palSelectCallback5 | ( | ) |
void palSelectCallback6 | ( | ) |
void palSelectCallback7 | ( | ) |
palSelectCallbackFunction_t s_palSelectPalCallbackFunctions[PAL_NET_SOCKET_SELECT_MAX_SOCKETS] = { palSelectCallback0, palSelectCallback1, palSelectCallback2, palSelectCallback3, palSelectCallback4, palSelectCallback5, palSelectCallback6, palSelectCallback7 } |
uint32_t s_select_event_happened[PAL_NET_SOCKET_SELECT_MAX_SOCKETS] |