Add sockaddr_dl for all bsdlike

This commit is contained in:
luozijun 2017-12-12 11:24:00 +08:00
parent 0061cc9510
commit 789fd5eb81
7 changed files with 60 additions and 32 deletions

View File

@ -180,9 +180,9 @@ fn main() {
if bsdlike {
cfg.header("sys/event.h");
cfg.header("net/if_dl.h");
if freebsd {
cfg.header("libutil.h");
cfg.header("net/if_dl.h");
} else {
cfg.header("util.h");
}

View File

@ -221,21 +221,6 @@ s! {
pub sin_zero: [::c_char; 8],
}
// https://github.com/apple/darwin-xnu
// /blob/master/bsd/net/if_dl.h#L95
pub struct sockaddr_dl {
pub sdl_len: ::c_uchar,
pub sdl_family: ::c_uchar,
pub sdl_index: ::c_ushort,
pub sdl_type: ::c_uchar,
pub sdl_nlen: ::c_uchar,
pub sdl_alen: ::c_uchar,
pub sdl_slen: ::c_uchar,
pub sdl_data: [::c_char; 12],
pub sdl_rcf: ::c_ushort,
pub sdl_route: [::c_ushort; 16],
}
pub struct statfs {
pub f_bsize: ::uint32_t,
pub f_iosize: ::int32_t,
@ -491,6 +476,19 @@ s! {
pub cmd: u32,
pub cmdsize: u32,
}
pub struct sockaddr_dl {
pub sdl_len: ::c_uchar,
pub sdl_family: ::c_uchar,
pub sdl_index: ::c_ushort,
pub sdl_type: ::c_uchar,
pub sdl_nlen: ::c_uchar,
pub sdl_alen: ::c_uchar,
pub sdl_slen: ::c_uchar,
pub sdl_data: [::c_char; 12],
pub sdl_rcf: ::c_ushort,
pub sdl_route: [::c_ushort; 16],
}
}
pub const _UTX_USERSIZE: usize = 256;

View File

@ -168,6 +168,19 @@ s! {
pub ifm_index: ::c_ushort,
pub ifm_data: if_data,
}
pub struct sockaddr_dl {
pub sdl_len: ::c_uchar,
pub sdl_family: ::c_uchar,
pub sdl_index: ::c_ushort,
pub sdl_type: ::c_uchar,
pub sdl_nlen: ::c_uchar,
pub sdl_alen: ::c_uchar,
pub sdl_slen: ::c_uchar,
pub sdl_data: [::c_char; 12],
pub sdl_rcf: ::c_ushort,
pub sdl_route: [::c_ushort; 16],
}
}
pub const RAND_MAX: ::c_int = 0x7fff_ffff;

View File

@ -135,6 +135,17 @@ s! {
pub cr_groups: [::gid_t;16],
__cr_unused1: *mut ::c_void,
}
pub struct sockaddr_dl {
pub sdl_len: ::c_uchar,
pub sdl_family: ::c_uchar,
pub sdl_index: ::c_ushort,
pub sdl_type: ::c_uchar,
pub sdl_nlen: ::c_uchar,
pub sdl_alen: ::c_uchar,
pub sdl_slen: ::c_uchar,
pub sdl_data: [::c_char; 46],
}
}
pub const SIGEV_THREAD_ID: ::c_int = 4;

View File

@ -160,22 +160,6 @@ s! {
pub int_n_sign_posn: ::c_char,
}
// See /usr/include/net/if_dl.h
// sdl_data does not match if_dl.h on OS X,
// since the size of 12 is a minimum.
// Will be unsafe
// when sdl_nlen > 40.
pub struct sockaddr_dl {
pub sdl_len: ::c_uchar,
pub sdl_family: ::c_uchar,
pub sdl_index: ::c_ushort,
pub sdl_type: ::c_uchar,
pub sdl_nlen: ::c_uchar,
pub sdl_alen: ::c_uchar,
pub sdl_slen: ::c_uchar,
pub sdl_data: [::c_char; 46],
}
pub struct cmsgcred {
pub cmcred_pid: ::pid_t,
pub cmcred_uid: ::uid_t,

View File

@ -293,6 +293,17 @@ s! {
pub sc_ngroups: ::c_int,
pub sc_groups: [::gid_t; 1],
}
pub struct sockaddr_dl {
pub sdl_len: ::c_uchar,
pub sdl_family: ::c_uchar,
pub sdl_index: ::c_ushort,
pub sdl_type: ::uint8_t,
pub sdl_nlen: ::uint8_t,
pub sdl_alen: ::uint8_t,
pub sdl_slen: ::uint8_t,
pub sdl_data: [::c_char; 12],
}
}
pub const AT_FDCWD: ::c_int = -100;

View File

@ -176,6 +176,17 @@ s! {
pub ifm_xflags: ::c_int,
pub ifm_data: if_data,
}
pub struct sockaddr_dl {
pub sdl_len: ::c_uchar,
pub sdl_family: ::c_uchar,
pub sdl_index: ::c_ushort,
pub sdl_type: ::c_uchar,
pub sdl_nlen: ::c_uchar,
pub sdl_alen: ::c_uchar,
pub sdl_slen: ::c_uchar,
pub sdl_data: [::c_char; 24],
}
}
pub const UT_NAMESIZE: usize = 32;