diff options
author | Martin Mathieson <martin.r.mathieson@googlemail.com> | 2010-07-29 09:30:09 +0000 |
---|---|---|
committer | Martin Mathieson <martin.r.mathieson@googlemail.com> | 2010-07-29 09:30:09 +0000 |
commit | 4a4f1965e965cca7df3ab3b3cddb4b88b5b27aab (patch) | |
tree | fac66e8823a4d82181490931516aec7d1426bedb /epan/dissectors/packet-catapult-dct2000.c | |
parent | 92429e22b01dfddafee03cfd336d4de9364e516a (diff) |
Improve display of tty lines.
svn path=/trunk/; revision=33667
Diffstat (limited to 'epan/dissectors/packet-catapult-dct2000.c')
-rw-r--r-- | epan/dissectors/packet-catapult-dct2000.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/epan/dissectors/packet-catapult-dct2000.c b/epan/dissectors/packet-catapult-dct2000.c index 340a2d90c3..cd06455422 100644 --- a/epan/dissectors/packet-catapult-dct2000.c +++ b/epan/dissectors/packet-catapult-dct2000.c @@ -1515,7 +1515,7 @@ static void dissect_tty_lines(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre /* Create tty tree. */ ti = proto_tree_add_item(tree, hf_catapult_dct2000_tty, tvb, offset, -1, FALSE); - tty_tree = proto_item_add_subtree(ti, ett_catapult_dct2000); + tty_tree = proto_item_add_subtree(ti, ett_catapult_dct2000_tty); /* Show the tty lines one at a time. */ while (tvb_reported_length_remaining(tvb, offset) > 0) { @@ -1524,15 +1524,35 @@ static void dissect_tty_lines(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre /* Extract & add the string. */ char *string = (char*)tvb_get_ephemeral_string(tvb, offset, linelen); - proto_tree_add_string_format(tty_tree, hf_catapult_dct2000_tty_line, - tvb, offset, - linelen, string, - "%s", string); + if (isascii(string[0])) { + /* If looks printable treat as string... */ + proto_tree_add_string_format(tty_tree, hf_catapult_dct2000_tty_line, + tvb, offset, + linelen, string, + "%s", string); + } + else { + /* Otherwise show as $hex */ + int n, idx; + char *hex_string; + int tty_string_length = tvb_length_remaining(tvb, offset); + hex_string = ep_alloc(1+(2*tty_string_length)+1); + + idx = sprintf(hex_string, "$"); + + /* Write hex out to new string */ + for (n=0; n < tty_string_length; n++) { + idx += sprintf(hex_string+idx, "%02x", + tvb_get_guint8(tvb, offset+n)); + } + string = hex_string; + } lines++; /* Show first line in info column */ if (lines == 1) { col_append_fstr(pinfo->cinfo, COL_INFO, "tty (%s", string); + proto_item_append_text(ti, " (%s)", string); } /* Move onto next line. */ |