1 /* 2 * Copyright (c) 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_DATA_CLOUD_SYNC_H 17 #define LNN_DATA_CLOUD_SYNC_H 18 19 #include <stdint.h> 20 21 #include "lnn_node_info.h" 22 #include "softbus_adapter_crypto.h" 23 #include "softbus_adapter_timer.h" 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 #define CLOUD_SYNC_INFO_SIZE 33 30 31 typedef struct { 32 char networkId[NETWORK_ID_BUF_LEN]; 33 char deviceName[DEVICE_NAME_BUF_LEN]; 34 char unifiedName[DEVICE_NAME_BUF_LEN]; 35 char unifiedDefaultName[DEVICE_NAME_BUF_LEN]; 36 char nickName[DEVICE_NAME_BUF_LEN]; 37 uint16_t deviceTypeId; 38 char deviceUdid[UDID_BUF_LEN]; 39 char uuid[UUID_BUF_LEN]; 40 char softBusVersion[VERSION_MAX_LEN]; 41 bool isBleP2p; 42 uint64_t supportedProtocols; 43 char pkgVersion[VERSION_MAX_LEN]; 44 int64_t wifiVersion; 45 int64_t bleVersion; 46 char macAddr[MAC_LEN]; 47 int64_t accountId; 48 uint64_t feature; 49 uint64_t connSubFeature; 50 uint32_t authCapacity; 51 uint32_t heartbeatCapacity; 52 int32_t osType; 53 char osVersion[OS_VERSION_BUF_LEN]; 54 int32_t stateVersion; 55 char p2pMac[MAC_LEN]; 56 uint8_t peerIrk[LFINDER_IRK_LEN]; 57 unsigned char publicAddress[LFINDER_MAC_ADDR_LEN]; 58 char remotePtk[PTK_DEFAULT_LEN]; 59 char *broadcastCipherKey; 60 unsigned char cipherKey[SESSION_KEY_LENGTH]; 61 unsigned char cipherIv[BROADCAST_IV_LEN]; 62 bool distributedSwitch; 63 uint64_t timestamp; 64 } CloudSyncInfo; 65 66 typedef enum { 67 DB_ADD = 0, 68 DB_UPDATE = 1, 69 DB_DELETE = 2, 70 DB_CHANGE_TYPE_MAX, 71 } ChangeType; 72 73 void LnnInitCloudSyncModule(void); 74 void LnnDeInitCloudSyncModule(void); 75 int32_t LnnLedgerAllDataSyncToDB(NodeInfo *info); 76 int32_t LnnAsyncCallLedgerAllDataSyncToDB(NodeInfo *info); 77 int32_t LnnLedgerDataChangeSyncToDB(const char *key, const char *value, size_t valueLength); 78 int32_t LnnDeleteSyncToDB(void); 79 int32_t LnnDBDataChangeSyncToCache(const char *key, const char *value, ChangeType changeType); 80 int32_t LnnDBDataAddChangeSyncToCache(const char **key, const char **value, int32_t keySize); 81 int32_t LnnDBDataChangeSyncToCacheInner(const char *key, const char *value); 82 int32_t LnnSetCloudAbility(const bool isEnableCloud); 83 #ifdef __cplusplus 84 } 85 #endif 86 87 #endif // LNN_DATA_CLOUD_SYNC_H 88