aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-diameter_3gpp.c
blob: 9a2874c326122fcb40bacd9a5586e1f977d18583 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
/* packet-diameter_3gpp.c
 * Routines for dissecting 3GPP OctetSting AVP:s
 * Copyright 2008, Anders Broman <anders.broman[at]ericsson.com>
 *
 * $Id$
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@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.
 */

 /* This dissector registers a dissector table for 3GPP Vendor specific
  * AVP:s which will be called from the Diameter dissector to dissect
  * the content of AVP:s of the OctetString type(or similar).
  */

  #ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <stdlib.h>

#include <glib.h>

#include <epan/packet.h>
#include <epan/proto.h>
#include <epan/asn1.h>

#include "packet-gsm_map.h"
#include "packet-gsm_a_common.h"
#include "packet-e164.h"
#include "packet-e212.h"

/* Initialize the protocol and registered fields */
static int proto_diameter_3gpp			= -1;

static int hf_diameter_3gpp_msisdn					= -1;
static int hf_diameter_3gpp_user_data				= -1;
static int hf_diameter_3gpp_ipaddr					= -1;
static int hf_diameter_3gpp_mbms_required_qos_prio	= -1;
static int hf_diameter_3gpp_tmgi					= -1;
static int hf_diameter_mbms_service_id				= -1;
static int hf_diameter_address_digits = -1;
static int hf_diameter_3gpp_spare_bits = -1;
static int hf_diameter_3gpp_ulr_flags = -1;
static int hf_diameter_3gpp_ulr_flags_bit0 = -1;
static int hf_diameter_3gpp_ulr_flags_bit1 = -1;
static int hf_diameter_3gpp_ulr_flags_bit2 = -1;
static int hf_diameter_3gpp_ulr_flags_bit3 = -1;
static int hf_diameter_3gpp_ulr_flags_bit4 = -1;
static int hf_diameter_3gpp_ulr_flags_bit5 = -1;
static int hf_diameter_3gpp_ulr_flags_bit6 = -1;
static int hf_diameter_3gpp_ula_flags = -1;
static int hf_diameter_3gpp_ula_flags_bit0 = -1;
static int hf_diameter_3gpp_dsr_flags = -1;
static int hf_diameter_3gpp_dsr_flags_bit0 = -1;
static int hf_diameter_3gpp_dsr_flags_bit1 = -1;
static int hf_diameter_3gpp_dsr_flags_bit2 = -1;
static int hf_diameter_3gpp_dsr_flags_bit3 = -1;
static int hf_diameter_3gpp_dsr_flags_bit4 = -1;
static int hf_diameter_3gpp_dsr_flags_bit5 = -1;
static int hf_diameter_3gpp_dsr_flags_bit6 = -1;
static int hf_diameter_3gpp_dsr_flags_bit7 = -1;
static int hf_diameter_3gpp_dsr_flags_bit8 = -1;
static int hf_diameter_3gpp_dsr_flags_bit9 = -1;
static int hf_diameter_3gpp_dsr_flags_bit10 = -1;
static int hf_diameter_3gpp_dsr_flags_bit11 = -1;
static int hf_diameter_3gpp_dsr_flags_bit12 = -1;
static int hf_diameter_3gpp_dsr_flags_bit13 = -1;
static int hf_diameter_3gpp_dsa_flags = -1;
static int hf_diameter_3gpp_dsa_flags_bit0 = -1;
static int hf_diameter_3gpp_ida_flags = -1;
static int hf_diameter_3gpp_ida_flags_bit0 = -1;
static int hf_diameter_3gpp_pua_flags = -1;
static int hf_diameter_3gpp_pua_flags_bit0 = -1;
static int hf_diameter_3gpp_pua_flags_bit1 = -1;
static int hf_diameter_3gpp_nor_flags = -1;
static int hf_diameter_3gpp_nor_flags_bit0 = -1;
static int hf_diameter_3gpp_nor_flags_bit1 = -1;
static int hf_diameter_3gpp_nor_flags_bit2 = -1;
static int hf_diameter_3gpp_nor_flags_bit3 = -1;
static int hf_diameter_3gpp_nor_flags_bit4 = -1;
static int hf_diameter_3gpp_idr_flags = -1;
static int hf_diameter_3gpp_idr_flags_bit0 = -1;
static int hf_diameter_3gpp_idr_flags_bit1 = -1;
static int hf_diameter_3gpp_idr_flags_bit2 = -1;
static int hf_diameter_3gpp_idr_flags_bit3 = -1;
static int hf_diameter_3gpp_idr_flags_bit4 = -1;

static gint diameter_3gpp_msisdn_ett				= -1;
static gint diameter_3gpp_tmgi_ett					= -1;
static gint diameter_3gpp_ulr_flags_ett = -1;
static gint diameter_3gpp_ula_flags_ett = -1;
static gint diameter_3gpp_dsr_flags_ett = -1;
static gint diameter_3gpp_dsa_flags_ett = -1;
static gint diameter_3gpp_ida_flags_ett = -1;
static gint diameter_3gpp_pua_flags_ett = -1;
static gint diameter_3gpp_nor_flags_ett = -1;
static gint diameter_3gpp_idr_flags_ett = -1;

/* Dissector handles */
static dissector_handle_t xml_handle;

/* AVP Code: 701 MSISDN */
static int
dissect_diameter_3gpp_msisdn(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {

	proto_item* item;
	proto_tree *sub_tree;
	int offset = 0;
	const char     *digit_str;

	item = proto_tree_add_item(tree, hf_diameter_3gpp_msisdn, tvb, offset, 6, FALSE);
	sub_tree = proto_item_add_subtree(item,diameter_3gpp_msisdn_ett);

	dissect_e164_cc(tvb, sub_tree, offset, TRUE);

	digit_str = unpack_digits(tvb, 1);
	proto_tree_add_string(sub_tree, hf_diameter_address_digits, tvb, 1, -1, digit_str);

	return tvb_length(tvb);

}

/* AVP Code: 702 User-Data 
 * TGPPSh.xml
 * The AVP codes from 709 to799 are reserved for TS 29.329
 */
/* AVP Code: 606 User-Data 
 * imscxdx.xml
 * IMS Cx Dx AVPS 3GPP TS 29.229
 */
static int
dissect_diameter_3gpp_user_data(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {

	guint8		word[6];
	int length = tvb_length(tvb);

	/* If there is less than 38 characters this is not XML
	 * <?xml version="1.0" encoding="UTF-8"?>
	 */
	if(length < 38)
		return length;

	tvb_get_nstringz0(tvb, 0, sizeof(word),word);
	if (g_ascii_strncasecmp(word, "<?xml", 5) == 0){
		call_dissector(xml_handle, tvb, pinfo, tree);
	}

	return length;

}

/* AVP Code: 900 TMGI */
static int
dissect_diameter_3gpp_tmgi(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {

	proto_item* item;
	proto_tree *sub_tree;
	int offset = 0;

	item = proto_tree_add_item(tree, hf_diameter_3gpp_tmgi, tvb, offset, 6, FALSE);
	sub_tree = proto_item_add_subtree(item,diameter_3gpp_tmgi_ett);

	/* MBMS Service ID consisting of three octets. MBMS Service ID consists of a 6-digit
	 * fixed-length hexadecimal number between 000000 and FFFFFF.
	 * MBMS Service ID uniquely identifies an MBMS bearer service within a PLMN.
	 */

	proto_tree_add_item(sub_tree, hf_diameter_mbms_service_id, tvb, offset, 3, FALSE);
	offset = offset+3;
	offset = dissect_e212_mcc_mnc(tvb, pinfo, sub_tree, offset, TRUE);

	return offset;

}

/* AVP Code: 918 MBMS-BMSC-SSM-IP-Address */
static int
dissect_diameter_3gpp_ipaddr(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {

	int offset = 0;

	proto_tree_add_item(tree, hf_diameter_3gpp_ipaddr, tvb, offset, 4, FALSE);
	offset += 4;

	return offset;

}

/* AVP Code: 913 MBMS-Required-QoS */
static int
dissect_diameter_3gpp_mbms_required_qos(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {

	int offset = 0;
	guint length;

	/* Octet
	 * 1		Allocation/Retention Priority as specified in 3GPP TS 23.107.
	 *			This octet encodes each priority level defined in 3GPP TS 23.107
	 *			as the binary value of the priority level. It specifies the relative
	 *			importance of the actual MBMS bearer service compared to other MBMS
	 *			and non-MBMS bearer services for allocation and retention of the
	 *			MBMS bearer service.
	 * 2-N		QoS Profile as specified by the Quality-of-Service information element,
	 *			from octet 3 onwards, in 3GPP TS 24.008
	 */
	proto_tree_add_item(tree, hf_diameter_3gpp_mbms_required_qos_prio, tvb, offset, 1, FALSE);
	offset++;
	length = tvb_length(tvb) - 1;
	de_sm_qos(tvb, tree, offset, length, NULL, 0);
	return offset+length;

}

/* AVP Code: 1405 ULR-Flags */
static int
dissect_diameter_3gpp_ulr_flags(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {

	proto_item* item;
	proto_tree *sub_tree;
	int offset = 0;
	guint32 bit_offset;

	item = proto_tree_add_item(tree, hf_diameter_3gpp_ulr_flags, tvb, offset, 4, FALSE);
	sub_tree = proto_item_add_subtree(item, diameter_3gpp_ulr_flags_ett);
	bit_offset = 0;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_spare_bits, tvb, bit_offset, 25, FALSE);
	bit_offset+=25;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_ulr_flags_bit6, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_ulr_flags_bit5, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_ulr_flags_bit4, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_ulr_flags_bit3, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_ulr_flags_bit2, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_ulr_flags_bit1, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_ulr_flags_bit0, tvb, bit_offset, 1, FALSE);
	bit_offset++;

	offset = bit_offset>>3;
	return offset;

}

/* AVP Code: 1406 ULA-Flags */
static int
dissect_diameter_3gpp_ula_flags(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {

	proto_item* item;
	proto_tree *sub_tree;
	int offset = 0;
	guint32 bit_offset;

	item = proto_tree_add_item(tree, hf_diameter_3gpp_ula_flags, tvb, offset, 4, FALSE);
	sub_tree = proto_item_add_subtree(item, diameter_3gpp_ula_flags_ett);
	bit_offset = 0;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_spare_bits, tvb, bit_offset, 31, FALSE);
	bit_offset+=31;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_ula_flags_bit0, tvb, bit_offset, 1, FALSE);
	bit_offset++;

	offset = bit_offset>>3;
	return offset;

}

/* AVP Code: 1421 DSR-Flags */
static int
dissect_diameter_3gpp_dsr_flags(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {

	proto_item* item;
	proto_tree *sub_tree;
	int offset = 0;
	guint32 bit_offset;

	item = proto_tree_add_item(tree, hf_diameter_3gpp_dsr_flags, tvb, offset, 4, FALSE);
	sub_tree = proto_item_add_subtree(item, diameter_3gpp_dsr_flags_ett);
	bit_offset = 0;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_spare_bits, tvb, bit_offset, 18, FALSE);
	bit_offset+=18;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit13, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit12, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit11, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit10, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit9, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit8, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit7, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit6, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit5, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit4, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit3, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit2, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit1, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsr_flags_bit0, tvb, bit_offset, 1, FALSE);
	bit_offset++;

	offset = bit_offset>>3;
	return offset;

}

/* AVP Code: 1422 DSA-Flags */
static int
dissect_diameter_3gpp_dsa_flags(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {

	proto_item* item;
	proto_tree *sub_tree;
	int offset = 0;
	guint32 bit_offset;

	item = proto_tree_add_item(tree, hf_diameter_3gpp_dsa_flags, tvb, offset, 4, FALSE);
	sub_tree = proto_item_add_subtree(item, diameter_3gpp_dsa_flags_ett);
	bit_offset = 0;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_spare_bits, tvb, bit_offset, 31, FALSE);
	bit_offset+=31;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_dsa_flags_bit0, tvb, bit_offset, 1, FALSE);
	bit_offset++;

	offset = bit_offset>>3;
	return offset;

}

/* AVP Code: 1441 IDA-Flags */
static int
dissect_diameter_3gpp_ida_flags(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {

	proto_item* item;
	proto_tree *sub_tree;
	int offset = 0;
	guint32 bit_offset;

	item = proto_tree_add_item(tree, hf_diameter_3gpp_ida_flags, tvb, offset, 4, FALSE);
	sub_tree = proto_item_add_subtree(item, diameter_3gpp_ida_flags_ett);
	bit_offset = 0;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_spare_bits, tvb, bit_offset, 31, FALSE);
	bit_offset+=31;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_ida_flags_bit0, tvb, bit_offset, 1, FALSE);
	bit_offset++;

	offset = bit_offset>>3;
	return offset;

}

/* AVP Code: 1442 PUA-Flags */
static int
dissect_diameter_3gpp_pua_flags(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {

	proto_item* item;
	proto_tree *sub_tree;
	int offset = 0;
	guint32 bit_offset;

	item = proto_tree_add_item(tree, hf_diameter_3gpp_pua_flags, tvb, offset, 4, FALSE);
	sub_tree = proto_item_add_subtree(item, diameter_3gpp_pua_flags_ett);
	bit_offset = 0;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_spare_bits, tvb, bit_offset, 30, FALSE);
	bit_offset+=30;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_pua_flags_bit1, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_pua_flags_bit0, tvb, bit_offset, 1, FALSE);
	bit_offset++;

	offset = bit_offset>>3;
	return offset;


}

/* AVP Code: 1443 NOR-Flags */
static int
dissect_diameter_3gpp_nor_flags(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {

	proto_item* item;
	proto_tree *sub_tree;
	int offset = 0;
	guint32 bit_offset;

	item = proto_tree_add_item(tree, hf_diameter_3gpp_nor_flags, tvb, offset, 4, FALSE);
	sub_tree = proto_item_add_subtree(item, diameter_3gpp_nor_flags_ett);
	bit_offset = 0;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_spare_bits, tvb, bit_offset, 27, FALSE);
	bit_offset+=27;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_nor_flags_bit4, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_nor_flags_bit3, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_nor_flags_bit2, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_nor_flags_bit1, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_nor_flags_bit0, tvb, bit_offset, 1, FALSE);
	bit_offset++;

	offset = bit_offset>>3;
	return offset;

}

/* AVP Code: 1490 IDR-Flags */
static int
dissect_diameter_3gpp_idr_flags(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {

	proto_item* item;
	proto_tree *sub_tree;
	int offset = 0;
	guint32 bit_offset;

	item = proto_tree_add_item(tree, hf_diameter_3gpp_idr_flags, tvb, offset, 4, FALSE);
	sub_tree = proto_item_add_subtree(item, diameter_3gpp_idr_flags_ett);
	bit_offset = 0;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_spare_bits, tvb, bit_offset, 27, FALSE);
	bit_offset+=27;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_idr_flags_bit4, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_idr_flags_bit3, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_idr_flags_bit2, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_idr_flags_bit1, tvb, bit_offset, 1, FALSE);
	bit_offset++;
	proto_tree_add_bits_item(sub_tree, hf_diameter_3gpp_idr_flags_bit0, tvb, bit_offset, 1, FALSE);
	bit_offset++;

	offset = bit_offset>>3;
	return offset;

}

void
proto_reg_handoff_diameter_3gpp(void)
{

	/* AVP Code: 5 3GPP-GPRS Negotiated QoS profile */
	/* Registered by packet-gtp.c */

	/* AVP Code: 22 3GPP-User-Location-Info
	 * Registered by packet-gtpv2.c
	 */

	/* AVP Code: 606 User-Data */
	dissector_add_uint("diameter.3gpp", 606, new_create_dissector_handle(dissect_diameter_3gpp_user_data, proto_diameter_3gpp));

	/* AVP Code: 701 MSISDN */
	dissector_add_uint("diameter.3gpp", 701, new_create_dissector_handle(dissect_diameter_3gpp_msisdn, proto_diameter_3gpp));

	/* AVP Code: 702 User-Data */
	dissector_add_uint("diameter.3gpp", 702, new_create_dissector_handle(dissect_diameter_3gpp_user_data, proto_diameter_3gpp));

	/* AVP Code: 900 TMGI */
	dissector_add_uint("diameter.3gpp", 900, new_create_dissector_handle(dissect_diameter_3gpp_tmgi, proto_diameter_3gpp));

	/* AVP Code: 904 MBMS-Session-Duration */
	/* AVP Code: 911 MBMS-Time-To-Data-Transfer */
	/* Registered by packet-gtp.c */

	/* AVP Code: 913 MBMS-Required-QoS */
	dissector_add_uint("diameter.3gpp", 913, new_create_dissector_handle(dissect_diameter_3gpp_mbms_required_qos, proto_diameter_3gpp));

	/* AVP Code: 918 MBMS-BMSC-SSM-IP-Address */
	dissector_add_uint("diameter.3gpp", 918, new_create_dissector_handle(dissect_diameter_3gpp_ipaddr, proto_diameter_3gpp));

	/* AVP Code: 1405 ULR-Flags */
	dissector_add_uint("diameter.3gpp", 1405, new_create_dissector_handle(dissect_diameter_3gpp_ulr_flags, proto_diameter_3gpp));

	/* AVP Code: 1406 ULA-Flags */
	dissector_add_uint("diameter.3gpp", 1406, new_create_dissector_handle(dissect_diameter_3gpp_ula_flags, proto_diameter_3gpp));

	/* AVP Code: 1421 DSR-Flags */
	dissector_add_uint("diameter.3gpp", 1421, new_create_dissector_handle(dissect_diameter_3gpp_dsr_flags, proto_diameter_3gpp));

	/* AVP Code: 1422 DSA-Flags */
	dissector_add_uint("diameter.3gpp", 1422, new_create_dissector_handle(dissect_diameter_3gpp_dsa_flags, proto_diameter_3gpp));

	/* AVP Code: 1441 IDA-Flags */
	dissector_add_uint("diameter.3gpp", 1441, new_create_dissector_handle(dissect_diameter_3gpp_ida_flags, proto_diameter_3gpp));

	/* AVP Code: 1442 PUA-Flags */
	dissector_add_uint("diameter.3gpp", 1442, new_create_dissector_handle(dissect_diameter_3gpp_pua_flags, proto_diameter_3gpp));

	/* AVP Code: 1443 NOR-Flags */
	dissector_add_uint("diameter.3gpp", 1443, new_create_dissector_handle(dissect_diameter_3gpp_nor_flags, proto_diameter_3gpp));

	/* AVP Code: 1490 IDR-Flags */
	dissector_add_uint("diameter.3gpp", 1490, new_create_dissector_handle(dissect_diameter_3gpp_idr_flags, proto_diameter_3gpp));

	xml_handle = find_dissector("xml");
}

void
proto_register_diameter_3gpp(void)
{

/* Setup list of header fields  See Section 1.6.1 for details*/
	static hf_register_info hf[] = {
		{ &hf_diameter_3gpp_msisdn,
			{ "MSISDN",           "diameter.3gpp.msisdn",
			FT_BYTES, BASE_NONE, NULL, 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_user_data,
			{ "User data",           "diameter.3gpp.user_data",
			FT_STRING, BASE_NONE, NULL, 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_ipaddr,
			{ "IPv4 Address",           "diameter.3gpp.ipaddr",
			FT_IPv4, BASE_NONE, NULL, 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_mbms_required_qos_prio,
			{ "Allocation/Retention Priority",           "diameter.3gpp.mbms_required_qos_prio",
			FT_UINT8, BASE_DEC, NULL, 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_tmgi,
			{ "TMGI",           "diameter.3gpp.tmgi",
			FT_BYTES, BASE_NONE, NULL, 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_mbms_service_id,
			{ "MBMS Service ID",           "diameter.3gpp.mbms_service_id",
			FT_UINT24, BASE_HEX, NULL, 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_address_digits,
			{ "Address digits", "diameter.3gpp.address_digits",
			FT_STRING, BASE_NONE, NULL, 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_spare_bits,
			{ "Spare bit(s)", "diameter.3gpp.spare_bits",
			FT_UINT32, BASE_HEX, NULL, 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_ulr_flags,
			{ "ULR Flags", "diameter.3gpp.ulr_flags",
			FT_UINT32, BASE_HEX, NULL, 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_ulr_flags_bit0,
			{ "Single-Registration-Indication", "diameter.3gpp.ulr_flags_bit0",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_ulr_flags_bit1,
			{ "S6a/S6d-Indicator", "diameter.3gpp.ulr_flags_bit1",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_ulr_flags_bit2,
			{ "Skip-Subscriber-Data", "diameter.3gpp.ulr_flags_bit2",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_ulr_flags_bit3,
			{ "GPRS-Subscription-Data-Indicator", "diameter.3gpp.ulr_flags_bit3",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_ulr_flags_bit4,
			{ "Node-Type-Indicator", "diameter.3gpp.ulr_flags_bit4",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_ulr_flags_bit5,
			{ "Initial-Attach-Indicator", "diameter.3gpp.ulr_flags_bit5",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_ulr_flags_bit6,
			{ "PS-LCS-Not-Supported-By-UE", "diameter.3gpp.ulr_flags_bit6",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_ula_flags,
			{ "ULA Flags", "diameter.3gpp.ula_flags",
			FT_UINT32, BASE_HEX, NULL, 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_ula_flags_bit0,
			{ "Separation Indication", "diameter.3gpp.ula_flags_bit0",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_dsr_flags,
			{ "DSR Flags", "diameter.3gpp.dsr_flags",
			FT_UINT32, BASE_HEX, NULL, 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_dsr_flags_bit0,
			{ "Regional Subscription Withdrawal", "diameter.3gpp.dsr_flags_bit0",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_dsr_flags_bit1,
			{ "Complete APN Configuration Profile Withdrawal", "diameter.3gpp.dsr_flags_bit1",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_dsr_flags_bit2,
			{ "Subscribed Charging Characteristics Withdrawal", "diameter.3gpp.dsr_flags_bit2",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_dsr_flags_bit3,
			{ "PDN subscription contexts Withdrawal", "diameter.3gpp.dsr_flags_bit3",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_dsr_flags_bit4,
			{ "STN-SR", "diameter.3gpp.dsr_flags_bit4",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_dsr_flags_bit5,
			{ "Complete PDP context list Withdrawal", "diameter.3gpp.dsr_flags_bit5",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_dsr_flags_bit6,
			{ "PDP contexts Withdrawal", "diameter.3gpp.dsr_flags_bit6",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_dsr_flags_bit7,
			{ "Roaming Restricted due to unsupported feature", "diameter.3gpp.dsr_flags_bit7",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_dsr_flags_bit8,
			{ "Trace Data Withdrawal", "diameter.3gpp.dsr_flags_bit8",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_dsr_flags_bit9,
			{ "CSG Deleted", "diameter.3gpp.dsr_flags_bit9",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_dsr_flags_bit10,
			{ "APN-OI-Replacement", "diameter.3gpp.dsr_flags_bit10",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_dsr_flags_bit11,
			{ "GMLC List Withdrawal", "diameter.3gpp.dsr_flags_bit11",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_dsr_flags_bit12,
			{ "LCS Withdrawal", "diameter.3gpp.dsr_flags_bit12",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_dsr_flags_bit13,
			{ "SMS Withdrawal", "diameter.3gpp.dsr_flags_bit13",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_dsa_flags,
			{ "DSA Flags", "diameter.3gpp.dsa_flags",
			FT_UINT32, BASE_HEX, NULL, 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_dsa_flags_bit0,
			{ "Network Node area restricted", "diameter.3gpp.dsa_flags_bit0",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_ida_flags,
			{ "IDA Flags", "diameter.3gpp.ida_flags",
			FT_UINT32, BASE_HEX, NULL, 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_ida_flags_bit0,
			{ "Network Node area restricted", "diameter.3gpp.ida_flags_bit0",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_pua_flags,
			{ "PUA Flags", "diameter.3gpp.pua_flags",
			FT_UINT32, BASE_HEX, NULL, 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_pua_flags_bit0,
			{ "Freeze M-TMSI", "diameter.3gpp.pua_flags_bit0",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_pua_flags_bit1,
			{ "Freeze P-TMSI", "diameter.3gpp.pua_flags_bit1",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_nor_flags,
			{ "NOR Flags", "diameter.3gpp.nor_flags",
			FT_UINT32, BASE_HEX, NULL, 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_nor_flags_bit0,
			{ "Single-Registration-Indication", "diameter.3gpp.nor_flags_bit0",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_nor_flags_bit1,
			{ "SGSN area restricted", "diameter.3gpp.nor_flags_bit1",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_nor_flags_bit2,
			{ "Ready for SM", "diameter.3gpp.nor_flags_bit2",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_nor_flags_bit3,
			{ "UE Reachable", "diameter.3gpp.nor_flags_bit3",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_nor_flags_bit4,
			{ "Delete all APN and PDN GW identity pairs", "diameter.3gpp.nor_flags_bit4",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_idr_flags,
			{ "IDR Flags", "diameter.3gpp.idr_flags",
			FT_UINT32, BASE_HEX, NULL, 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_idr_flags_bit0,
			{ "UE Reachability Request", "diameter.3gpp.idr_flags_bit0",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_idr_flags_bit1,
			{ "T-ADS Data Request", "diameter.3gpp.idr_flags_bit1",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_idr_flags_bit2,
			{ "EPS User State Request", "diameter.3gpp.idr_flags_bit2",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_idr_flags_bit3,
			{ "EPS Location Information Request", "diameter.3gpp.idr_flags_bit3",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
		{ &hf_diameter_3gpp_idr_flags_bit4,
			{ "Current Location Request", "diameter.3gpp.idr_flags_bit4",
			FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
			NULL, HFILL }
		},
	};

	/* Setup protocol subtree array */
	static gint *ett[] = {
		&diameter_3gpp_msisdn_ett,
		&diameter_3gpp_tmgi_ett,
		&diameter_3gpp_ulr_flags_ett,
		&diameter_3gpp_ula_flags_ett,
		&diameter_3gpp_dsr_flags_ett,
		&diameter_3gpp_dsa_flags_ett,
		&diameter_3gpp_ida_flags_ett,
		&diameter_3gpp_pua_flags_ett,
		&diameter_3gpp_nor_flags_ett,
		&diameter_3gpp_idr_flags_ett,
	};

	/* Required function calls to register the header fields and subtrees used */
	proto_diameter_3gpp = proto_register_protocol("Diameter 3GPP","Diameter3GPP", "diameter3gpp");
	proto_register_field_array(proto_diameter_3gpp, hf, array_length(hf));
	proto_register_subtree_array(ett, array_length(ett));
}