From 734b14e07db80d9fdcfe5057eb7930934aa08e54 Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Fri, 5 Feb 2021 23:56:09 +0900 Subject: [PATCH] Add a bpf_tethering_headers lib used by the programs and JNI. This provides a place to store common definitions that can be used by both the programs and by JNI code in the tethering module. Over time much of the tethering-specific code in bpf_shared.h could move here. Test: m Bug: 177884581 Change-Id: I4bf2c762d61cd5db003d59880e6bf7d107ff1a07 --- Tethering/Android.bp | 5 ++++- Tethering/bpf_progs/Android.bp | 20 ++++++++++++++++++++ Tethering/bpf_progs/bpf_tethering.h | 22 ++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 Tethering/bpf_progs/bpf_tethering.h diff --git a/Tethering/Android.bp b/Tethering/Android.bp index 7427481172..731755802b 100644 --- a/Tethering/Android.bp +++ b/Tethering/Android.bp @@ -62,7 +62,10 @@ cc_library { "com.android.tethering", ], min_sdk_version: "30", - header_libs: ["bpf_syscall_wrappers"], + header_libs: [ + "bpf_syscall_wrappers", + "bpf_tethering_headers", + ], srcs: [ "jni/*.cpp", ], diff --git a/Tethering/bpf_progs/Android.bp b/Tethering/bpf_progs/Android.bp index d62e9a1b4c..b06528b9d5 100644 --- a/Tethering/bpf_progs/Android.bp +++ b/Tethering/bpf_progs/Android.bp @@ -14,6 +14,26 @@ // limitations under the License. // +// +// struct definitions shared with JNI +// +cc_library_headers { + name: "bpf_tethering_headers", + vendor_available: false, + host_supported: false, + export_include_dirs: ["."], + cflags: [ + "-Wall", + "-Werror", + ], + sdk_version: "30", + min_sdk_version: "30", + apex_available: ["com.android.tethering"], + visibility: [ + "//packages/modules/Connectivity/Tethering", + ], +} + // // bpf kernel programs // diff --git a/Tethering/bpf_progs/bpf_tethering.h b/Tethering/bpf_progs/bpf_tethering.h new file mode 100644 index 0000000000..dfa26828f5 --- /dev/null +++ b/Tethering/bpf_progs/bpf_tethering.h @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +// Common definitions for BPF code in the tethering mainline module. +// These definitions are available to: +// - The BPF programs in Tethering/bpf_progs/ +// - JNI code that depends on the bpf_tethering_headers library.