PAL
A Platform Abstraction Layer connects the mbed-client with the underlying platform.
pal_plat_network.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2016 ARM Limited. All rights reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 * Licensed under the Apache License, Version 2.0 (the License); you may
5 * not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 
17 
18 #ifndef _PAL_PLAT_SOCKET_H
19 #define _PAL_PLAT_SOCKET_H
20 
21 #include "pal.h"
22 #include "pal_network.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
33 
38 palStatus_t pal_plat_socketsInit(void* context);
39 
45 palStatus_t pal_plat_RegisterNetworkInterface(void* networkInterfaceContext, uint32_t* interfaceIndex);
46 
52 
61 palStatus_t pal_plat_socket(palSocketDomain_t domain, palSocketType_t type, bool nonBlockingSocket, uint32_t interfaceNum, palSocket_t* socket);
62 
70 palStatus_t pal_plat_getSocketOptions(palSocket_t socket, palSocketOptionName_t optionName, void* optionValue, palSocketLength_t* optionLength);
71 
79 palStatus_t pal_plat_setSocketOptions(palSocket_t socket, int optionName, const void* optionValue, palSocketLength_t optionLength);
80 
88 
98 palStatus_t pal_plat_receiveFrom(palSocket_t socket, void* buffer, size_t length, palSocketAddress_t* from, palSocketLength_t* fromLength, size_t* bytesReceived);
99 
109 palStatus_t pal_plat_sendTo(palSocket_t socket, const void* buffer, size_t length, const palSocketAddress_t* to, palSocketLength_t toLength, size_t* bytesSent);
110 
117 
122 palStatus_t pal_plat_getNumberOfNetInterfaces(uint32_t* numInterfaces);
123 
129 palStatus_t pal_plat_getNetInterfaceInfo(uint32_t interfaceNum, palNetInterfaceInfo_t* interfaceInfo);
130 
131 
142 palStatus_t pal_plat_socketMiniSelect(const palSocket_t socketsToCheck[PAL_NET_SOCKET_SELECT_MAX_SOCKETS], uint32_t numberOfSockets, pal_timeVal_t* timeout,
143  uint8_t palSocketStatus[PAL_NET_SOCKET_SELECT_MAX_SOCKETS], uint32_t * numberOfSocketsSet);
144 
145 
146 #if PAL_NET_TCP_AND_TLS_SUPPORT // functionality below supported only in case TCP is supported.
147 
148 
154 palStatus_t pal_plat_listen(palSocket_t socket, int backlog);
155 
163 palStatus_t pal_plat_accept(palSocket_t socket, palSocketAddress_t* address, palSocketLength_t* addressLen, palSocket_t* acceptedSocket);
164 
171 palStatus_t pal_plat_connect(palSocket_t socket, const palSocketAddress_t* address, palSocketLength_t addressLen);
172 
180 palStatus_t pal_plat_recv(palSocket_t socket, void* buf, size_t len, size_t* recievedDataSize);
181 
189 palStatus_t pal_plat_send(palSocket_t socket, const void* buf, size_t len, size_t* sentDataSize);
190 
191 
192 #endif //PAL_NET_TCP_AND_TLS_SUPPORT
193 
194 
195 #if PAL_NET_ASYNCHRONOUS_SOCKET_API
196 
204 palStatus_t pal_plat_asynchronousSocket(palSocketDomain_t domain, palSocketType_t type, bool nonBlockingSocket, uint32_t interfaceNum, palAsyncSocketCallback_t callback, palSocket_t* socket);
205 
206 #endif
207 
208 #if PAL_NET_DNS_SUPPORT
209 
214 palStatus_t pal_plat_getAddressInfo(const char* url, palSocketAddress_t* address, palSocketLength_t* addressLength);
215 
216 #endif
217 
218 
219 #ifdef __cplusplus
220 }
221 #endif
222 #endif //_PAL_PLAT_SOCKET_H
palStatus_t pal_plat_getNumberOfNetInterfaces(uint32_t *numInterfaces)
Definition: pal_plat_network.cpp:458
uint32_t palSocketLength_t
Definition: pal_network.h:32
palStatus_t pal_plat_getSocketOptions(palSocket_t socket, palSocketOptionName_t optionName, void *optionValue, palSocketLength_t *optionLength)
Definition: pal_plat_network.cpp:301
void * palSocket_t
Definition: pal_network.h:33
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)
Definition: pal_plat_network.cpp:536
palStatus_t pal_plat_sendTo(palSocket_t socket, const void *buffer, size_t length, const palSocketAddress_t *to, palSocketLength_t toLength, size_t *bytesSent)
Definition: pal_plat_network.cpp:418
palStatus_t pal_plat_setSocketOptions(palSocket_t socket, int optionName, const void *optionValue, palSocketLength_t optionLength)
Definition: pal_plat_network.cpp:332
palStatus_t pal_plat_socketsTerminate(void *context)
Definition: pal_plat_network.cpp:144
palSocketType_t
Definition: pal_network.h:54
palStatus_t pal_plat_RegisterNetworkInterface(void *networkInterfaceContext, uint32_t *interfaceIndex)
Definition: pal_plat_network.cpp:107
Definition: pal_network.h:42
palSocketOptionName_t
Definition: pal_network.h:63
palStatus_t pal_plat_receiveFrom(palSocket_t socket, void *buffer, size_t length, palSocketAddress_t *from, palSocketLength_t *fromLength, size_t *bytesReceived)
Definition: pal_plat_network.cpp:386
palStatus_t pal_plat_close(palSocket_t *socket)
Definition: pal_plat_network.cpp:444
palStatus_t pal_plat_socketsInit(void *context)
Definition: pal_plat_network.cpp:93
#define PAL_NET_SOCKET_SELECT_MAX_SOCKETS
Definition: pal_network.h:216
palStatus_t pal_plat_getNetInterfaceInfo(uint32_t interfaceNum, palNetInterfaceInfo_t *interfaceInfo)
Definition: pal_plat_network.cpp:464
palStatus_t pal_plat_socket(palSocketDomain_t domain, palSocketType_t type, bool nonBlockingSocket, uint32_t interfaceNum, palSocket_t *socket)
Definition: pal_plat_network.cpp:251
palStatus_t pal_plat_bind(palSocket_t socket, palSocketAddress_t *myAddress, palSocketLength_t addressLength)
Definition: pal_plat_network.cpp:366
int32_t palStatus_t
Definition: pal_types.h:31
Definition: pal_network.h:80
palSocketDomain_t
Definition: pal_network.h:48
Definition: pal_network.h:37