1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef SOFTBUS_DEF_H 16 #define SOFTBUS_DEF_H 17 18 #include <pthread.h> 19 #include "common_list.h" 20 #include "softbus_adapter_thread.h" 21 #include "stdint.h" 22 23 24 #ifdef __cplusplus 25 #if __cplusplus 26 extern "C" { 27 #endif 28 #endif 29 30 #define INVALID_SESSION_ID (-1) 31 #define INVALID_CHANNEL_ID (-1) 32 33 #define PKG_NAME_SIZE_MAX 65 34 #define SESSION_NAME_SIZE_MAX 256 35 #define DEVICE_ID_SIZE_MAX 65 36 #define GROUP_ID_SIZE_MAX 65 37 #define REQ_ID_SIZE_MAX 65 38 #define AUTH_STATE_SIZE_MAX 65 39 #define FILE_RECV_ROOT_DIR_SIZE_MAX 256 40 41 #define MAX_DEV_INFO_VALUE_LEN 65 42 #define MAX_CAPABILITY_LEN 33 43 #define MAX_CAPABILITY_DATA_LEN 512 44 #define MAX_PACKAGE_NAME_LEN 33 45 #define MAX_DEV_INFO_COUNT 32 46 #define MAX_PUBLISH_INFO_COUNT 32 47 #define IP_LEN 46 48 #define MAX_PEERS_NUM 32 49 #define MAX_OPERATION_CODE_LEN 32 50 #define SESSION_KEY_LENGTH 32 51 #define DEVICE_KEY_LEN 16 52 53 #define MAX_SESSION_ID 16 54 #define MAX_SESSION_SERVER_NUMBER 8 55 56 #define WAIT_SERVER_READY_INTERVAL 200 57 58 typedef struct { 59 SoftBusMutex lock; 60 unsigned int cnt; 61 ListNode list; 62 } SoftBusList; 63 64 typedef enum { 65 SEC_TYPE_UNKNOWN = 0, 66 SEC_TYPE_PLAINTEXT = 1, 67 SEC_TYPE_CIPHERTEXT = 2, 68 } SoftBusSecType; 69 70 /* Timer type */ 71 enum { 72 TIMER_TYPE_ONCE, 73 TIMER_TYPE_PERIOD, 74 TIMER_TYPE_MAX, 75 }; 76 77 typedef enum { 78 TRANS_SESSION_BYTES = 0, 79 TRANS_SESSION_MESSAGE, 80 TRANS_SESSION_FILE_FIRST_FRAME = 3, 81 TRANS_SESSION_FILE_ONGOINE_FRAME, 82 TRANS_SESSION_FILE_LAST_FRAME, 83 TRANS_SESSION_FILE_ONLYONE_FRAME, 84 TRANS_SESSION_FILE_ALLFILE_SENT, 85 } SessionPktType; 86 87 typedef enum { 88 CHANNEL_TYPE_TCP_DIRECT = 0, 89 CHANNEL_TYPE_PROXY, 90 CHANNEL_TYPE_UDP, 91 CHANNEL_TYPE_AUTH, 92 CHANNEL_TYPE_BUTT, 93 } ChannelType; 94 95 typedef enum { 96 BUSINESS_TYPE_MESSAGE = 1, 97 BUSINESS_TYPE_BYTE = 2, 98 BUSINESS_TYPE_FILE = 3, 99 BUSINESS_TYPE_STREAM = 4, 100 } BusinessType; 101 102 typedef struct { 103 int32_t channelId; 104 int32_t channelType; 105 int32_t businessType; 106 int32_t fd; 107 bool isServer; 108 bool isEnabled; 109 int32_t peerUid; 110 int32_t peerPid; 111 char *groupId; 112 uint32_t keyLen; 113 char *sessionKey; 114 char *peerSessionName; 115 char *peerDeviceId; 116 char *myIp; 117 char *peerIp; 118 int32_t peerPort; 119 int32_t routeType; 120 } ChannelInfo; 121 122 #ifdef __cplusplus 123 #if __cplusplus 124 } 125 #endif /* __cplusplus */ 126 #endif /* __cplusplus */ 127 #endif /* SOFTBUS_DEF_H */ 128 129