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