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