Add cc only response
For a PLDM operation resulting in an error,
unless otherwise specified, the responder shall not
return any additional parametric data.
It is useful to implement a cc-only response
Signed-off-by: John Wang <wangzqbj@inspur.com>
Change-Id: Iec5299f4c4043491aa62e0b94de7f9c12d0bee2e
diff --git a/libpldm/base.c b/libpldm/base.c
index 5927ba1..b34045c 100644
--- a/libpldm/base.c
+++ b/libpldm/base.c
@@ -367,3 +367,26 @@
return PLDM_SUCCESS;
}
+
+int encode_cc_only_resp(uint8_t instance_id, uint8_t type, uint8_t command,
+ uint8_t cc, struct pldm_msg *msg)
+{
+ struct pldm_header_info header = {0};
+
+ if (msg == NULL) {
+ return PLDM_ERROR_INVALID_DATA;
+ }
+
+ header.instance = instance_id;
+ header.msg_type = PLDM_RESPONSE;
+ header.pldm_type = type;
+ header.command = command;
+ int rc = pack_pldm_header(&header, &msg->hdr);
+ if (rc != PLDM_SUCCESS) {
+ return rc;
+ }
+
+ msg->payload[0] = cc;
+
+ return PLDM_SUCCESS;
+}
diff --git a/libpldm/base.h b/libpldm/base.h
index 0738046..9d7961a 100644
--- a/libpldm/base.h
+++ b/libpldm/base.h
@@ -412,6 +412,18 @@
int encode_get_tid_resp(uint8_t instance_id, uint8_t completion_code,
uint8_t tid, struct pldm_msg *msg);
+/** @brief Create a PLDM response message containing only cc
+ *
+ * @param[in] instance_id - Message's instance id
+ * @param[in] type - PLDM Type
+ * @param[in] command - PLDM Command
+ * @param[in] cc - PLDM Completion Code
+ * @param[out] msg - Message will be written to this
+ * @return pldm_completion_codes
+ */
+int encode_cc_only_resp(uint8_t instance_id, uint8_t type, uint8_t command,
+ uint8_t cc, struct pldm_msg *msg);
+
#ifdef __cplusplus
}
#endif