• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 NETMANAGER_BASE_BPF_DEF_H
17 #define NETMANAGER_BASE_BPF_DEF_H
18 
19 #include <linux/bpf.h>
20 
21 static const int32_t APP_STATS_MAP_SIZE = 5000;
22 static const int32_t IFACE_STATS_MAP_SIZE = 1000;
23 static const int32_t IFACE_NAME_MAP_SIZE = 1000;
24 enum { IFNAME_SIZE = 32 };
25 
26 typedef struct {
27     enum bpf_map_type type;
28     __u32 key_size;
29     __u32 value_size;
30     __u32 max_entries;
31     __u32 map_flags;
32     __u32 inner_map_idx;
33     __u32 numa_node;
34 } bpf_map_def;
35 
36 typedef struct {
37     __u32 uId;
38     __u32 ifIndex;
39 } stats_key;
40 
41 typedef struct {
42     __u64 rxPackets;
43     __u64 rxBytes;
44     __u64 txPackets;
45     __u64 txBytes;
46 } stats_value;
47 
48 typedef struct {
49     char name[IFNAME_SIZE];
50 } iface_name;
51 
52 // network stats begin
53 typedef __u64 iface_stats_key;
54 typedef stats_value iface_stats_value;
55 
56 typedef __u64 app_uid_stats_key;
57 typedef stats_value app_uid_stats_value;
58 
59 typedef stats_key app_uid_if_stats_key;
60 typedef stats_value app_uid_if_stats_value;
61 // network stats end
62 
63 // internet permission begin
64 typedef __u32 sock_permission_key;
65 typedef __u8 sock_permission_value;
66 // internet permission end
67 #endif /* NETMANAGER_BASE_BPF_DEF_H */
68