functions to convert lchan/pchan type into human-readable string
diff --git a/include/openbsc/gsm_data.h b/include/openbsc/gsm_data.h
index 71ad88f..02fdeaf 100644
--- a/include/openbsc/gsm_data.h
+++ b/include/openbsc/gsm_data.h
@@ -190,6 +190,10 @@
struct gsm_network *gsm_network_init(unsigned int num_bts, u_int16_t country_code,
u_int16_t network_code);
+const char *gsm_pchan_name(enum gsm_phys_chan_config c);
+const char *gsm_lchan_name(enum gsm_chan_t c);
+const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
+
enum gsm_e1_event {
EVT_E1_NONE,
EVT_E1_OML_UP,
diff --git a/src/gsm_data.c b/src/gsm_data.c
index ed81954..def7fff 100644
--- a/src/gsm_data.c
+++ b/src/gsm_data.c
@@ -24,6 +24,56 @@
#include <openbsc/gsm_data.h>
+static const char *pchan_names[] = {
+ [GSM_PCHAN_NONE] = "NONE",
+ [GSM_PCHAN_CCCH] = "CCCH",
+ [GSM_PCHAN_CCCH_SDCCH4] = "CCCH+SDCCH4",
+ [GSM_PCHAN_TCH_F] = "TCH/F",
+ [GSM_PCHAN_TCH_H] = "TCH/H",
+ [GSM_PCHAN_SDCCH8_SACCH8C] = "SDCCH8",
+ [GSM_PCHAN_UNKNOWN] = "UNKNOWN",
+};
+
+const char *gsm_pchan_name(enum gsm_phys_chan_config c)
+{
+ if (c >= ARRAY_SIZE(pchan_names))
+ return "INVALID";
+
+ return pchan_names[c];
+}
+
+static const char *lchan_names[] = {
+ [GSM_LCHAN_NONE] = "NONE",
+ [GSM_LCHAN_SDCCH] = "SDCCH",
+ [GSM_LCHAN_TCH_F] = "TCH/F",
+ [GSM_LCHAN_TCH_H] = "TCH/H",
+ [GSM_LCHAN_UNKNOWN] = "UNKNOWN",
+};
+
+const char *gsm_lchan_name(enum gsm_chan_t c)
+{
+ if (c >= ARRAY_SIZE(lchan_names))
+ return "INVALID";
+
+ return lchan_names[c];
+}
+
+static const char *chreq_names[] = {
+ [GSM_CHREQ_REASON_EMERG] = "EMERGENCY",
+ [GSM_CHREQ_REASON_PAG] = "PAGING",
+ [GSM_CHREQ_REASON_CALL] = "CALL",
+ [GSM_CHREQ_REASON_LOCATION_UPD] = "LOCATION_UPDATE",
+ [GSM_CHREQ_REASON_OTHER] = "OTHER",
+};
+
+const char *gsm_chreq_name(enum gsm_chreq_reason_t c)
+{
+ if (c >= ARRAY_SIZE(chreq_names))
+ return "INVALID";
+
+ return chreq_names[c];
+}
+
struct gsm_network *gsm_network_init(unsigned int num_bts, u_int16_t country_code,
u_int16_t network_code)
{