Skip to content

Commit

Permalink
refine code
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Nov 19, 2024
1 parent 4d11403 commit cea3952
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub(crate) mod android;
#[cfg(target_os = "android")]
pub use self::android::{create, Device, PlatformConfig};

// Tip: OpenHarmony is a kind of Linux.
#[cfg(target_env = "ohos")]
pub(crate) mod ohos;
#[cfg(target_env = "ohos")]
Expand Down
2 changes: 1 addition & 1 deletion src/platform/ohos/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::device::AbstractDevice;
use crate::error::{Error, Result};
use crate::platform::posix::{self, Fd, Tun};

/// A TUN device for Android.
/// A TUN device for OpenHarmony.
pub struct Device {
tun: Tun,
}
Expand Down
24 changes: 8 additions & 16 deletions src/platform/ohos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,23 @@ use crate::error::Result;
pub struct PlatformConfig;

impl PlatformConfig {
/// Enable or disable packet information, the first 4 bytes of
/// each packet delivered from/to Linux underlying API is a header with flags and protocol type when enabled.
///
/// [Note: This configuration just applies to the Linux underlying API and is a no-op on tun(i.e. the packets delivered from/to tun always contain no packet information) -- end note].
#[deprecated(
since = "1.0.0",
note = "No effect applies to the packets delivered from/to tun since the packets always contain no header on all platforms."
)]
pub fn packet_information(&mut self, value: bool) -> &mut Self {
/// Dummy functions for compatibility with Linux.
pub fn packet_information(&mut self, _value: bool) -> &mut Self {
self
}

/// Indicated whether tun running in root privilege,
/// since some operations need it such as assigning IP/netmask/destination etc.
pub fn ensure_root_privileges(&mut self, value: bool) -> &mut Self {
/// Dummy functions for compatibility with Linux.
pub fn ensure_root_privileges(&mut self, _value: bool) -> &mut Self {
self
}

/// Enable / Disable IFF_NAPI flag.
pub fn napi(&mut self, value: bool) -> &mut Self {
/// Dummy functions for compatibility with Linux.
pub fn napi(&mut self, _value: bool) -> &mut Self {
self
}

/// Enable / Disable IFF_VNET_HDR flag.
pub fn vnet_hdr(&mut self, value: bool) -> &mut Self {
/// Dummy functions for compatibility with Linux.
pub fn vnet_hdr(&mut self, _value: bool) -> &mut Self {
self
}
}
Expand Down

0 comments on commit cea3952

Please sign in to comment.