forked from osmocom/wireshark
Remove decode_enumerated_bitfield and decode_enumerated_bitfield_shifted.
Effectively inline the only remain call (and replace a static buffer with ep memory). Much of the NFS dissector needs to be converted to use named fields at which point this code can go away, but that's a much bigger job. Also, add modelines to packet-nfs.c and mark some internal value_string functions as WS_DLL_LOCAL. svn path=/trunk/; revision=48635
This commit is contained in:
parent
37600a157b
commit
a0d107beec
|
@ -6706,9 +6706,17 @@ dissect_nfs_fattr4_fh_expire_type(tvbuff_t *tvb, int offset, proto_tree *tree)
|
|||
{
|
||||
if (expire_type == FH4_PERSISTENT)
|
||||
{
|
||||
proto_tree_add_text(expire_type_tree, tvb, offset, 4, "%s",
|
||||
decode_enumerated_bitfield(expire_type, 0xFFFFFFFF, 32,
|
||||
nfs4_fattr4_fh_expire_type_names, "%s"));
|
||||
char *p, *buf;
|
||||
|
||||
/* TODO: this should be replaced with a named field and
|
||||
* proto_tree_add_item */
|
||||
buf = (char *)ep_alloc(1025);
|
||||
p = decode_bitfield_value(buf, expire_type, 0xFFFFFFFF, 32);
|
||||
g_snprintf(p, (gulong) (1024-(p-buf)), "%s",
|
||||
val_to_str_const(expire_type,
|
||||
nfs4_fattr4_fh_expire_type_names,
|
||||
"Unknown"));
|
||||
proto_tree_add_text(expire_type_tree, tvb, offset, 4, "%s", buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -12758,3 +12766,16 @@ proto_reg_handoff_nfs(void)
|
|||
fhandle_handle=create_dissector_handle(dissect_fhandle_data_unknown, proto_nfs);
|
||||
dissector_add_uint("nfs_fhandle.type", FHT_UNKNOWN, fhandle_handle);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
||||
* :indentSize=8:tabSize=8:noTabs=false:
|
||||
*/
|
||||
|
|
|
@ -498,42 +498,6 @@ value_string_ext_match_type_str(const value_string_ext *vse)
|
|||
return "[Match Type not initialized or invalid]";
|
||||
}
|
||||
|
||||
/* Functions for bitfield generation, do they even belong here? */
|
||||
|
||||
/* Generate a string describing an enumerated bitfield (an N-bit field
|
||||
with various specific values having particular names). */
|
||||
const char *
|
||||
decode_enumerated_bitfield(const guint32 val, const guint32 mask,
|
||||
const int width, const value_string *tab, const char *fmt)
|
||||
{
|
||||
static char buf[1025];
|
||||
char *p;
|
||||
|
||||
p = decode_bitfield_value(buf, val, mask, width);
|
||||
g_snprintf(p, (gulong) (1024-(p-buf)), fmt, val_to_str_const(val & mask, tab, "Unknown"));
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* Generate a string describing an enumerated bitfield (an N-bit field
|
||||
with various specific values having particular names). */
|
||||
const char *
|
||||
decode_enumerated_bitfield_shifted(const guint32 val, const guint32 mask,
|
||||
const 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);
|
||||
g_snprintf(p, (gulong) (1024-(p-buf)), fmt, val_to_str_const((val & mask) >> shift, tab, "Unknown"));
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
|
|
|
@ -135,17 +135,12 @@ try_rval_to_str_idx(const guint32 val, const range_string *rs, gint *idx);
|
|||
|
||||
/* MISC (generally do not use) */
|
||||
|
||||
gboolean value_string_ext_validate(const value_string_ext *vse);
|
||||
const gchar *value_string_ext_match_type_str(const value_string_ext *vse);
|
||||
WS_DLL_LOCAL
|
||||
gboolean
|
||||
value_string_ext_validate(const value_string_ext *vse);
|
||||
|
||||
/* Generate a string describing an enumerated bitfield (an N-bit field
|
||||
with various specific values having particular names). */
|
||||
WS_DLL_PUBLIC const char *decode_enumerated_bitfield(const guint32 val, const guint32 mask,
|
||||
const int width, const value_string *tab, const char *fmt);
|
||||
|
||||
/* Generate a string describing an enumerated bitfield (an N-bit field
|
||||
with various specific values having particular names). */
|
||||
WS_DLL_PUBLIC const char *decode_enumerated_bitfield_shifted(const guint32 val, const guint32 mask,
|
||||
const int width, const value_string *tab, const char *fmt);
|
||||
WS_DLL_LOCAL
|
||||
const gchar*
|
||||
value_string_ext_match_type_str(const value_string_ext *vse);
|
||||
|
||||
#endif /* __VALUE_STRING_H__ */
|
||||
|
|
Loading…
Reference in New Issue