diff options
author | Enrico Jorns <ejo@pengutronix.de> | 2014-10-02 16:09:38 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2014-11-26 05:17:59 +0000 |
commit | 5464bc69ae714168e8db55a01618822eb3a90cb8 (patch) | |
tree | b561bca0e68a5a9caba8bb181124d5a3d4fc2257 /epan/dissectors/packet-canopen.c | |
parent | a559f2a050947f793c00159c0cd4d30f403f217c (diff) |
canopen: Improve NMT error control and SYNC message dissection
1. Also show Reserved/Toggle bit of NMT error control
In case of the node guarding protocol this bit is used as a toggle bit.
In case of the hearbeat protocol this bit is reserved.
Reference: CiA 301 (rev 4.2.0), Chap. 7.2.8.3.2
2. Show optional 'counter' parameter of SYNC messages if available
Reference: CiA 301 (rev 4.2.0), Chap. 7.2.5.3.1
Change-Id: I5dc0ab65e95fec4846a9c8bd8972ef2eba664ee2
Reviewed-on: https://code.wireshark.org/review/5484
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-canopen.c')
-rw-r--r-- | epan/dissectors/packet-canopen.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/epan/dissectors/packet-canopen.c b/epan/dissectors/packet-canopen.c index d8d7de3fba..548f5c1250 100644 --- a/epan/dissectors/packet-canopen.c +++ b/epan/dissectors/packet-canopen.c @@ -46,6 +46,8 @@ static int hf_canopen_em_err_field = -1; static int hf_canopen_nmt_ctrl_cs = -1; static int hf_canopen_nmt_ctrl_node_id = -1; static int hf_canopen_nmt_guard_state = -1; +static int hf_canopen_nmt_guard_toggle = -1; +static int hf_canopen_sync_counter = -1; static int hf_canopen_time_stamp = -1; static int hf_canopen_time_stamp_ms = -1; static int hf_canopen_time_stamp_days = -1; @@ -76,7 +78,7 @@ static gint ett_canopen_type = -1; static const value_string CAN_open_bcast_msg_type_vals[] = { { FC_NMT, "NMT"}, - { FC_SYNC, "Sync"}, + { FC_SYNC, "SYNC"}, { FC_TIME_STAMP, "TIME STAMP"}, { 0, NULL} }; @@ -270,10 +272,17 @@ dissect_canopen(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) case MT_NMT_ERR_CTRL: if (tvb_reported_length(tvb) > 0) { proto_tree_add_item(canopen_type_tree, + hf_canopen_nmt_guard_toggle, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(canopen_type_tree, hf_canopen_nmt_guard_state, tvb, offset, 1, ENC_LITTLE_ENDIAN); } break; case MT_SYNC: + /* Show optional counter parameter if present */ + if (tvb_reported_length(tvb) > 0) { + proto_tree_add_item(canopen_type_tree, + hf_canopen_sync_counter, tvb, offset, 1, ENC_LITTLE_ENDIAN); + } break; case MT_TIME_STAMP: /* calculate the real time stamp */ @@ -414,11 +423,22 @@ proto_register_canopen(void) FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } }, + { &hf_canopen_nmt_guard_toggle, + { "Reserved/Toggle", "canopen.nmt_guard.toggle", + FT_UINT8, BASE_DEC, NULL, 0x80, + NULL, HFILL } + }, { &hf_canopen_nmt_guard_state, { "State", "canopen.nmt_guard.state", FT_UINT8, BASE_HEX, VALS(nmt_guard_state), 0x7F, NULL, HFILL } }, + /* SYNC */ + { &hf_canopen_sync_counter, + { "Counter", "canopen.sync.counter", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL } + }, { &hf_canopen_time_stamp, { "Time stamp", "canopen.time_stamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x0, |