Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
67b7a0f2
Commit
67b7a0f2
authored
Jan 17, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clang-tidy jni-helper
parent
3d2d485a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
24 deletions
+9
-24
core/src/main/jni/Android.mk
core/src/main/jni/Android.mk
+1
-3
core/src/main/jni/jni-helper.cpp
core/src/main/jni/jni-helper.cpp
+8
-21
No files found.
core/src/main/jni/Android.mk
View file @
67b7a0f2
...
@@ -319,14 +319,12 @@ include $(CLEAR_VARS)
...
@@ -319,14 +319,12 @@ include $(CLEAR_VARS)
LOCAL_MODULE
:=
jni-helper
LOCAL_MODULE
:=
jni-helper
LOCAL_CFLAGS
:=
-std
=
c++1
1
LOCAL_CFLAGS
:=
-std
=
c++1
7
LOCAL_C_INCLUDES
:=
$(LOCAL_PATH)
/libancillary
LOCAL_C_INCLUDES
:=
$(LOCAL_PATH)
/libancillary
LOCAL_SRC_FILES
:=
jni-helper.cpp
LOCAL_SRC_FILES
:=
jni-helper.cpp
LOCAL_LDLIBS
:=
-ldl
-llog
LOCAL_STATIC_LIBRARIES
:=
libancillary
LOCAL_STATIC_LIBRARIES
:=
libancillary
include
$(BUILD_SHARED_LIBRARY)
include
$(BUILD_SHARED_LIBRARY)
...
...
core/src/main/jni/jni-helper.cpp
View file @
67b7a0f2
...
@@ -24,7 +24,7 @@ static void throwException(JNIEnv* env, jclass exceptionClass, jmethodID ctor2,
...
@@ -24,7 +24,7 @@ static void throwException(JNIEnv* env, jclass exceptionClass, jmethodID ctor2,
static
void
throwErrnoException
(
JNIEnv
*
env
,
const
char
*
functionName
)
{
static
void
throwErrnoException
(
JNIEnv
*
env
,
const
char
*
functionName
)
{
int
error
=
errno
;
int
error
=
errno
;
static
auto
ErrnoException
=
static
_cast
<
jclass
>
(
env
->
NewGlobalRef
(
static
auto
ErrnoException
=
reinterpret
_cast
<
jclass
>
(
env
->
NewGlobalRef
(
env
->
FindClass
(
"android/system/ErrnoException"
)));
env
->
FindClass
(
"android/system/ErrnoException"
)));
static
jmethodID
ctor2
=
env
->
GetMethodID
(
ErrnoException
,
"<init>"
,
"(Ljava/lang/String;I)V"
);
static
jmethodID
ctor2
=
env
->
GetMethodID
(
ErrnoException
,
"<init>"
,
"(Ljava/lang/String;I)V"
);
throwException
(
env
,
ErrnoException
,
ctor2
,
functionName
,
error
);
throwException
(
env
,
ErrnoException
,
ctor2
,
functionName
,
error
);
...
@@ -34,29 +34,16 @@ static void throwErrnoException(JNIEnv* env, const char* functionName) {
...
@@ -34,29 +34,16 @@ static void throwErrnoException(JNIEnv* env, const char* functionName) {
extern
"C"
{
extern
"C"
{
JNIEXPORT
void
JNICALL
JNIEXPORT
void
JNICALL
Java_com_github_shadowsocks_JniHelper_sendFd
(
JNIEnv
*
env
,
jclass
type
,
jint
tun_fd
,
jstring
path
)
{
Java_com_github_shadowsocks_JniHelper_sendFd
(
JNIEnv
*
env
,
jclass
type
,
jint
tun_fd
,
jstring
path
)
{
int
fd
;
struct
sockaddr_un
addr
;
const
char
*
sock_str
=
env
->
GetStringUTFChars
(
path
,
nullptr
);
const
char
*
sock_str
=
env
->
GetStringUTFChars
(
path
,
nullptr
);
if
(
int
fd
=
socket
(
AF_UNIX
,
SOCK_STREAM
|
SOCK_CLOEXEC
,
0
);
fd
==
-
1
)
{
if
((
fd
=
socket
(
AF_UNIX
,
SOCK_STREAM
,
0
))
==
-
1
)
{
throwErrnoException
(
env
,
"socket"
);
throwErrnoException
(
env
,
"socket"
);
goto
quit2
;
}
else
{
}
sockaddr_un
addr
{
.
sun_family
=
AF_UNIX
};
strncpy
(
addr
.
sun_path
,
sock_str
,
sizeof
(
addr
.
sun_path
)
-
1
);
memset
(
&
addr
,
0
,
sizeof
(
addr
));
if
(
connect
(
fd
,
(
sockaddr
*
)
&
addr
,
sizeof
(
addr
))
==
-
1
)
throwErrnoException
(
env
,
"connect"
);
addr
.
sun_family
=
AF_UNIX
;
else
if
(
ancil_send_fd
(
fd
,
tun_fd
))
throwErrnoException
(
env
,
"ancil_send_fd"
);
strncpy
(
addr
.
sun_path
,
sock_str
,
sizeof
(
addr
.
sun_path
)
-
1
);
close
(
fd
);
if
(
connect
(
fd
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
))
==
-
1
)
{
throwErrnoException
(
env
,
"connect"
);
goto
quit
;
}
}
if
(
ancil_send_fd
(
fd
,
tun_fd
))
throwErrnoException
(
env
,
"ancil_send_fd"
);
quit:
close
(
fd
);
quit2:
env
->
ReleaseStringUTFChars
(
path
,
sock_str
);
env
->
ReleaseStringUTFChars
(
path
,
sock_str
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment