2001-12-08 01:45:36 +00:00
|
|
|
/* packet-beep.c
|
|
|
|
* Routines for BEEP packet disassembly
|
2000-08-30 12:42:31 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) 2000 by Richard Sharpe <rsharpe@ns.aus.com>
|
2001-12-08 01:45:36 +00:00
|
|
|
* Modified 2001 Darren New <dnew@invisible.net> for BEEP.
|
2000-08-30 12:42:31 +00:00
|
|
|
*
|
2001-12-08 01:45:36 +00:00
|
|
|
* Original BXXP dissector developed with funding from InvisibleWorlds
|
|
|
|
* (www.invisibleworlds.com) via Collab.Net.
|
2000-10-09 03:36:15 +00:00
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
2000-08-30 12:42:31 +00:00
|
|
|
* By Gerald Combs
|
|
|
|
* Copyright 1999 Gerald Combs
|
2001-12-08 01:45:36 +00:00
|
|
|
*
|
2000-08-30 12:42:31 +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
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2000-08-30 12:42:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2016-07-12 17:18:05 +00:00
|
|
|
#include <stdlib.h>
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
2004-09-27 22:55:15 +00:00
|
|
|
#include <epan/prefs.h>
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/conversation.h>
|
2013-02-23 03:48:04 +00:00
|
|
|
#include <epan/expert.h>
|
2016-01-25 01:10:20 +00:00
|
|
|
#include <epan/proto_data.h>
|
2016-07-24 12:53:39 +00:00
|
|
|
#if defined(DEBUG_BEEP_HASH)
|
|
|
|
#include <wsutil/ws_printf.h> /* ws_debug_printf */
|
|
|
|
#endif
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
#define TCP_PORT_BEEP 10288 /* Don't think this is IANA registered */
|
2013-03-14 19:01:06 +00:00
|
|
|
|
|
|
|
void proto_register_beep(void);
|
2001-12-08 01:45:36 +00:00
|
|
|
void proto_reg_handoff_beep(void);
|
|
|
|
|
2005-07-09 00:53:17 +00:00
|
|
|
static guint global_beep_tcp_port = TCP_PORT_BEEP;
|
2001-12-08 01:45:36 +00:00
|
|
|
static int global_beep_strict_term = TRUE;
|
|
|
|
|
|
|
|
static int proto_beep = -1;
|
|
|
|
|
|
|
|
static int hf_beep_req = -1;
|
2013-02-23 03:48:04 +00:00
|
|
|
static int hf_beep_cmd = -1;
|
2001-12-08 01:45:36 +00:00
|
|
|
static int hf_beep_req_chan = -1;
|
2013-01-31 17:55:31 +00:00
|
|
|
/* static int hf_beep_rsp_chan = -1; */
|
2001-12-08 01:45:36 +00:00
|
|
|
static int hf_beep_seq_chan = -1;
|
2013-01-31 17:55:31 +00:00
|
|
|
/* static int hf_beep_rsp = -1; */
|
2013-02-23 03:48:04 +00:00
|
|
|
static int hf_beep_more = -1;
|
2001-12-08 01:45:36 +00:00
|
|
|
static int hf_beep_msgno = -1;
|
|
|
|
static int hf_beep_ansno = -1;
|
|
|
|
static int hf_beep_seqno = -1;
|
|
|
|
static int hf_beep_size = -1;
|
|
|
|
static int hf_beep_channel = -1;
|
2013-02-23 03:48:04 +00:00
|
|
|
static int hf_beep_mime_header = -1;
|
|
|
|
static int hf_beep_header = -1;
|
2013-01-31 17:55:31 +00:00
|
|
|
#if 0
|
2013-02-23 03:48:04 +00:00
|
|
|
static int hf_beep_status = -1;
|
2013-01-31 17:55:31 +00:00
|
|
|
#endif
|
2001-12-08 01:45:36 +00:00
|
|
|
static int hf_beep_ackno = -1;
|
|
|
|
static int hf_beep_window = -1;
|
2013-02-23 03:48:04 +00:00
|
|
|
static int hf_beep_payload = -1;
|
|
|
|
static int hf_beep_payload_undissected = -1;
|
2014-09-11 00:04:22 +00:00
|
|
|
static int hf_beep_crlf_terminator = -1;
|
2013-02-23 03:48:04 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
static const value_string beep_status_vals[] = {
|
|
|
|
{ '+', "Positive" },
|
|
|
|
{ '-', "Negative" },
|
|
|
|
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static const value_string beep_more_vals[] = {
|
|
|
|
{ '.', "Complete" },
|
|
|
|
{ '*', "Intermediate" },
|
|
|
|
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
/* Arrays of hf entry pointers for some routines to use. If you want more
|
2002-08-28 21:04:11 +00:00
|
|
|
* hidden items added for a field, add them to the list before the NULL,
|
2000-10-02 01:44:58 +00:00
|
|
|
* and the various routines that these are passed to will add them.
|
|
|
|
*/
|
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
static int *req_msgno_hfa[] = { &hf_beep_msgno, NULL };
|
|
|
|
static int *req_ansno_hfa[] = { &hf_beep_ansno, NULL };
|
|
|
|
static int *req_seqno_hfa[] = { &hf_beep_seqno, NULL };
|
|
|
|
static int *req_size_hfa[] = { &hf_beep_size, NULL };
|
|
|
|
static int *req_chan_hfa[] = { &hf_beep_channel, &hf_beep_req_chan, NULL };
|
|
|
|
/*
|
|
|
|
static int *rsp_msgno_hfa[] = { &hf_beep_msgno, NULL };
|
|
|
|
static int *rsp_seqno_hfa[] = { &hf_beep_seqno, NULL };
|
|
|
|
static int *rsp_size_hfa[] = { &hf_beep_size, NULL };
|
|
|
|
*/
|
|
|
|
static int *seq_chan_hfa[] = { &hf_beep_channel, &hf_beep_seq_chan, NULL };
|
|
|
|
static int *seq_ackno_hfa[] = { &hf_beep_ackno, NULL };
|
|
|
|
static int *seq_window_hfa[] = { &hf_beep_window, NULL };
|
|
|
|
|
|
|
|
static int ett_beep = -1;
|
2000-08-30 12:42:31 +00:00
|
|
|
static int ett_mime_header = -1;
|
|
|
|
static int ett_header = -1;
|
|
|
|
static int ett_trailer = -1;
|
|
|
|
|
2013-06-09 03:28:05 +00:00
|
|
|
static expert_field ei_beep_more = EI_INIT;
|
|
|
|
static expert_field ei_beep_cr_terminator = EI_INIT;
|
|
|
|
static expert_field ei_beep_lf_terminator = EI_INIT;
|
|
|
|
static expert_field ei_beep_invalid_terminator = EI_INIT;
|
|
|
|
|
2000-08-30 12:42:31 +00:00
|
|
|
/* Get the state of the more flag ... */
|
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
#define BEEP_VIOL 0
|
|
|
|
#define BEEP_INTERMEDIATE 1
|
|
|
|
#define BEEP_COMPLETE 2
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-09-08 06:19:37 +00:00
|
|
|
/*
|
|
|
|
* Per-frame data
|
2000-09-12 02:24:19 +00:00
|
|
|
*
|
|
|
|
* pl_left is the amount of data in this packet that belongs to another
|
|
|
|
* frame ...
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2000-09-12 02:24:19 +00:00
|
|
|
* It relies on TCP segments not being re-ordered too much ...
|
2000-09-08 06:19:37 +00:00
|
|
|
*/
|
2001-12-08 01:45:36 +00:00
|
|
|
struct beep_proto_data {
|
2000-09-12 02:24:19 +00:00
|
|
|
int pl_left; /* Payload at beginning of frame */
|
|
|
|
int pl_size; /* Payload in current message ...*/
|
2002-08-28 21:04:11 +00:00
|
|
|
int mime_hdr; /* Whether we expect a mime header. 1 on first, 0 on rest
|
2009-09-30 19:33:39 +00:00
|
|
|
* in a message
|
|
|
|
*/
|
2000-09-08 06:19:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Conversation stuff
|
|
|
|
*/
|
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
struct beep_request_key {
|
2000-09-08 06:19:37 +00:00
|
|
|
guint32 conversation;
|
|
|
|
};
|
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
struct beep_request_val {
|
2000-09-08 06:19:37 +00:00
|
|
|
guint16 processed; /* Have we processed this conversation? */
|
2000-09-12 02:24:19 +00:00
|
|
|
int size; /* Size of the message */
|
2000-10-05 13:13:49 +00:00
|
|
|
/* We need an indication in each dirn of
|
2009-09-30 19:33:39 +00:00
|
|
|
* whether on not a mime header is expected
|
|
|
|
*/
|
2000-10-05 13:13:49 +00:00
|
|
|
int c_mime_hdr, s_mime_hdr;
|
2000-09-08 06:19:37 +00:00
|
|
|
};
|
|
|
|
|
2002-04-08 02:13:36 +00:00
|
|
|
static GHashTable *beep_request_hash = NULL;
|
2000-09-08 06:19:37 +00:00
|
|
|
|
|
|
|
/* Hash Functions */
|
2001-04-27 01:27:37 +00:00
|
|
|
static gint
|
2001-12-08 01:45:36 +00:00
|
|
|
beep_equal(gconstpointer v, gconstpointer w)
|
2000-09-08 06:19:37 +00:00
|
|
|
{
|
2002-11-28 03:57:50 +00:00
|
|
|
const struct beep_request_key *v1 = (const struct beep_request_key *)v;
|
|
|
|
const struct beep_request_key *v2 = (const struct beep_request_key *)w;
|
2000-09-08 06:19:37 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
#if defined(DEBUG_BEEP_HASH)
|
2016-07-24 12:53:39 +00:00
|
|
|
ws_debug_printf("Comparing %08X\n and %08X\n",
|
2009-09-30 19:33:39 +00:00
|
|
|
v1->conversation, v2->conversation);
|
2000-09-08 06:19:37 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (v1->conversation == v2->conversation)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static guint
|
2001-12-08 01:45:36 +00:00
|
|
|
beep_hash(gconstpointer v)
|
2000-09-08 06:19:37 +00:00
|
|
|
{
|
2002-11-28 03:57:50 +00:00
|
|
|
const struct beep_request_key *key = (const struct beep_request_key *)v;
|
2000-09-08 06:19:37 +00:00
|
|
|
guint val;
|
|
|
|
|
|
|
|
val = key->conversation;
|
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
#if defined(DEBUG_BEEP_HASH)
|
2016-07-24 12:53:39 +00:00
|
|
|
ws_debug_printf("BEEP Hash calculated as %u\n", val);
|
2000-09-08 06:19:37 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return val;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-12-08 01:45:36 +00:00
|
|
|
beep_init_protocol(void)
|
2000-09-08 06:19:37 +00:00
|
|
|
{
|
2001-12-08 01:45:36 +00:00
|
|
|
beep_request_hash = g_hash_table_new(beep_hash, beep_equal);
|
2000-09-08 06:19:37 +00:00
|
|
|
}
|
|
|
|
|
2015-06-28 13:15:07 +00:00
|
|
|
static void
|
|
|
|
beep_cleanup_protocol(void)
|
|
|
|
{
|
|
|
|
g_hash_table_destroy(beep_request_hash);
|
|
|
|
}
|
|
|
|
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-10-05 13:13:49 +00:00
|
|
|
/* dissect the more flag, and return a value of:
|
|
|
|
* 1 -> more
|
|
|
|
* 0 -> no more
|
|
|
|
* -1 -> Proto violation
|
|
|
|
*/
|
|
|
|
|
2001-04-27 01:27:37 +00:00
|
|
|
static int
|
2013-02-23 03:48:04 +00:00
|
|
|
dissect_beep_more(tvbuff_t *tvb, packet_info *pinfo, int offset,
|
2009-09-30 19:33:39 +00:00
|
|
|
proto_tree *tree)
|
2000-08-30 12:42:31 +00:00
|
|
|
{
|
2008-05-09 13:59:10 +00:00
|
|
|
proto_item *hidden_item;
|
2008-02-07 15:44:45 +00:00
|
|
|
int ret = 0;
|
2013-02-23 03:48:04 +00:00
|
|
|
guint8 more = tvb_get_guint8(tvb, offset);
|
|
|
|
|
2016-09-19 01:48:50 +00:00
|
|
|
hidden_item = proto_tree_add_item(tree, hf_beep_more, tvb, offset, 1, ENC_ASCII|ENC_NA);
|
2013-02-23 03:48:04 +00:00
|
|
|
PROTO_ITEM_SET_HIDDEN(hidden_item);
|
|
|
|
|
|
|
|
switch(more) {
|
|
|
|
case '.':
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
case '*':
|
|
|
|
ret = 1;
|
|
|
|
break;
|
2002-08-28 21:04:11 +00:00
|
|
|
default:
|
2013-06-09 03:28:05 +00:00
|
|
|
expert_add_info(pinfo, hidden_item, &ei_beep_more);
|
2008-02-07 15:44:45 +00:00
|
|
|
ret = -1;
|
2000-08-30 12:42:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-02-07 15:44:45 +00:00
|
|
|
return ret;
|
2000-08-30 12:42:31 +00:00
|
|
|
}
|
|
|
|
|
2003-07-25 04:17:37 +00:00
|
|
|
#if 0
|
2002-04-08 02:13:36 +00:00
|
|
|
static void dissect_beep_status(tvbuff_t *tvb, int offset,
|
2009-09-30 19:33:39 +00:00
|
|
|
proto_tree *tree)
|
2000-08-30 12:42:31 +00:00
|
|
|
{
|
2000-10-02 01:44:58 +00:00
|
|
|
|
|
|
|
/* FIXME: We should return a value to indicate all OK. */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2014-12-13 21:26:07 +00:00
|
|
|
proto_tree_add_item(item_tree, hf_beep_status, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2000-08-30 12:42:31 +00:00
|
|
|
}
|
2003-07-25 04:17:37 +00:00
|
|
|
#endif
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2001-04-27 01:27:37 +00:00
|
|
|
static int num_len(tvbuff_t *tvb, int offset)
|
2000-08-30 12:42:31 +00:00
|
|
|
{
|
2001-04-27 01:27:37 +00:00
|
|
|
unsigned int i = 0;
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2014-10-20 06:14:50 +00:00
|
|
|
while (g_ascii_isdigit(tvb_get_guint8(tvb, offset + i))) i++;
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
return i;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-10-03 10:59:10 +00:00
|
|
|
/*
|
|
|
|
* We check for a terminator. This can be CRLF, which will be recorded
|
|
|
|
* as a terminator, or CR or LF by itself, which will be redorded as
|
|
|
|
* an incorrect terminator ... We build the tree at this point
|
2001-12-08 01:45:36 +00:00
|
|
|
* However, we depend on the variable beep_strict_term
|
2002-08-28 21:04:11 +00:00
|
|
|
*/
|
2000-10-03 10:59:10 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static int
|
2013-02-23 03:48:04 +00:00
|
|
|
check_term(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree)
|
2000-10-03 10:59:10 +00:00
|
|
|
{
|
2002-08-28 21:04:11 +00:00
|
|
|
/* First, check for CRLF, or, if global_beep_strict_term is false,
|
2000-10-03 10:59:10 +00:00
|
|
|
* one of CR or LF ... If neither of these hold, we add an element
|
|
|
|
* that complains of a protocol violation, and return -1, else
|
|
|
|
* we add a terminator to the tree (possibly non-standard) and return
|
2002-08-28 21:04:11 +00:00
|
|
|
* the count of characters we saw ... This may throw off the rest of the
|
2000-10-03 10:59:10 +00:00
|
|
|
* dissection ... so-be-it!
|
|
|
|
*/
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
if ((tvb_get_guint8(tvb, offset) == 0x0d &&
|
2000-10-03 10:59:10 +00:00
|
|
|
tvb_get_guint8(tvb, offset + 1) == 0x0a)){ /* Correct terminator */
|
|
|
|
|
2014-09-11 00:04:22 +00:00
|
|
|
proto_tree_add_item(tree, hf_beep_crlf_terminator, tvb, offset, 2, ENC_NA);
|
2000-10-03 10:59:10 +00:00
|
|
|
return 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-02-23 03:48:04 +00:00
|
|
|
if ((tvb_get_guint8(tvb, offset) == 0x0d) && !global_beep_strict_term) {
|
2000-10-03 10:59:10 +00:00
|
|
|
|
2013-07-03 02:59:31 +00:00
|
|
|
proto_tree_add_expert(tree, pinfo, &ei_beep_cr_terminator, tvb, offset, 1);
|
2000-10-03 10:59:10 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
2013-10-13 19:56:52 +00:00
|
|
|
|
2013-02-23 03:48:04 +00:00
|
|
|
if ((tvb_get_guint8(tvb, offset) == 0x0a) && !global_beep_strict_term) {
|
2000-10-03 10:59:10 +00:00
|
|
|
|
2013-07-03 02:59:31 +00:00
|
|
|
proto_tree_add_expert(tree, pinfo, &ei_beep_lf_terminator, tvb, offset, 1);
|
2013-02-23 03:48:04 +00:00
|
|
|
return 1;
|
2000-10-03 10:59:10 +00:00
|
|
|
}
|
|
|
|
|
2013-10-13 19:56:52 +00:00
|
|
|
proto_tree_add_expert_format(tree, pinfo, &ei_beep_invalid_terminator, tvb,
|
2013-07-03 02:59:31 +00:00
|
|
|
offset, 1, "Terminator: %s", tvb_format_text(tvb, offset, 2));
|
2013-02-23 03:48:04 +00:00
|
|
|
return -1;
|
2000-10-03 10:59:10 +00:00
|
|
|
}
|
|
|
|
|
2000-10-05 13:13:49 +00:00
|
|
|
/* Get the header length, up to CRLF or CR or LF */
|
2001-04-27 01:27:37 +00:00
|
|
|
static int header_len(tvbuff_t *tvb, int offset)
|
2000-08-30 12:42:31 +00:00
|
|
|
{
|
|
|
|
int i = 0;
|
2000-10-03 10:59:10 +00:00
|
|
|
guint8 sc;
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-10-03 10:59:10 +00:00
|
|
|
/* FIXME: Have to make sure we stop looking at the end of the tvb ... */
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* We look for CRLF, or CR or LF if global_beep_strict_term is
|
2000-10-03 10:59:10 +00:00
|
|
|
* not set.
|
|
|
|
*/
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-10-03 10:59:10 +00:00
|
|
|
while (1) {
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
if ((sc = tvb_get_guint8(tvb, offset + i)) == 0x0d
|
2009-09-30 19:33:39 +00:00
|
|
|
&& tvb_get_guint8(tvb, offset + i + 1) == 0x0a)
|
2000-10-03 10:59:10 +00:00
|
|
|
return i; /* Done here ... */
|
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
if (!global_beep_strict_term && (sc == 0x0d || sc == 0x0a))
|
2000-10-03 10:59:10 +00:00
|
|
|
return i; /* Done here also ... */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-10-03 10:59:10 +00:00
|
|
|
i++;
|
|
|
|
|
|
|
|
}
|
2000-08-30 12:42:31 +00:00
|
|
|
}
|
|
|
|
|
2001-04-27 01:27:37 +00:00
|
|
|
static int
|
2013-02-23 03:48:04 +00:00
|
|
|
dissect_beep_mime_header(tvbuff_t *tvb, packet_info *pinfo, int offset,
|
2009-09-30 19:33:39 +00:00
|
|
|
struct beep_proto_data *beep_frame_data,
|
|
|
|
proto_tree *tree)
|
2000-08-30 12:42:31 +00:00
|
|
|
{
|
2000-10-02 01:44:58 +00:00
|
|
|
proto_tree *ti = NULL, *mime_tree = NULL;
|
2000-10-03 10:59:10 +00:00
|
|
|
int mime_length = header_len(tvb, offset), cc = 0;
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2008-06-27 04:52:56 +00:00
|
|
|
if (beep_frame_data && !beep_frame_data->mime_hdr) return 0;
|
2000-10-05 13:13:49 +00:00
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
if (tree) {
|
2000-10-03 10:59:10 +00:00
|
|
|
|
|
|
|
/* FIXME: Should calculate the whole length of the mime headers */
|
2013-02-23 03:48:04 +00:00
|
|
|
ti = proto_tree_add_item(tree, hf_beep_mime_header, tvb, offset, mime_length, ENC_NA|ENC_ASCII);
|
2000-10-02 01:44:58 +00:00
|
|
|
mime_tree = proto_item_add_subtree(ti, ett_mime_header);
|
|
|
|
}
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
if (mime_length == 0) { /* Default header */
|
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
if (tree) {
|
2014-09-11 00:04:22 +00:00
|
|
|
proto_tree_add_string_format(mime_tree, hf_beep_header, tvb, offset, 0, "", "Default values");
|
2000-10-03 10:59:10 +00:00
|
|
|
}
|
|
|
|
|
2013-02-23 03:48:04 +00:00
|
|
|
if ((cc = check_term(tvb, pinfo, offset, mime_tree)) <= 0) {
|
2000-10-03 10:59:10 +00:00
|
|
|
|
|
|
|
/* Ignore it, it will cause funnies in the rest of the dissect */
|
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
}
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else { /* FIXME: Process the headers */
|
|
|
|
|
2000-10-03 10:59:10 +00:00
|
|
|
if (tree) {
|
2013-02-23 03:48:04 +00:00
|
|
|
proto_tree_add_item(mime_tree, hf_beep_header, tvb, offset, mime_length, ENC_NA|ENC_ASCII);
|
2000-10-03 10:59:10 +00:00
|
|
|
}
|
|
|
|
|
2013-02-23 03:48:04 +00:00
|
|
|
if ((cc = check_term(tvb, pinfo, offset + mime_length, mime_tree)) <= 0) {
|
2000-10-03 10:59:10 +00:00
|
|
|
|
|
|
|
/* Ignore it, it will cause funnies in the rest of the dissect */
|
|
|
|
|
|
|
|
}
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-10-03 10:59:10 +00:00
|
|
|
return mime_length + cc; /* FIXME: Check that the CRLF is there */
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-04-27 01:27:37 +00:00
|
|
|
static int
|
2002-04-08 02:13:36 +00:00
|
|
|
dissect_beep_int(tvbuff_t *tvb, int offset,
|
2009-09-30 19:33:39 +00:00
|
|
|
proto_tree *tree, int hf, int *val, int *hfa[])
|
2000-08-30 12:42:31 +00:00
|
|
|
{
|
2008-05-09 13:59:10 +00:00
|
|
|
proto_item *hidden_item;
|
2001-04-27 01:27:37 +00:00
|
|
|
int ival, ind = 0;
|
2016-07-12 17:18:05 +00:00
|
|
|
unsigned int len = num_len(tvb, offset);
|
2000-09-08 06:19:37 +00:00
|
|
|
|
2016-07-14 11:46:13 +00:00
|
|
|
ival = (int)strtol(tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_ASCII), NULL, 10);
|
2016-07-12 17:18:05 +00:00
|
|
|
proto_tree_add_uint(tree, hf, tvb, offset, len, ival);
|
2000-10-02 01:44:58 +00:00
|
|
|
|
|
|
|
while (hfa[ind]) {
|
|
|
|
|
2016-07-12 17:18:05 +00:00
|
|
|
hidden_item = proto_tree_add_uint(tree, *hfa[ind], tvb, offset, len, ival);
|
2009-09-30 19:33:39 +00:00
|
|
|
PROTO_ITEM_SET_HIDDEN(hidden_item);
|
2000-10-02 01:44:58 +00:00
|
|
|
ind++;
|
|
|
|
|
|
|
|
}
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
*val = ival; /* Return the value */
|
|
|
|
|
2016-07-12 17:18:05 +00:00
|
|
|
return len;
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-04-27 01:27:37 +00:00
|
|
|
static void
|
2002-08-28 21:04:11 +00:00
|
|
|
set_mime_hdr_flags(int more, struct beep_request_val *request_val,
|
2009-09-30 19:33:39 +00:00
|
|
|
struct beep_proto_data *beep_frame_data, packet_info *pinfo)
|
2000-10-05 13:13:49 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if (!request_val) return; /* Nothing to do ??? */
|
|
|
|
|
2008-09-11 14:07:02 +00:00
|
|
|
if (pinfo->destport == global_beep_tcp_port) { /* Going to the server ... client */
|
2000-10-05 13:13:49 +00:00
|
|
|
|
|
|
|
if (request_val->c_mime_hdr) {
|
|
|
|
|
2008-06-27 04:52:56 +00:00
|
|
|
beep_frame_data->mime_hdr = 0;
|
2000-10-05 13:13:49 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
if (!more) request_val->c_mime_hdr = 0;
|
2000-10-05 13:13:49 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
2008-06-27 04:52:56 +00:00
|
|
|
beep_frame_data->mime_hdr = 1;
|
2000-10-05 13:13:49 +00:00
|
|
|
|
|
|
|
if (more) request_val->c_mime_hdr = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
if (request_val->s_mime_hdr) {
|
|
|
|
|
2008-06-27 04:52:56 +00:00
|
|
|
beep_frame_data->mime_hdr = 0;
|
2000-10-05 13:13:49 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
if (!more) request_val->s_mime_hdr = 0;
|
2000-10-05 13:13:49 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
2008-06-27 04:52:56 +00:00
|
|
|
beep_frame_data->mime_hdr = 1;
|
2000-10-05 13:13:49 +00:00
|
|
|
|
|
|
|
if (more) request_val->s_mime_hdr = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
/* Build the tree
|
|
|
|
*
|
|
|
|
* A return value of <= 0 says we bailed out, skip the rest of this message,
|
|
|
|
* if any.
|
|
|
|
*
|
|
|
|
* A return value > 0 is the count of bytes we consumed ...
|
|
|
|
*/
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2001-04-27 01:27:37 +00:00
|
|
|
static int
|
2002-08-28 21:04:11 +00:00
|
|
|
dissect_beep_tree(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
2009-09-30 19:33:39 +00:00
|
|
|
proto_tree *tree, struct beep_request_val *request_val,
|
|
|
|
struct beep_proto_data *beep_frame_data)
|
2000-08-30 12:42:31 +00:00
|
|
|
{
|
2000-10-02 01:44:58 +00:00
|
|
|
proto_tree *ti = NULL, *hdr = NULL;
|
2011-04-04 20:03:27 +00:00
|
|
|
/*proto_item *hidden_item;*/
|
2001-12-08 01:45:36 +00:00
|
|
|
int st_offset, msgno, ansno, seqno, size, channel, ackno, window, cc,
|
2000-10-05 13:13:49 +00:00
|
|
|
more;
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2005-07-28 07:53:38 +00:00
|
|
|
const char * cmd_temp = NULL;
|
2001-12-08 01:45:36 +00:00
|
|
|
int is_ANS = 0;
|
2000-08-30 12:42:31 +00:00
|
|
|
st_offset = offset;
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
if (tvb_strneql(tvb, offset, "MSG ", 4) == 0)
|
2001-12-08 01:45:36 +00:00
|
|
|
cmd_temp = "Command: MSG";
|
2002-08-28 21:04:11 +00:00
|
|
|
if (tvb_strneql(tvb, offset, "RPY ", 4) == 0)
|
2001-12-08 01:45:36 +00:00
|
|
|
cmd_temp = "Command: RPY";
|
2002-08-28 21:04:11 +00:00
|
|
|
if (tvb_strneql(tvb, offset, "ERR ", 4) == 0)
|
2001-12-08 01:45:36 +00:00
|
|
|
cmd_temp = "Command: ERR";
|
2002-08-28 21:04:11 +00:00
|
|
|
if (tvb_strneql(tvb, offset, "NUL ", 4) == 0)
|
2001-12-08 01:45:36 +00:00
|
|
|
cmd_temp = "Command: NUL";
|
|
|
|
if (tvb_strneql(tvb, offset, "ANS ", 4) == 0) {
|
|
|
|
cmd_temp = "Command: ANS";
|
|
|
|
is_ANS = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmd_temp != NULL) {
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
if (tree) {
|
2014-06-22 20:01:36 +00:00
|
|
|
hdr = proto_tree_add_subtree(tree, tvb, offset, header_len(tvb, offset) + 2,
|
|
|
|
ett_header, NULL, "Header");
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2013-02-23 03:48:04 +00:00
|
|
|
ti = proto_tree_add_item(hdr, hf_beep_cmd, tvb, offset, 3, ENC_NA|ENC_ASCII);
|
|
|
|
/* Include space */
|
|
|
|
proto_item_set_len(ti, 4);
|
|
|
|
|
|
|
|
proto_tree_add_boolean(hdr, hf_beep_req, tvb, offset, 3, TRUE);
|
2000-10-02 01:44:58 +00:00
|
|
|
}
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
offset += 4;
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
/* Get the channel */
|
2002-04-08 02:13:36 +00:00
|
|
|
offset += dissect_beep_int(tvb, offset, hdr, hf_beep_channel, &channel, req_chan_hfa);
|
2001-12-08 01:45:36 +00:00
|
|
|
offset += 1; /* Skip the space */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
/* Dissect the message number */
|
2002-04-08 02:13:36 +00:00
|
|
|
offset += dissect_beep_int(tvb, offset, hdr, hf_beep_msgno, &msgno, req_msgno_hfa);
|
2001-12-08 01:45:36 +00:00
|
|
|
offset += 1; /* skip the space */
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
/* Insert the more elements ... */
|
2013-02-23 03:48:04 +00:00
|
|
|
if ((more = dissect_beep_more(tvb, pinfo, offset, hdr)) >= 0) {
|
2002-08-28 21:04:11 +00:00
|
|
|
/* Figure out which direction this is in and what mime_hdr flag to
|
2008-06-27 04:52:56 +00:00
|
|
|
* add to the beep_frame_data. If there are missing segments, this code
|
2000-10-05 13:13:49 +00:00
|
|
|
* will get it wrong!
|
|
|
|
*/
|
2008-06-27 04:52:56 +00:00
|
|
|
set_mime_hdr_flags(more, request_val, beep_frame_data, pinfo);
|
2000-10-05 13:13:49 +00:00
|
|
|
}
|
|
|
|
else { /* Protocol violation, so dissect rest as undisectable */
|
2015-04-15 15:20:35 +00:00
|
|
|
if (tree && (tvb_reported_length_remaining(tvb, offset) > 0)) {
|
2013-10-13 19:56:52 +00:00
|
|
|
proto_tree_add_item(tree, hf_beep_payload_undissected, tvb, offset,
|
2015-04-15 15:20:35 +00:00
|
|
|
tvb_reported_length_remaining(tvb, offset), ENC_NA|ENC_ASCII);
|
2000-10-05 13:13:49 +00:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
offset += 2; /* Skip the flag and the space ... */
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
/* now for the seqno */
|
2002-04-08 02:13:36 +00:00
|
|
|
offset += dissect_beep_int(tvb, offset, hdr, hf_beep_seqno, &seqno, req_seqno_hfa);
|
2001-12-08 01:45:36 +00:00
|
|
|
offset += 1; /* skip the space */
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2002-04-08 02:13:36 +00:00
|
|
|
offset += dissect_beep_int(tvb, offset, hdr, hf_beep_size, &size, req_size_hfa);
|
2000-10-05 13:13:49 +00:00
|
|
|
if (request_val) /* FIXME, is this the right order ... */
|
2000-09-12 02:24:19 +00:00
|
|
|
request_val -> size = size; /* Stash this away */
|
2009-09-30 19:33:39 +00:00
|
|
|
else if (beep_frame_data) {
|
2008-06-27 04:52:56 +00:00
|
|
|
beep_frame_data->pl_size = size;
|
|
|
|
if (beep_frame_data->pl_size < 0) beep_frame_data->pl_size = 0; /* FIXME: OK? */
|
2000-09-12 02:24:19 +00:00
|
|
|
}
|
2001-12-08 01:45:36 +00:00
|
|
|
/* offset += 1; skip the space */
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
if (is_ANS) { /* We need to put in the ansno */
|
|
|
|
offset += 1; /* skip the space */
|
|
|
|
/* Dissect the message number */
|
2002-04-08 02:13:36 +00:00
|
|
|
offset += dissect_beep_int(tvb, offset, hdr, hf_beep_ansno, &ansno, req_ansno_hfa);
|
2001-12-08 01:45:36 +00:00
|
|
|
}
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2013-02-23 03:48:04 +00:00
|
|
|
if ((cc = check_term(tvb, pinfo, offset, hdr)) <= 0) {
|
2000-10-02 01:44:58 +00:00
|
|
|
|
|
|
|
/* We dissect the rest as data and bail ... */
|
|
|
|
|
2015-04-15 15:20:35 +00:00
|
|
|
if (tree && (tvb_reported_length_remaining(tvb, offset) > 0)) {
|
2013-10-13 19:56:52 +00:00
|
|
|
proto_tree_add_item(tree, hf_beep_payload_undissected, tvb, offset,
|
2015-04-15 15:20:35 +00:00
|
|
|
tvb_reported_length_remaining(tvb, offset), ENC_NA|ENC_ASCII);
|
2000-10-02 01:44:58 +00:00
|
|
|
}
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
return -1;
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
offset += cc;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-08-30 12:42:31 +00:00
|
|
|
/* Insert MIME header ... */
|
|
|
|
|
2008-06-27 04:52:56 +00:00
|
|
|
if (beep_frame_data && beep_frame_data->mime_hdr)
|
2013-02-23 03:48:04 +00:00
|
|
|
offset += dissect_beep_mime_header(tvb, pinfo, offset, beep_frame_data, hdr);
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
/* Now for the payload, if any */
|
|
|
|
|
2015-04-15 15:20:35 +00:00
|
|
|
if (tvb_reported_length_remaining(tvb, offset) > 0) { /* Dissect what is left as payload */
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2015-04-15 15:20:35 +00:00
|
|
|
int pl_size = MIN(size, tvb_reported_length_remaining(tvb, offset));
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
/* Except, check the payload length, and only dissect that much */
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* We need to keep track, in the conversation, of how much is left
|
2000-09-12 02:24:19 +00:00
|
|
|
* so in the next packet, we can figure out what is part of the payload
|
|
|
|
* and what is the next message
|
|
|
|
*/
|
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
if (tree) {
|
2013-02-23 03:48:04 +00:00
|
|
|
proto_tree_add_item(tree, hf_beep_payload, tvb, offset, pl_size, ENC_NA|ENC_ASCII);
|
2000-10-02 01:44:58 +00:00
|
|
|
}
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
offset += pl_size;
|
|
|
|
|
2000-09-12 02:24:19 +00:00
|
|
|
if (request_val) {
|
2009-09-30 19:33:39 +00:00
|
|
|
request_val->size -= pl_size;
|
|
|
|
if (request_val->size < 0) request_val->size = 0;
|
2000-09-12 02:24:19 +00:00
|
|
|
}
|
2009-09-30 19:33:39 +00:00
|
|
|
else if (beep_frame_data) {
|
|
|
|
beep_frame_data->pl_size -= pl_size;
|
|
|
|
if (beep_frame_data->pl_size < 0) beep_frame_data->pl_size = 0;
|
2000-09-12 02:24:19 +00:00
|
|
|
}
|
2000-08-30 12:42:31 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
/* If anything else left, dissect it ... */
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2015-04-15 15:20:35 +00:00
|
|
|
if (tvb_reported_length_remaining(tvb, offset) > 0)
|
2008-06-27 04:52:56 +00:00
|
|
|
offset += dissect_beep_tree(tvb, offset, pinfo, tree, request_val, beep_frame_data);
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-09-08 06:19:37 +00:00
|
|
|
} else if (tvb_strneql(tvb, offset, "SEQ ", 4) == 0) {
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
if (tree) {
|
2013-02-23 03:48:04 +00:00
|
|
|
ti = proto_tree_add_item(hdr, hf_beep_cmd, tvb, offset, 3, ENC_NA|ENC_ASCII);
|
|
|
|
/* Include space */
|
|
|
|
proto_item_set_len(ti, 4);
|
2000-10-02 01:44:58 +00:00
|
|
|
}
|
|
|
|
|
2000-08-30 12:42:31 +00:00
|
|
|
offset += 3;
|
|
|
|
|
|
|
|
/* Now check the space: FIXME */
|
|
|
|
|
|
|
|
offset += 1;
|
|
|
|
|
2002-04-08 02:13:36 +00:00
|
|
|
offset += dissect_beep_int(tvb, offset, tree, hf_beep_channel, &channel, seq_chan_hfa);
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
/* Check the space: FIXME */
|
|
|
|
|
|
|
|
offset += 1;
|
|
|
|
|
2002-04-08 02:13:36 +00:00
|
|
|
offset += dissect_beep_int(tvb, offset, tree, hf_beep_ackno, &ackno, seq_ackno_hfa);
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
/* Check the space: FIXME */
|
|
|
|
|
|
|
|
offset += 1;
|
|
|
|
|
2002-04-08 02:13:36 +00:00
|
|
|
offset += dissect_beep_int(tvb, offset, tree, hf_beep_window, &window, seq_window_hfa);
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2013-02-23 03:48:04 +00:00
|
|
|
if ((cc = check_term(tvb, pinfo, offset, tree)) <= 0) {
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
/* We dissect the rest as data and bail ... */
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2015-04-15 15:20:35 +00:00
|
|
|
if (tree && (tvb_reported_length_remaining(tvb, offset) > 0)) {
|
2013-10-13 19:56:52 +00:00
|
|
|
proto_tree_add_item(tree, hf_beep_payload_undissected, tvb, offset,
|
2015-04-15 15:20:35 +00:00
|
|
|
tvb_reported_length_remaining(tvb, offset), ENC_NA|ENC_ASCII);
|
2000-10-02 01:44:58 +00:00
|
|
|
}
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
return -1;
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
offset += cc;
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-09-08 06:19:37 +00:00
|
|
|
} else if (tvb_strneql(tvb, offset, "END", 3) == 0) {
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
proto_tree *tr = NULL;
|
|
|
|
|
|
|
|
if (tree) {
|
2015-04-15 15:20:35 +00:00
|
|
|
tr = proto_tree_add_subtree(tree, tvb, offset, MIN(5, MAX(0, tvb_reported_length_remaining(tvb, offset))),
|
2014-06-22 20:01:36 +00:00
|
|
|
ett_trailer, NULL, "Trailer");
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2013-02-25 19:28:24 +00:00
|
|
|
proto_tree_add_item(hdr, hf_beep_cmd, tvb, offset, 3, ENC_NA|ENC_ASCII);
|
2000-10-02 01:44:58 +00:00
|
|
|
}
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
offset += 3;
|
|
|
|
|
2013-02-23 03:48:04 +00:00
|
|
|
if ((cc = check_term(tvb, pinfo, offset, tr)) <= 0) {
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
/* We dissect the rest as data and bail ... */
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2015-04-15 15:20:35 +00:00
|
|
|
if (tree && (tvb_reported_length_remaining(tvb, offset) > 0)) {
|
2013-10-13 19:56:52 +00:00
|
|
|
proto_tree_add_item(tree, hf_beep_payload_undissected, tvb, offset,
|
2015-04-15 15:20:35 +00:00
|
|
|
tvb_reported_length_remaining(tvb, offset), ENC_NA|ENC_ASCII);
|
2000-10-02 01:44:58 +00:00
|
|
|
}
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
return -1;
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
offset += cc;
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-04-15 15:20:35 +00:00
|
|
|
if (tvb_reported_length_remaining(tvb, offset) > 0) { /* Dissect anything left over */
|
2000-09-12 02:24:19 +00:00
|
|
|
|
|
|
|
int pl_size = 0;
|
|
|
|
|
|
|
|
if (request_val) {
|
|
|
|
|
2015-04-15 15:20:35 +00:00
|
|
|
pl_size = MIN(request_val->size, tvb_reported_length_remaining(tvb, offset));
|
2000-09-12 02:24:19 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
if (pl_size == 0) { /* The whole of the rest must be payload */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2015-04-15 15:20:35 +00:00
|
|
|
pl_size = tvb_reported_length_remaining(tvb, offset); /* Right place ? */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-09-12 02:24:19 +00:00
|
|
|
}
|
|
|
|
|
2008-06-27 04:52:56 +00:00
|
|
|
} else if (beep_frame_data) {
|
2015-04-15 15:20:35 +00:00
|
|
|
pl_size = MIN(beep_frame_data->pl_size, tvb_reported_length_remaining(tvb, offset));
|
2000-09-12 02:24:19 +00:00
|
|
|
} else { /* Just in case */
|
2015-04-15 15:20:35 +00:00
|
|
|
pl_size = tvb_reported_length_remaining(tvb, offset);
|
2000-09-12 02:24:19 +00:00
|
|
|
}
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* Take care here to handle the payload correctly, and if there is
|
2000-09-12 02:24:19 +00:00
|
|
|
* another message here, then handle it correctly as well.
|
|
|
|
*/
|
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
/* If the pl_size == 0 and the offset == 0?, then we have not processed
|
2002-08-28 21:04:11 +00:00
|
|
|
* anything in this frame above, so we better treat all this data as
|
2001-12-08 01:45:36 +00:00
|
|
|
* payload to avoid recursion loops
|
2000-09-12 02:24:19 +00:00
|
|
|
*/
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
if (pl_size == 0 && offset == st_offset)
|
2015-04-15 15:20:35 +00:00
|
|
|
pl_size = tvb_reported_length_remaining(tvb, offset);
|
2000-09-12 02:24:19 +00:00
|
|
|
|
|
|
|
if (pl_size > 0) {
|
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
if (tree) {
|
2013-02-23 03:48:04 +00:00
|
|
|
proto_tree_add_item(tree, hf_beep_payload, tvb, offset, pl_size, ENC_NA|ENC_ASCII);
|
2000-10-02 01:44:58 +00:00
|
|
|
}
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-09-12 02:24:19 +00:00
|
|
|
offset += pl_size; /* Advance past the payload */
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-09-12 02:24:19 +00:00
|
|
|
if (request_val){
|
2009-09-30 19:33:39 +00:00
|
|
|
request_val->size -= pl_size; /* Reduce payload by what we added */
|
|
|
|
if (request_val->size < 0) request_val->size = 0;
|
2000-09-12 02:24:19 +00:00
|
|
|
}
|
2009-09-30 19:33:39 +00:00
|
|
|
else if (beep_frame_data) {
|
|
|
|
beep_frame_data->pl_size -= pl_size;
|
|
|
|
if (beep_frame_data->pl_size < 0) beep_frame_data->pl_size = 0;
|
2000-09-12 02:24:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-15 15:20:35 +00:00
|
|
|
if (tvb_reported_length_remaining(tvb, offset) > 0) {
|
2008-06-27 04:52:56 +00:00
|
|
|
offset += dissect_beep_tree(tvb, offset, pinfo, tree, request_val, beep_frame_data);
|
2000-09-12 02:24:19 +00:00
|
|
|
}
|
2000-08-30 12:42:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return offset - st_offset;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-11-15 13:00:10 +00:00
|
|
|
static int
|
|
|
|
dissect_beep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
2000-08-30 12:42:31 +00:00
|
|
|
{
|
2000-09-08 06:19:37 +00:00
|
|
|
int offset;
|
2012-12-02 15:21:53 +00:00
|
|
|
struct beep_proto_data *beep_frame_data;
|
2001-12-08 01:45:36 +00:00
|
|
|
proto_tree *beep_tree = NULL, *ti = NULL;
|
2000-09-08 06:19:37 +00:00
|
|
|
conversation_t *conversation = NULL;
|
2001-12-08 01:45:36 +00:00
|
|
|
struct beep_request_key request_key, *new_request_key;
|
|
|
|
struct beep_request_val *request_val = NULL;
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-09-08 06:19:37 +00:00
|
|
|
offset = 0;
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-09-12 02:24:19 +00:00
|
|
|
/* If we have per frame data, use that, else, we must have lost the per-
|
|
|
|
* frame data, and we have to do a full dissect pass again.
|
|
|
|
*
|
|
|
|
* The per-frame data tells us how much of this frame is left over from a
|
|
|
|
* previous frame, so we dissect it as payload and then try to dissect the
|
|
|
|
* rest.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2000-09-12 02:24:19 +00:00
|
|
|
* We use the conversation to build up info on the first pass over the
|
2001-12-08 01:45:36 +00:00
|
|
|
* packets of type BEEP, and record anything that is needed if the user
|
2000-09-12 02:24:19 +00:00
|
|
|
* does random dissects of packets in per packet data.
|
|
|
|
*
|
2002-08-28 21:04:11 +00:00
|
|
|
* Once we have per-packet data, we don't need the conversation stuff
|
|
|
|
* anymore, but if per-packet data and conversation stuff gets deleted, as
|
|
|
|
* it does under some circumstances when a rescan is done, it all gets
|
2000-09-12 02:24:19 +00:00
|
|
|
* rebuilt.
|
2000-09-08 06:19:37 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Find out what conversation this packet is part of ... but only
|
2002-08-28 21:04:11 +00:00
|
|
|
* if we have no information on this packet, so find the per-frame
|
2000-09-08 06:19:37 +00:00
|
|
|
* info first.
|
|
|
|
*/
|
|
|
|
|
2013-11-23 02:20:13 +00:00
|
|
|
beep_frame_data = (struct beep_proto_data *)p_get_proto_data(wmem_file_scope(), pinfo, proto_beep, 0);
|
2000-09-08 06:19:37 +00:00
|
|
|
|
2008-06-27 04:52:56 +00:00
|
|
|
if (!beep_frame_data) {
|
2000-09-08 06:19:37 +00:00
|
|
|
|
2010-05-13 18:28:34 +00:00
|
|
|
conversation = find_or_create_conversation(pinfo);
|
2000-09-08 06:19:37 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/*
|
2000-09-08 06:19:37 +00:00
|
|
|
* Check for and insert an entry in the request table if does not exist
|
|
|
|
*/
|
2016-06-23 15:51:41 +00:00
|
|
|
request_key.conversation = conversation->conv_index;
|
2000-09-08 06:19:37 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
request_val = (struct beep_request_val *)g_hash_table_lookup(beep_request_hash, &request_key);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-09-08 06:19:37 +00:00
|
|
|
if (!request_val) { /* Create one */
|
|
|
|
|
2013-09-12 12:25:17 +00:00
|
|
|
new_request_key = wmem_new(wmem_file_scope(), struct beep_request_key);
|
2016-06-23 15:51:41 +00:00
|
|
|
new_request_key->conversation = conversation->conv_index;
|
2000-09-08 06:19:37 +00:00
|
|
|
|
2013-09-12 12:25:17 +00:00
|
|
|
request_val = wmem_new(wmem_file_scope(), struct beep_request_val);
|
2009-09-30 19:33:39 +00:00
|
|
|
request_val->processed = 0;
|
|
|
|
request_val->size = 0;
|
2000-09-08 06:19:37 +00:00
|
|
|
|
2009-09-30 19:33:39 +00:00
|
|
|
g_hash_table_insert(beep_request_hash, new_request_key, request_val);
|
2000-09-08 06:19:37 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "BEEP");
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
|
2011-09-26 09:01:17 +00:00
|
|
|
/* "tvb_format_text()" is passed a value that won't go past the end
|
2011-10-21 02:10:19 +00:00
|
|
|
* of the packet, so it won't throw an exception.
|
2011-09-26 09:01:17 +00:00
|
|
|
*/
|
2015-04-15 15:20:35 +00:00
|
|
|
if (tvb_reported_length_remaining(tvb, offset) > 0)
|
|
|
|
col_add_str(pinfo->cinfo, COL_INFO, tvb_format_text(tvb, offset, tvb_reported_length_remaining(tvb, offset)));
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* Here, we parse the message so we can retrieve the info we need, which
|
|
|
|
* is that there is some payload left from a previous segment on the
|
2000-10-02 01:44:58 +00:00
|
|
|
* front of this segment ... This all depends on TCP segments not getting
|
2002-08-28 21:04:11 +00:00
|
|
|
* out of order ...
|
2000-10-02 01:44:58 +00:00
|
|
|
*
|
|
|
|
* As a huge kludge, we push the checking for the tree down into the code
|
|
|
|
* and process as if we were given a tree but not call the routines that
|
|
|
|
* adorn the protocol tree if they were NULL.
|
|
|
|
*/
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
if (tree) { /* Build the tree info ... */
|
2000-09-12 02:24:19 +00:00
|
|
|
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_beep, tvb, offset, -1, ENC_NA);
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
beep_tree = proto_item_add_subtree(ti, ett_beep);
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
|
|
|
/* Check the per-frame data and the conversation for any left-over
|
|
|
|
* payload from the previous frame
|
2000-10-05 13:13:49 +00:00
|
|
|
*
|
|
|
|
* We check that per-frame data exists first, and if so, use it,
|
|
|
|
* else we use the conversation data.
|
|
|
|
*
|
|
|
|
* We create per-frame data here as well, but we must ensure we create it
|
|
|
|
* after we have done the check for per-frame or conversation data.
|
|
|
|
*
|
|
|
|
* We also depend on the first frame in a group having a pl_size of 0.
|
2000-10-02 01:44:58 +00:00
|
|
|
*/
|
2000-09-12 02:24:19 +00:00
|
|
|
|
2011-02-17 23:00:34 +00:00
|
|
|
if (beep_frame_data != NULL && beep_frame_data->pl_left > 0) {
|
2000-09-12 02:24:19 +00:00
|
|
|
|
2008-06-27 04:52:56 +00:00
|
|
|
int pl_left = beep_frame_data->pl_left;
|
2000-09-12 02:24:19 +00:00
|
|
|
|
2015-04-15 15:20:35 +00:00
|
|
|
pl_left = MIN(pl_left, MAX(0, tvb_reported_length_remaining(tvb, offset)));
|
2000-09-12 02:24:19 +00:00
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
/* Add the payload bit, only if we have a tree */
|
2012-05-25 02:43:39 +00:00
|
|
|
if (tree && (pl_left > 0)) {
|
2013-02-23 03:48:04 +00:00
|
|
|
proto_tree_add_item(tree, hf_beep_payload, tvb, offset, pl_left, ENC_NA|ENC_ASCII);
|
2000-09-12 02:24:19 +00:00
|
|
|
}
|
2000-10-02 01:44:58 +00:00
|
|
|
offset += pl_left;
|
|
|
|
}
|
2000-10-05 13:13:49 +00:00
|
|
|
else if (request_val && request_val->size > 0) {
|
2000-09-12 02:24:19 +00:00
|
|
|
|
2000-10-05 13:13:49 +00:00
|
|
|
int pl_left = request_val->size;
|
2000-09-12 02:24:19 +00:00
|
|
|
|
2000-10-05 13:13:49 +00:00
|
|
|
request_val->size = 0;
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* We create the frame data here for this case, and
|
2000-10-05 13:13:49 +00:00
|
|
|
* elsewhere for other frames
|
|
|
|
*/
|
|
|
|
|
2013-09-12 12:25:17 +00:00
|
|
|
beep_frame_data = wmem_new(wmem_file_scope(), struct beep_proto_data);
|
2000-10-05 13:13:49 +00:00
|
|
|
|
2008-06-27 04:52:56 +00:00
|
|
|
beep_frame_data->pl_left = pl_left;
|
|
|
|
beep_frame_data->pl_size = 0;
|
|
|
|
beep_frame_data->mime_hdr = 0;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2013-11-23 02:20:13 +00:00
|
|
|
p_add_proto_data(wmem_file_scope(), pinfo, proto_beep, 0, beep_frame_data);
|
2000-09-12 02:24:19 +00:00
|
|
|
|
2000-10-02 01:44:58 +00:00
|
|
|
}
|
2000-09-12 02:24:19 +00:00
|
|
|
|
2000-10-05 13:13:49 +00:00
|
|
|
/* Set up the per-frame data here if not already done so
|
|
|
|
* This _must_ come after the checks above ...
|
|
|
|
*/
|
2000-09-12 02:24:19 +00:00
|
|
|
|
2008-06-27 04:52:56 +00:00
|
|
|
if (beep_frame_data == NULL) {
|
2000-09-12 02:24:19 +00:00
|
|
|
|
2013-09-12 12:25:17 +00:00
|
|
|
beep_frame_data = wmem_new(wmem_file_scope(), struct beep_proto_data);
|
2000-09-12 02:24:19 +00:00
|
|
|
|
2008-06-27 04:52:56 +00:00
|
|
|
beep_frame_data->pl_left = 0;
|
|
|
|
beep_frame_data->pl_size = 0;
|
|
|
|
beep_frame_data->mime_hdr = 0;
|
2000-09-12 02:24:19 +00:00
|
|
|
|
2013-11-23 02:20:13 +00:00
|
|
|
p_add_proto_data(wmem_file_scope(), pinfo, proto_beep, 0, beep_frame_data);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-08-30 12:42:31 +00:00
|
|
|
}
|
|
|
|
|
2015-04-15 15:20:35 +00:00
|
|
|
if (tvb_reported_length_remaining(tvb, offset) > 0) {
|
2000-10-05 13:13:49 +00:00
|
|
|
|
2013-07-03 16:42:25 +00:00
|
|
|
/*offset += */dissect_beep_tree(tvb, offset, pinfo, beep_tree, request_val, beep_frame_data);
|
2000-10-05 13:13:49 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-11-15 13:00:10 +00:00
|
|
|
return tvb_captured_length(tvb);
|
2000-08-30 12:42:31 +00:00
|
|
|
}
|
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
static void
|
|
|
|
apply_beep_prefs(void)
|
|
|
|
{
|
|
|
|
/* Beep uses the port preference to determine client/server */
|
2016-11-18 02:45:28 +00:00
|
|
|
global_beep_tcp_port = prefs_get_uint_value("beep", "tcp.port");
|
2016-10-07 20:25:01 +00:00
|
|
|
}
|
|
|
|
|
2000-08-30 12:42:31 +00:00
|
|
|
/* Register all the bits needed with the filtering engine */
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
void
|
2001-12-08 01:45:36 +00:00
|
|
|
proto_register_beep(void)
|
2000-08-30 12:42:31 +00:00
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
2001-12-08 01:45:36 +00:00
|
|
|
{ &hf_beep_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", "beep.req", FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
2000-10-02 01:44:58 +00:00
|
|
|
|
2013-02-23 03:48:04 +00:00
|
|
|
{ &hf_beep_cmd,
|
|
|
|
{ "Command", "beep.command", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
{ &hf_beep_req_chan,
|
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 Channel Number", "beep.req.channel", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2013-01-31 17:55:31 +00:00
|
|
|
#if 0
|
2001-12-08 01:45:36 +00:00
|
|
|
{ &hf_beep_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", "beep.rsp", FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
2000-10-02 01:44:58 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
{ &hf_beep_rsp_chan,
|
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 Channel Number", "beep.rsp.channel", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
2013-01-31 17:55:31 +00:00
|
|
|
#endif
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
{ &hf_beep_seq_chan,
|
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
|
|
|
{ "Sequence Channel Number", "beep.seq.channel", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2013-02-23 03:48:04 +00:00
|
|
|
{ &hf_beep_more,
|
2016-09-19 01:48:50 +00:00
|
|
|
{ "More", "beep.more", FT_CHAR, BASE_HEX, VALS(beep_more_vals), 0x0, NULL, HFILL }},
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
{ &hf_beep_msgno,
|
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
|
|
|
{ "Msgno", "beep.msgno", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
{ &hf_beep_ansno,
|
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
|
|
|
{ "Ansno", "beep.ansno", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
{ &hf_beep_seqno,
|
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
|
|
|
{ "Seqno", "beep.seqno", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
{ &hf_beep_size,
|
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
|
|
|
{ "Size", "beep.size", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
{ &hf_beep_channel,
|
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
|
|
|
{ "Channel", "beep.channel", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2013-02-23 03:48:04 +00:00
|
|
|
{ &hf_beep_mime_header,
|
|
|
|
{ "Mime header", "beep.mime_header", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_beep_header,
|
|
|
|
{ "Header", "beep.header", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2013-02-23 03:48:04 +00:00
|
|
|
#if 0
|
|
|
|
{ &hf_beep_status,
|
|
|
|
{ "Status", "beep.status", FT_UINT8, BASE_HEX, VALS(beep_status_vals), 0x0, NULL, HFILL }},
|
2013-01-31 17:55:31 +00:00
|
|
|
#endif
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
{ &hf_beep_ackno,
|
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
|
|
|
{ "Ackno", "beep.seq.ackno", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
{ &hf_beep_window,
|
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
|
|
|
{ "Window", "beep.seq.window", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2013-02-23 03:48:04 +00:00
|
|
|
{ &hf_beep_payload,
|
|
|
|
{ "Payload", "beep.payload", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_beep_payload_undissected,
|
|
|
|
{ "Undissected Payload", "beep.payload_undissected", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
2014-09-11 00:04:22 +00:00
|
|
|
|
|
|
|
{ &hf_beep_crlf_terminator,
|
|
|
|
{ "Terminator: CRLF", "beep.crlf_terminator", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
2000-08-30 12:42:31 +00:00
|
|
|
};
|
|
|
|
static gint *ett[] = {
|
2001-12-08 01:45:36 +00:00
|
|
|
&ett_beep,
|
2000-08-30 12:42:31 +00:00
|
|
|
&ett_mime_header,
|
|
|
|
&ett_header,
|
|
|
|
&ett_trailer,
|
|
|
|
};
|
2013-06-09 03:28:05 +00:00
|
|
|
static ei_register_info ei[] = {
|
|
|
|
{ &ei_beep_more, { "beep.more.expected", PI_PROTOCOL, PI_WARN, "Expected More Flag (* or .)", EXPFILL }},
|
|
|
|
{ &ei_beep_cr_terminator, { "beep.cr_terminator", PI_PROTOCOL, PI_WARN, "Nonstandard Terminator: CR", EXPFILL }},
|
|
|
|
{ &ei_beep_lf_terminator, { "beep.lf_terminator", PI_PROTOCOL, PI_WARN, "Nonstandard Terminator: LF", EXPFILL }},
|
|
|
|
{ &ei_beep_invalid_terminator, { "beep.invalid_terminator", PI_PROTOCOL, PI_WARN, "Invalid Terminator", EXPFILL }},
|
|
|
|
};
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
module_t *beep_module;
|
2013-06-09 03:28:05 +00:00
|
|
|
expert_module_t* expert_beep;
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
proto_beep = proto_register_protocol("Blocks Extensible Exchange Protocol",
|
2009-09-30 19:33:39 +00:00
|
|
|
"BEEP", "beep");
|
2001-01-03 06:56:03 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
proto_register_field_array(proto_beep, hf, array_length(hf));
|
2001-01-03 06:56:03 +00:00
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2013-06-09 03:28:05 +00:00
|
|
|
expert_beep = expert_register_protocol(proto_beep);
|
|
|
|
expert_register_field_array(expert_beep, ei, array_length(ei));
|
2001-12-08 01:45:36 +00:00
|
|
|
register_init_routine(&beep_init_protocol);
|
2015-06-28 13:15:07 +00:00
|
|
|
register_cleanup_routine(&beep_cleanup_protocol);
|
2001-01-03 06:56:03 +00:00
|
|
|
|
2001-12-08 01:45:36 +00:00
|
|
|
/* Register our configuration options for BEEP, particularly our port */
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
beep_module = prefs_register_protocol(proto_beep, apply_beep_prefs);
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
prefs_register_bool_preference(beep_module, "strict_header_terminator",
|
2009-09-30 19:33:39 +00:00
|
|
|
"BEEP Header Requires CRLF",
|
|
|
|
"Specifies that BEEP requires CRLF as a "
|
|
|
|
"terminator, and not just CR or LF",
|
|
|
|
&global_beep_strict_term);
|
2000-08-30 12:42:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The registration hand-off routine */
|
|
|
|
void
|
2001-12-08 01:45:36 +00:00
|
|
|
proto_reg_handoff_beep(void)
|
2000-08-30 12:42:31 +00:00
|
|
|
{
|
2016-10-07 20:25:01 +00:00
|
|
|
dissector_handle_t beep_handle;
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
beep_handle = create_dissector_handle(dissect_beep, proto_beep);
|
2000-08-30 12:42:31 +00:00
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
dissector_add_uint_with_preference("tcp.port", TCP_PORT_BEEP, beep_handle);
|
2000-08-30 12:42:31 +00:00
|
|
|
|
|
|
|
}
|
2014-09-28 23:25:09 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 2
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=2 tabstop=8 expandtab:
|
|
|
|
* :indentSize=2:tabSize=8:noTabs=true:
|
|
|
|
*/
|