Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Socket lwip-eth lwip-sys lwip
Fork of 6_songs-from-the-cloud by
m2mconnectionsecurity.h
00001 /* 00002 * Copyright (c) 2015 ARM Limited. All rights reserved. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * Licensed under the Apache License, Version 2.0 (the License); you may 00005 * not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #ifndef __M2M_CONNECTION_SECURITY_H__ 00017 #define __M2M_CONNECTION_SECURITY_H__ 00018 00019 class M2MConnectionHandler; 00020 class M2MSecurity; 00021 class M2MConnectionSecurityPimpl; 00022 00023 /** 00024 * @brief M2MConnectionSecurity. 00025 * This class provides a method to create a secure socket connection 00026 * to handle connectivity for the mbed Client. It will handle sending, receiving 00027 * and establishing a secure connection for the mbed Client on top of the 00028 * normal socket connection. 00029 */ 00030 00031 class M2MConnectionSecurity { 00032 public: 00033 typedef enum { 00034 NO_SECURITY = 0, 00035 TLS, 00036 DTLS 00037 } SecurityMode; 00038 00039 private: 00040 // Prevents the use of assignment operator by accident. 00041 M2MConnectionSecurity& operator=( const M2MConnectionSecurity& /*other*/ ); 00042 // Prevents the use of copy constructor by accident. 00043 M2MConnectionSecurity( const M2MConnectionSecurity& /*other*/ ); 00044 00045 public: 00046 /** 00047 * @brief Default Constructor. 00048 */ 00049 M2MConnectionSecurity(SecurityMode mode); 00050 00051 /** 00052 * @brief Default Destructor. 00053 */ 00054 ~M2MConnectionSecurity(); 00055 00056 /** 00057 * @brief Resets the socket connection states. 00058 */ 00059 void reset(); 00060 00061 /** 00062 * @brief Initiatlizes the socket connection states. 00063 */ 00064 int init(const M2MSecurity *security); 00065 00066 /** 00067 * @brief Starts the connection in non-blocking mode. 00068 * @param connHandler, ConnectionHandler object that maintains the socket. 00069 * @return Returns the state of the connection. Successful or not. 00070 */ 00071 int start_connecting_non_blocking(M2MConnectionHandler* connHandler); 00072 00073 /** 00074 * @brief Continues connectivity logic for secure connection. 00075 * @return Returns error code if any while continuing connection sequence. 00076 */ 00077 int continue_connecting(); 00078 00079 /** 00080 * @brief Connects the client to the server. 00081 * @param connHandler, ConnectionHandler object that maintains the socket. 00082 * @return Returns the state of the connection. Successful or not. 00083 */ 00084 int connect(M2MConnectionHandler* connHandler); 00085 00086 /** 00087 * @brief Sends data to the server. 00088 * @param message, Data to be sent. 00089 * @param len, Length of the data. 00090 * @return Indicates whether the data is sent successfully or not. 00091 */ 00092 int send_message(unsigned char *message, int len); 00093 00094 /** 00095 * @brief Reads the data received from the server. 00096 * @param message, Data to be read. 00097 * @param len, Length of the data. 00098 * @return Indicates whether the data is read successfully or not. 00099 */ 00100 int read(unsigned char* buffer, uint16_t len); 00101 00102 private: 00103 00104 M2MConnectionSecurityPimpl* _private_impl; 00105 00106 friend class Test_M2MConnectionSecurity; 00107 //friend class Test_M2MConnectionSecurityImpl; 00108 }; 00109 00110 #endif //__M2M_CONNECTION_SECURITY_H__
Generated on Tue Jul 12 2022 12:47:47 by
1.7.2
