Commit 97bce210 authored by laurent's avatar laurent

code review comments, simplify asn1 coding

parent 44d309a6
......@@ -38,84 +38,83 @@
extern f1ap_setup_req_t *f1ap_du_data_from_du;
int CU_send_Paging(instance_t instance, f1ap_paging_ind_t *paging) {
F1AP_F1AP_PDU_t pdu;
F1AP_Paging_t *out;
F1AP_PagingIEs_t *ie;
F1AP_F1AP_PDU_t pdu = {0};
uint8_t *buffer;
uint32_t len;
memset(&pdu, 0, sizeof(pdu));
pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage;
pdu.choice.initiatingMessage = (F1AP_InitiatingMessage_t *)calloc(1, sizeof(F1AP_InitiatingMessage_t));
pdu.choice.initiatingMessage->procedureCode = F1AP_ProcedureCode_id_Paging;
pdu.choice.initiatingMessage->criticality = F1AP_Criticality_reject;
pdu.choice.initiatingMessage->value.present = F1AP_InitiatingMessage__value_PR_Paging;
out = &pdu.choice.initiatingMessage->value.choice.Paging;
asn1cCalloc(pdu.choice.initiatingMessage, msg);
msg->procedureCode = F1AP_ProcedureCode_id_Paging;
msg->criticality = F1AP_Criticality_reject;
msg->value.present = F1AP_InitiatingMessage__value_PR_Paging;
/* mandatory */
/* UEIdentityIndexValue */
ie = (F1AP_PagingIEs_t *)calloc(1, sizeof(F1AP_PagingIEs_t));
{
asn1cSequenceAdd(msg->value.choice.Paging.protocolIEs.list,
F1AP_PagingIEs_t, ie);
ie->id = F1AP_ProtocolIE_ID_id_UEIdentityIndexValue;
ie->criticality = F1AP_Criticality_reject;
ie->value.present = F1AP_PagingIEs__value_PR_UEIdentityIndexValue;
ie->value.choice.UEIdentityIndexValue.present = F1AP_UEIdentityIndexValue_PR_indexLength10;
UEIDENTITYINDEX_TO_BIT_STRING(paging->ueidentityindexvalue, &ie->value.choice.UEIdentityIndexValue.choice.indexLength10);
//LOG_D(F1AP, "indexLength10 %d \n", BIT_STRING_to_uint32(&ie->value.choice.UEIdentityIndexValue.choice.indexLength10));
ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
ie->value.choice.UEIdentityIndexValue.present =
F1AP_UEIdentityIndexValue_PR_indexLength10;
UEIDENTITYINDEX_TO_BIT_STRING(
paging->ueidentityindexvalue,
&ie->value.choice.UEIdentityIndexValue.choice.indexLength10);
}
/* mandatory */
/* PagingIdentity */
ie = (F1AP_PagingIEs_t *)calloc(1, sizeof(F1AP_PagingIEs_t));
{
asn1cSequenceAdd(msg->value.choice.Paging.protocolIEs.list,
F1AP_PagingIEs_t, ie);
ie->id = F1AP_ProtocolIE_ID_id_PagingIdentity;
ie->criticality = F1AP_Criticality_reject;
ie->value.present = F1AP_PagingIEs__value_PR_PagingIdentity;
ie->value.choice.PagingIdentity.present = F1AP_PagingIdentity_PR_cNUEPagingIdentity;
ie->value.choice.PagingIdentity.choice.cNUEPagingIdentity = (F1AP_CNUEPagingIdentity_t*)calloc(1, sizeof(F1AP_CNUEPagingIdentity_t));
ie->value.choice.PagingIdentity.choice.cNUEPagingIdentity->present = F1AP_CNUEPagingIdentity_PR_fiveG_S_TMSI;
FIVEG_S_TMSI_TO_BIT_STRING(paging->fiveg_s_tmsi,
&ie->value.choice.PagingIdentity.choice.cNUEPagingIdentity->choice.fiveG_S_TMSI);
ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
ie->value.choice.PagingIdentity.present =
F1AP_PagingIdentity_PR_cNUEPagingIdentity;
asn1cCalloc(ie->value.choice.PagingIdentity.choice.cNUEPagingIdentity, id);
id->present = F1AP_CNUEPagingIdentity_PR_fiveG_S_TMSI;
FIVEG_S_TMSI_TO_BIT_STRING(paging->fiveg_s_tmsi, &id->choice.fiveG_S_TMSI);
}
/* optional */
/* PagingDRX */
ie = (F1AP_PagingIEs_t *)calloc(1, sizeof(F1AP_PagingIEs_t));
{
asn1cSequenceAdd(msg->value.choice.Paging.protocolIEs.list,
F1AP_PagingIEs_t, ie);
ie->id = F1AP_ProtocolIE_ID_id_PagingDRX;
ie->criticality = F1AP_Criticality_ignore;
ie->value.present = F1AP_PagingIEs__value_PR_PagingDRX;
ie->value.choice.PagingDRX = paging->paging_drx;
ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
}
/* mandatory */
/* PagingCell_list */
ie = (F1AP_PagingIEs_t *)calloc(1, sizeof(F1AP_PagingIEs_t));
{
asn1cSequenceAdd(msg->value.choice.Paging.protocolIEs.list,
F1AP_PagingIEs_t, ie);
ie->id = F1AP_ProtocolIE_ID_id_PagingCell_List;
ie->criticality = F1AP_Criticality_reject;
ie->value.present = F1AP_PagingIEs__value_PR_PagingCell_list;
F1AP_PagingCell_ItemIEs_t *itemies;
F1AP_PagingCell_Item_t item;
memset((void *)&item, 0, sizeof(F1AP_PagingCell_Item_t));
itemies = (F1AP_PagingCell_ItemIEs_t *)calloc(1, sizeof(F1AP_PagingCell_ItemIEs_t));
asn1cSequenceAdd(ie->value.choice.PagingCell_list,
F1AP_PagingCell_ItemIEs_t, itemies);
itemies->id = F1AP_ProtocolIE_ID_id_PagingCell_Item;
itemies->criticality = F1AP_Criticality_reject;
itemies->value.present = F1AP_PagingCell_ItemIEs__value_PR_PagingCell_Item;
F1AP_NRCGI_t nRCGI;
MCC_MNC_TO_PLMNID(paging->mcc,
paging->mnc,
paging->mnc_digit_length,
&nRCGI.pLMN_Identity);
NR_CELL_ID_TO_BIT_STRING(paging->nr_cellid, &nRCGI.nRCellIdentity);
item.nRCGI = nRCGI;
itemies->value.choice.PagingCell_Item = item;
ASN_SEQUENCE_ADD(&ie->value.choice.PagingCell_list, itemies);
ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
F1AP_NRCGI_t *nRCGI = &itemies->value.choice.PagingCell_Item.nRCGI;
MCC_MNC_TO_PLMNID(paging->mcc, paging->mnc, paging->mnc_digit_length,
&nRCGI->pLMN_Identity);
NR_CELL_ID_TO_BIT_STRING(paging->nr_cellid, &nRCGI->nRCellIdentity);
}
uint8_t *buffer;
uint32_t len;
/* encode */
if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) {
LOG_E(F1AP, "Failed to encode F1 Paging failure\n");
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_F1AP_F1AP_PDU, &pdu);
return -1;
}
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_F1AP_F1AP_PDU, &pdu);
f1ap_itti_send_sctp_data_req(true, instance, buffer, len, 0);
return 0;
}
......@@ -2138,36 +2138,30 @@ NR_MeasConfig_t *get_defaultMeasConfig(const gNB_RrcConfigurationReq *conf)
uint8_t do_NR_Paging(uint8_t Mod_id, uint8_t *buffer, uint32_t tmsi) {
LOG_D(NR_RRC, "[gNB %d] do_NR_Paging start\n", Mod_id);
asn_enc_rval_t enc_rval;
NR_PCCH_Message_t pcch_msg;
NR_PagingRecord_t *paging_record_p = NULL;
pcch_msg.message.present = NR_PCCH_MessageType_PR_c1;
pcch_msg.message.choice.c1 = CALLOC(1, sizeof(struct NR_PCCH_MessageType__c1));
pcch_msg.message.choice.c1->present = NR_PCCH_MessageType__c1_PR_paging;
pcch_msg.message.choice.c1->choice.paging = CALLOC(1,sizeof(NR_Paging_t));
pcch_msg.message.choice.c1->choice.paging->pagingRecordList = CALLOC(1,sizeof(*pcch_msg.message.choice.c1->choice.paging->pagingRecordList));
pcch_msg.message.choice.c1->choice.paging->nonCriticalExtension = NULL;
asn_set_empty(&pcch_msg.message.choice.c1->choice.paging->pagingRecordList->list);
pcch_msg.message.choice.c1->choice.paging->pagingRecordList->list.count = 0;
if ((paging_record_p = calloc(1, sizeof(NR_PagingRecord_t))) == NULL) {
/* Possible error on calloc */
return (-1);
}
memset(paging_record_p, 0, sizeof(NR_PagingRecord_t));
asn1cCalloc(pcch_msg.message.choice.c1, c1);
c1->present = NR_PCCH_MessageType__c1_PR_paging;
c1->choice.paging = CALLOC(1, sizeof(NR_Paging_t));
c1->choice.paging->pagingRecordList = CALLOC(
1, sizeof(*pcch_msg.message.choice.c1->choice.paging->pagingRecordList));
c1->choice.paging->nonCriticalExtension = NULL;
asn_set_empty(&c1->choice.paging->pagingRecordList->list);
c1->choice.paging->pagingRecordList->list.count = 0;
asn1cSequenceAdd(c1->choice.paging->pagingRecordList->list, NR_PagingRecord_t,
paging_record_p);
/* convert ue_paging_identity_t to PagingUE_Identity_t */
paging_record_p->ue_Identity.present = NR_PagingUE_Identity_PR_ng_5G_S_TMSI;
// set ng_5G_S_TMSI
INT32_TO_BIT_STRING(tmsi, &paging_record_p->ue_Identity.choice.ng_5G_S_TMSI);
/* add to list */
ASN_SEQUENCE_ADD(&pcch_msg.message.choice.c1->choice.paging->pagingRecordList->list, paging_record_p);
LOG_D(NR_RRC, "[gNB %d] do_Paging paging_record: PagingRecordList.count %d\n",
Mod_id, pcch_msg.message.choice.c1->choice.paging->pagingRecordList->list.count);
enc_rval = uper_encode_to_buffer(&asn_DEF_NR_PCCH_Message, NULL, (void *)&pcch_msg, buffer, RRC_BUF_SIZE);
Mod_id, c1->choice.paging->pagingRecordList->list.count);
asn_enc_rval_t enc_rval = uper_encode_to_buffer(
&asn_DEF_NR_PCCH_Message, NULL, (void *)&pcch_msg, buffer, RRC_BUF_SIZE);
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_NR_PCCH_Message, &pcch_msg);
if(enc_rval.encoded == -1) {
LOG_I(NR_RRC, "[gNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
......
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