8 // long id[] = {1,2,3,4};
10 // void *buffer[8] = {} ;
11 // unsigned int sizeBuffer = 8;
12 // long actionDefCount = 8;
14 // long ricStyleType = 1;
16 // void *plm[8] = {} ;
17 // unsigned int sizePlm = 8;
18 // void *nRc[8] = {} ;
19 // unsigned int sizenRc = 8;
21 // int a = e2sm_encode_ric_action_definition(buffer, sizeBuffer, actionDefCount, measId, ricStyleType, periods, plm, nRc);
28 ssize_t e2sm_encode_ric_event_trigger_definition(void *buffer, size_t buf_size, size_t event_trigger_count, long *RT_periods) {
29 E2SM_KPM_EventTriggerDefinition_t *eventTriggerDef = (E2SM_KPM_EventTriggerDefinition_t *)calloc(1, sizeof(E2SM_KPM_EventTriggerDefinition_t));
30 if(!eventTriggerDef) {
31 fprintf(stderr, "Alloc EventTriggerDefinition failed\n");
35 E2SM_KPM_EventTriggerDefinition_Format1_t *innerDef = (E2SM_KPM_EventTriggerDefinition_Format1_t *)calloc(1, sizeof(E2SM_KPM_EventTriggerDefinition_Format1_t));
37 fprintf(stderr, "alloc EventTriggerDefinition Format1 failed\n");
38 ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_EventTriggerDefinition, eventTriggerDef);
42 eventTriggerDef->eventDefinition_formats.present = E2SM_KPM_EventTriggerDefinition__eventDefinition_formats_PR_eventDefinition_Format1;
43 eventTriggerDef->eventDefinition_formats.choice.eventDefinition_Format1 = innerDef;
45 // struct E2SM_KPM_EventTriggerDefinition_Format1__policyTest_List *policyTestList = (struct E2SM_KPM_EventTriggerDefinition_Format1__policyTest_List *)calloc(1, sizeof(struct E2SM_KPM_EventTriggerDefinition_Format1__policyTest_List));
46 // innerDef->policyTest_List = policyTestList;
49 // while(index < event_trigger_count) {
50 // Trigger_ConditionIE_Item *triggerCondition = (Trigger_ConditionIE_Item *)calloc(1, sizeof(Trigger_ConditionIE_Item));
51 // assert(triggerCondition != 0);
52 // triggerCondition->report_Period_IE = RT_periods[index];
53 // ASN_SEQUENCE_ADD(&policyTestList->list, triggerCondition);
57 asn_enc_rval_t encode_result;
58 encode_result = uper_encode_to_buffer(&asn_DEF_E2SM_KPM_EventTriggerDefinition, NULL, eventTriggerDef, buffer, buf_size);
59 ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_EventTriggerDefinition, eventTriggerDef);
60 if(encode_result.encoded == -1) {
61 fprintf(stderr, "Cannot encode %s: %s\n", encode_result.failed_type->name, strerror(errno));
64 return encode_result.encoded;
69 // long id[] = {1,2,3,4};
71 // void *buffer[8] = {} ;
72 // unsigned int sizeBuffer = 8;
73 // long actionDefCount = 8;
75 // long ricStyleType = 1;
77 // void *plm[8] = {} ;
78 // unsigned int sizePlm = 8;
79 // void *nRc[8] = {} ;
80 // unsigned int sizenRc = 8;
82 // int a = e2sm_encode_ric_action_definition(buffer, sizeBuffer, actionDefCount, measId, ricStyleType, periods, plm, nRc);
90 ssize_t e2sm_encode_ric_action_definition(void *buffer, size_t buf_size, long action_Def_count, long meas_ID, long ric_style_type, long GR_periods, Plm plm, Nrc nRc) {
91 E2SM_KPM_ActionDefinition_t *actionDef = (E2SM_KPM_ActionDefinition_t *)calloc(1, sizeof(E2SM_KPM_ActionDefinition_t));
93 fprintf(stderr, "alloc RIC ActionDefinition failed\n");
97 E2SM_KPM_ActionDefinition_Format1_t *actionDefFor1 = (E2SM_KPM_ActionDefinition_Format1_t *)calloc(1, sizeof(E2SM_KPM_ActionDefinition_Format1_t));
99 ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_ActionDefinition, actionDef);
100 fprintf(stderr, "alloc RIC ActionDefinition failed\n");
103 CGI_t *cellGlobal = (CGI_t *)calloc(1, sizeof(CGI_t));
105 fprintf(stderr, "alloc RIC ActionDefinition failed\n");
109 NR_CGI_t *nrCGIs = (NR_CGI_t *)calloc(1, sizeof(NR_CGI_t));
111 fprintf(stderr, "alloc RIC ActionDefinition failed\n");
115 actionDef->ric_Style_Type = ric_style_type;
116 actionDef->actionDefinition_formats.present = E2SM_KPM_ActionDefinition__actionDefinition_formats_PR_actionDefinition_Format1;
117 actionDef->actionDefinition_formats.choice.actionDefinition_Format1 = actionDefFor1;
118 actionDefFor1->granulPeriod = GR_periods;
119 actionDefFor1->cellGlobalID = cellGlobal;
120 cellGlobal->present = CGI_PR_nR_CGI;
121 cellGlobal->choice.nR_CGI = nrCGIs;
124 int plmSize = plm.size;
129 PLMNIdentity_t *plms = &nrCGIs->pLMNIdentity;
130 plms->buf = (uint8_t *)calloc(1, plmSize);
132 fprintf(stderr, "alloc plms failed\n");
133 ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_ActionDefinition, actionDef);
137 memcpy(plms->buf, plm.plms, plmSize);
138 plms->size = plmSize;
141 int nRcSize = nRc.size;
143 NRCellIdentity_t *nRCs = &nrCGIs->nRCellIdentity;
144 nRCs->buf = (uint8_t *)calloc(1, nRcSize);
146 fprintf(stderr, "alloc nRCs failed\n");
147 ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_ActionDefinition, actionDef);
151 memcpy(nRCs->buf, nRc.nRcs, nRcSize);
152 nRCs->size = nRcSize;
155 MeasurementInfoList_t *infoList = &actionDefFor1->measInfoList;
158 while(index < action_Def_count) {
159 MeasurementInfoItem_t *infoItem = (MeasurementInfoItem_t *)calloc(1, sizeof(MeasurementInfoItem_t));
161 // fprintf(stderr, "alloc Measurement Info Item failed\n");
162 // ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_ActionDefinition, actionDef);
165 assert(infoItem != 0);
168 MeasurementType_t *measureType = &infoItem->measType;
170 measureType->present = MeasurementType_PR_measID;
171 measureType->choice.measID = meas_ID;
174 LabelInfoList_t *lableList = &infoItem->labelInfoList;
176 ASN_SEQUENCE_ADD(&infoList->list, infoItem);
180 asn_enc_rval_t encode_result;
181 encode_result = uper_encode_to_buffer(&asn_DEF_E2SM_KPM_ActionDefinition, NULL,actionDef, buffer, buf_size);
182 ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_ActionDefinition, actionDef);
184 if(encode_result.encoded == -1) {
185 fprintf(stderr, "Cannot encode %s: %s\n", encode_result.failed_type->name, strerror(errno));
188 fprintf(stderr, "successfully\n");
189 return encode_result.encoded;
193 E2SM_KPM_IndicationHeader_t* e2sm_decode_ric_indication_header(void *buffer, size_t buf_size) {
194 asn_dec_rval_t decode_result;
195 E2SM_KPM_IndicationHeader_t *indHdr = 0;
196 //fprintf(stderr, "\nbuffer= %p",buffer);
197 //fprintf(stdout, "\nbuf_size=%ld",buf_size);
198 //fprintf(stdout, "\nE2SM_KPM_IndicationHeader_t_size=%ld",sizeof(E2SM_KPM_IndicationHeader_t));
199 //decode_result = uper_decode_complete(NULL, &asn_DEF_E2SM_KPM_IndicationHeader, (void **)&indHdr, (char*)buffer, buf_size);
200 //ATS_ALIGNED_CANONICAL_PER
201 decode_result =asn_decode(0,ATS_ALIGNED_BASIC_PER,&asn_DEF_E2SM_KPM_IndicationHeader,(void **)&indHdr,buffer,buf_size);
202 if(decode_result.code == RC_OK) {
203 // xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationHeader, indHdr);
206 else if (decode_result.code ==RC_WMORE ) {
207 //xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationHeader, indHdr);
208 //fprintf(stderr, "\n decode_result.consumed= %ld \n",decode_result.consumed);
209 fprintf(stderr, "\nheader RC_WMORE ");
214 ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationHeader, indHdr);
219 void e2sm_free_ric_indication_header(E2SM_KPM_IndicationHeader_t* indHdr) {
220 ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationHeader, indHdr);
223 E2SM_KPM_IndicationMessage_t* e2sm_decode_ric_indication_message(void *buffer, size_t buf_size) {
224 asn_dec_rval_t decode_result;
225 E2SM_KPM_IndicationMessage_t *indMsg = 0;
226 //fprintf(stdout, "\nbuffer= %p",buffer);
227 //fprintf(stdout, "\nbuf_size=%ld",buf_size);
228 //fprintf(stdout, "\nE2SM_KPM_IndicationMessage_t size=%ld",sizeof(E2SM_KPM_IndicationMessage_t));
229 //decode_result = uper_decode_complete(NULL, &asn_DEF_E2SM_KPM_IndicationMessage, (void **)&indMsg, (char *)buffer, buf_size);
230 //ATS_ALIGNED_CANONICAL_PER
231 decode_result =asn_decode(0,ATS_ALIGNED_BASIC_PER,&asn_DEF_E2SM_KPM_IndicationMessage,(void **)&indMsg,buffer,buf_size);
232 if(decode_result.code == RC_OK) {
233 //xer_fprint(stdout, &asn_DEF_E2SM_KPM_IndicationMessage, indMsg);
236 else if (decode_result.code ==RC_WMORE ) {
237 //xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indMsg);
238 //fprintf(stderr, "\n MSG decode_result.consumed= %ld \n",decode_result.consumed);
239 fprintf(stderr, "\n MSG RC_WMORE ");
244 ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationMessage, indMsg);
249 void e2sm_free_ric_indication_message(E2SM_KPM_IndicationMessage_t* indMsg) {
250 ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationMessage, indMsg);