Issue-ID: SIM-18
[sim/e2-interface.git] / e2sim / e2apv1sim / kpm_callbacks.cpp
1
2
3 #include <iostream>
4 #include <fstream>
5 #include <vector>
6
7
8
9 extern "C" {
10   #include "OCUCP-PF-Container.h"
11   #include "OCTET_STRING.h"
12   #include "asn_application.h"
13   #include "E2SM-KPM-IndicationMessage.h"
14   #include "FQIPERSlicesPerPlmnListItem.h"
15   #include "E2SM-KPM-RANfunction-Description.h"
16   #include "Timestamp.h"
17   #include "E2AP-PDU.h"
18   #include "RICsubscriptionRequest.h"
19   #include "RICsubscriptionResponse.h"
20   #include "RICactionType.h"
21   #include "ProtocolIE-Field.h"
22   #include "ProtocolIE-SingleContainer.h"
23   #include "InitiatingMessage.h"
24 }
25   
26 #include "encode_kpm.hpp"
27
28 #include "encode_e2apv1.hpp"
29
30 #include <nlohmann/json.hpp>
31 #include <thread>
32
33
34
35
36 #include "e2sim.hpp"
37
38 using json = nlohmann::json;
39
40 using namespace std;
41
42 struct neighbor_cell_entry {
43   char *cellid;
44   int rsrp;
45   int rsrq;
46   int rssinr;
47
48 };
49
50 void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long actionId, int socket_fd) {
51
52   //Process simulation file
53
54   ifstream simfile;
55   string line;
56
57   long seqNum = 1;
58   
59   simfile.open("simulation.txt", ios::in);
60
61   cout << "step1" << endl;
62     
63   std::ifstream ue_stream("ueMeasReport.txt");
64   std::ifstream cell_stream("cellMeasReport.txt");
65
66   json all_ues_json;
67
68   ue_stream  >> all_ues_json;
69
70   json all_cells_json;
71
72   cell_stream >> all_cells_json;
73
74   asn_codec_ctx_t *opt_cod;
75
76   cout << "UE RF Measurements" << endl;
77   cout << "******************" << endl;
78
79   int numMeasReports = (all_ues_json["/ueMeasReport/ueMeasReportList"_json_pointer]).size();
80
81   for (int i = 0; i < numMeasReports; i++) {
82     int nextCellId;
83     int nextRsrp;
84     int nextRsrq;
85     int nextRssinr;
86     cout << "UE number " + i << endl;
87     cout << "**********" << endl;
88     json::json_pointer p1(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/nrCellIdentity");
89     nextCellId = all_ues_json[p1].get<int>();
90     cout << "Serving Cell " << nextCellId << endl;
91     
92     json::json_pointer p2(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/servingCellRfReport/rsrp");
93     nextRsrp = all_ues_json[p2].get<int>();
94     cout << "  RSRP " << nextRsrp << endl;
95     json::json_pointer p3(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/servingCellRfReport/rsrq");
96     nextRsrq = all_ues_json[p3].get<int>();
97     cout << "  RSRQ " << nextRsrq << endl;
98     json::json_pointer p4(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/servingCellRfReport/rssinr");
99     nextRssinr = all_ues_json[p4].get<int>();
100     cout << "  RSSINR " << nextRssinr << endl;
101
102     json::json_pointer p5(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/neighbourCellList");
103
104     int numNeighborCells = (all_ues_json[p5]).size();
105
106
107     //REPORT Message 3 -- Encode and send OCUCP user-level report
108     
109     E2SM_KPM_IndicationMessage_t *ind_msg3 =
110       (E2SM_KPM_IndicationMessage_t*)calloc(1,sizeof(E2SM_KPM_IndicationMessage_t));
111     E2AP_PDU *pdu3 = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
112     
113     uint8_t *crnti_buf = (uint8_t*)calloc(1,2);
114
115     if (nextCellId == 0) {
116       uint8_t *buf2 = (uint8_t*)"12";
117       memcpy(crnti_buf, buf2, 2);
118     } else if (nextCellId == 1) {
119       uint8_t *buf2 = (uint8_t*)"22";
120       memcpy(crnti_buf, buf2, 2);
121     }
122
123     std::string serving_str = "{\"rsrp\": " + std::to_string(nextRsrp) + ", \"rsrq\": " +
124       std::to_string(nextRsrq) + ", \"rssinr\": " + std::to_string(nextRssinr) + "}";
125     const uint8_t *serving_buf = reinterpret_cast<const uint8_t*>(serving_str.c_str());
126         
127     std::string neighbor_str = "[";
128
129     int nextNbCell;
130     int nextNbRsrp;
131     int nextNbRsrq;
132     int nextNbRssinr;
133
134     for (int j = 0; j < numNeighborCells; j++) {
135       json::json_pointer p8(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/neighbourCellList/" + std::to_string(j) + "/nbCellIdentity");
136       nextNbCell = all_ues_json[p8].get<int>();
137       cout << "Neighbor Cell " << all_ues_json[p8] << endl;
138       json::json_pointer p9(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i)
139                             +"/neighbourCellList/" + std::to_string(j) + "/nbCellRfReport/rsrp");
140       nextNbRsrp = all_ues_json[p9].get<int>();
141       cout << "  RSRP " << nextNbRsrp << endl;
142
143       json::json_pointer p10(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i)
144                             +"/neighbourCellList/" + std::to_string(j) + "/nbCellRfReport/rsrq");
145       nextNbRsrq = all_ues_json[p10].get<int>();
146       cout << "  RSRQ " << nextNbRsrq << endl;
147
148       json::json_pointer p11(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i)
149                              +"/neighbourCellList/" + std::to_string(j) + "/nbCellRfReport/rssinr");
150       nextNbRssinr = all_ues_json[p11].get<int>();
151       cout << "  RSSINR " << nextNbRssinr << endl;
152
153       if (j != 0) {
154         neighbor_str += ",";
155
156       }
157
158       neighbor_str += "{\"CID\" : \"" + std::to_string(nextNbCell) + "\", \"Cell-RF\" : \"{\"rsrp\": " + std::to_string(nextNbRsrp) +
159         ", \"rsrq\": " + std::to_string(nextNbRsrq) + ", \"rssinr\": " + std::to_string(nextNbRssinr) + "}}";
160       
161     }
162
163     neighbor_str += "]";
164     
165     const uint8_t *neighbor_buf = reinterpret_cast<const uint8_t*>(neighbor_str.c_str());
166     
167     printf("Neighbor string\n%s", neighbor_buf);
168
169     uint8_t *plmnid_buf = (uint8_t*)"747";
170     uint8_t *nrcellid_buf = (uint8_t*)"12340";
171     
172     encode_kpm_report_rancontainer_cucp_parameterized(ind_msg3, plmnid_buf, nrcellid_buf, crnti_buf, serving_buf, neighbor_buf);
173     
174     uint8_t e2smbuffer3[8192];
175     size_t e2smbuffer_size3 = 8192;
176
177     
178     asn_enc_rval_t er3 = asn_encode_to_buffer(opt_cod,
179                                               ATS_ALIGNED_BASIC_PER,
180                                               &asn_DEF_E2SM_KPM_IndicationMessage,
181                                               ind_msg3, e2smbuffer3, e2smbuffer_size3);
182     
183     fprintf(stderr, "er encded is %d\n", er3.encoded);
184     fprintf(stderr, "after encoding message\n");
185     uint8_t *e2smheader_buf3 = (uint8_t*)"header";
186     
187     generate_e2apv1_indication_request_parameterized(pdu3, requestorId,
188                                                      instanceId, ranFunctionId,
189                                                      actionId, seqNum, e2smheader_buf3, 6, e2smbuffer3, er3.encoded);
190     
191     encode_and_send_sctp_data(pdu3, socket_fd);
192     
193     seqNum++;
194         
195   }
196
197
198   cout << "Cell Measurements" << endl;
199   cout << "******************" << endl;
200
201   int numCellMeasReports = (all_cells_json["/cellMeasReport/cellMeasReportList"_json_pointer]).size();
202
203   uint8_t *sst_buf = (uint8_t*)"1";
204   uint8_t *sd_buf = (uint8_t*)"100";
205   uint8_t *plmnid_buf = (uint8_t*)"747";
206   
207   for (int i = 0; i < numCellMeasReports; i++) {
208
209     int nextCellId;
210     int nextPdcpBytesDL;
211     int nextPdcpBytesUL;
212     int nextPRBBytesDL;
213     int nextPRBBytesUL;
214
215     json::json_pointer p1(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/nrCellIdentity");
216     nextCellId = all_cells_json[p1].get<int>();
217     cout << std::string("Cell number ") << nextCellId << endl;
218     
219     cout << "**********" << endl;
220     
221     json::json_pointer p2(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/pdcpByteMeasReport/pdcpBytesDl");
222     nextPdcpBytesDL = all_cells_json[p2].get<int>();
223     cout << std::string("  PDCP Bytes DL ") << nextPdcpBytesDL << endl;
224
225     json::json_pointer p3(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/pdcpByteMeasReport/pdcpBytesUl");
226     nextPdcpBytesUL = all_cells_json[p3].get<int>();    
227     cout << std::string("  PDCP Bytes UL ") << nextPdcpBytesUL << endl;
228
229     uint8_t *buf = (uint8_t*)"GNBCUUP5";
230     
231     int bytes_dl = nextPdcpBytesDL;
232
233     int bytes_ul = nextPdcpBytesUL;
234
235     //    int bytes_dl = 3905;
236     //    int bytes_ul = 1609321;    
237     
238     E2SM_KPM_IndicationMessage_t *ind_msg2 =
239       (E2SM_KPM_IndicationMessage_t*)calloc(1,sizeof(E2SM_KPM_IndicationMessage_t));
240     E2AP_PDU *pdu2 = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
241     
242     encode_kpm_report_style5_parameterized(ind_msg2 , buf, bytes_dl, bytes_ul, sst_buf, sd_buf, plmnid_buf);
243     
244     uint8_t e2smbuffer2[8192];
245     size_t e2smbuffer_size2 = 8192;
246     
247     asn_enc_rval_t er2 = asn_encode_to_buffer(opt_cod,
248                                               ATS_ALIGNED_BASIC_PER,
249                                               &asn_DEF_E2SM_KPM_IndicationMessage,
250                                               ind_msg2, e2smbuffer2, e2smbuffer_size2);
251     
252     fprintf(stderr, "er encded is %d\n", er2.encoded);
253     fprintf(stderr, "after encoding message\n");
254     uint8_t *e2smheader_buf2 = (uint8_t*)"header";
255     
256     generate_e2apv1_indication_request_parameterized(pdu2, requestorId,
257                                                      instanceId, ranFunctionId,
258                                                      actionId, seqNum, e2smheader_buf2, 6, e2smbuffer2, er2.encoded);
259     
260     encode_and_send_sctp_data(pdu2, socket_fd);
261     
262     seqNum++;
263
264     
265
266     json::json_pointer p4(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/prbMeasReport/availPrbDl");
267     nextPRBBytesDL = all_cells_json[p4].get<int>();    
268     cout << std::string("  PRB Bytes DL ") << all_cells_json[p4] << endl;
269
270     json::json_pointer p5(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/prbMeasReport/availPrbUl");
271     nextPRBBytesUL = all_cells_json[p5].get<int>();
272     cout << std::string("  PRB Bytes UL ") << all_cells_json[p5] << endl;
273
274
275     //REPORT Message 1 -- Encode and send ODU cell-level report
276     
277     E2SM_KPM_IndicationMessage_t *ind_msg1 =
278       (E2SM_KPM_IndicationMessage_t*)calloc(1,sizeof(E2SM_KPM_IndicationMessage_t));
279     E2AP_PDU *pdu = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
280     
281     long fiveqi = 7;
282
283     uint8_t *nrcellid_buf = (uint8_t*)"12340";
284     long dl_prbs = nextPRBBytesDL;
285     long ul_prbs = nextPRBBytesUL;
286     
287     encode_kpm_report_style1_parameterized(ind_msg1, fiveqi, dl_prbs, ul_prbs, sst_buf, sd_buf, plmnid_buf, nrcellid_buf, &dl_prbs, &ul_prbs);
288     
289     uint8_t e2smbuffer[8192];
290     size_t e2smbuffer_size = 8192;
291     
292     asn_enc_rval_t er = asn_encode_to_buffer(opt_cod,
293                                              ATS_ALIGNED_BASIC_PER,
294                                              &asn_DEF_E2SM_KPM_IndicationMessage,
295                                              ind_msg1, e2smbuffer, e2smbuffer_size);
296     
297     fprintf(stderr, "er encded is %d\n", er.encoded);
298     fprintf(stderr, "after encoding message\n");
299     uint8_t *e2smheader_buf = (uint8_t*)"header";
300     
301     uint8_t *cpid_buf = (uint8_t*)"CPID";
302     
303     fprintf(stderr, "About to encode Indication\n");
304     generate_e2apv1_indication_request_parameterized(pdu, requestorId,
305                                                      instanceId, ranFunctionId,
306                                                      actionId, seqNum, e2smheader_buf, 6, e2smbuffer, er.encoded);
307     
308     encode_and_send_sctp_data(pdu, socket_fd);
309     
310     seqNum++;
311     
312   }
313
314
315   /*
316   if (simfile.is_open()) {
317
318     while (getline(simfile, line)) {
319       cout << line << "\n";
320
321       //REPORT Message 1 -- Encode and send ODU cell-level report
322
323       E2SM_KPM_IndicationMessage_t *ind_msg1 =
324         (E2SM_KPM_IndicationMessage_t*)calloc(1,sizeof(E2SM_KPM_IndicationMessage_t));
325       E2AP_PDU *pdu = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
326
327       long fiveqi = 7;
328       uint8_t *sst_buf = (uint8_t*)"1";
329       uint8_t *sd_buf = (uint8_t*)"100";
330       uint8_t *plmnid_buf = (uint8_t*)"747";
331       uint8_t *nrcellid_buf = (uint8_t*)"12340";
332       long dl_prbs = 100;
333       long ul_prbs = 50; 
334      
335       encode_kpm_report_style1_parameterized(ind_msg1, fiveqi, dl_prbs, ul_prbs, sst_buf, sd_buf, plmnid_buf, nrcellid_buf, &dl_prbs, &ul_prbs);
336
337       uint8_t e2smbuffer[8192];
338       size_t e2smbuffer_size = 8192;
339       asn_codec_ctx_t *opt_cod;
340
341       asn_enc_rval_t er = asn_encode_to_buffer(opt_cod,
342                                                ATS_ALIGNED_BASIC_PER,
343                                                &asn_DEF_E2SM_KPM_IndicationMessage,
344                                                ind_msg1, e2smbuffer, e2smbuffer_size);
345       
346       fprintf(stderr, "er encded is %d\n", er.encoded);
347       fprintf(stderr, "after encoding message\n");
348       uint8_t *e2smheader_buf = (uint8_t*)"header";
349
350       uint8_t *cpid_buf = (uint8_t*)"CPID";
351
352       fprintf(stderr, "About to encode Indication\n");
353       generate_e2apv1_indication_request_parameterized(pdu, requestorId,
354                                                        instanceId, ranFunctionId,
355                                                        actionId, seqNum, e2smheader_buf, 6, e2smbuffer, er.encoded);
356
357       encode_and_send_sctp_data(pdu, socket_fd);
358       
359       seqNum++;
360
361       //REPORT Message 2 -- Encode and send OCUUP cell-level report
362
363       uint8_t *buf = (uint8_t*)"GNBCUUP5";
364
365       int bytes_dl = 40000;
366       int bytes_ul = 50000;
367
368       E2SM_KPM_IndicationMessage_t *ind_msg2 =
369         (E2SM_KPM_IndicationMessage_t*)calloc(1,sizeof(E2SM_KPM_IndicationMessage_t));
370       E2AP_PDU *pdu2 = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
371       
372       encode_kpm_report_style5_parameterized(ind_msg2 , buf, bytes_dl, bytes_ul, sst_buf, sd_buf, plmnid_buf);
373
374       uint8_t e2smbuffer2[8192];
375       size_t e2smbuffer_size2 = 8192;
376
377
378       asn_enc_rval_t er2 = asn_encode_to_buffer(opt_cod,
379                                                ATS_ALIGNED_BASIC_PER,
380                                                &asn_DEF_E2SM_KPM_IndicationMessage,
381                                                ind_msg2, e2smbuffer2, e2smbuffer_size2);
382       
383       fprintf(stderr, "er encded is %d\n", er2.encoded);
384       fprintf(stderr, "after encoding message\n");
385       uint8_t *e2smheader_buf2 = (uint8_t*)"header";
386
387       generate_e2apv1_indication_request_parameterized(pdu2, requestorId,
388                                                        instanceId, ranFunctionId,
389                                                        actionId, seqNum, e2smheader_buf2, 6, e2smbuffer2, er2.encoded);
390
391       encode_and_send_sctp_data(pdu2, socket_fd);
392       
393       seqNum++;
394
395       //REPORT Message 3 -- Encode and send OCUCP user-level report
396
397       E2SM_KPM_IndicationMessage_t *ind_msg3 =
398         (E2SM_KPM_IndicationMessage_t*)calloc(1,sizeof(E2SM_KPM_IndicationMessage_t));
399       E2AP_PDU *pdu3 = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
400
401       uint8_t *crnti_buf = (uint8_t*)"12";
402       //      uint8_t *serving_buf = (uint8_t*)"RSRP10";
403       //uint8_t *neighbor_buf = (uint8_t*)"-10,-15";
404       int rsrpServ = 10;
405       int rsrqServ = 0;
406       int rssinrServ = 0;
407
408       std::string serving_str = "{\"rsrp\": " + std::to_string(rsrpServ) + ", \"rsrq\": " +
409         std::to_string(rsrqServ) + ", \"rssinr\": " + std::to_string(rssinrServ) + "}";
410       const uint8_t *serving_buf = reinterpret_cast<const uint8_t*>(serving_str.c_str());
411
412
413       neighbor_cell_entry n_entries[3];
414       n_entries[0] = {"123", 10, 0, 0};
415       n_entries[1] = {"456", 10, 0, 0};
416       n_entries[2] = {"789", 10, 0, 0};
417
418       std::string neighbor_str = "[";
419
420       for (int i=0; i < sizeof(n_entries)/sizeof(n_entries[0]); i++) {
421
422         if (i != 0) {
423           neighbor_str += ",";
424         }
425         neighbor_str += "{\"CID\" : \"" + std::string(n_entries[i].cellid) + "\", \"Cell-RF\" : \"{\"rsrp\": " + std::to_string(n_entries[i].rsrp) +
426           ", \"rsrq\": " + std::to_string(n_entries[i].rsrq) + ", \"rssinr\": " + std::to_string(n_entries[i].rsrp) + "}}";
427       }
428
429       neighbor_str += "]";
430
431       const uint8_t *neighbor_buf = reinterpret_cast<const uint8_t*>(neighbor_str.c_str());
432
433       printf("Neighbor string\n%s", neighbor_buf);
434
435       encode_kpm_report_rancontainer_cucp_parameterized(ind_msg3, plmnid_buf, nrcellid_buf, crnti_buf, serving_buf, neighbor_buf);
436       
437       uint8_t e2smbuffer3[8192];
438       size_t e2smbuffer_size3 = 8192;
439
440       asn_enc_rval_t er3 = asn_encode_to_buffer(opt_cod,
441                                                 ATS_ALIGNED_BASIC_PER,
442                                                 &asn_DEF_E2SM_KPM_IndicationMessage,
443                                                 ind_msg3, e2smbuffer3, e2smbuffer_size3);
444       
445       fprintf(stderr, "er encded is %d\n", er3.encoded);
446       fprintf(stderr, "after encoding message\n");
447       uint8_t *e2smheader_buf3 = (uint8_t*)"header";
448
449       generate_e2apv1_indication_request_parameterized(pdu3, requestorId,
450                                                        instanceId, ranFunctionId,
451                                                        actionId, seqNum, e2smheader_buf3, 6, e2smbuffer3, er3.encoded);
452
453       encode_and_send_sctp_data(pdu3, socket_fd);
454             
455       seqNum++;
456       
457       //Encode and send OCUUP user-level report
458
459
460       
461       //Encode and send ODU user-level report
462
463       
464
465       
466     }
467
468     simfile.close();
469
470   }
471   */
472
473 }
474
475 void callback_kpm_subscription_request(E2AP_PDU_t *sub_req_pdu, int socket_fd) {
476
477
478   //Record RIC Request ID
479   //Go through RIC action to be Setup List
480   //Find first entry with REPORT action Type
481   //Record ricActionID
482   //Encode subscription response
483
484   RICsubscriptionRequest_t orig_req =
485     sub_req_pdu->choice.initiatingMessage->value.choice.RICsubscriptionRequest;
486   
487   RICsubscriptionResponse_IEs_t *ricreqid =
488     (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t));
489                                            
490   int count = orig_req.protocolIEs.list.count;
491   int size = orig_req.protocolIEs.list.size;
492   
493   RICsubscriptionRequest_IEs_t **ies = (RICsubscriptionRequest_IEs_t**)orig_req.protocolIEs.list.array;
494
495   fprintf(stderr, "count%d\n", count);
496   fprintf(stderr, "size%d\n", size);
497
498   RICsubscriptionRequest_IEs__value_PR pres;
499
500   long reqRequestorId;
501   long reqInstanceId;
502   long reqActionId;
503
504   std::vector<long> actionIdsAccept;
505   std::vector<long> actionIdsReject;
506
507   for (int i=0; i < count; i++) {
508     RICsubscriptionRequest_IEs_t *next_ie = ies[i];
509     pres = next_ie->value.present;
510     
511     fprintf(stderr, "next present value %d\n", pres);
512
513     switch(pres) {
514     case RICsubscriptionRequest_IEs__value_PR_RICrequestID:
515       {
516         RICrequestID_t reqId = next_ie->value.choice.RICrequestID;
517         long requestorId = reqId.ricRequestorID;
518         long instanceId = reqId.ricInstanceID;
519         fprintf(stderr, "requestorId %d\n", requestorId);
520         fprintf(stderr, "instanceId %d\n", instanceId);
521         reqRequestorId = requestorId;
522         reqInstanceId = instanceId;
523
524         break;
525       }
526     case RICsubscriptionRequest_IEs__value_PR_RANfunctionID:
527       break;
528     case RICsubscriptionRequest_IEs__value_PR_RICsubscriptionDetails:
529       {
530         RICsubscriptionDetails_t subDetails = next_ie->value.choice.RICsubscriptionDetails; 
531         RICeventTriggerDefinition_t triggerDef = subDetails.ricEventTriggerDefinition;
532         RICactions_ToBeSetup_List_t actionList = subDetails.ricAction_ToBeSetup_List;
533
534         //We are ignoring the trigger definition
535
536         //We identify the first action whose type is REPORT
537         //That is the only one accepted; all others are rejected
538         
539         int actionCount = actionList.list.count;
540         fprintf(stderr, "action count%d\n", actionCount);
541
542         auto **item_array = actionList.list.array;
543
544         bool foundAction = false;
545
546         for (int i=0; i < actionCount; i++) {
547
548           auto *next_item = item_array[i];
549           RICactionID_t actionId = ((RICaction_ToBeSetup_ItemIEs*)next_item)->value.choice.RICaction_ToBeSetup_Item.ricActionID;
550           RICactionType_t actionType = ((RICaction_ToBeSetup_ItemIEs*)next_item)->value.choice.RICaction_ToBeSetup_Item.ricActionType;
551
552           if (!foundAction && actionType == RICactionType_report) {
553             reqActionId = actionId;
554             actionIdsAccept.push_back(reqActionId);
555             printf("adding accept\n");
556             foundAction = true;
557           } else {
558             reqActionId = actionId;
559             printf("adding reject\n");
560             actionIdsReject.push_back(reqActionId);
561           }
562         }
563         
564         break;
565       }
566     }
567     
568   }
569
570   fprintf(stderr, "After Processing Subscription Request\n");
571
572   fprintf(stderr, "requestorId %d\n", reqRequestorId);
573   fprintf(stderr, "instanceId %d\n", reqInstanceId);
574
575
576   for (int i=0; i < actionIdsAccept.size(); i++) {
577     fprintf(stderr, "Action ID %d %ld\n", i, actionIdsAccept.at(i));
578     
579   }
580
581   E2AP_PDU *e2ap_pdu = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
582
583   long *accept_array = &actionIdsAccept[0];
584   long *reject_array = &actionIdsReject[0];
585   int accept_size = actionIdsAccept.size();
586   int reject_size = actionIdsReject.size();
587
588   generate_e2apv1_subscription_response_success(e2ap_pdu, accept_array, reject_array, accept_size, reject_size, reqRequestorId, reqInstanceId);
589
590   encode_and_send_sctp_data(e2ap_pdu,socket_fd);
591
592   //Start thread for sending REPORT messages
593
594   //  std::thread loop_thread;
595
596   long funcId = 1;
597
598   run_report_loop(reqRequestorId, reqInstanceId, funcId, reqActionId, socket_fd);
599
600   //  loop_thread = std::thread(&run_report_loop);
601
602 }