summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte2011-08-21 00:55:23 +0200
committerHarald Welte2011-08-21 12:15:08 +0200
commit6341aa0595879137ad0eec3e906db18698247234 (patch)
treedb4d8dddd2cf4defc12bf4234116ca3c9d33c5af
parente1_input: move the lapd_instance pointer out of dahdi specifics (diff)
downloadlibosmo-abis-6341aa0595879137ad0eec3e906db18698247234.tar.gz
libosmo-abis-6341aa0595879137ad0eec3e906db18698247234.tar.xz
libosmo-abis-6341aa0595879137ad0eec3e906db18698247234.zip
mISDN: use 'struct value_string' instead of local copy
Apparently value_string was not part of libosmocore when the code was written originally...
-rw-r--r--src/input/misdn.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/src/input/misdn.c b/src/input/misdn.c
index bb9145f..2af81f2 100644
--- a/src/input/misdn.c
+++ b/src/input/misdn.c
@@ -42,6 +42,7 @@
#endif
#include <osmocom/core/select.h>
+#include <osmocom/core/utils.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/logging.h>
#include <osmocom/abis/e1_input.h>
@@ -49,12 +50,7 @@
#define TS1_ALLOC_SIZE 300
-struct prim_name {
- unsigned int prim;
- const char *name;
-};
-
-const struct prim_name prim_names[] = {
+const struct value_string prim_names[] = {
{ PH_CONTROL_IND, "PH_CONTROL_IND" },
{ PH_DATA_IND, "PH_DATA_IND" },
{ PH_DATA_CNF, "PH_DATA_CNF" },
@@ -68,20 +64,9 @@ const struct prim_name prim_names[] = {
{ DL_INFORMATION_IND, "DL_INFORMATION_IND" },
{ MPH_ACTIVATE_IND, "MPH_ACTIVATE_IND" },
{ MPH_DEACTIVATE_IND, "MPH_DEACTIVATE_IND" },
+ { 0, NULL }
};
-const char *get_prim_name(unsigned int prim)
-{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(prim_names); i++) {
- if (prim_names[i].prim == prim)
- return prim_names[i].name;
- }
-
- return "UNKNOWN";
-}
-
static int handle_ts1_read(struct osmo_fd *bfd)
{
struct e1inp_line *line = bfd->data;
@@ -118,7 +103,7 @@ static int handle_ts1_read(struct osmo_fd *bfd)
alen, l2addr.dev, l2addr.channel, l2addr.sapi, l2addr.tei);
DEBUGP(DLMI, "<= len = %d, prim(0x%x) id(0x%x): %s\n",
- ret, hh->prim, hh->id, get_prim_name(hh->prim));
+ ret, hh->prim, hh->id, get_value_string(prim_names, hh->prim));
switch (hh->prim) {
case DL_INFORMATION_IND:
@@ -302,7 +287,8 @@ static int handle_tsX_read(struct osmo_fd *bfd)
if (hh->prim != PH_CONTROL_IND)
DEBUGP(DLMIB, "<= BCHAN len = %d, prim(0x%x) id(0x%x): %s\n",
- ret, hh->prim, hh->id, get_prim_name(hh->prim));
+ ret, hh->prim, hh->id,
+ get_value_string(prim_names, hh->prim));
switch (hh->prim) {
case PH_DATA_IND: