Add proto_tree_add_expert and proto_tree_add_expert_format. This was added to expert.h instead of proto.h because the underlying code to process expert info is static (and should probably remain so). Also, proto_tree_add_expert and proto_tree_add_expert_format follow "expert info" rules in that they should be called regardless of tree status (even though they take a tree as an argument), unlike the functions in proto.h

Also added an enumeration for checksum validation status, as verifying checksums is considered "expert" functionality.

svn path=/trunk/; revision=50322
This commit is contained in:
Michael Mann 2013-07-02 19:53:28 +00:00
parent b0e04aca73
commit e16933f496
2 changed files with 84 additions and 2 deletions

View File

@ -72,6 +72,15 @@ static gpa_expertinfo_t gpa_expertinfo;
*/
static emem_tree_t *expert_modules = NULL;
/* Possible values for a checksum evaluation */
const value_string expert_checksum_vals[] = {
{ -1, "Unknown/Disabled" },
{ 0, "Good" },
{ 1, "Bad" },
{ 0, NULL }
};
#define EXPERT_REGISTRAR_GET_NTH(eiindex, expinfo) \
if((guint)eiindex >= gpa_expertinfo.len && getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG")) \
@ -401,6 +410,39 @@ expert_add_info_format_text(packet_info *pinfo, proto_item *pi, expert_field *ex
va_end(ap);
}
proto_item *
proto_tree_add_expert(proto_tree *tree, packet_info *pinfo, expert_field* expindex,
tvbuff_t *tvb, gint start, gint length)
{
expert_field_info* eiinfo;
proto_item *ti;
/* Look up the item */
EXPERT_REGISTRAR_GET_NTH(expindex->ei, eiinfo);
ti = proto_tree_add_text(tree, tvb, start, length, "%s", eiinfo->summary);
expert_set_info_vformat(pinfo, ti, eiinfo->group, eiinfo->severity, *eiinfo->hf_info.p_id, FALSE, eiinfo->summary, NULL);
return ti;
}
proto_item *
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;
/* Look up the item */
EXPERT_REGISTRAR_GET_NTH(expindex->ei, eiinfo);
va_start(ap, format);
ti = proto_tree_add_text(tree, tvb, start, length, format, ap);
expert_set_info_vformat(pinfo, ti, eiinfo->group, eiinfo->severity, *eiinfo->hf_info.p_id, TRUE, format, ap);
va_end(ap);
return ti;
}
void
expert_add_undecoded_item(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int length, const int severity)
{
@ -409,7 +451,7 @@ expert_add_undecoded_item(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, i
expert_item = proto_tree_add_text(tree, tvb, offset, length, "Not dissected yet");
expert_add_info_format(pinfo, expert_item, PI_UNDECODED, severity, "Not dissected yet(report to wireshark.org)"); \
PROTO_ITEM_SET_GENERATED(expert_item); \
expert_add_info_format(pinfo, expert_item, PI_UNDECODED, severity, "Not dissected yet(report to wireshark.org)");
PROTO_ITEM_SET_GENERATED(expert_item);
}

View File

@ -166,6 +166,43 @@ WS_DLL_PUBLIC void
expert_add_info_format_text(packet_info *pinfo, proto_item *pi, expert_field *eiindex,
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 pinfo Packet info of the currently processed packet. May be NULL if
pi is supplied
@param pi Current protocol item (or NULL)
@param eiindex The registered expert info item
@param tvb the tv buffer of the current data
@param start start of data in tvb
@param length length of data in tvb
@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,
tvbuff_t *tvb, gint start, gint length);
/** Add an expert info associated with some byte data
Add an expert info tree to a protocol item, using registered expert info item,
but with a formatted message.
This function is intended to replace places where
proto_tree_add_text or proto_tree_add_none_format + expert_add_info_format_text
would be used.
@param pinfo Packet info of the currently processed packet. May be NULL if
pi is supplied
@param pi Current protocol item (or NULL)
@param eiindex The registered expert info item
@param tvb the tv buffer of the current data
@param start start of data in tvb
@param length length of data in tvb
@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,
tvbuff_t *tvb, gint start, gint length, const char *format, ...) G_GNUC_PRINTF(7, 8);
/*
* Register that a protocol has expert info.
*/
@ -191,6 +228,9 @@ expert_register_field_array(expert_module_t* module, ei_register_info *ei, const
WS_DLL_PUBLIC void
expert_add_undecoded_item(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int length, const int severity);
WS_DLL_PUBLIC const value_string expert_checksum_vals[];
#ifdef __cplusplus
}
#endif /* __cplusplus */