aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2002-07-17 06:55:29 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2002-07-17 06:55:29 +0000
commitfc616618cac99301b5e51d05a94a9582c37c3dca (patch)
treee3040460a5348a10bfe0cba753a7eec70fb5349b /epan
parent60f24595ad782fcd02f0179dbf6b84ecb8b26a36 (diff)
Add an extra argument to "tvb_find_line_end()", which specifies what it
should do if it doesn't find an EOL; if FALSE, it behaves as before, returning values that treat the line as ending at the end of the tvbuff, and if TRUE, it returns -1, so its caller can do segment reassembly until it gets the EOL. Add an option to the SMTP dissector to do segment reassembly, and do segment reassembly of the first line. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@5891 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan')
-rw-r--r--epan/tvbuff.c64
-rw-r--r--epan/tvbuff.h18
2 files changed, 66 insertions, 16 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