AWS IoT Embedded C Device SDK
Data Structures | Typedefs | Functions
network_interface.h File Reference

Network interface definition for MQTT client. More...

#include <stdint.h>
#include <stdbool.h>
#include <aws_iot_error.h>
#include "timer_interface.h"
#include "network_platform.h"

Go to the source code of this file.

Data Structures

struct  TLSConnectParams
 TLS Connection Parameters. More...
 
struct  Network
 Network Structure. More...
 

Typedefs

typedef struct Network Network
 Network Type. More...
 

Functions

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. More...
 
IoT_Error_t iot_tls_connect (Network *pNetwork, TLSConnectParams *TLSParams)
 Create a TLS socket and open the connection. More...
 
IoT_Error_t iot_tls_write (Network *, unsigned char *, size_t, Timer *, size_t *)
 Write bytes to the network socket. More...
 
IoT_Error_t iot_tls_read (Network *, unsigned char *, size_t, Timer *, size_t *)
 Read bytes from the network socket. More...
 
IoT_Error_t iot_tls_disconnect (Network *pNetwork)
 Disconnect from network socket. More...
 
IoT_Error_t iot_tls_destroy (Network *pNetwork)
 Perform any tear-down or cleanup of TLS layer. More...
 
IoT_Error_t iot_tls_is_connected (Network *pNetwork)
 Check if TLS layer is still connected. More...
 

Detailed Description

Defines an interface to the TLS layer to be used by the MQTT client. Starting point for porting the SDK to the networking layer of a new platform.

Typedef Documentation

typedef struct Network Network

Defines a type for the network struct. See structure definition below.

Function Documentation

IoT_Error_t iot_tls_connect ( Network pNetwork,
TLSConnectParams TLSParams 
)

Creates an open socket connection including TLS handshake.

Parameters
pNetwork- Pointer to a Network struct defining the network interface.
TLSParams- TLSConnectParams defines the properties of the TLS connection.
Returns
IoT_Error_t - successful connection or TLS error
IoT_Error_t iot_tls_destroy ( Network pNetwork)

Called to cleanup any resources required for the TLS layer.

Parameters
Network- Pointer to a Network struct defining the network interface
Returns
IoT_Error_t - successful cleanup or TLS error code
IoT_Error_t iot_tls_disconnect ( Network pNetwork)
Parameters
Network- Pointer to a Network struct defining the network interface.
Returns
IoT_Error_t - successful read or TLS error code
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 
)

Perform any initialization required by the TLS layer. Connects the interface to implementation by setting up the network layer function pointers to platform implementations.

Parameters
pNetwork- Pointer to a Network struct defining the network interface.
pRootCALocation- Path of the location of the Root CA
pDeviceCertLocation- Path to the location of the Device Cert
pDevicyPrivateKeyLocation- Path to the location of the device private key file
pDestinationURL- The target endpoint to connect to
DestinationPort- The port on the target to connect to
timeout_ms- The value to use for timeout of operation
ServerVerificationFlag- used to decide whether server verification is needed or not
Returns
IoT_Error_t - successful initialization or TLS error
IoT_Error_t iot_tls_is_connected ( Network pNetwork)

Called to check if the TLS layer is still connected or not.

Parameters
Network- Pointer to a Network struct defining the network interface
Returns
IoT_Error_t - TLS error code indicating status of network physical layer connection
IoT_Error_t iot_tls_read ( Network ,
unsigned char *  ,
size_t  ,
Timer ,
size_t *   
)
Parameters
Network- Pointer to a Network struct defining the network interface.
unsignedchar pointer - pointer to buffer where read bytes should be copied
size_t- number of bytes to read
Timer* - operation timer
size_t- pointer to store number of bytes read
Returns
IoT_Error_t - successful read or TLS error code
IoT_Error_t iot_tls_write ( Network ,
unsigned char *  ,
size_t  ,
Timer ,
size_t *   
)
Parameters
Network- Pointer to a Network struct defining the network interface.
unsignedchar pointer - buffer to write to socket
integer- number of bytes to write
Timer* - operation timer
Returns
integer - number of bytes written or TLS error
IoT_Error_t - successful write or TLS error code