Skip to content

Commit f2ebab8

Browse files
committed
Add SlirpService for Ethernet over BLE
1 parent c8a52d5 commit f2ebab8

File tree

159 files changed

+23264
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+23264
-3
lines changed

app/build.gradle.kts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ android {
1212
targetSdk = 33
1313
versionCode = 29
1414
versionName = "0.29"
15+
ndk.abiFilters.clear()
16+
ndk.abiFilters.add("arm64-v8a")
17+
ndk.abiFilters.add("armeabi-v7a")
18+
ndk.abiFilters.add("x86")
19+
ndk.abiFilters.add("x86_64")
20+
externalNativeBuild {
21+
cmake {
22+
cppFlags += ""
23+
}
24+
}
1525
}
1626
buildTypes {
1727
named("release") {
@@ -31,6 +41,9 @@ android {
3141
srcDir("src/main/lib/material-intro-screen/material-intro-screen/src/main/res/")
3242
srcDir("src/main/lib/powerampapi/poweramp_api_lib/res/")
3343
}
44+
jniLibs {
45+
srcDir("src/main/cpp/lib")
46+
}
3447
}
3548
}
3649

@@ -43,6 +56,12 @@ android {
4356
disable += "MissingTranslation"
4457
}
4558
namespace = "org.asteroidos.sync"
59+
externalNativeBuild {
60+
cmake {
61+
path = file("src/main/cpp/CMakeLists.txt")
62+
version = "3.22.1"
63+
}
64+
}
4665
}
4766

4867
repositories {

app/src/main/cpp/CMakeLists.txt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
# For more information about using CMake with Android Studio, read the
3+
# documentation: https://d.android.com/studio/projects/add-native-code.html.
4+
# For more examples on how to use CMake, see https://github.com/android/ndk-samples.
5+
6+
# Sets the minimum CMake version required for this project.
7+
cmake_minimum_required(VERSION 3.22.1)
8+
9+
# Declares the project name. The project name can be accessed via ${ PROJECT_NAME},
10+
# Since this is the top level CMakeLists.txt, the project name is also accessible
11+
# with ${CMAKE_PROJECT_NAME} (both CMake variables are in-sync within the top level
12+
# build script scope).
13+
project("sync")
14+
15+
add_subdirectory(libslirp)
16+
17+
# Creates and names a library, sets it as either STATIC
18+
# or SHARED, and provides the relative paths to its source code.
19+
# You can define multiple libraries, and CMake builds them for you.
20+
# Gradle automatically packages shared libraries with your APK.
21+
#
22+
# In this top level CMakeLists.txt, ${CMAKE_PROJECT_NAME} is used to define
23+
# the target library name; in the sub-module's CMakeLists.txt, ${PROJECT_NAME}
24+
# is preferred for the same purpose.
25+
#
26+
# In order to load a library into your app from Java/Kotlin, you must call
27+
# System.loadLibrary() and pass the name of the library defined here;
28+
# for GameActivity/NativeActivity derived applications, the same library name must be
29+
# used in the AndroidManifest.xml file.
30+
add_library(${CMAKE_PROJECT_NAME} SHARED
31+
# List C/C++ source files with relative paths to this CMakeLists.txt.
32+
sync.cpp)
33+
34+
# Specifies libraries CMake should link to your target library. You
35+
# can link libraries from various origins, such as libraries defined in this
36+
# build script, prebuilt third-party libraries, or Android system libraries.
37+
target_link_libraries(${CMAKE_PROJECT_NAME}
38+
slirp
39+
android
40+
log)
41+
42+
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE
43+
-fvisibility=hidden)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# https://clang.llvm.org/docs/ClangFormat.html
2+
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
3+
---
4+
Language: Cpp
5+
AlignAfterOpenBracket: Align
6+
AlignConsecutiveAssignments: false # although we like it, it creates churn
7+
AlignConsecutiveDeclarations: false
8+
AlignEscapedNewlinesLeft: true
9+
AlignOperands: true
10+
AlignTrailingComments: false # churn
11+
AllowAllParametersOfDeclarationOnNextLine: true
12+
AllowShortBlocksOnASingleLine: false
13+
AllowShortCaseLabelsOnASingleLine: false
14+
AllowShortFunctionsOnASingleLine: None
15+
AllowShortIfStatementsOnASingleLine: false
16+
AllowShortLoopsOnASingleLine: false
17+
AlwaysBreakAfterReturnType: None # AlwaysBreakAfterDefinitionReturnType is taken into account
18+
AlwaysBreakBeforeMultilineStrings: false
19+
BinPackArguments: true
20+
BinPackParameters: true
21+
BraceWrapping:
22+
AfterControlStatement: false
23+
AfterEnum: false
24+
AfterFunction: true
25+
AfterStruct: false
26+
AfterUnion: false
27+
BeforeElse: false
28+
IndentBraces: false
29+
BreakBeforeBinaryOperators: None
30+
BreakBeforeBraces: Custom
31+
BreakBeforeTernaryOperators: false
32+
BreakStringLiterals: true
33+
ColumnLimit: 80
34+
ContinuationIndentWidth: 4
35+
Cpp11BracedListStyle: false
36+
DerivePointerAlignment: false
37+
DisableFormat: false
38+
IndentCaseLabels: false
39+
IndentWidth: 4
40+
IndentWrappedFunctionNames: false
41+
KeepEmptyLinesAtTheStartOfBlocks: false
42+
MacroBlockBegin: '.*_BEGIN$' # only PREC_BEGIN ?
43+
MacroBlockEnd: '.*_END$'
44+
MaxEmptyLinesToKeep: 2
45+
PointerAlignment: Right
46+
ReflowComments: true
47+
SortIncludes: false
48+
SpaceAfterCStyleCast: false
49+
SpaceBeforeAssignmentOperators: true
50+
SpaceBeforeParens: ControlStatements
51+
SpaceInEmptyParentheses: false
52+
SpacesBeforeTrailingComments: 1
53+
SpacesInContainerLiterals: true
54+
SpacesInParentheses: false
55+
SpacesInSquareBrackets: false
56+
Standard: Auto
57+
UseTab: Never
58+
...
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*.[aod]
2+
*.gcda
3+
*.gcno
4+
*.gcov
5+
*.lib
6+
*.obj
7+
/build/
8+
/TAGS
9+
/cscope*
10+
/src/libslirp-version.h
11+
/tags
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
image: fedora:latest
2+
3+
variables:
4+
DEPS: meson ninja-build
5+
gcc libasan liblsan libubsan pkg-config glib2-devel
6+
mingw64-gcc mingw64-pkg-config mingw64-glib2
7+
clang-analyzer git-core
8+
9+
before_script:
10+
- dnf install -y $DEPS
11+
- git fetch --tags https://gitlab.freedesktop.org/slirp/libslirp.git
12+
- git describe
13+
14+
build:
15+
script:
16+
- meson --werror build || (cat build/meson-logs/meson-log.txt && exit 1)
17+
- ninja -C build
18+
- (cd build && meson test) || (cat build/meson-logs/testlog.txt && exit 1)
19+
- ninja -C build scan-build
20+
21+
build-asan:
22+
script:
23+
- CFLAGS=-fsanitize=address meson --werror build || (cat build/meson-logs/meson-log.txt && exit 1)
24+
- ninja -C build
25+
- (cd build && ASAN_OPTIONS=detect_leaks=0 meson test) || (cat build/meson-logs/testlog.txt && exit 1)
26+
27+
build-lsan:
28+
script:
29+
- CFLAGS=-fsanitize=leak meson --werror build || (cat build/meson-logs/meson-log.txt && exit 1)
30+
- ninja -C build
31+
- (cd build && meson test) || (cat build/meson-logs/testlog.txt && exit 1)
32+
33+
build-usan:
34+
script:
35+
- CFLAGS=-fsanitize=undefined meson --werror build || (cat build/meson-logs/meson-log.txt && exit 1)
36+
- ninja -C build
37+
- (cd build && meson test) || (cat build/meson-logs/testlog.txt && exit 1)
38+
39+
fuzz:
40+
parallel:
41+
matrix:
42+
- TARGET: [arp, ip-header, udp, udp-h, tftp, dhcp, icmp, tcp, tcp-h, ndp, ip6-header, udp6, udp6-h, tftp6, icmp6, tcp6, tcp6-h]
43+
script:
44+
- CC=clang CXX=clang++ meson build -Dllvm-fuzz=true || (cat build/meson-logs/meson-log.txt && exit 1)
45+
- ninja -C build
46+
- build/fuzzing/fuzz-$TARGET -seed=1234 -runs=1000000 fuzzing/IN_$TARGET
47+
artifacts:
48+
when: on_failure
49+
paths:
50+
- crash-*
51+
- leak-*
52+
- oom-*
53+
- timeout-*
54+
55+
build-mingw64:
56+
script:
57+
- (mkdir buildw && cd buildw && mingw64-meson --werror) || (cat buildw/meson-logs/meson-log.txt && exit 1)
58+
- ninja -C buildw
59+
60+
Coverity:
61+
only:
62+
refs:
63+
- master
64+
- coverity
65+
script:
66+
- dnf update -y
67+
- dnf install -y curl clang
68+
- curl -o /tmp/cov-analysis-linux64.tgz https://scan.coverity.com/download/linux64
69+
--form project=$COVERITY_SCAN_PROJECT_NAME --form token=$COVERITY_SCAN_TOKEN
70+
- tar xfz /tmp/cov-analysis-linux64.tgz
71+
- CC=clang meson build
72+
- cov-analysis-linux64-*/bin/cov-build --dir cov-int ninja -C build
73+
- tar cfz cov-int.tar.gz cov-int
74+
- curl https://scan.coverity.com/builds?project=$COVERITY_SCAN_PROJECT_NAME
75+
--form token=$COVERITY_SCAN_TOKEN --form email=$GITLAB_USER_EMAIL
76+
--form [email protected] --form version="`git describe --tags`"
77+
--form description="`git describe --tags` / $CI_COMMIT_TITLE / $CI_COMMIT_REF_NAME:$CI_PIPELINE_ID "
78+
79+
integration-slirp4netns:
80+
variables:
81+
SLIRP4NETNS_VERSION: "v1.1.12"
82+
# Consumed by `make benchmark`
83+
BENCHMARK_IPERF3_DURATION: "10"
84+
script:
85+
# Install libslirp
86+
- meson build
87+
- ninja -C build install
88+
# Register the path of libslirp.so.0
89+
- echo /usr/local/lib64 >/etc/ld.so.conf.d/libslirp.conf
90+
- ldconfig
91+
# Install the dependencies of slirp4netns and its test suite
92+
# TODO: install udhcpc for `slirp4netns/tests/test-slirp4netns-dhcp.sh` (currently skipped, due to lack of udhcpc)
93+
- dnf install -y autoconf automake findutils iperf3 iproute iputils jq libcap-devel libseccomp-devel nmap-ncat util-linux
94+
# Check whether the runner environment is configured correctly
95+
- unshare -rn true || (echo Make sure you have relaxed seccomp and appamor && exit 1)
96+
- unshare -rn ip tap add tap0 mode tap || (echo Make sure you have /dev/net/tun && exit 1)
97+
# Install slirp4netns
98+
- git clone https://github.com/rootless-containers/slirp4netns -b "${SLIRP4NETNS_VERSION}"
99+
- cd slirp4netns
100+
- ./autogen.sh
101+
- ./configure
102+
- make
103+
- make install
104+
- slirp4netns --version
105+
# Run slirp4netns integration test
106+
- make distcheck || (cat $(find . -name 'test-suite.log' ) && exit 1)
107+
# Run benchmark test to ensure that libslirp can actually handle packets, with several MTU configurations
108+
- make benchmark MTU=1500
109+
- make benchmark MTU=512
110+
- make benchmark MTU=65520
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[gitpublishprofile "default"]
2+
base = master
3+

0 commit comments

Comments
 (0)