blob: ab6c7a66ebe7476a808f220b2b9acf6a4be81408 [file] [log] [blame]
/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
#include <libpldm/oem/meta/file_io.h>
#include <endian.h>
#include <string.h>
#include <stdio.h>
#include "msgbuf.h"
#define PLDM_OEM_META_DECODE_WRITE_FILE_IO_MIN_SIZE 6
LIBPLDM_ABI_STABLE
int decode_oem_meta_file_io_req(const struct pldm_msg *msg,
size_t payload_length, uint8_t *file_handle,
uint32_t *length, uint8_t *data)
{
struct pldm_msgbuf _buf;
struct pldm_msgbuf *buf = &_buf;
if (msg == NULL || file_handle == NULL || length == NULL ||
data == NULL) {
return PLDM_ERROR_INVALID_DATA;
}
int rc = pldm_msgbuf_init(buf,
PLDM_OEM_META_DECODE_WRITE_FILE_IO_MIN_SIZE,
msg->payload, payload_length);
if (rc) {
return rc;
}
pldm_msgbuf_extract(buf, file_handle);
pldm_msgbuf_extract(buf, length);
pldm_msgbuf_extract_array_uint8(buf, data, *length);
return pldm_msgbuf_destroy_consumed(buf);
}