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).
24 // Created by adi ENZEL on 6/19/19.
29 #define printEntry(type, function) \
30 if (mdclog_level_get() >= MDCLOG_DEBUG) { \
31 mdclog_write(MDCLOG_DEBUG, "start Test %s , %s", type, function); \
35 static void checkAndPrint(asn_TYPE_descriptor_t *typeDescriptor, void *data, char *dataType, const char *function) {
36 char errbuf[128]; /* Buffer for error message */
37 size_t errlen = sizeof(errbuf); /* Size of the buffer */
38 if (asn_check_constraints(typeDescriptor, data, errbuf, &errlen) != 0) {
39 mdclog_write(MDCLOG_ERR, "%s Constraint validation failed: %s", dataType, errbuf);
40 } else if (mdclog_level_get() >= MDCLOG_DEBUG) {
41 mdclog_write(MDCLOG_DEBUG, "%s successes function %s", dataType, function);
45 static size_t encodebuff(int codingType,
46 asn_TYPE_descriptor_t *typeDescriptor,
51 struct timespec start = {0,0};
52 struct timespec end = {0,0};
53 clock_gettime(CLOCK_MONOTONIC, &start);
54 er = asn_encode_to_buffer(0, codingType, typeDescriptor, objectData, buffer, buffer_size);
55 clock_gettime(CLOCK_MONOTONIC, &end);
56 if (er.encoded == -1) {
57 mdclog_write(MDCLOG_ERR, "encoding of %s failed, %s", asn_DEF_E2SM_gNB_X2_eventTriggerDefinition.name, strerror(errno));
58 } else if (er.encoded > (ssize_t)buffer_size) {
59 mdclog_write(MDCLOG_ERR, "Buffer of size %d is to small for %s", (int) buffer_size,
60 typeDescriptor->name);
61 } else if (mdclog_level_get() >= MDCLOG_DEBUG) {
62 if (codingType == ATS_BASIC_XER) {
63 mdclog_write(MDCLOG_DEBUG, "Buffer of size %d, data = %s", (int) er.encoded, buffer);
66 if (mdclog_level_get() >= MDCLOG_INFO) {
69 FILE *stream = open_memstream(&printBuffer, &size);
70 asn_fprint(stream, typeDescriptor, objectData);
71 mdclog_write(MDCLOG_DEBUG, "Encoding E2SM PDU past : %s", printBuffer);
75 mdclog_write(MDCLOG_DEBUG, "Buffer of size %d", (int) er.encoded);
78 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);
79 //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));
83 PLMN_Identity_t *createPLMN_ID(const unsigned char *data) {
84 printEntry("PLMN_Identity_t", __func__)
85 PLMN_Identity_t *plmnId = calloc(1, sizeof(PLMN_Identity_t));
86 ASN_STRUCT_RESET(asn_DEF_PLMN_Identity, plmnId);
88 plmnId->buf = calloc(1, 3);
89 memcpy(plmnId->buf, data, 3);
91 if (mdclog_level_get() >= MDCLOG_DEBUG) {
92 checkAndPrint(&asn_DEF_PLMN_Identity, plmnId, "PLMN_Identity_t", __func__);
98 ENB_ID_t *createENB_ID(ENB_ID_PR enbType, unsigned char *data) {
99 printEntry("ENB_ID_t", __func__)
100 ENB_ID_t *enb = calloc(1, sizeof(ENB_ID_t));
101 ASN_STRUCT_RESET(asn_DEF_ENB_ID, enb);
103 enb->present = enbType;
106 case ENB_ID_PR_macro_eNB_ID: { // 20 bit 3 bytes
107 enb->choice.macro_eNB_ID.size = 3;
108 enb->choice.macro_eNB_ID.bits_unused = 4;
110 enb->present = ENB_ID_PR_macro_eNB_ID;
112 enb->choice.macro_eNB_ID.buf = calloc(1, enb->choice.macro_eNB_ID.size);
113 data[enb->choice.macro_eNB_ID.size - 1] = ((unsigned)(data[enb->choice.macro_eNB_ID.size - 1] >>
114 (unsigned)enb->choice.macro_eNB_ID.bits_unused) << (unsigned)enb->choice.macro_eNB_ID.bits_unused);
115 memcpy(enb->choice.macro_eNB_ID.buf, data, enb->choice.macro_eNB_ID.size);
119 case ENB_ID_PR_home_eNB_ID: { // 28 bit 4 bytes
120 enb->choice.home_eNB_ID.size = 4;
121 enb->choice.home_eNB_ID.bits_unused = 4;
122 enb->present = ENB_ID_PR_home_eNB_ID;
124 enb->choice.home_eNB_ID.buf = calloc(1, enb->choice.home_eNB_ID.size);
125 data[enb->choice.home_eNB_ID.size - 1] = ((unsigned)(data[enb->choice.home_eNB_ID.size - 1] >>
126 (unsigned)enb->choice.home_eNB_ID.bits_unused) << (unsigned)enb->choice.home_eNB_ID.bits_unused);
127 memcpy(enb->choice.home_eNB_ID.buf, data, enb->choice.home_eNB_ID.size);
130 case ENB_ID_PR_short_Macro_eNB_ID: { // 18 bit - 3 bytes
131 enb->choice.short_Macro_eNB_ID.size = 3;
132 enb->choice.short_Macro_eNB_ID.bits_unused = 6;
133 enb->present = ENB_ID_PR_short_Macro_eNB_ID;
135 enb->choice.short_Macro_eNB_ID.buf = calloc(1, enb->choice.short_Macro_eNB_ID.size);
136 data[enb->choice.short_Macro_eNB_ID.size - 1] = ((unsigned)(data[enb->choice.short_Macro_eNB_ID.size - 1] >>
137 (unsigned)enb->choice.short_Macro_eNB_ID.bits_unused) << (unsigned)enb->choice.short_Macro_eNB_ID.bits_unused);
138 memcpy(enb->choice.short_Macro_eNB_ID.buf, data, enb->choice.short_Macro_eNB_ID.size);
141 case ENB_ID_PR_long_Macro_eNB_ID: { // 21
142 enb->choice.long_Macro_eNB_ID.size = 3;
143 enb->choice.long_Macro_eNB_ID.bits_unused = 3;
144 enb->present = ENB_ID_PR_long_Macro_eNB_ID;
146 enb->choice.long_Macro_eNB_ID.buf = calloc(1, enb->choice.long_Macro_eNB_ID.size);
147 data[enb->choice.long_Macro_eNB_ID.size - 1] = ((unsigned)(data[enb->choice.long_Macro_eNB_ID.size - 1] >>
148 (unsigned)enb->choice.long_Macro_eNB_ID.bits_unused) << (unsigned)enb->choice.long_Macro_eNB_ID.bits_unused);
149 memcpy(enb->choice.long_Macro_eNB_ID.buf, data, enb->choice.long_Macro_eNB_ID.size);
158 if (mdclog_level_get() >= MDCLOG_DEBUG) {
159 checkAndPrint(&asn_DEF_ENB_ID, enb, "ENB_ID_t", __func__);
164 GNB_ID_t *createGnb_id(const unsigned char *data, int numOfBits) {
165 printEntry("GNB_ID_t", __func__)
166 if (numOfBits < 22 || numOfBits > 32) {
167 mdclog_write(MDCLOG_ERR, "GNB_ID_t number of bits = %d, needs to be 22 .. 32", numOfBits);
170 GNB_ID_t *gnb = calloc(1, sizeof(GNB_ID_t));
171 ASN_STRUCT_RESET(asn_DEF_GNB_ID, gnb);
173 gnb->present = GNB_ID_PR_gNB_ID;
174 gnb->choice.gNB_ID.size = numOfBits % 8 == 0 ? (unsigned int)(numOfBits / 8) : (unsigned int)(numOfBits / 8 + 1);
175 gnb->choice.gNB_ID.bits_unused = (int)gnb->choice.gNB_ID.size * 8 - numOfBits;
176 gnb->choice.gNB_ID.buf = calloc(1, gnb->choice.gNB_ID.size);
177 memcpy(gnb->choice.gNB_ID.buf, data, gnb->choice.gNB_ID.size);
178 gnb->choice.gNB_ID.buf[gnb->choice.gNB_ID.size - 1] =
179 ((unsigned)(gnb->choice.gNB_ID.buf[gnb->choice.gNB_ID.size - 1] >> (unsigned)gnb->choice.gNB_ID.bits_unused)
180 << (unsigned)gnb->choice.gNB_ID.bits_unused);
182 if (mdclog_level_get() >= MDCLOG_DEBUG) {
183 checkAndPrint(&asn_DEF_GNB_ID, gnb, "GNB_ID_t", __func__);
190 GlobalENB_ID_t *createGlobalENB_ID(PLMN_Identity_t *plmnIdentity, ENB_ID_t *enbId) {
191 printEntry("GlobalENB_ID_t", __func__)
192 GlobalENB_ID_t *genbId = calloc(1, sizeof(GlobalENB_ID_t));
193 ASN_STRUCT_RESET(asn_DEF_GlobalENB_ID, genbId);
194 memcpy(&genbId->pLMN_Identity, plmnIdentity, sizeof(PLMN_Identity_t));
195 memcpy(&genbId->eNB_ID, enbId, sizeof(ENB_ID_t));
197 if (mdclog_level_get() >= MDCLOG_DEBUG) {
198 checkAndPrint(&asn_DEF_GlobalENB_ID, genbId, "GlobalENB_ID_t", __func__);
203 GlobalGNB_ID_t *createGlobalGNB_ID(PLMN_Identity_t *plmnIdentity, GNB_ID_t *gnb) {
204 printEntry("GlobalGNB_ID_t", __func__)
205 GlobalGNB_ID_t *ggnbId = calloc(1, sizeof(GlobalGNB_ID_t));
206 ASN_STRUCT_RESET(asn_DEF_GlobalGNB_ID, ggnbId);
208 memcpy(&ggnbId->pLMN_Identity, plmnIdentity, sizeof(PLMN_Identity_t));
209 memcpy(&ggnbId->gNB_ID, gnb, sizeof(GNB_ID_t));
211 if (mdclog_level_get() >= MDCLOG_DEBUG) {
212 checkAndPrint(&asn_DEF_GlobalGNB_ID, ggnbId, "GlobalGNB_ID_t", __func__);
219 Interface_ID_t *createInterfaceIDForGnb(GlobalGNB_ID_t *gnb) {
220 printEntry("Interface_ID_t", __func__)
221 Interface_ID_t *interfaceId = calloc(1, sizeof(Interface_ID_t));
222 ASN_STRUCT_RESET(asn_DEF_Interface_ID, interfaceId);
224 interfaceId->present = Interface_ID_PR_global_gNB_ID;
225 //memcpy(&interfaceId->choice.global_gNB_ID, gnb, sizeof(GlobalGNB_ID_t));
226 interfaceId->choice.global_gNB_ID = gnb;
228 if (mdclog_level_get() >= MDCLOG_DEBUG) {
229 checkAndPrint(&asn_DEF_Interface_ID, interfaceId, "Interface_ID_t", __func__);
235 Interface_ID_t *createInterfaceIDForEnb(GlobalENB_ID_t *enb) {
236 printEntry("Interface_ID_t", __func__)
237 Interface_ID_t *interfaceId = calloc(1, sizeof(Interface_ID_t));
238 ASN_STRUCT_RESET(asn_DEF_Interface_ID, interfaceId);
240 interfaceId->present = Interface_ID_PR_global_eNB_ID;
241 //memcpy(&interfaceId->choice.global_eNB_ID, enb, sizeof(GlobalENB_ID_t));
242 interfaceId->choice.global_eNB_ID = enb;
244 if (mdclog_level_get() >= MDCLOG_DEBUG) {
245 checkAndPrint(&asn_DEF_Interface_ID, interfaceId, "Interface_ID_t", __func__);
253 InterfaceMessageType_t *createInterfaceMessageInitiating(long procedureCode) {
254 printEntry("InterfaceMessageType_t", __func__)
255 InterfaceMessageType_t *intMsgT = calloc(1, sizeof(InterfaceMessageType_t));
256 ASN_STRUCT_RESET(asn_DEF_InterfaceMessageType, intMsgT);
258 intMsgT->procedureCode = procedureCode;
259 intMsgT->typeOfMessage = TypeOfMessage_initiating_message;
261 if (mdclog_level_get() >= MDCLOG_DEBUG) {
262 checkAndPrint(&asn_DEF_InterfaceMessageType, intMsgT, "InterfaceMessageType_t", __func__);
268 InterfaceMessageType_t *createInterfaceMessageSuccsesful(long procedureCode) {
269 printEntry("InterfaceMessageType_t", __func__)
270 InterfaceMessageType_t *intMsgT = calloc(1, sizeof(InterfaceMessageType_t));
271 ASN_STRUCT_RESET(asn_DEF_InterfaceMessageType, intMsgT);
273 intMsgT->procedureCode = procedureCode;
274 intMsgT->typeOfMessage = TypeOfMessage_successful_outcome;
276 if (mdclog_level_get() >= MDCLOG_DEBUG) {
277 checkAndPrint(&asn_DEF_InterfaceMessageType, intMsgT, "InterfaceMessageType_t", __func__);
283 InterfaceMessageType_t *createInterfaceMessageUnsuccessful(long procedureCode) {
284 printEntry("InterfaceMessageType_t", __func__)
285 InterfaceMessageType_t *intMsgT = calloc(1, sizeof(InterfaceMessageType_t));
286 ASN_STRUCT_RESET(asn_DEF_InterfaceMessageType, intMsgT);
288 intMsgT->procedureCode = procedureCode;
289 intMsgT->typeOfMessage = TypeOfMessage_unsuccessful_outcome;
291 if (mdclog_level_get() >= MDCLOG_DEBUG) {
292 checkAndPrint(&asn_DEF_InterfaceMessageType, intMsgT, "InterfaceMessageType_t", __func__);
298 InterfaceProtocolIE_Value_t *createInterfaceProtocolValueInt(long number) {
299 printEntry("InterfaceProtocolIE_Value_t", __func__)
300 InterfaceProtocolIE_Value_t *value = calloc(1, sizeof(InterfaceProtocolIE_Value_t));
301 ASN_STRUCT_RESET(asn_DEF_InterfaceProtocolIE_Value, value);
303 value->present = InterfaceProtocolIE_Value_PR_valueInt;
304 value->choice.valueInt = number;
306 if (mdclog_level_get() >= MDCLOG_DEBUG) {
307 checkAndPrint(&asn_DEF_InterfaceProtocolIE_Value, value, "InterfaceProtocolIE_Value_t", __func__);
313 InterfaceProtocolIE_Value_t *createInterfaceProtocolValueEnum(long number) {
314 printEntry("InterfaceProtocolIE_Value_t", __func__)
315 InterfaceProtocolIE_Value_t *value = calloc(1, sizeof(InterfaceProtocolIE_Value_t));
316 ASN_STRUCT_RESET(asn_DEF_InterfaceProtocolIE_Value, value);
318 value->present = InterfaceProtocolIE_Value_PR_valueEnum;
319 value->choice.valueEnum = number;
321 if (mdclog_level_get() >= MDCLOG_DEBUG) {
322 checkAndPrint(&asn_DEF_InterfaceProtocolIE_Value, value, "InterfaceProtocolIE_Value_t", __func__);
328 InterfaceProtocolIE_Value_t *createInterfaceProtocolValueBool(int val) {
329 printEntry("InterfaceProtocolIE_Value_t", __func__)
330 InterfaceProtocolIE_Value_t *value = calloc(1, sizeof(InterfaceProtocolIE_Value_t));
331 ASN_STRUCT_RESET(asn_DEF_InterfaceProtocolIE_Value, value);
333 value->present = InterfaceProtocolIE_Value_PR_valueBool;
334 value->choice.valueBool = val == 0 ? 0 : 1;
336 if (mdclog_level_get() >= MDCLOG_DEBUG) {
337 checkAndPrint(&asn_DEF_InterfaceProtocolIE_Value, value, "InterfaceProtocolIE_Value_t", __func__);
344 InterfaceProtocolIE_Value_t *createInterfaceProtocolValueBitString(unsigned char *buf, int numOfBits) {
345 printEntry("InterfaceProtocolIE_Value_t", __func__)
346 size_t size = numOfBits % 8 == 0 ? (unsigned int)(numOfBits / 8) : (unsigned int)(numOfBits / 8 + 1);
347 if (strlen((const char *)buf) < size) {
348 mdclog_write(MDCLOG_ERR, "size of buffer is small : %d needs to be %d in %s", (int)strlen((const char *)buf), (int)size, __func__);
350 InterfaceProtocolIE_Value_t *value = calloc(1, sizeof(InterfaceProtocolIE_Value_t));
351 ASN_STRUCT_RESET(asn_DEF_InterfaceProtocolIE_Value, value);
353 value->present = InterfaceProtocolIE_Value_PR_valueBitS;
354 value->choice.valueBitS.size = numOfBits % 8 == 0 ? (unsigned int)(numOfBits / 8) : (unsigned int)(numOfBits / 8 + 1);
355 value->choice.valueBitS.buf = calloc(1, value->choice.valueBitS.size);
356 int bits_unused = (int)value->choice.valueBitS.size * 8 - numOfBits;
357 value->choice.valueBitS.bits_unused = bits_unused;
359 memcpy(value->choice.valueBitS.buf, buf, value->choice.valueBitS.size);
360 value->choice.valueBitS.buf[size -1] = ((unsigned)(buf[size - 1]) >> (unsigned)bits_unused << (unsigned)bits_unused);
362 if (mdclog_level_get() >= MDCLOG_DEBUG) {
363 checkAndPrint(&asn_DEF_InterfaceProtocolIE_Value, value, "InterfaceProtocolIE_Value_t", __func__);
370 InterfaceProtocolIE_Value_t *createInterfaceProtocolValueOCTETS(uint8_t *buf) {
371 printEntry("InterfaceProtocolIE_Value_t", __func__)
372 size_t size = strlen((const char *)buf);
373 InterfaceProtocolIE_Value_t *value = calloc(1, sizeof(InterfaceProtocolIE_Value_t));
374 ASN_STRUCT_RESET(asn_DEF_InterfaceProtocolIE_Value, value);
376 value->present = InterfaceProtocolIE_Value_PR_valueOctS;
377 value->choice.valueOctS.size = size;
378 value->choice.valueOctS.buf = calloc(1, value->choice.valueOctS.size);
379 memcpy(value->choice.valueOctS.buf, buf, value->choice.valueOctS.size);
381 if (mdclog_level_get() >= MDCLOG_DEBUG) {
382 checkAndPrint(&asn_DEF_InterfaceProtocolIE_Value, value, "InterfaceProtocolIE_Value_t", __func__);
389 InterfaceProtocolIE_Item_t *createInterfaceProtocolIE_Item(long id, long test, InterfaceProtocolIE_Value_t *value) {
390 printEntry("InterfaceProtocolIE_Item_t", __func__)
391 if (test < InterfaceProtocolIE_Test_equal || test > InterfaceProtocolIE_Test_present) {
392 mdclog_write(MDCLOG_ERR, "InterfaceProtocolIE_Item_t test value is %ld, out of scope %d .. %d ",
393 test, InterfaceProtocolIE_Test_equal, InterfaceProtocolIE_Test_present);
396 InterfaceProtocolIE_Item_t *intProtIt = calloc(1, sizeof(InterfaceProtocolIE_Item_t));
397 ASN_STRUCT_RESET(asn_DEF_InterfaceProtocolIE_Item, intProtIt);
400 intProtIt->interfaceProtocolIE_ID = id;
402 intProtIt->interfaceProtocolIE_Test = test;
404 memcpy(&intProtIt->interfaceProtocolIE_Value, value, sizeof(InterfaceProtocolIE_Value_t));
406 if (mdclog_level_get() >= MDCLOG_DEBUG) {
407 checkAndPrint(&asn_DEF_InterfaceProtocolIE_Item, intProtIt, "InterfaceProtocolIE_Item_t", __func__);
416 ActionParameter_Value_t *createActionParameterValue_Int(long number) {
417 printEntry("ActionParameter_Value_t", __func__)
418 ActionParameter_Value_t *value = calloc(1, sizeof(ActionParameter_Value_t));
419 ASN_STRUCT_RESET(asn_DEF_ActionParameter_Value, value);
421 value->present = ActionParameter_Value_PR_valueInt;
422 value->choice.valueInt = number;
424 if (mdclog_level_get() >= MDCLOG_DEBUG) {
425 checkAndPrint(&asn_DEF_ActionParameter_Value, value, "ActionParameter_Value_t", __func__);
431 ActionParameter_Value_t *createActionParameterValue_Enum(long number) {
432 printEntry("ActionParameter_Value_t", __func__)
433 ActionParameter_Value_t *value = calloc(1, sizeof(ActionParameter_Value_t));
434 ASN_STRUCT_RESET(asn_DEF_ActionParameter_Value, value);
436 value->present = ActionParameter_Value_PR_valueEnum;
437 value->choice.valueEnum = number;
439 if (mdclog_level_get() >= MDCLOG_DEBUG) {
440 checkAndPrint(&asn_DEF_ActionParameter_Value, value, "ActionParameter_Value_t", __func__);
446 ActionParameter_Value_t *createActionParameterValue_Bool(int val) {
447 printEntry("ActionParameter_Value_t", __func__)
448 ActionParameter_Value_t *value = calloc(1, sizeof(ActionParameter_Value_t));
449 ASN_STRUCT_RESET(asn_DEF_ActionParameter_Value, value);
451 value->present = ActionParameter_Value_PR_valueBool;
452 value->choice.valueBool = val == 0 ? 0 : 1;
454 if (mdclog_level_get() >= MDCLOG_DEBUG) {
455 checkAndPrint(&asn_DEF_ActionParameter_Value, value, "ActionParameter_Value_t", __func__);
462 ActionParameter_Value_t *createActionParameterValue_Bit_String(unsigned char *buf, int numOfBits) {
463 printEntry("ActionParameter_Value_t", __func__)
464 size_t size = numOfBits % 8 == 0 ? (unsigned int)(numOfBits / 8) : (unsigned int)(numOfBits / 8 + 1);
465 if (strlen((const char *)buf) < size) {
466 mdclog_write(MDCLOG_ERR, "size of buffer is small : %d needs to be %d in %s", (int)strlen((const char *)buf), (int)size, __func__);
468 int bits_unused = (int)size * 8 - numOfBits;
470 ActionParameter_Value_t *value = calloc(1, sizeof(ActionParameter_Value_t));
471 ASN_STRUCT_RESET(asn_DEF_ActionParameter_Value, value);
473 value->present = ActionParameter_Value_PR_valueBitS;
474 value->choice.valueBitS.size = size;
475 value->choice.valueBitS.buf = calloc(1, size);
476 value->choice.valueBitS.bits_unused = bits_unused;
478 memcpy(value->choice.valueBitS.buf, buf, size);
479 value->choice.valueBitS.buf[size -1] = ((unsigned)(buf[size - 1]) >> (unsigned)bits_unused << (unsigned)bits_unused);
481 if (mdclog_level_get() >= MDCLOG_DEBUG) {
482 checkAndPrint(&asn_DEF_ActionParameter_Value, value, "ActionParameter_Value_t", __func__);
489 ActionParameter_Value_t *createActionParameterValue_OCTETS(uint8_t *buf) {
490 printEntry("ActionParameter_Value_t", __func__)
491 size_t size = strlen((const char *)buf);
492 ActionParameter_Value_t *value = calloc(1, sizeof(ActionParameter_Value_t));
493 ASN_STRUCT_RESET(asn_DEF_ActionParameter_Value, value);
495 value->present = ActionParameter_Value_PR_valueOctS;
496 value->choice.valueOctS.size = size;
497 value->choice.valueOctS.buf = calloc(1, value->choice.valueOctS.size);
498 memcpy(value->choice.valueOctS.buf, buf, value->choice.valueOctS.size);
500 if (mdclog_level_get() >= MDCLOG_DEBUG) {
501 checkAndPrint(&asn_DEF_ActionParameter_Value, value, "ActionParameter_Value_t", __func__);
509 * @param buf buffer that must be null terminated
510 * @return ActionParameter_Value_t *
512 ActionParameter_Value_t *createActionParameterValue_PRINTS(char *buf) {
513 printEntry("ActionParameter_Value_t", __func__)
514 size_t size = strlen((const char *)buf);
515 ActionParameter_Value_t *value = calloc(1, sizeof(ActionParameter_Value_t));
516 ASN_STRUCT_RESET(asn_DEF_ActionParameter_Value, value);
518 value->present = ActionParameter_Value_PR_valuePrtS;
519 value->choice.valuePrtS.size = size;
520 value->choice.valuePrtS.buf = calloc(1, value->choice.valuePrtS.size);
521 memcpy(value->choice.valuePrtS.buf, buf, value->choice.valuePrtS.size);
523 if (mdclog_level_get() >= MDCLOG_DEBUG) {
524 checkAndPrint(&asn_DEF_ActionParameter_Value, value, "ActionParameter_Value_t", __func__);
530 ActionParameter_Item_t *creatActionParameter_Item(long id, ActionParameter_Value_t *val) {
531 printEntry("ActionParameter_Item_t", __func__)
532 if (id < 0 || id > 255) {
533 mdclog_write(MDCLOG_ERR, "ActionParameter_Item_t id = %ld, values are 0 .. 255", id);
536 ActionParameter_Item_t *actionParameterItem = calloc(1, sizeof(ActionParameter_Item_t));
537 ASN_STRUCT_RESET(asn_DEF_ActionParameter_Item, actionParameterItem);
539 actionParameterItem->actionParameter_ID = id;
540 memcpy(&actionParameterItem->actionParameter_Value, val, sizeof(ActionParameter_Value_t));
542 if (mdclog_level_get() >= MDCLOG_DEBUG) {
543 checkAndPrint(&asn_DEF_ActionParameter_Item, actionParameterItem, "ActionParameter_Item_t", __func__);
546 return actionParameterItem;
554 * @param interfaceProtocolItemList
560 size_t createEventTrigger(Interface_ID_t *interfaceId, long direction,
561 InterfaceMessageType_t *messageType,
562 InterfaceProtocolIE_Item_t interfaceProtocolItemList[],
565 size_t buffer_size) {
566 printEntry("E2SM_gNB_X2_eventTriggerDefinition_t", __func__)
567 if (direction < InterfaceDirection_incoming || direction > InterfaceDirection_outgoing) {
568 mdclog_write(MDCLOG_ERR, "E2SM_gNB_X2_eventTriggerDefinition_t direction = %ld, values are %d .. %d",
569 direction, InterfaceDirection_incoming, InterfaceDirection_outgoing);
573 E2SM_gNB_X2_eventTriggerDefinition_t *eventTrigger = calloc(1, sizeof(E2SM_gNB_X2_eventTriggerDefinition_t));
574 ASN_STRUCT_RESET(asn_DEF_E2SM_gNB_X2_eventTriggerDefinition, eventTrigger);
576 memcpy(&eventTrigger->interface_ID , interfaceId, sizeof(Interface_ID_t));
578 eventTrigger->interfaceDirection = direction;
579 memcpy(&eventTrigger->interfaceMessageType, messageType, sizeof(InterfaceMessageType_t));
581 for (int i = 0; i < listSize; i++) {
582 ASN_SEQUENCE_ADD(eventTrigger->interfaceProtocolIE_List, &interfaceProtocolItemList[i]);
585 if (mdclog_level_get() >= MDCLOG_DEBUG) {
586 checkAndPrint(&asn_DEF_E2SM_gNB_X2_eventTriggerDefinition, eventTrigger, "E2SM_gNB_X2_eventTriggerDefinition_t", __func__);
589 size_t len = encodebuff(ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_eventTriggerDefinition,
595 if (mdclog_level_get() >= MDCLOG_INFO) {
597 //asn_enc_rval_t er1;
598 encodebuff(ATS_BASIC_XER, &asn_DEF_E2SM_gNB_X2_eventTriggerDefinition,
609 size_t createActionDefinition(long styleId, ActionParameter_Item_t actionParamList[], int listSize,
611 size_t buffer_size) {
612 printEntry("E2SM_gNB_X2_actionDefinition_t", __func__)
613 E2SM_gNB_X2_actionDefinition_t *actDef = calloc(1, sizeof(E2SM_gNB_X2_actionDefinition_t));
614 ASN_STRUCT_RESET(asn_DEF_E2SM_gNB_X2_actionDefinition, actDef);
616 actDef->style_ID = styleId;
617 for (int i = 0; i < listSize; i++) {
618 ASN_SEQUENCE_ADD(actDef->actionParameter_List, &actionParamList[i]);
621 if (mdclog_level_get() >= MDCLOG_DEBUG) {
622 checkAndPrint(&asn_DEF_E2SM_gNB_X2_actionDefinition, actDef, "E2SM_gNB_X2_actionDefinition_t", __func__);
625 size_t len = encodebuff(ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_actionDefinition,
631 if (mdclog_level_get() >= MDCLOG_INFO) {
633 //asn_enc_rval_t er1;
634 encodebuff(ATS_BASIC_XER, &asn_DEF_E2SM_gNB_X2_actionDefinition,
644 size_t createE2SM_gNB_X2_indicationHeader(long direction,
645 Interface_ID_t *interfaceId,
646 uint8_t *timestamp, //can put NULL if size == 0
649 size_t buffer_size) {
650 printEntry("E2SM_gNB_X2_indicationHeader_t", __func__)
651 if (direction < InterfaceDirection_incoming || direction > InterfaceDirection_outgoing) {
652 mdclog_write(MDCLOG_ERR, "E2SM_gNB_X2_indicationHeader_t direction = %ld, values are %d .. %d",
653 direction, InterfaceDirection_incoming, InterfaceDirection_outgoing);
657 E2SM_gNB_X2_indicationHeader_t *indiHead = calloc(1, sizeof(E2SM_gNB_X2_indicationHeader_t));
658 ASN_STRUCT_RESET(asn_DEF_E2SM_gNB_X2_indicationHeader, indiHead);
660 indiHead->interfaceDirection = direction;
661 memcpy(&indiHead->interface_ID, interfaceId, sizeof(Interface_ID_t));
663 indiHead->timestamp->size = size;
664 indiHead->timestamp->buf = calloc(1, sizeof(uint8_t) * size);
665 memcpy(indiHead->timestamp->buf, timestamp, size);
668 if (mdclog_level_get() >= MDCLOG_DEBUG) {
669 checkAndPrint(&asn_DEF_E2SM_gNB_X2_indicationHeader, indiHead, "E2SM_gNB_X2_indicationHeader_t", __func__);
672 size_t len = encodebuff(ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_indicationHeader,
677 if (mdclog_level_get() >= MDCLOG_INFO) {
679 //asn_enc_rval_t er1;
680 encodebuff(ATS_BASIC_XER, &asn_DEF_E2SM_gNB_X2_indicationHeader,
690 size_t createE2SM_gNB_X2_indicationMessage(uint8_t *message, uint msgSize,
692 size_t buffer_size) {
693 printEntry("E2SM_gNB_X2_indicationMessage_t", __func__)
695 mdclog_write(MDCLOG_ERR, "E2SM_gNB_X2_indicationMessage_t failed messsage size = %d", msgSize);
699 E2SM_gNB_X2_indicationMessage_t *indicationMessage = calloc(1, sizeof(E2SM_gNB_X2_indicationMessage_t));
700 ASN_STRUCT_RESET(asn_DEF_E2SM_gNB_X2_indicationMessage, indicationMessage);
702 indicationMessage->interfaceMessage.size = msgSize;
703 indicationMessage->interfaceMessage.buf = calloc(1, sizeof(uint8_t) * msgSize);
704 memcpy(indicationMessage->interfaceMessage.buf, message, msgSize);
706 if (mdclog_level_get() >= MDCLOG_DEBUG) {
707 checkAndPrint(&asn_DEF_E2SM_gNB_X2_indicationMessage, indicationMessage, "E2SM_gNB_X2_indicationMessage_t", __func__);
710 size_t len = encodebuff(ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_indicationMessage,
716 if (mdclog_level_get() >= MDCLOG_INFO) {
718 //asn_enc_rval_t er1;
719 encodebuff(ATS_BASIC_XER, &asn_DEF_E2SM_gNB_X2_indicationMessage,
730 size_t createE2SM_gNB_X2_callProcessID(long callProcess_Id,
732 size_t buffer_size) {
733 printEntry("E2SM_gNB_X2_callProcessID_t", __func__)
734 E2SM_gNB_X2_callProcessID_t *callProcessId = calloc(1, sizeof(E2SM_gNB_X2_callProcessID_t));
735 ASN_STRUCT_RESET(asn_DEF_E2SM_gNB_X2_callProcessID, callProcessId);
737 callProcessId->callProcess_ID = callProcess_Id;
739 if (mdclog_level_get() >= MDCLOG_DEBUG) {
740 checkAndPrint(&asn_DEF_E2SM_gNB_X2_callProcessID, callProcessId, "E2SM_gNB_X2_indicationMessage_t", __func__);
743 size_t len = encodebuff(ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_callProcessID,
749 if (mdclog_level_get() >= MDCLOG_INFO) {
751 //asn_enc_rval_t er1;
752 encodebuff(ATS_BASIC_XER, &asn_DEF_E2SM_gNB_X2_callProcessID,
762 size_t createE2SM_gNB_X2_controlHeader(Interface_ID_t *interfaceId, long direction,
764 size_t buffer_size) {
765 printEntry("E2SM_gNB_X2_controlHeader_t", __func__)
766 if (direction < InterfaceDirection_incoming || direction > InterfaceDirection_outgoing) {
767 mdclog_write(MDCLOG_ERR, "E2SM_gNB_X2_controlHeader_t direction = %ld, values are %d .. %d",
768 direction, InterfaceDirection_incoming, InterfaceDirection_outgoing);
771 E2SM_gNB_X2_controlHeader_t *controlHeader = calloc(1, sizeof(E2SM_gNB_X2_controlHeader_t));
772 ASN_STRUCT_RESET(asn_DEF_E2SM_gNB_X2_controlHeader, controlHeader);
774 memcpy(&controlHeader->interface_ID, interfaceId, sizeof(Interface_ID_t));
775 controlHeader->interfaceDirection = direction;
777 if (mdclog_level_get() >= MDCLOG_DEBUG) {
778 checkAndPrint(&asn_DEF_E2SM_gNB_X2_controlHeader, controlHeader, "E2SM_gNB_X2_controlHeader_t", __func__);
781 size_t len = encodebuff(ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_controlHeader,
787 if (mdclog_level_get() >= MDCLOG_INFO) {
789 //asn_enc_rval_t er1;
790 encodebuff(ATS_BASIC_XER, &asn_DEF_E2SM_gNB_X2_controlHeader,
801 size_t createE2SM_gNB_X2_controlMessage(uint8_t *message, uint msgSize,
803 size_t buffer_size) {
804 printEntry("E2SM_gNB_X2_controlMessage_t", __func__)
805 E2SM_gNB_X2_controlMessage_t *controlMsg = calloc(1, sizeof(E2SM_gNB_X2_controlMessage_t));
806 ASN_STRUCT_RESET(asn_DEF_E2SM_gNB_X2_controlMessage, controlMsg);
808 controlMsg->interfaceMessage.size = msgSize;
809 controlMsg->interfaceMessage.buf = calloc(1, sizeof(uint8_t) * msgSize);
810 memcpy(controlMsg->interfaceMessage.buf, message, msgSize);
812 if (mdclog_level_get() >= MDCLOG_DEBUG) {
813 checkAndPrint(&asn_DEF_E2SM_gNB_X2_controlMessage, controlMsg, "E2SM_gNB_X2_controlMessage_t", __func__);
816 size_t len = encodebuff(ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_controlMessage,
822 if (mdclog_level_get() >= MDCLOG_INFO) {
824 //asn_enc_rval_t er1;
825 encodebuff(ATS_BASIC_XER, &asn_DEF_E2SM_gNB_X2_controlMessage,