diff options
author | Martin Kaiser <wireshark@kaiser.cx> | 2015-01-10 18:33:32 +0100 |
---|---|---|
committer | Martin Kaiser <wireshark@kaiser.cx> | 2015-01-17 18:41:50 +0000 |
commit | 21e40ea068b399f42192a9448c1a7530ff108d12 (patch) | |
tree | d087f55ef42e3ce1362cfd691f28a6a522c5f4cd /epan/dissectors/packet-zvt.c | |
parent | a38b7149084b1f07a769fe1d49f4fb25089c9b6b (diff) |
dissect the serial characters and the CRC
Change-Id: I64af822f30b02d313f5242014ff5e40a73dffa35
Reviewed-on: https://code.wireshark.org/review/6587
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Diffstat (limited to 'epan/dissectors/packet-zvt.c')
-rw-r--r-- | epan/dissectors/packet-zvt.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/epan/dissectors/packet-zvt.c b/epan/dissectors/packet-zvt.c index 09a3b531d7..205862d4a5 100644 --- a/epan/dissectors/packet-zvt.c +++ b/epan/dissectors/packet-zvt.c @@ -48,10 +48,11 @@ #include <epan/addr_resolv.h> /* special characters of the serial transport protocol */ +#define STX 0x02 +#define ETX 0x03 #define ACK 0x06 +#define DLE 0x10 #define NAK 0x15 -#define DLE 0x10 /* data line escape */ -#define STX 0x02 /* start of text */ /* an APDU needs at least a 2-byte control-field and one byte length */ #define ZVT_APDU_MIN_LEN 3 @@ -68,9 +69,21 @@ static int proto_zvt = -1; static int ett_zvt = -1; static int ett_zvt_apdu = -1; +static int hf_zvt_serial_char = -1; +static int hf_zvt_crc = -1; static int hf_zvt_ctrl = -1; static int hf_zvt_len = -1; +static const value_string serial_char[] = { + { STX, "Start of text (STX)" }, + { ETX, "End of text (ETX)" }, + { ACK, "Acknowledged (ACK)" }, + { DLE, "Data line escape (DLE)" }, + { NAK, "Not acknowledged (NAK)" }, + { 0, NULL } +}; +static value_string_ext serial_char_ext = VALUE_STRING_EXT_INIT(serial_char); + static const value_string ctrl_field[] = { { 0x040F, "Status Information" }, { 0x04FF, "Intermediate Status Information" }, @@ -148,11 +161,17 @@ dissect_zvt_serial(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, proto_tre offset_start = offset; if (tvb_reported_length_remaining(tvb, offset) == 1) { + proto_tree_add_item(tree, hf_zvt_serial_char, + tvb, offset, 1, ENC_BIG_ENDIAN); offset++; /* ACK or NAK byte */ return offset - offset_start; } + proto_tree_add_item(tree, hf_zvt_serial_char, + tvb, offset, 1, ENC_BIG_ENDIAN); offset ++; /* DLE byte */ + proto_tree_add_item(tree, hf_zvt_serial_char, + tvb, offset, 1, ENC_BIG_ENDIAN); offset ++; /* STX byte */ apdu_len = dissect_zvt_apdu(tvb, offset, pinfo, tree); @@ -161,8 +180,16 @@ dissect_zvt_serial(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, proto_tre offset += apdu_len; + proto_tree_add_item(tree, hf_zvt_serial_char, + tvb, offset, 1, ENC_BIG_ENDIAN); offset ++; /* DLE byte */ + proto_tree_add_item(tree, hf_zvt_serial_char, + tvb, offset, 1, ENC_BIG_ENDIAN); offset ++; /* ETX byte */ + + /* the CRC is little endian, the other fields are big endian */ + proto_tree_add_item(tree, hf_zvt_crc, + tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; /* CRC bytes */ return offset - offset_start; @@ -288,6 +315,12 @@ void proto_register_zvt(void) { static hf_register_info hf[] = { + { &hf_zvt_serial_char, + { "Serial character", "zvt.serial_char", FT_UINT8, + BASE_HEX|BASE_EXT_STRING, &serial_char_ext, 0, NULL, HFILL } }, + { &hf_zvt_crc, + { "CRC", "zvt.crc", FT_UINT16, + BASE_HEX, NULL, 0, NULL, HFILL } }, { &hf_zvt_ctrl, { "Control-field", "zvt.control_field", FT_UINT16, BASE_HEX|BASE_EXT_STRING, &ctrl_field_ext, 0, NULL, HFILL } }, |