Refactor (NGAP): adopt TO_ENUM/TO_TEXT pattern for NGAP enums

TO_ENUM/TO_TEXT are already used in NAS, and can be adopted in NGAP.
To avoid duplication, the following changes are introduced:

* Move text_info_t, TO_ENUM, TO_TEXT to common/utils/utils.h
* Include utils.h include to ngap_messages_types.h, fgs_nas_utils.h, and fgmm_lib.h
* RRC establishment cause: refactor to FOREACH_RRC_ESTABLISHMENT_CAUSE macro
* Cause Group: refactor to FOREACH_CAUSE_GROUP macro
* Radio Network Cause: refactor to FOREACH_CAUSE_RADIO_NETWORK macro
* Protocol Cause: refactor to FOREACH_CAUSE_PROTOCOL macro

This change is preparatory to the introduction the paging lib with unit
tests, with the goal of reducing the inter-dependency between concurrent
NGAP libs.
This commit is contained in:
Guido Casati
2026-02-17 12:25:58 +01:00
parent 3dc8647a58
commit c436f05ea9
7 changed files with 111 additions and 103 deletions
+9
View File
@@ -109,6 +109,15 @@ int hex_char_to_hex_value (char c);
// Converts an hexadecimal ASCII coded string into its value.**
int hex_string_to_hex_value (uint8_t *hex_value, const char *hex_string, int size);
/* Map task id to printable name. */
typedef struct {
int id;
char text[256];
} text_info_t;
#define TO_TEXT(LabEl, nUmID) {nUmID, #LabEl},
#define TO_ENUM(LabEl, nUmID) LabEl = nUmID,
char *itoa(int i);
#define STRINGIFY(S) #S