aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorStephen Fisher <steve@stephen-fisher.com>2007-12-11 04:33:08 +0000
committerStephen Fisher <steve@stephen-fisher.com>2007-12-11 04:33:08 +0000
commit1479f03673cdeadf15c55e0eac67798f2d583d66 (patch)
tree3c212c7ca306f4567a5cd81c051f529675a3f988 /epan
parent36c9b397d7e71b393a9e39429c7c67bb21eb41f9 (diff)
Make the EtherNet/IP (Industrial Protocol) I/O dissection a new type
of dissector that rejects packets it doesn't recognize (on udp port 2222). svn path=/trunk/; revision=23836
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-enip.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/epan/dissectors/packet-enip.c b/epan/dissectors/packet-enip.c
index 5a29f02709..193c338b4d 100644
--- a/epan/dissectors/packet-enip.c
+++ b/epan/dissectors/packet-enip.c
@@ -753,15 +753,24 @@ dissect_enip_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
/* Code to actually dissect the io packets*/
-static void
+static int
dissect_enipio(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
/* Set up structures needed to add the protocol subtree and manage it */
proto_item *ti;
proto_tree *enip_tree;
+ guint16 type_id;
g_tree = tree;
+ /* Verify that the packet belongs to this dissector */
+ if (tvb_length(tvb) < 4)
+ return 0;
+
+ type_id = tvb_get_letohs( tvb, 2 );
+ if (match_strval(type_id, cdf_type_vals) == NULL)
+ return 0; /* not a known type id */
+
/* Make entries in Protocol column and Info column on summary display */
if (check_col(pinfo->cinfo, COL_PROTOCOL))
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ENIP");
@@ -778,6 +787,7 @@ dissect_enipio(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
dissect_cpf( 0xFFFF, tvb, pinfo, enip_tree, 0, 0 );
}
+ return tvb_length(tvb);
} /* end of dissect_enipio() */
@@ -968,7 +978,7 @@ proto_reg_handoff_enip(void)
dissector_add("udp.port", ENIP_ENCAP_PORT, enip_udp_handle);
/* Register for EtherNet/IP IO data (UDP) */
- enipio_handle = create_dissector_handle(dissect_enipio, proto_enip);
+ enipio_handle = new_create_dissector_handle(dissect_enipio, proto_enip);
dissector_add("udp.port", ENIP_IO_PORT, enipio_handle);
/* Find dissector for data packet */