2 * Copyright 2019 AT&T Intellectual Property
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 // Created by adi ENZEL on 12/10/19.
22 #ifndef E2_E2BUILDER_H
23 #define E2_E2BUILDER_H
29 #include <sys/types.h>
34 //#include <mdclog/mdclog.h>
37 #include "oranE2/E2AP-PDU.h"
38 #include "oranE2/InitiatingMessage.h"
39 #include "oranE2/SuccessfulOutcome.h"
40 #include "oranE2/UnsuccessfulOutcome.h"
42 #include "oranE2/ProtocolIE-Field.h"
43 #include "oranE2/ENB-ID.h"
44 #include "oranE2/GlobalENB-ID.h"
45 #include "oranE2/GlobalE2node-gNB-ID.h"
46 #include "oranE2/constr_TYPE.h"
47 #include "oranE2/asn_constant.h"
51 #define printEntry(type, function); fprintf(stdout, "start Test %s , %s", type, function);
54 static void checkAndPrint(asn_TYPE_descriptor_t *typeDescriptor, void *data, char *dataType, const char *function) {
55 char errbuf[128]; /* Buffer for error message */
56 size_t errlen = sizeof(errbuf); /* Size of the buffer */
57 if (asn_check_constraints(typeDescriptor, data, errbuf, &errlen) != 0) {
58 fprintf(stderr, "%s Constraint validation failed: %s", dataType, errbuf);
60 fprintf(stdout, "%s successes function %s", dataType, function);
63 void createPLMN_IDByMCCandMNC(PLMN_Identity_t *plmnId, int mcc, int mnc) {
65 //printEntry("PLMN_Identity_t", __func__)
67 ASN_STRUCT_RESET(asn_DEF_PLMN_Identity, plmnId);
69 plmnId->buf = (uint8_t *) calloc(1, 3);
70 volatile auto mcc1 = (unsigned int) (mcc / 100);
71 volatile auto mcc2 = (unsigned int) (mcc / 10 % 10);
72 volatile auto mcc3 = (unsigned int) (mcc % 10);
73 plmnId->buf[0] = mcc2 << 4 | mcc1;
75 volatile auto mnc1 = (unsigned int)0;
76 volatile auto mnc2 = (unsigned int)0;
77 volatile auto mnc3 = (unsigned int)0;
80 mnc1 = (unsigned int) (mnc / 100);
81 mnc2 = (unsigned int) (mnc / 10 % 10);
82 mnc3 = (unsigned int) (mnc % 10);
84 mnc1 = (unsigned int) (mnc / 10);
85 mnc2 = (unsigned int) (mnc % 10);
88 plmnId->buf[1] = mcc3 << 4 | mnc3 ;
89 plmnId->buf[2] = mnc2 << 4 | mnc1 ;
91 //checkAndPrint(&asn_DEF_PLMN_Identity, plmnId, (char *) "PLMN_Identity_t", __func__);
96 PLMN_Identity_t *createPLMN_ID(const unsigned char *data) {
97 printEntry("PLMN_Identity_t", __func__)
98 auto *plmnId = (PLMN_Identity_t *) calloc(1, sizeof(PLMN_Identity_t));
99 ASN_STRUCT_RESET(asn_DEF_PLMN_Identity, plmnId);
101 plmnId->buf = (uint8_t *) calloc(1, 3);
102 memcpy(plmnId->buf, data, 3);
104 checkAndPrint(&asn_DEF_PLMN_Identity, plmnId, (char *) "PLMN_Identity_t", __func__);
109 BIT_STRING_t *createBIT_STRING(int size, int unusedBits, uint8_t *data) {
110 printEntry("BIT_STRING_t", __func__)
111 auto *bitString = (BIT_STRING_t *) calloc(1, sizeof(BIT_STRING_t));
112 ASN_STRUCT_RESET(asn_DEF_BIT_STRING, bitString);
113 bitString->size = size;
114 bitString->bits_unused = unusedBits;
115 bitString->buf = (uint8_t *) calloc(1, size);
117 data[bitString->size - 1] = ((unsigned) (data[bitString->size - 1] >>
118 (unsigned) bitString->bits_unused)
119 << (unsigned) bitString->bits_unused);
120 memcpy(bitString->buf, data, size);
122 checkAndPrint(&asn_DEF_BIT_STRING, bitString, (char *) "BIT_STRING_t", __func__);
128 OCTET_STRING_t *createOCTET_STRING(const unsigned char *data, int size) {
129 printEntry("OCTET_STRING_t", __func__)
130 auto *octs = (PLMN_Identity_t *) calloc(1, sizeof(PLMN_Identity_t));
131 ASN_STRUCT_RESET(asn_DEF_OCTET_STRING, octs);
133 octs->buf = (uint8_t *) calloc(1, size);
134 memcpy(octs->buf, data, size);
136 checkAndPrint(&asn_DEF_OCTET_STRING, octs, (char *) "OCTET_STRING_t", __func__);
141 ENB_ID_t *createENB_ID(ENB_ID_PR enbType, unsigned char *data) {
142 printEntry("ENB_ID_t", __func__)
143 auto *enb = (ENB_ID_t *) calloc(1, sizeof(ENB_ID_t));
144 ASN_STRUCT_RESET(asn_DEF_ENB_ID, enb);
146 enb->present = enbType;
149 case ENB_ID_PR_macro_eNB_ID: { // 20 bit 3 bytes
150 enb->choice.macro_eNB_ID.size = 3;
151 enb->choice.macro_eNB_ID.bits_unused = 4;
153 enb->present = ENB_ID_PR_macro_eNB_ID;
155 enb->choice.macro_eNB_ID.buf = (uint8_t *) calloc(1, enb->choice.macro_eNB_ID.size);
156 data[enb->choice.macro_eNB_ID.size - 1] = ((unsigned) (data[enb->choice.macro_eNB_ID.size - 1] >>
157 (unsigned) enb->choice.macro_eNB_ID.bits_unused)
158 << (unsigned) enb->choice.macro_eNB_ID.bits_unused);
159 memcpy(enb->choice.macro_eNB_ID.buf, data, enb->choice.macro_eNB_ID.size);
163 case ENB_ID_PR_home_eNB_ID: { // 28 bit 4 bytes
164 enb->choice.home_eNB_ID.size = 4;
165 enb->choice.home_eNB_ID.bits_unused = 4;
166 enb->present = ENB_ID_PR_home_eNB_ID;
168 enb->choice.home_eNB_ID.buf = (uint8_t *) calloc(1, enb->choice.home_eNB_ID.size);
169 data[enb->choice.home_eNB_ID.size - 1] = ((unsigned) (data[enb->choice.home_eNB_ID.size - 1] >>
170 (unsigned) enb->choice.home_eNB_ID.bits_unused)
171 << (unsigned) enb->choice.home_eNB_ID.bits_unused);
172 memcpy(enb->choice.home_eNB_ID.buf, data, enb->choice.home_eNB_ID.size);
175 case ENB_ID_PR_short_Macro_eNB_ID: { // 18 bit - 3 bytes
176 enb->choice.short_Macro_eNB_ID.size = 3;
177 enb->choice.short_Macro_eNB_ID.bits_unused = 6;
178 enb->present = ENB_ID_PR_short_Macro_eNB_ID;
180 enb->choice.short_Macro_eNB_ID.buf = (uint8_t *) calloc(1, enb->choice.short_Macro_eNB_ID.size);
181 data[enb->choice.short_Macro_eNB_ID.size - 1] = (
182 (unsigned) (data[enb->choice.short_Macro_eNB_ID.size - 1] >>
183 (unsigned) enb->choice.short_Macro_eNB_ID.bits_unused)
184 << (unsigned) enb->choice.short_Macro_eNB_ID.bits_unused);
185 memcpy(enb->choice.short_Macro_eNB_ID.buf, data, enb->choice.short_Macro_eNB_ID.size);
188 case ENB_ID_PR_long_Macro_eNB_ID: { // 21
189 enb->choice.long_Macro_eNB_ID.size = 3;
190 enb->choice.long_Macro_eNB_ID.bits_unused = 3;
191 enb->present = ENB_ID_PR_long_Macro_eNB_ID;
193 enb->choice.long_Macro_eNB_ID.buf = (uint8_t *) calloc(1, enb->choice.long_Macro_eNB_ID.size);
194 data[enb->choice.long_Macro_eNB_ID.size - 1] =
195 ((unsigned) (data[enb->choice.long_Macro_eNB_ID.size - 1] >> (unsigned) enb->choice.long_Macro_eNB_ID.bits_unused)
196 << (unsigned) enb->choice.long_Macro_eNB_ID.bits_unused);
197 memcpy(enb->choice.long_Macro_eNB_ID.buf, data, enb->choice.long_Macro_eNB_ID.size);
205 checkAndPrint(&asn_DEF_ENB_ID, enb, (char *) "ENB_ID_t", __func__);
209 GlobalENB_ID_t *createGlobalENB_ID(PLMN_Identity_t *plmnIdentity, ENB_ID_t *enbId) {
210 printEntry("GlobalENB_ID_t", __func__)
211 auto *genbId = (GlobalENB_ID_t *) calloc(1, sizeof(GlobalENB_ID_t));
212 ASN_STRUCT_RESET(asn_DEF_GlobalENB_ID, genbId);
213 memcpy(&genbId->pLMN_Identity, plmnIdentity, sizeof(PLMN_Identity_t));
214 memcpy(&genbId->eNB_ID, enbId, sizeof(ENB_ID_t));
216 checkAndPrint(&asn_DEF_GlobalENB_ID, genbId, (char *) "GlobalENB_ID_t", __func__);
221 //static void buildInitiatingMessagePDU(E2AP_PDU_t &pdu, InitiatingMessage_t *initMsg) {
222 // pdu.present = E2AP_PDU_PR_initiatingMessage;
223 // pdu.choice.initiatingMessage = initMsg;
227 static void buildInitMsg(InitiatingMessage_t &initMsg,
228 InitiatingMessage__value_PR present,
229 ProcedureCode_t procedureCode,
230 Criticality_t criticality,
232 initMsg.value.present = present;
233 initMsg.procedureCode = procedureCode;
234 initMsg.criticality = criticality;
237 case InitiatingMessage__value_PR_RICsubscriptionRequest: {
238 memcpy(&initMsg.value.choice.RICsubscriptionRequest, value, sizeof(*value));
241 case InitiatingMessage__value_PR_RICsubscriptionDeleteRequest: {
242 memcpy(&initMsg.value.choice.RICsubscriptionDeleteRequest, value, sizeof(*value));
245 case InitiatingMessage__value_PR_RICserviceUpdate: {
246 memcpy(&initMsg.value.choice.RICserviceUpdate, value, sizeof(*value));
249 case InitiatingMessage__value_PR_RICcontrolRequest: {
250 memcpy(&initMsg.value.choice.RICcontrolRequest, value, sizeof(*value));
253 case InitiatingMessage__value_PR_RICindication: {
254 memcpy(&initMsg.value.choice.RICindication, value, sizeof(*value));
257 case InitiatingMessage__value_PR_RICserviceQuery: {
258 memcpy(&initMsg.value.choice.RICserviceQuery, value, sizeof(*value));
261 case InitiatingMessage__value_PR_NOTHING:
268 //static void buildSuccsesfulMessagePDU(E2AP_PDU_t &pdu, SuccessfulOutcome_t *succMsg) {
269 // pdu.present = E2AP_PDU_PR_successfulOutcome;
270 // pdu.choice.successfulOutcome = succMsg;
274 static void buildSuccMsg(SuccessfulOutcome_t &succMsg,
275 SuccessfulOutcome__value_PR present,
276 ProcedureCode_t procedureCode,
277 Criticality_t criticality,
279 succMsg.value.present = present;
280 succMsg.procedureCode = procedureCode;
281 succMsg.criticality = criticality;
284 case SuccessfulOutcome__value_PR_RICsubscriptionResponse: {
285 memcpy(&succMsg.value.choice.RICsubscriptionResponse, value, sizeof(*value));
288 case SuccessfulOutcome__value_PR_RICsubscriptionDeleteResponse: {
289 memcpy(&succMsg.value.choice.RICsubscriptionDeleteResponse, value, sizeof(*value));
292 case SuccessfulOutcome__value_PR_RICserviceUpdateAcknowledge: {
293 memcpy(&succMsg.value.choice.RICserviceUpdateAcknowledge, value, sizeof(*value));
296 case SuccessfulOutcome__value_PR_RICcontrolAcknowledge: {
297 memcpy(&succMsg.value.choice.RICcontrolAcknowledge, value, sizeof(*value));
300 case SuccessfulOutcome__value_PR_ResetResponse: {
301 memcpy(&succMsg.value.choice.ResetResponse, value, sizeof(*value));
304 case SuccessfulOutcome__value_PR_NOTHING:
311 //static void buildUnSucssesfullMessagePDU(E2AP_PDU_t &pdu, UnsuccessfulOutcome_t *unSuccMsg) {
312 // pdu.present = E2AP_PDU_PR_unsuccessfulOutcome;
313 // pdu.choice.unsuccessfulOutcome = unSuccMsg;
317 static void buildUnSuccMsg(UnsuccessfulOutcome_t &unSuccMsg,
318 UnsuccessfulOutcome__value_PR present,
319 ProcedureCode_t procedureCode,
320 Criticality_t criticality,
322 unSuccMsg.value.present = present;
323 unSuccMsg.procedureCode = procedureCode;
324 unSuccMsg.criticality = criticality;
327 case UnsuccessfulOutcome__value_PR_RICsubscriptionFailure: {
328 memcpy(&unSuccMsg.value.choice.RICsubscriptionFailure, value, sizeof(*value));
331 case UnsuccessfulOutcome__value_PR_RICsubscriptionDeleteFailure: {
332 memcpy(&unSuccMsg.value.choice.RICsubscriptionDeleteFailure, value, sizeof(*value));
335 case UnsuccessfulOutcome__value_PR_RICserviceUpdateFailure: {
336 memcpy(&unSuccMsg.value.choice.RICserviceUpdateFailure, value, sizeof(*value));
339 case UnsuccessfulOutcome__value_PR_RICcontrolFailure: {
340 memcpy(&unSuccMsg.value.choice.RICcontrolFailure, value, sizeof(*value));
344 case UnsuccessfulOutcome__value_PR_NOTHING:
351 //static void createPLMN_ID(PLMN_Identity_t &plmnId, const unsigned char *data) {
352 // //printEntry("PLMN_Identity_t", __func__)
353 // //PLMN_Identity_t *plmnId = calloc(1, sizeof(PLMN_Identity_t));
354 // ASN_STRUCT_RESET(asn_DEF_PLMN_Identity, &plmnId);
355 // plmnId.size = 3;// uint64_t st = 0;
356 //// uint32_t aux1 = 0;
357 //// st = rdtscp(aux1);
359 // plmnId.buf = (uint8_t *) calloc(1, 3);
360 // memcpy(plmnId.buf, data, 3);
362 // checkAndPrint(&asn_DEF_PLMN_Identity, &plmnId, (char *) "PLMN_Identity_t", __func__);
366 static void createENB_ID(ENB_ID_t &enb, ENB_ID_PR enbType, unsigned char *data) {
367 //printEntry("ENB_ID_t", __func__)
368 ASN_STRUCT_RESET(asn_DEF_ENB_ID, &enb);
369 enb.present = enbType;
371 case ENB_ID_PR_macro_eNB_ID: { // 20 bit 3 bytes
372 enb.choice.macro_eNB_ID.size = 3;
373 enb.choice.macro_eNB_ID.bits_unused = 4;
375 enb.present = ENB_ID_PR_macro_eNB_ID;
377 enb.choice.macro_eNB_ID.buf = (uint8_t *) calloc(1, enb.choice.macro_eNB_ID.size);
378 data[enb.choice.macro_eNB_ID.size - 1] = ((unsigned) (data[enb.choice.macro_eNB_ID.size - 1]
379 >> (unsigned) enb.choice.macro_eNB_ID.bits_unused)
380 << (unsigned) enb.choice.macro_eNB_ID.bits_unused);
381 memcpy(enb.choice.macro_eNB_ID.buf, data, enb.choice.macro_eNB_ID.size);
385 case ENB_ID_PR_home_eNB_ID: { // 28 bit 4 bytes
386 enb.choice.home_eNB_ID.size = 4;
387 enb.choice.home_eNB_ID.bits_unused = 4;
388 enb.present = ENB_ID_PR_home_eNB_ID;
390 enb.choice.home_eNB_ID.buf = (uint8_t *) calloc(1, enb.choice.home_eNB_ID.size);
391 data[enb.choice.home_eNB_ID.size - 1] = ((unsigned) (data[enb.choice.home_eNB_ID.size - 1]
392 >> (unsigned) enb.choice.home_eNB_ID.bits_unused)
393 << (unsigned) enb.choice.home_eNB_ID.bits_unused);
394 memcpy(enb.choice.home_eNB_ID.buf, data, enb.choice.home_eNB_ID.size);
397 case ENB_ID_PR_short_Macro_eNB_ID: { // 18 bit - 3 bytes
398 enb.choice.short_Macro_eNB_ID.size = 3;
399 enb.choice.short_Macro_eNB_ID.bits_unused = 6;
400 enb.present = ENB_ID_PR_short_Macro_eNB_ID;
402 enb.choice.short_Macro_eNB_ID.buf = (uint8_t *) calloc(1, enb.choice.short_Macro_eNB_ID.size);
403 data[enb.choice.short_Macro_eNB_ID.size - 1] = ((unsigned) (data[enb.choice.short_Macro_eNB_ID.size - 1]
404 >> (unsigned) enb.choice.short_Macro_eNB_ID.bits_unused)
405 << (unsigned) enb.choice.short_Macro_eNB_ID.bits_unused);
406 memcpy(enb.choice.short_Macro_eNB_ID.buf, data, enb.choice.short_Macro_eNB_ID.size);
409 case ENB_ID_PR_long_Macro_eNB_ID: { // 21
410 enb.choice.long_Macro_eNB_ID.size = 3;
411 enb.choice.long_Macro_eNB_ID.bits_unused = 3;
412 enb.present = ENB_ID_PR_long_Macro_eNB_ID;
414 enb.choice.long_Macro_eNB_ID.buf = (uint8_t *) calloc(1, enb.choice.long_Macro_eNB_ID.size);
415 data[enb.choice.long_Macro_eNB_ID.size - 1] = ((unsigned) (data[enb.choice.long_Macro_eNB_ID.size - 1]
416 >> (unsigned) enb.choice.long_Macro_eNB_ID.bits_unused)
417 << (unsigned) enb.choice.long_Macro_eNB_ID.bits_unused);
418 memcpy(enb.choice.long_Macro_eNB_ID.buf, data, enb.choice.long_Macro_eNB_ID.size);
425 checkAndPrint(&asn_DEF_ENB_ID, &enb, (char *) "ENB_ID_t", __func__);
429 static void buildGlobalENB_ID(GlobalENB_ID_t *gnbId,
430 const unsigned char *gnbData,
432 unsigned char *enbData) {
433 auto *plmnID = createPLMN_ID(gnbData);
434 memcpy(&gnbId->pLMN_Identity, plmnID, sizeof(PLMN_Identity_t));
435 createENB_ID(gnbId->eNB_ID, enbType, enbData);
436 checkAndPrint(&asn_DEF_GlobalENB_ID, gnbId, (char *) "GlobalENB_ID_t", __func__);
440 void buildSetupRequest(E2AP_PDU_t *pdu, int mcc, int mnc) {
441 ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu);
443 pdu->choice.initiatingMessage = (InitiatingMessage_t *)calloc(1, sizeof(InitiatingMessage_t));
444 auto *initiatingMessage = pdu->choice.initiatingMessage;
445 ASN_STRUCT_RESET(asn_DEF_InitiatingMessage, initiatingMessage);
446 initiatingMessage->procedureCode = ProcedureCode_id_E2setup;
447 initiatingMessage->criticality = Criticality_reject;
448 initiatingMessage->value.present = InitiatingMessage__value_PR_E2setupRequest;
450 auto *e2SetupRequestIEs = (E2setupRequestIEs_t *)calloc(1, sizeof(E2setupRequestIEs_t));
451 ASN_STRUCT_RESET(asn_DEF_E2setupRequestIEs, e2SetupRequestIEs);
453 e2SetupRequestIEs->value.choice.GlobalE2node_ID.choice.gNB = (GlobalE2node_gNB_ID_t *)calloc(1, sizeof(GlobalE2node_gNB_ID_t));
454 auto *globalE2NodeGNbId = e2SetupRequestIEs->value.choice.GlobalE2node_ID.choice.gNB;
455 ASN_STRUCT_RESET(asn_DEF_GlobalE2node_gNB_ID, globalE2NodeGNbId);
457 createPLMN_IDByMCCandMNC(&globalE2NodeGNbId->global_gNB_ID.plmn_id, mcc, mnc);
458 globalE2NodeGNbId->global_gNB_ID.gnb_id.present = GNB_ID_Choice_PR_gnb_ID;
459 globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size = 4;
460 globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf =
461 (uint8_t *) calloc(1, globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size); //22..32 bits
462 globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.bits_unused = 0;
463 globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf[0] = 0xB5;
464 globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf[1] = 0xC6;
465 globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf[2] = 0x77;
466 globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf[3] = 0x88;
468 e2SetupRequestIEs->criticality = Criticality_reject;
469 e2SetupRequestIEs->id = ProtocolIE_ID_id_GlobalE2node_ID;
470 e2SetupRequestIEs->value.present = E2setupRequestIEs__value_PR_GlobalE2node_ID;
471 e2SetupRequestIEs->value.choice.GlobalE2node_ID.present = GlobalE2node_ID_PR_gNB;
474 auto *e2SetupRequest = &initiatingMessage->value.choice.E2setupRequest;
476 ASN_STRUCT_RESET(asn_DEF_E2setupRequest, e2SetupRequest);
477 ASN_SEQUENCE_ADD(&e2SetupRequest->protocolIEs.list, e2SetupRequestIEs);
479 pdu->present = E2AP_PDU_PR_initiatingMessage;
482 void buildSetupRequestWithFunc(E2AP_PDU_t *pdu, int mcc, int mnc) {
483 ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu);
485 pdu->choice.initiatingMessage = (InitiatingMessage_t *)calloc(1, sizeof(InitiatingMessage_t));
486 auto *initiatingMessage = pdu->choice.initiatingMessage;
487 ASN_STRUCT_RESET(asn_DEF_InitiatingMessage, initiatingMessage);
488 initiatingMessage->procedureCode = ProcedureCode_id_E2setup;
489 initiatingMessage->criticality = Criticality_reject;
490 initiatingMessage->value.present = InitiatingMessage__value_PR_E2setupRequest;
492 auto *e2SetupRequestIEs = (E2setupRequestIEs_t *)calloc(1, sizeof(E2setupRequestIEs_t));
493 ASN_STRUCT_RESET(asn_DEF_E2setupRequestIEs, e2SetupRequestIEs);
495 e2SetupRequestIEs->value.choice.GlobalE2node_ID.choice.gNB = (GlobalE2node_gNB_ID_t *)calloc(1, sizeof(GlobalE2node_gNB_ID_t));
496 auto *globalE2NodeGNbId = e2SetupRequestIEs->value.choice.GlobalE2node_ID.choice.gNB;
497 ASN_STRUCT_RESET(asn_DEF_GlobalE2node_gNB_ID, globalE2NodeGNbId);
499 createPLMN_IDByMCCandMNC(&globalE2NodeGNbId->global_gNB_ID.plmn_id, mcc, mnc);
500 globalE2NodeGNbId->global_gNB_ID.gnb_id.present = GNB_ID_Choice_PR_gnb_ID;
501 globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size = 4;
502 globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf =
503 (uint8_t *) calloc(1, globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.size); //22..32 bits
504 globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.bits_unused = 0;
505 globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf[0] = 0xB5;
506 globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf[1] = 0xC6;
507 globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf[2] = 0x77;
508 globalE2NodeGNbId->global_gNB_ID.gnb_id.choice.gnb_ID.buf[3] = 0x88;
510 e2SetupRequestIEs->criticality = Criticality_reject;
511 e2SetupRequestIEs->id = ProtocolIE_ID_id_GlobalE2node_ID;
512 e2SetupRequestIEs->value.present = E2setupRequestIEs__value_PR_GlobalE2node_ID;
513 e2SetupRequestIEs->value.choice.GlobalE2node_ID.present = GlobalE2node_ID_PR_gNB;
516 auto *e2SetupRequest = &initiatingMessage->value.choice.E2setupRequest;
518 ASN_STRUCT_RESET(asn_DEF_E2setupRequest, e2SetupRequest);
519 ASN_SEQUENCE_ADD(&e2SetupRequest->protocolIEs.list, e2SetupRequestIEs);
521 auto *ranFlistIEs = (E2setupRequestIEs_t *)calloc(1, sizeof(E2setupRequestIEs_t));
522 ASN_STRUCT_RESET(asn_DEF_E2setupRequestIEs, ranFlistIEs);
523 ranFlistIEs->criticality = Criticality_reject;
524 ranFlistIEs->id = ProtocolIE_ID_id_RANfunctionsAdded;
525 ranFlistIEs->value.present = E2setupRequestIEs__value_PR_RANfunctions_List;
527 auto *itemIes = (RANfunction_ItemIEs_t *)calloc(1, sizeof(RANfunction_ItemIEs_t));
528 ASN_STRUCT_RESET(asn_DEF_RANfunction_ItemIEs, itemIes);
530 uint8_t buf[3] = {0x33, 0x44, 0x55};
532 itemIes->id = ProtocolIE_ID_id_RANfunction_Item;
533 itemIes->criticality = Criticality_reject;
534 itemIes->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item;
535 itemIes->value.choice.RANfunction_Item.ranFunctionID = 1;
536 auto *ranDef = &itemIes->value.choice.RANfunction_Item.ranFunctionDefinition;
538 ranDef->buf = (uint8_t *)calloc(1, ranDef->size);
539 memcpy(ranDef->buf, buf, ranDef->size);
541 ASN_SEQUENCE_ADD(&ranFlistIEs->value.choice.RANfunctions_List.list, itemIes);
543 auto *itemIes1 = (RANfunction_ItemIEs_t *)calloc(1, sizeof(RANfunction_ItemIEs_t));
544 ASN_STRUCT_RESET(asn_DEF_RANfunction_ItemIEs, itemIes1);
545 itemIes1->id = ProtocolIE_ID_id_RANfunction_Item;
546 itemIes1->criticality = Criticality_reject;
547 itemIes1->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item;
548 itemIes1->value.choice.RANfunction_Item.ranFunctionID = 7;
549 ranDef = &itemIes1->value.choice.RANfunction_Item.ranFunctionDefinition;
551 ranDef->buf = (uint8_t *)calloc(1, ranDef->size);
552 memcpy(ranDef->buf, buf, ranDef->size);
553 ASN_SEQUENCE_ADD(&ranFlistIEs->value.choice.RANfunctions_List.list, itemIes1);
556 ASN_SEQUENCE_ADD(&e2SetupRequest->protocolIEs.list, ranFlistIEs);
558 pdu->present = E2AP_PDU_PR_initiatingMessage;
565 void buildSetupSuccsessfulResponse(E2AP_PDU_t *pdu, int mcc, int mnc, uint8_t *data) {
566 ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu);
568 pdu->choice.successfulOutcome = (SuccessfulOutcome_t *)calloc(1, sizeof(SuccessfulOutcome_t));
569 SuccessfulOutcome_t *successfulOutcome = pdu->choice.successfulOutcome;
570 ASN_STRUCT_RESET(asn_DEF_E2setupResponse, &successfulOutcome->value.choice.E2setupResponse);
571 successfulOutcome->procedureCode = ProcedureCode_id_E2setup;
572 successfulOutcome->criticality = Criticality_reject;
573 successfulOutcome->value.present = SuccessfulOutcome__value_PR_E2setupResponse;
576 auto *globalRicidIE = (E2setupResponseIEs_t *)calloc(1, sizeof(E2setupResponseIEs_t));
577 ASN_STRUCT_RESET(asn_DEF_E2setupResponseIEs, globalRicidIE);
579 globalRicidIE->criticality = Criticality_reject;
580 globalRicidIE->id = ProtocolIE_ID_id_GlobalRIC_ID;
581 globalRicidIE->value.present = E2setupResponseIEs__value_PR_GlobalRIC_ID;
582 createPLMN_IDByMCCandMNC(&globalRicidIE->value.choice.GlobalRIC_ID.pLMN_Identity, mcc, mnc);
584 globalRicidIE->value.choice.GlobalRIC_ID.ric_ID = {nullptr, 3, 4};
585 globalRicidIE->value.choice.GlobalRIC_ID.ric_ID.buf = (uint8_t *)calloc(1, globalRicidIE->value.choice.GlobalRIC_ID.ric_ID.size);
586 memcpy(globalRicidIE->value.choice.GlobalRIC_ID.ric_ID.buf, data, globalRicidIE->value.choice.GlobalRIC_ID.ric_ID.size);
587 globalRicidIE->value.choice.GlobalRIC_ID.ric_ID.buf[2] &= (unsigned)0xF0;
590 ASN_STRUCT_RESET(asn_DEF_E2setupResponse, &successfulOutcome->value.choice.E2setupResponse);
591 ASN_SEQUENCE_ADD(&successfulOutcome->value.choice.E2setupResponse.protocolIEs.list, globalRicidIE);
593 auto *ranFunctionAdd = (E2setupResponseIEs_t *)calloc(1, sizeof(E2setupResponseIEs_t));
594 ASN_STRUCT_RESET(asn_DEF_E2setupResponseIEs, ranFunctionAdd);
595 ranFunctionAdd->criticality = Criticality_reject;
596 ranFunctionAdd->id = ProtocolIE_ID_id_RANfunctionsAccepted;
597 ranFunctionAdd->value.present = E2setupResponseIEs__value_PR_RANfunctionsID_List;
599 auto *ranFuncIdItemIEs = (RANfunctionID_ItemIEs_t *)calloc(1, sizeof(RANfunctionID_ItemIEs_t));
601 ranFuncIdItemIEs->criticality = Criticality_ignore;
602 ranFuncIdItemIEs->id = ProtocolIE_ID_id_RANfunctionID_Item;
603 ranFuncIdItemIEs->value.present = RANfunctionID_ItemIEs__value_PR_RANfunctionID_Item;
604 ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionID = 10;
605 ranFuncIdItemIEs->value.choice.RANfunctionID_Item.ranFunctionRevision = 1;
607 ASN_SEQUENCE_ADD(&ranFunctionAdd->value.choice.RANfunctionsID_List.list, ranFuncIdItemIEs);
608 ASN_SEQUENCE_ADD(&successfulOutcome->value.choice.E2setupResponse.protocolIEs.list, ranFunctionAdd);
614 pdu->present = E2AP_PDU_PR_successfulOutcome;
618 void buildSetupUnSuccsessfulResponse(E2AP_PDU_t *pdu) {
619 ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu);
621 pdu->choice.unsuccessfulOutcome = (UnsuccessfulOutcome_t *)calloc(1, sizeof(UnsuccessfulOutcome_t));
622 UnsuccessfulOutcome_t *uns = pdu->choice.unsuccessfulOutcome;
623 uns->procedureCode = ProcedureCode_id_E2setup;
624 uns->criticality = Criticality_reject;
625 uns->value.present = UnsuccessfulOutcome__value_PR_E2setupFailure;
627 auto *e2SetupFIE = (E2setupFailureIEs_t *)calloc(1, sizeof(E2setupFailureIEs_t));
628 ASN_STRUCT_RESET(asn_DEF_E2setupFailureIEs, e2SetupFIE);
630 e2SetupFIE->criticality = Criticality_reject;
631 e2SetupFIE->id = ProtocolIE_ID_id_GlobalRIC_ID;
632 e2SetupFIE->value.present = E2setupFailureIEs__value_PR_Cause;
633 e2SetupFIE->value.choice.Cause.present = Cause_PR_transport;
634 e2SetupFIE->value.choice.Cause.choice.transport = CauseTransport_transport_resource_unavailable;
637 ASN_STRUCT_RESET(asn_DEF_E2setupFailure, &uns->value.choice.E2setupFailure);
638 ASN_SEQUENCE_ADD(&uns->value.choice.E2setupFailure.protocolIEs.list, e2SetupFIE);
640 pdu->present = E2AP_PDU_PR_unsuccessfulOutcome;
643 #endif //E2_E2BUILDER_H