• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 OHOS_STORAGE_DAEMON_NETLINK_DATA_H
17 #define OHOS_STORAGE_DAEMON_NETLINK_DATA_H
18 
19 #include <map>
20 #include <string>
21 
22 namespace OHOS {
23 namespace StorageDaemon {
24 class NetlinkData {
25 public:
26     enum Actions {
27         ADD,
28         REMOVE,
29         CHANGE,
30         MOVE,
31         ONLINE,
32         OFFLINE,
33         BIND,
34         UNBIND,
35         UNKNOWN,
36     };
37     std::map<std::string, Actions> actionMaps = {
38         {"add", Actions::ADD},
39         {"remove", Actions::REMOVE},
40         {"move", Actions::MOVE},
41         {"change", Actions::CHANGE},
42         {"online", Actions::ONLINE},
43         {"offline", Actions::OFFLINE},
44         {"bind", Actions::BIND},
45         {"unbind", Actions::UNBIND}
46     };
47 
48     std::string GetSyspath();
49     std::string GetDevpath();
50     std::string GetSubsystem();
51     Actions GetAction();
52     const std::string GetParam(const std::string paramName);
53     void Decode(const char *msg);
54 
55 private:
56     std::string sysPath_;
57     std::string subSystem_;
58     std::string devPath_;
59     std::vector<std::string> params_;
60     Actions action_ = Actions::UNKNOWN;
61 };
62 } // STORAGE_DAEMON
63 } // OHOS
64 
65 #endif // OHOS_STORAGE_DAEMON_NETLINK_DATA_H
66