diff options
author | Guy Harris <guy@alum.mit.edu> | 2000-11-10 06:50:37 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2000-11-10 06:50:37 +0000 |
commit | 07eb30403dae13dde668ff3b06d7d6c9bf677de9 (patch) | |
tree | 7a4c3b5a8262e5ec32132dd69225fd74d1a5fd16 /packet-sdp.c | |
parent | 9eb37f04e72d4d5a6f50e04e808757a648314fac (diff) | |
download | wireshark-07eb30403dae13dde668ff3b06d7d6c9bf677de9.tar.gz wireshark-07eb30403dae13dde668ff3b06d7d6c9bf677de9.tar.bz2 wireshark-07eb30403dae13dde668ff3b06d7d6c9bf677de9.zip |
Tvbuffify the SAP and SDP dissectors.
Add "tvb_find_line_end_unquoted()" for the benefit of the SDP dissector;
get rid of "find_line_end_unquoted()" as nobody uses it any more.
Add "tvb_pbrk_guint8()" for the benefit of
"tvb_find_line_end_unquoted()"; it searches for any of a number of
characters, unlike "tvb_find_guint8()" which searches for only one.
svn path=/trunk/; revision=2595
Diffstat (limited to 'packet-sdp.c')
-rw-r--r-- | packet-sdp.c | 67 |
1 files changed, 38 insertions, 29 deletions
diff --git a/packet-sdp.c b/packet-sdp.c index c673b3db9a..1398affef6 100644 --- a/packet-sdp.c +++ b/packet-sdp.c @@ -4,7 +4,7 @@ * Jason Lango <jal@netapp.com> * Liberally copied from packet-http.c, by Guy Harris <guy@alum.mit.edu> * - * $Id: packet-sdp.c,v 1.11 2000/11/09 02:42:31 guy Exp $ + * $Id: packet-sdp.c,v 1.12 2000/11/10 06:50:36 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -45,47 +45,51 @@ static int proto_sdp = -1; static int ett_sdp = -1; -void dissect_sdp(const u_char *pd, int offset, frame_data *fd, - proto_tree *tree) +void +dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_tree *sdp_tree; proto_item *ti; - const u_char *data, *dataend; - const u_char *lineend, *eol; + gint offset = 0; + const u_char *line; + gint next_offset; int linelen; u_char section; u_char type; const u_char *value; int valuelen; const char *typename; + int datalen; - OLD_CHECK_DISPLAY_AS_DATA(proto_sdp, pd, offset, fd, tree); + CHECK_DISPLAY_AS_DATA(proto_sdp, tvb, pinfo, tree); - data = &pd[offset]; - dataend = data + END_OF_FRAME; + pinfo->current_proto = "SDP"; - if (check_col(fd, COL_PROTOCOL)) - col_add_str(fd, COL_PROTOCOL, "SDP"); + if (check_col(pinfo->fd, COL_PROTOCOL)) + col_add_str(pinfo->fd, COL_PROTOCOL, "SDP"); - if (check_col(fd, COL_INFO)) { + if (check_col(pinfo->fd, COL_INFO)) { /* XXX: Needs description. */ - col_add_str(fd, COL_INFO, "Session Description"); + col_add_str(pinfo->fd, COL_INFO, "Session Description"); } if (!tree) return; - ti = proto_tree_add_item(tree, proto_sdp, NullTVB, offset, - END_OF_FRAME, FALSE); + ti = proto_tree_add_item(tree, proto_sdp, tvb, offset, + tvb_length_remaining(tvb, offset), FALSE); sdp_tree = proto_item_add_subtree(ti, ett_sdp); + /* + * Show the SDP message a line at a time. + */ section = 0; - for (; data < dataend; offset += linelen, data = lineend) { + while (tvb_length_remaining(tvb, offset)) { /* * Find the end of the line. */ - lineend = find_line_end_unquoted(data, dataend, &eol); - linelen = lineend - data; + linelen = tvb_find_line_end_unquoted(tvb, offset, -1, + &next_offset); /* * Line must contain at least e.g. "v=". @@ -93,14 +97,16 @@ void dissect_sdp(const u_char *pd, int offset, frame_data *fd, if (linelen < 2) break; - type = data[0]; - if (data[1] != '=') { - proto_tree_add_text(sdp_tree, NullTVB, offset, linelen, - "Invalid line: %s", - format_text(data, linelen)); + line = tvb_get_ptr(tvb, offset, next_offset - offset); + type = line[0]; + if (line[1] != '=') { + proto_tree_add_text(sdp_tree, tvb, offset, + next_offset - offset, + "Invalid line: %s", + tvb_format_text(tvb, offset, next_offset - offset)); continue; } - value = data + 2; + value = line + 2; valuelen = linelen - 2; /* @@ -170,14 +176,17 @@ void dissect_sdp(const u_char *pd, int offset, frame_data *fd, break; } - proto_tree_add_text(sdp_tree, NullTVB, offset, linelen, - "%s (%c): %s", typename, type, - format_text(value, valuelen)); + proto_tree_add_text(sdp_tree, tvb, offset, + next_offset - offset, + "%s (%c): %s", typename, type, + format_text(value, valuelen)); + offset = next_offset; } - if (data < dataend) { - proto_tree_add_text(sdp_tree, NullTVB, offset, END_OF_FRAME, - "Data (%d bytes)", END_OF_FRAME); + datalen = tvb_length_remaining(tvb, offset); + if (datalen > 0) { + proto_tree_add_text(sdp_tree, tvb, offset, datalen, + "Data (%d bytes)", datalen); } } |