├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── github │ │ └── qiang │ │ └── iproute2 │ │ └── parsemac │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ ├── SNAPSHOT.h │ │ │ ├── bpf_api.h │ │ │ ├── bpf_elf.h │ │ │ ├── bpf_scm.h │ │ │ ├── bpf_util.h │ │ │ ├── color.h │ │ │ ├── dlfcn.h │ │ │ ├── ip6tables.h │ │ │ ├── iptables.h │ │ │ ├── iptables │ │ │ │ └── internal.h │ │ │ ├── json_print.h │ │ │ ├── json_writer.h │ │ │ ├── libgenl.h │ │ │ ├── libiptc │ │ │ │ ├── ipt_kernel_headers.h │ │ │ │ ├── libip6tc.h │ │ │ │ ├── libiptc.h │ │ │ │ ├── libxtc.h │ │ │ │ └── xtcshared.h │ │ │ ├── libnetlink.h │ │ │ ├── linux │ │ │ │ └── xfrm.h │ │ │ ├── list.h │ │ │ ├── ll_map.h │ │ │ ├── names.h │ │ │ ├── namespace.h │ │ │ ├── netinet │ │ │ │ └── tcp.h │ │ │ ├── rt_names.h │ │ │ ├── rtm_map.h │ │ │ ├── uapi │ │ │ │ ├── linux │ │ │ │ │ ├── atm.h │ │ │ │ │ ├── atmapi.h │ │ │ │ │ ├── atmarp.h │ │ │ │ │ ├── atmdev.h │ │ │ │ │ ├── atmioc.h │ │ │ │ │ ├── atmsap.h │ │ │ │ │ ├── bpf.h │ │ │ │ │ ├── bpf_common.h │ │ │ │ │ ├── can.h │ │ │ │ │ ├── can │ │ │ │ │ │ ├── netlink.h │ │ │ │ │ │ └── vxcan.h │ │ │ │ │ ├── devlink.h │ │ │ │ │ ├── elf-em.h │ │ │ │ │ ├── fib_rules.h │ │ │ │ │ ├── filter.h │ │ │ │ │ ├── fou.h │ │ │ │ │ ├── gen_stats.h │ │ │ │ │ ├── genetlink.h │ │ │ │ │ ├── hdlc │ │ │ │ │ │ └── ioctl.h │ │ │ │ │ ├── icmpv6.h │ │ │ │ │ ├── if.h │ │ │ │ │ ├── if_addr.h │ │ │ │ │ ├── if_addrlabel.h │ │ │ │ │ ├── if_alg.h │ │ │ │ │ ├── if_arp.h │ │ │ │ │ ├── if_bonding.h │ │ │ │ │ ├── if_bridge.h │ │ │ │ │ ├── if_ether.h │ │ │ │ │ ├── if_link.h │ │ │ │ │ ├── if_macsec.h │ │ │ │ │ ├── if_packet.h │ │ │ │ │ ├── if_tun.h │ │ │ │ │ ├── if_tunnel.h │ │ │ │ │ ├── if_vlan.h │ │ │ │ │ ├── ife.h │ │ │ │ │ ├── ila.h │ │ │ │ │ ├── in.h │ │ │ │ │ ├── in6.h │ │ │ │ │ ├── in_route.h │ │ │ │ │ ├── inet_diag.h │ │ │ │ │ ├── ip.h │ │ │ │ │ ├── ip6_tunnel.h │ │ │ │ │ ├── ipsec.h │ │ │ │ │ ├── kernel.h │ │ │ │ │ ├── l2tp.h │ │ │ │ │ ├── libc-compat.h │ │ │ │ │ ├── limits.h │ │ │ │ │ ├── lwtunnel.h │ │ │ │ │ ├── magic.h │ │ │ │ │ ├── mpls.h │ │ │ │ │ ├── mpls_iptunnel.h │ │ │ │ │ ├── neighbour.h │ │ │ │ │ ├── net_namespace.h │ │ │ │ │ ├── netconf.h │ │ │ │ │ ├── netdevice.h │ │ │ │ │ ├── netfilter.h │ │ │ │ │ ├── netfilter │ │ │ │ │ │ ├── ipset │ │ │ │ │ │ │ └── ip_set.h │ │ │ │ │ │ ├── x_tables.h │ │ │ │ │ │ ├── xt_set.h │ │ │ │ │ │ └── xt_tcpudp.h │ │ │ │ │ ├── netfilter_ipv4.h │ │ │ │ │ ├── netfilter_ipv4 │ │ │ │ │ │ └── ip_tables.h │ │ │ │ │ ├── netfilter_ipv6.h │ │ │ │ │ ├── netfilter_ipv6 │ │ │ │ │ │ └── ip6_tables.h │ │ │ │ │ ├── netlink.h │ │ │ │ │ ├── netlink_diag.h │ │ │ │ │ ├── packet_diag.h │ │ │ │ │ ├── param.h │ │ │ │ │ ├── pfkeyv2.h │ │ │ │ │ ├── pkt_cls.h │ │ │ │ │ ├── pkt_sched.h │ │ │ │ │ ├── posix_types.h │ │ │ │ │ ├── rtnetlink.h │ │ │ │ │ ├── sctp.h │ │ │ │ │ ├── seg6.h │ │ │ │ │ ├── seg6_genl.h │ │ │ │ │ ├── seg6_hmac.h │ │ │ │ │ ├── seg6_iptunnel.h │ │ │ │ │ ├── seg6_local.h │ │ │ │ │ ├── sock_diag.h │ │ │ │ │ ├── socket.h │ │ │ │ │ ├── sockios.h │ │ │ │ │ ├── stddef.h │ │ │ │ │ ├── sysinfo.h │ │ │ │ │ ├── tc_act │ │ │ │ │ │ ├── tc_bpf.h │ │ │ │ │ │ ├── tc_connmark.h │ │ │ │ │ │ ├── tc_csum.h │ │ │ │ │ │ ├── tc_defact.h │ │ │ │ │ │ ├── tc_gact.h │ │ │ │ │ │ ├── tc_ife.h │ │ │ │ │ │ ├── tc_ipt.h │ │ │ │ │ │ ├── tc_mirred.h │ │ │ │ │ │ ├── tc_nat.h │ │ │ │ │ │ ├── tc_pedit.h │ │ │ │ │ │ ├── tc_sample.h │ │ │ │ │ │ ├── tc_skbedit.h │ │ │ │ │ │ ├── tc_skbmod.h │ │ │ │ │ │ ├── tc_tunnel_key.h │ │ │ │ │ │ └── tc_vlan.h │ │ │ │ │ ├── tc_ematch │ │ │ │ │ │ ├── tc_em_cmp.h │ │ │ │ │ │ ├── tc_em_meta.h │ │ │ │ │ │ └── tc_em_nbyte.h │ │ │ │ │ ├── tcp.h │ │ │ │ │ ├── tcp_metrics.h │ │ │ │ │ ├── tipc.h │ │ │ │ │ ├── tipc_netlink.h │ │ │ │ │ ├── types.h │ │ │ │ │ ├── unix_diag.h │ │ │ │ │ ├── veth.h │ │ │ │ │ └── xfrm.h │ │ │ │ └── rdma │ │ │ │ │ └── rdma_netlink.h │ │ │ ├── utils.h │ │ │ ├── xt-internal.h │ │ │ └── xtables.h │ │ ├── ip.c │ │ ├── ip.h │ │ ├── ip_common.h │ │ ├── ipaddress.c │ │ ├── iplink.c │ │ ├── iplink_vrf.c │ │ ├── iplink_xdp.c │ │ ├── iplink_xstats.c │ │ ├── lib │ │ │ ├── bpf.c │ │ │ ├── color.c │ │ │ ├── coverity_model.c │ │ │ ├── dnet_ntop.c │ │ │ ├── dnet_pton.c │ │ │ ├── exec.c │ │ │ ├── fs.c │ │ │ ├── inet_proto.c │ │ │ ├── ipx_ntop.c │ │ │ ├── ipx_pton.c │ │ │ ├── json_print.c │ │ │ ├── json_writer.c │ │ │ ├── libgenl.c │ │ │ ├── libnetlink.c │ │ │ ├── ll_addr.c │ │ │ ├── ll_map.c │ │ │ ├── ll_proto.c │ │ │ ├── ll_types.c │ │ │ ├── mpls_ntop.c │ │ │ ├── mpls_pton.c │ │ │ ├── names.c │ │ │ ├── namespace.c │ │ │ ├── rt_names.c │ │ │ └── utils.c │ │ ├── native-lib.cpp │ │ └── xdp.h │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── qiang │ │ │ └── iproute2 │ │ │ └── parsemac │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── values-night │ │ └── themes.xml │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── themes.xml │ └── test │ └── java │ └── com │ └── github │ └── qiang │ └── iproute2 │ └── parsemac │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | /.idea 17 | /gradle 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### 使用方式 2 | 3 | 直接运行demo,日志过滤 tag Q_M 4 | 5 | 点击按钮就能打印出mac地址。 6 | 7 | ### 测试手机 8 | 9 | 一加7t Android 10 10 | 11 | 一加8 Android 10 12 | 13 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | } 4 | 5 | android { 6 | compileSdkVersion 30 7 | buildToolsVersion "30.0.3" 8 | 9 | defaultConfig { 10 | applicationId "com.github.qiang.iproute2.parsemac" 11 | minSdkVersion 23 12 | targetSdkVersion 30 13 | versionCode 1 14 | versionName "1.0" 15 | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 17 | 18 | externalNativeBuild { 19 | cmake { 20 | cppFlags '' 21 | } 22 | } 23 | } 24 | 25 | buildTypes { 26 | release { 27 | minifyEnabled false 28 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 29 | } 30 | } 31 | compileOptions { 32 | sourceCompatibility JavaVersion.VERSION_1_8 33 | targetCompatibility JavaVersion.VERSION_1_8 34 | } 35 | 36 | externalNativeBuild { 37 | cmake { 38 | path file('src/main/cpp/CMakeLists.txt') 39 | version '3.10.2' 40 | } 41 | } 42 | } 43 | 44 | dependencies { 45 | 46 | implementation 'androidx.appcompat:appcompat:1.3.0' 47 | implementation 'com.google.android.material:material:1.4.0' 48 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 49 | testImplementation 'junit:junit:4.+' 50 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 51 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 52 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/com/github/qiang/iproute2/parsemac/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.github.qiang.iproute2.parsemac; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | assertEquals("com.github.qiang.iproute2.parsemac", appContext.getPackageName()); 25 | } 26 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # For more information about using CMake with Android Studio, read the 2 | # documentation: https://d.android.com/studio/projects/add-native-code.html 3 | 4 | # Sets the minimum version of CMake required to build the native library. 5 | 6 | cmake_minimum_required(VERSION 3.10.2) 7 | 8 | # Declares and names the project. 9 | 10 | project("parsemacbyiproute2") 11 | 12 | include_directories(include .) 13 | 14 | # Creates and names a library, sets it as either STATIC 15 | # or SHARED, and provides the relative paths to its source code. 16 | # You can define multiple libraries, and CMake builds them for you. 17 | # Gradle automatically packages shared libraries with your APK. 18 | 19 | aux_source_directory(lib sourceList) 20 | 21 | 22 | add_library( # Sets the name of the library. 23 | native-lib 24 | 25 | # Sets the library as a shared library. 26 | SHARED 27 | ${sourceList} 28 | ip.c 29 | iplink.c 30 | iplink_xdp.c 31 | iplink_vrf.c 32 | iplink_xstats.c 33 | ipaddress.c 34 | # Provides a relative path to your source file(s). 35 | native-lib.cpp ) 36 | 37 | 38 | # Searches for a specified prebuilt library and stores the path as a 39 | # variable. Because CMake includes system libraries in the search path by 40 | # default, you only need to specify the name of the public NDK library 41 | # you want to add. CMake verifies that the library exists before 42 | # completing its build. 43 | 44 | find_library( # Sets the name of the path variable. 45 | log-lib 46 | 47 | # Specifies the name of the NDK library that 48 | # you want CMake to locate. 49 | log ) 50 | 51 | # Specifies libraries CMake should link to your target library. You 52 | # can link multiple libraries, such as libraries you define in this 53 | # build script, prebuilt third-party libraries, or system libraries. 54 | 55 | target_link_libraries( # Specifies the target library. 56 | native-lib 57 | 58 | # Links the target library to the log library 59 | # included in the NDK. 60 | ${log-lib} ) -------------------------------------------------------------------------------- /app/src/main/cpp/include/SNAPSHOT.h: -------------------------------------------------------------------------------- 1 | static const char SNAPSHOT[] = "171113"; 2 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/bpf_elf.h: -------------------------------------------------------------------------------- 1 | #ifndef __BPF_ELF__ 2 | #define __BPF_ELF__ 3 | 4 | #include 5 | 6 | /* Note: 7 | * 8 | * Below ELF section names and bpf_elf_map structure definition 9 | * are not (!) kernel ABI. It's rather a "contract" between the 10 | * application and the BPF loader in tc. For compatibility, the 11 | * section names should stay as-is. Introduction of aliases, if 12 | * needed, are a possibility, though. 13 | */ 14 | 15 | /* ELF section names, etc */ 16 | #define ELF_SECTION_LICENSE "license" 17 | #define ELF_SECTION_MAPS "maps" 18 | #define ELF_SECTION_PROG "prog" 19 | #define ELF_SECTION_CLASSIFIER "classifier" 20 | #define ELF_SECTION_ACTION "action" 21 | 22 | #define ELF_MAX_MAPS 64 23 | #define ELF_MAX_LICENSE_LEN 128 24 | 25 | /* Object pinning settings */ 26 | #define PIN_NONE 0 27 | #define PIN_OBJECT_NS 1 28 | #define PIN_GLOBAL_NS 2 29 | 30 | /* ELF map definition */ 31 | struct bpf_elf_map { 32 | __u32 type; 33 | __u32 size_key; 34 | __u32 size_value; 35 | __u32 max_elem; 36 | __u32 flags; 37 | __u32 id; 38 | __u32 pinning; 39 | __u32 inner_id; 40 | __u32 inner_idx; 41 | }; 42 | 43 | #endif /* __BPF_ELF__ */ 44 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/bpf_scm.h: -------------------------------------------------------------------------------- 1 | #ifndef __BPF_SCM__ 2 | #define __BPF_SCM__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "utils.h" 9 | #include "bpf_elf.h" 10 | 11 | #define BPF_SCM_AUX_VER 1 12 | #define BPF_SCM_MAX_FDS ELF_MAX_MAPS 13 | #define BPF_SCM_MSG_SIZE 1024 14 | 15 | struct bpf_elf_st { 16 | dev_t st_dev; 17 | ino_t st_ino; 18 | }; 19 | 20 | struct bpf_map_aux { 21 | unsigned short uds_ver; 22 | unsigned short num_ent; 23 | char obj_name[64]; 24 | struct bpf_elf_st obj_st; 25 | struct bpf_elf_map ent[BPF_SCM_MAX_FDS]; 26 | }; 27 | 28 | struct bpf_map_set_msg { 29 | struct msghdr hdr; 30 | struct iovec iov; 31 | char msg_buf[BPF_SCM_MSG_SIZE]; 32 | struct bpf_map_aux aux; 33 | }; 34 | 35 | static inline int *bpf_map_set_init(struct bpf_map_set_msg *msg, 36 | struct sockaddr_un *addr, 37 | unsigned int addr_len) 38 | { 39 | const unsigned int cmsg_ctl_len = sizeof(int) * BPF_SCM_MAX_FDS; 40 | struct cmsghdr *cmsg; 41 | 42 | msg->iov.iov_base = &msg->aux; 43 | msg->iov.iov_len = sizeof(msg->aux); 44 | 45 | msg->hdr.msg_iov = &msg->iov; 46 | msg->hdr.msg_iovlen = 1; 47 | 48 | msg->hdr.msg_name = (struct sockaddr *)addr; 49 | msg->hdr.msg_namelen = addr_len; 50 | 51 | BUILD_BUG_ON(sizeof(msg->msg_buf) < cmsg_ctl_len); 52 | msg->hdr.msg_control = &msg->msg_buf; 53 | msg->hdr.msg_controllen = cmsg_ctl_len; 54 | 55 | cmsg = CMSG_FIRSTHDR(&msg->hdr); 56 | cmsg->cmsg_len = msg->hdr.msg_controllen; 57 | cmsg->cmsg_level = SOL_SOCKET; 58 | cmsg->cmsg_type = SCM_RIGHTS; 59 | 60 | return (int *)CMSG_DATA(cmsg); 61 | } 62 | 63 | static inline void bpf_map_set_init_single(struct bpf_map_set_msg *msg, 64 | int num) 65 | { 66 | struct cmsghdr *cmsg; 67 | 68 | msg->hdr.msg_controllen = CMSG_LEN(sizeof(int) * num); 69 | msg->iov.iov_len = offsetof(struct bpf_map_aux, ent) + 70 | sizeof(struct bpf_elf_map) * num; 71 | 72 | cmsg = CMSG_FIRSTHDR(&msg->hdr); 73 | cmsg->cmsg_len = msg->hdr.msg_controllen; 74 | } 75 | 76 | #endif /* __BPF_SCM__ */ 77 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/color.h: -------------------------------------------------------------------------------- 1 | #ifndef __COLOR_H__ 2 | #define __COLOR_H__ 1 3 | 4 | #include 5 | #include 6 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, "Q_M", __VA_ARGS__) 7 | 8 | 9 | enum color_attr { 10 | COLOR_IFNAME, 11 | COLOR_MAC, 12 | COLOR_INET, 13 | COLOR_INET6, 14 | COLOR_OPERSTATE_UP, 15 | COLOR_OPERSTATE_DOWN, 16 | COLOR_NONE 17 | }; 18 | 19 | void enable_color(void); 20 | void check_if_color_enabled(void); 21 | void set_color_palette(void); 22 | int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...); 23 | enum color_attr ifa_family_color(__u8 ifa_family); 24 | enum color_attr oper_state_color(__u8 state); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/dlfcn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Stub dlfcn implementation for systems that lack shared library support 3 | * but obviously can still reference compiled-in symbols. 4 | */ 5 | 6 | #ifndef NO_SHARED_LIBS 7 | #include_next 8 | #else 9 | 10 | #define RTLD_LAZY 0 11 | #define RTLD_GLOBAL 1 12 | #define _FAKE_DLFCN_HDL (void *)0xbeefcafe 13 | 14 | static inline void *dlopen(const char *file, int flag) 15 | { 16 | if (file == NULL) 17 | return _FAKE_DLFCN_HDL; 18 | else 19 | return NULL; 20 | } 21 | 22 | void *_dlsym(const char *sym); 23 | static inline void *dlsym(void *handle, const char *sym) 24 | { 25 | if (handle != _FAKE_DLFCN_HDL) 26 | return NULL; 27 | return _dlsym(sym); 28 | } 29 | 30 | static inline char *dlerror(void) 31 | { 32 | return NULL; 33 | } 34 | 35 | static inline int dlclose(void *handle) 36 | { 37 | return (handle == _FAKE_DLFCN_HDL) ? 0 : 1; 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/ip6tables.h: -------------------------------------------------------------------------------- 1 | #ifndef _IP6TABLES_USER_H 2 | #define _IP6TABLES_USER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | /* Your shared library should call one of these. */ 10 | extern int do_command6(int argc, char *argv[], char **table, 11 | struct xtc_handle **handle, bool restore); 12 | 13 | extern int for_each_chain6(int (*fn)(const xt_chainlabel, int, struct xtc_handle *), int verbose, int builtinstoo, struct xtc_handle *handle); 14 | extern int flush_entries6(const xt_chainlabel chain, int verbose, struct xtc_handle *handle); 15 | extern int delete_chain6(const xt_chainlabel chain, int verbose, struct xtc_handle *handle); 16 | void print_rule6(const struct ip6t_entry *e, struct xtc_handle *h, const char *chain, int counters); 17 | 18 | extern struct xtables_globals ip6tables_globals; 19 | 20 | #endif /*_IP6TABLES_USER_H*/ 21 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/iptables.h: -------------------------------------------------------------------------------- 1 | #ifndef _IPTABLES_USER_H 2 | #define _IPTABLES_USER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | /* Your shared library should call one of these. */ 10 | extern int do_command4(int argc, char *argv[], char **table, 11 | struct xtc_handle **handle, bool restore); 12 | extern int delete_chain4(const xt_chainlabel chain, int verbose, 13 | struct xtc_handle *handle); 14 | extern int flush_entries4(const xt_chainlabel chain, int verbose, 15 | struct xtc_handle *handle); 16 | extern int for_each_chain4(int (*fn)(const xt_chainlabel, int, struct xtc_handle *), 17 | int verbose, int builtinstoo, struct xtc_handle *handle); 18 | extern void print_rule4(const struct ipt_entry *e, 19 | struct xtc_handle *handle, const char *chain, int counters); 20 | 21 | extern struct xtables_globals iptables_globals; 22 | 23 | extern struct xtables_globals xtables_globals; 24 | 25 | #endif /*_IPTABLES_USER_H*/ 26 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/iptables/internal.h: -------------------------------------------------------------------------------- 1 | #ifndef IPTABLES_INTERNAL_H 2 | #define IPTABLES_INTERNAL_H 1 3 | 4 | #define IPTABLES_VERSION "1.6.0" 5 | 6 | /** 7 | * Program's own name and version. 8 | */ 9 | extern const char *program_name, *program_version; 10 | 11 | extern int line; 12 | 13 | #endif /* IPTABLES_INTERNAL_H */ 14 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/json_print.h: -------------------------------------------------------------------------------- 1 | /* 2 | * json_print.h "print regular or json output, based on json_writer". 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 7 | * 2 of the License, or (at your option) any later version. 8 | * 9 | * Authors: Julien Fortin, 10 | */ 11 | 12 | #ifndef _JSON_PRINT_H_ 13 | #define _JSON_PRINT_H_ 14 | 15 | #include "json_writer.h" 16 | #include "color.h" 17 | 18 | json_writer_t *get_json_writer(void); 19 | 20 | /* 21 | * use: 22 | * - PRINT_ANY for context based output 23 | * - PRINT_FP for non json specific output 24 | * - PRINT_JSON for json specific output 25 | */ 26 | enum output_type { 27 | PRINT_FP = 1, 28 | PRINT_JSON = 2, 29 | PRINT_ANY = 4, 30 | }; 31 | 32 | void new_json_obj(int json); 33 | void delete_json_obj(void); 34 | 35 | bool is_json_context(void); 36 | 37 | void fflush_fp(void); 38 | 39 | void open_json_object(const char *str); 40 | void close_json_object(void); 41 | void open_json_array(enum output_type type, const char *delim); 42 | void close_json_array(enum output_type type, const char *delim); 43 | 44 | #define _PRINT_FUNC(type_name, type) \ 45 | void print_color_##type_name(enum output_type t, \ 46 | enum color_attr color, \ 47 | const char *key, \ 48 | const char *fmt, \ 49 | type value); \ 50 | \ 51 | static inline void print_##type_name(enum output_type t, \ 52 | const char *key, \ 53 | const char *fmt, \ 54 | type value) \ 55 | { \ 56 | print_color_##type_name(t, COLOR_NONE, key, fmt, value); \ 57 | } 58 | _PRINT_FUNC(int, int); 59 | _PRINT_FUNC(bool, bool); 60 | _PRINT_FUNC(null, const char*); 61 | _PRINT_FUNC(string, const char*); 62 | _PRINT_FUNC(uint, uint64_t); 63 | _PRINT_FUNC(hu, unsigned short); 64 | _PRINT_FUNC(hex, unsigned int); 65 | _PRINT_FUNC(0xhex, unsigned int); 66 | _PRINT_FUNC(lluint, unsigned long long int); 67 | #undef _PRINT_FUNC 68 | 69 | #endif /* _JSON_PRINT_H_ */ 70 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/json_writer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Simple streaming JSON writer 3 | * 4 | * This takes care of the annoying bits of JSON syntax like the commas 5 | * after elements 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 10 | * 2 of the License, or (at your option) any later version. 11 | * 12 | * Authors: Stephen Hemminger 13 | */ 14 | 15 | #ifndef _JSON_WRITER_H_ 16 | #define _JSON_WRITER_H_ 17 | 18 | #include 19 | #include 20 | 21 | /* Opaque class structure */ 22 | typedef struct json_writer json_writer_t; 23 | 24 | /* Create a new JSON stream */ 25 | json_writer_t *jsonw_new(FILE *f); 26 | /* End output to JSON stream */ 27 | void jsonw_destroy(json_writer_t **self_p); 28 | 29 | /* Cause output to have pretty whitespace */ 30 | void jsonw_pretty(json_writer_t *self, bool on); 31 | 32 | /* Add property name */ 33 | void jsonw_name(json_writer_t *self, const char *name); 34 | 35 | /* Add value */ 36 | void jsonw_printf(json_writer_t *self, const char *fmt, ...); 37 | void jsonw_string(json_writer_t *self, const char *value); 38 | void jsonw_bool(json_writer_t *self, bool value); 39 | void jsonw_float(json_writer_t *self, double number); 40 | void jsonw_float_fmt(json_writer_t *self, const char *fmt, double num); 41 | void jsonw_uint(json_writer_t *self, uint64_t number); 42 | void jsonw_hu(json_writer_t *self, unsigned short number); 43 | void jsonw_int(json_writer_t *self, int64_t number); 44 | void jsonw_null(json_writer_t *self); 45 | void jsonw_lluint(json_writer_t *self, unsigned long long int num); 46 | 47 | /* Useful Combinations of name and value */ 48 | void jsonw_string_field(json_writer_t *self, const char *prop, const char *val); 49 | void jsonw_bool_field(json_writer_t *self, const char *prop, bool value); 50 | void jsonw_float_field(json_writer_t *self, const char *prop, double num); 51 | void jsonw_uint_field(json_writer_t *self, const char *prop, uint64_t num); 52 | void jsonw_hu_field(json_writer_t *self, const char *prop, unsigned short num); 53 | void jsonw_int_field(json_writer_t *self, const char *prop, int64_t num); 54 | void jsonw_null_field(json_writer_t *self, const char *prop); 55 | void jsonw_lluint_field(json_writer_t *self, const char *prop, 56 | unsigned long long int num); 57 | void jsonw_float_field_fmt(json_writer_t *self, const char *prop, 58 | const char *fmt, double val); 59 | 60 | /* Collections */ 61 | void jsonw_start_object(json_writer_t *self); 62 | void jsonw_end_object(json_writer_t *self); 63 | 64 | void jsonw_start_array(json_writer_t *self); 65 | void jsonw_end_array(json_writer_t *self); 66 | 67 | /* Override default exception handling */ 68 | typedef void (jsonw_err_handler_fn)(const char *); 69 | 70 | #endif /* _JSON_WRITER_H_ */ 71 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/libgenl.h: -------------------------------------------------------------------------------- 1 | #ifndef __LIBGENL_H__ 2 | #define __LIBGENL_H__ 3 | 4 | #include "libnetlink.h" 5 | 6 | #define GENL_REQUEST(_req, _bufsiz, _family, _hdrsiz, _ver, _cmd, _flags) \ 7 | struct { \ 8 | struct nlmsghdr n; \ 9 | struct genlmsghdr g; \ 10 | char buf[NLMSG_ALIGN(_hdrsiz) + (_bufsiz)]; \ 11 | } _req = { \ 12 | .n = { \ 13 | .nlmsg_type = (_family), \ 14 | .nlmsg_flags = (_flags), \ 15 | .nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN + (_hdrsiz)), \ 16 | }, \ 17 | .g = { \ 18 | .cmd = (_cmd), \ 19 | .version = (_ver), \ 20 | }, \ 21 | } 22 | 23 | extern int genl_resolve_family(struct rtnl_handle *grth, const char *family); 24 | extern int genl_init_handle(struct rtnl_handle *grth, const char *family, 25 | int *genl_family); 26 | 27 | #endif /* __LIBGENL_H__ */ 28 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/libiptc/ipt_kernel_headers.h: -------------------------------------------------------------------------------- 1 | /* This is the userspace/kernel interface for Generic IP Chains, 2 | required for libc6. */ 3 | #ifndef _FWCHAINS_KERNEL_HEADERS_H 4 | #define _FWCHAINS_KERNEL_HEADERS_H 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #endif 16 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/libiptc/libxtc.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIBXTC_H 2 | #define _LIBXTC_H 3 | /* Library which manipulates filtering rules. */ 4 | 5 | #include 6 | #include 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #ifndef XT_MIN_ALIGN 13 | /* xt_entry has pointers and u_int64_t's in it, so if you align to 14 | it, you'll also align to any crazy matches and targets someone 15 | might write */ 16 | #define XT_MIN_ALIGN (__alignof__(struct xt_entry)) 17 | #endif 18 | 19 | #ifndef XT_ALIGN 20 | #define XT_ALIGN(s) (((s) + ((XT_MIN_ALIGN)-1)) & ~((XT_MIN_ALIGN)-1)) 21 | #endif 22 | 23 | #define XTC_LABEL_ACCEPT "ACCEPT" 24 | #define XTC_LABEL_DROP "DROP" 25 | #define XTC_LABEL_QUEUE "QUEUE" 26 | #define XTC_LABEL_RETURN "RETURN" 27 | 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif /* _LIBXTC_H */ 34 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/libiptc/xtcshared.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIBXTC_SHARED_H 2 | #define _LIBXTC_SHARED_H 1 3 | 4 | typedef char xt_chainlabel[32]; 5 | struct xtc_handle; 6 | struct xt_counters; 7 | 8 | struct xtc_ops { 9 | int (*commit)(struct xtc_handle *); 10 | void (*free)(struct xtc_handle *); 11 | int (*builtin)(const char *, struct xtc_handle *const); 12 | int (*is_chain)(const char *, struct xtc_handle *const); 13 | int (*flush_entries)(const xt_chainlabel, struct xtc_handle *); 14 | int (*create_chain)(const xt_chainlabel, struct xtc_handle *); 15 | int (*set_policy)(const xt_chainlabel, const xt_chainlabel, 16 | struct xt_counters *, struct xtc_handle *); 17 | const char *(*strerror)(int); 18 | }; 19 | 20 | #endif /* _LIBXTC_SHARED_H */ 21 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/list.h: -------------------------------------------------------------------------------- 1 | #ifndef __LIST_H__ 2 | #define __LIST_H__ 1 3 | /* List and hash list stuff from kernel */ 4 | 5 | #include 6 | 7 | #define container_of(ptr, type, member) ({ \ 8 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ 9 | (type *)( (char *)__mptr - offsetof(type,member) );}) 10 | 11 | struct list_head { 12 | struct list_head *next, *prev; 13 | }; 14 | 15 | static inline void INIT_LIST_HEAD(struct list_head *list) 16 | { 17 | list->next = list; 18 | list->prev = list; 19 | } 20 | 21 | static inline void __list_add(struct list_head *new, 22 | struct list_head *prev, 23 | struct list_head *next) 24 | { 25 | next->prev = new; 26 | new->next = next; 27 | new->prev = prev; 28 | prev->next = new; 29 | } 30 | 31 | static inline void list_add(struct list_head *new, struct list_head *head) 32 | { 33 | __list_add(new, head, head->next); 34 | } 35 | 36 | static inline void list_add_tail(struct list_head *new, struct list_head *head) 37 | { 38 | __list_add(new, head->prev, head); 39 | } 40 | 41 | static inline void __list_del(struct list_head *prev, struct list_head *next) 42 | { 43 | next->prev = prev; 44 | prev->next = next; 45 | } 46 | 47 | static inline void list_del(struct list_head *entry) 48 | { 49 | __list_del(entry->prev, entry->next); 50 | } 51 | 52 | #define list_entry(ptr, type, member) \ 53 | container_of(ptr, type, member) 54 | 55 | #define list_first_entry(ptr, type, member) \ 56 | list_entry((ptr)->next, type, member) 57 | 58 | #define list_last_entry(ptr, type, member) \ 59 | list_entry((ptr)->prev, type, member) 60 | 61 | #define list_next_entry(pos, member) \ 62 | list_entry((pos)->member.next, typeof(*(pos)), member) 63 | 64 | #define list_prev_entry(pos, member) \ 65 | list_entry((pos)->member.prev, typeof(*(pos)), member) 66 | 67 | #define list_for_each_entry(pos, head, member) \ 68 | for (pos = list_first_entry(head, typeof(*pos), member); \ 69 | &pos->member != (head); \ 70 | pos = list_next_entry(pos, member)) 71 | 72 | #define list_for_each_entry_safe(pos, n, head, member) \ 73 | for (pos = list_first_entry(head, typeof(*pos), member), \ 74 | n = list_next_entry(pos, member); \ 75 | &pos->member != (head); \ 76 | pos = n, n = list_next_entry(n, member)) 77 | 78 | #define list_for_each_entry_reverse(pos, head, member) \ 79 | for (pos = list_last_entry(head, typeof(*pos), member); \ 80 | &pos->member != (head); \ 81 | pos = list_prev_entry(pos, member)) 82 | 83 | struct hlist_head { 84 | struct hlist_node *first; 85 | }; 86 | 87 | struct hlist_node { 88 | struct hlist_node *next, **pprev; 89 | }; 90 | 91 | static inline void hlist_del(struct hlist_node *n) 92 | { 93 | struct hlist_node *next = n->next; 94 | struct hlist_node **pprev = n->pprev; 95 | *pprev = next; 96 | if (next) 97 | next->pprev = pprev; 98 | } 99 | 100 | static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h) 101 | { 102 | struct hlist_node *first = h->first; 103 | n->next = first; 104 | if (first) 105 | first->pprev = &n->next; 106 | h->first = n; 107 | n->pprev = &h->first; 108 | } 109 | 110 | #define hlist_for_each(pos, head) \ 111 | for (pos = (head)->first; pos ; pos = pos->next) 112 | 113 | 114 | #define hlist_for_each_safe(pos, n, head) \ 115 | for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \ 116 | pos = n) 117 | 118 | #define hlist_entry_safe(ptr, type, member) \ 119 | ({ typeof(ptr) ____ptr = (ptr); \ 120 | ____ptr ? hlist_entry(____ptr, type, member) : NULL; \ 121 | }) 122 | 123 | #define hlist_for_each_entry(pos, head, member) \ 124 | for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\ 125 | pos; \ 126 | pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member)) 127 | 128 | #endif /* __LIST_H__ */ 129 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/ll_map.h: -------------------------------------------------------------------------------- 1 | #ifndef __LL_MAP_H__ 2 | #define __LL_MAP_H__ 1 3 | 4 | int ll_remember_index(const struct sockaddr_nl *who, 5 | struct nlmsghdr *n, void *arg); 6 | 7 | void ll_init_map(struct rtnl_handle *rth); 8 | unsigned ll_name_to_index(const char *name); 9 | const char *ll_index_to_name(unsigned idx); 10 | const char *ll_idx_n2a(unsigned idx, char *buf); 11 | int ll_index_to_type(unsigned idx); 12 | int ll_index_to_flags(unsigned idx); 13 | unsigned namehash(const char *str); 14 | 15 | #endif /* __LL_MAP_H__ */ 16 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/names.h: -------------------------------------------------------------------------------- 1 | #ifndef DB_NAMES_H_ 2 | #define DB_NAMES_H_ 1 3 | 4 | #define IDNAME_MAX 256 5 | 6 | struct db_entry { 7 | struct db_entry *next; 8 | unsigned int id; 9 | char *name; 10 | }; 11 | 12 | struct db_names { 13 | unsigned int size; 14 | struct db_entry *cached; 15 | struct db_entry **hash; 16 | int max; 17 | }; 18 | 19 | struct db_names *db_names_alloc(void); 20 | int db_names_load(struct db_names *db, const char *path); 21 | void db_names_free(struct db_names *db); 22 | 23 | char *id_to_name(struct db_names *db, int id, char *name); 24 | int name_to_id(struct db_names *db, int *id, const char *name); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/namespace.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAMESPACE_H__ 2 | #define __NAMESPACE_H__ 1 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #ifndef NETNS_RUN_DIR 11 | #define NETNS_RUN_DIR "/var/run/netns" 12 | #endif 13 | 14 | #ifndef NETNS_ETC_DIR 15 | #define NETNS_ETC_DIR "/etc/netns" 16 | #endif 17 | 18 | #ifndef CLONE_NEWNET 19 | #define CLONE_NEWNET 0x40000000 /* New network namespace (lo, device, names sockets, etc) */ 20 | #endif 21 | 22 | #ifndef MNT_DETACH 23 | #define MNT_DETACH 0x00000002 /* Just detach from the tree */ 24 | #endif /* MNT_DETACH */ 25 | 26 | /* sys/mount.h may be out too old to have these */ 27 | #ifndef MS_REC 28 | #define MS_REC 16384 29 | #endif 30 | 31 | #ifndef MS_SLAVE 32 | #define MS_SLAVE (1 << 19) 33 | #endif 34 | 35 | #ifndef MS_SHARED 36 | #define MS_SHARED (1 << 20) 37 | #endif 38 | 39 | #ifndef HAVE_SETNS 40 | static inline int setns(int fd, int nstype) 41 | { 42 | #ifdef __NR_setns 43 | return syscall(__NR_setns, fd, nstype); 44 | #else 45 | errno = ENOSYS; 46 | return -1; 47 | #endif 48 | } 49 | #endif /* HAVE_SETNS */ 50 | 51 | int netns_switch(char *netns); 52 | int netns_get_fd(const char *netns); 53 | int netns_foreach(int (*func)(char *nsname, void *arg), void *arg); 54 | 55 | struct netns_func { 56 | int (*func)(char *nsname, void *arg); 57 | void *arg; 58 | }; 59 | 60 | #endif /* __NAMESPACE_H__ */ 61 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/rt_names.h: -------------------------------------------------------------------------------- 1 | #ifndef RT_NAMES_H_ 2 | #define RT_NAMES_H_ 1 3 | 4 | #include 5 | 6 | const char *rtnl_rtprot_n2a(int id, char *buf, int len); 7 | const char *rtnl_rtscope_n2a(int id, char *buf, int len); 8 | const char *rtnl_rttable_n2a(__u32 id, char *buf, int len); 9 | const char *rtnl_rtrealm_n2a(int id, char *buf, int len); 10 | const char *rtnl_dsfield_n2a(int id, char *buf, int len); 11 | const char *rtnl_group_n2a(int id, char *buf, int len); 12 | 13 | int rtnl_rtprot_a2n(__u32 *id, const char *arg); 14 | int rtnl_rtscope_a2n(__u32 *id, const char *arg); 15 | int rtnl_rttable_a2n(__u32 *id, const char *arg); 16 | int rtnl_rtrealm_a2n(__u32 *id, const char *arg); 17 | int rtnl_dsfield_a2n(__u32 *id, const char *arg); 18 | int rtnl_group_a2n(int *id, const char *arg); 19 | 20 | const char *inet_proto_n2a(int proto, char *buf, int len); 21 | int inet_proto_a2n(const char *buf); 22 | 23 | 24 | const char * ll_type_n2a(int type, char *buf, int len); 25 | const char *ll_addr_n2a(const unsigned char *addr, int alen, 26 | int type, char *buf, int blen); 27 | int ll_addr_a2n(char *lladdr, int len, const char *arg); 28 | 29 | const char * ll_proto_n2a(unsigned short id, char *buf, int len); 30 | int ll_proto_a2n(unsigned short *id, const char *buf); 31 | 32 | const char *nl_proto_n2a(int id, char *buf, int len); 33 | int nl_proto_a2n(__u32 *id, const char *arg); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/rtm_map.h: -------------------------------------------------------------------------------- 1 | #ifndef __RTM_MAP_H__ 2 | #define __RTM_MAP_H__ 1 3 | 4 | char *rtnl_rtntype_n2a(int id, char *buf, int len); 5 | int rtnl_rtntype_a2n(int *id, char *arg); 6 | 7 | int get_rt_realms_or_raw(__u32 *realms, char *arg); 8 | 9 | #endif /* __RTM_MAP_H__ */ 10 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/atmapi.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | /* atmapi.h - ATM API user space/kernel compatibility */ 3 | 4 | /* Written 1999,2000 by Werner Almesberger, EPFL ICA */ 5 | 6 | 7 | #ifndef _LINUX_ATMAPI_H 8 | #define _LINUX_ATMAPI_H 9 | 10 | #if defined(__sparc__) || defined(__ia64__) 11 | /* such alignment is not required on 32 bit sparcs, but we can't 12 | figure that we are on a sparc64 while compiling user-space programs. */ 13 | #define __ATM_API_ALIGN __attribute__((aligned(8))) 14 | #else 15 | #define __ATM_API_ALIGN 16 | #endif 17 | 18 | 19 | /* 20 | * Opaque type for kernel pointers. Note that _ is never accessed. We need 21 | * the struct in order hide the array, so that we can make simple assignments 22 | * instead of being forced to use memcpy. It also improves error reporting for 23 | * code that still assumes that we're passing unsigned longs. 24 | * 25 | * Convention: NULL pointers are passed as a field of all zeroes. 26 | */ 27 | 28 | typedef struct { unsigned char _[8]; } __ATM_API_ALIGN atm_kptr_t; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/atmarp.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | /* atmarp.h - ATM ARP protocol and kernel-demon interface definitions */ 3 | 4 | /* Written 1995-1999 by Werner Almesberger, EPFL LRC/ICA */ 5 | 6 | 7 | #ifndef _LINUX_ATMARP_H 8 | #define _LINUX_ATMARP_H 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | #define ATMARP_RETRY_DELAY 30 /* request next resolution or forget 16 | NAK after 30 sec - should go into 17 | atmclip.h */ 18 | #define ATMARP_MAX_UNRES_PACKETS 5 /* queue that many packets while 19 | waiting for the resolver */ 20 | 21 | 22 | #define ATMARPD_CTRL _IO('a',ATMIOC_CLIP+1) /* become atmarpd ctrl sock */ 23 | #define ATMARP_MKIP _IO('a',ATMIOC_CLIP+2) /* attach socket to IP */ 24 | #define ATMARP_SETENTRY _IO('a',ATMIOC_CLIP+3) /* fill or hide ARP entry */ 25 | #define ATMARP_ENCAP _IO('a',ATMIOC_CLIP+5) /* change encapsulation */ 26 | 27 | 28 | enum atmarp_ctrl_type { 29 | act_invalid, /* catch uninitialized structures */ 30 | act_need, /* need address resolution */ 31 | act_up, /* interface is coming up */ 32 | act_down, /* interface is going down */ 33 | act_change /* interface configuration has changed */ 34 | }; 35 | 36 | struct atmarp_ctrl { 37 | enum atmarp_ctrl_type type; /* message type */ 38 | int itf_num;/* interface number (if present) */ 39 | __be32 ip; /* IP address (act_need only) */ 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/atmioc.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | /* atmioc.h - ranges for ATM-related ioctl numbers */ 3 | 4 | /* Written 1995-1999 by Werner Almesberger, EPFL LRC/ICA */ 5 | 6 | 7 | /* 8 | * See http://icawww1.epfl.ch/linux-atm/magic.html for the complete list of 9 | * "magic" ioctl numbers. 10 | */ 11 | 12 | 13 | #ifndef _LINUX_ATMIOC_H 14 | #define _LINUX_ATMIOC_H 15 | 16 | #include 17 | /* everybody including atmioc.h will also need _IO{,R,W,WR} */ 18 | 19 | #define ATMIOC_PHYCOM 0x00 /* PHY device common ioctls, globally unique */ 20 | #define ATMIOC_PHYCOM_END 0x0f 21 | #define ATMIOC_PHYTYP 0x10 /* PHY dev type ioctls, unique per PHY type */ 22 | #define ATMIOC_PHYTYP_END 0x2f 23 | #define ATMIOC_PHYPRV 0x30 /* PHY dev private ioctls, unique per driver */ 24 | #define ATMIOC_PHYPRV_END 0x4f 25 | #define ATMIOC_SARCOM 0x50 /* SAR device common ioctls, globally unique */ 26 | #define ATMIOC_SARCOM_END 0x50 27 | #define ATMIOC_SARPRV 0x60 /* SAR dev private ioctls, unique per driver */ 28 | #define ATMIOC_SARPRV_END 0x7f 29 | #define ATMIOC_ITF 0x80 /* Interface ioctls, globally unique */ 30 | #define ATMIOC_ITF_END 0x8f 31 | #define ATMIOC_BACKEND 0x90 /* ATM generic backend ioctls, u. per backend */ 32 | #define ATMIOC_BACKEND_END 0xaf 33 | /* 0xb0-0xbf: Reserved for future use */ 34 | #define ATMIOC_AREQUIPA 0xc0 /* Application requested IP over ATM, glob. u. */ 35 | #define ATMIOC_LANE 0xd0 /* LAN Emulation, globally unique */ 36 | #define ATMIOC_MPOA 0xd8 /* MPOA, globally unique */ 37 | #define ATMIOC_CLIP 0xe0 /* Classical IP over ATM control, globally u. */ 38 | #define ATMIOC_CLIP_END 0xef 39 | #define ATMIOC_SPECIAL 0xf0 /* Special-purpose controls, globally unique */ 40 | #define ATMIOC_SPECIAL_END 0xff 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/bpf_common.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __LINUX_BPF_COMMON_H__ 3 | #define __LINUX_BPF_COMMON_H__ 4 | 5 | /* Instruction classes */ 6 | #define BPF_CLASS(code) ((code) & 0x07) 7 | #define BPF_LD 0x00 8 | #define BPF_LDX 0x01 9 | #define BPF_ST 0x02 10 | #define BPF_STX 0x03 11 | #define BPF_ALU 0x04 12 | #define BPF_JMP 0x05 13 | #define BPF_RET 0x06 14 | #define BPF_MISC 0x07 15 | 16 | /* ld/ldx fields */ 17 | #define BPF_SIZE(code) ((code) & 0x18) 18 | #define BPF_W 0x00 19 | #define BPF_H 0x08 20 | #define BPF_B 0x10 21 | #define BPF_MODE(code) ((code) & 0xe0) 22 | #define BPF_IMM 0x00 23 | #define BPF_ABS 0x20 24 | #define BPF_IND 0x40 25 | #define BPF_MEM 0x60 26 | #define BPF_LEN 0x80 27 | #define BPF_MSH 0xa0 28 | 29 | /* alu/jmp fields */ 30 | #define BPF_OP(code) ((code) & 0xf0) 31 | #define BPF_ADD 0x00 32 | #define BPF_SUB 0x10 33 | #define BPF_MUL 0x20 34 | #define BPF_DIV 0x30 35 | #define BPF_OR 0x40 36 | #define BPF_AND 0x50 37 | #define BPF_LSH 0x60 38 | #define BPF_RSH 0x70 39 | #define BPF_NEG 0x80 40 | #define BPF_MOD 0x90 41 | #define BPF_XOR 0xa0 42 | 43 | #define BPF_JA 0x00 44 | #define BPF_JEQ 0x10 45 | #define BPF_JGT 0x20 46 | #define BPF_JGE 0x30 47 | #define BPF_JSET 0x40 48 | #define BPF_SRC(code) ((code) & 0x08) 49 | #define BPF_K 0x00 50 | #define BPF_X 0x08 51 | 52 | #ifndef BPF_MAXINSNS 53 | #define BPF_MAXINSNS 4096 54 | #endif 55 | 56 | #endif /* __LINUX_BPF_COMMON_H__ */ 57 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/can/netlink.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | /* 3 | * linux/can/netlink.h 4 | * 5 | * Definitions for the CAN netlink interface 6 | * 7 | * Copyright (c) 2009 Wolfgang Grandegger 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the version 2 of the GNU General Public License 11 | * as published by the Free Software Foundation 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | */ 18 | 19 | #ifndef _CAN_NETLINK_H 20 | #define _CAN_NETLINK_H 21 | 22 | #include 23 | 24 | /* 25 | * CAN bit-timing parameters 26 | * 27 | * For further information, please read chapter "8 BIT TIMING 28 | * REQUIREMENTS" of the "Bosch CAN Specification version 2.0" 29 | * at http://www.semiconductors.bosch.de/pdf/can2spec.pdf. 30 | */ 31 | struct can_bittiming { 32 | __u32 bitrate; /* Bit-rate in bits/second */ 33 | __u32 sample_point; /* Sample point in one-tenth of a percent */ 34 | __u32 tq; /* Time quanta (TQ) in nanoseconds */ 35 | __u32 prop_seg; /* Propagation segment in TQs */ 36 | __u32 phase_seg1; /* Phase buffer segment 1 in TQs */ 37 | __u32 phase_seg2; /* Phase buffer segment 2 in TQs */ 38 | __u32 sjw; /* Synchronisation jump width in TQs */ 39 | __u32 brp; /* Bit-rate prescaler */ 40 | }; 41 | 42 | /* 43 | * CAN harware-dependent bit-timing constant 44 | * 45 | * Used for calculating and checking bit-timing parameters 46 | */ 47 | struct can_bittiming_const { 48 | char name[16]; /* Name of the CAN controller hardware */ 49 | __u32 tseg1_min; /* Time segement 1 = prop_seg + phase_seg1 */ 50 | __u32 tseg1_max; 51 | __u32 tseg2_min; /* Time segement 2 = phase_seg2 */ 52 | __u32 tseg2_max; 53 | __u32 sjw_max; /* Synchronisation jump width */ 54 | __u32 brp_min; /* Bit-rate prescaler */ 55 | __u32 brp_max; 56 | __u32 brp_inc; 57 | }; 58 | 59 | /* 60 | * CAN clock parameters 61 | */ 62 | struct can_clock { 63 | __u32 freq; /* CAN system clock frequency in Hz */ 64 | }; 65 | 66 | /* 67 | * CAN operational and error states 68 | */ 69 | enum can_state { 70 | CAN_STATE_ERROR_ACTIVE = 0, /* RX/TX error count < 96 */ 71 | CAN_STATE_ERROR_WARNING, /* RX/TX error count < 128 */ 72 | CAN_STATE_ERROR_PASSIVE, /* RX/TX error count < 256 */ 73 | CAN_STATE_BUS_OFF, /* RX/TX error count >= 256 */ 74 | CAN_STATE_STOPPED, /* Device is stopped */ 75 | CAN_STATE_SLEEPING, /* Device is sleeping */ 76 | CAN_STATE_MAX 77 | }; 78 | 79 | /* 80 | * CAN bus error counters 81 | */ 82 | struct can_berr_counter { 83 | __u16 txerr; 84 | __u16 rxerr; 85 | }; 86 | 87 | /* 88 | * CAN controller mode 89 | */ 90 | struct can_ctrlmode { 91 | __u32 mask; 92 | __u32 flags; 93 | }; 94 | 95 | #define CAN_CTRLMODE_LOOPBACK 0x01 /* Loopback mode */ 96 | #define CAN_CTRLMODE_LISTENONLY 0x02 /* Listen-only mode */ 97 | #define CAN_CTRLMODE_3_SAMPLES 0x04 /* Triple sampling mode */ 98 | #define CAN_CTRLMODE_ONE_SHOT 0x08 /* One-Shot mode */ 99 | #define CAN_CTRLMODE_BERR_REPORTING 0x10 /* Bus-error reporting */ 100 | #define CAN_CTRLMODE_FD 0x20 /* CAN FD mode */ 101 | #define CAN_CTRLMODE_PRESUME_ACK 0x40 /* Ignore missing CAN ACKs */ 102 | #define CAN_CTRLMODE_FD_NON_ISO 0x80 /* CAN FD in non-ISO mode */ 103 | 104 | /* 105 | * CAN device statistics 106 | */ 107 | struct can_device_stats { 108 | __u32 bus_error; /* Bus errors */ 109 | __u32 error_warning; /* Changes to error warning state */ 110 | __u32 error_passive; /* Changes to error passive state */ 111 | __u32 bus_off; /* Changes to bus off state */ 112 | __u32 arbitration_lost; /* Arbitration lost errors */ 113 | __u32 restarts; /* CAN controller re-starts */ 114 | }; 115 | 116 | /* 117 | * CAN netlink interface 118 | */ 119 | enum { 120 | IFLA_CAN_UNSPEC, 121 | IFLA_CAN_BITTIMING, 122 | IFLA_CAN_BITTIMING_CONST, 123 | IFLA_CAN_CLOCK, 124 | IFLA_CAN_STATE, 125 | IFLA_CAN_CTRLMODE, 126 | IFLA_CAN_RESTART_MS, 127 | IFLA_CAN_RESTART, 128 | IFLA_CAN_BERR_COUNTER, 129 | IFLA_CAN_DATA_BITTIMING, 130 | IFLA_CAN_DATA_BITTIMING_CONST, 131 | IFLA_CAN_TERMINATION, 132 | IFLA_CAN_TERMINATION_CONST, 133 | IFLA_CAN_BITRATE_CONST, 134 | IFLA_CAN_DATA_BITRATE_CONST, 135 | __IFLA_CAN_MAX 136 | }; 137 | 138 | #define IFLA_CAN_MAX (__IFLA_CAN_MAX - 1) 139 | 140 | /* u16 termination range: 1..65535 Ohms */ 141 | #define CAN_TERMINATION_DISABLED 0 142 | 143 | #endif /* !_UAPI_CAN_NETLINK_H */ 144 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/can/vxcan.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _CAN_VXCAN_H 3 | #define _CAN_VXCAN_H 4 | 5 | enum { 6 | VXCAN_INFO_UNSPEC, 7 | VXCAN_INFO_PEER, 8 | 9 | __VXCAN_INFO_MAX 10 | #define VXCAN_INFO_MAX (__VXCAN_INFO_MAX - 1) 11 | }; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/elf-em.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_ELF_EM_H 3 | #define _LINUX_ELF_EM_H 4 | 5 | /* These constants define the various ELF target machines */ 6 | #define EM_NONE 0 7 | #define EM_M32 1 8 | #define EM_SPARC 2 9 | #define EM_386 3 10 | #define EM_68K 4 11 | #define EM_88K 5 12 | #define EM_486 6 /* Perhaps disused */ 13 | #define EM_860 7 14 | #define EM_MIPS 8 /* MIPS R3000 (officially, big-endian only) */ 15 | /* Next two are historical and binaries and 16 | modules of these types will be rejected by 17 | Linux. */ 18 | #define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */ 19 | #define EM_MIPS_RS4_BE 10 /* MIPS R4000 big-endian */ 20 | 21 | #define EM_PARISC 15 /* HPPA */ 22 | #define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ 23 | #define EM_PPC 20 /* PowerPC */ 24 | #define EM_PPC64 21 /* PowerPC64 */ 25 | #define EM_SPU 23 /* Cell BE SPU */ 26 | #define EM_ARM 40 /* ARM 32 bit */ 27 | #define EM_SH 42 /* SuperH */ 28 | #define EM_SPARCV9 43 /* SPARC v9 64-bit */ 29 | #define EM_H8_300 46 /* Renesas H8/300 */ 30 | #define EM_IA_64 50 /* HP/Intel IA-64 */ 31 | #define EM_X86_64 62 /* AMD x86-64 */ 32 | #define EM_S390 22 /* IBM S/390 */ 33 | #define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ 34 | #define EM_M32R 88 /* Renesas M32R */ 35 | #define EM_MN10300 89 /* Panasonic/MEI MN10300, AM33 */ 36 | #define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ 37 | #define EM_BLACKFIN 106 /* ADI Blackfin Processor */ 38 | #define EM_ALTERA_NIOS2 113 /* Altera Nios II soft-core processor */ 39 | #define EM_TI_C6000 140 /* TI C6X DSPs */ 40 | #define EM_AARCH64 183 /* ARM 64 bit */ 41 | #define EM_TILEPRO 188 /* Tilera TILEPro */ 42 | #define EM_MICROBLAZE 189 /* Xilinx MicroBlaze */ 43 | #define EM_TILEGX 191 /* Tilera TILE-Gx */ 44 | #define EM_BPF 247 /* Linux BPF - in-kernel virtual machine */ 45 | #define EM_FRV 0x5441 /* Fujitsu FR-V */ 46 | 47 | /* 48 | * This is an interim value that we will use until the committee comes 49 | * up with a final number. 50 | */ 51 | #define EM_ALPHA 0x9026 52 | 53 | /* Bogus old m32r magic number, used by old tools. */ 54 | #define EM_CYGNUS_M32R 0x9041 55 | /* This is the old interim value for S/390 architecture */ 56 | #define EM_S390_OLD 0xA390 57 | /* Also Panasonic/MEI MN10300, AM33 */ 58 | #define EM_CYGNUS_MN10300 0xbeef 59 | 60 | 61 | #endif /* _LINUX_ELF_EM_H */ 62 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/fib_rules.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __LINUX_FIB_RULES_H 3 | #define __LINUX_FIB_RULES_H 4 | 5 | #include 6 | #include 7 | 8 | /* rule is permanent, and cannot be deleted */ 9 | #define FIB_RULE_PERMANENT 0x00000001 10 | #define FIB_RULE_INVERT 0x00000002 11 | #define FIB_RULE_UNRESOLVED 0x00000004 12 | #define FIB_RULE_IIF_DETACHED 0x00000008 13 | #define FIB_RULE_DEV_DETACHED FIB_RULE_IIF_DETACHED 14 | #define FIB_RULE_OIF_DETACHED 0x00000010 15 | 16 | /* try to find source address in routing lookups */ 17 | #define FIB_RULE_FIND_SADDR 0x00010000 18 | 19 | struct fib_rule_hdr { 20 | __u8 family; 21 | __u8 dst_len; 22 | __u8 src_len; 23 | __u8 tos; 24 | 25 | __u8 table; 26 | __u8 res1; /* reserved */ 27 | __u8 res2; /* reserved */ 28 | __u8 action; 29 | 30 | __u32 flags; 31 | }; 32 | 33 | struct fib_rule_uid_range { 34 | __u32 start; 35 | __u32 end; 36 | }; 37 | 38 | enum { 39 | FRA_UNSPEC, 40 | FRA_DST, /* destination address */ 41 | FRA_SRC, /* source address */ 42 | FRA_IIFNAME, /* interface name */ 43 | #define FRA_IFNAME FRA_IIFNAME 44 | FRA_GOTO, /* target to jump to (FR_ACT_GOTO) */ 45 | FRA_UNUSED2, 46 | FRA_PRIORITY, /* priority/preference */ 47 | FRA_UNUSED3, 48 | FRA_UNUSED4, 49 | FRA_UNUSED5, 50 | FRA_FWMARK, /* mark */ 51 | FRA_FLOW, /* flow/class id */ 52 | FRA_TUN_ID, 53 | FRA_SUPPRESS_IFGROUP, 54 | FRA_SUPPRESS_PREFIXLEN, 55 | FRA_TABLE, /* Extended table id */ 56 | FRA_FWMASK, /* mask for netfilter mark */ 57 | FRA_OIFNAME, 58 | FRA_PAD, 59 | FRA_L3MDEV, /* iif or oif is l3mdev goto its table */ 60 | FRA_UID_RANGE, /* UID range */ 61 | __FRA_MAX 62 | }; 63 | 64 | #define FRA_MAX (__FRA_MAX - 1) 65 | 66 | enum { 67 | FR_ACT_UNSPEC, 68 | FR_ACT_TO_TBL, /* Pass to fixed table */ 69 | FR_ACT_GOTO, /* Jump to another rule */ 70 | FR_ACT_NOP, /* No operation */ 71 | FR_ACT_RES3, 72 | FR_ACT_RES4, 73 | FR_ACT_BLACKHOLE, /* Drop without notification */ 74 | FR_ACT_UNREACHABLE, /* Drop with ENETUNREACH */ 75 | FR_ACT_PROHIBIT, /* Drop with EACCES */ 76 | __FR_ACT_MAX, 77 | }; 78 | 79 | #define FR_ACT_MAX (__FR_ACT_MAX - 1) 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/filter.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | /* 3 | * Linux Socket Filter Data Structures 4 | */ 5 | 6 | #ifndef __LINUX_FILTER_H__ 7 | #define __LINUX_FILTER_H__ 8 | 9 | 10 | #include 11 | #include 12 | 13 | /* 14 | * Current version of the filter code architecture. 15 | */ 16 | #define BPF_MAJOR_VERSION 1 17 | #define BPF_MINOR_VERSION 1 18 | 19 | /* 20 | * Try and keep these values and structures similar to BSD, especially 21 | * the BPF code definitions which need to match so you can share filters 22 | */ 23 | 24 | struct sock_filter { /* Filter block */ 25 | __u16 code; /* Actual filter code */ 26 | __u8 jt; /* Jump true */ 27 | __u8 jf; /* Jump false */ 28 | __u32 k; /* Generic multiuse field */ 29 | }; 30 | 31 | struct sock_fprog { /* Required for SO_ATTACH_FILTER. */ 32 | unsigned short len; /* Number of filter blocks */ 33 | struct sock_filter *filter; 34 | }; 35 | 36 | /* ret - BPF_K and BPF_X also apply */ 37 | #define BPF_RVAL(code) ((code) & 0x18) 38 | #define BPF_A 0x10 39 | 40 | /* misc */ 41 | #define BPF_MISCOP(code) ((code) & 0xf8) 42 | #define BPF_TAX 0x00 43 | #define BPF_TXA 0x80 44 | 45 | /* 46 | * Macros for filter block array initializers. 47 | */ 48 | #ifndef BPF_STMT 49 | #define BPF_STMT(code, k) { (unsigned short)(code), 0, 0, k } 50 | #endif 51 | #ifndef BPF_JUMP 52 | #define BPF_JUMP(code, k, jt, jf) { (unsigned short)(code), jt, jf, k } 53 | #endif 54 | 55 | /* 56 | * Number of scratch memory words for: BPF_ST and BPF_STX 57 | */ 58 | #define BPF_MEMWORDS 16 59 | 60 | /* RATIONALE. Negative offsets are invalid in BPF. 61 | We use them to reference ancillary data. 62 | Unlike introduction new instructions, it does not break 63 | existing compilers/optimizers. 64 | */ 65 | #define SKF_AD_OFF (-0x1000) 66 | #define SKF_AD_PROTOCOL 0 67 | #define SKF_AD_PKTTYPE 4 68 | #define SKF_AD_IFINDEX 8 69 | #define SKF_AD_NLATTR 12 70 | #define SKF_AD_NLATTR_NEST 16 71 | #define SKF_AD_MARK 20 72 | #define SKF_AD_QUEUE 24 73 | #define SKF_AD_HATYPE 28 74 | #define SKF_AD_RXHASH 32 75 | #define SKF_AD_CPU 36 76 | #define SKF_AD_ALU_XOR_X 40 77 | #define SKF_AD_VLAN_TAG 44 78 | #define SKF_AD_VLAN_TAG_PRESENT 48 79 | #define SKF_AD_PAY_OFFSET 52 80 | #define SKF_AD_RANDOM 56 81 | #define SKF_AD_VLAN_TPID 60 82 | #define SKF_AD_MAX 64 83 | 84 | #define SKF_NET_OFF (-0x100000) 85 | #define SKF_LL_OFF (-0x200000) 86 | 87 | #define BPF_NET_OFF SKF_NET_OFF 88 | #define BPF_LL_OFF SKF_LL_OFF 89 | 90 | #endif /* __LINUX_FILTER_H__ */ 91 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/fou.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | /* fou.h - FOU Interface */ 3 | 4 | #ifndef _LINUX_FOU_H 5 | #define _LINUX_FOU_H 6 | 7 | /* NETLINK_GENERIC related info 8 | */ 9 | #define FOU_GENL_NAME "fou" 10 | #define FOU_GENL_VERSION 0x1 11 | 12 | enum { 13 | FOU_ATTR_UNSPEC, 14 | FOU_ATTR_PORT, /* u16 */ 15 | FOU_ATTR_AF, /* u8 */ 16 | FOU_ATTR_IPPROTO, /* u8 */ 17 | FOU_ATTR_TYPE, /* u8 */ 18 | FOU_ATTR_REMCSUM_NOPARTIAL, /* flag */ 19 | 20 | __FOU_ATTR_MAX, 21 | }; 22 | 23 | #define FOU_ATTR_MAX (__FOU_ATTR_MAX - 1) 24 | 25 | enum { 26 | FOU_CMD_UNSPEC, 27 | FOU_CMD_ADD, 28 | FOU_CMD_DEL, 29 | FOU_CMD_GET, 30 | 31 | __FOU_CMD_MAX, 32 | }; 33 | 34 | enum { 35 | FOU_ENCAP_UNSPEC, 36 | FOU_ENCAP_DIRECT, 37 | FOU_ENCAP_GUE, 38 | }; 39 | 40 | #define FOU_CMD_MAX (__FOU_CMD_MAX - 1) 41 | 42 | #endif /* _LINUX_FOU_H */ 43 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/gen_stats.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __LINUX_GEN_STATS_H 3 | #define __LINUX_GEN_STATS_H 4 | 5 | #include 6 | 7 | enum { 8 | TCA_STATS_UNSPEC, 9 | TCA_STATS_BASIC, 10 | TCA_STATS_RATE_EST, 11 | TCA_STATS_QUEUE, 12 | TCA_STATS_APP, 13 | TCA_STATS_RATE_EST64, 14 | TCA_STATS_PAD, 15 | __TCA_STATS_MAX, 16 | }; 17 | #define TCA_STATS_MAX (__TCA_STATS_MAX - 1) 18 | 19 | /** 20 | * struct gnet_stats_basic - byte/packet throughput statistics 21 | * @bytes: number of seen bytes 22 | * @packets: number of seen packets 23 | */ 24 | struct gnet_stats_basic { 25 | __u64 bytes; 26 | __u32 packets; 27 | }; 28 | struct gnet_stats_basic_packed { 29 | __u64 bytes; 30 | __u32 packets; 31 | } __attribute__ ((packed)); 32 | 33 | /** 34 | * struct gnet_stats_rate_est - rate estimator 35 | * @bps: current byte rate 36 | * @pps: current packet rate 37 | */ 38 | struct gnet_stats_rate_est { 39 | __u32 bps; 40 | __u32 pps; 41 | }; 42 | 43 | /** 44 | * struct gnet_stats_rate_est64 - rate estimator 45 | * @bps: current byte rate 46 | * @pps: current packet rate 47 | */ 48 | struct gnet_stats_rate_est64 { 49 | __u64 bps; 50 | __u64 pps; 51 | }; 52 | 53 | /** 54 | * struct gnet_stats_queue - queuing statistics 55 | * @qlen: queue length 56 | * @backlog: backlog size of queue 57 | * @drops: number of dropped packets 58 | * @requeues: number of requeues 59 | * @overlimits: number of enqueues over the limit 60 | */ 61 | struct gnet_stats_queue { 62 | __u32 qlen; 63 | __u32 backlog; 64 | __u32 drops; 65 | __u32 requeues; 66 | __u32 overlimits; 67 | }; 68 | 69 | /** 70 | * struct gnet_estimator - rate estimator configuration 71 | * @interval: sampling period 72 | * @ewma_log: the log of measurement window weight 73 | */ 74 | struct gnet_estimator { 75 | signed char interval; 76 | unsigned char ewma_log; 77 | }; 78 | 79 | 80 | #endif /* __LINUX_GEN_STATS_H */ 81 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/genetlink.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __LINUX_GENERIC_NETLINK_H 3 | #define __LINUX_GENERIC_NETLINK_H 4 | 5 | #include 6 | #include 7 | 8 | #define GENL_NAMSIZ 16 /* length of family name */ 9 | 10 | #define GENL_MIN_ID NLMSG_MIN_TYPE 11 | #define GENL_MAX_ID 1023 12 | 13 | struct genlmsghdr { 14 | __u8 cmd; 15 | __u8 version; 16 | __u16 reserved; 17 | }; 18 | 19 | #define GENL_HDRLEN NLMSG_ALIGN(sizeof(struct genlmsghdr)) 20 | 21 | #define GENL_ADMIN_PERM 0x01 22 | #define GENL_CMD_CAP_DO 0x02 23 | #define GENL_CMD_CAP_DUMP 0x04 24 | #define GENL_CMD_CAP_HASPOL 0x08 25 | #define GENL_UNS_ADMIN_PERM 0x10 26 | 27 | /* 28 | * List of reserved static generic netlink identifiers: 29 | */ 30 | #define GENL_ID_CTRL NLMSG_MIN_TYPE 31 | #define GENL_ID_VFS_DQUOT (NLMSG_MIN_TYPE + 1) 32 | #define GENL_ID_PMCRAID (NLMSG_MIN_TYPE + 2) 33 | /* must be last reserved + 1 */ 34 | #define GENL_START_ALLOC (NLMSG_MIN_TYPE + 3) 35 | 36 | /************************************************************************** 37 | * Controller 38 | **************************************************************************/ 39 | 40 | enum { 41 | CTRL_CMD_UNSPEC, 42 | CTRL_CMD_NEWFAMILY, 43 | CTRL_CMD_DELFAMILY, 44 | CTRL_CMD_GETFAMILY, 45 | CTRL_CMD_NEWOPS, 46 | CTRL_CMD_DELOPS, 47 | CTRL_CMD_GETOPS, 48 | CTRL_CMD_NEWMCAST_GRP, 49 | CTRL_CMD_DELMCAST_GRP, 50 | CTRL_CMD_GETMCAST_GRP, /* unused */ 51 | __CTRL_CMD_MAX, 52 | }; 53 | 54 | #define CTRL_CMD_MAX (__CTRL_CMD_MAX - 1) 55 | 56 | enum { 57 | CTRL_ATTR_UNSPEC, 58 | CTRL_ATTR_FAMILY_ID, 59 | CTRL_ATTR_FAMILY_NAME, 60 | CTRL_ATTR_VERSION, 61 | CTRL_ATTR_HDRSIZE, 62 | CTRL_ATTR_MAXATTR, 63 | CTRL_ATTR_OPS, 64 | CTRL_ATTR_MCAST_GROUPS, 65 | __CTRL_ATTR_MAX, 66 | }; 67 | 68 | #define CTRL_ATTR_MAX (__CTRL_ATTR_MAX - 1) 69 | 70 | enum { 71 | CTRL_ATTR_OP_UNSPEC, 72 | CTRL_ATTR_OP_ID, 73 | CTRL_ATTR_OP_FLAGS, 74 | __CTRL_ATTR_OP_MAX, 75 | }; 76 | 77 | #define CTRL_ATTR_OP_MAX (__CTRL_ATTR_OP_MAX - 1) 78 | 79 | enum { 80 | CTRL_ATTR_MCAST_GRP_UNSPEC, 81 | CTRL_ATTR_MCAST_GRP_NAME, 82 | CTRL_ATTR_MCAST_GRP_ID, 83 | __CTRL_ATTR_MCAST_GRP_MAX, 84 | }; 85 | 86 | #define CTRL_ATTR_MCAST_GRP_MAX (__CTRL_ATTR_MCAST_GRP_MAX - 1) 87 | 88 | 89 | #endif /* __LINUX_GENERIC_NETLINK_H */ 90 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/hdlc/ioctl.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __HDLC_IOCTL_H__ 3 | #define __HDLC_IOCTL_H__ 4 | 5 | 6 | #define GENERIC_HDLC_VERSION 4 /* For synchronization with sethdlc utility */ 7 | 8 | #define CLOCK_DEFAULT 0 /* Default setting */ 9 | #define CLOCK_EXT 1 /* External TX and RX clock - DTE */ 10 | #define CLOCK_INT 2 /* Internal TX and RX clock - DCE */ 11 | #define CLOCK_TXINT 3 /* Internal TX and external RX clock */ 12 | #define CLOCK_TXFROMRX 4 /* TX clock derived from external RX clock */ 13 | 14 | 15 | #define ENCODING_DEFAULT 0 /* Default setting */ 16 | #define ENCODING_NRZ 1 17 | #define ENCODING_NRZI 2 18 | #define ENCODING_FM_MARK 3 19 | #define ENCODING_FM_SPACE 4 20 | #define ENCODING_MANCHESTER 5 21 | 22 | 23 | #define PARITY_DEFAULT 0 /* Default setting */ 24 | #define PARITY_NONE 1 /* No parity */ 25 | #define PARITY_CRC16_PR0 2 /* CRC16, initial value 0x0000 */ 26 | #define PARITY_CRC16_PR1 3 /* CRC16, initial value 0xFFFF */ 27 | #define PARITY_CRC16_PR0_CCITT 4 /* CRC16, initial 0x0000, ITU-T version */ 28 | #define PARITY_CRC16_PR1_CCITT 5 /* CRC16, initial 0xFFFF, ITU-T version */ 29 | #define PARITY_CRC32_PR0_CCITT 6 /* CRC32, initial value 0x00000000 */ 30 | #define PARITY_CRC32_PR1_CCITT 7 /* CRC32, initial value 0xFFFFFFFF */ 31 | 32 | #define LMI_DEFAULT 0 /* Default setting */ 33 | #define LMI_NONE 1 /* No LMI, all PVCs are static */ 34 | #define LMI_ANSI 2 /* ANSI Annex D */ 35 | #define LMI_CCITT 3 /* ITU-T Annex A */ 36 | #define LMI_CISCO 4 /* The "original" LMI, aka Gang of Four */ 37 | 38 | #ifndef __ASSEMBLY__ 39 | 40 | typedef struct { 41 | unsigned int clock_rate; /* bits per second */ 42 | unsigned int clock_type; /* internal, external, TX-internal etc. */ 43 | unsigned short loopback; 44 | } sync_serial_settings; /* V.35, V.24, X.21 */ 45 | 46 | typedef struct { 47 | unsigned int clock_rate; /* bits per second */ 48 | unsigned int clock_type; /* internal, external, TX-internal etc. */ 49 | unsigned short loopback; 50 | unsigned int slot_map; 51 | } te1_settings; /* T1, E1 */ 52 | 53 | typedef struct { 54 | unsigned short encoding; 55 | unsigned short parity; 56 | } raw_hdlc_proto; 57 | 58 | typedef struct { 59 | unsigned int t391; 60 | unsigned int t392; 61 | unsigned int n391; 62 | unsigned int n392; 63 | unsigned int n393; 64 | unsigned short lmi; 65 | unsigned short dce; /* 1 for DCE (network side) operation */ 66 | } fr_proto; 67 | 68 | typedef struct { 69 | unsigned int dlci; 70 | } fr_proto_pvc; /* for creating/deleting FR PVCs */ 71 | 72 | typedef struct { 73 | unsigned int dlci; 74 | char master[IFNAMSIZ]; /* Name of master FRAD device */ 75 | }fr_proto_pvc_info; /* for returning PVC information only */ 76 | 77 | typedef struct { 78 | unsigned int interval; 79 | unsigned int timeout; 80 | } cisco_proto; 81 | 82 | /* PPP doesn't need any info now - supply length = 0 to ioctl */ 83 | 84 | #endif /* __ASSEMBLY__ */ 85 | #endif /* __HDLC_IOCTL_H__ */ 86 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/icmpv6.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_ICMPV6_H 3 | #define _LINUX_ICMPV6_H 4 | 5 | #include 6 | #include 7 | 8 | struct icmp6hdr { 9 | 10 | __u8 icmp6_type; 11 | __u8 icmp6_code; 12 | __sum16 icmp6_cksum; 13 | 14 | 15 | union { 16 | __be32 un_data32[1]; 17 | __be16 un_data16[2]; 18 | __u8 un_data8[4]; 19 | 20 | struct icmpv6_echo { 21 | __be16 identifier; 22 | __be16 sequence; 23 | } u_echo; 24 | 25 | struct icmpv6_nd_advt { 26 | #if defined(__LITTLE_ENDIAN_BITFIELD) 27 | __u32 reserved:5, 28 | override:1, 29 | solicited:1, 30 | router:1, 31 | reserved2:24; 32 | #elif defined(__BIG_ENDIAN_BITFIELD) 33 | __u32 router:1, 34 | solicited:1, 35 | override:1, 36 | reserved:29; 37 | #else 38 | #error "Please fix " 39 | #endif 40 | } u_nd_advt; 41 | 42 | struct icmpv6_nd_ra { 43 | __u8 hop_limit; 44 | #if defined(__LITTLE_ENDIAN_BITFIELD) 45 | __u8 reserved:3, 46 | router_pref:2, 47 | home_agent:1, 48 | other:1, 49 | managed:1; 50 | 51 | #elif defined(__BIG_ENDIAN_BITFIELD) 52 | __u8 managed:1, 53 | other:1, 54 | home_agent:1, 55 | router_pref:2, 56 | reserved:3; 57 | #else 58 | #error "Please fix " 59 | #endif 60 | __be16 rt_lifetime; 61 | } u_nd_ra; 62 | 63 | } icmp6_dataun; 64 | 65 | #define icmp6_identifier icmp6_dataun.u_echo.identifier 66 | #define icmp6_sequence icmp6_dataun.u_echo.sequence 67 | #define icmp6_pointer icmp6_dataun.un_data32[0] 68 | #define icmp6_mtu icmp6_dataun.un_data32[0] 69 | #define icmp6_unused icmp6_dataun.un_data32[0] 70 | #define icmp6_maxdelay icmp6_dataun.un_data16[0] 71 | #define icmp6_router icmp6_dataun.u_nd_advt.router 72 | #define icmp6_solicited icmp6_dataun.u_nd_advt.solicited 73 | #define icmp6_override icmp6_dataun.u_nd_advt.override 74 | #define icmp6_ndiscreserved icmp6_dataun.u_nd_advt.reserved 75 | #define icmp6_hop_limit icmp6_dataun.u_nd_ra.hop_limit 76 | #define icmp6_addrconf_managed icmp6_dataun.u_nd_ra.managed 77 | #define icmp6_addrconf_other icmp6_dataun.u_nd_ra.other 78 | #define icmp6_rt_lifetime icmp6_dataun.u_nd_ra.rt_lifetime 79 | #define icmp6_router_pref icmp6_dataun.u_nd_ra.router_pref 80 | }; 81 | 82 | 83 | #define ICMPV6_ROUTER_PREF_LOW 0x3 84 | #define ICMPV6_ROUTER_PREF_MEDIUM 0x0 85 | #define ICMPV6_ROUTER_PREF_HIGH 0x1 86 | #define ICMPV6_ROUTER_PREF_INVALID 0x2 87 | 88 | #define ICMPV6_DEST_UNREACH 1 89 | #define ICMPV6_PKT_TOOBIG 2 90 | #define ICMPV6_TIME_EXCEED 3 91 | #define ICMPV6_PARAMPROB 4 92 | 93 | #define ICMPV6_INFOMSG_MASK 0x80 94 | 95 | #define ICMPV6_ECHO_REQUEST 128 96 | #define ICMPV6_ECHO_REPLY 129 97 | #define ICMPV6_MGM_QUERY 130 98 | #define ICMPV6_MGM_REPORT 131 99 | #define ICMPV6_MGM_REDUCTION 132 100 | 101 | #define ICMPV6_NI_QUERY 139 102 | #define ICMPV6_NI_REPLY 140 103 | 104 | #define ICMPV6_MLD2_REPORT 143 105 | 106 | #define ICMPV6_DHAAD_REQUEST 144 107 | #define ICMPV6_DHAAD_REPLY 145 108 | #define ICMPV6_MOBILE_PREFIX_SOL 146 109 | #define ICMPV6_MOBILE_PREFIX_ADV 147 110 | 111 | /* 112 | * Codes for Destination Unreachable 113 | */ 114 | #define ICMPV6_NOROUTE 0 115 | #define ICMPV6_ADM_PROHIBITED 1 116 | #define ICMPV6_NOT_NEIGHBOUR 2 117 | #define ICMPV6_ADDR_UNREACH 3 118 | #define ICMPV6_PORT_UNREACH 4 119 | #define ICMPV6_POLICY_FAIL 5 120 | #define ICMPV6_REJECT_ROUTE 6 121 | 122 | /* 123 | * Codes for Time Exceeded 124 | */ 125 | #define ICMPV6_EXC_HOPLIMIT 0 126 | #define ICMPV6_EXC_FRAGTIME 1 127 | 128 | /* 129 | * Codes for Parameter Problem 130 | */ 131 | #define ICMPV6_HDR_FIELD 0 132 | #define ICMPV6_UNK_NEXTHDR 1 133 | #define ICMPV6_UNK_OPTION 2 134 | 135 | /* 136 | * constants for (set|get)sockopt 137 | */ 138 | 139 | #define ICMPV6_FILTER 1 140 | 141 | /* 142 | * ICMPV6 filter 143 | */ 144 | 145 | #define ICMPV6_FILTER_BLOCK 1 146 | #define ICMPV6_FILTER_PASS 2 147 | #define ICMPV6_FILTER_BLOCKOTHERS 3 148 | #define ICMPV6_FILTER_PASSONLY 4 149 | 150 | struct icmp6_filter { 151 | __u32 data[8]; 152 | }; 153 | 154 | /* 155 | * Definitions for MLDv2 156 | */ 157 | #define MLD2_MODE_IS_INCLUDE 1 158 | #define MLD2_MODE_IS_EXCLUDE 2 159 | #define MLD2_CHANGE_TO_INCLUDE 3 160 | #define MLD2_CHANGE_TO_EXCLUDE 4 161 | #define MLD2_ALLOW_NEW_SOURCES 5 162 | #define MLD2_BLOCK_OLD_SOURCES 6 163 | 164 | #define MLD2_ALL_MCR_INIT { { { 0xff,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0,0x16 } } } 165 | 166 | 167 | #endif /* _LINUX_ICMPV6_H */ 168 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/if_addr.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __LINUX_IF_ADDR_H 3 | #define __LINUX_IF_ADDR_H 4 | 5 | #include 6 | #include 7 | 8 | struct ifaddrmsg { 9 | __u8 ifa_family; 10 | __u8 ifa_prefixlen; /* The prefix length */ 11 | __u8 ifa_flags; /* Flags */ 12 | __u8 ifa_scope; /* Address scope */ 13 | __u32 ifa_index; /* Link index */ 14 | }; 15 | 16 | /* 17 | * Important comment: 18 | * IFA_ADDRESS is prefix address, rather than local interface address. 19 | * It makes no difference for normally configured broadcast interfaces, 20 | * but for point-to-point IFA_ADDRESS is DESTINATION address, 21 | * local address is supplied in IFA_LOCAL attribute. 22 | * 23 | * IFA_FLAGS is a u32 attribute that extends the u8 field ifa_flags. 24 | * If present, the value from struct ifaddrmsg will be ignored. 25 | */ 26 | enum { 27 | IFA_UNSPEC, 28 | IFA_ADDRESS, 29 | IFA_LOCAL, 30 | IFA_LABEL, 31 | IFA_BROADCAST, 32 | IFA_ANYCAST, 33 | IFA_CACHEINFO, 34 | IFA_MULTICAST, 35 | IFA_FLAGS, 36 | __IFA_MAX, 37 | }; 38 | 39 | #define IFA_MAX (__IFA_MAX - 1) 40 | 41 | /* ifa_flags */ 42 | #define IFA_F_SECONDARY 0x01 43 | #define IFA_F_TEMPORARY IFA_F_SECONDARY 44 | 45 | #define IFA_F_NODAD 0x02 46 | #define IFA_F_OPTIMISTIC 0x04 47 | #define IFA_F_DADFAILED 0x08 48 | #define IFA_F_HOMEADDRESS 0x10 49 | #define IFA_F_DEPRECATED 0x20 50 | #define IFA_F_TENTATIVE 0x40 51 | #define IFA_F_PERMANENT 0x80 52 | #define IFA_F_MANAGETEMPADDR 0x100 53 | #define IFA_F_NOPREFIXROUTE 0x200 54 | #define IFA_F_MCAUTOJOIN 0x400 55 | #define IFA_F_STABLE_PRIVACY 0x800 56 | 57 | struct ifa_cacheinfo { 58 | __u32 ifa_prefered; 59 | __u32 ifa_valid; 60 | __u32 cstamp; /* created timestamp, hundredths of seconds */ 61 | __u32 tstamp; /* updated timestamp, hundredths of seconds */ 62 | }; 63 | 64 | /* backwards compatibility for userspace */ 65 | #define IFA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg)))) 66 | #define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg)) 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/if_addrlabel.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | /* 3 | * if_addrlabel.h - netlink interface for address labels 4 | * 5 | * Copyright (C)2007 USAGI/WIDE Project, All Rights Reserved. 6 | * 7 | * Authors: 8 | * YOSHIFUJI Hideaki @ USAGI/WIDE 9 | */ 10 | 11 | #ifndef __LINUX_IF_ADDRLABEL_H 12 | #define __LINUX_IF_ADDRLABEL_H 13 | 14 | #include 15 | 16 | struct ifaddrlblmsg { 17 | __u8 ifal_family; /* Address family */ 18 | __u8 __ifal_reserved; /* Reserved */ 19 | __u8 ifal_prefixlen; /* Prefix length */ 20 | __u8 ifal_flags; /* Flags */ 21 | __u32 ifal_index; /* Link index */ 22 | __u32 ifal_seq; /* sequence number */ 23 | }; 24 | 25 | enum { 26 | IFAL_ADDRESS = 1, 27 | IFAL_LABEL = 2, 28 | __IFAL_MAX 29 | }; 30 | 31 | #define IFAL_MAX (__IFAL_MAX - 1) 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/if_alg.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2 | /* 3 | * if_alg: User-space algorithm interface 4 | * 5 | * Copyright (c) 2010 Herbert Xu 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the Free 9 | * Software Foundation; either version 2 of the License, or (at your option) 10 | * any later version. 11 | * 12 | */ 13 | 14 | #ifndef _LINUX_IF_ALG_H 15 | #define _LINUX_IF_ALG_H 16 | 17 | #include 18 | 19 | struct sockaddr_alg { 20 | __u16 salg_family; 21 | __u8 salg_type[14]; 22 | __u32 salg_feat; 23 | __u32 salg_mask; 24 | __u8 salg_name[64]; 25 | }; 26 | 27 | struct af_alg_iv { 28 | __u32 ivlen; 29 | __u8 iv[0]; 30 | }; 31 | 32 | /* Socket options */ 33 | #define ALG_SET_KEY 1 34 | #define ALG_SET_IV 2 35 | #define ALG_SET_OP 3 36 | #define ALG_SET_AEAD_ASSOCLEN 4 37 | #define ALG_SET_AEAD_AUTHSIZE 5 38 | 39 | /* Operations */ 40 | #define ALG_OP_DECRYPT 0 41 | #define ALG_OP_ENCRYPT 1 42 | 43 | #endif /* _LINUX_IF_ALG_H */ 44 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/if_tun.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2 | /* 3 | * Universal TUN/TAP device driver. 4 | * Copyright (C) 1999-2000 Maxim Krasnyansky 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | */ 16 | 17 | #ifndef __IF_TUN_H 18 | #define __IF_TUN_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | /* Read queue size */ 25 | #define TUN_READQ_SIZE 500 26 | /* TUN device type flags: deprecated. Use IFF_TUN/IFF_TAP instead. */ 27 | #define TUN_TUN_DEV IFF_TUN 28 | #define TUN_TAP_DEV IFF_TAP 29 | #define TUN_TYPE_MASK 0x000f 30 | 31 | /* Ioctl defines */ 32 | #define TUNSETNOCSUM _IOW('T', 200, int) 33 | #define TUNSETDEBUG _IOW('T', 201, int) 34 | #define TUNSETIFF _IOW('T', 202, int) 35 | #define TUNSETPERSIST _IOW('T', 203, int) 36 | #define TUNSETOWNER _IOW('T', 204, int) 37 | #define TUNSETLINK _IOW('T', 205, int) 38 | #define TUNSETGROUP _IOW('T', 206, int) 39 | #define TUNGETFEATURES _IOR('T', 207, unsigned int) 40 | #define TUNSETOFFLOAD _IOW('T', 208, unsigned int) 41 | #define TUNSETTXFILTER _IOW('T', 209, unsigned int) 42 | #define TUNGETIFF _IOR('T', 210, unsigned int) 43 | #define TUNGETSNDBUF _IOR('T', 211, int) 44 | #define TUNSETSNDBUF _IOW('T', 212, int) 45 | #define TUNATTACHFILTER _IOW('T', 213, struct sock_fprog) 46 | #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog) 47 | #define TUNGETVNETHDRSZ _IOR('T', 215, int) 48 | #define TUNSETVNETHDRSZ _IOW('T', 216, int) 49 | #define TUNSETQUEUE _IOW('T', 217, int) 50 | #define TUNSETIFINDEX _IOW('T', 218, unsigned int) 51 | #define TUNGETFILTER _IOR('T', 219, struct sock_fprog) 52 | #define TUNSETVNETLE _IOW('T', 220, int) 53 | #define TUNGETVNETLE _IOR('T', 221, int) 54 | /* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on 55 | * little-endian hosts. Not all kernel configurations support them, but all 56 | * configurations that support SET also support GET. 57 | */ 58 | #define TUNSETVNETBE _IOW('T', 222, int) 59 | #define TUNGETVNETBE _IOR('T', 223, int) 60 | 61 | /* TUNSETIFF ifr flags */ 62 | #define IFF_TUN 0x0001 63 | #define IFF_TAP 0x0002 64 | #define IFF_NO_PI 0x1000 65 | /* This flag has no real effect */ 66 | #define IFF_ONE_QUEUE 0x2000 67 | #define IFF_VNET_HDR 0x4000 68 | #define IFF_TUN_EXCL 0x8000 69 | #define IFF_MULTI_QUEUE 0x0100 70 | #define IFF_ATTACH_QUEUE 0x0200 71 | #define IFF_DETACH_QUEUE 0x0400 72 | /* read-only flag */ 73 | #define IFF_PERSIST 0x0800 74 | #define IFF_NOFILTER 0x1000 75 | 76 | /* Socket options */ 77 | #define TUN_TX_TIMESTAMP 1 78 | 79 | /* Features for GSO (TUNSETOFFLOAD). */ 80 | #define TUN_F_CSUM 0x01 /* You can hand me unchecksummed packets. */ 81 | #define TUN_F_TSO4 0x02 /* I can handle TSO for IPv4 packets */ 82 | #define TUN_F_TSO6 0x04 /* I can handle TSO for IPv6 packets */ 83 | #define TUN_F_TSO_ECN 0x08 /* I can handle TSO with ECN bits. */ 84 | #define TUN_F_UFO 0x10 /* I can handle UFO packets */ 85 | 86 | /* Protocol info prepended to the packets (when IFF_NO_PI is not set) */ 87 | #define TUN_PKT_STRIP 0x0001 88 | struct tun_pi { 89 | __u16 flags; 90 | __be16 proto; 91 | }; 92 | 93 | /* 94 | * Filter spec (used for SETXXFILTER ioctls) 95 | * This stuff is applicable only to the TAP (Ethernet) devices. 96 | * If the count is zero the filter is disabled and the driver accepts 97 | * all packets (promisc mode). 98 | * If the filter is enabled in order to accept broadcast packets 99 | * broadcast addr must be explicitly included in the addr list. 100 | */ 101 | #define TUN_FLT_ALLMULTI 0x0001 /* Accept all multicast packets */ 102 | struct tun_filter { 103 | __u16 flags; /* TUN_FLT_ flags see above */ 104 | __u16 count; /* Number of addresses */ 105 | __u8 addr[0][ETH_ALEN]; 106 | }; 107 | 108 | #endif /* __IF_TUN_H */ 109 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/if_tunnel.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _IF_TUNNEL_H_ 3 | #define _IF_TUNNEL_H_ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | #define SIOCGETTUNNEL (SIOCDEVPRIVATE + 0) 13 | #define SIOCADDTUNNEL (SIOCDEVPRIVATE + 1) 14 | #define SIOCDELTUNNEL (SIOCDEVPRIVATE + 2) 15 | #define SIOCCHGTUNNEL (SIOCDEVPRIVATE + 3) 16 | #define SIOCGETPRL (SIOCDEVPRIVATE + 4) 17 | #define SIOCADDPRL (SIOCDEVPRIVATE + 5) 18 | #define SIOCDELPRL (SIOCDEVPRIVATE + 6) 19 | #define SIOCCHGPRL (SIOCDEVPRIVATE + 7) 20 | #define SIOCGET6RD (SIOCDEVPRIVATE + 8) 21 | #define SIOCADD6RD (SIOCDEVPRIVATE + 9) 22 | #define SIOCDEL6RD (SIOCDEVPRIVATE + 10) 23 | #define SIOCCHG6RD (SIOCDEVPRIVATE + 11) 24 | 25 | #define GRE_CSUM __cpu_to_be16(0x8000) 26 | #define GRE_ROUTING __cpu_to_be16(0x4000) 27 | #define GRE_KEY __cpu_to_be16(0x2000) 28 | #define GRE_SEQ __cpu_to_be16(0x1000) 29 | #define GRE_STRICT __cpu_to_be16(0x0800) 30 | #define GRE_REC __cpu_to_be16(0x0700) 31 | #define GRE_ACK __cpu_to_be16(0x0080) 32 | #define GRE_FLAGS __cpu_to_be16(0x0078) 33 | #define GRE_VERSION __cpu_to_be16(0x0007) 34 | 35 | #define GRE_IS_CSUM(f) ((f) & GRE_CSUM) 36 | #define GRE_IS_ROUTING(f) ((f) & GRE_ROUTING) 37 | #define GRE_IS_KEY(f) ((f) & GRE_KEY) 38 | #define GRE_IS_SEQ(f) ((f) & GRE_SEQ) 39 | #define GRE_IS_STRICT(f) ((f) & GRE_STRICT) 40 | #define GRE_IS_REC(f) ((f) & GRE_REC) 41 | #define GRE_IS_ACK(f) ((f) & GRE_ACK) 42 | 43 | #define GRE_VERSION_0 __cpu_to_be16(0x0000) 44 | #define GRE_VERSION_1 __cpu_to_be16(0x0001) 45 | #define GRE_PROTO_PPP __cpu_to_be16(0x880b) 46 | #define GRE_PPTP_KEY_MASK __cpu_to_be32(0xffff) 47 | 48 | struct ip_tunnel_parm { 49 | char name[IFNAMSIZ]; 50 | int link; 51 | __be16 i_flags; 52 | __be16 o_flags; 53 | __be32 i_key; 54 | __be32 o_key; 55 | struct iphdr iph; 56 | }; 57 | 58 | enum { 59 | IFLA_IPTUN_UNSPEC, 60 | IFLA_IPTUN_LINK, 61 | IFLA_IPTUN_LOCAL, 62 | IFLA_IPTUN_REMOTE, 63 | IFLA_IPTUN_TTL, 64 | IFLA_IPTUN_TOS, 65 | IFLA_IPTUN_ENCAP_LIMIT, 66 | IFLA_IPTUN_FLOWINFO, 67 | IFLA_IPTUN_FLAGS, 68 | IFLA_IPTUN_PROTO, 69 | IFLA_IPTUN_PMTUDISC, 70 | IFLA_IPTUN_6RD_PREFIX, 71 | IFLA_IPTUN_6RD_RELAY_PREFIX, 72 | IFLA_IPTUN_6RD_PREFIXLEN, 73 | IFLA_IPTUN_6RD_RELAY_PREFIXLEN, 74 | IFLA_IPTUN_ENCAP_TYPE, 75 | IFLA_IPTUN_ENCAP_FLAGS, 76 | IFLA_IPTUN_ENCAP_SPORT, 77 | IFLA_IPTUN_ENCAP_DPORT, 78 | IFLA_IPTUN_COLLECT_METADATA, 79 | IFLA_IPTUN_FWMARK, 80 | __IFLA_IPTUN_MAX, 81 | }; 82 | #define IFLA_IPTUN_MAX (__IFLA_IPTUN_MAX - 1) 83 | 84 | enum tunnel_encap_types { 85 | TUNNEL_ENCAP_NONE, 86 | TUNNEL_ENCAP_FOU, 87 | TUNNEL_ENCAP_GUE, 88 | }; 89 | 90 | #define TUNNEL_ENCAP_FLAG_CSUM (1<<0) 91 | #define TUNNEL_ENCAP_FLAG_CSUM6 (1<<1) 92 | #define TUNNEL_ENCAP_FLAG_REMCSUM (1<<2) 93 | 94 | /* SIT-mode i_flags */ 95 | #define SIT_ISATAP 0x0001 96 | 97 | struct ip_tunnel_prl { 98 | __be32 addr; 99 | __u16 flags; 100 | __u16 __reserved; 101 | __u32 datalen; 102 | __u32 __reserved2; 103 | /* data follows */ 104 | }; 105 | 106 | /* PRL flags */ 107 | #define PRL_DEFAULT 0x0001 108 | 109 | struct ip_tunnel_6rd { 110 | struct in6_addr prefix; 111 | __be32 relay_prefix; 112 | __u16 prefixlen; 113 | __u16 relay_prefixlen; 114 | }; 115 | 116 | enum { 117 | IFLA_GRE_UNSPEC, 118 | IFLA_GRE_LINK, 119 | IFLA_GRE_IFLAGS, 120 | IFLA_GRE_OFLAGS, 121 | IFLA_GRE_IKEY, 122 | IFLA_GRE_OKEY, 123 | IFLA_GRE_LOCAL, 124 | IFLA_GRE_REMOTE, 125 | IFLA_GRE_TTL, 126 | IFLA_GRE_TOS, 127 | IFLA_GRE_PMTUDISC, 128 | IFLA_GRE_ENCAP_LIMIT, 129 | IFLA_GRE_FLOWINFO, 130 | IFLA_GRE_FLAGS, 131 | IFLA_GRE_ENCAP_TYPE, 132 | IFLA_GRE_ENCAP_FLAGS, 133 | IFLA_GRE_ENCAP_SPORT, 134 | IFLA_GRE_ENCAP_DPORT, 135 | IFLA_GRE_COLLECT_METADATA, 136 | IFLA_GRE_IGNORE_DF, 137 | IFLA_GRE_FWMARK, 138 | IFLA_GRE_ERSPAN_INDEX, 139 | __IFLA_GRE_MAX, 140 | }; 141 | 142 | #define IFLA_GRE_MAX (__IFLA_GRE_MAX - 1) 143 | 144 | /* VTI-mode i_flags */ 145 | #define VTI_ISVTI ((__be16)0x0001) 146 | 147 | enum { 148 | IFLA_VTI_UNSPEC, 149 | IFLA_VTI_LINK, 150 | IFLA_VTI_IKEY, 151 | IFLA_VTI_OKEY, 152 | IFLA_VTI_LOCAL, 153 | IFLA_VTI_REMOTE, 154 | IFLA_VTI_FWMARK, 155 | __IFLA_VTI_MAX, 156 | }; 157 | 158 | #define IFLA_VTI_MAX (__IFLA_VTI_MAX - 1) 159 | #endif /* _IF_TUNNEL_H_ */ 160 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/if_vlan.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2 | /* 3 | * VLAN An implementation of 802.1Q VLAN tagging. 4 | * 5 | * Authors: Ben Greear 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 10 | * 2 of the License, or (at your option) any later version. 11 | * 12 | */ 13 | 14 | #ifndef _LINUX_IF_VLAN_H_ 15 | #define _LINUX_IF_VLAN_H_ 16 | 17 | 18 | /* VLAN IOCTLs are found in sockios.h */ 19 | 20 | /* Passed in vlan_ioctl_args structure to determine behaviour. */ 21 | enum vlan_ioctl_cmds { 22 | ADD_VLAN_CMD, 23 | DEL_VLAN_CMD, 24 | SET_VLAN_INGRESS_PRIORITY_CMD, 25 | SET_VLAN_EGRESS_PRIORITY_CMD, 26 | GET_VLAN_INGRESS_PRIORITY_CMD, 27 | GET_VLAN_EGRESS_PRIORITY_CMD, 28 | SET_VLAN_NAME_TYPE_CMD, 29 | SET_VLAN_FLAG_CMD, 30 | GET_VLAN_REALDEV_NAME_CMD, /* If this works, you know it's a VLAN device, btw */ 31 | GET_VLAN_VID_CMD /* Get the VID of this VLAN (specified by name) */ 32 | }; 33 | 34 | enum vlan_flags { 35 | VLAN_FLAG_REORDER_HDR = 0x1, 36 | VLAN_FLAG_GVRP = 0x2, 37 | VLAN_FLAG_LOOSE_BINDING = 0x4, 38 | VLAN_FLAG_MVRP = 0x8, 39 | }; 40 | 41 | enum vlan_name_types { 42 | VLAN_NAME_TYPE_PLUS_VID, /* Name will look like: vlan0005 */ 43 | VLAN_NAME_TYPE_RAW_PLUS_VID, /* name will look like: eth1.0005 */ 44 | VLAN_NAME_TYPE_PLUS_VID_NO_PAD, /* Name will look like: vlan5 */ 45 | VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD, /* Name will look like: eth0.5 */ 46 | VLAN_NAME_TYPE_HIGHEST 47 | }; 48 | 49 | struct vlan_ioctl_args { 50 | int cmd; /* Should be one of the vlan_ioctl_cmds enum above. */ 51 | char device1[24]; 52 | 53 | union { 54 | char device2[24]; 55 | int VID; 56 | unsigned int skb_priority; 57 | unsigned int name_type; 58 | unsigned int bind_type; 59 | unsigned int flag; /* Matches vlan_dev_priv flags */ 60 | } u; 61 | 62 | short vlan_qos; 63 | }; 64 | 65 | #endif /* _LINUX_IF_VLAN_H_ */ 66 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/ife.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __UAPI_IFE_H 3 | #define __UAPI_IFE_H 4 | 5 | #define IFE_METAHDRLEN 2 6 | 7 | enum { 8 | IFE_META_SKBMARK = 1, 9 | IFE_META_HASHID, 10 | IFE_META_PRIO, 11 | IFE_META_QMAP, 12 | IFE_META_TCINDEX, 13 | __IFE_META_MAX 14 | }; 15 | 16 | /*Can be overridden at runtime by module option*/ 17 | #define IFE_META_MAX (__IFE_META_MAX - 1) 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/ila.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | /* ila.h - ILA Interface */ 3 | 4 | #ifndef _LINUX_ILA_H 5 | #define _LINUX_ILA_H 6 | 7 | /* NETLINK_GENERIC related info */ 8 | #define ILA_GENL_NAME "ila" 9 | #define ILA_GENL_VERSION 0x1 10 | 11 | enum { 12 | ILA_ATTR_UNSPEC, 13 | ILA_ATTR_LOCATOR, /* u64 */ 14 | ILA_ATTR_IDENTIFIER, /* u64 */ 15 | ILA_ATTR_LOCATOR_MATCH, /* u64 */ 16 | ILA_ATTR_IFINDEX, /* s32 */ 17 | ILA_ATTR_DIR, /* u32 */ 18 | ILA_ATTR_PAD, 19 | ILA_ATTR_CSUM_MODE, /* u8 */ 20 | 21 | __ILA_ATTR_MAX, 22 | }; 23 | 24 | #define ILA_ATTR_MAX (__ILA_ATTR_MAX - 1) 25 | 26 | enum { 27 | ILA_CMD_UNSPEC, 28 | ILA_CMD_ADD, 29 | ILA_CMD_DEL, 30 | ILA_CMD_GET, 31 | 32 | __ILA_CMD_MAX, 33 | }; 34 | 35 | #define ILA_CMD_MAX (__ILA_CMD_MAX - 1) 36 | 37 | #define ILA_DIR_IN (1 << 0) 38 | #define ILA_DIR_OUT (1 << 1) 39 | 40 | enum { 41 | ILA_CSUM_ADJUST_TRANSPORT, 42 | ILA_CSUM_NEUTRAL_MAP, 43 | ILA_CSUM_NO_ACTION, 44 | }; 45 | 46 | #endif /* _LINUX_ILA_H */ 47 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/in_route.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_IN_ROUTE_H 3 | #define _LINUX_IN_ROUTE_H 4 | 5 | /* IPv4 routing cache flags */ 6 | 7 | #define RTCF_DEAD RTNH_F_DEAD 8 | #define RTCF_ONLINK RTNH_F_ONLINK 9 | 10 | /* Obsolete flag. About to be deleted */ 11 | #define RTCF_NOPMTUDISC RTM_F_NOPMTUDISC 12 | 13 | #define RTCF_NOTIFY 0x00010000 14 | #define RTCF_DIRECTDST 0x00020000 /* unused */ 15 | #define RTCF_REDIRECTED 0x00040000 16 | #define RTCF_TPROXY 0x00080000 /* unused */ 17 | 18 | #define RTCF_FAST 0x00200000 /* unused */ 19 | #define RTCF_MASQ 0x00400000 /* unused */ 20 | #define RTCF_SNAT 0x00800000 /* unused */ 21 | #define RTCF_DOREDIRECT 0x01000000 22 | #define RTCF_DIRECTSRC 0x04000000 23 | #define RTCF_DNAT 0x08000000 24 | #define RTCF_BROADCAST 0x10000000 25 | #define RTCF_MULTICAST 0x20000000 26 | #define RTCF_REJECT 0x40000000 /* unused */ 27 | #define RTCF_LOCAL 0x80000000 28 | 29 | #define RTCF_NAT (RTCF_DNAT|RTCF_SNAT) 30 | 31 | #define RT_TOS(tos) ((tos)&IPTOS_TOS_MASK) 32 | 33 | #endif /* _LINUX_IN_ROUTE_H */ 34 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/ip6_tunnel.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _IP6_TUNNEL_H 3 | #define _IP6_TUNNEL_H 4 | 5 | #include 6 | #include /* For IFNAMSIZ. */ 7 | #include /* For struct in6_addr. */ 8 | 9 | #define IPV6_TLV_TNL_ENCAP_LIMIT 4 10 | #define IPV6_DEFAULT_TNL_ENCAP_LIMIT 4 11 | 12 | /* don't add encapsulation limit if one isn't present in inner packet */ 13 | #define IP6_TNL_F_IGN_ENCAP_LIMIT 0x1 14 | /* copy the traffic class field from the inner packet */ 15 | #define IP6_TNL_F_USE_ORIG_TCLASS 0x2 16 | /* copy the flowlabel from the inner packet */ 17 | #define IP6_TNL_F_USE_ORIG_FLOWLABEL 0x4 18 | /* being used for Mobile IPv6 */ 19 | #define IP6_TNL_F_MIP6_DEV 0x8 20 | /* copy DSCP from the outer packet */ 21 | #define IP6_TNL_F_RCV_DSCP_COPY 0x10 22 | /* copy fwmark from inner packet */ 23 | #define IP6_TNL_F_USE_ORIG_FWMARK 0x20 24 | 25 | struct ip6_tnl_parm { 26 | char name[IFNAMSIZ]; /* name of tunnel device */ 27 | int link; /* ifindex of underlying L2 interface */ 28 | __u8 proto; /* tunnel protocol */ 29 | __u8 encap_limit; /* encapsulation limit for tunnel */ 30 | __u8 hop_limit; /* hop limit for tunnel */ 31 | __be32 flowinfo; /* traffic class and flowlabel for tunnel */ 32 | __u32 flags; /* tunnel flags */ 33 | struct in6_addr laddr; /* local tunnel end-point address */ 34 | struct in6_addr raddr; /* remote tunnel end-point address */ 35 | }; 36 | 37 | struct ip6_tnl_parm2 { 38 | char name[IFNAMSIZ]; /* name of tunnel device */ 39 | int link; /* ifindex of underlying L2 interface */ 40 | __u8 proto; /* tunnel protocol */ 41 | __u8 encap_limit; /* encapsulation limit for tunnel */ 42 | __u8 hop_limit; /* hop limit for tunnel */ 43 | __be32 flowinfo; /* traffic class and flowlabel for tunnel */ 44 | __u32 flags; /* tunnel flags */ 45 | struct in6_addr laddr; /* local tunnel end-point address */ 46 | struct in6_addr raddr; /* remote tunnel end-point address */ 47 | 48 | __be16 i_flags; 49 | __be16 o_flags; 50 | __be32 i_key; 51 | __be32 o_key; 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/ipsec.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_IPSEC_H 3 | #define _LINUX_IPSEC_H 4 | 5 | /* The definitions, required to talk to KAME racoon IKE. */ 6 | 7 | #include 8 | 9 | #define IPSEC_PORT_ANY 0 10 | #define IPSEC_ULPROTO_ANY 255 11 | #define IPSEC_PROTO_ANY 255 12 | 13 | enum { 14 | IPSEC_MODE_ANY = 0, /* We do not support this for SA */ 15 | IPSEC_MODE_TRANSPORT = 1, 16 | IPSEC_MODE_TUNNEL = 2, 17 | IPSEC_MODE_BEET = 3 18 | }; 19 | 20 | enum { 21 | IPSEC_DIR_ANY = 0, 22 | IPSEC_DIR_INBOUND = 1, 23 | IPSEC_DIR_OUTBOUND = 2, 24 | IPSEC_DIR_FWD = 3, /* It is our own */ 25 | IPSEC_DIR_MAX = 4, 26 | IPSEC_DIR_INVALID = 5 27 | }; 28 | 29 | enum { 30 | IPSEC_POLICY_DISCARD = 0, 31 | IPSEC_POLICY_NONE = 1, 32 | IPSEC_POLICY_IPSEC = 2, 33 | IPSEC_POLICY_ENTRUST = 3, 34 | IPSEC_POLICY_BYPASS = 4 35 | }; 36 | 37 | enum { 38 | IPSEC_LEVEL_DEFAULT = 0, 39 | IPSEC_LEVEL_USE = 1, 40 | IPSEC_LEVEL_REQUIRE = 2, 41 | IPSEC_LEVEL_UNIQUE = 3 42 | }; 43 | 44 | #define IPSEC_MANUAL_REQID_MAX 0x3fff 45 | 46 | #define IPSEC_REPLAYWSIZE 32 47 | 48 | #endif /* _LINUX_IPSEC_H */ 49 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/kernel.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_KERNEL_H 3 | #define _LINUX_KERNEL_H 4 | 5 | #include 6 | 7 | /* 8 | * 'kernel.h' contains some often-used function prototypes etc 9 | */ 10 | #define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) 11 | #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask)) 12 | 13 | #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) 14 | 15 | #endif /* _LINUX_KERNEL_H */ 16 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/limits.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_LIMITS_H 3 | #define _LINUX_LIMITS_H 4 | 5 | #define NR_OPEN 1024 6 | 7 | #define NGROUPS_MAX 65536 /* supplemental group IDs are available */ 8 | #define ARG_MAX 131072 /* # bytes of args + environ for exec() */ 9 | #define LINK_MAX 127 /* # links a file may have */ 10 | #define MAX_CANON 255 /* size of the canonical input queue */ 11 | #define MAX_INPUT 255 /* size of the type-ahead buffer */ 12 | #define NAME_MAX 255 /* # chars in a file name */ 13 | #define PATH_MAX 4096 /* # chars in a path name including nul */ 14 | #define PIPE_BUF 4096 /* # bytes in atomic write to a pipe */ 15 | #define XATTR_NAME_MAX 255 /* # chars in an extended attribute name */ 16 | #define XATTR_SIZE_MAX 65536 /* size of an extended attribute value (64k) */ 17 | #define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */ 18 | 19 | #define RTSIG_MAX 32 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/lwtunnel.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LWTUNNEL_H_ 3 | #define _LWTUNNEL_H_ 4 | 5 | #include 6 | 7 | enum lwtunnel_encap_types { 8 | LWTUNNEL_ENCAP_NONE, 9 | LWTUNNEL_ENCAP_MPLS, 10 | LWTUNNEL_ENCAP_IP, 11 | LWTUNNEL_ENCAP_ILA, 12 | LWTUNNEL_ENCAP_IP6, 13 | LWTUNNEL_ENCAP_SEG6, 14 | LWTUNNEL_ENCAP_BPF, 15 | LWTUNNEL_ENCAP_SEG6_LOCAL, 16 | __LWTUNNEL_ENCAP_MAX, 17 | }; 18 | 19 | #define LWTUNNEL_ENCAP_MAX (__LWTUNNEL_ENCAP_MAX - 1) 20 | 21 | enum lwtunnel_ip_t { 22 | LWTUNNEL_IP_UNSPEC, 23 | LWTUNNEL_IP_ID, 24 | LWTUNNEL_IP_DST, 25 | LWTUNNEL_IP_SRC, 26 | LWTUNNEL_IP_TTL, 27 | LWTUNNEL_IP_TOS, 28 | LWTUNNEL_IP_FLAGS, 29 | LWTUNNEL_IP_PAD, 30 | __LWTUNNEL_IP_MAX, 31 | }; 32 | 33 | #define LWTUNNEL_IP_MAX (__LWTUNNEL_IP_MAX - 1) 34 | 35 | enum lwtunnel_ip6_t { 36 | LWTUNNEL_IP6_UNSPEC, 37 | LWTUNNEL_IP6_ID, 38 | LWTUNNEL_IP6_DST, 39 | LWTUNNEL_IP6_SRC, 40 | LWTUNNEL_IP6_HOPLIMIT, 41 | LWTUNNEL_IP6_TC, 42 | LWTUNNEL_IP6_FLAGS, 43 | LWTUNNEL_IP6_PAD, 44 | __LWTUNNEL_IP6_MAX, 45 | }; 46 | 47 | #define LWTUNNEL_IP6_MAX (__LWTUNNEL_IP6_MAX - 1) 48 | 49 | enum { 50 | LWT_BPF_PROG_UNSPEC, 51 | LWT_BPF_PROG_FD, 52 | LWT_BPF_PROG_NAME, 53 | __LWT_BPF_PROG_MAX, 54 | }; 55 | 56 | #define LWT_BPF_PROG_MAX (__LWT_BPF_PROG_MAX - 1) 57 | 58 | enum { 59 | LWT_BPF_UNSPEC, 60 | LWT_BPF_IN, 61 | LWT_BPF_OUT, 62 | LWT_BPF_XMIT, 63 | LWT_BPF_XMIT_HEADROOM, 64 | __LWT_BPF_MAX, 65 | }; 66 | 67 | #define LWT_BPF_MAX (__LWT_BPF_MAX - 1) 68 | 69 | #define LWT_BPF_MAX_HEADROOM 256 70 | 71 | #endif /* _LWTUNNEL_H_ */ 72 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/magic.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __LINUX_MAGIC_H__ 3 | #define __LINUX_MAGIC_H__ 4 | 5 | #define ADFS_SUPER_MAGIC 0xadf5 6 | #define AFFS_SUPER_MAGIC 0xadff 7 | #define AFS_SUPER_MAGIC 0x5346414F 8 | #define AUTOFS_SUPER_MAGIC 0x0187 9 | #define CODA_SUPER_MAGIC 0x73757245 10 | #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */ 11 | #define CRAMFS_MAGIC_WEND 0x453dcd28 /* magic number with the wrong endianess */ 12 | #define DEBUGFS_MAGIC 0x64626720 13 | #define SECURITYFS_MAGIC 0x73636673 14 | #define SELINUX_MAGIC 0xf97cff8c 15 | #define SMACK_MAGIC 0x43415d53 /* "SMAC" */ 16 | #define RAMFS_MAGIC 0x858458f6 /* some random number */ 17 | #define TMPFS_MAGIC 0x01021994 18 | #define HUGETLBFS_MAGIC 0x958458f6 /* some random number */ 19 | #define SQUASHFS_MAGIC 0x73717368 20 | #define ECRYPTFS_SUPER_MAGIC 0xf15f 21 | #define EFS_SUPER_MAGIC 0x414A53 22 | #define EXT2_SUPER_MAGIC 0xEF53 23 | #define EXT3_SUPER_MAGIC 0xEF53 24 | #define XENFS_SUPER_MAGIC 0xabba1974 25 | #define EXT4_SUPER_MAGIC 0xEF53 26 | #define BTRFS_SUPER_MAGIC 0x9123683E 27 | #define NILFS_SUPER_MAGIC 0x3434 28 | #define F2FS_SUPER_MAGIC 0xF2F52010 29 | #define HPFS_SUPER_MAGIC 0xf995e849 30 | #define ISOFS_SUPER_MAGIC 0x9660 31 | #define JFFS2_SUPER_MAGIC 0x72b6 32 | #define PSTOREFS_MAGIC 0x6165676C 33 | #define EFIVARFS_MAGIC 0xde5e81e4 34 | #define HOSTFS_SUPER_MAGIC 0x00c0ffee 35 | #define OVERLAYFS_SUPER_MAGIC 0x794c7630 36 | 37 | #define MINIX_SUPER_MAGIC 0x137F /* minix v1 fs, 14 char names */ 38 | #define MINIX_SUPER_MAGIC2 0x138F /* minix v1 fs, 30 char names */ 39 | #define MINIX2_SUPER_MAGIC 0x2468 /* minix v2 fs, 14 char names */ 40 | #define MINIX2_SUPER_MAGIC2 0x2478 /* minix v2 fs, 30 char names */ 41 | #define MINIX3_SUPER_MAGIC 0x4d5a /* minix v3 fs, 60 char names */ 42 | 43 | #define MSDOS_SUPER_MAGIC 0x4d44 /* MD */ 44 | #define NCP_SUPER_MAGIC 0x564c /* Guess, what 0x564c is :-) */ 45 | #define NFS_SUPER_MAGIC 0x6969 46 | #define OCFS2_SUPER_MAGIC 0x7461636f 47 | #define OPENPROM_SUPER_MAGIC 0x9fa1 48 | #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */ 49 | #define QNX6_SUPER_MAGIC 0x68191122 /* qnx6 fs detection */ 50 | 51 | #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */ 52 | /* used by file system utilities that 53 | look at the superblock, etc. */ 54 | #define REISERFS_SUPER_MAGIC_STRING "ReIsErFs" 55 | #define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs" 56 | #define REISER2FS_JR_SUPER_MAGIC_STRING "ReIsEr3Fs" 57 | 58 | #define SMB_SUPER_MAGIC 0x517B 59 | #define CGROUP_SUPER_MAGIC 0x27e0eb 60 | #define CGROUP2_SUPER_MAGIC 0x63677270 61 | 62 | #define RDTGROUP_SUPER_MAGIC 0x7655821 63 | 64 | #define STACK_END_MAGIC 0x57AC6E9D 65 | 66 | #define TRACEFS_MAGIC 0x74726163 67 | 68 | #define V9FS_MAGIC 0x01021997 69 | 70 | #define BDEVFS_MAGIC 0x62646576 71 | #define DAXFS_MAGIC 0x64646178 72 | #define BINFMTFS_MAGIC 0x42494e4d 73 | #define DEVPTS_SUPER_MAGIC 0x1cd1 74 | #define FUTEXFS_SUPER_MAGIC 0xBAD1DEA 75 | #define PIPEFS_MAGIC 0x50495045 76 | #define PROC_SUPER_MAGIC 0x9fa0 77 | #define SOCKFS_MAGIC 0x534F434B 78 | #define SYSFS_MAGIC 0x62656572 79 | #define USBDEVICE_SUPER_MAGIC 0x9fa2 80 | #define MTD_INODE_FS_MAGIC 0x11307854 81 | #define ANON_INODE_FS_MAGIC 0x09041934 82 | #define BTRFS_TEST_MAGIC 0x73727279 83 | #define NSFS_MAGIC 0x6e736673 84 | #define BPF_FS_MAGIC 0xcafe4a11 85 | #define AAFS_MAGIC 0x5a3c69f0 86 | 87 | /* Since UDF 2.01 is ISO 13346 based... */ 88 | #define UDF_SUPER_MAGIC 0x15013346 89 | #define BALLOON_KVM_MAGIC 0x13661366 90 | #define ZSMALLOC_MAGIC 0x58295829 91 | 92 | #endif /* __LINUX_MAGIC_H__ */ 93 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/mpls.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _MPLS_H 3 | #define _MPLS_H 4 | 5 | #include 6 | #include 7 | 8 | /* Reference: RFC 5462, RFC 3032 9 | * 10 | * 0 1 2 3 11 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 12 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 13 | * | Label | TC |S| TTL | 14 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 15 | * 16 | * Label: Label Value, 20 bits 17 | * TC: Traffic Class field, 3 bits 18 | * S: Bottom of Stack, 1 bit 19 | * TTL: Time to Live, 8 bits 20 | */ 21 | 22 | struct mpls_label { 23 | __be32 entry; 24 | }; 25 | 26 | #define MPLS_LS_LABEL_MASK 0xFFFFF000 27 | #define MPLS_LS_LABEL_SHIFT 12 28 | #define MPLS_LS_TC_MASK 0x00000E00 29 | #define MPLS_LS_TC_SHIFT 9 30 | #define MPLS_LS_S_MASK 0x00000100 31 | #define MPLS_LS_S_SHIFT 8 32 | #define MPLS_LS_TTL_MASK 0x000000FF 33 | #define MPLS_LS_TTL_SHIFT 0 34 | 35 | /* Reserved labels */ 36 | #define MPLS_LABEL_IPV4NULL 0 /* RFC3032 */ 37 | #define MPLS_LABEL_RTALERT 1 /* RFC3032 */ 38 | #define MPLS_LABEL_IPV6NULL 2 /* RFC3032 */ 39 | #define MPLS_LABEL_IMPLNULL 3 /* RFC3032 */ 40 | #define MPLS_LABEL_ENTROPY 7 /* RFC6790 */ 41 | #define MPLS_LABEL_GAL 13 /* RFC5586 */ 42 | #define MPLS_LABEL_OAMALERT 14 /* RFC3429 */ 43 | #define MPLS_LABEL_EXTENSION 15 /* RFC7274 */ 44 | 45 | #define MPLS_LABEL_FIRST_UNRESERVED 16 /* RFC3032 */ 46 | 47 | /* These are embedded into IFLA_STATS_AF_SPEC: 48 | * [IFLA_STATS_AF_SPEC] 49 | * -> [AF_MPLS] 50 | * -> [MPLS_STATS_xxx] 51 | * 52 | * Attributes: 53 | * [MPLS_STATS_LINK] = { 54 | * struct mpls_link_stats 55 | * } 56 | */ 57 | enum { 58 | MPLS_STATS_UNSPEC, /* also used as 64bit pad attribute */ 59 | MPLS_STATS_LINK, 60 | __MPLS_STATS_MAX, 61 | }; 62 | 63 | #define MPLS_STATS_MAX (__MPLS_STATS_MAX - 1) 64 | 65 | struct mpls_link_stats { 66 | __u64 rx_packets; /* total packets received */ 67 | __u64 tx_packets; /* total packets transmitted */ 68 | __u64 rx_bytes; /* total bytes received */ 69 | __u64 tx_bytes; /* total bytes transmitted */ 70 | __u64 rx_errors; /* bad packets received */ 71 | __u64 tx_errors; /* packet transmit problems */ 72 | __u64 rx_dropped; /* packet dropped on receive */ 73 | __u64 tx_dropped; /* packet dropped on transmit */ 74 | __u64 rx_noroute; /* no route for packet dest */ 75 | }; 76 | 77 | #endif /* _MPLS_H */ 78 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/mpls_iptunnel.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2 | /* 3 | * mpls tunnel api 4 | * 5 | * Authors: 6 | * Roopa Prabhu 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation; either version 11 | * 2 of the License, or (at your option) any later version. 12 | */ 13 | 14 | #ifndef _LINUX_MPLS_IPTUNNEL_H 15 | #define _LINUX_MPLS_IPTUNNEL_H 16 | 17 | /* MPLS tunnel attributes 18 | * [RTA_ENCAP] = { 19 | * [MPLS_IPTUNNEL_DST] 20 | * [MPLS_IPTUNNEL_TTL] 21 | * } 22 | */ 23 | enum { 24 | MPLS_IPTUNNEL_UNSPEC, 25 | MPLS_IPTUNNEL_DST, 26 | MPLS_IPTUNNEL_TTL, 27 | __MPLS_IPTUNNEL_MAX, 28 | }; 29 | #define MPLS_IPTUNNEL_MAX (__MPLS_IPTUNNEL_MAX - 1) 30 | 31 | #endif /* _LINUX_MPLS_IPTUNNEL_H */ 32 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/net_namespace.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | /* Copyright (c) 2015 6WIND S.A. 3 | * Author: Nicolas Dichtel 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | */ 9 | #ifndef _LINUX_NET_NAMESPACE_H_ 10 | #define _LINUX_NET_NAMESPACE_H_ 11 | 12 | /* Attributes of RTM_NEWNSID/RTM_GETNSID messages */ 13 | enum { 14 | NETNSA_NONE, 15 | #define NETNSA_NSID_NOT_ASSIGNED -1 16 | NETNSA_NSID, 17 | NETNSA_PID, 18 | NETNSA_FD, 19 | __NETNSA_MAX, 20 | }; 21 | 22 | #define NETNSA_MAX (__NETNSA_MAX - 1) 23 | 24 | #endif /* _LINUX_NET_NAMESPACE_H_ */ 25 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/netconf.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_NETCONF_H_ 3 | #define _LINUX_NETCONF_H_ 4 | 5 | #include 6 | #include 7 | 8 | struct netconfmsg { 9 | __u8 ncm_family; 10 | }; 11 | 12 | enum { 13 | NETCONFA_UNSPEC, 14 | NETCONFA_IFINDEX, 15 | NETCONFA_FORWARDING, 16 | NETCONFA_RP_FILTER, 17 | NETCONFA_MC_FORWARDING, 18 | NETCONFA_PROXY_NEIGH, 19 | NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN, 20 | NETCONFA_INPUT, 21 | __NETCONFA_MAX 22 | }; 23 | #define NETCONFA_MAX (__NETCONFA_MAX - 1) 24 | #define NETCONFA_ALL -1 25 | 26 | #define NETCONFA_IFINDEX_ALL -1 27 | #define NETCONFA_IFINDEX_DEFAULT -2 28 | 29 | #endif /* _LINUX_NETCONF_H_ */ 30 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/netdevice.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2 | /* 3 | * INET An implementation of the TCP/IP protocol suite for the LINUX 4 | * operating system. INET is implemented using the BSD Socket 5 | * interface as the means of communication with the user level. 6 | * 7 | * Definitions for the Interfaces handler. 8 | * 9 | * Version: @(#)dev.h 1.0.10 08/12/93 10 | * 11 | * Authors: Ross Biro 12 | * Fred N. van Kempen, 13 | * Corey Minyard 14 | * Donald J. Becker, 15 | * Alan Cox, 16 | * Bjorn Ekwall. 17 | * Pekka Riikonen 18 | * 19 | * This program is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU General Public License 21 | * as published by the Free Software Foundation; either version 22 | * 2 of the License, or (at your option) any later version. 23 | * 24 | * Moved to /usr/include/linux for NET3 25 | */ 26 | #ifndef _LINUX_NETDEVICE_H 27 | #define _LINUX_NETDEVICE_H 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | 35 | #define MAX_ADDR_LEN 32 /* Largest hardware address length */ 36 | 37 | /* Initial net device group. All devices belong to group 0 by default. */ 38 | #define INIT_NETDEV_GROUP 0 39 | 40 | 41 | /* interface name assignment types (sysfs name_assign_type attribute) */ 42 | #define NET_NAME_UNKNOWN 0 /* unknown origin (not exposed to userspace) */ 43 | #define NET_NAME_ENUM 1 /* enumerated by kernel */ 44 | #define NET_NAME_PREDICTABLE 2 /* predictably named by the kernel */ 45 | #define NET_NAME_USER 3 /* provided by user-space */ 46 | #define NET_NAME_RENAMED 4 /* renamed by user-space */ 47 | 48 | /* Media selection options. */ 49 | enum { 50 | IF_PORT_UNKNOWN = 0, 51 | IF_PORT_10BASE2, 52 | IF_PORT_10BASET, 53 | IF_PORT_AUI, 54 | IF_PORT_100BASET, 55 | IF_PORT_100BASETX, 56 | IF_PORT_100BASEFX 57 | }; 58 | 59 | /* hardware address assignment types */ 60 | #define NET_ADDR_PERM 0 /* address is permanent (default) */ 61 | #define NET_ADDR_RANDOM 1 /* address is generated randomly */ 62 | #define NET_ADDR_STOLEN 2 /* address is stolen from other device */ 63 | #define NET_ADDR_SET 3 /* address is set using 64 | * dev_set_mac_address() */ 65 | 66 | #endif /* _LINUX_NETDEVICE_H */ 67 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/netfilter.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __LINUX_NETFILTER_H 3 | #define __LINUX_NETFILTER_H 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | /* Responses from hook functions. */ 11 | #define NF_DROP 0 12 | #define NF_ACCEPT 1 13 | #define NF_STOLEN 2 14 | #define NF_QUEUE 3 15 | #define NF_REPEAT 4 16 | #define NF_STOP 5 /* Deprecated, for userspace nf_queue compatibility. */ 17 | #define NF_MAX_VERDICT NF_STOP 18 | 19 | /* we overload the higher bits for encoding auxiliary data such as the queue 20 | * number or errno values. Not nice, but better than additional function 21 | * arguments. */ 22 | #define NF_VERDICT_MASK 0x000000ff 23 | 24 | /* extra verdict flags have mask 0x0000ff00 */ 25 | #define NF_VERDICT_FLAG_QUEUE_BYPASS 0x00008000 26 | 27 | /* queue number (NF_QUEUE) or errno (NF_DROP) */ 28 | #define NF_VERDICT_QMASK 0xffff0000 29 | #define NF_VERDICT_QBITS 16 30 | 31 | #define NF_QUEUE_NR(x) ((((x) << 16) & NF_VERDICT_QMASK) | NF_QUEUE) 32 | 33 | #define NF_DROP_ERR(x) (((-x) << 16) | NF_DROP) 34 | 35 | /* only for userspace compatibility */ 36 | /* Generic cache responses from hook functions. 37 | <= 0x2000 is used for protocol-flags. */ 38 | #define NFC_UNKNOWN 0x4000 39 | #define NFC_ALTERED 0x8000 40 | 41 | /* NF_VERDICT_BITS should be 8 now, but userspace might break if this changes */ 42 | #define NF_VERDICT_BITS 16 43 | 44 | enum nf_inet_hooks { 45 | NF_INET_PRE_ROUTING, 46 | NF_INET_LOCAL_IN, 47 | NF_INET_FORWARD, 48 | NF_INET_LOCAL_OUT, 49 | NF_INET_POST_ROUTING, 50 | NF_INET_NUMHOOKS 51 | }; 52 | 53 | enum nf_dev_hooks { 54 | NF_NETDEV_INGRESS, 55 | NF_NETDEV_NUMHOOKS 56 | }; 57 | 58 | enum { 59 | NFPROTO_UNSPEC = 0, 60 | NFPROTO_INET = 1, 61 | NFPROTO_IPV4 = 2, 62 | NFPROTO_ARP = 3, 63 | NFPROTO_NETDEV = 5, 64 | NFPROTO_BRIDGE = 7, 65 | NFPROTO_IPV6 = 10, 66 | NFPROTO_DECNET = 12, 67 | NFPROTO_NUMPROTO, 68 | }; 69 | 70 | union nf_inet_addr { 71 | __u32 all[4]; 72 | __be32 ip; 73 | __be32 ip6[4]; 74 | struct in_addr in; 75 | struct in6_addr in6; 76 | }; 77 | 78 | #endif /* __LINUX_NETFILTER_H */ 79 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/netfilter/xt_set.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _XT_SET_H 3 | #define _XT_SET_H 4 | 5 | #include 6 | #include 7 | 8 | /* Revision 0 interface: backward compatible with netfilter/iptables */ 9 | 10 | /* 11 | * Option flags for kernel operations (xt_set_info_v0) 12 | */ 13 | #define IPSET_SRC 0x01 /* Source match/add */ 14 | #define IPSET_DST 0x02 /* Destination match/add */ 15 | #define IPSET_MATCH_INV 0x04 /* Inverse matching */ 16 | 17 | struct xt_set_info_v0 { 18 | ip_set_id_t index; 19 | union { 20 | __u32 flags[IPSET_DIM_MAX + 1]; 21 | struct { 22 | __u32 __flags[IPSET_DIM_MAX]; 23 | __u8 dim; 24 | __u8 flags; 25 | } compat; 26 | } u; 27 | }; 28 | 29 | /* match and target infos */ 30 | struct xt_set_info_match_v0 { 31 | struct xt_set_info_v0 match_set; 32 | }; 33 | 34 | struct xt_set_info_target_v0 { 35 | struct xt_set_info_v0 add_set; 36 | struct xt_set_info_v0 del_set; 37 | }; 38 | 39 | /* Revision 1 match and target */ 40 | 41 | struct xt_set_info { 42 | ip_set_id_t index; 43 | __u8 dim; 44 | __u8 flags; 45 | }; 46 | 47 | /* match and target infos */ 48 | struct xt_set_info_match_v1 { 49 | struct xt_set_info match_set; 50 | }; 51 | 52 | struct xt_set_info_target_v1 { 53 | struct xt_set_info add_set; 54 | struct xt_set_info del_set; 55 | }; 56 | 57 | /* Revision 2 target */ 58 | 59 | struct xt_set_info_target_v2 { 60 | struct xt_set_info add_set; 61 | struct xt_set_info del_set; 62 | __u32 flags; 63 | __u32 timeout; 64 | }; 65 | 66 | /* Revision 3 match */ 67 | 68 | struct xt_set_info_match_v3 { 69 | struct xt_set_info match_set; 70 | struct ip_set_counter_match0 packets; 71 | struct ip_set_counter_match0 bytes; 72 | __u32 flags; 73 | }; 74 | 75 | /* Revision 3 target */ 76 | 77 | struct xt_set_info_target_v3 { 78 | struct xt_set_info add_set; 79 | struct xt_set_info del_set; 80 | struct xt_set_info map_set; 81 | __u32 flags; 82 | __u32 timeout; 83 | }; 84 | 85 | /* Revision 4 match */ 86 | 87 | struct xt_set_info_match_v4 { 88 | struct xt_set_info match_set; 89 | struct ip_set_counter_match packets; 90 | struct ip_set_counter_match bytes; 91 | __u32 flags; 92 | }; 93 | 94 | #endif /*_XT_SET_H*/ 95 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/netfilter/xt_tcpudp.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _XT_TCPUDP_H 3 | #define _XT_TCPUDP_H 4 | 5 | #include 6 | 7 | /* TCP matching stuff */ 8 | struct xt_tcp { 9 | __u16 spts[2]; /* Source port range. */ 10 | __u16 dpts[2]; /* Destination port range. */ 11 | __u8 option; /* TCP Option iff non-zero*/ 12 | __u8 flg_mask; /* TCP flags mask byte */ 13 | __u8 flg_cmp; /* TCP flags compare byte */ 14 | __u8 invflags; /* Inverse flags */ 15 | }; 16 | 17 | /* Values for "inv" field in struct ipt_tcp. */ 18 | #define XT_TCP_INV_SRCPT 0x01 /* Invert the sense of source ports. */ 19 | #define XT_TCP_INV_DSTPT 0x02 /* Invert the sense of dest ports. */ 20 | #define XT_TCP_INV_FLAGS 0x04 /* Invert the sense of TCP flags. */ 21 | #define XT_TCP_INV_OPTION 0x08 /* Invert the sense of option test. */ 22 | #define XT_TCP_INV_MASK 0x0F /* All possible flags. */ 23 | 24 | /* UDP matching stuff */ 25 | struct xt_udp { 26 | __u16 spts[2]; /* Source port range. */ 27 | __u16 dpts[2]; /* Destination port range. */ 28 | __u8 invflags; /* Inverse flags */ 29 | }; 30 | 31 | /* Values for "invflags" field in struct ipt_udp. */ 32 | #define XT_UDP_INV_SRCPT 0x01 /* Invert the sense of source ports. */ 33 | #define XT_UDP_INV_DSTPT 0x02 /* Invert the sense of dest ports. */ 34 | #define XT_UDP_INV_MASK 0x03 /* All possible flags. */ 35 | 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/netfilter_ipv4.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | /* IPv4-specific defines for netfilter. 3 | * (C)1998 Rusty Russell -- This code is GPL. 4 | */ 5 | #ifndef __LINUX_IP_NETFILTER_H 6 | #define __LINUX_IP_NETFILTER_H 7 | 8 | 9 | #include 10 | 11 | /* only for userspace compatibility */ 12 | 13 | #include /* for INT_MIN, INT_MAX */ 14 | 15 | /* IP Cache bits. */ 16 | /* Src IP address. */ 17 | #define NFC_IP_SRC 0x0001 18 | /* Dest IP address. */ 19 | #define NFC_IP_DST 0x0002 20 | /* Input device. */ 21 | #define NFC_IP_IF_IN 0x0004 22 | /* Output device. */ 23 | #define NFC_IP_IF_OUT 0x0008 24 | /* TOS. */ 25 | #define NFC_IP_TOS 0x0010 26 | /* Protocol. */ 27 | #define NFC_IP_PROTO 0x0020 28 | /* IP options. */ 29 | #define NFC_IP_OPTIONS 0x0040 30 | /* Frag & flags. */ 31 | #define NFC_IP_FRAG 0x0080 32 | 33 | /* Per-protocol information: only matters if proto match. */ 34 | /* TCP flags. */ 35 | #define NFC_IP_TCPFLAGS 0x0100 36 | /* Source port. */ 37 | #define NFC_IP_SRC_PT 0x0200 38 | /* Dest port. */ 39 | #define NFC_IP_DST_PT 0x0400 40 | /* Something else about the proto */ 41 | #define NFC_IP_PROTO_UNKNOWN 0x2000 42 | 43 | /* IP Hooks */ 44 | /* After promisc drops, checksum checks. */ 45 | #define NF_IP_PRE_ROUTING 0 46 | /* If the packet is destined for this box. */ 47 | #define NF_IP_LOCAL_IN 1 48 | /* If the packet is destined for another interface. */ 49 | #define NF_IP_FORWARD 2 50 | /* Packets coming from a local process. */ 51 | #define NF_IP_LOCAL_OUT 3 52 | /* Packets about to hit the wire. */ 53 | #define NF_IP_POST_ROUTING 4 54 | #define NF_IP_NUMHOOKS 5 55 | 56 | enum nf_ip_hook_priorities { 57 | NF_IP_PRI_FIRST = INT_MIN, 58 | NF_IP_PRI_CONNTRACK_DEFRAG = -400, 59 | NF_IP_PRI_RAW = -300, 60 | NF_IP_PRI_SELINUX_FIRST = -225, 61 | NF_IP_PRI_CONNTRACK = -200, 62 | NF_IP_PRI_MANGLE = -150, 63 | NF_IP_PRI_NAT_DST = -100, 64 | NF_IP_PRI_FILTER = 0, 65 | NF_IP_PRI_SECURITY = 50, 66 | NF_IP_PRI_NAT_SRC = 100, 67 | NF_IP_PRI_SELINUX_LAST = 225, 68 | NF_IP_PRI_CONNTRACK_HELPER = 300, 69 | NF_IP_PRI_CONNTRACK_CONFIRM = INT_MAX, 70 | NF_IP_PRI_LAST = INT_MAX, 71 | }; 72 | 73 | /* Arguments for setsockopt SOL_IP: */ 74 | /* 2.0 firewalling went from 64 through 71 (and +256, +512, etc). */ 75 | /* 2.2 firewalling (+ masq) went from 64 through 76 */ 76 | /* 2.4 firewalling went 64 through 67. */ 77 | #define SO_ORIGINAL_DST 80 78 | 79 | 80 | #endif /* __LINUX_IP_NETFILTER_H */ 81 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/netfilter_ipv6.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | /* IPv6-specific defines for netfilter. 3 | * (C)1998 Rusty Russell -- This code is GPL. 4 | * (C)1999 David Jeffery 5 | * this header was blatantly ripped from netfilter_ipv4.h 6 | * it's amazing what adding a bunch of 6s can do =8^) 7 | */ 8 | #ifndef __LINUX_IP6_NETFILTER_H 9 | #define __LINUX_IP6_NETFILTER_H 10 | 11 | 12 | #include 13 | 14 | /* only for userspace compatibility */ 15 | 16 | #include /* for INT_MIN, INT_MAX */ 17 | 18 | /* IP Cache bits. */ 19 | /* Src IP address. */ 20 | #define NFC_IP6_SRC 0x0001 21 | /* Dest IP address. */ 22 | #define NFC_IP6_DST 0x0002 23 | /* Input device. */ 24 | #define NFC_IP6_IF_IN 0x0004 25 | /* Output device. */ 26 | #define NFC_IP6_IF_OUT 0x0008 27 | /* TOS. */ 28 | #define NFC_IP6_TOS 0x0010 29 | /* Protocol. */ 30 | #define NFC_IP6_PROTO 0x0020 31 | /* IP options. */ 32 | #define NFC_IP6_OPTIONS 0x0040 33 | /* Frag & flags. */ 34 | #define NFC_IP6_FRAG 0x0080 35 | 36 | 37 | /* Per-protocol information: only matters if proto match. */ 38 | /* TCP flags. */ 39 | #define NFC_IP6_TCPFLAGS 0x0100 40 | /* Source port. */ 41 | #define NFC_IP6_SRC_PT 0x0200 42 | /* Dest port. */ 43 | #define NFC_IP6_DST_PT 0x0400 44 | /* Something else about the proto */ 45 | #define NFC_IP6_PROTO_UNKNOWN 0x2000 46 | 47 | /* IP6 Hooks */ 48 | /* After promisc drops, checksum checks. */ 49 | #define NF_IP6_PRE_ROUTING 0 50 | /* If the packet is destined for this box. */ 51 | #define NF_IP6_LOCAL_IN 1 52 | /* If the packet is destined for another interface. */ 53 | #define NF_IP6_FORWARD 2 54 | /* Packets coming from a local process. */ 55 | #define NF_IP6_LOCAL_OUT 3 56 | /* Packets about to hit the wire. */ 57 | #define NF_IP6_POST_ROUTING 4 58 | #define NF_IP6_NUMHOOKS 5 59 | 60 | 61 | enum nf_ip6_hook_priorities { 62 | NF_IP6_PRI_FIRST = INT_MIN, 63 | NF_IP6_PRI_CONNTRACK_DEFRAG = -400, 64 | NF_IP6_PRI_RAW = -300, 65 | NF_IP6_PRI_SELINUX_FIRST = -225, 66 | NF_IP6_PRI_CONNTRACK = -200, 67 | NF_IP6_PRI_MANGLE = -150, 68 | NF_IP6_PRI_NAT_DST = -100, 69 | NF_IP6_PRI_FILTER = 0, 70 | NF_IP6_PRI_SECURITY = 50, 71 | NF_IP6_PRI_NAT_SRC = 100, 72 | NF_IP6_PRI_SELINUX_LAST = 225, 73 | NF_IP6_PRI_CONNTRACK_HELPER = 300, 74 | NF_IP6_PRI_LAST = INT_MAX, 75 | }; 76 | 77 | 78 | #endif /* __LINUX_IP6_NETFILTER_H */ 79 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/netlink_diag.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __NETLINK_DIAG_H__ 3 | #define __NETLINK_DIAG_H__ 4 | 5 | #include 6 | 7 | struct netlink_diag_req { 8 | __u8 sdiag_family; 9 | __u8 sdiag_protocol; 10 | __u16 pad; 11 | __u32 ndiag_ino; 12 | __u32 ndiag_show; 13 | __u32 ndiag_cookie[2]; 14 | }; 15 | 16 | struct netlink_diag_msg { 17 | __u8 ndiag_family; 18 | __u8 ndiag_type; 19 | __u8 ndiag_protocol; 20 | __u8 ndiag_state; 21 | 22 | __u32 ndiag_portid; 23 | __u32 ndiag_dst_portid; 24 | __u32 ndiag_dst_group; 25 | __u32 ndiag_ino; 26 | __u32 ndiag_cookie[2]; 27 | }; 28 | 29 | struct netlink_diag_ring { 30 | __u32 ndr_block_size; 31 | __u32 ndr_block_nr; 32 | __u32 ndr_frame_size; 33 | __u32 ndr_frame_nr; 34 | }; 35 | 36 | enum { 37 | /* NETLINK_DIAG_NONE, standard nl API requires this attribute! */ 38 | NETLINK_DIAG_MEMINFO, 39 | NETLINK_DIAG_GROUPS, 40 | NETLINK_DIAG_RX_RING, 41 | NETLINK_DIAG_TX_RING, 42 | NETLINK_DIAG_FLAGS, 43 | 44 | __NETLINK_DIAG_MAX, 45 | }; 46 | 47 | #define NETLINK_DIAG_MAX (__NETLINK_DIAG_MAX - 1) 48 | 49 | #define NDIAG_PROTO_ALL ((__u8) ~0) 50 | 51 | #define NDIAG_SHOW_MEMINFO 0x00000001 /* show memory info of a socket */ 52 | #define NDIAG_SHOW_GROUPS 0x00000002 /* show groups of a netlink socket */ 53 | /* deprecated since 4.6 */ 54 | #define NDIAG_SHOW_RING_CFG 0x00000004 /* show ring configuration */ 55 | #define NDIAG_SHOW_FLAGS 0x00000008 /* show flags of a netlink socket */ 56 | 57 | /* flags */ 58 | #define NDIAG_FLAG_CB_RUNNING 0x00000001 59 | #define NDIAG_FLAG_PKTINFO 0x00000002 60 | #define NDIAG_FLAG_BROADCAST_ERROR 0x00000004 61 | #define NDIAG_FLAG_NO_ENOBUFS 0x00000008 62 | #define NDIAG_FLAG_LISTEN_ALL_NSID 0x00000010 63 | #define NDIAG_FLAG_CAP_ACK 0x00000020 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/packet_diag.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __PACKET_DIAG_H__ 3 | #define __PACKET_DIAG_H__ 4 | 5 | #include 6 | 7 | struct packet_diag_req { 8 | __u8 sdiag_family; 9 | __u8 sdiag_protocol; 10 | __u16 pad; 11 | __u32 pdiag_ino; 12 | __u32 pdiag_show; 13 | __u32 pdiag_cookie[2]; 14 | }; 15 | 16 | #define PACKET_SHOW_INFO 0x00000001 /* Basic packet_sk information */ 17 | #define PACKET_SHOW_MCLIST 0x00000002 /* A set of packet_diag_mclist-s */ 18 | #define PACKET_SHOW_RING_CFG 0x00000004 /* Rings configuration parameters */ 19 | #define PACKET_SHOW_FANOUT 0x00000008 20 | #define PACKET_SHOW_MEMINFO 0x00000010 21 | #define PACKET_SHOW_FILTER 0x00000020 22 | 23 | struct packet_diag_msg { 24 | __u8 pdiag_family; 25 | __u8 pdiag_type; 26 | __u16 pdiag_num; 27 | 28 | __u32 pdiag_ino; 29 | __u32 pdiag_cookie[2]; 30 | }; 31 | 32 | enum { 33 | /* PACKET_DIAG_NONE, standard nl API requires this attribute! */ 34 | PACKET_DIAG_INFO, 35 | PACKET_DIAG_MCLIST, 36 | PACKET_DIAG_RX_RING, 37 | PACKET_DIAG_TX_RING, 38 | PACKET_DIAG_FANOUT, 39 | PACKET_DIAG_UID, 40 | PACKET_DIAG_MEMINFO, 41 | PACKET_DIAG_FILTER, 42 | 43 | __PACKET_DIAG_MAX, 44 | }; 45 | 46 | #define PACKET_DIAG_MAX (__PACKET_DIAG_MAX - 1) 47 | 48 | struct packet_diag_info { 49 | __u32 pdi_index; 50 | __u32 pdi_version; 51 | __u32 pdi_reserve; 52 | __u32 pdi_copy_thresh; 53 | __u32 pdi_tstamp; 54 | __u32 pdi_flags; 55 | 56 | #define PDI_RUNNING 0x1 57 | #define PDI_AUXDATA 0x2 58 | #define PDI_ORIGDEV 0x4 59 | #define PDI_VNETHDR 0x8 60 | #define PDI_LOSS 0x10 61 | }; 62 | 63 | struct packet_diag_mclist { 64 | __u32 pdmc_index; 65 | __u32 pdmc_count; 66 | __u16 pdmc_type; 67 | __u16 pdmc_alen; 68 | __u8 pdmc_addr[32]; /* MAX_ADDR_LEN */ 69 | }; 70 | 71 | struct packet_diag_ring { 72 | __u32 pdr_block_size; 73 | __u32 pdr_block_nr; 74 | __u32 pdr_frame_size; 75 | __u32 pdr_frame_nr; 76 | __u32 pdr_retire_tmo; 77 | __u32 pdr_sizeof_priv; 78 | __u32 pdr_features; 79 | }; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/param.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_PARAM_H 3 | #define _LINUX_PARAM_H 4 | 5 | #include 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/posix_types.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_POSIX_TYPES_H 3 | #define _LINUX_POSIX_TYPES_H 4 | 5 | #include 6 | 7 | /* 8 | * This allows for 1024 file descriptors: if NR_OPEN is ever grown 9 | * beyond that you'll have to change this too. But 1024 fd's seem to be 10 | * enough even for such "real" unices like OSF/1, so hopefully this is 11 | * one limit that doesn't have to be changed [again]. 12 | * 13 | * Note that POSIX wants the FD_CLEAR(fd,fdsetp) defines to be in 14 | * (and thus ) - but this is a more logical 15 | * place for them. Solved by having dummy defines in . 16 | */ 17 | 18 | /* 19 | * This macro may have been defined in . But we always 20 | * use the one here. 21 | */ 22 | #undef __FD_SETSIZE 23 | #define __FD_SETSIZE 1024 24 | 25 | typedef struct { 26 | unsigned long fds_bits[__FD_SETSIZE / (8 * sizeof(long))]; 27 | } __kernel_fd_set; 28 | 29 | /* Type of a signal handler. */ 30 | typedef void (*__kernel_sighandler_t)(int); 31 | 32 | /* Type of a SYSV IPC key. */ 33 | typedef int __kernel_key_t; 34 | typedef int __kernel_mqd_t; 35 | 36 | #include 37 | 38 | #endif /* _LINUX_POSIX_TYPES_H */ 39 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/seg6.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2 | /* 3 | * SR-IPv6 implementation 4 | * 5 | * Author: 6 | * David Lebrun 7 | * 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 12 | * 2 of the License, or (at your option) any later version. 13 | */ 14 | 15 | #ifndef _LINUX_SEG6_H 16 | #define _LINUX_SEG6_H 17 | 18 | #include 19 | #include /* For struct in6_addr. */ 20 | 21 | /* 22 | * SRH 23 | */ 24 | struct ipv6_sr_hdr { 25 | __u8 nexthdr; 26 | __u8 hdrlen; 27 | __u8 type; 28 | __u8 segments_left; 29 | __u8 first_segment; 30 | __u8 flags; 31 | __u16 reserved; 32 | 33 | struct in6_addr segments[0]; 34 | }; 35 | 36 | #define SR6_FLAG1_PROTECTED (1 << 6) 37 | #define SR6_FLAG1_OAM (1 << 5) 38 | #define SR6_FLAG1_ALERT (1 << 4) 39 | #define SR6_FLAG1_HMAC (1 << 3) 40 | 41 | #define SR6_TLV_INGRESS 1 42 | #define SR6_TLV_EGRESS 2 43 | #define SR6_TLV_OPAQUE 3 44 | #define SR6_TLV_PADDING 4 45 | #define SR6_TLV_HMAC 5 46 | 47 | #define sr_has_hmac(srh) ((srh)->flags & SR6_FLAG1_HMAC) 48 | 49 | struct sr6_tlv { 50 | __u8 type; 51 | __u8 len; 52 | __u8 data[0]; 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/seg6_genl.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_SEG6_GENL_H 3 | #define _LINUX_SEG6_GENL_H 4 | 5 | #define SEG6_GENL_NAME "SEG6" 6 | #define SEG6_GENL_VERSION 0x1 7 | 8 | enum { 9 | SEG6_ATTR_UNSPEC, 10 | SEG6_ATTR_DST, 11 | SEG6_ATTR_DSTLEN, 12 | SEG6_ATTR_HMACKEYID, 13 | SEG6_ATTR_SECRET, 14 | SEG6_ATTR_SECRETLEN, 15 | SEG6_ATTR_ALGID, 16 | SEG6_ATTR_HMACINFO, 17 | __SEG6_ATTR_MAX, 18 | }; 19 | 20 | #define SEG6_ATTR_MAX (__SEG6_ATTR_MAX - 1) 21 | 22 | enum { 23 | SEG6_CMD_UNSPEC, 24 | SEG6_CMD_SETHMAC, 25 | SEG6_CMD_DUMPHMAC, 26 | SEG6_CMD_SET_TUNSRC, 27 | SEG6_CMD_GET_TUNSRC, 28 | __SEG6_CMD_MAX, 29 | }; 30 | 31 | #define SEG6_CMD_MAX (__SEG6_CMD_MAX - 1) 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/seg6_hmac.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_SEG6_HMAC_H 3 | #define _LINUX_SEG6_HMAC_H 4 | 5 | #include 6 | #include 7 | 8 | #define SEG6_HMAC_SECRET_LEN 64 9 | #define SEG6_HMAC_FIELD_LEN 32 10 | 11 | struct sr6_tlv_hmac { 12 | struct sr6_tlv tlvhdr; 13 | __u16 reserved; 14 | __be32 hmackeyid; 15 | __u8 hmac[SEG6_HMAC_FIELD_LEN]; 16 | }; 17 | 18 | enum { 19 | SEG6_HMAC_ALGO_SHA1 = 1, 20 | SEG6_HMAC_ALGO_SHA256 = 2, 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/seg6_iptunnel.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2 | /* 3 | * SR-IPv6 implementation 4 | * 5 | * Author: 6 | * David Lebrun 7 | * 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 12 | * 2 of the License, or (at your option) any later version. 13 | */ 14 | 15 | #ifndef _LINUX_SEG6_IPTUNNEL_H 16 | #define _LINUX_SEG6_IPTUNNEL_H 17 | 18 | #include /* For struct ipv6_sr_hdr. */ 19 | 20 | enum { 21 | SEG6_IPTUNNEL_UNSPEC, 22 | SEG6_IPTUNNEL_SRH, 23 | __SEG6_IPTUNNEL_MAX, 24 | }; 25 | #define SEG6_IPTUNNEL_MAX (__SEG6_IPTUNNEL_MAX - 1) 26 | 27 | struct seg6_iptunnel_encap { 28 | int mode; 29 | struct ipv6_sr_hdr srh[0]; 30 | }; 31 | 32 | #define SEG6_IPTUN_ENCAP_SIZE(x) ((sizeof(*x)) + (((x)->srh->hdrlen + 1) << 3)) 33 | 34 | enum { 35 | SEG6_IPTUN_MODE_INLINE, 36 | SEG6_IPTUN_MODE_ENCAP, 37 | SEG6_IPTUN_MODE_L2ENCAP, 38 | }; 39 | 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/seg6_local.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SR-IPv6 implementation 3 | * 4 | * Author: 5 | * David Lebrun 6 | * 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation; either version 11 | * 2 of the License, or (at your option) any later version. 12 | */ 13 | 14 | #ifndef _LINUX_SEG6_LOCAL_H 15 | #define _LINUX_SEG6_LOCAL_H 16 | 17 | #include 18 | 19 | enum { 20 | SEG6_LOCAL_UNSPEC, 21 | SEG6_LOCAL_ACTION, 22 | SEG6_LOCAL_SRH, 23 | SEG6_LOCAL_TABLE, 24 | SEG6_LOCAL_NH4, 25 | SEG6_LOCAL_NH6, 26 | SEG6_LOCAL_IIF, 27 | SEG6_LOCAL_OIF, 28 | __SEG6_LOCAL_MAX, 29 | }; 30 | #define SEG6_LOCAL_MAX (__SEG6_LOCAL_MAX - 1) 31 | 32 | enum { 33 | SEG6_LOCAL_ACTION_UNSPEC = 0, 34 | /* node segment */ 35 | SEG6_LOCAL_ACTION_END = 1, 36 | /* adjacency segment (IPv6 cross-connect) */ 37 | SEG6_LOCAL_ACTION_END_X = 2, 38 | /* lookup of next seg NH in table */ 39 | SEG6_LOCAL_ACTION_END_T = 3, 40 | /* decap and L2 cross-connect */ 41 | SEG6_LOCAL_ACTION_END_DX2 = 4, 42 | /* decap and IPv6 cross-connect */ 43 | SEG6_LOCAL_ACTION_END_DX6 = 5, 44 | /* decap and IPv4 cross-connect */ 45 | SEG6_LOCAL_ACTION_END_DX4 = 6, 46 | /* decap and lookup of DA in v6 table */ 47 | SEG6_LOCAL_ACTION_END_DT6 = 7, 48 | /* decap and lookup of DA in v4 table */ 49 | SEG6_LOCAL_ACTION_END_DT4 = 8, 50 | /* binding segment with insertion */ 51 | SEG6_LOCAL_ACTION_END_B6 = 9, 52 | /* binding segment with encapsulation */ 53 | SEG6_LOCAL_ACTION_END_B6_ENCAP = 10, 54 | /* binding segment with MPLS encap */ 55 | SEG6_LOCAL_ACTION_END_BM = 11, 56 | /* lookup last seg in table */ 57 | SEG6_LOCAL_ACTION_END_S = 12, 58 | /* forward to SR-unaware VNF with static proxy */ 59 | SEG6_LOCAL_ACTION_END_AS = 13, 60 | /* forward to SR-unaware VNF with masquerading */ 61 | SEG6_LOCAL_ACTION_END_AM = 14, 62 | 63 | __SEG6_LOCAL_ACTION_MAX, 64 | }; 65 | 66 | #define SEG6_LOCAL_ACTION_MAX (__SEG6_LOCAL_ACTION_MAX - 1) 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/sock_diag.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __SOCK_DIAG_H__ 3 | #define __SOCK_DIAG_H__ 4 | 5 | #include 6 | 7 | #define SOCK_DIAG_BY_FAMILY 20 8 | #define SOCK_DESTROY 21 9 | 10 | struct sock_diag_req { 11 | __u8 sdiag_family; 12 | __u8 sdiag_protocol; 13 | }; 14 | 15 | enum { 16 | SK_MEMINFO_RMEM_ALLOC, 17 | SK_MEMINFO_RCVBUF, 18 | SK_MEMINFO_WMEM_ALLOC, 19 | SK_MEMINFO_SNDBUF, 20 | SK_MEMINFO_FWD_ALLOC, 21 | SK_MEMINFO_WMEM_QUEUED, 22 | SK_MEMINFO_OPTMEM, 23 | SK_MEMINFO_BACKLOG, 24 | SK_MEMINFO_DROPS, 25 | 26 | SK_MEMINFO_VARS, 27 | }; 28 | 29 | enum sknetlink_groups { 30 | SKNLGRP_NONE, 31 | SKNLGRP_INET_TCP_DESTROY, 32 | SKNLGRP_INET_UDP_DESTROY, 33 | SKNLGRP_INET6_TCP_DESTROY, 34 | SKNLGRP_INET6_UDP_DESTROY, 35 | __SKNLGRP_MAX, 36 | }; 37 | #define SKNLGRP_MAX (__SKNLGRP_MAX - 1) 38 | 39 | #endif /* __SOCK_DIAG_H__ */ 40 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/socket.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_SOCKET_H 3 | #define _LINUX_SOCKET_H 4 | 5 | /* 6 | * Desired design of maximum size and alignment (see RFC2553) 7 | */ 8 | #define _K_SS_MAXSIZE 128 /* Implementation specific max size */ 9 | #define _K_SS_ALIGNSIZE (__alignof__ (struct sockaddr *)) 10 | /* Implementation specific desired alignment */ 11 | 12 | typedef unsigned short __kernel_sa_family_t; 13 | 14 | struct __kernel_sockaddr_storage { 15 | __kernel_sa_family_t ss_family; /* address family */ 16 | /* Following field(s) are implementation specific */ 17 | char __data[_K_SS_MAXSIZE - sizeof(unsigned short)]; 18 | /* space to achieve desired size, */ 19 | /* _SS_MAXSIZE value minus size of ss_family */ 20 | } __attribute__ ((aligned(_K_SS_ALIGNSIZE))); /* force desired alignment */ 21 | 22 | #endif /* _LINUX_SOCKET_H */ 23 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/stddef.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | 3 | 4 | #ifndef __always_inline 5 | #define __always_inline __inline__ 6 | #endif 7 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/sysinfo.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_SYSINFO_H 3 | #define _LINUX_SYSINFO_H 4 | 5 | #include 6 | 7 | #define SI_LOAD_SHIFT 16 8 | struct sysinfo { 9 | __kernel_long_t uptime; /* Seconds since boot */ 10 | __kernel_ulong_t loads[3]; /* 1, 5, and 15 minute load averages */ 11 | __kernel_ulong_t totalram; /* Total usable main memory size */ 12 | __kernel_ulong_t freeram; /* Available memory size */ 13 | __kernel_ulong_t sharedram; /* Amount of shared memory */ 14 | __kernel_ulong_t bufferram; /* Memory used by buffers */ 15 | __kernel_ulong_t totalswap; /* Total swap space size */ 16 | __kernel_ulong_t freeswap; /* swap space still available */ 17 | __u16 procs; /* Number of current processes */ 18 | __u16 pad; /* Explicit padding for m68k */ 19 | __kernel_ulong_t totalhigh; /* Total high memory size */ 20 | __kernel_ulong_t freehigh; /* Available high memory size */ 21 | __u32 mem_unit; /* Memory unit size in bytes */ 22 | char _f[20-2*sizeof(__kernel_ulong_t)-sizeof(__u32)]; /* Padding: libc5 uses this.. */ 23 | }; 24 | 25 | #endif /* _LINUX_SYSINFO_H */ 26 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tc_act/tc_bpf.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2 | /* 3 | * Copyright (c) 2015 Jiri Pirko 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | */ 10 | 11 | #ifndef __LINUX_TC_BPF_H 12 | #define __LINUX_TC_BPF_H 13 | 14 | #include 15 | 16 | #define TCA_ACT_BPF 13 17 | 18 | struct tc_act_bpf { 19 | tc_gen; 20 | }; 21 | 22 | enum { 23 | TCA_ACT_BPF_UNSPEC, 24 | TCA_ACT_BPF_TM, 25 | TCA_ACT_BPF_PARMS, 26 | TCA_ACT_BPF_OPS_LEN, 27 | TCA_ACT_BPF_OPS, 28 | TCA_ACT_BPF_FD, 29 | TCA_ACT_BPF_NAME, 30 | TCA_ACT_BPF_PAD, 31 | TCA_ACT_BPF_TAG, 32 | TCA_ACT_BPF_ID, 33 | __TCA_ACT_BPF_MAX, 34 | }; 35 | #define TCA_ACT_BPF_MAX (__TCA_ACT_BPF_MAX - 1) 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tc_act/tc_connmark.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __UAPI_TC_CONNMARK_H 3 | #define __UAPI_TC_CONNMARK_H 4 | 5 | #include 6 | #include 7 | 8 | #define TCA_ACT_CONNMARK 14 9 | 10 | struct tc_connmark { 11 | tc_gen; 12 | __u16 zone; 13 | }; 14 | 15 | enum { 16 | TCA_CONNMARK_UNSPEC, 17 | TCA_CONNMARK_PARMS, 18 | TCA_CONNMARK_TM, 19 | TCA_CONNMARK_PAD, 20 | __TCA_CONNMARK_MAX 21 | }; 22 | #define TCA_CONNMARK_MAX (__TCA_CONNMARK_MAX - 1) 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tc_act/tc_csum.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __LINUX_TC_CSUM_H 3 | #define __LINUX_TC_CSUM_H 4 | 5 | #include 6 | #include 7 | 8 | #define TCA_ACT_CSUM 16 9 | 10 | enum { 11 | TCA_CSUM_UNSPEC, 12 | TCA_CSUM_PARMS, 13 | TCA_CSUM_TM, 14 | TCA_CSUM_PAD, 15 | __TCA_CSUM_MAX 16 | }; 17 | #define TCA_CSUM_MAX (__TCA_CSUM_MAX - 1) 18 | 19 | enum { 20 | TCA_CSUM_UPDATE_FLAG_IPV4HDR = 1, 21 | TCA_CSUM_UPDATE_FLAG_ICMP = 2, 22 | TCA_CSUM_UPDATE_FLAG_IGMP = 4, 23 | TCA_CSUM_UPDATE_FLAG_TCP = 8, 24 | TCA_CSUM_UPDATE_FLAG_UDP = 16, 25 | TCA_CSUM_UPDATE_FLAG_UDPLITE = 32, 26 | TCA_CSUM_UPDATE_FLAG_SCTP = 64, 27 | }; 28 | 29 | struct tc_csum { 30 | tc_gen; 31 | 32 | __u32 update_flags; 33 | }; 34 | 35 | #endif /* __LINUX_TC_CSUM_H */ 36 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tc_act/tc_defact.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __LINUX_TC_DEF_H 3 | #define __LINUX_TC_DEF_H 4 | 5 | #include 6 | 7 | struct tc_defact { 8 | tc_gen; 9 | }; 10 | 11 | enum { 12 | TCA_DEF_UNSPEC, 13 | TCA_DEF_TM, 14 | TCA_DEF_PARMS, 15 | TCA_DEF_DATA, 16 | TCA_DEF_PAD, 17 | __TCA_DEF_MAX 18 | }; 19 | #define TCA_DEF_MAX (__TCA_DEF_MAX - 1) 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tc_act/tc_gact.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __LINUX_TC_GACT_H 3 | #define __LINUX_TC_GACT_H 4 | 5 | #include 6 | #include 7 | 8 | #define TCA_ACT_GACT 5 9 | struct tc_gact { 10 | tc_gen; 11 | 12 | }; 13 | 14 | struct tc_gact_p { 15 | #define PGACT_NONE 0 16 | #define PGACT_NETRAND 1 17 | #define PGACT_DETERM 2 18 | #define MAX_RAND (PGACT_DETERM + 1 ) 19 | __u16 ptype; 20 | __u16 pval; 21 | int paction; 22 | }; 23 | 24 | enum { 25 | TCA_GACT_UNSPEC, 26 | TCA_GACT_TM, 27 | TCA_GACT_PARMS, 28 | TCA_GACT_PROB, 29 | TCA_GACT_PAD, 30 | __TCA_GACT_MAX 31 | }; 32 | #define TCA_GACT_MAX (__TCA_GACT_MAX - 1) 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tc_act/tc_ife.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __UAPI_TC_IFE_H 3 | #define __UAPI_TC_IFE_H 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #define TCA_ACT_IFE 25 10 | /* Flag bits for now just encoding/decoding; mutually exclusive */ 11 | #define IFE_ENCODE 1 12 | #define IFE_DECODE 0 13 | 14 | struct tc_ife { 15 | tc_gen; 16 | __u16 flags; 17 | }; 18 | 19 | /*XXX: We need to encode the total number of bytes consumed */ 20 | enum { 21 | TCA_IFE_UNSPEC, 22 | TCA_IFE_PARMS, 23 | TCA_IFE_TM, 24 | TCA_IFE_DMAC, 25 | TCA_IFE_SMAC, 26 | TCA_IFE_TYPE, 27 | TCA_IFE_METALST, 28 | TCA_IFE_PAD, 29 | __TCA_IFE_MAX 30 | }; 31 | #define TCA_IFE_MAX (__TCA_IFE_MAX - 1) 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tc_act/tc_ipt.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __LINUX_TC_IPT_H 3 | #define __LINUX_TC_IPT_H 4 | 5 | #include 6 | 7 | #define TCA_ACT_IPT 6 8 | #define TCA_ACT_XT 10 9 | 10 | enum { 11 | TCA_IPT_UNSPEC, 12 | TCA_IPT_TABLE, 13 | TCA_IPT_HOOK, 14 | TCA_IPT_INDEX, 15 | TCA_IPT_CNT, 16 | TCA_IPT_TM, 17 | TCA_IPT_TARG, 18 | TCA_IPT_PAD, 19 | __TCA_IPT_MAX 20 | }; 21 | #define TCA_IPT_MAX (__TCA_IPT_MAX - 1) 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tc_act/tc_mirred.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __LINUX_TC_MIR_H 3 | #define __LINUX_TC_MIR_H 4 | 5 | #include 6 | #include 7 | 8 | #define TCA_ACT_MIRRED 8 9 | #define TCA_EGRESS_REDIR 1 /* packet redirect to EGRESS*/ 10 | #define TCA_EGRESS_MIRROR 2 /* mirror packet to EGRESS */ 11 | #define TCA_INGRESS_REDIR 3 /* packet redirect to INGRESS*/ 12 | #define TCA_INGRESS_MIRROR 4 /* mirror packet to INGRESS */ 13 | 14 | struct tc_mirred { 15 | tc_gen; 16 | int eaction; /* one of IN/EGRESS_MIRROR/REDIR */ 17 | __u32 ifindex; /* ifindex of egress port */ 18 | }; 19 | 20 | enum { 21 | TCA_MIRRED_UNSPEC, 22 | TCA_MIRRED_TM, 23 | TCA_MIRRED_PARMS, 24 | TCA_MIRRED_PAD, 25 | __TCA_MIRRED_MAX 26 | }; 27 | #define TCA_MIRRED_MAX (__TCA_MIRRED_MAX - 1) 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tc_act/tc_nat.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __LINUX_TC_NAT_H 3 | #define __LINUX_TC_NAT_H 4 | 5 | #include 6 | #include 7 | 8 | #define TCA_ACT_NAT 9 9 | 10 | enum { 11 | TCA_NAT_UNSPEC, 12 | TCA_NAT_PARMS, 13 | TCA_NAT_TM, 14 | TCA_NAT_PAD, 15 | __TCA_NAT_MAX 16 | }; 17 | #define TCA_NAT_MAX (__TCA_NAT_MAX - 1) 18 | 19 | #define TCA_NAT_FLAG_EGRESS 1 20 | 21 | struct tc_nat { 22 | tc_gen; 23 | __be32 old_addr; 24 | __be32 new_addr; 25 | __be32 mask; 26 | __u32 flags; 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tc_act/tc_pedit.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __LINUX_TC_PED_H 3 | #define __LINUX_TC_PED_H 4 | 5 | #include 6 | #include 7 | 8 | #define TCA_ACT_PEDIT 7 9 | 10 | enum { 11 | TCA_PEDIT_UNSPEC, 12 | TCA_PEDIT_TM, 13 | TCA_PEDIT_PARMS, 14 | TCA_PEDIT_PAD, 15 | TCA_PEDIT_PARMS_EX, 16 | TCA_PEDIT_KEYS_EX, 17 | TCA_PEDIT_KEY_EX, 18 | __TCA_PEDIT_MAX 19 | }; 20 | #define TCA_PEDIT_MAX (__TCA_PEDIT_MAX - 1) 21 | 22 | enum { 23 | TCA_PEDIT_KEY_EX_HTYPE = 1, 24 | TCA_PEDIT_KEY_EX_CMD = 2, 25 | __TCA_PEDIT_KEY_EX_MAX 26 | }; 27 | #define TCA_PEDIT_KEY_EX_MAX (__TCA_PEDIT_KEY_EX_MAX - 1) 28 | 29 | /* TCA_PEDIT_KEY_EX_HDR_TYPE_NETWROK is a special case for legacy users. It 30 | * means no specific header type - offset is relative to the network layer 31 | */ 32 | enum pedit_header_type { 33 | TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK = 0, 34 | TCA_PEDIT_KEY_EX_HDR_TYPE_ETH = 1, 35 | TCA_PEDIT_KEY_EX_HDR_TYPE_IP4 = 2, 36 | TCA_PEDIT_KEY_EX_HDR_TYPE_IP6 = 3, 37 | TCA_PEDIT_KEY_EX_HDR_TYPE_TCP = 4, 38 | TCA_PEDIT_KEY_EX_HDR_TYPE_UDP = 5, 39 | __PEDIT_HDR_TYPE_MAX, 40 | }; 41 | #define TCA_PEDIT_HDR_TYPE_MAX (__PEDIT_HDR_TYPE_MAX - 1) 42 | 43 | enum pedit_cmd { 44 | TCA_PEDIT_KEY_EX_CMD_SET = 0, 45 | TCA_PEDIT_KEY_EX_CMD_ADD = 1, 46 | __PEDIT_CMD_MAX, 47 | }; 48 | #define TCA_PEDIT_CMD_MAX (__PEDIT_CMD_MAX - 1) 49 | 50 | struct tc_pedit_key { 51 | __u32 mask; /* AND */ 52 | __u32 val; /*XOR */ 53 | __u32 off; /*offset */ 54 | __u32 at; 55 | __u32 offmask; 56 | __u32 shift; 57 | }; 58 | 59 | struct tc_pedit_sel { 60 | tc_gen; 61 | unsigned char nkeys; 62 | unsigned char flags; 63 | struct tc_pedit_key keys[0]; 64 | }; 65 | #define tc_pedit tc_pedit_sel 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tc_act/tc_sample.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __LINUX_TC_SAMPLE_H 3 | #define __LINUX_TC_SAMPLE_H 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #define TCA_ACT_SAMPLE 26 10 | 11 | struct tc_sample { 12 | tc_gen; 13 | }; 14 | 15 | enum { 16 | TCA_SAMPLE_UNSPEC, 17 | TCA_SAMPLE_TM, 18 | TCA_SAMPLE_PARMS, 19 | TCA_SAMPLE_RATE, 20 | TCA_SAMPLE_TRUNC_SIZE, 21 | TCA_SAMPLE_PSAMPLE_GROUP, 22 | TCA_SAMPLE_PAD, 23 | __TCA_SAMPLE_MAX 24 | }; 25 | #define TCA_SAMPLE_MAX (__TCA_SAMPLE_MAX - 1) 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tc_act/tc_skbedit.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | /* 3 | * Copyright (c) 2008, Intel Corporation. 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along with 15 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple 16 | * Place - Suite 330, Boston, MA 02111-1307 USA. 17 | * 18 | * Author: Alexander Duyck 19 | */ 20 | 21 | #ifndef __LINUX_TC_SKBEDIT_H 22 | #define __LINUX_TC_SKBEDIT_H 23 | 24 | #include 25 | 26 | #define TCA_ACT_SKBEDIT 11 27 | 28 | #define SKBEDIT_F_PRIORITY 0x1 29 | #define SKBEDIT_F_QUEUE_MAPPING 0x2 30 | #define SKBEDIT_F_MARK 0x4 31 | #define SKBEDIT_F_PTYPE 0x8 32 | #define SKBEDIT_F_MASK 0x10 33 | 34 | struct tc_skbedit { 35 | tc_gen; 36 | }; 37 | 38 | enum { 39 | TCA_SKBEDIT_UNSPEC, 40 | TCA_SKBEDIT_TM, 41 | TCA_SKBEDIT_PARMS, 42 | TCA_SKBEDIT_PRIORITY, 43 | TCA_SKBEDIT_QUEUE_MAPPING, 44 | TCA_SKBEDIT_MARK, 45 | TCA_SKBEDIT_PAD, 46 | TCA_SKBEDIT_PTYPE, 47 | TCA_SKBEDIT_MASK, 48 | __TCA_SKBEDIT_MAX 49 | }; 50 | #define TCA_SKBEDIT_MAX (__TCA_SKBEDIT_MAX - 1) 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tc_act/tc_skbmod.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2 | /* 3 | * Copyright (c) 2016, Jamal Hadi Salim 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | */ 10 | 11 | #ifndef __LINUX_TC_SKBMOD_H 12 | #define __LINUX_TC_SKBMOD_H 13 | 14 | #include 15 | 16 | #define TCA_ACT_SKBMOD 15 17 | 18 | #define SKBMOD_F_DMAC 0x1 19 | #define SKBMOD_F_SMAC 0x2 20 | #define SKBMOD_F_ETYPE 0x4 21 | #define SKBMOD_F_SWAPMAC 0x8 22 | 23 | struct tc_skbmod { 24 | tc_gen; 25 | __u64 flags; 26 | }; 27 | 28 | enum { 29 | TCA_SKBMOD_UNSPEC, 30 | TCA_SKBMOD_TM, 31 | TCA_SKBMOD_PARMS, 32 | TCA_SKBMOD_DMAC, 33 | TCA_SKBMOD_SMAC, 34 | TCA_SKBMOD_ETYPE, 35 | TCA_SKBMOD_PAD, 36 | __TCA_SKBMOD_MAX 37 | }; 38 | #define TCA_SKBMOD_MAX (__TCA_SKBMOD_MAX - 1) 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tc_act/tc_tunnel_key.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2 | /* 3 | * Copyright (c) 2016, Amir Vadai 4 | * Copyright (c) 2016, Mellanox Technologies. All rights reserved. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | */ 11 | 12 | #ifndef __LINUX_TC_TUNNEL_KEY_H 13 | #define __LINUX_TC_TUNNEL_KEY_H 14 | 15 | #include 16 | 17 | #define TCA_ACT_TUNNEL_KEY 17 18 | 19 | #define TCA_TUNNEL_KEY_ACT_SET 1 20 | #define TCA_TUNNEL_KEY_ACT_RELEASE 2 21 | 22 | struct tc_tunnel_key { 23 | tc_gen; 24 | int t_action; 25 | }; 26 | 27 | enum { 28 | TCA_TUNNEL_KEY_UNSPEC, 29 | TCA_TUNNEL_KEY_TM, 30 | TCA_TUNNEL_KEY_PARMS, 31 | TCA_TUNNEL_KEY_ENC_IPV4_SRC, /* be32 */ 32 | TCA_TUNNEL_KEY_ENC_IPV4_DST, /* be32 */ 33 | TCA_TUNNEL_KEY_ENC_IPV6_SRC, /* struct in6_addr */ 34 | TCA_TUNNEL_KEY_ENC_IPV6_DST, /* struct in6_addr */ 35 | TCA_TUNNEL_KEY_ENC_KEY_ID, /* be64 */ 36 | TCA_TUNNEL_KEY_PAD, 37 | TCA_TUNNEL_KEY_ENC_DST_PORT, /* be16 */ 38 | TCA_TUNNEL_KEY_NO_CSUM, /* u8 */ 39 | __TCA_TUNNEL_KEY_MAX, 40 | }; 41 | 42 | #define TCA_TUNNEL_KEY_MAX (__TCA_TUNNEL_KEY_MAX - 1) 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tc_act/tc_vlan.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2 | /* 3 | * Copyright (c) 2014 Jiri Pirko 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | */ 10 | 11 | #ifndef __LINUX_TC_VLAN_H 12 | #define __LINUX_TC_VLAN_H 13 | 14 | #include 15 | 16 | #define TCA_ACT_VLAN 12 17 | 18 | #define TCA_VLAN_ACT_POP 1 19 | #define TCA_VLAN_ACT_PUSH 2 20 | #define TCA_VLAN_ACT_MODIFY 3 21 | 22 | struct tc_vlan { 23 | tc_gen; 24 | int v_action; 25 | }; 26 | 27 | enum { 28 | TCA_VLAN_UNSPEC, 29 | TCA_VLAN_TM, 30 | TCA_VLAN_PARMS, 31 | TCA_VLAN_PUSH_VLAN_ID, 32 | TCA_VLAN_PUSH_VLAN_PROTOCOL, 33 | TCA_VLAN_PAD, 34 | TCA_VLAN_PUSH_VLAN_PRIORITY, 35 | __TCA_VLAN_MAX, 36 | }; 37 | #define TCA_VLAN_MAX (__TCA_VLAN_MAX - 1) 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tc_ematch/tc_em_cmp.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __LINUX_TC_EM_CMP_H 3 | #define __LINUX_TC_EM_CMP_H 4 | 5 | #include 6 | #include 7 | 8 | struct tcf_em_cmp { 9 | __u32 val; 10 | __u32 mask; 11 | __u16 off; 12 | __u8 align:4; 13 | __u8 flags:4; 14 | __u8 layer:4; 15 | __u8 opnd:4; 16 | }; 17 | 18 | enum { 19 | TCF_EM_ALIGN_U8 = 1, 20 | TCF_EM_ALIGN_U16 = 2, 21 | TCF_EM_ALIGN_U32 = 4 22 | }; 23 | 24 | #define TCF_EM_CMP_TRANS 1 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tc_ematch/tc_em_meta.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __LINUX_TC_EM_META_H 3 | #define __LINUX_TC_EM_META_H 4 | 5 | #include 6 | #include 7 | 8 | enum { 9 | TCA_EM_META_UNSPEC, 10 | TCA_EM_META_HDR, 11 | TCA_EM_META_LVALUE, 12 | TCA_EM_META_RVALUE, 13 | __TCA_EM_META_MAX 14 | }; 15 | #define TCA_EM_META_MAX (__TCA_EM_META_MAX - 1) 16 | 17 | struct tcf_meta_val { 18 | __u16 kind; 19 | __u8 shift; 20 | __u8 op; 21 | }; 22 | 23 | #define TCF_META_TYPE_MASK (0xf << 12) 24 | #define TCF_META_TYPE(kind) (((kind) & TCF_META_TYPE_MASK) >> 12) 25 | #define TCF_META_ID_MASK 0x7ff 26 | #define TCF_META_ID(kind) ((kind) & TCF_META_ID_MASK) 27 | 28 | enum { 29 | TCF_META_TYPE_VAR, 30 | TCF_META_TYPE_INT, 31 | __TCF_META_TYPE_MAX 32 | }; 33 | #define TCF_META_TYPE_MAX (__TCF_META_TYPE_MAX - 1) 34 | 35 | enum { 36 | TCF_META_ID_VALUE, 37 | TCF_META_ID_RANDOM, 38 | TCF_META_ID_LOADAVG_0, 39 | TCF_META_ID_LOADAVG_1, 40 | TCF_META_ID_LOADAVG_2, 41 | TCF_META_ID_DEV, 42 | TCF_META_ID_PRIORITY, 43 | TCF_META_ID_PROTOCOL, 44 | TCF_META_ID_PKTTYPE, 45 | TCF_META_ID_PKTLEN, 46 | TCF_META_ID_DATALEN, 47 | TCF_META_ID_MACLEN, 48 | TCF_META_ID_NFMARK, 49 | TCF_META_ID_TCINDEX, 50 | TCF_META_ID_RTCLASSID, 51 | TCF_META_ID_RTIIF, 52 | TCF_META_ID_SK_FAMILY, 53 | TCF_META_ID_SK_STATE, 54 | TCF_META_ID_SK_REUSE, 55 | TCF_META_ID_SK_BOUND_IF, 56 | TCF_META_ID_SK_REFCNT, 57 | TCF_META_ID_SK_SHUTDOWN, 58 | TCF_META_ID_SK_PROTO, 59 | TCF_META_ID_SK_TYPE, 60 | TCF_META_ID_SK_RCVBUF, 61 | TCF_META_ID_SK_RMEM_ALLOC, 62 | TCF_META_ID_SK_WMEM_ALLOC, 63 | TCF_META_ID_SK_OMEM_ALLOC, 64 | TCF_META_ID_SK_WMEM_QUEUED, 65 | TCF_META_ID_SK_RCV_QLEN, 66 | TCF_META_ID_SK_SND_QLEN, 67 | TCF_META_ID_SK_ERR_QLEN, 68 | TCF_META_ID_SK_FORWARD_ALLOCS, 69 | TCF_META_ID_SK_SNDBUF, 70 | TCF_META_ID_SK_ALLOCS, 71 | __TCF_META_ID_SK_ROUTE_CAPS, /* unimplemented but in ABI already */ 72 | TCF_META_ID_SK_HASH, 73 | TCF_META_ID_SK_LINGERTIME, 74 | TCF_META_ID_SK_ACK_BACKLOG, 75 | TCF_META_ID_SK_MAX_ACK_BACKLOG, 76 | TCF_META_ID_SK_PRIO, 77 | TCF_META_ID_SK_RCVLOWAT, 78 | TCF_META_ID_SK_RCVTIMEO, 79 | TCF_META_ID_SK_SNDTIMEO, 80 | TCF_META_ID_SK_SENDMSG_OFF, 81 | TCF_META_ID_SK_WRITE_PENDING, 82 | TCF_META_ID_VLAN_TAG, 83 | TCF_META_ID_RXHASH, 84 | __TCF_META_ID_MAX 85 | }; 86 | #define TCF_META_ID_MAX (__TCF_META_ID_MAX - 1) 87 | 88 | struct tcf_meta_hdr { 89 | struct tcf_meta_val left; 90 | struct tcf_meta_val right; 91 | }; 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tc_ematch/tc_em_nbyte.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __LINUX_TC_EM_NBYTE_H 3 | #define __LINUX_TC_EM_NBYTE_H 4 | 5 | #include 6 | #include 7 | 8 | struct tcf_em_nbyte { 9 | __u16 off; 10 | __u16 len:12; 11 | __u8 layer:4; 12 | }; 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/tcp_metrics.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | /* tcp_metrics.h - TCP Metrics Interface */ 3 | 4 | #ifndef _LINUX_TCP_METRICS_H 5 | #define _LINUX_TCP_METRICS_H 6 | 7 | #include 8 | 9 | /* NETLINK_GENERIC related info 10 | */ 11 | #define TCP_METRICS_GENL_NAME "tcp_metrics" 12 | #define TCP_METRICS_GENL_VERSION 0x1 13 | 14 | enum tcp_metric_index { 15 | TCP_METRIC_RTT, /* in ms units */ 16 | TCP_METRIC_RTTVAR, /* in ms units */ 17 | TCP_METRIC_SSTHRESH, 18 | TCP_METRIC_CWND, 19 | TCP_METRIC_REORDERING, 20 | 21 | TCP_METRIC_RTT_US, /* in usec units */ 22 | TCP_METRIC_RTTVAR_US, /* in usec units */ 23 | 24 | /* Always last. */ 25 | __TCP_METRIC_MAX, 26 | }; 27 | 28 | #define TCP_METRIC_MAX (__TCP_METRIC_MAX - 1) 29 | 30 | enum { 31 | TCP_METRICS_ATTR_UNSPEC, 32 | TCP_METRICS_ATTR_ADDR_IPV4, /* u32 */ 33 | TCP_METRICS_ATTR_ADDR_IPV6, /* binary */ 34 | TCP_METRICS_ATTR_AGE, /* msecs */ 35 | TCP_METRICS_ATTR_TW_TSVAL, /* u32, raw, rcv tsval */ 36 | TCP_METRICS_ATTR_TW_TS_STAMP, /* s32, sec age */ 37 | TCP_METRICS_ATTR_VALS, /* nested +1, u32 */ 38 | TCP_METRICS_ATTR_FOPEN_MSS, /* u16 */ 39 | TCP_METRICS_ATTR_FOPEN_SYN_DROPS, /* u16, count of drops */ 40 | TCP_METRICS_ATTR_FOPEN_SYN_DROP_TS, /* msecs age */ 41 | TCP_METRICS_ATTR_FOPEN_COOKIE, /* binary */ 42 | TCP_METRICS_ATTR_SADDR_IPV4, /* u32 */ 43 | TCP_METRICS_ATTR_SADDR_IPV6, /* binary */ 44 | TCP_METRICS_ATTR_PAD, 45 | 46 | __TCP_METRICS_ATTR_MAX, 47 | }; 48 | 49 | #define TCP_METRICS_ATTR_MAX (__TCP_METRICS_ATTR_MAX - 1) 50 | 51 | enum { 52 | TCP_METRICS_CMD_UNSPEC, 53 | TCP_METRICS_CMD_GET, 54 | TCP_METRICS_CMD_DEL, 55 | 56 | __TCP_METRICS_CMD_MAX, 57 | }; 58 | 59 | #define TCP_METRICS_CMD_MAX (__TCP_METRICS_CMD_MAX - 1) 60 | 61 | #endif /* _LINUX_TCP_METRICS_H */ 62 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/types.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_TYPES_H 3 | #define _LINUX_TYPES_H 4 | 5 | #include 6 | 7 | #ifndef __ASSEMBLY__ 8 | 9 | #include 10 | 11 | 12 | /* 13 | * Below are truly Linux-specific types that should never collide with 14 | * any application/library that wants linux/types.h. 15 | */ 16 | 17 | #ifdef __CHECKER__ 18 | #define __bitwise__ __attribute__((bitwise)) 19 | #else 20 | #define __bitwise__ 21 | #endif 22 | #define __bitwise __bitwise__ 23 | 24 | typedef __u16 __bitwise __le16; 25 | typedef __u16 __bitwise __be16; 26 | typedef __u32 __bitwise __le32; 27 | typedef __u32 __bitwise __be32; 28 | typedef __u64 __bitwise __le64; 29 | typedef __u64 __bitwise __be64; 30 | 31 | typedef __u16 __bitwise __sum16; 32 | typedef __u32 __bitwise __wsum; 33 | 34 | /* 35 | * aligned_u64 should be used in defining kernel<->userspace ABIs to avoid 36 | * common 32/64-bit compat problems. 37 | * 64-bit values align to 4-byte boundaries on x86_32 (and possibly other 38 | * architectures) and to 8-byte boundaries on 64-bit architectures. The new 39 | * aligned_64 type enforces 8-byte alignment so that structs containing 40 | * aligned_64 values have the same alignment on 32-bit and 64-bit architectures. 41 | * No conversions are necessary between 32-bit user-space and a 64-bit kernel. 42 | */ 43 | #define __aligned_u64 __u64 __attribute__((aligned(8))) 44 | #define __aligned_be64 __be64 __attribute__((aligned(8))) 45 | #define __aligned_le64 __le64 __attribute__((aligned(8))) 46 | 47 | #endif /* __ASSEMBLY__ */ 48 | #endif /* _LINUX_TYPES_H */ 49 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/unix_diag.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __UNIX_DIAG_H__ 3 | #define __UNIX_DIAG_H__ 4 | 5 | #include 6 | 7 | struct unix_diag_req { 8 | __u8 sdiag_family; 9 | __u8 sdiag_protocol; 10 | __u16 pad; 11 | __u32 udiag_states; 12 | __u32 udiag_ino; 13 | __u32 udiag_show; 14 | __u32 udiag_cookie[2]; 15 | }; 16 | 17 | #define UDIAG_SHOW_NAME 0x00000001 /* show name (not path) */ 18 | #define UDIAG_SHOW_VFS 0x00000002 /* show VFS inode info */ 19 | #define UDIAG_SHOW_PEER 0x00000004 /* show peer socket info */ 20 | #define UDIAG_SHOW_ICONS 0x00000008 /* show pending connections */ 21 | #define UDIAG_SHOW_RQLEN 0x00000010 /* show skb receive queue len */ 22 | #define UDIAG_SHOW_MEMINFO 0x00000020 /* show memory info of a socket */ 23 | 24 | struct unix_diag_msg { 25 | __u8 udiag_family; 26 | __u8 udiag_type; 27 | __u8 udiag_state; 28 | __u8 pad; 29 | 30 | __u32 udiag_ino; 31 | __u32 udiag_cookie[2]; 32 | }; 33 | 34 | enum { 35 | /* UNIX_DIAG_NONE, standard nl API requires this attribute! */ 36 | UNIX_DIAG_NAME, 37 | UNIX_DIAG_VFS, 38 | UNIX_DIAG_PEER, 39 | UNIX_DIAG_ICONS, 40 | UNIX_DIAG_RQLEN, 41 | UNIX_DIAG_MEMINFO, 42 | UNIX_DIAG_SHUTDOWN, 43 | 44 | __UNIX_DIAG_MAX, 45 | }; 46 | 47 | #define UNIX_DIAG_MAX (__UNIX_DIAG_MAX - 1) 48 | 49 | struct unix_diag_vfs { 50 | __u32 udiag_vfs_ino; 51 | __u32 udiag_vfs_dev; 52 | }; 53 | 54 | struct unix_diag_rqlen { 55 | __u32 udiag_rqueue; 56 | __u32 udiag_wqueue; 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/uapi/linux/veth.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __NET_VETH_H_ 3 | #define __NET_VETH_H_ 4 | 5 | enum { 6 | VETH_INFO_UNSPEC, 7 | VETH_INFO_PEER, 8 | 9 | __VETH_INFO_MAX 10 | #define VETH_INFO_MAX (__VETH_INFO_MAX - 1) 11 | }; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/xt-internal.h: -------------------------------------------------------------------------------- 1 | #ifndef _XTABLES_INTERNAL_H 2 | #define _XTABLES_INTERNAL_H 1 3 | 4 | #ifndef XT_LIB_DIR 5 | # define XT_LIB_DIR "/lib/xtables" 6 | #endif 7 | 8 | /* protocol family dependent informations */ 9 | struct afinfo { 10 | /* protocol family */ 11 | int family; 12 | 13 | /* prefix of library name (ex "libipt_" */ 14 | char *libprefix; 15 | 16 | /* used by setsockopt (ex IPPROTO_IP */ 17 | int ipproto; 18 | 19 | /* kernel module (ex "ip_tables" */ 20 | char *kmod; 21 | 22 | /* optname to check revision support of match */ 23 | int so_rev_match; 24 | 25 | /* optname to check revision support of match */ 26 | int so_rev_target; 27 | }; 28 | 29 | enum xt_tryload { 30 | DONT_LOAD, 31 | DURING_LOAD, 32 | TRY_LOAD, 33 | LOAD_MUST_SUCCEED 34 | }; 35 | 36 | struct xtables_rule_match { 37 | struct xtables_rule_match *next; 38 | struct xtables_match *match; 39 | /* Multiple matches of the same type: the ones before 40 | the current one are completed from parsing point of view */ 41 | unsigned int completed; 42 | }; 43 | 44 | extern char *lib_dir; 45 | 46 | extern void *fw_calloc(size_t count, size_t size); 47 | extern void *fw_malloc(size_t size); 48 | 49 | extern const char *modprobe_program; 50 | extern int xtables_insmod(const char *modname, const char *modprobe, int quiet); 51 | extern int load_xtables_ko(const char *modprobe, int quiet); 52 | 53 | /* This is decleared in ip[6]tables.c */ 54 | extern struct afinfo afinfo; 55 | 56 | /* Keeping track of external matches and targets: linked lists. */ 57 | extern struct xtables_match *xtables_matches; 58 | extern struct xtables_target *xtables_targets; 59 | 60 | extern struct xtables_match *find_match(const char *name, enum xt_tryload, 61 | struct xtables_rule_match **match); 62 | extern struct xtables_target *find_target(const char *name, enum xt_tryload); 63 | 64 | extern void _init(void); 65 | 66 | #endif /* _XTABLES_INTERNAL_H */ 67 | -------------------------------------------------------------------------------- /app/src/main/cpp/ip.c: -------------------------------------------------------------------------------- 1 | // 2 | // Created by liuqiang on 2021/7/9. 3 | // 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "SNAPSHOT.h" 16 | #include "utils.h" 17 | #include "ip_common.h" 18 | #include "namespace.h" 19 | #include "color.h" 20 | 21 | int preferred_family = AF_UNSPEC; 22 | int human_readable; 23 | int use_iec; 24 | int show_stats; 25 | int show_details; 26 | int oneline; 27 | int brief; 28 | int json; 29 | int timestamp; 30 | const char *_SL_; 31 | int force; 32 | int max_flush_loops = 10; 33 | int batch_mode; 34 | bool do_all; 35 | 36 | struct rtnl_handle rth = {.fd = -1}; 37 | 38 | 39 | int main() { 40 | 41 | _SL_ = oneline ? "\\" : "\n"; 42 | 43 | 44 | if (rtnl_open(&rth, 0) < 0) 45 | exit(1); 46 | 47 | char *arr[] = { 48 | "wlan0" 49 | }; 50 | 51 | do_ipaddr(1, arr); 52 | 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/cpp/ip.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by liuqiang on 2021/7/9. 3 | // 4 | 5 | #ifndef TESTIPROUTE2_IP_H 6 | #define TESTIPROUTE2_IP_H 7 | 8 | int main(); 9 | 10 | #endif //TESTIPROUTE2_IP_H 11 | -------------------------------------------------------------------------------- /app/src/main/cpp/iplink_xdp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * iplink_xdp.c XDP program loader 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 7 | * 2 of the License, or (at your option) any later version. 8 | * 9 | * Authors: Daniel Borkmann 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include "json_print.h" 18 | #include "xdp.h" 19 | #include "bpf_util.h" 20 | 21 | extern int force; 22 | 23 | struct xdp_req { 24 | struct iplink_req *req; 25 | __u32 flags; 26 | }; 27 | 28 | static void xdp_ebpf_cb(void *raw, int fd, const char *annotation) 29 | { 30 | struct xdp_req *xdp = raw; 31 | struct iplink_req *req = xdp->req; 32 | struct rtattr *xdp_attr; 33 | 34 | xdp_attr = addattr_nest(&req->n, sizeof(*req), IFLA_XDP); 35 | addattr32(&req->n, sizeof(*req), IFLA_XDP_FD, fd); 36 | if (xdp->flags) 37 | addattr32(&req->n, sizeof(*req), IFLA_XDP_FLAGS, xdp->flags); 38 | addattr_nest_end(&req->n, xdp_attr); 39 | } 40 | 41 | static const struct bpf_cfg_ops bpf_cb_ops = { 42 | .ebpf_cb = xdp_ebpf_cb, 43 | }; 44 | 45 | static int xdp_delete(struct xdp_req *xdp) 46 | { 47 | xdp_ebpf_cb(xdp, -1, NULL); 48 | return 0; 49 | } 50 | 51 | int xdp_parse(int *argc, char ***argv, struct iplink_req *req, bool generic, 52 | bool drv, bool offload) 53 | { 54 | struct bpf_cfg_in cfg = { 55 | .argc = *argc, 56 | .argv = *argv, 57 | }; 58 | struct xdp_req xdp = { 59 | .req = req, 60 | }; 61 | 62 | if (!force) 63 | xdp.flags |= XDP_FLAGS_UPDATE_IF_NOEXIST; 64 | if (generic) 65 | xdp.flags |= XDP_FLAGS_SKB_MODE; 66 | if (drv) 67 | xdp.flags |= XDP_FLAGS_DRV_MODE; 68 | if (offload) 69 | xdp.flags |= XDP_FLAGS_HW_MODE; 70 | 71 | if (*argc == 1) { 72 | if (strcmp(**argv, "none") == 0 || 73 | strcmp(**argv, "off") == 0) 74 | return xdp_delete(&xdp); 75 | } 76 | 77 | if (bpf_parse_common(BPF_PROG_TYPE_XDP, &cfg, &bpf_cb_ops, &xdp)) 78 | return -1; 79 | 80 | *argc = cfg.argc; 81 | *argv = cfg.argv; 82 | return 0; 83 | } 84 | 85 | static void xdp_dump_json(struct rtattr *tb[IFLA_XDP_MAX + 1]) 86 | { 87 | __u32 prog_id = 0; 88 | __u8 mode; 89 | 90 | mode = rta_getattr_u8(tb[IFLA_XDP_ATTACHED]); 91 | if (tb[IFLA_XDP_PROG_ID]) 92 | prog_id = rta_getattr_u32(tb[IFLA_XDP_PROG_ID]); 93 | 94 | open_json_object("xdp"); 95 | print_uint(PRINT_JSON, "mode", NULL, mode); 96 | if (prog_id) 97 | bpf_dump_prog_info(NULL, prog_id); 98 | close_json_object(); 99 | } 100 | 101 | void xdp_dump(FILE *fp, struct rtattr *xdp, bool link, bool details) 102 | { 103 | struct rtattr *tb[IFLA_XDP_MAX + 1]; 104 | __u32 prog_id = 0; 105 | __u8 mode; 106 | 107 | parse_rtattr_nested(tb, IFLA_XDP_MAX, xdp); 108 | 109 | if (!tb[IFLA_XDP_ATTACHED]) 110 | return; 111 | 112 | mode = rta_getattr_u8(tb[IFLA_XDP_ATTACHED]); 113 | if (mode == XDP_ATTACHED_NONE) 114 | return; 115 | else if (is_json_context()) 116 | return details ? (void)0 : xdp_dump_json(tb); 117 | else if (details && link) 118 | fprintf(fp, "%s prog/xdp", _SL_); 119 | else if (mode == XDP_ATTACHED_DRV) 120 | fprintf(fp, "xdp"); 121 | else if (mode == XDP_ATTACHED_SKB) 122 | fprintf(fp, "xdpgeneric"); 123 | else if (mode == XDP_ATTACHED_HW) 124 | fprintf(fp, "xdpoffload"); 125 | else 126 | fprintf(fp, "xdp[%u]", mode); 127 | 128 | if (tb[IFLA_XDP_PROG_ID]) 129 | prog_id = rta_getattr_u32(tb[IFLA_XDP_PROG_ID]); 130 | if (!details) { 131 | if (prog_id && !link) 132 | fprintf(fp, "/id:%u", prog_id); 133 | fprintf(fp, " "); 134 | return; 135 | } 136 | 137 | if (prog_id) { 138 | fprintf(fp, " "); 139 | bpf_dump_prog_info(fp, prog_id); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /app/src/main/cpp/iplink_xstats.c: -------------------------------------------------------------------------------- 1 | /* 2 | * iplink_stats.c Extended statistics commands 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 7 | * 2 of the License, or (at your option) any later version. 8 | * 9 | * Authors: Nikolay Aleksandrov 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "utils.h" 19 | #include "ip_common.h" 20 | 21 | static void print_explain(FILE *f) 22 | { 23 | fprintf(f, "Usage: ... xstats type TYPE [ ARGS ]\n"); 24 | } 25 | 26 | int iplink_ifla_xstats(int argc, char **argv) 27 | { 28 | struct link_util *lu = NULL; 29 | __u32 filt_mask; 30 | 31 | if (!argc) { 32 | fprintf(stderr, "xstats: missing argument\n"); 33 | return -1; 34 | } 35 | 36 | if (matches(*argv, "type") == 0) { 37 | NEXT_ARG(); 38 | lu = get_link_kind(*argv); 39 | if (!lu) 40 | invarg("invalid type", *argv); 41 | } else if (matches(*argv, "help") == 0) { 42 | print_explain(stdout); 43 | return 0; 44 | } else { 45 | invarg("unknown argument", *argv); 46 | } 47 | 48 | if (!lu) { 49 | print_explain(stderr); 50 | return -1; 51 | } 52 | 53 | if (!lu->print_ifla_xstats) { 54 | fprintf(stderr, "xstats: link type %s doesn't support xstats\n", 55 | lu->id); 56 | return -1; 57 | } 58 | 59 | if (lu->parse_ifla_xstats && 60 | lu->parse_ifla_xstats(lu, argc-1, argv+1)) 61 | return -1; 62 | 63 | if (strstr(lu->id, "_slave")) 64 | filt_mask = IFLA_STATS_FILTER_BIT(IFLA_STATS_LINK_XSTATS_SLAVE); 65 | else 66 | filt_mask = IFLA_STATS_FILTER_BIT(IFLA_STATS_LINK_XSTATS); 67 | 68 | if (rtnl_wilddump_stats_req_filter(&rth, AF_UNSPEC, 69 | RTM_GETSTATS, 70 | filt_mask) < 0) { 71 | perror("Cannont send dump request"); 72 | return -1; 73 | } 74 | 75 | if (rtnl_dump_filter(&rth, lu->print_ifla_xstats, stdout) < 0) { 76 | fprintf(stderr, "Dump terminated\n"); 77 | return -1; 78 | } 79 | 80 | return 0; 81 | } 82 | -------------------------------------------------------------------------------- /app/src/main/cpp/lib/color.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "color.h" 10 | 11 | enum color { 12 | C_RED, 13 | C_GREEN, 14 | C_YELLOW, 15 | C_BLUE, 16 | C_MAGENTA, 17 | C_CYAN, 18 | C_WHITE, 19 | C_BOLD_RED, 20 | C_BOLD_GREEN, 21 | C_BOLD_YELLOW, 22 | C_BOLD_BLUE, 23 | C_BOLD_MAGENTA, 24 | C_BOLD_CYAN, 25 | C_BOLD_WHITE, 26 | C_CLEAR 27 | }; 28 | 29 | static const char *const color_codes[] = { 30 | "\e[31m", 31 | "\e[32m", 32 | "\e[33m", 33 | "\e[34m", 34 | "\e[35m", 35 | "\e[36m", 36 | "\e[37m", 37 | "\e[1;31m", 38 | "\e[1;32m", 39 | "\e[1;33m", 40 | "\e[1;34m", 41 | "\e[1;35m", 42 | "\e[1;36m", 43 | "\e[1;37m", 44 | "\e[0m", 45 | NULL, 46 | }; 47 | 48 | /* light background */ 49 | static enum color attr_colors_light[] = { 50 | C_CYAN, 51 | C_YELLOW, 52 | C_MAGENTA, 53 | C_BLUE, 54 | C_GREEN, 55 | C_RED, 56 | C_CLEAR, 57 | }; 58 | 59 | /* dark background */ 60 | static enum color attr_colors_dark[] = { 61 | C_BOLD_CYAN, 62 | C_BOLD_YELLOW, 63 | C_BOLD_MAGENTA, 64 | C_BOLD_BLUE, 65 | C_BOLD_GREEN, 66 | C_BOLD_RED, 67 | C_CLEAR 68 | }; 69 | 70 | static int is_dark_bg; 71 | static int color_is_enabled; 72 | 73 | void enable_color(void) { 74 | color_is_enabled = 1; 75 | set_color_palette(); 76 | } 77 | 78 | void set_color_palette(void) { 79 | char *p = getenv("COLORFGBG"); 80 | 81 | /* 82 | * COLORFGBG environment variable usually contains either two or three 83 | * values separated by semicolons; we want the last value in either case. 84 | * If this value is 0-6 or 8, background is dark. 85 | */ 86 | if (p && (p = strrchr(p, ';')) != NULL 87 | && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8') 88 | && p[2] == '\0') 89 | is_dark_bg = 1; 90 | } 91 | 92 | void check_if_color_enabled(void) { 93 | if (color_is_enabled) { 94 | fprintf(stderr, "Option \"-json\" conflicts with \"-color\".\n"); 95 | exit(1); 96 | } 97 | } 98 | //fmt format ==> 格式化的字符串的那个占位符 %d %s 99 | int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...) { 100 | int ret = 0; 101 | va_list args; 102 | 103 | va_start(args, fmt); 104 | 105 | if (!color_is_enabled || attr == COLOR_NONE) { 106 | //C 库函数 int vfprintf(FILE *stream, const char *format, va_list arg) 使用参数列表发送格式化输出到流 stream 中。 107 | ret = vfprintf(fp, fmt, args); 108 | __android_log_vprint(ANDROID_LOG_INFO, "Q_M", fmt, args); 109 | goto end; 110 | } 111 | 112 | ret += fprintf(fp, "%s", color_codes[is_dark_bg ? 113 | attr_colors_dark[attr] : attr_colors_light[attr]]); 114 | 115 | ret += vfprintf(fp, fmt, args); 116 | ret += fprintf(fp, "%s", color_codes[C_CLEAR]); 117 | 118 | end: 119 | va_end(args); 120 | return ret; 121 | } 122 | 123 | enum color_attr ifa_family_color(__u8 ifa_family) { 124 | switch (ifa_family) { 125 | case AF_INET: 126 | return COLOR_INET; 127 | case AF_INET6: 128 | return COLOR_INET6; 129 | default: 130 | return COLOR_NONE; 131 | } 132 | } 133 | 134 | enum color_attr oper_state_color(__u8 state) { 135 | switch (state) { 136 | case IF_OPER_UP: 137 | return COLOR_OPERSTATE_UP; 138 | case IF_OPER_DOWN: 139 | return COLOR_OPERSTATE_DOWN; 140 | default: 141 | return COLOR_NONE; 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /app/src/main/cpp/lib/coverity_model.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Coverity Scan model 3 | * 4 | * This is a modeling file for Coverity Scan. Modeling helps to avoid false 5 | * positives. 6 | * 7 | * - A model file can't import any header files. 8 | * - Therefore only some built-in primitives like int, char and void are 9 | * available but not wchar_t, NULL etc. 10 | * - Modeling doesn't need full structs and typedefs. Rudimentary structs 11 | * and similar types are sufficient. 12 | * - An uninitialized local pointer is not an error. It signifies that the 13 | * variable could be either NULL or have some data. 14 | * 15 | * Coverity Scan doesn't pick up modifications automatically. The model file 16 | * must be uploaded by an admin. 17 | */ 18 | -------------------------------------------------------------------------------- /app/src/main/cpp/lib/dnet_ntop.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "utils.h" 7 | 8 | static __inline__ u_int16_t dn_ntohs(u_int16_t addr) 9 | { 10 | union { 11 | u_int8_t byte[2]; 12 | u_int16_t word; 13 | } u; 14 | 15 | u.word = addr; 16 | return ((u_int16_t)u.byte[0]) | (((u_int16_t)u.byte[1]) << 8); 17 | } 18 | 19 | static __inline__ int do_digit(char *str, u_int16_t *addr, u_int16_t scale, size_t *pos, size_t len, int *started) 20 | { 21 | u_int16_t tmp = *addr / scale; 22 | 23 | if (*pos == len) 24 | return 1; 25 | 26 | if (((tmp) > 0) || *started || (scale == 1)) { 27 | *str = tmp + '0'; 28 | *started = 1; 29 | (*pos)++; 30 | *addr -= (tmp * scale); 31 | } 32 | 33 | return 0; 34 | } 35 | 36 | 37 | static const char *dnet_ntop1(const struct dn_naddr *dna, char *str, size_t len) 38 | { 39 | u_int16_t addr, area; 40 | size_t pos = 0; 41 | int started = 0; 42 | 43 | memcpy(&addr, dna->a_addr, sizeof(addr)); 44 | addr = dn_ntohs(addr); 45 | area = addr >> 10; 46 | 47 | if (dna->a_len != 2) 48 | return NULL; 49 | 50 | addr &= 0x03ff; 51 | 52 | if (len == 0) 53 | return str; 54 | 55 | if (do_digit(str + pos, &area, 10, &pos, len, &started)) 56 | return str; 57 | 58 | if (do_digit(str + pos, &area, 1, &pos, len, &started)) 59 | return str; 60 | 61 | if (pos == len) 62 | return str; 63 | 64 | *(str + pos) = '.'; 65 | pos++; 66 | started = 0; 67 | 68 | if (do_digit(str + pos, &addr, 1000, &pos, len, &started)) 69 | return str; 70 | 71 | if (do_digit(str + pos, &addr, 100, &pos, len, &started)) 72 | return str; 73 | 74 | if (do_digit(str + pos, &addr, 10, &pos, len, &started)) 75 | return str; 76 | 77 | if (do_digit(str + pos, &addr, 1, &pos, len, &started)) 78 | return str; 79 | 80 | if (pos == len) 81 | return str; 82 | 83 | *(str + pos) = 0; 84 | 85 | return str; 86 | } 87 | 88 | 89 | const char *dnet_ntop(int af, const void *addr, char *str, size_t len) 90 | { 91 | switch(af) { 92 | case AF_DECnet: 93 | errno = 0; 94 | return dnet_ntop1((struct dn_naddr *)addr, str, len); 95 | default: 96 | errno = EAFNOSUPPORT; 97 | } 98 | 99 | return NULL; 100 | } 101 | -------------------------------------------------------------------------------- /app/src/main/cpp/lib/dnet_pton.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "utils.h" 7 | 8 | static __inline__ u_int16_t dn_htons(u_int16_t addr) 9 | { 10 | union { 11 | u_int8_t byte[2]; 12 | u_int16_t word; 13 | } u; 14 | 15 | u.word = addr; 16 | return ((u_int16_t)u.byte[0]) | (((u_int16_t)u.byte[1]) << 8); 17 | } 18 | 19 | 20 | static int dnet_num(const char *src, u_int16_t * dst) 21 | { 22 | int rv = 0; 23 | int tmp; 24 | *dst = 0; 25 | 26 | while ((tmp = *src++) != 0) { 27 | tmp -= '0'; 28 | if ((tmp < 0) || (tmp > 9)) 29 | return rv; 30 | 31 | rv++; 32 | (*dst) *= 10; 33 | (*dst) += tmp; 34 | } 35 | 36 | return rv; 37 | } 38 | 39 | static int dnet_pton1(const char *src, struct dn_naddr *dna) 40 | { 41 | u_int16_t addr; 42 | u_int16_t area = 0; 43 | u_int16_t node = 0; 44 | int pos; 45 | 46 | pos = dnet_num(src, &area); 47 | if ((pos == 0) || (area > 63) || (*(src + pos) != '.')) 48 | return 0; 49 | pos = dnet_num(src + pos + 1, &node); 50 | if ((pos == 0) || (node > 1023)) 51 | return 0; 52 | dna->a_len = 2; 53 | addr = dn_htons((area << 10) | node); 54 | memcpy(dna->a_addr, &addr, sizeof(addr)); 55 | 56 | return 1; 57 | } 58 | 59 | int dnet_pton(int af, const char *src, void *addr) 60 | { 61 | int err; 62 | 63 | switch (af) { 64 | case AF_DECnet: 65 | errno = 0; 66 | err = dnet_pton1(src, (struct dn_naddr *)addr); 67 | break; 68 | default: 69 | errno = EAFNOSUPPORT; 70 | err = -1; 71 | } 72 | 73 | return err; 74 | } 75 | -------------------------------------------------------------------------------- /app/src/main/cpp/lib/exec.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "utils.h" 7 | 8 | int cmd_exec(const char *cmd, char **argv, bool do_fork) 9 | { 10 | fflush(stdout); 11 | if (do_fork) { 12 | int status; 13 | pid_t pid; 14 | 15 | pid = fork(); 16 | if (pid < 0) { 17 | perror("fork"); 18 | exit(1); 19 | } 20 | 21 | if (pid != 0) { 22 | /* Parent */ 23 | if (waitpid(pid, &status, 0) < 0) { 24 | perror("waitpid"); 25 | exit(1); 26 | } 27 | 28 | if (WIFEXITED(status)) { 29 | return WEXITSTATUS(status); 30 | } 31 | 32 | exit(1); 33 | } 34 | } 35 | 36 | if (execvp(cmd, argv) < 0) 37 | fprintf(stderr, "exec of \"%s\" failed: %s\n", 38 | cmd, strerror(errno)); 39 | _exit(1); 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/cpp/lib/fs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fs.c filesystem APIs 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 7 | * 2 of the License, or (at your option) any later version. 8 | * 9 | * Authors: David Ahern 10 | * 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "utils.h" 27 | 28 | #define CGROUP2_FS_NAME "cgroup2" 29 | 30 | /* if not already mounted cgroup2 is mounted here for iproute2's use */ 31 | #define MNT_CGRP2_PATH "/var/run/cgroup2" 32 | 33 | /* return mount path of first occurrence of given fstype */ 34 | static char *find_fs_mount(const char *fs_to_find) 35 | { 36 | char path[4096]; 37 | char fstype[128]; /* max length of any filesystem name */ 38 | char *mnt = NULL; 39 | FILE *fp; 40 | 41 | fp = fopen("/proc/mounts", "r"); 42 | if (!fp) { 43 | fprintf(stderr, 44 | "Failed to open mounts file: %s\n", strerror(errno)); 45 | return NULL; 46 | } 47 | 48 | while (fscanf(fp, "%*s %4095s %127s %*s %*d %*d\n", 49 | path, fstype) == 2) { 50 | if (strcmp(fstype, fs_to_find) == 0) { 51 | mnt = strdup(path); 52 | break; 53 | } 54 | } 55 | 56 | fclose(fp); 57 | 58 | return mnt; 59 | } 60 | 61 | /* caller needs to free string returned */ 62 | char *find_cgroup2_mount(void) 63 | { 64 | char *mnt = find_fs_mount(CGROUP2_FS_NAME); 65 | 66 | if (mnt) 67 | return mnt; 68 | 69 | mnt = strdup(MNT_CGRP2_PATH); 70 | if (!mnt) { 71 | fprintf(stderr, "Failed to allocate memory for cgroup2 path\n"); 72 | return NULL; 73 | 74 | } 75 | 76 | if (make_path(mnt, 0755)) { 77 | fprintf(stderr, "Failed to setup vrf cgroup2 directory\n"); 78 | free(mnt); 79 | return NULL; 80 | } 81 | 82 | if (mount("none", mnt, CGROUP2_FS_NAME, 0, NULL)) { 83 | /* EBUSY means already mounted */ 84 | if (errno == EBUSY) 85 | goto out; 86 | 87 | if (errno == ENODEV) { 88 | fprintf(stderr, 89 | "Failed to mount cgroup2. Are CGROUPS enabled in your kernel?\n"); 90 | } else { 91 | fprintf(stderr, 92 | "Failed to mount cgroup2: %s\n", 93 | strerror(errno)); 94 | } 95 | free(mnt); 96 | return NULL; 97 | } 98 | out: 99 | return mnt; 100 | } 101 | 102 | int make_path(const char *path, mode_t mode) 103 | { 104 | char *dir, *delim; 105 | int rc = -1; 106 | 107 | delim = dir = strdup(path); 108 | if (dir == NULL) { 109 | fprintf(stderr, "strdup failed copying path"); 110 | return -1; 111 | } 112 | 113 | /* skip '/' -- it had better exist */ 114 | if (*delim == '/') 115 | delim++; 116 | 117 | while (1) { 118 | delim = strchr(delim, '/'); 119 | if (delim) 120 | *delim = '\0'; 121 | 122 | rc = mkdir(dir, mode); 123 | if (mkdir(dir, mode) != 0 && errno != EEXIST) { 124 | fprintf(stderr, "mkdir failed for %s: %s\n", 125 | dir, strerror(errno)); 126 | goto out; 127 | } 128 | 129 | if (delim == NULL) 130 | break; 131 | 132 | *delim = '/'; 133 | delim++; 134 | if (*delim == '\0') 135 | break; 136 | } 137 | rc = 0; 138 | out: 139 | free(dir); 140 | 141 | return rc; 142 | } 143 | 144 | int get_command_name(const char *pid, char *comm, size_t len) 145 | { 146 | char path[PATH_MAX]; 147 | char line[128]; 148 | FILE *fp; 149 | 150 | if (snprintf(path, sizeof(path), 151 | "/proc/%s/status", pid) >= sizeof(path)) { 152 | return -1; 153 | } 154 | 155 | fp = fopen(path, "r"); 156 | if (!fp) 157 | return -1; 158 | 159 | comm[0] = '\0'; 160 | while (fgets(line, sizeof(line), fp)) { 161 | char *nl, *name; 162 | 163 | name = strstr(line, "Name:"); 164 | if (!name) 165 | continue; 166 | 167 | name += 5; 168 | while (isspace(*name)) 169 | name++; 170 | 171 | nl = strchr(name, '\n'); 172 | if (nl) 173 | *nl = '\0'; 174 | 175 | strlcpy(comm, name, len); 176 | break; 177 | } 178 | 179 | fclose(fp); 180 | 181 | return 0; 182 | } 183 | -------------------------------------------------------------------------------- /app/src/main/cpp/lib/inet_proto.c: -------------------------------------------------------------------------------- 1 | /* 2 | * inet_proto.c 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 7 | * 2 of the License, or (at your option) any later version. 8 | * 9 | * Authors: Alexey Kuznetsov, 10 | * 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "rt_names.h" 24 | #include "utils.h" 25 | 26 | const char *inet_proto_n2a(int proto, char *buf, int len) 27 | { 28 | static char *ncache; 29 | static int icache = -1; 30 | struct protoent *pe; 31 | 32 | if (proto == icache) 33 | return ncache; 34 | 35 | pe = getprotobynumber(proto); 36 | if (pe) { 37 | if (icache != -1) 38 | free(ncache); 39 | icache = proto; 40 | ncache = strdup(pe->p_name); 41 | strlcpy(buf, pe->p_name, len); 42 | return buf; 43 | } 44 | snprintf(buf, len, "ipproto-%d", proto); 45 | return buf; 46 | } 47 | 48 | int inet_proto_a2n(const char *buf) 49 | { 50 | static char *ncache; 51 | static int icache = -1; 52 | struct protoent *pe; 53 | __u8 ret; 54 | 55 | if (icache != -1 && strcmp(ncache, buf) == 0) 56 | return icache; 57 | 58 | if (!get_u8(&ret, buf, 10)) 59 | return ret; 60 | 61 | pe = getprotobyname(buf); 62 | if (pe) { 63 | if (icache != -1) 64 | free(ncache); 65 | icache = pe->p_proto; 66 | ncache = strdup(pe->p_name); 67 | return pe->p_proto; 68 | } 69 | return -1; 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/cpp/lib/ipx_ntop.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "utils.h" 7 | 8 | static __inline__ int do_digit(char *str, u_int32_t addr, u_int32_t scale, size_t *pos, size_t len) 9 | { 10 | u_int32_t tmp = addr >> (scale * 4); 11 | 12 | if (*pos == len) 13 | return 1; 14 | 15 | tmp &= 0x0f; 16 | if (tmp > 9) 17 | *str = tmp + 'A' - 10; 18 | else 19 | *str = tmp + '0'; 20 | (*pos)++; 21 | 22 | return 0; 23 | } 24 | 25 | static const char *ipx_ntop1(const struct ipx_addr *addr, char *str, size_t len) 26 | { 27 | int i; 28 | size_t pos = 0; 29 | 30 | if (len == 0) 31 | return str; 32 | 33 | for(i = 7; i >= 0; i--) 34 | if (do_digit(str + pos, ntohl(addr->ipx_net), i, &pos, len)) 35 | return str; 36 | 37 | if (pos == len) 38 | return str; 39 | 40 | *(str + pos) = '.'; 41 | pos++; 42 | 43 | for(i = 0; i < 6; i++) { 44 | if (do_digit(str + pos, addr->ipx_node[i], 1, &pos, len)) 45 | return str; 46 | if (do_digit(str + pos, addr->ipx_node[i], 0, &pos, len)) 47 | return str; 48 | } 49 | 50 | if (pos == len) 51 | return str; 52 | 53 | *(str + pos) = 0; 54 | 55 | return str; 56 | } 57 | 58 | 59 | const char *ipx_ntop(int af, const void *addr, char *str, size_t len) 60 | { 61 | switch(af) { 62 | case AF_IPX: 63 | errno = 0; 64 | return ipx_ntop1((struct ipx_addr *)addr, str, len); 65 | default: 66 | errno = EAFNOSUPPORT; 67 | } 68 | 69 | return NULL; 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/cpp/lib/ipx_pton.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "utils.h" 8 | 9 | static int ipx_getnet(u_int32_t *net, const char *str) 10 | { 11 | int i; 12 | u_int32_t tmp; 13 | 14 | for(i = 0; *str && (i < 8); i++) { 15 | 16 | if ((tmp = get_hex(*str)) == -1) { 17 | if (*str == '.') 18 | return 0; 19 | else 20 | return -1; 21 | } 22 | 23 | str++; 24 | (*net) <<= 4; 25 | (*net) |= tmp; 26 | } 27 | 28 | if (*str == 0) 29 | return 0; 30 | 31 | return -1; 32 | } 33 | 34 | static int ipx_getnode(u_int8_t *node, const char *str) 35 | { 36 | int i; 37 | u_int32_t tmp; 38 | 39 | for(i = 0; i < 6; i++) { 40 | if ((tmp = get_hex(*str++)) == -1) 41 | return -1; 42 | node[i] = (u_int8_t)tmp; 43 | node[i] <<= 4; 44 | if ((tmp = get_hex(*str++)) == -1) 45 | return -1; 46 | node[i] |= (u_int8_t)tmp; 47 | if (*str == ':') 48 | str++; 49 | } 50 | 51 | return 0; 52 | } 53 | 54 | static int ipx_pton1(const char *src, struct ipx_addr *addr) 55 | { 56 | char *sep = (char *)src; 57 | int no_node = 0; 58 | 59 | memset(addr, 0, sizeof(struct ipx_addr)); 60 | 61 | while(*sep && (*sep != '.')) 62 | sep++; 63 | 64 | if (*sep != '.') 65 | no_node = 1; 66 | 67 | if (ipx_getnet(&addr->ipx_net, src)) 68 | return 0; 69 | 70 | addr->ipx_net = htonl(addr->ipx_net); 71 | 72 | if (no_node) 73 | return 1; 74 | 75 | if (ipx_getnode(addr->ipx_node, sep + 1)) 76 | return 0; 77 | 78 | return 1; 79 | } 80 | 81 | int ipx_pton(int af, const char *src, void *addr) 82 | { 83 | int err; 84 | 85 | switch (af) { 86 | case AF_IPX: 87 | errno = 0; 88 | err = ipx_pton1(src, (struct ipx_addr *)addr); 89 | break; 90 | default: 91 | errno = EAFNOSUPPORT; 92 | err = -1; 93 | } 94 | 95 | return err; 96 | } 97 | -------------------------------------------------------------------------------- /app/src/main/cpp/lib/libgenl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libgenl.c GENL library 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include "libgenl.h" 11 | 12 | static int genl_parse_getfamily(struct nlmsghdr *nlh) 13 | { 14 | struct rtattr *tb[CTRL_ATTR_MAX + 1]; 15 | struct genlmsghdr *ghdr = NLMSG_DATA(nlh); 16 | int len = nlh->nlmsg_len; 17 | struct rtattr *attrs; 18 | 19 | if (nlh->nlmsg_type != GENL_ID_CTRL) { 20 | fprintf(stderr, "Not a controller message, nlmsg_len=%d " 21 | "nlmsg_type=0x%x\n", nlh->nlmsg_len, nlh->nlmsg_type); 22 | return -1; 23 | } 24 | 25 | len -= NLMSG_LENGTH(GENL_HDRLEN); 26 | 27 | if (len < 0) { 28 | fprintf(stderr, "wrong controller message len %d\n", len); 29 | return -1; 30 | } 31 | 32 | if (ghdr->cmd != CTRL_CMD_NEWFAMILY) { 33 | fprintf(stderr, "Unknown controller command %d\n", ghdr->cmd); 34 | return -1; 35 | } 36 | 37 | attrs = (struct rtattr *) ((char *) ghdr + GENL_HDRLEN); 38 | parse_rtattr(tb, CTRL_ATTR_MAX, attrs, len); 39 | 40 | if (tb[CTRL_ATTR_FAMILY_ID] == NULL) { 41 | fprintf(stderr, "Missing family id TLV\n"); 42 | return -1; 43 | } 44 | 45 | return rta_getattr_u16(tb[CTRL_ATTR_FAMILY_ID]); 46 | } 47 | 48 | int genl_resolve_family(struct rtnl_handle *grth, const char *family) 49 | { 50 | GENL_REQUEST(req, 1024, GENL_ID_CTRL, 0, 0, CTRL_CMD_GETFAMILY, 51 | NLM_F_REQUEST); 52 | 53 | addattr_l(&req.n, sizeof(req), CTRL_ATTR_FAMILY_NAME, 54 | family, strlen(family) + 1); 55 | 56 | if (rtnl_talk(grth, &req.n, &req.n, sizeof(req)) < 0) { 57 | fprintf(stderr, "Error talking to the kernel\n"); 58 | return -2; 59 | } 60 | 61 | return genl_parse_getfamily(&req.n); 62 | } 63 | 64 | int genl_init_handle(struct rtnl_handle *grth, const char *family, 65 | int *genl_family) 66 | { 67 | if (*genl_family >= 0) 68 | return 0; 69 | 70 | if (rtnl_open_byproto(grth, 0, NETLINK_GENERIC) < 0) { 71 | fprintf(stderr, "Cannot open generic netlink socket\n"); 72 | return -1; 73 | } 74 | 75 | *genl_family = genl_resolve_family(grth, family); 76 | if (*genl_family < 0) 77 | return -1; 78 | 79 | return 0; 80 | } 81 | -------------------------------------------------------------------------------- /app/src/main/cpp/lib/ll_addr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ll_addr.c 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 7 | * 2 of the License, or (at your option) any later version. 8 | * 9 | * Authors: Alexey Kuznetsov, 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "rt_names.h" 28 | #include "utils.h" 29 | 30 | 31 | const char *ll_addr_n2a(const unsigned char *addr, int alen, int type, char *buf, int blen) 32 | { 33 | int i; 34 | int l; 35 | 36 | if (alen == 4 && 37 | (type == ARPHRD_TUNNEL || type == ARPHRD_SIT || type == ARPHRD_IPGRE)) { 38 | return inet_ntop(AF_INET, addr, buf, blen); 39 | } 40 | if (alen == 16 && type == ARPHRD_TUNNEL6) { 41 | return inet_ntop(AF_INET6, addr, buf, blen); 42 | } 43 | snprintf(buf, blen, "%02x", addr[0]); 44 | for (i = 1, l = 2; i < alen && l < blen; i++, l += 3) 45 | snprintf(buf + l, blen - l, ":%02x", addr[i]); 46 | return buf; 47 | } 48 | 49 | /*NB: lladdr is char * (rather than u8 *) because sa_data is char * (1003.1g) */ 50 | int ll_addr_a2n(char *lladdr, int len, const char *arg) 51 | { 52 | if (strchr(arg, '.')) { 53 | inet_prefix pfx; 54 | if (get_addr_1(&pfx, arg, AF_INET)) { 55 | fprintf(stderr, "\"%s\" is invalid lladdr.\n", arg); 56 | return -1; 57 | } 58 | if (len < 4) 59 | return -1; 60 | memcpy(lladdr, pfx.data, 4); 61 | return 4; 62 | } else { 63 | int i; 64 | 65 | for (i=0; i 255) { 77 | fprintf(stderr, "\"%s\" is invalid lladdr.\n", arg); 78 | return -1; 79 | } 80 | lladdr[i] = temp; 81 | if (!cp) 82 | break; 83 | arg = cp; 84 | } 85 | return i+1; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /app/src/main/cpp/lib/ll_proto.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ll_proto.c 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 7 | * 2 of the License, or (at your option) any later version. 8 | * 9 | * Authors: Alexey Kuznetsov, 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "utils.h" 28 | #include "rt_names.h" 29 | 30 | 31 | #define __PF(f,n) { ETH_P_##f, #n }, 32 | static const struct { 33 | int id; 34 | const char *name; 35 | } llproto_names[] = { 36 | __PF(LOOP,loop) 37 | __PF(PUP,pup) 38 | __PF(PUPAT,pupat) 39 | __PF(IP,ip) 40 | __PF(X25,x25) 41 | __PF(ARP,arp) 42 | __PF(BPQ,bpq) 43 | __PF(IEEEPUP,ieeepup) 44 | __PF(IEEEPUPAT,ieeepupat) 45 | __PF(DEC,dec) 46 | __PF(DNA_DL,dna_dl) 47 | __PF(DNA_RC,dna_rc) 48 | __PF(DNA_RT,dna_rt) 49 | __PF(LAT,lat) 50 | __PF(DIAG,diag) 51 | __PF(CUST,cust) 52 | __PF(SCA,sca) 53 | __PF(RARP,rarp) 54 | __PF(ATALK,atalk) 55 | __PF(AARP,aarp) 56 | __PF(IPX,ipx) 57 | __PF(IPV6,ipv6) 58 | __PF(PPP_DISC,ppp_disc) 59 | __PF(PPP_SES,ppp_ses) 60 | __PF(ATMMPOA,atmmpoa) 61 | __PF(ATMFATE,atmfate) 62 | __PF(802_3,802_3) 63 | __PF(AX25,ax25) 64 | __PF(ALL,all) 65 | __PF(802_2,802_2) 66 | __PF(SNAP,snap) 67 | __PF(DDCMP,ddcmp) 68 | __PF(WAN_PPP,wan_ppp) 69 | __PF(PPP_MP,ppp_mp) 70 | __PF(LOCALTALK,localtalk) 71 | __PF(CAN,can) 72 | __PF(PPPTALK,ppptalk) 73 | __PF(TR_802_2,tr_802_2) 74 | __PF(MOBITEX,mobitex) 75 | __PF(CONTROL,control) 76 | __PF(IRDA,irda) 77 | __PF(ECONET,econet) 78 | __PF(TIPC,tipc) 79 | __PF(AOE,aoe) 80 | __PF(8021Q,802.1Q) 81 | __PF(8021AD,802.1ad) 82 | 83 | { 0x8100, "802.1Q" }, 84 | { 0x88cc, "LLDP" }, 85 | { ETH_P_IP, "ipv4" }, 86 | }; 87 | #undef __PF 88 | 89 | 90 | const char * ll_proto_n2a(unsigned short id, char *buf, int len) 91 | { 92 | int i; 93 | 94 | id = ntohs(id); 95 | 96 | for (i=0; i 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "rt_names.h" 28 | 29 | const char * ll_type_n2a(int type, char *buf, int len) 30 | { 31 | #define __PF(f,n) { ARPHRD_##f, #n }, 32 | static const struct { 33 | int type; 34 | const char *name; 35 | } arphrd_names[] = { 36 | { 0, "generic" }, 37 | __PF(ETHER,ether) 38 | __PF(EETHER,eether) 39 | __PF(AX25,ax25) 40 | __PF(PRONET,pronet) 41 | __PF(CHAOS,chaos) 42 | __PF(IEEE802,ieee802) 43 | __PF(ARCNET,arcnet) 44 | __PF(APPLETLK,atalk) 45 | __PF(DLCI,dlci) 46 | __PF(ATM,atm) 47 | __PF(METRICOM,metricom) 48 | __PF(IEEE1394,ieee1394) 49 | __PF(INFINIBAND,infiniband) 50 | __PF(SLIP,slip) 51 | __PF(CSLIP,cslip) 52 | __PF(SLIP6,slip6) 53 | __PF(CSLIP6,cslip6) 54 | __PF(RSRVD,rsrvd) 55 | __PF(ADAPT,adapt) 56 | __PF(ROSE,rose) 57 | __PF(X25,x25) 58 | __PF(HWX25,hwx25) 59 | __PF(CAN,can) 60 | __PF(PPP,ppp) 61 | __PF(HDLC,hdlc) 62 | __PF(LAPB,lapb) 63 | __PF(DDCMP,ddcmp) 64 | __PF(RAWHDLC,rawhdlc) 65 | __PF(TUNNEL,ipip) 66 | __PF(TUNNEL6,tunnel6) 67 | __PF(FRAD,frad) 68 | __PF(SKIP,skip) 69 | __PF(LOOPBACK,loopback) 70 | __PF(LOCALTLK,ltalk) 71 | __PF(FDDI,fddi) 72 | __PF(BIF,bif) 73 | __PF(SIT,sit) 74 | __PF(IPDDP,ip/ddp) 75 | __PF(IPGRE,gre) 76 | __PF(PIMREG,pimreg) 77 | __PF(HIPPI,hippi) 78 | __PF(ASH,ash) 79 | __PF(ECONET,econet) 80 | __PF(IRDA,irda) 81 | __PF(FCPP,fcpp) 82 | __PF(FCAL,fcal) 83 | __PF(FCPL,fcpl) 84 | __PF(FCFABRIC,fcfb0) 85 | __PF(FCFABRIC+1,fcfb1) 86 | __PF(FCFABRIC+2,fcfb2) 87 | __PF(FCFABRIC+3,fcfb3) 88 | __PF(FCFABRIC+4,fcfb4) 89 | __PF(FCFABRIC+5,fcfb5) 90 | __PF(FCFABRIC+6,fcfb6) 91 | __PF(FCFABRIC+7,fcfb7) 92 | __PF(FCFABRIC+8,fcfb8) 93 | __PF(FCFABRIC+9,fcfb9) 94 | __PF(FCFABRIC+10,fcfb10) 95 | __PF(FCFABRIC+11,fcfb11) 96 | __PF(FCFABRIC+12,fcfb12) 97 | __PF(IEEE802_TR,tr) 98 | __PF(IEEE80211,ieee802.11) 99 | __PF(IEEE80211_PRISM,ieee802.11/prism) 100 | __PF(IEEE80211_RADIOTAP,ieee802.11/radiotap) 101 | __PF(IEEE802154, ieee802.15.4) 102 | __PF(IEEE802154_MONITOR, ieee802.15.4/monitor) 103 | __PF(PHONET, phonet) 104 | __PF(PHONET_PIPE, phonet_pipe) 105 | __PF(CAIF, caif) 106 | __PF(IP6GRE, gre6) 107 | __PF(NETLINK, netlink) 108 | __PF(6LOWPAN, 6lowpan) 109 | 110 | __PF(NONE, none) 111 | __PF(VOID,void) 112 | }; 113 | #undef __PF 114 | 115 | int i; 116 | for (i=0; i 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "utils.h" 8 | 9 | static const char *mpls_ntop1(const struct mpls_label *addr, char *buf, size_t buflen) 10 | { 11 | size_t destlen = buflen; 12 | char *dest = buf; 13 | int count = 0; 14 | 15 | while (1) { 16 | uint32_t entry = ntohl(addr[count++].entry); 17 | uint32_t label = (entry & MPLS_LS_LABEL_MASK) >> MPLS_LS_LABEL_SHIFT; 18 | int len = snprintf(dest, destlen, "%u", label); 19 | 20 | if (len >= destlen) 21 | break; 22 | 23 | /* Is this the end? */ 24 | if (entry & MPLS_LS_S_MASK) 25 | return buf; 26 | 27 | dest += len; 28 | destlen -= len; 29 | if (destlen) { 30 | *dest = '/'; 31 | dest++; 32 | destlen--; 33 | } 34 | } 35 | errno = -E2BIG; 36 | return NULL; 37 | } 38 | 39 | const char *mpls_ntop(int af, const void *addr, char *buf, size_t buflen) 40 | { 41 | switch(af) { 42 | case AF_MPLS: 43 | errno = 0; 44 | return mpls_ntop1((struct mpls_label *)addr, buf, buflen); 45 | default: 46 | errno = EAFNOSUPPORT; 47 | } 48 | 49 | return NULL; 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/cpp/lib/mpls_pton.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "utils.h" 8 | 9 | 10 | static int mpls_pton1(const char *name, struct mpls_label *addr, 11 | unsigned int maxlabels) 12 | { 13 | char *endp; 14 | unsigned count; 15 | 16 | for (count = 0; count < maxlabels; count++) { 17 | unsigned long label; 18 | 19 | label = strtoul(name, &endp, 0); 20 | /* Fail when the label value is out or range */ 21 | if (label >= (1 << 20)) 22 | return 0; 23 | 24 | if (endp == name) /* no digits */ 25 | return 0; 26 | 27 | addr->entry = htonl(label << MPLS_LS_LABEL_SHIFT); 28 | if (*endp == '\0') { 29 | addr->entry |= htonl(1 << MPLS_LS_S_SHIFT); 30 | return 1; 31 | } 32 | 33 | /* Bad character in the address */ 34 | if (*endp != '/') 35 | return 0; 36 | 37 | name = endp + 1; 38 | addr += 1; 39 | } 40 | /* The address was too long */ 41 | fprintf(stderr, "Error: too many labels.\n"); 42 | return 0; 43 | } 44 | 45 | int mpls_pton(int af, const char *src, void *addr, size_t alen) 46 | { 47 | unsigned int maxlabels = alen / sizeof(struct mpls_label); 48 | int err; 49 | 50 | switch(af) { 51 | case AF_MPLS: 52 | errno = 0; 53 | err = mpls_pton1(src, (struct mpls_label *)addr, maxlabels); 54 | break; 55 | default: 56 | errno = EAFNOSUPPORT; 57 | err = -1; 58 | } 59 | 60 | return err; 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/cpp/lib/names.c: -------------------------------------------------------------------------------- 1 | /* 2 | * names.c db names 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 7 | * 2 of the License, or (at your option) any later version. 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "names.h" 17 | #include "utils.h" 18 | 19 | #define MAX_ENTRIES 256 20 | #define NAME_MAX_LEN 512 21 | 22 | static int read_id_name(FILE *fp, int *id, char *name) 23 | { 24 | char buf[NAME_MAX_LEN]; 25 | int min, maj; 26 | 27 | while (fgets(buf, sizeof(buf), fp)) { 28 | char *p = buf; 29 | 30 | while (*p == ' ' || *p == '\t') 31 | p++; 32 | 33 | if (*p == '#' || *p == '\n' || *p == 0) 34 | continue; 35 | 36 | if (sscanf(p, "%x:%x %s\n", &maj, &min, name) == 3) { 37 | *id = (maj << 16) | min; 38 | } else if (sscanf(p, "%x:%x %s #", &maj, &min, name) == 3) { 39 | *id = (maj << 16) | min; 40 | } else if (sscanf(p, "0x%x %s\n", id, name) != 2 && 41 | sscanf(p, "0x%x %s #", id, name) != 2 && 42 | sscanf(p, "%d %s\n", id, name) != 2 && 43 | sscanf(p, "%d %s #", id, name) != 2) { 44 | strcpy(name, p); 45 | return -1; 46 | } 47 | return 1; 48 | } 49 | 50 | return 0; 51 | } 52 | 53 | struct db_names *db_names_alloc(void) 54 | { 55 | struct db_names *db; 56 | 57 | db = calloc(1, sizeof(*db)); 58 | if (!db) 59 | return NULL; 60 | 61 | db->size = MAX_ENTRIES; 62 | db->hash = calloc(db->size, sizeof(struct db_entry *)); 63 | 64 | return db; 65 | } 66 | 67 | int db_names_load(struct db_names *db, const char *path) 68 | { 69 | struct db_entry *entry; 70 | FILE *fp; 71 | int id; 72 | char namebuf[NAME_MAX_LEN] = {0}; 73 | int ret = -1; 74 | 75 | fp = fopen(path, "r"); 76 | if (!fp) 77 | return -ENOENT; 78 | 79 | while ((ret = read_id_name(fp, &id, &namebuf[0]))) { 80 | if (ret == -1) { 81 | fprintf(stderr, "Database %s is corrupted at %s\n", 82 | path, namebuf); 83 | goto Exit; 84 | } 85 | ret = -1; 86 | 87 | if (id < 0) 88 | continue; 89 | 90 | entry = malloc(sizeof(*entry)); 91 | if (!entry) 92 | goto Exit; 93 | 94 | entry->name = strdup(namebuf); 95 | if (!entry->name) { 96 | free(entry); 97 | goto Exit; 98 | } 99 | 100 | entry->id = id; 101 | entry->next = db->hash[id & (db->size - 1)]; 102 | db->hash[id & (db->size - 1)] = entry; 103 | } 104 | ret = 0; 105 | 106 | Exit: 107 | fclose(fp); 108 | return ret; 109 | } 110 | 111 | void db_names_free(struct db_names *db) 112 | { 113 | int i; 114 | 115 | if (!db) 116 | return; 117 | 118 | for (i = 0; i < db->size; i++) { 119 | struct db_entry *entry = db->hash[i]; 120 | 121 | while (entry) { 122 | struct db_entry *next = entry->next; 123 | 124 | free(entry->name); 125 | free(entry); 126 | entry = next; 127 | } 128 | } 129 | 130 | free(db->hash); 131 | free(db); 132 | } 133 | 134 | char *id_to_name(struct db_names *db, int id, char *name) 135 | { 136 | struct db_entry *entry; 137 | 138 | if (!db) 139 | return NULL; 140 | 141 | entry = db->hash[id & (db->size - 1)]; 142 | while (entry && entry->id != id) 143 | entry = entry->next; 144 | 145 | if (entry) { 146 | strncpy(name, entry->name, IDNAME_MAX); 147 | return name; 148 | } 149 | 150 | snprintf(name, IDNAME_MAX, "%d", id); 151 | return NULL; 152 | } 153 | 154 | int name_to_id(struct db_names *db, int *id, const char *name) 155 | { 156 | struct db_entry *entry; 157 | int i; 158 | 159 | if (!db) 160 | return -1; 161 | 162 | if (db->cached && strcmp(db->cached->name, name) == 0) { 163 | *id = db->cached->id; 164 | return 0; 165 | } 166 | 167 | for (i = 0; i < db->size; i++) { 168 | entry = db->hash[i]; 169 | while (entry && strcmp(entry->name, name)) 170 | entry = entry->next; 171 | 172 | if (entry) { 173 | db->cached = entry; 174 | *id = entry->id; 175 | return 0; 176 | } 177 | } 178 | 179 | return -1; 180 | } 181 | -------------------------------------------------------------------------------- /app/src/main/cpp/lib/namespace.c: -------------------------------------------------------------------------------- 1 | /* 2 | * namespace.c 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 7 | * 2 of the License, or (at your option) any later version. 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "utils.h" 15 | #include "namespace.h" 16 | 17 | static void bind_etc(const char *name) 18 | { 19 | char etc_netns_path[PATH_MAX]; 20 | char netns_name[PATH_MAX]; 21 | char etc_name[PATH_MAX]; 22 | struct dirent *entry; 23 | DIR *dir; 24 | 25 | snprintf(etc_netns_path, sizeof(etc_netns_path), "%s/%s", NETNS_ETC_DIR, name); 26 | dir = opendir(etc_netns_path); 27 | if (!dir) 28 | return; 29 | 30 | while ((entry = readdir(dir)) != NULL) { 31 | if (strcmp(entry->d_name, ".") == 0) 32 | continue; 33 | if (strcmp(entry->d_name, "..") == 0) 34 | continue; 35 | snprintf(netns_name, sizeof(netns_name), "%s/%s", etc_netns_path, entry->d_name); 36 | snprintf(etc_name, sizeof(etc_name), "/etc/%s", entry->d_name); 37 | if (mount(netns_name, etc_name, "none", MS_BIND, NULL) < 0) { 38 | fprintf(stderr, "Bind %s -> %s failed: %s\n", 39 | netns_name, etc_name, strerror(errno)); 40 | } 41 | } 42 | closedir(dir); 43 | } 44 | 45 | int netns_switch(char *name) 46 | { 47 | char net_path[PATH_MAX]; 48 | int netns; 49 | 50 | snprintf(net_path, sizeof(net_path), "%s/%s", NETNS_RUN_DIR, name); 51 | netns = open(net_path, O_RDONLY | O_CLOEXEC); 52 | if (netns < 0) { 53 | fprintf(stderr, "Cannot open network namespace \"%s\": %s\n", 54 | name, strerror(errno)); 55 | return -1; 56 | } 57 | 58 | if (setns(netns, CLONE_NEWNET) < 0) { 59 | fprintf(stderr, "setting the network namespace \"%s\" failed: %s\n", 60 | name, strerror(errno)); 61 | close(netns); 62 | return -1; 63 | } 64 | close(netns); 65 | 66 | if (unshare(CLONE_NEWNS) < 0) { 67 | fprintf(stderr, "unshare failed: %s\n", strerror(errno)); 68 | return -1; 69 | } 70 | /* Don't let any mounts propagate back to the parent */ 71 | if (mount("", "/", "none", MS_SLAVE | MS_REC, NULL)) { 72 | fprintf(stderr, "\"mount --make-rslave /\" failed: %s\n", 73 | strerror(errno)); 74 | return -1; 75 | } 76 | /* Mount a version of /sys that describes the network namespace */ 77 | if (umount2("/sys", MNT_DETACH) < 0) { 78 | fprintf(stderr, "umount of /sys failed: %s\n", strerror(errno)); 79 | return -1; 80 | } 81 | if (mount(name, "/sys", "sysfs", 0, NULL) < 0) { 82 | fprintf(stderr, "mount of /sys failed: %s\n",strerror(errno)); 83 | return -1; 84 | } 85 | 86 | /* Setup bind mounts for config files in /etc */ 87 | bind_etc(name); 88 | return 0; 89 | } 90 | 91 | int netns_get_fd(const char *name) 92 | { 93 | char pathbuf[PATH_MAX]; 94 | const char *path, *ptr; 95 | 96 | path = name; 97 | ptr = strchr(name, '/'); 98 | if (!ptr) { 99 | snprintf(pathbuf, sizeof(pathbuf), "%s/%s", 100 | NETNS_RUN_DIR, name ); 101 | path = pathbuf; 102 | } 103 | return open(path, O_RDONLY); 104 | } 105 | 106 | int netns_foreach(int (*func)(char *nsname, void *arg), void *arg) 107 | { 108 | DIR *dir; 109 | struct dirent *entry; 110 | 111 | dir = opendir(NETNS_RUN_DIR); 112 | if (!dir) 113 | return -1; 114 | 115 | while ((entry = readdir(dir)) != NULL) { 116 | if (strcmp(entry->d_name, ".") == 0) 117 | continue; 118 | if (strcmp(entry->d_name, "..") == 0) 119 | continue; 120 | if (func(entry->d_name, arg)) 121 | break; 122 | } 123 | 124 | closedir(dir); 125 | return 0; 126 | } 127 | -------------------------------------------------------------------------------- /app/src/main/cpp/native-lib.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ip.h" 4 | 5 | extern "C" 6 | JNIEXPORT jstring JNICALL 7 | Java_com_github_qiang_iproute2_parsemac_MainActivity_parseMac(JNIEnv *env, jobject thiz) { 8 | main(); 9 | 10 | std::string hello = "Hello from C++"; 11 | return env->NewStringUTF(hello.c_str()); 12 | } -------------------------------------------------------------------------------- /app/src/main/cpp/xdp.h: -------------------------------------------------------------------------------- 1 | #ifndef __XDP__ 2 | #define __XDP__ 3 | 4 | #include "utils.h" 5 | 6 | int xdp_parse(int *argc, char ***argv, struct iplink_req *req, bool generic, 7 | bool drv, bool offload); 8 | void xdp_dump(FILE *fp, struct rtattr *tb, bool link, bool details); 9 | 10 | #endif /* __XDP__ */ 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/qiang/iproute2/parsemac/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.qiang.iproute2.parsemac; 2 | 3 | import androidx.appcompat.app.AppCompatActivity; 4 | 5 | import android.os.Bundle; 6 | import android.view.View; 7 | 8 | public class MainActivity extends AppCompatActivity { 9 | 10 | static { 11 | System.loadLibrary("native-lib"); 12 | } 13 | 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_main); 19 | } 20 | 21 | public native String parseMac(); 22 | 23 | public void click(View view) { 24 | parseMac(); 25 | } 26 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |