Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added ifconf struct #3393

Merged
merged 1 commit into from Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions libc-test/build.rs
Expand Up @@ -4058,6 +4058,8 @@ fn test_linux(target: &str) {
(struct_ == "sockaddr_vm" && field == "svm_zero") ||
// the `ifr_ifru` field is an anonymous union
(struct_ == "ifreq" && field == "ifr_ifru") ||
// the `ifc_ifcu` field is an anonymous union
(struct_ == "ifconf" && field == "ifc_ifcu") ||
// glibc uses a single array `uregs` instead of individual fields.
(struct_ == "user_regs" && arm)
});
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/linux.txt
Expand Up @@ -3211,6 +3211,7 @@ if_freenameindex
if_nameindex
ifaddrs
ifreq
ifconf
in6_ifreq
in6_pktinfo
in6_rtmsg
Expand Down
34 changes: 34 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Expand Up @@ -792,6 +792,23 @@ s_no_extra_traits! {
pub ifr_ifru: ::sockaddr,
}

#[cfg(libc_union)]
pub union __c_anonymous_ifc_ifcu {
Brijeshkrishna marked this conversation as resolved.
Show resolved Hide resolved
pub ifcu_buf: *mut ::c_char,
pub ifcu_req: *mut ::ifreq,
}

/* Structure used in SIOCGIFCONF request. Used to retrieve interface
configuration for machine (useful for programs which must know all
networks accessible). */
pub struct ifconf {
pub ifc_len: ::c_int, /* Size of buffer. */
#[cfg(libc_union)]
pub ifc_ifcu: __c_anonymous_ifc_ifcu,
#[cfg(not(libc_union))]
pub ifc_ifcu: *mut ::ifreq,
}

pub struct hwtstamp_config {
pub flags: ::c_int,
pub tx_type: ::c_int,
Expand Down Expand Up @@ -1229,6 +1246,23 @@ cfg_if! {
}
}

#[cfg(libc_union)]
impl ::fmt::Debug for __c_anonymous_ifc_ifcu {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("ifr_ifru")
.field("ifcu_buf", unsafe { &self.ifcu_buf })
.field("ifcu_req", unsafe { &self.ifcu_req })
.finish()
}
}
impl ::fmt::Debug for ifconf {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("ifconf")
.field("ifc_len", &self.ifc_len)
.field("ifc_ifcu", &self.ifc_ifcu)
.finish()
}
}
impl ::fmt::Debug for hwtstamp_config {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("hwtstamp_config")
Expand Down