use core::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum PrivilegeLevel {
Callback = 0x01,
User = 0x02,
Operator = 0x03,
Administrator = 0x04,
Oem = 0x05,
}
impl PrivilegeLevel {
pub(crate) fn as_u8(self) -> u8 {
self as u8
}
}
#[derive(Clone, PartialEq, Eq)]
pub struct RawResponse {
pub completion_code: u8,
pub data: Vec<u8>,
}
impl fmt::Debug for RawResponse {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RawResponse")
.field(
"completion_code",
&format_args!("{:#04x}", self.completion_code),
)
.field("data_len", &self.data.len())
.finish()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DeviceId {
pub device_id: u8,
pub device_revision: u8,
pub firmware_major: u8,
pub firmware_minor: u8,
pub ipmi_version: u8,
pub manufacturer_id: u32,
pub product_id: u16,
pub aux_firmware_revision: [u8; 4],
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SelfTestResult {
Passed,
NotImplemented,
DeviceError(SelfTestDeviceError),
FatalError(u8),
DeviceSpecific {
code: u8,
detail: u8,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct SelfTestDeviceError {
pub firmware_corrupted: bool,
pub boot_block_corrupted: bool,
pub fru_internal_corrupted: bool,
pub sdr_repository_empty: bool,
pub ipmb_not_responding: bool,
pub bmc_fru_access_error: bool,
pub sdr_repository_access_error: bool,
pub sel_access_error: bool,
}
impl SelfTestDeviceError {
pub(crate) fn from_bits(bits: u8) -> Self {
Self {
firmware_corrupted: bits & 0x01 != 0,
boot_block_corrupted: bits & 0x02 != 0,
fru_internal_corrupted: bits & 0x04 != 0,
sdr_repository_empty: bits & 0x08 != 0,
ipmb_not_responding: bits & 0x10 != 0,
bmc_fru_access_error: bits & 0x20 != 0,
sdr_repository_access_error: bits & 0x40 != 0,
sel_access_error: bits & 0x80 != 0,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct SystemGuid {
pub bytes: [u8; 16],
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PowerRestorePolicy {
AlwaysOff,
Previous,
AlwaysOn,
Unknown(u8),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct LastPowerEvent {
pub ac_failed: bool,
pub power_overload: bool,
pub power_interlock: bool,
pub power_fault: bool,
pub power_on_command: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct FrontPanelControls {
pub sleep_button_disable_allowed: bool,
pub diag_button_disable_allowed: bool,
pub reset_button_disable_allowed: bool,
pub power_button_disable_allowed: bool,
pub sleep_button_disabled: bool,
pub diag_button_disabled: bool,
pub reset_button_disabled: bool,
pub power_button_disabled: bool,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ChassisStatus {
pub system_power_on: bool,
pub power_overload: bool,
pub power_interlock: bool,
pub main_power_fault: bool,
pub power_control_fault: bool,
pub power_restore_policy: PowerRestorePolicy,
pub last_power_event: LastPowerEvent,
pub chassis_intrusion: bool,
pub front_panel_lockout: bool,
pub drive_fault: bool,
pub cooling_fan_fault: bool,
pub front_panel_controls: Option<FrontPanelControls>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ChassisControl {
PowerDown,
PowerUp,
PowerCycle,
HardReset,
PulseDiagnostic,
AcpiSoft,
}
impl ChassisControl {
pub(crate) fn as_u8(self) -> u8 {
match self {
Self::PowerDown => 0x00,
Self::PowerUp => 0x01,
Self::PowerCycle => 0x02,
Self::HardReset => 0x03,
Self::PulseDiagnostic => 0x04,
Self::AcpiSoft => 0x05,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ChannelAuthCapabilities {
pub channel_number: u8,
pub v20_data_available: bool,
pub enabled_auth_types: u8,
pub per_message_auth_disabled: bool,
pub user_level_auth_disabled: bool,
pub non_null_usernames: bool,
pub null_usernames: bool,
pub anonymous_login_enabled: bool,
pub kg_nonzero: bool,
pub supports_ipmi_v1_5: bool,
pub supports_ipmi_v2_0: bool,
pub oem_id: Option<u32>,
pub oem_aux_data: Option<u8>,
}