Add F1AP UE context setup response message enc/dec + test
See commit "Add F1AP UE context setup request message enc/dec + test" for more details on the approach taken.
This commit is contained in:
@@ -460,6 +460,11 @@ typedef struct f1ap_cu_to_du_rrc_info_s {
|
||||
byte_array_t *ho_prep_info;
|
||||
} f1ap_cu_to_du_rrc_info_t;
|
||||
|
||||
typedef struct f1ap_du_to_cu_rrc_info_t {
|
||||
byte_array_t cell_group_config;
|
||||
byte_array_t *meas_gap_config;
|
||||
} f1ap_du_to_cu_rrc_info_t;
|
||||
|
||||
typedef struct du_to_cu_rrc_information_s {
|
||||
uint8_t * cellGroupConfig;
|
||||
uint32_t cellGroupConfig_length;
|
||||
@@ -494,6 +499,11 @@ typedef struct f1ap_srb_to_setup_t {
|
||||
int id;
|
||||
} f1ap_srb_to_setup_t;
|
||||
|
||||
typedef struct f1ap_srb_setup_t {
|
||||
int id;
|
||||
int lcid;
|
||||
} f1ap_srb_setup_t;
|
||||
|
||||
/// 9.3.1.52 Packet Error Rate
|
||||
typedef struct f1ap_per_t {
|
||||
uint8_t scalar;
|
||||
@@ -560,6 +570,13 @@ typedef struct f1ap_drb_to_setup_t {
|
||||
f1ap_pdcp_sn_len_t *ul_pdcp_sn_len;
|
||||
} f1ap_drb_to_setup_t;
|
||||
|
||||
typedef struct f1ap_drb_setup_t {
|
||||
int id;
|
||||
int *lcid;
|
||||
int up_dl_tnl_len;
|
||||
f1ap_up_tnl_t up_dl_tnl[2];
|
||||
} f1ap_drb_setup_t;
|
||||
|
||||
typedef struct f1ap_drb_to_release_t {
|
||||
int id;
|
||||
} f1ap_drb_to_release_t;
|
||||
@@ -585,6 +602,21 @@ typedef struct f1ap_ue_context_setup_req_s {
|
||||
uint64_t *gnb_du_ue_agg_mbr_ul; // C-ifDRBSetup
|
||||
} f1ap_ue_context_setup_req_t;
|
||||
|
||||
typedef struct f1ap_ue_context_setup_resp_s {
|
||||
uint32_t gNB_CU_ue_id;
|
||||
uint32_t gNB_DU_ue_id;
|
||||
|
||||
f1ap_du_to_cu_rrc_info_t du_to_cu_rrc_info;
|
||||
|
||||
uint16_t *crnti;
|
||||
|
||||
int drbs_len;
|
||||
f1ap_drb_setup_t *drbs;
|
||||
|
||||
int srbs_len;
|
||||
f1ap_srb_setup_t *srbs;
|
||||
} f1ap_ue_context_setup_resp_t;
|
||||
|
||||
typedef struct f1ap_ue_context_mod_req_t {
|
||||
uint32_t gNB_CU_ue_id;
|
||||
uint32_t gNB_DU_ue_id;
|
||||
|
||||
@@ -46,5 +46,6 @@
|
||||
#include "F1AP_Flows-Mapped-To-DRB-Item.h"
|
||||
#include "F1AP_NonDynamic5QIDescriptor.h"
|
||||
#include "F1AP_Dynamic5QIDescriptor.h"
|
||||
#include "F1AP_DLUPTNLInformation-ToBeSetup-Item.h"
|
||||
|
||||
#endif /* F1AP_LIB_INCLUDES_H_ */
|
||||
|
||||
@@ -138,6 +138,58 @@ static void free_cu_to_du_rrc_info(f1ap_cu_to_du_rrc_info_t *cu2du)
|
||||
FREE_OPT_BYTE_ARRAY(cu2du->ho_prep_info);
|
||||
}
|
||||
|
||||
static F1AP_DUtoCURRCInformation_t encode_du_to_cu_rrc_info(const f1ap_du_to_cu_rrc_info_t *du2cu)
|
||||
{
|
||||
F1AP_DUtoCURRCInformation_t enc = {0};
|
||||
|
||||
/* mandatory: cellGroupConfig */
|
||||
const byte_array_t *ba = &du2cu->cell_group_config;
|
||||
OCTET_STRING_fromBuf(&enc.cellGroupConfig, (const char *)ba->buf, ba->len);
|
||||
|
||||
/* optional: MeasGapConfig */
|
||||
if (du2cu->meas_gap_config) {
|
||||
ba = du2cu->meas_gap_config;
|
||||
asn1cCalloc(enc.measGapConfig, measGapConfig);
|
||||
OCTET_STRING_fromBuf(measGapConfig, (const char *)ba->buf, ba->len);
|
||||
}
|
||||
|
||||
return enc;
|
||||
}
|
||||
|
||||
static bool decode_du_to_cu_rrc_info(f1ap_du_to_cu_rrc_info_t *dec, const F1AP_DUtoCURRCInformation_t *du2cu)
|
||||
{
|
||||
const F1AP_CellGroupConfig_t *cgc = &du2cu->cellGroupConfig;
|
||||
dec->cell_group_config = create_byte_array(cgc->size, (uint8_t *)cgc->buf);
|
||||
|
||||
if (du2cu->measGapConfig) {
|
||||
const F1AP_MeasGapConfig_t *mgc = du2cu->measGapConfig;
|
||||
dec->meas_gap_config = calloc_or_fail(1, sizeof(*dec->meas_gap_config));
|
||||
*dec->meas_gap_config = create_byte_array(mgc->size, (uint8_t *)mgc->buf);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static f1ap_du_to_cu_rrc_info_t cp_du_to_cu_rrc_info(const f1ap_du_to_cu_rrc_info_t *src)
|
||||
{
|
||||
f1ap_du_to_cu_rrc_info_t cp = {0};
|
||||
cp.cell_group_config = copy_byte_array(src->cell_group_config);
|
||||
CP_OPT_BYTE_ARRAY(cp.meas_gap_config, src->meas_gap_config);
|
||||
return cp;
|
||||
}
|
||||
|
||||
static bool eq_du_to_cu_rrc_info(const f1ap_du_to_cu_rrc_info_t *a, const f1ap_du_to_cu_rrc_info_t *b)
|
||||
{
|
||||
_F1_CHECK_EXP(eq_byte_array(&a->cell_group_config, &b->cell_group_config));
|
||||
_F1_EQ_CHECK_OPTIONAL_IE(a, b, meas_gap_config, eq_ba);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void free_du_to_cu_rrc_info(f1ap_du_to_cu_rrc_info_t *du2cu)
|
||||
{
|
||||
free_byte_array(du2cu->cell_group_config);
|
||||
FREE_OPT_BYTE_ARRAY(du2cu->meas_gap_config);
|
||||
}
|
||||
|
||||
/* \brief Encode SRB-ToBeSetup List, for UE Context Setup Request, from
|
||||
* f1ap_srb_to_setup_t. */
|
||||
static F1AP_SRBs_ToBeSetup_List_t encode_srbs_to_setup(int n, const f1ap_srb_to_setup_t *srbs)
|
||||
@@ -231,6 +283,59 @@ static void free_srb_to_setup(f1ap_srb_to_setup_t *srbs)
|
||||
// nothing to free
|
||||
}
|
||||
|
||||
static F1AP_SRBs_Setup_List_t encode_srbs_setup(int n, const f1ap_srb_setup_t *srbs)
|
||||
{
|
||||
F1AP_SRBs_Setup_List_t list = {0};
|
||||
for (int i = 0; i < n; ++i) {
|
||||
asn1cSequenceAdd(list, F1AP_SRBs_Setup_ItemIEs_t, itie);
|
||||
itie->id = F1AP_ProtocolIE_ID_id_SRBs_Setup_Item;
|
||||
itie->criticality = F1AP_Criticality_ignore;
|
||||
itie->value.present = F1AP_SRBs_Setup_ItemIEs__value_PR_SRBs_Setup_Item;
|
||||
F1AP_SRBs_Setup_Item_t *it = &itie->value.choice.SRBs_Setup_Item;
|
||||
it->sRBID = srbs[i].id;
|
||||
it->lCID = srbs[i].lcid;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
static bool decode_srbs_setup(const F1AP_SRBs_Setup_List_t *f1ap, int *n, f1ap_srb_setup_t **out)
|
||||
{
|
||||
DevAssert(out != NULL);
|
||||
*out = NULL;
|
||||
int count = *n = f1ap->list.count;
|
||||
if (count == 0)
|
||||
return true;
|
||||
|
||||
f1ap_srb_setup_t *srbs = *out = calloc_or_fail(count, sizeof(*srbs));
|
||||
for (int i = 0; i < count; ++i) {
|
||||
const F1AP_SRBs_Setup_ItemIEs_t *itie = (F1AP_SRBs_Setup_ItemIEs_t *)f1ap->list.array[i];
|
||||
_F1_EQ_CHECK_LONG(itie->id, F1AP_ProtocolIE_ID_id_SRBs_Setup_Item);
|
||||
_F1_EQ_CHECK_INT(itie->value.present, F1AP_SRBs_Setup_ItemIEs__value_PR_SRBs_Setup_Item);
|
||||
const F1AP_SRBs_Setup_Item_t *it = &itie->value.choice.SRBs_Setup_Item;
|
||||
srbs[i].id = it->sRBID;
|
||||
srbs[i].lcid = it->lCID;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static f1ap_srb_setup_t cp_srb_setup(const f1ap_srb_setup_t *orig)
|
||||
{
|
||||
f1ap_srb_setup_t cp = {.id = orig->id, .lcid = orig->lcid};
|
||||
return cp;
|
||||
}
|
||||
|
||||
static bool eq_srb_setup(const f1ap_srb_setup_t *a, const f1ap_srb_setup_t *b)
|
||||
{
|
||||
_F1_EQ_CHECK_INT(a->id, b->id);
|
||||
_F1_EQ_CHECK_INT(a->lcid, b->lcid);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void free_srb_setup(f1ap_srb_setup_t *srbs)
|
||||
{
|
||||
// nothing to free
|
||||
}
|
||||
|
||||
static F1AP_QoSFlowLevelQoSParameters_t encode_qos_flow_param(const f1ap_qos_flow_param_t *p)
|
||||
{
|
||||
F1AP_QoSFlowLevelQoSParameters_t f1ap = {0};
|
||||
@@ -784,6 +889,88 @@ static void free_drb_to_setup(f1ap_drb_to_setup_t *drb)
|
||||
free(drb->ul_pdcp_sn_len);
|
||||
}
|
||||
|
||||
static F1AP_DRBs_Setup_List_t encode_drbs_setup(int n, const f1ap_drb_setup_t *drbs)
|
||||
{
|
||||
F1AP_DRBs_Setup_List_t list = {0};
|
||||
for (int i = 0; i < n; ++i) {
|
||||
const f1ap_drb_setup_t *drb = &drbs[i];
|
||||
asn1cSequenceAdd(list, F1AP_DRBs_Setup_ItemIEs_t, itie);
|
||||
itie->id = F1AP_ProtocolIE_ID_id_DRBs_Setup_Item;
|
||||
itie->criticality = F1AP_Criticality_ignore;
|
||||
itie->value.present = F1AP_DRBs_Setup_ItemIEs__value_PR_DRBs_Setup_Item;
|
||||
|
||||
F1AP_DRBs_Setup_Item_t *it = &itie->value.choice.DRBs_Setup_Item;
|
||||
it->dRBID = drb->id;
|
||||
if (drb->lcid)
|
||||
asn1cCallocOne(it->lCID, *drb->lcid);
|
||||
for (int j = 0; j < drb->up_dl_tnl_len; ++j) {
|
||||
DevAssert(drb->up_dl_tnl[j].teid > 0);
|
||||
asn1cSequenceAdd(it->dLUPTNLInformation_ToBeSetup_List.list, F1AP_DLUPTNLInformation_ToBeSetup_Item_t, tnl_it);
|
||||
tnl_it->dLUPTNLInformation = encode_up_tnl(&drb->up_dl_tnl[j]);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
static bool decode_drbs_setup(const F1AP_DRBs_Setup_List_t *f1ap, int *n, f1ap_drb_setup_t **out)
|
||||
{
|
||||
DevAssert(out != NULL);
|
||||
*out = NULL;
|
||||
int count = *n = f1ap->list.count;
|
||||
if (count == 0)
|
||||
return true;
|
||||
|
||||
f1ap_drb_setup_t *drbs = *out = calloc_or_fail(count, sizeof(*drbs));
|
||||
for (int i = 0; i < count; ++i) {
|
||||
const F1AP_DRBs_Setup_ItemIEs_t *itie = (const F1AP_DRBs_Setup_ItemIEs_t *)f1ap->list.array[i];
|
||||
_F1_EQ_CHECK_LONG(itie->id, F1AP_ProtocolIE_ID_id_DRBs_Setup_Item);
|
||||
_F1_EQ_CHECK_INT(itie->value.present, F1AP_DRBs_Setup_ItemIEs__value_PR_DRBs_Setup_Item);
|
||||
const F1AP_DRBs_Setup_Item_t *it = &itie->value.choice.DRBs_Setup_Item;
|
||||
|
||||
f1ap_drb_setup_t *drb = &drbs[i];
|
||||
drb->id = it->dRBID;
|
||||
if (it->lCID)
|
||||
_F1_MALLOC(drb->lcid, *it->lCID);
|
||||
|
||||
drb->up_dl_tnl_len = it->dLUPTNLInformation_ToBeSetup_List.list.count;
|
||||
_F1_EQ_CHECK_GENERIC(drb->up_dl_tnl_len > 0 && drb->up_dl_tnl_len <= 2, "%d", drb->up_dl_tnl_len, 1);
|
||||
for (int j = 0; j < drb->up_dl_tnl_len; ++j) {
|
||||
F1AP_DLUPTNLInformation_ToBeSetup_Item_t *it_tnl = it->dLUPTNLInformation_ToBeSetup_List.list.array[j];
|
||||
_F1_CHECK_EXP(decode_up_tnl(&it_tnl->dLUPTNLInformation, &drb->up_dl_tnl[j]));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static f1ap_drb_setup_t cp_drb_setup(const f1ap_drb_setup_t *orig)
|
||||
{
|
||||
f1ap_drb_setup_t cp = {
|
||||
.id = orig->id,
|
||||
.up_dl_tnl_len = orig->up_dl_tnl_len,
|
||||
.up_dl_tnl[0] = cp_up_tnl(&orig->up_dl_tnl[0]),
|
||||
.up_dl_tnl[1] = cp_up_tnl(&orig->up_dl_tnl[1]),
|
||||
};
|
||||
if (orig->lcid)
|
||||
_F1_MALLOC(cp.lcid, *orig->lcid);
|
||||
return cp;
|
||||
}
|
||||
|
||||
static bool eq_drb_setup(const f1ap_drb_setup_t *a, const f1ap_drb_setup_t *b)
|
||||
{
|
||||
_F1_EQ_CHECK_INT(a->id, b->id);
|
||||
_F1_EQ_CHECK_OPTIONAL_IE(a, b, lcid, _F1_EQ_CHECK_INT);
|
||||
_F1_EQ_CHECK_INT(a->up_dl_tnl_len, b->up_dl_tnl_len);
|
||||
for (int i = 0; i < a->up_dl_tnl_len; ++i)
|
||||
_F1_CHECK_EXP(eq_up_tnl(&a->up_dl_tnl[i], &b->up_dl_tnl[i]));
|
||||
return true;
|
||||
}
|
||||
|
||||
static void free_drb_setup(f1ap_drb_setup_t *drb)
|
||||
{
|
||||
free(drb->lcid);
|
||||
}
|
||||
|
||||
static F1AP_DRBs_ToBeReleased_List_t encode_drbs_to_release(int n, const f1ap_drb_to_release_t *drbs)
|
||||
{
|
||||
F1AP_DRBs_ToBeReleased_List_t list = {0};
|
||||
@@ -1087,6 +1274,194 @@ void free_ue_context_setup_req(f1ap_ue_context_setup_req_t *req)
|
||||
free(req->gnb_du_ue_agg_mbr_ul);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Encode F1 UE context setup response to ASN.1
|
||||
*/
|
||||
F1AP_F1AP_PDU_t *encode_ue_context_setup_resp(const f1ap_ue_context_setup_resp_t *msg)
|
||||
{
|
||||
F1AP_F1AP_PDU_t *pdu = calloc_or_fail(1, sizeof(*pdu));
|
||||
|
||||
/* Message Type */
|
||||
pdu->present = F1AP_F1AP_PDU_PR_successfulOutcome;
|
||||
asn1cCalloc(pdu->choice.successfulOutcome, tmp);
|
||||
tmp->procedureCode = F1AP_ProcedureCode_id_UEContextSetup;
|
||||
tmp->criticality = F1AP_Criticality_reject;
|
||||
tmp->value.present = F1AP_SuccessfulOutcome__value_PR_UEContextSetupResponse;
|
||||
F1AP_UEContextSetupResponse_t *out = &tmp->value.choice.UEContextSetupResponse;
|
||||
|
||||
/* mandatory: GNB_CU_UE_F1AP_ID */
|
||||
asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie1);
|
||||
ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
|
||||
ie1->criticality = F1AP_Criticality_reject;
|
||||
ie1->value.present = F1AP_UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
|
||||
ie1->value.choice.GNB_CU_UE_F1AP_ID = msg->gNB_CU_ue_id;
|
||||
|
||||
/* mandatory: GNB_DU_UE_F1AP_ID */
|
||||
asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie2);
|
||||
ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
|
||||
ie2->criticality = F1AP_Criticality_reject;
|
||||
ie2->value.present = F1AP_UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
|
||||
ie2->value.choice.GNB_DU_UE_F1AP_ID = msg->gNB_DU_ue_id;
|
||||
|
||||
/* mandatory: DUtoCURRCInformation */
|
||||
asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie3);
|
||||
ie3->id = F1AP_ProtocolIE_ID_id_DUtoCURRCInformation;
|
||||
ie3->criticality = F1AP_Criticality_reject;
|
||||
ie3->value.present = F1AP_UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation;
|
||||
ie3->value.choice.DUtoCURRCInformation = encode_du_to_cu_rrc_info(&msg->du_to_cu_rrc_info);
|
||||
|
||||
/* optional: C-RNTI */
|
||||
if (msg->crnti) {
|
||||
asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie4);
|
||||
ie4->id = F1AP_ProtocolIE_ID_id_C_RNTI;
|
||||
ie4->criticality = F1AP_Criticality_ignore;
|
||||
ie4->value.present = F1AP_UEContextSetupResponseIEs__value_PR_C_RNTI;
|
||||
ie4->value.choice.C_RNTI = *msg->crnti;
|
||||
}
|
||||
|
||||
/* optional: DRB Setup List */
|
||||
if (msg->drbs_len > 0) {
|
||||
asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie7);
|
||||
ie7->id = F1AP_ProtocolIE_ID_id_DRBs_Setup_List;
|
||||
ie7->criticality = F1AP_Criticality_ignore;
|
||||
ie7->value.present = F1AP_UEContextSetupResponseIEs__value_PR_DRBs_Setup_List;
|
||||
ie7->value.choice.DRBs_Setup_List = encode_drbs_setup(msg->drbs_len, msg->drbs);
|
||||
}
|
||||
|
||||
/* optional: SRB Setup List */
|
||||
if (msg->srbs_len > 0) {
|
||||
asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie11);
|
||||
ie11->id = F1AP_ProtocolIE_ID_id_SRBs_Setup_List;
|
||||
ie11->criticality = F1AP_Criticality_ignore;
|
||||
ie11->value.present = F1AP_UEContextSetupResponseIEs__value_PR_SRBs_Setup_List;
|
||||
ie11->value.choice.SRBs_Setup_List = encode_srbs_setup(msg->srbs_len, msg->srbs);
|
||||
}
|
||||
|
||||
return pdu;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode F1 UE Context Setup Response
|
||||
*/
|
||||
bool decode_ue_context_setup_resp(const struct F1AP_F1AP_PDU *pdu, f1ap_ue_context_setup_resp_t *out)
|
||||
{
|
||||
DevAssert(out != NULL);
|
||||
memset(out, 0, sizeof(*out));
|
||||
|
||||
F1AP_UEContextSetupResponse_t *in = &pdu->choice.successfulOutcome->value.choice.UEContextSetupResponse;
|
||||
F1AP_UEContextSetupResponseIEs_t *ie;
|
||||
|
||||
F1AP_LIB_FIND_IE(F1AP_UEContextSetupResponseIEs_t, ie, &in->protocolIEs.list, F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true);
|
||||
F1AP_LIB_FIND_IE(F1AP_UEContextSetupResponseIEs_t, ie, &in->protocolIEs.list, F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true);
|
||||
F1AP_LIB_FIND_IE(F1AP_UEContextSetupResponseIEs_t, ie, &in->protocolIEs.list, F1AP_ProtocolIE_ID_id_DUtoCURRCInformation, true);
|
||||
|
||||
for (int i = 0; i < in->protocolIEs.list.count; ++i) {
|
||||
ie = in->protocolIEs.list.array[i];
|
||||
AssertError(ie != NULL, return false, "in->protocolIEs.list.array[i] is NULL");
|
||||
switch (ie->id) {
|
||||
case F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
|
||||
_F1_EQ_CHECK_INT(ie->value.present, F1AP_UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID);
|
||||
out->gNB_CU_ue_id = ie->value.choice.GNB_CU_UE_F1AP_ID;
|
||||
break;
|
||||
case F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
|
||||
_F1_EQ_CHECK_INT(ie->value.present, F1AP_UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID);
|
||||
out->gNB_DU_ue_id = ie->value.choice.GNB_DU_UE_F1AP_ID;
|
||||
break;
|
||||
case F1AP_ProtocolIE_ID_id_DUtoCURRCInformation:
|
||||
_F1_EQ_CHECK_INT(ie->value.present, F1AP_UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation);
|
||||
_F1_CHECK_EXP(decode_du_to_cu_rrc_info(&out->du_to_cu_rrc_info, &ie->value.choice.DUtoCURRCInformation));
|
||||
break;
|
||||
case F1AP_ProtocolIE_ID_id_C_RNTI:
|
||||
_F1_EQ_CHECK_INT(ie->value.present, F1AP_UEContextSetupResponseIEs__value_PR_C_RNTI);
|
||||
_F1_MALLOC(out->crnti, ie->value.choice.C_RNTI);
|
||||
break;
|
||||
case F1AP_ProtocolIE_ID_id_DRBs_Setup_List:
|
||||
_F1_EQ_CHECK_INT(ie->value.present, F1AP_UEContextSetupResponseIEs__value_PR_DRBs_Setup_List);
|
||||
_F1_CHECK_EXP(decode_drbs_setup(&ie->value.choice.DRBs_Setup_List, &out->drbs_len, &out->drbs));
|
||||
break;
|
||||
case F1AP_ProtocolIE_ID_id_SRBs_Setup_List:
|
||||
_F1_EQ_CHECK_INT(ie->value.present, F1AP_UEContextSetupResponseIEs__value_PR_SRBs_Setup_List);
|
||||
_F1_CHECK_EXP(decode_srbs_setup(&ie->value.choice.SRBs_Setup_List, &out->srbs_len, &out->srbs));
|
||||
break;
|
||||
default:
|
||||
PRINT_ERROR("F1AP_ProtocolIE_ID_id %ld unknown, skipping\n", ie->id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief F1 UE Context Setup Response deep copy
|
||||
*/
|
||||
f1ap_ue_context_setup_resp_t cp_ue_context_setup_resp(const f1ap_ue_context_setup_resp_t *orig)
|
||||
{
|
||||
f1ap_ue_context_setup_resp_t cp = {
|
||||
.gNB_CU_ue_id = orig->gNB_CU_ue_id,
|
||||
.gNB_DU_ue_id = orig->gNB_DU_ue_id,
|
||||
.du_to_cu_rrc_info = cp_du_to_cu_rrc_info(&orig->du_to_cu_rrc_info),
|
||||
// crnti below
|
||||
.drbs_len = orig->drbs_len,
|
||||
// drbs below
|
||||
.srbs_len = orig->srbs_len,
|
||||
// srbs below
|
||||
};
|
||||
if (orig->crnti)
|
||||
_F1_MALLOC(cp.crnti, *orig->crnti);
|
||||
if (orig->drbs_len > 0 && orig->drbs) {
|
||||
cp.drbs = calloc_or_fail(orig->drbs_len, sizeof(*cp.drbs));
|
||||
cp.drbs_len = orig->drbs_len;
|
||||
for (int i = 0; i < cp.drbs_len; ++i)
|
||||
cp.drbs[i] = cp_drb_setup(&orig->drbs[i]);
|
||||
}
|
||||
if (orig->srbs_len > 0 && orig->srbs) {
|
||||
cp.srbs = calloc_or_fail(orig->srbs_len, sizeof(*cp.srbs));
|
||||
cp.srbs_len = orig->srbs_len;
|
||||
for (int i = 0; i < cp.srbs_len; ++i)
|
||||
cp.srbs[i] = cp_srb_setup(&orig->srbs[i]);
|
||||
}
|
||||
return cp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief F1 UE Context Setup Response equality check
|
||||
*/
|
||||
bool eq_ue_context_setup_resp(const f1ap_ue_context_setup_resp_t *a, const f1ap_ue_context_setup_resp_t *b)
|
||||
{
|
||||
_F1_EQ_CHECK_INT(a->gNB_CU_ue_id, b->gNB_CU_ue_id);
|
||||
_F1_EQ_CHECK_INT(a->gNB_DU_ue_id, b->gNB_DU_ue_id);
|
||||
_F1_CHECK_EXP(eq_du_to_cu_rrc_info(&a->du_to_cu_rrc_info, &b->du_to_cu_rrc_info));
|
||||
_F1_EQ_CHECK_OPTIONAL_IE(a, b, crnti, _F1_EQ_CHECK_INT);
|
||||
|
||||
_F1_EQ_CHECK_INT(a->drbs_len, b->drbs_len);
|
||||
_F1_CHECK_EXP(a->drbs_len == 0 || (a->drbs && b->drbs));
|
||||
for (int i = 0; i < a->drbs_len; ++i)
|
||||
_F1_CHECK_EXP(eq_drb_setup(&a->drbs[i], &b->drbs[i]));
|
||||
|
||||
_F1_EQ_CHECK_INT(a->srbs_len, b->srbs_len);
|
||||
_F1_CHECK_EXP(a->srbs_len == 0 || (a->srbs && b->srbs));
|
||||
for (int i = 0; i < a->srbs_len; ++i)
|
||||
_F1_CHECK_EXP(eq_srb_setup(&a->srbs[i], &b->srbs[i]));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Free Allocated F1 UE Context Setup Response
|
||||
*/
|
||||
void free_ue_context_setup_resp(f1ap_ue_context_setup_resp_t *resp)
|
||||
{
|
||||
free_du_to_cu_rrc_info(&resp->du_to_cu_rrc_info);
|
||||
free(resp->crnti);
|
||||
for (int i = 0; i < resp->drbs_len; ++i)
|
||||
free_drb_setup(&resp->drbs[i]);
|
||||
free(resp->drbs);
|
||||
for (int i = 0; i < resp->srbs_len; ++i)
|
||||
free_srb_setup(&resp->srbs[i]);
|
||||
free(resp->srbs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Encode F1 UE context modification request to ASN.1
|
||||
*/
|
||||
|
||||
@@ -33,6 +33,12 @@ f1ap_ue_context_setup_req_t cp_ue_context_setup_req(const f1ap_ue_context_setup_
|
||||
bool eq_ue_context_setup_req(const f1ap_ue_context_setup_req_t *a, const f1ap_ue_context_setup_req_t *b);
|
||||
void free_ue_context_setup_req(f1ap_ue_context_setup_req_t *req);
|
||||
|
||||
struct F1AP_F1AP_PDU *encode_ue_context_setup_resp(const f1ap_ue_context_setup_resp_t *msg);
|
||||
bool decode_ue_context_setup_resp(const struct F1AP_F1AP_PDU *pdu, f1ap_ue_context_setup_resp_t *out);
|
||||
f1ap_ue_context_setup_resp_t cp_ue_context_setup_resp(const f1ap_ue_context_setup_resp_t *orig);
|
||||
bool eq_ue_context_setup_resp(const f1ap_ue_context_setup_resp_t *a, const f1ap_ue_context_setup_resp_t *b);
|
||||
void free_ue_context_setup_resp(f1ap_ue_context_setup_resp_t *resp);
|
||||
|
||||
struct F1AP_F1AP_PDU *encode_ue_context_mod_req(const f1ap_ue_context_mod_req_t *msg);
|
||||
bool decode_ue_context_mod_req(const struct F1AP_F1AP_PDU *pdu, f1ap_ue_context_mod_req_t *out);
|
||||
f1ap_ue_context_mod_req_t cp_ue_context_mod_req(const f1ap_ue_context_mod_req_t *orig);
|
||||
|
||||
@@ -885,6 +885,100 @@ static void test_f1ap_ue_context_setup_request_simple()
|
||||
printf("%s() successful\n", __func__);
|
||||
}
|
||||
|
||||
static void test_f1ap_ue_context_setup_response()
|
||||
{
|
||||
f1ap_ue_context_setup_resp_t orig = {
|
||||
.gNB_CU_ue_id = 12,
|
||||
.gNB_DU_ue_id = 13,
|
||||
//.du_to_cu_rrc_info below
|
||||
//.crnti below
|
||||
//.drbs below
|
||||
//.srbs below
|
||||
};
|
||||
|
||||
orig.du_to_cu_rrc_info.cell_group_config = get_test_ba("CELL GROUP CONFIG");
|
||||
orig.du_to_cu_rrc_info.meas_gap_config = get_malloced_test_ba("MGC");
|
||||
|
||||
_F1_MALLOC(orig.crnti, 0x1234);
|
||||
|
||||
orig.drbs_len = 2;
|
||||
orig.drbs = calloc_or_fail(orig.drbs_len, sizeof(*orig.drbs));
|
||||
f1ap_drb_setup_t *drb1 = &orig.drbs[0];
|
||||
drb1->id = 12;
|
||||
_F1_MALLOC(drb1->lcid, 12);
|
||||
drb1->up_dl_tnl_len = 2;
|
||||
inet_pton(AF_INET, "192.168.40.23", &drb1->up_dl_tnl[0].tl_address);
|
||||
drb1->up_dl_tnl[0].teid = 0x11223344;
|
||||
inet_pton(AF_INET, "192.168.40.23", &drb1->up_dl_tnl[1].tl_address);
|
||||
drb1->up_dl_tnl[1].teid = 0x11223345;
|
||||
f1ap_drb_setup_t *drb2 = &orig.drbs[1];
|
||||
drb2->id = 13;
|
||||
_F1_MALLOC(drb2->lcid, 13);
|
||||
drb2->up_dl_tnl_len = 2;
|
||||
inet_pton(AF_INET, "192.168.50.23", &drb2->up_dl_tnl[0].tl_address);
|
||||
drb2->up_dl_tnl[0].teid = 0x21223354;
|
||||
inet_pton(AF_INET, "192.168.50.23", &drb2->up_dl_tnl[1].tl_address);
|
||||
drb2->up_dl_tnl[1].teid = 0x21223355;
|
||||
|
||||
orig.srbs_len = 2;
|
||||
orig.srbs = calloc_or_fail(orig.srbs_len, sizeof(*orig.srbs));
|
||||
for (int i = 0; i < orig.srbs_len; ++i) {
|
||||
orig.srbs[i].id = 1 + i;
|
||||
orig.srbs[i].lcid = 1+i+10;
|
||||
}
|
||||
|
||||
F1AP_F1AP_PDU_t *f1enc = encode_ue_context_setup_resp(&orig);
|
||||
F1AP_F1AP_PDU_t *f1dec = f1ap_encode_decode(f1enc);
|
||||
f1ap_msg_free(f1enc);
|
||||
|
||||
f1ap_ue_context_setup_resp_t decoded = {0};
|
||||
bool ret = decode_ue_context_setup_resp(f1dec, &decoded);
|
||||
AssertFatal(ret, "decode_ue_context_setup_resp(): could not decode message\n");
|
||||
f1ap_msg_free(f1dec);
|
||||
|
||||
ret = eq_ue_context_setup_resp(&orig, &decoded);
|
||||
AssertFatal(ret, "eq_ue_context_setup_resp(): decoded message doesn't match\n");
|
||||
free_ue_context_setup_resp(&decoded);
|
||||
|
||||
f1ap_ue_context_setup_resp_t cp = cp_ue_context_setup_resp(&orig);
|
||||
ret = eq_ue_context_setup_resp(&orig, &cp);
|
||||
AssertFatal(ret, "eq_ue_context_setup_resp(): copied message doesn't match\n");
|
||||
free_ue_context_setup_resp(&orig);
|
||||
free_ue_context_setup_resp(&cp);
|
||||
|
||||
printf("%s() successful\n", __func__);
|
||||
}
|
||||
|
||||
static void test_f1ap_ue_context_setup_response_simple()
|
||||
{
|
||||
f1ap_ue_context_setup_resp_t orig = {
|
||||
.gNB_CU_ue_id = 12,
|
||||
.gNB_DU_ue_id = 13,
|
||||
.du_to_cu_rrc_info.cell_group_config = get_test_ba("small cg"),
|
||||
// rest is optional and intentionally left empty
|
||||
};
|
||||
|
||||
F1AP_F1AP_PDU_t *f1enc = encode_ue_context_setup_resp(&orig);
|
||||
F1AP_F1AP_PDU_t *f1dec = f1ap_encode_decode(f1enc);
|
||||
f1ap_msg_free(f1enc);
|
||||
|
||||
f1ap_ue_context_setup_resp_t decoded = {0};
|
||||
bool ret = decode_ue_context_setup_resp(f1dec, &decoded);
|
||||
AssertFatal(ret, "decode_ue_context_setup_resp(): could not decode message\n");
|
||||
f1ap_msg_free(f1dec);
|
||||
|
||||
ret = eq_ue_context_setup_resp(&orig, &decoded);
|
||||
AssertFatal(ret, "eq_ue_context_setup_resp(): decoded message doesn't match\n");
|
||||
free_ue_context_setup_resp(&decoded);
|
||||
|
||||
f1ap_ue_context_setup_resp_t cp = cp_ue_context_setup_resp(&orig);
|
||||
ret = eq_ue_context_setup_resp(&orig, &cp);
|
||||
AssertFatal(ret, "eq_ue_context_setup_resp(): copied message doesn't match\n");
|
||||
free_ue_context_setup_resp(&orig);
|
||||
free_ue_context_setup_resp(&cp);
|
||||
|
||||
printf("%s() successful\n", __func__);
|
||||
}
|
||||
|
||||
static void test_f1ap_ue_context_modification_request()
|
||||
{
|
||||
@@ -1012,6 +1106,8 @@ int main()
|
||||
test_f1ap_du_configuration_update_acknowledge();
|
||||
test_f1ap_ue_context_setup_request();
|
||||
test_f1ap_ue_context_setup_request_simple();
|
||||
test_f1ap_ue_context_setup_response();
|
||||
test_f1ap_ue_context_setup_response_simple();
|
||||
test_f1ap_ue_context_modification_request();
|
||||
test_f1ap_ue_context_modification_request_simple();
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user