2 * Routines for Universal Mobile Telecommunications System (UMTS);
3 * Radio Resource Control (RRC) protocol specification
4 * (3GPP TS 25.331 packet dissection)
5 * Copyright 2006-2010, Anders Broman <anders.broman@ericsson.com>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 * Ref: 3GPP TS 25.331 V13.2.0 (2016-03)
31 * - Fix ciphering information for circuit switched stuff
36 #include <epan/packet.h>
37 #include <epan/asn1.h>
38 #include <epan/conversation.h>
39 #include <epan/expert.h>
40 #include <epan/proto_data.h>
42 #include "packet-ber.h"
43 #include "packet-per.h"
44 #include "packet-rrc.h"
45 #include "packet-gsm_a_common.h"
46 #include "packet-umts_fp.h"
49 /* disable: "warning C4049: compiler limit : terminating line number emission" */
50 #pragma warning(disable:4049)
51 /* disable: "warning C4146: unary minus operator applied to unsigned type, result still unsigned" */
52 #pragma warning(disable:4146)
55 #define PNAME "Radio Resource Control (RRC) protocol"
59 extern int proto_fp; /*Handler to FP*/
61 GTree * hsdsch_muxed_flows = NULL;
62 GTree * rrc_ciph_inf = NULL;
63 static int msg_type _U_;
65 static dissector_handle_t gsm_a_dtap_handle;
66 static dissector_handle_t rrc_ue_radio_access_cap_info_handle=NULL;
67 static dissector_handle_t rrc_pcch_handle=NULL;
68 static dissector_handle_t rrc_ul_ccch_handle=NULL;
69 static dissector_handle_t rrc_dl_ccch_handle=NULL;
70 static dissector_handle_t rrc_ul_dcch_handle=NULL;
71 static dissector_handle_t rrc_dl_dcch_handle=NULL;
72 static dissector_handle_t rrc_bcch_fach_handle=NULL;
73 static dissector_handle_t lte_rrc_ue_eutra_cap_handle=NULL;
74 static dissector_handle_t lte_rrc_dl_dcch_handle=NULL;
75 static dissector_handle_t gsm_rlcmac_dl_handle=NULL;
77 enum nas_sys_info_gsm_map {
80 RRC_NAS_SYS_INFO_CN_COMMON
83 /* Forward declarations */
84 void proto_register_rrc(void);
85 void proto_reg_handoff_rrc(void);
86 static int dissect_UE_RadioAccessCapabilityInfo_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
87 static int dissect_SysInfoTypeSB1_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
88 static int dissect_SysInfoTypeSB2_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
89 static int dissect_SysInfoType5_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
90 static int dissect_SysInfoType11_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
91 static int dissect_SysInfoType11bis_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
92 static int dissect_SysInfoType11ter_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
93 static int dissect_SysInfoType22_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
95 /* Include constants */
96 #include "packet-rrc-val.h"
98 /* Initialize the protocol and registered fields */
101 #include "packet-rrc-hf.c"
103 /* Initialize the subtree pointers */
104 static int ett_rrc = -1;
106 #include "packet-rrc-ett.c"
108 static gint ett_rrc_eutraFeatureGroupIndicators = -1;
109 static gint ett_rrc_cn_CommonGSM_MAP_NAS_SysInfo = -1;
110 static gint ett_rrc_ims_info = -1;
112 static expert_field ei_rrc_no_hrnti = EI_INIT;
114 /* Global variables */
115 static proto_tree *top_tree;
117 static int hf_rrc_eutra_feat_group_ind_1 = -1;
118 static int hf_rrc_eutra_feat_group_ind_2 = -1;
119 static int hf_rrc_eutra_feat_group_ind_3 = -1;
120 static int hf_rrc_eutra_feat_group_ind_4 = -1;
121 static int hf_rrc_ims_info_atgw_trans_det_cont_type = -1;
122 static int hf_rrc_ims_info_atgw_udp_port = -1;
123 static int hf_rrc_ims_info_atgw_ipv4 = -1;
124 static int hf_rrc_ims_info_atgw_ipv6 = -1;
126 static const true_false_string rrc_eutra_feat_group_ind_1_val = {
127 "UTRA CELL_PCH to EUTRA RRC_IDLE cell reselection - Supported",
128 "UTRA CELL_PCH to EUTRA RRC_IDLE cell reselection - Not supported"
130 static const true_false_string rrc_eutra_feat_group_ind_2_val = {
131 "EUTRAN measurements and reporting in connected mode - Supported",
132 "EUTRAN measurements and reporting in connected mode - Not supported"
134 static const true_false_string rrc_eutra_feat_group_ind_3_val = {
135 "UTRA CELL_FACH absolute priority cell reselection for high priority layers - Supported",
136 "UTRA CELL_FACH absolute priority cell reselection for high priority layers - Not supported"
138 static const true_false_string rrc_eutra_feat_group_ind_4_val = {
139 "UTRA CELL_FACH absolute priority cell reselection for all layers - Supported",
140 "UTRA CELL_FACH absolute priority cell reselection for all layers - Not supported"
142 static const value_string rrc_ims_info_atgw_trans_det_cont_type[] = {
143 {0, "ATGW-IPv4-address-and-port"},
144 {1, "ATGW-IPv6-address-and-port"},
145 {2, "ATGW-not-available"},
148 static int flowd,type;
150 static int cipher_start_val[2] _U_;
152 /*Stores how many channels we have detected for a HS-DSCH MAC-flow*/
153 #define RRC_MAX_NUM_HSDHSCH_MACDFLOW 8
154 static guint8 num_chans_per_flow[RRC_MAX_NUM_HSDHSCH_MACDFLOW];
156 static int activation_frame;
160 * Return the maximum counter, useful for initiating counters
163 static int get_max_counter(int com_context){
166 rrc_ciphering_info * c_inf;
168 if( (c_inf = g_tree_lookup(rrc_ciph_inf, GINT_TO_POINTER((gint)com_context))) == NULL ){
171 for(i = 0; i<31; i++){
172 max = MAX(c_inf->ps_conf_counters[i][0], max);
173 max = MAX(c_inf->ps_conf_counters[i][1], max);
178 /** Utility functions used for various comparisons/cleanups in tree **/
179 static gint rrc_key_cmp(gconstpointer b_ptr, gconstpointer a_ptr, gpointer ignore _U_){
180 if( GPOINTER_TO_INT(a_ptr) > GPOINTER_TO_INT(b_ptr) ){
183 return GPOINTER_TO_INT(a_ptr) < GPOINTER_TO_INT(b_ptr);
186 static void rrc_free_key(gpointer key _U_){
187 /*Keys should be de allocated elsewhere.*/
191 static void rrc_free_value(gpointer value ){
194 #include "packet-rrc-fn.c"
199 dissect_rrc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
201 /* FIX ME Currently don't know the 'starting point' of this protocol
202 * exported DL-DCCH-Message is the entry point.
204 proto_item *rrc_item = NULL;
205 proto_tree *rrc_tree = NULL;
206 struct rrc_info *rrcinf;
209 rrcinf = (struct rrc_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_rrc, 0);
211 /* make entry in the Protocol column on summary display */
212 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RRC");
215 memset(num_chans_per_flow,0,sizeof(guint8)*RRC_MAX_NUM_HSDHSCH_MACDFLOW);
217 /* create the rrc protocol tree */
218 rrc_item = proto_tree_add_item(tree, proto_rrc, tvb, 0, -1, ENC_NA);
219 rrc_tree = proto_item_add_subtree(rrc_item, ett_rrc);
222 switch (rrcinf->msgtype[pinfo->fd->subnum]) {
223 case RRC_MESSAGE_TYPE_PCCH:
224 call_dissector(rrc_pcch_handle, tvb, pinfo, rrc_tree);
226 case RRC_MESSAGE_TYPE_UL_CCCH:
227 call_dissector(rrc_ul_ccch_handle, tvb, pinfo, rrc_tree);
229 case RRC_MESSAGE_TYPE_DL_CCCH:
230 call_dissector(rrc_dl_ccch_handle, tvb, pinfo, rrc_tree);
232 case RRC_MESSAGE_TYPE_UL_DCCH:
233 call_dissector(rrc_ul_dcch_handle, tvb, pinfo, rrc_tree);
235 case RRC_MESSAGE_TYPE_DL_DCCH:
236 call_dissector(rrc_dl_dcch_handle, tvb, pinfo, rrc_tree);
238 case RRC_MESSAGE_TYPE_BCCH_FACH:
239 call_dissector(rrc_bcch_fach_handle, tvb, pinfo, rrc_tree);
245 return tvb_captured_length(tvb);
250 /*Initialize structure for muxed flow indication*/
251 hsdsch_muxed_flows = g_tree_new_full(rrc_key_cmp,
252 NULL, /* data pointer, optional */
256 /*Initialize structure for muxed flow indication*/
257 rrc_ciph_inf = g_tree_new_full(rrc_key_cmp,
258 NULL, /* data pointer, optional */
266 g_tree_destroy(hsdsch_muxed_flows);
267 g_tree_destroy(rrc_ciph_inf);
270 /*--- proto_register_rrc -------------------------------------------*/
271 void proto_register_rrc(void) {
274 static hf_register_info hf[] = {
276 #include "packet-rrc-hfarr.c"
278 { "RAB Test", "rrc.RAB.test",
279 FT_UINT8, BASE_DEC, NULL, 0,
280 "rrc.RAB_Info_r6", HFILL }},
281 { &hf_rrc_eutra_feat_group_ind_1,
282 { "Indicator 1", "rrc.eutra_feat_group_ind_1",
283 FT_BOOLEAN, BASE_NONE, TFS(&rrc_eutra_feat_group_ind_1_val), 0,
284 "EUTRA Feature Group Indicator 1", HFILL }},
285 { &hf_rrc_eutra_feat_group_ind_2,
286 { "Indicator 2", "rrc.eutra_feat_group_ind_2",
287 FT_BOOLEAN, BASE_NONE, TFS(&rrc_eutra_feat_group_ind_2_val), 0,
288 "EUTRA Feature Group Indicator 2", HFILL }},
289 { &hf_rrc_eutra_feat_group_ind_3,
290 { "Indicator 3", "rrc.eutra_feat_group_ind_3",
291 FT_BOOLEAN, BASE_NONE, TFS(&rrc_eutra_feat_group_ind_3_val), 0,
292 "EUTRA Feature Group Indicator 3", HFILL }},
293 { &hf_rrc_eutra_feat_group_ind_4,
294 { "Indicator 4", "rrc.eutra_feat_group_ind_4",
295 FT_BOOLEAN, BASE_NONE, TFS(&rrc_eutra_feat_group_ind_4_val), 0,
296 "EUTRA Feature Group Indicator 4", HFILL }},
297 { &hf_rrc_ims_info_atgw_trans_det_cont_type,
298 { "ATGW transfer details content type", "rrc.rsrvcc_info.ims_info_atgw_trans_det_cont",
299 FT_UINT8, BASE_DEC, VALS(rrc_ims_info_atgw_trans_det_cont_type), 0x3,
300 "rSR-VCC IMS information ATGW transfer details content type", HFILL }},
301 {&hf_rrc_ims_info_atgw_udp_port,
302 {"ATGW UDP port","rrc.rsrvcc_info.ims_info_atgw_udp_port",
303 FT_UINT16,BASE_DEC, NULL, 0x0,
304 "rSR-VCC IMS information ATGW UDP port", HFILL }},
305 { &hf_rrc_ims_info_atgw_ipv4,
306 {"ATGW IPv4", "rrc.rsrvcc_info.ims_info_atgw_ipv4",
307 FT_IPv4, BASE_NONE, NULL, 0x0,
308 "rSR-VCC IMS information ATGW IPv4", HFILL}},
309 { &hf_rrc_ims_info_atgw_ipv6,
310 {"ATGW IPv6", "rrc.rsrvcc_info.ims_info_atgw_ipv6",
311 FT_IPv6, BASE_NONE, NULL, 0x0,
312 "rSR-VCC IMS information ATGW IPv6", HFILL}},
315 /* List of subtrees */
316 static gint *ett[] = {
318 #include "packet-rrc-ettarr.c"
319 &ett_rrc_eutraFeatureGroupIndicators,
320 &ett_rrc_cn_CommonGSM_MAP_NAS_SysInfo,
324 static ei_register_info ei[] = {
325 { &ei_rrc_no_hrnti, { "rrc.no_hrnti", PI_SEQUENCE, PI_NOTE, "Did not detect any H-RNTI", EXPFILL }},
328 expert_module_t* expert_rrc;
330 /* Register protocol */
331 proto_rrc = proto_register_protocol(PNAME, PSNAME, PFNAME);
332 /* Register fields and subtrees */
333 proto_register_field_array(proto_rrc, hf, array_length(hf));
334 proto_register_subtree_array(ett, array_length(ett));
335 expert_rrc = expert_register_protocol(proto_rrc);
336 expert_register_field_array(expert_rrc, ei, array_length(ei));
338 register_dissector("rrc", dissect_rrc, proto_rrc);
340 #include "packet-rrc-dis-reg.c"
345 register_init_routine(rrc_init);
346 register_cleanup_routine(rrc_cleanup);
350 /*--- proto_reg_handoff_rrc ---------------------------------------*/
352 proto_reg_handoff_rrc(void)
354 gsm_a_dtap_handle = find_dissector_add_dependency("gsm_a_dtap", proto_rrc);
355 rrc_pcch_handle = find_dissector("rrc.pcch");
356 rrc_ul_ccch_handle = find_dissector("rrc.ul.ccch");
357 rrc_dl_ccch_handle = find_dissector("rrc.dl.ccch");
358 rrc_ul_dcch_handle = find_dissector("rrc.ul.dcch");
359 rrc_dl_dcch_handle = find_dissector("rrc.dl.dcch");
360 rrc_ue_radio_access_cap_info_handle = find_dissector("rrc.ue_radio_access_cap_info");
361 rrc_dl_dcch_handle = find_dissector("rrc.dl.dcch");
362 lte_rrc_ue_eutra_cap_handle = find_dissector_add_dependency("lte-rrc.ue_eutra_cap", proto_rrc);
363 lte_rrc_dl_dcch_handle = find_dissector_add_dependency("lte-rrc.dl.dcch", proto_rrc);
364 rrc_bcch_fach_handle = find_dissector("rrc.bcch.fach");
365 gsm_rlcmac_dl_handle = find_dissector_add_dependency("gsm_rlcmac_dl", proto_rrc);