Network interface definition for MQTT client.
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.
Data Structures | |
struct | Network |
Network Structure. More... | |
struct | TLSConnectParams |
TLS Connection Parameters. More... | |
Typedefs | |
typedef struct Network | Network |
Network Type. More... | |
Functions | |
int | iot_tls_connect (Network *pNetwork, TLSConnectParams TLSParams) |
Create a TLS socket and open the connection. More... | |
int | iot_tls_destroy (Network *pNetwork) |
Perform any tear-down or cleanup of TLS layer. More... | |
void | iot_tls_disconnect (Network *pNetwork) |
Disconnect from network socket. More... | |
int | iot_tls_init (Network *pNetwork) |
Initialize the TLS implementation. More... | |
int | iot_tls_is_connected (Network *pNetwork) |
Check if TLS layer is still connected. More... | |
int | iot_tls_read (Network *, unsigned char *, int, int) |
Read bytes from the network socket. More... | |
int | iot_tls_write (Network *, unsigned char *, int, int) |
Write bytes to the network socket. More... | |
Network Type.
Defines a type for the network struct. See structure definition below.
int iot_tls_connect | ( | Network * | pNetwork, |
TLSConnectParams | params | ||
) |
Create a TLS socket and open the connection.
Creates an open socket connection including TLS handshake.
pNetwork | - Pointer to a Network struct defining the network interface. |
TLSParams | - TLSConnectParams defines the properties of the TLS connection. |
Create a TLS socket and open the connection.
[in] | pNetwork | Network interface. |
[in] | params | connection parameters for TLS. |
References _htons, AF_INET, close(), connect(), TLSConnectParams::DestinationPort, DNS_REQUEST, err, gethostbyname(), gu32HostIp, Network::my_socket, NONE_ERROR, TLSConnectParams::pDestinationURL, printf, ret, in_addr::s_addr, set_alpn_list(), sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, SOCK_STREAM, socket(), SOCKET_FLAGS_SSL, SOCKET_MSG_CONNECT, SSL_CONNECT_ERROR, TCP_CONNECT_ERROR, and wait_for_event().
Referenced by iot_tls_init().
int iot_tls_destroy | ( | Network * | pNetwork | ) |
Perform any tear-down or cleanup of TLS layer.
Called to cleanup any resources required for the TLS layer.
Perform any tear-down or cleanup of TLS layer.
[in] | pNetwork | Network interface. |
References Network::disconnect, Network::mqttread, Network::mqttwrite, Network::my_socket, NONE_ERROR, NULL, and NULL_VALUE_ERROR.
Referenced by iot_tls_init().
void iot_tls_disconnect | ( | Network * | pNetwork | ) |
Disconnect from network socket.
Disconnect from network socket.
[in] | pNetwork | Network interface. |
References close(), Network::my_socket, and NULL.
Referenced by iot_tls_init().
int iot_tls_init | ( | Network * | pNetwork | ) |
Initialize the TLS implementation.
Perform any initialization required by the TLS layer. Connects the interface to implementation by setting up the network layer function pointers to platform implementations.
pNetwork | - Pointer to a Network struct defining the network interface. |
Initialize the TLS implementation.
[in] | pNetwork | Network interface. |
References Network::connect, Network::destroy, Network::disconnect, iot_tls_connect(), iot_tls_destroy(), iot_tls_disconnect(), iot_tls_is_connected(), iot_tls_read(), iot_tls_write(), Network::isConnected, Network::mqttread, Network::mqttwrite, Network::my_socket, NONE_ERROR, NULL, NULL_VALUE_ERROR, registerSocketCallback(), resolve_cb(), socket_cb(), and socketInit().
Referenced by aws_iot_mqtt_connect().
int iot_tls_is_connected | ( | Network * | pNetwork | ) |
Check if TLS layer is still connected.
Called to check if the TLS layer is still connected or not.
Check if TLS layer is still connected.
[in] | pNetwork | Network interface. |
Referenced by iot_tls_init().
int iot_tls_read | ( | Network * | , |
unsigned char * | , | ||
int | , | ||
int | |||
) |
Read bytes from the network socket.
Network | - Pointer to a Network struct defining the network interface. |
unsigned | char pointer - pointer to buffer where read bytes should be copied |
integer | - number of bytes to read |
integer | - read timeout value in milliseconds |
References buf_ptr, err, gau8SocketTestBuffer, i, len, Network::my_socket, NULL, NULL_VALUE_ERROR, printf, received_bytes, recv(), ret, SOCKET_MSG_RECV, SSL_READ_ERROR, and wait_for_event().
Referenced by iot_tls_init().
int iot_tls_write | ( | Network * | pNetwork, |
unsigned char * | pMsg, | ||
int | len, | ||
int | timeout_ms | ||
) |
Write bytes to the network socket.
Network | - Pointer to a Network struct defining the network interface. |
unsigned | char pointer - buffer to write to socket |
integer | - number of bytes to write |
integer | - write timeout value in milliseconds |
Write bytes to the network socket.
[in] | pNetwork | Network interface. |
[in] | pMsg | data to write |
[in] | len | length of data. |
[in] | timeout_ms | timeout for write function. |
References err, i, len, Network::my_socket, NULL, NULL_VALUE_ERROR, printf, ret, send(), sent_bytes, SOCKET_MSG_SEND, SSL_WRITE_ERROR, and wait_for_event().
Referenced by iot_tls_init().