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