aboutsummaryrefslogtreecommitdiffstats
path: root/packet-smtp.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-07-17 06:55:29 +0000
committerGuy Harris <guy@alum.mit.edu>2002-07-17 06:55:29 +0000
commit47b147ffd119809198871932874f6fc5b7e6e836 (patch)
treee3040460a5348a10bfe0cba753a7eec70fb5349b /packet-smtp.c
parentcc00331455604ca51fa743a4f73f5c899c023a67 (diff)
downloadwireshark-47b147ffd119809198871932874f6fc5b7e6e836.tar.gz
wireshark-47b147ffd119809198871932874f6fc5b7e6e836.tar.bz2
wireshark-47b147ffd119809198871932874f6fc5b7e6e836.zip
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. svn path=/trunk/; revision=5891
Diffstat (limited to 'packet-smtp.c')
-rw-r--r--packet-smtp.c39
1 files changed, 31 insertions, 8 deletions
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 */