Dissect AVP Code: 606 User-Data if it's xml.
[obnox/wireshark/wip.git] / epan / dissectors / packet-diameter_3gpp.c
1 /* packet-diameter_3gpp.c
2  * Routines for dissecting 3GPP OctetSting AVP:s
3  * Copyright 2008, Anders Broman <anders.broman[at]ericsson.com>
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24  */
25
26  /* This dissector registers a dissector table for 3GPP Vendor specific
27   * AVP:s which will be called from the Diameter dissector to dissect
28   * the content of AVP:s of the OctetString type(or similar).
29   */
30
31   #ifdef HAVE_CONFIG_H
32 # include "config.h"
33 #endif
34
35 #include <stdlib.h>
36
37 #include <glib.h>
38
39 #include <epan/packet.h>
40 #include <epan/proto.h>
41 #include <epan/asn1.h>
42
43 #include "packet-gsm_map.h"
44 #include "packet-gsm_a_common.h"
45 #include "packet-e164.h"
46 #include "packet-e212.h"
47
48 /* Initialize the protocol and registered fields */
49 static int proto_diameter_3gpp                  = -1;
50
51 static int hf_diameter_3gpp_msisdn                                      = -1;
52 static int hf_diameter_3gpp_user_data                           = -1;
53 static int hf_diameter_3gpp_ipaddr                                      = -1;
54 static int hf_diameter_3gpp_mbms_required_qos_prio      = -1;
55 static int hf_diameter_3gpp_tmgi                                        = -1;
56 static int hf_diameter_mbms_service_id                          = -1;
57 static int hf_diameter_address_digits = -1;
58 static int hf_diameter_3gpp_spare_bits = -1;
59 static int hf_diameter_3gpp_ulr_flags = -1;
60 static int hf_diameter_3gpp_ulr_flags_bit0 = -1;
61 static int hf_diameter_3gpp_ulr_flags_bit1 = -1;
62 static int hf_diameter_3gpp_ulr_flags_bit2 = -1;
63 static int hf_diameter_3gpp_ulr_flags_bit3 = -1;
64 static int hf_diameter_3gpp_ulr_flags_bit4 = -1;
65 static int hf_diameter_3gpp_ulr_flags_bit5 = -1;
66 static int hf_diameter_3gpp_ulr_flags_bit6 = -1;
67 static int hf_diameter_3gpp_ula_flags = -1;
68 static int hf_diameter_3gpp_ula_flags_bit0 = -1;
69 static int hf_diameter_3gpp_dsr_flags = -1;
70 static int hf_diameter_3gpp_dsr_flags_bit0 = -1;
71 static int hf_diameter_3gpp_dsr_flags_bit1 = -1;
72 static int hf_diameter_3gpp_dsr_flags_bit2 = -1;
73 static int hf_diameter_3gpp_dsr_flags_bit3 = -1;
74 static int hf_diameter_3gpp_dsr_flags_bit4 = -1;
75 static int hf_diameter_3gpp_dsr_flags_bit5 = -1;
76 static int hf_diameter_3gpp_dsr_flags_bit6 = -1;
77 static int hf_diameter_3gpp_dsr_flags_bit7 = -1;
78 static int hf_diameter_3gpp_dsr_flags_bit8 = -1;
79 static int hf_diameter_3gpp_dsr_flags_bit9 = -1;
80 static int hf_diameter_3gpp_dsr_flags_bit10 = -1;
81 static int hf_diameter_3gpp_dsr_flags_bit11 = -1;
82 static int hf_diameter_3gpp_dsr_flags_bit12 = -1;
83 static int hf_diameter_3gpp_dsr_flags_bit13 = -1;
84 static int hf_diameter_3gpp_dsa_flags = -1;
85 static int hf_diameter_3gpp_dsa_flags_bit0 = -1;
86 static int hf_diameter_3gpp_ida_flags = -1;
87 static int hf_diameter_3gpp_ida_flags_bit0 = -1;
88 static int hf_diameter_3gpp_pua_flags = -1;
89 static int hf_diameter_3gpp_pua_flags_bit0 = -1;
90 static int hf_diameter_3gpp_pua_flags_bit1 = -1;
91 static int hf_diameter_3gpp_nor_flags = -1;
92 static int hf_diameter_3gpp_nor_flags_bit0 = -1;
93 static int hf_diameter_3gpp_nor_flags_bit1 = -1;
94 static int hf_diameter_3gpp_nor_flags_bit2 = -1;
95 static int hf_diameter_3gpp_nor_flags_bit3 = -1;
96 static int hf_diameter_3gpp_nor_flags_bit4 = -1;
97 static int hf_diameter_3gpp_idr_flags = -1;
98 static int hf_diameter_3gpp_idr_flags_bit0 = -1;
99 static int hf_diameter_3gpp_idr_flags_bit1 = -1;
100 static int hf_diameter_3gpp_idr_flags_bit2 = -1;
101 static int hf_diameter_3gpp_idr_flags_bit3 = -1;
102 static int hf_diameter_3gpp_idr_flags_bit4 = -1;
103
104 static gint diameter_3gpp_msisdn_ett                            = -1;
105 static gint diameter_3gpp_tmgi_ett                                      = -1;
106 static gint diameter_3gpp_ulr_flags_ett = -1;
107 static gint diameter_3gpp_ula_flags_ett = -1;
108 static gint diameter_3gpp_dsr_flags_ett = -1;
109 static gint diameter_3gpp_dsa_flags_ett = -1;
110 static gint diameter_3gpp_ida_flags_ett = -1;
111 static gint diameter_3gpp_pua_flags_ett = -1;
112 static gint diameter_3gpp_nor_flags_ett = -1;
113 static gint diameter_3gpp_idr_flags_ett = -1;
114
115 /* Dissector handles */
116 static dissector_handle_t xml_handle;
117
118 /* AVP Code: 701 MSISDN */
119 static int
120 dissect_diameter_3gpp_msisdn(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
121
122         proto_item* item;
123         proto_tree *sub_tree;
124         int offset = 0;
125         const char     *digit_str;
126
127         item = proto_tree_add_item(tree, hf_diameter_3gpp_msisdn, tvb, offset, 6, FALSE);
128         sub_tree = proto_item_add_subtree(item,diameter_3gpp_msisdn_ett);
129
130         dissect_e164_cc(tvb, sub_tree, offset, TRUE);
131
132         digit_str = unpack_digits(tvb, 1);
133         proto_tree_add_string(sub_tree, hf_diameter_address_digits, tvb, 1, -1, digit_str);
134
135         return tvb_length(tvb);
136
137 }
138
139 /* AVP Code: 702 User-Data 
140  * TGPPSh.xml
141  * The AVP codes from 709 to799 are reserved for TS 29.329
142  */
143 /* AVP Code: 606 User-Data 
144  * imscxdx.xml
145  * IMS Cx Dx AVPS 3GPP TS 29.229
146  */
147 static int
148 dissect_diameter_3gpp_user_data(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
149
150         guint8          word[6];
151         int length = tvb_length(tvb);
152
153         /* If there is less than 38 characters this is not XML
154          * <?xml version="1.0" encoding="UTF-8"?>
155          */
156         if(length < 38)
157                 return length;
158
159         tvb_get_nstringz0(tvb, 0, sizeof(word),word);
160         if (g_ascii_strncasecmp(word, "<?xml", 5) == 0){
161                 call_dissector(xml_handle, tvb, pinfo, tree);
162         }
163
164         return length;
165
166 }
167
168 /* AVP Code: 900 TMGI */
169 static int
170 dissect_diameter_3gpp_tmgi(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
171
172         proto_item* item;
173         proto_tree *sub_tree;
174         int offset = 0;
175
176         item = proto_tree_add_item(tree, hf_diameter_3gpp_tmgi, tvb, offset, 6, FALSE);
177         sub_tree = proto_item_add_subtree(item,diameter_3gpp_tmgi_ett);
178
179         /* MBMS Service ID consisting of three octets. MBMS Service ID consists of a 6-digit
180          * fixed-length hexadecimal number between 000000 and FFFFFF.
181          * MBMS Service ID uniquely identifies an MBMS bearer service within a PLMN.
182          */
183
184         proto_tree_add_item(sub_tree, hf_diameter_mbms_service_id, tvb, offset, 3, FALSE);
185         offset = offset+3;
186         offset = dissect_e212_mcc_mnc(tvb, pinfo, sub_tree, offset, TRUE);
187
188         return offset;
189
190 }
191
192 /* AVP Code: 918 MBMS-BMSC-SSM-IP-Address */
193 static int
194 dissect_diameter_3gpp_ipaddr(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
195
196         int offset = 0;
197
198         proto_tree_add_item(tree, hf_diameter_3gpp_ipaddr, tvb, offset, 4, FALSE);
199         offset += 4;
200
201         return offset;
202
203 }
204
205 /* AVP Code: 913 MBMS-Required-QoS */
206 static int
207 dissect_diameter_3gpp_mbms_required_qos(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
208
209         int offset = 0;
210         guint length;
211
212         /* Octet
213          * 1            Allocation/Retention Priority as specified in 3GPP TS 23.107.
214          *                      This octet encodes each priority level defined in 3GPP TS 23.107
215          *                      as the binary value of the priority level. It specifies the relative
216          *                      importance of the actual MBMS bearer service compared to other MBMS
217          *                      and non-MBMS bearer services for allocation and retention of the
218          *                      MBMS bearer service.
219          * 2-N          QoS Profile as specified by the Quality-of-Service information element,
220          *                      from octet 3 onwards, in 3GPP TS 24.008
221          */
222         proto_tree_add_item(tree, hf_diameter_3gpp_mbms_required_qos_prio, tvb, offset, 1, FALSE);
223         offset++;
224         length = tvb_length(tvb) - 1;
225         de_sm_qos(tvb, tree, offset, length, NULL, 0);
226         return offset+length;
227
228 }
229
230 /* AVP Code: 1405 ULR-Flags */
231 static int
232 dissect_diameter_3gpp_ulr_flags(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
233
234         proto_item* item;
235         proto_tree *sub_tree;
236         int offset = 0;
237         guint32 bit_offset;
238
239         item = proto_tree_add_item(tree, hf_diameter_3gpp_ulr_flags, tvb, offset, 4, FALSE);
240         sub_tree = proto_item_add_subtree(item, diameter_3gpp_ulr_flags_ett);
241         bit_offset = 0;
242         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_spare_bits, tvb, bit_offset, 25, FALSE);
243         bit_offset+=25;
244         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_ulr_flags_bit6, tvb, bit_offset, 1, FALSE);
245         bit_offset++;
246         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_ulr_flags_bit5, tvb, bit_offset, 1, FALSE);
247         bit_offset++;
248         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_ulr_flags_bit4, tvb, bit_offset, 1, FALSE);
249         bit_offset++;
250         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_ulr_flags_bit3, tvb, bit_offset, 1, FALSE);
251         bit_offset++;
252         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_ulr_flags_bit2, tvb, bit_offset, 1, FALSE);
253         bit_offset++;
254         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_ulr_flags_bit1, tvb, bit_offset, 1, FALSE);
255         bit_offset++;
256         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_ulr_flags_bit0, tvb, bit_offset, 1, FALSE);
257         bit_offset++;
258
259         offset = bit_offset>>3;
260         return offset;
261
262 }
263
264 /* AVP Code: 1406 ULA-Flags */
265 static int
266 dissect_diameter_3gpp_ula_flags(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
267
268         proto_item* item;
269         proto_tree *sub_tree;
270         int offset = 0;
271         guint32 bit_offset;
272
273         item = proto_tree_add_item(tree, hf_diameter_3gpp_ula_flags, tvb, offset, 4, FALSE);
274         sub_tree = proto_item_add_subtree(item, diameter_3gpp_ula_flags_ett);
275         bit_offset = 0;
276         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_spare_bits, tvb, bit_offset, 31, FALSE);
277         bit_offset+=31;
278         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_ula_flags_bit0, tvb, bit_offset, 1, FALSE);
279         bit_offset++;
280
281         offset = bit_offset>>3;
282         return offset;
283
284 }
285
286 /* AVP Code: 1421 DSR-Flags */
287 static int
288 dissect_diameter_3gpp_dsr_flags(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
289
290         proto_item* item;
291         proto_tree *sub_tree;
292         int offset = 0;
293         guint32 bit_offset;
294
295         item = proto_tree_add_item(tree, hf_diameter_3gpp_dsr_flags, tvb, offset, 4, FALSE);
296         sub_tree = proto_item_add_subtree(item, diameter_3gpp_dsr_flags_ett);
297         bit_offset = 0;
298         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_spare_bits, tvb, bit_offset, 18, FALSE);
299         bit_offset+=18;
300         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit13, tvb, bit_offset, 1, FALSE);
301         bit_offset++;
302         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit12, tvb, bit_offset, 1, FALSE);
303         bit_offset++;
304         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit11, tvb, bit_offset, 1, FALSE);
305         bit_offset++;
306         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit10, tvb, bit_offset, 1, FALSE);
307         bit_offset++;
308         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit9, tvb, bit_offset, 1, FALSE);
309         bit_offset++;
310         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit8, tvb, bit_offset, 1, FALSE);
311         bit_offset++;
312         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit7, tvb, bit_offset, 1, FALSE);
313         bit_offset++;
314         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit6, tvb, bit_offset, 1, FALSE);
315         bit_offset++;
316         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit5, tvb, bit_offset, 1, FALSE);
317         bit_offset++;
318         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit4, tvb, bit_offset, 1, FALSE);
319         bit_offset++;
320         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit3, tvb, bit_offset, 1, FALSE);
321         bit_offset++;
322         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit2, tvb, bit_offset, 1, FALSE);
323         bit_offset++;
324         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit1, tvb, bit_offset, 1, FALSE);
325         bit_offset++;
326         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit0, tvb, bit_offset, 1, FALSE);
327         bit_offset++;
328
329         offset = bit_offset>>3;
330         return offset;
331
332 }
333
334 /* AVP Code: 1422 DSA-Flags */
335 static int
336 dissect_diameter_3gpp_dsa_flags(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
337
338         proto_item* item;
339         proto_tree *sub_tree;
340         int offset = 0;
341         guint32 bit_offset;
342
343         item = proto_tree_add_item(tree, hf_diameter_3gpp_dsa_flags, tvb, offset, 4, FALSE);
344         sub_tree = proto_item_add_subtree(item, diameter_3gpp_dsa_flags_ett);
345         bit_offset = 0;
346         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_spare_bits, tvb, bit_offset, 31, FALSE);
347         bit_offset+=31;
348         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsa_flags_bit0, tvb, bit_offset, 1, FALSE);
349         bit_offset++;
350
351         offset = bit_offset>>3;
352         return offset;
353
354 }
355
356 /* AVP Code: 1441 IDA-Flags */
357 static int
358 dissect_diameter_3gpp_ida_flags(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
359
360         proto_item* item;
361         proto_tree *sub_tree;
362         int offset = 0;
363         guint32 bit_offset;
364
365         item = proto_tree_add_item(tree, hf_diameter_3gpp_ida_flags, tvb, offset, 4, FALSE);
366         sub_tree = proto_item_add_subtree(item, diameter_3gpp_ida_flags_ett);
367         bit_offset = 0;
368         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_spare_bits, tvb, bit_offset, 31, FALSE);
369         bit_offset+=31;
370         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_ida_flags_bit0, tvb, bit_offset, 1, FALSE);
371         bit_offset++;
372
373         offset = bit_offset>>3;
374         return offset;
375
376 }
377
378 /* AVP Code: 1442 PUA-Flags */
379 static int
380 dissect_diameter_3gpp_pua_flags(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
381
382         proto_item* item;
383         proto_tree *sub_tree;
384         int offset = 0;
385         guint32 bit_offset;
386
387         item = proto_tree_add_item(tree, hf_diameter_3gpp_pua_flags, tvb, offset, 4, FALSE);
388         sub_tree = proto_item_add_subtree(item, diameter_3gpp_pua_flags_ett);
389         bit_offset = 0;
390         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_spare_bits, tvb, bit_offset, 30, FALSE);
391         bit_offset+=30;
392         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_pua_flags_bit1, tvb, bit_offset, 1, FALSE);
393         bit_offset++;
394         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_pua_flags_bit0, tvb, bit_offset, 1, FALSE);
395         bit_offset++;
396
397         offset = bit_offset>>3;
398         return offset;
399
400
401 }
402
403 /* AVP Code: 1443 NOR-Flags */
404 static int
405 dissect_diameter_3gpp_nor_flags(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
406
407         proto_item* item;
408         proto_tree *sub_tree;
409         int offset = 0;
410         guint32 bit_offset;
411
412         item = proto_tree_add_item(tree, hf_diameter_3gpp_nor_flags, tvb, offset, 4, FALSE);
413         sub_tree = proto_item_add_subtree(item, diameter_3gpp_nor_flags_ett);
414         bit_offset = 0;
415         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_spare_bits, tvb, bit_offset, 27, FALSE);
416         bit_offset+=27;
417         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_nor_flags_bit4, tvb, bit_offset, 1, FALSE);
418         bit_offset++;
419         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_nor_flags_bit3, tvb, bit_offset, 1, FALSE);
420         bit_offset++;
421         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_nor_flags_bit2, tvb, bit_offset, 1, FALSE);
422         bit_offset++;
423         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_nor_flags_bit1, tvb, bit_offset, 1, FALSE);
424         bit_offset++;
425         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_nor_flags_bit0, tvb, bit_offset, 1, FALSE);
426         bit_offset++;
427
428         offset = bit_offset>>3;
429         return offset;
430
431 }
432
433 /* AVP Code: 1490 IDR-Flags */
434 static int
435 dissect_diameter_3gpp_idr_flags(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
436
437         proto_item* item;
438         proto_tree *sub_tree;
439         int offset = 0;
440         guint32 bit_offset;
441
442         item = proto_tree_add_item(tree, hf_diameter_3gpp_idr_flags, tvb, offset, 4, FALSE);
443         sub_tree = proto_item_add_subtree(item, diameter_3gpp_idr_flags_ett);
444         bit_offset = 0;
445         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_spare_bits, tvb, bit_offset, 27, FALSE);
446         bit_offset+=27;
447         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_idr_flags_bit4, tvb, bit_offset, 1, FALSE);
448         bit_offset++;
449         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_idr_flags_bit3, tvb, bit_offset, 1, FALSE);
450         bit_offset++;
451         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_idr_flags_bit2, tvb, bit_offset, 1, FALSE);
452         bit_offset++;
453         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_idr_flags_bit1, tvb, bit_offset, 1, FALSE);
454         bit_offset++;
455         proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_idr_flags_bit0, tvb, bit_offset, 1, FALSE);
456         bit_offset++;
457
458         offset = bit_offset>>3;
459         return offset;
460
461 }
462
463 void
464 proto_reg_handoff_diameter_3gpp(void)
465 {
466
467         /* AVP Code: 5 3GPP-GPRS Negotiated QoS profile */
468         /* Registered by packet-gtp.c */
469
470         /* AVP Code: 22 3GPP-User-Location-Info
471          * Registered by packet-gtpv2.c
472          */
473
474         /* AVP Code: 706 User-Data */
475         dissector_add("diameter.3gpp", 606, new_create_dissector_handle(dissect_diameter_3gpp_user_data, proto_diameter_3gpp));
476
477         /* AVP Code: 701 MSISDN */
478         dissector_add("diameter.3gpp", 701, new_create_dissector_handle(dissect_diameter_3gpp_msisdn, proto_diameter_3gpp));
479
480         /* AVP Code: 702 User-Data */
481         dissector_add("diameter.3gpp", 702, new_create_dissector_handle(dissect_diameter_3gpp_user_data, proto_diameter_3gpp));
482
483         /* AVP Code: 900 TMGI */
484         dissector_add("diameter.3gpp", 900, new_create_dissector_handle(dissect_diameter_3gpp_tmgi, proto_diameter_3gpp));
485
486         /* AVP Code: 904 MBMS-Session-Duration */
487         /* AVP Code: 911 MBMS-Time-To-Data-Transfer */
488         /* Registered by packet-gtp.c */
489
490         /* AVP Code: 913 MBMS-Required-QoS */
491         dissector_add("diameter.3gpp", 913, new_create_dissector_handle(dissect_diameter_3gpp_mbms_required_qos, proto_diameter_3gpp));
492
493         /* AVP Code: 918 MBMS-BMSC-SSM-IP-Address */
494         dissector_add("diameter.3gpp", 918, new_create_dissector_handle(dissect_diameter_3gpp_ipaddr, proto_diameter_3gpp));
495
496         /* AVP Code: 1405 ULR-Flags */
497         dissector_add("diameter.3gpp", 1405, new_create_dissector_handle(dissect_diameter_3gpp_ulr_flags, proto_diameter_3gpp));
498
499         /* AVP Code: 1406 ULA-Flags */
500         dissector_add("diameter.3gpp", 1406, new_create_dissector_handle(dissect_diameter_3gpp_ula_flags, proto_diameter_3gpp));
501
502         /* AVP Code: 1421 DSR-Flags */
503         dissector_add("diameter.3gpp", 1421, new_create_dissector_handle(dissect_diameter_3gpp_dsr_flags, proto_diameter_3gpp));
504
505         /* AVP Code: 1422 DSA-Flags */
506         dissector_add("diameter.3gpp", 1422, new_create_dissector_handle(dissect_diameter_3gpp_dsa_flags, proto_diameter_3gpp));
507
508         /* AVP Code: 1441 IDA-Flags */
509         dissector_add("diameter.3gpp", 1441, new_create_dissector_handle(dissect_diameter_3gpp_ida_flags, proto_diameter_3gpp));
510
511         /* AVP Code: 1442 PUA-Flags */
512         dissector_add("diameter.3gpp", 1442, new_create_dissector_handle(dissect_diameter_3gpp_pua_flags, proto_diameter_3gpp));
513
514         /* AVP Code: 1443 NOR-Flags */
515         dissector_add("diameter.3gpp", 1443, new_create_dissector_handle(dissect_diameter_3gpp_nor_flags, proto_diameter_3gpp));
516
517         /* AVP Code: 1490 IDR-Flags */
518         dissector_add("diameter.3gpp", 1490, new_create_dissector_handle(dissect_diameter_3gpp_idr_flags, proto_diameter_3gpp));
519
520         xml_handle = find_dissector("xml");
521 }
522
523 void
524 proto_register_diameter_3gpp(void)
525 {
526
527 /* Setup list of header fields  See Section 1.6.1 for details*/
528         static hf_register_info hf[] = {
529                 { &hf_diameter_3gpp_msisdn,
530                         { "MSISDN",           "diameter.3gpp.msisdn",
531                         FT_BYTES, BASE_NONE, NULL, 0x0,
532                         NULL, HFILL }
533                 },
534                 { &hf_diameter_3gpp_user_data,
535                         { "User data",           "diameter.3gpp.user_data",
536                         FT_STRING, BASE_NONE, NULL, 0x0,
537                         NULL, HFILL }
538                 },
539                 { &hf_diameter_3gpp_ipaddr,
540                         { "IPv4 Address",           "diameter.3gpp.ipaddr",
541                         FT_IPv4, BASE_NONE, NULL, 0x0,
542                         NULL, HFILL }
543                 },
544                 { &hf_diameter_3gpp_mbms_required_qos_prio,
545                         { "Allocation/Retention Priority",           "diameter.3gpp.mbms_required_qos_prio",
546                         FT_UINT8, BASE_DEC, NULL, 0x0,
547                         NULL, HFILL }
548                 },
549                 { &hf_diameter_3gpp_tmgi,
550                         { "TMGI",           "diameter.3gpp.tmgi",
551                         FT_BYTES, BASE_NONE, NULL, 0x0,
552                         NULL, HFILL }
553                 },
554                 { &hf_diameter_mbms_service_id,
555                         { "MBMS Service ID",           "diameter.3gpp.mbms_service_id",
556                         FT_UINT24, BASE_HEX, NULL, 0x0,
557                         NULL, HFILL }
558                 },
559                 { &hf_diameter_address_digits,
560                         { "Address digits", "diameter.3gpp.address_digits",
561                         FT_STRING, BASE_NONE, NULL, 0x0,
562                         NULL, HFILL }
563                 },
564                 { &hf_diameter_3gpp_spare_bits,
565                         { "Spare bit(s)", "diameter.3gpp.spare_bits",
566                         FT_UINT32, BASE_HEX, NULL, 0x0,
567                         NULL, HFILL }
568                 },
569                 { &hf_diameter_3gpp_ulr_flags,
570                         { "ULR Flags", "diameter.3gpp.ulr_flags",
571                         FT_UINT32, BASE_HEX, NULL, 0x0,
572                         NULL, HFILL }
573                 },
574                 { &hf_diameter_3gpp_ulr_flags_bit0,
575                         { "Single-Registration-Indication", "diameter.3gpp.ulr_flags_bit0",
576                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
577                         NULL, HFILL }
578                 },
579                 { &hf_diameter_3gpp_ulr_flags_bit1,
580                         { "S6a/S6d-Indicator", "diameter.3gpp.ulr_flags_bit1",
581                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
582                         NULL, HFILL }
583                 },
584                 { &hf_diameter_3gpp_ulr_flags_bit2,
585                         { "Skip-Subscriber-Data", "diameter.3gpp.ulr_flags_bit2",
586                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
587                         NULL, HFILL }
588                 },
589                 { &hf_diameter_3gpp_ulr_flags_bit3,
590                         { "GPRS-Subscription-Data-Indicator", "diameter.3gpp.ulr_flags_bit3",
591                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
592                         NULL, HFILL }
593                 },
594                 { &hf_diameter_3gpp_ulr_flags_bit4,
595                         { "Node-Type-Indicator", "diameter.3gpp.ulr_flags_bit4",
596                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
597                         NULL, HFILL }
598                 },
599                 { &hf_diameter_3gpp_ulr_flags_bit5,
600                         { "Initial-Attach-Indicator", "diameter.3gpp.ulr_flags_bit5",
601                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
602                         NULL, HFILL }
603                 },
604                 { &hf_diameter_3gpp_ulr_flags_bit6,
605                         { "PS-LCS-Not-Supported-By-UE", "diameter.3gpp.ulr_flags_bit6",
606                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
607                         NULL, HFILL }
608                 },
609                 { &hf_diameter_3gpp_ula_flags,
610                         { "ULA Flags", "diameter.3gpp.ula_flags",
611                         FT_UINT32, BASE_HEX, NULL, 0x0,
612                         NULL, HFILL }
613                 },
614                 { &hf_diameter_3gpp_ula_flags_bit0,
615                         { "Separation Indication", "diameter.3gpp.ula_flags_bit0",
616                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
617                         NULL, HFILL }
618                 },
619                 { &hf_diameter_3gpp_dsr_flags,
620                         { "DSR Flags", "diameter.3gpp.dsr_flags",
621                         FT_UINT32, BASE_HEX, NULL, 0x0,
622                         NULL, HFILL }
623                 },
624                 { &hf_diameter_3gpp_dsr_flags_bit0,
625                         { "Regional Subscription Withdrawal", "diameter.3gpp.dsr_flags_bit0",
626                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
627                         NULL, HFILL }
628                 },
629                 { &hf_diameter_3gpp_dsr_flags_bit1,
630                         { "Complete APN Configuration Profile Withdrawal", "diameter.3gpp.dsr_flags_bit1",
631                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
632                         NULL, HFILL }
633                 },
634                 { &hf_diameter_3gpp_dsr_flags_bit2,
635                         { "Subscribed Charging Characteristics Withdrawal", "diameter.3gpp.dsr_flags_bit2",
636                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
637                         NULL, HFILL }
638                 },
639                 { &hf_diameter_3gpp_dsr_flags_bit3,
640                         { "PDN subscription contexts Withdrawal", "diameter.3gpp.dsr_flags_bit3",
641                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
642                         NULL, HFILL }
643                 },
644                 { &hf_diameter_3gpp_dsr_flags_bit4,
645                         { "STN-SR", "diameter.3gpp.dsr_flags_bit4",
646                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
647                         NULL, HFILL }
648                 },
649                 { &hf_diameter_3gpp_dsr_flags_bit5,
650                         { "Complete PDP context list Withdrawal", "diameter.3gpp.dsr_flags_bit5",
651                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
652                         NULL, HFILL }
653                 },
654                 { &hf_diameter_3gpp_dsr_flags_bit6,
655                         { "PDP contexts Withdrawal", "diameter.3gpp.dsr_flags_bit6",
656                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
657                         NULL, HFILL }
658                 },
659                 { &hf_diameter_3gpp_dsr_flags_bit7,
660                         { "Roaming Restricted due to unsupported feature", "diameter.3gpp.dsr_flags_bit7",
661                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
662                         NULL, HFILL }
663                 },
664                 { &hf_diameter_3gpp_dsr_flags_bit8,
665                         { "Trace Data Withdrawal", "diameter.3gpp.dsr_flags_bit8",
666                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
667                         NULL, HFILL }
668                 },
669                 { &hf_diameter_3gpp_dsr_flags_bit9,
670                         { "CSG Deleted", "diameter.3gpp.dsr_flags_bit9",
671                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
672                         NULL, HFILL }
673                 },
674                 { &hf_diameter_3gpp_dsr_flags_bit10,
675                         { "APN-OI-Replacement", "diameter.3gpp.dsr_flags_bit10",
676                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
677                         NULL, HFILL }
678                 },
679                 { &hf_diameter_3gpp_dsr_flags_bit11,
680                         { "GMLC List Withdrawal", "diameter.3gpp.dsr_flags_bit11",
681                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
682                         NULL, HFILL }
683                 },
684                 { &hf_diameter_3gpp_dsr_flags_bit12,
685                         { "LCS Withdrawal", "diameter.3gpp.dsr_flags_bit12",
686                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
687                         NULL, HFILL }
688                 },
689                 { &hf_diameter_3gpp_dsr_flags_bit13,
690                         { "SMS Withdrawal", "diameter.3gpp.dsr_flags_bit13",
691                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
692                         NULL, HFILL }
693                 },
694                 { &hf_diameter_3gpp_dsa_flags,
695                         { "DSA Flags", "diameter.3gpp.dsa_flags",
696                         FT_UINT32, BASE_HEX, NULL, 0x0,
697                         NULL, HFILL }
698                 },
699                 { &hf_diameter_3gpp_dsa_flags_bit0,
700                         { "Network Node area restricted", "diameter.3gpp.dsa_flags_bit0",
701                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
702                         NULL, HFILL }
703                 },
704                 { &hf_diameter_3gpp_ida_flags,
705                         { "IDA Flags", "diameter.3gpp.ida_flags",
706                         FT_UINT32, BASE_HEX, NULL, 0x0,
707                         NULL, HFILL }
708                 },
709                 { &hf_diameter_3gpp_ida_flags_bit0,
710                         { "Network Node area restricted", "diameter.3gpp.ida_flags_bit0",
711                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
712                         NULL, HFILL }
713                 },
714                 { &hf_diameter_3gpp_pua_flags,
715                         { "PUA Flags", "diameter.3gpp.pua_flags",
716                         FT_UINT32, BASE_HEX, NULL, 0x0,
717                         NULL, HFILL }
718                 },
719                 { &hf_diameter_3gpp_pua_flags_bit0,
720                         { "Freeze M-TMSI", "diameter.3gpp.pua_flags_bit0",
721                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
722                         NULL, HFILL }
723                 },
724                 { &hf_diameter_3gpp_pua_flags_bit1,
725                         { "Freeze P-TMSI", "diameter.3gpp.pua_flags_bit1",
726                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
727                         NULL, HFILL }
728                 },
729                 { &hf_diameter_3gpp_nor_flags,
730                         { "NOR Flags", "diameter.3gpp.nor_flags",
731                         FT_UINT32, BASE_HEX, NULL, 0x0,
732                         NULL, HFILL }
733                 },
734                 { &hf_diameter_3gpp_nor_flags_bit0,
735                         { "Single-Registration-Indication", "diameter.3gpp.nor_flags_bit0",
736                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
737                         NULL, HFILL }
738                 },
739                 { &hf_diameter_3gpp_nor_flags_bit1,
740                         { "SGSN area restricted", "diameter.3gpp.nor_flags_bit1",
741                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
742                         NULL, HFILL }
743                 },
744                 { &hf_diameter_3gpp_nor_flags_bit2,
745                         { "Ready for SM", "diameter.3gpp.nor_flags_bit2",
746                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
747                         NULL, HFILL }
748                 },
749                 { &hf_diameter_3gpp_nor_flags_bit3,
750                         { "UE Reachable", "diameter.3gpp.nor_flags_bit3",
751                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
752                         NULL, HFILL }
753                 },
754                 { &hf_diameter_3gpp_nor_flags_bit4,
755                         { "Delete all APN and PDN GW identity pairs", "diameter.3gpp.nor_flags_bit4",
756                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
757                         NULL, HFILL }
758                 },
759                 { &hf_diameter_3gpp_idr_flags,
760                         { "IDR Flags", "diameter.3gpp.idr_flags",
761                         FT_UINT32, BASE_HEX, NULL, 0x0,
762                         NULL, HFILL }
763                 },
764                 { &hf_diameter_3gpp_idr_flags_bit0,
765                         { "UE Reachability Request", "diameter.3gpp.idr_flags_bit0",
766                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
767                         NULL, HFILL }
768                 },
769                 { &hf_diameter_3gpp_idr_flags_bit1,
770                         { "T-ADS Data Request", "diameter.3gpp.idr_flags_bit1",
771                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
772                         NULL, HFILL }
773                 },
774                 { &hf_diameter_3gpp_idr_flags_bit2,
775                         { "EPS User State Request", "diameter.3gpp.idr_flags_bit2",
776                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
777                         NULL, HFILL }
778                 },
779                 { &hf_diameter_3gpp_idr_flags_bit3,
780                         { "EPS Location Information Request", "diameter.3gpp.idr_flags_bit3",
781                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
782                         NULL, HFILL }
783                 },
784                 { &hf_diameter_3gpp_idr_flags_bit4,
785                         { "Current Location Request", "diameter.3gpp.idr_flags_bit4",
786                         FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
787                         NULL, HFILL }
788                 },
789         };
790
791         /* Setup protocol subtree array */
792         static gint *ett[] = {
793                 &diameter_3gpp_msisdn_ett,
794                 &diameter_3gpp_tmgi_ett,
795                 &diameter_3gpp_ulr_flags_ett,
796                 &diameter_3gpp_ula_flags_ett,
797                 &diameter_3gpp_dsr_flags_ett,
798                 &diameter_3gpp_dsa_flags_ett,
799                 &diameter_3gpp_ida_flags_ett,
800                 &diameter_3gpp_pua_flags_ett,
801                 &diameter_3gpp_nor_flags_ett,
802                 &diameter_3gpp_idr_flags_ett,
803         };
804
805         /* Required function calls to register the header fields and subtrees used */
806         proto_diameter_3gpp = proto_register_protocol("Diameter 3GPP","Diameter3GPP", "diameter3gpp");
807         proto_register_field_array(proto_diameter_3gpp, hf, array_length(hf));
808         proto_register_subtree_array(ett, array_length(ett));
809 }