diff options
author | Michael Mann <mmann78@netscape.net> | 2015-08-17 20:34:47 -0400 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2015-08-18 12:50:29 +0000 |
commit | c05df9932caeb14dd32f5edce65cb9c348b5984c (patch) | |
tree | a40040496a3991311f33831c085ea327432b3359 /epan/dissectors/packet-dnp.c | |
parent | db5b786e55d25139b8806fcbc2852941a77118db (diff) |
Add udp_dissect_pdus.
It works similar to tcp_dissect_pdus, but only works on a single packet. Intended for protocols that go over TCP and UDP so that they can have a common dissection function.
Will of course, also work on UDP-only protocols with a fixed length header and size.
Used DNP3 as a guinea pig since "multiple PDU support" over UDP was just added.
Change-Id: Ib7af8eaf7102c96b4f8b5c1b891ae2d8f0886f9d
Reviewed-on: https://code.wireshark.org/review/10083
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-dnp.c')
-rw-r--r-- | epan/dissectors/packet-dnp.c | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/epan/dissectors/packet-dnp.c b/epan/dissectors/packet-dnp.c index 91411efeb2..ce0f7221e7 100644 --- a/epan/dissectors/packet-dnp.c +++ b/epan/dissectors/packet-dnp.c @@ -35,6 +35,7 @@ #include <epan/prefs.h> #include <epan/reassemble.h> #include "packet-tcp.h" +#include "packet-udp.h" #include <epan/expert.h> #include <epan/to_str.h> #include <epan/crc16-tvb.h> @@ -3521,35 +3522,29 @@ dissect_dnp3_tcp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void } static int -dissect_dnp3_udp_loop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data, gboolean use_heuristics) +dissect_dnp3_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { - guint offset; - tvbuff_t* next_tvb; - int bytes_dissected; - - offset = 0; - do { - next_tvb = tvb_new_subset_remaining(tvb, offset); - if (!check_dnp3_header(next_tvb, use_heuristics)) { - return offset; - } - bytes_dissected = dissect_dnp3_message(next_tvb, pinfo, tree, data); - offset += bytes_dissected; - } while ((bytes_dissected > 0) && (offset < tvb_reported_length(tvb))); + if (!check_dnp3_header(tvb, FALSE)) { + return 0; + } - return offset; -} + udp_dissect_pdus(tvb, pinfo, tree, DNP_HDR_LEN, + get_dnp3_message_len, dissect_dnp3_message, data); -static int -dissect_dnp3_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) -{ - return dissect_dnp3_udp_loop(tvb, pinfo, tree, data, FALSE); + return tvb_captured_length(tvb); } static gboolean dissect_dnp3_udp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { - return dissect_dnp3_udp_loop(tvb, pinfo, tree, data, TRUE) != 0; + if (!check_dnp3_header(tvb, FALSE)) { + return FALSE; + } + + udp_dissect_pdus(tvb, pinfo, tree, DNP_HDR_LEN, + get_dnp3_message_len, dissect_dnp3_message, data); + + return TRUE; } static void |