Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FXAS21002 FXOS8700Q
pal_plat_network.h File Reference
PAL network - platform. This file contains the network APIs that need to be implemented in the platform layer. More...
Go to the source code of this file.
Functions | |
palStatus_t | pal_plat_socketsInit (void *context) |
Initialize sockets. | |
palStatus_t | pal_plat_registerNetworkInterface (void *networkInterfaceContext, uint32_t *interfaceIndex) |
Register a network interface for use with PAL sockets. | |
palStatus_t | pal_plat_unregisterNetworkInterface (uint32_t interfaceIndex) |
palStatus_t | pal_plat_socketsTerminate (void *context) |
Socket termination. | |
palStatus_t | pal_plat_socket (palSocketDomain_t domain, palSocketType_t type, bool nonBlockingSocket, uint32_t interfaceNum, palSocket_t *socket) |
Get a network socket. | |
palStatus_t | pal_plat_setSocketOptions (palSocket_t socket, int optionName, const void *optionValue, palSocketLength_t optionLength) |
Set options for a network socket. | |
palStatus_t | pal_plat_isNonBlocking (palSocket_t socket, bool *isNonBlocking) |
Check if a socket is non-blocking. | |
palStatus_t | pal_plat_bind (palSocket_t socket, palSocketAddress_t *myAddress, palSocketLength_t addressLength) |
Bind a socket to a local address. | |
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 a socket. | |
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 an address using a specific socket. | |
palStatus_t | pal_plat_close (palSocket_t *socket) |
Close a network socket. | |
palStatus_t | pal_plat_getNumberOfNetInterfaces (uint32_t *numInterfaces) |
Get the number of current network interfaces. | |
palStatus_t | pal_plat_getNetInterfaceInfo (uint32_t interfaceNum, palNetInterfaceInfo_t *interfaceInfo) |
Get information regarding a socket at a specific interface number. | |
palStatus_t | pal_plat_listen (palSocket_t socket, int backlog) |
Use a socket to listen to incoming connections. | |
palStatus_t | pal_plat_accept (palSocket_t socket, palSocketAddress_t *address, palSocketLength_t *addressLen, palSocket_t *acceptedSocket) |
Accept a connection on a socket. | |
palStatus_t | pal_plat_connect (palSocket_t socket, const palSocketAddress_t *address, palSocketLength_t addressLen) |
Open a connection from a socket to a specific address. | |
palStatus_t | pal_plat_recv (palSocket_t socket, void *buf, size_t len, size_t *recievedDataSize) |
Receive data from a connected socket. | |
palStatus_t | pal_plat_send (palSocket_t socket, const void *buf, size_t len, size_t *sentDataSize) |
Send a buffer via a specific connected socket. | |
palStatus_t | pal_plat_asynchronousSocket (palSocketDomain_t domain, palSocketType_t type, bool nonBlockingSocket, uint32_t interfaceNum, palAsyncSocketCallback_t callback, void *callbackArgument, palSocket_t *socket) |
Get an asynchronous network socket. | |
palStatus_t | pal_plat_getAddressInfo (const char *url, palSocketAddress_t *address, palSocketLength_t *addressLength) |
This function translates a URL to a `palSocketAddress_t` that can be used with PAL sockets. | |
palStatus_t | pal_plat_getAddressInfoAsync (pal_asyncAddressInfo_t *info) |
This function translates a URL to a `palSocketAddress_t` that can be used with PAL sockets. | |
palStatus_t | pal_plat_cancelAddressInfoAsync (palDNSQuery_t queryHandle) |
This function is cancelation for `pal_plat_getAddressInfoAsync()`. |
Detailed Description
PAL network - platform. This file contains the network APIs that need to be implemented in the platform layer.
**PAL network socket API** /n PAL network socket configuration 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.
Definition in file pal_plat_network.h.
Function Documentation
palStatus_t pal_plat_accept | ( | palSocket_t | socket, |
palSocketAddress_t * | address, | ||
palSocketLength_t * | addressLen, | ||
palSocket_t * | acceptedSocket | ||
) |
Accept a connection on a socket.
- Parameters:
-
[in] socket The socket on which to accept the connection. The socket needs to be created and bound, and `pal_plat_listen` must have been called on it. The socket passed to this function should be of type `PAL_SOCK_STREAM_SERVER`, unless your specific implementation supports other types as well. [out] address The source address of the incoming connection. [in,out] addressLen The length of the address field on input, the length of the data returned on output. [out] acceptedSocket The socket of the accepted connection is returned if the connection is accepted successfully.
- Returns:
- PAL_SUCCESS (0) in case of success, a specific negative error code in case of failure.
Definition at line 707 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
palStatus_t pal_plat_asynchronousSocket | ( | palSocketDomain_t | domain, |
palSocketType_t | type, | ||
bool | nonBlockingSocket, | ||
uint32_t | interfaceNum, | ||
palAsyncSocketCallback_t | callback, | ||
void * | callbackArgument, | ||
palSocket_t * | socket | ||
) |
Get an asynchronous network socket.
- Parameters:
-
[in] domain The domain of the created socket. See enum `palSocketDomain_t` for supported types. [in] type The type of the created socket. See enum `palSocketType_t` for supported types. [in] callback A callback function that is called when any supported event takes place in the given asynchronous socket. [in] callbackArgument the argument with which the specified callback will be called when any supported event takes place in the given asynchronous socket. [out] socket This output parameter returns the socket.
- Returns:
- PAL_SUCCESS (0) in case of success, a specific negative error code in case of failure.
Definition at line 932 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
palStatus_t pal_plat_bind | ( | palSocket_t | socket, |
palSocketAddress_t * | myAddress, | ||
palSocketLength_t | addressLength | ||
) |
Bind a socket to a local address.
- Parameters:
-
[in] socket The socket to bind. [in] myAddress The address to bind to. [in] addressLength The length of the address passed in `myAddress`.
- Returns:
- PAL_SUCCESS (0) in case of success. A specific negative error code in case of failure.
Definition at line 381 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
palStatus_t pal_plat_cancelAddressInfoAsync | ( | palDNSQuery_t | queryHandle ) |
This function is cancelation for `pal_plat_getAddressInfoAsync()`.
- Parameters:
-
[in] queryHandle ID of ongoing DNS query.
Definition at line 1140 of file pal_plat_network.cpp.
palStatus_t pal_plat_close | ( | palSocket_t * | socket ) |
Close a network socket.
- Note:
- The function recieves `palSocket_t*` and not `palSocket_t` so that it can zero the socket to avoid re-use.
- Parameters:
-
[in,out] socket Pointer to the socket to release and zero.
- Returns:
- PAL_SUCCESS (0) in case of success. A specific negative error code in case of failure.
Definition at line 563 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
palStatus_t pal_plat_connect | ( | palSocket_t | socket, |
const palSocketAddress_t * | address, | ||
palSocketLength_t | addressLen | ||
) |
Open a connection from a socket to a specific address.
- Parameters:
-
[in] socket The socket to use for the connection to the given address. The socket passed to this function should be of type `PAL_SOCK_STREAM`, unless your specific implementation supports other types as well. [in] address The destination address of the connection. [in] addressLen The length of the address field.
- Returns:
- PAL_SUCCESS (0) in case of success, a specific negative error code in case of failure.
Definition at line 776 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
palStatus_t pal_plat_getAddressInfo | ( | const char * | url, |
palSocketAddress_t * | address, | ||
palSocketLength_t * | addressLength | ||
) |
This function translates a URL to a `palSocketAddress_t` that can be used with PAL sockets.
- Parameters:
-
[in] url The URL to be translated to a `palSocketAddress_t`. [out] address The address for the output of the translation. [out] addressLength The length of the output address.
Definition at line 1002 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
palStatus_t pal_plat_getAddressInfoAsync | ( | pal_asyncAddressInfo_t * | info ) |
This function translates a URL to a `palSocketAddress_t` that can be used with PAL sockets.
- Parameters:
-
[in] info address of `pal_asyncAddressInfo_t`.
Definition at line 1104 of file pal_plat_network.cpp.
palStatus_t pal_plat_getNetInterfaceInfo | ( | uint32_t | interfaceNum, |
palNetInterfaceInfo_t * | interfaceInfo | ||
) |
Get information regarding a socket at a specific interface number.
- Parameters:
-
[in] interfaceNum The number of the interface to get information from. [out] interfaceInfo The information for the given interface number.
- Returns:
- PAL_SUCCESS (0) in case of success. A specific negative error code in case of failure.
Definition at line 615 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
palStatus_t pal_plat_getNumberOfNetInterfaces | ( | uint32_t * | numInterfaces ) |
Get the number of current network interfaces.
The function counts interfaces that have been successfully registered.
- Parameters:
-
[out] numInterfaces The number of interfaces after a successful call.
- Returns:
- PAL_SUCCESS (0) in case of success. A specific negative error code in case of failure.
Definition at line 609 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
palStatus_t pal_plat_isNonBlocking | ( | palSocket_t | socket, |
bool * | isNonBlocking | ||
) |
Check if a socket is non-blocking.
- Parameters:
-
[in] socket The socket for which to check non-blocking status. [out] isNonBlocking The non-blocking status for the socket. Is `true` if non-blocking, otherwise `false`.
- Returns:
- PAL_SUCCESS (0) in case of success. A specific negative error code in case of failure.
Definition at line 359 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
palStatus_t pal_plat_listen | ( | palSocket_t | socket, |
int | backlog | ||
) |
Use a socket to listen to incoming connections.
You may also limit the queue of incoming connections.
- Parameters:
-
[in] socket The socket to listen to. The docket passed to this function should be of type `PAL_SOCK_STREAM_SERVER`, unless your specific implementation supports other types as well. [in] backlog The number of pending connections that can be saved for the socket.
- Returns:
- PAL_SUCCESS (0) in case of success. A specific negative error code in case of failure.
Definition at line 689 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
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 a socket.
- Parameters:
-
[in] socket The socket to receive from. The socket passed to this function should be of type `PAL_SOCK_DGRAM`, unless your specific implementation supports other types as well. [out] buffer The buffer for the payload data. [in] length The length of the buffer for the payload data in bytes. [out] from The address that sent the payload. This value is optional, pass NULL when not used. [in,out] fromLength The length of the `from` address. When completed, this contains the amount of data actually written to the `from` address. This value is optional, pass NULL when not used. [out] bytesReceived The actual amount of payload data received in the buffer.
- Returns:
- PAL_SUCCESS (0) in case of success. A specific negative error code in case of failure.
Definition at line 414 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
palStatus_t pal_plat_recv | ( | palSocket_t | socket, |
void * | buf, | ||
size_t | len, | ||
size_t * | recievedDataSize | ||
) |
Receive data from a connected socket.
- Parameters:
-
[in] socket The connected socket on which to receive data. Sockets passed to this function should be of type PAL_SOCK_STREAM, unless your specific implementation supports other types as well. [out] buf The output buffer for the message data. [in] len The length of the input data buffer in bytes. [out] recievedDataSize The length of the data actually received in bytes.
- Returns:
- PAL_SUCCESS (0) in case of success, a specific negative error code in case of failure.
Definition at line 827 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
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 an interface is added.
- Parameters:
-
[in] networkInterfaceContext The context of the network interface to be added. This is OS-specific.
In mbed OS, this is the NetworkInterface object pointer for the network adapter and assumes a connect has already been called on this.
If not available, use NULL. This is not required on some OSs.[out] interfaceIndex Contains the index assigned to the interface if it has been assigned successfully. This index can be used when creating a socket to bind the socket to the interface.
- Returns:
- PAL_SUCCESS (0) in case of success. A specific negative error code in case of failure.
Definition at line 113 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
palStatus_t pal_plat_send | ( | palSocket_t | socket, |
const void * | buf, | ||
size_t | len, | ||
size_t * | sentDataSize | ||
) |
Send a buffer via a specific connected socket.
- Parameters:
-
[in] socket The connected socket on which to send data. The socket passed to this function should be of type `PAL_SOCK_STREAM`, unless your specific implementation supports other types as well. [in] buf The output buffer for the message data. [in] len The length of the output data buffer in bytes. [out] sentDataSize The length of the data sent in bytes.
- Returns:
- PAL_SUCCESS (0) in case of success, a specific negative error code in case of failure.
Definition at line 892 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
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 an address using a specific socket.
- Parameters:
-
[in] socket The socket to use for sending the payload. The socket passed to this function should be of type `PAL_SOCK_DGRAM`, unless your specific implementation supports 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.
- Returns:
- PAL_SUCCESS (0) in case of success. A specific negative error code in case of failure.
Definition at line 496 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
palStatus_t pal_plat_setSocketOptions | ( | palSocket_t | socket, |
int | optionName, | ||
const void * | optionValue, | ||
palSocketLength_t | optionLength | ||
) |
Set options for a network socket.
See `palSocketOptionName_t` for supported options.
- Parameters:
-
[in] socket The socket to configure. [in] optionName The name of the option to be set. See enum `palSocketOptionName_t` for supported types. [in] optionValue The buffer holding the value to set for the given option. [in] optionLength The size of the buffer provided for `optionValue` in bytes.
- Returns:
- PAL_SUCCESS (0) in case of success. A specific negative error code in case of failure.
Definition at line 301 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
palStatus_t pal_plat_socket | ( | palSocketDomain_t | domain, |
palSocketType_t | type, | ||
bool | nonBlockingSocket, | ||
uint32_t | interfaceNum, | ||
palSocket_t * | socket | ||
) |
Get a network socket.
- Parameters:
-
[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. [in] interfaceNum The number of the network interface used for this socket. Select `PAL_NET_DEFAULT_INTERFACE` for the default interface. [out] socket The socket is returned through this output parameter.
- Returns:
- PAL_SUCCESS (0) in case of success. A specific negative error code in case of failure.
Definition at line 221 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
palStatus_t pal_plat_socketsInit | ( | void * | context ) |
Initialize sockets.
Must be called before other socket functions. By default, is called from PAL init.
- Parameters:
-
[in] context Optional context. If not available or applicable, use NULL.
- Returns:
- PAL_SUCCESS (0) in case of success. A specific negative error code in case of failure.
Definition at line 106 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
palStatus_t pal_plat_socketsTerminate | ( | void * | context ) |
Socket termination.
This can be called when sockets are no longer needed, to free socket resources.
- Parameters:
-
[in] context Optional context. If not available, use NULL.
- Returns:
- PAL_SUCCESS (0) in case of success. A specific negative error code in case of failure.
Definition at line 153 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
palStatus_t pal_plat_unregisterNetworkInterface | ( | uint32_t | interfaceIndex ) |
Unregister a network interface.
- Parameters:
-
interfaceIndex Index of the network interface to be removed.
- Returns:
- PAL_SUCCESS (0) in case of success. A specific negative error code in case of failure.
Definition at line 146 of file FreeRTOS/Networking/LWIP/pal_plat_network.c.
Generated on Tue Jul 12 2022 20:21:04 by
