Skip to content

Commit 526cb13

Browse files
committed
Auto merge of #2653 - devnexen:fbsd_ifreq_ifconf, r=Amanieu
freebsd add ifconf data.
2 parents 7f1da49 + 619119e commit 526cb13

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

libc-test/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2316,6 +2316,7 @@ fn test_freebsd(target: &str) {
23162316
("if_data", "__ifi_epoch") => true,
23172317
("if_data", "__ifi_lastchange") => true,
23182318
("ifreq", "ifr_ifru") => true,
2319+
("ifconf", "ifc_ifcu") => true,
23192320

23202321
// anonymous struct
23212322
("devstat", "dev_links") => true,

libc-test/semver/freebsd.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,8 @@ idtype_t
15361536
if_freenameindex
15371537
if_nameindex
15381538
ifaddrs
1539+
ifconf
1540+
ifreq
15391541
in6_pktinfo
15401542
initgroups
15411543
ip_mreqn

src/unix/bsd/freebsdlike/freebsd/mod.rs

+44
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,13 @@ s! {
960960
pub sc_ngroups: ::c_int,
961961
pub sc_groups: [::gid_t; 1],
962962
}
963+
964+
pub struct ifconf {
965+
pub ifc_len: ::c_int,
966+
#[cfg(libc_union)]
967+
pub ifc_ifcu: __c_anonymous_ifc_ifcu,
968+
}
969+
963970
}
964971

965972
s_no_extra_traits! {
@@ -1142,6 +1149,12 @@ s_no_extra_traits! {
11421149
pub ifr_ifru: ::sockaddr,
11431150
}
11441151

1152+
#[cfg(libc_union)]
1153+
pub union __c_anonymous_ifc_ifcu {
1154+
pub ifcu_buf: ::caddr_t,
1155+
pub ifcu_req: *mut ifreq,
1156+
}
1157+
11451158
pub struct ifstat {
11461159
/// if name, e.g. "en0"
11471160
pub ifs_name: [::c_char; ::IFNAMSIZ as usize],
@@ -1549,6 +1562,37 @@ cfg_if! {
15491562
}
15501563
}
15511564

1565+
#[cfg(libc_union)]
1566+
impl Eq for __c_anonymous_ifc_ifcu {}
1567+
1568+
#[cfg(libc_union)]
1569+
impl PartialEq for __c_anonymous_ifc_ifcu {
1570+
fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool {
1571+
unsafe {
1572+
self.ifcu_buf == other.ifcu_buf &&
1573+
self.ifcu_req == other.ifcu_req
1574+
}
1575+
}
1576+
}
1577+
1578+
#[cfg(libc_union)]
1579+
impl ::fmt::Debug for __c_anonymous_ifc_ifcu {
1580+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1581+
f.debug_struct("ifc_ifcu")
1582+
.field("ifcu_buf", unsafe { &self.ifcu_buf })
1583+
.field("ifcu_req", unsafe { &self.ifcu_req })
1584+
.finish()
1585+
}
1586+
}
1587+
1588+
#[cfg(libc_union)]
1589+
impl ::hash::Hash for __c_anonymous_ifc_ifcu {
1590+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
1591+
unsafe { self.ifcu_buf.hash(state) };
1592+
unsafe { self.ifcu_req.hash(state) };
1593+
}
1594+
}
1595+
15521596
impl PartialEq for ifstat {
15531597
fn eq(&self, other: &ifstat) -> bool {
15541598
let self_ascii: &[::c_char] = &self.ascii;

0 commit comments

Comments
 (0)