27 lines
763 B
Rust
27 lines
763 B
Rust
//! `sys/un.h` implementation.
|
|
//!
|
|
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_un.h.html>.
|
|
|
|
use crate::{header::bits_safamily_t::sa_family_t, platform::types::c_char};
|
|
|
|
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_un.h.html>.
|
|
///
|
|
/// # Implementation
|
|
/// Size of `sun_path` is `108` bytes.
|
|
#[repr(C)]
|
|
pub struct sockaddr_un {
|
|
/// Address family.
|
|
pub sun_family: sa_family_t,
|
|
/// Socket pathname storage.
|
|
pub sun_path: [c_char; 108],
|
|
}
|
|
|
|
impl sockaddr_un {
|
|
pub fn path_offset(&self) -> usize {
|
|
let base = core::ptr::from_ref(self) as usize;
|
|
let path = &raw const self.sun_path as usize;
|
|
log::trace!("base: {:#X}, path: {:#X}", base, path);
|
|
path - base
|
|
}
|
|
}
|