aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-mbtcp.c
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2008-09-30 21:23:19 +0000
committerJaap Keuter <jaap.keuter@xs4all.nl>2008-09-30 21:23:19 +0000
commit51a72a3478457aa8d7b96aa934caeeb518d9f5f8 (patch)
tree01b973e95b7fcb8c6db7a27815ee2931624308a3 /epan/dissectors/packet-mbtcp.c
parentd3ffd5cafdf21d2583fd09887e54e3e1493f8eb7 (diff)
Fix for bug 2917:
Modbus Application Protocol Specification V1.1b includes a function 43 (0x2b) Encapsulated Interface Transport. When Wireshark encounters this message it is shown as a TCP message, not a Modbus message. svn path=/trunk/; revision=26314
Diffstat (limited to 'epan/dissectors/packet-mbtcp.c')
-rw-r--r--epan/dissectors/packet-mbtcp.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/epan/dissectors/packet-mbtcp.c b/epan/dissectors/packet-mbtcp.c
index 1ffd01f7ac..64d66d21a7 100644
--- a/epan/dissectors/packet-mbtcp.c
+++ b/epan/dissectors/packet-mbtcp.c
@@ -73,6 +73,7 @@
#define READ_WRITE_REG 23
#define READ_FIFO_QUEUE 24
#define PROGRAM_CONCEPT 40
+#define ENCAP_INTERFACE_TRANSP 43
#define FIRMWARE_REPLACE 125
#define PROGRAM_584_984_2 126
#define REPORT_LOCAL_ADDR_MB 127
@@ -141,14 +142,11 @@ classify_packet(packet_info *pinfo)
{
/* see if nature of packets can be derived from src/dst ports */
/* if so, return as found */
- if ( ( 502 == pinfo->srcport && 502 != pinfo->destport ) ||
- ( 502 != pinfo->srcport && 502 == pinfo->destport ) ) {
- /* the slave is receiving queries on port 502 */
- if ( 502 == pinfo->srcport )
- return RESPONSE_PACKET;
- else if ( 502 == pinfo->destport )
- return QUERY_PACKET;
- }
+ if (( pinfo->srcport == TCP_PORT_MBTCP ) && ( pinfo->destport != TCP_PORT_MBTCP ))
+ return RESPONSE_PACKET;
+ if (( pinfo->srcport != TCP_PORT_MBTCP ) && ( pinfo->destport == TCP_PORT_MBTCP ))
+ return QUERY_PACKET;
+
/* else, cannot classify */
return CANNOT_CLASSIFY;
}
@@ -181,6 +179,7 @@ static const value_string function_code_vals[] = {
{ READ_WRITE_REG, "Read Write Register" },
{ READ_FIFO_QUEUE, "Read FIFO Queue" },
{ PROGRAM_CONCEPT, "Program (ConCept)" },
+ { ENCAP_INTERFACE_TRANSP, "Encapsulated Interface Transport" },
{ FIRMWARE_REPLACE, "Firmware replacement" },
{ PROGRAM_584_984_2, "Program (584/984)" },
{ REPORT_LOCAL_ADDR_MB, "Report local address (Modbus)" },
@@ -242,12 +241,8 @@ dissect_mbtcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* Note that function code is only 7 bits.
*/
fc=mh.mdbs_hdr.function_code&0x7f;
- if( (fc<1)
- ||(fc>127)
- ||((fc>24)&&(fc<40))
- ||((fc>40)&&(fc<125)) ){
+ if(!match_strval(fc, function_code_vals))
return 0;
- }
/* Make entries in Protocol column on summary display */
@@ -319,7 +314,7 @@ dissect_mbtcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* Add items to protocol tree specific to Modbus generic */
- mf = proto_tree_add_text(mbtcp_tree, tvb, offset + 6, mh.len,
+ mf = proto_tree_add_text(mbtcp_tree, tvb, offset + 7, mh.len - 1,
"Modbus");
modbus_tree = proto_item_add_subtree(mf, ett_modbus_hdr);
mi = proto_tree_add_uint(modbus_tree, hf_mbtcp_functioncode, tvb, offset + 7, 1,