From d6af8397a5fbcbee4b545cac4e9a5bb599b42c9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20L=C3=BCke?= Date: Wed, 8 Nov 2023 14:03:34 +0100 Subject: [PATCH] chore: make wgbindraw-sys a dependency --- Cargo.lock | 12 + wgbind/Cargo.toml | 1 + wgbind/src/bindings.rs | 886 ----------------------------------------- wgbind/src/lib.rs | 4 +- 4 files changed, 16 insertions(+), 887 deletions(-) delete mode 100644 wgbind/src/bindings.rs diff --git a/Cargo.lock b/Cargo.lock index 4cba34e..84e9cb9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -286,6 +286,7 @@ dependencies = [ "bindgen", "cc", "libc", + "wgbindraw-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -297,6 +298,17 @@ dependencies = [ "libc", ] +[[package]] +name = "wgbindraw-sys" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9a86bf745cafa030ff960ddef84fe6b0a99aa54953f4d8a5b094270940ce44d" +dependencies = [ + "bindgen", + "cc", + "libc", +] + [[package]] name = "which" version = "4.4.2" diff --git a/wgbind/Cargo.toml b/wgbind/Cargo.toml index 32fd3e9..b71ce11 100644 --- a/wgbind/Cargo.toml +++ b/wgbind/Cargo.toml @@ -12,6 +12,7 @@ description = "Wireguard bindings and wrapper around bindings for safe access - [dependencies] libc = "0.2.150" +wgbindraw-sys = "0.1.0" [build-dependencies] bindgen = "0.69.1" diff --git a/wgbind/src/bindings.rs b/wgbind/src/bindings.rs deleted file mode 100644 index a4a4793..0000000 --- a/wgbind/src/bindings.rs +++ /dev/null @@ -1,886 +0,0 @@ -/* automatically generated by rust-bindgen 0.69.1 */ - -pub type sa_family_t = ::core::ffi::c_ushort; -pub type in_addr_t = u32; -pub type in_port_t = u16; -pub type wg_key = [u8; 32usize]; -pub type wg_key_b64_string = [::core::ffi::c_char; 45usize]; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct sockaddr { - pub sa_family: sa_family_t, - pub sa_data: [::core::ffi::c_char; 14usize], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct in_addr { - pub s_addr: in_addr_t, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct in6_addr { - pub __in6_u: in6_addr__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct sockaddr_in { - pub sin_family: sa_family_t, - pub sin_port: in_port_t, - pub sin_addr: in_addr, - pub sin_zero: [::core::ffi::c_uchar; 8usize], -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct sockaddr_in6 { - pub sin6_family: sa_family_t, - pub sin6_port: in_port_t, - pub sin6_flowinfo: u32, - pub sin6_addr: in6_addr, - pub sin6_scope_id: u32, -} -#[doc = " Cross platform __kernel_timespec"] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct timespec64 { - pub tv_sec: i64, - pub tv_nsec: i64, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct wg_allowedip { - pub family: u16, - pub __bindgen_padding_0: [u8; 2usize], - pub wg_anonym_1: wg_allowedip__bindgen_ty_1, - pub cidr: u8, - pub __bindgen_padding_1: [u8; 3usize], - pub next_allowedip: *mut wg_allowedip, -} -#[repr(transparent)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct wg_peer_flags(pub u32); -#[repr(C)] -#[derive(Copy, Clone)] -pub struct wg_peer { - pub flags: wg_peer_flags, - pub public_key: wg_key, - pub preshared_key: wg_key, - pub endpoint: wg_endpoint, - pub last_handshake_time: timespec64, - pub rx_bytes: u64, - pub tx_bytes: u64, - pub persistent_keepalive_interval: u16, - pub __bindgen_padding_0: [u8; 6usize], - pub first_allowedip: *mut wg_allowedip, - pub last_allowedip: *mut wg_allowedip, - pub next_peer: *mut wg_peer, -} -#[repr(transparent)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct wg_device_flags(pub u32); -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct wg_device { - pub name: [::core::ffi::c_char; 16usize], - pub ifindex: u32, - pub flags: wg_device_flags, - pub public_key: wg_key, - pub private_key: wg_key, - pub fwmark: u32, - pub listen_port: u16, - pub __bindgen_padding_0: [u8; 2usize], - pub first_peer: *mut wg_peer, - pub last_peer: *mut wg_peer, -} -#[test] -fn bindgen_test_layout_sockaddr() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(sockaddr)) - ); - assert_eq!( - ::core::mem::align_of::(), - 2usize, - concat!("Alignment of ", stringify!(sockaddr)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sa_family) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(sockaddr), - "::", - stringify!(sa_family) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sa_data) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(sockaddr), - "::", - stringify!(sa_data) - ) - ); -} -#[test] -fn bindgen_test_layout_in_addr() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(in_addr)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(in_addr)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).s_addr) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(in_addr), - "::", - stringify!(s_addr) - ) - ); -} -#[test] -fn bindgen_test_layout_in6_addr__bindgen_ty_1() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(in6_addr__bindgen_ty_1)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(in6_addr__bindgen_ty_1)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).__u6_addr8) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(in6_addr__bindgen_ty_1), - "::", - stringify!(__u6_addr8) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).__u6_addr16) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(in6_addr__bindgen_ty_1), - "::", - stringify!(__u6_addr16) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).__u6_addr32) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(in6_addr__bindgen_ty_1), - "::", - stringify!(__u6_addr32) - ) - ); -} -#[test] -fn bindgen_test_layout_in6_addr() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(in6_addr)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(in6_addr)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).__in6_u) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(in6_addr), - "::", - stringify!(__in6_u) - ) - ); -} -#[test] -fn bindgen_test_layout_sockaddr_in() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(sockaddr_in)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(sockaddr_in)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sin_family) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(sockaddr_in), - "::", - stringify!(sin_family) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sin_port) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(sockaddr_in), - "::", - stringify!(sin_port) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sin_addr) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(sockaddr_in), - "::", - stringify!(sin_addr) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sin_zero) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(sockaddr_in), - "::", - stringify!(sin_zero) - ) - ); -} -#[test] -fn bindgen_test_layout_sockaddr_in6() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 28usize, - concat!("Size of: ", stringify!(sockaddr_in6)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(sockaddr_in6)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sin6_family) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(sockaddr_in6), - "::", - stringify!(sin6_family) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sin6_port) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(sockaddr_in6), - "::", - stringify!(sin6_port) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sin6_flowinfo) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(sockaddr_in6), - "::", - stringify!(sin6_flowinfo) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sin6_addr) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(sockaddr_in6), - "::", - stringify!(sin6_addr) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sin6_scope_id) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(sockaddr_in6), - "::", - stringify!(sin6_scope_id) - ) - ); -} -#[test] -fn bindgen_test_layout_timespec64() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(timespec64)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(timespec64)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).tv_sec) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(timespec64), - "::", - stringify!(tv_sec) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).tv_nsec) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(timespec64), - "::", - stringify!(tv_nsec) - ) - ); -} -#[test] -fn bindgen_test_layout_wg_allowedip__bindgen_ty_1() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(wg_allowedip__bindgen_ty_1)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(wg_allowedip__bindgen_ty_1)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ip4) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(wg_allowedip__bindgen_ty_1), - "::", - stringify!(ip4) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ip6) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(wg_allowedip__bindgen_ty_1), - "::", - stringify!(ip6) - ) - ); -} -#[test] -fn bindgen_test_layout_wg_allowedip() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(wg_allowedip)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(wg_allowedip)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).family) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(wg_allowedip), - "::", - stringify!(family) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).cidr) as usize - ptr as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(wg_allowedip), - "::", - stringify!(cidr) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).next_allowedip) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(wg_allowedip), - "::", - stringify!(next_allowedip) - ) - ); -} -#[test] -fn bindgen_test_layout_wg_endpoint() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 28usize, - concat!("Size of: ", stringify!(wg_endpoint)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(wg_endpoint)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(wg_endpoint), - "::", - stringify!(addr) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).addr4) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(wg_endpoint), - "::", - stringify!(addr4) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).addr6) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(wg_endpoint), - "::", - stringify!(addr6) - ) - ); -} -#[test] -fn bindgen_test_layout_wg_peer() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 160usize, - concat!("Size of: ", stringify!(wg_peer)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(wg_peer)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(wg_peer), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).public_key) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(wg_peer), - "::", - stringify!(public_key) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).preshared_key) as usize - ptr as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(wg_peer), - "::", - stringify!(preshared_key) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).endpoint) as usize - ptr as usize }, - 68usize, - concat!( - "Offset of field: ", - stringify!(wg_peer), - "::", - stringify!(endpoint) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).last_handshake_time) as usize - ptr as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(wg_peer), - "::", - stringify!(last_handshake_time) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).rx_bytes) as usize - ptr as usize }, - 112usize, - concat!( - "Offset of field: ", - stringify!(wg_peer), - "::", - stringify!(rx_bytes) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).tx_bytes) as usize - ptr as usize }, - 120usize, - concat!( - "Offset of field: ", - stringify!(wg_peer), - "::", - stringify!(tx_bytes) - ) - ); - assert_eq!( - unsafe { - ::core::ptr::addr_of!((*ptr).persistent_keepalive_interval) as usize - ptr as usize - }, - 128usize, - concat!( - "Offset of field: ", - stringify!(wg_peer), - "::", - stringify!(persistent_keepalive_interval) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).first_allowedip) as usize - ptr as usize }, - 136usize, - concat!( - "Offset of field: ", - stringify!(wg_peer), - "::", - stringify!(first_allowedip) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).last_allowedip) as usize - ptr as usize }, - 144usize, - concat!( - "Offset of field: ", - stringify!(wg_peer), - "::", - stringify!(last_allowedip) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).next_peer) as usize - ptr as usize }, - 152usize, - concat!( - "Offset of field: ", - stringify!(wg_peer), - "::", - stringify!(next_peer) - ) - ); -} -#[test] -fn bindgen_test_layout_wg_device() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 112usize, - concat!("Size of: ", stringify!(wg_device)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(wg_device)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).name) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(wg_device), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ifindex) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(wg_device), - "::", - stringify!(ifindex) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(wg_device), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).public_key) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(wg_device), - "::", - stringify!(public_key) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).private_key) as usize - ptr as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(wg_device), - "::", - stringify!(private_key) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).fwmark) as usize - ptr as usize }, - 88usize, - concat!( - "Offset of field: ", - stringify!(wg_device), - "::", - stringify!(fwmark) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).listen_port) as usize - ptr as usize }, - 92usize, - concat!( - "Offset of field: ", - stringify!(wg_device), - "::", - stringify!(listen_port) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).first_peer) as usize - ptr as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(wg_device), - "::", - stringify!(first_peer) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).last_peer) as usize - ptr as usize }, - 104usize, - concat!( - "Offset of field: ", - stringify!(wg_device), - "::", - stringify!(last_peer) - ) - ); -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union in6_addr__bindgen_ty_1 { - pub __u6_addr8: [u8; 16usize], - pub __u6_addr16: [u16; 8usize], - pub __u6_addr32: [u32; 4usize], -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union wg_allowedip__bindgen_ty_1 { - pub ip4: in_addr, - pub ip6: in6_addr, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union wg_endpoint { - pub addr: sockaddr, - pub addr4: sockaddr_in, - pub addr6: sockaddr_in6, -} -impl wg_peer_flags { - pub const WGPEER_REMOVE_ME: wg_peer_flags = wg_peer_flags(1); -} -impl wg_peer_flags { - pub const WGPEER_REPLACE_ALLOWEDIPS: wg_peer_flags = wg_peer_flags(2); -} -impl wg_peer_flags { - pub const WGPEER_HAS_PUBLIC_KEY: wg_peer_flags = wg_peer_flags(4); -} -impl wg_peer_flags { - pub const WGPEER_HAS_PRESHARED_KEY: wg_peer_flags = wg_peer_flags(8); -} -impl wg_peer_flags { - pub const WGPEER_HAS_PERSISTENT_KEEPALIVE_INTERVAL: wg_peer_flags = wg_peer_flags(16); -} -impl ::core::ops::BitOr for wg_peer_flags { - type Output = Self; - #[inline] - fn bitor(self, other: Self) -> Self { - wg_peer_flags(self.0 | other.0) - } -} -impl ::core::ops::BitOrAssign for wg_peer_flags { - #[inline] - fn bitor_assign(&mut self, rhs: wg_peer_flags) { - self.0 |= rhs.0; - } -} -impl ::core::ops::BitAnd for wg_peer_flags { - type Output = Self; - #[inline] - fn bitand(self, other: Self) -> Self { - wg_peer_flags(self.0 & other.0) - } -} -impl ::core::ops::BitAndAssign for wg_peer_flags { - #[inline] - fn bitand_assign(&mut self, rhs: wg_peer_flags) { - self.0 &= rhs.0; - } -} -impl wg_device_flags { - pub const WGDEVICE_REPLACE_PEERS: wg_device_flags = wg_device_flags(1); -} -impl wg_device_flags { - pub const WGDEVICE_HAS_PRIVATE_KEY: wg_device_flags = wg_device_flags(2); -} -impl wg_device_flags { - pub const WGDEVICE_HAS_PUBLIC_KEY: wg_device_flags = wg_device_flags(4); -} -impl wg_device_flags { - pub const WGDEVICE_HAS_LISTEN_PORT: wg_device_flags = wg_device_flags(8); -} -impl wg_device_flags { - pub const WGDEVICE_HAS_FWMARK: wg_device_flags = wg_device_flags(16); -} -impl ::core::ops::BitOr for wg_device_flags { - type Output = Self; - #[inline] - fn bitor(self, other: Self) -> Self { - wg_device_flags(self.0 | other.0) - } -} -impl ::core::ops::BitOrAssign for wg_device_flags { - #[inline] - fn bitor_assign(&mut self, rhs: wg_device_flags) { - self.0 |= rhs.0; - } -} -impl ::core::ops::BitAnd for wg_device_flags { - type Output = Self; - #[inline] - fn bitand(self, other: Self) -> Self { - wg_device_flags(self.0 & other.0) - } -} -impl ::core::ops::BitAndAssign for wg_device_flags { - #[inline] - fn bitand_assign(&mut self, rhs: wg_device_flags) { - self.0 &= rhs.0; - } -} -extern "C" { - #[must_use] - pub fn wg_set_device(dev: *mut wg_device) -> ::core::ffi::c_int; -} -extern "C" { - #[must_use] - pub fn wg_get_device( - dev: *mut *mut wg_device, - device_name: *const ::core::ffi::c_char, - ) -> ::core::ffi::c_int; -} -extern "C" { - #[must_use] - pub fn wg_add_device(device_name: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -extern "C" { - #[must_use] - pub fn wg_del_device(device_name: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -extern "C" { - pub fn wg_free_device(dev: *mut wg_device); -} -extern "C" { - pub fn wg_list_device_names() -> *mut ::core::ffi::c_char; -} -extern "C" { - pub fn wg_key_to_base64(base64: *mut wg_key_b64_string, key: *mut wg_key); -} -extern "C" { - #[must_use] - pub fn wg_key_from_base64( - key: *mut wg_key, - base64: *mut wg_key_b64_string, - ) -> ::core::ffi::c_int; -} -extern "C" { - pub fn wg_key_is_zero(key: *mut wg_key) -> bool; -} -extern "C" { - pub fn wg_generate_public_key(public_key: *mut wg_key, private_key: *mut wg_key); -} -extern "C" { - pub fn wg_generate_private_key(private_key: *mut wg_key); -} -extern "C" { - pub fn wg_generate_preshared_key(preshared_key: *mut wg_key); -} diff --git a/wgbind/src/lib.rs b/wgbind/src/lib.rs index 89f9b0b..11577c4 100644 --- a/wgbind/src/lib.rs +++ b/wgbind/src/lib.rs @@ -5,7 +5,9 @@ use std::{alloc::Layout, ffi::{CStr, CString}}; extern crate libc; - +extern crate wgbindraw_sys; + +use wgbindraw_sys::*;