Platform API Reference
Platform portability layer
iot_network.h
Go to the documentation of this file.
1 /*
2  * Amazon FreeRTOS Platform V1.1.0
3  * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://aws.amazon.com/freertos
23  * http://www.FreeRTOS.org
24  */
25 
31 #ifndef IOT_NETWORK_H_
32 #define IOT_NETWORK_H_
33 
34 /* Standard includes. */
35 #include <stdbool.h>
36 #include <stdint.h>
37 #include <stdlib.h>
38 
43 typedef enum IotNetworkError
44 {
51 
93 /* @[declare_platform_network_receivecallback] */
94 typedef void ( * IotNetworkReceiveCallback_t )( void * pConnection,
95  void * pContext );
96 /* @[declare_platform_network_receivecallback] */
97 
105 typedef struct IotNetworkInterface
106 {
120  /* @[declare_platform_network_create] */
121  IotNetworkError_t ( * create )( void * pConnectionInfo,
122  void * pCredentialInfo,
123  void ** pConnection );
124  /* @[declare_platform_network_create] */
125 
146  /* @[declare_platform_network_setreceivecallback] */
147  IotNetworkError_t ( * setReceiveCallback )( void * pConnection,
148  IotNetworkReceiveCallback_t receiveCallback,
149  void * pContext );
150  /* @[declare_platform_network_setreceivecallback] */
151 
166  /* @[declare_platform_network_send] */
167  size_t ( * send )( void * pConnection,
168  const uint8_t * pMessage,
169  size_t messageLength );
170  /* @[declare_platform_network_send] */
171 
188  /* @[declare_platform_network_receive] */
189  size_t ( * receive )( void * pConnection,
190  uint8_t * pBuffer,
191  size_t bytesRequested );
192  /* @[declare_platform_network_receive] */
193 
211  /* @[declare_platform_network_receiveupto] */
212  size_t ( * receiveUpto )( void * pConnection,
213  uint8_t * pBuffer,
214  size_t bufferSize );
215  /* @[declare_platform_network_receiveupto] */
216 
236  /* @[declare_platform_network_close] */
237  IotNetworkError_t ( * close )( void * pConnection );
238  /* @[declare_platform_network_close] */
239 
255  /* @[declare_platform_network_destroy] */
256  IotNetworkError_t ( * destroy )( void * pConnection );
257  /* @[declare_platform_network_destroy] */
259 
268 typedef struct IotNetworkServerInfo
269 {
270  const char * pHostName;
271  uint16_t port;
273 
282 typedef struct IotNetworkCredentials
283 {
293  const char * pAlpnProtos;
294 
303 
308 
309  const char * pRootCa;
310  size_t rootCaSize;
311  const char * pClientCert;
312  size_t clientCertSize;
313  const char * pPrivateKey;
314  size_t privateKeySize;
316 
317 #endif /* ifndef IOT_NETWORK_H_ */
IotNetworkCredentials_t::pClientCert
const char * pClientCert
String representing the client certificate.
Definition: iot_network.h:311
IotNetworkServerInfo_t::pHostName
const char * pHostName
Server host name. Must be NULL-terminated.
Definition: iot_network.h:270
IotNetworkCredentials_t::maxFragmentLength
size_t maxFragmentLength
Set this to a non-zero value to use TLS max fragment length negotiation (TLS MFLN).
Definition: iot_network.h:302
IotNetworkCredentials_t::pAlpnProtos
const char * pAlpnProtos
Set this to a non-NULL value to use ALPN.
Definition: iot_network.h:293
IotNetworkCredentials_t::pPrivateKey
const char * pPrivateKey
String representing the client certificate's private key.
Definition: iot_network.h:313
IOT_NETWORK_SYSTEM_ERROR
Definition: iot_network.h:49
IOT_NETWORK_SUCCESS
Definition: iot_network.h:45
IotNetworkCredentials_t
Contains the credentials necessary for connection setup.
Definition: iot_network.h:282
IotNetworkError_t
IotNetworkError_t
Return codes for network functions.
Definition: iot_network.h:43
IotNetworkCredentials_t::rootCaSize
size_t rootCaSize
Size associated with IotNetworkCredentials_t.pRootCa.
Definition: iot_network.h:310
IotNetworkInterface_t
Represents the functions of a network stack.
Definition: iot_network.h:105
IotNetworkServerInfo_t
Information on the remote server for connection setup.
Definition: iot_network.h:268
IotNetworkCredentials_t::privateKeySize
size_t privateKeySize
Size associated with IotNetworkCredentials_t.pPrivateKey.
Definition: iot_network.h:314
IotNetworkServerInfo_t::port
uint16_t port
Server port in host-order.
Definition: iot_network.h:271
IotNetworkCredentials_t::disableSni
bool disableSni
Disable server name indication (SNI) for a TLS session.
Definition: iot_network.h:307
IotNetworkCredentials_t::clientCertSize
size_t clientCertSize
Size associated with IotNetworkCredentials_t.pClientCert.
Definition: iot_network.h:312
IOT_NETWORK_BAD_PARAMETER
Definition: iot_network.h:47
IOT_NETWORK_FAILURE
Definition: iot_network.h:46
IotNetworkReceiveCallback_t
void(* IotNetworkReceiveCallback_t)(void *pConnection, void *pContext)
Provide an asynchronous notification of incoming network data.
Definition: iot_network.h:94
IotNetworkCredentials_t::pRootCa
const char * pRootCa
String representing a trusted server root certificate.
Definition: iot_network.h:309
IOT_NETWORK_NO_MEMORY
Definition: iot_network.h:48