diff options
author | Harald Welte <laforge@gnumonks.org> | 2011-08-21 00:55:23 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2011-08-21 12:15:08 +0200 |
commit | 6341aa0595879137ad0eec3e906db18698247234 (patch) | |
tree | db4d8dddd2cf4defc12bf4234116ca3c9d33c5af /src/input/misdn.c | |
parent | fd44a5f2fed648b3d182136d15d89bd6a5fdecf3 (diff) |
mISDN: use 'struct value_string' instead of local copy
Apparently value_string was not part of libosmocore when the code was
written originally...
Diffstat (limited to 'src/input/misdn.c')
-rw-r--r-- | src/input/misdn.c | 26 |
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: |