• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 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 "inner_socket.h"
20 #include "session.h"
21 #include "softbus_common.h"
22 #include "softbus_def.h"
23 #include "softbus_protocol_def.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif // __cplusplus
28 
29 #define APP_INFO_FILE_FEATURES_SUPPORT 1
30 #define APP_INFO_FILE_FEATURES_NO_SUPPORT 0
31 
32 #define APP_INFO_ALGORITHM_AES_GCM_256 0
33 #define APP_INFO_ALGORITHM_CHACHA 1
34 
35 #define APP_INFO_UDP_FILE_PROTOCOL 0x5a
36 
37 #define TRANS_FLAG_HAS_CHANNEL_AUTH 0x02L
38 
39 #define MAX_FAST_DATA_LEN (4 * 1024)
40 #define BASE64_FAST_DATA_LEN 5558
41 #define TOKENID_NOT_SET 0
42 #define ACCOUNT_UID_LEN_MAX 65
43 #define PAGING_NONCE_LEN 16
44 
45 typedef enum {
46     API_UNKNOWN = 0,
47     API_V1 = 1,
48     API_V2 = 2,
49 } ApiVersion;
50 
51 typedef enum {
52     APP_TYPE_NOT_CARE,
53     APP_TYPE_NORMAL,
54     APP_TYPE_AUTH,
55     APP_TYPE_INNER
56 } AppType;
57 
58 typedef enum {
59     TRANS_CONN_ALL = 0,
60     TRANS_CONN_P2P = 1,
61     TRANS_CONN_HML = 2,
62 } TransConnType;
63 
64 typedef enum {
65     ROUTE_TYPE_ALL = 0,
66     WIFI_STA = 1,
67     WIFI_P2P = 2,
68     BT_BR = 3,
69     BT_BLE = 4,
70     WIFI_P2P_REUSE = 6,
71     WIFI_USB = 7,
72     BT_SLE = 8,
73 } RouteType;
74 
75 typedef enum {
76     UDP_CONN_TYPE_INVALID = -1,
77     UDP_CONN_TYPE_WIFI = 0,
78     UDP_CONN_TYPE_P2P = 1,
79     UDP_CONN_TYPE_USB = 2,
80 } UdpConnType;
81 
82 typedef enum {
83     TYPE_INVALID_CHANNEL = -1,
84     TYPE_UDP_CHANNEL_OPEN = 1,
85     TYPE_UDP_CHANNEL_CLOSE = 2,
86 } UdpChannelOptType;
87 
88 typedef struct {
89     char deviceId[DEVICE_ID_SIZE_MAX];
90     char pkgName[PKG_NAME_SIZE_MAX];
91     char sessionName[SESSION_NAME_SIZE_MAX];
92     char authState[AUTH_STATE_SIZE_MAX];
93     char addr[IP_LEN];
94     char mac[MAC_MAX_LEN];
95     char accountId[ACCOUNT_UID_LEN_MAX];
96     char callerAccountId[ACCOUNT_UID_LEN_MAX];
97     char calleeAccountId[ACCOUNT_UID_LEN_MAX];
98     uint8_t shortAccountHash[D2D_SHORT_ACCOUNT_HASH_LEN];
99     uint8_t shortUdidHash[D2D_SHORT_UDID_HASH_LEN];
100     char extraData[EXTRA_DATA_MAX_LEN];
101     uint32_t dataLen;
102     uint32_t businessFlag;
103     int32_t uid;
104     int32_t pid;
105     int32_t port;
106     ApiVersion apiVersion;
107     uint32_t dataConfig;
108     int32_t userId;
109     int32_t userKeyId;
110     int64_t channelId;
111     uint64_t tokenId; // identify first caller
112     int32_t tokenType;
113     int32_t sessionId;
114     uint32_t devTypeId;
115 } AppInfoData;
116 
117 typedef struct {
118     char groupId[GROUP_ID_SIZE_MAX];
119     char sessionKey[SESSION_KEY_LENGTH];
120     char sinkSessionKey[SESSION_KEY_LENGTH];
121     char reqId[REQ_ID_SIZE_MAX];
122     char peerNetWorkId[DEVICE_ID_SIZE_MAX];
123     char peerUdid[DEVICE_ID_SIZE_MAX];
124     char peerVersion[DEVICE_VERSION_SIZE_MAX];
125     char tokenName[PKG_NAME_SIZE_MAX];
126     char extraAccessInfo[EXTRA_ACCESS_INFO_LEN_MAX];
127     char pagingNonce[PAGING_NONCE_LEN];
128     char pagingSessionkey[SHORT_SESSION_KEY_LENGTH];
129     bool isClient;
130     bool isD2D;
131     bool isLowLatency;
132     bool isFlashLight;
133     uint16_t fastTransDataSize;
134     RouteType routeType;
135     StreamType streamType;
136     BusinessType businessType;
137     UdpConnType udpConnType;
138     UdpChannelOptType udpChannelOptType;
139     BlePriority blePriority;
140     TransFlowInfo flowInfo;
141     int fd;
142     AppType appType;
143     ProtocolType protocol;
144     int32_t pagingId;
145     int32_t encrypt;
146     int32_t algorithm;
147     int32_t crc;
148     int32_t fileProtocol;
149     int32_t autoCloseTime;
150     int32_t myHandleId;
151     int32_t peerHandleId;
152     int32_t transFlag;
153     int32_t linkType;
154     int32_t connectType;
155     int32_t channelType;
156     int32_t errorCode;
157     uint64_t callingTokenId; // for transmission access control
158     int32_t osType;
159     int32_t waitOpenReplyCnt;
160     uint32_t channelCapability;
161     const uint8_t *fastTransData;
162     int64_t timeStart;
163     int64_t connectedStart;
164     int64_t authSeq;
165     AppInfoData myData;
166     AppInfoData peerData;
167     ProtocolType fdProtocol;
168 } AppInfo;
169 
170 enum {
171     FLAG_BYTES = 0,
172     FLAG_ACK = 1,
173     FLAG_MESSAGE = 2,
174     FILE_FIRST_FRAME = 3,
175     FILE_ONGOINE_FRAME = 4,
176     FILE_LAST_FRAME = 5,
177     FILE_ONLYONE_FRAME = 6,
178     FILE_ALLFILE_SENT = 7,
179     FLAG_ASYNC_MESSAGE = 8,
180     FLAG_SET_LOW_LATENCY = 9
181 };
182 
183 #ifdef __cplusplus
184 }
185 #endif // __cplusplus
186 #endif // SOFTBUS_APP_INFO_H