From d2456988df66b00bd81da9c08b20d932c586a38f Mon Sep 17 00:00:00 2001 From: Roland Knall Date: Tue, 5 Jul 2016 16:01:10 +0200 Subject: openSAFETY: Add byte offset of frame Add the absolute byte offset of each openSAFETY frame to dissection, so a change in the offset can be easily detected Change-Id: Ib935eff7ba1e2e1169cb9071a5c9703cc58fc123 Reviewed-on: https://code.wireshark.org/review/16301 Petri-Dish: Roland Knall Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall --- epan/dissectors/packet-opensafety.c | 8 ++++++++ epan/dissectors/packet-opensafety.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/epan/dissectors/packet-opensafety.c b/epan/dissectors/packet-opensafety.c index 0b8c9ee91c..eaaa84731b 100644 --- a/epan/dissectors/packet-opensafety.c +++ b/epan/dissectors/packet-opensafety.c @@ -140,6 +140,7 @@ static int hf_oss_msg_sender = -1; static int hf_oss_msg_receiver = -1; static int hf_oss_length= -1; static int hf_oss_crc = -1; +static int hf_oss_byte_offset = -1; static int hf_oss_crc_valid = -1; static int hf_oss_crc2_valid = -1; @@ -1788,6 +1789,9 @@ dissect_opensafety_message(opensafety_packet_info *packet, val_to_str(packet->msg_id, opensafety_message_type_values, "Unknown Message (0x%02X) ")); } + item = proto_tree_add_uint(opensafety_tree, hf_oss_byte_offset, packet->frame.frame_tvb, 0, 1, packet->frame.byte_offset); + PROTO_ITEM_SET_GENERATED(item); + if ( packet->msg_type == OPENSAFETY_SNMT_MESSAGE_TYPE ) { proto_item_append_text(opensafety_item, ", SNMT"); @@ -2181,6 +2185,7 @@ opensafety_package_dissector(const gchar *protocolName, const gchar *sub_diss_ha packet->msg_type = type; packet->frame.frame_tvb = next_tvb; + packet->frame.byte_offset = frameOffset + tvb_raw_offset(message_tvb); packet->frame.subframe1 = frameStart1; packet->frame.subframe2 = frameStart2; packet->frame.length = frameLength; @@ -2420,6 +2425,9 @@ proto_register_opensafety(void) { "SCM UDID Valid", "opensafety.scm_udid.valid", FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL } }, + { &hf_oss_byte_offset, + { "Byte Offset", "opensafety.msg.byte_offset", + FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } }, { &hf_oss_msg, { "Message", "opensafety.msg.id", FT_UINT8, BASE_HEX, VALS(opensafety_message_type_values), 0x0, NULL, HFILL } }, diff --git a/epan/dissectors/packet-opensafety.h b/epan/dissectors/packet-opensafety.h index 9ceacd0da1..419c4cf0be 100644 --- a/epan/dissectors/packet-opensafety.h +++ b/epan/dissectors/packet-opensafety.h @@ -449,6 +449,8 @@ typedef struct _opensafety_packet_frame guint length; + guint16 byte_offset; + tvbuff_t *frame_tvb; } opensafety_packet_frame; -- cgit v1.2.3