1 /* 2 * Copyright (c) 2022 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 INCLUDE_FWMARK_H 17 #define INCLUDE_FWMARK_H 18 19 #include <sys/un.h> 20 21 #include "network_permission.h" 22 23 namespace OHOS { 24 namespace nmd { 25 union Fwmark { 26 uint32_t intValue; 27 struct { 28 uint16_t netId : 16; 29 bool explicitlySelected : 1; 30 bool protectedFromVpn : 1; 31 NetworkPermission permission : 2; 32 bool uidBillingDone : 1; 33 }; Fwmark()34 constexpr Fwmark() : intValue(0) {} GetUidBillingMask()35 static inline uint32_t GetUidBillingMask() 36 { 37 Fwmark m; 38 m.uidBillingDone = true; 39 return m.intValue; 40 } 41 }; 42 static constexpr uint32_t FWMARK_NET_ID_MASK = 0xffff; 43 static const struct sockaddr_un FWMARK_SERVER_PATH = {AF_UNIX, "/dev/unix/socket/fwmarkd"}; 44 } // namespace nmd 45 } // namespace OHOS 46 #endif // INCLUDE_FWMARK_H 47