Skip to content

Commit c47184c

Browse files
committed
support ohos
1 parent 34d6ca3 commit c47184c

File tree

4 files changed

+6
-33
lines changed

4 files changed

+6
-33
lines changed

src/device.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,4 @@ pub trait AbstractDevice: Read + Write {
9393
///
9494
/// [Note: This value is not used to specify whether the packets delivered from/to tun2 have packet information. -- end note]
9595
fn packet_information(&self) -> bool;
96-
fn tun_index(&self) -> Result<i32>;
9796
}

src/platform/ohos/device.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ impl Write for Device {
9797
}
9898

9999
impl AbstractDevice for Device {
100-
fn tun_index(&self) -> Result<i32> {
101-
Err(Error::NotImplemented)
102-
}
103-
104100
fn tun_name(&self) -> Result<String> {
105101
Ok("vpn-tun".to_string())
106102
}

src/platform/ohos/mod.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,6 @@ use crate::error::Result;
2525
#[derive(Copy, Clone, Default, Debug)]
2626
pub struct PlatformConfig;
2727

28-
impl PlatformConfig {
29-
/// Dummy functions for compatibility with Linux.
30-
pub fn packet_information(&mut self, _value: bool) -> &mut Self {
31-
self
32-
}
33-
34-
/// Dummy functions for compatibility with Linux.
35-
pub fn ensure_root_privileges(&mut self, _value: bool) -> &mut Self {
36-
self
37-
}
38-
39-
/// Dummy functions for compatibility with Linux.
40-
pub fn napi(&mut self, _value: bool) -> &mut Self {
41-
self
42-
}
43-
44-
/// Dummy functions for compatibility with Linux.
45-
pub fn vnet_hdr(&mut self, _value: bool) -> &mut Self {
46-
self
47-
}
48-
}
49-
5028
/// Create a TUN device with the given name.
5129
pub fn create(configuration: &Configuration) -> Result<Device> {
5230
Device::new(configuration)

src/platform/posix/sockaddr.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ fn rs_addr_to_sockaddr(addr: std::net::SocketAddr) -> sockaddr_union {
3939
{
4040
addr.addr4.sin_len = std::mem::size_of::<libc::sockaddr_in>() as u8;
4141
}
42-
unsafe { addr.addr4.sin_family = libc::AF_INET as libc::sa_family_t; }
43-
unsafe { addr.addr4.sin_addr.s_addr = u32::from_ne_bytes(ipv4.ip().octets()); }
44-
unsafe { addr.addr4.sin_port = ipv4.port().to_be(); }
42+
addr.addr4.sin_family = libc::AF_INET as libc::sa_family_t;
43+
addr.addr4.sin_addr.s_addr = u32::from_ne_bytes(ipv4.ip().octets());
44+
addr.addr4.sin_port = ipv4.port().to_be();
4545
addr
4646
}
4747
std::net::SocketAddr::V6(ipv6) => {
@@ -50,9 +50,9 @@ fn rs_addr_to_sockaddr(addr: std::net::SocketAddr) -> sockaddr_union {
5050
{
5151
addr.addr6.sin6_len = std::mem::size_of::<libc::sockaddr_in6>() as u8;
5252
}
53-
unsafe { addr.addr6.sin6_family = libc::AF_INET6 as libc::sa_family_t; }
54-
unsafe { addr.addr6.sin6_addr.s6_addr = ipv6.ip().octets(); }
55-
unsafe { addr.addr6.sin6_port = ipv6.port().to_be(); }
53+
addr.addr6.sin6_family = libc::AF_INET6 as libc::sa_family_t;
54+
addr.addr6.sin6_addr.s6_addr = ipv6.ip().octets();
55+
addr.addr6.sin6_port = ipv6.port().to_be();
5656
addr
5757
}
5858
}

0 commit comments

Comments
 (0)