Mistake on this page? Email us
m2mconnectionsecurity.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 ARM Limited. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  * Licensed under the Apache License, Version 2.0 (the License); you may
5  * not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef __M2M_CONNECTION_SECURITY_H__
17 #define __M2M_CONNECTION_SECURITY_H__
18 
19 #include "mbed-client/m2mconfig.h"
20 
21 #include <stdint.h>
22 
24 class M2MSecurity;
25 class M2MConnectionSecurityPimpl;
27 
37 public:
38  typedef enum {
39  NO_SECURITY = 0,
40  TLS,
41  DTLS
42  } SecurityMode;
43 
44 private:
45  // Prevents the use of assignment operator by accident.
46  M2MConnectionSecurity& operator=( const M2MConnectionSecurity& /*other*/ );
47  // Prevents the use of copy constructor by accident.
48  M2MConnectionSecurity( const M2MConnectionSecurity& /*other*/ );
49 
50 public:
54  M2MConnectionSecurity(SecurityMode mode);
55 
60 
64  void reset();
65 
69  int init(const M2MSecurity *security, uint16_t security_instance_id, bool is_server_ping);
70 
77 
82  int continue_connecting();
83 
90  int connect(M2MConnectionHandler* connHandler, bool is_server_ping = false);
91 
98  int send_message(unsigned char *message, int len);
99 
106  int read(unsigned char* buffer, uint16_t len);
107 
115  void set_random_number_callback(random_number_cb callback);
116 
126  void set_entropy_callback(entropy_cb callback);
127 
134  void set_socket(void *socket, void *address);
135 
142  int set_dtls_socket_callback(void(*foo)(void*), void *argument);
143 
144  void update_network_rtt_estimate(uint8_t rtt_estimate);
145 
146  void store_cid();
147 
148  void remove_cid();
149 
150  bool is_cid_available();
151 
157  void set_cid_value(const uint8_t *data_ptr, const size_t data_len);
158 private:
159 
160  M2MConnectionSecurityPimpl* _private_impl;
161 
162  friend class Test_M2MConnectionSecurity;
163  //friend class Test_M2MConnectionSecurityImpl;
164 };
165 
166 #endif //__M2M_CONNECTION_SECURITY_H__
int send_message(unsigned char *message, int len)
Sends data to the server.
Definition: m2mconnectionhandler.h:30
int set_dtls_socket_callback(void(*foo)(void *), void *argument)
Set socket information for this secure connection.
int read(unsigned char *buffer, uint16_t len)
Reads the data received from the server.
int continue_connecting()
Continues connectivity logic for a secure connection.
void set_socket(void *socket, void *address)
Set socket information for this secure connection.
Definition: m2msecurity.h:31
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...
Definition: m2mconnectionsecurity.h:36
int init(const M2MSecurity *security, uint16_t security_instance_id, bool is_server_ping)
Initiatlizes the socket connection states.
~M2MConnectionSecurity()
Default Destructor.
void reset()
Resets the socket connection states.
Definition: m2mconfig.h:113
File defining all system build time configuration used by mbed-client.
void set_cid_value(const uint8_t *data_ptr, const size_t data_len)
Internal test function. Set CID for current tls session.
void set_entropy_callback(entropy_cb callback)
Sets the function callback that is called by mbed Client to provide an entropy source from an applica...
int connect(M2MConnectionHandler *connHandler, bool is_server_ping=false)
Connects the client to the server.
int start_connecting_non_blocking(M2MConnectionHandler *connHandler)
Starts the connection in non-blocking mode.