Skip to content

Commit 8498879

Browse files
committed
Auto merge of #3393 - Brijeshkrishna:main, r=JohnTitor
feat: Added ifconf struct Adding ifconf struct As per defined in C ```c struct ifconf { int ifc_len; /* Size of buffer. */ union { __caddr_t ifcu_buf; struct ifreq *ifcu_req; } ifc_ifcu; }; ```
2 parents f367fa2 + 66c4a5e commit 8498879

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

libc-test/build.rs

+2
Original file line numberDiff line numberDiff line change
@@ -4086,6 +4086,8 @@ fn test_linux(target: &str) {
40864086
(struct_ == "sockaddr_vm" && field == "svm_zero") ||
40874087
// the `ifr_ifru` field is an anonymous union
40884088
(struct_ == "ifreq" && field == "ifr_ifru") ||
4089+
// the `ifc_ifcu` field is an anonymous union
4090+
(struct_ == "ifconf" && field == "ifc_ifcu") ||
40894091
// glibc uses a single array `uregs` instead of individual fields.
40904092
(struct_ == "user_regs" && arm)
40914093
});

libc-test/semver/linux.txt

+1
Original file line numberDiff line numberDiff line change
@@ -3250,6 +3250,7 @@ if_freenameindex
32503250
if_nameindex
32513251
ifaddrs
32523252
ifreq
3253+
ifconf
32533254
in6_ifreq
32543255
in6_pktinfo
32553256
in6_rtmsg

src/unix/linux_like/linux/mod.rs

+34
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,23 @@ s_no_extra_traits! {
792792
pub ifr_ifru: ::sockaddr,
793793
}
794794

795+
#[cfg(libc_union)]
796+
pub union __c_anonymous_ifc_ifcu {
797+
pub ifcu_buf: *mut ::c_char,
798+
pub ifcu_req: *mut ::ifreq,
799+
}
800+
801+
/* Structure used in SIOCGIFCONF request. Used to retrieve interface
802+
configuration for machine (useful for programs which must know all
803+
networks accessible). */
804+
pub struct ifconf {
805+
pub ifc_len: ::c_int, /* Size of buffer. */
806+
#[cfg(libc_union)]
807+
pub ifc_ifcu: __c_anonymous_ifc_ifcu,
808+
#[cfg(not(libc_union))]
809+
pub ifc_ifcu: *mut ::ifreq,
810+
}
811+
795812
pub struct hwtstamp_config {
796813
pub flags: ::c_int,
797814
pub tx_type: ::c_int,
@@ -1229,6 +1246,23 @@ cfg_if! {
12291246
}
12301247
}
12311248

1249+
#[cfg(libc_union)]
1250+
impl ::fmt::Debug for __c_anonymous_ifc_ifcu {
1251+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1252+
f.debug_struct("ifr_ifru")
1253+
.field("ifcu_buf", unsafe { &self.ifcu_buf })
1254+
.field("ifcu_req", unsafe { &self.ifcu_req })
1255+
.finish()
1256+
}
1257+
}
1258+
impl ::fmt::Debug for ifconf {
1259+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1260+
f.debug_struct("ifconf")
1261+
.field("ifc_len", &self.ifc_len)
1262+
.field("ifc_ifcu", &self.ifc_ifcu)
1263+
.finish()
1264+
}
1265+
}
12321266
impl ::fmt::Debug for hwtstamp_config {
12331267
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
12341268
f.debug_struct("hwtstamp_config")

0 commit comments

Comments
 (0)