Commit 7e495db5 authored by Guido Casati's avatar Guido Casati

Add encoding/decoding lib for F1 Setup Failure (interface management)

parent 28e2d67e
......@@ -856,3 +856,117 @@ void free_f1ap_setup_response(const f1ap_setup_resp_t *msg)
if (msg->cells_to_activate[i].SI_msg[j].SI_container_length > 0)
free(msg->cells_to_activate[i].SI_msg[j].SI_container);
}
/* ====================================
* F1AP Setup Failure
* ==================================== */
/**
* @brief F1AP Setup Failure encoding
*/
F1AP_F1AP_PDU_t *encode_f1ap_setup_failure(const f1ap_setup_failure_t *msg)
{
F1AP_F1AP_PDU_t *pdu = calloc_or_fail(1, sizeof(*pdu));
/* Create */
/* 0. Message Type */
asn1cCalloc(pdu->choice.unsuccessfulOutcome, UnsuccessfulOutcome);
pdu->present = F1AP_F1AP_PDU_PR_unsuccessfulOutcome;
UnsuccessfulOutcome->procedureCode = F1AP_ProcedureCode_id_F1Setup;
UnsuccessfulOutcome->criticality = F1AP_Criticality_reject;
UnsuccessfulOutcome->value.present = F1AP_UnsuccessfulOutcome__value_PR_F1SetupFailure;
F1AP_F1SetupFailure_t *out = &pdu->choice.unsuccessfulOutcome->value.choice.F1SetupFailure;
/* mandatory */
/* c1. Transaction ID (integer value)*/
asn1cSequenceAdd(out->protocolIEs.list, F1AP_F1SetupFailureIEs_t, ie1);
ie1->id = F1AP_ProtocolIE_ID_id_TransactionID;
ie1->criticality = F1AP_Criticality_reject;
ie1->value.present = F1AP_F1SetupFailureIEs__value_PR_TransactionID;
ie1->value.choice.TransactionID = msg->transaction_id;
/* mandatory */
/* c2. Cause */
asn1cSequenceAdd(out->protocolIEs.list, F1AP_F1SetupFailureIEs_t, ie2);
ie2->id = F1AP_ProtocolIE_ID_id_Cause;
ie2->criticality = F1AP_Criticality_ignore;
ie2->value.present = F1AP_F1SetupFailureIEs__value_PR_Cause;
ie2->value.choice.Cause.present = F1AP_Cause_PR_radioNetwork;
ie2->value.choice.Cause.choice.radioNetwork = msg->cause;
/* optional */
/* c3. TimeToWait */
if (msg->time_to_wait > 0) {
asn1cSequenceAdd(out->protocolIEs.list, F1AP_F1SetupFailureIEs_t, ie3);
ie3->id = F1AP_ProtocolIE_ID_id_TimeToWait;
ie3->criticality = F1AP_Criticality_ignore;
ie3->value.present = F1AP_F1SetupFailureIEs__value_PR_TimeToWait;
ie3->value.choice.TimeToWait = F1AP_TimeToWait_v10s;
}
/* optional */
/* c4. CriticalityDiagnostics*/
if (msg->criticality_diagnostics) {
asn1cSequenceAdd(out->protocolIEs.list, F1AP_F1SetupFailureIEs_t, ie4);
ie4->id = F1AP_ProtocolIE_ID_id_CriticalityDiagnostics;
ie4->criticality = F1AP_Criticality_ignore;
ie4->value.present = F1AP_F1SetupFailureIEs__value_PR_CriticalityDiagnostics;
asn1cCallocOne(ie4->value.choice.CriticalityDiagnostics.procedureCode, F1AP_ProcedureCode_id_UEContextSetup);
asn1cCallocOne(ie4->value.choice.CriticalityDiagnostics.triggeringMessage, F1AP_TriggeringMessage_initiating_message);
asn1cCallocOne(ie4->value.choice.CriticalityDiagnostics.procedureCriticality, F1AP_Criticality_reject);
asn1cCallocOne(ie4->value.choice.CriticalityDiagnostics.transactionID, 0);
}
return pdu;
}
/**
* @brief F1AP Setup Failure decoding
*/
bool decode_f1ap_setup_failure(const F1AP_F1AP_PDU_t *pdu, f1ap_setup_failure_t *out)
{
F1AP_F1SetupFailureIEs_t *ie;
F1AP_F1SetupFailure_t *in = &pdu->choice.unsuccessfulOutcome->value.choice.F1SetupFailure;
/* Check presence of mandatory IEs */
F1AP_LIB_FIND_IE(F1AP_F1SetupFailureIEs_t, ie, in, F1AP_ProtocolIE_ID_id_TransactionID, true);
F1AP_LIB_FIND_IE(F1AP_F1SetupFailureIEs_t, ie, in, F1AP_ProtocolIE_ID_id_Cause, true);
/* Loop over all IEs */
for (int i = 0; i < in->protocolIEs.list.count; i++) {
ie = in->protocolIEs.list.array[i];
switch (ie->id) {
case F1AP_ProtocolIE_ID_id_TransactionID:
/* Transaction ID (M) */
out->transaction_id = ie->value.choice.TransactionID;
break;
case F1AP_ProtocolIE_ID_id_Cause:
/* Cause (M) */
out->cause = ie->value.choice.Cause.choice.radioNetwork;
break;
case F1AP_ProtocolIE_ID_id_TimeToWait:
out->time_to_wait = ie->value.choice.TimeToWait;
break;
case F1AP_ProtocolIE_ID_id_CriticalityDiagnostics:
AssertError(1 == 0, return false, "F1AP_ProtocolIE_ID_id_CriticalityDiagnostics is not supported");
break;
default:
AssertError(1 == 0, return false, "F1AP_ProtocolIE_ID_id %ld unknown\n", ie->id);
break;
}
}
return true;
}
/**
* @brief F1AP Setup Failure equality check
*/
bool eq_f1ap_setup_failure(const f1ap_setup_failure_t *a, const f1ap_setup_failure_t *b)
{
if (a->transaction_id != b->transaction_id)
return false;
return true;
}
/**
* @brief F1AP Setup Failure deep copy
*/
f1ap_setup_failure_t cp_f1ap_setup_failure(const f1ap_setup_failure_t *msg)
{
f1ap_setup_failure_t cp = {0};
/* transaction_id */
cp.transaction_id = msg->transaction_id;
return cp;
}
......@@ -40,4 +40,10 @@ void free_f1ap_setup_response(const f1ap_setup_resp_t *msg);
f1ap_setup_resp_t cp_f1ap_setup_response(const f1ap_setup_resp_t *msg);
bool eq_f1ap_setup_response(const f1ap_setup_resp_t *a, const f1ap_setup_resp_t *b);
/* F1 Setup Failure */
struct F1AP_F1AP_PDU *encode_f1ap_setup_failure(const f1ap_setup_failure_t *msg);
bool decode_f1ap_setup_failure(const struct F1AP_F1AP_PDU *pdu, f1ap_setup_failure_t *out);
bool eq_f1ap_setup_failure(const f1ap_setup_failure_t *a, const f1ap_setup_failure_t *b);
f1ap_setup_failure_t cp_f1ap_setup_failure(const f1ap_setup_failure_t *msg);
#endif /* F1AP_INTERFACE_MANAGEMENT_H_ */
......@@ -39,5 +39,6 @@
#include "F1AP_FreqBandNrItem.h"
#include "F1AP_SuccessfulOutcome.h"
#include "F1AP_SibtypetobeupdatedListItem.h"
#include "F1AP_UnsuccessfulOutcome.h"
#endif /* F1AP_LIB_INCLUDES_H_ */
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