2008-03-06 20:09:34 +00:00
|
|
|
/* packet-redbackli.c
|
2008-03-07 23:12:05 +00:00
|
|
|
*
|
|
|
|
* $Id$
|
2008-03-06 20:09:34 +00:00
|
|
|
*
|
|
|
|
* Redback Lawful Intercept Packet dissector
|
|
|
|
*
|
|
|
|
* Copyright 2008 Florian Lohoff <flo[AT]rfc822.org>
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald[AT]wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* 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 <glib.h>
|
2012-05-15 19:23:35 +00:00
|
|
|
|
2008-03-06 20:09:34 +00:00
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <epan/addr_resolv.h>
|
|
|
|
#include <epan/strutil.h>
|
|
|
|
|
|
|
|
static int proto_redbackli = -1;
|
|
|
|
|
|
|
|
static int hf_redbackli_seqno = -1; /* Sequence No */
|
|
|
|
static int hf_redbackli_liid = -1; /* LI Id */
|
|
|
|
static int hf_redbackli_sessid = -1; /* Session Id */
|
|
|
|
static int hf_redbackli_label = -1; /* Label */
|
2008-10-14 19:14:57 +00:00
|
|
|
static int hf_redbackli_acctid = -1; /* Accounting Session Id */
|
|
|
|
static int hf_redbackli_dir = -1; /* Direction */
|
2008-03-06 20:09:34 +00:00
|
|
|
static int hf_redbackli_eohpad = -1; /* End Of Header Padding */
|
|
|
|
static int hf_redbackli_unknownavp = -1; /* Unknown AVP */
|
|
|
|
|
|
|
|
static int ett_redbackli = -1;
|
|
|
|
|
|
|
|
static dissector_handle_t ip_handle;
|
|
|
|
|
|
|
|
#define RB_AVP_SEQNO 1
|
|
|
|
#define RB_AVP_LIID 2
|
|
|
|
#define RB_AVP_SESSID 3
|
2008-10-14 19:14:57 +00:00
|
|
|
#define RB_AVP_DIR 4
|
2008-03-06 20:09:34 +00:00
|
|
|
#define RB_AVP_LABEL 20
|
2008-10-14 19:14:57 +00:00
|
|
|
#define RB_AVP_ACCTID 40
|
2008-03-06 20:09:34 +00:00
|
|
|
#define RB_AVP_EOH 0
|
|
|
|
|
|
|
|
static const value_string avp_names[] = {
|
|
|
|
{RB_AVP_SEQNO, "Sequence No"},
|
|
|
|
{RB_AVP_LIID, "Lawful Intercept Id"},
|
|
|
|
{RB_AVP_SESSID, "Session Id"},
|
|
|
|
{RB_AVP_LABEL, "Label"},
|
2008-10-14 19:14:57 +00:00
|
|
|
{RB_AVP_ACCTID, "Accounting Session Id"},
|
|
|
|
{RB_AVP_DIR, "Direction"},
|
2008-03-06 20:09:34 +00:00
|
|
|
{RB_AVP_EOH, "End Of Header"},
|
2008-10-14 19:14:57 +00:00
|
|
|
{0, NULL}
|
2008-03-06 20:09:34 +00:00
|
|
|
};
|
|
|
|
|
2008-10-14 19:14:57 +00:00
|
|
|
static void
|
2008-03-06 20:09:34 +00:00
|
|
|
redbackli_dissect_avp(guint8 avptype, guint8 avplen, tvbuff_t *tvb, gint offset, proto_tree *tree)
|
|
|
|
{
|
|
|
|
const char *avpname;
|
|
|
|
proto_tree *ti, *st=NULL;
|
|
|
|
|
|
|
|
avpname=val_to_str(avptype, avp_names, "Unknown");
|
|
|
|
|
2008-10-14 19:14:57 +00:00
|
|
|
ti = proto_tree_add_text(tree, tvb, offset, avplen+2, "%s AVP", avpname);
|
|
|
|
st = proto_item_add_subtree(ti, ett_redbackli);
|
2008-03-06 20:09:34 +00:00
|
|
|
|
2008-10-14 19:14:57 +00:00
|
|
|
proto_tree_add_text(st, tvb, offset, 1, "AVP Type: %d", avptype);
|
|
|
|
proto_tree_add_text(st, tvb, offset+1, 1, "AVP Length: %d", avplen);
|
|
|
|
|
|
|
|
if (!avplen)
|
|
|
|
return;
|
2008-03-06 20:09:34 +00:00
|
|
|
|
2009-08-10 18:45:47 +00:00
|
|
|
/* XXX: ToDo: Validate the length (avplen) of the fixed length fields
|
|
|
|
before calling proto_tree_add_item().
|
2011-10-21 02:10:19 +00:00
|
|
|
Note that the field lengths have been validated when
|
2009-08-10 18:45:47 +00:00
|
|
|
dissect_avp() is called from redbackli_dissect_heur().
|
|
|
|
*/
|
2011-10-21 02:10:19 +00:00
|
|
|
|
2008-03-06 20:09:34 +00:00
|
|
|
switch(avptype) {
|
|
|
|
case(RB_AVP_SEQNO):
|
2008-10-14 19:14:57 +00:00
|
|
|
proto_tree_add_item(st, hf_redbackli_seqno, tvb,
|
2011-10-06 03:35:44 +00:00
|
|
|
offset+2, avplen, ENC_BIG_ENDIAN);
|
2008-03-06 20:09:34 +00:00
|
|
|
break;
|
|
|
|
case(RB_AVP_LIID):
|
2008-10-14 19:14:57 +00:00
|
|
|
proto_tree_add_item(st, hf_redbackli_liid, tvb,
|
2011-10-06 03:35:44 +00:00
|
|
|
offset+2, avplen, ENC_BIG_ENDIAN);
|
2008-03-06 20:09:34 +00:00
|
|
|
break;
|
|
|
|
case(RB_AVP_SESSID):
|
2008-10-14 19:14:57 +00:00
|
|
|
proto_tree_add_item(st, hf_redbackli_sessid, tvb,
|
2011-10-06 03:35:44 +00:00
|
|
|
offset+2, avplen, ENC_BIG_ENDIAN);
|
2008-03-06 20:09:34 +00:00
|
|
|
break;
|
|
|
|
case(RB_AVP_LABEL):
|
2008-10-14 19:14:57 +00:00
|
|
|
proto_tree_add_item(st, hf_redbackli_label, tvb,
|
2011-10-15 18:46:26 +00:00
|
|
|
offset+2, avplen, ENC_ASCII|ENC_NA);
|
2008-03-06 20:09:34 +00:00
|
|
|
break;
|
|
|
|
case(RB_AVP_EOH):
|
2008-10-14 19:14:57 +00:00
|
|
|
proto_tree_add_item(st, hf_redbackli_eohpad, tvb,
|
2011-10-04 22:44:31 +00:00
|
|
|
offset+2, avplen, ENC_NA);
|
2008-10-14 19:14:57 +00:00
|
|
|
break;
|
|
|
|
case(RB_AVP_DIR):
|
|
|
|
proto_tree_add_item(st, hf_redbackli_dir, tvb,
|
2011-11-09 17:33:18 +00:00
|
|
|
offset+2, avplen, ENC_NA);
|
2008-10-14 19:14:57 +00:00
|
|
|
break;
|
|
|
|
case(RB_AVP_ACCTID):
|
|
|
|
proto_tree_add_item(st, hf_redbackli_acctid, tvb,
|
2011-10-04 22:44:31 +00:00
|
|
|
offset+2, avplen, ENC_NA);
|
2008-10-14 19:14:57 +00:00
|
|
|
break;
|
2008-03-06 20:09:34 +00:00
|
|
|
default:
|
2008-10-14 19:14:57 +00:00
|
|
|
proto_tree_add_item(st, hf_redbackli_unknownavp, tvb,
|
2011-10-04 22:44:31 +00:00
|
|
|
offset+2, avplen, ENC_NA);
|
2008-10-14 19:14:57 +00:00
|
|
|
break;
|
2008-03-06 20:09:34 +00:00
|
|
|
}
|
|
|
|
|
2008-10-14 19:14:57 +00:00
|
|
|
return;
|
2008-03-06 20:09:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
redbackli_dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
guint8 avptype, avplen;
|
2008-10-14 19:14:57 +00:00
|
|
|
gint len, offset=0;
|
|
|
|
gboolean eoh;
|
2008-03-06 20:09:34 +00:00
|
|
|
proto_tree *ti, *redbackli_tree=NULL;
|
|
|
|
tvbuff_t *next_tvb;
|
|
|
|
|
2010-01-13 20:32:01 +00:00
|
|
|
col_set_str(pinfo->cinfo,COL_PROTOCOL,"RBLI");
|
2008-03-06 20:09:34 +00:00
|
|
|
|
|
|
|
if (tree) {
|
|
|
|
ti = proto_tree_add_item(tree, proto_redbackli,
|
2011-10-21 02:10:19 +00:00
|
|
|
tvb, 0, -1, ENC_NA);
|
2008-03-06 20:09:34 +00:00
|
|
|
redbackli_tree = proto_item_add_subtree(ti, ett_redbackli);
|
|
|
|
}
|
|
|
|
|
|
|
|
len=tvb_length(tvb);
|
|
|
|
offset=0;
|
2008-10-14 19:14:57 +00:00
|
|
|
eoh=FALSE;
|
2009-08-10 18:45:47 +00:00
|
|
|
while(!eoh && (len > 2)) {
|
2008-03-06 20:09:34 +00:00
|
|
|
avptype = tvb_get_guint8(tvb, offset+0);
|
|
|
|
avplen = tvb_get_guint8(tvb, offset+1);
|
|
|
|
|
2009-08-10 18:45:47 +00:00
|
|
|
if ((len-2) < avplen) /* AVP Complete ? */
|
2008-03-06 20:09:34 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-14 19:14:57 +00:00
|
|
|
if (tree)
|
|
|
|
redbackli_dissect_avp(avptype, avplen, tvb, offset, redbackli_tree);
|
|
|
|
|
|
|
|
if (avptype == RB_AVP_EOH)
|
|
|
|
eoh=TRUE;
|
2008-03-06 20:09:34 +00:00
|
|
|
|
|
|
|
offset+=2+avplen;
|
|
|
|
len-=2+avplen;
|
|
|
|
}
|
|
|
|
|
2009-08-16 12:36:22 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, offset);
|
2008-03-06 20:09:34 +00:00
|
|
|
call_dissector(ip_handle, next_tvb, pinfo, tree);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define REDBACKLI_INTSIZE 6
|
|
|
|
#define REDBACKLI_EOHSIZE 2
|
|
|
|
#define MIN_REDBACKLI_SIZE (3*REDBACKLI_INTSIZE+REDBACKLI_EOHSIZE)
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
redbackli_dissect_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
2008-10-14 19:14:57 +00:00
|
|
|
gint len, offset=0;
|
|
|
|
gboolean eoh=FALSE;
|
2008-03-06 20:09:34 +00:00
|
|
|
guint8 avptype, avplen;
|
2008-04-10 19:35:07 +00:00
|
|
|
guint32 avpfound=0;
|
2008-03-06 20:09:34 +00:00
|
|
|
|
|
|
|
len=tvb_length(tvb);
|
|
|
|
if (len < MIN_REDBACKLI_SIZE)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We scan the possible AVPs and look out for mismatches.
|
|
|
|
* An int AVP needs to be 4 byte long, and the eoh must be 0 or 1
|
|
|
|
* long .. Unknown AVPs also mean not for us ...
|
|
|
|
*
|
|
|
|
*/
|
2009-08-10 18:45:47 +00:00
|
|
|
while((len > 2) && !eoh) {
|
2008-03-06 20:09:34 +00:00
|
|
|
avptype = tvb_get_guint8(tvb, offset+0);
|
|
|
|
avplen = tvb_get_guint8(tvb, offset+1);
|
|
|
|
|
|
|
|
switch(avptype) {
|
|
|
|
case(RB_AVP_SEQNO):
|
|
|
|
case(RB_AVP_LIID):
|
|
|
|
case(RB_AVP_SESSID):
|
|
|
|
if (avplen != 4)
|
|
|
|
return FALSE;
|
2008-04-10 19:35:07 +00:00
|
|
|
avpfound|=1<<avptype;
|
2008-03-06 20:09:34 +00:00
|
|
|
break;
|
|
|
|
case(RB_AVP_EOH):
|
2008-04-10 19:35:07 +00:00
|
|
|
if (avplen > 1 || offset == 0)
|
2008-03-06 20:09:34 +00:00
|
|
|
return FALSE;
|
2008-10-14 19:14:57 +00:00
|
|
|
eoh=TRUE;
|
|
|
|
break;
|
|
|
|
case(RB_AVP_LABEL):
|
2009-08-10 18:45:47 +00:00
|
|
|
case(RB_AVP_DIR): /* Is this correct? the hf_ originally had FT_UINT8 for DIR */
|
2008-10-14 19:14:57 +00:00
|
|
|
case(RB_AVP_ACCTID):
|
2008-03-06 20:09:34 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
offset+=2+avplen;
|
|
|
|
len-=2+avplen;
|
|
|
|
}
|
|
|
|
|
2008-04-10 19:35:07 +00:00
|
|
|
if (!(avpfound & (1<<RB_AVP_SEQNO)))
|
|
|
|
return FALSE;
|
|
|
|
if (!(avpfound & (1<<RB_AVP_SESSID)))
|
|
|
|
return FALSE;
|
|
|
|
if (!(avpfound & (1<<RB_AVP_LIID)))
|
|
|
|
return FALSE;
|
|
|
|
|
2008-03-06 20:09:34 +00:00
|
|
|
redbackli_dissect(tvb, pinfo, tree);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
void proto_register_redbackli(void) {
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_redbackli_seqno,
|
|
|
|
{ "Sequence No", "redbackli.seqno", FT_UINT32, BASE_DEC, NULL, 0x0,
|
2008-10-14 19:14:57 +00:00
|
|
|
NULL, HFILL }},
|
2008-03-06 20:09:34 +00:00
|
|
|
{ &hf_redbackli_liid,
|
|
|
|
{ "Lawful Intercept Id", "redbackli.liid", FT_UINT32, BASE_DEC, NULL, 0x0,
|
|
|
|
"LI Identifier", HFILL }},
|
|
|
|
{ &hf_redbackli_sessid,
|
|
|
|
{ "Session Id", "redbackli.sessid", FT_UINT32, BASE_DEC, NULL, 0x0,
|
|
|
|
"Session Identifier", HFILL }},
|
2008-10-14 19:14:57 +00:00
|
|
|
{ &hf_redbackli_dir,
|
2009-08-10 18:45:47 +00:00
|
|
|
#if 0 /* XXX: If one goes by the heuristic then this field can be variable length ??
|
2011-10-21 02:10:19 +00:00
|
|
|
In the absence of any documentation We'll assume that's the case
|
2009-08-10 18:45:47 +00:00
|
|
|
(even though 'direction' sounds like a fixed length field */
|
2008-10-14 19:14:57 +00:00
|
|
|
{ "Direction", "redbackli.dir", FT_UINT8, BASE_DEC, NULL, 0x0,
|
2009-08-10 18:45:47 +00:00
|
|
|
#endif
|
2009-10-07 23:08:22 +00:00
|
|
|
{ "Direction", "redbackli.dir", FT_BYTES, BASE_NONE, NULL, 0x0,
|
2008-10-14 19:14:57 +00:00
|
|
|
NULL, HFILL }},
|
2008-03-06 20:09:34 +00:00
|
|
|
{ &hf_redbackli_label,
|
|
|
|
{ "Label", "redbackli.label", FT_STRING, BASE_NONE, NULL, 0x0,
|
2008-10-14 19:14:57 +00:00
|
|
|
NULL, HFILL }},
|
|
|
|
{ &hf_redbackli_acctid,
|
|
|
|
{ "Acctid", "redbackli.acctid", FT_BYTES, BASE_NONE, NULL, 0x0,
|
|
|
|
NULL, HFILL }},
|
2008-03-06 20:09:34 +00:00
|
|
|
{ &hf_redbackli_eohpad,
|
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
|
|
|
{ "End of Header Padding", "redbackli.eohpad", FT_BYTES, BASE_NONE, NULL, 0x0,
|
2008-10-14 19:14:57 +00:00
|
|
|
NULL, HFILL }},
|
2008-03-06 20:09:34 +00:00
|
|
|
{ &hf_redbackli_unknownavp,
|
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
|
|
|
{ "Unknown AVP", "redbackli.unknownavp", FT_BYTES, BASE_NONE, NULL, 0x0,
|
2008-10-14 19:14:57 +00:00
|
|
|
NULL, HFILL }}
|
2008-03-06 20:09:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] = {
|
2008-10-14 19:14:57 +00:00
|
|
|
&ett_redbackli
|
2008-03-06 20:09:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
proto_redbackli = proto_register_protocol("Redback Lawful Intercept",
|
|
|
|
"RedbackLI","redbackli");
|
|
|
|
|
|
|
|
proto_register_field_array(proto_redbackli,hf,array_length(hf));
|
|
|
|
proto_register_subtree_array(ett,array_length(ett));
|
|
|
|
|
|
|
|
register_dissector("redbackli", redbackli_dissect, proto_redbackli);
|
|
|
|
}
|
|
|
|
|
|
|
|
void proto_reg_handoff_redbackli(void) {
|
2008-09-12 16:52:01 +00:00
|
|
|
dissector_handle_t redbackli_handle;
|
|
|
|
|
2008-03-06 20:09:34 +00:00
|
|
|
ip_handle = find_dissector("ip");
|
|
|
|
|
|
|
|
redbackli_handle = find_dissector("redbackli");
|
2008-09-23 00:45:05 +00:00
|
|
|
dissector_add_handle("udp.port", redbackli_handle); /* for 'decode-as' */
|
2008-03-06 20:09:34 +00:00
|
|
|
|
|
|
|
heur_dissector_add("udp", redbackli_dissect_heur, proto_redbackli);
|
|
|
|
}
|