AWS IoT Embedded C Device SDK
network_interface.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
24 #ifndef __NETWORK_INTERFACE_H_
25 #define __NETWORK_INTERFACE_H_
26 
27 #include <stdint.h>
28 #include <stdbool.h>
29 #include <aws_iot_error.h>
30 #include "timer_interface.h"
31 #include "network_platform.h"
32 
38 typedef struct Network Network;
39 
46 typedef struct {
51  uint16_t DestinationPort;
52  uint32_t timeout_ms;
55 
61 struct Network{
62  IoT_Error_t (*connect) (Network *, TLSConnectParams *);
63  IoT_Error_t (*read) (Network *, unsigned char *, size_t, Timer *, size_t *);
64  IoT_Error_t (*write) (Network *, unsigned char *, size_t, Timer *, size_t *);
68 
71 };
72 
91 IoT_Error_t iot_tls_init(Network *pNetwork, char *pRootCALocation, char *pDeviceCertLocation,
92  char *pDevicePrivateKeyLocation, char *pDestinationURL,
93  uint16_t DestinationPort, uint32_t timeout_ms, bool ServerVerificationFlag);
94 
104 IoT_Error_t iot_tls_connect(Network *pNetwork, TLSConnectParams *TLSParams);
105 
116 IoT_Error_t iot_tls_write(Network*, unsigned char*, size_t, Timer *, size_t *);
117 
128 IoT_Error_t iot_tls_read(Network*, unsigned char*, size_t, Timer *, size_t *);
129 
137 
147 
157 
158 #endif //__NETWORK_INTERFACE_H_
IoT_Error_t iot_tls_init(Network *pNetwork, char *pRootCALocation, char *pDeviceCertLocation, char *pDevicePrivateKeyLocation, char *pDestinationURL, uint16_t DestinationPort, uint32_t timeout_ms, bool ServerVerificationFlag)
Initialize the TLS implementation.
Definition: network_mbedtls_wrapper.c:62
IoT_Error_t iot_tls_disconnect(Network *pNetwork)
Disconnect from network socket.
Definition: network_mbedtls_wrapper.c:319
char * pDestinationURL
Pointer to string containing the endpoint of the MQTT service.
Definition: network_interface.h:50
TLSDataParams tlsDataParams
TLSData params structure containing the connection data parameters that are specific to the library b...
Definition: network_interface.h:70
IoT_Error_t iot_tls_is_connected(Network *pNetwork)
Check if TLS layer is still connected.
Definition: network_mbedtls_wrapper.c:78
Definition of error types for the SDK.
IoT_Error_t iot_tls_connect(Network *pNetwork, TLSConnectParams *TLSParams)
Create a TLS socket and open the connection.
Definition: network_mbedtls_wrapper.c:83
IoT_Error_t iot_tls_read(Network *, unsigned char *, size_t, Timer *, size_t *)
Read bytes from the network socket.
Definition: network_mbedtls_wrapper.c:282
Timer interface definition for MQTT client.
IoT_Error_t(* destroy)(Network *)
Function pointer pointing to the network function to destroy the network object.
Definition: network_interface.h:67
IoT_Error_t
IoT Error enum.
Definition: aws_iot_error.h:36
IoT_Error_t(* disconnect)(Network *)
Function pointer pointing to the network function to disconnect from the network. ...
Definition: network_interface.h:65
Definition: timer_platform.h:29
TLS Connection Parameters.
Definition: network_interface.h:46
IoT_Error_t iot_tls_write(Network *, unsigned char *, size_t, Timer *, size_t *)
Write bytes to the network socket.
Definition: network_mbedtls_wrapper.c:250
uint32_t timeout_ms
Unsigned integer defining the TLS handshake timeout value in milliseconds.
Definition: network_interface.h:52
Network Structure.
Definition: network_interface.h:61
IoT_Error_t(* read)(Network *, unsigned char *, size_t, Timer *, size_t *)
Function pointer pointing to the network function to read from the network.
Definition: network_interface.h:63
uint16_t DestinationPort
Integer defining the connection port of the MQTT service.
Definition: network_interface.h:51
bool ServerVerificationFlag
Boolean. True = perform server certificate hostname validation. False = skip validation NOT recommend...
Definition: network_interface.h:53
IoT_Error_t iot_tls_destroy(Network *pNetwork)
Perform any tear-down or cleanup of TLS layer.
Definition: network_mbedtls_wrapper.c:332
TLSConnectParams tlsConnectParams
TLSConnect params structure containing the common connection parameters.
Definition: network_interface.h:69
char * pDevicePrivateKeyLocation
Pointer to string containing the filename (including path) of the device private key file...
Definition: network_interface.h:49
char * pRootCALocation
Pointer to string containing the filename (including path) of the root CA file.
Definition: network_interface.h:47
IoT_Error_t(* write)(Network *, unsigned char *, size_t, Timer *, size_t *)
Function pointer pointing to the network function to write to the network.
Definition: network_interface.h:64
char * pDeviceCertLocation
Pointer to string containing the filename (including path) of the device certificate.
Definition: network_interface.h:48
IoT_Error_t(* isConnected)(Network *)
Function pointer pointing to the network function to check if physical layer is connected.
Definition: network_interface.h:66
TLS Connection Parameters.
Definition: network_platform.h:36