aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/epan
diff options
context:
space:
mode:
authornakarlsson <se.nakarlsson@gmail.com>2018-11-28 12:51:56 +0100
committerAnders Broman <a.broman58@gmail.com>2018-11-30 11:25:59 +0000
commit26fe83e1db8b35ad07370ef2307324cc273a4f1d (patch)
tree61a0867d53010572b998a69337d06707dd68aae5 /plugins/epan
parentdd457b08783e89e36e6e9e886438b7d7602c66fb (diff)
PROFINET: fix dissection of IO conversasion direction
Bug: 15313 Change-Id: I5255f8b03f9d86cd7da8be34a71f0a3932bfca5c Reviewed-on: https://code.wireshark.org/review/30821 Petri-Dish: Anders Broman <a.broman58@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'plugins/epan')
-rw-r--r--plugins/epan/profinet/packet-dcerpc-pn-io.c28
-rw-r--r--plugins/epan/profinet/packet-pn-dcp.c27
2 files changed, 44 insertions, 11 deletions
diff --git a/plugins/epan/profinet/packet-dcerpc-pn-io.c b/plugins/epan/profinet/packet-dcerpc-pn-io.c
index e20c84a321..e2f34b7822 100644
--- a/plugins/epan/profinet/packet-dcerpc-pn-io.c
+++ b/plugins/epan/profinet/packet-dcerpc-pn-io.c
@@ -7653,10 +7653,10 @@ dissect_ARBlockReq_block(tvbuff_t *tvb, int offset,
/* Get current conversation endpoints using MAC addresses */
conversation = find_conversation(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_UDP, 0, 0, 0);
if (conversation == NULL) {
- /* If conversation is null, then create new conversation */
- /* Connect Request is sent by controller and not by device. */
- /* All conversations are based on Controller MAC as address */
- conversation = conversation_new(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_UDP, 0, 0, 0);
+ /* Create new conversation, if no "Ident OK" frame as been dissected yet!
+ * Need to switch dl_src & dl_dst, as current packet is sent by controller and not by device.
+ * All conversations are based on Device MAC as addr1 */
+ conversation = conversation_new(pinfo->num, &pinfo->dl_dst, &pinfo->dl_src, ENDPOINT_NONE, 0, 0, 0);
}
/* Try to get apdu status switch information from the conversation */
@@ -8672,7 +8672,10 @@ dissect_DataDescription(tvbuff_t *tvb, int offset,
/* Get current conversation endpoints using MAC addresses */
conversation = find_conversation(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
if (conversation == NULL) {
- conversation = conversation_new(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
+ /* Create new conversation, if no "Ident OK" frame as been dissected yet!
+ * Need to switch dl_src & dl_dst, as current packet is sent by controller and not by device.
+ * All conversations are based on Device MAC as addr1 */
+ conversation = conversation_new(pinfo->num, &pinfo->dl_dst, &pinfo->dl_src, ENDPOINT_NONE, 0, 0, 0);
}
station_info = (stationInfo*)conversation_get_proto_data(conversation, proto_pn_dcp);
@@ -8804,7 +8807,10 @@ dissect_ExpectedSubmoduleBlockReq_block(tvbuff_t *tvb, int offset,
/* Get current conversation endpoints using MAC addresses */
conversation = find_conversation(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
if (conversation == NULL) {
- conversation = conversation_new(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
+ /* Create new conversation, if no "Ident OK" frame as been dissected yet!
+ * Need to switch dl_src & dl_dst, as current packet is sent by controller and not by device.
+ * All conversations are based on Device MAC as addr1 */
+ conversation = conversation_new(pinfo->num, &pinfo->dl_dst, &pinfo->dl_src, ENDPOINT_NONE, 0, 0, 0);
}
station_info = (stationInfo*)conversation_get_proto_data(conversation, proto_pn_dcp);
@@ -10656,7 +10662,10 @@ dissect_ProfiSafeParameterRequest(tvbuff_t *tvb, int offset,
/* Get current conversation endpoints using MAC addresses */
conversation = find_conversation(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
if (conversation == NULL) {
- conversation = conversation_new(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
+ /* Create new conversation, if no "Ident OK" frame as been dissected yet!
+ * Need to switch dl_src & dl_dst, as current packet is sent by controller and not by device.
+ * All conversations are based on Device MAC as addr1 */
+ conversation = conversation_new(pinfo->num, &pinfo->dl_dst, &pinfo->dl_src, ENDPOINT_NONE, 0, 0, 0);
}
station_info = (stationInfo*)conversation_get_proto_data(conversation, proto_pn_dcp);
@@ -10721,7 +10730,10 @@ dissect_RecordDataWrite(tvbuff_t *tvb, int offset,
/* Get current conversation endpoints using MAC addresses */
conversation = find_conversation(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
if (conversation == NULL) {
- conversation = conversation_new(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
+ /* Create new conversation, if no "Ident OK" frame as been dissected yet!
+ * Need to switch dl_src & dl_dst, as current packet is sent by controller and not by device.
+ * All conversations are based on Device MAC as addr1 */
+ conversation = conversation_new(pinfo->num, &pinfo->dl_dst, &pinfo->dl_src, ENDPOINT_NONE, 0, 0, 0);
}
station_info = (stationInfo*)conversation_get_proto_data(conversation, proto_pn_dcp);
diff --git a/plugins/epan/profinet/packet-pn-dcp.c b/plugins/epan/profinet/packet-pn-dcp.c
index f440cc1bc4..4a4145734c 100644
--- a/plugins/epan/profinet/packet-pn-dcp.c
+++ b/plugins/epan/profinet/packet-pn-dcp.c
@@ -544,7 +544,14 @@ dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo,
/* Create a conversation between the MAC addresses */
conversation = find_conversation(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
if (conversation == NULL) {
- conversation = conversation_new(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
+ /* Create new conversation, need to switch dl_src & dl_dst if not a response
+ * All conversations are based on Device MAC as addr1 */
+ if (is_response) {
+ conversation = conversation_new(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
+ }
+ else {
+ conversation = conversation_new(pinfo->num, &pinfo->dl_dst, &pinfo->dl_src, ENDPOINT_NONE, 0, 0, 0);
+ }
}
station_info = (stationInfo*)conversation_get_proto_data(conversation, proto_pn_dcp);
@@ -582,7 +589,14 @@ dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo,
/* Create a conversation between the MAC addresses */
conversation = find_conversation(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
if (conversation == NULL) {
- conversation = conversation_new(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
+ /* Create new conversation, need to switch dl_src & dl_dst if not a response
+ * All conversations are based on Device MAC as addr1 */
+ if (is_response) {
+ conversation = conversation_new(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
+ }
+ else {
+ conversation = conversation_new(pinfo->num, &pinfo->dl_dst, &pinfo->dl_src, ENDPOINT_NONE, 0, 0, 0);
+ }
}
station_info = (stationInfo*)conversation_get_proto_data(conversation, proto_pn_dcp);
@@ -606,7 +620,14 @@ dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo,
/* Create a conversation between the MAC addresses */
conversation = find_conversation(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
if (conversation == NULL) {
- conversation = conversation_new(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
+ /* Create new conversation, need to switch dl_src & dl_dst if not a response
+ * All conversations are based on Device MAC as addr1 */
+ if (is_response) {
+ conversation = conversation_new(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
+ }
+ else {
+ conversation = conversation_new(pinfo->num, &pinfo->dl_dst, &pinfo->dl_src, ENDPOINT_NONE, 0, 0, 0);
+ }
}
station_info = (stationInfo*)conversation_get_proto_data(conversation, proto_pn_dcp);