aboutsummaryrefslogtreecommitdiffstats
path: root/epan/value_string.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-12-01 23:42:32 +0000
committerGuy Harris <guy@alum.mit.edu>2003-12-01 23:42:32 +0000
commitf549d46c376eddc2dab6ba97d774a4b11ec315d2 (patch)
treeff658e4a0fbc613aceea023ab958426d06c1da5b /epan/value_string.c
parent00fbb882299228eb1cb367ac4cce4b98ccbda1ca (diff)
From Tomas Kukosa: add "decode_enumerated_bitfield_shifted()", which is
like "decode_enumerated_bitfield()" but handles value_string tables containing values as they appear in the bitfield rather than as they appear in the item containing the bitfield. svn path=/trunk/; revision=9134
Diffstat (limited to 'epan/value_string.c')
-rw-r--r--epan/value_string.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/epan/value_string.c b/epan/value_string.c
index 36e2e0dd1c..f5c1cbe5a3 100644
--- a/epan/value_string.c
+++ b/epan/value_string.c
@@ -1,7 +1,7 @@
/* value_string.c
* Routines for value_strings
*
- * $Id: value_string.c,v 1.4 2002/08/28 20:40:45 jmayer Exp $
+ * $Id: value_string.c,v 1.5 2003/12/01 23:41:44 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -88,3 +88,22 @@ decode_enumerated_bitfield(guint32 val, guint32 mask, int width,
}
+/* Generate a string describing an enumerated bitfield (an N-bit field
+ with various specific values having particular names). */
+const char *
+decode_enumerated_bitfield_shifted(guint32 val, guint32 mask, int width,
+ const value_string *tab, const char *fmt)
+{
+ static char buf[1025];
+ char *p;
+ int shift = 0;
+
+ /* Compute the number of bits we have to shift the bitfield right
+ to extract its value. */
+ while ((mask & (1<<shift)) == 0)
+ shift++;
+
+ p = decode_bitfield_value(buf, val, mask, width);
+ sprintf(p, fmt, val_to_str((val & mask) >> shift, tab, "Unknown"));
+ return buf;
+}