2000-08-19 23:06:51 +00:00
|
|
|
/* packet-smtp.c
|
2000-08-20 02:16:23 +00:00
|
|
|
* Routines for SMTP packet disassembly
|
2000-08-19 23:06:51 +00:00
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2000-08-19 23:06:51 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) 2000 by Richard Sharpe <rsharpe@ns.aus.com>
|
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2000-08-19 23:06:51 +00:00
|
|
|
* Copyright 1999 Gerald Combs
|
2001-12-03 04:00:26 +00:00
|
|
|
*
|
2000-08-19 23:06:51 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <glib.h>
|
|
|
|
#include <string.h>
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <epan/conversation.h>
|
2004-08-06 19:57:49 +00:00
|
|
|
#include <epan/addr_resolv.h>
|
2004-09-27 22:55:15 +00:00
|
|
|
#include <epan/prefs.h>
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/strutil.h>
|
2005-08-12 10:03:17 +00:00
|
|
|
#include <epan/emem.h>
|
2007-07-04 16:16:32 +00:00
|
|
|
#include <epan/reassemble.h>
|
2010-01-10 19:39:35 +00:00
|
|
|
#include <epan/dissectors/packet-ssl.h>
|
2000-08-19 23:06:51 +00:00
|
|
|
|
2007-12-28 09:09:09 +00:00
|
|
|
/* RFC 2821 */
|
2000-08-19 23:06:51 +00:00
|
|
|
#define TCP_PORT_SMTP 25
|
2010-01-10 19:39:35 +00:00
|
|
|
#define TCP_PORT_SSL_SMTP 465
|
2000-08-19 23:06:51 +00:00
|
|
|
|
2007-12-28 09:09:09 +00:00
|
|
|
/* RFC 4409 */
|
|
|
|
#define TCP_PORT_SUBMISSION 587
|
|
|
|
|
2000-08-19 23:06:51 +00:00
|
|
|
static int proto_smtp = -1;
|
|
|
|
|
|
|
|
static int hf_smtp_req = -1;
|
|
|
|
static int hf_smtp_rsp = -1;
|
2002-07-14 00:40:07 +00:00
|
|
|
static int hf_smtp_req_command = -1;
|
|
|
|
static int hf_smtp_req_parameter = -1;
|
|
|
|
static int hf_smtp_rsp_code = -1;
|
|
|
|
static int hf_smtp_rsp_parameter = -1;
|
2000-08-19 23:06:51 +00:00
|
|
|
|
2007-07-04 16:16:32 +00:00
|
|
|
static int hf_smtp_data_fragments = -1;
|
|
|
|
static int hf_smtp_data_fragment = -1;
|
|
|
|
static int hf_smtp_data_fragment_overlap = -1;
|
|
|
|
static int hf_smtp_data_fragment_overlap_conflicts = -1;
|
|
|
|
static int hf_smtp_data_fragment_multiple_tails = -1;
|
|
|
|
static int hf_smtp_data_fragment_too_long_fragment = -1;
|
|
|
|
static int hf_smtp_data_fragment_error = -1;
|
|
|
|
static int hf_smtp_data_reassembled_in = -1;
|
|
|
|
|
2000-08-19 23:06:51 +00:00
|
|
|
static int ett_smtp = -1;
|
2003-06-11 18:22:12 +00:00
|
|
|
static int ett_smtp_cmdresp = -1;
|
2000-08-19 23:06:51 +00:00
|
|
|
|
2007-07-04 16:16:32 +00:00
|
|
|
static gint ett_smtp_data_fragment = -1;
|
|
|
|
static gint ett_smtp_data_fragments = -1;
|
|
|
|
|
2002-07-17 06:55:29 +00:00
|
|
|
/* desegmentation of SMTP command and response lines */
|
|
|
|
static gboolean smtp_desegment = TRUE;
|
2007-07-04 16:16:32 +00:00
|
|
|
static gboolean smtp_data_desegment = TRUE;
|
|
|
|
|
|
|
|
static GHashTable *smtp_data_segment_table = NULL;
|
|
|
|
static GHashTable *smtp_data_reassembled_table = NULL;
|
|
|
|
|
|
|
|
static const fragment_items smtp_data_frag_items = {
|
|
|
|
/* Fragment subtrees */
|
|
|
|
&ett_smtp_data_fragment,
|
|
|
|
&ett_smtp_data_fragments,
|
|
|
|
/* Fragment fields */
|
|
|
|
&hf_smtp_data_fragments,
|
|
|
|
&hf_smtp_data_fragment,
|
|
|
|
&hf_smtp_data_fragment_overlap,
|
|
|
|
&hf_smtp_data_fragment_overlap_conflicts,
|
|
|
|
&hf_smtp_data_fragment_multiple_tails,
|
|
|
|
&hf_smtp_data_fragment_too_long_fragment,
|
|
|
|
&hf_smtp_data_fragment_error,
|
|
|
|
/* Reassembled in field */
|
|
|
|
&hf_smtp_data_reassembled_in,
|
|
|
|
/* Tag */
|
|
|
|
"DATA fragments"
|
|
|
|
};
|
|
|
|
|
2008-09-07 01:28:43 +00:00
|
|
|
static dissector_handle_t ssl_handle;
|
2008-09-07 01:50:44 +00:00
|
|
|
static dissector_handle_t imf_handle;
|
2002-07-17 06:55:29 +00:00
|
|
|
|
2000-08-24 11:32:09 +00:00
|
|
|
/*
|
|
|
|
* A CMD is an SMTP command, MESSAGE is the message portion, and EOM is the
|
|
|
|
* last part of a message
|
|
|
|
*/
|
2002-08-28 21:04:11 +00:00
|
|
|
#define SMTP_PDU_CMD 0
|
2000-08-24 11:32:09 +00:00
|
|
|
#define SMTP_PDU_MESSAGE 1
|
|
|
|
#define SMTP_PDU_EOM 2
|
|
|
|
|
|
|
|
struct smtp_proto_data {
|
|
|
|
guint16 pdu_type;
|
2007-07-04 16:16:32 +00:00
|
|
|
guint16 conversation_id;
|
2007-08-15 22:29:58 +00:00
|
|
|
gboolean more_frags;
|
2000-08-24 11:32:09 +00:00
|
|
|
};
|
|
|
|
|
Simplify the state machine:
you're either reading commands, or you're reading message data;
if you're reading commands, and you see a DATA command, you
start reading data;
if you're reading data, and you see an EOM, you start reading
commands.
Also, *always* fill in the per-frame data you allocate for a frame, and
*always* attach it to the packet.
The old state machine assumed it was done with the SMTP conversation
once it saw an EOM, and the dissector wouldn't fill in the per-frame
data it'd allocated and attach it to the packet if it thought it was
done with the SMTP conversation. This meant that:
1) the per-frame data allocated for frames following the EOM
(e.g., a QUIT command) would contain random junk for data
such as the packet type;
2) that per-frame data would be re-allocated every time the
frame was looked at, as it wouldn't be attached to the frame,
so you might well get *different* random junk each time the
frame was looked at.
This caused Tethereal and Ethereal to sometimes fail to recognize
commands following the EOM - but it wouldn't *always* fail to do so,
sometimes it'd work and sometimes it wouldn't.
Fix a comment; conversations are *not* removed during filter operations,
and the visited flag is *not* cleared during a filter operation - that's
only true on a *redissection* operation. In any case, given that frames
can, after the initial sequential scan through the capture, be visited
in any order, and visited repeatedly, it's irrelevant whether
conversations are removed or not - we have to associate with each frame
information telling us how to process it.
svn path=/trunk/; revision=2608
2000-11-11 07:48:30 +00:00
|
|
|
/*
|
|
|
|
* State information stored with a conversation.
|
|
|
|
*/
|
2008-09-07 01:28:43 +00:00
|
|
|
typedef enum {
|
|
|
|
READING_CMDS, /* reading commands */
|
|
|
|
READING_DATA, /* reading message data */
|
|
|
|
AWAITING_STARTTLS_RESPONSE /* sent STARTTLS, awaiting response */
|
|
|
|
} smtp_state_t;
|
|
|
|
|
|
|
|
struct smtp_session_state {
|
|
|
|
smtp_state_t smtp_state; /* Current state */
|
|
|
|
gboolean crlf_seen; /* Have we seen a CRLF on the end of a packet */
|
|
|
|
gboolean data_seen; /* Have we seen a DATA command yet */
|
|
|
|
guint32 msg_read_len; /* Length of BDAT message read so far */
|
|
|
|
guint32 msg_tot_len; /* Total length of BDAT message */
|
|
|
|
gboolean msg_last; /* Is this the last BDAT chunk */
|
|
|
|
guint32 last_nontls_frame; /* last non-TLS frame; 0 if not known or no TLS */
|
2000-08-24 11:32:09 +00:00
|
|
|
};
|
|
|
|
|
2008-09-06 23:58:23 +00:00
|
|
|
/*
|
|
|
|
* See
|
|
|
|
*
|
|
|
|
* http://support.microsoft.com/default.aspx?scid=kb;[LN];812455
|
|
|
|
*
|
|
|
|
* for the Exchange extensions.
|
|
|
|
*/
|
|
|
|
static const struct {
|
|
|
|
const char *command;
|
|
|
|
int len;
|
|
|
|
} commands[] = {
|
|
|
|
{ "STARTTLS", 8 }, /* RFC 2487 */
|
|
|
|
{ "X-EXPS", 6 }, /* Microsoft Exchange */
|
|
|
|
{ "X-LINK2STATE", 12 }, /* Microsoft Exchange */
|
|
|
|
{ "XEXCH50", 7 } /* Microsoft Exchange */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define NCOMMANDS (sizeof commands / sizeof commands[0])
|
|
|
|
|
2009-12-18 04:04:15 +00:00
|
|
|
/* The following were copied from RFC 2821 */
|
|
|
|
static const value_string response_codes_vs[] = {
|
|
|
|
{ 211, "System status, or system help reply" },
|
|
|
|
{ 214, "Help message" },
|
|
|
|
{ 220, "<domain> Service ready" },
|
|
|
|
{ 221, "<domain> Service closing transmission channel" },
|
|
|
|
{ 250, "Requested mail action okay, completed" },
|
|
|
|
{ 251, "User not local; will forward to <forward-path>" },
|
|
|
|
{ 252, "Cannot VRFY user, but will accept message and attempt delivery" },
|
|
|
|
{ 354, "Start mail input; end with <CRLF>.<CRLF>" },
|
|
|
|
{ 421, "<domain> Service not available, closing transmission channel" },
|
|
|
|
{ 450, "Requested mail action not taken: mailbox unavailable" },
|
|
|
|
{ 451, "Requested action aborted: local error in processing" },
|
|
|
|
{ 452, "Requested action not taken: insufficient system storage" },
|
|
|
|
{ 500, "Syntax error, command unrecognized" },
|
|
|
|
{ 501, "Syntax error in parameters or arguments" },
|
|
|
|
{ 502, "Command not implemented" },
|
|
|
|
{ 503, "Bad sequence of commands" },
|
|
|
|
{ 504, "Command parameter not implemented" },
|
|
|
|
{ 550, "Requested action not taken: mailbox unavailable" },
|
|
|
|
{ 551, "User not local; please try <forward-path>" },
|
|
|
|
{ 552, "Requested mail action aborted: exceeded storage allocation" },
|
|
|
|
{ 553, "Requested action not taken: mailbox name not allowed" },
|
|
|
|
{ 554, "Transaction failed" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-09-06 23:58:23 +00:00
|
|
|
static gboolean
|
|
|
|
line_is_smtp_command(const guchar *command, int commandlen)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* To quote RFC 821, "Command codes are four alphabetic
|
2008-09-07 01:50:44 +00:00
|
|
|
* characters".
|
2008-09-06 23:58:23 +00:00
|
|
|
*
|
|
|
|
* However, there are some SMTP extensions that involve commands
|
|
|
|
* longer than 4 characters and/or that contain non-alphabetic
|
|
|
|
* characters; we treat them specially.
|
|
|
|
*
|
|
|
|
* XXX - should we just have a table of known commands? Or would
|
|
|
|
* that fail to catch some extensions we don't know about?
|
|
|
|
*/
|
2008-09-07 01:50:44 +00:00
|
|
|
if (commandlen == 4 && g_ascii_isalpha(command[0]) &&
|
|
|
|
g_ascii_isalpha(command[1]) && g_ascii_isalpha(command[2]) &&
|
|
|
|
g_ascii_isalpha(command[3])) {
|
2008-09-06 23:58:23 +00:00
|
|
|
/* standard 4-alphabetic command */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check the list of non-4-alphabetic commands.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < NCOMMANDS; i++) {
|
|
|
|
if (commandlen == commands[i].len &&
|
|
|
|
g_ascii_strncasecmp(command, commands[i].command, commands[i].len) == 0)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-07-04 16:16:32 +00:00
|
|
|
|
2008-09-07 01:50:44 +00:00
|
|
|
static void
|
|
|
|
dissect_smtp_data(tvbuff_t *tvb, int offset, proto_tree *smtp_tree)
|
2007-07-04 16:16:32 +00:00
|
|
|
{
|
|
|
|
gint next_offset;
|
|
|
|
|
2008-11-23 14:18:07 +00:00
|
|
|
if (smtp_tree) {
|
|
|
|
while (tvb_offset_exists(tvb, offset)) {
|
|
|
|
/*
|
|
|
|
* Find the end of the line.
|
|
|
|
*/
|
|
|
|
tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
|
2007-07-04 16:16:32 +00:00
|
|
|
|
2008-11-23 14:18:07 +00:00
|
|
|
/*
|
|
|
|
* Put this line.
|
|
|
|
*/
|
|
|
|
proto_tree_add_text(smtp_tree, tvb, offset, next_offset - offset,
|
|
|
|
"Message: %s",
|
|
|
|
tvb_format_text(tvb, offset, next_offset - offset));
|
2007-07-04 16:16:32 +00:00
|
|
|
|
2008-11-23 14:18:07 +00:00
|
|
|
/*
|
|
|
|
* Step to the next line.
|
|
|
|
*/
|
|
|
|
offset = next_offset;
|
|
|
|
}
|
2007-07-04 16:16:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-19 23:06:51 +00:00
|
|
|
static void
|
|
|
|
dissect_smtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
2010-01-22 17:41:47 +00:00
|
|
|
struct smtp_proto_data *spd_frame_data;
|
2008-09-07 01:28:43 +00:00
|
|
|
proto_tree *smtp_tree = NULL;
|
|
|
|
proto_tree *cmdresp_tree;
|
|
|
|
proto_item *ti, *hidden_item;
|
|
|
|
int offset = 0;
|
|
|
|
int request = 0;
|
|
|
|
conversation_t *conversation;
|
|
|
|
struct smtp_session_state *session_state;
|
|
|
|
const guchar *line, *linep, *lineend;
|
|
|
|
guchar c;
|
|
|
|
guint32 code;
|
|
|
|
int linelen = 0;
|
|
|
|
gint length_remaining;
|
|
|
|
gboolean eom_seen = FALSE;
|
|
|
|
gint next_offset;
|
2008-10-11 16:01:48 +00:00
|
|
|
gint loffset = 0;
|
2008-09-07 01:28:43 +00:00
|
|
|
gboolean is_continuation_line;
|
|
|
|
int cmdlen;
|
|
|
|
fragment_data *frag_msg = NULL;
|
|
|
|
tvbuff_t *next_tvb;
|
2000-08-19 23:06:51 +00:00
|
|
|
|
Simplify the state machine:
you're either reading commands, or you're reading message data;
if you're reading commands, and you see a DATA command, you
start reading data;
if you're reading data, and you see an EOM, you start reading
commands.
Also, *always* fill in the per-frame data you allocate for a frame, and
*always* attach it to the packet.
The old state machine assumed it was done with the SMTP conversation
once it saw an EOM, and the dissector wouldn't fill in the per-frame
data it'd allocated and attach it to the packet if it thought it was
done with the SMTP conversation. This meant that:
1) the per-frame data allocated for frames following the EOM
(e.g., a QUIT command) would contain random junk for data
such as the packet type;
2) that per-frame data would be re-allocated every time the
frame was looked at, as it wouldn't be attached to the frame,
so you might well get *different* random junk each time the
frame was looked at.
This caused Tethereal and Ethereal to sometimes fail to recognize
commands following the EOM - but it wouldn't *always* fail to do so,
sometimes it'd work and sometimes it wouldn't.
Fix a comment; conversations are *not* removed during filter operations,
and the visited flag is *not* cleared during a filter operation - that's
only true on a *redissection* operation. In any case, given that frames
can, after the initial sequential scan through the capture, be visited
in any order, and visited repeatedly, it's irrelevant whether
conversations are removed or not - we have to associate with each frame
information telling us how to process it.
svn path=/trunk/; revision=2608
2000-11-11 07:48:30 +00:00
|
|
|
/* As there is no guarantee that we will only see frames in the
|
|
|
|
* the SMTP conversation once, and that we will see them in
|
2006-05-21 04:49:01 +00:00
|
|
|
* order - in Wireshark, the user could randomly click on frames
|
Simplify the state machine:
you're either reading commands, or you're reading message data;
if you're reading commands, and you see a DATA command, you
start reading data;
if you're reading data, and you see an EOM, you start reading
commands.
Also, *always* fill in the per-frame data you allocate for a frame, and
*always* attach it to the packet.
The old state machine assumed it was done with the SMTP conversation
once it saw an EOM, and the dissector wouldn't fill in the per-frame
data it'd allocated and attach it to the packet if it thought it was
done with the SMTP conversation. This meant that:
1) the per-frame data allocated for frames following the EOM
(e.g., a QUIT command) would contain random junk for data
such as the packet type;
2) that per-frame data would be re-allocated every time the
frame was looked at, as it wouldn't be attached to the frame,
so you might well get *different* random junk each time the
frame was looked at.
This caused Tethereal and Ethereal to sometimes fail to recognize
commands following the EOM - but it wouldn't *always* fail to do so,
sometimes it'd work and sometimes it wouldn't.
Fix a comment; conversations are *not* removed during filter operations,
and the visited flag is *not* cleared during a filter operation - that's
only true on a *redissection* operation. In any case, given that frames
can, after the initial sequential scan through the capture, be visited
in any order, and visited repeatedly, it's irrelevant whether
conversations are removed or not - we have to associate with each frame
information telling us how to process it.
svn path=/trunk/; revision=2608
2000-11-11 07:48:30 +00:00
|
|
|
* in the conversation in any order in which they choose - we
|
|
|
|
* have to store information with each frame indicating whether
|
|
|
|
* it contains commands or data or an EOM indication.
|
|
|
|
*
|
|
|
|
* XXX - what about frames that contain *both*? TCP is a
|
|
|
|
* byte-stream protocol, and there are no guarantees that
|
|
|
|
* TCP segment boundaries will correspond to SMTP commands
|
|
|
|
* or EOM indications.
|
|
|
|
*
|
|
|
|
* We only need that for the client->server stream; responses
|
2000-08-24 11:32:09 +00:00
|
|
|
* are easy to manage.
|
Simplify the state machine:
you're either reading commands, or you're reading message data;
if you're reading commands, and you see a DATA command, you
start reading data;
if you're reading data, and you see an EOM, you start reading
commands.
Also, *always* fill in the per-frame data you allocate for a frame, and
*always* attach it to the packet.
The old state machine assumed it was done with the SMTP conversation
once it saw an EOM, and the dissector wouldn't fill in the per-frame
data it'd allocated and attach it to the packet if it thought it was
done with the SMTP conversation. This meant that:
1) the per-frame data allocated for frames following the EOM
(e.g., a QUIT command) would contain random junk for data
such as the packet type;
2) that per-frame data would be re-allocated every time the
frame was looked at, as it wouldn't be attached to the frame,
so you might well get *different* random junk each time the
frame was looked at.
This caused Tethereal and Ethereal to sometimes fail to recognize
commands following the EOM - but it wouldn't *always* fail to do so,
sometimes it'd work and sometimes it wouldn't.
Fix a comment; conversations are *not* removed during filter operations,
and the visited flag is *not* cleared during a filter operation - that's
only true on a *redissection* operation. In any case, given that frames
can, after the initial sequential scan through the capture, be visited
in any order, and visited repeatedly, it's irrelevant whether
conversations are removed or not - we have to associate with each frame
information telling us how to process it.
svn path=/trunk/; revision=2608
2000-11-11 07:48:30 +00:00
|
|
|
*
|
2002-08-28 21:04:11 +00:00
|
|
|
* If we have per frame data, use that, else, we must be on the first
|
Simplify the state machine:
you're either reading commands, or you're reading message data;
if you're reading commands, and you see a DATA command, you
start reading data;
if you're reading data, and you see an EOM, you start reading
commands.
Also, *always* fill in the per-frame data you allocate for a frame, and
*always* attach it to the packet.
The old state machine assumed it was done with the SMTP conversation
once it saw an EOM, and the dissector wouldn't fill in the per-frame
data it'd allocated and attach it to the packet if it thought it was
done with the SMTP conversation. This meant that:
1) the per-frame data allocated for frames following the EOM
(e.g., a QUIT command) would contain random junk for data
such as the packet type;
2) that per-frame data would be re-allocated every time the
frame was looked at, as it wouldn't be attached to the frame,
so you might well get *different* random junk each time the
frame was looked at.
This caused Tethereal and Ethereal to sometimes fail to recognize
commands following the EOM - but it wouldn't *always* fail to do so,
sometimes it'd work and sometimes it wouldn't.
Fix a comment; conversations are *not* removed during filter operations,
and the visited flag is *not* cleared during a filter operation - that's
only true on a *redissection* operation. In any case, given that frames
can, after the initial sequential scan through the capture, be visited
in any order, and visited repeatedly, it's irrelevant whether
conversations are removed or not - we have to associate with each frame
information telling us how to process it.
svn path=/trunk/; revision=2608
2000-11-11 07:48:30 +00:00
|
|
|
* pass, so we figure it out on the first pass.
|
2000-08-24 11:32:09 +00:00
|
|
|
*/
|
|
|
|
|
2008-09-07 01:28:43 +00:00
|
|
|
/*
|
|
|
|
* Find the conversation for this.
|
|
|
|
*/
|
|
|
|
conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype,
|
|
|
|
pinfo->srcport, pinfo->destport, 0);
|
|
|
|
if (conversation == NULL) { /* No conversation, create one */
|
|
|
|
conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype,
|
|
|
|
pinfo->srcport, pinfo->destport, 0);
|
|
|
|
}
|
2008-09-05 09:51:13 +00:00
|
|
|
|
2008-09-07 01:28:43 +00:00
|
|
|
/*
|
|
|
|
* Is there a request structure attached to this conversation?
|
2000-08-24 11:32:09 +00:00
|
|
|
*/
|
2008-09-07 01:28:43 +00:00
|
|
|
session_state = conversation_get_proto_data(conversation, proto_smtp);
|
|
|
|
if (!session_state) {
|
|
|
|
/*
|
|
|
|
* No - create one and attach it.
|
|
|
|
*/
|
|
|
|
session_state = se_alloc(sizeof(struct smtp_session_state));
|
|
|
|
session_state->smtp_state = READING_CMDS;
|
|
|
|
session_state->crlf_seen = FALSE;
|
|
|
|
session_state->data_seen = FALSE;
|
|
|
|
session_state->msg_read_len = 0;
|
|
|
|
session_state->msg_tot_len = 0;
|
|
|
|
session_state->msg_last = TRUE;
|
|
|
|
session_state->last_nontls_frame = 0;
|
|
|
|
|
|
|
|
conversation_add_proto_data(conversation, proto_smtp, session_state);
|
|
|
|
}
|
|
|
|
|
2008-11-23 14:18:07 +00:00
|
|
|
/* Are we doing TLS?
|
|
|
|
* FIXME In my understanding of RFC 2487 client and server can send SMTP cmds
|
|
|
|
* after a rejected TLS negotiation
|
|
|
|
*/
|
|
|
|
if (session_state->last_nontls_frame != 0 && pinfo->fd->num > session_state->last_nontls_frame) {
|
|
|
|
guint16 save_can_desegment;
|
|
|
|
/* This is TLS, not raw SMTP. TLS can desegment */
|
|
|
|
save_can_desegment = pinfo->can_desegment;
|
|
|
|
pinfo->can_desegment = pinfo->saved_can_desegment;
|
|
|
|
call_dissector(ssl_handle, tvb, pinfo, tree);
|
|
|
|
pinfo->can_desegment = save_can_desegment;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-09-07 01:28:43 +00:00
|
|
|
/* Is this a request or a response? */
|
|
|
|
request = pinfo->destport == pinfo->match_port;
|
2000-08-24 11:32:09 +00:00
|
|
|
|
2008-09-07 01:28:43 +00:00
|
|
|
/*
|
|
|
|
* Is there any data attached to this frame?
|
|
|
|
*/
|
2010-01-22 17:41:47 +00:00
|
|
|
spd_frame_data = p_get_proto_data(pinfo->fd, proto_smtp);
|
2000-08-19 23:06:51 +00:00
|
|
|
|
2010-01-22 17:41:47 +00:00
|
|
|
if (!spd_frame_data) {
|
2000-08-19 23:06:51 +00:00
|
|
|
|
2008-09-06 22:33:22 +00:00
|
|
|
/*
|
2008-09-07 01:28:43 +00:00
|
|
|
* No frame data.
|
2008-09-06 22:33:22 +00:00
|
|
|
*/
|
2008-04-13 16:33:44 +00:00
|
|
|
if(request) {
|
2008-09-06 22:33:22 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a frame data structure and attach it to the packet.
|
|
|
|
*/
|
2010-01-22 17:41:47 +00:00
|
|
|
spd_frame_data = se_alloc0(sizeof(struct smtp_proto_data));
|
2008-04-13 16:33:44 +00:00
|
|
|
|
2010-01-22 17:41:47 +00:00
|
|
|
spd_frame_data->conversation_id = conversation->index;
|
|
|
|
spd_frame_data->more_frags = TRUE;
|
2008-04-13 16:33:44 +00:00
|
|
|
|
2010-01-22 17:41:47 +00:00
|
|
|
p_add_proto_data(pinfo->fd, proto_smtp, spd_frame_data);
|
2008-04-13 16:33:44 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-09-05 09:28:08 +00:00
|
|
|
/*
|
|
|
|
* Get the first line from the buffer.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2008-09-05 09:07:46 +00:00
|
|
|
loffset = offset;
|
|
|
|
while (tvb_offset_exists(tvb, loffset)) {
|
|
|
|
linelen = tvb_find_line_end(tvb, loffset, -1, &next_offset,
|
|
|
|
smtp_desegment && pinfo->can_desegment);
|
|
|
|
if (linelen == -1) {
|
2008-09-07 01:50:44 +00:00
|
|
|
if (offset == loffset) {
|
2008-09-05 09:07:46 +00:00
|
|
|
/*
|
|
|
|
* We didn't find a line ending, and we're doing desegmentation;
|
|
|
|
* tell the TCP dissector where the data for this message starts
|
2008-11-23 14:18:07 +00:00
|
|
|
* in the data it handed us, and tell it we need more bytes
|
2008-09-05 09:07:46 +00:00
|
|
|
*/
|
|
|
|
pinfo->desegment_offset = loffset;
|
2008-11-23 14:18:07 +00:00
|
|
|
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
|
2008-09-05 09:07:46 +00:00
|
|
|
return;
|
2008-09-07 01:50:44 +00:00
|
|
|
} else {
|
2008-09-05 09:07:46 +00:00
|
|
|
linelen = tvb_length_remaining(tvb, loffset);
|
|
|
|
next_offset = loffset + linelen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
line = tvb_get_ptr(tvb, loffset, linelen);
|
2008-04-13 16:33:44 +00:00
|
|
|
|
2008-09-05 09:07:46 +00:00
|
|
|
/*
|
|
|
|
* Check whether or not this packet is an end of message packet
|
|
|
|
* We should look for CRLF.CRLF and they may be split.
|
|
|
|
* We have to keep in mind that we may see what we want on
|
|
|
|
* two passes through here ...
|
|
|
|
*/
|
2008-09-07 01:28:43 +00:00
|
|
|
if (session_state->smtp_state == READING_DATA) {
|
2008-09-05 09:07:46 +00:00
|
|
|
/*
|
|
|
|
* The order of these is important ... We want to avoid
|
|
|
|
* cases where there is a CRLF at the end of a packet and a
|
|
|
|
* .CRLF at the begining of the same packet.
|
|
|
|
*/
|
2008-09-07 01:28:43 +00:00
|
|
|
if ((session_state->crlf_seen && tvb_strneql(tvb, loffset, ".\r\n", 3) == 0) ||
|
2008-09-07 01:50:44 +00:00
|
|
|
tvb_strneql(tvb, loffset, "\r\n.\r\n", 5) == 0)
|
2008-09-05 09:07:46 +00:00
|
|
|
eom_seen = TRUE;
|
2000-08-24 11:32:09 +00:00
|
|
|
|
2008-09-05 09:07:46 +00:00
|
|
|
length_remaining = tvb_length_remaining(tvb, loffset);
|
|
|
|
if (length_remaining == tvb_reported_length_remaining(tvb, loffset) &&
|
2008-09-07 01:50:44 +00:00
|
|
|
tvb_strneql(tvb, loffset + length_remaining - 2, "\r\n", 2) == 0)
|
2008-09-07 01:28:43 +00:00
|
|
|
session_state->crlf_seen = TRUE;
|
2008-09-07 01:50:44 +00:00
|
|
|
else
|
2008-09-07 01:28:43 +00:00
|
|
|
session_state->crlf_seen = FALSE;
|
2008-09-05 09:07:46 +00:00
|
|
|
}
|
2000-08-24 11:32:09 +00:00
|
|
|
|
2008-09-05 09:07:46 +00:00
|
|
|
/*
|
|
|
|
* OK, Check if we have seen a DATA request. We do it here for
|
|
|
|
* simplicity, but we have to be careful below.
|
|
|
|
*/
|
|
|
|
if (request) {
|
2008-09-07 01:28:43 +00:00
|
|
|
if (session_state->smtp_state == READING_DATA) {
|
2008-09-05 09:07:46 +00:00
|
|
|
/*
|
|
|
|
* This is message data.
|
|
|
|
*/
|
|
|
|
if (eom_seen) { /* Seen the EOM */
|
|
|
|
/*
|
|
|
|
* EOM.
|
|
|
|
* Everything that comes after it is commands.
|
|
|
|
*/
|
2010-01-22 17:41:47 +00:00
|
|
|
spd_frame_data->pdu_type = SMTP_PDU_EOM;
|
2008-09-07 01:28:43 +00:00
|
|
|
session_state->smtp_state = READING_CMDS;
|
2008-09-05 09:07:46 +00:00
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Message data with no EOM.
|
|
|
|
*/
|
2010-01-22 17:41:47 +00:00
|
|
|
spd_frame_data->pdu_type = SMTP_PDU_MESSAGE;
|
2008-09-05 09:07:46 +00:00
|
|
|
|
2008-09-07 01:28:43 +00:00
|
|
|
if (session_state->msg_tot_len > 0) {
|
2008-09-05 09:07:46 +00:00
|
|
|
/*
|
|
|
|
* We are handling a BDAT message.
|
|
|
|
* Check if we have reached end of the data chunk.
|
|
|
|
*/
|
2008-09-07 01:28:43 +00:00
|
|
|
session_state->msg_read_len += tvb_length_remaining(tvb, loffset);
|
2008-09-05 09:07:46 +00:00
|
|
|
|
2008-09-07 01:28:43 +00:00
|
|
|
if (session_state->msg_read_len == session_state->msg_tot_len) {
|
2008-09-05 09:07:46 +00:00
|
|
|
/*
|
|
|
|
* We have reached end of BDAT data chunk.
|
|
|
|
* Everything that comes after this is commands.
|
|
|
|
*/
|
2008-09-07 01:28:43 +00:00
|
|
|
session_state->smtp_state = READING_CMDS;
|
2008-09-05 09:07:46 +00:00
|
|
|
|
2008-09-07 01:28:43 +00:00
|
|
|
if (session_state->msg_last) {
|
2008-09-05 09:07:46 +00:00
|
|
|
/*
|
|
|
|
* We have found the LAST data chunk.
|
|
|
|
* The message can now be reassembled.
|
|
|
|
*/
|
2010-01-22 17:41:47 +00:00
|
|
|
spd_frame_data->more_frags = FALSE;
|
2008-09-05 09:07:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break; /* no need to go through the remaining lines */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* This is commands - unless the capture started in the
|
|
|
|
* middle of a session, and we're in the middle of data.
|
2008-09-06 23:58:23 +00:00
|
|
|
*
|
|
|
|
* Commands are not necessarily 4 characters; look
|
|
|
|
* for a space or the end of the line to see where
|
|
|
|
* the putative command ends.
|
2008-09-05 09:07:46 +00:00
|
|
|
*/
|
2008-09-06 23:58:23 +00:00
|
|
|
linep = line;
|
|
|
|
lineend = line + linelen;
|
|
|
|
while (linep < lineend && (c = *linep) != ' ')
|
|
|
|
linep++;
|
2009-04-03 19:03:31 +00:00
|
|
|
cmdlen = (int)(linep - line);
|
2008-09-06 23:58:23 +00:00
|
|
|
if (line_is_smtp_command(line, cmdlen)) {
|
2008-09-05 09:07:46 +00:00
|
|
|
if (g_ascii_strncasecmp(line, "DATA", 4) == 0) {
|
|
|
|
/*
|
|
|
|
* DATA command.
|
|
|
|
* This is a command, but everything that comes after it,
|
|
|
|
* until an EOM, is data.
|
|
|
|
*/
|
2010-01-22 17:41:47 +00:00
|
|
|
spd_frame_data->pdu_type = SMTP_PDU_CMD;
|
2008-09-07 01:28:43 +00:00
|
|
|
session_state->smtp_state = READING_DATA;
|
|
|
|
session_state->data_seen = TRUE;
|
2008-09-05 09:07:46 +00:00
|
|
|
} else if (g_ascii_strncasecmp(line, "BDAT", 4) == 0) {
|
|
|
|
/*
|
|
|
|
* BDAT command.
|
|
|
|
* This is a command, but everything that comes after it,
|
|
|
|
* until given length is received, is data.
|
|
|
|
*/
|
|
|
|
guint32 msg_len;
|
|
|
|
|
|
|
|
msg_len = strtoul (line+5, NULL, 10);
|
|
|
|
|
2010-01-22 17:41:47 +00:00
|
|
|
spd_frame_data->pdu_type = SMTP_PDU_CMD;
|
2008-09-07 01:28:43 +00:00
|
|
|
session_state->data_seen = TRUE;
|
|
|
|
session_state->msg_tot_len += msg_len;
|
2008-09-05 09:07:46 +00:00
|
|
|
|
|
|
|
if (msg_len == 0) {
|
|
|
|
/* No data to read, next will be a command */
|
2008-09-07 01:28:43 +00:00
|
|
|
session_state->smtp_state = READING_CMDS;
|
2008-09-05 09:07:46 +00:00
|
|
|
} else {
|
2008-09-07 01:28:43 +00:00
|
|
|
session_state->smtp_state = READING_DATA;
|
2008-09-05 09:07:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (g_ascii_strncasecmp(line+linelen-4, "LAST", 4) == 0) {
|
|
|
|
/*
|
|
|
|
* This is the last data chunk.
|
|
|
|
*/
|
2008-09-07 01:28:43 +00:00
|
|
|
session_state->msg_last = TRUE;
|
2008-09-05 09:07:46 +00:00
|
|
|
|
|
|
|
if (msg_len == 0) {
|
|
|
|
/*
|
|
|
|
* No more data to expect.
|
|
|
|
* The message can now be reassembled.
|
|
|
|
*/
|
2010-01-22 17:41:47 +00:00
|
|
|
spd_frame_data->more_frags = FALSE;
|
2008-09-05 09:07:46 +00:00
|
|
|
}
|
|
|
|
} else {
|
2008-09-07 01:28:43 +00:00
|
|
|
session_state->msg_last = FALSE;
|
2008-09-05 09:07:46 +00:00
|
|
|
}
|
2008-11-23 14:18:07 +00:00
|
|
|
} else if (g_ascii_strncasecmp(line, "STARTTLS", 8) == 0) {
|
2008-09-07 01:28:43 +00:00
|
|
|
/*
|
|
|
|
* STARTTLS command.
|
|
|
|
* This is a command, but if the response is 220,
|
|
|
|
* everything after the response is TLS.
|
|
|
|
*/
|
|
|
|
session_state->smtp_state = AWAITING_STARTTLS_RESPONSE;
|
2010-01-22 17:41:47 +00:00
|
|
|
spd_frame_data->pdu_type = SMTP_PDU_CMD;
|
2008-09-05 09:07:46 +00:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Regular command.
|
|
|
|
*/
|
2010-01-22 17:41:47 +00:00
|
|
|
spd_frame_data->pdu_type = SMTP_PDU_CMD;
|
2008-09-05 09:07:46 +00:00
|
|
|
}
|
|
|
|
} else {
|
2008-09-06 23:58:23 +00:00
|
|
|
/*
|
|
|
|
* Assume it's message data.
|
|
|
|
*/
|
2010-01-22 17:41:47 +00:00
|
|
|
spd_frame_data->pdu_type = session_state->data_seen ? SMTP_PDU_MESSAGE : SMTP_PDU_CMD;
|
2008-09-05 09:07:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Simplify the state machine:
you're either reading commands, or you're reading message data;
if you're reading commands, and you see a DATA command, you
start reading data;
if you're reading data, and you see an EOM, you start reading
commands.
Also, *always* fill in the per-frame data you allocate for a frame, and
*always* attach it to the packet.
The old state machine assumed it was done with the SMTP conversation
once it saw an EOM, and the dissector wouldn't fill in the per-frame
data it'd allocated and attach it to the packet if it thought it was
done with the SMTP conversation. This meant that:
1) the per-frame data allocated for frames following the EOM
(e.g., a QUIT command) would contain random junk for data
such as the packet type;
2) that per-frame data would be re-allocated every time the
frame was looked at, as it wouldn't be attached to the frame,
so you might well get *different* random junk each time the
frame was looked at.
This caused Tethereal and Ethereal to sometimes fail to recognize
commands following the EOM - but it wouldn't *always* fail to do so,
sometimes it'd work and sometimes it wouldn't.
Fix a comment; conversations are *not* removed during filter operations,
and the visited flag is *not* cleared during a filter operation - that's
only true on a *redissection* operation. In any case, given that frames
can, after the initial sequential scan through the capture, be visited
in any order, and visited repeatedly, it's irrelevant whether
conversations are removed or not - we have to associate with each frame
information telling us how to process it.
svn path=/trunk/; revision=2608
2000-11-11 07:48:30 +00:00
|
|
|
|
2008-09-05 09:07:46 +00:00
|
|
|
/*
|
|
|
|
* Step past this line.
|
|
|
|
*/
|
|
|
|
loffset = next_offset;
|
|
|
|
}
|
2000-08-19 23:06:51 +00:00
|
|
|
}
|
|
|
|
|
2008-09-07 01:28:43 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/*
|
|
|
|
* From here, we simply add items to the tree and info to the info
|
2000-08-24 11:32:09 +00:00
|
|
|
* fields ...
|
|
|
|
*/
|
|
|
|
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMTP");
|
2000-08-19 23:06:51 +00:00
|
|
|
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO)) { /* Add the appropriate type here */
|
2008-04-13 16:33:44 +00:00
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2000-08-19 23:06:51 +00:00
|
|
|
|
2000-08-24 11:32:09 +00:00
|
|
|
/*
|
|
|
|
* If it is a request, we have to look things up, otherwise, just
|
2002-08-28 21:04:11 +00:00
|
|
|
* display the right things
|
2000-08-24 11:32:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
if (request) {
|
2008-09-05 09:07:46 +00:00
|
|
|
/* We must have frame_data here ... */
|
2010-01-22 17:41:47 +00:00
|
|
|
switch (spd_frame_data->pdu_type) {
|
2008-09-05 09:07:46 +00:00
|
|
|
case SMTP_PDU_MESSAGE:
|
2000-08-24 11:32:09 +00:00
|
|
|
|
2008-09-05 09:07:46 +00:00
|
|
|
length_remaining = tvb_length_remaining(tvb, offset);
|
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, smtp_data_desegment ? "C: DATA fragment" : "C: Message Body");
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, ", %d byte%s", length_remaining,
|
|
|
|
plurality (length_remaining, "", "s"));
|
|
|
|
break;
|
2000-08-24 11:32:09 +00:00
|
|
|
|
2008-09-05 09:07:46 +00:00
|
|
|
case SMTP_PDU_EOM:
|
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "C: .");
|
|
|
|
break;
|
2000-08-24 11:32:09 +00:00
|
|
|
|
2008-09-05 09:07:46 +00:00
|
|
|
case SMTP_PDU_CMD:
|
|
|
|
loffset = offset;
|
|
|
|
while (tvb_offset_exists(tvb, loffset)) {
|
|
|
|
/*
|
|
|
|
* Find the end of the line.
|
|
|
|
*/
|
|
|
|
linelen = tvb_find_line_end(tvb, loffset, -1, &next_offset, FALSE);
|
|
|
|
line = tvb_get_ptr(tvb, loffset, linelen);
|
2008-04-13 16:33:44 +00:00
|
|
|
|
2008-09-05 09:07:46 +00:00
|
|
|
if(loffset == offset)
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, "C: %s",
|
|
|
|
format_text(line, linelen));
|
|
|
|
else {
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, " | %s",
|
|
|
|
format_text(line, linelen));
|
|
|
|
}
|
2008-04-13 16:33:44 +00:00
|
|
|
|
2008-09-05 09:07:46 +00:00
|
|
|
loffset = next_offset;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-09-07 01:50:44 +00:00
|
|
|
} else {
|
|
|
|
loffset = offset;
|
|
|
|
while (tvb_offset_exists(tvb, loffset)) {
|
|
|
|
/*
|
|
|
|
* Find the end of the line.
|
|
|
|
*/
|
|
|
|
linelen = tvb_find_line_end(tvb, loffset, -1, &next_offset, FALSE);
|
|
|
|
line = tvb_get_ptr(tvb, loffset, linelen);
|
2000-08-24 11:32:09 +00:00
|
|
|
|
2008-09-07 01:50:44 +00:00
|
|
|
if (loffset == offset)
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, "S: %s",
|
|
|
|
format_text(line, linelen));
|
|
|
|
else {
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, " | %s",
|
|
|
|
format_text(line, linelen));
|
2008-09-05 09:07:46 +00:00
|
|
|
}
|
2008-09-07 01:50:44 +00:00
|
|
|
|
|
|
|
loffset = next_offset;
|
|
|
|
}
|
2000-08-24 11:32:09 +00:00
|
|
|
}
|
2000-08-19 23:06:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tree) { /* Build the tree info ... */
|
2002-01-24 09:20:54 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_smtp, tvb, offset, -1, FALSE);
|
2000-08-19 23:06:51 +00:00
|
|
|
smtp_tree = proto_item_add_subtree(ti, ett_smtp);
|
2008-09-07 01:28:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (request) {
|
2008-09-05 09:07:46 +00:00
|
|
|
/*
|
|
|
|
* Check out whether or not we can see a command in there ...
|
|
|
|
* What we are looking for is not data_seen and the word DATA
|
|
|
|
* and not eom_seen.
|
|
|
|
*
|
2008-09-07 01:28:43 +00:00
|
|
|
* We will see DATA and session_state->data_seen when we process the
|
2008-09-05 09:07:46 +00:00
|
|
|
* tree view after we have seen a DATA packet when processing
|
|
|
|
* the packet list pane.
|
|
|
|
*
|
|
|
|
* On the first pass, we will not have any info on the packets
|
|
|
|
* On second and subsequent passes, we will.
|
|
|
|
*/
|
2010-01-22 17:41:47 +00:00
|
|
|
switch (spd_frame_data->pdu_type) {
|
2008-09-05 09:07:46 +00:00
|
|
|
|
|
|
|
case SMTP_PDU_MESSAGE:
|
2008-09-07 01:50:44 +00:00
|
|
|
if (smtp_data_desegment) {
|
2010-01-22 17:41:47 +00:00
|
|
|
frag_msg = fragment_add_seq_next(tvb, 0, pinfo, spd_frame_data->conversation_id,
|
2008-09-07 01:50:44 +00:00
|
|
|
smtp_data_segment_table, smtp_data_reassembled_table,
|
2010-01-22 17:41:47 +00:00
|
|
|
tvb_length(tvb), spd_frame_data->more_frags);
|
2008-09-05 09:07:46 +00:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Message body.
|
|
|
|
* Put its lines into the protocol tree, a line at a time.
|
|
|
|
*/
|
|
|
|
dissect_smtp_data(tvb, offset, smtp_tree);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SMTP_PDU_EOM:
|
|
|
|
/*
|
|
|
|
* End-of-message-body indicator.
|
|
|
|
*
|
|
|
|
* XXX - what about stuff after the first line?
|
|
|
|
* Unlikely, as the client should wait for a response to the
|
|
|
|
* DATA command this terminates before sending another
|
|
|
|
* request, but we should probably handle it.
|
|
|
|
*/
|
|
|
|
proto_tree_add_text(smtp_tree, tvb, offset, linelen, "C: .");
|
|
|
|
|
2008-09-07 01:50:44 +00:00
|
|
|
if (smtp_data_desegment) {
|
2008-10-11 16:01:48 +00:00
|
|
|
/* add final data segment */
|
|
|
|
if (loffset)
|
2010-01-22 17:41:47 +00:00
|
|
|
fragment_add_seq_next(tvb, 0, pinfo, spd_frame_data->conversation_id,
|
2008-10-11 16:01:48 +00:00
|
|
|
smtp_data_segment_table, smtp_data_reassembled_table,
|
2010-01-22 17:41:47 +00:00
|
|
|
loffset, spd_frame_data->more_frags);
|
2008-10-11 16:01:48 +00:00
|
|
|
|
2008-09-05 09:07:46 +00:00
|
|
|
/* terminate the desegmentation */
|
2010-01-22 17:41:47 +00:00
|
|
|
frag_msg = fragment_end_seq_next (pinfo, spd_frame_data->conversation_id, smtp_data_segment_table,
|
2008-09-05 09:07:46 +00:00
|
|
|
smtp_data_reassembled_table);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SMTP_PDU_CMD:
|
|
|
|
/*
|
|
|
|
* Command.
|
|
|
|
*
|
|
|
|
* XXX - what about stuff after the first line?
|
|
|
|
* Unlikely, as the client should wait for a response to the
|
|
|
|
* previous command before sending another request, but we
|
|
|
|
* should probably handle it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
loffset = offset;
|
|
|
|
while (tvb_offset_exists(tvb, loffset)) {
|
|
|
|
/*
|
|
|
|
* Find the end of the line.
|
|
|
|
*/
|
|
|
|
linelen = tvb_find_line_end(tvb, loffset, -1, &next_offset, FALSE);
|
|
|
|
|
|
|
|
if (linelen >= 4)
|
|
|
|
cmdlen = 4;
|
|
|
|
else
|
|
|
|
cmdlen = linelen;
|
|
|
|
hidden_item = proto_tree_add_boolean(smtp_tree, hf_smtp_req, tvb,
|
|
|
|
0, 0, TRUE);
|
|
|
|
PROTO_ITEM_SET_HIDDEN(hidden_item);
|
2008-09-07 01:50:44 +00:00
|
|
|
|
2008-09-05 09:07:46 +00:00
|
|
|
/*
|
|
|
|
* Put the command line into the protocol tree.
|
|
|
|
*/
|
|
|
|
ti = proto_tree_add_text(smtp_tree, tvb, loffset, next_offset - loffset,
|
|
|
|
"Command: %s",
|
|
|
|
tvb_format_text(tvb, loffset, next_offset - loffset));
|
|
|
|
cmdresp_tree = proto_item_add_subtree(ti, ett_smtp_cmdresp);
|
|
|
|
|
|
|
|
proto_tree_add_item(cmdresp_tree, hf_smtp_req_command, tvb,
|
|
|
|
loffset, cmdlen, FALSE);
|
|
|
|
if (linelen > 5) {
|
|
|
|
proto_tree_add_item(cmdresp_tree, hf_smtp_req_parameter, tvb,
|
|
|
|
loffset + 5, linelen - 5, FALSE);
|
|
|
|
}
|
|
|
|
|
2010-01-22 17:41:47 +00:00
|
|
|
if (smtp_data_desegment && !spd_frame_data->more_frags) {
|
2008-09-05 09:07:46 +00:00
|
|
|
/* terminate the desegmentation */
|
2010-01-22 17:41:47 +00:00
|
|
|
frag_msg = fragment_end_seq_next (pinfo, spd_frame_data->conversation_id, smtp_data_segment_table,
|
2008-09-05 09:07:46 +00:00
|
|
|
smtp_data_reassembled_table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Step past this line.
|
|
|
|
*/
|
|
|
|
loffset = next_offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (smtp_data_desegment) {
|
2008-09-07 01:50:44 +00:00
|
|
|
next_tvb = process_reassembled_data(tvb, offset, pinfo, "Reassembled DATA",
|
|
|
|
frag_msg, &smtp_data_frag_items, NULL, smtp_tree);
|
2008-09-05 09:07:46 +00:00
|
|
|
if (next_tvb) {
|
|
|
|
/* XXX: this is presumptious - we may have negotiated something else */
|
2008-09-07 01:50:44 +00:00
|
|
|
if (imf_handle) {
|
2008-09-05 09:07:46 +00:00
|
|
|
call_dissector(imf_handle, next_tvb, pinfo, tree);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Message body.
|
|
|
|
* Put its lines into the protocol tree, a line at a time.
|
|
|
|
*/
|
|
|
|
dissect_smtp_data(tvb, offset, smtp_tree);
|
|
|
|
}
|
|
|
|
|
|
|
|
pinfo->fragmented = FALSE;
|
|
|
|
} else {
|
|
|
|
pinfo->fragmented = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2008-09-07 01:50:44 +00:00
|
|
|
} else {
|
2008-09-07 01:28:43 +00:00
|
|
|
/*
|
|
|
|
* Process the response, a line at a time, until we hit a line
|
|
|
|
* that doesn't have a continuation indication on it.
|
|
|
|
*/
|
|
|
|
if (tree) {
|
2008-09-05 09:07:46 +00:00
|
|
|
hidden_item = proto_tree_add_boolean(smtp_tree, hf_smtp_rsp, tvb,
|
2008-09-07 01:28:43 +00:00
|
|
|
0, 0, TRUE);
|
2008-09-05 09:07:46 +00:00
|
|
|
PROTO_ITEM_SET_HIDDEN(hidden_item);
|
2008-09-07 01:28:43 +00:00
|
|
|
}
|
2008-09-05 09:07:46 +00:00
|
|
|
|
2008-09-07 01:28:43 +00:00
|
|
|
while (tvb_offset_exists(tvb, offset)) {
|
|
|
|
/*
|
|
|
|
* Find the end of the line.
|
|
|
|
*/
|
|
|
|
linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
|
2008-09-05 09:07:46 +00:00
|
|
|
|
2008-09-07 01:28:43 +00:00
|
|
|
if (tree) {
|
2008-09-05 09:07:46 +00:00
|
|
|
/*
|
|
|
|
* Put it into the protocol tree.
|
|
|
|
*/
|
|
|
|
ti = proto_tree_add_text(smtp_tree, tvb, offset,
|
|
|
|
next_offset - offset, "Response: %s",
|
|
|
|
tvb_format_text(tvb, offset,
|
|
|
|
next_offset - offset));
|
|
|
|
cmdresp_tree = proto_item_add_subtree(ti, ett_smtp_cmdresp);
|
2008-09-07 01:28:43 +00:00
|
|
|
} else
|
|
|
|
cmdresp_tree = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Is it a continuation line?
|
|
|
|
*/
|
|
|
|
is_continuation_line =
|
|
|
|
(linelen >= 4 && tvb_get_guint8(tvb, offset + 3) == '-');
|
2008-09-05 09:07:46 +00:00
|
|
|
|
2008-09-07 01:28:43 +00:00
|
|
|
line = tvb_get_ptr(tvb, offset, linelen);
|
|
|
|
if (linelen >= 3 && isdigit(line[0]) && isdigit(line[1])
|
|
|
|
&& isdigit(line[2])) {
|
2008-09-05 09:07:46 +00:00
|
|
|
/*
|
2008-09-07 01:28:43 +00:00
|
|
|
* We have a 3-digit response code.
|
2008-09-05 09:07:46 +00:00
|
|
|
*/
|
2008-09-07 01:28:43 +00:00
|
|
|
code = (line[0] - '0')*100 + (line[1] - '0')*10 + (line[2] - '0');
|
2008-09-05 09:07:46 +00:00
|
|
|
|
|
|
|
/*
|
2008-09-07 01:28:43 +00:00
|
|
|
* If we're awaiting the response to a STARTTLS code, this
|
|
|
|
* is it - if it's 220, all subsequent traffic will
|
|
|
|
* be TLS, otherwise we're back to boring old SMTP.
|
2008-09-05 09:07:46 +00:00
|
|
|
*/
|
2008-09-07 01:28:43 +00:00
|
|
|
if (session_state->smtp_state == AWAITING_STARTTLS_RESPONSE) {
|
|
|
|
if (code == 220) {
|
|
|
|
/* This is the last non-TLS frame. */
|
|
|
|
session_state->last_nontls_frame = pinfo->fd->num;
|
|
|
|
session_state->smtp_state = READING_DATA;
|
|
|
|
} else
|
|
|
|
session_state->smtp_state = READING_CMDS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tree) {
|
2008-09-05 09:07:46 +00:00
|
|
|
/*
|
2008-09-07 01:28:43 +00:00
|
|
|
* Put the response code and parameters into the protocol tree.
|
2008-09-05 09:07:46 +00:00
|
|
|
*/
|
|
|
|
proto_tree_add_uint(cmdresp_tree, hf_smtp_rsp_code, tvb, offset, 3,
|
|
|
|
code);
|
|
|
|
|
|
|
|
if (linelen >= 4) {
|
|
|
|
proto_tree_add_item(cmdresp_tree, hf_smtp_rsp_parameter, tvb,
|
|
|
|
offset + 4, linelen - 4, FALSE);
|
|
|
|
}
|
|
|
|
}
|
2008-09-07 08:44:47 +00:00
|
|
|
}
|
2008-09-05 09:07:46 +00:00
|
|
|
|
2008-09-07 08:44:47 +00:00
|
|
|
/*
|
|
|
|
* Step past this line.
|
|
|
|
*/
|
|
|
|
offset = next_offset;
|
2008-09-05 09:07:46 +00:00
|
|
|
|
2008-09-07 08:44:47 +00:00
|
|
|
/*
|
|
|
|
* If it's not a continuation line, quit.
|
|
|
|
*/
|
|
|
|
/* if (!is_continuation_line)
|
|
|
|
break; */
|
2000-08-19 23:06:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-04 16:16:32 +00:00
|
|
|
static void smtp_data_reassemble_init (void)
|
|
|
|
{
|
|
|
|
fragment_table_init (&smtp_data_segment_table);
|
|
|
|
reassembled_table_init (&smtp_data_reassembled_table);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-19 23:06:51 +00:00
|
|
|
/* Register all the bits needed by the filtering engine */
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_smtp(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_smtp_req,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
{ "Request", "smtp.req", FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
2000-08-19 23:06:51 +00:00
|
|
|
|
|
|
|
{ &hf_smtp_rsp,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
{ "Response", "smtp.rsp", FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
2002-07-14 00:40:07 +00:00
|
|
|
|
|
|
|
{ &hf_smtp_req_command,
|
|
|
|
{ "Command", "smtp.req.command", FT_STRING, BASE_NONE, NULL, 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }},
|
2002-07-14 00:40:07 +00:00
|
|
|
|
|
|
|
{ &hf_smtp_req_parameter,
|
|
|
|
{ "Request parameter", "smtp.req.parameter", FT_STRING, BASE_NONE, NULL, 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }},
|
2002-07-14 00:40:07 +00:00
|
|
|
|
|
|
|
{ &hf_smtp_rsp_code,
|
2009-12-18 04:04:15 +00:00
|
|
|
{ "Response code", "smtp.response.code", FT_UINT32, BASE_DEC, VALS(response_codes_vs), 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }},
|
2002-07-14 00:40:07 +00:00
|
|
|
|
|
|
|
{ &hf_smtp_rsp_parameter,
|
|
|
|
{ "Response parameter", "smtp.rsp.parameter", FT_STRING, BASE_NONE, NULL, 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }},
|
2007-07-04 16:16:32 +00:00
|
|
|
|
|
|
|
/* Fragment entries */
|
|
|
|
{ &hf_smtp_data_fragments,
|
|
|
|
{ "DATA fragments", "smtp.data.fragments", FT_NONE, BASE_NONE,
|
|
|
|
NULL, 0x00, "Message fragments", HFILL } },
|
|
|
|
{ &hf_smtp_data_fragment,
|
|
|
|
{ "DATA fragment", "smtp.data.fragment", FT_FRAMENUM, BASE_NONE,
|
|
|
|
NULL, 0x00, "Message fragment", HFILL } },
|
|
|
|
{ &hf_smtp_data_fragment_overlap,
|
|
|
|
{ "DATA fragment overlap", "smtp.data.fragment.overlap", FT_BOOLEAN,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
BASE_NONE, NULL, 0x0, "Message fragment overlap", HFILL } },
|
2007-07-04 16:16:32 +00:00
|
|
|
{ &hf_smtp_data_fragment_overlap_conflicts,
|
|
|
|
{ "DATA fragment overlapping with conflicting data",
|
|
|
|
"smtp.data.fragment.overlap.conflicts", FT_BOOLEAN, BASE_NONE, NULL,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
0x0, "Message fragment overlapping with conflicting data", HFILL } },
|
2007-07-04 16:16:32 +00:00
|
|
|
{ &hf_smtp_data_fragment_multiple_tails,
|
|
|
|
{ "DATA has multiple tail fragments",
|
|
|
|
"smtp.data.fragment.multiple_tails", FT_BOOLEAN, BASE_NONE,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, 0x0, "Message has multiple tail fragments", HFILL } },
|
2007-07-04 16:16:32 +00:00
|
|
|
{ &hf_smtp_data_fragment_too_long_fragment,
|
|
|
|
{ "DATA fragment too long", "smtp.data.fragment.too_long_fragment",
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
FT_BOOLEAN, BASE_NONE, NULL, 0x0, "Message fragment too long",
|
2007-07-04 16:16:32 +00:00
|
|
|
HFILL } },
|
|
|
|
{ &hf_smtp_data_fragment_error,
|
|
|
|
{ "DATA defragmentation error", "smtp.data.fragment.error", FT_FRAMENUM,
|
|
|
|
BASE_NONE, NULL, 0x00, "Message defragmentation error", HFILL } },
|
|
|
|
{ &hf_smtp_data_reassembled_in,
|
|
|
|
{ "Reassembled DATA in frame", "smtp.data.reassembled.in", FT_FRAMENUM, BASE_NONE,
|
|
|
|
NULL, 0x00, "This DATA fragment is reassembled in this frame", HFILL } },
|
2000-08-19 23:06:51 +00:00
|
|
|
};
|
|
|
|
static gint *ett[] = {
|
2003-06-11 18:22:12 +00:00
|
|
|
&ett_smtp,
|
|
|
|
&ett_smtp_cmdresp,
|
2007-07-04 16:16:32 +00:00
|
|
|
&ett_smtp_data_fragment,
|
|
|
|
&ett_smtp_data_fragments,
|
|
|
|
|
2000-08-19 23:06:51 +00:00
|
|
|
};
|
2002-07-17 06:55:29 +00:00
|
|
|
module_t *smtp_module;
|
2000-08-19 23:06:51 +00:00
|
|
|
|
2001-01-03 06:56:03 +00:00
|
|
|
proto_smtp = proto_register_protocol("Simple Mail Transfer Protocol",
|
|
|
|
"SMTP", "smtp");
|
2000-08-19 23:06:51 +00:00
|
|
|
|
|
|
|
proto_register_field_array(proto_smtp, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2007-07-04 16:16:32 +00:00
|
|
|
register_init_routine (&smtp_data_reassemble_init);
|
2000-08-19 23:06:51 +00:00
|
|
|
|
2006-10-25 16:46:27 +00:00
|
|
|
/* Allow dissector to find be found by name. */
|
|
|
|
register_dissector("smtp", dissect_smtp, proto_smtp);
|
|
|
|
|
|
|
|
/* Preferences */
|
2002-07-17 06:55:29 +00:00
|
|
|
smtp_module = prefs_register_protocol(proto_smtp, NULL);
|
|
|
|
prefs_register_bool_preference(smtp_module, "desegment_lines",
|
2004-08-21 09:02:52 +00:00
|
|
|
"Reassemble SMTP command and response lines\nspanning multiple TCP segments",
|
|
|
|
"Whether the SMTP dissector should reassemble command and response lines spanning multiple TCP segments."
|
|
|
|
" To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
|
2002-07-17 06:55:29 +00:00
|
|
|
&smtp_desegment);
|
2007-07-04 16:16:32 +00:00
|
|
|
|
|
|
|
prefs_register_bool_preference(smtp_module, "desegment_data",
|
|
|
|
"Reassemble SMTP DATA commands spanning multiple TCP segments",
|
|
|
|
"Whether the SMTP dissector should reassemble DATA command and lines spanning multiple TCP segments."
|
|
|
|
" To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
|
|
|
|
&smtp_data_desegment);
|
|
|
|
|
2000-08-19 23:06:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The registration hand-off routine */
|
|
|
|
void
|
|
|
|
proto_reg_handoff_smtp(void)
|
|
|
|
{
|
2003-09-16 17:42:01 +00:00
|
|
|
dissector_handle_t smtp_handle;
|
2000-08-19 23:06:51 +00:00
|
|
|
|
2008-09-30 14:49:44 +00:00
|
|
|
smtp_handle = find_dissector("smtp");
|
2003-09-16 17:42:01 +00:00
|
|
|
dissector_add("tcp.port", TCP_PORT_SMTP, smtp_handle);
|
2010-01-10 19:39:35 +00:00
|
|
|
ssl_dissector_add(TCP_PORT_SSL_SMTP, "smtp", TRUE);
|
2007-12-28 09:09:09 +00:00
|
|
|
dissector_add("tcp.port", TCP_PORT_SUBMISSION, smtp_handle);
|
2007-07-04 16:16:32 +00:00
|
|
|
|
|
|
|
/* find the IMF dissector */
|
|
|
|
imf_handle = find_dissector("imf");
|
|
|
|
|
2008-09-07 01:28:43 +00:00
|
|
|
/* find the SSL dissector */
|
|
|
|
ssl_handle = find_dissector("ssl");
|
2000-08-19 23:06:51 +00:00
|
|
|
}
|