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);
70 
77 
82  int continue_connecting();
83 
89  int connect(M2MConnectionHandler* connHandler);
90 
97  int send_message(unsigned char *message, int len);
98 
105  int read(unsigned char* buffer, uint16_t len);
106 
114  void set_random_number_callback(random_number_cb callback);
115 
125  void set_entropy_callback(entropy_cb callback);
126 
133  void set_socket(void *socket, void *address);
134 
141  int set_dtls_socket_callback(void(*foo)(void*), void *argument);
142 
143 private:
144 
145  M2MConnectionSecurityPimpl* _private_impl;
146 
147  friend class Test_M2MConnectionSecurity;
148  //friend class Test_M2MConnectionSecurityImpl;
149 };
150 
151 #endif //__M2M_CONNECTION_SECURITY_H__
int send_message(unsigned char *message, int len)
Sends data to the server.
Definition: m2mconnectionhandler.h:32
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
~M2MConnectionSecurity()
Default Destructor.
void reset()
Resets the socket connection states.
Definition: m2mconfig.h:116
File defining all system build time configuration used by mbed-client.
int connect(M2MConnectionHandler *connHandler)
Connects the client to the server.
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 init(const M2MSecurity *security, uint16_t security_instance_id)
Initiatlizes the socket connection states.
int start_connecting_non_blocking(M2MConnectionHandler *connHandler)
Starts the connection in non-blocking mode.