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 16 #ifndef SOFTBUS_APP_INFO_H 17 #define SOFTBUS_APP_INFO_H 18 19 #include "session.h" 20 #include "softbus_def.h" 21 #include "softbus_protocol_def.h" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif // __cplusplus 26 27 #define APP_INFO_FILE_FEATURES_SUPPORT 1 28 #define APP_INFO_FILE_FEATURES_NO_SUPPORT 0 29 30 #define APP_INFO_ALGORITHM_AES_GCM_256 0 31 #define APP_INFO_ALGORITHM_CHACHA 1 32 33 #define APP_INFO_UDP_FILE_PROTOCOL 0x5a 34 35 #define TRANS_FLAG_HAS_CHANNEL_AUTH 0x02L 36 37 #define MAX_FAST_DATA_LEN (4 * 1024) 38 #define BASE64_FAST_DATA_LEN 5558 39 40 typedef enum { 41 API_UNKNOWN = 0, 42 API_V1 = 1, 43 API_V2 = 2, 44 } ApiVersion; 45 46 typedef enum { 47 APP_TYPE_NOT_CARE, 48 APP_TYPE_NORMAL, 49 APP_TYPE_AUTH, 50 APP_TYPE_INNER 51 } AppType; 52 53 typedef enum { 54 TRANS_CONN_ALL = 0, 55 TRANS_CONN_P2P = 1, 56 TRANS_CONN_HML = 2, 57 } TransConnType; 58 59 typedef enum { 60 ROUTE_TYPE_ALL = 0, 61 WIFI_STA = 1, 62 WIFI_P2P = 2, 63 BT_BR = 3, 64 BT_BLE = 4, 65 WIFI_P2P_REUSE = 6, 66 } RouteType; 67 68 typedef enum { 69 UDP_CONN_TYPE_INVALID = -1, 70 UDP_CONN_TYPE_WIFI = 0, 71 UDP_CONN_TYPE_P2P = 1, 72 } UdpConnType; 73 74 typedef enum { 75 TYPE_INVALID_CHANNEL = -1, 76 TYPE_UDP_CHANNEL_OPEN = 1, 77 TYPE_UDP_CHANNEL_CLOSE = 2, 78 } UdpChannelOptType; 79 80 typedef struct { 81 ApiVersion apiVersion; 82 char deviceId[DEVICE_ID_SIZE_MAX]; 83 char pkgName[PKG_NAME_SIZE_MAX]; 84 char sessionName[SESSION_NAME_SIZE_MAX]; 85 int uid; 86 int pid; 87 char authState[AUTH_STATE_SIZE_MAX]; 88 char addr[IP_LEN]; 89 int port; 90 int64_t channelId; 91 uint32_t dataConfig; 92 } AppInfoData; 93 94 typedef struct { 95 char groupId[GROUP_ID_SIZE_MAX]; 96 char sessionKey[SESSION_KEY_LENGTH]; 97 char reqId[REQ_ID_SIZE_MAX]; 98 char peerNetWorkId[DEVICE_ID_SIZE_MAX]; 99 RouteType routeType; 100 BusinessType businessType; 101 StreamType streamType; 102 UdpConnType udpConnType; 103 UdpChannelOptType udpChannelOptType; 104 int fd; 105 AppType appType; 106 AppInfoData myData; 107 AppInfoData peerData; 108 ProtocolType protocol; 109 int32_t encrypt; 110 int32_t algorithm; 111 int32_t crc; 112 int32_t fileProtocol; 113 int32_t autoCloseTime; 114 int myHandleId; 115 int peerHandleId; 116 int32_t transFlag; 117 int64_t authSeq; 118 int32_t linkType; 119 int32_t connectType; 120 int32_t channelType; 121 int32_t errorCode; 122 int64_t timeStart; 123 int64_t connectedStart; 124 const uint8_t *fastTransData; 125 uint16_t fastTransDataSize; 126 } AppInfo; 127 128 #ifdef __cplusplus 129 } 130 #endif // __cplusplus 131 #endif // SOFTBUS_APP_INFO_H