/* strutil.c
* String utility routines
*
- * $Id: strutil.c,v 1.4 2000/11/09 02:42:33 guy Exp $
+ * $Id: strutil.c,v 1.5 2000/11/10 06:50:37 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
return lineend;
}
-const u_char *
-find_line_end_unquoted(const u_char *data, const u_char *dataend,
- const u_char **eol)
-{
- const u_char *pp;
- gboolean is_quoted;
-
- pp = data;
- is_quoted = FALSE;
- *eol = NULL;
- for (pp = data, is_quoted = FALSE; pp < dataend; pp++) {
- if (*pp == '\n') {
- if (is_quoted) {
- /* Do nothing. Wait for next quote. */
- } else {
- *eol = (pp > data && *(pp - 1) == '\r')
- ? pp - 1
- : pp;
- pp++;
- break;
- }
- } else if (*pp == '"') {
- is_quoted = !is_quoted;
- }
- }
- if (!*eol)
- *eol = pp;
- return pp;
-}
-
/*
* Get the length of the next token in a line, and the beginning of the
* next token after that (if any).
/* strutil.h
* String utility definitions
*
- * $Id: strutil.h,v 1.3 2000/11/09 02:42:33 guy Exp $
+ * $Id: strutil.h,v 1.4 2000/11/10 06:50:37 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
const u_char *find_line_end(const u_char *data, const u_char *dataend,
const u_char **eol);
-const u_char *find_line_end_unquoted(const u_char *data, const u_char *dataend,
- const u_char **eol);
int get_token_len(const u_char *linep, const u_char *lineend,
const u_char **next_token);
gchar* format_text(const u_char *line, int len);
* the data of a backing tvbuff, or can be a composite of
* other tvbuffs.
*
- * $Id: tvbuff.c,v 1.3 2000/11/09 10:56:33 guy Exp $
+ * $Id: tvbuff.c,v 1.4 2000/11/10 06:50:37 guy Exp $
*
* Copyright (c) 2000 by Gilbert Ramirez <gram@xiexie.org>
*
return NULL;
}
+static const guint8*
+guint8_pbrk(const guint8* haystack, size_t haystacklen, guint8 *needles)
+{
+ const guint8 *b;
+ int i;
+ guint8 item, *needlep, needle;
+
+ for (b = haystack, i = 0; i < haystacklen; i++, b++) {
+ item = *b;
+ needlep = needles;
+ while ((needle = *needlep) != '\0') {
+ if (item == needle)
+ return b;
+ needlep++;
+ }
+ }
+
+ return NULL;
+}
+
/************** ACCESSORS **************/
return -1;
}
+/* Find first occurence of any of the needles in tvbuff, starting at offset.
+ * Searches at most maxlength number of bytes. Returns the offset of the
+ * found needle, or -1 if not found. Will not throw an exception, even if
+ * maxlength exceeds boundary of tvbuff; in that case, -1 will be returned if
+ * the boundary is reached before finding needle. */
+gint
+tvb_pbrk_guint8(tvbuff_t *tvb, gint offset, guint maxlength, guint8 *needles)
+{
+ guint abs_offset, junk_length;
+ const guint8 *result;
+ guint limit;
+
+ check_offset_length(tvb, offset, 0, &abs_offset, &junk_length);
+
+ /* Only search to end of tvbuff, w/o throwing exception. */
+ if (tvb_length_remaining(tvb, abs_offset) < maxlength) {
+ limit = maxlength - (tvb_length(tvb) - abs_offset);
+ }
+ else {
+ limit = maxlength;
+ }
+
+ /* If we have real data, perform our search now. */
+ if (tvb->real_data) {
+ result = guint8_pbrk(tvb->real_data + abs_offset, limit, needles);
+ if (result == NULL) {
+ return -1;
+ }
+ else {
+ return result - tvb->real_data;
+ }
+ }
+
+ switch(tvb->type) {
+ case TVBUFF_REAL_DATA:
+ g_assert_not_reached();
+
+ case TVBUFF_SUBSET:
+ return tvb_pbrk_guint8(tvb->tvbuffs.subset.tvb,
+ abs_offset - tvb->tvbuffs.subset.offset,
+ limit, needles);
+
+ case TVBUFF_COMPOSITE:
+ g_assert_not_reached();
+ /* XXX - return composite_pbrk_guint8(tvb, offset, limit, needle); */
+ }
+
+ g_assert_not_reached();
+ return -1;
+}
+
/* Find length of string by looking for end of string ('\0'), up to
* 'max_length' characters'. Returns -1 if 'max_length' reached
* before finding EOS. */
* terminator, or past the end of the buffer if we don't find a line
* terminator.
*/
-int
+gint
tvb_find_line_end(tvbuff_t *tvb, gint offset, int len, gint *next_offset)
{
gint eob_offset;
* No LF - line is presumably continued in next packet.
* We pretend the line runs to the end of the tvbuff.
*/
- *next_offset = eob_offset;
linelen = eob_offset - offset;
+ *next_offset = eob_offset;
} else {
/*
* Find the number of bytes between the starting offset
}
/*
- * Point to the character after the last character.
+ * Return the offset of the character after the last
+ * character in the line.
+ */
+ *next_offset = eol_offset + 1;
+ }
+ return linelen;
+}
+
+/*
+ * Given a tvbuff, an offset into the tvbuff, and a length that starts
+ * at that offset (which may be -1 for "all the way to the end of the
+ * tvbuff"), find the end of the (putative) line that starts at the
+ * specified offset in the tvbuff, going no further than the specified
+ * length.
+ *
+ * However, treat quoted strings inside the buffer specially - don't
+ * treat newlines in quoted strings as line terminators.
+ *
+ * Return the length of the line (not counting the line terminator at
+ * the end), or the amount of data remaining in the buffer if we don't
+ * find a line terminator.
+ *
+ * Set "*next_offset" to the offset of the character past the line
+ * terminator, or past the end of the buffer if we don't find a line
+ * terminator.
+ */
+gint
+tvb_find_line_end_unquoted(tvbuff_t *tvb, gint offset, int len,
+ gint *next_offset)
+{
+ gint cur_offset, char_offset;
+ gboolean is_quoted;
+ u_char c;
+ gint eob_offset;
+ int linelen;
+
+ if (len == -1)
+ len = tvb_length_remaining(tvb, offset);
+ /*
+ * XXX - what if "len" is still -1, meaning "offset is past the
+ * end of the tvbuff"?
+ */
+ eob_offset = offset + len;
+
+ cur_offset = offset;
+ is_quoted = FALSE;
+ for (;;) {
+ /*
+ * Is this part of the string quoted?
+ */
+ if (is_quoted) {
+ /*
+ * Yes - look only for the terminating quote.
+ */
+ char_offset = tvb_find_guint8(tvb, cur_offset, len,
+ '"');
+ } else {
+ /*
+ * Look either for an LF or a '"'.
+ */
+ char_offset = tvb_pbrk_guint8(tvb, cur_offset, len,
+ "\n\"");
+ }
+ if (cur_offset == -1) {
+ /*
+ * Not found - line is presumably continued in
+ * next packet.
+ * We pretend the line runs to the end of the tvbuff.
+ */
+ linelen = eob_offset - offset;
+ *next_offset = eob_offset;
+ break;
+ }
+
+ /*
+ * OK, which is it?
+ */
+ c = tvb_get_guint8(tvb, char_offset);
+ if (c == '\n') {
+ if (is_quoted) {
+ /*
+ * Quoted LF; it's part of the string, not
+ * a line terminator.
+ * Do nothing. Wait for next quote.
+ */
+ } else {
+ /*
+ * Un-quoted LF; it's a line terminator.
+ * Find the number of bytes between the
+ * starting offset and the LF.
+ */
+ linelen = char_offset - offset;
+
+ /*
+ * Is the LF at the beginning of the line?
+ */
+ if (linelen > 0) {
+ /*
+ * No - is it preceded by a carriage
+ * return?
+ * (Perhaps it's supposed to be, but
+ * that's not guaranteed....)
+ */
+ if (tvb_get_guint8(tvb, char_offset-1)
+ == '\r') {
+ /*
+ * Yes. The EOL starts with
+ * the CR; don't count it as
+ * part of the data in the
+ * line.
+ */
+ linelen--;
+ }
+ }
+
+ /*
+ * Return the offset of the character after
+ * the last character in the line, and
+ * quit.
+ */
+ *next_offset = char_offset + 1;
+ break;
+ }
+ } else if (c == '"') {
+ is_quoted = !is_quoted;
+ }
+
+ /*
+ * Step past the character we found.
*/
- eol_offset++;
- *next_offset = eol_offset;
+ cur_offset = char_offset + 1;
+ if (cur_offset >= eob_offset) {
+ /*
+ * The character we found was the last character
+ * in the tvbuff - line is presumably continued in
+ * next packet.
+ * We pretend the line runs to the end of the tvbuff.
+ */
+ linelen = eob_offset - offset;
+ *next_offset = eob_offset;
+ break;
+ }
}
return linelen;
}
* the data of a backing tvbuff, or can be a composite of
* other tvbuffs.
*
- * $Id: tvbuff.h,v 1.2 2000/11/09 10:56:33 guy Exp $
+ * $Id: tvbuff.h,v 1.3 2000/11/10 06:50:37 guy Exp $
*
* Copyright (c) 2000 by Gilbert Ramirez <gram@xiexie.org>
*
* reached before finding needle. */
gint tvb_find_guint8(tvbuff_t*, gint offset, guint maxlength, guint8 needle);
+/* Find first occurence of any of the needles in tvbuff, starting at offset.
+ * Searches at most maxlength number of bytes. Returns the offset of the
+ * found needle, or -1 if not found. Will not throw an exception, even if
+ * maxlength exceeds boundary of tvbuff; in that case, -1 will be returned if
+ * the boundary is reached before finding needle. */
+gint tvb_pbrk_guint8(tvbuff_t *, gint offset, guint maxlength, guint8 *needles);
+
/* Find length of string by looking for end of string ('\0'), up to
* 'max_length' characters'. Returns -1 if 'max_length' reached
* before finding EOS. */
*/
gint tvb_find_line_end(tvbuff_t *tvb, gint offset, int len, gint *eol);
+/*
+ * Given a tvbuff, an offset into the tvbuff, and a length that starts
+ * at that offset (which may be -1 for "all the way to the end of the
+ * tvbuff"), find the end of the (putative) line that starts at the
+ * specified offset in the tvbuff, going no further than the specified
+ * length.
+ *
+ * However, treat quoted strings inside the buffer specially - don't
+ * treat newlines in quoted strings as line terminators.
+ *
+ * Return the length of the line (not counting the line terminator at
+ * the end), or the amount of data remaining in the buffer if we don't
+ * find a line terminator.
+ *
+ * Set "*next_offset" to the offset of the character past the line
+ * terminator, or past the end of the buffer if we don't find a line
+ * terminator.
+ */
+gint tvb_find_line_end_unquoted(tvbuff_t *tvb, gint offset, int len,
+ gint *next_offset);
+
/* Call strncmp after checking if enough chars left, otherwise return -1 */
gint tvb_strneql(tvbuff_t *tvb, gint offset, guint8 *str, gint size);
* Jason Lango <jal@netapp.com>
* Liberally copied from packet-http.c, by Guy Harris <guy@alum.mit.edu>
*
- * $Id: packet-rtsp.c,v 1.22 2000/11/09 10:56:32 guy Exp $
+ * $Id: packet-rtsp.c,v 1.23 2000/11/10 06:50:36 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
datalen = tvb_length_remaining(tvb, offset);
if (is_sdp) {
if (datalen > 0) {
- tvbuff_t *new_tvb = tvb_new_subset(tvb, offset, -1, -1);
- const guint8 *pd;
+ tvbuff_t *new_tvb;
/*
* Fix up the top-level item so that it doesn't
proto_item_set_len(ti, offset);
/*
- * Now create a tvbuff for the SDP stuff, and dissect
- * it.
+ * Now creat a tvbuff for the SDP stuff and
+ * dissect it.
*/
- tvb_compat(new_tvb, &pd, &offset);
- dissect_sdp(pd, offset, pinfo->fd, tree);
+ new_tvb = tvb_new_subset(tvb, offset, -1, -1);
+ dissect_sdp(new_tvb, pinfo, tree);
}
if (check_col(pinfo->fd, COL_PROTOCOL))
col_add_str(pinfo->fd, COL_PROTOCOL, "RTSP/SDP");
*
* Heikki Vatiainen <hessu@cs.tut.fi>
*
- * $Id: packet-sap.c,v 1.12 2000/10/17 11:03:24 gram Exp $
+ * $Id: packet-sap.c,v 1.13 2000/11/10 06:50:36 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
static gint ett_sap_authf = -1;
static void
-dissect_sap(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
+dissect_sap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
+ int offset = 0;
int sap_version, is_ipv6, is_del, is_enc, is_comp, addr_len;
+ guint8 vers_flags;
guint8 auth_len;
guint16 tmp1;
+ guint8 *addr;
+ guint8 auth_flags;
proto_item *si, *sif;
proto_tree *sap_tree, *sap_flags_tree;
- OLD_CHECK_DISPLAY_AS_DATA(proto_sap, pd, offset, fd, tree);
+ CHECK_DISPLAY_AS_DATA(proto_sap, tvb, pinfo, tree);
- is_ipv6 = pd[offset]&MCAST_SAP_BIT_A;
- is_del = pd[offset]&MCAST_SAP_BIT_T;
- is_enc = pd[offset]&MCAST_SAP_BIT_E;
- is_comp = pd[offset]&MCAST_SAP_BIT_C;
+ vers_flags = tvb_get_guint8(tvb, offset);
+ is_ipv6 = vers_flags&MCAST_SAP_BIT_A;
+ is_del = vers_flags&MCAST_SAP_BIT_T;
+ is_enc = vers_flags&MCAST_SAP_BIT_E;
+ is_comp = vers_flags&MCAST_SAP_BIT_C;
- sap_version = (pd[offset]&MCAST_SAP_VERSION_MASK)>>MCAST_SAP_VERSION_SHIFT;
+ sap_version = (vers_flags&MCAST_SAP_VERSION_MASK)>>MCAST_SAP_VERSION_SHIFT;
addr_len = (is_ipv6) ? sizeof(struct e_in6_addr) : 4;
- if (check_col(fd, COL_PROTOCOL))
- col_add_str(fd, COL_PROTOCOL, "SAP");
+ pinfo->current_proto = "SAP";
+
+ if (check_col(pinfo->fd, COL_PROTOCOL))
+ col_add_str(pinfo->fd, COL_PROTOCOL, "SAP");
- if (check_col(fd, COL_INFO)) {
- col_add_fstr(fd, COL_INFO, "%s (v%u)",
+ if (check_col(pinfo->fd, COL_INFO)) {
+ col_add_fstr(pinfo->fd, COL_INFO, "%s (v%u)",
(is_del) ? "Deletion" : "Announcement", sap_version);
}
if (tree) {
- si = proto_tree_add_item(tree, proto_sap, NullTVB, offset, END_OF_FRAME, FALSE);
+ si = proto_tree_add_item(tree, proto_sap, tvb, offset, END_OF_FRAME, FALSE);
sap_tree = proto_item_add_subtree(si, ett_sap);
- sif = proto_tree_add_uint(sap_tree, hf_sap_flags, NullTVB, offset, 1, pd[offset]);
+ sif = proto_tree_add_uint(sap_tree, hf_sap_flags, tvb, offset, 1, vers_flags);
sap_flags_tree = proto_item_add_subtree(sif, ett_sap_flags);
- proto_tree_add_uint(sap_flags_tree, hf_sap_flags_v, NullTVB, offset, 1, pd[offset]);
- proto_tree_add_boolean(sap_flags_tree, hf_sap_flags_a, NullTVB, offset, 1, pd[offset]);
- proto_tree_add_boolean(sap_flags_tree, hf_sap_flags_r, NullTVB, offset, 1, pd[offset]);
- proto_tree_add_boolean(sap_flags_tree, hf_sap_flags_t, NullTVB, offset, 1, pd[offset]);
- proto_tree_add_boolean(sap_flags_tree, hf_sap_flags_e, NullTVB, offset, 1, pd[offset]);
- proto_tree_add_boolean(sap_flags_tree, hf_sap_flags_c, NullTVB, offset, 1, pd[offset]);
+ proto_tree_add_uint(sap_flags_tree, hf_sap_flags_v, tvb, offset, 1, vers_flags);
+ proto_tree_add_boolean(sap_flags_tree, hf_sap_flags_a, tvb, offset, 1, vers_flags);
+ proto_tree_add_boolean(sap_flags_tree, hf_sap_flags_r, tvb, offset, 1, vers_flags);
+ proto_tree_add_boolean(sap_flags_tree, hf_sap_flags_t, tvb, offset, 1, vers_flags);
+ proto_tree_add_boolean(sap_flags_tree, hf_sap_flags_e, tvb, offset, 1, vers_flags);
+ proto_tree_add_boolean(sap_flags_tree, hf_sap_flags_c, tvb, offset, 1, vers_flags);
offset++;
- proto_tree_add_text(sap_tree, NullTVB, offset, 1, "Authentication Length: %u", pd[offset]);
- auth_len = pd[offset];
+ auth_len = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(sap_tree, tvb, offset, 1, "Authentication Length: %u", auth_len);
offset++;
- tmp1 = pntohs(pd+offset);
- proto_tree_add_text(sap_tree, NullTVB, offset, 2, "Message Identifier Hash: 0x%x", tmp1);
+ tmp1 = tvb_get_ntohs(tvb, offset);
+ proto_tree_add_text(sap_tree, tvb, offset, 2, "Message Identifier Hash: 0x%x", tmp1);
offset +=2;
- proto_tree_add_text(sap_tree, NullTVB, offset, addr_len, "Originating Source: %s",
- (is_ipv6) ? ip6_to_str((struct e_in6_addr*)(pd+offset)) : ip_to_str(pd+offset));
+ addr = tvb_get_ptr(tvb, offset, addr_len);
+ proto_tree_add_text(sap_tree, tvb, offset, addr_len, "Originating Source: %s",
+ (is_ipv6) ? ip6_to_str((struct e_in6_addr*)addr) : ip_to_str(addr));
offset += addr_len;
/* Authentication data lives in its own subtree */
auth_data_len = auth_len * sizeof(guint32);
- sdi = proto_tree_add_item(sap_tree, hf_auth_data, NullTVB, offset, auth_data_len, FALSE);
+ sdi = proto_tree_add_item(sap_tree, hf_auth_data, tvb, offset, auth_data_len, FALSE);
sa_tree = proto_item_add_subtree(sdi, ett_sap_auth);
- sai = proto_tree_add_uint(sa_tree, hf_auth_flags, NullTVB, offset, 1, pd[offset]);
+ auth_flags = tvb_get_guint8(tvb, offset);
+ sai = proto_tree_add_uint(sa_tree, hf_auth_flags, tvb, offset, 1, auth_flags);
saf_tree = proto_item_add_subtree(sai, ett_sap_authf);
- proto_tree_add_uint(saf_tree, hf_auth_flags_v, NullTVB, offset, 1, pd[offset]);
- proto_tree_add_boolean(saf_tree, hf_auth_flags_p, NullTVB, offset, 1, pd[offset]);
- proto_tree_add_uint(saf_tree, hf_auth_flags_t, NullTVB, offset, 1, pd[offset]);
+ proto_tree_add_uint(saf_tree, hf_auth_flags_v, tvb, offset, 1, auth_flags);
+ proto_tree_add_boolean(saf_tree, hf_auth_flags_p, tvb, offset, 1, auth_flags);
+ proto_tree_add_uint(saf_tree, hf_auth_flags_t, tvb, offset, 1, auth_flags);
- has_pad = pd[offset]&MCAST_SAP_AUTH_BIT_P;
- if (has_pad) pad_len = *(pd+offset+auth_data_len-1);
+ has_pad = auth_flags&MCAST_SAP_AUTH_BIT_P;
+ if (has_pad)
+ pad_len = tvb_get_guint8(tvb, offset+auth_data_len-1);
- proto_tree_add_text(sa_tree, NullTVB, offset+1, auth_data_len-pad_len-1,
+ proto_tree_add_text(sa_tree, tvb, offset+1, auth_data_len-pad_len-1,
"Authentication subheader: (%u byte%s)",
auth_data_len-1, plurality(auth_data_len-1, "", "s"));
if (has_pad) {
- proto_tree_add_text(sa_tree, NullTVB, offset+auth_data_len-pad_len, pad_len,
+ proto_tree_add_text(sa_tree, tvb, offset+auth_data_len-pad_len, pad_len,
"Authentication data padding: (%u byte%s)",
pad_len, plurality(pad_len, "", "s"));
- proto_tree_add_text(sa_tree, NullTVB, offset+auth_data_len-1, 1,
+ proto_tree_add_text(sa_tree, tvb, offset+auth_data_len-1, 1,
"Authentication data pad count: %u byte%s",
pad_len, plurality(pad_len, "", "s"));
}
if (is_enc && is_comp) mangle = "compressed and encrypted";
else if (is_enc) mangle = "encrypted";
else mangle = "compressed";
- proto_tree_add_text(sap_tree, NullTVB, offset, END_OF_FRAME,
+ proto_tree_add_text(sap_tree, tvb, offset,
+ tvb_length_remaining(tvb, offset),
"The rest of the packet is %s", mangle);
return;
}
/* Do we have the optional payload type aka. MIME content specifier */
- if (strncasecmp(pd+offset, "v=", strlen("v="))) {
- guint32 pt_len = strlen(pd+offset); /* BUG: should use strnlen */
- proto_tree_add_text(sap_tree, NullTVB, offset, pt_len, "Payload type: %s", pd+offset);
+ if (!tvb_strneql(tvb, offset, "v=", strlen("v="))) {
+ gint remaining_len;
+ guint32 pt_len;
+ int pt_string_len;
+
+ remaining_len = tvb_length_remaining(tvb, offset);
+ if (remaining_len == 0) {
+ /*
+ * "tvb_strneql()" failed because there was no
+ * data left in the packet.
+ *
+ * Set the remaining length to 1, so that
+ * we throw the appropriate exception in
+ * "tvb_get_ptr()", rather than displaying
+ * the payload type.
+ */
+ remaining_len = 1;
+ }
+ pt_string_len = tvb_strnlen(tvb, offset, remaining_len);
+ if (pt_string_len == -1) {
+ /*
+ * We didn't find a terminating '\0'; run to the
+ * end of the buffer.
+ */
+ pt_string_len = remaining_len;
+ pt_len = pt_string_len;
+ } else {
+ /*
+ * Include the '\0' in the total item length.
+ */
+ pt_len = pt_string_len + 1;
+ }
+ proto_tree_add_text(sap_tree, tvb, offset, pt_len,
+ "Payload type: %.*s", pt_string_len,
+ tvb_get_ptr(tvb, offset, pt_string_len));
offset += pt_len;
- if (pd[offset] == '\0')
- offset++; /* Skip possible '\0' */
}
/* Done with SAP */
- dissect_sdp(pd, offset, fd, tree);
+ dissect_sdp(tvb, pinfo, tree);
}
return;
void
proto_reg_handoff_sap(void)
{
- old_dissector_add("udp.port", UDP_PORT_SAP, dissect_sap);
+ dissector_add("udp.port", UDP_PORT_SAP, dissect_sap);
}
* 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>
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=".
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;
/*
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);
}
}
/* packet-sdp.h
*
- * $Id: packet-sdp.h,v 1.2 2000/08/11 13:34:00 deniel Exp $
+ * $Id: packet-sdp.h,v 1.3 2000/11/10 06:50:36 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
#ifndef __PACKET_SDP_H__
#define __PACKET_SDP_H__
-void dissect_sdp(const u_char *, int, frame_data *, proto_tree *);
+void dissect_sdp(tvbuff_t *, packet_info *, proto_tree *);
#endif
*
* Copyright 2000, Heikki Vatiainen <hessu@cs.tut.fi>
*
- * $Id: packet-sip.c,v 1.1 2000/11/04 07:50:47 guy Exp $
+ * $Id: packet-sip.c,v 1.2 2000/11/10 06:50:36 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
guint32 offset;
gint eol, msg_offset;
tvbuff_t *next_tvb;
- const guint8 *next_pd;
- int next_offset;
CHECK_DISPLAY_AS_DATA(proto_sip, tvb, pinfo, tree);
if (tvb_length_remaining(tvb, offset) > 0) {
next_tvb = tvb_new_subset(tvb, offset, -1, -1);
- tvb_compat(next_tvb, &next_pd, &next_offset);
- dissect_sdp(next_pd, next_offset, pinfo->fd, tree);
+ dissect_sdp(next_tvb, pinfo, tree);
}
return;
* Routines for mgcp packet disassembly
* RFC 2705
*
- * $Id: packet-mgcp.c,v 1.2 2000/11/10 04:58:29 guy Exp $
+ * $Id: packet-mgcp.c,v 1.3 2000/11/10 06:50:37 guy Exp $
*
* Copyright (c) 2000 by Ed Warnicke <hagbard@physics.rutgers.edu>
*
gint sectionlen;
gint tvb_sectionend,tvb_sectionbegin, tvb_len, tvb_current_len;
tvbuff_t *next_tvb;
- const guint8 *next_pd;
- int next_offset;
CHECK_DISPLAY_AS_DATA(proto_mgcp, tvb, pinfo, tree);
tvb_current_len,'\n')) != -1){
tvb_sectionbegin++;
next_tvb = tvb_new_subset(tvb, tvb_sectionbegin, -1, -1);
- tvb_compat(next_tvb, &next_pd, &next_offset);
- dissect_sdp(next_pd, next_offset,pinfo->fd,tree);
+ dissect_sdp(next_tvb, pinfo, tree);
}
}
/*