Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,27 @@ jobs:
- name: Run cargo check with all features
run: cargo check --all-features

apple-mobile:
name: Check iOS
runs-on: macOS-latest
strategy:
fail-fast: false
matrix:
target:
- aarch64-apple-ios
- aarch64-apple-ios-sim

steps:
- uses: actions/checkout@v4

- name: Install Rust Toolchain
run: rustup toolchain install stable --profile minimal --no-self-update --target ${{ matrix.target }}

- uses: swatinem/rust-cache@v2

- name: Run cargo check
run: cargo check --target ${{ matrix.target }}

cross:
name: Cross compile
runs-on: ubuntu-latest
Expand Down
20 changes: 19 additions & 1 deletion src/os/darwin/ipv6_addr_flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,32 @@ const IN6_IFF_DUPLICATED: u32 = 0x04;
const IN6_IFF_DEPRECATED: u32 = 0x10;
const IN6_IFF_TEMPORARY: u32 = 0x80;

// `libc` only exposes `in6_ifreq` on macOS (`<netinet6/in6_var.h>` is not part of the
// iOS SDK), so define it here to build for every Apple target. `SIOCGIFAFLAG_IN6` encodes
// `sizeof(struct in6_ifreq)` (0x120 = 288 bytes), so the union is padded to 272 bytes.
#[repr(C)]
struct In6Ifreq {
ifr_name: [libc::c_char; libc::IFNAMSIZ],
ifr_ifru: In6IfreqUnion,
}

#[repr(C)]
union In6IfreqUnion {
ifru_addr: libc::sockaddr_in6,
ifru_flags6: libc::c_int,
// 8-byte aligned, as `in6_ifstat` holds u64 counters.
_size: [u64; 34],
}

pub(crate) fn get_ipv6_addr_flags(ifname: &str, addr: &Ipv6Addr) -> Ipv6AddrFlags {
unsafe {
let fd = libc::socket(libc::AF_INET6, libc::SOCK_DGRAM, 0);
if fd < 0 {
return Ipv6AddrFlags::default();
}

let mut req: libc::in6_ifreq = std::mem::zeroed();
let mut req: In6Ifreq = std::mem::zeroed();
const _: () = assert!(std::mem::size_of::<In6Ifreq>() == 0x120);

let name_bytes = ifname.as_bytes();
let copy_len = name_bytes.len().min(libc::IFNAMSIZ - 1);
Expand Down