use std::fmt;
use bitflags::bitflags;
use neli::{
attr::AttrHandle,
consts::genl::NlAttrType,
genl::Nlattr,
types::{Buffer, GenlBuffer},
};
use neli_proc_macros::neli_enum;
pub type Attrs<'a, T> = AttrHandle<'a, GenlBuffer<T, Buffer>, Nlattr<T, Buffer>>;
#[neli_enum(serialized_type = "u16")]
pub(crate) enum Attribute {
Unspec = 0,
Wiphy = 1,
WiphyName = 2,
Ifindex = 3,
Ifname = 4,
Iftype = 5,
Mac = 6,
KeyData = 7,
KeyIdx = 8,
KeyCipher = 9,
KeySeq = 10,
KeyDefault = 11,
BeaconInterval = 12,
DtimPeriod = 13,
BeaconHead = 14,
BeaconTail = 15,
StaAid = 16,
StaFlags = 17,
StaListenInterval = 18,
StaSupportedRates = 19,
StaVlan = 20,
StaInfo = 21,
WiphyBands = 22,
MntrFlags = 23,
MeshId = 24,
StaPlinkAction = 25,
MpathNextHop = 26,
MpathInfo = 27,
BssCtsProt = 28,
BssShortPreamble = 29,
BssShortSlotTime = 30,
HtCapability = 31,
SupportedIftypes = 32,
RegAlpha2 = 33,
RegRules = 34,
MeshConfig = 35,
BssBasicRates = 36,
WiphyTxqParams = 37,
WiphyFreq = 38,
WiphyChannelType = 39,
KeyDefaultMgmt = 40,
MgmtSubtype = 41,
Ie = 42,
MaxNumScanSsids = 43,
ScanFrequencies = 44,
ScanSsids = 45,
Generation = 46,
Bss = 47,
RegInitiator = 48,
RegType = 49,
SupportedCommands = 50,
Frame = 51,
Ssid = 52,
AuthType = 53,
ReasonCode = 54,
KeyType = 55,
MaxScanIeLen = 56,
CipherSuites = 57,
FreqBefore = 58,
FreqAfter = 59,
FreqFixed = 60,
WiphyRetryShort = 61,
WiphyRetryLong = 62,
WiphyFragThreshold = 63,
WiphyRtsThreshold = 64,
TimedOut = 65,
UseMfp = 66,
StaFlags2 = 67,
ControlPort = 68,
Testdata = 69,
Privacy = 70,
DisconnectedByAp = 71,
StatusCode = 72,
CipherSuitesPairwise = 73,
CipherSuiteGroup = 74,
WpaVersions = 75,
AkmSuites = 76,
ReqIe = 77,
RespIe = 78,
PrevBssid = 79,
Key = 80,
Keys = 81,
Pid = 82,
Use4addrFrames = 83,
SurveyInfo = 84,
Pmkid = 85,
MaxNumPmkids = 86,
Duration = 87,
Cookie = 88,
WiphyCoverageClass = 89,
TxRates = 90,
FrameMatch = 91,
Ack = 92,
PsState = 93,
Cqm = 94,
LocalStateChange = 95,
ApIsolate = 96,
WiphyTxPowerSetting = 97,
WiphyTxPowerLevel = 98,
TxFrameTypes = 99,
RxFrameTypes = 100,
FrameType = 101,
ControlPortEthertype = 102,
ControlPortNoEncrypt = 103,
SupportIbssRsn = 104,
WiphyAntennaTx = 105,
WiphyAntennaRx = 106,
McastRate = 107,
OffchannelTxOk = 108,
BssHtOpmode = 109,
KeyDefaultTypes = 110,
MaxRemainOnChannelDuration = 111,
MeshSetup = 112,
WiphyAntennaAvailTx = 113,
WiphyAntennaAvailRx = 114,
SupportMeshAuth = 115,
StaPlinkState = 116,
WowlanTriggers = 117,
WowlanTriggersSupported = 118,
SchedScanInterval = 119,
InterfaceCombinations = 120,
SoftwareIftypes = 121,
RekeyData = 122,
MaxNumSchedScanSsids = 123,
MaxSchedScanIeLen = 124,
ScanSuppRates = 125,
HiddenSsid = 126,
IeProbeResp = 127,
IeAssocResp = 128,
StaWme = 129,
SupportApUapsd = 130,
RoamSupport = 131,
SchedScanMatch = 132,
MaxMatchSets = 133,
PmksaCandidate = 134,
TxNoCckRate = 135,
TdlsAction = 136,
TdlsDialogToken = 137,
TdlsOperation = 138,
TdlsSupport = 139,
TdlsExternalSetup = 140,
DeviceApSme = 141,
DontWaitForAck = 142,
FeatureFlags = 143,
ProbeRespOffload = 144,
ProbeResp = 145,
DfsRegion = 146,
DisableHt = 147,
HtCapabilityMask = 148,
NoackMap = 149,
InactivityTimeout = 150,
RxSignalDbm = 151,
BgScanPeriod = 152,
Wdev = 153,
UserRegHintType = 154,
ConnFailedReason = 155,
SaeData = 156,
VhtCapability = 157,
ScanFlags = 158,
ChannelWidth = 159,
CenterFreq1 = 160,
CenterFreq2 = 161,
P2pCtwindow = 162,
P2pOppps = 163,
LocalMeshPowerMode = 164,
AclPolicy = 165,
MacAddrs = 166,
MacAclMax = 167,
RadarEvent = 168,
ExtCapa = 169,
ExtCapaMask = 170,
StaCapability = 171,
StaExtCapability = 172,
ProtocolFeatures = 173,
SplitWiphyDump = 174,
DisableVht = 175,
VhtCapabilityMask = 176,
Mdid = 177,
IeRic = 178,
CritProtId = 179,
MaxCritProtDuration = 180,
PeerAid = 181,
CoalesceRule = 182,
ChSwitchCount = 183,
ChSwitchBlockTx = 184,
CsaIes = 185,
CsaCOffBeacon = 186,
CsaCOffPresp = 187,
RxmgmtFlags = 188,
StaSupportedChannels = 189,
StaSupportedOperClasses = 190,
HandleDfs = 191,
Support5Mhz = 192,
Support10Mhz = 193,
OpmodeNotif = 194,
VendorId = 195,
VendorSubcmd = 196,
VendorData = 197,
VendorEvents = 198,
QosMap = 199,
MacHint = 200,
WiphyFreqHint = 201,
MaxApAssocSta = 202,
TdlsPeerCapability = 203,
SocketOwner = 204,
CsaCOffsetsTx = 205,
MaxCsaCounters = 206,
TdlsInitiator = 207,
UseRrm = 208,
WiphyDynAck = 209,
Tsid = 210,
UserPrio = 211,
AdmittedTime = 212,
SmpsMode = 213,
OperClass = 214,
MacMask = 215,
WiphySelfManagedReg = 216,
ExtFeatures = 217,
SurveyRadioStats = 218,
NetnsFd = 219,
SchedScanDelay = 220,
RegIndoor = 221,
MaxNumSchedScanPlans = 222,
MaxScanPlanInterval = 223,
MaxScanPlanIterations = 224,
SchedScanPlans = 225,
Pbss = 226,
BssSelect = 227,
StaSupportP2pPs = 228,
Pad = 229,
IftypeExtCapa = 230,
MuMimoGroupData = 231,
MuMimoFollowMacAddr = 232,
ScanStartTimeTsf = 233,
ScanStartTimeTsfBssid = 234,
MeasurementDuration = 235,
MeasurementDurationMandatory = 236,
MeshPeerAid = 237,
NanMasterPref = 238,
NanDual = 239,
NanFunc = 240,
NanMatch = 241,
FilsKek = 242,
FilsNonces = 243,
MulticastToUnicastEnabled = 244,
Bssid = 245,
SchedScanRelativeRssi = 246,
SchedScanRssiAdjust = 247,
AttrTimeoutReason = 248,
FilsErpUsername = 249,
FilsErpRealm = 250,
FilsErpNextSeqNum = 251,
FilsErpRrk = 252,
FilsCacheId = 253,
Pmk = 254,
SchedScanMulti = 255,
SchedScanMaxReqs = 256,
Want1x4wayHs = 257,
Pmkr0Name = 258,
PortAuthorized = 259,
ExternalAuthAction = 260,
ExternalAuthSupport = 261,
Nss = 262,
AckSignal = 263,
ControlPortOverNl80211 = 264,
TxqStats = 265,
TxqLimit = 266,
TxqMemoryLimit = 267,
TxqQuantum = 268,
HeCapability = 269,
FtmResponder = 270,
FtmResponderStats = 271,
Timeout = 272,
PeerMeasurements = 273,
AirtimeWeight = 274,
StaTxPowerSetting = 275,
StaTxPower = 276,
SaePassword = 277,
TwtResponder = 278,
HeObssPd = 279,
WiphyEdmgChannels = 280,
WiphyEdmgBwConfig = 281,
VlanId = 282,
HeBssColor = 283,
IfTypeAkmSuites = 284,
TidConfig = 285,
ControlPortNoPreauth = 286,
PmkLifetime = 287,
PmkReauthThreshold = 288,
ReceiveMulticast = 289,
WiphyFreqOffset = 290,
CenterFreq1Offset = 291,
ScanFreqKhz = 292,
He6ghzCapability = 293,
FilsDiscovery = 294,
UnsolBcastProbeResp = 295,
S1gCapability = 296,
S1gCapabilityMask = 297,
SaePwe = 298,
ReconnectRequested = 299,
SarSpec = 300,
DisableHe = 301,
ObssColorBitmap = 302,
ColorChangeCount = 303,
ColorChangeColor = 304,
ColorChangeElems = 305,
MbssidConfig = 306,
MbssidElems = 307,
RadarBackground = 308,
EhtCapability = 309,
DisableEht = 310,
MloLinks = 311,
MloLinkId = 312,
MldAddr = 313,
MloSupport = 314,
MaxNumAkmSuites = 315,
EmlCapability = 316,
MldCapaAndOps = 317,
TxHwTimestamp = 318,
RxHwTimestamp = 319,
TdBitmap = 320,
PunctBitmap = 321,
MaxHwTimestampPeers = 322,
HwTimestampEnabled = 323,
EmaRnrElems = 324,
MloLinkDisabled = 325,
BssDumpIncludeUseData = 326,
MloTtlmDlink = 327,
MloTtlmUlink = 328,
AssocSppAmsdu = 329,
WiphyRadios = 330,
WiphyInterfaceCombinations = 331,
VifRadioMask = 332,
SupportedSelectors = 333,
MloReconfRemLinks = 334,
Epcs = 335,
AssocMldExtCapaOps = 336,
WiphyRadioIndex = 337,
S1gLongBeaconPeriod = 338,
S1gShortBeacon = 339,
BssParam = 340,
NanConfig = 341,
NanNewCluster = 342,
NanCapabilities = 343,
S1gPrimary2MHz = 344,
}
impl NlAttrType for Attribute {}
#[neli_enum(serialized_type = "u32")]
pub(crate) enum InterfaceType {
Unspecified = 0,
Adhoc = 1,
Station = 2,
Ap = 3,
ApVlan = 4,
Wds = 5,
Monitor = 6,
MeshPoint = 7,
P2pClient = 8,
P2pGo = 9,
P2pDevice = 10,
Ocb = 11,
Nan = 12,
}
#[neli_enum(serialized_type = "u16")]
pub(crate) enum TxqStats {
Invalid = 0,
BacklogBytes = 1,
BacklogPackets = 2,
Flows = 3,
Drops = 4,
EcnMarks = 5,
Overlimit = 6,
Overmemory = 7,
Collisions = 8,
TxBytes = 9,
TxPackets = 10,
MaxFlows = 11,
}
impl NlAttrType for TxqStats {}
#[neli_enum(serialized_type = "u16")]
pub(crate) enum StationInfo {
Invalid = 0,
InactiveTime = 1,
RxBytes = 2,
TxBytes = 3,
Llid = 4,
Plid = 5,
PlinkState = 6,
Signal = 7,
TxBitrate = 8,
RxPackets = 9,
TxPackets = 10,
TxRetries = 11,
TxFailed = 12,
SignalAvg = 13,
RxBitrate = 14,
BssParam = 15,
ConnectedTime = 16,
StaFlags = 17,
BeaconLoss = 18,
TOffset = 19,
LocalPm = 20,
PeerPm = 21,
NonpeerPm = 22,
RxBytes64 = 23,
TxBytes64 = 24,
ChainSignal = 25,
ChainSignalAvg = 26,
ExpectedThroughput = 27,
RxDropMisc = 28,
BeaconRx = 29,
BeaconSignalAvg = 30,
TidStats = 31,
RxDuration = 32,
Pad = 33,
AckSignal = 34,
AckSignalAvg = 35,
RxMpdus = 36,
FcsErrorCount = 37,
ConnectedToGate = 38,
TxDuration = 39,
AirtimeWeight = 40,
AirtimeLinkMetric = 41,
AssocAtBootTime = 42,
ConnectedToAs = 43,
}
impl NlAttrType for StationInfo {}
bitflags! {
pub struct StationFlagBits: u32 {
const AUTHORIZED = 1 << 1;
const SHORT_PREAMBLE = 1 << 2;
const WME = 1 << 3;
const MFP = 1 << 4;
const AUTHENTICATED = 1 << 5;
const TDLS_PEER = 1 << 6;
const ASSOCIATED = 1 << 7;
const SPP_AMSDU = 1 << 8;
}
}
impl fmt::Debug for StationFlagBits {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&self.bits(), f)
}
}
#[neli_enum(serialized_type = "u16")]
pub(crate) enum RateInfo {
Invalid = 0,
Bitrate = 1,
Mcs = 2,
MhzWidth40 = 3,
ShortGuardInterval = 4,
Bitrate32 = 5,
VhtMcs = 6,
VhtNss = 7,
MhzWidth80 = 8,
MhzWidth80p80 = 9,
MhzWidth160 = 10,
MhzWidth10 = 11,
MhzWidth5 = 12,
HeMcs = 13,
HeNss = 14,
HeGuardInterval = 15,
HeDcm = 16,
HeRuAlloc = 17,
}
impl NlAttrType for RateInfo {}
#[neli_enum(serialized_type = "u16")]
pub(crate) enum BssParam {
Invalid = 0,
CtsProt = 1,
ShortPreamble = 2,
ShortSlotTime = 3,
DtimPeriod = 4,
BeaconInterval = 5,
}
impl NlAttrType for BssParam {}
#[neli_enum(serialized_type = "u8")]
pub(crate) enum HeGuardInterval {
Usec0_8 = 0,
Usec1_6 = 1,
Usec3_2 = 2,
}
#[neli_enum(serialized_type = "u16")]
pub(crate) enum HeRuAlloc {
Alloc26 = 0,
Alloc52 = 1,
Alloc106 = 2,
Alloc242 = 3,
Alloc484 = 4,
Alloc996 = 5,
Alloc2x996 = 6,
}
impl NlAttrType for HeRuAlloc {}
#[neli_enum(serialized_type = "u16")]
pub(crate) enum TidStats {
Invalid = 0,
RxMsdu = 1,
TxMsdu = 2,
TxMsduRetries = 3,
TxMsduFailed = 4,
Pad = 5,
TxqStats = 6,
}
impl NlAttrType for TidStats {}
#[neli_enum(serialized_type = "u16")]
pub(crate) enum BandAttr {
Invalid = 0,
Frequencies = 1,
Bitrates = 2,
HtMcsSet = 3,
HtCapabilities = 4,
HtAmpduFactor = 5,
HtAmpduDensity = 6,
VhtMcsSet = 7,
VhtCapabilities = 8,
IftypeData = 9,
EdmgChannels = 10,
EdmgBwConfig = 11,
}
impl NlAttrType for BandAttr {}
#[allow(clippy::enum_variant_names)]
#[neli_enum(serialized_type = "u16")]
pub(crate) enum Band {
Band2ghz = 0,
Band5ghz = 1,
Band60ghz = 2,
Band6ghz = 3,
BandS1ghz = 4,
BandLc = 5,
}
impl NlAttrType for Band {}
#[neli_enum(serialized_type = "u16")]
pub(crate) enum FrequencyAttr {
Invalid = 0,
Frequency = 1,
Disabled = 2,
NoIr = 3,
NoIbss = 4,
Radar = 5,
MaxTxPower = 6,
DfsState = 7,
DfdTime = 8,
NoHt40Minus = 9,
NoHt40Plus = 10,
No80Mhz = 11,
No160Mhz = 12,
DfsCacTime = 13,
IndoorOnly = 14,
IrConcurrent = 15,
No20Mhz = 16,
No10Mhz = 17,
Wmm = 18,
NoHe = 19,
Offset = 20,
Allow1Mhz = 21,
Allow2Mhz = 22,
Allow4Mhz = 23,
Allow8Mhz = 24,
Allow16Mhz = 25,
No320Mhz = 26,
NoEht = 27,
}
impl NlAttrType for FrequencyAttr {}
#[neli_enum(serialized_type = "u16")]
pub(crate) enum RegRuleAttr {
Invalid = 0,
RegRuleFlags = 1,
FreqRangeStart = 2,
FreqRangeEnd = 3,
FreqRangeMaxBw = 4,
PowerRuleMaxAntGain = 5,
PowerRuleMaxEirp = 6,
DfsCacTime = 7,
}
impl NlAttrType for RegRuleAttr {}
bitflags! {
pub struct RegRuleFlags: u32 {
const NO_OFDM = 1<<0;
const NO_CCK = 1<<1;
const NO_INDOOR = 1<<2;
const NO_OUTDOOR = 1<<3;
const DFS = 1<<4;
const PTP_ONLY = 1<<5;
const PTMP_ONLY = 1<<6;
const NO_IR = 1<<7;
const __NO_IBSS = 1<<8;
const AUTO_BW = 1<<11;
const IR_CONCURRENT = 1<<12;
const NO_HT40MINUS = 1<<13;
const NO_HT40PLUS = 1<<14;
const NO_80MHZ = 1<<15;
const NO_160MHZ = 1<<16;
const NO_HE = 1<<17;
const NO_320MHZ = 1<<18;
const NO_EHT = 1<<19;
}
}
impl fmt::Debug for RegRuleFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&self.0, f)
}
}
#[neli_enum(serialized_type = "u16")]
pub enum MonitorFlags {
Invalid = 0,
FcsFail = 1,
PlcpFail = 2,
Control = 3,
OtherBss = 4,
CookFrames = 5,
Active = 6,
}
impl NlAttrType for MonitorFlags {}
#[neli_enum(serialized_type = "u32")]
pub(crate) enum ChannelWidth {
Width20NoHT = 0,
Width20 = 1,
Width40 = 2,
Width80 = 3,
Width80P80 = 4,
Width160 = 5,
Width5 = 6,
Width10 = 7,
Width1 = 8,
Width2 = 9,
Width4 = 10,
Width8 = 11,
Width16 = 12,
Width320 = 13,
}