X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=e2sim%2Fe2sm_examples%2Fkpm_e2sm%2Fsrc%2Fkpm%2Fencode_kpm.cpp;h=55abcb5f71a20933fafd2e97c791a163c3000ffa;hb=d5c4439d0f5e2d06f0316f24fee331760c865df1;hp=764c69bcddd2093faddd6022512961971d65eeca;hpb=417a0f7a4a7e90ebfb069908e6adb612a39e233d;p=sim%2Fe2-interface.git diff --git a/e2sim/e2sm_examples/kpm_e2sm/src/kpm/encode_kpm.cpp b/e2sim/e2sm_examples/kpm_e2sm/src/kpm/encode_kpm.cpp index 764c69b..55abcb5 100755 --- a/e2sim/e2sm_examples/kpm_e2sm/src/kpm/encode_kpm.cpp +++ b/e2sim/e2sm_examples/kpm_e2sm/src/kpm/encode_kpm.cpp @@ -33,18 +33,14 @@ void encode_kpm_function_description(E2SM_KPM_RANfunction_Description_t* ranfunc uint8_t *buf = (uint8_t*)"ORAN-E2SM-KPM"; uint8_t *buf2 = (uint8_t*)"KPM monitor"; uint8_t *buf3 = (uint8_t*)"OID123"; - - OCTET_STRING_t *sname = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t)); - sname->buf = (uint8_t*)calloc(1,13); - - memcpy(sname->buf, buf, 13); - sname->size = strlen((char*)buf); - ranfunc_desc->ranFunction_Name.ranFunction_ShortName = *sname; - long inst = 1; ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_RANfunction_Description, ranfunc_desc); + ranfunc_desc->ranFunction_Name.ranFunction_ShortName.size = strlen((char*)buf); + ranfunc_desc->ranFunction_Name.ranFunction_ShortName.buf = (uint8_t*)calloc(strlen((char*)buf), sizeof(uint8_t)); + memcpy(ranfunc_desc->ranFunction_Name.ranFunction_ShortName.buf, buf, ranfunc_desc->ranFunction_Name.ranFunction_ShortName.size); + // ranfunc_desc->ranFunction_Name.ranFunction_Description = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t)); ranfunc_desc->ranFunction_Name.ranFunction_Description.buf = (uint8_t*)calloc(1,strlen((char*)buf2)); memcpy(ranfunc_desc->ranFunction_Name.ranFunction_Description.buf, buf2, strlen((char*)buf2)); @@ -187,11 +183,6 @@ void encode_e2sm_kpm_indication_header(E2SM_KPM_IndicationHeader_t *ihead, uint8 E2SM_KPM_IndicationHeader_Format1_t* ind_header = (E2SM_KPM_IndicationHeader_Format1_t*)calloc(1,sizeof(E2SM_KPM_IndicationHeader_Format1_t)); - OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t)); - plmnid->buf = (uint8_t*)calloc(3,1); - plmnid->size = 3; - memcpy(plmnid->buf, plmnid_buf, plmnid->size); - // long fqival = 9; // long qcival = 9; @@ -218,18 +209,6 @@ void encode_e2sm_kpm_indication_header(E2SM_KPM_IndicationHeader_t *ihead, uint8 */ nrcellid->bits_unused = 4; - BIT_STRING_t *gnb_bstring = (BIT_STRING_t*)calloc(1, sizeof(BIT_STRING_t));; - gnb_bstring->buf = (uint8_t*)calloc(1,4); - gnb_bstring->size = 4; - memcpy(gnb_bstring->buf, gnbid_buf, 4); - /* - gnb_bstring->buf[0] = 0xB5; - gnb_bstring->buf[1] = 0xC6; - gnb_bstring->buf[2] = 0x77; - gnb_bstring->buf[3] = 0x88; - */ - - gnb_bstring->bits_unused = gnbid_unused; INTEGER_t *cuup_id = (INTEGER_t*)calloc(1, sizeof(INTEGER_t)); // uint8_t buffer[1]; @@ -252,21 +231,44 @@ void encode_e2sm_kpm_indication_header(E2SM_KPM_IndicationHeader_t *ihead, uint8 cuupname->buf = (uint8_t*)calloc(1,8); memcpy(cuupname->buf, cuupname_buf, cuupname->size); + OCTET_STRING_t *plmnid_id_GlobalKPMnode_ID = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t)); + plmnid_id_GlobalKPMnode_ID->size = strlen((char *)plmnid_buf); + plmnid_id_GlobalKPMnode_ID->buf = (uint8_t*)calloc(plmnid_id_GlobalKPMnode_ID->size, sizeof(uint8_t)); + memcpy(plmnid_id_GlobalKPMnode_ID->buf, plmnid_buf, plmnid_id_GlobalKPMnode_ID->size); + + BIT_STRING_t *gnb_bstring_id_GlobalKPMnode_ID = (BIT_STRING_t*)calloc(1, sizeof(BIT_STRING_t)); + gnb_bstring_id_GlobalKPMnode_ID->size = strlen((char *)gnbid_buf); + gnb_bstring_id_GlobalKPMnode_ID->buf = (uint8_t*)calloc(gnb_bstring_id_GlobalKPMnode_ID->size, sizeof(uint8_t)); + memcpy(gnb_bstring_id_GlobalKPMnode_ID->buf, gnbid_buf, gnb_bstring_id_GlobalKPMnode_ID->size); + gnb_bstring_id_GlobalKPMnode_ID->bits_unused = gnbid_unused; ind_header->id_GlobalKPMnode_ID = (GlobalKPMnode_ID*)calloc(1,sizeof(GlobalKPMnode_ID)); ind_header->id_GlobalKPMnode_ID->present = GlobalKPMnode_ID_PR_gNB; ind_header->id_GlobalKPMnode_ID->choice.gNB.global_gNB_ID.gnb_id.present = GNB_ID_Choice_PR_gnb_ID; - ind_header->id_GlobalKPMnode_ID->choice.gNB.global_gNB_ID.gnb_id.choice.gnb_ID = *gnb_bstring; - ind_header->id_GlobalKPMnode_ID->choice.gNB.global_gNB_ID.plmn_id = *plmnid; + ind_header->id_GlobalKPMnode_ID->choice.gNB.global_gNB_ID.gnb_id.choice.gnb_ID = *gnb_bstring_id_GlobalKPMnode_ID; + ind_header->id_GlobalKPMnode_ID->choice.gNB.global_gNB_ID.plmn_id = *plmnid_id_GlobalKPMnode_ID; ind_header->id_GlobalKPMnode_ID->choice.gNB.gNB_CU_UP_ID = cuup_id; + if (plmnid_id_GlobalKPMnode_ID) free(plmnid_id_GlobalKPMnode_ID); + if (gnb_bstring_id_GlobalKPMnode_ID) free(gnb_bstring_id_GlobalKPMnode_ID); - + OCTET_STRING_t *plmnid_nRCGI = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t)); + plmnid_nRCGI->buf = (uint8_t*)calloc(3,1); + plmnid_nRCGI->size = 3; + memcpy(plmnid_nRCGI->buf, plmnid_buf, plmnid_nRCGI->size); + ind_header->nRCGI = (NRCGI*)calloc(1,sizeof(NRCGI)); - ind_header->nRCGI->pLMN_Identity = *plmnid; + ind_header->nRCGI->pLMN_Identity = *plmnid_nRCGI; ind_header->nRCGI->nRCellIdentity = *nrcellid; + if (plmnid_nRCGI) free(plmnid_nRCGI); if (nrcellid) free(nrcellid); - + + + OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t)); + plmnid->buf = (uint8_t*)calloc(3,1); + plmnid->size = 3; + memcpy(plmnid->buf, plmnid_buf, plmnid->size); + ind_header->pLMN_Identity = plmnid; // memcpy(ind_header->fiveQI, &fqival, 4); @@ -279,11 +281,24 @@ void encode_e2sm_kpm_indication_header(E2SM_KPM_IndicationHeader_t *ihead, uint8 ind_header->gNB_Name->choice.gNB_CU_UP_Name = *cuupname; if (cuupname) free(cuupname); - + + OCTET_STRING_t *plmnid_global_GNB_ID = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t)); + plmnid_global_GNB_ID->buf = (uint8_t*)calloc(3,1); + plmnid_global_GNB_ID->size = 3; + memcpy(plmnid_global_GNB_ID->buf, plmnid_buf, plmnid_global_GNB_ID->size); + + BIT_STRING_t *gnb_bstring_global_GNB_ID = (BIT_STRING_t*)calloc(1, sizeof(BIT_STRING_t));; + gnb_bstring_global_GNB_ID->buf = (uint8_t*)calloc(1,4); + gnb_bstring_global_GNB_ID->size = 4; + memcpy(gnb_bstring_global_GNB_ID->buf, gnbid_buf, 4); + gnb_bstring_global_GNB_ID->bits_unused = gnbid_unused; + ind_header->global_GNB_ID = (GlobalgNB_ID*)calloc(1,sizeof(GlobalgNB_ID)); - ind_header->global_GNB_ID->plmn_id = *plmnid; + ind_header->global_GNB_ID->plmn_id = *plmnid_global_GNB_ID; ind_header->global_GNB_ID->gnb_id.present = GNB_ID_Choice_PR_gnb_ID; - ind_header->global_GNB_ID->gnb_id.choice.gnb_ID = *gnb_bstring; + ind_header->global_GNB_ID->gnb_id.choice.gnb_ID = *gnb_bstring_global_GNB_ID; + if (plmnid_global_GNB_ID) free(plmnid_global_GNB_ID); + if (gnb_bstring_global_GNB_ID) free(gnb_bstring_global_GNB_ID); // long msg_type = 2; @@ -724,14 +739,18 @@ void encode_kpm_odu_user_level(RAN_Container_t *ranco, printf("enc4\n"); + long *p_prb_usage_dl = (long*)calloc(1, sizeof(long)); + long *p_prb_usage_ul = (long*)calloc(1, sizeof(long)); + *p_prb_usage_dl = (long)prb_usage_dl; + *p_prb_usage_ul = (long)prb_usage_ul; ue_report_item->c_RNTI = *crnti; - ue_report_item->dl_PRBUsage = &prb_usage_dl; + ue_report_item->dl_PRBUsage = p_prb_usage_dl; if (crnti) free(crnti); printf("enc5\n"); - ue_report_item->ul_PRBUsage = &prb_usage_ul; + ue_report_item->ul_PRBUsage = p_prb_usage_ul; printf("enc6\n"); @@ -779,7 +798,7 @@ void encode_kpm_report_rancontainer_du_parameterized(E2SM_KPM_IndicationMessage_ if (format) free(format); char error_buf[300] = {0, }; - size_t errlen; + size_t errlen = 0; asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen); printf("error length %d\n", errlen); @@ -789,10 +808,10 @@ void encode_kpm_report_rancontainer_du_parameterized(E2SM_KPM_IndicationMessage_ asn_codec_ctx_t *opt_cod; - uint8_t e2smbuffer[8192]; + uint8_t e2smbuffer[8192] = {0, }; size_t e2smbuffer_size = 8192; - uint8_t e2smbuffer2[8192]; + uint8_t e2smbuffer2[8192] = {0, }; size_t e2smbuffer_size2 = 8192; asn_enc_rval_t er = @@ -841,7 +860,7 @@ void encode_kpm_report_rancontainer_cucp_parameterized(E2SM_KPM_IndicationMessag if (format) free(format); char error_buf[300] = {0, }; - size_t errlen; + size_t errlen = 0; asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen); printf("error length %d\n", errlen); @@ -851,10 +870,10 @@ void encode_kpm_report_rancontainer_cucp_parameterized(E2SM_KPM_IndicationMessag asn_codec_ctx_t *opt_cod; - uint8_t e2smbuffer[8192]; + uint8_t e2smbuffer[8192] = {0, }; size_t e2smbuffer_size = 8192; - uint8_t e2smbuffer2[8192]; + uint8_t e2smbuffer2[8192] = {0, }; size_t e2smbuffer_size2 = 8192; asn_enc_rval_t er = @@ -892,7 +911,7 @@ void encode_kpm_report_rancontainer_cucp(E2SM_KPM_IndicationMessage_t* indicatio if (format) free(format); char error_buf[300] = {0, }; - size_t errlen; + size_t errlen = 0; asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen); printf("error length %d\n", errlen); @@ -902,10 +921,10 @@ void encode_kpm_report_rancontainer_cucp(E2SM_KPM_IndicationMessage_t* indicatio asn_codec_ctx_t *opt_cod; - uint8_t e2smbuffer[8192]; + uint8_t e2smbuffer[8192] = {0, }; size_t e2smbuffer_size = 8192; - uint8_t e2smbuffer2[8192]; + uint8_t e2smbuffer2[8192] = {0, }; size_t e2smbuffer_size2 = 8192; asn_enc_rval_t er = @@ -951,7 +970,7 @@ void encode_kpm_report_rancontainer_cuup_parameterized(E2SM_KPM_IndicationMessag if (format) free(format); char error_buf[300] = {0, }; - size_t errlen; + size_t errlen = 0; asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen); printf("error length %d\n", errlen); @@ -961,10 +980,10 @@ void encode_kpm_report_rancontainer_cuup_parameterized(E2SM_KPM_IndicationMessag asn_codec_ctx_t *opt_cod; - uint8_t e2smbuffer[8192]; + uint8_t e2smbuffer[8192] = {0, }; size_t e2smbuffer_size = 8192; - uint8_t e2smbuffer2[8192]; + uint8_t e2smbuffer2[8192] = {0, }; size_t e2smbuffer_size2 = 8192; // xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage); @@ -1085,7 +1104,7 @@ void encode_kpm_report_rancontainer_cuup(E2SM_KPM_IndicationMessage_t* indicatio if (format) free(format); char error_buf[300] = {0, }; - size_t errlen; + size_t errlen = 0; asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen); printf("error length %d\n", errlen); @@ -1095,10 +1114,10 @@ void encode_kpm_report_rancontainer_cuup(E2SM_KPM_IndicationMessage_t* indicatio asn_codec_ctx_t *opt_cod; - uint8_t e2smbuffer[8192]; + uint8_t e2smbuffer[8192] = {0, }; size_t e2smbuffer_size = 8192; - uint8_t e2smbuffer2[8192]; + uint8_t e2smbuffer2[8192] = {0, }; size_t e2smbuffer_size2 = 8192; asn_enc_rval_t er = @@ -1117,8 +1136,8 @@ void encode_kpm_report_style1_parameterized(E2SM_KPM_IndicationMessage_t* indica long fiveqi, long dl_prb_usage, long ul_prb_usage, - uint8_t* sd_buf, uint8_t* sst_buf, + uint8_t* sd_buf, uint8_t* plmnid_buf, uint8_t* nrcellid_buf, long *dl_prbs, @@ -1129,9 +1148,15 @@ void encode_kpm_report_style1_parameterized(E2SM_KPM_IndicationMessage_t* indica FQIPERSlicesPerPlmnPerCellListItem_t *fqi_item = (FQIPERSlicesPerPlmnPerCellListItem_t*)calloc(1,sizeof(FQIPERSlicesPerPlmnPerCellListItem_t)); + + long *p_dl_prb_usage = (long*)calloc(1, sizeof(long)); + long *p_ul_prb_usage = (long*)calloc(1, sizeof(long)); + *p_dl_prb_usage = (long)dl_prb_usage; + *p_ul_prb_usage = (long)ul_prb_usage; + fqi_item->fiveQI = fiveqi; - fqi_item->dl_PRBUsage = &dl_prb_usage; - fqi_item->ul_PRBUsage = &ul_prb_usage; + fqi_item->dl_PRBUsage = p_dl_prb_usage; + fqi_item->ul_PRBUsage = p_ul_prb_usage; uint8_t *buf1 = (uint8_t*)"4"; @@ -1230,7 +1255,7 @@ void encode_kpm_report_style1_parameterized(E2SM_KPM_IndicationMessage_t* indica if (format) free(format); char error_buf[300] = {0, }; - size_t errlen; + size_t errlen = 0; asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen); printf("error length %d\n", errlen); @@ -1239,10 +1264,10 @@ void encode_kpm_report_style1_parameterized(E2SM_KPM_IndicationMessage_t* indica xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage); - uint8_t e2smbuffer[8192]; + uint8_t e2smbuffer[8192] = {0, }; size_t e2smbuffer_size = 8192; - uint8_t e2smbuffer2[8192]; + uint8_t e2smbuffer2[8192] = {0, }; size_t e2smbuffer_size2 = 8192; asn_enc_rval_t er = @@ -1369,7 +1394,7 @@ void encode_kpm_report_style1(E2SM_KPM_IndicationMessage_t* indicationmessage) { if (format) free(format); char error_buf[300] = {0, }; - size_t errlen; + size_t errlen = 0; asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen); printf("error length %d\n", errlen); @@ -1378,10 +1403,10 @@ void encode_kpm_report_style1(E2SM_KPM_IndicationMessage_t* indicationmessage) { xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage); - uint8_t e2smbuffer[8192]; + uint8_t e2smbuffer[8192] = {0, }; size_t e2smbuffer_size = 8192; - uint8_t e2smbuffer2[8192]; + uint8_t e2smbuffer2[8192] = {0, }; size_t e2smbuffer_size2 = 8192; asn_enc_rval_t er = @@ -1542,7 +1567,7 @@ void encode_kpm_report_style5_parameterized(E2SM_KPM_IndicationMessage_t* indica asn_codec_ctx_t *opt_cod; - uint8_t e2smbuffera[8192]; + uint8_t e2smbuffera[8192] = {0, }; size_t e2smbuffer_sizea = 8192; @@ -1622,7 +1647,7 @@ void encode_kpm_report_style5_parameterized(E2SM_KPM_IndicationMessage_t* indica if (format) free(format); char error_buf[300] = {0, }; - size_t errlen; + size_t errlen = 0; asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen); printf("error length %d\n", errlen); @@ -1631,10 +1656,10 @@ void encode_kpm_report_style5_parameterized(E2SM_KPM_IndicationMessage_t* indica xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage); - uint8_t e2smbuffer[8192]; + uint8_t e2smbuffer[8192] = {0, }; size_t e2smbuffer_size = 8192; - uint8_t e2smbuffer2[8192]; + uint8_t e2smbuffer2[8192] = {0, }; size_t e2smbuffer_size2 = 8192; asn_enc_rval_t er = @@ -1706,7 +1731,7 @@ void encode_kpm_report_style5(E2SM_KPM_IndicationMessage_t* indicationmessage) { asn_codec_ctx_t *opt_cod; - uint8_t e2smbuffera[8192]; + uint8_t e2smbuffera[8192] = {0, }; size_t e2smbuffer_sizea = 8192; @@ -1785,7 +1810,7 @@ void encode_kpm_report_style5(E2SM_KPM_IndicationMessage_t* indicationmessage) { if (format) free(format); char error_buf[300] = {0, }; - size_t errlen; + size_t errlen = 0; asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen); printf("error length %d\n", errlen); @@ -1794,10 +1819,10 @@ void encode_kpm_report_style5(E2SM_KPM_IndicationMessage_t* indicationmessage) { xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage); - uint8_t e2smbuffer[8192]; + uint8_t e2smbuffer[8192] = {0, }; size_t e2smbuffer_size = 8192; - uint8_t e2smbuffer2[8192]; + uint8_t e2smbuffer2[8192] = {0, }; size_t e2smbuffer_size2 = 8192; asn_enc_rval_t er =