aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/asn1/rrc/packet-rrc-template.c
blob: a4be1d7d8e86bd9b41d778a35fc8e49cb6a43f24 (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
/* packet-rrc.c
 * Routines for Universal Mobile Telecommunications System (UMTS);
 * Radio Resource Control (RRC) protocol specification
 * (3GPP TS 25.331  packet dissection)
 * Copyright 2006-2010, Anders Broman <anders.broman@ericsson.com>
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 *
 * Ref: 3GPP TS 25.331 V15.4.0 (2018-09)
 */

/**
 *
 * TODO:
 * - Fix ciphering information for circuit switched stuff
 */

#include "config.h"

#include <epan/packet.h>
#include <epan/asn1.h>
#include <epan/conversation.h>
#include <epan/expert.h>
#include <epan/proto_data.h>

#include "packet-ber.h"
#include "packet-per.h"
#include "packet-rrc.h"
#include "packet-gsm_a_common.h"
#include "packet-nbap.h"
#include "packet-umts_fp.h"
#include "packet-umts_mac.h"
#include "packet-umts_rlc.h"

#ifdef _MSC_VER
/* disable: "warning C4049: compiler limit : terminating line number emission" */
#pragma warning(disable:4049)
/* disable: "warning C4146: unary minus operator applied to unsigned type, result still unsigned" */
#pragma warning(disable:4146)
#endif

#define PNAME  "Radio Resource Control (RRC) protocol"
#define PSNAME "RRC"
#define PFNAME "rrc"

extern int proto_fp;       /*Handler to FP*/
extern int proto_umts_mac; /*Handler to MAC*/
extern int proto_umts_rlc; /*Handler to RLC*/

GTree * hsdsch_muxed_flows = NULL;
GTree * rrc_ciph_info_tree = NULL;
wmem_tree_t* rrc_global_urnti_crnti_map = NULL;
static int msg_type _U_;

enum rrc_sib_segment_type {
  RRC_SIB_SEG_NO_SEGMENT = 0,
  RRC_SIB_SEG_FIRST = 1,
  RRC_SIB_SEG_SUBSEQUENT = 2,
  RRC_SIB_SEG_LAST_SHORT = 3,
  RRC_SIB_SEG_LAST_AND_FIRST = 4,
  RRC_SIB_SEG_LAST_AND_COMP = 5,
  RRC_SIB_SEG_LAST_AND_COMP_AND_FIRST = 6,
  RRC_SIB_SEG_COMP_LIST = 7,
  RRC_SIB_SEG_COMP_AND_FIRST = 8,
  RRC_SIB_SEG_COMP = 10,
};

/*****************************************************************************/
/* Packet private data                                                       */
/* For this dissector, all access to actx->private_data should be made       */
/* through this API, which ensures that they will not overwrite each other!! */
/*****************************************************************************/

typedef struct umts_rrc_private_data_t
{
  guint32 s_rnc_id; /* The S-RNC ID part of a U-RNTI */
  guint32 s_rnti; /* The S-RNTI part of a U-RNTI */
  guint32 new_u_rnti;
  guint32 current_u_rnti;
  guint32 scrambling_code;
  enum nas_sys_info_gsm_map cn_domain;
  wmem_strbuf_t* digits_strbuf; /* A collection of digits in a string. Used for reconstructing IMSIs or MCC-MNC pairs */
  wmem_strbuf_t* last_mcc_strbuf; /* Last seen MCC digits string */
  gboolean digits_strbuf_parsing_failed_flag; /* Whether an error occured when creating the IMSI/MCC-MNC pair string */
  guint32 rbid;
  guint32 rlc_ciphering_sqn; /* Sequence number where ciphering starts in a given bearer */
  rrc_ciphering_info* ciphering_info;
  enum rrc_ue_state rrc_state_indicator;
  enum rrc_sib_segment_type curr_sib_segment_type;
  guint32 curr_sib_type;
} umts_rrc_private_data_t;


/* Helper function to get or create a struct that will be actx->private_data */
static umts_rrc_private_data_t* umts_rrc_get_private_data(asn1_ctx_t *actx)
{
  if (actx->private_data == NULL) {
    actx->private_data = wmem_new0(wmem_packet_scope(), umts_rrc_private_data_t);
  }
  return (umts_rrc_private_data_t*)actx->private_data;
}

static guint32 private_data_get_s_rnc_id(asn1_ctx_t *actx)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  return private_data->s_rnc_id;
}

static void private_data_set_s_rnc_id(asn1_ctx_t *actx, guint32 s_rnc_id)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  private_data->s_rnc_id = s_rnc_id;
}

static guint32 private_data_get_s_rnti(asn1_ctx_t *actx)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  return private_data->s_rnti;
}

static void private_data_set_s_rnti(asn1_ctx_t *actx, guint32 s_rnti)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  private_data->s_rnti = s_rnti;
}

static guint32 private_data_get_new_u_rnti(asn1_ctx_t *actx)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  return private_data->new_u_rnti;
}

static void private_data_set_new_u_rnti(asn1_ctx_t *actx, guint32 new_u_rnti)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  private_data->new_u_rnti = new_u_rnti;
}

static guint32 private_data_get_current_u_rnti(asn1_ctx_t *actx)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  return private_data->current_u_rnti;
}

static void private_data_set_current_u_rnti(asn1_ctx_t *actx, guint32 current_u_rnti)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  private_data->current_u_rnti = current_u_rnti;
}

static guint32 private_data_get_scrambling_code(asn1_ctx_t *actx)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  return private_data->scrambling_code;
}

static void private_data_set_scrambling_code(asn1_ctx_t *actx, guint32 scrambling_code)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  private_data->scrambling_code = scrambling_code;
}

static enum nas_sys_info_gsm_map private_data_get_cn_domain(asn1_ctx_t *actx)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  return private_data->cn_domain;
}

static void private_data_set_cn_domain(asn1_ctx_t *actx, enum nas_sys_info_gsm_map cn_domain)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  private_data->cn_domain = cn_domain;
}

static wmem_strbuf_t* private_data_get_digits_strbuf(asn1_ctx_t *actx)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  return private_data->digits_strbuf;
}

static void private_data_set_digits_strbuf(asn1_ctx_t *actx, wmem_strbuf_t* digits_strbuf)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  private_data->digits_strbuf = digits_strbuf;
}

static gboolean private_data_get_digits_strbuf_parsing_failed_flag(asn1_ctx_t *actx)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  return private_data->digits_strbuf_parsing_failed_flag;
}

static void private_data_set_digits_strbuf_parsing_failed_flag(asn1_ctx_t *actx, gboolean digits_strbuf_parsing_failed_flag)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  private_data->digits_strbuf_parsing_failed_flag = digits_strbuf_parsing_failed_flag;
}

static wmem_strbuf_t* private_data_get_last_mcc_strbuf(asn1_ctx_t *actx)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  return private_data->last_mcc_strbuf;
}

static void private_data_set_last_mcc_strbuf(asn1_ctx_t *actx, wmem_strbuf_t* last_mcc_strbuf)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  private_data->last_mcc_strbuf = last_mcc_strbuf;
}

static guint32 private_data_get_rbid(asn1_ctx_t *actx)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  return private_data->rbid;
}

static void private_data_set_rbid(asn1_ctx_t *actx, guint32 rbid)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  private_data->rbid = rbid;
}

static guint32 private_data_get_rlc_ciphering_sqn(asn1_ctx_t *actx)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  return private_data->rlc_ciphering_sqn;
}

static void private_data_set_rlc_ciphering_sqn(asn1_ctx_t *actx, guint32 rlc_ciphering_sqn)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  private_data->rlc_ciphering_sqn = rlc_ciphering_sqn;
}

static rrc_ciphering_info* private_data_get_ciphering_info(asn1_ctx_t *actx)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  return private_data->ciphering_info;
}

static void private_data_set_ciphering_info(asn1_ctx_t *actx, rrc_ciphering_info* ciphering_info)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  private_data->ciphering_info = ciphering_info;
}

static enum rrc_ue_state private_data_get_rrc_state_indicator(asn1_ctx_t *actx)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  return private_data->rrc_state_indicator;
}

static void private_data_set_rrc_state_indicator(asn1_ctx_t *actx, enum rrc_ue_state rrc_state_indicator)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  private_data->rrc_state_indicator = rrc_state_indicator;
}

static enum rrc_sib_segment_type private_data_get_curr_sib_segment_type(asn1_ctx_t *actx)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  return private_data->curr_sib_segment_type;
}

static void private_data_set_curr_sib_segment_type(asn1_ctx_t *actx, enum rrc_sib_segment_type curr_sib_segment_type)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  private_data->curr_sib_segment_type = curr_sib_segment_type;
}

static guint32 private_data_get_curr_sib_type(asn1_ctx_t *actx)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  return private_data->curr_sib_type;
}

static void private_data_set_curr_sib_type(asn1_ctx_t *actx, guint32 curr_sib_type)
{
  umts_rrc_private_data_t *private_data = (umts_rrc_private_data_t*)umts_rrc_get_private_data(actx);
  private_data->curr_sib_type = curr_sib_type;
}

/*****************************************************************************/

static dissector_handle_t gsm_a_dtap_handle;
static dissector_handle_t rrc_ue_radio_access_cap_info_handle=NULL;
static dissector_handle_t rrc_pcch_handle=NULL;
static dissector_handle_t rrc_ul_ccch_handle=NULL;
static dissector_handle_t rrc_dl_ccch_handle=NULL;
static dissector_handle_t rrc_ul_dcch_handle=NULL;
static dissector_handle_t rrc_dl_dcch_handle=NULL;
static dissector_handle_t rrc_bcch_fach_handle=NULL;
static dissector_handle_t lte_rrc_ue_eutra_cap_handle=NULL;
static dissector_handle_t lte_rrc_dl_dcch_handle=NULL;
static dissector_handle_t gsm_rlcmac_dl_handle=NULL;

/* Forward declarations */
void proto_register_rrc(void);
void proto_reg_handoff_rrc(void);
static int dissect_UE_RadioAccessCapabilityInfo_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
static int dissect_SysInfoType11bis_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
static int dissect_SysInfoType11ter_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
static int dissect_SysInfoType22_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);

/* Include constants */
#include "packet-rrc-val.h"

/* Initialize the protocol and registered fields */
int proto_rrc = -1;
static int hf_test;
static int hf_urnti;
static int hf_urnti_new;
static int hf_urnti_current;
#include "packet-rrc-hf.c"

/* Initialize the subtree pointers */
static int ett_rrc = -1;

#include "packet-rrc-ett.c"

static gint ett_rrc_eutraFeatureGroupIndicators = -1;
static gint ett_rrc_cn_CommonGSM_MAP_NAS_SysInfo = -1;
static gint ett_rrc_ims_info = -1;
static gint ett_rrc_cellIdentity = -1;
static gint ett_rrc_sib_data_var = -1;

static expert_field ei_rrc_no_hrnti = EI_INIT;

/* Global variables */
static proto_tree *top_tree;

static int hf_rrc_eutra_feat_group_ind_1 = -1;
static int hf_rrc_eutra_feat_group_ind_2 = -1;
static int hf_rrc_eutra_feat_group_ind_3 = -1;
static int hf_rrc_eutra_feat_group_ind_4 = -1;
static int hf_rrc_ims_info_atgw_trans_det_cont_type = -1;
static int hf_rrc_ims_info_atgw_udp_port = -1;
static int hf_rrc_ims_info_atgw_ipv4 = -1;
static int hf_rrc_ims_info_atgw_ipv6 = -1;
static int hf_rrc_cellIdentity_rnc_id = -1;
static int hf_rrc_cellIdentity_c_id = -1;

static const true_false_string rrc_eutra_feat_group_ind_1_val = {
  "UTRA CELL_PCH to EUTRA RRC_IDLE cell reselection - Supported",
  "UTRA CELL_PCH to EUTRA RRC_IDLE cell reselection - Not supported"
};
static const true_false_string rrc_eutra_feat_group_ind_2_val = {
  "EUTRAN measurements and reporting in connected mode - Supported",
  "EUTRAN measurements and reporting in connected mode - Not supported"
};
static const true_false_string rrc_eutra_feat_group_ind_3_val = {
  "UTRA CELL_FACH absolute priority cell reselection for high priority layers - Supported",
  "UTRA CELL_FACH absolute priority cell reselection for high priority layers - Not supported"
};
static const true_false_string rrc_eutra_feat_group_ind_4_val = {
  "UTRA CELL_FACH absolute priority cell reselection for all layers - Supported",
  "UTRA CELL_FACH absolute priority cell reselection for all layers - Not supported"
};
static const value_string rrc_ims_info_atgw_trans_det_cont_type[] = {
  {0, "ATGW-IPv4-address-and-port"},
  {1, "ATGW-IPv6-address-and-port"},
  {2, "ATGW-not-available"},
  {0, NULL}
};
static int flowd,type;

/*Stores how many channels we have detected for a HS-DSCH MAC-flow*/
#define    RRC_MAX_NUM_HSDHSCH_MACDFLOW 8
static guint8 num_chans_per_flow[RRC_MAX_NUM_HSDHSCH_MACDFLOW];

/**
 * Return the maximum counter, useful for initiating counters
 */
#if 0
static int get_max_counter(int com_context){
    int i;
    guint32 max = 0;
    rrc_ciphering_info * ciphering_info;

    if( (ciphering_info = g_tree_lookup(rrc_ciph_info_tree, GINT_TO_POINTER((gint)com_context))) == NULL ){
        return 0;
    }
    for(i = 0; i<31; i++){
        max = MAX(ciphering_info->ps_conf_counters[i][0], max);
        max = MAX(ciphering_info->ps_conf_counters[i][1], max);
    }
    return max;
}
#endif
/** Utility functions used for various comparisons/cleanups in tree **/
static gint rrc_key_cmp(gconstpointer b_ptr, gconstpointer a_ptr, gpointer ignore _U_){
    if( GPOINTER_TO_INT(a_ptr) > GPOINTER_TO_INT(b_ptr) ){
        return  -1;
    }
    return GPOINTER_TO_INT(a_ptr) < GPOINTER_TO_INT(b_ptr);
}

static void rrc_free_value(gpointer value ){
            g_free(value);
}

static rrc_ciphering_info*
get_or_create_cipher_info(fp_info *fpinf, rlc_info *rlcinf) {
  rrc_ciphering_info *cipher_info = NULL;
  guint32 ueid;
  int i;

  if (!fpinf || !rlcinf)
    return NULL;

  ueid = rlcinf->ueid[fpinf->cur_tb];
  cipher_info = (rrc_ciphering_info *)g_tree_lookup(rrc_ciph_info_tree, GINT_TO_POINTER((gint)ueid));

  if( cipher_info == NULL ){
    cipher_info = g_new0(rrc_ciphering_info,1);

    /*Initiate tree with START_PS values.*/
    if(!cipher_info->start_ps)
      cipher_info->start_ps = g_tree_new_full(rrc_key_cmp,
                                        NULL,NULL,rrc_free_value);

    /*Clear and initialize seq_no matrix*/
    for(i = 0; i< 31; i++){
      cipher_info->seq_no[i][0] = -1;
      cipher_info->seq_no[i][1] = -1;
    }
    g_tree_insert(rrc_ciph_info_tree, GINT_TO_POINTER((gint)rlcinf->ueid[fpinf->cur_tb]), cipher_info);
  }
  return cipher_info;
}

/* Try to find the NBAP C-RNC Context and, if found, pair it with a given U-RNTI */
static void
rrc_try_map_urnti_to_crncc(guint32 u_rnti, asn1_ctx_t *actx)
{
  guint32 scrambling_code, crnc_context;
  /* Getting the user's Uplink Scrambling Code*/
  scrambling_code = private_data_get_scrambling_code(actx);
  if (u_rnti != 0 && scrambling_code != 0) {
    /* Looking for the C-RNC Context mapped to this Scrambling Code */
    crnc_context = GPOINTER_TO_UINT(wmem_tree_lookup32(nbap_scrambling_code_crncc_map,scrambling_code));
    if (crnc_context != 0) {
      /* Mapping the U-RNTI to the C-RNC context*/
      wmem_tree_insert32(nbap_crncc_urnti_map,crnc_context,GUINT_TO_POINTER(u_rnti));
    }
  }
}

#include "packet-rrc-fn.c"


static int
dissect_rrc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
    /* FIX ME Currently don't know the 'starting point' of this protocol
     * exported DL-DCCH-Message is the entry point.
     */
    proto_item    *rrc_item = NULL;
    proto_tree    *rrc_tree = NULL;
    struct rrc_info *rrcinf;

    top_tree = tree;
    rrcinf = (struct rrc_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_rrc, 0);

    /* make entry in the Protocol column on summary display */
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "RRC");

    /*Clear memory*/
    memset(num_chans_per_flow,0,sizeof(guint8)*RRC_MAX_NUM_HSDHSCH_MACDFLOW);

    /* create the rrc protocol tree */
    rrc_item = proto_tree_add_item(tree, proto_rrc, tvb, 0, -1, ENC_NA);
    rrc_tree = proto_item_add_subtree(rrc_item, ett_rrc);

    if (rrcinf) {
        switch (rrcinf->msgtype[pinfo->fd->subnum]) {
            case RRC_MESSAGE_TYPE_PCCH:
                call_dissector(rrc_pcch_handle, tvb, pinfo, rrc_tree);
                break;
            case RRC_MESSAGE_TYPE_UL_CCCH:
                call_dissector(rrc_ul_ccch_handle, tvb, pinfo, rrc_tree);
                break;
            case RRC_MESSAGE_TYPE_DL_CCCH:
                call_dissector(rrc_dl_ccch_handle, tvb, pinfo, rrc_tree);
                break;
            case RRC_MESSAGE_TYPE_UL_DCCH:
                call_dissector(rrc_ul_dcch_handle, tvb, pinfo, rrc_tree);
                break;
            case RRC_MESSAGE_TYPE_DL_DCCH:
                call_dissector(rrc_dl_dcch_handle, tvb, pinfo, rrc_tree);
                break;
            case RRC_MESSAGE_TYPE_BCCH_FACH:
                call_dissector(rrc_bcch_fach_handle, tvb, pinfo, rrc_tree);
                break;
            default:
                ;
        }
    }
    return tvb_captured_length(tvb);
}

static void
rrc_init(void) {
    /*Initialize structure for muxed flow indication*/
    hsdsch_muxed_flows = g_tree_new_full(rrc_key_cmp,
                       NULL,      /* data pointer, optional */
                       NULL,
                       rrc_free_value);

    rrc_ciph_info_tree = g_tree_new_full(rrc_key_cmp,
                       NULL,      /* data pointer, optional */
                       NULL,
                       rrc_free_value);

    /* Global U-RNTI / C-RNTI map to be used in RACH channels */
    rrc_global_urnti_crnti_map = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
}

static void
rrc_cleanup(void) {
    /*Cleanup*/
    g_tree_destroy(hsdsch_muxed_flows);
    g_tree_destroy(rrc_ciph_info_tree);
}

/*--- proto_register_rrc -------------------------------------------*/
void proto_register_rrc(void) {

  /* List of fields */
  static hf_register_info hf[] = {

#include "packet-rrc-hfarr.c"
    { &hf_test,
      { "RAB Test", "rrc.RAB.test",
        FT_UINT8, BASE_DEC, NULL, 0,
        "rrc.RAB_Info_r6", HFILL }},
    { &hf_urnti,
      { "U-RNTI", "rrc.urnti",
        FT_UINT32, BASE_HEX, NULL, 0,
        NULL, HFILL }},
    { &hf_urnti_new,
      { "New U-RNTI", "rrc.urnti_new",
        FT_UINT32, BASE_HEX, NULL, 0,
        NULL, HFILL }},
    { &hf_urnti_current,
      { "Current U-RNTI", "rrc.urnti_current",
        FT_UINT32, BASE_HEX, NULL, 0,
        NULL, HFILL }},
    { &hf_rrc_eutra_feat_group_ind_1,
      { "Indicator 1", "rrc.eutra_feat_group_ind_1",
        FT_BOOLEAN, BASE_NONE, TFS(&rrc_eutra_feat_group_ind_1_val), 0,
        "EUTRA Feature Group Indicator 1", HFILL }},
    { &hf_rrc_eutra_feat_group_ind_2,
      { "Indicator 2", "rrc.eutra_feat_group_ind_2",
        FT_BOOLEAN, BASE_NONE, TFS(&rrc_eutra_feat_group_ind_2_val), 0,
        "EUTRA Feature Group Indicator 2", HFILL }},
    { &hf_rrc_eutra_feat_group_ind_3,
      { "Indicator 3", "rrc.eutra_feat_group_ind_3",
        FT_BOOLEAN, BASE_NONE, TFS(&rrc_eutra_feat_group_ind_3_val), 0,
        "EUTRA Feature Group Indicator 3", HFILL }},
    { &hf_rrc_eutra_feat_group_ind_4,
      { "Indicator 4", "rrc.eutra_feat_group_ind_4",
        FT_BOOLEAN, BASE_NONE, TFS(&rrc_eutra_feat_group_ind_4_val), 0,
        "EUTRA Feature Group Indicator 4", HFILL }},
    { &hf_rrc_ims_info_atgw_trans_det_cont_type,
      { "ATGW transfer details content type", "rrc.rsrvcc_info.ims_info_atgw_trans_det_cont",
        FT_UINT8, BASE_DEC, VALS(rrc_ims_info_atgw_trans_det_cont_type), 0x3,
        "rSR-VCC IMS information ATGW transfer details content type", HFILL }},
    {&hf_rrc_ims_info_atgw_udp_port,
        {"ATGW UDP port","rrc.rsrvcc_info.ims_info_atgw_udp_port",
        FT_UINT16,BASE_DEC, NULL, 0x0,
        "rSR-VCC IMS information ATGW UDP port", HFILL }},
    { &hf_rrc_ims_info_atgw_ipv4,
        {"ATGW IPv4", "rrc.rsrvcc_info.ims_info_atgw_ipv4",
        FT_IPv4, BASE_NONE, NULL, 0x0,
        "rSR-VCC IMS information ATGW IPv4", HFILL}},
    { &hf_rrc_ims_info_atgw_ipv6,
        {"ATGW IPv6", "rrc.rsrvcc_info.ims_info_atgw_ipv6",
        FT_IPv6, BASE_NONE, NULL, 0x0,
        "rSR-VCC IMS information ATGW IPv6", HFILL}},
    { &hf_rrc_cellIdentity_rnc_id,
        {"RNC Identifier", "rrc.cellIdentity.rnc_id",
        FT_UINT32, BASE_DEC, NULL, 0,
        "The RNC Identifier (RNC-Id) part of the Cell Identity", HFILL }},
    { &hf_rrc_cellIdentity_c_id,
        {"Cell Identifier", "rrc.cellIdentity.c_id",
        FT_UINT32, BASE_DEC, NULL, 0,
        "The Cell Identifier (C-Id) part of the Cell Identity", HFILL }}
  };

  /* List of subtrees */
  static gint *ett[] = {
    &ett_rrc,
#include "packet-rrc-ettarr.c"
    &ett_rrc_eutraFeatureGroupIndicators,
    &ett_rrc_cn_CommonGSM_MAP_NAS_SysInfo,
    &ett_rrc_ims_info,
    &ett_rrc_cellIdentity,
    &ett_rrc_sib_data_var,
  };

  static ei_register_info ei[] = {
     { &ei_rrc_no_hrnti, { "rrc.no_hrnti", PI_SEQUENCE, PI_NOTE, "Did not detect any H-RNTI", EXPFILL }},
  };

  expert_module_t* expert_rrc;

  /* Register protocol */
  proto_rrc = proto_register_protocol(PNAME, PSNAME, PFNAME);
  /* Register fields and subtrees */
  proto_register_field_array(proto_rrc, hf, array_length(hf));
  proto_register_subtree_array(ett, array_length(ett));
  expert_rrc = expert_register_protocol(proto_rrc);
  expert_register_field_array(expert_rrc, ei, array_length(ei));

  register_dissector("rrc", dissect_rrc, proto_rrc);

#include "packet-rrc-dis-reg.c"




    register_init_routine(rrc_init);
    register_cleanup_routine(rrc_cleanup);
}


/*--- proto_reg_handoff_rrc ---------------------------------------*/
void
proto_reg_handoff_rrc(void)
{
  gsm_a_dtap_handle = find_dissector_add_dependency("gsm_a_dtap", proto_rrc);
  rrc_pcch_handle = find_dissector("rrc.pcch");
  rrc_ul_ccch_handle = find_dissector("rrc.ul.ccch");
  rrc_dl_ccch_handle = find_dissector("rrc.dl.ccch");
  rrc_ul_dcch_handle = find_dissector("rrc.ul.dcch");
  rrc_dl_dcch_handle = find_dissector("rrc.dl.dcch");
  rrc_ue_radio_access_cap_info_handle = find_dissector("rrc.ue_radio_access_cap_info");
  rrc_dl_dcch_handle = find_dissector("rrc.dl.dcch");
  lte_rrc_ue_eutra_cap_handle = find_dissector_add_dependency("lte-rrc.ue_eutra_cap", proto_rrc);
  lte_rrc_dl_dcch_handle = find_dissector_add_dependency("lte-rrc.dl.dcch", proto_rrc);
  rrc_bcch_fach_handle = find_dissector("rrc.bcch.fach");
  gsm_rlcmac_dl_handle = find_dissector_add_dependency("gsm_rlcmac_dl", proto_rrc);
}