PAL
A Platform Abstraction Layer connects the mbed-client with the underlying platform.
Macros | Functions
pal_plat_socket_lwip.cpp File Reference
#include "pal_common.h"
#include "pal_plat_socket.h"
#include "/tmp/mbedos/mbed-os/features/net/FEATURE_IPV4/lwip-interface/lwip/include/lwip/sockets.h"

Macros

#define PAL_POSIX_ERROR_CODE   (-1)
 

Functions

palStatus_t pal_plat_sockets_init (void *context)
 
palStatus_t pal_plat_socket (palSocketDomain_t domain, palSocketType_t type, bool nonBlockingSocket, int interfaceNum, palSocket_t *socket)
 
palStatus_t pal_plat_getSocketOptions (palSocket_t socket, palSocketOptionName_t optionName, void *optionValue, palSocketLength_t *optionLength)
 
palStatus_t pal_plat_setSocketOptions (palSocket_t socket, int optionName, const void *optionValue, palSocketLength_t optionLength)
 
palStatus_t pal_plat_bind (palSocket_t socket, palSocketAddress_t *myAddress, palSocketLength_t addressLength)
 
palStatus_t pal_plat_receiveFrom (palSocket_t socket, void *buffer, size_t length, palSocketAddress_t *from, palSocketLength_t *fromLength, size_t *bytesReceived)
 
palStatus_t pal_plat_sendTo (palSocket_t socket, const void *buffer, size_t length, const palSocketAddress_t *to, palSocketLength_t toLength, size_t *bytesSent)
 
palStatus_t pal_plat_close (palSocket_t *socket)
 
palStatus_t pal_plat_getNumberOfNetInterfaces (uint32_t *numInterfaces)
 
palStatus_t pal_plat_getNetInterfaceInfo (uint32_t interfaceNum, palNetInterfaceInfo_t *interfaceInfo)
 
palStatus_t pal_plat_socketMiniSelect (const palSocket_t socketsToCheck[PAL_NET_SOCKET_SELECT_MAX_SOCKETS], unsigned int numberOfSockets, pal_timeVal_t *timeout, palSocketStatus_t socketStatus, int *numberOfSocketsSet)
 

Macro Definition Documentation

#define PAL_POSIX_ERROR_CODE   (-1)

Function Documentation

palStatus_t pal_plat_bind ( palSocket_t  socket,
palSocketAddress_t myAddress,
palSocketLength_t  addressLength 
)

Bind a given socket to a local address.

Parameters
[in]socketThe socket to bind.
[in]myAddressThe address to bind to.
[in]addressLengthThe length of the address passed in myAddress.
Returns
The status in the form of PalStatus_t; PAL_SUCCESS (0) in case of success, a specific negative error code in case of failure.
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.

Parameters
[in,out]socketRelease and zero socket pointed to by given pointer.
Returns
The status in the form of PalStatus_t; PAL_SUCCESS (0) in case of success, a specific negative error code in case of failure.
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).

Parameters
[in]interfaceNumThe number of the interface to get information for.
[out]interfaceInfoThe information for the given interface number.
Returns
The status in the form of PalStatus_t; PAL_SUCCESS (0) in case of success, a specific negative error code in case of failure.
palStatus_t pal_plat_getNumberOfNetInterfaces ( uint32_t *  numInterfaces)

Get the number of current network interfaces (interfaces that have been registered through).

Parameters
[out]numInterfacesThe number of interfaces after a successful call.
Returns
The status as in the form of PalStatus_t; PAL_SUCCESS (0) in case of success, a specific negative error code in case of failure.
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).

Parameters
[in]socketThe socket for which to get options.
[in]optionNameThe name for which to set the option (see enum PAL_NET_SOCKET_OPTION for supported types).
[out]optionValueThe buffer holding the option value returned by the function.
[in,out]optionLengthThe 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.
Returns
The status in the form of PalStatus_t; PAL_SUCCESS (0) in case of success, a specific negative error code in case of failure.
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.

Parameters
[in]socketThe 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]bufferThe buffer for the payload data.
[in]lengthThe length of the buffer for the payload data.
[out]fromThe address that sent the payload [optional - if not required pass NULL].
[in,out]fromLengthThe 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]bytesReceivedThe actual amount of payload data received to the buffer.
Returns
The status in the form of PalStatus_t; PAL_SUCCESS (0) in case of success, a specific negative error code in case of failure.
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.

Parameters
[in]socketThe 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]bufferThe buffer for the payload data.
[in]lengthThe length of the buffer for the payload data.
[in]toThe address to which the payload should be sent.
[in]toLengthThe length of the 'to' address.
[out]bytesSentThe actual amount of payload data sent.
Returns
The status in the form of PalStatus_t; PAL_SUCCESS (0) in case of success, a specific negative error code in case of failure.
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).

Parameters
[in]socketThe socket for which to get options.
[in]optionNameThe name for which to set the option (see enum PAL_NET_SOCKET_OPTION for supported types).
[in]optionValueThe buffer holding the option value to set for the given option.
[in]optionLengthThe size of the buffer provided for optionValue.
Returns
The status in the form of PalStatus_t; PAL_SUCCESS (0) in case of success, a specific negative error code in case of failure.
palStatus_t pal_plat_socket ( palSocketDomain_t  domain,
palSocketType_t  type,
bool  nonBlockingSocket,
int  interfaceNum,
palSocket_t socket 
)
palStatus_t pal_plat_socketMiniSelect ( const palSocket_t  socketsToCheck[PAL_NET_SOCKET_SELECT_MAX_SOCKETS],
unsigned int  numberOfSockets,
pal_timeVal_t timeout,
palSocketStatus_t  socketStatus,
int *  numberOfSocketsSet 
)
palStatus_t pal_plat_sockets_init ( void *  context)