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 
32 typedef struct Network Network;
33 
40 typedef struct{
46  unsigned int timeout_ms;
47  unsigned char ServerVerificationFlag;
49 
55 struct Network{
56  int my_socket;
57  int (*connect) (Network *, TLSConnectParams);
58  int (*mqttread) (Network*, unsigned char*, int, int);
59  int (*mqttwrite) (Network*, unsigned char*, int, int);
60  void (*disconnect) (Network*);
61  int (*isConnected) (Network*);
62  int (*destroy) (Network*);
63 };
64 
75 int iot_tls_init(Network *pNetwork);
76 
86 int iot_tls_connect(Network *pNetwork, TLSConnectParams TLSParams);
87 
97 int iot_tls_write(Network*, unsigned char*, int, int);
98 
108 int iot_tls_read(Network*, unsigned char*, int, int);
109 
115 void iot_tls_disconnect(Network *pNetwork);
116 
125 int iot_tls_destroy(Network *pNetwork);
126 
135 int iot_tls_is_connected(Network *pNetwork);
136 
137 #endif //__NETWORK_INTERFACE_H_
int iot_tls_init(Network *pNetwork)
Initialize the TLS implementation.
Definition: network_mbedtls_wrapper.c:66
char * pDestinationURL
Pointer to string containing the endpoint of the MQTT service.
Definition: network_interface.h:44
int(* destroy)(Network *)
Function pointer pointing to the network function to destroy the network object.
Definition: network_interface.h:62
int iot_tls_connect(Network *pNetwork, TLSConnectParams TLSParams)
Create a TLS socket and open the connection.
Definition: network_mbedtls_wrapper.c:103
int(* mqttread)(Network *, unsigned char *, int, int)
Function pointer pointing to the network function to read from the network.
Definition: network_interface.h:58
int iot_tls_destroy(Network *pNetwork)
Perform any tear-down or cleanup of TLS layer.
Definition: network_mbedtls_wrapper.c:268
TLS Connection Parameters.
Definition: network_interface.h:40
int DestinationPort
Integer defining the connection port of the MQTT service.
Definition: network_interface.h:45
unsigned int timeout_ms
Unsigned integer defining the TLS handshake timeout value in milliseconds.
Definition: network_interface.h:46
int iot_tls_read(Network *, unsigned char *, int, int)
Read bytes from the network socket.
Definition: network_mbedtls_wrapper.c:240
Network Structure.
Definition: network_interface.h:55
void(* disconnect)(Network *)
Function pointer pointing to the network function to disconnect from the network. ...
Definition: network_interface.h:60
int my_socket
Integer holding the socket file descriptor.
Definition: network_interface.h:56
int(* isConnected)(Network *)
Function pointer pointing to the network function to check if physical layer is connected.
Definition: network_interface.h:61
char * pDevicePrivateKeyLocation
Pointer to string containing the filename (including path) of the device private key file...
Definition: network_interface.h:43
char * pRootCALocation
Pointer to string containing the filename (including path) of the root CA file.
Definition: network_interface.h:41
unsigned char ServerVerificationFlag
Boolean. True = perform server certificate hostname validation. False = skip validation NOT recommend...
Definition: network_interface.h:47
char * pDeviceCertLocation
Pointer to string containing the filename (including path) of the device certificate.
Definition: network_interface.h:42
int iot_tls_write(Network *, unsigned char *, int, int)
Write bytes to the network socket.
Definition: network_mbedtls_wrapper.c:224
int iot_tls_is_connected(Network *pNetwork)
Check if TLS layer is still connected.
Definition: network_mbedtls_wrapper.c:98
int(* mqttwrite)(Network *, unsigned char *, int, int)
Function pointer pointing to the network function to write to the network.
Definition: network_interface.h:59
void iot_tls_disconnect(Network *pNetwork)
Disconnect from network socket.
Definition: network_mbedtls_wrapper.c:262