Skip to content

Commit

Permalink
Add ifreq, ifconf and related constants to Android
Browse files Browse the repository at this point in the history
  • Loading branch information
arctic-alpaca committed Dec 19, 2023
1 parent 23b49bb commit 8fc4f23
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 0 deletions.
43 changes: 43 additions & 0 deletions libc-test/semver/android.txt
Expand Up @@ -2241,7 +2241,44 @@ SIOCADDMULTI
SIOCADDRT
SIOCDARP
SIOCDELMULTI
SIOCGIFINDEX
SIOGIFINDEX
SIOCSIFPFLAGS
SIOCGIFPFLAGS
SIOCDIFADDR
SIOCSIFHWBROADCAST
SIOCGIFCOUNT
SIOCGIFBR
SIOCSIFBR
SIOCGIFTXQLEN
SIOCSIFTXQLEN
SIOCETHTOOL
SIOCGMIIPHY
SIOCGMIIREG
SIOCSMIIREG
SIOCWANDEV
SIOCOUTQNSD
SIOCGSKNS
SIOCADDDLCI
SIOCDELDLCI
SIOCGIFVLAN
SIOCSIFVLAN
SIOCBONDENSLAVE
SIOCBONDRELEASE
SIOCBONDSETHWADDR
SIOCBONDSLAVEINFOQUERY
SIOCBONDINFOQUERY
SIOCBONDCHANGEACTIVE
SIOCBRADDBR
SIOCBRDELBR
SIOCBRADDIF
SIOCBRDELIF
SIOCSHWTSTAMP
SIOCGHWTSTAMP
SIOCDEVPRIVATE
SIOCPROTOPRIVATE
SIOCDELRT
SIOCRTMSG
SIOCDRARP
SIOCGARP
SIOCGIFADDR
Expand All @@ -2250,6 +2287,7 @@ SIOCGIFCONF
SIOCGIFDSTADDR
SIOCGIFENCAP
SIOCGIFFLAGS
SIOCSIFNAME
SIOCGIFHWADDR
SIOCGIFMAP
SIOCGIFMEM
Expand Down Expand Up @@ -3223,6 +3261,11 @@ group
hostent
id_t
idtype_t
ifconf
ifreq
__c_anonymous_ifc_ifcu
__c_anonymous_ifr_ifru
__c_anonymous_ifru_map
if_indextoname
if_nametoindex
ifaddrs
Expand Down
91 changes: 91 additions & 0 deletions src/unix/linux_like/android/mod.rs
Expand Up @@ -496,6 +496,15 @@ s! {
pub flag: *mut ::c_int,
pub val: ::c_int,
}

pub struct __c_anonymous_ifru_map {
pub mem_start: ::c_ulong,
pub mem_end: ::c_ulong,
pub base_addr: ::c_ushort,
pub irq: ::c_uchar,
pub dma: ::c_uchar,
pub port: ::c_uchar,
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -591,6 +600,50 @@ s_no_extra_traits! {
__serial: ::c_uint,
__value: [[::c_char; 4]; 23],
}

#[cfg(libc_union)]
pub union __c_anonymous_ifr_ifru {
pub ifru_addr: ::sockaddr,
pub ifru_dstaddr: ::sockaddr,
pub ifru_broadaddr: ::sockaddr,
pub ifru_netmask: ::sockaddr,
pub ifru_hwaddr: ::sockaddr,
pub ifru_flags: ::c_short,
pub ifru_ifindex: ::c_int,
pub ifru_metric: ::c_int,
pub ifru_mtu: ::c_int,
pub ifru_map: __c_anonymous_ifru_map,
pub ifru_slave: [::c_char; ::IFNAMSIZ],
pub ifru_newname: [::c_char; ::IFNAMSIZ],
pub ifru_data: *mut ::c_char,
}

pub struct ifreq {
/// interface name, e.g. "en0"
pub ifr_name: [::c_char; ::IFNAMSIZ],
#[cfg(libc_union)]
pub ifr_ifru: __c_anonymous_ifr_ifru,
#[cfg(not(libc_union))]
pub ifr_ifru: ::sockaddr,
}

#[cfg(libc_union)]
pub union __c_anonymous_ifc_ifcu {
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,
}

}

cfg_if! {
Expand Down Expand Up @@ -2715,6 +2768,7 @@ pub const NFEA_DONT_REFRESH: ::c_ushort = 2;

pub const SIOCADDRT: ::c_ulong = 0x0000890B;
pub const SIOCDELRT: ::c_ulong = 0x0000890C;
pub const SIOCRTMSG: ::c_ulong = 0x0000890D;
pub const SIOCGIFNAME: ::c_ulong = 0x00008910;
pub const SIOCSIFLINK: ::c_ulong = 0x00008911;
pub const SIOCGIFCONF: ::c_ulong = 0x00008912;
Expand All @@ -2734,6 +2788,7 @@ pub const SIOCGIFMEM: ::c_ulong = 0x0000891F;
pub const SIOCSIFMEM: ::c_ulong = 0x00008920;
pub const SIOCGIFMTU: ::c_ulong = 0x00008921;
pub const SIOCSIFMTU: ::c_ulong = 0x00008922;
pub const SIOCSIFNAME: ::c_ulong = 0x00008923;
pub const SIOCSIFHWADDR: ::c_ulong = 0x00008924;
pub const SIOCGIFENCAP: ::c_ulong = 0x00008925;
pub const SIOCSIFENCAP: ::c_ulong = 0x00008926;
Expand All @@ -2742,6 +2797,24 @@ pub const SIOCGIFSLAVE: ::c_ulong = 0x00008929;
pub const SIOCSIFSLAVE: ::c_ulong = 0x00008930;
pub const SIOCADDMULTI: ::c_ulong = 0x00008931;
pub const SIOCDELMULTI: ::c_ulong = 0x00008932;
pub const SIOCGIFINDEX: ::c_ulong = 0x00008933;
pub const SIOGIFINDEX: ::c_ulong = SIOCGIFINDEX;
pub const SIOCSIFPFLAGS: ::c_ulong = 0x00008934;
pub const SIOCGIFPFLAGS: ::c_ulong = 0x00008935;
pub const SIOCDIFADDR: ::c_ulong = 0x00008936;
pub const SIOCSIFHWBROADCAST: ::c_ulong = 0x00008937;
pub const SIOCGIFCOUNT: ::c_ulong = 0x00008938;
pub const SIOCGIFBR: ::c_ulong = 0x00008940;
pub const SIOCSIFBR: ::c_ulong = 0x00008941;
pub const SIOCGIFTXQLEN: ::c_ulong = 0x00008942;
pub const SIOCSIFTXQLEN: ::c_ulong = 0x00008943;
pub const SIOCETHTOOL: ::c_ulong = 0x00008946;
pub const SIOCGMIIPHY: ::c_ulong = 0x00008947;
pub const SIOCGMIIREG: ::c_ulong = 0x00008948;
pub const SIOCSMIIREG: ::c_ulong = 0x00008949;
pub const SIOCWANDEV: ::c_ulong = 0x0000894A;
pub const SIOCOUTQNSD: ::c_ulong = 0x0000894B;
pub const SIOCGSKNS: ::c_ulong = 0x0000894C;
pub const SIOCDARP: ::c_ulong = 0x00008953;
pub const SIOCGARP: ::c_ulong = 0x00008954;
pub const SIOCSARP: ::c_ulong = 0x00008955;
Expand All @@ -2750,6 +2823,24 @@ pub const SIOCGRARP: ::c_ulong = 0x00008961;
pub const SIOCSRARP: ::c_ulong = 0x00008962;
pub const SIOCGIFMAP: ::c_ulong = 0x00008970;
pub const SIOCSIFMAP: ::c_ulong = 0x00008971;
pub const SIOCADDDLCI: ::c_ulong = 0x00008980;
pub const SIOCDELDLCI: ::c_ulong = 0x00008981;
pub const SIOCGIFVLAN: ::c_ulong = 0x00008982;
pub const SIOCSIFVLAN: ::c_ulong = 0x00008983;
pub const SIOCBONDENSLAVE: ::c_ulong = 0x00008990;
pub const SIOCBONDRELEASE: ::c_ulong = 0x00008991;
pub const SIOCBONDSETHWADDR: ::c_ulong = 0x00008992;
pub const SIOCBONDSLAVEINFOQUERY: ::c_ulong = 0x00008993;
pub const SIOCBONDINFOQUERY: ::c_ulong = 0x00008994;
pub const SIOCBONDCHANGEACTIVE: ::c_ulong = 0x00008995;
pub const SIOCBRADDBR: ::c_ulong = 0x000089a0;
pub const SIOCBRDELBR: ::c_ulong = 0x000089a1;
pub const SIOCBRADDIF: ::c_ulong = 0x000089a2;
pub const SIOCBRDELIF: ::c_ulong = 0x000089a3;
pub const SIOCSHWTSTAMP: ::c_ulong = 0x000089b0;
pub const SIOCGHWTSTAMP: ::c_ulong = 0x000089b1;
pub const SIOCDEVPRIVATE: ::c_ulong = 0x000089F0;
pub const SIOCPROTOPRIVATE: ::c_ulong = 0x000089E0;

// linux/module.h
pub const MODULE_INIT_IGNORE_MODVERSIONS: ::c_uint = 0x0001;
Expand Down

0 comments on commit 8fc4f23

Please sign in to comment.