• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #ifndef DEVSL_DISPATCHER_H
17 #define DEVSL_DISPATCHER_H
18 
19 #include <map>
20 #include <memory>
21 #include <mutex>
22 #include <string>
23 #include <vector>
24 #include "dev_slinfo_mgr.h"
25 #include "network/kernel_talker.h"
26 
27 namespace OHOS {
28 namespace Storage {
29 namespace DistributedFile {
30 enum class SecurityLabel : int32_t {
31     S1 = 1,
32     S2,
33     S3,
34     S4,
35 };
36 
37 class DevslDispatcher final {
38 public:
39     DevslDispatcher() = delete;
40     ~DevslDispatcher() = delete;
41     static int Start();
42     static void Stop();
43     static void DevslGottonCallback(DEVSLQueryParams *queryParams, int32_t result, uint32_t levelInfo);
44     static uint32_t DevslGetRegister(const std::string &cid, std::weak_ptr<KernelTalker>);
45     static bool CompareDevslWithLocal(const std::string &peerNetworkId, const std::vector<std::string> &paths);
46     static int32_t GetDeviceDevsl(const std::string &networkId);
47 
48 private:
49     static DEVSLQueryParams MakeDevslQueryParams(const std::string &cid);
50     static void DevslGottonCallbackAsync(const std::string udid, uint32_t devsl);
51     static int32_t GetSecurityLabel(const std::string &path);
52     static std::map<std::string, std::vector<std::weak_ptr<KernelTalker>>> talkersMap_;
53     static std::map<std::string, std::string> idMap_;
54     static std::mutex mutex;
55     static std::mutex devslMapMutex_;
56     static std::map<std::string, int32_t> devslMap_;
57 };
58 } // namespace DistributedFile
59 } // namespace Storage
60 } // namespace OHOS
61 #endif // DSL_DISPATCHER_H