Skip to content

Commit 42a7ec1

Browse files
committed
Auto merge of #3487 - arctic-alpaca:main, r=JohnTitor
Add `ifreq`, `ifconf` and related constants to Android Hi, this adds `ifreq`, `ifconf` and all related constants defined in Android to Android. I also added missing symbols to `semver/linux.txt`.
2 parents add5f9b + ba4dd05 commit 42a7ec1

File tree

4 files changed

+195
-15
lines changed

4 files changed

+195
-15
lines changed

libc-test/build.rs

+2-15
Original file line numberDiff line numberDiff line change
@@ -1979,21 +1979,6 @@ fn test_android(target: &str) {
19791979
(struct_ == "flock64" && (field == "l_start" || field == "l_len"))
19801980
});
19811981

1982-
cfg.skip_field(move |struct_, field| {
1983-
// this is actually a union on linux, so we can't represent it well and
1984-
// just insert some padding.
1985-
(struct_ == "siginfo_t" && field == "_pad") ||
1986-
// FIXME: `sa_sigaction` has type `sighandler_t` but that type is
1987-
// incorrect, see: https://github.com/rust-lang/libc/issues/1359
1988-
(struct_ == "sigaction" && field == "sa_sigaction") ||
1989-
// sigev_notify_thread_id is actually part of a sigev_un union
1990-
(struct_ == "sigevent" && field == "sigev_notify_thread_id") ||
1991-
// signalfd had SIGSYS fields added in Android 4.19, but CI does not have that version yet.
1992-
(struct_ == "signalfd_siginfo" && (field == "ssi_syscall" ||
1993-
field == "ssi_call_addr" ||
1994-
field == "ssi_arch"))
1995-
});
1996-
19971982
cfg.skip_field(|struct_, field| {
19981983
match (struct_, field) {
19991984
// conflicting with `p_type` macro from <resolve.h>.
@@ -2003,6 +1988,8 @@ fn test_android(target: &str) {
20031988
// this is actually a union on linux, so we can't represent it well and
20041989
// just insert some padding.
20051990
("siginfo_t", "_pad") => true,
1991+
("ifreq", "ifr_ifru") => true,
1992+
("ifconf", "ifc_ifcu") => true,
20061993

20071994
_ => false,
20081995
}

libc-test/semver/android.txt

+44
Original file line numberDiff line numberDiff line change
@@ -2241,7 +2241,44 @@ SIOCADDMULTI
22412241
SIOCADDRT
22422242
SIOCDARP
22432243
SIOCDELMULTI
2244+
SIOCGIFINDEX
2245+
SIOGIFINDEX
2246+
SIOCSIFPFLAGS
2247+
SIOCGIFPFLAGS
2248+
SIOCDIFADDR
2249+
SIOCSIFHWBROADCAST
2250+
SIOCGIFCOUNT
2251+
SIOCGIFBR
2252+
SIOCSIFBR
2253+
SIOCGIFTXQLEN
2254+
SIOCSIFTXQLEN
2255+
SIOCETHTOOL
2256+
SIOCGMIIPHY
2257+
SIOCGMIIREG
2258+
SIOCSMIIREG
2259+
SIOCWANDEV
2260+
SIOCOUTQNSD
2261+
SIOCGSKNS
2262+
SIOCADDDLCI
2263+
SIOCDELDLCI
2264+
SIOCGIFVLAN
2265+
SIOCSIFVLAN
2266+
SIOCBONDENSLAVE
2267+
SIOCBONDRELEASE
2268+
SIOCBONDSETHWADDR
2269+
SIOCBONDSLAVEINFOQUERY
2270+
SIOCBONDINFOQUERY
2271+
SIOCBONDCHANGEACTIVE
2272+
SIOCBRADDBR
2273+
SIOCBRDELBR
2274+
SIOCBRADDIF
2275+
SIOCBRDELIF
2276+
SIOCSHWTSTAMP
2277+
SIOCGHWTSTAMP
2278+
SIOCDEVPRIVATE
2279+
SIOCPROTOPRIVATE
22442280
SIOCDELRT
2281+
SIOCRTMSG
22452282
SIOCDRARP
22462283
SIOCGARP
22472284
SIOCGIFADDR
@@ -2250,6 +2287,7 @@ SIOCGIFCONF
22502287
SIOCGIFDSTADDR
22512288
SIOCGIFENCAP
22522289
SIOCGIFFLAGS
2290+
SIOCSIFNAME
22532291
SIOCGIFHWADDR
22542292
SIOCGIFMAP
22552293
SIOCGIFMEM
@@ -3223,10 +3261,16 @@ group
32233261
hostent
32243262
id_t
32253263
idtype_t
3264+
ifconf
3265+
ifreq
3266+
__c_anonymous_ifc_ifcu
3267+
__c_anonymous_ifr_ifru
3268+
__c_anonymous_ifru_map
32263269
if_indextoname
32273270
if_nametoindex
32283271
ifaddrs
32293272
in6_addr
3273+
in6_ifreq
32303274
in6_pktinfo
32313275
in6_rtmsg
32323276
in_addr

libc-test/semver/linux.txt

+4
Original file line numberDiff line numberDiff line change
@@ -2475,6 +2475,7 @@ SIOCSIFMAP
24752475
SIOCSIFMEM
24762476
SIOCSIFMETRIC
24772477
SIOCSIFMTU
2478+
SIOCSIFNAME
24782479
SIOCSIFNETMASK
24792480
SIOCSIFPFLAGS
24802481
SIOCSIFSLAVE
@@ -3860,3 +3861,6 @@ wait4
38603861
waitid
38613862
eventfd_read
38623863
eventfd_write
3864+
__c_anonymous_ifru_map
3865+
__c_anonymous_ifr_ifru
3866+
__c_anonymous_ifc_ifcu

src/unix/linux_like/android/mod.rs

+145
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,22 @@ s! {
496496
pub flag: *mut ::c_int,
497497
pub val: ::c_int,
498498
}
499+
500+
pub struct __c_anonymous_ifru_map {
501+
pub mem_start: ::c_ulong,
502+
pub mem_end: ::c_ulong,
503+
pub base_addr: ::c_ushort,
504+
pub irq: ::c_uchar,
505+
pub dma: ::c_uchar,
506+
pub port: ::c_uchar,
507+
}
508+
509+
pub struct in6_ifreq {
510+
pub ifr6_addr: ::in6_addr,
511+
pub ifr6_prefixlen: u32,
512+
pub ifr6_ifindex: ::c_int,
513+
}
514+
499515
}
500516

501517
s_no_extra_traits! {
@@ -591,6 +607,50 @@ s_no_extra_traits! {
591607
__serial: ::c_uint,
592608
__value: [[::c_char; 4]; 23],
593609
}
610+
611+
#[cfg(libc_union)]
612+
pub union __c_anonymous_ifr_ifru {
613+
pub ifru_addr: ::sockaddr,
614+
pub ifru_dstaddr: ::sockaddr,
615+
pub ifru_broadaddr: ::sockaddr,
616+
pub ifru_netmask: ::sockaddr,
617+
pub ifru_hwaddr: ::sockaddr,
618+
pub ifru_flags: ::c_short,
619+
pub ifru_ifindex: ::c_int,
620+
pub ifru_metric: ::c_int,
621+
pub ifru_mtu: ::c_int,
622+
pub ifru_map: __c_anonymous_ifru_map,
623+
pub ifru_slave: [::c_char; ::IFNAMSIZ],
624+
pub ifru_newname: [::c_char; ::IFNAMSIZ],
625+
pub ifru_data: *mut ::c_char,
626+
}
627+
628+
pub struct ifreq {
629+
/// interface name, e.g. "en0"
630+
pub ifr_name: [::c_char; ::IFNAMSIZ],
631+
#[cfg(libc_union)]
632+
pub ifr_ifru: __c_anonymous_ifr_ifru,
633+
#[cfg(not(libc_union))]
634+
pub ifr_ifru: ::sockaddr,
635+
}
636+
637+
#[cfg(libc_union)]
638+
pub union __c_anonymous_ifc_ifcu {
639+
pub ifcu_buf: *mut ::c_char,
640+
pub ifcu_req: *mut ::ifreq,
641+
}
642+
643+
/* Structure used in SIOCGIFCONF request. Used to retrieve interface
644+
configuration for machine (useful for programs which must know all
645+
networks accessible). */
646+
pub struct ifconf {
647+
pub ifc_len: ::c_int, /* Size of buffer. */
648+
#[cfg(libc_union)]
649+
pub ifc_ifcu: __c_anonymous_ifc_ifcu,
650+
#[cfg(not(libc_union))]
651+
pub ifc_ifcu: *mut ::ifreq,
652+
}
653+
594654
}
595655

596656
cfg_if! {
@@ -938,6 +998,53 @@ cfg_if! {
938998
}
939999
}
9401000

1001+
#[cfg(libc_union)]
1002+
impl ::fmt::Debug for __c_anonymous_ifr_ifru {
1003+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1004+
f.debug_struct("ifr_ifru")
1005+
.field("ifru_addr", unsafe { &self.ifru_addr })
1006+
.field("ifru_dstaddr", unsafe { &self.ifru_dstaddr })
1007+
.field("ifru_broadaddr", unsafe { &self.ifru_broadaddr })
1008+
.field("ifru_netmask", unsafe { &self.ifru_netmask })
1009+
.field("ifru_hwaddr", unsafe { &self.ifru_hwaddr })
1010+
.field("ifru_flags", unsafe { &self.ifru_flags })
1011+
.field("ifru_ifindex", unsafe { &self.ifru_ifindex })
1012+
.field("ifru_metric", unsafe { &self.ifru_metric })
1013+
.field("ifru_mtu", unsafe { &self.ifru_mtu })
1014+
.field("ifru_map", unsafe { &self.ifru_map })
1015+
.field("ifru_slave", unsafe { &self.ifru_slave })
1016+
.field("ifru_newname", unsafe { &self.ifru_newname })
1017+
.field("ifru_data", unsafe { &self.ifru_data })
1018+
.finish()
1019+
}
1020+
}
1021+
impl ::fmt::Debug for ifreq {
1022+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1023+
f.debug_struct("ifreq")
1024+
.field("ifr_name", &self.ifr_name)
1025+
.field("ifr_ifru", &self.ifr_ifru)
1026+
.finish()
1027+
}
1028+
}
1029+
1030+
#[cfg(libc_union)]
1031+
impl ::fmt::Debug for __c_anonymous_ifc_ifcu {
1032+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1033+
f.debug_struct("ifr_ifru")
1034+
.field("ifcu_buf", unsafe { &self.ifcu_buf })
1035+
.field("ifcu_req", unsafe { &self.ifcu_req })
1036+
.finish()
1037+
}
1038+
}
1039+
impl ::fmt::Debug for ifconf {
1040+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1041+
f.debug_struct("ifconf")
1042+
.field("ifc_len", &self.ifc_len)
1043+
.field("ifc_ifcu", &self.ifc_ifcu)
1044+
.finish()
1045+
}
1046+
}
1047+
9411048
#[allow(deprecated)]
9421049
impl af_alg_iv {
9431050
fn as_slice(&self) -> &[u8] {
@@ -2715,6 +2822,7 @@ pub const NFEA_DONT_REFRESH: ::c_ushort = 2;
27152822

27162823
pub const SIOCADDRT: ::c_ulong = 0x0000890B;
27172824
pub const SIOCDELRT: ::c_ulong = 0x0000890C;
2825+
pub const SIOCRTMSG: ::c_ulong = 0x0000890D;
27182826
pub const SIOCGIFNAME: ::c_ulong = 0x00008910;
27192827
pub const SIOCSIFLINK: ::c_ulong = 0x00008911;
27202828
pub const SIOCGIFCONF: ::c_ulong = 0x00008912;
@@ -2734,6 +2842,7 @@ pub const SIOCGIFMEM: ::c_ulong = 0x0000891F;
27342842
pub const SIOCSIFMEM: ::c_ulong = 0x00008920;
27352843
pub const SIOCGIFMTU: ::c_ulong = 0x00008921;
27362844
pub const SIOCSIFMTU: ::c_ulong = 0x00008922;
2845+
pub const SIOCSIFNAME: ::c_ulong = 0x00008923;
27372846
pub const SIOCSIFHWADDR: ::c_ulong = 0x00008924;
27382847
pub const SIOCGIFENCAP: ::c_ulong = 0x00008925;
27392848
pub const SIOCSIFENCAP: ::c_ulong = 0x00008926;
@@ -2742,6 +2851,24 @@ pub const SIOCGIFSLAVE: ::c_ulong = 0x00008929;
27422851
pub const SIOCSIFSLAVE: ::c_ulong = 0x00008930;
27432852
pub const SIOCADDMULTI: ::c_ulong = 0x00008931;
27442853
pub const SIOCDELMULTI: ::c_ulong = 0x00008932;
2854+
pub const SIOCGIFINDEX: ::c_ulong = 0x00008933;
2855+
pub const SIOGIFINDEX: ::c_ulong = SIOCGIFINDEX;
2856+
pub const SIOCSIFPFLAGS: ::c_ulong = 0x00008934;
2857+
pub const SIOCGIFPFLAGS: ::c_ulong = 0x00008935;
2858+
pub const SIOCDIFADDR: ::c_ulong = 0x00008936;
2859+
pub const SIOCSIFHWBROADCAST: ::c_ulong = 0x00008937;
2860+
pub const SIOCGIFCOUNT: ::c_ulong = 0x00008938;
2861+
pub const SIOCGIFBR: ::c_ulong = 0x00008940;
2862+
pub const SIOCSIFBR: ::c_ulong = 0x00008941;
2863+
pub const SIOCGIFTXQLEN: ::c_ulong = 0x00008942;
2864+
pub const SIOCSIFTXQLEN: ::c_ulong = 0x00008943;
2865+
pub const SIOCETHTOOL: ::c_ulong = 0x00008946;
2866+
pub const SIOCGMIIPHY: ::c_ulong = 0x00008947;
2867+
pub const SIOCGMIIREG: ::c_ulong = 0x00008948;
2868+
pub const SIOCSMIIREG: ::c_ulong = 0x00008949;
2869+
pub const SIOCWANDEV: ::c_ulong = 0x0000894A;
2870+
pub const SIOCOUTQNSD: ::c_ulong = 0x0000894B;
2871+
pub const SIOCGSKNS: ::c_ulong = 0x0000894C;
27452872
pub const SIOCDARP: ::c_ulong = 0x00008953;
27462873
pub const SIOCGARP: ::c_ulong = 0x00008954;
27472874
pub const SIOCSARP: ::c_ulong = 0x00008955;
@@ -2750,6 +2877,24 @@ pub const SIOCGRARP: ::c_ulong = 0x00008961;
27502877
pub const SIOCSRARP: ::c_ulong = 0x00008962;
27512878
pub const SIOCGIFMAP: ::c_ulong = 0x00008970;
27522879
pub const SIOCSIFMAP: ::c_ulong = 0x00008971;
2880+
pub const SIOCADDDLCI: ::c_ulong = 0x00008980;
2881+
pub const SIOCDELDLCI: ::c_ulong = 0x00008981;
2882+
pub const SIOCGIFVLAN: ::c_ulong = 0x00008982;
2883+
pub const SIOCSIFVLAN: ::c_ulong = 0x00008983;
2884+
pub const SIOCBONDENSLAVE: ::c_ulong = 0x00008990;
2885+
pub const SIOCBONDRELEASE: ::c_ulong = 0x00008991;
2886+
pub const SIOCBONDSETHWADDR: ::c_ulong = 0x00008992;
2887+
pub const SIOCBONDSLAVEINFOQUERY: ::c_ulong = 0x00008993;
2888+
pub const SIOCBONDINFOQUERY: ::c_ulong = 0x00008994;
2889+
pub const SIOCBONDCHANGEACTIVE: ::c_ulong = 0x00008995;
2890+
pub const SIOCBRADDBR: ::c_ulong = 0x000089a0;
2891+
pub const SIOCBRDELBR: ::c_ulong = 0x000089a1;
2892+
pub const SIOCBRADDIF: ::c_ulong = 0x000089a2;
2893+
pub const SIOCBRDELIF: ::c_ulong = 0x000089a3;
2894+
pub const SIOCSHWTSTAMP: ::c_ulong = 0x000089b0;
2895+
pub const SIOCGHWTSTAMP: ::c_ulong = 0x000089b1;
2896+
pub const SIOCDEVPRIVATE: ::c_ulong = 0x000089F0;
2897+
pub const SIOCPROTOPRIVATE: ::c_ulong = 0x000089E0;
27532898

27542899
// linux/module.h
27552900
pub const MODULE_INIT_IGNORE_MODVERSIONS: ::c_uint = 0x0001;

0 commit comments

Comments
 (0)