expert.[hc] Minor changes:
- Fix a few parameter descriptions in expert.h; - Do whitespace changes; - Add editor modelines. Change-Id: I1b75fa88021f1f44bd607cd33d0ab7f9ec672ab7 Reviewed-on: https://code.wireshark.org/review/4122 Reviewed-by: Bill Meier <wmeier@newsguy.com>
This commit is contained in:
parent
85dceb34a1
commit
126b4a6a98
151
epan/expert.c
151
epan/expert.c
|
@ -53,7 +53,7 @@ static int hf_expert_severity = -1;
|
|||
|
||||
struct expert_module
|
||||
{
|
||||
const char* proto_name;
|
||||
const char *proto_name;
|
||||
int proto_id; /* Cache this for registering hfs */
|
||||
};
|
||||
|
||||
|
@ -69,28 +69,28 @@ static gpa_expertinfo_t gpa_expertinfo;
|
|||
static GHashTable *gpa_name_map = NULL;
|
||||
|
||||
const value_string expert_group_vals[] = {
|
||||
{ PI_CHECKSUM, "Checksum" },
|
||||
{ PI_SEQUENCE, "Sequence" },
|
||||
{ PI_RESPONSE_CODE, "Response" },
|
||||
{ PI_REQUEST_CODE, "Request" },
|
||||
{ PI_UNDECODED, "Undecoded" },
|
||||
{ PI_REASSEMBLE, "Reassemble" },
|
||||
{ PI_MALFORMED, "Malformed" },
|
||||
{ PI_DEBUG, "Debug" },
|
||||
{ PI_PROTOCOL, "Protocol" },
|
||||
{ PI_SECURITY, "Security" },
|
||||
{ PI_COMMENTS_GROUP, "Comment" },
|
||||
{ 0, NULL }
|
||||
{ PI_CHECKSUM, "Checksum" },
|
||||
{ PI_SEQUENCE, "Sequence" },
|
||||
{ PI_RESPONSE_CODE, "Response" },
|
||||
{ PI_REQUEST_CODE, "Request" },
|
||||
{ PI_UNDECODED, "Undecoded" },
|
||||
{ PI_REASSEMBLE, "Reassemble" },
|
||||
{ PI_MALFORMED, "Malformed" },
|
||||
{ PI_DEBUG, "Debug" },
|
||||
{ PI_PROTOCOL, "Protocol" },
|
||||
{ PI_SECURITY, "Security" },
|
||||
{ PI_COMMENTS_GROUP, "Comment" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
const value_string expert_severity_vals[] = {
|
||||
{ PI_ERROR, "Error" },
|
||||
{ PI_WARN, "Warn" },
|
||||
{ PI_NOTE, "Note" },
|
||||
{ PI_CHAT, "Chat" },
|
||||
{ PI_COMMENT, "Comment" },
|
||||
{ 1, "Ok" },
|
||||
{ 0, NULL }
|
||||
{ PI_ERROR, "Error" },
|
||||
{ PI_WARN, "Warn" },
|
||||
{ PI_NOTE, "Note" },
|
||||
{ PI_CHAT, "Chat" },
|
||||
{ PI_COMMENT, "Comment" },
|
||||
{ 1, "Ok" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
/* Possible values for a checksum evaluation */
|
||||
|
@ -102,18 +102,18 @@ const value_string expert_checksum_vals[] = {
|
|||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static expert_field_info* expert_registrar_get_byname(const char *field_name);
|
||||
static expert_field_info *expert_registrar_get_byname(const char *field_name);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* UAT for customizing severity levels. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
char * field;
|
||||
guint32 severity;
|
||||
char *field;
|
||||
guint32 severity;
|
||||
} expert_level_entry_t;
|
||||
|
||||
static expert_level_entry_t* uat_expert_entries = NULL;
|
||||
static expert_level_entry_t *uat_expert_entries = NULL;
|
||||
static guint expert_level_entry_count = 0;
|
||||
/* Array of field names currently in UAT */
|
||||
static GArray *uat_saved_fields = NULL;
|
||||
|
@ -121,19 +121,19 @@ static GArray *uat_saved_fields = NULL;
|
|||
UAT_CSTRING_CB_DEF(uat_expert_entries, field, expert_level_entry_t)
|
||||
UAT_VS_DEF(uat_expert_entries, severity, expert_level_entry_t, guint32, PI_ERROR, "Error")
|
||||
|
||||
static void uat_expert_update_cb(void* r, const char** err)
|
||||
static void uat_expert_update_cb(void *r, const char **err)
|
||||
{
|
||||
expert_level_entry_t* rec = (expert_level_entry_t *)r;
|
||||
expert_level_entry_t *rec = (expert_level_entry_t *)r;
|
||||
|
||||
if (expert_registrar_get_byname(rec->field) == NULL) {
|
||||
*err = g_strdup_printf("Expert Info field doesn't exist");
|
||||
}
|
||||
}
|
||||
|
||||
static void* uat_expert_copy_cb(void* n, const void* o, size_t siz _U_)
|
||||
static void *uat_expert_copy_cb(void *n, const void *o, size_t siz _U_)
|
||||
{
|
||||
expert_level_entry_t* new_record = (expert_level_entry_t*)n;
|
||||
const expert_level_entry_t* old_record = (const expert_level_entry_t*)o;
|
||||
expert_level_entry_t *new_record = (expert_level_entry_t*)n;
|
||||
const expert_level_entry_t *old_record = (const expert_level_entry_t *)o;
|
||||
|
||||
if (old_record->field) {
|
||||
new_record->field = g_strdup(old_record->field);
|
||||
|
@ -141,14 +141,14 @@ static void* uat_expert_copy_cb(void* n, const void* o, size_t siz _U_)
|
|||
new_record->field = NULL;
|
||||
}
|
||||
|
||||
new_record->severity = old_record->severity;
|
||||
new_record->severity = old_record->severity;
|
||||
|
||||
return new_record;
|
||||
}
|
||||
|
||||
static void uat_expert_free_cb(void*r)
|
||||
{
|
||||
expert_level_entry_t* rec = (expert_level_entry_t *)r;
|
||||
expert_level_entry_t *rec = (expert_level_entry_t *)r;
|
||||
|
||||
if (rec->field)
|
||||
g_free(rec->field);
|
||||
|
@ -156,8 +156,8 @@ static void uat_expert_free_cb(void*r)
|
|||
|
||||
static void uat_expert_post_update_cb(void)
|
||||
{
|
||||
guint i;
|
||||
expert_field_info* field;
|
||||
guint i;
|
||||
expert_field_info *field;
|
||||
|
||||
/* Reset any of the previous list of expert info fields to their original severity */
|
||||
for ( i = 0 ; i < uat_saved_fields->len; i++ ) {
|
||||
|
@ -180,17 +180,17 @@ static void uat_expert_post_update_cb(void)
|
|||
}
|
||||
}
|
||||
|
||||
#define EXPERT_REGISTRAR_GET_NTH(eiindex, expinfo) \
|
||||
if((guint)eiindex >= gpa_expertinfo.len && getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG")) \
|
||||
g_error("Unregistered expert info! index=%d", eiindex); \
|
||||
DISSECTOR_ASSERT_HINT((guint)eiindex < gpa_expertinfo.len, "Unregistered expert info!");\
|
||||
#define EXPERT_REGISTRAR_GET_NTH(eiindex, expinfo) \
|
||||
if((guint)eiindex >= gpa_expertinfo.len && getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG")) \
|
||||
g_error("Unregistered expert info! index=%d", eiindex); \
|
||||
DISSECTOR_ASSERT_HINT((guint)eiindex < gpa_expertinfo.len, "Unregistered expert info!"); \
|
||||
expinfo = gpa_expertinfo.ei[eiindex];
|
||||
|
||||
void
|
||||
expert_packet_init(void)
|
||||
{
|
||||
module_t *module_expert;
|
||||
uat_t * expert_uat;
|
||||
uat_t *expert_uat;
|
||||
|
||||
static hf_register_info hf[] = {
|
||||
{ &hf_expert_msg,
|
||||
|
@ -231,7 +231,7 @@ expert_packet_init(void)
|
|||
sizeof(expert_level_entry_t),
|
||||
"expert_severity",
|
||||
TRUE,
|
||||
(void * *)&uat_expert_entries,
|
||||
(void **)&uat_expert_entries,
|
||||
&expert_level_entry_count,
|
||||
UAT_AFFECTS_DISSECTION,
|
||||
NULL,
|
||||
|
@ -259,9 +259,9 @@ expert_init(void)
|
|||
{
|
||||
gpa_expertinfo.len = 0;
|
||||
gpa_expertinfo.allocated_len = 0;
|
||||
gpa_expertinfo.ei = NULL;
|
||||
gpa_name_map = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
|
||||
uat_saved_fields = g_array_new(FALSE, FALSE, sizeof(expert_field_info*));
|
||||
gpa_expertinfo.ei = NULL;
|
||||
gpa_name_map = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
|
||||
uat_saved_fields = g_array_new(FALSE, FALSE, sizeof(expert_field_info*));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -302,14 +302,14 @@ expert_get_highest_severity(void)
|
|||
void
|
||||
expert_update_comment_count(guint64 count)
|
||||
{
|
||||
if (count==0 && highest_severity==PI_COMMENT)
|
||||
highest_severity = 0;
|
||||
if (count==0 && highest_severity==PI_COMMENT)
|
||||
highest_severity = 0;
|
||||
}
|
||||
|
||||
expert_module_t *expert_register_protocol(int id)
|
||||
{
|
||||
expert_module_t *module;
|
||||
protocol_t *protocol;
|
||||
protocol_t *protocol;
|
||||
|
||||
protocol = find_protocol_by_id(id);
|
||||
|
||||
|
@ -321,7 +321,7 @@ expert_module_t *expert_register_protocol(int id)
|
|||
}
|
||||
|
||||
static int
|
||||
expert_register_field_init(expert_field_info *expinfo, expert_module_t* module)
|
||||
expert_register_field_init(expert_field_info *expinfo, expert_module_t *module)
|
||||
{
|
||||
expinfo->protocol = module->proto_name;
|
||||
|
||||
|
@ -352,7 +352,7 @@ expert_register_field_init(expert_field_info *expinfo, expert_module_t* module)
|
|||
/* for use with static arrays only, since we don't allocate our own copies
|
||||
of the expert_field_info struct contained within the exp_register_info struct */
|
||||
void
|
||||
expert_register_field_array(expert_module_t* module, ei_register_info *exp, const int num_records)
|
||||
expert_register_field_array(expert_module_t *module, ei_register_info *exp, const int num_records)
|
||||
{
|
||||
int i;
|
||||
ei_register_info *ptr = exp;
|
||||
|
@ -392,7 +392,7 @@ expert_register_field_array(expert_module_t* module, ei_register_info *exp, cons
|
|||
static expert_field_info *
|
||||
expert_registrar_get_byname(const char *field_name)
|
||||
{
|
||||
expert_field_info *hfinfo;
|
||||
expert_field_info *hfinfo;
|
||||
|
||||
if (!field_name)
|
||||
return NULL;
|
||||
|
@ -448,13 +448,13 @@ expert_create_tree(proto_item *pi, int group, int severity, const char *msg)
|
|||
|
||||
static void
|
||||
expert_set_info_vformat(packet_info *pinfo, proto_item *pi, int group, int severity, int hf_index, gboolean use_vaformat,
|
||||
const char *format, va_list ap)
|
||||
const char *format, va_list ap)
|
||||
{
|
||||
char formatted[ITEM_LABEL_LENGTH];
|
||||
int tap;
|
||||
expert_info_t *ei;
|
||||
proto_tree *tree;
|
||||
proto_item *ti;
|
||||
char formatted[ITEM_LABEL_LENGTH];
|
||||
int tap;
|
||||
expert_info_t *ei;
|
||||
proto_tree *tree;
|
||||
proto_item *ti;
|
||||
|
||||
if (pinfo == NULL && pi && pi->tree_data) {
|
||||
pinfo = PTREE_DATA(pi)->pinfo;
|
||||
|
@ -532,13 +532,13 @@ expert_set_info_vformat(packet_info *pinfo, proto_item *pi, int group, int sever
|
|||
tap_queue_packet(expert_tap, pinfo, ei);
|
||||
}
|
||||
|
||||
/* Helper function for expert_add_info() to work around compiler's special needs on ARM*/
|
||||
/* Helper function for expert_add_info() to work around compiler's special needs on ARM */
|
||||
static inline void
|
||||
expert_add_info_internal(packet_info *pinfo, proto_item *pi, expert_field *expindex, ...)
|
||||
{
|
||||
/* the va_list is ignored */
|
||||
va_list unused;
|
||||
expert_field_info* eiinfo;
|
||||
va_list unused;
|
||||
expert_field_info *eiinfo;
|
||||
|
||||
/* Look up the item */
|
||||
EXPERT_REGISTRAR_GET_NTH(expindex->ei, eiinfo);
|
||||
|
@ -557,8 +557,8 @@ expert_add_info(packet_info *pinfo, proto_item *pi, expert_field *expindex)
|
|||
void
|
||||
expert_add_info_format(packet_info *pinfo, proto_item *pi, expert_field *expindex, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
expert_field_info* eiinfo;
|
||||
va_list ap;
|
||||
expert_field_info *eiinfo;
|
||||
|
||||
/* Look up the item */
|
||||
EXPERT_REGISTRAR_GET_NTH(expindex->ei, eiinfo);
|
||||
|
@ -568,14 +568,14 @@ expert_add_info_format(packet_info *pinfo, proto_item *pi, expert_field *expinde
|
|||
va_end(ap);
|
||||
}
|
||||
|
||||
/* Helper function for expert_add_expert() to work around compiler's special needs on ARM*/
|
||||
/* Helper function for expert_add_expert() to work around compiler's special needs on ARM */
|
||||
static inline proto_item *
|
||||
proto_tree_add_expert_internal(proto_tree *tree, packet_info *pinfo, expert_field* expindex,
|
||||
proto_tree_add_expert_internal(proto_tree *tree, packet_info *pinfo, expert_field *expindex,
|
||||
tvbuff_t *tvb, gint start, gint length, ...)
|
||||
{
|
||||
expert_field_info* eiinfo;
|
||||
proto_item *ti;
|
||||
va_list unused;
|
||||
expert_field_info *eiinfo;
|
||||
proto_item *ti;
|
||||
va_list unused;
|
||||
|
||||
/* Look up the item */
|
||||
EXPERT_REGISTRAR_GET_NTH(expindex->ei, eiinfo);
|
||||
|
@ -588,19 +588,19 @@ proto_tree_add_expert_internal(proto_tree *tree, packet_info *pinfo, expert_fiel
|
|||
}
|
||||
|
||||
proto_item *
|
||||
proto_tree_add_expert(proto_tree *tree, packet_info *pinfo, expert_field* expindex,
|
||||
proto_tree_add_expert(proto_tree *tree, packet_info *pinfo, expert_field *expindex,
|
||||
tvbuff_t *tvb, gint start, gint length)
|
||||
{
|
||||
return proto_tree_add_expert_internal(tree, pinfo, expindex, tvb, start, length);
|
||||
}
|
||||
|
||||
proto_item *
|
||||
proto_tree_add_expert_format(proto_tree *tree, packet_info *pinfo, expert_field* expindex,
|
||||
proto_tree_add_expert_format(proto_tree *tree, packet_info *pinfo, expert_field *expindex,
|
||||
tvbuff_t *tvb, gint start, gint length, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
expert_field_info* eiinfo;
|
||||
proto_item *ti;
|
||||
va_list ap;
|
||||
expert_field_info *eiinfo;
|
||||
proto_item *ti;
|
||||
|
||||
/* Look up the item */
|
||||
EXPERT_REGISTRAR_GET_NTH(expindex->ei, eiinfo);
|
||||
|
@ -615,3 +615,16 @@ proto_tree_add_expert_format(proto_tree *tree, packet_info *pinfo, expert_field*
|
|||
|
||||
return ti;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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:
|
||||
*/
|
||||
|
|
|
@ -36,12 +36,12 @@ extern "C" {
|
|||
|
||||
/** only for internal and display use. */
|
||||
typedef struct expert_info_s {
|
||||
guint32 packet_num;
|
||||
int group;
|
||||
int severity;
|
||||
guint32 packet_num;
|
||||
int group;
|
||||
int severity;
|
||||
const gchar *protocol;
|
||||
gchar *summary;
|
||||
proto_item *pitem;
|
||||
gchar *summary;
|
||||
proto_item *pitem;
|
||||
} expert_info_t;
|
||||
|
||||
/* Expert Info and Display hf data */
|
||||
|
@ -57,17 +57,17 @@ typedef struct expert_field
|
|||
|
||||
typedef struct expert_field_info {
|
||||
/* ---------- set by dissector --------- */
|
||||
const char *name;
|
||||
int group;
|
||||
int severity;
|
||||
const gchar *summary;
|
||||
const char *name;
|
||||
int group;
|
||||
int severity;
|
||||
const gchar *summary;
|
||||
|
||||
/* ------- set by register routines (prefilled by EXPFILL macro, see below) ------ */
|
||||
int id;
|
||||
const gchar *protocol;
|
||||
int orig_severity; /* Matches severity when registered, used to restore original severity
|
||||
* if UAT severity entry is removed */
|
||||
hf_register_info hf_info;
|
||||
int id;
|
||||
const gchar *protocol;
|
||||
int orig_severity; /* Matches severity when registered, used to restore original severity
|
||||
* if UAT severity entry is removed */
|
||||
hf_register_info hf_info;
|
||||
|
||||
} expert_field_info;
|
||||
|
||||
|
@ -76,7 +76,7 @@ typedef struct expert_field_info {
|
|||
|
||||
typedef struct ei_register_info {
|
||||
expert_field *ids; /**< written to by register() function */
|
||||
expert_field_info eiinfo; /**< the field info to be registered */
|
||||
expert_field_info eiinfo; /**< the field info to be registered */
|
||||
} ei_register_info;
|
||||
|
||||
typedef struct expert_module expert_module_t;
|
||||
|
@ -114,10 +114,10 @@ expert_update_comment_count(guint64 count);
|
|||
@param eiindex The registered expert info item
|
||||
*/
|
||||
WS_DLL_PUBLIC void
|
||||
expert_add_info(packet_info *pinfo, proto_item *pi, expert_field* eiindex);
|
||||
expert_add_info(packet_info *pinfo, proto_item *pi, expert_field *eiindex);
|
||||
|
||||
/** Add an expert info.
|
||||
Add an expert info tree to a protocol item, using registered expert info item,
|
||||
Add an expert info tree to a protocol item using registered expert info item,
|
||||
but with a formatted message.
|
||||
@param pinfo Packet info of the currently processed packet. May be NULL if
|
||||
pi is supplied
|
||||
|
@ -127,16 +127,15 @@ expert_add_info(packet_info *pinfo, proto_item *pi, expert_field* eiindex);
|
|||
*/
|
||||
WS_DLL_PUBLIC void
|
||||
expert_add_info_format(packet_info *pinfo, proto_item *pi, expert_field *eiindex,
|
||||
const char *format, ...) G_GNUC_PRINTF(4, 5);
|
||||
const char *format, ...) G_GNUC_PRINTF(4, 5);
|
||||
|
||||
/** Add an expert info associated with some byte data
|
||||
Add an expert info tree to a protocol item using registered expert info item.
|
||||
This function is intended to replace places where
|
||||
proto_tree_add_text or proto_tree_add_none_format + expert_add_info
|
||||
would be used.
|
||||
@param tree Current protocol item (or NULL)
|
||||
@param pinfo Packet info of the currently processed packet. May be NULL if
|
||||
pi is supplied
|
||||
@param tree Current protocol tree (or NULL)
|
||||
@param pinfo Packet info of the currently processed packet. May be NULL if tree is supplied
|
||||
@param eiindex The registered expert info item
|
||||
@param tvb the tv buffer of the current data
|
||||
@param start start of data in tvb
|
||||
|
@ -144,7 +143,7 @@ expert_add_info_format(packet_info *pinfo, proto_item *pi, expert_field *eiindex
|
|||
@return the newly created item above expert info tree
|
||||
*/
|
||||
WS_DLL_PUBLIC proto_item *
|
||||
proto_tree_add_expert(proto_tree *tree, packet_info *pinfo, expert_field* eiindex,
|
||||
proto_tree_add_expert(proto_tree *tree, packet_info *pinfo, expert_field *eiindex,
|
||||
tvbuff_t *tvb, gint start, gint length);
|
||||
|
||||
/** Add an expert info associated with some byte data
|
||||
|
@ -153,7 +152,7 @@ proto_tree_add_expert(proto_tree *tree, packet_info *pinfo, expert_field* eiinde
|
|||
This function is intended to replace places where
|
||||
proto_tree_add_text or proto_tree_add_none_format + expert_add_info_format
|
||||
would be used.
|
||||
@param tree Current protocol item (or NULL)
|
||||
@param tree Current protocol tree (or NULL)
|
||||
@param pinfo Packet info of the currently processed packet. May be NULL if tree is supplied
|
||||
@param eiindex The registered expert info item
|
||||
@param tvb the tv buffer of the current data
|
||||
|
@ -163,7 +162,7 @@ proto_tree_add_expert(proto_tree *tree, packet_info *pinfo, expert_field* eiinde
|
|||
@return the newly created item above expert info tree
|
||||
*/
|
||||
WS_DLL_PUBLIC proto_item *
|
||||
proto_tree_add_expert_format(proto_tree *tree, packet_info *pinfo, expert_field* eiindex,
|
||||
proto_tree_add_expert_format(proto_tree *tree, packet_info *pinfo, expert_field *eiindex,
|
||||
tvbuff_t *tvb, gint start, gint length, const char *format, ...) G_GNUC_PRINTF(7, 8);
|
||||
|
||||
/*
|
||||
|
@ -176,7 +175,7 @@ WS_DLL_PUBLIC expert_module_t *expert_register_protocol(int id);
|
|||
@param ei the ei_register_info array
|
||||
@param num_records the number of records in exp */
|
||||
WS_DLL_PUBLIC void
|
||||
expert_register_field_array(expert_module_t* module, ei_register_info *ei, const int num_records);
|
||||
expert_register_field_array(expert_module_t *module, ei_register_info *ei, const int num_records);
|
||||
|
||||
#define EXPERT_CHECKSUM_DISABLED -2
|
||||
#define EXPERT_CHECKSUM_UNKNOWN -1
|
||||
|
@ -194,3 +193,16 @@ WS_DLL_PUBLIC const value_string expert_checksum_vals[];
|
|||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __EXPERT_H__ */
|
||||
|
||||
/*
|
||||
* 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:
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue