aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/asn1/nr-rrc/packet-nr-rrc-template.c
blob: be4000a1db6a166597b5619e9081e9941fa4072b (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
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
/* packet-nr-rrc-template.c
 * NR;
 * Radio Resource Control (RRC) protocol specification
 * (3GPP TS 38.331 V16.6.0 Release 16) packet dissection
 * Copyright 2018-2021, Pascal Quantin
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include "config.h"

#include <stdlib.h>

#include <epan/packet.h>
#include <epan/asn1.h>
#include <epan/expert.h>
#include <epan/reassemble.h>
#include <epan/exceptions.h>
#include <epan/show_exception.h>
#include <epan/proto_data.h>
#include <epan/prefs.h>

#include <wsutil/str_util.h>
#include <wsutil/epochs.h>

#include "packet-per.h"
#include "packet-gsm_map.h"
#include "packet-cell_broadcast.h"
#include "packet-mac-nr.h"
#include "packet-rlc-nr.h"
#include "packet-pdcp-nr.h"
#include "packet-rrc.h"
#include "packet-lte-rrc.h"
#include "packet-nr-rrc.h"
#include "packet-gsm_a_common.h"
#include "packet-lpp.h"

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

void proto_register_nr_rrc(void);
void proto_reg_handoff_nr_rrc(void);

static dissector_handle_t nas_5gs_handle = NULL;
static dissector_handle_t lte_rrc_conn_reconf_handle = NULL;
static dissector_handle_t lte_rrc_conn_reconf_compl_handle = NULL;
static dissector_handle_t lte_rrc_ul_dcch_handle = NULL;
static dissector_handle_t lte_rrc_dl_dcch_handle = NULL;

static wmem_map_t *nr_rrc_etws_cmas_dcs_hash = NULL;

static reassembly_table nr_rrc_sib7_reassembly_table;
static reassembly_table nr_rrc_sib8_reassembly_table;

static gboolean nr_rrc_nas_in_root_tree;

extern int proto_mac_nr;
extern int proto_pdcp_nr;

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

/* Initialize the protocol and registered fields */
static int proto_nr_rrc = -1;
#include "packet-nr-rrc-hf.c"
static int hf_nr_rrc_serialNumber_gs = -1;
static int hf_nr_rrc_serialNumber_msg_code = -1;
static int hf_nr_rrc_serialNumber_upd_nb = -1;
static int hf_nr_rrc_warningType_value = -1;
static int hf_nr_rrc_warningType_emergency_user_alert = -1;
static int hf_nr_rrc_warningType_popup = -1;
static int hf_nr_rrc_warningMessageSegment_nb_pages = -1;
static int hf_nr_rrc_warningMessageSegment_decoded_page = -1;
static int hf_nr_rrc_sib7_fragments = -1;
static int hf_nr_rrc_sib7_fragment = -1;
static int hf_nr_rrc_sib7_fragment_overlap = -1;
static int hf_nr_rrc_sib7_fragment_overlap_conflict = -1;
static int hf_nr_rrc_sib7_fragment_multiple_tails = -1;
static int hf_nr_rrc_sib7_fragment_too_long_fragment = -1;
static int hf_nr_rrc_sib7_fragment_error = -1;
static int hf_nr_rrc_sib7_fragment_count = -1;
static int hf_nr_rrc_sib7_reassembled_in = -1;
static int hf_nr_rrc_sib7_reassembled_length = -1;
static int hf_nr_rrc_sib7_reassembled_data = -1;
static int hf_nr_rrc_sib8_fragments = -1;
static int hf_nr_rrc_sib8_fragment = -1;
static int hf_nr_rrc_sib8_fragment_overlap = -1;
static int hf_nr_rrc_sib8_fragment_overlap_conflict = -1;
static int hf_nr_rrc_sib8_fragment_multiple_tails = -1;
static int hf_nr_rrc_sib8_fragment_too_long_fragment = -1;
static int hf_nr_rrc_sib8_fragment_error = -1;
static int hf_nr_rrc_sib8_fragment_count = -1;
static int hf_nr_rrc_sib8_reassembled_in = -1;
static int hf_nr_rrc_sib8_reassembled_length = -1;
static int hf_nr_rrc_sib8_reassembled_data = -1;
static int hf_nr_rrc_utc_time = -1;
static int hf_nr_rrc_local_time = -1;
static int hf_nr_rrc_absolute_time = -1;

/* Initialize the subtree pointers */
static gint ett_nr_rrc = -1;
#include "packet-nr-rrc-ett.c"
static gint ett_nr_rrc_DedicatedNAS_Message = -1;
static gint ett_nr_rrc_targetRAT_MessageContainer = -1;
static gint ett_nr_rrc_nas_Container = -1;
static gint ett_nr_rrc_serialNumber = -1;
static gint ett_nr_rrc_warningType = -1;
static gint ett_nr_rrc_dataCodingScheme = -1;
static gint ett_nr_rrc_sib7_fragment = -1;
static gint ett_nr_rrc_sib7_fragments = -1;
static gint ett_nr_rrc_sib8_fragment = -1;
static gint ett_nr_rrc_sib8_fragments = -1;
static gint ett_nr_rrc_warningMessageSegment = -1;
static gint ett_nr_rrc_timeInfo = -1;
static gint ett_nr_rrc_capabilityRequestFilter = -1;
static gint ett_nr_rrc_sourceSCG_EUTRA_Config = -1;
static gint ett_nr_rrc_scg_CellGroupConfigEUTRA = -1;
static gint ett_nr_rrc_candidateCellInfoListSN_EUTRA = -1;
static gint ett_nr_rrc_candidateCellInfoListMN_EUTRA = -1;
static gint ett_nr_rrc_sourceConfigSCG_EUTRA = -1;
static gint ett_nr_rrc_eutra_SCG = -1;
static gint ett_nr_rrc_nr_SCG_Response = -1;
static gint ett_nr_rrc_eutra_SCG_Response = -1;
static gint ett_nr_rrc_measResultSCG_FailureMRDC = -1;
static gint ett_nr_rrc_ul_DCCH_MessageNR = -1;
static gint ett_nr_rrc_ul_DCCH_MessageEUTRA = -1;
static gint ett_rr_rrc_nas_SecurityParamFromNR = -1;
static gint ett_nr_rrc_sidelinkUEInformationNR = -1;
static gint ett_nr_rrc_sidelinkUEInformationEUTRA = -1;
static gint ett_nr_rrc_ueAssistanceInformationEUTRA = -1;
static gint ett_nr_rrc_dl_DCCH_MessageNR = -1;
static gint ett_nr_rrc_dl_DCCH_MessageEUTRA = -1;
static gint ett_nr_rrc_sl_ConfigDedicatedEUTRA = -1;
static gint ett_nr_rrc_sl_CapabilityInformationSidelink = -1;
static gint ett_nr_rrc_measResult_RLF_Report_EUTRA = -1;
static gint ett_nr_rrc_locationTimestamp_r16 = -1;
static gint ett_nr_rrc_locationCoordinate_r16 = -1;
static gint ett_nr_rrc_locationError_r16 = -1;
static gint ett_nr_rrc_locationSource_r16 = -1;
static gint ett_nr_rrc_velocityEstimate_r16 = -1;
static gint ett_nr_rrc_sensor_MeasurementInformation_r16 = -1;
static gint ett_nr_rrc_sensor_MotionInformation_r16 = -1;
static gint ett_nr_rrc_bandParametersSidelinkEUTRA1_r16 = -1;
static gint ett_nr_rrc_bandParametersSidelinkEUTRA2_r16 = -1;
static gint ett_nr_rrc_sl_ParametersEUTRA1_r16 = -1;
static gint ett_nr_rrc_sl_ParametersEUTRA2_r16 = -1;
static gint ett_nr_rrc_sl_ParametersEUTRA3_r16 = -1;
static gint ett_nr_rrc_absTimeInfo = -1;
static gint ett_nr_rrc_assistanceDataSIB_Element_r16 = -1;
static gint ett_nr_sl_V2X_ConfigCommon_r16 = -1;
static gint ett_nr_tdd_Config_r16 = -1;

static expert_field ei_nr_rrc_number_pages_le15 = EI_INIT;

/* Forward declarations */
static int dissect_UECapabilityInformationSidelink_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_);
static int dissect_DL_DCCH_Message_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_);
static int dissect_DL_CCCH_Message_PDU(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_);
static int dissect_UL_CCCH_Message_PDU(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_);
static int dissect_UERadioAccessCapabilityInformation_PDU(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_);

static const unit_name_string units_periodicities = { " periodicity", " periodicities" };
static const unit_name_string units_prbs = { " PRB", " PRBs" };
static const unit_name_string units_slots = { " slot", " slots" };

typedef struct {
  guint8 rat_type;
  guint8 target_rat_type;
  guint16 message_identifier;
  guint8 warning_message_segment_type;
  guint8 warning_message_segment_number;
  nr_drb_mac_rlc_mapping_t drb_rlc_mapping;
  nr_drb_rlc_pdcp_mapping_t drb_pdcp_mapping;
  lpp_pos_sib_type_t pos_sib_type;
  pdcp_nr_security_info_t pdcp_security;
} nr_rrc_private_data_t;

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


static void
nr_rrc_call_dissector(dissector_handle_t handle, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
  TRY {
    call_dissector(handle, tvb, pinfo, tree);
  }
  CATCH_BOUNDS_ERRORS {
    show_exception(tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
  }
  ENDTRY;
}

static void
nr_rrc_q_RxLevMin_fmt(gchar *s, guint32 v)
{
  gint32 d = (gint32)v;

  g_snprintf(s, ITEM_LABEL_LENGTH, "%d dB (%d)", 2*d, d);
}

static const value_string nr_rrc_serialNumber_gs_vals[] = {
  { 0, "Display mode immediate, cell wide"},
  { 1, "Display mode normal, PLMN wide"},
  { 2, "Display mode normal, tracking area wide"},
  { 3, "Display mode normal, cell wide"},
  { 0, NULL},
};

static const value_string nr_rrc_warningType_vals[] = {
  { 0, "Earthquake"},
  { 1, "Tsunami"},
  { 2, "Earthquake and Tsunami"},
  { 3, "Test"},
  { 4, "Other"},
  { 0, NULL},
};

static const fragment_items nr_rrc_sib7_frag_items = {
    &ett_nr_rrc_sib7_fragment,
    &ett_nr_rrc_sib7_fragments,
    &hf_nr_rrc_sib7_fragments,
    &hf_nr_rrc_sib7_fragment,
    &hf_nr_rrc_sib7_fragment_overlap,
    &hf_nr_rrc_sib7_fragment_overlap_conflict,
    &hf_nr_rrc_sib7_fragment_multiple_tails,
    &hf_nr_rrc_sib7_fragment_too_long_fragment,
    &hf_nr_rrc_sib7_fragment_error,
    &hf_nr_rrc_sib7_fragment_count,
    &hf_nr_rrc_sib7_reassembled_in,
    &hf_nr_rrc_sib7_reassembled_length,
    &hf_nr_rrc_sib7_reassembled_data,
    "SIB7 warning message segments"
};

static const fragment_items nr_rrc_sib8_frag_items = {
    &ett_nr_rrc_sib8_fragment,
    &ett_nr_rrc_sib8_fragments,
    &hf_nr_rrc_sib8_fragments,
    &hf_nr_rrc_sib8_fragment,
    &hf_nr_rrc_sib8_fragment_overlap,
    &hf_nr_rrc_sib8_fragment_overlap_conflict,
    &hf_nr_rrc_sib8_fragment_multiple_tails,
    &hf_nr_rrc_sib8_fragment_too_long_fragment,
    &hf_nr_rrc_sib8_fragment_error,
    &hf_nr_rrc_sib8_fragment_count,
    &hf_nr_rrc_sib8_reassembled_in,
    &hf_nr_rrc_sib8_reassembled_length,
    &hf_nr_rrc_sib8_reassembled_data,
    "SIB8 warning message segments"
};

static void
dissect_nr_rrc_warningMessageSegment(tvbuff_t *warning_msg_seg_tvb, proto_tree *tree, packet_info *pinfo, guint8 dataCodingScheme)
{
  guint32 offset;
  guint8 nb_of_pages, length, *str;
  proto_item *ti;
  tvbuff_t *cb_data_page_tvb, *cb_data_tvb;
  int i;

  nb_of_pages = tvb_get_guint8(warning_msg_seg_tvb, 0);
  ti = proto_tree_add_uint(tree, hf_nr_rrc_warningMessageSegment_nb_pages, warning_msg_seg_tvb, 0, 1, nb_of_pages);
  if (nb_of_pages > 15) {
    expert_add_info_format(pinfo, ti, &ei_nr_rrc_number_pages_le15,
                           "Number of pages should be <=15 (found %u)", nb_of_pages);
    nb_of_pages = 15;
  }
  for (i = 0, offset = 1; i < nb_of_pages; i++) {
    length = tvb_get_guint8(warning_msg_seg_tvb, offset+82);
    cb_data_page_tvb = tvb_new_subset_length(warning_msg_seg_tvb, offset, length);
    cb_data_tvb = dissect_cbs_data(dataCodingScheme, cb_data_page_tvb, tree, pinfo, 0);
    if (cb_data_tvb) {
      str = tvb_get_string_enc(pinfo->pool, cb_data_tvb, 0, tvb_reported_length(cb_data_tvb), ENC_UTF_8|ENC_NA);
      proto_tree_add_string_format(tree, hf_nr_rrc_warningMessageSegment_decoded_page, warning_msg_seg_tvb, offset, 83,
                                   str, "Decoded Page %u: %s", i+1, str);
    }
    offset += 83;
  }
}

static const value_string nr_rrc_daylightSavingTime_vals[] = {
  { 0, "No adjustment for Daylight Saving Time"},
  { 1, "+1 hour adjustment for Daylight Saving Time"},
  { 2, "+2 hours adjustment for Daylight Saving Time"},
  { 3, "Reserved"},
  { 0, NULL},
};

static void
nr_rrc_localTimeOffset_fmt(gchar *s, guint32 v)
{
  gint32 time_offset = (gint32) v;

  g_snprintf(s, ITEM_LABEL_LENGTH, "UTC time %c %dhr %dmin (%d)",
             (time_offset < 0) ? '-':'+', abs(time_offset) >> 2,
             (abs(time_offset) & 0x03) * 15, time_offset);
}

static void
nr_rrc_drx_SlotOffset_fmt(gchar *s, guint32 v)
{
  g_snprintf(s, ITEM_LABEL_LENGTH, "%g ms (%u)", 1./32 * v, v);
}

static void
nr_rrc_Hysteresis_fmt(gchar *s, guint32 v)
{
  g_snprintf(s, ITEM_LABEL_LENGTH, "%gdB (%u)", 0.5 * v, v);
}

static void
nr_rrc_msg3_DeltaPreamble_fmt(gchar *s, guint32 v)
{
  gint32 d = (gint32)v;

  g_snprintf(s, ITEM_LABEL_LENGTH, "%ddB (%d)", 2 * d, d);
}

static void
nr_rrc_Q_RxLevMin_fmt(gchar *s, guint32 v)
{
  gint32 d = (gint32)v;

  g_snprintf(s, ITEM_LABEL_LENGTH, "%ddBm (%d)", 2 * d, d);
}

static void
nr_rrc_RSRP_RangeEUTRA_fmt(gchar *s, guint32 v)
{
  if (v == 0) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "RSRP < -140dBm (0)");
  } else if (v < 97) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "%ddBm <= RSRP < %ddBm (%u)", v-141, v-140, v);
  } else {
    g_snprintf(s, ITEM_LABEL_LENGTH, "-44dBm <= RSRP (97)");
  }
}

static void
nr_rrc_RSRQ_RangeEUTRA_fmt(gchar *s, guint32 v)
{
  if (v == 0) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "RSRQ < -19.5dB (0)");
  } else if (v < 34) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "%.1fdB <= RSRQ < %.1fdB (%u)", ((float)v/2)-20, (((float)v+1)/2)-20, v);
  } else {
    g_snprintf(s, ITEM_LABEL_LENGTH, "-3dB <= RSRQ (34)");
  }
}

static void
nr_rrc_SINR_RangeEUTRA_fmt(gchar *s, guint32 v)
{
  if (v == 0) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "SINR < -23dB (0)");
  } else if (v == 127) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "40dB <= SINR (127)");
  } else {
    g_snprintf(s, ITEM_LABEL_LENGTH, "%.1fdB <= SINR < %.1fdB (%u)", (((float)v-1)/2)-23, ((float)v/2)-23, v);
  }
}

static void
nr_rrc_ReselectionThreshold_fmt(gchar *s, guint32 v)
{
  g_snprintf(s, ITEM_LABEL_LENGTH, "%udB (%u)", 2 * v, v);
}

static void
nr_rrc_RSRP_Range_fmt(gchar *s, guint32 v)
{
  if (v == 0) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "SS-RSRP < -156dBm (0)");
  } else if (v < 126) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "%ddBm <= SS-RSRP < %ddBm (%u)", v-157, v-156, v);
  } else if (v == 126) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "-31dBm <= SS-RSRP (126)");
  } else {
    g_snprintf(s, ITEM_LABEL_LENGTH, "infinity (127)");
  }
}

static void
nr_rrc_RSRQ_Range_fmt(gchar *s, guint32 v)
{
  if (v == 0) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "SS-RSRQ < -43dB (0)");
  } else if (v < 127) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "%.1fdB <= SS-RSRQ < %.1fdB (%u)", (((float)v-1)/2)-43, ((float)v/2)-43, v);
  } else {
    g_snprintf(s, ITEM_LABEL_LENGTH, "-20dB <= SS-RSRQ (127)");
  }
}

static void
nr_rrc_SINR_Range_fmt(gchar *s, guint32 v)
{
  if (v == 0) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "SS-SINR < -23dB (0)");
  } else if (v < 127) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "%.1fdB <= SS-SINR < %.1fdB (%u)", (((float)v-1)/2)-23, ((float)v/2)-23, v);
  } else {
    g_snprintf(s, ITEM_LABEL_LENGTH, "40dB <= SS-SINR (127)");
  }
}

static void
nr_rrc_dl_1024QAM_TotalWeightedLayers_fmt(gchar *s, guint32 v)
{
  g_snprintf(s, ITEM_LABEL_LENGTH, "%u (%u)", 10+(2*v), v);
}

static void
nr_rrc_timeConnFailure_r16_fmt(gchar *s, guint32 v)
{
  g_snprintf(s, ITEM_LABEL_LENGTH, "%ums (%u)", 100*v, v);
}

static void
nr_rrc_RSSI_Range_r16_fmt(gchar *s, guint32 v)
{
  if (v == 0) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "RSSI < -100dBm (0)");
  } else if (v < 76) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "%ddBm <= RSSI < %ddBm (%u)", v-101, v-100, v);
  } else {
    g_snprintf(s, ITEM_LABEL_LENGTH, "-25dBm <= RSSI (76)");
  }
}

static void
nr_rrc_RSRQ_RangeEUTRA_r16_fmt(gchar *s, guint32 v)
{
  gint32 d = (gint32)v;

  if (d == -34) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "RSRQ < -36dB (-34)");
  } else if (d < 0) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "%.1fdB <= RSRQ < %.1fdB (%d)", (((float)d-1)/2)-19, ((float)d/2)-19, d);
  } else if (d == 0) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "RSRQ < -19.5dB (0)");
  } else if (d < 34) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "%.1fdB <= RSRQ < %.1fdB (%d)", (((float)d-1)/2)-19.5, ((float)d/2)-19.5, d);
  } else if (d == 34) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "-3dB <= RSRQ (34)");
  } else if (d < 46) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "%.1fdB <= RSRQ < %.1fdB (%d)", (((float)d-1)/2)-20, ((float)d/2)-20, d);
  } else {
    g_snprintf(s, ITEM_LABEL_LENGTH, "2.5dB <= RSRQ (46)");
  }
}

static void
nr_rrc_utra_FDD_RSCP_r16_fmt(gchar *s, guint32 v)
{
  gint32 d = (gint32)v;

  if (d == -5) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "RSCP < -120dBm (-5)");
  } else if (d < 91) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "%ddBm <= RSCP < %ddB (%d)", d-116, d-115, d);
  } else {
    g_snprintf(s, ITEM_LABEL_LENGTH, "-25dBm <= RSCP (91)");
  }
}

static void
nr_rrc_utra_FDD_EcN0_r16_fmt(gchar *s, guint32 v)
{
  if (v == 0) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "Ec/No < -24dB (0)");
  } else if (v < 49) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "%.1fdB <= Ec/No < %.1fdB (%u)", (((float)v-1)/2)-24, ((float)v/2)-24, v);
  } else {
    g_snprintf(s, ITEM_LABEL_LENGTH, "0dB <= Ec/No (49)");
  }
}

static void
nr_rrc_averageDelay_r16_fmt(gchar *s, guint32 v)
{
  g_snprintf(s, ITEM_LABEL_LENGTH, "%.1fms (%u)", (float)v/10, v);
}

static void
nr_rrc_measTriggerQuantity_utra_FDD_RSCP_r16_fmt(gchar *s, guint32 v)
{
  gint32 d = (gint32)v;

  g_snprintf(s, ITEM_LABEL_LENGTH, "%ddBm (%d)", d-115, d);
}

static void
nr_rrc_measTriggerQuantity_utra_FDD_EcN0_r16_fmt(gchar *s, guint32 v)
{
  g_snprintf(s, ITEM_LABEL_LENGTH, "%.1fdB (%u)", (float)v/2-24.5, v);
}

static void
nr_rrc_SRS_RSRP_r16_fmt(gchar *s, guint32 v)
{
  if (v == 0) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "SRS-RSRP < -140dBm (0)");
  } else if (v < 97) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "%ddBm <= SRS-RSRP < %ddB (%u)", v-141, v-140, v);
  } else if (v == 97) {
    g_snprintf(s, ITEM_LABEL_LENGTH, "-44dBm <= SRS-RSRP (97)");
  } else {
    g_snprintf(s, ITEM_LABEL_LENGTH, "Infinity (98)");
  }
}

static void
nr_rrc_MeasTriggerQuantityOffset_fmt(gchar *s, guint32 v)
{
  gint32 d = (gint32)v;

  g_snprintf(s, ITEM_LABEL_LENGTH, "%.1fdB (%d)", (float)d/2, d);
}

static int
dissect_nr_rrc_cg_configinfo_msg(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_)
{
    proto_item* ti;
    proto_tree* sub_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NR RRC");
    col_set_str(pinfo->cinfo, COL_INFO, "CG-ConfigInfo");

    ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
    sub_tree = proto_item_add_subtree(ti, ett_nr_rrc);
    return dissect_nr_rrc_CG_ConfigInfo_PDU(tvb, pinfo, sub_tree, NULL);
}

static int
dissect_nr_rrc_radiobearerconfig_msg(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_)
{
    proto_item* ti;
    proto_tree* sub_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NR RRC");
    col_set_str(pinfo->cinfo, COL_INFO, "RadioBearerConfig");

    ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
    sub_tree = proto_item_add_subtree(ti, ett_nr_rrc);
    return dissect_nr_rrc_RadioBearerConfig_PDU(tvb, pinfo, sub_tree, NULL);
}

static int
dissect_nr_rrc_ue_mrdc_capability_msg(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_)
{
    proto_item* ti;
    proto_tree* sub_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NR RRC");
    col_set_str(pinfo->cinfo, COL_INFO, "UE-MRDC-Capability");

    ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
    sub_tree = proto_item_add_subtree(ti, ett_nr_rrc);
    return dissect_nr_rrc_UE_MRDC_Capability_PDU(tvb, pinfo, sub_tree, NULL);
}

static int
dissect_nr_rrc_ue_nr_capability_msg(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_)
{
    proto_item* ti;
    proto_tree* sub_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NR RRC");
    col_set_str(pinfo->cinfo, COL_INFO, "UE-NR-Capability");

    ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
    sub_tree = proto_item_add_subtree(ti, ett_nr_rrc);
    return dissect_nr_rrc_UE_NR_Capability_PDU(tvb, pinfo, sub_tree, NULL);
}

static int
dissect_nr_rrc_ul_dcch_message_msg(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_)
{
    proto_item* ti;
    proto_tree* sub_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NR RRC");
    col_set_str(pinfo->cinfo, COL_INFO, "UL-DCCH-Message");

    ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
    sub_tree = proto_item_add_subtree(ti, ett_nr_rrc);
    return dissect_nr_rrc_UL_DCCH_Message_PDU(tvb, pinfo, sub_tree, NULL);
}

static int
dissect_nr_rrc_dl_dcch_message_msg(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_)
{
    proto_item* ti;
    proto_tree* sub_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NR RRC");
    col_set_str(pinfo->cinfo, COL_INFO, "DL-DCCH-Message");

    ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
    sub_tree = proto_item_add_subtree(ti, ett_nr_rrc);
    return dissect_DL_DCCH_Message_PDU(tvb, pinfo, sub_tree, NULL);
}

static int
dissect_nr_rrc_dl_ccch_message_msg(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_)
{
    proto_item* ti;
    proto_tree* sub_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NR RRC");
    col_set_str(pinfo->cinfo, COL_INFO, "DL-CCCH-Message");

    ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
    sub_tree = proto_item_add_subtree(ti, ett_nr_rrc);
    return dissect_DL_CCCH_Message_PDU(tvb, pinfo, sub_tree, NULL);
}

static int
dissect_nr_rrc_ul_ccch_message_msg(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_)
{
    proto_item* ti;
    proto_tree* sub_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NR RRC");
    col_set_str(pinfo->cinfo, COL_INFO, "UL-CCCH-Message");

    ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
    sub_tree = proto_item_add_subtree(ti, ett_nr_rrc);
    return dissect_UL_CCCH_Message_PDU(tvb, pinfo, sub_tree, NULL);
}


static int
dissect_nr_rrc_cellgroupconfig_msg(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_)
{
    proto_item* ti;
    proto_tree* sub_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NR RRC");
    col_set_str(pinfo->cinfo, COL_INFO, "CellGroupConfig");

    ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
    sub_tree = proto_item_add_subtree(ti, ett_nr_rrc);
    return dissect_nr_rrc_CellGroupConfig_PDU(tvb, pinfo, sub_tree, NULL);
}

static int
dissect_ueradioaccesscapabilityinformation_msg(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_)
{
    proto_item* ti;
    proto_tree* sub_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NR RRC");
    col_set_str(pinfo->cinfo, COL_INFO, "UERadioAccessCapabilityInformation");

    ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
    sub_tree = proto_item_add_subtree(ti, ett_nr_rrc);
    return dissect_UERadioAccessCapabilityInformation_PDU(tvb, pinfo, sub_tree, NULL);
}

static int
dissect_nr_rrc_measconfig_msg(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_)
{
    proto_item* ti;
    proto_tree* sub_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NR RRC");
    col_set_str(pinfo->cinfo, COL_INFO, "MeasConfig");

    ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
    sub_tree = proto_item_add_subtree(ti, ett_nr_rrc);
    return dissect_nr_rrc_MeasConfig_PDU(tvb, pinfo, sub_tree, NULL);
}

static int
dissect_nr_rrc_measgapconfig_msg(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_)
{
    proto_item* ti;
    proto_tree* sub_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NR RRC");
    col_set_str(pinfo->cinfo, COL_INFO, "MeasGapConfig");

    ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
    sub_tree = proto_item_add_subtree(ti, ett_nr_rrc);
    return dissect_nr_rrc_MeasGapConfig_PDU(tvb, pinfo, sub_tree, NULL);
}

static int
dissect_nr_rrc_handoverpreparationinformation_msg(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_)
{
    proto_item* ti;
    proto_tree* sub_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NR RRC");
    col_set_str(pinfo->cinfo, COL_INFO, "MeasGapConfig");

    ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
    sub_tree = proto_item_add_subtree(ti, ett_nr_rrc);
    return dissect_nr_rrc_HandoverPreparationInformation_PDU(tvb, pinfo, sub_tree, NULL);
}



static int
dissect_nr_rrc_rrcreconfiguration_msg(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_)
{
    proto_item* ti;
    proto_tree* sub_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NR RRC");
    col_set_str(pinfo->cinfo, COL_INFO, "RRCReconfiguration");

    ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
    sub_tree = proto_item_add_subtree(ti, ett_nr_rrc);
    return dissect_nr_rrc_RRCReconfiguration_PDU(tvb, pinfo, sub_tree, NULL);
}


static int
dissect_nr_rrc_ue_capabilityrat_containerlist_msg(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_)
{
    proto_item* ti;
    proto_tree* sub_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NR RRC");
    col_set_str(pinfo->cinfo, COL_INFO, "UE-CapabilityRAT-ContainerList");

    ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
    sub_tree = proto_item_add_subtree(ti, ett_nr_rrc);
    return dissect_nr_rrc_UE_CapabilityRAT_ContainerList_PDU(tvb, pinfo, sub_tree, NULL);
}

static int
dissect_nr_rrc_handovercommand_msg(tvbuff_t* tvb _U_, packet_info* pinfo _U_, proto_tree* tree _U_, void* data _U_)
{
    proto_item* ti;
    proto_tree* sub_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NR RRC");
    col_set_str(pinfo->cinfo, COL_INFO, "HandoverCommand");

    ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
    sub_tree = proto_item_add_subtree(ti, ett_nr_rrc);
    return dissect_nr_rrc_HandoverCommand_PDU(tvb, pinfo, sub_tree, NULL);
}


#include "packet-nr-rrc-fn.c"

int
dissect_nr_rrc_nr_RLF_Report_r16_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
  proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
  proto_item_set_hidden(prot_ti);
  int offset = 0;
  asn1_ctx_t asn1_ctx;
  asn1_ctx_init(&asn1_ctx, ASN1_ENC_PER, FALSE, pinfo);
  offset = dissect_nr_rrc_T_nr_RLF_Report_r16(tvb, offset, &asn1_ctx, tree, hf_nr_rrc_BCCH_DL_SCH_Message_PDU);
  offset += 7; offset >>= 3;
  return offset;
}

int
dissect_nr_rrc_subCarrierSpacingCommon_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
  proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
  proto_item_set_hidden(prot_ti);
  int offset = 0;
  asn1_ctx_t asn1_ctx;
  asn1_ctx_init(&asn1_ctx, ASN1_ENC_PER, FALSE, pinfo);
  offset = dissect_nr_rrc_T_subCarrierSpacingCommon(tvb, offset, &asn1_ctx, tree, hf_nr_rrc_BCCH_DL_SCH_Message_PDU);
  offset += 7; offset >>= 3;
  return offset;
}

void
proto_register_nr_rrc(void) {

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

#include "packet-nr-rrc-hfarr.c"

    { &hf_nr_rrc_serialNumber_gs,
      { "Geographical Scope", "nr-rrc.serialNumber.gs",
        FT_UINT16, BASE_DEC, VALS(nr_rrc_serialNumber_gs_vals), 0xc000,
        NULL, HFILL }},
    { &hf_nr_rrc_serialNumber_msg_code,
      { "Message Code", "nr-rrc.serialNumber.msg_code",
        FT_UINT16, BASE_DEC, NULL, 0x3ff0,
        NULL, HFILL }},
    { &hf_nr_rrc_serialNumber_upd_nb,
      { "Update Number", "nr-rrc.serialNumber.upd_nb",
        FT_UINT16, BASE_DEC, NULL, 0x000f,
        NULL, HFILL }},
    { &hf_nr_rrc_warningType_value,
      { "Warning Type Value", "nr-rrc.warningType.value",
        FT_UINT16, BASE_DEC, VALS(nr_rrc_warningType_vals), 0xfe00,
        NULL, HFILL }},
    { &hf_nr_rrc_warningType_emergency_user_alert,
      { "Emergency User Alert", "nr-rrc.warningType.emergency_user_alert",
        FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x0100,
        NULL, HFILL }},
    { &hf_nr_rrc_warningType_popup,
      { "Popup", "nr-rrc.warningType.popup",
        FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x0080,
        NULL, HFILL }},
    { &hf_nr_rrc_warningMessageSegment_nb_pages,
      { "Number of Pages", "nr-rrc.warningMessageSegment.nb_pages",
        FT_UINT8, BASE_DEC, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_warningMessageSegment_decoded_page,
      { "Decoded Page", "nr-rrc.warningMessageSegment.decoded_page",
        FT_STRING, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib7_fragments,
      { "Fragments", "nr-rrc.warningMessageSegment.fragments",
        FT_NONE, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib7_fragment,
      { "Fragment", "nr-rrc.warningMessageSegment.fragment",
         FT_FRAMENUM, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib7_fragment_overlap,
      { "Fragment Overlap", "nr-rrc.warningMessageSegment.fragment_overlap",
         FT_BOOLEAN, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib7_fragment_overlap_conflict,
      { "Fragment Overlap Conflict", "nr-rrc.warningMessageSegment.fragment_overlap_conflict",
         FT_BOOLEAN, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib7_fragment_multiple_tails,
      { "Fragment Multiple Tails", "nr-rrc.warningMessageSegment.fragment_multiple_tails",
         FT_BOOLEAN, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib7_fragment_too_long_fragment,
      { "Too Long Fragment", "nr-rrc.warningMessageSegment.fragment_too_long_fragment",
         FT_BOOLEAN, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib7_fragment_error,
      { "Fragment Error", "nr-rrc.warningMessageSegment.fragment_error",
         FT_FRAMENUM, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib7_fragment_count,
      { "Fragment Count", "nr-rrc.warningMessageSegment.fragment_count",
         FT_UINT32, BASE_DEC, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib7_reassembled_in,
      { "Reassembled In", "nr-rrc.warningMessageSegment.reassembled_in",
         FT_FRAMENUM, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib7_reassembled_length,
      { "Reassembled Length", "nr-rrc.warningMessageSegment.reassembled_length",
         FT_UINT32, BASE_DEC, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib7_reassembled_data,
      { "Reassembled Data", "nr-rrc.warningMessageSegment.reassembled_data",
         FT_BYTES, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib8_fragments,
      { "Fragments", "nr-rrc.warningMessageSegment.fragments",
        FT_NONE, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib8_fragment,
      { "Fragment", "nr-rrc.warningMessageSegment.fragment",
         FT_FRAMENUM, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib8_fragment_overlap,
      { "Fragment Overlap", "nr-rrc.warningMessageSegment.fragment_overlap",
         FT_BOOLEAN, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib8_fragment_overlap_conflict,
      { "Fragment Overlap Conflict", "nr-rrc.warningMessageSegment.fragment_overlap_conflict",
         FT_BOOLEAN, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib8_fragment_multiple_tails,
      { "Fragment Multiple Tails", "nr-rrc.warningMessageSegment.fragment_multiple_tails",
         FT_BOOLEAN, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib8_fragment_too_long_fragment,
      { "Too Long Fragment", "nr-rrc.warningMessageSegment.fragment_too_long_fragment",
         FT_BOOLEAN, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib8_fragment_error,
      { "Fragment Error", "nr-rrc.warningMessageSegment.fragment_error",
         FT_FRAMENUM, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib8_fragment_count,
      { "Fragment Count", "nr-rrc.warningMessageSegment.fragment_count",
         FT_UINT32, BASE_DEC, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib8_reassembled_in,
      { "Reassembled In", "nr-rrc.warningMessageSegment.reassembled_in",
         FT_FRAMENUM, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib8_reassembled_length,
      { "Reassembled Length", "nr-rrc.warningMessageSegment.reassembled_length",
         FT_UINT32, BASE_DEC, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_sib8_reassembled_data,
      { "Reassembled Data", "nr-rrc.warningMessageSegment.reassembled_data",
         FT_BYTES, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_nr_rrc_utc_time,
      { "UTC   time", "nr-rrc.utc_time",
        FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x0,
        NULL, HFILL }},
    { &hf_nr_rrc_local_time,
      { "Local time", "nr-rrc.local_time",
        FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0,
        NULL, HFILL }},
    { &hf_nr_rrc_absolute_time,
      { "Absolute time", "nr-rrc.absolute_time",
        FT_STRING, BASE_NONE, NULL, 0x0,
        NULL, HFILL }},
  };

  static gint *ett[] = {
    &ett_nr_rrc,
#include "packet-nr-rrc-ettarr.c"
    &ett_nr_rrc_DedicatedNAS_Message,
    &ett_nr_rrc_targetRAT_MessageContainer,
    &ett_nr_rrc_nas_Container,
    &ett_nr_rrc_serialNumber,
    &ett_nr_rrc_warningType,
    &ett_nr_rrc_dataCodingScheme,
    &ett_nr_rrc_sib7_fragment,
    &ett_nr_rrc_sib7_fragments,
    &ett_nr_rrc_sib8_fragment,
    &ett_nr_rrc_sib8_fragments,
    &ett_nr_rrc_warningMessageSegment,
    &ett_nr_rrc_timeInfo,
    &ett_nr_rrc_capabilityRequestFilter,
    &ett_nr_rrc_sourceSCG_EUTRA_Config,
    &ett_nr_rrc_scg_CellGroupConfigEUTRA,
    &ett_nr_rrc_candidateCellInfoListSN_EUTRA,
    &ett_nr_rrc_candidateCellInfoListMN_EUTRA,
    &ett_nr_rrc_sourceConfigSCG_EUTRA,
    &ett_nr_rrc_eutra_SCG,
    &ett_nr_rrc_nr_SCG_Response,
    &ett_nr_rrc_eutra_SCG_Response,
    &ett_nr_rrc_measResultSCG_FailureMRDC,
    &ett_nr_rrc_ul_DCCH_MessageNR,
    &ett_nr_rrc_ul_DCCH_MessageEUTRA,
    &ett_rr_rrc_nas_SecurityParamFromNR,
    &ett_nr_rrc_sidelinkUEInformationNR,
    &ett_nr_rrc_sidelinkUEInformationEUTRA,
    &ett_nr_rrc_ueAssistanceInformationEUTRA,
    &ett_nr_rrc_dl_DCCH_MessageNR,
    &ett_nr_rrc_dl_DCCH_MessageEUTRA,
    &ett_nr_rrc_sl_ConfigDedicatedEUTRA,
    &ett_nr_rrc_sl_CapabilityInformationSidelink,
    &ett_nr_rrc_measResult_RLF_Report_EUTRA,
    &ett_nr_rrc_locationTimestamp_r16,
    &ett_nr_rrc_locationCoordinate_r16,
    &ett_nr_rrc_locationError_r16,
    &ett_nr_rrc_locationSource_r16,
    &ett_nr_rrc_velocityEstimate_r16,
    &ett_nr_rrc_sensor_MeasurementInformation_r16,
    &ett_nr_rrc_sensor_MotionInformation_r16,
    &ett_nr_rrc_bandParametersSidelinkEUTRA1_r16,
    &ett_nr_rrc_bandParametersSidelinkEUTRA2_r16,
    &ett_nr_rrc_sl_ParametersEUTRA1_r16,
    &ett_nr_rrc_sl_ParametersEUTRA2_r16,
    &ett_nr_rrc_sl_ParametersEUTRA3_r16,
    &ett_nr_rrc_absTimeInfo,
    &ett_nr_rrc_assistanceDataSIB_Element_r16,
    &ett_nr_sl_V2X_ConfigCommon_r16,
    &ett_nr_tdd_Config_r16
  };

  static ei_register_info ei[] = {
     { &ei_nr_rrc_number_pages_le15, { "nr-rrc.number_pages_le15", PI_MALFORMED, PI_ERROR, "Number of pages should be <=15", EXPFILL }},
  };

  expert_module_t* expert_nr_rrc;
  module_t *nr_rrc_module;

  /* Register protocol */
  proto_nr_rrc = proto_register_protocol(PNAME, PSNAME, PFNAME);

  /* Register fields and subtrees */
  proto_register_field_array(proto_nr_rrc, hf, array_length(hf));
  proto_register_subtree_array(ett, array_length(ett));
  expert_nr_rrc = expert_register_protocol(proto_nr_rrc);
  expert_register_field_array(expert_nr_rrc, ei, array_length(ei));

  /* Register the dissectors defined in nr-rrc.cnf */
  register_dissector("nr-rrc.cg_configinfo", dissect_nr_rrc_cg_configinfo_msg, proto_nr_rrc);
  register_dissector("nr-rrc.radiobearerconfig", dissect_nr_rrc_radiobearerconfig_msg, proto_nr_rrc);
  register_dissector("nr-rrc.rrc_reconf_msg", dissect_nr_rrc_rrcreconfiguration_msg, proto_nr_rrc);
  register_dissector("nr-rrc.ue_capabilityrat_containerlist", dissect_nr_rrc_ue_capabilityrat_containerlist_msg, proto_nr_rrc);
  register_dissector("nr-rrc.ue_mrdc_cap_msg", dissect_nr_rrc_ue_mrdc_capability_msg, proto_nr_rrc);
  register_dissector("nr-rrc.ue_nr_cap_msg", dissect_nr_rrc_ue_nr_capability_msg, proto_nr_rrc);
  register_dissector("nr-rrc.ul.dcch_msg_msg", dissect_nr_rrc_ul_dcch_message_msg, proto_nr_rrc);
  register_dissector("nr-rrc.dl.dcch_msg_msg", dissect_nr_rrc_dl_dcch_message_msg, proto_nr_rrc);
  register_dissector("nr-rrc.ul.ccch_msg_msg", dissect_nr_rrc_ul_ccch_message_msg, proto_nr_rrc);
  register_dissector("nr-rrc.dl.ccch_msg_msg", dissect_nr_rrc_dl_ccch_message_msg, proto_nr_rrc);
  register_dissector("nr-rrc.cellgroupconfig_msg", dissect_nr_rrc_cellgroupconfig_msg, proto_nr_rrc);
  register_dissector("nr-rrc.ue_radio_access_cap_info_msg", dissect_ueradioaccesscapabilityinformation_msg, proto_nr_rrc);
  register_dissector("nr-rrc.measconfig_msg", dissect_nr_rrc_measconfig_msg, proto_nr_rrc);
  register_dissector("nr-rrc.measgapconfig_msg", dissect_nr_rrc_measgapconfig_msg, proto_nr_rrc);
  register_dissector("nr-rrc.handoverpreparationinformation_msg", dissect_nr_rrc_handoverpreparationinformation_msg, proto_nr_rrc);
  register_dissector("nr-rrc.handovercommand_msg", dissect_nr_rrc_handovercommand_msg, proto_nr_rrc);

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

  nr_rrc_etws_cmas_dcs_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(),
                                                     g_direct_hash, g_direct_equal);

  reassembly_table_register(&nr_rrc_sib7_reassembly_table,
                            &addresses_reassembly_table_functions);
  reassembly_table_register(&nr_rrc_sib8_reassembly_table,
                            &addresses_reassembly_table_functions);

  /* Register configuration preferences */
  nr_rrc_module = prefs_register_protocol(proto_nr_rrc, NULL);
  prefs_register_bool_preference(nr_rrc_module, "nas_in_root_tree",
                                 "Show NAS PDU in root packet details",
                                 "Whether the NAS PDU should be shown in the root packet details tree",
                                 &nr_rrc_nas_in_root_tree);
}

void
proto_reg_handoff_nr_rrc(void)
{
  nas_5gs_handle = find_dissector("nas-5gs");
  lte_rrc_conn_reconf_handle = find_dissector("lte-rrc.rrc_conn_reconf");
  lte_rrc_conn_reconf_compl_handle = find_dissector("lte-rrc.rrc_conn_reconf_compl");
  lte_rrc_ul_dcch_handle = find_dissector("lte-rrc.ul.dcch");
  lte_rrc_dl_dcch_handle = find_dissector("lte-rrc.dl.dcch");
}