• 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 LNN_NODE_INFO_STRUCT_H
17 #define LNN_NODE_INFO_STRUCT_H
18 
19 #include <stdbool.h>
20 #include <stdint.h>
21 
22 #include "bus_center_info_key_struct.h"
23 #include "lnn_connect_info_struct.h"
24 #include "lnn_device_info_struct.h"
25 #include "softbus_def.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #define WIFI_SSID_LEN 32
32 #define WIFI_MAC_LEN 6
33 #define OFFLINE_CODE_LEN 32
34 #define OFFLINE_CODE_BYTE_SIZE 4
35 #define EXTDATA_LEN 8
36 #define PTK_DEFAULT_LEN 32
37 #define STATIC_CAP_LEN 100
38 #define USERID_CHECKSUM_LEN 4
39 #define USERID_LEN 4
40 #define STATIC_CAP_STR_LEN 201
41 #define PTK_ENCODE_LEN 45
42 
43 #define LNN_RELATION_MASK 0x03
44 #define WIFI_CFG_INFO_MAX_LEN 512
45 #define CHANNEL_LIST_STR_LEN  256
46 
47 #define SESSION_KEY_STR_LEN 65
48 #define PTK_STR_LEN 65
49 
50 #define BROADCAST_IV_LEN 16
51 #define BROADCAST_IV_STR_LEN 33
52 
53 #define LFINDER_UDID_HASH_LEN 32
54 #define LFINDER_IRK_LEN 16
55 #define LFINDER_IRK_STR_LEN 33
56 #define LFINDER_MAC_ADDR_LEN 6
57 #define LFINDER_MAC_ADDR_STR_LEN 13
58 
59 typedef enum {
60     AUTH_AS_CLIENT_SIDE = 0,
61     AUTH_AS_SERVER_SIDE,
62     AUTH_SIDE_MAX,
63 } AuthSide;
64 
65 typedef enum {
66     ROLE_UNKNOWN = 0,
67     ROLE_CONTROLLER,
68     ROLE_LEAF,
69 } ConnectRole;
70 
71 typedef enum {
72     STATUS_OFFLINE = 0,
73     STATUS_ONLINE,
74 } ConnectStatus;
75 
76 typedef enum {
77     DISCOVERY_TYPE_UNKNOWN = 0,
78     DISCOVERY_TYPE_WIFI,
79     DISCOVERY_TYPE_BLE,
80     DISCOVERY_TYPE_BR,
81     DISCOVERY_TYPE_P2P,
82     DISCOVERY_TYPE_LSA,
83     DISCOVERY_TYPE_SLE,
84     DISCOVERY_TYPE_SESSION_KEY,
85     DISCOVERY_TYPE_USB,
86     DISCOVERY_TYPE_COUNT,
87 } DiscoveryType;
88 
89 typedef enum {
90     ACL_WRITE_DEFAULT = 0,
91     ACL_CAN_WRITE,
92     ACL_NOT_WRITE,
93 } AclWriteState;
94 
95 typedef struct {
96     char ssid[WIFI_SSID_LEN + 1];
97     unsigned char targetBssid[WIFI_MAC_LEN];
98 } BssTransInfo;
99 
100 typedef struct {
101     int32_t p2pRole;
102     char wifiCfg[WIFI_CFG_INFO_MAX_LEN];
103     char chanList5g[CHANNEL_LIST_STR_LEN];
104     int32_t staFrequency;
105     char p2pMac[MAC_LEN]; // the mac of local p2p interface
106     char goMac[MAC_LEN]; // the mac of p2p Go device, while local device as Gc role.
107     char p2pIp[IP_LEN];
108 } P2pInfo;
109 
110 typedef struct {
111     bool isMetaNode;
112     uint32_t metaDiscType;
113 } MetaInfo;
114 
115 typedef struct {
116     bool isCharging;
117     int32_t batteryLevel;
118 } BatteryInfo;
119 
120 typedef enum {
121     BIT_SUPPORT_EXCHANGE_NETWORKID = 0,
122     BIT_SUPPORT_NORMALIZED_LINK = 1,
123     BIT_SUPPORT_NEGOTIATION_AUTH = 2,
124     BIT_SUPPORT_BR_DUP_BLE = 3,
125     BIT_SUPPORT_ADV_OFFLINE = 4,
126     BIT_SUPPORT_ENHANCEDP2P_DUP_BLE = 5,
127     BIT_SUPPORT_SESSION_DUP_BLE = 6,
128     BIT_SUPPORT_USERKEY_NEGO = 7,
129 } AuthCapability;
130 
131 typedef struct {
132     int32_t keylen;
133     unsigned char key[SESSION_KEY_LENGTH];
134     unsigned char iv[BROADCAST_IV_LEN];
135 } BroadcastCipherInfo;
136 
137 typedef struct {
138     uint8_t peerIrk[LFINDER_IRK_LEN];
139     unsigned char publicAddress[LFINDER_MAC_ADDR_LEN];
140     unsigned char peerUdidHash[LFINDER_UDID_HASH_LEN];
141 } RpaInfo;
142 
143 typedef struct {
144     char softBusVersion[VERSION_MAX_LEN];
145     char versionType[VERSION_MAX_LEN]; // compatible nearby
146     char pkgVersion[VERSION_MAX_LEN];
147     char uuid[UUID_BUF_LEN]; // compatible nearby
148     char lastNetworkId[NETWORK_ID_BUF_LEN];
149     char networkId[NETWORK_ID_BUF_LEN];
150     char publicId[ID_MAX_LEN];
151     char parentId[ID_MAX_LEN];
152     char masterUdid[UDID_BUF_LEN];
153     char nodeAddress[SHORT_ADDRESS_MAX_LEN];
154     char extData[EXTDATA_LEN];
155     char wifiDirectAddr[MAC_LEN];
156     char accountHash[SHA_256_HASH_LEN];
157     char accountUid[ACCOUNT_UID_STR_LEN];
158     unsigned char offlineCode[OFFLINE_CODE_BYTE_SIZE];
159     char remotePtk[PTK_DEFAULT_LEN];
160     char remoteMetaPtk[PTK_DEFAULT_LEN];
161     bool isNeedReSyncDeviceName;
162     bool isScreenOn;
163     bool initPreventFlag;
164     bool isAuthExchangeUdid;
165     bool isSupportIpv6;
166     bool isBleP2p; // true: this device support connect p2p via ble connection
167     bool isSupportSv;
168     uint8_t staticCapability[STATIC_CAP_LEN];
169     uint8_t relation[CONNECTION_ADDR_MAX];
170     uint8_t userIdCheckSum[USERID_CHECKSUM_LEN];
171     uint16_t dataChangeFlag;
172     uint16_t dataDynamicLevel;
173     uint16_t dataStaticLevel;
174     uint32_t dataSwitchLevel;
175     uint16_t dataSwitchLength;
176     BssTransInfo bssTransInfo;
177     RpaInfo rpaInfo;
178     int32_t masterWeight;
179     ConnectRole role;
180     ConnectStatus status;
181     uint32_t staticNetCap;
182     uint32_t netCapacity;
183     uint32_t authCapacity;
184     uint32_t heartbeatCapacity;
185     uint32_t discoveryType;
186     int32_t wifiBuffSize;
187     int32_t brBuffSize;
188     int32_t stateVersion;
189     int32_t localStateVersion;
190     uint32_t groupType;
191     int32_t bleMacRefreshSwitch;
192     int32_t bleConnCloseDelayTime;
193     int32_t staticCapLen;
194     int32_t userId;
195     uint32_t stateVersionReason;
196     int32_t deviceSecurityLevel;
197     int32_t authChannelId[CONNECTION_ADDR_MAX][AUTH_SIDE_MAX];
198     uint32_t AuthTypeValue;
199     DeviceBasicInfo deviceInfo;
200     P2pInfo p2pInfo;
201     MetaInfo metaInfo;
202     BatteryInfo batteryInfo;
203     BroadcastCipherInfo cipherInfo;
204     int64_t wifiVersion;
205     int64_t bleVersion;
206     uint64_t feature;
207     uint64_t connSubFeature;
208     int64_t bleStartTimestamp;
209     uint64_t supportedProtocols;
210     int64_t accountId;
211     int64_t authSeq[DISCOVERY_TYPE_COUNT];
212     int64_t networkIdTimestamp;
213     int64_t authSeqNum;
214     uint64_t heartbeatTimestamp;
215     uint64_t bleDirectTimestamp;
216     uint64_t sleHbTiemstamp;
217     uint64_t onlineTimestamp;
218     uint64_t offlineTimestamp;
219     uint64_t updateTimestamp;
220     int64_t lastAuthSeq;
221     uint64_t huksKeyTime;
222     ConnectInfo connectInfo;
223     int32_t sleRangeCapacity;
224     AclWriteState aclState;
225 } NodeInfo;
226 
227 #ifdef __cplusplus
228 }
229 #endif
230 
231 #endif // LNN_NODE_INFO_STRUCT_H