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>
31 #include <mdclog/mdclog.h>
35 #include <mdclog/mdclog.h>
38 #include "asn1cFiles/E2AP-PDU.h"
39 #include "asn1cFiles/InitiatingMessage.h"
40 #include "asn1cFiles/SuccessfulOutcome.h"
41 #include "asn1cFiles/UnsuccessfulOutcome.h"
43 #include "asn1cFiles/ProtocolIE-Field.h"
45 #include "asn1cFiles/FDD-Info.h"
46 #include "asn1cFiles/TDD-Info.h"
47 #include "asn1cFiles/Neighbour-Information.h"
50 #include "asn1cFiles/constr_TYPE.h"
51 #include "asn1cFiles/asn_constant.h"
55 #define printEntry(type, function) \
56 if (mdclog_level_get() >= MDCLOG_DEBUG) { \
57 mdclog_write(MDCLOG_DEBUG, "start Test %s , %s", type, function); \
61 static void checkAndPrint(asn_TYPE_descriptor_t *typeDescriptor, void *data, char *dataType, const char *function) {
62 char errbuf[128]; /* Buffer for error message */
63 size_t errlen = sizeof(errbuf); /* Size of the buffer */
64 if (asn_check_constraints(typeDescriptor, data, errbuf, &errlen) != 0) {
65 mdclog_write(MDCLOG_ERR, "%s Constraint validation failed: %s", dataType, errbuf);
66 } else if (mdclog_level_get() >= MDCLOG_DEBUG) {
67 mdclog_write(MDCLOG_DEBUG, "%s successes function %s", dataType, function);
71 BIT_STRING_t *createBIT_STRING(int size, int unusedBits, uint8_t *data) {
72 printEntry("BIT_STRING_t", __func__)
73 auto *bitString = (BIT_STRING_t *)calloc(1, sizeof(BIT_STRING_t));
74 ASN_STRUCT_RESET(asn_DEF_BIT_STRING, bitString);
75 bitString->size = size;
76 bitString->bits_unused = unusedBits;
77 bitString->buf = (uint8_t *)calloc(1, size);
79 data[bitString->size - 1] = ((unsigned)(data[bitString->size - 1] >>
80 (unsigned)bitString->bits_unused) << (unsigned)bitString->bits_unused);
81 memcpy(bitString->buf, data, size);
83 if (mdclog_level_get() >= MDCLOG_DEBUG) {
84 checkAndPrint(&asn_DEF_BIT_STRING, bitString, (char *)"BIT_STRING_t", __func__);
91 OCTET_STRING_t *createOCTET_STRING(const unsigned char *data, int size) {
92 printEntry("OCTET_STRING_t", __func__)
93 auto *octs = (PLMN_Identity_t *)calloc(1, sizeof(PLMN_Identity_t));
94 ASN_STRUCT_RESET(asn_DEF_OCTET_STRING, octs);
96 octs->buf = (uint8_t *)calloc(1, size);
97 memcpy(octs->buf, data, size);
99 if (mdclog_level_get() >= MDCLOG_DEBUG) {
100 checkAndPrint(&asn_DEF_OCTET_STRING, octs, (char *)"OCTET_STRING_t", __func__);
106 PLMN_Identity_t *createPLMN_ID(const unsigned char *data) {
107 printEntry("PLMN_Identity_t", __func__)
108 auto *plmnId = (PLMN_Identity_t *)calloc(1, sizeof(PLMN_Identity_t));
109 ASN_STRUCT_RESET(asn_DEF_PLMN_Identity, plmnId);
111 plmnId->buf = (uint8_t *)calloc(1, 3);
112 memcpy(plmnId->buf, data, 3);
114 if (mdclog_level_get() >= MDCLOG_DEBUG) {
115 checkAndPrint(&asn_DEF_PLMN_Identity, plmnId, (char *)"PLMN_Identity_t", __func__);
120 ENB_ID_t *createENB_ID(ENB_ID_PR enbType, unsigned char *data) {
121 printEntry("ENB_ID_t", __func__)
122 auto *enb = (ENB_ID_t *)calloc(1, sizeof(ENB_ID_t));
123 ASN_STRUCT_RESET(asn_DEF_ENB_ID, enb);
125 enb->present = enbType;
128 case ENB_ID_PR_macro_eNB_ID: { // 20 bit 3 bytes
129 enb->choice.macro_eNB_ID.size = 3;
130 enb->choice.macro_eNB_ID.bits_unused = 4;
132 enb->present = ENB_ID_PR_macro_eNB_ID;
134 enb->choice.macro_eNB_ID.buf = (uint8_t *)calloc(1, enb->choice.macro_eNB_ID.size);
135 data[enb->choice.macro_eNB_ID.size - 1] = ((unsigned)(data[enb->choice.macro_eNB_ID.size - 1] >>
136 (unsigned)enb->choice.macro_eNB_ID.bits_unused) << (unsigned)enb->choice.macro_eNB_ID.bits_unused);
137 memcpy(enb->choice.macro_eNB_ID.buf, data, enb->choice.macro_eNB_ID.size);
141 case ENB_ID_PR_home_eNB_ID: { // 28 bit 4 bytes
142 enb->choice.home_eNB_ID.size = 4;
143 enb->choice.home_eNB_ID.bits_unused = 4;
144 enb->present = ENB_ID_PR_home_eNB_ID;
146 enb->choice.home_eNB_ID.buf = (uint8_t *)calloc(1, enb->choice.home_eNB_ID.size);
147 data[enb->choice.home_eNB_ID.size - 1] = ((unsigned)(data[enb->choice.home_eNB_ID.size - 1] >>
148 (unsigned)enb->choice.home_eNB_ID.bits_unused) << (unsigned)enb->choice.home_eNB_ID.bits_unused);
149 memcpy(enb->choice.home_eNB_ID.buf, data, enb->choice.home_eNB_ID.size);
152 case ENB_ID_PR_short_Macro_eNB_ID: { // 18 bit - 3 bytes
153 enb->choice.short_Macro_eNB_ID.size = 3;
154 enb->choice.short_Macro_eNB_ID.bits_unused = 6;
155 enb->present = ENB_ID_PR_short_Macro_eNB_ID;
157 enb->choice.short_Macro_eNB_ID.buf = (uint8_t *)calloc(1, enb->choice.short_Macro_eNB_ID.size);
158 data[enb->choice.short_Macro_eNB_ID.size - 1] = ((unsigned)(data[enb->choice.short_Macro_eNB_ID.size - 1] >>
159 (unsigned)enb->choice.short_Macro_eNB_ID.bits_unused) << (unsigned)enb->choice.short_Macro_eNB_ID.bits_unused);
160 memcpy(enb->choice.short_Macro_eNB_ID.buf, data, enb->choice.short_Macro_eNB_ID.size);
163 case ENB_ID_PR_long_Macro_eNB_ID: { // 21
164 enb->choice.long_Macro_eNB_ID.size = 3;
165 enb->choice.long_Macro_eNB_ID.bits_unused = 3;
166 enb->present = ENB_ID_PR_long_Macro_eNB_ID;
168 enb->choice.long_Macro_eNB_ID.buf = (uint8_t *)calloc(1, enb->choice.long_Macro_eNB_ID.size);
169 data[enb->choice.long_Macro_eNB_ID.size - 1] = ((unsigned)(data[enb->choice.long_Macro_eNB_ID.size - 1] >>
170 (unsigned)enb->choice.long_Macro_eNB_ID.bits_unused) << (unsigned)enb->choice.long_Macro_eNB_ID.bits_unused);
171 memcpy(enb->choice.long_Macro_eNB_ID.buf, data, enb->choice.long_Macro_eNB_ID.size);
179 if (mdclog_level_get() >= MDCLOG_DEBUG) {
180 checkAndPrint(&asn_DEF_ENB_ID, enb, (char *)"ENB_ID_t", __func__);
185 GlobalENB_ID_t *createGlobalENB_ID(PLMN_Identity_t *plmnIdentity, ENB_ID_t *enbId) {
186 printEntry("GlobalENB_ID_t", __func__)
187 auto *genbId = (GlobalENB_ID_t *)calloc(1, sizeof(GlobalENB_ID_t));
188 ASN_STRUCT_RESET(asn_DEF_GlobalENB_ID, genbId);
189 memcpy(&genbId->pLMN_Identity, plmnIdentity, sizeof(PLMN_Identity_t));
190 memcpy(&genbId->eNB_ID, enbId, sizeof(ENB_ID_t));
192 if (mdclog_level_get() >= MDCLOG_DEBUG) {
193 checkAndPrint(&asn_DEF_GlobalENB_ID, genbId, (char *)"GlobalENB_ID_t", __func__);
199 ECGI_t *CreateECGI(PLMN_Identity_t *plmnIdentity, BIT_STRING_t * eUtran) {
200 printEntry("ECGI_t", __func__)
201 auto *ecgi = (ECGI_t *)calloc(1, sizeof(ECGI_t));
202 ASN_STRUCT_RESET(asn_DEF_ECGI, ecgi);
204 memcpy(&ecgi->pLMN_Identity, plmnIdentity, sizeof(PLMN_Identity_t));
205 memcpy(&ecgi->eUTRANcellIdentifier, eUtran, sizeof(BIT_STRING_t));
207 if (mdclog_level_get() >= MDCLOG_DEBUG) {
208 checkAndPrint(&asn_DEF_ECGI, ecgi, (char *)"ECGI_t", __func__);
214 //FDD-Info ::= SEQUENCE {
217 // uL-Transmission-Bandwidth Transmission-Bandwidth,
218 // dL-Transmission-Bandwidth Transmission-Bandwidth,
219 // iE-Extensions ProtocolExtensionContainer { {FDD-Info-ExtIEs} } OPTIONAL,
223 //FDD-Info-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
224 // { ID id-UL-EARFCNExtension CRITICALITY reject EXTENSION EARFCNExtension PRESENCE optional}|
225 // { ID id-DL-EARFCNExtension CRITICALITY reject EXTENSION EARFCNExtension PRESENCE optional}|
226 // { ID id-OffsetOfNbiotChannelNumberToDL-EARFCN CRITICALITY reject EXTENSION OffsetOfNbiotChannelNumberToEARFCN PRESENCE optional}|
227 // { ID id-OffsetOfNbiotChannelNumberToUL-EARFCN CRITICALITY reject EXTENSION OffsetOfNbiotChannelNumberToEARFCN PRESENCE optional}|
228 // { ID id-NRS-NSSS-PowerOffset CRITICALITY ignore EXTENSION NRS-NSSS-PowerOffset PRESENCE optional}|
229 // { ID id-NSSS-NumOccasionDifferentPrecoder CRITICALITY ignore EXTENSION NSSS-NumOccasionDifferentPrecoder PRESENCE optional},
233 static FDD_Info_t *create_fdd(long dL_EARFCN,
235 e_Transmission_Bandwidth ultb,
236 e_Transmission_Bandwidth dltb) {
237 printEntry("FDD_Info_t", __func__)
238 auto *fdd = (FDD_Info_t *)calloc(1, sizeof(FDD_Info_t));
239 ASN_STRUCT_RESET(asn_DEF_FDD_Info, fdd);
241 //EARFCN ::= INTEGER (0..maxEARFCN)
243 if (dL_EARFCN >= 0 && dL_EARFCN <= maxEARFCN) {
244 fdd->dL_EARFCN = dL_EARFCN;
246 fdd->dL_EARFCN = maxEARFCN;
248 if (uL_EARFCN >= 0 && uL_EARFCN <= maxEARFCN) {
249 fdd->uL_EARFCN = uL_EARFCN;
251 fdd->uL_EARFCN = maxEARFCN;
254 fdd->uL_Transmission_Bandwidth = ultb;
255 fdd->dL_Transmission_Bandwidth = dltb;
257 if (mdclog_level_get() >= MDCLOG_DEBUG) {
258 checkAndPrint(&asn_DEF_FDD_Info, fdd, (char *)"FDD_Info_t", __func__);
264 SpecialSubframe_Info_t *createSpecialSubframe_Info(e_CyclicPrefixDL eCyclicPrefixDl,
265 e_CyclicPrefixUL eCyclicPrefixUl,
266 e_SpecialSubframePatterns eSpecialSubframePatterns) {
267 printEntry("SpecialSubframe_Info_t", __func__)
268 auto *ssf = (SpecialSubframe_Info_t *)calloc(1, sizeof(SpecialSubframe_Info_t));
269 ASN_STRUCT_RESET(asn_DEF_SpecialSubframe_Info, ssf);
271 ssf->cyclicPrefixDL = eCyclicPrefixDl;
272 ssf->cyclicPrefixUL = eCyclicPrefixUl;
273 ssf->specialSubframePatterns = eSpecialSubframePatterns;
275 if (mdclog_level_get() >= MDCLOG_DEBUG) {
276 checkAndPrint(&asn_DEF_SpecialSubframe_Info, ssf, (char *)"SpecialSubframe_Info_t", __func__);
281 //TDD-Info ::= SEQUENCE {
283 // transmission-Bandwidth Transmission-Bandwidth,
284 // subframeAssignment SubframeAssignment,
285 // specialSubframe-Info SpecialSubframe-Info,
286 // iE-Extensions ProtocolExtensionContainer { {TDD-Info-ExtIEs} } OPTIONAL,
290 //TDD-Info-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
291 // { ID id-AdditionalSpecialSubframe-Info CRITICALITY ignore EXTENSION AdditionalSpecialSubframe-Info PRESENCE optional}|
292 // { ID id-eARFCNExtension CRITICALITY reject EXTENSION EARFCNExtension PRESENCE optional}|
293 // { ID id-AdditionalSpecialSubframeExtension-Info CRITICALITY ignore EXTENSION AdditionalSpecialSubframeExtension-Info PRESENCE optional}|
294 // { ID id-OffsetOfNbiotChannelNumberToDL-EARFCN CRITICALITY reject EXTENSION OffsetOfNbiotChannelNumberToEARFCN PRESENCE optional}|
295 // { ID id-NBIoT-UL-DL-AlignmentOffset CRITICALITY reject EXTENSION NBIoT-UL-DL-AlignmentOffset PRESENCE optional},
299 static TDD_Info_t *create_Tdd(long eARFCN,
300 e_Transmission_Bandwidth tb,
301 e_SubframeAssignment sfA,
302 SpecialSubframe_Info_t *ssfi) {
303 printEntry("TDD_Info_t", __func__)
304 auto *tdd = (TDD_Info_t *)calloc(1, sizeof(FDD_Info_t));
305 ASN_STRUCT_RESET(asn_DEF_TDD_Info, tdd);
307 if (eARFCN >= 0 && eARFCN <= maxEARFCN) {
308 tdd->eARFCN = eARFCN;
310 tdd->eARFCN = maxEARFCN;
312 tdd->transmission_Bandwidth = tb;
313 tdd->subframeAssignment = sfA;
314 memcpy(&tdd->specialSubframe_Info, ssfi, sizeof(SpecialSubframe_Info_t));
316 if (mdclog_level_get() >= MDCLOG_DEBUG) {
317 checkAndPrint(&asn_DEF_TDD_Info, tdd, (char *)"TDD_Info_t", __func__);
322 static EUTRA_Mode_Info_t *createEUTRA_Mode_Info_FDD(FDD_Info_t *fdd) {
323 printEntry("EUTRA_Mode_Info_t", __func__)
324 auto *eutraModeInfo = (EUTRA_Mode_Info_t *)calloc(1, sizeof(EUTRA_Mode_Info_t));
325 ASN_STRUCT_RESET(asn_DEF_EUTRA_Mode_Info, eutraModeInfo);
327 eutraModeInfo->present = EUTRA_Mode_Info_PR_fDD;
328 eutraModeInfo->choice.fDD = fdd;
330 if (mdclog_level_get() >= MDCLOG_DEBUG) {
331 checkAndPrint(&asn_DEF_EUTRA_Mode_Info, eutraModeInfo, (char *)"EUTRA_Mode_Info_t", __func__);
333 return eutraModeInfo;
337 static EUTRA_Mode_Info_t *createEUTRA_Mode_Info_TDD(TDD_Info_t *tdd) {
338 printEntry("EUTRA_Mode_Info_t", __func__)
339 auto *eutraModeInfo = (EUTRA_Mode_Info_t *)calloc(1, sizeof(EUTRA_Mode_Info_t));
340 ASN_STRUCT_RESET(asn_DEF_EUTRA_Mode_Info, eutraModeInfo);
342 eutraModeInfo->present = EUTRA_Mode_Info_PR_tDD;
343 eutraModeInfo->choice.tDD = tdd;
345 if (mdclog_level_get() >= MDCLOG_DEBUG) {
346 checkAndPrint(&asn_DEF_EUTRA_Mode_Info, eutraModeInfo, (char *)"EUTRA_Mode_Info_t", __func__);
348 return eutraModeInfo;
352 Neighbour_Information__Member *createNeighbour_Information__Member(ECGI_t *eCGI, long pci, long eARFCN) {
353 printEntry("Neighbour_Information__Member", __func__)
354 auto *nigborInformation = (Neighbour_Information__Member *)calloc(1, sizeof(Neighbour_Information__Member));
355 ASN_STRUCT_RESET(asn_DEF_Neighbour_Information, nigborInformation);
357 memcpy(&nigborInformation->eCGI, eCGI, sizeof(ECGI_t));
358 nigborInformation->pCI = pci;
359 nigborInformation->eARFCN = eARFCN;
361 if (mdclog_level_get() >= MDCLOG_DEBUG) {
362 checkAndPrint(&asn_DEF_Neighbour_Information, nigborInformation, (char *)"Neighbour_Information__Member", __func__);
364 return nigborInformation;
367 void buildNeighbour_InformationVector(Neighbour_Information_t *neighbourInformation, Neighbour_Information__Member *member) {
368 ASN_SEQUENCE_ADD(&neighbourInformation->list, member);
371 //ServedCell-Information ::= SEQUENCE {
375 // broadcastPLMNs BroadcastPLMNs-Item,
376 // eUTRA-Mode-Info EUTRA-Mode-Info,
377 // iE-Extensions ProtocolExtensionContainer { {ServedCell-Information-ExtIEs} } OPTIONAL,
381 //ServedCell-Information-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
382 // { ID id-Number-of-Antennaports CRITICALITY ignore EXTENSION Number-of-Antennaports PRESENCE optional}|
383 // { ID id-PRACH-Configuration CRITICALITY ignore EXTENSION PRACH-Configuration PRESENCE optional}|
384 // { ID id-MBSFN-Subframe-Info CRITICALITY ignore EXTENSION MBSFN-Subframe-Infolist PRESENCE optional}|
385 // { ID id-CSG-Id CRITICALITY ignore EXTENSION CSG-Id PRESENCE optional}|
386 // { ID id-MBMS-Service-Area-List CRITICALITY ignore EXTENSION MBMS-Service-Area-Identity-List PRESENCE optional}|
387 // { ID id-MultibandInfoList CRITICALITY ignore EXTENSION MultibandInfoList PRESENCE optional}|
388 // { ID id-FreqBandIndicatorPriority CRITICALITY ignore EXTENSION FreqBandIndicatorPriority PRESENCE optional}|
389 // { ID id-BandwidthReducedSI CRITICALITY ignore EXTENSION BandwidthReducedSI PRESENCE optional}|
390 // { ID id-ProtectedEUTRAResourceIndication CRITICALITY ignore EXTENSION ProtectedEUTRAResourceIndication PRESENCE optional}|
391 // { ID id-BPLMN-ID-Info-EUTRA CRITICALITY ignore EXTENSION BPLMN-ID-Info-EUTRA PRESENCE optional},
400 * @param broadcastPLMNs
401 * @param eutranModeInfo
404 ServedCell_Information_t *createServedCellInfo(long pci,
407 vector<PLMN_Identity_t> &broadcastPLMNs,
408 EUTRA_Mode_Info_t *eutranModeInfo) {
410 printEntry("ServedCell_Information_t", __func__)
411 auto servedCellinfo = (ServedCell_Information_t *)calloc(1, sizeof(ServedCell_Information_t));
412 ASN_STRUCT_RESET(asn_DEF_ServedCell_Information, servedCellinfo);
414 servedCellinfo->pCI = pci;
415 memcpy(&servedCellinfo->cellId, cellId, sizeof(ECGI_t));
416 memcpy(&servedCellinfo->tAC, tac, sizeof(TAC_t));
418 for (auto v : broadcastPLMNs) {
419 ASN_SEQUENCE_ADD(&servedCellinfo->broadcastPLMNs.list, &v);
422 memcpy(&servedCellinfo->eUTRA_Mode_Info, eutranModeInfo, sizeof(EUTRA_Mode_Info_t));
424 if (mdclog_level_get() >= MDCLOG_DEBUG) {
425 checkAndPrint(&asn_DEF_ServedCell_Information, servedCellinfo, (char *)"ServedCell_Information_t", __func__);
428 return servedCellinfo;
432 ServedCells__Member *createServedCellsMember(ServedCell_Information_t *servedCellInfo, Neighbour_Information_t *neighbourInformation) {
433 printEntry("ServedCells__Member", __func__)
434 auto servedCellMember = (ServedCells__Member *)calloc(1, sizeof(ServedCells__Member));
436 memcpy(&servedCellMember->servedCellInfo, servedCellInfo, sizeof(ServedCell_Information_t));
437 servedCellMember->neighbour_Info = neighbourInformation;
439 if (mdclog_level_get() >= MDCLOG_DEBUG) {
440 checkAndPrint(&asn_DEF_ServedCells, servedCellMember, (char *)"ServedCells__Member", __func__);
443 return servedCellMember;
446 void buildServedCells(ServedCells_t *servedCells, ServedCells__Member *member) {
447 ASN_SEQUENCE_ADD(&servedCells->list, member);
451 static void buildInitiatingMessagePDU(E2AP_PDU_t &pdu, InitiatingMessage_t *initMsg) {
452 pdu.present = E2AP_PDU_PR_initiatingMessage;
453 pdu.choice.initiatingMessage = initMsg;
457 static void buildInitMsg(InitiatingMessage_t &initMsg,
458 InitiatingMessage__value_PR present,
459 ProcedureCode_t procedureCode,
460 Criticality_t criticality,
462 initMsg.value.present = present;
463 initMsg.procedureCode = procedureCode;
464 initMsg.criticality = criticality;
467 case InitiatingMessage__value_PR_RICsubscriptionRequest: {
468 memcpy(&initMsg.value.choice.RICsubscriptionRequest, value, sizeof(*value));
471 case InitiatingMessage__value_PR_RICsubscriptionDeleteRequest: {
472 memcpy(&initMsg.value.choice.RICsubscriptionDeleteRequest, value, sizeof(*value));
475 case InitiatingMessage__value_PR_RICserviceUpdate: {
476 memcpy(&initMsg.value.choice.RICserviceUpdate, value, sizeof(*value));
479 case InitiatingMessage__value_PR_RICcontrolRequest: {
480 memcpy(&initMsg.value.choice.RICcontrolRequest, value, sizeof(*value));
483 case InitiatingMessage__value_PR_X2SetupRequest: {
484 memcpy(&initMsg.value.choice.X2SetupRequest, value, sizeof(*value));
487 case InitiatingMessage__value_PR_ENDCX2SetupRequest: {
488 memcpy(&initMsg.value.choice.ENDCX2SetupRequest, value, sizeof(*value));
491 case InitiatingMessage__value_PR_ResourceStatusRequest: {
492 memcpy(&initMsg.value.choice.ResourceStatusRequest, value, sizeof(*value));
495 case InitiatingMessage__value_PR_ENBConfigurationUpdate: {
496 memcpy(&initMsg.value.choice.ENBConfigurationUpdate, value, sizeof(*value));
499 case InitiatingMessage__value_PR_ENDCConfigurationUpdate: {
500 memcpy(&initMsg.value.choice.ENDCConfigurationUpdate, value, sizeof(*value));
503 case InitiatingMessage__value_PR_ResetRequest: {
504 memcpy(&initMsg.value.choice.ResetRequest, value, sizeof(*value));
507 case InitiatingMessage__value_PR_RICindication: {
508 memcpy(&initMsg.value.choice.RICindication, value, sizeof(*value));
511 case InitiatingMessage__value_PR_RICserviceQuery: {
512 memcpy(&initMsg.value.choice.RICserviceQuery, value, sizeof(*value));
515 case InitiatingMessage__value_PR_LoadInformation: {
516 memcpy(&initMsg.value.choice.LoadInformation, value, sizeof(*value));
519 case InitiatingMessage__value_PR_GNBStatusIndication: {
520 memcpy(&initMsg.value.choice.GNBStatusIndication, value, sizeof(*value));
523 case InitiatingMessage__value_PR_ResourceStatusUpdate: {
524 memcpy(&initMsg.value.choice.ResourceStatusUpdate, value, sizeof(*value));
527 case InitiatingMessage__value_PR_ErrorIndication: {
528 memcpy(&initMsg.value.choice.ErrorIndication, value, sizeof(*value));
531 case InitiatingMessage__value_PR_NOTHING:
538 static void buildSuccsesfulMessagePDU(E2AP_PDU_t &pdu, SuccessfulOutcome_t *succMsg) {
539 pdu.present = E2AP_PDU_PR_successfulOutcome;
540 pdu.choice.successfulOutcome = succMsg;
544 static void buildSuccMsg(SuccessfulOutcome_t &succMsg,
545 SuccessfulOutcome__value_PR present,
546 ProcedureCode_t procedureCode,
547 Criticality_t criticality,
549 succMsg.value.present = present;
550 succMsg.procedureCode = procedureCode;
551 succMsg.criticality = criticality;
554 case SuccessfulOutcome__value_PR_RICsubscriptionResponse: {
555 memcpy(&succMsg.value.choice.RICsubscriptionResponse, value, sizeof(*value));
558 case SuccessfulOutcome__value_PR_RICsubscriptionDeleteResponse: {
559 memcpy(&succMsg.value.choice.RICsubscriptionDeleteResponse, value, sizeof(*value));
562 case SuccessfulOutcome__value_PR_RICserviceUpdateAcknowledge: {
563 memcpy(&succMsg.value.choice.RICserviceUpdateAcknowledge, value, sizeof(*value));
566 case SuccessfulOutcome__value_PR_RICcontrolAcknowledge: {
567 memcpy(&succMsg.value.choice.RICcontrolAcknowledge, value, sizeof(*value));
570 case SuccessfulOutcome__value_PR_X2SetupResponse: {
571 memcpy(&succMsg.value.choice.X2SetupResponse, value, sizeof(*value));
574 case SuccessfulOutcome__value_PR_ENDCX2SetupResponse: {
575 memcpy(&succMsg.value.choice.ENDCX2SetupResponse, value, sizeof(*value));
578 case SuccessfulOutcome__value_PR_ResourceStatusResponse: {
579 memcpy(&succMsg.value.choice.ResourceStatusResponse, value, sizeof(*value));
582 case SuccessfulOutcome__value_PR_ENBConfigurationUpdateAcknowledge: {
583 memcpy(&succMsg.value.choice.ENBConfigurationUpdateAcknowledge, value, sizeof(*value));
586 case SuccessfulOutcome__value_PR_ENDCConfigurationUpdateAcknowledge: {
587 memcpy(&succMsg.value.choice.ENDCConfigurationUpdateAcknowledge, value, sizeof(*value));
590 case SuccessfulOutcome__value_PR_ResetResponse: {
591 memcpy(&succMsg.value.choice.ResetResponse, value, sizeof(*value));
594 case SuccessfulOutcome__value_PR_NOTHING:
601 static void buildUnSucssesfullMessagePDU(E2AP_PDU_t &pdu, UnsuccessfulOutcome_t *unSuccMsg) {
602 pdu.present = E2AP_PDU_PR_unsuccessfulOutcome;
603 pdu.choice.unsuccessfulOutcome = unSuccMsg;
607 static void buildUnSuccMsg(UnsuccessfulOutcome_t &unSuccMsg,
608 UnsuccessfulOutcome__value_PR present,
609 ProcedureCode_t procedureCode,
610 Criticality_t criticality,
612 unSuccMsg.value.present = present;
613 unSuccMsg.procedureCode = procedureCode;
614 unSuccMsg.criticality = criticality;
617 case UnsuccessfulOutcome__value_PR_RICsubscriptionFailure: {
618 memcpy(&unSuccMsg.value.choice.RICsubscriptionFailure, value, sizeof(*value));
621 case UnsuccessfulOutcome__value_PR_RICsubscriptionDeleteFailure: {
622 memcpy(&unSuccMsg.value.choice.RICsubscriptionDeleteFailure, value, sizeof(*value));
625 case UnsuccessfulOutcome__value_PR_RICserviceUpdateFailure: {
626 memcpy(&unSuccMsg.value.choice.RICserviceUpdateFailure, value, sizeof(*value));
629 case UnsuccessfulOutcome__value_PR_RICcontrolFailure: {
630 memcpy(&unSuccMsg.value.choice.RICcontrolFailure, value, sizeof(*value));
633 case UnsuccessfulOutcome__value_PR_X2SetupFailure: {
634 memcpy(&unSuccMsg.value.choice.X2SetupFailure, value, sizeof(*value));
637 case UnsuccessfulOutcome__value_PR_ENDCX2SetupFailure: {
638 memcpy(&unSuccMsg.value.choice.ENDCX2SetupFailure, value, sizeof(*value));
641 case UnsuccessfulOutcome__value_PR_ResourceStatusFailure: {
642 memcpy(&unSuccMsg.value.choice.ResourceStatusFailure, value, sizeof(*value));
645 case UnsuccessfulOutcome__value_PR_ENBConfigurationUpdateFailure: {
646 memcpy(&unSuccMsg.value.choice.ENBConfigurationUpdateFailure, value, sizeof(*value));
649 case UnsuccessfulOutcome__value_PR_ENDCConfigurationUpdateFailure: {
650 memcpy(&unSuccMsg.value.choice.ENDCConfigurationUpdateFailure, value, sizeof(*value));
653 case UnsuccessfulOutcome__value_PR_NOTHING:
660 static void createPLMN_ID(PLMN_Identity_t &plmnId, const unsigned char *data) {
661 //printEntry("PLMN_Identity_t", __func__)
662 //PLMN_Identity_t *plmnId = calloc(1, sizeof(PLMN_Identity_t));
663 ASN_STRUCT_RESET(asn_DEF_PLMN_Identity, &plmnId);
665 plmnId.buf = (uint8_t *) calloc(1, 3);
666 memcpy(plmnId.buf, data, 3);
668 if (mdclog_level_get() >= MDCLOG_DEBUG) {
669 checkAndPrint(&asn_DEF_PLMN_Identity, &plmnId, (char *) "PLMN_Identity_t", __func__);
674 static void createENB_ID(ENB_ID_t &enb, ENB_ID_PR enbType, unsigned char *data) {
675 //printEntry("ENB_ID_t", __func__)
676 ASN_STRUCT_RESET(asn_DEF_ENB_ID, &enb);
677 enb.present = enbType;
679 case ENB_ID_PR_macro_eNB_ID: { // 20 bit 3 bytes
680 enb.choice.macro_eNB_ID.size = 3;
681 enb.choice.macro_eNB_ID.bits_unused = 4;
683 enb.present = ENB_ID_PR_macro_eNB_ID;
685 enb.choice.macro_eNB_ID.buf = (uint8_t *) calloc(1, enb.choice.macro_eNB_ID.size);
686 data[enb.choice.macro_eNB_ID.size - 1] = ((unsigned) (data[enb.choice.macro_eNB_ID.size - 1]
687 >> (unsigned) enb.choice.macro_eNB_ID.bits_unused)
688 << (unsigned) enb.choice.macro_eNB_ID.bits_unused);
689 memcpy(enb.choice.macro_eNB_ID.buf, data, enb.choice.macro_eNB_ID.size);
693 case ENB_ID_PR_home_eNB_ID: { // 28 bit 4 bytes
694 enb.choice.home_eNB_ID.size = 4;
695 enb.choice.home_eNB_ID.bits_unused = 4;
696 enb.present = ENB_ID_PR_home_eNB_ID;
698 enb.choice.home_eNB_ID.buf = (uint8_t *) calloc(1, enb.choice.home_eNB_ID.size);
699 data[enb.choice.home_eNB_ID.size - 1] = ((unsigned) (data[enb.choice.home_eNB_ID.size - 1]
700 >> (unsigned) enb.choice.home_eNB_ID.bits_unused)
701 << (unsigned) enb.choice.home_eNB_ID.bits_unused);
702 memcpy(enb.choice.home_eNB_ID.buf, data, enb.choice.home_eNB_ID.size);
705 case ENB_ID_PR_short_Macro_eNB_ID: { // 18 bit - 3 bytes
706 enb.choice.short_Macro_eNB_ID.size = 3;
707 enb.choice.short_Macro_eNB_ID.bits_unused = 6;
708 enb.present = ENB_ID_PR_short_Macro_eNB_ID;
710 enb.choice.short_Macro_eNB_ID.buf = (uint8_t *) calloc(1, enb.choice.short_Macro_eNB_ID.size);
711 data[enb.choice.short_Macro_eNB_ID.size - 1] = ((unsigned) (data[enb.choice.short_Macro_eNB_ID.size - 1]
712 >> (unsigned) enb.choice.short_Macro_eNB_ID.bits_unused)
713 << (unsigned) enb.choice.short_Macro_eNB_ID.bits_unused);
714 memcpy(enb.choice.short_Macro_eNB_ID.buf, data, enb.choice.short_Macro_eNB_ID.size);
717 case ENB_ID_PR_long_Macro_eNB_ID: { // 21
718 enb.choice.long_Macro_eNB_ID.size = 3;
719 enb.choice.long_Macro_eNB_ID.bits_unused = 3;
720 enb.present = ENB_ID_PR_long_Macro_eNB_ID;
722 enb.choice.long_Macro_eNB_ID.buf = (uint8_t *) calloc(1, enb.choice.long_Macro_eNB_ID.size);
723 data[enb.choice.long_Macro_eNB_ID.size - 1] = ((unsigned) (data[enb.choice.long_Macro_eNB_ID.size - 1]
724 >> (unsigned) enb.choice.long_Macro_eNB_ID.bits_unused)
725 << (unsigned) enb.choice.long_Macro_eNB_ID.bits_unused);
726 memcpy(enb.choice.long_Macro_eNB_ID.buf, data, enb.choice.long_Macro_eNB_ID.size);
733 if (mdclog_level_get() >= MDCLOG_DEBUG) {
734 checkAndPrint(&asn_DEF_ENB_ID, &enb, (char *) "ENB_ID_t", __func__);
739 static void buildGlobalENB_ID(GlobalENB_ID_t *gnbId,
740 const unsigned char *gnbData,
742 unsigned char *enbData) {
743 createPLMN_ID(gnbId->pLMN_Identity, gnbData);
744 createENB_ID(gnbId->eNB_ID, enbType, enbData);
745 if (mdclog_level_get() >= MDCLOG_DEBUG) {
746 checkAndPrint(&asn_DEF_GlobalENB_ID, gnbId, (char *) "GlobalENB_ID_t", __func__);
750 #endif //E2_E2BUILDER_H