1 /* 2 * Copyright (c) 2023 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 INTERFACES_INNER_API_NETWORK_MANAGER_INCLUDE_IPTABLES_FIREWALL_RULE_H 17 #define INTERFACES_INNER_API_NETWORK_MANAGER_INCLUDE_IPTABLES_FIREWALL_RULE_H 18 19 #include <tuple> 20 21 #include "iptables_utils.h" 22 #include "message_parcel.h" 23 24 namespace OHOS { 25 namespace EDM { 26 namespace IPTABLES { 27 28 const int32_t FIREWALL_DICECTION_IND = 0; 29 const int32_t FIREWALL_ACTION_IND = 1; 30 const int32_t FIREWALL_PROT_IND = 2; 31 const int32_t FIREWALL_SRCADDR_IND = 3; 32 const int32_t FIREWALL_DESTADDR_IND = 4; 33 const int32_t FIREWALL_SRCPORT_IND = 5; 34 const int32_t FIREWALL_DESTPORT_IND = 6; 35 const int32_t FIREWALL_APPUID_IND = 7; 36 37 using FirewallRule = std::tuple<Direction, Action, Protocol, std::string /*srcAddr*/, std::string /*destAddr*/, 38 std::string /*srcPort*/, std::string /*destPort*/, std::string /*appUid*/>; 39 class FirewallRuleParcel { 40 public: 41 FirewallRuleParcel() = default; 42 explicit FirewallRuleParcel(FirewallRule rule); 43 44 FirewallRule GetRule() const; 45 46 bool Marshalling(MessageParcel& parcel) const; 47 48 static bool Unmarshalling(MessageParcel& parcel, FirewallRuleParcel& firewallRuleParcel); 49 50 private: 51 FirewallRule rule_; 52 }; 53 } // namespace IPTABLES 54 } // namespace EDM 55 } // namespace OHOS 56 #endif // INTERFACES_INNER_API_NETWORK_MANAGER_INCLUDE_IPTABLES_FIREWALL_RULE_H 57