Commit 97bce210 authored by laurent's avatar laurent

code review comments, simplify asn1 coding

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