Skip to content

Commit eb54370

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 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 5a03d5d commit eb54370

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
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: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -754,11 +754,20 @@ pub struct FileDescriptorPdr {
754754
#[deku(count = "file_name_len")]
755755
pub file_name: AsciiString<MAX_PDR_TRANSFER>,
756756

757-
#[deku(temp, temp_value = "self.oem_file_name.len() as u8")]
757+
#[deku(skip, cond = "*oem_file_classification == 0")]
758+
#[deku(
759+
temp,
760+
temp_value = "self.oem_file_classification_name.as_ref().map(|f| f.len()).unwrap_or(0) as u8"
761+
)]
758762
pub oem_file_name_len: u8,
759-
/// OEM file name.
763+
764+
/// OEM file classification name.
760765
///
761766
/// A null terminated string. Must be empty if `oem_file_classification == 0`.
767+
#[deku(skip, cond = "*oem_file_classification == 0")]
768+
#[deku(
769+
assert = "*oem_file_classification > 0 || oem_file_classification_name.is_none()"
770+
)]
762771
#[deku(count = "oem_file_name_len")]
763-
pub oem_file_name: AsciiString<MAX_PDR_TRANSFER>,
772+
pub oem_file_classification_name: Option<AsciiString<MAX_PDR_TRANSFER>>,
764773
}

0 commit comments

Comments
 (0)