FreeRTOS: Platform
Platform portability layer
Return to main page ↑
iot_network.h
Go to the documentation of this file.
1 /*
2  * FreeRTOS Platform V1.1.2
3  * Copyright (C) 2020 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 
119 /* @[declare_platform_network_receivecallback] */
120 typedef void ( * IotNetworkReceiveCallback_t )( void * pConnection,
121  void * pContext );
122 /* @[declare_platform_network_receivecallback] */
123 
131 typedef struct IotNetworkInterface
132 {
146  /* @[declare_platform_network_create] */
147  IotNetworkError_t ( * create )( void * pConnectionInfo,
148  void * pCredentialInfo,
149  void ** pConnection );
150  /* @[declare_platform_network_create] */
151 
172  /* @[declare_platform_network_setreceivecallback] */
173  IotNetworkError_t ( * setReceiveCallback )( void * pConnection,
174  IotNetworkReceiveCallback_t receiveCallback,
175  void * pContext );
176  /* @[declare_platform_network_setreceivecallback] */
177 
192  /* @[declare_platform_network_send] */
193  size_t ( * send )( void * pConnection,
194  const uint8_t * pMessage,
195  size_t messageLength );
196  /* @[declare_platform_network_send] */
197 
214  /* @[declare_platform_network_receive] */
215  size_t ( * receive )( void * pConnection,
216  uint8_t * pBuffer,
217  size_t bytesRequested );
218  /* @[declare_platform_network_receive] */
219 
237  /* @[declare_platform_network_receiveupto] */
238  size_t ( * receiveUpto )( void * pConnection,
239  uint8_t * pBuffer,
240  size_t bufferSize );
241  /* @[declare_platform_network_receiveupto] */
242 
262  /* @[declare_platform_network_close] */
263  IotNetworkError_t ( * close )( void * pConnection );
264  /* @[declare_platform_network_close] */
265 
281  /* @[declare_platform_network_destroy] */
282  IotNetworkError_t ( * destroy )( void * pConnection );
283  /* @[declare_platform_network_destroy] */
285 
294 typedef struct IotNetworkServerInfo
295 {
296  const char * pHostName;
297  uint16_t port;
299 
308 typedef struct IotNetworkCredentials
309 {
319  const char * pAlpnProtos;
320 
329 
334 
335  const char * pRootCa;
336  size_t rootCaSize;
337  const char * pClientCert;
338  size_t clientCertSize;
339  const char * pPrivateKey;
340  size_t privateKeySize;
342 
343 #endif /* ifndef IOT_NETWORK_H_ */
size_t maxFragmentLength
Set this to a non-zero value to use TLS max fragment length negotiation (TLS MFLN).
Definition: iot_network.h:328
const char * pHostName
Server host name. Must be NULL-terminated.
Definition: iot_network.h:296
Contains the credentials necessary for connection setup.
Definition: iot_network.h:308
void(* IotNetworkReceiveCallback_t)(void *pConnection, void *pContext)
Provide an asynchronous notification of incoming network data.
Definition: iot_network.h:120
Represents the functions of a network stack.
Definition: iot_network.h:131
Definition: iot_network.h:49
const char * pAlpnProtos
Set this to a non-NULL value to use ALPN.
Definition: iot_network.h:319
Definition: iot_network.h:48
uint16_t port
Server port in host-order.
Definition: iot_network.h:297
bool disableSni
Disable server name indication (SNI) for a TLS session.
Definition: iot_network.h:333
const char * pClientCert
String representing the client certificate.
Definition: iot_network.h:337
Definition: iot_network.h:46
size_t clientCertSize
Size associated with IotNetworkCredentials_t.pClientCert.
Definition: iot_network.h:338
IotNetworkError_t
Return codes for network functions.
Definition: iot_network.h:43
Information on the remote server for connection setup.
Definition: iot_network.h:294
Definition: iot_network.h:45
size_t rootCaSize
Size associated with IotNetworkCredentials_t.pRootCa.
Definition: iot_network.h:336
size_t privateKeySize
Size associated with IotNetworkCredentials_t.pPrivateKey.
Definition: iot_network.h:340
const char * pRootCa
String representing a trusted server root certificate.
Definition: iot_network.h:335
const char * pPrivateKey
String representing the client certificate&#39;s private key.
Definition: iot_network.h:339
Definition: iot_network.h:47