diff options
author | Guy Harris <guy@alum.mit.edu> | 2000-09-29 19:06:12 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2000-09-29 19:06:12 +0000 |
commit | 691b2f0244c33d6d9cdeb6945dcced0b4da9da37 (patch) | |
tree | f09139b2c7cbcb2b6bc7a0d39a1c089b10a517af /packet-telnet.c | |
parent | bdca198efb8207a95989db650580da26798dc4fa (diff) |
When displaying Telnet data, split it into lines (perhaps not ideal if
you're doing full-screen stuff or binary data, but splitting it based on
"\r" and/or "\n" probably necessarily make things worse, and it
definitely makes things better if you're doing line-at-a-time text).
svn path=/trunk/; revision=2467
Diffstat (limited to 'packet-telnet.c')
-rw-r--r-- | packet-telnet.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/packet-telnet.c b/packet-telnet.c index 8bc0cb801a..11e41912ff 100644 --- a/packet-telnet.c +++ b/packet-telnet.c @@ -2,7 +2,7 @@ * Routines for telnet packet dissection * Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com> * - * $Id: packet-telnet.c,v 1.16 2000/09/11 16:16:11 gram Exp $ + * $Id: packet-telnet.c,v 1.17 2000/09/29 19:06:12 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -294,6 +294,30 @@ telnet_command(proto_tree *telnet_tree, const u_char *pd, int start_offset) } static void +telnet_add_text(proto_tree *tree, tvbuff_t *tvb, const u_char *pd, + int offset, int len) +{ + const u_char *data, *dataend; + const u_char *lineend, *eol; + int linelen; + + data = &pd[offset]; + dataend = data + len; + while (data < dataend) { + /* + * Find the end of the line. + */ + lineend = find_line_end(data, dataend, &eol); + linelen = lineend - data; + + proto_tree_add_text(tree, NullTVB, offset, linelen, + "Data: %s", format_text(data, linelen)); + offset += linelen; + data = lineend; + } +} + +static void dissect_telnet(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { proto_tree *telnet_tree, *ti; @@ -324,11 +348,10 @@ dissect_telnet(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) /* * We found an IAC byte. * If there's any data before it, add that data to the - * tree. + * tree, a line at a time. */ if (data_len > 0) { - proto_tree_add_text(telnet_tree, NullTVB, data_offset, data_len, - "Data: %s", format_text(&pd[data_offset], data_len)); + telnet_add_text(telnet_tree, NullTVB, pd, data_offset, data_len); data_len = 0; data_offset = offset; } @@ -349,10 +372,8 @@ dissect_telnet(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) * We've reached the end of the buffer. * If there's any data left, add it to the tree. */ - if (data_len > 0) { - proto_tree_add_text(telnet_tree, NullTVB, data_offset, data_len, "Data: %s", - format_text(&pd[data_offset], data_len)); - } + if (data_len > 0) + telnet_add_text(telnet_tree, NullTVB, pd, data_offset, data_len); } } |