• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     ROUTE_TYPE_ALL = 0,
55     WIFI_STA = 1,
56     WIFI_P2P = 2,
57     BT_BR = 3,
58     BT_BLE = 4,
59     WIFI_P2P_REUSE = 6,
60 } RouteType;
61 
62 typedef enum {
63     UDP_CONN_TYPE_INVALID = -1,
64     UDP_CONN_TYPE_WIFI = 0,
65     UDP_CONN_TYPE_P2P = 1,
66 } UdpConnType;
67 
68 typedef enum {
69     TYPE_INVALID_CHANNEL = -1,
70     TYPE_UDP_CHANNEL_OPEN = 1,
71     TYPE_UDP_CHANNEL_CLOSE = 2,
72 } UdpChannelOptType;
73 
74 typedef struct {
75     ApiVersion apiVersion;
76     char deviceId[DEVICE_ID_SIZE_MAX];
77     char pkgName[PKG_NAME_SIZE_MAX];
78     char sessionName[SESSION_NAME_SIZE_MAX];
79     int uid;
80     int pid;
81     char authState[AUTH_STATE_SIZE_MAX];
82     char addr[IP_LEN];
83     int port;
84     int64_t channelId;
85     uint32_t dataConfig;
86 } AppInfoData;
87 
88 typedef struct {
89     char groupId[GROUP_ID_SIZE_MAX];
90     char sessionKey[SESSION_KEY_LENGTH];
91     char reqId[REQ_ID_SIZE_MAX];
92     char peerNetWorkId[DEVICE_ID_SIZE_MAX];
93     RouteType routeType;
94     BusinessType businessType;
95     StreamType streamType;
96     UdpConnType udpConnType;
97     UdpChannelOptType udpChannelOptType;
98     int fd;
99     AppType appType;
100     AppInfoData myData;
101     AppInfoData peerData;
102     ProtocolType protocol;
103     int32_t encrypt;
104     int32_t algorithm;
105     int32_t crc;
106     int32_t fileProtocol;
107     int32_t autoCloseTime;
108     int myHandleId;
109     int peerHandleId;
110     int32_t transFlag;
111     int64_t authSeq;
112     int32_t linkType;
113     int32_t channelType;
114     int32_t errorCode;
115     int64_t timeStart;
116     const uint8_t *fastTransData;
117     uint16_t fastTransDataSize;
118 } AppInfo;
119 
120 #ifdef __cplusplus
121 }
122 #endif // __cplusplus
123 #endif // SOFTBUS_APP_INFO_H