• 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_MESSAGE_OPEN_CHANNEL_H
17 #define SOFTBUS_MESSAGE_OPEN_CHANNEL_H
18 
19 #include "cJSON.h"
20 #include "softbus_app_info.h"
21 
22 #define CODE "CODE"
23 #define ERR_CODE "ERR_CODE"
24 #define ERR_DESC "ERR_DESC"
25 #define API_VERSION "API_VERSION"
26 #define DEVICE_ID "DEVICE_ID"
27 #define BUS_NAME "BUS_NAME"
28 #define GROUP_ID "GROUP_ID"
29 #define UID "UID"
30 #define PID "PID"
31 #define SESSION_KEY "SESSION_KEY"
32 #define MTU_SIZE "MTU_SIZE"
33 #define PKG_NAME "PKG_NAME"
34 #define CLIENT_BUS_NAME "CLIENT_BUS_NAME"
35 #define AUTH_STATE "AUTH_STATE"
36 #define MSG_ROUTE_TYPE "ROUTE_TYPE"
37 #define BUSINESS_TYPE "BUSINESS_TYPE"
38 #define AUTO_CLOSE_TIME "AUTO_CLOSE_TIME"
39 #define TRANS_FLAGS "TRANS_FLAGS"
40 #define MIGRATE_OPTION "MIGRATE_OPTION"
41 #define MY_HANDLE_ID "MY_HANDLE_ID"
42 #define PEER_HANDLE_ID "PEER_HANDLE_ID"
43 #define FIRST_DATA "FIRST_DATA"
44 #define FIRST_DATA_SIZE "FIRST_DATA_SIZE"
45 #define JSON_KEY_CALLING_TOKEN_ID "CALLING_TOKEN_ID"
46 #define ACCOUNT_ID "ACCOUNT_ID"
47 #define USER_ID "USER_ID"
48 #define SOURCE_ACL_TOKEN_ID "SOURCE_ACL_TOKEN_ID"
49 #define SOURCE_ACL_EXTRA_INFO "SOURCE_ACL_EXTRA_INFO"
50 #define SINK_ACL_ACCOUNT_ID "SINK_ACL_ACCOUNT_ID"
51 #define SINK_ACL_USER_ID "SINK_ACL_USER_ID"
52 #define SINK_ACL_TOKEN_ID "SINK_ACL_TOKEN_ID"
53 
54 #define TRANS_CAPABILITY "TRANS_CAPABILITY"
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif // __cplusplus
59 
60 typedef enum {
61     CODE_OPEN_CHANNEL = 1,
62 } MessageCode;
63 
64 #define FAST_DATA_HEAD_SIZE 16
65 #define FAST_BYTE_TOS 0x60
66 #define FAST_MESSAGE_TOS 0xC0
67 
68 typedef struct {
69     uint32_t magicNumber;
70     int32_t seq;
71     uint32_t flags;
72     uint32_t dataLen;
73 } __attribute__((packed)) TcpFastDataPacketHead;
74 
75 #define FAST_TDC_EXT_DATA_SIZE (OVERHEAD_LEN + sizeof(TcpFastDataPacketHead))
76 
77 char *PackRequest(const AppInfo *appInfo, int64_t requestId);
78 
79 int32_t UnpackRequest(const cJSON *msg, AppInfo *appInfo);
80 
81 char *PackReply(const AppInfo *appInfo);
82 
83 int32_t UnpackReply(const cJSON *msg, AppInfo *appInfo, uint16_t *fastDataSize);
84 
85 char *PackError(int errCode, const char *errDesc);
86 
87 int32_t UnpackReplyErrCode(const cJSON *msg, int32_t *errCode);
88 
89 char *TransTdcPackFastData(const AppInfo *appInfo, uint32_t *outLen);
90 
91 #ifdef __cplusplus
92 }
93 #endif // __cplusplus
94 #endif // SOFTBUS_MESSAGE_OPEN_CHANNEL
95