Skip to content

Commit 3d47823

Browse files
committed
pldm-platform: Fix oem_file_classification_name
The length field is now omitted entirely when oem_classification is set to 0. Previously in that case length was included and set to zero, which is not the correct message format. The name field is renamed from oem_file_name to oem_file_classification_name, and is now an Option. Signed-off-by: Matt Johnston <[email protected]>
1 parent ac1eac4 commit 3d47823

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

pldm-file/examples/host.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn handle_get_pdr(
192192
// TODO
193193
file_max_desc_count: 1,
194194
file_name: FILENAME.try_into().expect("Filename too long"),
195-
oem_file_name: Default::default(),
195+
oem_file_classification_name: Default::default(),
196196
}),
197197
)?;
198198
let enc = pdr_resp.to_bytes().context("Encoding failed")?;

pldm-platform/src/proto.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,10 @@ pub struct FileDescriptorPdr {
739739
pub container_id: u16,
740740
pub superior_directory: u16,
741741
pub file_classification: FileClassification,
742+
/// OEM File Classification
743+
///
744+
/// `oem_file_classification_name` must be `Some` if this is
745+
/// non-zero (may be an empty string).
742746
pub oem_file_classification: u8,
743747
pub capabilities: u16,
744748
pub file_version: u32,
@@ -754,11 +758,20 @@ pub struct FileDescriptorPdr {
754758
#[deku(count = "file_name_len")]
755759
pub file_name: AsciiString<MAX_PDR_TRANSFER>,
756760

757-
#[deku(temp, temp_value = "self.oem_file_name.len() as u8")]
761+
#[deku(skip, cond = "*oem_file_classification == 0")]
762+
#[deku(
763+
temp,
764+
temp_value = "self.oem_file_classification_name.as_ref().map(|f| f.len()).unwrap_or(0) as u8"
765+
)]
758766
pub oem_file_name_len: u8,
759-
/// OEM file name.
767+
768+
/// OEM file classification name.
760769
///
761-
/// A null terminated string. Must be empty if `oem_file_classification == 0`.
770+
/// A null terminated string. Must be `None` if `oem_file_classification == 0`.
771+
#[deku(skip, cond = "*oem_file_classification == 0")]
772+
#[deku(
773+
assert = "(*oem_file_classification > 0) == oem_file_classification_name.is_some()"
774+
)]
762775
#[deku(count = "oem_file_name_len")]
763-
pub oem_file_name: AsciiString<MAX_PDR_TRANSFER>,
776+
pub oem_file_classification_name: Option<AsciiString<MAX_PDR_TRANSFER>>,
764777
}

0 commit comments

Comments
 (0)