Mistake on this page? Email us
M2MConnectionSecurity Class Reference

#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
 

Detailed Description

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.

Member Function Documentation

int M2MConnectionSecurity::connect ( M2MConnectionHandler connHandler,
bool  is_server_ping = false 
)

Connects the client to the server.

Parameters
connHandlerThe ConnectionHandler object that maintains the socket.
is_server_pingDefines whether the call is for Server ping or not.
Returns
Returns the state of the connection. Successful or not.
int M2MConnectionSecurity::continue_connecting ( )

Continues connectivity logic for a secure connection.

Returns
Returns an error code if any while continuing the connection sequence.
int M2MConnectionSecurity::read ( unsigned char *  buffer,
uint16_t  len 
)

Reads the data received from the server.

Parameters
messageThe data to be read.
lenThe length of the data.
Returns
Indicates whether the data is read successfully or not.
int M2MConnectionSecurity::send_message ( unsigned char *  message,
int  len 
)

Sends data to the server.

Parameters
messageThe data to be sent.
lenThe length of the data.
Returns
Indicates whether the data is sent successfully or not.
void M2MConnectionSecurity::set_cid_value ( const uint8_t *  data_ptr,
const size_t  data_len 
)

Internal test function. Set CID for current tls session.

Parameters
data_ptrCID
data_lenlength of the CID
int M2MConnectionSecurity::set_dtls_socket_callback ( void(*)(void *)  foo,
void *  argument 
)

Set socket information for this secure connection.

Parameters
socketSocket used with this TLS session.
addressPointer to the address of the server.
Returns
Indicates whether the data is read successfully or not.
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.

Parameters
entropy_callbackA 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.

Parameters
random_callbackA 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.

Parameters
socketSocket used with this TLS session.
addressPointer to the address of the server.
Returns
Indicates whether the data is read successfully or not.
int M2MConnectionSecurity::start_connecting_non_blocking ( M2MConnectionHandler connHandler)

Starts the connection in non-blocking mode.

Parameters
connHandlerThe ConnectionHandler object that maintains the socket.
Returns
Returns the state of the connection. Successful or not.

The documentation for this class was generated from the following file: