summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2015-12-03 14:35:05 +0100
committerHarald Welte <laforge@gnumonks.org>2015-12-12 21:43:16 +0100
commitda8a19fec0ae16f110869508dd20f9ebab1520e5 (patch)
tree5b44834a0a42e929d7a543067f3e39722fc0f6d2
parent36948bf7c71d89746314e93ffe8f3eb2c2fbc5ea (diff)
mncc.c: Convert mncc_names[] to 'struct value_string'
-rw-r--r--openbsc/include/openbsc/mncc.h2
-rw-r--r--openbsc/src/libmsc/mncc.c129
2 files changed, 61 insertions, 70 deletions
diff --git a/openbsc/include/openbsc/mncc.h b/openbsc/include/openbsc/mncc.h
index 46ba23729..2a170cd4d 100644
--- a/openbsc/include/openbsc/mncc.h
+++ b/openbsc/include/openbsc/mncc.h
@@ -191,7 +191,7 @@ struct gsm_mncc_rtp {
uint32_t payload_msg_type;
};
-char *get_mncc_name(int value);
+const char *get_mncc_name(int value);
void mncc_set_cause(struct gsm_mncc *data, int loc, int val);
void cc_tx_to_mncc(struct gsm_network *net, struct msgb *msg);
diff --git a/openbsc/src/libmsc/mncc.c b/openbsc/src/libmsc/mncc.c
index 2767faa35..8110eadca 100644
--- a/openbsc/src/libmsc/mncc.c
+++ b/openbsc/src/libmsc/mncc.c
@@ -26,85 +26,76 @@
#include <string.h>
#include <errno.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/utils.h>
+
#include <openbsc/gsm_04_08.h>
#include <openbsc/debug.h>
#include <openbsc/mncc.h>
-#include <osmocom/core/talloc.h>
#include <openbsc/gsm_data.h>
#include <openbsc/transaction.h>
#include <openbsc/rtp_proxy.h>
-static struct mncc_names {
- char *name;
- int value;
-} mncc_names[] = {
- {"MNCC_SETUP_REQ", 0x0101},
- {"MNCC_SETUP_IND", 0x0102},
- {"MNCC_SETUP_RSP", 0x0103},
- {"MNCC_SETUP_CNF", 0x0104},
- {"MNCC_SETUP_COMPL_REQ",0x0105},
- {"MNCC_SETUP_COMPL_IND",0x0106},
- {"MNCC_CALL_CONF_IND", 0x0107},
- {"MNCC_CALL_PROC_REQ", 0x0108},
- {"MNCC_PROGRESS_REQ", 0x0109},
- {"MNCC_ALERT_REQ", 0x010a},
- {"MNCC_ALERT_IND", 0x010b},
- {"MNCC_NOTIFY_REQ", 0x010c},
- {"MNCC_NOTIFY_IND", 0x010d},
- {"MNCC_DISC_REQ", 0x010e},
- {"MNCC_DISC_IND", 0x010f},
- {"MNCC_REL_REQ", 0x0110},
- {"MNCC_REL_IND", 0x0111},
- {"MNCC_REL_CNF", 0x0112},
- {"MNCC_FACILITY_REQ", 0x0113},
- {"MNCC_FACILITY_IND", 0x0114},
- {"MNCC_START_DTMF_IND", 0x0115},
- {"MNCC_START_DTMF_RSP", 0x0116},
- {"MNCC_START_DTMF_REJ", 0x0117},
- {"MNCC_STOP_DTMF_IND", 0x0118},
- {"MNCC_STOP_DTMF_RSP", 0x0119},
- {"MNCC_MODIFY_REQ", 0x011a},
- {"MNCC_MODIFY_IND", 0x011b},
- {"MNCC_MODIFY_RSP", 0x011c},
- {"MNCC_MODIFY_CNF", 0x011d},
- {"MNCC_MODIFY_REJ", 0x011e},
- {"MNCC_HOLD_IND", 0x011f},
- {"MNCC_HOLD_CNF", 0x0120},
- {"MNCC_HOLD_REJ", 0x0121},
- {"MNCC_RETRIEVE_IND", 0x0122},
- {"MNCC_RETRIEVE_CNF", 0x0123},
- {"MNCC_RETRIEVE_REJ", 0x0124},
- {"MNCC_USERINFO_REQ", 0x0125},
- {"MNCC_USERINFO_IND", 0x0126},
- {"MNCC_REJ_REQ", 0x0127},
- {"MNCC_REJ_IND", 0x0128},
-
- {"MNCC_BRIDGE", 0x0200},
- {"MNCC_FRAME_RECV", 0x0201},
- {"MNCC_FRAME_DROP", 0x0202},
- {"MNCC_LCHAN_MODIFY", 0x0203},
- {"MNCC_RTP_CREATE", 0x0204},
- {"MNCC_RTP_CONNECT", 0x0205},
- {"MNCC_RTP_FREE", 0x0206},
- {"GSM_TCHF_FRAME", 0x0300},
- {"GSM_TCHF_FRAME_EFR", 0x0301},
- {"GSM_TCHH_FRAME", 0x0302},
- {"GSM_TCH_FRAME_AMR", 0x0303},
- {"GSM_BAD_FRAME", 0x03ff},
+static const struct value_string mncc_names[] = {
+ { MNCC_SETUP_REQ, "MNCC_SETUP_REQ" },
+ { MNCC_SETUP_IND, "MNCC_SETUP_IND" },
+ { MNCC_SETUP_RSP, "MNCC_SETUP_RSP" },
+ { MNCC_SETUP_CNF, "MNCC_SETUP_CNF" },
+ { MNCC_SETUP_COMPL_REQ, "MNCC_SETUP_COMPL_REQ" },
+ { MNCC_SETUP_COMPL_IND, "MNCC_SETUP_COMPL_IND" },
+ { MNCC_CALL_CONF_IND, "MNCC_CALL_CONF_IND" },
+ { MNCC_CALL_PROC_REQ, "MNCC_CALL_PROC_REQ" },
+ { MNCC_PROGRESS_REQ, "MNCC_PROGRESS_REQ" },
+ { MNCC_ALERT_REQ, "MNCC_ALERT_REQ" },
+ { MNCC_ALERT_IND, "MNCC_ALERT_IND" },
+ { MNCC_NOTIFY_REQ, "MNCC_NOTIFY_REQ" },
+ { MNCC_NOTIFY_IND, "MNCC_NOTIFY_IND" },
+ { MNCC_DISC_REQ, "MNCC_DISC_REQ" },
+ { MNCC_DISC_IND, "MNCC_DISC_IND" },
+ { MNCC_REL_REQ, "MNCC_REL_REQ" },
+ { MNCC_REL_IND, "MNCC_REL_IND" },
+ { MNCC_REL_CNF, "MNCC_REL_CNF" },
+ { MNCC_FACILITY_REQ, "MNCC_FACILITY_REQ" },
+ { MNCC_FACILITY_IND, "MNCC_FACILITY_IND" },
+ { MNCC_START_DTMF_IND, "MNCC_START_DTMF_IND" },
+ { MNCC_START_DTMF_RSP, "MNCC_START_DTMF_RSP" },
+ { MNCC_START_DTMF_REJ, "MNCC_START_DTMF_REJ" },
+ { MNCC_STOP_DTMF_IND, "MNCC_STOP_DTMF_IND" },
+ { MNCC_STOP_DTMF_RSP, "MNCC_STOP_DTMF_RSP" },
+ { MNCC_MODIFY_REQ, "MNCC_MODIFY_REQ" },
+ { MNCC_MODIFY_IND, "MNCC_MODIFY_IND" },
+ { MNCC_MODIFY_RSP, "MNCC_MODIFY_RSP" },
+ { MNCC_MODIFY_CNF, "MNCC_MODIFY_CNF" },
+ { MNCC_MODIFY_REJ, "MNCC_MODIFY_REJ" },
+ { MNCC_HOLD_IND, "MNCC_HOLD_IND" },
+ { MNCC_HOLD_CNF, "MNCC_HOLD_CNF" },
+ { MNCC_HOLD_REJ, "MNCC_HOLD_REJ" },
+ { MNCC_RETRIEVE_IND, "MNCC_RETRIEVE_IND" },
+ { MNCC_RETRIEVE_CNF, "MNCC_RETRIEVE_CNF" },
+ { MNCC_RETRIEVE_REJ, "MNCC_RETRIEVE_REJ" },
+ { MNCC_USERINFO_REQ, "MNCC_USERINFO_REQ" },
+ { MNCC_USERINFO_IND, "MNCC_USERINFO_IND" },
+ { MNCC_REJ_REQ, "MNCC_REJ_REQ" },
+ { MNCC_REJ_IND, "MNCC_REJ_IND" },
+ { MNCC_BRIDGE, "MNCC_BRIDGE" },
+ { MNCC_FRAME_RECV, "MNCC_FRAME_RECV" },
+ { MNCC_FRAME_DROP, "MNCC_FRAME_DROP" },
+ { MNCC_LCHAN_MODIFY, "MNCC_LCHAN_MODIFY" },
+ { MNCC_RTP_CREATE, "MNCC_RTP_CREATE" },
+ { MNCC_RTP_CONNECT, "MNCC_RTP_CONNECT" },
+ { MNCC_RTP_FREE, "MNCC_RTP_FREE" },
+ { GSM_TCHF_FRAME, "GSM_TCHF_FRAME" },
+ { GSM_TCHF_FRAME_EFR, "GSM_TCHF_FRAME_EFR" },
+ { GSM_TCHH_FRAME, "GSM_TCHH_FRAME" },
+ { GSM_TCH_FRAME_AMR, "GSM_TCH_FRAME_AMR" },
+ { GSM_BAD_FRAME, "GSM_BAD_FRAME" },
+ { 0, NULL },
+};
- {NULL, 0} };
-
-char *get_mncc_name(int value)
+const char *get_mncc_name(int value)
{
- int i;
-
- for (i = 0; mncc_names[i].name; i++) {
- if (mncc_names[i].value == value)
- return mncc_names[i].name;
- }
-
- return "MNCC_Unknown";
+ return get_value_string(mncc_names, value);
}
void mncc_set_cause(struct gsm_mncc *data, int loc, int val)