devpath/msg/
mod.rs

1//! Messaging device path types and parsing
2//!
3//! This module contains all messaging device path sub-types defined in UEFI 2.11.
4//! Messaging device paths describe communication interfaces and protocols.
5
6pub mod atapi;
7pub mod bt;
8pub mod btle;
9pub mod dlu;
10pub mod dns;
11pub mod emmc;
12pub mod fc;
13pub mod i2o;
14pub mod ib;
15pub mod ieee1394;
16pub mod ipv4;
17pub mod ipv6;
18pub mod iscsi;
19pub mod mac;
20pub mod nvdimm;
21pub mod nvme;
22pub mod nvme_of;
23pub mod rest;
24pub mod sasex;
25pub mod sata;
26pub mod scsi;
27pub mod sd;
28pub mod uart;
29pub mod ufs;
30pub mod uri;
31pub mod usb;
32pub mod vendor;
33pub mod vlan;
34pub mod wifi;
35
36use crate::{Error, Head, Type};
37
38/// UEFI Messaging Device Path Types
39///
40/// This enum represents all messaging device path sub-types defined in UEFI 2.11 specification.
41/// Each variant corresponds to a specific messaging protocol or device interface.
42#[derive(Debug, Clone, PartialEq, Eq, Hash)]
43#[non_exhaustive]
44pub enum Messaging {
45    /// ATAPI Device Path (0x01) - IDE/ATAPI controller device
46    Atapi(atapi::Atapi),
47
48    /// SCSI Device Path (0x02) - SCSI target device
49    Scsi(scsi::Scsi),
50
51    /// Fibre Channel Device Path (0x03) - Fibre Channel target device
52    FibreChannel(fc::FibreChannel),
53
54    /// IEEE 1394 Device Path (0x04) - FireWire device
55    Ieee1394(ieee1394::Ieee1394),
56
57    /// USB Device Path (0x05) - USB device on specific port/interface
58    Usb(usb::Usb),
59
60    /// I2O Device Path (0x06) - I2O Random Block Storage Class device
61    I2O(i2o::I2o),
62
63    /// InfiniBand Device Path (0x09) - InfiniBand fabric device
64    InfiniBand(ib::InfiniBand),
65
66    /// Vendor-Defined Messaging Device Path (0x0A) - Vendor-specific messaging protocol
67    Vendor(vendor::Vendor),
68
69    /// MAC Address Device Path (0x0B) - Network interface by MAC address
70    MacAddress(mac::MacAddress),
71
72    /// IPv4 Device Path (0x0C) - IPv4 network connection
73    Ipv4(ipv4::Ipv4),
74
75    /// IPv6 Device Path (0x0D) - IPv6 network connection
76    Ipv6(ipv6::Ipv6),
77
78    /// UART Device Path (0x0E) - Serial UART device
79    Uart(uart::Uart),
80
81    /// USB Class Device Path (0x0F) - USB device by class/vendor/product
82    UsbClass(usb::UsbClass),
83
84    /// USB WWID Device Path (0x10) - USB device by World Wide ID
85    UsbWwid(usb::UsbWwid),
86
87    /// Device Logical Unit (0x11) - Logical unit number for multi-LUN devices
88    DeviceLogicalUnit(dlu::DeviceLogicalUnit),
89
90    /// SATA Device Path (0x12) - Serial ATA device
91    Sata(sata::Sata),
92
93    /// iSCSI Device Path (0x13) - iSCSI target device
94    IScsi(iscsi::IScsi),
95
96    /// VLAN Device Path (0x14) - 802.1Q VLAN interface
97    Vlan(vlan::Vlan),
98
99    /// Fibre Channel Ex Device Path (0x15) - Extended Fibre Channel target (byte arrays)
100    FibreChannelEx(fc::FibreChannelEx),
101
102    /// SAS Extended Device Path (0x16) - Serial Attached SCSI Extended
103    SasExtended(sasex::SasExtended),
104
105    /// NVMe Namespace Device Path (0x17) - NVMe namespace
106    NvmeNamespace(nvme::NvmeNamespace),
107
108    /// URI Device Path (0x18) - URI Device Path
109    Uri(uri::Uri),
110
111    /// UFS Device Path (0x19) - Universal Flash Storage
112    Ufs(ufs::Ufs),
113
114    /// SD Device Path (0x1A) - Secure Digital
115    Sd(sd::SecureDigital),
116
117    /// Bluetooth Device Path (0x1B) - Bluetooth device
118    Bluetooth(bt::Bluetooth),
119
120    /// Wi-Fi Device Path (0x1C) - Wi-Fi device
121    Wifi(wifi::Wifi),
122
123    /// eMMC Device Path (0x1D) - Embedded MultiMediaCard
124    EMmc(emmc::EMmc),
125
126    /// BluetoothLE Device Path (0x1E) - Bluetooth Low Energy
127    BluetoothLe(btle::BluetoothLe),
128
129    /// DNS Device Path (0x1F) - DNS device
130    Dns(dns::Dns),
131
132    /// NVDIMM Namespace Device Path (0x20) - NVDIMM Namespace
133    NvdimmNamespace(nvdimm::NvdimmNamespace),
134
135    /// REST Service Device Path (0x21) - REST service endpoint
136    RestService(rest::Rest),
137
138    /// NVMe-oF Namespace Device Path (0x22) - NVMe over Fabric Namespace
139    NvmeOfNamespace(nvme_of::NvmeOfNamespace),
140}
141
142impl TryFrom<Head<'_>> for Messaging {
143    type Error = Error;
144
145    fn try_from(head: Head<'_>) -> Result<Self, Self::Error> {
146        match head.subkind {
147            0x01 => TryFrom::try_from(head).map(Messaging::Atapi),
148            0x02 => TryFrom::try_from(head).map(Messaging::Scsi),
149            0x03 => TryFrom::try_from(head).map(Messaging::FibreChannel),
150            0x04 => TryFrom::try_from(head).map(Messaging::Ieee1394),
151            0x05 => TryFrom::try_from(head).map(Messaging::Usb),
152            0x06 => TryFrom::try_from(head).map(Messaging::I2O),
153            0x09 => TryFrom::try_from(head).map(Messaging::InfiniBand),
154            0x0A => TryFrom::try_from(head).map(Messaging::Vendor),
155            0x0B => TryFrom::try_from(head).map(Messaging::MacAddress),
156            0x0C => TryFrom::try_from(head).map(Messaging::Ipv4),
157            0x0D => TryFrom::try_from(head).map(Messaging::Ipv6),
158            0x0E => TryFrom::try_from(head).map(Messaging::Uart),
159            0x0F => TryFrom::try_from(head).map(Messaging::UsbClass),
160            0x10 => TryFrom::try_from(head).map(Messaging::UsbWwid),
161            0x11 => TryFrom::try_from(head).map(Messaging::DeviceLogicalUnit),
162            0x12 => TryFrom::try_from(head).map(Messaging::Sata),
163            0x13 => TryFrom::try_from(head).map(Messaging::IScsi),
164            0x14 => TryFrom::try_from(head).map(Messaging::Vlan),
165            0x15 => TryFrom::try_from(head).map(Messaging::FibreChannelEx),
166            0x16 => TryFrom::try_from(head).map(Messaging::SasExtended),
167            0x17 => TryFrom::try_from(head).map(Messaging::NvmeNamespace),
168            0x18 => TryFrom::try_from(head).map(Messaging::Uri),
169            0x19 => TryFrom::try_from(head).map(Messaging::Ufs),
170            0x1A => TryFrom::try_from(head).map(Messaging::Sd),
171            0x1B => TryFrom::try_from(head).map(Messaging::Bluetooth),
172            0x1C => TryFrom::try_from(head).map(Messaging::Wifi),
173            0x1D => TryFrom::try_from(head).map(Messaging::EMmc),
174            0x1E => TryFrom::try_from(head).map(Messaging::BluetoothLe),
175            0x1F => TryFrom::try_from(head).map(Messaging::Dns),
176            0x20 => TryFrom::try_from(head).map(Messaging::NvdimmNamespace),
177            0x21 => TryFrom::try_from(head).map(Messaging::RestService),
178            0x22 => TryFrom::try_from(head).map(Messaging::NvmeOfNamespace),
179            n => Err(Error::UnknownSubType(Type::Messaging, n)),
180        }
181    }
182}