From cbd8b0f144aaa2429822817110d00f1d87432ac3 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Thu, 18 May 2023 09:21:04 +0800 Subject: [PATCH] refactor: update the function name --- common/build.rs | 2 +- common/src/vpn/ffi.rs | 4 ++-- common/src/vpn/vpn.c | 4 ++-- common/src/vpn/vpn.h | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common/build.rs b/common/build.rs index 66d83b5..d073c4a 100644 --- a/common/build.rs +++ b/common/build.rs @@ -4,7 +4,7 @@ fn main() { println!("cargo:rerun-if-changed=src/vpn/vpn.c"); println!("cargo:rerun-if-changed=src/vpn/vpn.h"); - // Compile the wrapper.c file + // Compile the vpn.c file cc::Build::new() .file("src/vpn/vpn.c") .include("src/vpn") diff --git a/common/src/vpn/ffi.rs b/common/src/vpn/ffi.rs index 9b3d843..833a0ca 100644 --- a/common/src/vpn/ffi.rs +++ b/common/src/vpn/ffi.rs @@ -12,10 +12,10 @@ pub(crate) struct Options { #[link(name = "vpn")] extern "C" { - #[link_name = "start"] + #[link_name = "vpn_connect"] pub(crate) fn connect(options: *const Options) -> ::std::os::raw::c_int; - #[link_name = "stop"] + #[link_name = "vpn_disconnect"] pub(crate) fn disconnect(); } diff --git a/common/src/vpn/vpn.c b/common/src/vpn/vpn.c index 4efc0f6..dae4464 100644 --- a/common/src/vpn/vpn.c +++ b/common/src/vpn/vpn.c @@ -46,7 +46,7 @@ static void setup_tun_handler(void *_vpninfo) } /* Initialize VPN connection */ -int start(const Options *options) +int vpn_connect(const Options *options) { struct openconnect_info *vpninfo; struct utsname utsbuf; @@ -111,7 +111,7 @@ int start(const Options *options) } /* Stop the VPN connection */ -void stop() +void vpn_disconnect() { char cmd = OC_CMD_CANCEL; if (write(g_cmd_pipe_fd, &cmd, 1) < 0) diff --git a/common/src/vpn/vpn.h b/common/src/vpn/vpn.h index 2c0e9a9..c2300c7 100644 --- a/common/src/vpn/vpn.h +++ b/common/src/vpn/vpn.h @@ -5,8 +5,8 @@ typedef struct Options { void *user_data; } Options; -int start(const Options *options); -void stop(); +int vpn_connect(const Options *options); +void vpn_disconnect(); extern void on_vpn_connected(int cmd_pipe_fd, void *user_data); extern void vpn_log(int level, const char *msg); \ No newline at end of file