Skip to content

Commit 4978030

Browse files
feat: Added ifconf struct
fix: skiping ifconf and adding debug trait to ifconf Added ifconf to linux.txt
1 parent 5d572a1 commit 4978030

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

libc-test/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4041,6 +4041,8 @@ fn test_linux(target: &str) {
40414041
(struct_ == "sockaddr_vm" && field == "svm_zero") ||
40424042
// the `ifr_ifru` field is an anonymous union
40434043
(struct_ == "ifreq" && field == "ifr_ifru") ||
4044+
// the `ifc_ifcu` field is an anonymous union
4045+
(struct_ == "ifconf" && field == "ifc_ifcu") ||
40444046
// glibc uses a single array `uregs` instead of individual fields.
40454047
(struct_ == "user_regs" && arm)
40464048
});

libc-test/semver/linux.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3199,6 +3199,7 @@ if_freenameindex
31993199
if_nameindex
32003200
ifaddrs
32013201
ifreq
3202+
ifconf
32023203
in6_ifreq
32033204
in6_pktinfo
32043205
in6_rtmsg

src/unix/linux_like/linux/mod.rs

Lines changed: 34 additions & 1 deletion
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,
@@ -1228,7 +1245,23 @@ cfg_if! {
12281245
.finish()
12291246
}
12301247
}
1231-
1248+
#[cfg(libc_union)]
1249+
impl ::fmt::Debug for __c_anonymous_ifc_ifcu {
1250+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1251+
f.debug_struct("ifr_ifru")
1252+
.field("ifcu_buf", unsafe { &self.ifcu_buf })
1253+
.field("ifcu_req", unsafe { &self.ifcu_req })
1254+
.finish()
1255+
}
1256+
}
1257+
impl ::fmt::Debug for ifconf {
1258+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1259+
f.debug_struct("ifconf")
1260+
.field("ifc_len", &self.ifc_len)
1261+
.field("ifc_ifcu", &self.ifc_ifcu)
1262+
.finish()
1263+
}
1264+
}
12321265
impl ::fmt::Debug for hwtstamp_config {
12331266
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
12341267
f.debug_struct("hwtstamp_config")

0 commit comments

Comments
 (0)