• 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 
17 #ifndef LNN_CONNECTION_FSM_STRUCT_H
18 #define LNN_CONNECTION_FSM_STRUCT_H
19 
20 #include <stdint.h>
21 
22 #include "auth_interface_struct.h"
23 #include "common_list.h"
24 #include "lnn_net_builder_struct.h"
25 #include "lnn_node_info_struct.h"
26 #include "lnn_state_machine_struct.h"
27 #include "softbus_bus_center.h"
28 #include "softbus_common.h"
29 #include "legacy/softbus_hisysevt_bus_center.h"
30 
31 #ifdef __cplusplus
32 #if __cplusplus
33 extern "C" {
34 #endif
35 #endif
36 
37 #define LNN_CONNECTION_FSM_NAME_LEN 32
38 
39 #define LNN_CONN_INFO_FLAG_JOIN_REQUEST 0x01
40 #define LNN_CONN_INFO_FLAG_JOIN_AUTO 0x02
41 #define LNN_CONN_INFO_FLAG_JOIN_PASSIVE 0x04
42 #define LNN_CONN_INFO_FLAG_LEAVE_REQUEST 0x08
43 #define LNN_CONN_INFO_FLAG_LEAVE_AUTO 0x10
44 #define LNN_CONN_INFO_FLAG_LEAVE_PASSIVE 0x20
45 #define LNN_CONN_INFO_FLAG_INITIATE_ONLINE 0x40
46 #define LNN_CONN_INFO_FLAG_ONLINE 0x80
47 
48 #define LNN_CONN_INFO_FLAG_JOIN_ACTIVE (LNN_CONN_INFO_FLAG_JOIN_REQUEST | LNN_CONN_INFO_FLAG_JOIN_AUTO)
49 #define LNN_CONN_INFO_FLAG_JOIN (LNN_CONN_INFO_FLAG_JOIN_ACTIVE | LNN_CONN_INFO_FLAG_JOIN_PASSIVE)
50 
51 #define LNN_CONN_INFO_FLAG_LEAVE_ACTIVE (LNN_CONN_INFO_FLAG_LEAVE_REQUEST | LNN_CONN_INFO_FLAG_LEAVE_AUTO)
52 #define LNN_CONN_INFO_FLAG_LEAVE (LNN_CONN_INFO_FLAG_LEAVE_ACTIVE | LNN_CONN_INFO_FLAG_LEAVE_PASSIVE)
53 
54 typedef struct {
55     /* clean invalid addr type */
56     ConnectionAddrType addrType;
57     /* record newer connection networkId */
58     char networkId[NETWORK_ID_BUF_LEN];
59 } LnnInvalidCleanInfo;
60 
61 typedef struct {
62     char peerNetworkId[NETWORK_ID_BUF_LEN];
63     uint32_t requestId;
64     uint32_t flag;
65     SoftBusVersion version;
66     AuthHandle authHandle;
67     LnnDfxDeviceInfoReport infoReport;
68     ConnectionAddr addr;
69     LnnInvalidCleanInfo *cleanInfo;
70     NodeInfo *nodeInfo;
71     NodeInfo *dupInfo;
72 } LnnConntionInfo;
73 
74 struct tagLnnConnectionFsm;
75 
76 typedef void (*LnnConnectionFsmStopCallback)(struct tagLnnConnectionFsm *connFsm);
77 
78 typedef struct tagLnnConnectionFsm {
79     char fsmName[LNN_CONNECTION_FSM_NAME_LEN];
80     char pkgName[PKG_NAME_SIZE_MAX];
81     bool isDead;
82     bool isNeedConnect;
83     bool isSession;
84     uint16_t id;
85 
86     LnnConnectionFsmStopCallback stopCallback;
87     ListNode node;
88     LnnStatisticData statisticData;
89     FsmStateMachine fsm;
90     LnnConntionInfo connInfo;
91 } LnnConnectionFsm;
92 
93 #ifdef __cplusplus
94 #if __cplusplus
95 }
96 #endif /* __cplusplus */
97 #endif /* __cplusplus */
98 
99 #endif /* LNN_CONNECTION_FSM_STRUCT_H */