aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epan/tvbuff.c64
-rw-r--r--epan/tvbuff.h18
-rw-r--r--packet-cdp.c4
-rw-r--r--packet-dccp.c7
-rw-r--r--packet-ftp.c6
-rw-r--r--packet-http.c8
-rw-r--r--packet-icap.c8
-rw-r--r--packet-imap.c4
-rw-r--r--packet-irc.c4
-rw-r--r--packet-nntp.c8
-rw-r--r--packet-pop.c6
-rw-r--r--packet-rmi.c4
-rw-r--r--packet-rsh.c7
-rw-r--r--packet-rtsp.c8
-rw-r--r--packet-sip.c9
-rw-r--r--packet-smtp.c39
-rw-r--r--packet-telnet.c4
-rw-r--r--plugins/mgcp/packet-mgcp.c20
-rw-r--r--plugins/plugin_table.h4
19 files changed, 158 insertions, 74 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index a79eb2e30d..8fe482fab6 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -9,7 +9,7 @@
* the data of a backing tvbuff, or can be a composite of
* other tvbuffs.
*
- * $Id: tvbuff.c,v 1.37 2002/05/13 01:24:47 guy Exp $
+ * $Id: tvbuff.c,v 1.38 2002/07/17 06:55:24 guy Exp $
*
* Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu>
*
@@ -1763,15 +1763,20 @@ tvb_get_nstringz0(tvbuff_t *tvb, gint offset, guint maxlength, guint8* buffer)
* length.
*
* 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.
+ * the end), or, if we don't find a line terminator:
+ *
+ * if "deseg" is true, return -1;
+ *
+ * if "deseg" is false, return the amount of data remaining in
+ * the buffer.
*
* 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.
+ * terminator. (It's not set if we return -1.)
*/
gint
-tvb_find_line_end(tvbuff_t *tvb, gint offset, int len, gint *next_offset)
+tvb_find_line_end(tvbuff_t *tvb, gint offset, int len, gint *next_offset,
+ gboolean desegment)
{
gint eob_offset;
gint eol_offset;
@@ -1792,10 +1797,21 @@ tvb_find_line_end(tvbuff_t *tvb, gint offset, int len, gint *next_offset)
if (eol_offset == -1) {
/*
* No CR or LF - 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;
+ if (desegment) {
+ /*
+ * Tell our caller we saw no EOL, so they can
+ * try to desegment and get the entire line
+ * into one tvbuff.
+ */
+ return -1;
+ } else {
+ /*
+ * Pretend the line runs to the end of the tvbuff.
+ */
+ linelen = eob_offset - offset;
+ *next_offset = eob_offset;
+ }
} else {
/*
* Find the number of bytes between the starting offset
@@ -1810,12 +1826,36 @@ tvb_find_line_end(tvbuff_t *tvb, gint offset, int len, gint *next_offset)
/*
* Yes - is it followed by an LF?
*/
- if (eol_offset + 1 < eob_offset &&
- tvb_get_guint8(tvb, eol_offset + 1) == '\n') {
+ if (eol_offset + 1 >= eob_offset) {
/*
- * Yes; skip over the CR.
+ * Dunno - the next byte isn't in this
+ * tvbuff.
*/
- eol_offset++;
+ if (desegment) {
+ /*
+ * We'll return -1, although that
+ * runs the risk that if the line
+ * really *is* terminated with a CR,
+ * we won't properly dissect this
+ * tvbuff.
+ *
+ * It's probably more likely that
+ * the line ends with CR-LF than
+ * that it ends with CR by itself.
+ */
+ return -1;
+ }
+ } else {
+ /*
+ * Well, we can at least look at the next
+ * byte.
+ */
+ if (tvb_get_guint8(tvb, eol_offset + 1) == '\n') {
+ /*
+ * It's an LF; skip over the CR.
+ */
+ eol_offset++;
+ }
}
}
diff --git a/epan/tvbuff.h b/epan/tvbuff.h
index 4b96f2a519..e770ed98ad 100644
--- a/epan/tvbuff.h
+++ b/epan/tvbuff.h
@@ -9,7 +9,7 @@
* the data of a backing tvbuff, or can be a composite of
* other tvbuffs.
*
- * $Id: tvbuff.h,v 1.27 2002/05/13 01:24:47 guy Exp $
+ * $Id: tvbuff.h,v 1.28 2002/07/17 06:55:24 guy Exp $
*
* Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu>
*
@@ -341,10 +341,20 @@ extern gint tvb_get_nstringz0(tvbuff_t *tvb, gint offset, guint maxlength,
* specified offset in the tvbuff, going no further than the specified
* length.
*
- * Return the offset right past the end of the line as the return value,
- * and return the offset of the EOL character(s) in "*eol".
+ * Return the length of the line (not counting the line terminator at
+ * the end), or, if we don't find a line terminator:
+ *
+ * if "deseg" is true, return -1;
+ *
+ * if "deseg" is false, return the amount of data remaining in
+ * the buffer.
+ *
+ * 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. (It's not set if we return -1.)
*/
-extern gint tvb_find_line_end(tvbuff_t *tvb, gint offset, int len, gint *eol);
+extern gint tvb_find_line_end(tvbuff_t *tvb, gint offset, int len,
+ gint *next_offset, gboolean desegment);
/*
* Given a tvbuff, an offset into the tvbuff, and a length that starts
diff --git a/packet-cdp.c b/packet-cdp.c
index 714bbe01b4..e98ad8480c 100644
--- a/packet-cdp.c
+++ b/packet-cdp.c
@@ -2,7 +2,7 @@
* Routines for the disassembly of the "Cisco Discovery Protocol"
* (c) Copyright Hannes R. Boehm <hannes@boehm.org>
*
- * $Id: packet-cdp.c,v 1.45 2002/05/30 01:56:54 guy Exp $
+ * $Id: packet-cdp.c,v 1.46 2002/07/17 06:55:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -530,7 +530,7 @@ add_multi_line_string_to_tree(proto_tree *tree, tvbuff_t *tvb, gint start,
blanks[i] = ' ';
blanks[i] = '\0';
while (len > 0) {
- line_len = tvb_find_line_end(tvb, start, len, &next);
+ line_len = tvb_find_line_end(tvb, start, len, &next, FALSE);
data_len = next - start;
proto_tree_add_text(tree, tvb, start, data_len, "%s%.*s", prefix,
line_len, tvb_get_ptr(tvb, start, line_len));
diff --git a/packet-dccp.c b/packet-dccp.c
index be36cf0d62..435166b1a2 100644
--- a/packet-dccp.c
+++ b/packet-dccp.c
@@ -4,7 +4,7 @@
*
* Copyright 1999, Nathan Neulinger <nneul@umr.edu>
*
- * $Id: packet-dccp.c,v 1.5 2002/05/03 20:34:14 nneul Exp $
+ * $Id: packet-dccp.c,v 1.6 2002/07/17 06:55:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -102,9 +102,10 @@ static gint ett_dccp_trace = -1;
#define D_TEXT(label, endpad) { \
int next_offset,linelen,left; \
const char *line; \
- while (tvb_offset_exists(tvb, offset+endpad)) { \
+ while (tvb_offset_exists(tvb, offset+endpad)) { \
left = tvb_length_remaining(tvb,offset) - endpad; \
- linelen = tvb_find_line_end(tvb, offset, left, &next_offset); \
+ linelen = tvb_find_line_end(tvb, offset, left, &next_offset, \
+ FALSE); \
line = tvb_get_ptr(tvb, offset, linelen); \
proto_tree_add_text(dccp_optree, tvb, offset, \
next_offset - offset, "%s: %s", \
diff --git a/packet-ftp.c b/packet-ftp.c
index d5b6a39c41..4c3d3d5fe8 100644
--- a/packet-ftp.c
+++ b/packet-ftp.c
@@ -3,7 +3,7 @@
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
* Copyright 2001, Juan Toledo <toledo@users.sourceforge.net> (Passive FTP)
*
- * $Id: packet-ftp.c,v 1.46 2002/07/15 09:40:20 guy Exp $
+ * $Id: packet-ftp.c,v 1.47 2002/07/17 06:55:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -236,7 +236,7 @@ dissect_ftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* not longer than what's in the buffer, so the "tvb_get_ptr()"
* call won't throw an exception.
*/
- linelen = tvb_find_line_end(tvb, offset, -1, &next_offset);
+ linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
line = tvb_get_ptr(tvb, offset, linelen);
if (check_col(pinfo->cinfo, COL_INFO)) {
@@ -382,7 +382,7 @@ dissect_ftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* Find the end of the line.
*/
linelen = tvb_find_line_end(tvb, offset, -1,
- &next_offset);
+ &next_offset, FALSE);
/*
* Put this line.
diff --git a/packet-http.c b/packet-http.c
index dafa470378..466a469f00 100644
--- a/packet-http.c
+++ b/packet-http.c
@@ -3,7 +3,7 @@
*
* Guy Harris <guy@alum.mit.edu>
*
- * $Id: packet-http.c,v 1.48 2002/05/30 01:56:54 guy Exp $
+ * $Id: packet-http.c,v 1.49 2002/07/17 06:55:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -124,7 +124,8 @@ dissect_http(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* is not longer than what's in the buffer, so the
* "tvb_get_ptr()" call won't throw an exception.
*/
- linelen = tvb_find_line_end(tvb, offset, -1, &next_offset);
+ linelen = tvb_find_line_end(tvb, offset, -1, &next_offset,
+ FALSE);
line = tvb_get_ptr(tvb, offset, linelen);
http_type = HTTP_OTHERS; /* type not known yet */
if (is_http_request_or_reply(line, linelen, &http_type))
@@ -148,7 +149,8 @@ dissect_http(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/*
* Find the end of the line.
*/
- linelen = tvb_find_line_end(tvb, offset, -1, &next_offset);
+ linelen = tvb_find_line_end(tvb, offset, -1, &next_offset,
+ FALSE);
/*
* Get a buffer that refers to the line.
diff --git a/packet-icap.c b/packet-icap.c
index 429f892715..e3817f38c1 100644
--- a/packet-icap.c
+++ b/packet-icap.c
@@ -3,7 +3,7 @@
*
* Srishylam Simharajan simha@netapp.com
*
- * $Id: packet-icap.c,v 1.9 2002/06/28 23:59:47 guy Exp $
+ * $Id: packet-icap.c,v 1.10 2002/07/17 06:55:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -88,7 +88,8 @@ dissect_icap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* is not longer than what's in the buffer, so the
* "tvb_get_ptr()" call won't throw an exception.
*/
- linelen = tvb_find_line_end(tvb, offset, -1, &next_offset);
+ linelen = tvb_find_line_end(tvb, offset, -1, &next_offset,
+ FALSE);
line = tvb_get_ptr(tvb, offset, linelen);
icap_type = ICAP_OTHER; /* type not known yet */
if (is_icap_message(line, linelen, &icap_type))
@@ -114,7 +115,8 @@ dissect_icap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/*
* Find the end of the line.
*/
- linelen = tvb_find_line_end(tvb, offset, -1, &next_offset);
+ linelen = tvb_find_line_end(tvb, offset, -1, &next_offset,
+ FALSE);
/*
* Get a buffer that refers to the line.
diff --git a/packet-imap.c b/packet-imap.c
index b1d7d2be53..3538b840cb 100644
--- a/packet-imap.c
+++ b/packet-imap.c
@@ -2,7 +2,7 @@
* Routines for imap packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
- * $Id: packet-imap.c,v 1.19 2002/01/24 09:20:48 guy Exp $
+ * $Id: packet-imap.c,v 1.20 2002/07/17 06:55:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -74,7 +74,7 @@ dissect_imap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* not longer than what's in the buffer, so the "tvb_get_ptr()"
* call won't throw an exception.
*/
- linelen = tvb_find_line_end(tvb, offset, -1, &next_offset);
+ linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
line = tvb_get_ptr(tvb, offset, linelen);
if (pinfo->match_port == pinfo->destport)
diff --git a/packet-irc.c b/packet-irc.c
index 80a5d745ac..e2e6eb593f 100644
--- a/packet-irc.c
+++ b/packet-irc.c
@@ -1,7 +1,7 @@
/* packet-irc.c
* Routines for IRC packet dissection
*
- * $Id: packet-irc.c,v 1.18 2002/01/24 09:20:48 guy Exp $
+ * $Id: packet-irc.c,v 1.19 2002/07/17 06:55:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -104,7 +104,7 @@ dissect_irc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* Find the end of the line.
*/
linelen = tvb_find_line_end(tvb, offset, -1,
- &next_offset);
+ &next_offset, FALSE);
/*
* Get a buffer that refers to the line (without
diff --git a/packet-nntp.c b/packet-nntp.c
index 67dbaad2fd..7f78efd2d9 100644
--- a/packet-nntp.c
+++ b/packet-nntp.c
@@ -2,7 +2,7 @@
* Routines for nntp packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
- * $Id: packet-nntp.c,v 1.24 2002/01/24 09:20:50 guy Exp $
+ * $Id: packet-nntp.c,v 1.25 2002/07/17 06:55:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -77,7 +77,8 @@ dissect_nntp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* is not longer than what's in the buffer, so the
* "tvb_get_ptr()" call won't throw an exception.
*/
- linelen = tvb_find_line_end(tvb, offset, -1, &next_offset);
+ linelen = tvb_find_line_end(tvb, offset, -1, &next_offset,
+ FALSE);
col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %s", type,
tvb_format_text(tvb, offset, linelen));
}
@@ -107,7 +108,8 @@ dissect_nntp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/*
* Find the end of the line.
*/
- tvb_find_line_end(tvb, offset, -1, &next_offset);
+ tvb_find_line_end(tvb, offset, -1, &next_offset,
+ FALSE);
/*
* Put this line.
diff --git a/packet-pop.c b/packet-pop.c
index 5b6a4b6f2d..4bfb96a775 100644
--- a/packet-pop.c
+++ b/packet-pop.c
@@ -2,7 +2,7 @@
* Routines for pop packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
- * $Id: packet-pop.c,v 1.30 2002/01/24 09:20:50 guy Exp $
+ * $Id: packet-pop.c,v 1.31 2002/07/17 06:55:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -80,7 +80,7 @@ dissect_pop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* not longer than what's in the buffer, so the "tvb_get_ptr()"
* call won't throw an exception.
*/
- linelen = tvb_find_line_end(tvb, offset, -1, &next_offset);
+ linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
line = tvb_get_ptr(tvb, offset, linelen);
if (pinfo->match_port == pinfo->destport) {
@@ -173,7 +173,7 @@ dissect_pop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* Find the end of the line.
*/
linelen = tvb_find_line_end(tvb, offset, -1,
- &next_offset);
+ &next_offset, FALSE);
/*
* Put this line.
diff --git a/packet-rmi.c b/packet-rmi.c
index 9e1f9e3b37..3a630bcfc7 100644
--- a/packet-rmi.c
+++ b/packet-rmi.c
@@ -2,7 +2,7 @@
* Routines for java rmiregistry dissection
* Copyright 2002, Michael Stiller <ms@2scale.net>
*
- * $Id: packet-rmi.c,v 1.2 2002/07/17 00:42:42 guy Exp $
+ * $Id: packet-rmi.c,v 1.3 2002/07/17 06:55:20 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -105,7 +105,7 @@ dissect_rmi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (check_col(pinfo->cinfo, COL_PROTOCOL))
col_set_str(pinfo->cinfo, COL_PROTOCOL, "RMI");
- datalen = tvb_find_line_end(tvb, offset, -1, &next_offset);
+ datalen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
data = tvb_get_ptr(tvb, offset, datalen);
rmitype = get_rmi_type(data, datalen);
diff --git a/packet-rsh.c b/packet-rsh.c
index f604edf81b..1e760c8d16 100644
--- a/packet-rsh.c
+++ b/packet-rsh.c
@@ -4,7 +4,7 @@
* Robert Tsai <rtsai@netapp.com>
* Liberally copied from packet-http.c, by Guy Harris <guy@alum.mit.edu>
*
- * $Id: packet-rsh.c,v 1.17 2002/04/14 23:04:04 guy Exp $
+ * $Id: packet-rsh.c,v 1.18 2002/07/17 06:55:20 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -57,7 +57,7 @@ dissect_rsh(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
col_set_str(pinfo->cinfo, COL_PROTOCOL, "RSH");
if (check_col(pinfo->cinfo, COL_INFO)) {
/* Put the first line from the buffer into the summary. */
- tvb_find_line_end(tvb, offset, -1, &next_offset);
+ tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
linelen = next_offset - offset; /* include the line terminator */
/*
@@ -82,7 +82,8 @@ dissect_rsh(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/*
* Find the end of the line.
*/
- tvb_find_line_end(tvb, offset, -1, &next_offset);
+ tvb_find_line_end(tvb, offset, -1, &next_offset,
+ FALSE);
/*
* Put this line.
diff --git a/packet-rtsp.c b/packet-rtsp.c
index 7d9eda7f52..4b11d986ed 100644
--- a/packet-rtsp.c
+++ b/packet-rtsp.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-rtsp.c,v 1.47 2002/01/21 07:36:41 guy Exp $
+ * $Id: packet-rtsp.c,v 1.48 2002/07/17 06:55:20 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -425,7 +425,8 @@ dissect_rtspmessage(tvbuff_t *tvb, int offset, packet_info *pinfo,
* line terminator).
* Otherwise, just call it a continuation.
*/
- linelen = tvb_find_line_end(tvb, offset, -1, &next_offset);
+ linelen = tvb_find_line_end(tvb, offset, -1, &next_offset,
+ FALSE);
line = tvb_get_ptr(tvb, offset, linelen);
switch (is_rtsp_request_or_reply(line, linelen)) {
@@ -458,7 +459,8 @@ dissect_rtspmessage(tvbuff_t *tvb, int offset, packet_info *pinfo,
/*
* Find the end of the line.
*/
- linelen = tvb_find_line_end(tvb, offset, -1, &next_offset);
+ linelen = tvb_find_line_end(tvb, offset, -1, &next_offset,
+ FALSE);
/*
* Get a buffer that refers to the line.
diff --git a/packet-sip.c b/packet-sip.c
index 6c3d7e6c1a..2aa4517072 100644
--- a/packet-sip.c
+++ b/packet-sip.c
@@ -15,7 +15,7 @@
* Copyright 2000, Heikki Vatiainen <hessu@cs.tut.fi>
* Copyright 2001, Jean-Francois Mule <jfm@clarent.com>
*
- * $Id: packet-sip.c,v 1.29 2002/05/09 08:27:51 guy Exp $
+ * $Id: packet-sip.c,v 1.30 2002/07/17 06:55:20 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -107,7 +107,7 @@ static void dissect_sip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* "tvb_get_ptr()" call s below won't throw exceptions.
*/
offset = 0;
- eol = tvb_find_line_end(tvb, 0, -1, &next_offset);
+ eol = tvb_find_line_end(tvb, 0, -1, &next_offset, FALSE);
/* XXX - Check for a valid status message as well. */
is_request = sip_is_request(tvb, eol);
is_known_request = sip_is_known_request(tvb, 0);
@@ -153,7 +153,8 @@ static void dissect_sip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* - 2 since we have a CRLF separating the message-body */
while (msg_offset - 2 > (int) offset) {
- eol = tvb_find_line_end(tvb, offset, -1, &next_offset);
+ eol = tvb_find_line_end(tvb, offset, -1, &next_offset,
+ FALSE);
proto_tree_add_text(hdr_tree, tvb, offset, next_offset - offset, "%s",
tvb_format_text(tvb, offset, eol));
offset = next_offset;
@@ -207,7 +208,7 @@ dissect_sip_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* We don't, so this isn't a response; check for a request.
* They *end* with "SIP/2.0".
*/
- eol = tvb_find_line_end(tvb, 0, -1, &next_offset);
+ eol = tvb_find_line_end(tvb, 0, -1, &next_offset, FALSE);
if (eol <= (gint)SIP2_HDR_LEN) {
/*
* The line isn't long enough to end with "SIP/2.0".
diff --git a/packet-smtp.c b/packet-smtp.c
index 2c0e5cc42d..bca97cb453 100644
--- a/packet-smtp.c
+++ b/packet-smtp.c
@@ -1,7 +1,7 @@
/* packet-smtp.c
* Routines for SMTP packet disassembly
*
- * $Id: packet-smtp.c,v 1.29 2002/07/15 09:40:20 guy Exp $
+ * $Id: packet-smtp.c,v 1.30 2002/07/17 06:55:20 guy Exp $
*
* Copyright (c) 2000 by Richard Sharpe <rsharpe@ns.aus.com>
*
@@ -65,6 +65,9 @@ static int ett_smtp = -1;
static int global_smtp_tcp_port = TCP_PORT_SMTP;
+/* desegmentation of SMTP command and response lines */
+static gboolean smtp_desegment = TRUE;
+
/*
* A CMD is an SMTP command, MESSAGE is the message portion, and EOM is the
* last part of a message
@@ -157,11 +160,26 @@ dissect_smtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/*
* Get the first line from the buffer.
*
- * Note that "tvb_find_line_end()" will return a value that
- * is not longer than what's in the buffer, so the
- * "tvb_get_ptr()" call won't throw an exception.
+ * Note that "tvb_find_line_end()" will, if it doesn't return
+ * -1, return a value that is not longer than what's in the buffer,
+ * and "tvb_find_line_end()" will always return a value that is not
+ * longer than what's in the buffer, so the "tvb_get_ptr()" call
+ * won't throw an exception.
*/
- linelen = tvb_find_line_end(tvb, offset, -1, &next_offset);
+ linelen = tvb_find_line_end(tvb, offset, -1, &next_offset,
+ smtp_desegment && pinfo->can_desegment);
+ if (linelen == -1) {
+ /*
+ * We didn't find a line ending, and we're doing desegmentation;
+ * tell the TCP dissector where the data for this message starts
+ * in the data it handed us, and tell it we need one more byte
+ * (we may need more, but we'll try again if what we get next
+ * isn't enough), and return.
+ */
+ pinfo->desegment_offset = offset;
+ pinfo->desegment_len = 1;
+ return;
+ }
line = tvb_get_ptr(tvb, offset, linelen);
frame_data = p_get_proto_data(pinfo->fd, proto_smtp);
@@ -387,7 +405,7 @@ dissect_smtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/*
* Find the end of the line.
*/
- tvb_find_line_end(tvb, offset, -1, &next_offset);
+ tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
/*
* Put this line.
@@ -460,7 +478,7 @@ dissect_smtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/*
* Find the end of the line.
*/
- linelen = tvb_find_line_end(tvb, offset, -1, &next_offset);
+ linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
/*
* Is it a continuation line?
@@ -542,7 +560,7 @@ proto_register_smtp(void)
static gint *ett[] = {
&ett_smtp
};
- /*module_t *smtp_module = NULL; */ /* Not yet used */
+ module_t *smtp_module;
/* No Configuration options to register? */
@@ -553,6 +571,11 @@ proto_register_smtp(void)
proto_register_subtree_array(ett, array_length(ett));
register_init_routine(&smtp_init_protocol);
+ smtp_module = prefs_register_protocol(proto_smtp, NULL);
+ prefs_register_bool_preference(smtp_module, "desegment_lines",
+ "Desegment all SMTP command and response lines spanning multiple TCP segments",
+ "Whether the SMTP dissector should desegment all command and response lines spanning multiple TCP segments",
+ &smtp_desegment);
}
/* The registration hand-off routine */
diff --git a/packet-telnet.c b/packet-telnet.c
index 846af252bb..41bc328e4b 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.29 2002/01/24 09:20:52 guy Exp $
+ * $Id: packet-telnet.c,v 1.30 2002/07/17 06:55:20 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -311,7 +311,7 @@ telnet_add_text(proto_tree *tree, tvbuff_t *tvb, int offset, int len)
/*
* Find the end of the line.
*/
- linelen = tvb_find_line_end(tvb, offset, len, &next_offset);
+ linelen = tvb_find_line_end(tvb, offset, len, &next_offset, FALSE);
len -= next_offset - offset; /* subtract out the line's characters */
/*
diff --git a/plugins/mgcp/packet-mgcp.c b/plugins/mgcp/packet-mgcp.c
index 77c94fffbf..320d633733 100644
--- a/plugins/mgcp/packet-mgcp.c
+++ b/plugins/mgcp/packet-mgcp.c
@@ -2,7 +2,7 @@
* Routines for mgcp packet disassembly
* RFC 2705
*
- * $Id: packet-mgcp.c,v 1.32 2002/04/30 10:37:37 guy Exp $
+ * $Id: packet-mgcp.c,v 1.33 2002/07/17 06:55:29 guy Exp $
*
* Copyright (c) 2000 by Ed Warnicke <hagbard@physics.rutgers.edu>
*
@@ -280,7 +280,7 @@ dissect_mgcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (check_col(pinfo->cinfo, COL_INFO) ){
sectionlen = tvb_find_line_end(tvb, tvb_sectionbegin,-1,
- &tvb_sectionend);
+ &tvb_sectionend,FALSE);
col_add_fstr(pinfo->cinfo, COL_INFO, "%s",
tvb_format_text(tvb,tvb_sectionbegin,sectionlen));
}
@@ -317,7 +317,7 @@ dissect_mgcp_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
tvb_sectionbegin = 0;
tvb_current_len = tvb_len;
tvb_sectionend = tvb_sectionbegin;
- sectionlen = tvb_find_line_end(tvb,0,-1,&tvb_sectionend);
+ sectionlen = tvb_find_line_end(tvb,0,-1,&tvb_sectionend,FALSE);
if( sectionlen > 0){
dissect_mgcp_firstline(tvb_new_subset(tvb, tvb_sectionbegin,
sectionlen,-1),
@@ -372,7 +372,7 @@ static void mgcp_raw_text_add(tvbuff_t *tvb, proto_tree *tree){
tvb_len = tvb_length(tvb);
do {
- tvb_find_line_end(tvb,tvb_linebegin,-1,&tvb_lineend);
+ tvb_find_line_end(tvb,tvb_linebegin,-1,&tvb_lineend,FALSE);
linelen = tvb_lineend - tvb_linebegin;
proto_tree_add_text(tree, tvb, tvb_linebegin, linelen,
"%s", tvb_format_text(tvb,tvb_linebegin,
@@ -940,7 +940,7 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb,
else if(mgcp_type == MGCP_RESPONSE){
if(tvb_current_offset < tvb_len){
tokenlen = tvb_find_line_end(tvb, tvb_previous_offset,
- -1,&tvb_current_offset);
+ -1,&tvb_current_offset,FALSE);
}
else{
tokenlen = tvb_current_len;
@@ -955,7 +955,7 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb,
if( (tokennum == 3 && mgcp_type == MGCP_REQUEST) ){
if(tvb_current_offset < tvb_len ){
tokenlen = tvb_find_line_end(tvb, tvb_previous_offset,
- -1,&tvb_current_offset);
+ -1,&tvb_current_offset,FALSE);
}
else{
tokenlen = tvb_current_len;
@@ -1031,11 +1031,11 @@ static void dissect_mgcp_params(tvbuff_t *tvb, proto_tree *tree){
/* Parse the parameters */
while(tvb_lineend < tvb_len){
- linelen = tvb_find_line_end(tvb, tvb_linebegin, -1,&tvb_lineend);
+ linelen = tvb_find_line_end(tvb, tvb_linebegin, -1,&tvb_lineend,FALSE);
tvb_tokenbegin = tvb_parse_param(tvb, tvb_linebegin, linelen,
&my_param);
if( my_param != NULL ){
- tokenlen = tvb_find_line_end(tvb,tvb_tokenbegin,-1,&tvb_lineend);
+ tokenlen = tvb_find_line_end(tvb,tvb_tokenbegin,-1,&tvb_lineend,FALSE);
my_proto_tree_add_string(mgcp_param_tree,*my_param, tvb,
tvb_linebegin, linelen,
tvb_format_text(tvb,tvb_tokenbegin,
@@ -1122,7 +1122,7 @@ static gint tvb_find_null_line(tvbuff_t* tvb, gint offset,
do {
tvb_linebegin = tvb_lineend;
tvb_current_len = tvb_length_remaining(tvb,tvb_linebegin);
- tvb_find_line_end(tvb, tvb_linebegin, tvb_current_len, &tvb_lineend);
+ tvb_find_line_end(tvb, tvb_linebegin, tvb_current_len, &tvb_lineend,FALSE);
tempchar = tvb_get_guint8(tvb,tvb_linebegin);
}
while( tempchar != '\r' && tempchar != '\n' &&
@@ -1233,7 +1233,7 @@ static gint tvb_find_dot_line(tvbuff_t* tvb, gint offset,
*next_offset = maxoffset + 1;
}
else {
- tvb_find_line_end(tvb,tvb_current_offset,tvb_current_len,next_offset);
+ tvb_find_line_end(tvb,tvb_current_offset,tvb_current_len,next_offset,FALSE);
}
if( tvb_current_offset == offset ){
diff --git a/plugins/plugin_table.h b/plugins/plugin_table.h
index f47ec6597b..76c8da448a 100644
--- a/plugins/plugin_table.h
+++ b/plugins/plugin_table.h
@@ -1,7 +1,7 @@
/* plugin_table.h
* Table of exported addresses for Ethereal plugins.
*
- * $Id: plugin_table.h,v 1.50 2002/07/12 22:52:39 guy Exp $
+ * $Id: plugin_table.h,v 1.51 2002/07/17 06:55:26 guy Exp $
*
* Ethereal - Network traffic analyzer
* Copyright 2000 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -171,7 +171,7 @@ typedef guint8 * (*addr_tvb_format_text)(tvbuff_t*, gint, gint);
typedef gint (*addr_tvb_get_nstringz)(tvbuff_t*, gint, guint, guint8*);
typedef gint (*addr_tvb_get_nstringz0)(tvbuff_t*, gint, guint, guint8*);
-typedef gint (*addr_tvb_find_line_end)(tvbuff_t*, gint, int, gint *);
+typedef gint (*addr_tvb_find_line_end)(tvbuff_t*, gint, int, gint *, gboolean);
typedef gint (*addr_tvb_find_line_end_unquoted)(tvbuff_t*, gint, int, gint *);
typedef gint (*addr_tvb_strneql)(tvbuff_t*, gint, const guint8 *, gint);