1 /* 2 * This file is part of the openHiTLS project. 3 * 4 * openHiTLS is licensed under the Mulan PSL v2. 5 * You can use this software according to the terms and conditions of the Mulan PSL v2. 6 * You may obtain a copy of Mulan PSL v2 at: 7 * 8 * http://license.coscl.org.cn/MulanPSL2 9 * 10 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 11 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 12 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 13 * See the Mulan PSL v2 for more details. 14 */ 15 16 #ifndef PROCESS_H 17 #define PROCESS_H 18 19 #include <sys/types.h> 20 #include <sys/socket.h> 21 #include <arpa/inet.h> 22 #include "hlt_type.h" 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 #define DOMAIN_PATH_LEN (128) 29 #define TLS_RES_MAX_NUM (64) 30 31 typedef struct ProcessSt { 32 TLS_TYPE tlsType; // Identifies whether the HiTLS interface is used. 33 char srcDomainPath[DOMAIN_PATH_LEN]; 34 char peerDomainPath[DOMAIN_PATH_LEN]; // This field is used only by remote processes. 35 int controlChannelFd; // This field is used only by the local process. 36 int remoteFlag; // Indicates whether the process is a remote process. The value 1 indicates a remote process. 37 int connFd; // FD used by the TLS link 38 int connType; // Enumerated value of HILT_TransportType, which is the communication protocol type used by the 39 // TLS link. 40 int connPort; 41 struct sockaddr_in sockAddr; 42 void* tlsResArray[TLS_RES_MAX_NUM]; // Stores ctx SSL resources. 43 int tlsResNum; // Number of created TLS resources 44 void* hltTlsResArray[TLS_RES_MAX_NUM]; // Stores the HLT_Tls_Res resource. This resource is used only 45 // by the local process. 46 int hltTlsResNum; // Number of created HLT_Tls_Res resources. 47 } Process; 48 49 /** 50 * @brief Initializes the global table used to represent command IDs. 51 */ 52 void InitCmdIndex(void); 53 54 /** 55 * @brief Initializing Process Resources 56 */ 57 int InitProcess(void); 58 59 /** 60 * @brief Obtaining Process Resources 61 */ 62 Process *GetProcess(void); 63 64 /** 65 * @brief Obtain the process from the linked list. 66 */ 67 Process *GetProcessFromList(void); 68 69 /** 70 * @brief Release the linked list of the storage process. 71 */ 72 void FreeProcessResList(void); 73 74 /** 75 * @brief Release process resources. 76 */ 77 void FreeProcess(void); 78 79 #ifdef __cplusplus 80 } 81 #endif 82 83 #endif // PROCESS_H