Commit e19b7140 authored by Rúben Soares Silva's avatar Rúben Soares Silva

Add utility functions related to PARAM.request

parent 5ef1217a
......@@ -34,5 +34,27 @@
#include "stdio.h"
#include "stdint.h"
#include "nr_fapi.h"
#include "nfapi/oai_integration/vendor_ext.h"
#define EQ_TLV(_tlv_a, _tlv_b) \
do { \
EQ(_tlv_a.tl.tag, _tlv_b.tl.tag); \
EQ(_tlv_a.value, _tlv_b.value); \
} while (0)
#define EQ(_a, _b) \
do { \
if ((_a) != (_b)) { \
return false; \
} \
} while (0)
void copy_vendor_extension_value(nfapi_vendor_extension_tlv_t *dst, const nfapi_vendor_extension_tlv_t *src);
bool eq_param_request(const nfapi_nr_param_request_scf_t *unpacked_req, const nfapi_nr_param_request_scf_t *req);
void free_param_request(nfapi_nr_param_request_scf_t *msg);
void copy_param_request(const nfapi_nr_param_request_scf_t *src, nfapi_nr_param_request_scf_t *dst);
#endif // OPENAIRINTERFACE_NR_FAPI_P5_UTILS_H
......@@ -29,3 +29,50 @@
* \warning
*/
#include "nr_fapi_p5_utils.h"
void copy_vendor_extension_value(nfapi_vendor_extension_tlv_t *dst, const nfapi_vendor_extension_tlv_t *src)
{
nfapi_tl_t *dst_tlv = (nfapi_tl_t *)dst;
nfapi_tl_t *src_tlv = (nfapi_tl_t *)src;
switch (dst_tlv->tag) {
case VENDOR_EXT_TLV_2_TAG: {
vendor_ext_tlv_2 *dst_ve = (vendor_ext_tlv_2 *)dst_tlv;
vendor_ext_tlv_2 *src_ve = (vendor_ext_tlv_2 *)src_tlv;
dst_ve->dummy = src_ve->dummy;
} break;
case VENDOR_EXT_TLV_1_TAG: {
vendor_ext_tlv_1 *dst_ve = (vendor_ext_tlv_1 *)dst_tlv;
vendor_ext_tlv_1 *src_ve = (vendor_ext_tlv_1 *)src_tlv;
dst_ve->dummy = src_ve->dummy;
} break;
}
}
bool eq_param_request(const nfapi_nr_param_request_scf_t *unpacked_req, const nfapi_nr_param_request_scf_t *req)
{
EQ(unpacked_req->header.message_id, req->header.message_id);
EQ(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) {
free(msg->vendor_extension);
}
}
void copy_param_request(const nfapi_nr_param_request_scf_t *src, nfapi_nr_param_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);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment