10 #include "encode_e2apv1.hpp"
13 #include "E2SM-KPM-RANfunction-Description.h"
15 #include "e2ap_asn1c_codec.h"
16 #include "GlobalE2node-ID.h"
17 #include "GlobalE2node-gNB-ID.h"
18 #include "GlobalgNB-ID.h"
19 #include "OCTET_STRING.h"
20 #include "asn_application.h"
21 #include "GNB-ID-Choice.h"
22 #include "ProtocolIE-Field.h"
23 #include "E2setupRequest.h"
24 #include "RICaction-ToBeSetup-Item.h"
25 #include "RICactions-ToBeSetup-List.h"
26 #include "RICeventTriggerDefinition.h"
27 #include "RICsubscriptionRequest.h"
28 #include "RICsubscriptionResponse.h"
29 #include "ProtocolIE-SingleContainer.h"
30 #include "RANfunctions-List.h"
31 #include "RICindication.h"
32 #include "RICsubsequentActionType.h"
33 #include "RICsubsequentAction.h"
34 #include "RICtimeToWait.h"
38 void generate_e2apv1_setup_request(E2AP_PDU_t *e2ap_pdu) {
40 // uint8_t *buf = (uint8_t *)"gnb1"
42 BIT_STRING_t *gnb_bstring = (BIT_STRING_t*)calloc(1, sizeof(BIT_STRING_t));;
43 gnb_bstring->buf = (uint8_t*)calloc(1,4);
44 gnb_bstring->size = 4;
45 gnb_bstring->buf[0] = 0xB5;
46 gnb_bstring->buf[1] = 0xC6;
47 gnb_bstring->buf[2] = 0x77;
48 gnb_bstring->buf[3] = 0x88;
50 gnb_bstring->bits_unused = 3;
52 uint8_t *buf2 = (uint8_t *)"747";
53 OCTET_STRING_t *plmn = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
54 plmn->buf = (uint8_t*)calloc(1,3);
55 memcpy(plmn->buf, buf2, 3);
58 GNB_ID_Choice_t *gnbchoice = (GNB_ID_Choice_t*)calloc(1,sizeof(GNB_ID_Choice_t));
59 GNB_ID_Choice_PR pres2 = GNB_ID_Choice_PR_gnb_ID;
60 gnbchoice->present = pres2;
61 gnbchoice->choice.gnb_ID = *gnb_bstring;
63 GlobalgNB_ID_t *gnb = (GlobalgNB_ID_t*)calloc(1, sizeof(GlobalgNB_ID_t));
65 gnb->gnb_id = *gnbchoice;
67 GlobalE2node_gNB_ID_t *e2gnb = (GlobalE2node_gNB_ID_t*)calloc(1, sizeof(GlobalE2node_gNB_ID_t));
68 e2gnb->global_gNB_ID = *gnb;
70 GlobalE2node_ID_t *globale2nodeid = (GlobalE2node_ID_t*)calloc(1, sizeof(GlobalE2node_ID_t));
71 GlobalE2node_ID_PR pres;
72 pres = GlobalE2node_ID_PR_gNB;
73 globale2nodeid->present = pres;
74 globale2nodeid->choice.gNB = e2gnb;
76 E2setupRequestIEs_t *e2setuprid = (E2setupRequestIEs_t*)calloc(1, sizeof(E2setupRequestIEs_t));
77 E2setupRequestIEs__value_PR pres3;
78 pres3 = E2setupRequestIEs__value_PR_GlobalE2node_ID;
80 e2setuprid->criticality = 0;
81 e2setuprid->value.choice.GlobalE2node_ID = *globale2nodeid;
82 e2setuprid->value.present = pres3;
85 auto *ranFlistIEs = (E2setupRequestIEs_t *)calloc(1, sizeof(E2setupRequestIEs_t));
86 ASN_STRUCT_RESET(asn_DEF_E2setupRequestIEs, ranFlistIEs);
87 ranFlistIEs->criticality = 0;
88 ranFlistIEs->id = ProtocolIE_ID_id_RANfunctionsAdded;
89 ranFlistIEs->value.present = E2setupRequestIEs__value_PR_RANfunctions_List;
91 auto *itemIes = (RANfunction_ItemIEs_t *)calloc(1, sizeof(RANfunction_ItemIEs_t));
92 itemIes->id = ProtocolIE_ID_id_RANfunction_Item;
93 itemIes->criticality = Criticality_reject;
94 itemIes->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item;
95 itemIes->value.choice.RANfunction_Item.ranFunctionID = 1;
97 E2SM_KPM_RANfunction_Description_t *ranfunc_desc =
98 (E2SM_KPM_RANfunction_Description_t*)calloc(1,sizeof(E2SM_KPM_RANfunction_Description_t));
99 encode_kpm_function_description(ranfunc_desc);
101 uint8_t e2smbuffer[8192];
102 size_t e2smbuffer_size = 8192;
104 asn_codec_ctx_t *opt_cod;
107 asn_encode_to_buffer(opt_cod,
108 ATS_ALIGNED_BASIC_PER,
109 &asn_DEF_E2SM_KPM_RANfunction_Description,
110 ranfunc_desc, e2smbuffer, e2smbuffer_size);
112 fprintf(stderr, "er encded is %d\n", er.encoded);
113 fprintf(stderr, "after encoding message\n");
115 OCTET_STRING_t *ranfuncdesc_str = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
116 ranfuncdesc_str->buf = (uint8_t*)calloc(1,er.encoded);
117 ranfuncdesc_str->size = er.encoded;
118 memcpy(ranfuncdesc_str->buf, e2smbuffer, er.encoded);
121 itemIes->value.choice.RANfunction_Item.ranFunctionDefinition = *ranfuncdesc_str;
122 itemIes->value.choice.RANfunction_Item.ranFunctionRevision = (long)2;
124 ASN_SEQUENCE_ADD(&ranFlistIEs->value.choice.RANfunctions_List.list, itemIes);
126 E2setupRequest_t *e2setupreq = (E2setupRequest_t*)calloc(1, sizeof(E2setupRequest_t));
127 ASN_SEQUENCE_ADD(&e2setupreq->protocolIEs.list, e2setuprid);
128 ASN_SEQUENCE_ADD(&e2setupreq->protocolIEs.list, ranFlistIEs);
130 InitiatingMessage__value_PR pres4;
131 pres4 = InitiatingMessage__value_PR_E2setupRequest;
132 InitiatingMessage_t *initmsg = (InitiatingMessage_t*)calloc(1, sizeof(InitiatingMessage_t));
134 initmsg->procedureCode = ProcedureCode_id_E2setup;
135 initmsg->criticality = Criticality_reject;
136 initmsg->value.present = pres4;
137 initmsg->value.choice.E2setupRequest = *e2setupreq;
140 pres5 = E2AP_PDU_PR_initiatingMessage;
143 e2ap_pdu->present = pres5;
144 e2ap_pdu->choice.initiatingMessage = initmsg;
149 void generate_e2apv1_setup_response(E2AP_PDU_t *e2ap_pdu) {
151 E2setupResponseIEs *resp_ies1 = (E2setupResponseIEs_t*)calloc(1, sizeof(E2setupResponseIEs_t));
152 E2setupResponseIEs *resp_ies2 = (E2setupResponseIEs_t*)calloc(1, sizeof(E2setupResponseIEs_t));
153 E2setupResponseIEs *resp_ies3 = (E2setupResponseIEs_t*)calloc(1, sizeof(E2setupResponseIEs_t));
155 uint8_t *buf = (uint8_t *)"gnb1";
157 BIT_STRING_t *ricid_bstring = (BIT_STRING_t*)calloc(1,sizeof(BIT_STRING_t));
158 ricid_bstring->buf = buf;
159 ricid_bstring->size = 4;
160 ricid_bstring->bits_unused = 0;
162 uint8_t *buf2 = (uint8_t *)"plmn3";
163 OCTET_STRING_t *plmn = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
167 GlobalRIC_ID_t *globalricid = (GlobalRIC_ID_t*)calloc(1,sizeof(GlobalRIC_ID_t));
168 globalricid->pLMN_Identity = *plmn;
169 globalricid->ric_ID = *ricid_bstring;
171 E2setupResponseIEs__value_PR pres1;
172 pres1 = E2setupResponseIEs__value_PR_GlobalRIC_ID;
174 resp_ies1->id = ProtocolIE_ID_id_GlobalRIC_ID;
175 resp_ies1->criticality = 0;
176 resp_ies1->value.present = pres1;
177 resp_ies1->value.choice.GlobalRIC_ID = *globalricid;
179 E2setupResponse_t *e2setupresp = (E2setupResponse_t*)calloc(1,sizeof(E2setupResponse_t));
180 int ret = ASN_SEQUENCE_ADD(&e2setupresp->protocolIEs.list, resp_ies1);
183 SuccessfulOutcome__value_PR pres;
184 pres = SuccessfulOutcome__value_PR_E2setupResponse;
185 SuccessfulOutcome_t *successoutcome = (SuccessfulOutcome_t*)calloc(1, sizeof(SuccessfulOutcome_t));
186 successoutcome->procedureCode = 1;
187 successoutcome->criticality = 0;
188 successoutcome->value.present = pres;
189 successoutcome->value.choice.E2setupResponse = *e2setupresp;
191 E2AP_PDU_PR pres5 = E2AP_PDU_PR_successfulOutcome;
193 e2ap_pdu->present = pres5;
194 e2ap_pdu->choice.successfulOutcome = successoutcome;
199 void generate_e2apv1_subscription_request(E2AP_PDU *e2ap_pdu) {
201 fprintf(stderr, "in sub 1\n");
202 RICsubscriptionRequest_IEs_t *ricreqid = (RICsubscriptionRequest_IEs_t*)calloc(1, sizeof(RICsubscriptionRequest_IEs_t));
203 fprintf(stderr, "in sub 2\n");
204 ASN_STRUCT_RESET(asn_DEF_RICsubscriptionRequest_IEs, ricreqid);
205 fprintf(stderr, "in sub 3\n");
206 auto *ricsubrid = (RICsubscriptionRequest_IEs_t*)calloc(1, sizeof(RICsubscriptionRequest_IEs_t));
207 fprintf(stderr, "in sub 4\n");
208 ASN_STRUCT_RESET(asn_DEF_RICsubscriptionRequest_IEs, ricsubrid);
210 fprintf(stderr, "in generate sub\n");
211 uint8_t *buf2 = (uint8_t *)"SubscriptionTriggers";
212 fprintf(stderr, "in gen sub 1\n");
213 OCTET_STRING_t *triggerdef = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
214 triggerdef->buf = (uint8_t *)calloc(1,20);
215 triggerdef->size = 20;
216 memcpy(triggerdef->buf, buf2, triggerdef->size);
219 fprintf(stderr, "sub1\n");
220 ProtocolIE_ID_t proto_id= ProtocolIE_ID_id_RICaction_ToBeSetup_Item;
222 RICaction_ToBeSetup_ItemIEs__value_PR pres6;
223 pres6 = RICaction_ToBeSetup_ItemIEs__value_PR_RICaction_ToBeSetup_Item;
227 uint8_t *buf5 = (uint8_t *)"ActionDef";
229 OCTET_STRING_t *actdef = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
230 actdef->buf = (uint8_t *)calloc(1,9);
232 memcpy(triggerdef->buf, buf5, 9);
234 auto *sa = (RICsubsequentAction_t *) calloc(1, sizeof(RICsubsequentAction_t));
235 ASN_STRUCT_RESET(asn_DEF_RICsubsequentAction, sa);
237 sa->ricTimeToWait = RICtimeToWait_w500ms;
238 sa->ricSubsequentActionType = RICsubsequentActionType_continue;
241 RICaction_ToBeSetup_Item_t *action_item = (RICaction_ToBeSetup_Item_t*)calloc(1, sizeof(RICaction_ToBeSetup_Item_t));
242 action_item->ricActionID = 5;
243 action_item->ricActionType = 9;
244 action_item->ricActionDefinition = actdef;
245 action_item->ricSubsequentAction = sa;
249 RICaction_ToBeSetup_ItemIEs_t *action_item_ies = (RICaction_ToBeSetup_ItemIEs_t *)calloc(1, sizeof(RICaction_ToBeSetup_Item_t));
250 action_item_ies->id = proto_id;
251 action_item_ies->criticality = 0;
253 action_item_ies->value.present = pres6;
254 action_item_ies->value.choice.RICaction_ToBeSetup_Item.ricActionID = 5;
255 action_item_ies->value.choice.RICaction_ToBeSetup_Item.ricActionType = RICactionType_report;
256 action_item_ies->value.choice.RICaction_ToBeSetup_Item.ricActionDefinition = actdef;
257 action_item_ies->value.choice.RICaction_ToBeSetup_Item.ricSubsequentAction = sa;
262 RICsubscriptionDetails_t *ricsubdetails = (RICsubscriptionDetails_t*)calloc(1, sizeof(RICsubscriptionDetails_t));
265 ASN_SEQUENCE_ADD(&ricsubdetails->ricAction_ToBeSetup_List.list, action_item_ies);
266 ricsubdetails->ricEventTriggerDefinition = *triggerdef;
272 RICsubscriptionRequest_IEs__value_PR pres3;
274 pres3 = RICsubscriptionRequest_IEs__value_PR_RICsubscriptionDetails;
275 ricsubrid->id = ProtocolIE_ID_id_RICsubscriptionDetails;
278 ricsubrid->criticality = 0;
279 ricsubrid->value.present = pres3;
282 ricsubrid->value.choice.RICsubscriptionDetails.ricEventTriggerDefinition = *triggerdef;
285 ASN_SEQUENCE_ADD(&ricsubrid->value.choice.RICsubscriptionDetails.ricAction_ToBeSetup_List.list, action_item_ies);
290 ricreqid->id = ProtocolIE_ID_id_RICrequestID;
291 ricreqid->criticality = 0;
292 ricreqid->value.present = RICsubscriptionRequest_IEs__value_PR_RICrequestID;
293 ricreqid->value.choice.RICrequestID.ricRequestorID = 22;
294 ricreqid->value.choice.RICrequestID.ricInstanceID = 6;
296 RICsubscriptionRequest_t *ricsubreq = (RICsubscriptionRequest_t*)calloc(1, sizeof(RICsubscriptionRequest_t));
298 ASN_SEQUENCE_ADD(&ricsubreq->protocolIEs.list,ricreqid);
299 ASN_SEQUENCE_ADD(&ricsubreq->protocolIEs.list,ricsubrid);
303 InitiatingMessage__value_PR pres4;
304 pres4 = InitiatingMessage__value_PR_RICsubscriptionRequest;
305 InitiatingMessage_t *initmsg = (InitiatingMessage_t*)calloc(1, sizeof(InitiatingMessage_t));
306 initmsg->procedureCode = ProcedureCode_id_RICsubscription;
307 initmsg->criticality = Criticality_reject;
308 initmsg->value.present = pres4;
309 initmsg->value.choice.RICsubscriptionRequest = *ricsubreq;
312 pres5 = E2AP_PDU_PR_initiatingMessage;
315 e2ap_pdu->present = pres5;
316 e2ap_pdu->choice.initiatingMessage = initmsg;
318 char *error_buf = (char*)calloc(300, sizeof(char));;
321 asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen);
322 printf("error length %d\n", errlen);
323 printf("error buf %s\n", error_buf);
325 // xer_fprint(stderr, &asn_DEF_E2AP_PDU, e2ap_pdu);
329 void generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu, long reqActionIdsAccepted[],
330 long reqActionIdsRejected[], int accept_size, int reject_size,
331 long reqRequestorId, long reqInstanceId) {
333 RICsubscriptionResponse_IEs_t *respricreqid =
334 (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t));
336 respricreqid->id = ProtocolIE_ID_id_RICrequestID;
337 respricreqid->criticality = 0;
338 respricreqid->value.present = RICsubscriptionResponse_IEs__value_PR_RICrequestID;
339 respricreqid->value.choice.RICrequestID.ricRequestorID = reqRequestorId;
341 respricreqid->value.choice.RICrequestID.ricInstanceID = reqInstanceId;
344 RICsubscriptionResponse_IEs_t *ricactionadmitted =
345 (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t));
346 ricactionadmitted->id = ProtocolIE_ID_id_RICactions_Admitted;
347 ricactionadmitted->criticality = 0;
348 ricactionadmitted->value.present = RICsubscriptionResponse_IEs__value_PR_RICaction_Admitted_List;
350 RICaction_Admitted_List_t* admlist =
351 (RICaction_Admitted_List_t*)calloc(1,sizeof(RICaction_Admitted_List_t));
352 ricactionadmitted->value.choice.RICaction_Admitted_List = *admlist;
354 // int numAccept = sizeof(reqActionIdsAccepted);
355 int numAccept = accept_size;
356 int numReject = reject_size;
357 // int numReject = sizeof(reqActionIdsRejected);
360 for (int i=0; i < numAccept ; i++) {
361 fprintf(stderr, "in for loop i = %d\n", i);
363 long aid = reqActionIdsAccepted[i];
365 RICaction_Admitted_ItemIEs_t *admitie = (RICaction_Admitted_ItemIEs_t*)calloc(1,sizeof(RICaction_Admitted_ItemIEs_t));
366 admitie->id = ProtocolIE_ID_id_RICaction_Admitted_Item;
367 admitie->criticality = 0;
368 admitie->value.present = RICaction_Admitted_ItemIEs__value_PR_RICaction_Admitted_Item;
369 admitie->value.choice.RICaction_Admitted_Item.ricActionID = aid;
371 ASN_SEQUENCE_ADD(&ricactionadmitted->value.choice.RICaction_Admitted_List.list, admitie);
375 RICsubscriptionResponse_t *ricsubresp = (RICsubscriptionResponse_t*)calloc(1,sizeof(RICsubscriptionResponse_t));
376 ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, respricreqid);
377 ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, ricactionadmitted);
382 RICsubscriptionResponse_IEs_t *ricactionrejected =
383 (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t));
384 ricactionrejected->id = ProtocolIE_ID_id_RICactions_NotAdmitted;
385 ricactionrejected->criticality = 0;
386 ricactionrejected->value.present = RICsubscriptionResponse_IEs__value_PR_RICaction_NotAdmitted_List;
388 RICaction_NotAdmitted_List_t* rejectlist =
389 (RICaction_NotAdmitted_List_t*)calloc(1,sizeof(RICaction_NotAdmitted_List_t));
390 ricactionadmitted->value.choice.RICaction_NotAdmitted_List = *rejectlist;
392 for (int i=0; i < numReject; i++) {
393 fprintf(stderr, "in for loop i = %d\n", i);
395 long aid = reqActionIdsRejected[i];
397 RICaction_NotAdmitted_ItemIEs_t *noadmitie = (RICaction_NotAdmitted_ItemIEs_t*)calloc(1,sizeof(RICaction_NotAdmitted_ItemIEs_t));
398 noadmitie->id = ProtocolIE_ID_id_RICaction_NotAdmitted_Item;
399 noadmitie->criticality = 0;
400 noadmitie->value.present = RICaction_NotAdmitted_ItemIEs__value_PR_RICaction_NotAdmitted_Item;
401 noadmitie->value.choice.RICaction_NotAdmitted_Item.ricActionID = aid;
403 ASN_SEQUENCE_ADD(&ricactionrejected->value.choice.RICaction_NotAdmitted_List.list, noadmitie);
404 ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, ricactionrejected);
409 SuccessfulOutcome__value_PR pres2;
410 pres2 = SuccessfulOutcome__value_PR_RICsubscriptionResponse;
411 SuccessfulOutcome_t *successoutcome = (SuccessfulOutcome_t*)calloc(1, sizeof(SuccessfulOutcome_t));
412 successoutcome->procedureCode = ProcedureCode_id_RICsubscription;
413 successoutcome->criticality = 0;
414 successoutcome->value.present = pres2;
415 successoutcome->value.choice.RICsubscriptionResponse = *ricsubresp;
417 E2AP_PDU_PR pres5 = E2AP_PDU_PR_successfulOutcome;
419 e2ap_pdu->present = pres5;
420 e2ap_pdu->choice.successfulOutcome = successoutcome;
422 char *error_buf = (char*)calloc(300, sizeof(char));
425 asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen);
426 printf("error length %d\n", errlen);
427 printf("error buf %s\n", error_buf);
432 void generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PDU *sub_req_pdu) {
434 //Gather details of the request
436 RICsubscriptionRequest_t orig_req =
437 sub_req_pdu->choice.initiatingMessage->value.choice.RICsubscriptionRequest;
439 RICsubscriptionResponse_IEs_t *ricreqid =
440 (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t));
442 int count = orig_req.protocolIEs.list.count;
443 int size = orig_req.protocolIEs.list.size;
445 RICsubscriptionRequest_IEs_t **ies = (RICsubscriptionRequest_IEs_t**)orig_req.protocolIEs.list.array;
447 fprintf(stderr, "count%d\n", count);
448 fprintf(stderr, "size%d\n", size);
450 RICsubscriptionRequest_IEs__value_PR pres;
452 long responseRequestorId;
453 long responseInstanceId;
454 long responseActionId;
456 std::vector<long> actionIds;
458 for (int i=0; i < count; i++) {
459 RICsubscriptionRequest_IEs_t *next_ie = ies[i];
460 pres = next_ie->value.present;
462 fprintf(stderr, "next present value %d\n", pres);
465 case RICsubscriptionRequest_IEs__value_PR_RICrequestID:
467 RICrequestID_t reqId = next_ie->value.choice.RICrequestID;
468 long requestorId = reqId.ricRequestorID;
469 long instanceId = reqId.ricInstanceID;
470 fprintf(stderr, "requestorId %d\n", requestorId);
471 fprintf(stderr, "instanceId %d\n", instanceId);
472 responseRequestorId = requestorId;
473 responseInstanceId = instanceId;
477 case RICsubscriptionRequest_IEs__value_PR_RANfunctionID:
479 case RICsubscriptionRequest_IEs__value_PR_RICsubscriptionDetails:
481 RICsubscriptionDetails_t subDetails = next_ie->value.choice.RICsubscriptionDetails;
482 RICeventTriggerDefinition_t triggerDef = subDetails.ricEventTriggerDefinition;
483 RICactions_ToBeSetup_List_t actionList = subDetails.ricAction_ToBeSetup_List;
485 int actionCount = actionList.list.count;
486 fprintf(stderr, "action count%d\n", actionCount);
488 auto **item_array = actionList.list.array;
490 for (int i=0; i < actionCount; i++) {
491 //RICaction_ToBeSetup_Item_t
492 auto *next_item = item_array[i];
493 RICactionID_t actionId = ((RICaction_ToBeSetup_ItemIEs*)next_item)->value.choice.RICaction_ToBeSetup_Item.ricActionID;
494 fprintf(stderr, "Next Action ID %ld\n", actionId);
495 responseActionId = actionId;
496 actionIds.push_back(responseActionId);
505 fprintf(stderr, "After Processing Subscription Request\n");
507 fprintf(stderr, "requestorId %d\n", responseRequestorId);
508 fprintf(stderr, "instanceId %d\n", responseInstanceId);
511 for (int i=0; i < actionIds.size(); i++) {
512 fprintf(stderr, "Action ID %d %ld\n", i, actionIds.at(i));
517 RICsubscriptionResponse_IEs_t *respricreqid =
518 (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t));
520 respricreqid->id = ProtocolIE_ID_id_RICrequestID;
521 respricreqid->criticality = 0;
522 respricreqid->value.present = RICsubscriptionResponse_IEs__value_PR_RICrequestID;
523 respricreqid->value.choice.RICrequestID.ricRequestorID = responseRequestorId;
525 respricreqid->value.choice.RICrequestID.ricInstanceID = responseInstanceId;
528 RICsubscriptionResponse_IEs_t *ricactionadmitted =
529 (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t));
530 ricactionadmitted->id = ProtocolIE_ID_id_RICactions_Admitted;
531 ricactionadmitted->criticality = 0;
532 ricactionadmitted->value.present = RICsubscriptionResponse_IEs__value_PR_RICaction_Admitted_List;
534 RICaction_Admitted_List_t* admlist =
535 (RICaction_Admitted_List_t*)calloc(1,sizeof(RICaction_Admitted_List_t));
536 ricactionadmitted->value.choice.RICaction_Admitted_List = *admlist;
538 for (int i=0; i < actionIds.size(); i++) {
539 fprintf(stderr, "in for loop i = %d\n", i);
541 long aid = actionIds.at(i);
543 RICaction_Admitted_ItemIEs_t *admitie = (RICaction_Admitted_ItemIEs_t*)calloc(1,sizeof(RICaction_Admitted_ItemIEs_t));
544 admitie->id = ProtocolIE_ID_id_RICaction_Admitted_Item;
545 admitie->criticality = 0;
546 admitie->value.present = RICaction_Admitted_ItemIEs__value_PR_RICaction_Admitted_Item;
547 admitie->value.choice.RICaction_Admitted_Item.ricActionID = aid;
549 ASN_SEQUENCE_ADD(&ricactionadmitted->value.choice.RICaction_Admitted_List.list, admitie);
554 RICsubscriptionResponse_t *ricsubresp = (RICsubscriptionResponse_t*)calloc(1,sizeof(RICsubscriptionResponse_t));
556 ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, respricreqid);
557 ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, ricactionadmitted);
560 SuccessfulOutcome__value_PR pres2;
561 pres2 = SuccessfulOutcome__value_PR_RICsubscriptionResponse;
562 SuccessfulOutcome_t *successoutcome = (SuccessfulOutcome_t*)calloc(1, sizeof(SuccessfulOutcome_t));
563 successoutcome->procedureCode = ProcedureCode_id_RICsubscription;
564 successoutcome->criticality = 0;
565 successoutcome->value.present = pres2;
566 successoutcome->value.choice.RICsubscriptionResponse = *ricsubresp;
568 E2AP_PDU_PR pres5 = E2AP_PDU_PR_successfulOutcome;
570 e2ap_pdu->present = pres5;
571 e2ap_pdu->choice.successfulOutcome = successoutcome;
573 char *error_buf = (char*)calloc(300, sizeof(char));
576 asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen);
577 printf("error length %d\n", errlen);
578 printf("error buf %s\n", error_buf);
582 void generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_pdu,
588 uint8_t *ind_header_buf,
590 uint8_t *ind_message_buf,
591 int message_length) {
593 fprintf(stderr, "ind1\n");
594 RICindication_IEs_t *ricind_ies = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t));
595 RICindication_IEs_t *ricind_ies2 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t));
596 RICindication_IEs_t *ricind_ies3 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t));
597 RICindication_IEs_t *ricind_ies4 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t));
598 RICindication_IEs_t *ricind_ies5 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t));
599 RICindication_IEs_t *ricind_ies6 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t));
600 RICindication_IEs_t *ricind_ies7 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t));
601 RICindication_IEs_t *ricind_ies8 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t));
603 RICindication_IEs__value_PR pres3;
605 pres3 = RICindication_IEs__value_PR_RICrequestID;
606 ricind_ies->id = ProtocolIE_ID_id_RICrequestID;
607 ricind_ies->criticality = 0;
608 ricind_ies->value.present = pres3;
609 ricind_ies->value.choice.RICrequestID.ricRequestorID = requestorId;
610 ricind_ies->value.choice.RICrequestID.ricInstanceID = instanceId;
612 fprintf(stderr, "ind2\n");
614 pres3 = RICindication_IEs__value_PR_RANfunctionID;
615 ricind_ies2->id = ProtocolIE_ID_id_RANfunctionID;
616 ricind_ies2->criticality = 0;
617 ricind_ies2->value.present = pres3;
618 ricind_ies2->value.choice.RANfunctionID = ranFunctionId;
621 ricind_ies3->id = ProtocolIE_ID_id_RICactionID;
622 ricind_ies3->criticality = 0;
623 pres3 = RICindication_IEs__value_PR_RICactionID;
624 ricind_ies3->value.present = pres3;
625 ricind_ies3->value.choice.RICactionID = actionId;
628 pres3 = RICindication_IEs__value_PR_RICindicationSN;
629 ricind_ies4->id = ProtocolIE_ID_id_RICindicationSN;
630 ricind_ies4->criticality = 0;
631 ricind_ies4->value.present = pres3;
632 ricind_ies4->value.choice.RICindicationSN = seqNum;
634 //Indication type is REPORT
635 pres3 = RICindication_IEs__value_PR_RICindicationType;
636 ricind_ies5->id = ProtocolIE_ID_id_RICindicationType;
637 ricind_ies5->criticality = 0;
638 ricind_ies5->value.present = pres3;
639 ricind_ies5->value.choice.RICindicationType = 0;
642 uint8_t *buf2 = (uint8_t *)"reportheader";
643 OCTET_STRING_t *hdr_str = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
645 hdr_str->buf = (uint8_t*)calloc(1,header_length);
646 hdr_str->size = header_length;
647 memcpy(hdr_str->buf, ind_header_buf, header_length);
649 fprintf(stderr, "ind3\n");
651 ricind_ies6->value.choice.RICindicationHeader.buf = (uint8_t*)calloc(1,header_length);
653 pres3 = RICindication_IEs__value_PR_RICindicationHeader;
654 ricind_ies6->id = ProtocolIE_ID_id_RICindicationHeader;
655 ricind_ies6->criticality = 0;
656 ricind_ies6->value.present = pres3;
657 ricind_ies6->value.choice.RICindicationHeader.size = header_length;
658 memcpy(ricind_ies6->value.choice.RICindicationHeader.buf, ind_header_buf, header_length);
660 ricind_ies7->value.choice.RICindicationMessage.buf = (uint8_t*)calloc(1,8192);
665 pres3 = RICindication_IEs__value_PR_RICindicationMessage;
666 ricind_ies7->id = ProtocolIE_ID_id_RICindicationMessage;
667 fprintf(stderr, "after encoding message 1\n");
669 ricind_ies7->criticality = 0;
670 ricind_ies7->value.present = pres3;
672 fprintf(stderr, "after encoding message 2\n");
674 fprintf(stderr, "after encoding message 3\n");
675 ricind_ies7->value.choice.RICindicationMessage.size = message_length;
677 fprintf(stderr, "after encoding message 4\n");
678 memcpy(ricind_ies7->value.choice.RICindicationMessage.buf, ind_message_buf, message_length);
680 fprintf(stderr, "after encoding message 5\n");
682 uint8_t *cpid_buf = (uint8_t *)"cpid";
683 OCTET_STRING_t cpid_str;
687 int cpid_buf_len = strlen((char*)cpid_buf);
688 pres3 = RICindication_IEs__value_PR_RICcallProcessID;
689 ricind_ies8->id = ProtocolIE_ID_id_RICcallProcessID;
691 ricind_ies8->criticality = 0;
692 ricind_ies8->value.present = pres3;
694 ricind_ies8->value.choice.RICcallProcessID.buf = (uint8_t*)calloc(1,cpid_buf_len);
695 ricind_ies8->value.choice.RICcallProcessID.size = cpid_buf_len;
697 memcpy(ricind_ies8->value.choice.RICcallProcessID.buf, cpid_buf, cpid_buf_len);
701 RICindication_t *ricindication = (RICindication_t*)calloc(1, sizeof(RICindication_t));
706 ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies);
708 ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies2);
712 ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies3);
716 ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies4);
720 ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies5);
724 ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies6);
728 ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies7);
730 // ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies8);
733 InitiatingMessage__value_PR pres4;
734 pres4 = InitiatingMessage__value_PR_RICindication;
735 InitiatingMessage_t *initmsg = (InitiatingMessage_t*)calloc(1, sizeof(InitiatingMessage_t));
736 initmsg->procedureCode = 5;
737 initmsg->criticality = 1;
738 initmsg->value.present = pres4;
739 initmsg->value.choice.RICindication = *ricindication;
742 pres5 = E2AP_PDU_PR_initiatingMessage;
744 e2ap_pdu->present = pres5;
745 e2ap_pdu->choice.initiatingMessage = initmsg;
747 char *error_buf = (char*)calloc(300, sizeof(char));
750 asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen);
751 printf("error length %d\n", errlen);
752 printf("error buf %s\n", error_buf);
754 xer_fprint(stderr, &asn_DEF_E2AP_PDU, e2ap_pdu);
758 void generate_e2apv1_indication_request(E2AP_PDU *e2ap_pdu) {
759 fprintf(stderr, "ind1\n");
760 RICindication_IEs_t *ricind_ies = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t));
761 RICindication_IEs_t *ricind_ies2 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t));
762 RICindication_IEs_t *ricind_ies3 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t));
763 RICindication_IEs_t *ricind_ies4 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t));
764 RICindication_IEs_t *ricind_ies5 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t));
765 RICindication_IEs_t *ricind_ies6 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t));
766 RICindication_IEs_t *ricind_ies7 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t));
767 RICindication_IEs_t *ricind_ies8 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t));
769 RICindication_IEs__value_PR pres3;
771 pres3 = RICindication_IEs__value_PR_RICrequestID;
772 ricind_ies->id = ProtocolIE_ID_id_RICrequestID;
773 ricind_ies->criticality = 0;
774 ricind_ies->value.present = pres3;
775 ricind_ies->value.choice.RICrequestID.ricRequestorID = 25;
776 ricind_ies->value.choice.RICrequestID.ricInstanceID = 3;
778 fprintf(stderr, "ind2\n");
780 pres3 = RICindication_IEs__value_PR_RANfunctionID;
781 ricind_ies2->id = ProtocolIE_ID_id_RANfunctionID;
782 ricind_ies2->criticality = 0;
783 ricind_ies2->value.present = pres3;
784 ricind_ies2->value.choice.RANfunctionID = 70;
787 ricind_ies3->id = ProtocolIE_ID_id_RICactionID;
788 ricind_ies3->criticality = 0;
789 pres3 = RICindication_IEs__value_PR_RICactionID;
790 ricind_ies3->value.present = pres3;
791 ricind_ies3->value.choice.RICactionID = 80;
794 pres3 = RICindication_IEs__value_PR_RICindicationSN;
795 ricind_ies4->id = ProtocolIE_ID_id_RICindicationSN;
796 ricind_ies4->criticality = 0;
797 ricind_ies4->value.present = pres3;
798 ricind_ies4->value.choice.RICindicationSN = 45;
800 pres3 = RICindication_IEs__value_PR_RICindicationType;
801 ricind_ies5->id = ProtocolIE_ID_id_RICindicationType;
802 ricind_ies5->criticality = 0;
803 ricind_ies5->value.present = pres3;
804 ricind_ies5->value.choice.RICindicationType = 0;
807 uint8_t *buf2 = (uint8_t *)"reportheader";
808 OCTET_STRING_t *hdr_str = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
809 hdr_str->buf = (uint8_t*)calloc(1,12);
811 memcpy(hdr_str->buf, buf2, 12);
813 fprintf(stderr, "ind3\n");
815 ricind_ies6->value.choice.RICindicationHeader.buf = (uint8_t*)calloc(1,12);
817 pres3 = RICindication_IEs__value_PR_RICindicationHeader;
818 ricind_ies6->id = ProtocolIE_ID_id_RICindicationHeader;
819 ricind_ies6->criticality = 0;
820 ricind_ies6->value.present = pres3;
821 ricind_ies6->value.choice.RICindicationHeader.size = 12;
822 memcpy(ricind_ies6->value.choice.RICindicationHeader.buf, buf2, 12);
824 ricind_ies7->value.choice.RICindicationMessage.buf = (uint8_t*)calloc(1,8192);
825 // uint8_t *buf9 = (uint8_t *)"reportmsg";
828 E2SM_KPM_IndicationMessage_t *e2sm_ind_msg =
829 (E2SM_KPM_IndicationMessage_t*)calloc(1,sizeof(E2SM_KPM_IndicationMessage_t));
831 encode_kpm(e2sm_ind_msg);
834 E2SM_KPM_RANfunction_Description_t *e2sm_desc =
835 (E2SM_KPM_RANfunction_Description_t*)calloc(1,sizeof(E2SM_KPM_RANfunction_Description_t));
837 encode_kpm_function_description(e2sm_desc);
840 uint8_t e2smbuffer[8192];
841 size_t e2smbuffer_size = 8192;
843 asn_codec_ctx_t *opt_cod;
847 asn_encode_to_buffer(opt_cod,
848 ATS_ALIGNED_BASIC_PER,
849 &asn_DEF_E2SM_KPM_RANfunction_Description,
850 e2sm_desc, e2smbuffer, e2smbuffer_size);
853 asn_encode_to_buffer(opt_cod,
854 ATS_ALIGNED_BASIC_PER,
855 &asn_DEF_E2SM_KPM_IndicationMessage,
856 e2sm_ind_msg, e2smbuffer, e2smbuffer_size);
861 fprintf(stderr, "er encded is %d\n", er.encoded);
862 fprintf(stderr, "after encoding message\n");
864 OCTET_STRING_t *msg_str = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
865 msg_str->buf = (uint8_t*)calloc(1,er.encoded);
866 msg_str->size = er.encoded;
867 memcpy(msg_str->buf, e2smbuffer, er.encoded);
870 pres3 = RICindication_IEs__value_PR_RICindicationMessage;
871 ricind_ies7->id = ProtocolIE_ID_id_RICindicationMessage;
872 fprintf(stderr, "after encoding message 1\n");
874 ricind_ies7->criticality = 0;
875 ricind_ies7->value.present = pres3;
877 fprintf(stderr, "after encoding message 2\n");
879 fprintf(stderr, "after encoding message 3\n");
880 ricind_ies7->value.choice.RICindicationMessage.size = er.encoded;
882 fprintf(stderr, "after encoding message 4\n");
883 memcpy(ricind_ies7->value.choice.RICindicationMessage.buf, e2smbuffer, er.encoded);
885 fprintf(stderr, "after encoding message 5\n");
887 uint8_t *buf4 = (uint8_t *)"cpid";
888 OCTET_STRING_t cpid_str;
893 pres3 = RICindication_IEs__value_PR_RICcallProcessID;
894 ricind_ies8->id = ProtocolIE_ID_id_RICcallProcessID;
896 ricind_ies8->criticality = 0;
897 ricind_ies8->value.present = pres3;
899 ricind_ies8->value.choice.RICcallProcessID = cpid_str;
902 RICindication_t *ricindication = (RICindication_t*)calloc(1, sizeof(RICindication_t));
907 ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies);
909 ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies2);
911 ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies3);
912 ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies4);
913 ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies5);
915 ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies6);
917 ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies7);
919 ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies8);
922 InitiatingMessage__value_PR pres4;
923 pres4 = InitiatingMessage__value_PR_RICindication;
924 InitiatingMessage_t *initmsg = (InitiatingMessage_t*)calloc(1, sizeof(InitiatingMessage_t));
925 initmsg->procedureCode = 5;
926 initmsg->criticality = 1;
927 initmsg->value.present = pres4;
928 initmsg->value.choice.RICindication = *ricindication;
931 pres5 = E2AP_PDU_PR_initiatingMessage;
933 e2ap_pdu->present = pres5;
934 e2ap_pdu->choice.initiatingMessage = initmsg;
936 char *error_buf = (char*)calloc(300, sizeof(char));;
939 asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen);
940 printf("error length %d\n", errlen);
941 printf("error buf %s\n", error_buf);
943 xer_fprint(stderr, &asn_DEF_E2AP_PDU, e2ap_pdu);
947 void generate_e2apv1_indication_response(E2AP_PDU *e2ap_pdu) {