blob: f888298e6248c4fb8feeb421825f791c9f4d841c [file] [log] [blame]
Junyu Lai29b7b632023-08-23 17:35:17 +08001/*
2 * Copyright (C) 2023 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.net;
18
19import android.util.Pair;
20
21import com.android.net.module.util.Struct;
22
23import java.util.Arrays;
24import java.util.List;
25
26/**
27 * BpfNetMaps related constants that can be shared among modules.
28 *
29 * @hide
30 */
31// Note that this class should be put into bootclasspath instead of static libraries.
32// Because modules could have different copies of this class if this is statically linked,
33// which would be problematic if the definitions in these modules are not synchronized.
34public class BpfNetMapsConstants {
35 // Prevent this class from being accidental instantiated.
36 private BpfNetMapsConstants() {}
37
38 public static final String CONFIGURATION_MAP_PATH =
39 "/sys/fs/bpf/netd_shared/map_netd_configuration_map";
40 public static final String UID_OWNER_MAP_PATH =
41 "/sys/fs/bpf/netd_shared/map_netd_uid_owner_map";
42 public static final String UID_PERMISSION_MAP_PATH =
43 "/sys/fs/bpf/netd_shared/map_netd_uid_permission_map";
44 public static final String COOKIE_TAG_MAP_PATH =
45 "/sys/fs/bpf/netd_shared/map_netd_cookie_tag_map";
Ken Chen24330172023-10-20 13:02:14 +080046 public static final String DATA_SAVER_ENABLED_MAP_PATH =
47 "/sys/fs/bpf/netd_shared/map_netd_data_saver_enabled_map";
Motomu Utsumi77b49992023-10-23 17:06:12 +090048 public static final String INGRESS_DISCARD_MAP_PATH =
49 "/sys/fs/bpf/netd_shared/map_netd_ingress_discard_map";
Junyu Lai29b7b632023-08-23 17:35:17 +080050 public static final Struct.S32 UID_RULES_CONFIGURATION_KEY = new Struct.S32(0);
51 public static final Struct.S32 CURRENT_STATS_MAP_CONFIGURATION_KEY = new Struct.S32(1);
Ken Chen24330172023-10-20 13:02:14 +080052 public static final Struct.S32 DATA_SAVER_ENABLED_KEY = new Struct.S32(0);
53
54 public static final short DATA_SAVER_DISABLED = 0;
55 public static final short DATA_SAVER_ENABLED = 1;
Junyu Lai29b7b632023-08-23 17:35:17 +080056
57 // LINT.IfChange(match_type)
58 public static final long NO_MATCH = 0;
59 public static final long HAPPY_BOX_MATCH = (1 << 0);
60 public static final long PENALTY_BOX_MATCH = (1 << 1);
61 public static final long DOZABLE_MATCH = (1 << 2);
62 public static final long STANDBY_MATCH = (1 << 3);
63 public static final long POWERSAVE_MATCH = (1 << 4);
64 public static final long RESTRICTED_MATCH = (1 << 5);
65 public static final long LOW_POWER_STANDBY_MATCH = (1 << 6);
66 public static final long IIF_MATCH = (1 << 7);
67 public static final long LOCKDOWN_VPN_MATCH = (1 << 8);
68 public static final long OEM_DENY_1_MATCH = (1 << 9);
69 public static final long OEM_DENY_2_MATCH = (1 << 10);
70 public static final long OEM_DENY_3_MATCH = (1 << 11);
Ken Chencf25a542023-10-20 16:42:17 +080071 // LINT.ThenChange(../../../../bpf_progs/netd.h)
Junyu Lai29b7b632023-08-23 17:35:17 +080072
73 public static final List<Pair<Long, String>> MATCH_LIST = Arrays.asList(
74 Pair.create(HAPPY_BOX_MATCH, "HAPPY_BOX_MATCH"),
75 Pair.create(PENALTY_BOX_MATCH, "PENALTY_BOX_MATCH"),
76 Pair.create(DOZABLE_MATCH, "DOZABLE_MATCH"),
77 Pair.create(STANDBY_MATCH, "STANDBY_MATCH"),
78 Pair.create(POWERSAVE_MATCH, "POWERSAVE_MATCH"),
79 Pair.create(RESTRICTED_MATCH, "RESTRICTED_MATCH"),
80 Pair.create(LOW_POWER_STANDBY_MATCH, "LOW_POWER_STANDBY_MATCH"),
81 Pair.create(IIF_MATCH, "IIF_MATCH"),
82 Pair.create(LOCKDOWN_VPN_MATCH, "LOCKDOWN_VPN_MATCH"),
83 Pair.create(OEM_DENY_1_MATCH, "OEM_DENY_1_MATCH"),
84 Pair.create(OEM_DENY_2_MATCH, "OEM_DENY_2_MATCH"),
85 Pair.create(OEM_DENY_3_MATCH, "OEM_DENY_3_MATCH")
86 );
87}