#include <m2mconnectionsecurity.h>
Public Types | |
enum | SecurityMode { NO_SECURITY = 0, TLS, DTLS } |
Public Member Functions | |
M2MConnectionSecurity (SecurityMode mode) | |
Default Constructor. | |
~M2MConnectionSecurity () | |
Default Destructor. | |
void | reset () |
Resets the socket connection states. | |
int | init (const M2MSecurity *security, uint16_t security_instance_id, bool is_server_ping) |
Initiatlizes the socket connection states. | |
int | start_connecting_non_blocking (M2MConnectionHandler *connHandler) |
Starts the connection in non-blocking mode. More... | |
int | continue_connecting () |
Continues connectivity logic for a secure connection. More... | |
int | connect (M2MConnectionHandler *connHandler, bool is_server_ping=false) |
Connects the client to the server. More... | |
int | send_message (unsigned char *message, int len) |
Sends data to the server. More... | |
int | read (unsigned char *buffer, uint16_t len) |
Reads the data received from the server. More... | |
void | set_random_number_callback (random_number_cb callback) |
Sets the function callback that is called by mbed Client to fetch a random number from an application to ensure strong entropy. More... | |
void | set_entropy_callback (entropy_cb callback) |
Sets the function callback that is called by mbed Client to provide an entropy source from an application to ensure strong entropy. More... | |
void | set_socket (void *socket, void *address) |
Set socket information for this secure connection. More... | |
int | set_dtls_socket_callback (void(*foo)(void *), void *argument) |
Set socket information for this secure connection. More... | |
void | update_network_rtt_estimate (uint8_t rtt_estimate) |
void | store_cid () |
void | remove_cid () |
bool | is_cid_available () |
void | set_cid_value (const uint8_t *data_ptr, const size_t data_len) |
Internal test function. Set CID for current tls session. More... | |
Friends | |
class | Test_M2MConnectionSecurity |
This class provides a method to create a secure socket connection.
Handles connectivity for the mbed Client. It handles sending, receiving and establishing a secure connection for mbed Client on top of the normal socket connection.
int M2MConnectionSecurity::connect | ( | M2MConnectionHandler * | connHandler, |
bool | is_server_ping = false |
||
) |
Connects the client to the server.
connHandler | The ConnectionHandler object that maintains the socket. |
is_server_ping | Defines whether the call is for Server ping or not. |
int M2MConnectionSecurity::continue_connecting | ( | ) |
Continues connectivity logic for a secure connection.
int M2MConnectionSecurity::read | ( | unsigned char * | buffer, |
uint16_t | len | ||
) |
Reads the data received from the server.
message | The data to be read. |
len | The length of the data. |
int M2MConnectionSecurity::send_message | ( | unsigned char * | message, |
int | len | ||
) |
Sends data to the server.
message | The data to be sent. |
len | The length of the data. |
void M2MConnectionSecurity::set_cid_value | ( | const uint8_t * | data_ptr, |
const size_t | data_len | ||
) |
Internal test function. Set CID for current tls session.
data_ptr | CID |
data_len | length of the CID |
int M2MConnectionSecurity::set_dtls_socket_callback | ( | void(*)(void *) | foo, |
void * | argument | ||
) |
Set socket information for this secure connection.
socket | Socket used with this TLS session. |
address | Pointer to the address of the server. |
void M2MConnectionSecurity::set_entropy_callback | ( | entropy_cb | callback | ) |
Sets the function callback that is called by mbed Client to provide an entropy source from an application to ensure strong entropy.
entropy_callback | A function pointer that is called by mbed-client while performing a secure handshake. Function signature, if using mbed-client-mbedtls, should be int (*mbedtls_entropy_f_source_ptr)(void *data, unsigned char *output, size_t len, size_t *olen); |
void M2MConnectionSecurity::set_random_number_callback | ( | random_number_cb | callback | ) |
Sets the function callback that is called by mbed Client to fetch a random number from an application to ensure strong entropy.
random_callback | A function pointer that is called by mbed Client while performing a secure handshake. The function signature should be uint32_t (*random_number_callback)(void); |
void M2MConnectionSecurity::set_socket | ( | void * | socket, |
void * | address | ||
) |
Set socket information for this secure connection.
socket | Socket used with this TLS session. |
address | Pointer to the address of the server. |
int M2MConnectionSecurity::start_connecting_non_blocking | ( | M2MConnectionHandler * | connHandler | ) |
Starts the connection in non-blocking mode.
connHandler | The ConnectionHandler object that maintains the socket. |