Skip to content

Commit

Permalink
Added remaining linux/wireless.h struct and constants
Browse files Browse the repository at this point in the history
added remaining linux/wireless.h struct and constants

added linux/wireless.h struct and constants

fix

fix

fix2

fix

fix

fix

fix

fix

fix

fix

fix

fix
  • Loading branch information
Brijeshkrishna committed Jan 5, 2024
1 parent 3bd79c8 commit 8ccd2c0
Show file tree
Hide file tree
Showing 3 changed files with 280 additions and 3 deletions.
4 changes: 4 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4171,6 +4171,10 @@ fn test_linux(target: &str) {
(struct_ == "ifreq" && field == "ifr_ifru") ||
// the `ifc_ifcu` field is an anonymous union
(struct_ == "ifconf" && field == "ifc_ifcu") ||
// the `ifr_ifrn` field is an anonymous union
(struct_ == "iwreq" && field == "ifr_ifrn") ||
// the `key` field is a zero-sized array
(struct_ == "iw_encode_ext" && field == "key") ||
// glibc uses a single array `uregs` instead of individual fields.
(struct_ == "user_regs" && arm)
});
Expand Down
28 changes: 27 additions & 1 deletion libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2704,13 +2704,20 @@ IW_ENC_CAPA_WPA2
IW_ENC_CAPA_CIPHER_TKIP
IW_ENC_CAPA_CIPHER_CCMP
IW_ENC_CAPA_4WAY_HANDSHAKE
IW_EVENT_CAPA_K_0
IW_EVENT_CAPA_K_1
IW_PMKSA_ADD
IW_PMKSA_REMOVE
IW_PMKSA_FLUSH
IW_PMKID_LEN
IW_PMKID_CAND_PREAUTH
IW_EV_CHAR_PK_LEN
IW_EV_LCP_PK_LEN
IW_EV_CHAR_PK_LEN
IW_EV_UINT_PK_LEN
IW_EV_FREQ_PK_LEN
IW_EV_PARAM_PK_LEN
IW_EV_ADDR_PK_LEN
IW_EV_QUAL_PK_LEN
IW_EV_POINT_PK_LEN
SI_LOAD_SHIFT
SND_CNT
Expand Down Expand Up @@ -3540,6 +3547,25 @@ ip_mreqn
ip_mreq_source
ipc_perm
itimerspec
iw_discarded
iw_encode_ext
iw_event
iw_freq
iw_michaelmicfailure
iw_missed
iw_mlme
iw_param
iw_pmkid_cand
iw_pmksa
iw_point
iw_priv_args
iw_quality
iw_range
iwreq
iwreq_data
iw_scan_req
iw_statistics
iw_thrspy
j1939_filter
jrand48
key_t
Expand Down
251 changes: 249 additions & 2 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,145 @@ s! {
pub salt: [::c_uchar; TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE],
pub rec_seq: [::c_uchar; TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE],
}

// linux/wireless.h

pub struct iw_param {
pub value: __s32,
pub fixed: __u8,
pub disabled: __u8,
pub flags: __u16,
}
pub struct iw_point {
pub pointer: *mut ::c_void,
pub length: __u16,
pub flags: __u16,
}
pub struct iw_freq {
pub m: __s32,
pub e: __s16,
pub i: __u8,
pub flags: __u8,
}
pub struct iw_quality {
pub qual: __u8,
pub level: __u8,
pub noise: __u8,
pub updated: __u8,
}
pub struct iw_discarded {
pub nwid: __u32,
pub code: __u32,
pub fragment: __u32,
pub retries: __u32,
pubmisc: __u32,
}
pub struct iw_missed {
pub beacon: __u32,
}
pub struct iw_thrspy {
pub addr: ::sockaddr,
pub qual: iw_quality,
pub low: iw_quality,
pub high: iw_quality,
}
pub struct iw_scan_req {
pub scan_type: __u8,
pub essid_len: __u8,
pub num_channels: __u8,
pub flags: __u8,
pub bssid: ::sockaddr,
pub essid: [__u8; IW_ESSID_MAX_SIZE],
pub min_channel_time: __u32,
pub max_channel_time: __u32,
pub channel_list: [iw_freq; IW_MAX_FREQUENCIES],
}
pub struct iw_encode_ext {
pub ext_flags: __u32,
pub tx_seq: [__u8; IW_ENCODE_SEQ_MAX_SIZE],
pub rx_seq: [__u8; IW_ENCODE_SEQ_MAX_SIZE],
pub addr: ::sockaddr,
pub alg: __u16,
pub key_len: __u16,
pub key: [__u8;0],
}
pub struct iw_mlme {
pub cmd: __u16,
pub reason_code: __u16,
pub addr: ::sockaddr,
}
pub struct iw_pmksa {
pub cmd: __u32,
pub bssid: ::sockaddr,
pub pmkid: [__u8; IW_PMKID_LEN],
}
pub struct iw_michaelmicfailure {
pub flags: __u32,
pub src_addr: ::sockaddr,
pub tsc: [__u8; IW_ENCODE_SEQ_MAX_SIZE],
}
pub struct iw_pmkid_cand {
pub flags: __u32,
pub index: __u32,
pub bssid: ::sockaddr,
}
pub struct iw_statistics {
pub status: __u16,
pub qual: iw_quality,
pub discard: iw_discarded,
pub miss: iw_missed,
}
pub struct iw_range {
pub throughput: __u32,
pub min_nwid: __u32,
pub max_nwid: __u32,
pub old_num_channels: __u16,
pub old_num_frequency: __u8,
pub scan_capa: __u8,
pub event_capa: [__u32; 6],
pub sensitivity: __s32,
pub max_qual: iw_quality,
pub avg_qual: iw_quality,
pub num_bitrates: __u8,
pub bitrate: [__s32; IW_MAX_BITRATES],
pub min_rts: __s32,
pub max_rts: __s32,
pub min_frag: __s32,
pub max_frag: __s32,
pub min_pmp: __s32,
pub max_pmp: __s32,
pub min_pmt: __s32,
pub max_pmt: __s32,
pub pmp_flags: __u16,
pub pmt_flags: __u16,
pub pm_capa: __u16,
pub encoding_size: [__u16; IW_MAX_ENCODING_SIZES],
pub num_encoding_sizes: __u8,
pub max_encoding_tokens: __u8,
pub encoding_login_index: __u8,
pub txpower_capa: __u16,
pub num_txpower: __u8,
pub txpower: [__s32;IW_MAX_TXPOWER],
pub we_version_compiled: __u8,
pub we_version_source: __u8,
pub retry_capa: __u16,
pub retry_flags: __u16,
pub r_time_flags: __u16,
pub min_retry: __s32,
pub max_retry: __s32,
pub min_r_time: __s32,
pub max_r_time: __s32,
pub num_channels: __u16,
pub num_frequency: __u8,
pub freq: [iw_freq; IW_MAX_FREQUENCIES],
pub enc_capa: __u32,
}
pub struct iw_priv_args {
pub cmd: __u32,
pub set_args: __u16,
pub get_args: __u16,
pub name: [c_char; ::IFNAMSIZ],
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -856,6 +995,52 @@ s_no_extra_traits! {
}
}

s_no_extra_traits! {
// linux/wireless.h
#[cfg(libc_union)]
pub union iwreq_data {
pub name: [c_char; ::IFNAMSIZ],
pub essid: iw_point,
pub nwid: iw_param,
pub freq: iw_freq,
pub sens: iw_param,
pub bitrate: iw_param,
pub txpower: iw_param,
pub rts: iw_param,
pub frag: iw_param,
pub mode: __u32,
pub retry: iw_param,
pub encoding: iw_point,
pub power: iw_param,
pub qual: iw_quality,
pub ap_addr: ::sockaddr,
pub addr: ::sockaddr,
pub param: iw_param,
pub data: iw_point,
}

pub struct iw_event {
pub len: __u16,
pub cmd: __u16,
#[cfg(libc_union)]
pub u: iwreq_data,
#[cfg(not(libc_union))]
pub u: [c_char; ::IFNAMSIZ],
}

#[cfg(libc_union)]
pub union __c_anonymous_iwreq {
pub ifrn_name: [c_char; ::IFNAMSIZ],
}

pub struct iwreq {
#[cfg(libc_union)]
pub ifr_ifrn: __c_anonymous_iwreq,
#[cfg(not(libc_union))]
pub ifr_ifrn: [c_char; ::IFNAMSIZ],
pub u: iwreq_data,
}
}
s_no_extra_traits! {
// linux/net_tstamp.h
#[allow(missing_debug_implementations)]
Expand Down Expand Up @@ -1319,6 +1504,59 @@ cfg_if! {
self.rx_filter.hash(state);
}
}
#[cfg(libc_union)]
impl ::fmt::Debug for iwreq_data {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("iwreq_data")
.field("name", unsafe { &self.name })
.field("essid", unsafe { &self.essid })
.field("nwid", unsafe { &self.nwid })
.field("freq", unsafe { &self.freq })
.field("sens", unsafe { &self.sens })
.field("bitrate", unsafe { &self.bitrate })
.field("txpower", unsafe { &self.txpower })
.field("rts", unsafe { &self.rts })
.field("frag", unsafe { &self.frag })
.field("mode", unsafe { &self.mode })
.field("retry", unsafe { &self.retry })
.field("encoding", unsafe { &self.encoding })
.field("power", unsafe { &self.power })
.field("qual", unsafe { &self.qual })
.field("ap_addr", unsafe { &self.ap_addr })
.field("addr", unsafe { &self.addr })
.field("param", unsafe { &self.param })
.field("data", unsafe { &self.data })
.finish()
}
}

impl ::fmt::Debug for iw_event {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("iw_event")
.field("len", &self.len )
.field("cmd", &self.cmd )
.field("u", &self.u )
.finish()
}
}

#[cfg(libc_union)]
impl ::fmt::Debug for __c_anonymous_iwreq {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("__c_anonymous_iwreq")
.field("ifrn_name", unsafe { &self.ifrn_name })
.finish()
}
}

impl ::fmt::Debug for iwreq {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("iwreq")
.field("ifr_ifrn", &self.ifr_ifrn )
.field("u", &self.u )
.finish()
}
}
}
}

Expand Down Expand Up @@ -3165,6 +3403,9 @@ pub const IW_ENC_CAPA_CIPHER_TKIP: ::c_ulong = 0x00000004;
pub const IW_ENC_CAPA_CIPHER_CCMP: ::c_ulong = 0x00000008;
pub const IW_ENC_CAPA_4WAY_HANDSHAKE: ::c_ulong = 0x00000010;

pub const IW_EVENT_CAPA_K_0: c_ulong = 0x4000050; // IW_EVENT_CAPA_MASK(0x8B04) | IW_EVENT_CAPA_MASK(0x8B06) | IW_EVENT_CAPA_MASK(0x8B1A);
pub const IW_EVENT_CAPA_K_1: c_ulong = 0x400; // W_EVENT_CAPA_MASK(0x8B2A);

pub const IW_PMKSA_ADD: usize = 1;
pub const IW_PMKSA_REMOVE: usize = 2;
pub const IW_PMKSA_FLUSH: usize = 3;
Expand All @@ -3175,8 +3416,13 @@ pub const IW_PMKID_CAND_PREAUTH: ::c_ulong = 0x00000001;

pub const IW_EV_LCP_PK_LEN: usize = 4;

pub const IW_EV_CHAR_PK_LEN: usize = IW_EV_LCP_PK_LEN + ::IFNAMSIZ;
pub const IW_EV_POINT_PK_LEN: usize = IW_EV_LCP_PK_LEN + 4;
pub const IW_EV_CHAR_PK_LEN: usize = 20; // IW_EV_LCP_PK_LEN + ::IFNAMSIZ;
pub const IW_EV_UINT_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + ::mem::size_of::<u32>();
pub const IW_EV_FREQ_PK_LEN: usize = 12; // IW_EV_LCP_PK_LEN + ::mem::size_of::<iw_freq>();
pub const IW_EV_PARAM_PK_LEN: usize = 12; // IW_EV_LCP_PK_LEN + ::mem::size_of::<iw_param>();
pub const IW_EV_ADDR_PK_LEN: usize = 20; // IW_EV_LCP_PK_LEN + ::mem::size_of::<::sockaddr>();
pub const IW_EV_QUAL_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + ::mem::size_of::<iw_quality>();
pub const IW_EV_POINT_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + 4;

pub const IPTOS_TOS_MASK: u8 = 0x1E;
pub const IPTOS_PREC_MASK: u8 = 0xE0;
Expand Down Expand Up @@ -5505,6 +5751,7 @@ cfg_if! {
}

mod arch;

pub use self::arch::*;

cfg_if! {
Expand Down

0 comments on commit 8ccd2c0

Please sign in to comment.