Mistake on this page? Email us
pal_plat_network.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright 2016, 2017 ARM Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may 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,
12  * WITHOUT 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 
44 palStatus_t pal_plat_socketsInit(void* context);
45 
55 palStatus_t pal_plat_registerNetworkInterface(void* networkInterfaceContext, uint32_t* interfaceIndex);
56 
61 palStatus_t pal_plat_unregisterNetworkInterface(uint32_t interfaceIndex);
62 
70 
80 palStatus_t pal_plat_setSocketOptions(palSocket_t socket, int optionName, const void* optionValue, palSocketLength_t optionLength);
81 
87 palStatus_t pal_plat_isNonBlocking(palSocket_t socket, bool* isNonBlocking);
88 
96 
106 palStatus_t pal_plat_receiveFrom(palSocket_t socket, void* buffer, size_t length, palSocketAddress_t* from, palSocketLength_t* fromLength, size_t* bytesReceived);
107 
117 palStatus_t pal_plat_sendTo(palSocket_t socket, const void* buffer, size_t length, const palSocketAddress_t* to, palSocketLength_t toLength, size_t* bytesSent);
118 
125 
132 palStatus_t pal_plat_getNumberOfNetInterfaces(uint32_t* numInterfaces);
133 
139 palStatus_t pal_plat_getNetInterfaceInfo(uint32_t interfaceNum, palNetInterfaceInfo_t* interfaceInfo);
140 
141 #if PAL_NET_TCP_AND_TLS_SUPPORT // The functionality below is supported only if TCP is supported.
142 
143 #if PAL_NET_SERVER_SOCKET_API
144 
152 palStatus_t pal_plat_listen(palSocket_t socket, int backlog);
153 
163 palStatus_t pal_plat_accept(palSocket_t socket, palSocketAddress_t* address, palSocketLength_t* addressLen, palSocket_t* acceptedSocket, palAsyncSocketCallback_t callback, void* callbackArgument);
164 
165 #endif // PAL_NET_SERVER_SOCKET_API
166 
173 palStatus_t pal_plat_connect(palSocket_t socket, const palSocketAddress_t* address, palSocketLength_t addressLen);
174 
182 palStatus_t pal_plat_recv(palSocket_t socket, void* buf, size_t len, size_t* recievedDataSize);
183 
191 palStatus_t pal_plat_send(palSocket_t socket, const void* buf, size_t len, size_t* sentDataSize);
192 
199 palStatus_t pal_plat_setConnectionStatusCallback(uint32_t interfaceIndex, connectionStatusCallback callback, void *client_arg);
200 
201 #endif //PAL_NET_TCP_AND_TLS_SUPPORT
202 
211 palStatus_t pal_plat_asynchronousSocket(palSocketDomain_t domain, palSocketType_t type, bool nonBlockingSocket, uint32_t interfaceNum, palAsyncSocketCallback_t callback, void* callbackArgument , palSocket_t* socket);
212 
213 #if PAL_NET_DNS_SUPPORT
214 #if (PAL_DNS_API_VERSION == 0) || (PAL_DNS_API_VERSION == 1)
215 
221 palStatus_t pal_plat_getAddressInfo(const char* hostname, palSocketAddress_t* address, palSocketLength_t* addressLength);
222 
223 #elif (PAL_DNS_API_VERSION == 2)
224 
228 palStatus_t pal_plat_getAddressInfoAsync(pal_asyncAddressInfo_t* info);
229 
233 palStatus_t pal_plat_cancelAddressInfoAsync(palDNSQuery_t queryHandle);
234 #else
235  #error "Please specify the platform PAL_DNS_API_VERSION 0, 1, or 2."
236 #endif // PAL_DNS_API_VERSION
237 
238 #endif // PAL_NET_DNS_SUPPORT
239 
240 #ifdef __cplusplus
241 }
242 #endif
243 #endif //_PAL_PLAT_SOCKET_H
PAL. This file contains the general API to initiate and destroy the PAL component. This is part of the PAL service API.
palStatus_t pal_plat_isNonBlocking(palSocket_t socket, bool *isNonBlocking)
Check if a socket is non-blocking.
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.
PAL network. This file contains the network APIs and it is a part of the PAL service API...
palStatus_t pal_plat_getNumberOfNetInterfaces(uint32_t *numInterfaces)
Get the number of current network interfaces.
uint32_t palSocketLength_t
The length of data.
Definition: pal_network.h:43
void * palSocket_t
PAL socket handle type.
Definition: pal_network.h:44
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_registerNetworkInterface(void *networkInterfaceContext, uint32_t *interfaceIndex)
Register a network interface for use with PAL sockets.
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_socketsTerminate(void *context)
Socket termination.
palSocketType_t
Socket types supported by PAL.
Definition: pal_network.h:73
Definition: pal_network.h:53
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_close(palSocket_t *socket)
Close a network socket.
palStatus_t pal_plat_socketsInit(void *context)
Initialize sockets.
void(* connectionStatusCallback)(palNetworkStatus_t status, void *client_arg)
Definition: pal_network.h:101
palStatus_t pal_plat_getNetInterfaceInfo(uint32_t interfaceNum, palNetInterfaceInfo_t *interfaceInfo)
Get information regarding a socket at a specific interface number.
void(* palAsyncSocketCallback_t)(void *)
The type of the callback function passed when creating asynchronous sockets.
Definition: pal_network.h:253
palStatus_t pal_plat_unregisterNetworkInterface(uint32_t interfaceIndex)
palStatus_t pal_plat_bind(palSocket_t socket, palSocketAddress_t *myAddress, palSocketLength_t addressLength)
Bind a socket to a local address.
int32_t palStatus_t
Definition: pal_types.h:49
palSocketDomain_t
Network domains supported by PAL.
Definition: pal_network.h:60
Definition: pal_network.h:48