From 6341aa0595879137ad0eec3e906db18698247234 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 21 Aug 2011 00:55:23 +0200 Subject: mISDN: use 'struct value_string' instead of local copy Apparently value_string was not part of libosmocore when the code was written originally... --- src/input/misdn.c | 26 ++++++-------------------- 1 file 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 +#include #include #include #include @@ -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: -- cgit v1.2.3-55-g7522