summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2014-12-13 17:27:28 +0100
committerPascal Quantin <pascal.quantin@gmail.com>2014-12-13 16:36:13 +0000
commit80d44af6b22dd08f59281bf3531fb870bfc96393 (patch)
tree5450279b3abae4ec39e6cce927c0cda7db1e32e3
parentcc12c726b88a7f056a21f78fb531d0e2e986b133 (diff)
downloadwireshark-80d44af6b22dd08f59281bf3531fb870bfc96393.tar.gz
dissector_try_uint(_new) and dissector_try_string now return the number of bytes consumed
Change-Id: I528ad736caee1f29e2f0abfc0afcca6587d74eca Reviewed-on: https://code.wireshark.org/review/5743 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
-rw-r--r--epan/dissectors/packet-ethertype.c4
-rw-r--r--epan/dissectors/packet-mpls.c2
-rw-r--r--epan/dissectors/packet-msrp.c4
-rw-r--r--epan/dissectors/packet-nhrp.c10
-rw-r--r--epan/dissectors/packet-rtp.c5
-rw-r--r--epan/dissectors/packet-sdp.c2
-rw-r--r--epan/dissectors/packet-sip.c13
-rw-r--r--epan/dissectors/packet-usb.c2
-rw-r--r--epan/dissectors/packet-wsp.c12
-rw-r--r--epan/packet.h12
10 files changed, 32 insertions, 34 deletions
diff --git a/epan/dissectors/packet-ethertype.c b/epan/dissectors/packet-ethertype.c
index d2b8c1f177..3ee8d3307b 100644
--- a/epan/dissectors/packet-ethertype.c
+++ b/epan/dissectors/packet-ethertype.c
@@ -251,7 +251,7 @@ dissect_ethertype(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
tvbuff_t *volatile next_tvb;
guint length_before;
gint captured_length, reported_length;
- volatile gboolean dissector_found = FALSE;
+ volatile int dissector_found = 0;
const char *volatile saved_proto;
ethertype_data_t *ethertype_data;
@@ -314,7 +314,7 @@ dissect_ethertype(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
before we called the subdissector. */
show_exception(next_tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
- dissector_found = TRUE;
+ dissector_found = 1;
pinfo->current_proto = saved_proto;
}
ENDTRY;
diff --git a/epan/dissectors/packet-mpls.c b/epan/dissectors/packet-mpls.c
index ab9adce9ab..a2d83ece64 100644
--- a/epan/dissectors/packet-mpls.c
+++ b/epan/dissectors/packet-mpls.c
@@ -480,7 +480,7 @@ dissect_mpls(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
guint8 bos;
guint8 ttl;
tvbuff_t *next_tvb;
- gboolean found;
+ int found;
guint8 first_nibble;
struct mplsinfo mplsinfo;
diff --git a/epan/dissectors/packet-msrp.c b/epan/dissectors/packet-msrp.c
index 35ba5152c4..c82b2455ea 100644
--- a/epan/dissectors/packet-msrp.c
+++ b/epan/dissectors/packet-msrp.c
@@ -469,7 +469,7 @@ dissect_msrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
gint value_len;
char *value;
gboolean have_body = FALSE;
- gboolean found_match = FALSE;
+ int found_match = 0;
gint content_type_len, content_type_parameter_str_len;
gchar *media_type_str_lower_case = NULL;
char *content_type_parameter_str = NULL;
@@ -695,7 +695,7 @@ dissect_msrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
msrp_data_tree, content_type_parameter_str);
/* If no match dump as text */
}
- if ( found_match != TRUE )
+ if ( found_match == 0 )
{
offset = 0;
while (tvb_offset_exists(next_tvb, offset)) {
diff --git a/epan/dissectors/packet-nhrp.c b/epan/dissectors/packet-nhrp.c
index 5f507a2941..b71514cc59 100644
--- a/epan/dissectors/packet-nhrp.c
+++ b/epan/dissectors/packet-nhrp.c
@@ -730,7 +730,7 @@ static void dissect_nhrp_mand(tvbuff_t *tvb,
gboolean save_in_error_pkt;
gint pkt_len = mandEnd - offset;
proto_tree *ind_tree = proto_tree_add_subtree(tree, tvb, offset, pkt_len, ett_nhrp_indication, NULL, "Packet Causing Indication");
- gboolean dissected;
+ int dissected;
tvbuff_t *sub_tvb;
save_in_error_pkt = pinfo->flags.in_error_pkt;
@@ -770,7 +770,7 @@ static void dissect_nhrp_mand(tvbuff_t *tvb,
sub_tvb, pinfo,
ind_tree);
} else
- dissected = FALSE;
+ dissected = 0;
}
} else {
/*
@@ -787,13 +787,13 @@ static void dissect_nhrp_mand(tvbuff_t *tvb,
}
} else if (hdr->ar_pro_type <= 0x3FF) {
/* Reserved for future use by the IETF */
- dissected = FALSE;
+ dissected = 0;
} else if (hdr->ar_pro_type <= 0x04FF) {
/* Allocated for use by the ATM Forum */
- dissected = FALSE;
+ dissected = 0;
} else if (hdr->ar_pro_type <= 0x05FF) {
/* Experimental/Local use */
- dissected = FALSE;
+ dissected = 0;
} else {
dissected = dissector_try_uint(
ethertype_subdissector_table,
diff --git a/epan/dissectors/packet-rtp.c b/epan/dissectors/packet-rtp.c
index c832c0067b..87fb7af388 100644
--- a/epan/dissectors/packet-rtp.c
+++ b/epan/dissectors/packet-rtp.c
@@ -1442,7 +1442,8 @@ process_rtp_payload(tvbuff_t *newtvb, packet_info *pinfo, proto_tree *tree,
if (p_conv_data && p_conv_data->rtp_dyn_payload) {
const gchar *payload_type_str = rtp_dyn_payload_get_name(p_conv_data->rtp_dyn_payload, payload_type);
if (payload_type_str) {
- found_match = dissector_try_string(rtp_dyn_pt_dissector_table,
+ int len;
+ len = dissector_try_string(rtp_dyn_pt_dissector_table,
payload_type_str, newtvb, pinfo, tree, NULL);
/* If payload type string set from conversation and
* no matching dissector found it's probably because no subdissector
@@ -1450,7 +1451,7 @@ process_rtp_payload(tvbuff_t *newtvb, packet_info *pinfo, proto_tree *tree,
* as that'd probably be the wrong dissector in this case.
* Just add it as data.
*/
- if(found_match==FALSE)
+ if(len==0)
proto_tree_add_item( rtp_tree, hf_rtp_data, newtvb, 0, -1, ENC_NA );
return;
}
diff --git a/epan/dissectors/packet-sdp.c b/epan/dissectors/packet-sdp.c
index 440e4d6776..a93f6ed897 100644
--- a/epan/dissectors/packet-sdp.c
+++ b/epan/dissectors/packet-sdp.c
@@ -755,7 +755,7 @@ static void dissect_key_mgmt(tvbuff_t *tvb, packet_info * pinfo, proto_item * ti
gchar *prtcl_id = NULL;
gint len;
tvbuff_t *keymgmt_tvb;
- gboolean found_match = FALSE;
+ int found_match = 0;
proto_tree *key_tree;
gint next_offset;
gint offset = 0;
diff --git a/epan/dissectors/packet-sip.c b/epan/dissectors/packet-sip.c
index b3a10b4754..9daf0dde61 100644
--- a/epan/dissectors/packet-sip.c
+++ b/epan/dissectors/packet-sip.c
@@ -2516,7 +2516,7 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info
line_type_t line_type;
tvbuff_t *next_tvb;
gboolean is_known_request;
- gboolean found_match = FALSE;
+ int found_match = 0;
const char *descr;
guint token_1_len = 0;
guint current_method_idx = SIP_METHOD_INVALID;
@@ -3808,8 +3808,7 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info
next_tvb, pinfo,
message_body_tree, content_type_parameter_str);
DENDENT();
- DPRINT(("done calling dissector_try_string() with found_match=%s",
- found_match?"TRUE":"FALSE"));
+ DPRINT(("done calling dissector_try_string() with found_match=%u", found_match));
if (!found_match &&
!strncmp(media_type_str_lower_case, "multipart/", sizeof("multipart/")-1)) {
@@ -3821,15 +3820,13 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info
next_tvb, pinfo,
message_body_tree, content_type_parameter_str);
DENDENT();
- DPRINT(("done calling dissector_try_string() with found_match=%s",
- found_match?"TRUE":"FALSE"));
+ DPRINT(("done calling dissector_try_string() with found_match=%u", found_match));
}
/* If no match dump as text */
}
- if ( found_match != TRUE )
+ if ( found_match == 0 )
{
- DPRINT(("calling dissector_try_heuristic() with found_match=%s",
- found_match?"TRUE":"FALSE"));
+ DPRINT(("calling dissector_try_heuristic() with found_match=0"));
DINDENT();
if (!(dissector_try_heuristic(heur_subdissector_list,
next_tvb, pinfo, message_body_tree, &hdtbl_entry, NULL))) {
diff --git a/epan/dissectors/packet-usb.c b/epan/dissectors/packet-usb.c
index 9a278295c0..33b19cfc2d 100644
--- a/epan/dissectors/packet-usb.c
+++ b/epan/dissectors/packet-usb.c
@@ -2639,7 +2639,7 @@ static gint
try_dissect_next_protocol(proto_tree *tree, tvbuff_t *next_tvb, packet_info *pinfo,
usb_conv_info_t *usb_conv_info, guint8 urb_type)
{
- gboolean ret;
+ int ret;
wmem_tree_key_t key[4];
guint32 k_frame_number;
guint32 k_device_address;
diff --git a/epan/dissectors/packet-wsp.c b/epan/dissectors/packet-wsp.c
index a8295a8658..e3e0d3d269 100644
--- a/epan/dissectors/packet-wsp.c
+++ b/epan/dissectors/packet-wsp.c
@@ -4770,7 +4770,7 @@ dissect_wsp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
guint contentType = 0;
const char *contentTypeStr;
tvbuff_t *tmp_tvb;
- gboolean found_match;
+ int found_match;
heur_dtbl_entry_t *hdtbl_entry;
/* Set up structures we will need to add the protocol subtree and manage it */
@@ -5001,7 +5001,7 @@ dissect_wsp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
* Try finding a dissector for the content
* first, then fallback.
*/
- found_match = FALSE;
+ found_match = 0;
if (contentTypeStr) {
/*
* Content type is a string.
@@ -5091,7 +5091,7 @@ dissect_wsp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
* Try finding a dissector for the content
* first, then fallback.
*/
- found_match = FALSE;
+ found_match = 0;
if (contentTypeStr) {
/*
* Content type is a string.
@@ -5167,7 +5167,7 @@ dissect_wsp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
* Try finding a dissector for the content
* first, then fallback.
*/
- found_match = FALSE;
+ found_match = 0;
if (contentTypeStr) {
/*
* Content type is a string.
@@ -5702,7 +5702,7 @@ add_multipart_data (proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo)
tvbuff_t *tmp_tvb;
int partnr = 1;
int part_start;
- gboolean found_match = FALSE;
+ int found_match = 0;
proto_item *sub_tree = NULL;
proto_item *ti = NULL;
@@ -5766,7 +5766,7 @@ add_multipart_data (proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo)
* Try finding a dissector for the content
* first, then fallback.
*/
- found_match = FALSE;
+ found_match = 0;
if (contentTypeStr) {
/*
* Content type is a string.
diff --git a/epan/packet.h b/epan/packet.h
index 637d359cfa..88783fe735 100644
--- a/epan/packet.h
+++ b/epan/packet.h
@@ -243,14 +243,14 @@ WS_DLL_PUBLIC void dissector_change_uint(const char *abbrev, const guint32 patte
WS_DLL_PUBLIC void dissector_reset_uint(const char *name, const guint32 pattern);
/* Look for a given value in a given uint dissector table and, if found,
- call the dissector with the arguments supplied, and return TRUE,
- otherwise return FALSE. */
+ call the dissector with the arguments supplied, and return the number
+ of bytes consumed, otherwise return 0. */
WS_DLL_PUBLIC int dissector_try_uint(dissector_table_t sub_dissectors,
const guint32 uint_val, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
/* Look for a given value in a given uint dissector table and, if found,
- call the dissector with the arguments supplied, and return TRUE,
- otherwise return FALSE. */
+ call the dissector with the arguments supplied, and return the number
+ of bytes consumed, otherwise return 0. */
WS_DLL_PUBLIC int dissector_try_uint_new(dissector_table_t sub_dissectors,
const guint32 uint_val, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const gboolean add_proto_name, void *data);
@@ -292,8 +292,8 @@ WS_DLL_PUBLIC void dissector_change_string(const char *name, const gchar *patter
WS_DLL_PUBLIC void dissector_reset_string(const char *name, const gchar *pattern);
/* Look for a given string in a given dissector table and, if found, call
- the dissector with the arguments supplied, and return TRUE, otherwise
- return FALSE. */
+ the dissector with the arguments supplied, and return the number of
+ bytes consumed, otherwise return 0. */
WS_DLL_PUBLIC int dissector_try_string(dissector_table_t sub_dissectors,
const gchar *string, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data);