5 * Redback Lawful Intercept Packet dissector
7 * Copyright 2008 Florian Lohoff <flo[AT]rfc822.org>
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald[AT]wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39 #include <epan/packet.h>
40 #include <epan/addr_resolv.h>
41 #include <epan/strutil.h>
43 static int proto_redbackli = -1;
45 static int hf_redbackli_seqno = -1; /* Sequence No */
46 static int hf_redbackli_liid = -1; /* LI Id */
47 static int hf_redbackli_sessid = -1; /* Session Id */
48 static int hf_redbackli_label = -1; /* Label */
49 static int hf_redbackli_acctid = -1; /* Accounting Session Id */
50 static int hf_redbackli_dir = -1; /* Direction */
51 static int hf_redbackli_eohpad = -1; /* End Of Header Padding */
52 static int hf_redbackli_unknownavp = -1; /* Unknown AVP */
54 static int ett_redbackli = -1;
56 static dissector_handle_t ip_handle;
58 #define RB_AVP_SEQNO 1
60 #define RB_AVP_SESSID 3
62 #define RB_AVP_LABEL 20
63 #define RB_AVP_ACCTID 40
66 static const value_string avp_names[] = {
67 {RB_AVP_SEQNO, "Sequence No"},
68 {RB_AVP_LIID, "Lawful Intercept Id"},
69 {RB_AVP_SESSID, "Session Id"},
70 {RB_AVP_LABEL, "Label"},
71 {RB_AVP_ACCTID, "Accounting Session Id"},
72 {RB_AVP_DIR, "Direction"},
73 {RB_AVP_EOH, "End Of Header"},
78 redbackli_dissect_avp(guint8 avptype, guint8 avplen, tvbuff_t *tvb, gint offset, proto_tree *tree)
81 proto_tree *ti, *st=NULL;
83 avpname=val_to_str(avptype, avp_names, "Unknown");
85 ti = proto_tree_add_text(tree, tvb, offset, avplen+2, "%s AVP", avpname);
86 st = proto_item_add_subtree(ti, ett_redbackli);
88 proto_tree_add_text(st, tvb, offset, 1, "AVP Type: %d", avptype);
89 proto_tree_add_text(st, tvb, offset+1, 1, "AVP Length: %d", avplen);
96 proto_tree_add_item(st, hf_redbackli_seqno, tvb,
97 offset+2, avplen, FALSE);
100 proto_tree_add_item(st, hf_redbackli_liid, tvb,
101 offset+2, avplen, FALSE);
104 proto_tree_add_item(st, hf_redbackli_sessid, tvb,
105 offset+2, avplen, FALSE);
108 proto_tree_add_item(st, hf_redbackli_label, tvb,
109 offset+2, avplen, FALSE);
112 proto_tree_add_item(st, hf_redbackli_eohpad, tvb,
113 offset+2, avplen, FALSE);
116 proto_tree_add_item(st, hf_redbackli_dir, tvb,
117 offset+2, avplen, FALSE);
120 proto_tree_add_item(st, hf_redbackli_acctid, tvb,
121 offset+2, avplen, FALSE);
124 proto_tree_add_item(st, hf_redbackli_unknownavp, tvb,
125 offset+2, avplen, FALSE);
133 redbackli_dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
135 guint8 avptype, avplen;
138 proto_tree *ti, *redbackli_tree=NULL;
141 if(check_col(pinfo->cinfo,COL_PROTOCOL))
142 col_add_str(pinfo->cinfo,COL_PROTOCOL,"RBLI");
145 ti = proto_tree_add_item(tree, proto_redbackli,
147 redbackli_tree = proto_item_add_subtree(ti, ett_redbackli);
153 while(!eoh && len > 2) {
154 avptype = tvb_get_guint8(tvb, offset+0);
155 avplen = tvb_get_guint8(tvb, offset+1);
157 if (len < avplen+2) /* AVP Complete ? */
161 redbackli_dissect_avp(avptype, avplen, tvb, offset, redbackli_tree);
163 if (avptype == RB_AVP_EOH)
170 next_tvb = tvb_new_subset(tvb, offset, -1, -1);
171 call_dissector(ip_handle, next_tvb, pinfo, tree);
175 #define REDBACKLI_INTSIZE 6
176 #define REDBACKLI_EOHSIZE 2
177 #define MIN_REDBACKLI_SIZE (3*REDBACKLI_INTSIZE+REDBACKLI_EOHSIZE)
180 redbackli_dissect_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
184 guint8 avptype, avplen;
188 if (len < MIN_REDBACKLI_SIZE)
192 * We scan the possible AVPs and look out for mismatches.
193 * An int AVP needs to be 4 byte long, and the eoh must be 0 or 1
194 * long .. Unknown AVPs also mean not for us ...
197 while(len > 2 && !eoh) {
198 avptype = tvb_get_guint8(tvb, offset+0);
199 avplen = tvb_get_guint8(tvb, offset+1);
207 avpfound|=1<<avptype;
210 if (avplen > 1 || offset == 0)
225 if (!(avpfound & (1<<RB_AVP_SEQNO)))
227 if (!(avpfound & (1<<RB_AVP_SESSID)))
229 if (!(avpfound & (1<<RB_AVP_LIID)))
232 redbackli_dissect(tvb, pinfo, tree);
236 void proto_register_redbackli(void) {
237 static hf_register_info hf[] = {
238 { &hf_redbackli_seqno,
239 { "Sequence No", "redbackli.seqno", FT_UINT32, BASE_DEC, NULL, 0x0,
241 { &hf_redbackli_liid,
242 { "Lawful Intercept Id", "redbackli.liid", FT_UINT32, BASE_DEC, NULL, 0x0,
243 "LI Identifier", HFILL }},
244 { &hf_redbackli_sessid,
245 { "Session Id", "redbackli.sessid", FT_UINT32, BASE_DEC, NULL, 0x0,
246 "Session Identifier", HFILL }},
248 { "Direction", "redbackli.dir", FT_UINT8, BASE_DEC, NULL, 0x0,
250 { &hf_redbackli_label,
251 { "Label", "redbackli.label", FT_STRING, BASE_NONE, NULL, 0x0,
253 { &hf_redbackli_acctid,
254 { "Acctid", "redbackli.acctid", FT_BYTES, BASE_NONE, NULL, 0x0,
256 { &hf_redbackli_eohpad,
257 { "End of Header Padding", "redbackli.eohpad", FT_BYTES, BASE_NONE, NULL, 0x0,
259 { &hf_redbackli_unknownavp,
260 { "Unknown AVP", "redbackli.unknownavp", FT_BYTES, BASE_NONE, NULL, 0x0,
264 static gint *ett[] = {
268 proto_redbackli = proto_register_protocol("Redback Lawful Intercept",
269 "RedbackLI","redbackli");
271 proto_register_field_array(proto_redbackli,hf,array_length(hf));
272 proto_register_subtree_array(ett,array_length(ett));
274 register_dissector("redbackli", redbackli_dissect, proto_redbackli);
277 void proto_reg_handoff_redbackli(void) {
278 dissector_handle_t redbackli_handle;
280 ip_handle = find_dissector("ip");
282 redbackli_handle = find_dissector("redbackli");
283 dissector_add_handle("udp.port", redbackli_handle); /* for 'decode-as' */
285 heur_dissector_add("udp", redbackli_dissect_heur, proto_redbackli);