• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 LNN_NET_BUILDER_STRUCT_H
17 #define LNN_NET_BUILDER_STRUCT_H
18 
19 #include <stdint.h>
20 
21 #include "common_list.h"
22 #include "lnn_node_info_struct.h"
23 #include "message_handler.h"
24 #include "softbus_bus_center.h"
25 #include "softbus_common.h"
26 
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 typedef enum {
33     NODE_TYPE_C,
34     NODE_TYPE_L
35 } NodeType;
36 
37 #define JSON_KEY_NODE_CODE "NODE_CODE"
38 #define JSON_KEY_NODE_ADDR "NODE_ADDR"
39 #define JSON_KEY_NODE_PROXY_PORT "PROXY_PORT"
40 #define JSON_KEY_NODE_SESSION_PORT "SESSION_PORT"
41 
42 typedef enum {
43     MSG_TYPE_JOIN_LNN = 0,
44     MSG_TYPE_DISCOVERY_DEVICE,
45     MSG_TYPE_CLEAN_CONN_FSM,
46     MSG_TYPE_VERIFY_RESULT,
47     MSG_TYPE_DEVICE_VERIFY_PASS,
48     MSG_TYPE_DEVICE_DISCONNECT = 5,
49     MSG_TYPE_DEVICE_NOT_TRUSTED,
50     MSG_TYPE_LEAVE_LNN,
51     MSG_TYPE_SYNC_OFFLINE_FINISH,
52     MSG_TYPE_NODE_STATE_CHANGED,
53     MSG_TYPE_MASTER_ELECT = 10,
54     MSG_TYPE_LEAVE_INVALID_CONN,
55     MSG_TYPE_LEAVE_BY_ADDR_TYPE,
56     MSG_TYPE_LEAVE_SPECIFIC,
57     MSG_TYPE_LEAVE_BY_AUTH_ID,
58     MSG_TYPE_RE_SYNC_DEVICE_NAME = 15,
59     MSG_TYPE_BUILD_MAX,
60 } NetBuilderMessageType;
61 
62 typedef struct {
63     char nodeAddr[SHORT_ADDRESS_MAX_LEN];
64     int32_t code;
65     int32_t proxyPort;
66     int32_t sessionPort;
67     int32_t authPort;
68 } LnnNodeAddr;
69 
70 typedef struct {
71     char networkId[NETWORK_ID_BUF_LEN];
72     char pkgName[PKG_NAME_SIZE_MAX];
73     bool needReportFailure;
74     int32_t callingPid;
75     uint32_t requestId;
76     uint32_t flag;
77     ConnectionAddr addr;
78     int64_t authId;
79     ListNode node;
80 } MetaJoinRequestNode;
81 
82 typedef struct {
83     ListNode node;
84     ConnectionAddr addr;
85     bool needReportFailure;
86 } PendingJoinRequestNode;
87 
88 typedef struct {
89     NodeType nodeType;
90 
91     /* connection fsm list */
92     ListNode fsmList;
93     ListNode pendingList;
94     /* connection count */
95     int32_t connCount;
96 
97     SoftBusLooper *looper;
98     SoftBusHandler handler;
99 
100     int32_t maxConnCount;
101     int32_t maxConcurrentCount;
102     bool isInit;
103 } NetBuilder;
104 
105 typedef struct {
106     uint32_t requestId;
107     int32_t retCode;
108     NodeInfo *nodeInfo;
109     AuthHandle authHandle;
110 } VerifyResultMsgPara;
111 
112 typedef struct {
113     NodeInfo *nodeInfo;
114     AuthHandle authHandle;
115     ConnectionAddr addr;
116 } DeviceVerifyPassMsgPara;
117 
118 typedef struct {
119     char networkId[NETWORK_ID_BUF_LEN];
120     char masterUdid[UDID_BUF_LEN];
121     int32_t masterWeight;
122 } ElectMsgPara;
123 
124 typedef struct {
125     char oldNetworkId[NETWORK_ID_BUF_LEN];
126     char newNetworkId[NETWORK_ID_BUF_LEN];
127     ConnectionAddrType addrType;
128 } LeaveInvalidConnMsgPara;
129 
130 typedef struct {
131     char networkId[NETWORK_ID_BUF_LEN];
132     ConnectionAddrType addrType;
133 } SpecificLeaveMsgPara;
134 
135 typedef struct {
136     char pkgName[PKG_NAME_SIZE_MAX];
137     bool isNeedConnect;
138     bool isSession;
139     bool isForceJoin;
140     ConnectionAddr addr;
141     NodeInfo *dupInfo;
142     LnnDfxDeviceInfoReport infoReport;
143 } JoinLnnMsgPara;
144 
145 typedef struct {
146     char pkgName[PKG_NAME_SIZE_MAX];
147     char networkId[NETWORK_ID_BUF_LEN];
148 } LeaveLnnMsgPara;
149 
150 #ifdef __cplusplus
151 }
152 #endif
153 
154 #endif /* LNN_NET_BUILDER_STRUCT_H */