Add F1AP UE context release complete 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:
@@ -668,6 +668,11 @@ typedef struct f1ap_ue_context_rel_cmd_t {
|
||||
uint32_t *old_gNB_DU_ue_id; // if after reestablishment request
|
||||
} f1ap_ue_context_rel_cmd_t;
|
||||
|
||||
typedef struct f1ap_ue_context_rel_cplt_t {
|
||||
uint32_t gNB_CU_ue_id;
|
||||
uint32_t gNB_DU_ue_id;
|
||||
} f1ap_ue_context_rel_cplt_t;
|
||||
|
||||
typedef struct f1ap_ue_context_release_s {
|
||||
uint32_t gNB_CU_ue_id;
|
||||
uint32_t gNB_DU_ue_id;
|
||||
|
||||
@@ -2370,3 +2370,99 @@ void free_ue_context_rel_cmd(f1ap_ue_context_rel_cmd_t *cmd)
|
||||
free(cmd->srb_id);
|
||||
free(cmd->old_gNB_DU_ue_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Encode F1 UE context release complete to ASN.1
|
||||
*/
|
||||
struct F1AP_F1AP_PDU *encode_ue_context_rel_cplt(const f1ap_ue_context_rel_cplt_t *cplt)
|
||||
{
|
||||
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_UEContextRelease;
|
||||
tmp->criticality = F1AP_Criticality_reject;
|
||||
tmp->value.present = F1AP_SuccessfulOutcome__value_PR_UEContextReleaseComplete;
|
||||
F1AP_UEContextReleaseComplete_t *out = &tmp->value.choice.UEContextReleaseComplete;
|
||||
|
||||
/* mandatory: GNB_CU_UE_F1AP_ID */
|
||||
asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextReleaseCompleteIEs_t, ie1);
|
||||
ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
|
||||
ie1->criticality = F1AP_Criticality_reject;
|
||||
ie1->value.present = F1AP_UEContextReleaseCompleteIEs__value_PR_GNB_CU_UE_F1AP_ID;
|
||||
ie1->value.choice.GNB_CU_UE_F1AP_ID = cplt->gNB_CU_ue_id;
|
||||
|
||||
/* mandatory: GNB_DU_UE_F1AP_ID */
|
||||
asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextReleaseCompleteIEs_t, ie2);
|
||||
ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
|
||||
ie2->criticality = F1AP_Criticality_reject;
|
||||
ie2->value.present = F1AP_UEContextReleaseCompleteIEs__value_PR_GNB_DU_UE_F1AP_ID;
|
||||
ie2->value.choice.GNB_DU_UE_F1AP_ID = cplt->gNB_DU_ue_id;
|
||||
|
||||
return pdu;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode F1 UE Context Release Complete
|
||||
*/
|
||||
bool decode_ue_context_rel_cplt(const struct F1AP_F1AP_PDU *pdu, f1ap_ue_context_rel_cplt_t *out)
|
||||
{
|
||||
DevAssert(out != NULL);
|
||||
memset(out, 0, sizeof(*out));
|
||||
|
||||
F1AP_UEContextReleaseComplete_t *in = &pdu->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
|
||||
F1AP_UEContextReleaseCompleteIEs_t *ie;
|
||||
F1AP_LIB_FIND_IE(F1AP_UEContextReleaseCompleteIEs_t, ie, &in->protocolIEs.list, F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true);
|
||||
F1AP_LIB_FIND_IE(F1AP_UEContextReleaseCompleteIEs_t, ie, &in->protocolIEs.list, F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, 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_UEContextReleaseCompleteIEs__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_UEContextReleaseCompleteIEs__value_PR_GNB_DU_UE_F1AP_ID);
|
||||
out->gNB_DU_ue_id = ie->value.choice.GNB_DU_UE_F1AP_ID;
|
||||
break;
|
||||
default:
|
||||
PRINT_ERROR("F1AP_ProtocolIE_ID_id %ld unknown, skipping\n", ie->id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief F1 UE Context Release Complete deep copy
|
||||
*/
|
||||
f1ap_ue_context_rel_cplt_t cp_ue_context_rel_cplt(const f1ap_ue_context_rel_cplt_t *orig)
|
||||
{
|
||||
f1ap_ue_context_rel_cplt_t cp = {
|
||||
.gNB_CU_ue_id = orig->gNB_CU_ue_id,
|
||||
.gNB_DU_ue_id = orig->gNB_DU_ue_id,
|
||||
};
|
||||
return cp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief F1 UE Context Release Complete equality check
|
||||
*/
|
||||
bool eq_ue_context_rel_cplt(const f1ap_ue_context_rel_cplt_t *a, const f1ap_ue_context_rel_cplt_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);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Free Allocated F1 UE Context Release Complete
|
||||
*/
|
||||
void free_ue_context_rel_cplt(f1ap_ue_context_rel_cplt_t *cplt)
|
||||
{
|
||||
// nothing to free
|
||||
}
|
||||
|
||||
@@ -63,4 +63,10 @@ f1ap_ue_context_rel_cmd_t cp_ue_context_rel_cmd(const f1ap_ue_context_rel_cmd_t
|
||||
bool eq_ue_context_rel_cmd(const f1ap_ue_context_rel_cmd_t *a, const f1ap_ue_context_rel_cmd_t *b);
|
||||
void free_ue_context_rel_cmd(f1ap_ue_context_rel_cmd_t *cmd);
|
||||
|
||||
struct F1AP_F1AP_PDU *encode_ue_context_rel_cplt(const f1ap_ue_context_rel_cplt_t *msg);
|
||||
bool decode_ue_context_rel_cplt(const struct F1AP_F1AP_PDU *pdu, f1ap_ue_context_rel_cplt_t *out);
|
||||
f1ap_ue_context_rel_cplt_t cp_ue_context_rel_cplt(const f1ap_ue_context_rel_cplt_t *orig);
|
||||
bool eq_ue_context_rel_cplt(const f1ap_ue_context_rel_cplt_t *a, const f1ap_ue_context_rel_cplt_t *b);
|
||||
void free_ue_context_rel_cplt(f1ap_ue_context_rel_cplt_t *cplt);
|
||||
|
||||
#endif /* F1AP_UE_CONTEXT_SETUP_REQ_H_ */
|
||||
|
||||
@@ -1237,6 +1237,35 @@ static void test_f1ap_ue_context_release_command()
|
||||
printf("%s() successful\n", __func__);
|
||||
}
|
||||
|
||||
static void test_f1ap_ue_context_release_complete()
|
||||
{
|
||||
f1ap_ue_context_rel_cplt_t orig = {
|
||||
.gNB_CU_ue_id = 1111,
|
||||
.gNB_DU_ue_id = 2222,
|
||||
};
|
||||
|
||||
F1AP_F1AP_PDU_t *f1enc = encode_ue_context_rel_cplt(&orig);
|
||||
F1AP_F1AP_PDU_t *f1dec = f1ap_encode_decode(f1enc);
|
||||
f1ap_msg_free(f1enc);
|
||||
|
||||
f1ap_ue_context_rel_cplt_t decoded = {0};
|
||||
bool ret = decode_ue_context_rel_cplt(f1dec, &decoded);
|
||||
AssertFatal(ret, "decode_ue_context_rel_cplt(): could not decode message\n");
|
||||
f1ap_msg_free(f1dec);
|
||||
|
||||
ret = eq_ue_context_rel_cplt(&orig, &decoded);
|
||||
AssertFatal(ret, "eq_ue_context_rel_cplt(): decoded message doesn't match\n");
|
||||
free_ue_context_rel_cplt(&decoded);
|
||||
|
||||
f1ap_ue_context_rel_cplt_t cp = cp_ue_context_rel_cplt(&orig);
|
||||
ret = eq_ue_context_rel_cplt(&orig, &cp);
|
||||
AssertFatal(ret, "eq_ue_context_rel_cplt(): copied message doesn't match\n");
|
||||
free_ue_context_rel_cplt(&orig);
|
||||
free_ue_context_rel_cplt(&cp);
|
||||
|
||||
printf("%s() successful\n", __func__);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_initial_ul_rrc_message_transfer();
|
||||
@@ -1262,5 +1291,6 @@ int main()
|
||||
test_f1ap_ue_context_modification_response_simple();
|
||||
test_f1ap_ue_context_release_request();
|
||||
test_f1ap_ue_context_release_command();
|
||||
test_f1ap_ue_context_release_complete();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user