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 NET_POLICY_DEFINE_H 17 #define NET_POLICY_DEFINE_H 18 19 #include "net_policy_cellular_policy.h" 20 21 namespace OHOS { 22 namespace NetManagerStandard { 23 const mode_t CHOWN_RWX_USR_GRP = 0770; 24 constexpr int16_t PERIODDURATION_POS_NUM_ONE = 1; 25 constexpr int16_t DAY_ONE = 1; 26 constexpr int16_t DAY_THIRTY_ONE = 31; 27 constexpr int16_t LIMIT_ACTION_ONE = 1; 28 constexpr int16_t LIMIT_ACTION_THREE = 3; 29 constexpr int16_t LIMIT_CALLBACK_NUM = 200; 30 const std::string POLICY_QUOTA_MONTH_U = "M"; 31 const std::string POLICY_QUOTA_MONTH_L = "m"; 32 const std::string POLICY_FILE_NAME = "/data/system/net_policy.json"; 33 const std::string CONFIG_HOS_VERSION = "hosVersion"; 34 const std::string CONFIG_UID_POLICY = "uidPolicy"; 35 const std::string CONFIG_UID = "uid"; 36 const std::string CONFIG_POLICY = "policy"; 37 const std::string HOS_VERSION = "1.0"; 38 const std::string CONFIG_BACKGROUND_POLICY = "backgroundPolicy"; 39 const std::string CONFIG_BACKGROUND_POLICY_STATUS = "status"; 40 const std::string CONFIG_QUOTA_POLICY = "quotaPolicy"; 41 const std::string CONFIG_QUOTA_POLICY_NETTYPE = "netType"; 42 const std::string CONFIG_QUOTA_POLICY_SUBSCRIBERID = "simId"; 43 const std::string CONFIG_QUOTA_POLICY_PERIODSTARTTIME = "periodStartTime"; 44 const std::string CONFIG_QUOTA_POLICY_PERIODDURATION = "periodDuration"; 45 const std::string CONFIG_QUOTA_POLICY_WARNINGBYTES = "warningBytes"; 46 const std::string CONFIG_QUOTA_POLICY_LIMITBYTES = "limitBytes"; 47 const std::string CONFIG_QUOTA_POLICY_LASTLIMITSNOOZE = "lastLimitSnooze"; 48 const std::string CONFIG_QUOTA_POLICY_METERED = "metered"; 49 const std::string CONFIG_QUOTA_POLICY_SOURCE = "source"; 50 const std::string CONFIG_CELLULAR_POLICY = "cellularPolicy"; 51 const std::string CONFIG_CELLULAR_POLICY_SUBSCRIBERID = "simId"; 52 const std::string CONFIG_CELLULAR_POLICY_PERIODSTARTTIME = "periodStartTime"; 53 const std::string CONFIG_CELLULAR_POLICY_PERIODDURATION = "periodDuration"; 54 const std::string CONFIG_CELLULAR_POLICY_TITLE = "title"; 55 const std::string CONFIG_CELLULAR_POLICY_SUMMARY = "summary"; 56 const std::string CONFIG_CELLULAR_POLICY_LIMITBYTES = "limitBytes"; 57 const std::string CONFIG_CELLULAR_POLICY_LIMITACTION = "limitAction"; 58 const std::string CONFIG_CELLULAR_POLICY_USEDBYTES = "usedBytes"; 59 const std::string CONFIG_CELLULAR_POLICY_USEDTIMEDURATION = "usedTimeDuration"; 60 const std::string CONFIG_CELLULAR_POLICY_POSSESSOR = "possessor"; 61 const std::string BACKGROUND_POLICY_ALLOW = "allow"; 62 const std::string BACKGROUND_POLICY_REJECT = "reject"; 63 const std::string IDENT_PREFIX = "usb0"; 64 65 struct UidPolicy { 66 std::string uid; 67 std::string policy; 68 }; 69 70 struct NetPolicyQuota { 71 std::string netType; 72 std::string simId; 73 std::string periodStartTime; 74 std::string periodDuration; 75 std::string warningBytes; 76 std::string limitBytes; 77 std::string lastLimitSnooze; 78 std::string metered; 79 std::string source; 80 }; 81 82 struct NetPolicyCellular { 83 std::string simId; 84 std::string periodStartTime; 85 std::string periodDuration; 86 std::string title; 87 std::string summary; 88 std::string limitBytes; 89 std::string limitAction; 90 std::string usedBytes; 91 std::string usedTimeDuration; 92 std::string possessor; 93 }; 94 95 struct NetPolicy { 96 std::string hosVersion; 97 std::vector<UidPolicy> uidPolicys; 98 std::string backgroundPolicyStatus_; 99 std::vector<NetPolicyQuota> netQuotaPolicys; 100 std::vector<NetPolicyCellular> netCellularPolicys; 101 }; 102 } // namespace NetManagerStandard 103 } // namespace OHOS 104 #endif // NET_POLICY_DEFINE_H