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 * This source code is part of the near-RT RIC (RAN Intelligent Controller)
20 * platform project (RICP).
25 // Created by adi ENZEL on 6/19/19.
30 #define printEntry(type, function) \
31 if (mdclog_level_get() >= MDCLOG_DEBUG) { \
32 mdclog_write(MDCLOG_DEBUG, "start Test %s , %s", type, function); \
36 static void checkAndPrint(asn_TYPE_descriptor_t *typeDescriptor, void *data, char *dataType, const char *function) {
37 char errbuf[128]; /* Buffer for error message */
38 size_t errlen = sizeof(errbuf); /* Size of the buffer */
39 if (asn_check_constraints(typeDescriptor, data, errbuf, &errlen) != 0) {
40 mdclog_write(MDCLOG_ERR, "%s Constraint validation failed: %s", dataType, errbuf);
41 } else if (mdclog_level_get() >= MDCLOG_DEBUG) {
42 mdclog_write(MDCLOG_DEBUG, "%s successes function %s", dataType, function);
46 static size_t encodebuff(int codingType,
47 asn_TYPE_descriptor_t *typeDescriptor,
52 struct timespec start = {0,0};
53 struct timespec end = {0,0};
54 clock_gettime(CLOCK_MONOTONIC, &start);
55 er = asn_encode_to_buffer(0, codingType, typeDescriptor, objectData, buffer, buffer_size);
56 clock_gettime(CLOCK_MONOTONIC, &end);
57 if (er.encoded == -1) {
58 mdclog_write(MDCLOG_ERR, "encoding of %s failed, %s", asn_DEF_E2SM_gNB_X2_eventTriggerDefinition.name, strerror(errno));
59 } else if (er.encoded > buffer_size) {
60 mdclog_write(MDCLOG_ERR, "Buffer of size %d is to small for %s", (int) buffer_size,
61 typeDescriptor->name);
62 } else if (mdclog_level_get() >= MDCLOG_DEBUG) {
63 if (codingType == ATS_BASIC_XER) {
64 mdclog_write(MDCLOG_DEBUG, "Buffer of size %d, data = %s", (int) er.encoded, buffer);
67 if (mdclog_level_get() >= MDCLOG_INFO) {
70 FILE *stream = open_memstream(&printBuffer, &size);
71 asn_fprint(stream, typeDescriptor, objectData);
72 mdclog_write(MDCLOG_DEBUG, "Encoding E2SM PDU past : %s", printBuffer);
76 mdclog_write(MDCLOG_DEBUG, "Buffer of size %d", (int) er.encoded);
79 mdclog_write(MDCLOG_INFO, "Encoding type %d, time is %ld seconds, %ld nanoseconds", codingType, end.tv_sec - start.tv_sec, end.tv_nsec - start.tv_nsec);
80 //mdclog_write(MDCLOG_INFO, "Encoding time is %3.9f seconds", ((double)end.tv_sec + 1.0e-9 * end.tv_nsec) - ((double)start.tv_sec + 1.0e-9 * start.tv_nsec));
84 PLMN_Identity_t *createPLMN_ID(const unsigned char *data) {
85 printEntry("PLMN_Identity_t", __func__);
86 PLMN_Identity_t *plmnId = calloc(1, sizeof(PLMN_Identity_t));
87 ASN_STRUCT_RESET(asn_DEF_PLMN_Identity, plmnId);
89 plmnId->buf = calloc(1, 3);
90 memcpy(plmnId->buf, data, 3);
92 if (mdclog_level_get() >= MDCLOG_DEBUG) {
93 checkAndPrint(&asn_DEF_PLMN_Identity, plmnId, "PLMN_Identity_t", __func__);
99 ENB_ID_t *createENB_ID(ENB_ID_PR enbType, unsigned char *data) {
100 printEntry("ENB_ID_t", __func__);
101 ENB_ID_t *enb = calloc(1, sizeof(ENB_ID_t));
102 ASN_STRUCT_RESET(asn_DEF_ENB_ID, enb);
104 case ENB_ID_PR_macro_eNB_ID: { // 20 bit 3 bytes
105 enb->choice.macro_eNB_ID.size = 3;
106 enb->choice.macro_eNB_ID.bits_unused = 4;
108 enb->present = ENB_ID_PR_macro_eNB_ID;
110 enb->choice.macro_eNB_ID.buf = calloc(1, enb->choice.macro_eNB_ID.size);
111 data[enb->choice.macro_eNB_ID.size - 1] = ((unsigned)(data[enb->choice.macro_eNB_ID.size - 1] >>
112 (unsigned)enb->choice.macro_eNB_ID.bits_unused) << (unsigned)enb->choice.macro_eNB_ID.bits_unused);
113 memcpy(enb->choice.macro_eNB_ID.buf, data, enb->choice.macro_eNB_ID.size);
117 case ENB_ID_PR_home_eNB_ID: { // 28 bit 4 bytes
118 enb->choice.home_eNB_ID.size = 4;
119 enb->choice.home_eNB_ID.bits_unused = 4;
120 enb->present = ENB_ID_PR_home_eNB_ID;
122 enb->choice.home_eNB_ID.buf = calloc(1, enb->choice.home_eNB_ID.size);
123 data[enb->choice.home_eNB_ID.size - 1] = ((unsigned)(data[enb->choice.home_eNB_ID.size - 1] >>
124 (unsigned)enb->choice.home_eNB_ID.bits_unused) << (unsigned)enb->choice.home_eNB_ID.bits_unused);
125 memcpy(enb->choice.home_eNB_ID.buf, data, enb->choice.home_eNB_ID.size);
128 case ENB_ID_PR_short_Macro_eNB_ID: { // 18 bit - 3 bytes
129 enb->choice.short_Macro_eNB_ID.size = 3;
130 enb->choice.short_Macro_eNB_ID.bits_unused = 6;
131 enb->present = ENB_ID_PR_short_Macro_eNB_ID;
133 enb->choice.short_Macro_eNB_ID.buf = calloc(1, enb->choice.short_Macro_eNB_ID.size);
134 data[enb->choice.short_Macro_eNB_ID.size - 1] = ((unsigned)(data[enb->choice.short_Macro_eNB_ID.size - 1] >>
135 (unsigned)enb->choice.short_Macro_eNB_ID.bits_unused) << (unsigned)enb->choice.short_Macro_eNB_ID.bits_unused);
136 memcpy(enb->choice.short_Macro_eNB_ID.buf, data, enb->choice.short_Macro_eNB_ID.size);
139 case ENB_ID_PR_long_Macro_eNB_ID: { // 21
140 enb->choice.long_Macro_eNB_ID.size = 3;
141 enb->choice.long_Macro_eNB_ID.bits_unused = 3;
142 enb->present = ENB_ID_PR_long_Macro_eNB_ID;
144 enb->choice.long_Macro_eNB_ID.buf = calloc(1, enb->choice.long_Macro_eNB_ID.size);
145 data[enb->choice.long_Macro_eNB_ID.size - 1] = ((unsigned)(data[enb->choice.long_Macro_eNB_ID.size - 1] >>
146 (unsigned)enb->choice.long_Macro_eNB_ID.bits_unused) << (unsigned)enb->choice.long_Macro_eNB_ID.bits_unused);
147 memcpy(enb->choice.long_Macro_eNB_ID.buf, data, enb->choice.long_Macro_eNB_ID.size);
156 if (mdclog_level_get() >= MDCLOG_DEBUG) {
157 checkAndPrint(&asn_DEF_ENB_ID, enb, "ENB_ID_t", __func__);
162 GNB_ID_t *createGnb_id(const unsigned char *data, int numOfBits) {
163 printEntry("GNB_ID_t", __func__);
164 if (numOfBits < 22 || numOfBits > 32) {
165 mdclog_write(MDCLOG_ERR, "GNB_ID_t number of bits = %d, needs to be 22 .. 32", numOfBits);
168 GNB_ID_t *gnb = calloc(1, sizeof(GNB_ID_t));
169 ASN_STRUCT_RESET(asn_DEF_GNB_ID, gnb);
171 gnb->present = GNB_ID_PR_gNB_ID;
172 gnb->choice.gNB_ID.size = numOfBits % 8 == 0 ? (unsigned int)(numOfBits / 8) : (unsigned int)(numOfBits / 8 + 1);
173 gnb->choice.gNB_ID.bits_unused = gnb->choice.gNB_ID.size * 8 - numOfBits;
174 gnb->choice.gNB_ID.buf = calloc(1, gnb->choice.gNB_ID.size);
175 memcpy(gnb->choice.gNB_ID.buf, data, gnb->choice.gNB_ID.size);
176 gnb->choice.gNB_ID.buf[gnb->choice.gNB_ID.size - 1] =
177 ((unsigned)(gnb->choice.gNB_ID.buf[gnb->choice.gNB_ID.size - 1] >> (unsigned)gnb->choice.gNB_ID.bits_unused)
178 << (unsigned)gnb->choice.gNB_ID.bits_unused);
180 if (mdclog_level_get() >= MDCLOG_DEBUG) {
181 checkAndPrint(&asn_DEF_GNB_ID, gnb, "GNB_ID_t", __func__);
188 GlobalENB_ID_t *createGlobalENB_ID(PLMN_Identity_t *plmnIdentity, ENB_ID_t *enbId) {
189 printEntry("GlobalENB_ID_t", __func__);
190 GlobalENB_ID_t *genbId = calloc(1, sizeof(GlobalENB_ID_t));
191 ASN_STRUCT_RESET(asn_DEF_GlobalENB_ID, genbId);
192 memcpy(&genbId->pLMN_Identity, plmnIdentity, sizeof(PLMN_Identity_t));
193 memcpy(&genbId->eNB_ID, enbId, sizeof(ENB_ID_t));
195 if (mdclog_level_get() >= MDCLOG_DEBUG) {
196 checkAndPrint(&asn_DEF_GlobalENB_ID, genbId, "GlobalENB_ID_t", __func__);
201 GlobalGNB_ID_t *createGlobalGNB_ID(PLMN_Identity_t *plmnIdentity, GNB_ID_t *gnb) {
202 printEntry("GlobalGNB_ID_t", __func__);
203 GlobalGNB_ID_t *ggnbId = calloc(1, sizeof(GlobalGNB_ID_t));
204 ASN_STRUCT_RESET(asn_DEF_GlobalGNB_ID, ggnbId);
206 memcpy(&ggnbId->pLMN_Identity, plmnIdentity, sizeof(PLMN_Identity_t));
207 memcpy(&ggnbId->gNB_ID, gnb, sizeof(GNB_ID_t));
209 if (mdclog_level_get() >= MDCLOG_DEBUG) {
210 checkAndPrint(&asn_DEF_GlobalGNB_ID, ggnbId, "GlobalGNB_ID_t", __func__);
217 Interface_ID_t *createInterfaceIDForGnb(GlobalGNB_ID_t *gnb) {
218 printEntry("Interface_ID_t", __func__);
219 Interface_ID_t *interfaceId = calloc(1, sizeof(Interface_ID_t));
220 ASN_STRUCT_RESET(asn_DEF_Interface_ID, interfaceId);
222 interfaceId->present = Interface_ID_PR_global_gNB_ID;
223 //memcpy(&interfaceId->choice.global_gNB_ID, gnb, sizeof(GlobalGNB_ID_t));
224 interfaceId->choice.global_gNB_ID = gnb;
226 if (mdclog_level_get() >= MDCLOG_DEBUG) {
227 checkAndPrint(&asn_DEF_Interface_ID, interfaceId, "Interface_ID_t", __func__);
233 Interface_ID_t *createInterfaceIDForEnb(GlobalENB_ID_t *enb) {
234 printEntry("Interface_ID_t", __func__);
235 Interface_ID_t *interfaceId = calloc(1, sizeof(Interface_ID_t));
236 ASN_STRUCT_RESET(asn_DEF_Interface_ID, interfaceId);
238 interfaceId->present = Interface_ID_PR_global_eNB_ID;
239 //memcpy(&interfaceId->choice.global_eNB_ID, enb, sizeof(GlobalENB_ID_t));
240 interfaceId->choice.global_eNB_ID = enb;
242 if (mdclog_level_get() >= MDCLOG_DEBUG) {
243 checkAndPrint(&asn_DEF_Interface_ID, interfaceId, "Interface_ID_t", __func__);
251 InterfaceMessageType_t *createInterfaceMessageInitiating(long procedureCode) {
252 printEntry("InterfaceMessageType_t", __func__);
253 InterfaceMessageType_t *intMsgT = calloc(1, sizeof(InterfaceMessageType_t));
254 ASN_STRUCT_RESET(asn_DEF_InterfaceMessageType, intMsgT);
256 intMsgT->procedureCode = procedureCode;
257 intMsgT->typeOfMessage = TypeOfMessage_initiating_message;
259 if (mdclog_level_get() >= MDCLOG_DEBUG) {
260 checkAndPrint(&asn_DEF_InterfaceMessageType, intMsgT, "InterfaceMessageType_t", __func__);
266 InterfaceMessageType_t *createInterfaceMessageSuccsesful(long procedureCode) {
267 printEntry("InterfaceMessageType_t", __func__);
268 InterfaceMessageType_t *intMsgT = calloc(1, sizeof(InterfaceMessageType_t));
269 ASN_STRUCT_RESET(asn_DEF_InterfaceMessageType, intMsgT);
271 intMsgT->procedureCode = procedureCode;
272 intMsgT->typeOfMessage = TypeOfMessage_successful_outcome;
274 if (mdclog_level_get() >= MDCLOG_DEBUG) {
275 checkAndPrint(&asn_DEF_InterfaceMessageType, intMsgT, "InterfaceMessageType_t", __func__);
281 InterfaceMessageType_t *createInterfaceMessageUnsuccessful(long procedureCode) {
282 printEntry("InterfaceMessageType_t", __func__);
283 InterfaceMessageType_t *intMsgT = calloc(1, sizeof(InterfaceMessageType_t));
284 ASN_STRUCT_RESET(asn_DEF_InterfaceMessageType, intMsgT);
286 intMsgT->procedureCode = procedureCode;
287 intMsgT->typeOfMessage = TypeOfMessage_unsuccessful_outcome;
289 if (mdclog_level_get() >= MDCLOG_DEBUG) {
290 checkAndPrint(&asn_DEF_InterfaceMessageType, intMsgT, "InterfaceMessageType_t", __func__);
296 InterfaceProtocolIE_Value_t *createInterfaceProtocolValueInt(long number) {
297 printEntry("InterfaceProtocolIE_Value_t", __func__);
298 InterfaceProtocolIE_Value_t *value = calloc(1, sizeof(InterfaceProtocolIE_Value_t));
299 ASN_STRUCT_RESET(asn_DEF_InterfaceProtocolIE_Value, value);
301 value->present = InterfaceProtocolIE_Value_PR_valueInt;
302 value->choice.valueInt = number;
304 if (mdclog_level_get() >= MDCLOG_DEBUG) {
305 checkAndPrint(&asn_DEF_InterfaceProtocolIE_Value, value, "InterfaceProtocolIE_Value_t", __func__);
311 InterfaceProtocolIE_Value_t *createInterfaceProtocolValueEnum(long number) {
312 printEntry("InterfaceProtocolIE_Value_t", __func__);
313 InterfaceProtocolIE_Value_t *value = calloc(1, sizeof(InterfaceProtocolIE_Value_t));
314 ASN_STRUCT_RESET(asn_DEF_InterfaceProtocolIE_Value, value);
316 value->present = InterfaceProtocolIE_Value_PR_valueEnum;
317 value->choice.valueEnum = number;
319 if (mdclog_level_get() >= MDCLOG_DEBUG) {
320 checkAndPrint(&asn_DEF_InterfaceProtocolIE_Value, value, "InterfaceProtocolIE_Value_t", __func__);
326 InterfaceProtocolIE_Value_t *createInterfaceProtocolValueBool(int val) {
327 printEntry("InterfaceProtocolIE_Value_t", __func__);
328 InterfaceProtocolIE_Value_t *value = calloc(1, sizeof(InterfaceProtocolIE_Value_t));
329 ASN_STRUCT_RESET(asn_DEF_InterfaceProtocolIE_Value, value);
331 value->present = InterfaceProtocolIE_Value_PR_valueBool;
332 value->choice.valueBool = val == 0 ? 0 : 1;
334 if (mdclog_level_get() >= MDCLOG_DEBUG) {
335 checkAndPrint(&asn_DEF_InterfaceProtocolIE_Value, value, "InterfaceProtocolIE_Value_t", __func__);
342 InterfaceProtocolIE_Value_t *createInterfaceProtocolValueBitString(unsigned char *buf, int numOfBits) {
343 printEntry("InterfaceProtocolIE_Value_t", __func__);
344 size_t size = numOfBits % 8 == 0 ? (unsigned int)(numOfBits / 8) : (unsigned int)(numOfBits / 8 + 1);
345 if (strlen((const char *)buf) < size) {
346 mdclog_write(MDCLOG_ERR, "size of buffer is small : %d needs to be %d in %s", (int)strlen((const char *)buf), (int)size, __func__);
348 InterfaceProtocolIE_Value_t *value = calloc(1, sizeof(InterfaceProtocolIE_Value_t));
349 ASN_STRUCT_RESET(asn_DEF_InterfaceProtocolIE_Value, value);
351 value->present = InterfaceProtocolIE_Value_PR_valueBitS;
352 value->choice.valueBitS.size = numOfBits % 8 == 0 ? (unsigned int)(numOfBits / 8) : (unsigned int)(numOfBits / 8 + 1);
353 value->choice.valueBitS.buf = calloc(1, value->choice.valueBitS.size);
354 int bits_unused = value->choice.valueBitS.size * 8 - numOfBits;
355 value->choice.valueBitS.bits_unused = bits_unused;
357 memcpy(value->choice.valueBitS.buf, buf, value->choice.valueBitS.size);
358 value->choice.valueBitS.buf[size -1] = ((unsigned)(buf[size - 1]) >> (unsigned)bits_unused << (unsigned)bits_unused);
360 if (mdclog_level_get() >= MDCLOG_DEBUG) {
361 checkAndPrint(&asn_DEF_InterfaceProtocolIE_Value, value, "InterfaceProtocolIE_Value_t", __func__);
368 InterfaceProtocolIE_Value_t *createInterfaceProtocolValueOCTETS(uint8_t *buf) {
369 printEntry("InterfaceProtocolIE_Value_t", __func__);
370 size_t size = strlen((const char *)buf);
371 InterfaceProtocolIE_Value_t *value = calloc(1, sizeof(InterfaceProtocolIE_Value_t));
372 ASN_STRUCT_RESET(asn_DEF_InterfaceProtocolIE_Value, value);
374 value->present = InterfaceProtocolIE_Value_PR_valueOctS;
375 value->choice.valueOctS.size = size;
376 value->choice.valueOctS.buf = calloc(1, value->choice.valueOctS.size);
377 memcpy(value->choice.valueOctS.buf, buf, value->choice.valueOctS.size);
379 if (mdclog_level_get() >= MDCLOG_DEBUG) {
380 checkAndPrint(&asn_DEF_InterfaceProtocolIE_Value, value, "InterfaceProtocolIE_Value_t", __func__);
387 InterfaceProtocolIE_Item_t *createInterfaceProtocolIE_Item(long id, long test, InterfaceProtocolIE_Value_t *value) {
388 printEntry("InterfaceProtocolIE_Item_t", __func__);
389 if (test < InterfaceProtocolIE_Test_equal || test > InterfaceProtocolIE_Test_present) {
390 mdclog_write(MDCLOG_ERR, "InterfaceProtocolIE_Item_t test value is %ld, out of scope %d .. %d ",
391 test, InterfaceProtocolIE_Test_equal, InterfaceProtocolIE_Test_present);
394 InterfaceProtocolIE_Item_t *intProtIt = calloc(1, sizeof(InterfaceProtocolIE_Item_t));
395 ASN_STRUCT_RESET(asn_DEF_InterfaceProtocolIE_Item, intProtIt);
398 intProtIt->interfaceProtocolIE_ID = id;
400 intProtIt->interfaceProtocolIE_Test = test;
402 memcpy(&intProtIt->interfaceProtocolIE_Value, value, sizeof(InterfaceProtocolIE_Value_t));
404 if (mdclog_level_get() >= MDCLOG_DEBUG) {
405 checkAndPrint(&asn_DEF_InterfaceProtocolIE_Item, intProtIt, "InterfaceProtocolIE_Item_t", __func__);
414 ActionParameter_Value_t *createActionParameterValue_Int(long number) {
415 printEntry("ActionParameter_Value_t", __func__);
416 ActionParameter_Value_t *value = calloc(1, sizeof(ActionParameter_Value_t));
417 ASN_STRUCT_RESET(asn_DEF_ActionParameter_Value, value);
419 value->present = ActionParameter_Value_PR_valueInt;
420 value->choice.valueInt = number;
422 if (mdclog_level_get() >= MDCLOG_DEBUG) {
423 checkAndPrint(&asn_DEF_ActionParameter_Value, value, "ActionParameter_Value_t", __func__);
429 ActionParameter_Value_t *createActionParameterValue_Enum(long number) {
430 printEntry("ActionParameter_Value_t", __func__);
431 ActionParameter_Value_t *value = calloc(1, sizeof(ActionParameter_Value_t));
432 ASN_STRUCT_RESET(asn_DEF_ActionParameter_Value, value);
434 value->present = ActionParameter_Value_PR_valueEnum;
435 value->choice.valueEnum = number;
437 if (mdclog_level_get() >= MDCLOG_DEBUG) {
438 checkAndPrint(&asn_DEF_ActionParameter_Value, value, "ActionParameter_Value_t", __func__);
444 ActionParameter_Value_t *createActionParameterValue_Bool(int val) {
445 printEntry("ActionParameter_Value_t", __func__);
446 ActionParameter_Value_t *value = calloc(1, sizeof(ActionParameter_Value_t));
447 ASN_STRUCT_RESET(asn_DEF_ActionParameter_Value, value);
449 value->present = ActionParameter_Value_PR_valueBool;
450 value->choice.valueBool = val == 0 ? 0 : 1;
452 if (mdclog_level_get() >= MDCLOG_DEBUG) {
453 checkAndPrint(&asn_DEF_ActionParameter_Value, value, "ActionParameter_Value_t", __func__);
460 ActionParameter_Value_t *createActionParameterValue_Bit_String(unsigned char *buf, int numOfBits) {
461 printEntry("ActionParameter_Value_t", __func__);
462 size_t size = numOfBits % 8 == 0 ? (unsigned int)(numOfBits / 8) : (unsigned int)(numOfBits / 8 + 1);
463 if (strlen((const char *)buf) < size) {
464 mdclog_write(MDCLOG_ERR, "size of buffer is small : %d needs to be %d in %s", (int)strlen((const char *)buf), (int)size, __func__);
466 int bits_unused = size * 8 - numOfBits;
468 ActionParameter_Value_t *value = calloc(1, sizeof(ActionParameter_Value_t));
469 ASN_STRUCT_RESET(asn_DEF_ActionParameter_Value, value);
471 value->present = ActionParameter_Value_PR_valueBitS;
472 value->choice.valueBitS.size = size;
473 value->choice.valueBitS.buf = calloc(1, size);
474 value->choice.valueBitS.bits_unused = bits_unused;
476 memcpy(value->choice.valueBitS.buf, buf, size);
477 value->choice.valueBitS.buf[size -1] = ((unsigned)(buf[size - 1]) >> (unsigned)bits_unused << (unsigned)bits_unused);
479 if (mdclog_level_get() >= MDCLOG_DEBUG) {
480 checkAndPrint(&asn_DEF_ActionParameter_Value, value, "ActionParameter_Value_t", __func__);
487 ActionParameter_Value_t *createActionParameterValue_OCTETS(uint8_t *buf) {
488 printEntry("ActionParameter_Value_t", __func__);
489 size_t size = strlen((const char *)buf);
490 ActionParameter_Value_t *value = calloc(1, sizeof(ActionParameter_Value_t));
491 ASN_STRUCT_RESET(asn_DEF_ActionParameter_Value, value);
493 value->present = ActionParameter_Value_PR_valueOctS;
494 value->choice.valueOctS.size = size;
495 value->choice.valueOctS.buf = calloc(1, value->choice.valueOctS.size);
496 memcpy(value->choice.valueOctS.buf, buf, value->choice.valueOctS.size);
498 if (mdclog_level_get() >= MDCLOG_DEBUG) {
499 checkAndPrint(&asn_DEF_ActionParameter_Value, value, "ActionParameter_Value_t", __func__);
507 * @param buf buffer that must be null terminated
508 * @return ActionParameter_Value_t *
510 ActionParameter_Value_t *createActionParameterValue_PRINTS(char *buf) {
511 printEntry("ActionParameter_Value_t", __func__);
512 size_t size = strlen((const char *)buf);
513 ActionParameter_Value_t *value = calloc(1, sizeof(ActionParameter_Value_t));
514 ASN_STRUCT_RESET(asn_DEF_ActionParameter_Value, value);
516 value->present = ActionParameter_Value_PR_valuePrtS;
517 value->choice.valuePrtS.size = size;
518 value->choice.valuePrtS.buf = calloc(1, value->choice.valuePrtS.size);
519 memcpy(value->choice.valuePrtS.buf, buf, value->choice.valuePrtS.size);
521 if (mdclog_level_get() >= MDCLOG_DEBUG) {
522 checkAndPrint(&asn_DEF_ActionParameter_Value, value, "ActionParameter_Value_t", __func__);
528 ActionParameter_Item_t *creatActionParameter_Item(long id, ActionParameter_Value_t *val) {
529 printEntry("ActionParameter_Item_t", __func__);
530 if (id < 0 || id > 255) {
531 mdclog_write(MDCLOG_ERR, "ActionParameter_Item_t id = %ld, values are 0 .. 255", id);
534 ActionParameter_Item_t *actionParameterItem = calloc(1, sizeof(ActionParameter_Item_t));
535 ASN_STRUCT_RESET(asn_DEF_ActionParameter_Item, actionParameterItem);
537 actionParameterItem->actionParameter_ID = id;
538 memcpy(&actionParameterItem->actionParameter_Value, val, sizeof(ActionParameter_Value_t));
540 if (mdclog_level_get() >= MDCLOG_DEBUG) {
541 checkAndPrint(&asn_DEF_ActionParameter_Item, actionParameterItem, "ActionParameter_Item_t", __func__);
544 return actionParameterItem;
552 * @param interfaceProtocolItemList
558 size_t createEventTrigger(Interface_ID_t *interfaceId, long direction,
559 InterfaceMessageType_t *messageType,
560 InterfaceProtocolIE_Item_t interfaceProtocolItemList[],
563 size_t buffer_size) {
564 printEntry("E2SM_gNB_X2_eventTriggerDefinition_t", __func__);
565 if (direction < InterfaceDirection_incoming || direction > InterfaceDirection_outgoing) {
566 mdclog_write(MDCLOG_ERR, "E2SM_gNB_X2_eventTriggerDefinition_t direction = %ld, values are %d .. %d",
567 direction, InterfaceDirection_incoming, InterfaceDirection_outgoing);
571 E2SM_gNB_X2_eventTriggerDefinition_t *eventTrigger = calloc(1, sizeof(E2SM_gNB_X2_eventTriggerDefinition_t));
572 ASN_STRUCT_RESET(asn_DEF_E2SM_gNB_X2_eventTriggerDefinition, eventTrigger);
574 memcpy(&eventTrigger->interface_ID , interfaceId, sizeof(Interface_ID_t));
576 eventTrigger->interfaceDirection = direction;
577 memcpy(&eventTrigger->interfaceMessageType, messageType, sizeof(InterfaceMessageType_t));
579 for (int i = 0; i < listSize; i++) {
580 ASN_SEQUENCE_ADD(eventTrigger->interfaceProtocolIE_List, &interfaceProtocolItemList[i]);
583 if (mdclog_level_get() >= MDCLOG_DEBUG) {
584 checkAndPrint(&asn_DEF_E2SM_gNB_X2_eventTriggerDefinition, eventTrigger, "E2SM_gNB_X2_eventTriggerDefinition_t", __func__);
587 size_t len = encodebuff(ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_eventTriggerDefinition,
593 if (mdclog_level_get() >= MDCLOG_INFO) {
596 encodebuff(ATS_BASIC_XER, &asn_DEF_E2SM_gNB_X2_eventTriggerDefinition,
607 size_t createActionDefinition(long styleId, ActionParameter_Item_t actionParamList[], int listSize,
609 size_t buffer_size) {
610 printEntry("E2SM_gNB_X2_actionDefinition_t", __func__);
611 E2SM_gNB_X2_actionDefinition_t *actDef = calloc(1, sizeof(E2SM_gNB_X2_actionDefinition_t));
612 ASN_STRUCT_RESET(asn_DEF_E2SM_gNB_X2_actionDefinition, actDef);
614 actDef->style_ID = styleId;
615 for (int i = 0; i < listSize; i++) {
616 ASN_SEQUENCE_ADD(actDef->actionParameter_List, &actionParamList[i]);
619 if (mdclog_level_get() >= MDCLOG_DEBUG) {
620 checkAndPrint(&asn_DEF_E2SM_gNB_X2_actionDefinition, actDef, "E2SM_gNB_X2_actionDefinition_t", __func__);
623 size_t len = encodebuff(ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_actionDefinition,
629 if (mdclog_level_get() >= MDCLOG_INFO) {
632 encodebuff(ATS_BASIC_XER, &asn_DEF_E2SM_gNB_X2_actionDefinition,
642 size_t createE2SM_gNB_X2_indicationHeader(long direction,
643 Interface_ID_t *interfaceId,
644 uint8_t *timestamp, //can put NULL if size == 0
647 size_t buffer_size) {
648 printEntry("E2SM_gNB_X2_indicationHeader_t", __func__);
649 if (direction < InterfaceDirection_incoming || direction > InterfaceDirection_outgoing) {
650 mdclog_write(MDCLOG_ERR, "E2SM_gNB_X2_indicationHeader_t direction = %ld, values are %d .. %d",
651 direction, InterfaceDirection_incoming, InterfaceDirection_outgoing);
655 E2SM_gNB_X2_indicationHeader_t *indiHead = calloc(1, sizeof(E2SM_gNB_X2_indicationHeader_t));
656 ASN_STRUCT_RESET(asn_DEF_E2SM_gNB_X2_indicationHeader, indiHead);
658 indiHead->interfaceDirection = direction;
659 memcpy(&indiHead->interface_ID, interfaceId, sizeof(Interface_ID_t));
661 indiHead->timestamp->size = size;
662 indiHead->timestamp->buf = calloc(1, sizeof(uint8_t) * size);
663 memcpy(indiHead->timestamp->buf, timestamp, size);
666 if (mdclog_level_get() >= MDCLOG_DEBUG) {
667 checkAndPrint(&asn_DEF_E2SM_gNB_X2_indicationHeader, indiHead, "E2SM_gNB_X2_indicationHeader_t", __func__);
670 size_t len = encodebuff(ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_indicationHeader,
675 if (mdclog_level_get() >= MDCLOG_INFO) {
678 encodebuff(ATS_BASIC_XER, &asn_DEF_E2SM_gNB_X2_indicationHeader,
688 size_t createE2SM_gNB_X2_indicationMessage(uint8_t *message, uint msgSize,
690 size_t buffer_size) {
691 printEntry("E2SM_gNB_X2_indicationMessage_t", __func__);
693 mdclog_write(MDCLOG_ERR, "E2SM_gNB_X2_indicationMessage_t failed messsage size = %d", msgSize);
697 E2SM_gNB_X2_indicationMessage_t *indicationMessage = calloc(1, sizeof(E2SM_gNB_X2_indicationMessage_t));
698 ASN_STRUCT_RESET(asn_DEF_E2SM_gNB_X2_indicationMessage, indicationMessage);
700 indicationMessage->interfaceMessage.size = msgSize;
701 indicationMessage->interfaceMessage.buf = calloc(1, sizeof(uint8_t) * msgSize);
702 memcpy(indicationMessage->interfaceMessage.buf, message, msgSize);
704 if (mdclog_level_get() >= MDCLOG_DEBUG) {
705 checkAndPrint(&asn_DEF_E2SM_gNB_X2_indicationMessage, indicationMessage, "E2SM_gNB_X2_indicationMessage_t", __func__);
708 size_t len = encodebuff(ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_indicationMessage,
714 if (mdclog_level_get() >= MDCLOG_INFO) {
717 encodebuff(ATS_BASIC_XER, &asn_DEF_E2SM_gNB_X2_indicationMessage,
728 size_t createE2SM_gNB_X2_callProcessID(long callProcess_Id,
730 size_t buffer_size) {
731 printEntry("E2SM_gNB_X2_callProcessID_t", __func__);
732 E2SM_gNB_X2_callProcessID_t *callProcessId = calloc(1, sizeof(E2SM_gNB_X2_callProcessID_t));
733 ASN_STRUCT_RESET(asn_DEF_E2SM_gNB_X2_callProcessID, callProcessId);
735 callProcessId->callProcess_ID = callProcess_Id;
737 if (mdclog_level_get() >= MDCLOG_DEBUG) {
738 checkAndPrint(&asn_DEF_E2SM_gNB_X2_callProcessID, callProcessId, "E2SM_gNB_X2_indicationMessage_t", __func__);
741 size_t len = encodebuff(ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_callProcessID,
747 if (mdclog_level_get() >= MDCLOG_INFO) {
750 encodebuff(ATS_BASIC_XER, &asn_DEF_E2SM_gNB_X2_callProcessID,
760 size_t createE2SM_gNB_X2_controlHeader(Interface_ID_t *interfaceId, long direction,
762 size_t buffer_size) {
763 printEntry("E2SM_gNB_X2_controlHeader_t", __func__);
764 if (direction < InterfaceDirection_incoming || direction > InterfaceDirection_outgoing) {
765 mdclog_write(MDCLOG_ERR, "E2SM_gNB_X2_controlHeader_t direction = %ld, values are %d .. %d",
766 direction, InterfaceDirection_incoming, InterfaceDirection_outgoing);
769 E2SM_gNB_X2_controlHeader_t *controlHeader = calloc(1, sizeof(E2SM_gNB_X2_controlHeader_t));
770 ASN_STRUCT_RESET(asn_DEF_E2SM_gNB_X2_controlHeader, controlHeader);
772 memcpy(&controlHeader->interface_ID, interfaceId, sizeof(Interface_ID_t));
773 controlHeader->interfaceDirection = direction;
775 if (mdclog_level_get() >= MDCLOG_DEBUG) {
776 checkAndPrint(&asn_DEF_E2SM_gNB_X2_controlHeader, controlHeader, "E2SM_gNB_X2_controlHeader_t", __func__);
779 size_t len = encodebuff(ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_controlHeader,
785 if (mdclog_level_get() >= MDCLOG_INFO) {
788 encodebuff(ATS_BASIC_XER, &asn_DEF_E2SM_gNB_X2_controlHeader,
799 size_t createE2SM_gNB_X2_controlMessage(uint8_t *message, uint msgSize,
801 size_t buffer_size) {
802 printEntry("E2SM_gNB_X2_controlMessage_t", __func__);
803 E2SM_gNB_X2_controlMessage_t *controlMsg = calloc(1, sizeof(E2SM_gNB_X2_controlMessage_t));
804 ASN_STRUCT_RESET(asn_DEF_E2SM_gNB_X2_controlMessage, controlMsg);
806 controlMsg->interfaceMessage.size = msgSize;
807 controlMsg->interfaceMessage.buf = calloc(1, sizeof(uint8_t) * msgSize);
808 memcpy(controlMsg->interfaceMessage.buf, message, msgSize);
810 if (mdclog_level_get() >= MDCLOG_DEBUG) {
811 checkAndPrint(&asn_DEF_E2SM_gNB_X2_controlMessage, controlMsg, "E2SM_gNB_X2_controlMessage_t", __func__);
814 size_t len = encodebuff(ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_controlMessage,
820 if (mdclog_level_get() >= MDCLOG_INFO) {
823 encodebuff(ATS_BASIC_XER, &asn_DEF_E2SM_gNB_X2_controlMessage,