From dca2c03a58223f440784de6ebf2600a96a4ba315 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=BAben=20Soares=20da=20Silva?= <rsilva@allbesmart.pt>
Date: Wed, 24 Apr 2024 12:20:39 +0100
Subject: [PATCH] Add utility functions related to STOP.request

---
 nfapi/open-nFAPI/fapi/inc/nr_fapi_p5_utils.h |  3 +++
 nfapi/open-nFAPI/fapi/src/nr_fapi_p5_utils.c | 26 ++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/nfapi/open-nFAPI/fapi/inc/nr_fapi_p5_utils.h b/nfapi/open-nFAPI/fapi/inc/nr_fapi_p5_utils.h
index d9b0a687da..b0f39649fa 100644
--- a/nfapi/open-nFAPI/fapi/inc/nr_fapi_p5_utils.h
+++ b/nfapi/open-nFAPI/fapi/inc/nr_fapi_p5_utils.h
@@ -46,6 +46,7 @@ bool compare_config_request(const nfapi_nr_config_request_scf_t *unpacked_req, c
 bool compare_config_response(const nfapi_nr_config_response_scf_t *unpacked_req, const nfapi_nr_config_response_scf_t *req);
 bool compare_start_request(const nfapi_nr_start_request_scf_t *unpacked_req, const nfapi_nr_start_request_scf_t *req);
 bool compare_start_response(const nfapi_nr_start_response_scf_t *unpacked_req, const nfapi_nr_start_response_scf_t *req);
+bool compare_stop_request(const nfapi_nr_stop_request_scf_t *unpacked_req, const nfapi_nr_stop_request_scf_t *req);
 
 void free_param_request(nfapi_nr_param_request_scf_t *msg);
 void free_param_response(nfapi_nr_param_response_scf_t *msg);
@@ -53,6 +54,7 @@ void free_config_request(nfapi_nr_config_request_scf_t *msg);
 void free_config_response(nfapi_nr_config_response_scf_t *msg);
 void free_start_request(nfapi_nr_start_request_scf_t *msg);
 void free_start_response(nfapi_nr_start_response_scf_t *msg);
+void free_stop_request(nfapi_nr_stop_request_scf_t *msg);
 
 void copy_param_request(const nfapi_nr_param_request_scf_t *src,  nfapi_nr_param_request_scf_t *dst);
 void copy_param_response(const nfapi_nr_param_response_scf_t *src,  nfapi_nr_param_response_scf_t *dst);
@@ -60,5 +62,6 @@ void copy_config_request(const nfapi_nr_config_request_scf_t *src,  nfapi_nr_con
 void copy_config_response(const nfapi_nr_config_response_scf_t *src,  nfapi_nr_config_response_scf_t *dst);
 void copy_start_request(const nfapi_nr_start_request_scf_t *src,  nfapi_nr_start_request_scf_t *dst);
 void copy_start_response(const nfapi_nr_start_response_scf_t *src,  nfapi_nr_start_response_scf_t *dst);
+void copy_stop_request(const nfapi_nr_stop_request_scf_t *src,  nfapi_nr_stop_request_scf_t *dst);
 
 #endif // OPENAIRINTERFACE_NR_FAPI_P5_UTILS_H
diff --git a/nfapi/open-nFAPI/fapi/src/nr_fapi_p5_utils.c b/nfapi/open-nFAPI/fapi/src/nr_fapi_p5_utils.c
index 902629d76e..6457a71211 100644
--- a/nfapi/open-nFAPI/fapi/src/nr_fapi_p5_utils.c
+++ b/nfapi/open-nFAPI/fapi/src/nr_fapi_p5_utils.c
@@ -481,6 +481,13 @@ bool compare_start_response(const nfapi_nr_start_response_scf_t *unpacked_req, c
   return true;
 }
 
+bool compare_stop_request(const nfapi_nr_stop_request_scf_t *unpacked_req, const nfapi_nr_stop_request_scf_t *req)
+{
+  CMP(unpacked_req->header.message_id, req->header.message_id);
+  CMP(unpacked_req->header.message_length, req->header.message_length);
+  return true;
+}
+
 void free_param_request(nfapi_nr_param_request_scf_t *msg)
 {
   if (msg->vendor_extension) {
@@ -564,6 +571,13 @@ void free_start_response(nfapi_nr_start_response_scf_t *msg)
   }
 }
 
+void free_stop_request(nfapi_nr_stop_request_scf_t *msg)
+{
+  if (msg->vendor_extension) {
+    free(msg->vendor_extension);
+  }
+}
+
 void copy_tl(const nfapi_tl_t *src, nfapi_tl_t *dst)
 {
   dst->tag = src->tag;
@@ -1105,3 +1119,15 @@ void copy_start_response(const nfapi_nr_start_response_scf_t *src, nfapi_nr_star
   }
   dst->error_code = src->error_code;
 }
+
+void copy_stop_request(const nfapi_nr_stop_request_scf_t *src, nfapi_nr_stop_request_scf_t *dst)
+{
+  dst->header.message_id = src->header.message_id;
+  dst->header.message_length = src->header.message_length;
+  if (src->vendor_extension) {
+    dst->vendor_extension = calloc(1, sizeof(nfapi_vendor_extension_tlv_t));
+    dst->vendor_extension->tag = src->vendor_extension->tag;
+    dst->vendor_extension->length = src->vendor_extension->length;
+    copy_vendor_extension_value(&dst->vendor_extension,&src->vendor_extension);
+  }
+}
-- 
2.26.2