Add R5 content to master
[ric-plt/e2.git] / RIC-E2-TERMINATION / TEST / T1 / E2Builder.h
1 /*
2  * Copyright 2019 AT&T Intellectual Property
3  * Copyright 2019 Nokia
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 //
19 // Created by adi ENZEL on 12/10/19.
20 //
21
22 #ifndef E2_E2BUILDER_H
23 #define E2_E2BUILDER_H
24
25 #include <cstring>
26 #include <cstdio>
27 #include <cerrno>
28 #include <cstdlib>
29 #include <sys/types.h>
30 #include <error.h>
31 #include <algorithm>
32 #include <3rdparty/oranE2SM/E2SM-gNB-NRT-RANfunction-Definition.h>
33 #include <3rdparty/oranE2SM/RIC-InsertStyle-List.h>
34 #include <3rdparty/oranE2SM/RANparameterDef-Item.h>
35 #include <3rdparty/oranE2/GlobalE2node-en-gNB-ID.h>
36 #include <3rdparty/oranE2/RICsubsequentAction.h>
37
38
39 //#include <mdclog/mdclog.h>
40
41
42 #include "oranE2/E2AP-PDU.h"
43 #include "oranE2/InitiatingMessage.h"
44 #include "oranE2/SuccessfulOutcome.h"
45 #include "oranE2/UnsuccessfulOutcome.h"
46
47 #include "oranE2/ProtocolIE-Field.h"
48 #include "oranE2/ENB-ID.h"
49 #include "oranE2/GlobalENB-ID.h"
50 #include "oranE2/GlobalE2node-gNB-ID.h"
51 #include "oranE2/constr_TYPE.h"
52 #include "oranE2/asn_constant.h"
53
54 using namespace std;
55
56 #define printEntry(type, function);  fprintf(stdout, "start Test %s , %s", type, function);
57
58
59 static void checkAndPrint(asn_TYPE_descriptor_t *typeDescriptor, void *data, char *dataType, const char *function) {
60     char errbuf[128]; /* Buffer for error message */
61     size_t errlen = sizeof(errbuf); /* Size of the buffer */
62     if (asn_check_constraints(typeDescriptor, data, errbuf, &errlen) != 0) {
63         fprintf(stderr, "%s Constraint validation failed: %s", dataType, errbuf);
64     }
65     fprintf(stdout, "%s successes function %s", dataType, function);
66 }
67
68 void createPLMN_IDByMCCandMNC(PLMN_Identity_t *plmnId, int mcc, int mnc) {
69
70     //printEntry("PLMN_Identity_t", __func__)
71
72     ASN_STRUCT_RESET(asn_DEF_PLMN_Identity, plmnId);
73     plmnId->size = 3;
74     plmnId->buf = (uint8_t *) calloc(1, 3);
75     volatile auto mcc1 = (unsigned int) (mcc / 100);
76     volatile auto mcc2 = (unsigned int) (mcc / 10 % 10);
77     volatile auto mcc3 = (unsigned int) (mcc % 10);
78     plmnId->buf[0] = mcc2 << 4 | mcc1;
79
80     volatile auto mnc1 = (unsigned int)0;
81     volatile auto mnc2 = (unsigned int)0;
82     volatile auto mnc3 = (unsigned int)0;
83
84     if (mnc >= 100) {
85         mnc1 = (unsigned int) (mnc / 100);
86         mnc2 = (unsigned int) (mnc / 10 % 10);
87         mnc3 = (unsigned int) (mnc % 10);
88     } else {
89         mnc1 = (unsigned int) (mnc / 10);
90         mnc2 = (unsigned int) (mnc % 10);
91         mnc3 = 15;
92     }
93     plmnId->buf[1] = mcc3 << 4 | mnc3 ;
94     plmnId->buf[2] = mnc2 << 4 | mnc1 ;
95
96     //checkAndPrint(&asn_DEF_PLMN_Identity, plmnId, (char *) "PLMN_Identity_t", __func__);
97
98 }
99
100
101 PLMN_Identity_t *createPLMN_ID(const unsigned char *data) {
102     printEntry("PLMN_Identity_t", __func__)
103     auto *plmnId = (PLMN_Identity_t *) calloc(1, sizeof(PLMN_Identity_t));
104     ASN_STRUCT_RESET(asn_DEF_PLMN_Identity, plmnId);
105     plmnId->size = 3;
106     plmnId->buf = (uint8_t *) calloc(1, 3);
107     memcpy(plmnId->buf, data, 3);
108
109     checkAndPrint(&asn_DEF_PLMN_Identity, plmnId, (char *) "PLMN_Identity_t", __func__);
110
111     return plmnId;
112 }
113
114 BIT_STRING_t *createBIT_STRING(int size, int unusedBits, uint8_t *data) {
115     printEntry("BIT_STRING_t", __func__)
116     auto *bitString = (BIT_STRING_t *) calloc(1, sizeof(BIT_STRING_t));
117     ASN_STRUCT_RESET(asn_DEF_BIT_STRING, bitString);
118     bitString->size = size;
119     bitString->bits_unused = unusedBits;
120     bitString->buf = (uint8_t *) calloc(1, size);
121     // set bits to zero
122     data[bitString->size - 1] = ((unsigned) (data[bitString->size - 1] >>
123                                                                        (unsigned) bitString->bits_unused)
124             << (unsigned) bitString->bits_unused);
125     memcpy(bitString->buf, data, size);
126
127     checkAndPrint(&asn_DEF_BIT_STRING, bitString, (char *) "BIT_STRING_t", __func__);
128
129     return bitString;
130 }
131
132
133 OCTET_STRING_t *createOCTET_STRING(const unsigned char *data, int size) {
134     printEntry("OCTET_STRING_t", __func__)
135     auto *octs = (PLMN_Identity_t *) calloc(1, sizeof(PLMN_Identity_t));
136     ASN_STRUCT_RESET(asn_DEF_OCTET_STRING, octs);
137     octs->size = size;
138     octs->buf = (uint8_t *) calloc(1, size);
139     memcpy(octs->buf, data, size);
140
141     checkAndPrint(&asn_DEF_OCTET_STRING, octs, (char *) "OCTET_STRING_t", __func__);
142     return octs;
143 }
144
145
146 ENB_ID_t *createENB_ID(ENB_ID_PR enbType, unsigned char *data) {
147     printEntry("ENB_ID_t", __func__)
148     auto *enb = (ENB_ID_t *) calloc(1, sizeof(ENB_ID_t));
149     ASN_STRUCT_RESET(asn_DEF_ENB_ID, enb);
150
151     enb->present = enbType;
152
153     switch (enbType) {
154         case ENB_ID_PR_macro_eNB_ID: { // 20 bit 3 bytes
155             enb->choice.macro_eNB_ID.size = 3;
156             enb->choice.macro_eNB_ID.bits_unused = 4;
157
158             enb->present = ENB_ID_PR_macro_eNB_ID;
159
160             enb->choice.macro_eNB_ID.buf = (uint8_t *) calloc(1, enb->choice.macro_eNB_ID.size);
161             data[enb->choice.macro_eNB_ID.size - 1] = ((unsigned) (data[enb->choice.macro_eNB_ID.size - 1] >>
162                                                                                                            (unsigned) enb->choice.macro_eNB_ID.bits_unused)
163                     << (unsigned) enb->choice.macro_eNB_ID.bits_unused);
164             memcpy(enb->choice.macro_eNB_ID.buf, data, enb->choice.macro_eNB_ID.size);
165
166             break;
167         }
168         case ENB_ID_PR_home_eNB_ID: { // 28 bit 4 bytes
169             enb->choice.home_eNB_ID.size = 4;
170             enb->choice.home_eNB_ID.bits_unused = 4;
171             enb->present = ENB_ID_PR_home_eNB_ID;
172
173             enb->choice.home_eNB_ID.buf = (uint8_t *) calloc(1, enb->choice.home_eNB_ID.size);
174             data[enb->choice.home_eNB_ID.size - 1] = ((unsigned) (data[enb->choice.home_eNB_ID.size - 1] >>
175                                                                                                          (unsigned) enb->choice.home_eNB_ID.bits_unused)
176                     << (unsigned) enb->choice.home_eNB_ID.bits_unused);
177             memcpy(enb->choice.home_eNB_ID.buf, data, enb->choice.home_eNB_ID.size);
178             break;
179         }
180         case ENB_ID_PR_short_Macro_eNB_ID: { // 18 bit - 3 bytes
181             enb->choice.short_Macro_eNB_ID.size = 3;
182             enb->choice.short_Macro_eNB_ID.bits_unused = 6;
183             enb->present = ENB_ID_PR_short_Macro_eNB_ID;
184
185             enb->choice.short_Macro_eNB_ID.buf = (uint8_t *) calloc(1, enb->choice.short_Macro_eNB_ID.size);
186             data[enb->choice.short_Macro_eNB_ID.size - 1] = (
187                     (unsigned) (data[enb->choice.short_Macro_eNB_ID.size - 1] >>
188                                                                               (unsigned) enb->choice.short_Macro_eNB_ID.bits_unused)
189                             << (unsigned) enb->choice.short_Macro_eNB_ID.bits_unused);
190             memcpy(enb->choice.short_Macro_eNB_ID.buf, data, enb->choice.short_Macro_eNB_ID.size);
191             break;
192         }
193         case ENB_ID_PR_long_Macro_eNB_ID: { // 21
194             enb->choice.long_Macro_eNB_ID.size = 3;
195             enb->choice.long_Macro_eNB_ID.bits_unused = 3;
196             enb->present = ENB_ID_PR_long_Macro_eNB_ID;
197
198             enb->choice.long_Macro_eNB_ID.buf = (uint8_t *) calloc(1, enb->choice.long_Macro_eNB_ID.size);
199             data[enb->choice.long_Macro_eNB_ID.size - 1] =
200                     ((unsigned) (data[enb->choice.long_Macro_eNB_ID.size - 1] >> (unsigned) enb->choice.long_Macro_eNB_ID.bits_unused)
201                             << (unsigned) enb->choice.long_Macro_eNB_ID.bits_unused);
202             memcpy(enb->choice.long_Macro_eNB_ID.buf, data, enb->choice.long_Macro_eNB_ID.size);
203             break;
204         }
205         default:
206             free(enb);
207             return nullptr;
208     }
209
210     checkAndPrint(&asn_DEF_ENB_ID, enb, (char *) "ENB_ID_t", __func__);
211     return enb;
212 }
213
214 GlobalENB_ID_t *createGlobalENB_ID(PLMN_Identity_t *plmnIdentity, ENB_ID_t *enbId) {
215     printEntry("GlobalENB_ID_t", __func__)
216     auto *genbId = (GlobalENB_ID_t *) calloc(1, sizeof(GlobalENB_ID_t));
217     ASN_STRUCT_RESET(asn_DEF_GlobalENB_ID, genbId);
218     memcpy(&genbId->pLMN_Identity, plmnIdentity, sizeof(PLMN_Identity_t));
219     memcpy(&genbId->eNB_ID, enbId, sizeof(ENB_ID_t));
220
221     checkAndPrint(&asn_DEF_GlobalENB_ID, genbId, (char *) "GlobalENB_ID_t", __func__);
222     return genbId;
223 }
224
225
226 //static void buildInitiatingMessagePDU(E2AP_PDU_t &pdu, InitiatingMessage_t *initMsg) {
227 //    pdu.present = E2AP_PDU_PR_initiatingMessage;
228 //    pdu.choice.initiatingMessage = initMsg;
229 //}
230
231 template<typename T>
232 static void buildInitMsg(InitiatingMessage_t &initMsg,
233                          InitiatingMessage__value_PR present,
234                          ProcedureCode_t procedureCode,
235                          Criticality_t criticality,
236                          T *value) {
237     initMsg.value.present = present;
238     initMsg.procedureCode = procedureCode;
239     initMsg.criticality = criticality;
240
241     switch (present) {
242         case InitiatingMessage__value_PR_RICsubscriptionRequest: {
243             memcpy(&initMsg.value.choice.RICsubscriptionRequest, value, sizeof(*value));
244             break;
245         }
246         case InitiatingMessage__value_PR_RICsubscriptionDeleteRequest: {
247             memcpy(&initMsg.value.choice.RICsubscriptionDeleteRequest, value, sizeof(*value));
248             break;
249         }
250         case InitiatingMessage__value_PR_RICserviceUpdate: {
251             memcpy(&initMsg.value.choice.RICserviceUpdate, value, sizeof(*value));
252             break;
253         }
254         case InitiatingMessage__value_PR_RICcontrolRequest: {
255             memcpy(&initMsg.value.choice.RICcontrolRequest, value, sizeof(*value));
256             break;
257         }
258         case InitiatingMessage__value_PR_RICindication: {
259             memcpy(&initMsg.value.choice.RICindication, value, sizeof(*value));
260             break;
261         }
262         case InitiatingMessage__value_PR_RICserviceQuery: {
263             memcpy(&initMsg.value.choice.RICserviceQuery, value, sizeof(*value));
264             break;
265         }
266         case InitiatingMessage__value_PR_NOTHING:
267         default : {
268             break;
269         }
270     }
271 }
272
273 //static void buildSuccsesfulMessagePDU(E2AP_PDU_t &pdu, SuccessfulOutcome_t *succMsg) {
274 //    pdu.present = E2AP_PDU_PR_successfulOutcome;
275 //    pdu.choice.successfulOutcome = succMsg;
276 //}
277
278 template<typename T>
279 static void buildSuccMsg(SuccessfulOutcome_t &succMsg,
280                          SuccessfulOutcome__value_PR present,
281                          ProcedureCode_t procedureCode,
282                          Criticality_t criticality,
283                          T *value) {
284     succMsg.value.present = present;
285     succMsg.procedureCode = procedureCode;
286     succMsg.criticality = criticality;
287
288     switch (present) {
289         case SuccessfulOutcome__value_PR_RICsubscriptionResponse: {
290             memcpy(&succMsg.value.choice.RICsubscriptionResponse, value, sizeof(*value));
291             break;
292         }
293         case SuccessfulOutcome__value_PR_RICsubscriptionDeleteResponse: {
294             memcpy(&succMsg.value.choice.RICsubscriptionDeleteResponse, value, sizeof(*value));
295             break;
296         }
297         case SuccessfulOutcome__value_PR_RICserviceUpdateAcknowledge: {
298             memcpy(&succMsg.value.choice.RICserviceUpdateAcknowledge, value, sizeof(*value));
299             break;
300         }
301         case SuccessfulOutcome__value_PR_RICcontrolAcknowledge: {
302             memcpy(&succMsg.value.choice.RICcontrolAcknowledge, value, sizeof(*value));
303             break;
304         }
305         case SuccessfulOutcome__value_PR_ResetResponse: {
306             memcpy(&succMsg.value.choice.ResetResponse, value, sizeof(*value));
307             break;
308         }
309         case SuccessfulOutcome__value_PR_NOTHING:
310         default:
311             break;
312     }
313 }
314
315
316 //static void buildUnSucssesfullMessagePDU(E2AP_PDU_t &pdu, UnsuccessfulOutcome_t *unSuccMsg) {
317 //    pdu.present = E2AP_PDU_PR_unsuccessfulOutcome;
318 //    pdu.choice.unsuccessfulOutcome = unSuccMsg;
319 //}
320
321 template<typename T>
322 static void buildUnSuccMsg(UnsuccessfulOutcome_t &unSuccMsg,
323                            UnsuccessfulOutcome__value_PR present,
324                            ProcedureCode_t procedureCode,
325                            Criticality_t criticality,
326                            T *value) {
327     unSuccMsg.value.present = present;
328     unSuccMsg.procedureCode = procedureCode;
329     unSuccMsg.criticality = criticality;
330
331     switch (present) {
332         case UnsuccessfulOutcome__value_PR_RICsubscriptionFailure: {
333             memcpy(&unSuccMsg.value.choice.RICsubscriptionFailure, value, sizeof(*value));
334             break;
335         }
336         case UnsuccessfulOutcome__value_PR_RICsubscriptionDeleteFailure: {
337             memcpy(&unSuccMsg.value.choice.RICsubscriptionDeleteFailure, value, sizeof(*value));
338             break;
339         }
340         case UnsuccessfulOutcome__value_PR_RICserviceUpdateFailure: {
341             memcpy(&unSuccMsg.value.choice.RICserviceUpdateFailure, value, sizeof(*value));
342             break;
343         }
344         case UnsuccessfulOutcome__value_PR_RICcontrolFailure: {
345             memcpy(&unSuccMsg.value.choice.RICcontrolFailure, value, sizeof(*value));
346             break;
347
348         }
349         case UnsuccessfulOutcome__value_PR_NOTHING:
350         default:
351             break;
352     }
353 }
354
355
356 //static void createPLMN_ID(PLMN_Identity_t &plmnId, const unsigned char *data) {
357 //    //printEntry("PLMN_Identity_t", __func__)
358 //    //PLMN_Identity_t *plmnId = calloc(1, sizeof(PLMN_Identity_t));
359 //    ASN_STRUCT_RESET(asn_DEF_PLMN_Identity, &plmnId);
360 //    plmnId.size = 3;//    uint64_t st = 0;
361 ////    uint32_t aux1 = 0;
362 ////    st = rdtscp(aux1);
363 //
364 //    plmnId.buf = (uint8_t *) calloc(1, 3);
365 //    memcpy(plmnId.buf, data, 3);
366 //
367 //    checkAndPrint(&asn_DEF_PLMN_Identity, &plmnId, (char *) "PLMN_Identity_t", __func__);
368 //
369 //}
370
371 static void createENB_ID(ENB_ID_t &enb, ENB_ID_PR enbType, unsigned char *data) {
372     //printEntry("ENB_ID_t", __func__)
373     ASN_STRUCT_RESET(asn_DEF_ENB_ID, &enb);
374     enb.present = enbType;
375     switch (enbType) {
376         case ENB_ID_PR_macro_eNB_ID: { // 20 bit 3 bytes
377             enb.choice.macro_eNB_ID.size = 3;
378             enb.choice.macro_eNB_ID.bits_unused = 4;
379
380             enb.present = ENB_ID_PR_macro_eNB_ID;
381
382             enb.choice.macro_eNB_ID.buf = (uint8_t *) calloc(1, enb.choice.macro_eNB_ID.size);
383             data[enb.choice.macro_eNB_ID.size - 1] = ((unsigned) (data[enb.choice.macro_eNB_ID.size - 1]
384                     >> (unsigned) enb.choice.macro_eNB_ID.bits_unused)
385                     << (unsigned) enb.choice.macro_eNB_ID.bits_unused);
386             memcpy(enb.choice.macro_eNB_ID.buf, data, enb.choice.macro_eNB_ID.size);
387
388             break;
389         }
390         case ENB_ID_PR_home_eNB_ID: { // 28 bit 4 bytes
391             enb.choice.home_eNB_ID.size = 4;
392             enb.choice.home_eNB_ID.bits_unused = 4;
393             enb.present = ENB_ID_PR_home_eNB_ID;
394
395             enb.choice.home_eNB_ID.buf = (uint8_t *) calloc(1, enb.choice.home_eNB_ID.size);
396             data[enb.choice.home_eNB_ID.size - 1] = ((unsigned) (data[enb.choice.home_eNB_ID.size - 1]
397                     >> (unsigned) enb.choice.home_eNB_ID.bits_unused)
398                     << (unsigned) enb.choice.home_eNB_ID.bits_unused);
399             memcpy(enb.choice.home_eNB_ID.buf, data, enb.choice.home_eNB_ID.size);
400             break;
401         }
402         case ENB_ID_PR_short_Macro_eNB_ID: { // 18 bit - 3 bytes
403             enb.choice.short_Macro_eNB_ID.size = 3;
404             enb.choice.short_Macro_eNB_ID.bits_unused = 6;
405             enb.present = ENB_ID_PR_short_Macro_eNB_ID;
406
407             enb.choice.short_Macro_eNB_ID.buf = (uint8_t *) calloc(1, enb.choice.short_Macro_eNB_ID.size);
408             data[enb.choice.short_Macro_eNB_ID.size - 1] = ((unsigned) (data[enb.choice.short_Macro_eNB_ID.size - 1]
409                     >> (unsigned) enb.choice.short_Macro_eNB_ID.bits_unused)
410                     << (unsigned) enb.choice.short_Macro_eNB_ID.bits_unused);
411             memcpy(enb.choice.short_Macro_eNB_ID.buf, data, enb.choice.short_Macro_eNB_ID.size);
412             break;
413         }
414         case ENB_ID_PR_long_Macro_eNB_ID: { // 21
415             enb.choice.long_Macro_eNB_ID.size = 3;
416             enb.choice.long_Macro_eNB_ID.bits_unused = 3;
417             enb.present = ENB_ID_PR_long_Macro_eNB_ID;
418
419             enb.choice.long_Macro_eNB_ID.buf = (uint8_t *) calloc(1, enb.choice.long_Macro_eNB_ID.size);
420             data[enb.choice.long_Macro_eNB_ID.size - 1] = ((unsigned) (data[enb.choice.long_Macro_eNB_ID.size - 1]
421                     >> (unsigned) enb.choice.long_Macro_eNB_ID.bits_unused)
422                     << (unsigned) enb.choice.long_Macro_eNB_ID.bits_unused);
423             memcpy(enb.choice.long_Macro_eNB_ID.buf, data, enb.choice.long_Macro_eNB_ID.size);
424             break;
425         }
426         default:
427             break;
428     }
429
430     checkAndPrint(&asn_DEF_ENB_ID, &enb, (char *) "ENB_ID_t", __func__);
431 }
432
433
434 static void buildGlobalENB_ID(GlobalENB_ID_t *gnbId,
435                               const unsigned char *gnbData,
436                               ENB_ID_PR enbType,
437                               unsigned char *enbData) {
438     auto *plmnID = createPLMN_ID(gnbData);
439     memcpy(&gnbId->pLMN_Identity, plmnID, sizeof(PLMN_Identity_t));
440     createENB_ID(gnbId->eNB_ID, enbType, enbData);
441     checkAndPrint(&asn_DEF_GlobalENB_ID, gnbId, (char *) "GlobalENB_ID_t", __func__);
442 }
443
444
445 void buildSetupRequest(E2AP_PDU_t *pdu, int mcc, int mnc) {
446     ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu);
447
448     pdu->choice.initiatingMessage = (InitiatingMessage_t *)calloc(1, sizeof(InitiatingMessage_t));
449     auto *initiatingMessage = pdu->choice.initiatingMessage;
450     ASN_STRUCT_RESET(asn_DEF_InitiatingMessage, initiatingMessage);
451     initiatingMessage->procedureCode = ProcedureCode_id_E2setup;
452     initiatingMessage->criticality = Criticality_reject;
453     initiatingMessage->value.present = InitiatingMessage__value_PR_E2setupRequest;
454
455     auto *e2SetupRequestIEs = (E2setupRequestIEs_t *)calloc(1, sizeof(E2setupRequestIEs_t));
456     ASN_STRUCT_RESET(asn_DEF_E2setupRequestIEs, e2SetupRequestIEs);
457
458     e2SetupRequestIEs->value.choice.GlobalE2node_ID.present = GlobalE2node_ID_PR_gNB;
459     e2SetupRequestIEs->value.choice.GlobalE2node_ID.choice.gNB = (GlobalE2node_gNB_ID_t *)calloc(1, sizeof(GlobalE2node_gNB_ID_t));
460     auto *globalE2NodeGNbId = e2SetupRequestIEs->value.choice.GlobalE2node_ID.choice.gNB;
461     ASN_STRUCT_RESET(asn_DEF_GlobalE2node_gNB_ID, globalE2NodeGNbId);
462
463     createPLMN_IDByMCCandMNC(&globalE2NodeGNbId->global_gNB_ID.plmn_id, mcc, mnc);
464     globalE2NodeGNbId->global_gNB_ID.gnb_id.present = GNB_ID_Choice_PR_gnb_ID;
465     globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size = 4;
466     globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf =
467             (uint8_t *) calloc(1, globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size); //22..32 bits
468     globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.bits_unused = 0;
469     globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf[0] = 0xB5;
470     globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf[1] = 0xC6;
471     globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf[2] = 0x77;
472     globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf[3] = 0x88;
473
474     e2SetupRequestIEs->criticality = Criticality_reject;
475     e2SetupRequestIEs->id = ProtocolIE_ID_id_GlobalE2node_ID;
476     e2SetupRequestIEs->value.present = E2setupRequestIEs__value_PR_GlobalE2node_ID;
477
478
479     auto *e2SetupRequest = &initiatingMessage->value.choice.E2setupRequest;
480
481     ASN_STRUCT_RESET(asn_DEF_E2setupRequest, e2SetupRequest);
482     ASN_SEQUENCE_ADD(&e2SetupRequest->protocolIEs.list, e2SetupRequestIEs);
483
484     pdu->present = E2AP_PDU_PR_initiatingMessage;
485 }
486
487 void buildSetupRequesteenGNB(E2AP_PDU_t *pdu, int mcc, int mnc) {
488     ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu);
489
490     pdu->choice.initiatingMessage = (InitiatingMessage_t *)calloc(1, sizeof(InitiatingMessage_t));
491     auto *initiatingMessage = pdu->choice.initiatingMessage;
492     ASN_STRUCT_RESET(asn_DEF_InitiatingMessage, initiatingMessage);
493     initiatingMessage->procedureCode = ProcedureCode_id_E2setup;
494     initiatingMessage->criticality = Criticality_reject;
495     initiatingMessage->value.present = InitiatingMessage__value_PR_E2setupRequest;
496
497     auto *e2SetupRequestIEs = (E2setupRequestIEs_t *)calloc(1, sizeof(E2setupRequestIEs_t));
498     ASN_STRUCT_RESET(asn_DEF_E2setupRequestIEs, e2SetupRequestIEs);
499
500     e2SetupRequestIEs->value.choice.GlobalE2node_ID.present = GlobalE2node_ID_PR_en_gNB;
501     e2SetupRequestIEs->value.choice.GlobalE2node_ID.choice.en_gNB = (GlobalE2node_en_gNB_ID_t *)calloc(1, sizeof(GlobalE2node_en_gNB_ID_t));
502     auto *globalE2NodeEN_GNb = e2SetupRequestIEs->value.choice.GlobalE2node_ID.choice.en_gNB;
503     ASN_STRUCT_RESET(asn_DEF_GlobalE2node_en_gNB_ID, globalE2NodeEN_GNb);
504
505     globalE2NodeEN_GNb->global_gNB_ID.gNB_ID.present = ENGNB_ID_PR_gNB_ID;
506     createPLMN_IDByMCCandMNC(&globalE2NodeEN_GNb->global_gNB_ID.pLMN_Identity, mcc, mnc);
507     globalE2NodeEN_GNb->global_gNB_ID.gNB_ID.choice.gNB_ID.size = 4;
508     globalE2NodeEN_GNb->global_gNB_ID.gNB_ID.choice.gNB_ID.buf =
509             (uint8_t *) calloc(1, globalE2NodeEN_GNb->global_gNB_ID.gNB_ID.choice.gNB_ID.size); //22..32 bits
510     globalE2NodeEN_GNb->global_gNB_ID.gNB_ID.choice.gNB_ID.buf[0] = 0xC5;
511     globalE2NodeEN_GNb->global_gNB_ID.gNB_ID.choice.gNB_ID.buf[1] = 0xC6;
512     globalE2NodeEN_GNb->global_gNB_ID.gNB_ID.choice.gNB_ID.buf[2] = 0xC7;
513     globalE2NodeEN_GNb->global_gNB_ID.gNB_ID.choice.gNB_ID.buf[3] = 0xF8;
514     globalE2NodeEN_GNb->global_gNB_ID.gNB_ID.choice.gNB_ID.bits_unused = 0;
515     e2SetupRequestIEs->criticality = Criticality_reject;
516     e2SetupRequestIEs->id = ProtocolIE_ID_id_GlobalE2node_ID;
517     e2SetupRequestIEs->value.present = E2setupRequestIEs__value_PR_GlobalE2node_ID;
518
519
520     auto *e2SetupRequest = &initiatingMessage->value.choice.E2setupRequest;
521
522     ASN_STRUCT_RESET(asn_DEF_E2setupRequest, e2SetupRequest);
523     ASN_SEQUENCE_ADD(&e2SetupRequest->protocolIEs.list, e2SetupRequestIEs);
524
525     pdu->present = E2AP_PDU_PR_initiatingMessage;
526 }
527
528
529
530 void buildSetupRequestWithFunc(E2AP_PDU_t *pdu, int mcc, int mnc) {
531     ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu);
532
533     pdu->choice.initiatingMessage = (InitiatingMessage_t *)calloc(1, sizeof(InitiatingMessage_t));
534     auto *initiatingMessage = pdu->choice.initiatingMessage;
535     ASN_STRUCT_RESET(asn_DEF_InitiatingMessage, initiatingMessage);
536     initiatingMessage->procedureCode = ProcedureCode_id_E2setup;
537     initiatingMessage->criticality = Criticality_reject;
538     initiatingMessage->value.present = InitiatingMessage__value_PR_E2setupRequest;
539
540     auto *e2SetupRequestIEs = (E2setupRequestIEs_t *)calloc(1, sizeof(E2setupRequestIEs_t));
541     ASN_STRUCT_RESET(asn_DEF_E2setupRequestIEs, e2SetupRequestIEs);
542
543     e2SetupRequestIEs->value.choice.GlobalE2node_ID.choice.gNB = (GlobalE2node_gNB_ID_t *)calloc(1, sizeof(GlobalE2node_gNB_ID_t));
544     auto *globalE2NodeGNbId = e2SetupRequestIEs->value.choice.GlobalE2node_ID.choice.gNB;
545     ASN_STRUCT_RESET(asn_DEF_GlobalE2node_gNB_ID, globalE2NodeGNbId);
546
547     createPLMN_IDByMCCandMNC(&globalE2NodeGNbId->global_gNB_ID.plmn_id, mcc, mnc);
548     globalE2NodeGNbId->global_gNB_ID.gnb_id.present = GNB_ID_Choice_PR_gnb_ID;
549     globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size = 4;
550     globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf =
551             (uint8_t *) calloc(1, globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size); //22..32 bits
552     globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.bits_unused = 0;
553     globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf[0] = 0xB5;
554     globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf[1] = 0xC6;
555     globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf[2] = 0x77;
556     globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf[3] = 0x88;
557
558     e2SetupRequestIEs->criticality = Criticality_reject;
559     e2SetupRequestIEs->id = ProtocolIE_ID_id_GlobalE2node_ID;
560     e2SetupRequestIEs->value.present = E2setupRequestIEs__value_PR_GlobalE2node_ID;
561     e2SetupRequestIEs->value.choice.GlobalE2node_ID.present = GlobalE2node_ID_PR_gNB;
562
563
564     auto *e2SetupRequest = &initiatingMessage->value.choice.E2setupRequest;
565
566     ASN_STRUCT_RESET(asn_DEF_E2setupRequest, e2SetupRequest);
567     ASN_SEQUENCE_ADD(&e2SetupRequest->protocolIEs.list, e2SetupRequestIEs);
568
569     auto *ranFlistIEs = (E2setupRequestIEs_t *)calloc(1, sizeof(E2setupRequestIEs_t));
570     ASN_STRUCT_RESET(asn_DEF_E2setupRequestIEs, ranFlistIEs);
571     ranFlistIEs->criticality = Criticality_reject;
572     ranFlistIEs->id = ProtocolIE_ID_id_RANfunctionsAdded;
573     ranFlistIEs->value.present = E2setupRequestIEs__value_PR_RANfunctions_List;
574
575
576
577     E2SM_gNB_NRT_RANfunction_Definition_t ranFunDef;
578     uint8_t funcDes[] = "asdfghjklpoiuytrewq\0";
579     ranFunDef.ranFunction_Name.ranFunction_Description.buf = (uint8_t *)calloc(1, strlen((char *)funcDes));
580     ranFunDef.ranFunction_Name.ranFunction_Description.size = strlen((char *)funcDes);
581     memcpy(ranFunDef.ranFunction_Name.ranFunction_Description.buf, funcDes, strlen((char *)funcDes));
582
583     uint8_t funcOID[] = "ABCDEFGHIJ1234567890\0";
584     ranFunDef.ranFunction_Name.ranFunction_E2SM_OID.buf = (uint8_t *)calloc(1, strlen((char *)funcOID));
585     ranFunDef.ranFunction_Name.ranFunction_E2SM_OID.size = strlen((char *)funcOID);
586     memcpy(ranFunDef.ranFunction_Name.ranFunction_E2SM_OID.buf, funcOID, strlen((char *)funcOID));
587
588     uint8_t shortName[] = "Nothing to declare\0";
589     ranFunDef.ranFunction_Name.ranFunction_ShortName.buf = (uint8_t *)calloc(1, strlen((char *)shortName));
590     ranFunDef.ranFunction_Name.ranFunction_ShortName.size = strlen((char *)shortName);
591     memcpy(ranFunDef.ranFunction_Name.ranFunction_ShortName.buf, shortName, strlen((char *)shortName));
592
593
594     RIC_InsertStyle_List_t insertStyleList;
595     insertStyleList.ric_CallProcessIDFormat_Type = 28l;
596     insertStyleList.ric_IndicationHeaderFormat_Type = 29;
597     insertStyleList.ric_IndicationMessageFormat_Type = 30;
598     insertStyleList.ric_InsertActionFormat_Type = 31l;
599
600     uint8_t styleName[] = "What a style\0";
601
602     insertStyleList.ric_InsertStyle_Name.buf = (uint8_t *)calloc(1, strlen((char *)styleName));
603     insertStyleList.ric_InsertStyle_Name.size = strlen((char *)styleName);
604     memcpy(insertStyleList.ric_InsertStyle_Name.buf, styleName, strlen((char *)styleName));
605
606
607     insertStyleList.ric_InsertStyle_Type = 23;
608
609     RANparameterDef_Item_t raNparameterDefItem;
610     raNparameterDefItem.ranParameter_ID = 8;
611     raNparameterDefItem.ranParameter_Type = 12;
612
613     uint8_t ItemName[] = "What a style\0";
614     raNparameterDefItem.ranParameter_Name.buf = (uint8_t *)calloc(1, strlen((char *)ItemName));
615     raNparameterDefItem.ranParameter_Name.size = strlen((char *)ItemName);
616     memcpy(raNparameterDefItem.ranParameter_Name.buf, ItemName, strlen((char *)ItemName));
617
618     ASN_SEQUENCE_ADD(&insertStyleList.ric_InsertRanParameterDef_List.list, &raNparameterDefItem);
619
620     ASN_SEQUENCE_ADD(&ranFunDef.ric_InsertStyle_List->list, &insertStyleList);
621     //ranFunDef.ric_InsertStyle_List.
622
623     auto *itemIes = (RANfunction_ItemIEs_t *)calloc(1, sizeof(RANfunction_ItemIEs_t));
624     ASN_STRUCT_RESET(asn_DEF_RANfunction_ItemIEs, itemIes);
625
626     uint8_t buffer[8192];
627     size_t buffer_size = 8192;
628     auto *ranDef = &itemIes->value.choice.RANfunction_Item.ranFunctionDefinition;
629
630     auto er = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_NRT_RANfunction_Definition, &ranFunDef, buffer, buffer_size);
631     if (er.encoded == -1) {
632         cerr << "encoding of " << asn_DEF_E2SM_gNB_NRT_RANfunction_Definition.name << " failed, " << strerror(errno) << endl;
633         exit(-1);
634     } else if (er.encoded > (ssize_t) buffer_size) {
635         cerr << "Buffer of size " << buffer_size << " is to small for " << asn_DEF_E2SM_gNB_NRT_RANfunction_Definition.name << endl;
636         exit(-1);
637     } else {
638         ranDef->buf = (uint8_t *)calloc(1, er.encoded);
639         ranDef->size = er.encoded;
640         memcpy(ranDef->buf, buffer, ranDef->size);
641     }
642
643     itemIes->id = ProtocolIE_ID_id_RANfunction_Item;
644     itemIes->criticality = Criticality_reject;
645     itemIes->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item;
646     itemIes->value.choice.RANfunction_Item.ranFunctionID = 1;
647 //    auto *ranDef = &itemIes->value.choice.RANfunction_Item.ranFunctionDefinition;
648 //    ranDef->size = 3;
649 //    ranDef->buf = (uint8_t *)calloc(1, ranDef->size);
650 //    memcpy(ranDef->buf, buf, ranDef->size);
651
652     ASN_SEQUENCE_ADD(&ranFlistIEs->value.choice.RANfunctions_List.list, itemIes);
653
654     auto *itemIes1 = (RANfunction_ItemIEs_t *)calloc(1, sizeof(RANfunction_ItemIEs_t));
655     ASN_STRUCT_RESET(asn_DEF_RANfunction_ItemIEs, itemIes1);
656     itemIes1->id = ProtocolIE_ID_id_RANfunction_Item;
657     itemIes1->criticality = Criticality_reject;
658     itemIes1->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item;
659     itemIes1->value.choice.RANfunction_Item.ranFunctionID = 7;
660     ranDef = &itemIes1->value.choice.RANfunction_Item.ranFunctionDefinition;
661
662     ranDef->buf = (uint8_t *)calloc(1, er.encoded);
663     ranDef->size = er.encoded;
664     memcpy(ranDef->buf, buffer, ranDef->size);
665
666     ASN_SEQUENCE_ADD(&ranFlistIEs->value.choice.RANfunctions_List.list, itemIes1);
667
668
669     ASN_SEQUENCE_ADD(&e2SetupRequest->protocolIEs.list, ranFlistIEs);
670
671     pdu->present = E2AP_PDU_PR_initiatingMessage;
672 }
673
674
675 void buildSubsReq(E2AP_PDU_t *pdu) {
676     ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu);
677
678     pdu->choice.initiatingMessage = (InitiatingMessage_t *)calloc(1, sizeof(InitiatingMessage_t));
679     pdu->present = E2AP_PDU_PR_initiatingMessage;
680
681     auto *initMsg = pdu->choice.initiatingMessage;
682     ASN_STRUCT_RESET(asn_DEF_InitiatingMessage, initMsg);
683     initMsg->procedureCode = ProcedureCode_id_RICsubscription;
684     initMsg->criticality = Criticality_reject;
685     initMsg->value.present = InitiatingMessage__value_PR_RICsubscriptionRequest;
686
687     auto *subReq = &(initMsg->value.choice.RICsubscriptionRequest);
688     ASN_STRUCT_RESET(asn_DEF_RICsubscriptionRequest, subReq);
689
690     { // RICrequestID
691         auto *e = (RICsubscriptionRequest_IEs_t *)calloc(1, sizeof(RICsubscriptionRequest_IEs_t));
692         ASN_STRUCT_RESET(asn_DEF_RICsubscriptionRequest_IEs, e);
693         e->id = ProtocolIE_ID_id_RICrequestID;
694         e->value.present = RICsubscriptionRequest_IEs__value_PR_RICrequestID;
695         e->value.choice.RICrequestID.ricRequestorID = 88;
696         e->value.choice.RICrequestID.ricInstanceID = 5;
697         ASN_SEQUENCE_ADD(&subReq->protocolIEs.list, e);
698     }
699     { // RANfunctionID
700         auto *e = (RICsubscriptionRequest_IEs_t *)calloc(1, sizeof(RICsubscriptionRequest_IEs_t));
701         ASN_STRUCT_RESET(asn_DEF_RICsubscriptionRequest_IEs, e);
702         e->id = ProtocolIE_ID_id_RANfunctionID;
703         e->criticality = Criticality_reject;
704         e->value.present = RICsubscriptionRequest_IEs__value_PR_RANfunctionID;
705         e->value.choice.RANfunctionID = 8;
706         ASN_SEQUENCE_ADD(&subReq->protocolIEs.list, e);
707     }
708     { // RICrequestID
709         auto *e = (RICsubscriptionRequest_IEs_t *)calloc(1, sizeof(RICsubscriptionRequest_IEs_t));
710         ASN_STRUCT_RESET(asn_DEF_RICsubscriptionRequest_IEs, e);
711         e->id = ProtocolIE_ID_id_RICsubscriptionDetails;
712         e->criticality = Criticality_reject;
713         e->value.present = RICsubscriptionRequest_IEs__value_PR_RICsubscriptionDetails;
714
715         uint8_t buf[10] = {1,2,3,4,5,6,7,8,9,0} ;
716         e->value.choice.RICsubscriptionDetails.ricEventTriggerDefinition.size = 10;
717         e->value.choice.RICsubscriptionDetails.ricEventTriggerDefinition.buf = (uint8_t *)calloc(1, 10);
718         memcpy(e->value.choice.RICsubscriptionDetails.ricEventTriggerDefinition.buf,
719                 buf,
720                 e->value.choice.RICsubscriptionDetails.ricEventTriggerDefinition.size);
721         { // item 1
722             auto ie = (RICaction_ToBeSetup_ItemIEs_t *)calloc(1, sizeof(RICaction_ToBeSetup_ItemIEs_t));
723             ASN_STRUCT_RESET(asn_DEF_RICaction_ToBeSetup_ItemIEs, ie);
724             ie->id = ProtocolIE_ID_id_RICaction_ToBeSetup_Item;
725             ie->criticality = Criticality_ignore;
726             ie->value.present = RICaction_ToBeSetup_ItemIEs__value_PR_RICaction_ToBeSetup_Item;
727             ie->value.choice.RICaction_ToBeSetup_Item.ricActionID = 22;
728             ie->value.choice.RICaction_ToBeSetup_Item.ricActionType = RICactionType_report;
729
730             auto *ad = (RICactionDefinition_t *)calloc(1, sizeof(RICactionDefinition_t));
731             ASN_STRUCT_RESET(asn_DEF_RICactionDefinition, ad);
732             ad->size = 10;
733             uint8_t buf[10] = {1,2,3,4,5,6,7,8,9,0} ;
734             ad->buf = (uint8_t *)calloc(1, ad->size);
735             memcpy(ad->buf, buf, ad->size);
736             ie->value.choice.RICaction_ToBeSetup_Item.ricActionDefinition = ad;
737
738             auto *sa = (RICsubsequentAction_t *) calloc(1, sizeof(RICsubsequentAction_t));
739             ASN_STRUCT_RESET(asn_DEF_RICsubsequentAction, sa);
740
741             sa->ricTimeToWait = RICtimeToWait_w500ms;
742             sa->ricSubsequentActionType = RICsubsequentActionType_continue;
743
744             ie->value.choice.RICaction_ToBeSetup_Item.ricSubsequentAction = sa;
745             ASN_SEQUENCE_ADD(&e->value.choice.RICsubscriptionDetails.ricAction_ToBeSetup_List.list, ie);
746         }
747
748         { // item 2
749             auto ie = (RICaction_ToBeSetup_ItemIEs_t *)calloc(1, sizeof(RICaction_ToBeSetup_ItemIEs_t));
750             ASN_STRUCT_RESET(asn_DEF_RICaction_ToBeSetup_ItemIEs, ie);
751             ie->id = ProtocolIE_ID_id_RICaction_ToBeSetup_Item;
752             ie->criticality = Criticality_ignore;
753             ie->value.present = RICaction_ToBeSetup_ItemIEs__value_PR_RICaction_ToBeSetup_Item;
754             ie->value.choice.RICaction_ToBeSetup_Item.ricActionID = 47;
755             ie->value.choice.RICaction_ToBeSetup_Item.ricActionType = RICactionType_policy;
756
757             auto *ad = (RICactionDefinition_t *)calloc(1, sizeof(RICactionDefinition_t));
758             ASN_STRUCT_RESET(asn_DEF_RICactionDefinition, ad);
759             ad->size = 10;
760             uint8_t buf[10] = {1,2,3,4,5,6,7,8,9,0} ;
761             ad->buf = (uint8_t *)calloc(1, ad->size);
762             memcpy(ad->buf, buf, ad->size);
763             ie->value.choice.RICaction_ToBeSetup_Item.ricActionDefinition = ad;
764
765             auto *sa = (RICsubsequentAction_t *) calloc(1, sizeof(RICsubsequentAction_t));
766             ASN_STRUCT_RESET(asn_DEF_RICsubsequentAction, sa);
767
768             sa->ricTimeToWait = RICtimeToWait_w5s;
769             sa->ricSubsequentActionType = RICsubsequentActionType_wait;
770
771             ie->value.choice.RICaction_ToBeSetup_Item.ricSubsequentAction = sa;
772             ASN_SEQUENCE_ADD(&e->value.choice.RICsubscriptionDetails.ricAction_ToBeSetup_List.list, ie);
773         }
774
775         ASN_SEQUENCE_ADD(&subReq->protocolIEs.list, e);
776     }
777 }
778
779
780 void buildSetupSuccsessfulResponse(E2AP_PDU_t *pdu, int mcc, int mnc, uint8_t *data) {
781     ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu);
782
783     pdu->choice.successfulOutcome = (SuccessfulOutcome_t *)calloc(1, sizeof(SuccessfulOutcome_t));
784     SuccessfulOutcome_t *successfulOutcome = pdu->choice.successfulOutcome;
785     ASN_STRUCT_RESET(asn_DEF_E2setupResponse, &successfulOutcome->value.choice.E2setupResponse);
786     successfulOutcome->procedureCode = ProcedureCode_id_E2setup;
787     successfulOutcome->criticality = Criticality_reject;
788     successfulOutcome->value.present = SuccessfulOutcome__value_PR_E2setupResponse;
789
790
791     auto *globalRicidIE = (E2setupResponseIEs_t *)calloc(1, sizeof(E2setupResponseIEs_t));
792     ASN_STRUCT_RESET(asn_DEF_E2setupResponseIEs, globalRicidIE);
793
794     globalRicidIE->criticality = Criticality_reject;
795     globalRicidIE->id = ProtocolIE_ID_id_GlobalRIC_ID;
796     globalRicidIE->value.present = E2setupResponseIEs__value_PR_GlobalRIC_ID;
797     createPLMN_IDByMCCandMNC(&globalRicidIE->value.choice.GlobalRIC_ID.pLMN_Identity, mcc, mnc);
798
799     globalRicidIE->value.choice.GlobalRIC_ID.ric_ID = {nullptr, 3, 4};
800     globalRicidIE->value.choice.GlobalRIC_ID.ric_ID.buf = (uint8_t *)calloc(1, globalRicidIE->value.choice.GlobalRIC_ID.ric_ID.size);
801     memcpy(globalRicidIE->value.choice.GlobalRIC_ID.ric_ID.buf, data, globalRicidIE->value.choice.GlobalRIC_ID.ric_ID.size);
802     globalRicidIE->value.choice.GlobalRIC_ID.ric_ID.buf[2] &= (unsigned)0xF0;
803
804
805     ASN_STRUCT_RESET(asn_DEF_E2setupResponse, &successfulOutcome->value.choice.E2setupResponse);
806     ASN_SEQUENCE_ADD(&successfulOutcome->value.choice.E2setupResponse.protocolIEs.list, globalRicidIE);
807
808     auto *ranFunctionAdd = (E2setupResponseIEs_t *)calloc(1, sizeof(E2setupResponseIEs_t));
809     ASN_STRUCT_RESET(asn_DEF_E2setupResponseIEs, ranFunctionAdd);
810     ranFunctionAdd->criticality = Criticality_reject;
811     ranFunctionAdd->id = ProtocolIE_ID_id_RANfunctionsAccepted;
812     ranFunctionAdd->value.present = E2setupResponseIEs__value_PR_RANfunctionsID_List;
813
814     auto *ranFuncIdItemIEs = (RANfunctionID_ItemIEs_t *)calloc(1, sizeof(RANfunctionID_ItemIEs_t));
815
816     ranFuncIdItemIEs->criticality = Criticality_ignore;
817     ranFuncIdItemIEs->id = ProtocolIE_ID_id_RANfunctionID_Item;
818     ranFuncIdItemIEs->value.present = RANfunctionID_ItemIEs__value_PR_RANfunctionID_Item;
819     ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionID = 10;
820     ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionRevision = 1;
821
822     ASN_SEQUENCE_ADD(&ranFunctionAdd->value.choice.RANfunctionsID_List.list, ranFuncIdItemIEs);
823     ASN_SEQUENCE_ADD(&successfulOutcome->value.choice.E2setupResponse.protocolIEs.list, ranFunctionAdd);
824
825
826
827
828
829     pdu->present = E2AP_PDU_PR_successfulOutcome;
830 }
831
832
833 void buildSetupUnSuccsessfulResponse(E2AP_PDU_t *pdu) {
834     ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu);
835
836     pdu->choice.unsuccessfulOutcome = (UnsuccessfulOutcome_t *)calloc(1, sizeof(UnsuccessfulOutcome_t));
837     UnsuccessfulOutcome_t *uns = pdu->choice.unsuccessfulOutcome;
838     uns->procedureCode = ProcedureCode_id_E2setup;
839     uns->criticality = Criticality_reject;
840     uns->value.present = UnsuccessfulOutcome__value_PR_E2setupFailure;
841
842     ASN_STRUCT_RESET(asn_DEF_E2setupFailure, &uns->value.choice.E2setupFailure);
843
844
845     {
846         auto *e2SetupFIE = (E2setupFailureIEs_t *) calloc(1, sizeof(E2setupFailureIEs_t));
847         ASN_STRUCT_RESET(asn_DEF_E2setupFailureIEs, e2SetupFIE);
848
849         e2SetupFIE->criticality = Criticality_ignore;
850         e2SetupFIE->id = ProtocolIE_ID_id_Cause;
851         e2SetupFIE->value.present = E2setupFailureIEs__value_PR_Cause;
852         e2SetupFIE->value.choice.Cause.present = Cause_PR_transport;
853         e2SetupFIE->value.choice.Cause.choice.transport = CauseTransport_transport_resource_unavailable;
854
855
856         ASN_SEQUENCE_ADD(&uns->value.choice.E2setupFailure.protocolIEs.list, e2SetupFIE);
857     }
858
859     {
860         auto *e2SetupFIE = (E2setupFailureIEs_t *) calloc(1, sizeof(E2setupFailureIEs_t));
861         ASN_STRUCT_RESET(asn_DEF_E2setupFailureIEs, e2SetupFIE);
862
863         e2SetupFIE->criticality = Criticality_ignore;
864         e2SetupFIE->id = ProtocolIE_ID_id_TimeToWait;
865         e2SetupFIE->value.present = E2setupFailureIEs__value_PR_TimeToWait;
866         e2SetupFIE->value.choice.TimeToWait = TimeToWait_v60s;
867
868         ASN_SEQUENCE_ADD(&uns->value.choice.E2setupFailure.protocolIEs.list, e2SetupFIE);
869     }
870     {
871         auto *e2SetupFIE = (E2setupFailureIEs_t *) calloc(1, sizeof(E2setupFailureIEs_t));
872         ASN_STRUCT_RESET(asn_DEF_E2setupFailureIEs, e2SetupFIE);
873
874         e2SetupFIE->criticality = Criticality_ignore;
875         e2SetupFIE->id = ProtocolIE_ID_id_CriticalityDiagnostics;
876         e2SetupFIE->value.present = E2setupFailureIEs__value_PR_CriticalityDiagnostics;
877         e2SetupFIE->value.choice.CriticalityDiagnostics.procedureCode = (ProcedureCode_t *)calloc(1,sizeof(ProcedureCode_t));
878         *e2SetupFIE->value.choice.CriticalityDiagnostics.procedureCode = ProcedureCode_id_E2setup;
879         e2SetupFIE->value.choice.CriticalityDiagnostics.triggeringMessage = (TriggeringMessage_t *)calloc(1,sizeof(TriggeringMessage_t));
880         *e2SetupFIE->value.choice.CriticalityDiagnostics.triggeringMessage = TriggeringMessage_initiating_message;
881         e2SetupFIE->value.choice.CriticalityDiagnostics.procedureCriticality = (Criticality_t *)calloc(1, sizeof(Criticality_t));
882         *e2SetupFIE->value.choice.CriticalityDiagnostics.procedureCriticality = Criticality_reject;
883         ASN_SEQUENCE_ADD(&uns->value.choice.E2setupFailure.protocolIEs.list, e2SetupFIE);
884     }
885
886     pdu->present = E2AP_PDU_PR_unsuccessfulOutcome;
887 }
888
889 void buildResetReq(E2AP_PDU_t *pdu) {
890     ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu);
891
892     pdu->choice.initiatingMessage = (InitiatingMessage_t *)calloc(1, sizeof(InitiatingMessage_t));
893     pdu->present = E2AP_PDU_PR_initiatingMessage;
894
895     auto *initMsg = pdu->choice.initiatingMessage;
896     ASN_STRUCT_RESET(asn_DEF_InitiatingMessage, initMsg);
897     initMsg->procedureCode = ProcedureCode_id_Reset;
898     initMsg->criticality = Criticality_reject;
899     initMsg->value.present = InitiatingMessage__value_PR_ResetRequest;
900
901
902     auto *resetReq = &(initMsg->value.choice.ResetRequest);
903     ASN_STRUCT_RESET(asn_DEF_ResetRequest, resetReq);
904
905     { //
906         auto *e = (ResetRequestIEs_t *)calloc(1, sizeof(ResetRequestIEs_t));
907         ASN_STRUCT_RESET(asn_DEF_ResetRequestIEs, e);
908         e->id = ProtocolIE_ID_id_Cause;
909         e->criticality = Criticality_ignore;
910         e->value.present = ResetRequestIEs__value_PR_Cause;
911         e->value.choice.Cause.present = Cause_PR_ricRequest;
912         e->value.choice.Cause.choice.ricRequest = 1;
913         ASN_SEQUENCE_ADD(&resetReq->protocolIEs.list, e);
914     }
915
916 }
917
918 void buildResetResponse(E2AP_PDU_t *pdu) {
919     ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu);
920
921     pdu->choice.successfulOutcome = (SuccessfulOutcome_t *)calloc(1, sizeof(SuccessfulOutcome_t));
922     pdu->present = E2AP_PDU_PR_successfulOutcome;
923
924     auto *succ = pdu->choice.successfulOutcome;
925     ASN_STRUCT_RESET(asn_DEF_InitiatingMessage, succ);
926     succ->procedureCode = ProcedureCode_id_Reset;
927     succ->criticality = Criticality_reject;
928     succ->value.present = SuccessfulOutcome__value_PR_ResetResponse;
929
930
931     auto *resetRespo = &(succ->value.choice.ResetResponse);
932     ASN_STRUCT_RESET(asn_DEF_ResetResponse, resetRespo);
933
934     { //
935         auto *e = (ResetResponseIEs_t *)calloc(1, sizeof(ResetResponseIEs_t));
936         ASN_STRUCT_RESET(asn_DEF_ResetResponseIEs, e);
937         e->id = ProtocolIE_ID_id_CriticalityDiagnostics;
938         e->criticality = Criticality_ignore;
939         e->value.present = ResetResponseIEs__value_PR_CriticalityDiagnostics;
940
941         e->value.choice.CriticalityDiagnostics.procedureCode = (ProcedureCode_t *)calloc(1,sizeof(ProcedureCode_t));
942         *e->value.choice.CriticalityDiagnostics.procedureCode = ProcedureCode_id_Reset;
943         e->value.choice.CriticalityDiagnostics.triggeringMessage = (TriggeringMessage_t *)calloc(1,sizeof(TriggeringMessage_t));
944         *e->value.choice.CriticalityDiagnostics.triggeringMessage = TriggeringMessage_initiating_message;
945         e->value.choice.CriticalityDiagnostics.procedureCriticality = (Criticality_t *)calloc(1, sizeof(Criticality_t));
946         *e->value.choice.CriticalityDiagnostics.procedureCriticality = Criticality_reject;
947         ASN_SEQUENCE_ADD(&resetRespo->protocolIEs.list, e);
948     }
949
950 }
951
952 void buildServiceQuery(E2AP_PDU_t *pdu) {
953     ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu);
954
955     pdu->choice.initiatingMessage = (InitiatingMessage_t *)calloc(1, sizeof(InitiatingMessage_t));
956     pdu->present = E2AP_PDU_PR_initiatingMessage;
957
958     auto *initMsg = pdu->choice.initiatingMessage;
959     ASN_STRUCT_RESET(asn_DEF_InitiatingMessage, initMsg);
960     initMsg->procedureCode = ProcedureCode_id_RICserviceQuery;
961     initMsg->criticality = Criticality_ignore;
962     initMsg->value.present = InitiatingMessage__value_PR_RICserviceQuery;
963
964
965     auto *serviceQuery = &(initMsg->value.choice.RICserviceQuery);
966     ASN_STRUCT_RESET(asn_DEF_ResetRequest, serviceQuery);
967
968     { //
969         auto *e = (RICserviceQuery_IEs_t *)calloc(1, sizeof(RICserviceQuery_IEs_t));
970         ASN_STRUCT_RESET(asn_DEF_RICserviceQuery_IEs, e);
971         e->id = ProtocolIE_ID_id_RANfunctionsAccepted;
972         e->criticality = Criticality_reject;
973         e->value.present = RICserviceQuery_IEs__value_PR_RANfunctionsID_List;
974         {
975             auto *ranFuncIdItemIEs = (RANfunctionID_ItemIEs_t *)calloc(1, sizeof(RANfunctionID_ItemIEs_t));
976
977             ranFuncIdItemIEs->criticality = Criticality_ignore;
978             ranFuncIdItemIEs->id = ProtocolIE_ID_id_RANfunctionID_Item;
979             ranFuncIdItemIEs->value.present = RANfunctionID_ItemIEs__value_PR_RANfunctionID_Item;
980             ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionID = 10;
981             ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionRevision = 1;
982             ASN_SEQUENCE_ADD(&e->value.choice.RANfunctionsID_List.list, ranFuncIdItemIEs);
983         }
984         {
985             auto *ranFuncIdItemIEs = (RANfunctionID_ItemIEs_t *)calloc(1, sizeof(RANfunctionID_ItemIEs_t));
986
987             ranFuncIdItemIEs->criticality = Criticality_ignore;
988             ranFuncIdItemIEs->id = ProtocolIE_ID_id_RANfunctionID_Item;
989             ranFuncIdItemIEs->value.present = RANfunctionID_ItemIEs__value_PR_RANfunctionID_Item;
990             ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionID = 11;
991             ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionRevision = 2;
992             ASN_SEQUENCE_ADD(&e->value.choice.RANfunctionsID_List.list, ranFuncIdItemIEs);
993         }
994         {
995             auto *ranFuncIdItemIEs = (RANfunctionID_ItemIEs_t *)calloc(1, sizeof(RANfunctionID_ItemIEs_t));
996
997             ranFuncIdItemIEs->criticality = Criticality_ignore;
998             ranFuncIdItemIEs->id = ProtocolIE_ID_id_RANfunctionID_Item;
999             ranFuncIdItemIEs->value.present = RANfunctionID_ItemIEs__value_PR_RANfunctionID_Item;
1000             ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionID = 28;
1001             ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionRevision = 13;
1002             ASN_SEQUENCE_ADD(&e->value.choice.RANfunctionsID_List.list, ranFuncIdItemIEs);
1003         }
1004         {
1005             auto *ranFuncIdItemIEs = (RANfunctionID_ItemIEs_t *)calloc(1, sizeof(RANfunctionID_ItemIEs_t));
1006
1007             ranFuncIdItemIEs->criticality = Criticality_ignore;
1008             ranFuncIdItemIEs->id = ProtocolIE_ID_id_RANfunctionID_Item;
1009             ranFuncIdItemIEs->value.present = RANfunctionID_ItemIEs__value_PR_RANfunctionID_Item;
1010             ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionID = 1;
1011             ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionRevision = 4;
1012             ASN_SEQUENCE_ADD(&e->value.choice.RANfunctionsID_List.list, ranFuncIdItemIEs);
1013         }
1014         ASN_SEQUENCE_ADD(&serviceQuery->protocolIEs.list, e);
1015     }
1016
1017 }
1018 void buildServiceUpdateResponce(E2AP_PDU_t *pdu) {
1019     ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu);
1020
1021     pdu->choice.successfulOutcome = (SuccessfulOutcome_t *)calloc(1, sizeof(SuccessfulOutcome_t));
1022     pdu->present = E2AP_PDU_PR_successfulOutcome;
1023
1024     auto *succ = pdu->choice.successfulOutcome;
1025     ASN_STRUCT_RESET(asn_DEF_SuccessfulOutcome, succ);
1026     succ->procedureCode = ProcedureCode_id_RICserviceQuery;
1027     succ->criticality = Criticality_reject;
1028     succ->value.present = SuccessfulOutcome__value_PR_RICserviceUpdateAcknowledge;
1029
1030
1031     auto *serviceUpdAck = &(succ->value.choice.RICserviceUpdateAcknowledge);
1032     ASN_STRUCT_RESET(asn_DEF_RICserviceUpdateAcknowledge, serviceUpdAck);
1033
1034     { //
1035         auto *e = (RICserviceUpdateAcknowledge_IEs_t *)calloc(1, sizeof(RICserviceUpdateAcknowledge_IEs_t));
1036         ASN_STRUCT_RESET(asn_DEF_RICserviceUpdateAcknowledge_IEs, e);
1037         e->id = ProtocolIE_ID_id_RANfunctionsAccepted;
1038         e->criticality = Criticality_reject;
1039         e->value.present = RICserviceUpdateAcknowledge_IEs__value_PR_RANfunctionsID_List;
1040         {
1041             auto *ranFuncIdItemIEs = (RANfunctionID_ItemIEs_t *)calloc(1, sizeof(RANfunctionID_ItemIEs_t));
1042
1043             ranFuncIdItemIEs->criticality = Criticality_reject;
1044             ranFuncIdItemIEs->id = ProtocolIE_ID_id_RANfunctionID_Item;
1045             ranFuncIdItemIEs->value.present = RANfunctionID_ItemIEs__value_PR_RANfunctionID_Item;
1046             ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionID = 10;
1047             ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionRevision = 1;
1048             ASN_SEQUENCE_ADD(&e->value.choice.RANfunctionsID_List.list, ranFuncIdItemIEs);
1049         }
1050         {
1051             auto *ranFuncIdItemIEs = (RANfunctionID_ItemIEs_t *)calloc(1, sizeof(RANfunctionID_ItemIEs_t));
1052
1053             ranFuncIdItemIEs->criticality = Criticality_reject;
1054             ranFuncIdItemIEs->id = ProtocolIE_ID_id_RANfunctionID_Item;
1055             ranFuncIdItemIEs->value.present = RANfunctionID_ItemIEs__value_PR_RANfunctionID_Item;
1056             ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionID = 11;
1057             ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionRevision = 2;
1058             ASN_SEQUENCE_ADD(&e->value.choice.RANfunctionsID_List.list, ranFuncIdItemIEs);
1059         }
1060         {
1061             auto *ranFuncIdItemIEs = (RANfunctionID_ItemIEs_t *)calloc(1, sizeof(RANfunctionID_ItemIEs_t));
1062
1063             ranFuncIdItemIEs->criticality = Criticality_reject;
1064             ranFuncIdItemIEs->id = ProtocolIE_ID_id_RANfunctionID_Item;
1065             ranFuncIdItemIEs->value.present = RANfunctionID_ItemIEs__value_PR_RANfunctionID_Item;
1066             ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionID = 28;
1067             ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionRevision = 13;
1068             ASN_SEQUENCE_ADD(&e->value.choice.RANfunctionsID_List.list, ranFuncIdItemIEs);
1069         }
1070         {
1071             auto *ranFuncIdItemIEs = (RANfunctionID_ItemIEs_t *)calloc(1, sizeof(RANfunctionID_ItemIEs_t));
1072
1073             ranFuncIdItemIEs->criticality = Criticality_reject;
1074             ranFuncIdItemIEs->id = ProtocolIE_ID_id_RANfunctionID_Item;
1075             ranFuncIdItemIEs->value.present = RANfunctionID_ItemIEs__value_PR_RANfunctionID_Item;
1076             ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionID = 1;
1077             ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionRevision = 4;
1078             ASN_SEQUENCE_ADD(&e->value.choice.RANfunctionsID_List.list, ranFuncIdItemIEs);
1079         }
1080         ASN_SEQUENCE_ADD(&serviceUpdAck->protocolIEs.list, e);
1081     }
1082
1083
1084     {
1085         auto *e = (RICserviceUpdateAcknowledge_IEs_t *)calloc(1, sizeof(RICserviceUpdateAcknowledge_IEs_t));
1086         ASN_STRUCT_RESET(asn_DEF_RICserviceUpdateAcknowledge_IEs, e);
1087         e->id = ProtocolIE_ID_id_RANfunctionsRejected;
1088         e->criticality = Criticality_reject;
1089         e->value.present = RICserviceUpdateAcknowledge_IEs__value_PR_RANfunctionsIDcause_List;
1090         {
1091
1092             auto *ranFuncIdcause = (RANfunctionIDcause_ItemIEs_t *) calloc(1, sizeof(RANfunctionIDcause_ItemIEs_t));
1093             ASN_STRUCT_RESET(asn_DEF_RANfunctionIDcause_Item, ranFuncIdcause);
1094
1095             ranFuncIdcause->criticality = Criticality_ignore;
1096             ranFuncIdcause->id = ProtocolIE_ID_id_RANfunctionIEcause_Item;
1097             ranFuncIdcause->value.present = RANfunctionIDcause_ItemIEs__value_PR_RANfunctionIDcause_Item;
1098             ranFuncIdcause->value.choice.RANfunctionIDcause_Item.ranFunctionID = 1;
1099
1100             ranFuncIdcause->value.choice.RANfunctionIDcause_Item.cause.present = Cause_PR_ricService;
1101             ranFuncIdcause->value.choice.RANfunctionIDcause_Item.cause.choice.ricService = 1;
1102             ASN_SEQUENCE_ADD(&e->value.choice.RANfunctionsIDcause_List.list, ranFuncIdcause);
1103
1104         }
1105         {
1106
1107             auto *ranFuncIdcause = (RANfunctionIDcause_ItemIEs_t *) calloc(1, sizeof(RANfunctionIDcause_ItemIEs_t));
1108             ASN_STRUCT_RESET(asn_DEF_RANfunctionIDcause_Item, ranFuncIdcause);
1109
1110             ranFuncIdcause->criticality = Criticality_ignore;
1111             ranFuncIdcause->id = ProtocolIE_ID_id_RANfunctionIEcause_Item;
1112             ranFuncIdcause->value.present = RANfunctionIDcause_ItemIEs__value_PR_RANfunctionIDcause_Item;
1113             ranFuncIdcause->value.choice.RANfunctionIDcause_Item.ranFunctionID = 2;
1114
1115             ranFuncIdcause->value.choice.RANfunctionIDcause_Item.cause.present = Cause_PR_ricService;
1116             ranFuncIdcause->value.choice.RANfunctionIDcause_Item.cause.choice.ricService = 2;
1117             ASN_SEQUENCE_ADD(&e->value.choice.RANfunctionsIDcause_List.list, ranFuncIdcause);
1118
1119         }
1120         {
1121             auto *ranFuncIdcause = (RANfunctionIDcause_ItemIEs_t *) calloc(1, sizeof(RANfunctionIDcause_ItemIEs_t));
1122             ASN_STRUCT_RESET(asn_DEF_RANfunctionIDcause_Item, ranFuncIdcause);
1123
1124             ranFuncIdcause->criticality = Criticality_ignore;
1125             ranFuncIdcause->id = ProtocolIE_ID_id_RANfunctionIEcause_Item;
1126             ranFuncIdcause->value.present = RANfunctionIDcause_ItemIEs__value_PR_RANfunctionIDcause_Item;
1127             ranFuncIdcause->value.choice.RANfunctionIDcause_Item.ranFunctionID = 3;
1128
1129             ranFuncIdcause->value.choice.RANfunctionIDcause_Item.cause.present = Cause_PR_ricService;
1130             ranFuncIdcause->value.choice.RANfunctionIDcause_Item.cause.choice.ricService = 2;
1131             ASN_SEQUENCE_ADD(&e->value.choice.RANfunctionsIDcause_List.list, ranFuncIdcause);
1132
1133         }
1134         ASN_SEQUENCE_ADD(&serviceUpdAck->protocolIEs.list, e);
1135     }
1136
1137 }
1138
1139 #endif //E2_E2BUILDER_H