1 /*
2  * Copyright (c) 2021 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_LOCAL_NET_LEDGER_H
17 #define LNN_LOCAL_NET_LEDGER_H
18 
19 #include <pthread.h>
20 #include <stdint.h>
21 
22 #include "bus_center_info_key.h"
23 #include "lnn_device_info.h"
24 #include "lnn_node_info.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 typedef enum {
31     LL_INIT_UNKNOWN = 0,
32     LL_INIT_FAIL,
33     LL_INIT_SUCCESS,
34 } LocalLedgerStatus;
35 
36 typedef struct {
37     InfoKey key;
38     int32_t maxLen;
39     int32_t (*getInfo)(void *info, uint32_t len);
40     int32_t (*setInfo)(const void *info);
41 } LocalLedgerKey;
42 
43 typedef enum {
44     UPDATE_ACCOUNT_LONG = 1,
45     UPDATE_DEV_NAME = 2,
46     UPDATE_DEV_UNIFIED_NAME = 4,
47     UPDATE_DEV_UNIFIED_DEFAULT_NAME = 8,
48     UPDATE_DEV_NICK_NAME = 16,
49     UPDATE_NETWORKID = 32,
50     UPDATE_CONCURRENT_AUTH = 64,
51     UPDATE_CIPHERKEY = 128,
52 } StateVersionChangeReason;
53 
54 int32_t LnnInitLocalLedger(void);
55 int32_t LnnInitLocalLedgerDelay(void);
56 void LnnDeinitLocalLedger(void);
57 
58 const NodeInfo *LnnGetLocalNodeInfo(void);
59 int32_t LnnGetLocalNodeInfoSafe(NodeInfo *info);
60 int32_t LnnUpdateLocalNetworkId(const void *id);
61 int32_t LnnUpdateLocalNetworkIdTime(int64_t time);
62 int32_t LnnUpdateLocalScreenStatus(bool isScreenOn);
63 void LnnUpdateStateVersion(StateVersionChangeReason reason);
64 
65 #ifdef __cplusplus
66 }
67 #endif
68 
69 #endif // LNN_LOCAL_NET_LEDGER_H