support ohos (#974)

* support ohos

---------

Co-authored-by: FrankHan <2777926911@qq.com>
This commit is contained in:
韩嘉乐
2025-07-02 09:44:45 +08:00
committed by GitHub
parent bf021a9ead
commit 01e491ec07
22 changed files with 668 additions and 21 deletions
+3 -3
View File
@@ -110,7 +110,7 @@ enum PacketProtocol {
// Note: the protocol in the packet information header is platform dependent.
impl PacketProtocol {
#[cfg(any(target_os = "linux", target_os = "android"))]
#[cfg(any(target_os = "linux", target_os = "android", target_env = "ohos"))]
fn into_pi_field(self) -> Result<u16, io::Error> {
use nix::libc;
match self {
@@ -328,7 +328,7 @@ impl VirtualNic {
Ok(tun::create(&config)?)
}
#[cfg(target_os = "android")]
#[cfg(any(target_os = "android", target_env = "ohos"))]
pub async fn create_dev_for_android(
&mut self,
tun_fd: std::os::fd::RawFd,
@@ -690,7 +690,7 @@ impl NicCtx {
Ok(())
}
#[cfg(target_os = "android")]
#[cfg(any(target_os = "android", target_env = "ohos"))]
pub async fn run_for_android(&mut self, tun_fd: std::os::fd::RawFd) -> Result<(), Error> {
let tunnel = {
let mut nic = self.nic.lock().await;