aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-cip.c
diff options
context:
space:
mode:
authorcbontje <cbontje@gmail.com>2015-08-07 11:18:00 -0600
committerAnders Broman <a.broman58@gmail.com>2015-11-06 07:52:09 +0000
commit35a13838146ac5d83b57435ff34f2960ea911248 (patch)
treeb78cc34febd561fabd5674fd9fb86c40517ce71c /epan/dissectors/packet-cip.c
parent018e93a384c5aca7471d7d9303af637e71320ea2 (diff)
downloadwireshark-35a13838146ac5d83b57435ff34f2960ea911248.tar.gz
wireshark-35a13838146ac5d83b57435ff34f2960ea911248.tar.bz2
wireshark-35a13838146ac5d83b57435ff34f2960ea911248.zip
Major Re-factoring of the dissector and some new features.
A change-list is as follows: - Removed un-necessary dissector revision updates from the file header since GIT tracks these nicely. - Added proper size detection of Modbus RTU messages (including exception responses), when dealing with partial TCP segment reassembly. - Moved the 'register' decode preferences to the Modbus dissector as TCP vs. RTU granularity isn't needed in this case. - Obsoleted un-unused 'address type format' user preferences - Cleaned up dissect_modbus_data to remove proto_tree_set_text instances. - For decoded register tree objects, use register 'address' instead of 'value' for the filter field to provide a more useful filter. - Added in conversation support, to attempt to track responses back to matching requests. - Use conversation support to attempt to populate proper register address offsets in the response messages. Currently each request is saved and each response looks for the last prior request that matches the function code. - Re-factored Modbus dissector to split apart request vs. response decoding. This has led to cleaner code paths, but some duplication where replies and requests are identical format. Change-Id: I0c86ae85b8ae4cc59b037e5f68f408833205fadd Reviewed-on: https://code.wireshark.org/review/9914 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-cip.c')
-rw-r--r--epan/dissectors/packet-cip.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/epan/dissectors/packet-cip.c b/epan/dissectors/packet-cip.c
index 038a2d532e..3fd2b9e14d 100644
--- a/epan/dissectors/packet-cip.c
+++ b/epan/dissectors/packet-cip.c
@@ -5500,7 +5500,6 @@ dissect_cip_mb_data( proto_tree *item_tree, tvbuff_t *tvb, int offset, int item_
tvbuff_t *next_tvb;
int req_path_size;
guint8 gen_status, add_stat_size, service;
- modbus_request_info_t* request_info;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "CIP MB");
@@ -5567,18 +5566,14 @@ dissect_cip_mb_data( proto_tree *item_tree, tvbuff_t *tvb, int offset, int item_
/* Passthrough response (Success) */
if( tvb_reported_length_remaining(tvb, offset) > 0 )
{
+ int packet_type = RESPONSE_PACKET;
+
/* dissect the Modbus PDU */
next_tvb = tvb_new_subset_length( tvb, offset+4+add_stat_size, item_length-4-add_stat_size);
- /* keep packet context */
- request_info = wmem_new(wmem_packet_scope(), modbus_request_info_t);
- request_info->packet_type = RESPONSE_PACKET;
- request_info->register_addr_type = MBTCP_PREF_REGISTER_ADDR_RAW;
- request_info->register_format = MBTCP_PREF_REGISTER_FORMAT_UINT16;
- p_add_proto_data(wmem_file_scope(), pinfo, proto_modbus, 0, request_info);
+ /* Call Modbus Dissector */
+ call_dissector_with_data(modbus_handle, next_tvb, pinfo, cmd_data_tree, &packet_type );
- call_dissector(modbus_handle, next_tvb, pinfo, cmd_data_tree);
- p_remove_proto_data(wmem_file_scope(), pinfo, proto_modbus, 0);
}
break;
@@ -5657,18 +5652,13 @@ dissect_cip_mb_data( proto_tree *item_tree, tvbuff_t *tvb, int offset, int item_
/* Passthrough Request */
if( tvb_reported_length_remaining(tvb, offset) > 0 )
{
+ int packet_type = QUERY_PACKET;
+
/* dissect the Modbus PDU */
next_tvb = tvb_new_subset_length( tvb, offset+2+req_path_size, item_length-req_path_size-2);
- /* keep packet context */
- request_info = wmem_new(wmem_packet_scope(), modbus_request_info_t);
- request_info->packet_type = QUERY_PACKET;
- request_info->register_addr_type = MBTCP_PREF_REGISTER_ADDR_RAW;
- request_info->register_format = MBTCP_PREF_REGISTER_FORMAT_UINT16;
- p_add_proto_data(wmem_file_scope(), pinfo, proto_modbus, 0, request_info);
-
- call_dissector(modbus_handle, next_tvb, pinfo, cmd_data_tree);
- p_remove_proto_data(wmem_file_scope(), pinfo, proto_modbus, 0);
+ /* Call Modbus Dissector */
+ call_dissector_with_data(modbus_handle, next_tvb, pinfo, cmd_data_tree, &packet_type);
}
break;