Fix [-Wmissing-prototypes]
[metze/wireshark/wip.git] / epan / dissectors / packet-gmr1_rr.c
1 /* packet-gmr1_rr.c
2  *
3  * Routines for GMR-1 Radio Resource dissection in wireshark.
4  * Copyright (c) 2011 Sylvain Munaut <tnt@246tNt.com>
5  *
6  * References:
7  *  [1] ETSI TS 101 376-4-8 V1.3.1 - GMR-1 04.008
8  *  [2] ETSI TS 101 376-4-8 V2.2.1 - GMPRS-1 04.008
9  *  [3] ETSI TS 101 376-4-8 V3.1.1 - GMR-1 3G 44.008
10  *  [4] ETSI TS 100 940 V7.21.0 - GSM 04.08
11  *  [5] ETSI TS 101 376-4-12 V3.2.1 - GMR-1 3G 44.060
12  *  [6] ETSI TS 101 376-5-6 V1.3.1 - GMR-1 05.008
13  *
14  * $Id$
15  *
16  * Wireshark - Network traffic analyzer
17  * By Gerald Combs <gerald@wireshark.org>
18  * Copyright 1998 Gerald Combs
19  *
20  * This program is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU General Public License
22  * as published by the Free Software Foundation; either version 2
23  * of the License, or (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28  * GNU General Public License for more details.
29  *
30  * You should have received a copy of the GNU General Public License
31  * along with this program; if not, write to the Free Software
32  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33  */
34
35 #include "config.h"
36
37 #include <glib.h>
38 #include <epan/packet.h>
39
40 #include "packet-gmr1_common.h"
41 #include "packet-gsm_sms.h"
42
43 void proto_register_gmr1_rr(void);
44 void proto_reg_handoff_gmr1_rr(void);
45
46 /* GMR-1 RR and CCCH proto */
47 static int proto_gmr1_rr = -1;
48 static int proto_gmr1_ccch = -1;
49
50 /* Fallback CCCH sub tree */
51 static gint ett_msg_ccch = -1;
52
53 static gint ett_rr_pd = -1;
54
55 /* Handoffs */
56 static dissector_handle_t data_handle;
57
58
59
60 /* ------------------------------------------------------------------------ */
61 /* RR Information Elements                                                  */
62 /* ------------------------------------------------------------------------ */
63
64 enum gmr1_ie_rr_idx {
65         GMR1_IE_RR_CHAN_DESC = 0,               /* [1] 11.5.2.5   */
66         GMR1_IE_RR_CHAN_MODE,                   /* [1] 11.5.2.6   */
67         GMR1_IE_RR_CIPH_MODE_SETTING,           /* [4] 10.5.2.9   */
68         GMR1_IE_RR_CIPH_RESP,                   /* [4] 10.5.2.10  */
69         GMR1_IE_RR_L2_PSEUDO_LEN,               /* [1] 11.5.2.19  */
70         GMR1_IE_RR_PAGE_MODE,                   /* [1] 11.5.2.26  */
71         GMR1_IE_RR_REQ_REF,                     /* [1] 11.5.2.30  */
72         GMR1_IE_RR_CAUSE,                       /* [1] 11.5.2.31  */
73         GMR1_IE_RR_TIMING_OFS,                  /* [1] 11.5.2.40  */
74         GMR1_IE_RR_TMSI_PTMSI,                  /* [4] 10.5.2.42  */
75         GMR1_IE_RR_WAIT_IND,                    /* [4] 10.5.2.43  */
76         GMR1_IE_RR_MES_INFO_FLG,                /* [1] 11.5.2.44  */
77         GMR1_IE_RR_FREQ_OFS,                    /* [1] 11.5.2.49  */
78         GMR1_IE_RR_PAGE_INFO,                   /* [1] 11.5.2.51  */
79         GMR1_IE_RR_POS_DISPLAY,                 /* [1] 11.5.2.52  */
80         GMR1_IE_RR_POS_UPD_INFO,                /* [1] 11.5.2.54  */
81         GMR1_IE_RR_BCCH_CARRIER,                /* [1] 11.5.2.55  */
82         GMR1_IE_RR_REJECT_CAUSE,                /* [1] 11.5.2.56  */
83         GMR1_IE_RR_GPS_TIMESTAMP,               /* [1] 11.5.2.57  */
84         GMR1_IE_RR_PWR_CTRL_PRM,                /* [1] 11.5.2.60  */
85         GMR1_IE_RR_TMSI_AVAIL_MSK,              /* [1] 11.5.2.62  */
86         GMR1_IE_RR_GPS_ALMANAC,                 /* [1] 11.5.2.63  */
87         GMR1_IE_RR_MSC_ID,                      /* [1] 11.5.2.100 */
88         GMR1_IE_RR_GPS_DISCR,                   /* [1] 11.5.2.101 */
89         GMR1_IE_RR_PKT_IMM_ASS_3_PRM,           /* [3] 11.5.2.105 */
90         GMR1_IE_RR_PKT_FREQ_PRM,                /* [3] 11.5.2.106 */
91         GMR1_IE_RR_PKT_IMM_ASS_2_PRM,           /* [3] 11.5.2.107 */
92         GMR1_IE_RR_USF,                         /* [3] 11.5.2.110 */
93         GMR1_IE_RR_TIMING_ADV_IDX,              /* [3] 10.1.18.3.4 */
94         GMR1_IE_RR_TLLI,                        /* [5] 12.16      */
95         GMR1_IE_RR_PKT_PWR_CTRL_PRM,            /* [3] 10.1.18.3.3 */
96         GMR1_IE_RR_PERSISTENCE_LVL,             /* [3] 10.1.18.4.2 */
97         NUM_GMR1_IE_RR  /* Terminator */
98 };
99
100 static const value_string gmr1_ie_rr_strings[] = {
101         { GMR1_IE_RR_CHAN_DESC,
102           "Channel Description" },              /* [1] 11.5.2.5   */
103         { GMR1_IE_RR_CHAN_MODE,
104           "Channel Mode" },                     /* [1] 11.5.2.6   */
105         { GMR1_IE_RR_CIPH_MODE_SETTING,
106           "Cipher Mode Setting" },              /* [4] 10.5.2.9   */
107         { GMR1_IE_RR_CIPH_RESP,
108           "Cipher Response" },                  /* [4] 10.5.2.10  */
109         { GMR1_IE_RR_L2_PSEUDO_LEN,
110           "L2 Pseudo Length" },                 /* [1] 11.5.2.19  */
111         { GMR1_IE_RR_PAGE_MODE,
112           "Page Mode" },                        /* [1] 11.5.2.26  */
113         { GMR1_IE_RR_REQ_REF,
114           "Request Reference" },                /* [1] 11.5.2.30  */
115         { GMR1_IE_RR_CAUSE,
116           "RR Cause" },                         /* [1] 11.5.2.31  */
117         { GMR1_IE_RR_TIMING_OFS,
118           "Timing Offset" },                    /* [1] 11.5.2.40  */
119         { GMR1_IE_RR_TMSI_PTMSI,
120           "TMSI/P-TMSI" },                      /* [4] 10.5.2.42  */
121         { GMR1_IE_RR_WAIT_IND,
122           "Wait Indication" },                  /* [4] 10.5.2.43  */
123         { GMR1_IE_RR_MES_INFO_FLG,
124           "MES Information Flag" },             /* [1] 11.5.2.44  */
125         { GMR1_IE_RR_FREQ_OFS,
126           "Frequency Offset" },                 /* [1] 11.5.2.49  */
127         { GMR1_IE_RR_PAGE_INFO,
128           "Paging Information" },               /* [1] 11.5.2.51  */
129         { GMR1_IE_RR_POS_DISPLAY,
130           "Position Display" },                 /* [1] 11.5.2.52  */
131         { GMR1_IE_RR_POS_UPD_INFO,
132           "Position Update Information" },      /* [1] 11.5.2.54  */
133         { GMR1_IE_RR_BCCH_CARRIER,
134           "BCCH Carrier Specification"},        /* [1] 11.5.2.55  */
135         { GMR1_IE_RR_REJECT_CAUSE,
136           "Reject Cause" },                     /* [1] 11.5.2.56  */
137         { GMR1_IE_RR_GPS_TIMESTAMP,
138           "GPS timestamp" },                    /* [1] 11.5.2.57  */
139         { GMR1_IE_RR_PWR_CTRL_PRM,
140           "Power Control Params" },             /* [1] 11.5.2.60  */
141         { GMR1_IE_RR_TMSI_AVAIL_MSK,
142           "TMSI Availability Mask" },           /* [1] 11.5.2.62  */
143         { GMR1_IE_RR_GPS_ALMANAC,
144           "GPS Almanac Data" },                 /* [1] 11.5.2.63  */
145         { GMR1_IE_RR_MSC_ID,
146           "MSC ID" },                           /* [1] 11.5.2.100 */
147         { GMR1_IE_RR_GPS_DISCR,
148           "GPS Discriminator" },                /* [1] 11.5.2.101 */
149         { GMR1_IE_RR_PKT_IMM_ASS_3_PRM,
150           "Packet Imm. Ass. Type 3 Params" },   /* [3] 11.5.2.105 */
151         { GMR1_IE_RR_PKT_FREQ_PRM,
152           "Packet Frequency Parameters" },      /* [3] 11.5.2.106 */
153         { GMR1_IE_RR_PKT_IMM_ASS_2_PRM,
154           "Packet Imm. Ass. Type 2 Params" },   /* [3] 11.5.2.107 */
155         { GMR1_IE_RR_USF,
156           "USF" },                              /* [3] 11.5.2.110 */
157         { GMR1_IE_RR_TIMING_ADV_IDX,
158           "Timing Advance Index" },             /* [3] 10.1.18.3.4 */
159         { GMR1_IE_RR_TLLI,
160           "TLLI" },                             /* [5] 12.16      */
161         { GMR1_IE_RR_PKT_PWR_CTRL_PRM,
162           "Packet Power Control Params" },      /* [3] 10.1.18.3.3 */
163         { GMR1_IE_RR_PERSISTENCE_LVL,
164           "Persistence Level" },                /* [3] 10.1.18.4.2 */
165         { 0, NULL },
166 };
167 value_string_ext gmr1_ie_rr_strings_ext = VALUE_STRING_EXT_INIT(gmr1_ie_rr_strings);
168
169 gint ett_gmr1_ie_rr[NUM_GMR1_IE_RR];
170
171
172 /* Fields */
173 static int hf_rr_msg_type = -1;
174 static int hf_rr_chan_desc_kab_loc = -1;
175 static int hf_rr_chan_desc_rx_tn = -1;
176 static int hf_rr_chan_desc_arfcn = -1;
177 static int hf_rr_chan_desc_tx_tn = -1;
178 static int hf_rr_chan_desc_chan_type = -1;
179 static int hf_rr_chan_mode = -1;
180 static int hf_rr_ciph_mode_setting_sc = -1;
181 static int hf_rr_ciph_mode_setting_algo = -1;
182 static int hf_rr_ciph_resp_cr = -1;
183 static int hf_rr_ciph_resp_spare = -1;
184 static int hf_rr_l2_pseudo_len = -1;
185 static int hf_rr_page_mode = -1;
186 static int hf_rr_page_mode_spare = -1;
187 static int hf_rr_req_ref_est_cause = -1;
188 static int hf_rr_req_ref_ra = -1;
189 static int hf_rr_req_ref_fn = -1;
190 static int hf_rr_cause = -1;
191 static int hf_rr_timing_ofs_ti = -1;
192 static int hf_rr_timing_ofs_value = -1;
193 static int hf_rr_tmsi_ptmsi = -1;
194 static int hf_rr_wait_ind_timeout = -1;
195 static int hf_rr_mif_mes1_ab = -1;
196 static int hf_rr_mif_mes1_i = -1;
197 static int hf_rr_mif_mes1_d = -1;
198 static int hf_rr_mif_mes2 = -1;
199 static int hf_rr_mif_mes3 = -1;
200 static int hf_rr_mif_mes4 = -1;
201 static int hf_rr_mif_pv = -1;
202 static int hf_rr_freq_ofs_fi = -1;
203 static int hf_rr_freq_ofs_value = -1;
204 static int hf_rr_freq_ofs_spare = -1;
205 static int hf_rr_page_info_msc_id = -1;
206 static int hf_rr_page_info_chan_needed = -1;
207 static int hf_rr_pos_display_flag = -1;
208 static int hf_rr_pos_display_text = -1;
209 static int hf_rr_pos_upd_info_v = -1;
210 static int hf_rr_pos_upd_info_dist = -1;
211 static int hf_rr_pos_upd_info_time = -1;
212 static int hf_rr_bcch_carrier_arfcn = -1;
213 static int hf_rr_bcch_carrier_si = -1;
214 static int hf_rr_bcch_carrier_ri = -1;
215 static int hf_rr_bcch_carrier_spare = -1;
216 static int hf_rr_reject_cause = -1;
217 static int hf_rr_reject_cause_b = -1;
218 static int hf_rr_gps_timestamp = -1;
219 static int hf_rr_tmsi_avail_msk_tmsi[4] = { -1, -1, -1, -1 };
220 static int hf_rr_gps_almanac_pn = -1;
221 static int hf_rr_gps_almanac_wn = -1;
222 static int hf_rr_gps_almanac_word = -1;
223 static int hf_rr_gps_almanac_sfn = -1;
224 static int hf_rr_gps_almanac_co = -1;
225 static int hf_rr_gps_almanac_spare = -1;
226 static int hf_rr_msc_id = -1;
227 static int hf_rr_msc_id_spare = -1;
228 static int hf_rr_gps_discr = -1;
229 static int hf_rr_pkt_imm_ass_3_prm_rlc_mode = -1;
230 static int hf_rr_pkt_imm_ass_3_prm_spare = -1;
231 static int hf_rr_pkt_imm_ass_3_prm_dl_tfi = -1;
232 static int hf_rr_pkt_imm_ass_3_prm_start_fn = -1;
233 static int hf_rr_pkt_imm_ass_3_prm_mac_slot_alloc = -1;
234 static int hf_rr_pkt_freq_prm_arfcn = -1;
235 static int hf_rr_pkt_freq_prm_dl_freq_plan_id = -1;
236 static int hf_rr_pkt_freq_prm_dl_bw = -1;
237 static int hf_rr_pkt_freq_prm_ul_freq_dist = -1;
238 static int hf_rr_pkt_freq_prm_ul_bw = -1;
239 static int hf_rr_pkt_freq_prm_spare = -1;
240 static int hf_rr_pkt_imm_ass_2_prm_ac_spare1 = -1;
241 static int hf_rr_pkt_imm_ass_2_prm_ac_final_alloc = -1;
242 static int hf_rr_pkt_imm_ass_2_prm_ac_usf_granularity = -1;
243 static int hf_rr_pkt_imm_ass_2_prm_ac_dl_ctl_mac_slot = -1;
244 static int hf_rr_pkt_imm_ass_2_prm_ac_mac_mode = -1;
245 static int hf_rr_pkt_imm_ass_2_prm_ac_start_fn = -1;
246 static int hf_rr_pkt_imm_ass_2_prm_ac_rlc_dblk_gnt = -1;
247 static int hf_rr_pkt_imm_ass_2_prm_ac_mcs = -1;
248 static int hf_rr_pkt_imm_ass_2_prm_ac_tfi = -1;
249 static int hf_rr_pkt_imm_ass_2_prm_ac_spare2 = -1;
250 static int hf_rr_pkt_imm_ass_2_prm_ac_mac_slot_alloc = -1;
251 static int hf_rr_pkt_imm_ass_2_prm_d_chan_mcs_cmd = -1;
252 static int hf_rr_pkt_imm_ass_2_prm_d_chan_mcs_cmd_pnb512 = -1;
253 static int hf_rr_pkt_imm_ass_2_prm_d_spare1 = -1;
254 static int hf_rr_pkt_imm_ass_2_prm_d_rlc_dblk_gnt = -1;
255 static int hf_rr_pkt_imm_ass_2_prm_d_spare2 = -1;
256 static int hf_rr_pkt_imm_ass_2_prm_d_tfi = -1;
257 static int hf_rr_pkt_imm_ass_2_prm_d_usf_granularity = -1;
258 static int hf_rr_pkt_imm_ass_2_prm_d_mac_slot_alloc = -1;
259 static int hf_rr_usf_value = -1;
260 static int hf_rr_usf_spare = -1;
261 static int hf_rr_timing_adv_idx_value = -1;
262 static int hf_rr_timing_adv_idx_spare = -1;
263 static int hf_rr_tlli = -1;
264 static int hf_rr_pkt_pwr_ctrl_prm_par = -1;
265 static int hf_rr_pkt_pwr_ctrl_prm_spare = -1;
266 static int hf_rr_persistence_lvl[4] = { -1, -1, -1, -1 };
267
268
269 /* Generic display vals/func */
270 static const value_string rr_gen_ie_presence_vals[] = {
271         { 0, "IE is absent" },
272         { 1, "IE is present" },
273         { 0, NULL }
274 };
275
276 static void
277 rr_gen_ie_seconds_fmt(gchar *s, guint32 v)
278 {
279         g_snprintf(s, ITEM_LABEL_LENGTH, "%u seconds", v);
280 }
281
282
283
284 /* [1] 11.5.2.5 - Channel Description */
285 static const value_string rr_chan_desc_chan_type_vals[] = {
286         {  1, "TCH3 No offset" },
287         {  3, "TCH3 1/2 symbol offset" },
288         {  6, "TCH6 No offset" },
289         {  7, "TCH6 1/2 symbol offset" },
290         {  4, "TCH9 No offset" },
291         {  5, "TCH9 1/2 symbol offset" },
292         { 13, "Reserved for SDCCH frames xx00" },
293         { 14, "Reserved for SDCCH frames xx01" },
294         { 15, "Reserved for SDCCH frames xx10" },
295         { 16, "Reserved for SDCCH frames xx11" },
296         { 0, NULL }
297 };
298
299 GMR1_IE_FUNC(gmr1_ie_rr_chan_desc)
300 {
301         gint bit_offset;
302
303         bit_offset = offset << 3;
304
305         /* KAB Location (6 bits)*/
306         proto_tree_add_bits_item(tree, hf_rr_chan_desc_kab_loc, tvb,
307                                  bit_offset, 6, ENC_BIG_ENDIAN);
308         bit_offset += 6;
309
310         /* RX Timeslot (5 bits) */
311         proto_tree_add_bits_item(tree, hf_rr_chan_desc_rx_tn, tvb,
312                                  bit_offset, 5, ENC_BIG_ENDIAN);
313         bit_offset += 5;
314
315         /* ARFCN (11 bits) */
316         proto_tree_add_bits_item(tree, hf_rr_chan_desc_arfcn, tvb,
317                                  bit_offset, 11, ENC_BIG_ENDIAN);
318         bit_offset += 11;
319
320         /* TX Timeslot (5 bits) */
321         proto_tree_add_bits_item(tree, hf_rr_chan_desc_tx_tn, tvb,
322                                  bit_offset, 5, ENC_BIG_ENDIAN);
323         bit_offset += 5;
324
325         /* Channel Type (5 bits) */
326         proto_tree_add_bits_item(tree, hf_rr_chan_desc_chan_type, tvb,
327                                  bit_offset, 5, ENC_BIG_ENDIAN);
328         /*bit_offset += 5;*/
329
330         return 4;
331 }
332
333 /* [1] 11.5.2.6 - Channel Mode */
334 static const value_string rr_chan_mode_vals[] = {
335         { 0x00, "Signalling only" },
336         { 0x01, "Speech" },
337         { 0x03, "Data, 12,0 kbit/s radio I/F rate" },
338         { 0x0b, "Data, 6,0 kbit/s radio I/F rate" },
339         { 0x13, "Data, 3,6 kbit/s radio I/F rate" },
340         { 0, NULL }
341 };
342
343 GMR1_IE_FUNC(gmr1_ie_rr_chan_mode)
344 {
345         /* Channel Mode */
346         proto_tree_add_item(tree, hf_rr_chan_mode, tvb, offset, 1, ENC_BIG_ENDIAN);
347
348         return 1;
349 }
350
351 /* [4] 10.5.2.9 - Cipher Mode Setting */
352 static const value_string rr_ciph_mode_setting_sc_vals[] = {
353         { 0, "No ciphering"},
354         { 1, "Start ciphering"},
355         { 0, NULL }
356 };
357
358 static const value_string rr_ciph_mode_setting_algo_vals[] = {
359         { 0, "A5/1" },
360         { 1, "A5/2" },
361         { 2, "A5/3" },
362         { 3, "A5/4" },
363         { 4, "A5/5" },
364         { 5, "A5/6" },
365         { 6, "A5/7" },
366         { 7, "Reverved" },
367         { 0, NULL }
368 };
369
370 GMR1_IE_FUNC(gmr1_ie_rr_ciph_mode_setting)
371 {
372         /* SC */
373         proto_tree_add_item(tree, hf_rr_ciph_mode_setting_sc, tvb, offset, 1, ENC_BIG_ENDIAN);
374
375         /* Algo */
376         proto_tree_add_item(tree, hf_rr_ciph_mode_setting_algo, tvb, offset, 1, ENC_BIG_ENDIAN);
377
378         return 1;
379 }
380
381 /* [4] 10.5.2.10 - Cipher Response */
382 static const value_string rr_ciph_resp_cr_vals[] = {
383         { 0, "IMEISV shall not be included"},
384         { 1, "IMEISV shall be included"},
385         { 0, NULL }
386 };
387
388 GMR1_IE_FUNC(gmr1_ie_rr_ciph_resp)
389 {
390         /* CR */
391         proto_tree_add_item(tree, hf_rr_ciph_resp_cr, tvb, offset, 1, ENC_BIG_ENDIAN);
392
393         /* Spare */
394         proto_tree_add_item(tree, hf_rr_ciph_resp_spare, tvb, offset, 1, ENC_BIG_ENDIAN);
395
396         return 1;
397 }
398
399 /* [1] 11.5.2.19 - L2 Pseudo Length */
400 GMR1_IE_FUNC(gmr1_ie_rr_l2_pseudo_len)
401 {
402         /* L2 Pseudo Length value */
403         proto_tree_add_item(tree, hf_rr_l2_pseudo_len, tvb, offset, 1, ENC_BIG_ENDIAN);
404
405         return 1;
406 }
407
408 /* [1] 11.5.2.26 - Page Mode */
409 static const value_string rr_page_mode_vals[] = {
410         { 0, "Normal Paging" },
411         { 1, "Reserved (Changed from Extended Paging in GSM)" },
412         { 2, "Paging Reorganization" },
413         { 3, "Same as before" },
414         { 0, NULL }
415 };
416
417 GMR1_IE_FUNC(gmr1_ie_rr_page_mode)
418 {
419         /* Page mode */
420         proto_tree_add_item(tree, hf_rr_page_mode, tvb, offset, 1, ENC_BIG_ENDIAN);
421
422         /* Spare */
423         proto_tree_add_item(tree, hf_rr_page_mode_spare, tvb, offset, 1, ENC_BIG_ENDIAN);
424
425         return 1;
426 }
427
428 /* [1] 11.5.2.30 - Request Reference */
429 static const value_string rr_req_ref_est_cause_vals[] = {
430         { 0, "MO call" },
431         { 1, "In response to paging/alerting" },
432         { 2, "Location update/IMSI detach" },
433         { 3, "Emergency call" },
434         { 4, "Supplementary/short message service" },
435         { 5, "Position verification" },
436         { 6, "Any other valid cause" },
437         { 7, "Reserved" },
438         { 0, NULL }
439 };
440
441 GMR1_IE_FUNC(gmr1_ie_rr_req_ref)
442 {
443         /* Establishement Cause + RA */
444         proto_tree_add_item(tree, hf_rr_req_ref_est_cause, tvb, offset, 1, ENC_BIG_ENDIAN);
445         proto_tree_add_item(tree, hf_rr_req_ref_ra, tvb, offset, 1, ENC_BIG_ENDIAN);
446         offset++;
447
448         /* Frame number % 256 */
449         proto_tree_add_item(tree, hf_rr_req_ref_fn, tvb, offset, 1, ENC_BIG_ENDIAN);
450
451         return 2;
452 }
453
454 /* [1] 11.5.2.31 - RR Cause */
455 static const value_string rr_cause_vals[] = {
456         { 0x00, "Normal event" },
457         { 0x01, "Abnormal release, unspecified" },
458         { 0x02, "Abnormal release, channel unacceptable" },
459         { 0x03, "Abnormal release, timer expired" },
460         { 0x04, "Abnormal release, no activity on the radio path" },
461         { 0x05, "Preemptive release" },
462         { 0x09, "Channel mode unacceptable" },
463         { 0x0a, "Frequency not implemented" },
464         { 0x0b, "Position unacceptable" },
465         { 0x41, "Call already cleared" },
466         { 0x5f, "Semantically incorrect message" },
467         { 0x60, "Invalid mandatory information" },
468         { 0x61, "Message type nonexistent or not implemented" },
469         { 0x62, "Message type not compatible with protocol state" },
470         { 0x6f, "Protocol error unspecified" },
471         { 0, NULL }
472 };
473
474 GMR1_IE_FUNC(gmr1_ie_rr_cause)
475 {
476         /* RR Cause */
477         proto_tree_add_item(tree, hf_rr_cause, tvb, offset, 1, ENC_BIG_ENDIAN);
478
479         return 1;
480 }
481
482 /* [1] 11.5.2.40 - Timing Offset */
483 static const value_string rr_timing_ofs_ti_vals[] = {
484         { 0, "The timing offset parameter in this IE to be ignored" },
485         { 1, "The timing offset parameter has a valid value" },
486         { 0, NULL }
487 };
488
489 static void
490 rr_timing_ofs_value_fmt(gchar *s, guint32 v)
491 {
492         gint32 sv = (signed)v;
493
494         g_snprintf(s, ITEM_LABEL_LENGTH, "%.3f symbols ( ~ %.3f ms )",
495                 sv / 40.0f, (sv / 40.0f) * (10.0f / 234.0f));
496 }
497
498 GMR1_IE_FUNC(gmr1_ie_rr_timing_ofs)
499 {
500         gint bit_offset;
501
502         bit_offset = offset << 3;
503
504         /* TI */
505         proto_tree_add_bits_item(tree, hf_rr_timing_ofs_ti, tvb,
506                                  bit_offset, 1, ENC_BIG_ENDIAN);
507         bit_offset++;
508
509         /* Value */
510         proto_tree_add_bits_item(tree, hf_rr_timing_ofs_value, tvb,
511                                  bit_offset, 15, ENC_BIG_ENDIAN);
512         /*bit_offset += 15;*/
513
514         return 2;
515 }
516
517 /* [4] 10.5.2.42 - TMSI/P-TMSI */
518 GMR1_IE_FUNC(gmr1_ie_rr_tmsi_ptmsi)
519 {
520         /* TMSI/P-TMSI value as hex */
521         proto_tree_add_item(tree, hf_rr_tmsi_ptmsi, tvb, offset, 4, ENC_BIG_ENDIAN);
522
523         return 4;
524 }
525
526 /* [4] 10.5.2.43 - Wait Indication */
527 GMR1_IE_FUNC(gmr1_ie_rr_wait_ind)
528 {
529         /* Timeout value */
530         proto_tree_add_item(tree, hf_rr_wait_ind_timeout, tvb, offset, 1, ENC_BIG_ENDIAN);
531
532         return 1;
533 }
534
535 /* [1] 11.5.2.44 - MES Information Flag */
536 static const value_string rr_mif_mes1_ab_vals[] = {
537         { 0, "Chan. Assigned: MES1 registered at selected GS" },
538         { 1, "Chan. Assigned: MES1 requires registration at selected GS" },
539         { 2, "Chan. Assigned; MES 1 Extended Channel Req. Reqd" },
540         { 3, "Pause Timer Indication" },
541         { 0, NULL }
542 };
543
544 static const value_string rr_mif_mes234_vals[] = {
545         { 0, "MES doesn't exists" },
546         { 1, "Pause Timer Ind for this MES" },
547         { 0, NULL }
548 };
549
550 static const value_string rr_mif_pv_vals[] = {
551         { 0, "Position Verification not requested" },
552         { 1, "MES1 shall send a Channel Request for Position Verification following the completion of the upcoming call" },
553         { 0, NULL }
554 };
555
556 GMR1_IE_FUNC(gmr1_ie_rr_mes_info_flg)
557 {
558         proto_tree_add_item(tree, hf_rr_mif_mes1_ab,
559                             tvb, offset, 1, ENC_BIG_ENDIAN);
560
561         proto_tree_add_item(tree, hf_rr_mif_mes1_i,
562                             tvb, offset, 1, ENC_BIG_ENDIAN);
563
564         proto_tree_add_item(tree, hf_rr_mif_mes1_d,
565                             tvb, offset, 1, ENC_BIG_ENDIAN);
566
567         proto_tree_add_item(tree, hf_rr_mif_mes2,
568                             tvb, offset, 1, ENC_BIG_ENDIAN);
569
570         proto_tree_add_item(tree, hf_rr_mif_mes3,
571                             tvb, offset, 1, ENC_BIG_ENDIAN);
572
573         proto_tree_add_item(tree, hf_rr_mif_mes4,
574                             tvb, offset, 1, ENC_BIG_ENDIAN);
575
576         proto_tree_add_item(tree, hf_rr_mif_pv,
577                             tvb, offset, 1, ENC_BIG_ENDIAN);
578
579         return 1;
580 }
581
582 /* [1] 11.5.2.49 - Frequency Offset */
583 static const value_string rr_freq_ofs_fi_vals[] = {
584         { 0, "The frequency offset parameter in this IE to be ignored" },
585         { 1, "The frequency offset parameter has a valid value" },
586         { 0, NULL }
587 };
588
589 static void
590 rr_freq_ofs_value_fmt(gchar *s, guint32 v)
591 {
592         gint32 sv = (signed)v;
593
594         g_snprintf(s, ITEM_LABEL_LENGTH, "%d Hz", sv);
595 }
596
597 GMR1_IE_FUNC(gmr1_ie_rr_freq_ofs)
598 {
599         gint bit_offset;
600
601         bit_offset = offset << 3;
602
603         /* FI */
604         proto_tree_add_bits_item(tree, hf_rr_freq_ofs_fi, tvb,
605                                  bit_offset, 1, ENC_BIG_ENDIAN);
606         bit_offset++;
607
608         /* Value */
609         proto_tree_add_bits_item(tree, hf_rr_freq_ofs_value, tvb,
610                                  bit_offset, 12, ENC_BIG_ENDIAN);
611         bit_offset += 12;
612
613         /* Spare */
614         proto_tree_add_bits_item(tree, hf_rr_freq_ofs_spare, tvb,
615                                  bit_offset, 3, ENC_BIG_ENDIAN);
616         /*bit_offset += 3;*/
617
618         return 2;
619 }
620
621 /* [1] 11.5.2.51 - Paging Information */
622 static const value_string rr_page_info_chan_needed_vals[] = {
623         { 0, "Any" },
624         { 1, "SDCCH" },
625         { 2, "TCH3" },
626         { 3, "PDCCH" },
627         { 0, NULL }
628 };
629
630 GMR1_IE_FUNC(gmr1_ie_rr_page_info)
631 {
632         /* MSC ID & Channe needed */
633         proto_tree_add_item(tree, hf_rr_page_info_msc_id,
634                             tvb, offset, 1, ENC_BIG_ENDIAN);
635         proto_tree_add_item(tree, hf_rr_page_info_chan_needed,
636                             tvb, offset, 1, ENC_BIG_ENDIAN);
637
638         return 1;
639 }
640
641 /* [1] 11.5.2.52 - Position Display */
642 static const value_string rr_pos_display_flag_vals[] = {
643         { 0, "Position not available" },
644         { 1, "No position display service" },
645         { 2, "Use default 7-bit alphabet (GSM 03.38)" },
646         { 0, NULL }
647 };
648
649 GMR1_IE_FUNC(gmr1_ie_rr_pos_display)
650 {
651         const unsigned char *txt_raw;
652         unsigned char txt_packed[11], txt_unpacked[12];
653         int out_len, i;
654
655         /* Flag */
656         proto_tree_add_item(tree, hf_rr_pos_display_flag,
657                             tvb, offset, 1, ENC_BIG_ENDIAN);
658
659         /* Unpack text */
660         txt_raw = tvb_get_ptr(tvb, offset, 11);
661
662         for (i=0; i<10; i++)
663                 txt_packed[i] = (txt_raw[i] << 4) | (txt_raw[i+1] >> 4);
664         txt_packed[10] = txt_raw[10];
665
666         out_len = gsm_sms_char_7bit_unpack(0, 11, 12, txt_packed, txt_unpacked);
667
668         /* Display it */
669         proto_tree_add_string(tree, hf_rr_pos_display_text, tvb, offset, 11,
670                               gsm_sms_chars_to_utf8(txt_unpacked, out_len));
671
672         return 11;
673 }
674
675 /* [1] 11.5.2.54 - Position Update Information */
676 static const value_string rr_pos_upd_info_v_vals[] = {
677         { 0, "Information in this IE is Invalid and should be ignored" },
678         { 1, "Information in this IE is Valid" },
679         { 0, NULL }
680 };
681
682 static void
683 rr_pos_upd_info_dist_fmt(gchar *s, guint32 v)
684 {
685         g_snprintf(s, ITEM_LABEL_LENGTH, "%d km", v);
686 }
687
688 static void
689 rr_pos_upd_info_time_fmt(gchar *s, guint32 v)
690 {
691         g_snprintf(s, ITEM_LABEL_LENGTH, "%d minutes", v);
692 }
693
694 GMR1_IE_FUNC(gmr1_ie_rr_pos_upd_info)
695 {
696         gint curr_offset = offset;
697
698         /* Valid & GPS Update Distance */
699         proto_tree_add_item(tree, hf_rr_pos_upd_info_v,
700                             tvb, curr_offset, 1, ENC_BIG_ENDIAN);
701         proto_tree_add_item(tree, hf_rr_pos_upd_info_dist,
702                             tvb, curr_offset, 1, ENC_BIG_ENDIAN);
703         curr_offset++;
704
705         /* GPS Update Timer */
706         proto_tree_add_item(tree, hf_rr_pos_upd_info_time,
707                             tvb, curr_offset, 1, ENC_BIG_ENDIAN);
708         curr_offset++;
709
710         return 2;
711 }
712
713 /* [1] 11.5.2.55 - BCCH Carrier */
714 static const value_string rr_bcch_carrier_si_vals[] = {
715         { 0, "BCCH carrier is on the same satellite" },
716         { 1, "BCCH carrier is on a different satellite" },
717         { 0, NULL }
718 };
719
720 static const value_string rr_bcch_carrier_ri_vals[] = {
721         { 0, "Spot beam reselection not needed; use the spot beam with given BCCH" },
722         { 1, "Spot beam reselection needed; use the BCCH for spot beam reselection" },
723         { 0, NULL }
724 };
725
726 GMR1_IE_FUNC(gmr1_ie_rr_bcch_carrier)
727 {
728         gint bit_offset;
729
730         bit_offset = offset << 3;
731
732         /* ARFCN */
733         proto_tree_add_bits_item(tree, hf_rr_bcch_carrier_arfcn,
734                                  tvb, bit_offset, 11, ENC_BIG_ENDIAN);
735         bit_offset += 11;
736
737         /* Sat ind */
738         proto_tree_add_bits_item(tree, hf_rr_bcch_carrier_si,
739                                  tvb, bit_offset, 1, ENC_BIG_ENDIAN);
740         bit_offset++;
741
742         /* Resel ind */
743         proto_tree_add_bits_item(tree, hf_rr_bcch_carrier_ri,
744                                  tvb, bit_offset, 1, ENC_BIG_ENDIAN);
745         bit_offset++;
746
747         /* Spare */
748         proto_tree_add_bits_item(tree, hf_rr_bcch_carrier_spare,
749                                  tvb, bit_offset, 3, ENC_BIG_ENDIAN);
750         /*bit_offset += 3;*/
751
752         return 2;
753 }
754
755 /* [1] 11.5.2.56 - Reject Cause */
756 static const value_string rr_reject_cause_vals[] = {
757         { 0x00, "Lack of resources (default)" },
758         { 0x11, "Invalid position for selected LAI" },
759         { 0x12, "Invalid position for selected spot beam" },
760         { 0x13, "Invalid position" },
761         { 0x15, "Position too old" },
762         { 0x16, "Invalid position for service provider" },
763         { 0x17, "Redirect to new satellite" },
764         { 0x3f, "Reported position acceptable" },
765         { 0, NULL }
766 };
767
768 GMR1_IE_FUNC(gmr1_ie_rr_reject_cause)
769 {
770         /* Cause */
771         proto_tree_add_item(tree, hf_rr_reject_cause,
772                             tvb, offset, 1, ENC_BIG_ENDIAN);
773
774         /* BCCH carrier */
775         proto_tree_add_item(tree, hf_rr_reject_cause_b,
776                             tvb, offset, 1, ENC_BIG_ENDIAN);
777
778         return 1;
779 }
780
781 /* [1] 11.5.2.57 - GPS timestamp */
782 static void
783 rr_gps_timestamp_fmt(gchar *s, guint32 v)
784 {
785         if (v == 0xffff)
786                 g_snprintf(s, ITEM_LABEL_LENGTH, "> 65535 minutes or N/A");
787         else
788                 g_snprintf(s, ITEM_LABEL_LENGTH, "%d minutes", v);
789 }
790
791 GMR1_IE_FUNC(gmr1_ie_rr_gps_timestamp)
792 {
793         /* GPS timestamp */
794         proto_tree_add_item(tree, hf_rr_gps_timestamp,
795                             tvb, offset, 2, ENC_BIG_ENDIAN);
796
797         return 2;
798 }
799
800 /* [1] 11.5.2.60 - Power Control Params */
801 GMR1_IE_FUNC(gmr1_ie_rr_pwr_ctrl_prm)
802 {
803         /* It's CSN1 encoded and we have no real world sample. Until we do,
804          * we don't pollute the code with a bunch of untested stuff ... */
805
806         proto_tree_add_text(tree, tvb, offset, 5, "Power Control Parameters");
807
808         return 5;
809 }
810
811 /* [1] 11.5.2.62 - Availability Mask */
812 GMR1_IE_FUNC(gmr1_ie_rr_tmsi_avail_msk)
813 {
814         int i;
815
816         for (i=0; i<4; i++)
817                 proto_tree_add_item(tree, hf_rr_tmsi_avail_msk_tmsi[i],
818                                     tvb, offset, 1, ENC_BIG_ENDIAN);
819
820         return 1;
821 }
822
823 /* [1] 11.5.2.63 - GPS Almanac Data */
824 static void
825 rr_gps_almanac_pn_fmt(gchar *s, guint32 v)
826 {
827         g_snprintf(s, ITEM_LABEL_LENGTH, "%d", v+1);
828 }
829
830 static const value_string rr_gps_almanac_sfn_vals[] = {
831         { 0, "Frame 4" },
832         { 1, "Frame 5" },
833         { 0, NULL }
834 };
835
836
837 GMR1_IE_FUNC(gmr1_ie_rr_gps_almanac)
838 {
839         gint curr_offset = offset;
840
841         /* Page Number & Word Number */
842         proto_tree_add_item(tree, hf_rr_gps_almanac_pn,
843                             tvb, curr_offset, 1, ENC_BIG_ENDIAN);
844         proto_tree_add_item(tree, hf_rr_gps_almanac_wn,
845                             tvb, curr_offset, 1, ENC_BIG_ENDIAN);
846         curr_offset++;
847
848         /* Almanac Data */
849         proto_tree_add_item(tree, hf_rr_gps_almanac_word,
850                             tvb, curr_offset, 3, ENC_BIG_ENDIAN);
851         curr_offset += 3;
852
853         /* SubFrame Number & CO & Spare */
854         proto_tree_add_item(tree, hf_rr_gps_almanac_sfn,
855                             tvb, curr_offset, 1, ENC_BIG_ENDIAN);
856         proto_tree_add_item(tree, hf_rr_gps_almanac_co,
857                             tvb, curr_offset, 1, ENC_BIG_ENDIAN);
858         proto_tree_add_item(tree, hf_rr_gps_almanac_spare,
859                             tvb, curr_offset, 1, ENC_BIG_ENDIAN);
860         curr_offset++;
861
862         return 5;
863 }
864
865 /* [1] 11.5.2.100 - MSC ID */
866 GMR1_IE_FUNC(gmr1_ie_rr_msc_id)
867 {
868         /* MSC ID */
869         proto_tree_add_item(tree, hf_rr_msc_id,
870                             tvb, offset, 1, ENC_BIG_ENDIAN);
871
872         /* Spare bits */
873         proto_tree_add_item(tree, hf_rr_msc_id_spare,
874                             tvb, offset, 1, ENC_BIG_ENDIAN);
875
876         return 1;
877 }
878
879 /* [1] 11.5.2.101 - GPS Discriminator */
880 GMR1_IE_FUNC(gmr1_ie_rr_gps_discr)
881 {
882         /* GPS Position CRC value */
883         proto_tree_add_item(tree, hf_rr_gps_discr, tvb, offset, 2, ENC_BIG_ENDIAN);
884
885         return 2;
886 }
887
888 /* [3] 11.5.2.105 - Packet Imm. Ass. Type 3 Params */
889 static const value_string rr_pkt_imm_ass_3_prm_rlc_mode_vals[] = {
890         { 0, "RLC acknowledged mode" },
891         { 1, "RLC unacknowledged mode" },
892         { 0, NULL }
893 };
894
895 static const crumb_spec_t rr_pkt_imm_ass_3_prm_dl_tfi_crumbs[] = {
896         {  0, 3 },
897         { 12, 4 },
898         {  0, 0 }
899 };
900
901 GMR1_IE_FUNC(gmr1_ie_rr_pkt_imm_ass_3_prm)
902 {
903         /* RLC Mode */
904         proto_tree_add_item(tree, hf_rr_pkt_imm_ass_3_prm_rlc_mode,
905                             tvb, offset, 1, ENC_BIG_ENDIAN);
906
907         /* Spare */
908         proto_tree_add_item(tree, hf_rr_pkt_imm_ass_3_prm_spare,
909                             tvb, offset, 1, ENC_BIG_ENDIAN);
910
911         /* Downlink Tempory Flow Identifier (TFI) */
912         proto_tree_add_split_bits_item_ret_val(
913                 tree, hf_rr_pkt_imm_ass_3_prm_dl_tfi,
914                 tvb, offset << 3,
915                 rr_pkt_imm_ass_3_prm_dl_tfi_crumbs,
916                 NULL);
917
918         /* Starting Frame Number */
919         proto_tree_add_item(tree, hf_rr_pkt_imm_ass_3_prm_start_fn,
920                             tvb, offset+1, 1, ENC_BIG_ENDIAN);
921
922         /* MAC Slot allocation */
923         proto_tree_add_item(tree, hf_rr_pkt_imm_ass_3_prm_mac_slot_alloc,
924                             tvb, offset+2, 1, ENC_BIG_ENDIAN);
925
926         return 3;
927 }
928
929 /* [3] 11.5.2.106 - Packet Frequency Parameters */
930 static const value_string rr_pkt_freq_prm_dl_freq_plan_id_vals[] = {
931         { 0, "S-Band" },        /* Pretty much a guess ... */
932         { 1, "L-Band" },        /* didn't find exact value in specs */
933         { 0, NULL }
934 };
935
936 static const crumb_spec_t rr_pkt_freq_prm_arfcn_crumbs[] = {
937         {  0, 8 },
938         { 13, 3 },
939         {  0, 0 }
940 };
941
942 static const crumb_spec_t rr_pkt_freq_prm_ul_freq_dist_crumbs[] = {
943         {  0, 1 },
944         { 12, 4 },
945         {  0, 0 }
946 };
947
948 static void
949 rr_pkt_freq_prm_xx_bw_fmt(gchar *s, guint32 v)
950 {
951         g_snprintf(s, ITEM_LABEL_LENGTH, "%d * 31.25 kHz = %.2f kHz (%d)", v, 31.25f*v, v);
952 }
953
954 GMR1_IE_FUNC(gmr1_ie_rr_pkt_freq_prm)
955 {
956         /* ARFCN */
957         proto_tree_add_split_bits_item_ret_val(
958                 tree, hf_rr_pkt_freq_prm_arfcn,
959                 tvb, offset << 3,
960                 rr_pkt_freq_prm_arfcn_crumbs,
961                 NULL);
962
963         /* DL Freq plan ID */
964         proto_tree_add_item(tree, hf_rr_pkt_freq_prm_dl_freq_plan_id,
965                             tvb, offset+1, 1, ENC_BIG_ENDIAN);
966
967         /* DL bandwidth */
968         proto_tree_add_item(tree, hf_rr_pkt_freq_prm_dl_bw,
969                             tvb, offset+1, 1, ENC_BIG_ENDIAN);
970
971         /* UL Freq distance */
972         proto_tree_add_split_bits_item_ret_val(
973                 tree, hf_rr_pkt_freq_prm_ul_freq_dist,
974                 tvb, (offset+1) << 3,
975                 rr_pkt_freq_prm_ul_freq_dist_crumbs,
976                 NULL);
977
978         /* UL bandwidth */
979         proto_tree_add_item(tree, hf_rr_pkt_freq_prm_ul_bw,
980                             tvb, offset+2, 1, ENC_BIG_ENDIAN);
981
982         /* Spare */
983         proto_tree_add_item(tree, hf_rr_pkt_freq_prm_spare,
984                             tvb, offset+2, 1, ENC_BIG_ENDIAN);
985
986         return 3;
987 }
988
989 /* [3] 11.5.2.107 - Packet Imm. Ass. Type 2 Params */
990 static const value_string rr_pkt_imm_ass_2_prm_ac_mac_mode_vals[] = {
991         { 0, "Dynamic allocation" },
992         { 1, "Reverved" },
993         { 2, "Reverved" },
994         { 3, "Reverved" },
995         { 0, NULL }
996 };
997
998 static const crumb_spec_t rr_pkt_imm_ass_2_prm_ac_rlc_dblk_gnt_crumbs[] = {
999         {  0, 4 },
1000         { 13, 3 },
1001         {  0, 0 }
1002 };
1003
1004 GMR1_IE_FUNC(gmr1_ie_rr_pkt_imm_ass_2_prm)
1005 {
1006         proto_tree *subtree_ac, *subtree_d;
1007         proto_item *item_ac, *item_d;
1008
1009
1010         /* Terminal AC */
1011         /* ----------- */
1012
1013         item_ac = proto_tree_add_text(tree, tvb, offset, 5, "GMPRS Terminal type A or C");
1014         subtree_ac = proto_item_add_subtree(item_ac, ett_gmr1_ie_rr[GMR1_IE_RR_PKT_IMM_ASS_2_PRM]);
1015
1016         /* Spare */
1017         proto_tree_add_item(subtree_ac, hf_rr_pkt_imm_ass_2_prm_ac_spare1,
1018                             tvb, offset, 1, ENC_BIG_ENDIAN);
1019
1020         /* Final Allocation */
1021         proto_tree_add_item(subtree_ac, hf_rr_pkt_imm_ass_2_prm_ac_final_alloc,
1022                             tvb, offset, 1, ENC_BIG_ENDIAN);
1023
1024         /* USF Granularity */
1025         proto_tree_add_item(subtree_ac, hf_rr_pkt_imm_ass_2_prm_ac_usf_granularity,
1026                             tvb, offset, 1, ENC_BIG_ENDIAN);
1027
1028         /* Downlink Control MAC slot */
1029         proto_tree_add_item(subtree_ac, hf_rr_pkt_imm_ass_2_prm_ac_dl_ctl_mac_slot,
1030                             tvb, offset, 1, ENC_BIG_ENDIAN);
1031
1032         /* MAC Mode */
1033         proto_tree_add_item(subtree_ac, hf_rr_pkt_imm_ass_2_prm_ac_mac_mode,
1034                             tvb, offset, 1, ENC_BIG_ENDIAN);
1035
1036         /* Starting Frame Number */
1037         proto_tree_add_item(subtree_ac, hf_rr_pkt_imm_ass_2_prm_ac_start_fn,
1038                             tvb, offset+1, 1, ENC_BIG_ENDIAN);
1039
1040         /* RLC Data Blocks Granted */
1041         proto_tree_add_split_bits_item_ret_val(
1042                 tree, hf_rr_pkt_imm_ass_2_prm_ac_rlc_dblk_gnt,
1043                 tvb, (offset+1) << 3,
1044                 rr_pkt_imm_ass_2_prm_ac_rlc_dblk_gnt_crumbs,
1045                 NULL);
1046
1047         /* MCS */
1048         proto_tree_add_item(subtree_ac, hf_rr_pkt_imm_ass_2_prm_ac_mcs,
1049                             tvb, offset+2, 1, ENC_BIG_ENDIAN);
1050
1051         /* TFI */
1052         proto_tree_add_item(subtree_ac, hf_rr_pkt_imm_ass_2_prm_ac_tfi,
1053                             tvb, offset+3, 1, ENC_BIG_ENDIAN);
1054
1055         /* Spare */
1056         proto_tree_add_item(subtree_ac, hf_rr_pkt_imm_ass_2_prm_ac_spare2,
1057                             tvb, offset+3, 1, ENC_BIG_ENDIAN);
1058
1059         /* MAC Slot allocation */
1060         proto_tree_add_item(subtree_ac, hf_rr_pkt_imm_ass_2_prm_ac_mac_slot_alloc,
1061                             tvb, offset+4, 1, ENC_BIG_ENDIAN);
1062
1063         /* Terminal D */
1064         /* ---------- */
1065
1066         item_d = proto_tree_add_text(tree, tvb, offset, 5, "GMPRS Terminal type D");
1067         subtree_d = proto_item_add_subtree(item_d, ett_gmr1_ie_rr[GMR1_IE_RR_PKT_IMM_ASS_2_PRM]);
1068
1069         /* Channel MCS command */
1070         proto_tree_add_item(subtree_d, hf_rr_pkt_imm_ass_2_prm_d_chan_mcs_cmd,
1071                             tvb, offset, 1, ENC_BIG_ENDIAN);
1072
1073         /* Channel MCS command PNB(5,12) */
1074         proto_tree_add_item(subtree_d, hf_rr_pkt_imm_ass_2_prm_d_chan_mcs_cmd_pnb512,
1075                             tvb, offset, 1, ENC_BIG_ENDIAN);
1076
1077         /* Spare */
1078         proto_tree_add_item(subtree_d, hf_rr_pkt_imm_ass_2_prm_d_spare1,
1079                             tvb, offset+1, 1, ENC_BIG_ENDIAN);
1080
1081         /* RLC Data Blocks Granted */
1082         proto_tree_add_item(subtree_d, hf_rr_pkt_imm_ass_2_prm_d_rlc_dblk_gnt,
1083                             tvb, offset+2, 1, ENC_BIG_ENDIAN);
1084
1085         /* Spare */
1086         proto_tree_add_item(subtree_d, hf_rr_pkt_imm_ass_2_prm_d_spare2,
1087                             tvb, offset+2, 1, ENC_BIG_ENDIAN);
1088
1089         /* TFI */
1090         proto_tree_add_item(subtree_d, hf_rr_pkt_imm_ass_2_prm_d_tfi,
1091                             tvb, offset+3, 1, ENC_BIG_ENDIAN);
1092
1093         /* USF Granularity */
1094         proto_tree_add_item(subtree_d, hf_rr_pkt_imm_ass_2_prm_d_usf_granularity,
1095                             tvb, offset+3, 1, ENC_BIG_ENDIAN);
1096
1097         /* MAC Slot allocation */
1098         proto_tree_add_item(subtree_d, hf_rr_pkt_imm_ass_2_prm_d_mac_slot_alloc,
1099                             tvb, offset+4, 1, ENC_BIG_ENDIAN);
1100
1101
1102         return 5;
1103 }
1104
1105 /* [3] 11.5.2.110 - USF */
1106 GMR1_IE_FUNC(gmr1_ie_rr_usf)
1107 {
1108         /* Spare */
1109         proto_tree_add_item(tree, hf_rr_usf_spare,
1110                             tvb, offset, 3, ENC_BIG_ENDIAN);
1111
1112         /* USF */
1113         proto_tree_add_item(tree, hf_rr_usf_value,
1114                             tvb, offset+2, 1, ENC_BIG_ENDIAN);
1115
1116         return 3;
1117 }
1118
1119 /* [3] 10.1.18.3.4 & [5] 12.29 - Timing Advance Index */
1120 GMR1_IE_FUNC(gmr1_ie_rr_timing_adv_idx)
1121 {
1122         /* TAI */
1123         proto_tree_add_item(tree, hf_rr_timing_adv_idx_value,
1124                             tvb, offset, 1, ENC_BIG_ENDIAN);
1125
1126         /* Spare */
1127         proto_tree_add_item(tree, hf_rr_timing_adv_idx_spare,
1128                             tvb, offset, 1, ENC_BIG_ENDIAN);
1129
1130         return 1;
1131 }
1132
1133 /* [5] 12.16 - TLLI */
1134 GMR1_IE_FUNC(gmr1_ie_rr_tlli)
1135 {
1136         /* TLLI value as hex */
1137         proto_tree_add_item(tree, hf_rr_tlli, tvb, offset, 4, ENC_BIG_ENDIAN);
1138
1139         return 4;
1140 }
1141
1142 /* [3] 10.1.18.3.3 & [5] 10.4.10a & [6] 5.3.3 - Packet Power Control Params */
1143 static void
1144 rr_pkt_pwr_ctrl_prm_par_fmt(gchar *s, guint32 v)
1145 {
1146         if (v >= 61) {
1147                 g_snprintf(s, ITEM_LABEL_LENGTH, "Escape %d (%d)", v-60, v);
1148                 return;
1149         }
1150
1151         g_snprintf(s, ITEM_LABEL_LENGTH, "%.1f dB (%d)", v*0.4f, v);
1152 }
1153
1154 GMR1_IE_FUNC(gmr1_ie_rr_pkt_pwr_ctrl_prm)
1155 {
1156         /* Power Attenuation Request (PAR) */
1157         proto_tree_add_item(tree, hf_rr_pkt_pwr_ctrl_prm_par,
1158                             tvb, offset, 1, ENC_BIG_ENDIAN);
1159
1160         /* Spare */
1161         proto_tree_add_item(tree, hf_rr_pkt_pwr_ctrl_prm_spare,
1162                             tvb, offset, 1, ENC_BIG_ENDIAN);
1163
1164         return 1;
1165 }
1166
1167 /* [3] 10.1.18.4.2 & [5] 12.14 - Persistence Level */
1168 GMR1_IE_FUNC(gmr1_ie_rr_persistence_lvl)
1169 {
1170         int i;
1171
1172         for (i=0; i<4; i++)
1173                 proto_tree_add_item(tree, hf_rr_persistence_lvl[i],
1174                                     tvb, offset + (i>>1), 1, ENC_BIG_ENDIAN);
1175
1176         return 2;
1177 }
1178
1179
1180 elem_fcn gmr1_ie_rr_func[NUM_GMR1_IE_RR] = {
1181         gmr1_ie_rr_chan_desc,           /* Channel Description */
1182         gmr1_ie_rr_chan_mode,           /* Channel Mode */
1183         gmr1_ie_rr_ciph_mode_setting,   /* Cipher Mode Setting */
1184         gmr1_ie_rr_ciph_resp,           /* Cipher Response */
1185         gmr1_ie_rr_l2_pseudo_len,       /* L2 Pseudo Length */
1186         gmr1_ie_rr_page_mode,           /* Page Mode */
1187         gmr1_ie_rr_req_ref,             /* Request Reference */
1188         gmr1_ie_rr_cause,               /* RR Cause */
1189         gmr1_ie_rr_timing_ofs,          /* Timing Offset */
1190         gmr1_ie_rr_tmsi_ptmsi,          /* TMSI/P-TMSI */
1191         gmr1_ie_rr_wait_ind,            /* Wait Indication */
1192         gmr1_ie_rr_mes_info_flg,        /* MES Information Flag */
1193         gmr1_ie_rr_freq_ofs,            /* Frequency Offset */
1194         gmr1_ie_rr_page_info,           /* Paging Information */
1195         gmr1_ie_rr_pos_display,         /* Position Display */
1196         gmr1_ie_rr_pos_upd_info,        /* Position Update Information */
1197         gmr1_ie_rr_bcch_carrier,        /* BCCH Carrier */
1198         gmr1_ie_rr_reject_cause,        /* Reject Cause */
1199         gmr1_ie_rr_gps_timestamp,       /* GPS timestamp */
1200         gmr1_ie_rr_pwr_ctrl_prm,        /* Power Control Params */
1201         gmr1_ie_rr_tmsi_avail_msk,      /* TMSI Availability Mask */
1202         gmr1_ie_rr_gps_almanac,         /* GPS Almanac Data */
1203         gmr1_ie_rr_msc_id,              /* MSC ID */
1204         gmr1_ie_rr_gps_discr,           /* GPS Discriminator */
1205         gmr1_ie_rr_pkt_imm_ass_3_prm,   /* Packet Imm. Ass. Type 3 Params */
1206         gmr1_ie_rr_pkt_freq_prm,        /* Packet Frequency Parameters */
1207         gmr1_ie_rr_pkt_imm_ass_2_prm,   /* Packet Imm. Ass. Type 2 Params */
1208         gmr1_ie_rr_usf,                 /* USF */
1209         gmr1_ie_rr_timing_adv_idx,      /* Timing Advance Index */
1210         gmr1_ie_rr_tlli,                /* TLLI */
1211         gmr1_ie_rr_pkt_pwr_ctrl_prm,    /* Packet Power Control Params */
1212         gmr1_ie_rr_persistence_lvl,     /* Persistence Level */
1213 };
1214
1215
1216 /* ------------------------------------------------------------------------ */
1217 /* RR Messages                                                              */
1218 /* ------------------------------------------------------------------------ */
1219
1220 /* [1] 10.1.18 - Immediate Assignment */
1221 GMR1_MSG_FUNC(gmr1_rr_msg_imm_ass)
1222 {
1223         guint8 mif;
1224
1225         GMR1_MSG_FUNC_BEGIN
1226
1227         /* MES Information Flag                 [1] 11.5.2.44   - M V 1 */
1228         mif = tvb_get_guint8(tvb, curr_offset);
1229
1230         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_MES_INFO_FLG, NULL);
1231
1232         /* Request Reference 1 (MES1)           [1] 11.5.2.30   - M V 2 */
1233         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_REQ_REF, " - MES1");
1234
1235         /* GPS Discriminator                    [1] 11.5.2.101  - C V 2 */
1236         if ((mif & 0x03) != 0x02) {
1237                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_GPS_DISCR, " - MES1");
1238         }
1239
1240         /* Channel Description                  [1] 11.5.2.5    - C V 4 */
1241         if ((mif & 0x03) != 0x03) {
1242                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_CHAN_DESC, " - MES1");
1243         }
1244
1245         /* Timing Offset                        [1] 11.5.2.40   - C V 2 */
1246         if ((mif & 0x03) != 0x03) {
1247                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_TIMING_OFS, " - MES1");
1248         }
1249
1250         /* Frequency Offset                     [1] 11.5.2.49   - C V 2 */
1251         if ((mif & 0x03) != 0x03) {
1252                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_FREQ_OFS, " - MES1");
1253         }
1254
1255         /* Idle Mode Pos. Upd. Info.            [1] 11.5.2.54   - C V 2 */
1256         if (mif & 0x04) {
1257                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_POS_UPD_INFO, " - Idle Mode");
1258         }
1259
1260         /* Ded. Mode Pos. Upd. Info.            [1] 11.5.2.54   - C V 2 */
1261         if (mif & 0x08) {
1262                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_POS_UPD_INFO, " - Dedicated Mode");
1263         }
1264
1265         /* Request Reference 2 (MES2)           [1] 11.5.2.30   - C V 2 */
1266         if (mif & 0x10) {
1267                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_REQ_REF, " - MES2");
1268         }
1269
1270         /* Request Reference 3 (MES3)           [1] 11.5.2.30   - C V 2 */
1271         if (mif & 0x20) {
1272                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_REQ_REF, " - MES3");
1273         }
1274
1275         /* Request Reference 4 (MES4)           [1] 11.5.2.30   - C V 2 */
1276         if (mif & 0x40) {
1277                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_REQ_REF, " - MES4");
1278         }
1279
1280         /* IA Rest Octets                       [1] 11.5.2.16   - M V 0..18 */
1281                 /* FIXME */
1282
1283         GMR1_MSG_FUNC_END
1284 }
1285
1286 /* [1] 10.1.20.1 - Immediate Assignment Reject Type 1 */
1287 GMR1_MSG_FUNC(gmr1_rr_msg_imm_ass_rej_1)
1288 {
1289         guint8 rej_cause;
1290
1291         GMR1_MSG_FUNC_BEGIN
1292
1293         /* Request Reference 1 (MES1)           [1] 11.5.2.30   - M V 2 */
1294         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_REQ_REF, " - MES1");
1295
1296         /* GPS Discriminator                    [1] 11.5.2.101  - M V 2 */
1297         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_GPS_DISCR, NULL);
1298
1299         /* Reject Cause                         [1] 11.5.2.56   - M V 1 */
1300         rej_cause = tvb_get_guint8(tvb, curr_offset);
1301
1302         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_REJECT_CAUSE, NULL);
1303
1304         /* Wait Indication 1 (MES1)             [4] 10.5.2.43   - C V 1 */
1305         if ((rej_cause & 0xfc) == 0x00) {
1306                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_WAIT_IND, " - MES1");
1307         }
1308
1309         /* Request Reference 2 (MES2)           [1] 11.5.2.30   - M V 2 */
1310         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_REQ_REF, " - MES2");
1311
1312         /* Wait Indication 2 (MES2)             [4] 10.5.2.43   - M V 1 */
1313         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_WAIT_IND, " - MES2");
1314
1315         /* Request Reference 3 (MES3)           [1] 11.5.2.30   - M V 2 */
1316         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_REQ_REF, " - MES3");
1317
1318         /* Wait Indication 3 (MES3)             [4] 10.5.2.43   - M V 1 */
1319         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_WAIT_IND, " - MES3");
1320
1321         /* Request Reference 4 (MES4)           [1] 11.5.2.30   - M V 2 */
1322         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_REQ_REF, " - MES4");
1323
1324         /* Wait Indication 4 (MES4)             [4] 10.5.2.43   - M V 1 */
1325         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_WAIT_IND, " - MES4");
1326
1327         /* Idle Mode Position Update Info.      [1] 11.5.2.54   - M V 2 */
1328         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_POS_UPD_INFO, " - Idle Mode");
1329
1330         /* BCCH Carrier Specification           [1] 11.5.2.55   - C V 2 */
1331         if (rej_cause & 1) {
1332                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_BCCH_CARRIER, NULL);
1333         }
1334
1335         /* MSC ID                               [1] 11.5.2.100  - C V 1 */
1336         if ((rej_cause & 0xfc) == 0x5c) {
1337                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_MSC_ID, NULL);
1338         }
1339
1340         /* IAR Rest Octets                      [1] 11.5.2.17   - M V 1..4 */
1341                 /* FIXME */
1342
1343         GMR1_MSG_FUNC_END
1344 }
1345
1346 /* [1] 10.1.20.4 - Position Verification Notify */
1347 GMR1_MSG_FUNC(gmr1_rr_msg_pos_verif_notify)
1348 {
1349         GMR1_MSG_FUNC_BEGIN
1350
1351         /* Request Reference                    [1] 11.5.2.30   - M V 2 */
1352         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_REQ_REF, NULL);
1353
1354         /* GPS Discriminator                    [1] 11.5.2.101  - M V 2 */
1355         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_GPS_DISCR, NULL);
1356
1357         /* Position Display                     [1] 11.5.2.52   - M V 11 */
1358         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_POS_DISPLAY, NULL);
1359
1360         /* 78 Idle Mode Position Update Info.   [1] 11.5.2.54   - O TV 3 */
1361         ELEM_OPT_TV(0x78, GMR1_IE_RR, GMR1_IE_RR_POS_UPD_INFO, NULL);
1362
1363         /* IAR Rest Octets                      [1] 11.5.2.17   - M V 3..6 */
1364                 /* FIXME */
1365
1366         GMR1_MSG_FUNC_END
1367 }
1368
1369 /* [3] 10.1.18.3 - Immediate Assignment Type 2 */
1370 GMR1_MSG_FUNC(gmr1_rr_msg_imm_ass_2)
1371 {
1372         GMR1_MSG_FUNC_BEGIN
1373
1374         /* USF                                  [3] 11.5.2.110  - M V 3 */
1375         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_USF, NULL);
1376
1377         /* Timing Advance Index                 [3] 10.1.18.3.4 - M V 1 */
1378         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_TIMING_ADV_IDX, NULL);
1379
1380         /* TLLI                                 [5] 12.16       - M V 4 */
1381         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_TLLI, NULL);
1382
1383         /* Timing Offset                        [1] 11.5.2.40   - M V 2 */
1384         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_TIMING_OFS, NULL);
1385
1386         /* Frequency Offset                     [1] 11.5.2.49   - M V 2 */
1387         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_FREQ_OFS, NULL);
1388
1389         /* Packet Imm. Ass. Type 2 Params.      [3] 11.5.2.107  - M V 5 */
1390         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_PKT_IMM_ASS_2_PRM, NULL);
1391
1392         /* Packet Frequency Parameters          [3] 11.5.2.106  - M V 3 */
1393         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_PKT_FREQ_PRM, NULL);
1394
1395         /* Packet Power Control Parameters      [3] 10.1.18.3.3 - M V 1 */
1396         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_PKT_PWR_CTRL_PRM, NULL);
1397
1398         GMR1_MSG_FUNC_END
1399 }
1400
1401 /* [3] 10.1.18.4 - Immediate Assignment Type 3 */
1402 GMR1_MSG_FUNC(gmr1_rr_msg_imm_ass_3)
1403 {
1404         GMR1_MSG_FUNC_BEGIN
1405
1406         /* Page Mode                            [1] 11.5.2.26   - M V 1/2 */
1407         /* Spare Half Octet                     [1] 11.5.1.8    - M V 1/2 */
1408         ELEM_MAND_VV_SHORT(GMR1_IE_RR, GMR1_IE_RR_PAGE_MODE,
1409                            GMR1_IE_COMMON, GMR1_IE_COM_SPARE_NIBBLE);
1410
1411         /* Persistence Level                    [3] 10.1.18.4.2 - M V 2 */
1412         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_PERSISTENCE_LVL, NULL);
1413
1414         /* Timing Advance Index                 [3] 10.1.18.3.4 - M V 1 */
1415         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_TIMING_ADV_IDX, NULL);
1416
1417         /* TLLI                                 [5] 12.16       - M V 4 */
1418         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_TLLI, NULL);
1419
1420         /* Packet Imm. Ass. Type 3 Params       [3] 11.5.2.105  - M V 3 */
1421         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_PKT_IMM_ASS_3_PRM, NULL);
1422
1423         /* Packet Frequency Parameters          [3] 11.5.2.106  - M V 3 */
1424         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_PKT_FREQ_PRM, NULL);
1425
1426         /* Packet Power Control Parameters      [3] 10.1.18.3.3 - M V 1 */
1427         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_PKT_PWR_CTRL_PRM, NULL);
1428
1429         /* P1 Rest Octets                       [1] 11.5.2.23   - M V 6 */
1430                 /* FIXME */
1431
1432         GMR1_MSG_FUNC_END
1433 }
1434
1435 /* [3] 10.1.9 - Ciphering Mode Command */
1436 GMR1_MSG_FUNC(gmr1_rr_msg_ciph_mode_cmd)
1437 {
1438         GMR1_MSG_FUNC_BEGIN
1439
1440         /* Cipher Mode Setting                  [4] 10.5.2.9    - M V 1/2 */
1441         /* Cipher Response                      [4] 10.5.2.10   - M V 1/2 */
1442         ELEM_MAND_VV_SHORT(GMR1_IE_RR, GMR1_IE_RR_CIPH_MODE_SETTING,
1443                            GMR1_IE_RR, GMR1_IE_RR_CIPH_RESP);
1444
1445         /* 75  Position Display                 [1] 11.5.2.52   - O TV 12 */
1446         ELEM_OPT_TV(0x75, GMR1_IE_RR, GMR1_IE_RR_POS_DISPLAY, NULL);
1447
1448         GMR1_MSG_FUNC_END
1449 }
1450
1451 /* [1] 10.1.10 - Ciphering Mode Complete */
1452 GMR1_MSG_FUNC(gmr1_rr_msg_ciph_mode_complete)
1453 {
1454         GMR1_MSG_FUNC_BEGIN
1455
1456         /* 17  Mobile Identity                  [1] 11.5.1.4    - O TLV 3-11 */
1457         ELEM_OPT_TLV(0x17, GSM_A_PDU_TYPE_COMMON, DE_MID, NULL);
1458
1459         /* 76  GPS Timestamp                    [1] 11.5.2.57   - O TV 3 */
1460         ELEM_OPT_TV(0x76, GMR1_IE_RR, GMR1_IE_RR_GPS_TIMESTAMP, NULL);
1461
1462         GMR1_MSG_FUNC_END
1463 }
1464
1465 /* [1] 10.1.2.1 - Assignment Command 1 */
1466 GMR1_MSG_FUNC(gmr1_rr_msg_ass_cmd_1)
1467 {
1468         GMR1_MSG_FUNC_BEGIN
1469
1470         /* Channel Description                  [1] 11.5.2.5    - M V 4 */
1471         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_CHAN_DESC, NULL);
1472
1473         /* 7D  Timing Offset                    [1] 11.5.2.40   - O TV 3 */
1474         ELEM_OPT_TV(0x7D, GMR1_IE_RR, GMR1_IE_RR_TIMING_OFS, NULL);
1475
1476         /* 7F  Frequency Offset                 [1] 11.5.2.49   - O TV 3 */
1477         ELEM_OPT_TV(0x7F, GMR1_IE_RR, GMR1_IE_RR_FREQ_OFS, NULL);
1478
1479         /* 63  Channel Mode                     [1] 11.5.2.6    - O TV 2 */
1480         ELEM_OPT_TV(0x63, GMR1_IE_RR, GMR1_IE_RR_CHAN_MODE, NULL);
1481
1482         /* 71  Power Control Parameters         [1] 11.5.2.60   - O TV 6 */
1483         ELEM_OPT_TV(0x71, GMR1_IE_RR, GMR1_IE_RR_PWR_CTRL_PRM, NULL);
1484
1485         /* 9-  Cipher Mode Setting              [4] 10.5.2.9    - O TV 1 */
1486         ELEM_OPT_TV_SHORT(0x90, GMR1_IE_RR, GMR1_IE_RR_CIPH_MODE_SETTING, NULL);
1487
1488         GMR1_MSG_FUNC_END
1489 }
1490
1491 /* [1] 10.1.7 - Channel Release */
1492 GMR1_MSG_FUNC(gmr1_rr_msg_chan_release)
1493 {
1494         GMR1_MSG_FUNC_BEGIN
1495
1496         /* RR Cause                             [1] 11.5.2.31   - M V 1 */
1497         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_CAUSE, NULL);
1498
1499         GMR1_MSG_FUNC_END
1500 }
1501
1502 /* [1] 10.1.24 - Paging Request Type 3 */
1503 GMR1_MSG_FUNC(gmr1_rr_msg_pag_req_3)
1504 {
1505         guint8 tam;
1506
1507         GMR1_MSG_FUNC_BEGIN
1508
1509         /* Page Mode                            [1] 11.5.2.26   - M V 1/2 */
1510         /* TMSI Availability Mask               [1] 11.5.2.62   - M V 1/2 */
1511         tam = (tvb_get_guint8(tvb, curr_offset) & 0xf0) >> 4;
1512
1513         ELEM_MAND_VV_SHORT(GMR1_IE_RR, GMR1_IE_RR_PAGE_MODE,
1514                            GMR1_IE_RR, GMR1_IE_RR_TMSI_AVAIL_MSK);
1515
1516         /* Mobile Identity 1 (TMSI)             [4] 10.5.2.42   - C V 4 */
1517         if (tam & 0x01) {
1518                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_TMSI_PTMSI, " - 1");
1519         }
1520
1521         /* GPS Almanac Data 1                   [1] 11.5.2.63   - C V 5 */
1522         if (!(tam & 0x01)) {
1523                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_GPS_ALMANAC, " - 1");
1524         }
1525
1526         /* Mobile Identity 2 (TMSI)             [4] 10.5.2.42   - C V 4 */
1527         if (tam & 0x02) {
1528                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_TMSI_PTMSI, " - 2");
1529         }
1530
1531         /* GPS Almanac Data 2                   [1] 11.5.2.63   - C V 5 */
1532         if (!(tam & 0x02)) {
1533                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_GPS_ALMANAC, " - 2");
1534         }
1535
1536         /* Mobile Identity 3 (TMSI)             [4] 10.5.2.42   - C V 4 */
1537         if (tam & 0x04) {
1538                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_TMSI_PTMSI, " - 3");
1539         }
1540
1541         /* GPS Almanac Data 3                   [1] 11.5.2.63   - C V 5 */
1542         if (!(tam & 0x04)) {
1543                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_GPS_ALMANAC, " - 3");
1544         }
1545
1546         /* Mobile Identity 4 (TMSI)             [4] 10.5.2.42   - C V 4 */
1547         if (tam & 0x08) {
1548                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_TMSI_PTMSI, " - 4");
1549         }
1550
1551         /* GPS Almanac Data 4                   [1] 11.5.2.63   - C V 5 */
1552         if (!(tam & 0x08)) {
1553                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_GPS_ALMANAC, " - 4");
1554         }
1555
1556         /* Paging Information 1                 [1] 11.5.2.51   - C V 1 */
1557         if (tam & 0x01) {
1558                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_PAGE_INFO, " - 1");
1559         }
1560
1561         /* Paging Information 2                 [1] 11.5.2.51   - C V 1 */
1562         if (tam & 0x02) {
1563                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_PAGE_INFO, " - 2");
1564         }
1565
1566         /* Paging Information 3                 [1] 11.5.2.51   - C V 1 */
1567         if (tam & 0x04) {
1568                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_PAGE_INFO, " - 3");
1569         }
1570
1571         /* Paging Information 4                 [1] 11.5.2.51   - C V 1 */
1572         if (tam & 0x08) {
1573                 ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_PAGE_INFO, " - 4");
1574         }
1575
1576         GMR1_MSG_FUNC_END
1577 }
1578
1579 /* [1] 10.1.25 - Paging Response */
1580 GMR1_MSG_FUNC(gmr1_rr_msg_pag_resp)
1581 {
1582         GMR1_MSG_FUNC_BEGIN
1583
1584         /* Ciphering Key Sequence Number        [4] 10.5.1.2    - M V 1/2 */
1585         /* Spare Half Octet                     [1] 11.5.1.8    - M V 1/2 */
1586         ELEM_MAND_VV_SHORT(GSM_A_PDU_TYPE_COMMON, DE_CIPH_KEY_SEQ_NUM,
1587                            GMR1_IE_COMMON, GMR1_IE_COM_SPARE_NIBBLE);
1588
1589         /* Mobile Earth Station Classmark 2     [1] 11.5.1.6    - M L V 4 */
1590         ELEM_MAND_LV(GMR1_IE_COMMON, GMR1_IE_COM_CM2, NULL);
1591
1592         /* Mobile Identity                      [4] 10.5.1.4    - M L V 2-9 */
1593         ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MID, NULL);
1594
1595         GMR1_MSG_FUNC_END
1596 }
1597
1598 /* [1] 10.1.5 - Channel Mode Modify */
1599 GMR1_MSG_FUNC(gmr1_rr_msg_chan_mode_modify)
1600 {
1601         GMR1_MSG_FUNC_BEGIN
1602
1603         /* Channel Description                  [1] 11.5.2.5    - M V 4 */
1604         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_CHAN_DESC, NULL);
1605
1606         /* Channel Mode                         [1] 11.5.2.6    - M V 1 */
1607         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_CHAN_MODE, NULL);
1608
1609         GMR1_MSG_FUNC_END
1610 }
1611
1612 /* [1] 10.1.6 - Channel Mode Modify Acknowledge */
1613 GMR1_MSG_FUNC(gmr1_rr_msg_chan_mode_mod_ack)
1614 {
1615         GMR1_MSG_FUNC_BEGIN
1616
1617         /* Channel Description                  [1] 11.5.2.5    - M V 4 */
1618         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_CHAN_DESC, NULL);
1619
1620         /* Channel Mode                         [1] 11.5.2.6    - M V 1 */
1621         ELEM_MAND_V(GMR1_IE_RR, GMR1_IE_RR_CHAN_MODE, NULL);
1622
1623         GMR1_MSG_FUNC_END
1624 }
1625
1626
1627 /* See [3] 11.4.1 - Table 11.1 */
1628 static const value_string gmr1_msg_rr_strings[] = {
1629         /* Channel establishment messages */
1630         { 0x3f, "Immediate Assignment" },
1631         { 0x3a, "Immediate Assignment Reject Type 1" },
1632         { 0x3b, "Immediate Assignment Reject Type 2" },
1633         { 0x13e, "Extended Immediate Assignment" },     /* Conflict ... add 0x100 */
1634         { 0x13b, "Extended Imm. Assignment Reject" },   /* Conflict ... add 0x100 */
1635         { 0x39, "Position Verification Notify" },
1636         { 0x3c, "Immediate Assignment Reject Type 3" },
1637         { 0x3e, "Immediate Assignment Type 2" },
1638         { 0x3d, "Immediate Assignment Type 3" },
1639
1640         /* Ciphering messages */
1641         { 0x35, "Ciphering Mode Command" },
1642         { 0x32, "Ciphering Mode Complete" },
1643
1644         /* Channel assignment/handover messages */
1645         { 0x2e, "Assignment Command 1" },
1646         { 0x2a, "Assignment Command 2" },
1647         { 0x29, "Assignment Complete" },
1648         { 0x2f, "Assignment Failure" },
1649         { 0x2b, "Handover Command" },
1650         { 0x2c, "Handover Complete" },
1651
1652         /* Channel release messages */
1653         { 0x0d, "Channel Release" },
1654         { 0x0e, "TtT Signalling Link Failure" },
1655
1656         /* Paging messages */
1657         { 0x21, "Paging Request Type 1" },
1658         { 0x22, "Paging Request Type 2" },
1659         { 0x24, "Paging Request Type 3" },
1660         { 0x27, "Paging Response" },
1661
1662         /* Miscellaneous messages */
1663         { 0x10, "Channel Mode Modify" },
1664         { 0x12, "RR Status" },
1665         { 0x17, "Channel Mode Modify Acknowledge" },
1666         { 0x16, "Classmark Change" },
1667         { 0x13, "Classmark Enquiry" },
1668         { 0x14, "Position Update Request" },
1669         { 0x15, "Position Update Accept" },
1670         { 0x11, "Link Correction Message" },
1671
1672         { 0x01, "Power Control Parameters Update" },
1673         { 0x02, "Guard Time Violation" },
1674         { 0x04, "Extended Channel Request" },
1675
1676         /* Status and Diagnostic Messages */
1677         { 0x40, "Information Request" },
1678         { 0x41, "Information Response Position" },
1679         { 0x42, "Information Response Version" },
1680         { 0x43, "Information Response Spot Beam Selection" },
1681         { 0x44, "Information Response Power Control" },
1682         { 0x45, "Information Response Vendor Specific" },
1683         { 0x46, "Information Response Current Beam" },
1684         { 0x4f, "Information Response Error" },
1685
1686         /* End */
1687         { 0, NULL }
1688 };
1689
1690
1691 #define NUM_GMR1_MSG_RR (sizeof(gmr1_msg_rr_strings) / sizeof(value_string))
1692 static gint ett_msg_rr[NUM_GMR1_MSG_RR];
1693
1694         /* same order as gmr1_msg_rr_strings */
1695 static const gmr1_msg_func_t gmr1_msg_rr_func[NUM_GMR1_MSG_RR] = {
1696         /* Channel establishment messages */
1697         gmr1_rr_msg_imm_ass,            /* Imm. Ass.*/
1698         gmr1_rr_msg_imm_ass_rej_1,      /* Imm. Ass. Reject Type 1 */
1699         NULL,                           /* Imm. Ass. Reject Type 2 */
1700         NULL,                           /* Extended Imm. Ass. */
1701         NULL,                           /* Extended Imm. Ass. Reject */
1702         gmr1_rr_msg_pos_verif_notify,   /* Position Verification Notify */
1703         NULL,                           /* Imm. Ass. Reject Type 3 */
1704         gmr1_rr_msg_imm_ass_2,          /* Imm. Ass. Type 2 */
1705         gmr1_rr_msg_imm_ass_3,          /* Imm. Ass. Type 3 */
1706
1707         /* Ciphering messages */
1708         gmr1_rr_msg_ciph_mode_cmd,      /* Ciphering Mode Command */
1709         gmr1_rr_msg_ciph_mode_complete, /* Ciphering Mode Complete */
1710
1711         /* Channel assignment/handover messages */
1712         gmr1_rr_msg_ass_cmd_1,          /* Assignment Command 1 */
1713         NULL,                           /* Assignment Command 2 */
1714         NULL,                           /* Assignment Complete */
1715         NULL,                           /* Assignment Failure */
1716         NULL,                           /* Handover Command */
1717         NULL,                           /* Handover Complete */
1718
1719         /* Channel release messages */
1720         gmr1_rr_msg_chan_release,       /* Channel Release */
1721         NULL,                           /* TtT Signalling Link Failure */
1722
1723         /* Paging messages */
1724         NULL,                           /* Paging Request Type 1 */
1725         NULL,                           /* Paging Request Type 2 */
1726         gmr1_rr_msg_pag_req_3,          /* Paging Request Type 3 */
1727         gmr1_rr_msg_pag_resp,           /* Paging Response */
1728
1729         /* Miscellaneous messages */
1730         gmr1_rr_msg_chan_mode_modify,   /* Channel Mode Modify */
1731         NULL,                           /* RR Status */
1732         gmr1_rr_msg_chan_mode_mod_ack,  /* Channel Mode Modify Acknowledge */
1733         NULL,                           /* Classmark Change */
1734         NULL,                           /* Classmark Enquiry */
1735         NULL,                           /* Position Update Request */
1736         NULL,                           /* Position Update Accept */
1737         NULL,                           /* Link Correction Message */
1738
1739         NULL,                           /* Power Control Parameters Update */
1740         NULL,                           /* Guard Time Violation */
1741         NULL,                           /* Extended Channel Request */
1742
1743         /* Status and Diagnostic Messages */
1744         NULL,                           /* Info. Req. */
1745         NULL,                           /* Info. Resp. Position */
1746         NULL,                           /* Info. Resp. Version */
1747         NULL,                           /* Info. Resp. Spot Beam Selection */
1748         NULL,                           /* Info. Resp. Power Control */
1749         NULL,                           /* Info. Resp. Vendor Specific */
1750         NULL,                           /* Info. Resp. Current Beam */
1751         NULL,                           /* Info. Resp. Error */
1752
1753         NULL,
1754 };
1755
1756
1757 void
1758 gmr1_get_msg_rr_params(guint8 oct, int dcch, const gchar **msg_str,
1759                        int *ett_tree, int *hf_idx, gmr1_msg_func_t *msg_func_p)
1760 {
1761         const gchar *m = NULL;
1762         gint idx;
1763
1764         if (dcch)
1765                 m = try_val_to_str_idx((guint32)oct | 0x100, gmr1_msg_rr_strings, &idx);
1766
1767         if (!m)
1768                 m = try_val_to_str_idx((guint32)oct, gmr1_msg_rr_strings, &idx);
1769
1770         *msg_str = m;
1771         *hf_idx = hf_rr_msg_type;
1772         if (m != NULL) {
1773                 *ett_tree  = ett_msg_rr[idx];
1774                 *msg_func_p = gmr1_msg_rr_func[idx];
1775         } else {
1776                 *ett_tree = -1;
1777                 *msg_func_p = NULL;
1778         }
1779 }
1780
1781
1782 /* ------------------------------------------------------------------------ */
1783 /* Dissector code                                                           */
1784 /* ------------------------------------------------------------------------ */
1785
1786 static void
1787 dissect_gmr1_ccch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1788 {
1789         guint32 len, offset;
1790         gmr1_msg_func_t msg_func;
1791         const gchar *msg_str;
1792         gint ett_tree;
1793         int hf_idx;
1794         proto_item *ccch_item = NULL, *pd_item = NULL;
1795         proto_tree *ccch_tree = NULL, *pd_tree = NULL;
1796         guint32 oct[3];
1797         guint8 pd;
1798         gint ti = -1;
1799
1800         /* Scan init */
1801         len = tvb_length(tvb);
1802         offset = 0;
1803
1804         /* Safety */
1805         if (len < 3) {
1806                 /* Can't be a CCCH */
1807                 goto err;
1808         }
1809
1810         col_append_str(pinfo->cinfo, COL_INFO, "(CCCH) ");
1811
1812         /* First octed with pseudo len */
1813         oct[0] = tvb_get_guint8(tvb, offset++);
1814
1815         /* Check protocol descriptor */
1816         oct[1] = tvb_get_guint8(tvb, offset++);
1817
1818         if ((oct[1] & GMR1_PD_EXT_MSK) == GMR1_PD_EXT_VAL)
1819                 pd = oct[1] & 0xff;
1820         else
1821                 pd = oct[1] & 0x0f;
1822
1823         col_append_fstr(pinfo->cinfo, COL_INFO, "(%s) ",
1824                 val_to_str(pd, gmr1_pd_short_vals, "Unknown (%u)"));
1825
1826         if (pd != GMR1_PD_RR)
1827                 goto err;       /* CCCH is only RR */
1828
1829         /* Get message parameters */
1830         oct[2] = tvb_get_guint8(tvb, offset);
1831
1832         gmr1_get_msg_rr_params(oct[2], 0, &msg_str, &ett_tree, &hf_idx, &msg_func);
1833
1834         /* Create protocol tree */
1835         if (msg_str == NULL)
1836         {
1837                 ccch_item = proto_tree_add_protocol_format(
1838                         tree, proto_gmr1_ccch, tvb, 0, len,
1839                         "GMR-1 CCCH - Message Type (0x%02x)", oct[2]);
1840                 ccch_tree = proto_item_add_subtree(ccch_item, ett_msg_ccch);
1841
1842                 col_append_fstr(pinfo->cinfo, COL_INFO, "Message Type (0x%02x) ", oct[2]);
1843         }
1844         else
1845         {
1846                 ccch_item = proto_tree_add_protocol_format(
1847                         tree, proto_gmr1_ccch, tvb, 0, -1,
1848                         "GMR-1 CCCH - %s", msg_str);
1849                 ccch_tree = proto_item_add_subtree(ccch_item, ett_tree);
1850
1851                 col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", msg_str);
1852         }
1853
1854         /* Start over */
1855         offset = 0;
1856
1857         /* L2 Pseudo Length - [1] 11.5.2.19 */
1858         offset += elem_v(tvb, ccch_tree, pinfo, GMR1_IE_RR, GMR1_IE_RR_L2_PSEUDO_LEN, offset, NULL);
1859
1860         /* Protocol discriminator item */
1861         pd_item = proto_tree_add_text(
1862                 ccch_tree, tvb, 1, 1,
1863                 "Protocol Discriminator: %s",
1864                 val_to_str(pd, gmr1_pd_vals, "Unknown (%u)")
1865         );
1866
1867         pd_tree = proto_item_add_subtree(pd_item, ett_rr_pd);
1868
1869                 /* Skip indicator / Transaction indicator */
1870         if (ti == -1) {
1871                 proto_tree_add_item(pd_tree, hf_gmr1_skip_ind, tvb, 1, 1, ENC_BIG_ENDIAN);
1872         } else {
1873                 /* FIXME !!! */
1874         }
1875
1876                 /* Protocol discriminator value */
1877         proto_tree_add_item(pd_tree, hf_gmr1_l3_pd, tvb, 1, 1, ENC_BIG_ENDIAN);
1878
1879
1880                 /* Move on */
1881         offset++;
1882
1883         /* Message type - [1] 11.4 */
1884         proto_tree_add_uint_format(
1885                 ccch_tree, hf_idx, tvb, offset, 1, oct[2],
1886                 "Message Type: %s", msg_str ? msg_str : "(Unknown)"
1887         );
1888
1889         offset++;
1890
1891         /* Decode elements */
1892         if (msg_func) {
1893                 (*msg_func)(tvb, ccch_tree, pinfo, offset, len - offset);
1894         } else {
1895                 proto_tree_add_text(ccch_tree, tvb, offset, len - offset,
1896                                     "Message Elements");
1897         }
1898
1899         /* Done ! */
1900         return;
1901
1902         /* Error handling */
1903 err:
1904         call_dissector(data_handle, tvb, pinfo, tree);
1905 }
1906
1907 void
1908 proto_register_gmr1_rr(void)
1909 {
1910         static hf_register_info hf[] = {
1911                 { &hf_rr_msg_type,
1912                   { "Radio Resources Management Message Type", "gmr1.rr.msg_type",
1913                     FT_UINT8, BASE_HEX, VALS(gmr1_msg_rr_strings), 0x00,
1914                     NULL, HFILL }       /* FIXME handle CCCH/DCCH conflicts */
1915                 },
1916                 { &hf_rr_chan_desc_kab_loc,
1917                   { "KAB Location", "gmr1.rr.chan_desc.kab_loc",
1918                     FT_UINT8, BASE_DEC, NULL, 0x00,
1919                     NULL, HFILL }
1920                 },
1921                 { &hf_rr_chan_desc_rx_tn,
1922                   { "RX Timeslot", "gmr1.rr.chan_desc.rx_tn",
1923                     FT_UINT8, BASE_DEC, NULL, 0x00,
1924                     NULL, HFILL }
1925                 },
1926                 { &hf_rr_chan_desc_arfcn,
1927                   { "ARFCN", "gmr1.rr.chan_desc.arfcn",
1928                     FT_UINT16, BASE_DEC, NULL, 0x00,
1929                     NULL, HFILL }
1930                 },
1931                 { &hf_rr_chan_desc_tx_tn,
1932                   { "TX Timeslot", "gmr1.rr.chan_desc.tx_tn",
1933                     FT_UINT8, BASE_DEC, NULL, 0x00,
1934                     NULL, HFILL }
1935                 },
1936                 { &hf_rr_chan_desc_chan_type,
1937                   { "Channel Type", "gmr1.rr.chan_desc.chan_type",
1938                     FT_UINT8, BASE_DEC, VALS(rr_chan_desc_chan_type_vals), 0x00,
1939                     NULL, HFILL }
1940                 },
1941                 { &hf_rr_chan_mode,
1942                   { "Channel Mode", "gmr1.rr.chan_mode",
1943                     FT_UINT8, BASE_DEC, VALS(rr_chan_mode_vals), 0x00,
1944                     NULL, HFILL }
1945                 },
1946                 { &hf_rr_ciph_mode_setting_sc,
1947                   { "SC", "gmr1.rr.ciph_mode_setting.sc",
1948                     FT_UINT8, BASE_DEC, VALS(rr_ciph_mode_setting_sc_vals), 0x01,
1949                     NULL, HFILL }
1950                 },
1951                 { &hf_rr_ciph_mode_setting_algo,
1952                   { "Algorithm", "gmr1.rr.ciph_mode_setting.algo",
1953                     FT_UINT8, BASE_DEC, VALS(rr_ciph_mode_setting_algo_vals), 0x0e,
1954                     NULL, HFILL }
1955                 },
1956                 { &hf_rr_ciph_resp_cr,
1957                   { "CR", "gmr1.rr.ciph_resp.cr",
1958                     FT_UINT8, BASE_DEC, VALS(rr_ciph_resp_cr_vals), 0x10,
1959                     NULL, HFILL }
1960                 },
1961                 { &hf_rr_ciph_resp_spare,
1962                   { "Spare", "gmr1.rr.ciph_resp.spare",
1963                     FT_UINT8, BASE_DEC, NULL, 0xe0,
1964                     NULL, HFILL }
1965                 },
1966                 { &hf_rr_l2_pseudo_len,
1967                   { "L2 Pseudo Length value", "gmr1.rr.l2_pseudo_len",
1968                     FT_UINT8, BASE_DEC, NULL, 0xfc,
1969                     NULL, HFILL }
1970                 },
1971                 { &hf_rr_page_mode,
1972                   { "Page Mode", "gmr1.rr.page_mode.mode",
1973                     FT_UINT8, BASE_DEC, VALS(rr_page_mode_vals), 0x03,
1974                     NULL, HFILL }
1975                 },
1976                 { &hf_rr_page_mode_spare,
1977                   { "Spare", "gmr1.rr.page_mode.spare",
1978                     FT_UINT8, BASE_DEC, NULL, 0x0c,
1979                     NULL, HFILL }
1980                 },
1981                 { &hf_rr_req_ref_est_cause,
1982                   { "Establishment cause group ID", "gmr1.rr.req_ref.est_cause",
1983                     FT_UINT8, BASE_DEC, VALS(rr_req_ref_est_cause_vals), 0xe0,
1984                     NULL, HFILL }
1985                 },
1986                 { &hf_rr_req_ref_ra,
1987                   { "Random Access Information", "gmr1.rr.req_ref.ra",
1988                     FT_UINT8, BASE_HEX, NULL, 0x1f,
1989                     NULL, HFILL }
1990                 },
1991                 { &hf_rr_req_ref_fn,
1992                   { "Frame Number mod 256", "gmr1.rr.req_ref.fn",
1993                     FT_UINT8, BASE_DEC, NULL, 0x00,
1994                     NULL, HFILL }
1995                 },
1996                 { &hf_rr_cause,
1997                   { "RR Cause", "gmr1.rr.cause",
1998                     FT_UINT8, BASE_DEC, VALS(rr_cause_vals), 0x00,
1999                     NULL, HFILL }
2000                 },
2001                 { &hf_rr_timing_ofs_ti,
2002                   { "TI", "gmr1.rr.timing_offset.ti",
2003                     FT_UINT8, BASE_DEC, VALS(rr_timing_ofs_ti_vals), 0x00,
2004                     NULL, HFILL }
2005                 },
2006                 { &hf_rr_timing_ofs_value,
2007                   { "Timing Offset value", "gmr1.rr.timing_offset.value",
2008                     FT_INT16, BASE_CUSTOM, rr_timing_ofs_value_fmt, 0x00,
2009                     NULL, HFILL }
2010                 },
2011                 { &hf_rr_tmsi_ptmsi,
2012                   { "TMSI/P-TMSI Value","gmr1.rr.tmsi_ptmsi",
2013                     FT_UINT32,BASE_HEX,  NULL, 0x00,
2014                     NULL, HFILL }
2015                 },
2016                 { &hf_rr_wait_ind_timeout,
2017                   { "T3122/T3142 timeout", "gmr1.rr.wait_ind.timeout",
2018                     FT_UINT8, BASE_CUSTOM, rr_gen_ie_seconds_fmt, 0x00,
2019                     NULL, HFILL }
2020                 },
2021                 { &hf_rr_mif_mes1_ab,
2022                   { "MES1 - Assignment Type", "gmr1.rr.mes_info_flag.1.ab",
2023                     FT_UINT8, BASE_DEC, VALS(rr_mif_mes1_ab_vals), 0x03,
2024                     NULL, HFILL }
2025                 },
2026                 { &hf_rr_mif_mes1_i,
2027                   { "MES1 - Idle mode position update", "gmr1.rr.mes_info_flag.1.i",
2028                     FT_UINT8, BASE_DEC, VALS(rr_gen_ie_presence_vals), 0x04,
2029                     NULL, HFILL }
2030                 },
2031                 { &hf_rr_mif_mes1_d,
2032                   { "MES1 - Dedicated mode position update", "gmr1.rr.mes_info_flag.1.d",
2033                     FT_UINT8, BASE_DEC, VALS(rr_gen_ie_presence_vals), 0x08,
2034                     NULL, HFILL }
2035                 },
2036                 { &hf_rr_mif_mes2,
2037                   { "MES2", "gmr1.rr.mes_info_flag.2",
2038                     FT_UINT8, BASE_DEC, VALS(rr_mif_mes234_vals), 0x10,
2039                     NULL, HFILL }
2040                 },
2041                 { &hf_rr_mif_mes3,
2042                   { "MES3", "gmr1.rr.mes_info_flag.3",
2043                     FT_UINT8, BASE_DEC, VALS(rr_mif_mes234_vals), 0x20,
2044                     NULL, HFILL }
2045                 },
2046                 { &hf_rr_mif_mes4,
2047                   { "MES4", "gmr1.rr.mes_info_flag.4",
2048                     FT_UINT8, BASE_DEC, VALS(rr_mif_mes234_vals), 0x40,
2049                     NULL, HFILL }
2050                 },
2051                 { &hf_rr_mif_pv,
2052                   { "Position Verification indicator", "gmr1.rr.mes_info_flag.pv",
2053                     FT_UINT8, BASE_DEC, VALS(rr_mif_pv_vals), 0x80,
2054                     NULL, HFILL }
2055                 },
2056                 { &hf_rr_freq_ofs_fi,
2057                   { "FI", "gmr1.rr.frequency_offset.fi",
2058                     FT_UINT8, BASE_DEC, VALS(rr_freq_ofs_fi_vals), 0x00,
2059                     NULL, HFILL }
2060                 },
2061                 { &hf_rr_freq_ofs_value,
2062                   { "Frequency Offset value", "gmr1.rr.frequency_offset.value",
2063                     FT_INT16, BASE_CUSTOM, rr_freq_ofs_value_fmt, 0x00,
2064                     NULL, HFILL }
2065                 },
2066                 { &hf_rr_freq_ofs_spare,
2067                   { "Spare", "gmr1.rr.frequency_offset.spare",
2068                     FT_UINT8, BASE_DEC, NULL, 0x00,
2069                     NULL, HFILL }
2070                 },
2071                 { &hf_rr_page_info_msc_id,
2072                   { "MSC ID", "gmr1.rr.paging_info.msc_id",
2073                     FT_UINT8, BASE_DEC, NULL, 0xfc,
2074                     NULL, HFILL }
2075                 },
2076                 { &hf_rr_page_info_chan_needed,
2077                   { "Channel Needed", "gmr1.rr.paging_info.chan_needed",
2078                     FT_UINT8, BASE_DEC, VALS(rr_page_info_chan_needed_vals), 0x03,
2079                     NULL, HFILL }
2080                 },
2081                 { &hf_rr_pos_display_flag,
2082                   { "Display Information Flag", "gmr1.rr.pos_display.flag",
2083                     FT_UINT8, BASE_DEC, VALS(rr_pos_display_flag_vals), 0xf0,
2084                     NULL, HFILL }
2085                 },
2086                 { &hf_rr_pos_display_text,
2087                   { "Country and Region name", "gmr1.rr.pos_display.text",
2088                     FT_STRING, STR_UNICODE, NULL, 0x00,
2089                     NULL, HFILL }
2090                 },
2091                 { &hf_rr_pos_upd_info_v,
2092                   { "Valid", "gmr1.rr.pos_upd_info.valid",
2093                     FT_UINT8, BASE_DEC, VALS(rr_pos_upd_info_v_vals), 0x01,
2094                     NULL, HFILL }
2095                 },
2096                 { &hf_rr_pos_upd_info_dist,
2097                   { "GPS Update Distance", "gmr1.rr.pos_upd_info.distance",
2098                     FT_UINT8, BASE_CUSTOM, rr_pos_upd_info_dist_fmt, 0xfe,
2099                     NULL, HFILL }
2100                 },
2101                 { &hf_rr_pos_upd_info_time,
2102                   { "GPS Update Timer", "gmr1.rr.pos_upd_info.time",
2103                     FT_UINT8, BASE_CUSTOM, rr_pos_upd_info_time_fmt, 0xff,
2104                     NULL, HFILL }
2105                 },
2106                 { &hf_rr_bcch_carrier_arfcn,
2107                   { "ARFCN", "gmr1.rr.bcch_carrier.arfcn",
2108                     FT_UINT16, BASE_DEC, NULL, 0x00,
2109                     NULL, HFILL }
2110                 },
2111                 { &hf_rr_bcch_carrier_si,
2112                   { "Satellite Indication", "gmr1.rr.bcch_carrier.si",
2113                     FT_UINT8, BASE_DEC, VALS(rr_bcch_carrier_si_vals), 0x00,
2114                     NULL, HFILL }
2115                 },
2116                 { &hf_rr_bcch_carrier_ri,
2117                   { "Reselection Indication", "gmr1.rr.bcch_carrier.ri",
2118                     FT_UINT8, BASE_DEC, VALS(rr_bcch_carrier_ri_vals), 0x00,
2119                     NULL, HFILL }
2120                 },
2121                 { &hf_rr_bcch_carrier_spare,
2122                   { "Spare", "gmr1.rr.bcch_carrier.spare",
2123                     FT_UINT8, BASE_DEC, NULL, 0x00,
2124                     NULL, HFILL }
2125                 },
2126                 { &hf_rr_reject_cause,
2127                   { "Cause", "gmr1.rr.reject_cause.cause",
2128                     FT_UINT8, BASE_DEC, VALS(rr_reject_cause_vals), 0xfc,
2129                     NULL, HFILL }
2130                 },
2131                 { &hf_rr_reject_cause_b,
2132                   { "BCCH Carrier IE presence", "gmr1.rr.reject_cause.b",
2133                     FT_UINT8, BASE_DEC, VALS(rr_gen_ie_presence_vals), 0x01,
2134                     NULL, HFILL }
2135                 },
2136                 { &hf_rr_gps_timestamp,
2137                   { "GPS timestamp", "gmr1.rr.gps_timestamp",
2138                     FT_UINT16, BASE_CUSTOM, rr_gps_timestamp_fmt, 0xffff,
2139                     NULL, HFILL }
2140                 },
2141                 { &hf_rr_tmsi_avail_msk_tmsi[0],
2142                   { "TMSI 1 Presence", "gmr1.rr.tmsi_avail_msk.tmsi1",
2143                     FT_UINT8, BASE_DEC, VALS(rr_gen_ie_presence_vals), 0x10,
2144                     NULL, HFILL }
2145                 },
2146                 { &hf_rr_tmsi_avail_msk_tmsi[1],
2147                   { "TMSI 2 Presence", "gmr1.rr.tmsi_avail_msk.tmsi2",
2148                     FT_UINT8, BASE_DEC, VALS(rr_gen_ie_presence_vals), 0x20,
2149                     NULL, HFILL }
2150                 },
2151                 { &hf_rr_tmsi_avail_msk_tmsi[2],
2152                   { "TMSI 3 Presence", "gmr1.rr.tmsi_avail_msk.tmsi3",
2153                     FT_UINT8, BASE_DEC, VALS(rr_gen_ie_presence_vals), 0x40,
2154                     NULL, HFILL }
2155                 },
2156                 { &hf_rr_tmsi_avail_msk_tmsi[3],
2157                   { "TMSI 4 Presence", "gmr1.rr.tmsi_avail_msk.tmsi4",
2158                     FT_UINT8, BASE_DEC, VALS(rr_gen_ie_presence_vals), 0x80,
2159                     NULL, HFILL }
2160                 },
2161                 { &hf_rr_gps_almanac_pn,
2162                   { "Page Number", "gmr1.rr.gps_almanac.pn",
2163                     FT_UINT8, BASE_CUSTOM, rr_gps_almanac_pn_fmt, 0xf8,
2164                     "See ICD-GPS-200", HFILL }
2165                 },
2166                 { &hf_rr_gps_almanac_wn,
2167                   { "Word Number", "gmr1.rr.gps_almanac.wn",
2168                     FT_UINT8, BASE_DEC, NULL, 0x07,
2169                     "See ICD-GPS-200", HFILL }
2170                 },
2171                 { &hf_rr_gps_almanac_word,
2172                   { "GPS Almanac Word", "gmr1.rr.gps_almanac.word",
2173                     FT_UINT24, BASE_HEX, NULL, 0x00,
2174                     "See ICD-GPS-200", HFILL }
2175                 },
2176                 { &hf_rr_gps_almanac_sfn,
2177                   { "Sub Frame Number", "gmr1.rr.gps_almanac.sfn",
2178                     FT_UINT8, BASE_DEC, VALS(rr_gps_almanac_sfn_vals), 0x80,
2179                     "See ICD-GPS-200", HFILL }
2180                 },
2181                 { &hf_rr_gps_almanac_co,
2182                   { "CO", "gmr1.rr.gps_almanac.co",
2183                     FT_UINT8, BASE_DEC, NULL, 0x40,
2184                     NULL, HFILL }
2185                 },
2186                 { &hf_rr_gps_almanac_spare,
2187                   { "Spare", "gmr1.rr.gps_almanac.spare",
2188                     FT_UINT8, BASE_DEC, NULL, 0x3f,
2189                     NULL, HFILL }
2190                 },
2191                 { &hf_rr_msc_id,
2192                   { "MSC ID", "gmr1.rr.msc_id",
2193                     FT_UINT8, BASE_DEC, NULL, 0xfc,
2194                     NULL, HFILL }
2195                 },
2196                 { &hf_rr_msc_id_spare,
2197                   { "Spare", "gmr1.rr.msc_id.spare",
2198                     FT_UINT8, BASE_DEC, NULL, 0x03,
2199                     NULL, HFILL }
2200                 },
2201                 { &hf_rr_gps_discr,
2202                   { "GPS Position field CRC-16", "gmr1.rr.gps_discriminator",
2203                     FT_UINT16, BASE_HEX, NULL, 0x00,
2204                     NULL, HFILL }
2205                 },
2206                 { &hf_rr_pkt_imm_ass_3_prm_rlc_mode,
2207                   { "RLC Mode", "gmr1.rr.pkt_imm_ass_3_prm",
2208                     FT_UINT8, BASE_DEC, VALS(rr_pkt_imm_ass_3_prm_rlc_mode_vals), 0x01,
2209                     NULL, HFILL }
2210                 },
2211                 { &hf_rr_pkt_imm_ass_3_prm_spare,
2212                   { "Spare", "gmr1.rr.pkt_imm_ass_3_prm.spare",
2213                     FT_UINT8, BASE_DEC, NULL, 0x1e,
2214                     NULL, HFILL }
2215                 },
2216                 { &hf_rr_pkt_imm_ass_3_prm_dl_tfi,
2217                   { "Downlink TFI", "gmr1.rr.pkt_imm_ass_3_prm.tfi",
2218                     FT_UINT8, BASE_HEX, NULL, 0x00,
2219                     "Temporary Flow Identifier", HFILL }
2220                 },
2221                 { &hf_rr_pkt_imm_ass_3_prm_start_fn,
2222                   { "Start Framenumber", "gmr1.rr.pkt_imm_ass_3_prm.start_fn",
2223                     FT_UINT8, BASE_DEC, NULL, 0xf0,
2224                     NULL, HFILL }
2225                 },
2226                 { &hf_rr_pkt_imm_ass_3_prm_mac_slot_alloc,
2227                   { "MAC-slot Allocation", "gmr1.rr.pkt_imm_ass_3_prm.mac_slot_alloc",
2228                     FT_UINT8, BASE_HEX, NULL, 0xff,
2229                     "LSB=slot 0, MSB=slot 7", HFILL }
2230                 },
2231                 { &hf_rr_pkt_freq_prm_arfcn,
2232                   { "ARFCN", "gmr1.rr.pkt_freq_prm.arfcn",
2233                     FT_UINT16, BASE_DEC, NULL, 0x00,
2234                     NULL, HFILL }
2235                 },
2236                 { &hf_rr_pkt_freq_prm_dl_freq_plan_id,
2237                   { "Downlink Freq. Plan ID", "gmr1.rr.pkt_freq_prm.dl_freq_plan_id",
2238                     FT_UINT8, BASE_DEC, VALS(rr_pkt_freq_prm_dl_freq_plan_id_vals), 0x08,
2239                     NULL, HFILL }
2240                 },
2241                 { &hf_rr_pkt_freq_prm_dl_bw,
2242                   { "Downlink Bandwidth", "gmr1.rr.pkt_freq_prm.dl_bw",
2243                     FT_UINT8, BASE_CUSTOM, rr_pkt_freq_prm_xx_bw_fmt, 0x70,
2244                     NULL, HFILL }
2245                 },
2246                 { &hf_rr_pkt_freq_prm_ul_freq_dist,
2247                   { "Uplink Freq. Distance", "gmr1.rr.pkt_freq_prm.ul_freq_dist",
2248                     FT_INT8, BASE_DEC, NULL, 0x00,
2249                     NULL, HFILL }
2250                 },
2251                 { &hf_rr_pkt_freq_prm_ul_bw,
2252                   { "Uplink Bandwidth", "gmr1.rr.pkt_freq_prm.ul_bw",
2253                     FT_UINT8, BASE_CUSTOM, rr_pkt_freq_prm_xx_bw_fmt, 0x70,
2254                     NULL, HFILL }
2255                 },
2256                 { &hf_rr_pkt_freq_prm_spare,
2257                   { "Spare", "gmr1.rr.pkt_freq_prm.spare",
2258                     FT_UINT8, BASE_DEC, NULL, 0x80,
2259                     NULL, HFILL }
2260                 },
2261                 { &hf_rr_pkt_imm_ass_2_prm_ac_spare1,
2262                   { "Spare", "gmr1.rr.pkt_imm_ass_2_prm.ac.spare1",
2263                     FT_UINT8, BASE_DEC, NULL, 0x01,
2264                     NULL, HFILL }
2265                 },
2266                 { &hf_rr_pkt_imm_ass_2_prm_ac_final_alloc,
2267                   { "Final Allocation", "gmr1.rr.pkt_imm_ass_2_prm.ac.final_alloc",
2268                     FT_UINT8, BASE_DEC, NULL, 0x02,
2269                     NULL, HFILL }
2270                 },
2271                 { &hf_rr_pkt_imm_ass_2_prm_ac_usf_granularity,
2272                   { "USF Granularity", "gmr1.rr.pkt_imm_ass_2_prm.ac.usf_granularity",
2273                     FT_UINT8, BASE_DEC, NULL, 0x04,
2274                     NULL, HFILL }
2275                 },
2276                 { &hf_rr_pkt_imm_ass_2_prm_ac_dl_ctl_mac_slot,
2277                   { "Downlink Control MAC-slot", "gmr1.rr.pkt_imm_ass_2_prm.ac.dl_ctl_mac_slot",
2278                     FT_UINT8, BASE_DEC, NULL, 0x38,
2279                     NULL, HFILL }
2280                 },
2281                 { &hf_rr_pkt_imm_ass_2_prm_ac_mac_mode,
2282                   { "MAC mode", "gmr1.rr.pkt_imm_ass_2_prm.ac.mac_mode",
2283                     FT_UINT8, BASE_DEC, VALS(rr_pkt_imm_ass_2_prm_ac_mac_mode_vals), 0xc0,
2284                     NULL, HFILL }
2285                 },
2286                 { &hf_rr_pkt_imm_ass_2_prm_ac_start_fn,
2287                   { "Starting Frame Number", "gmr1.rr.pkt_imm_ass_2_prm.ac.start_fn",
2288                     FT_UINT8, BASE_DEC, NULL, 0x0f,
2289                     NULL, HFILL }
2290                 },
2291                 { &hf_rr_pkt_imm_ass_2_prm_ac_rlc_dblk_gnt,
2292                   { "RLC Data Blocks Granted", "gmr1.rr.pkt_imm_ass_2_prm.ac.rlc_dblk_gnt",
2293                     FT_UINT8, BASE_DEC, NULL, 0x00,
2294                     NULL, HFILL }
2295                 },
2296                 { &hf_rr_pkt_imm_ass_2_prm_ac_mcs,
2297                   { "MCS", "gmr1.rr.pkt_imm_ass_2_prm.ac.mcs",
2298                     FT_UINT8, BASE_DEC, NULL, 0xf8,
2299                     NULL, HFILL }
2300                 },
2301                 { &hf_rr_pkt_imm_ass_2_prm_ac_tfi,
2302                   { "TFI", "gmr1.rr.pkt_imm_ass_2_prm.ac.tfi",
2303                     FT_UINT8, BASE_HEX, NULL, 0x7f,
2304                     NULL, HFILL }
2305                 },
2306                 { &hf_rr_pkt_imm_ass_2_prm_ac_spare2,
2307                   { "Spare", "gmr1.rr.pkt_imm_ass_2_prm.ac.spare2",
2308                     FT_UINT8, BASE_HEX, NULL, 0x80,
2309                     NULL, HFILL }
2310                 },
2311                 { &hf_rr_pkt_imm_ass_2_prm_ac_mac_slot_alloc,
2312                   { "MAC-slot Allocation", "gmr1.rr.pkt_imm_ass_2_prm.ac.mac_slot_alloc",
2313                     FT_UINT8, BASE_HEX, NULL, 0xff,
2314                     "LSB=slot 0, MSB=slot 7", HFILL }
2315                 },
2316                 { &hf_rr_pkt_imm_ass_2_prm_d_chan_mcs_cmd,
2317                   { "Channel MCS Command", "gmr1.rr.pkt_imm_ass_2_prm.d.chan_mcs_cmd",
2318                     FT_UINT8, BASE_HEX, NULL, 0x0f,
2319                     NULL, HFILL }
2320                 },
2321                 { &hf_rr_pkt_imm_ass_2_prm_d_chan_mcs_cmd_pnb512,
2322                   { "Channel MCS Command PNB 5,12", "gmr1.rr.pkt_imm_ass_2_prm.d.chan_mcs_cmd_pnb512",
2323                     FT_UINT8, BASE_HEX, NULL, 0xf0,
2324                     NULL, HFILL }
2325                 },
2326                 { &hf_rr_pkt_imm_ass_2_prm_d_spare1,
2327                   { "Spare", "gmr1.rr.pkt_imm_ass_2_prm.d.spare1",
2328                     FT_UINT8, BASE_HEX, NULL, 0xff,
2329                     NULL, HFILL }
2330                 },
2331                 { &hf_rr_pkt_imm_ass_2_prm_d_rlc_dblk_gnt,
2332                   { "RLC Data Blocks Granted", "gmr1.rr.pkt_imm_ass_2_prm.d.rlc_dblk_gnt",
2333                     FT_UINT8, BASE_DEC, NULL, 0x7f,
2334                     NULL, HFILL }
2335                 },
2336                 { &hf_rr_pkt_imm_ass_2_prm_d_spare2,
2337                   { "Spare", "gmr1.rr.pkt_imm_ass_2_prm.d.spare2",
2338                     FT_UINT8, BASE_HEX, NULL, 0x80,
2339                     NULL, HFILL }
2340                 },
2341                 { &hf_rr_pkt_imm_ass_2_prm_d_tfi,
2342                   { "TFI", "gmr1.rr.pkt_imm_ass_2_prm.d.tfi",
2343                     FT_UINT8, BASE_HEX, NULL, 0x7f,
2344                     NULL, HFILL }
2345                 },
2346                 { &hf_rr_pkt_imm_ass_2_prm_d_usf_granularity,
2347                   { "USF Granularity", "gmr1.rr.pkt_imm_ass_2_prm.ac.usf_granularity",
2348                     FT_UINT8, BASE_DEC, NULL, 0x80,
2349                     NULL, HFILL }
2350                 },
2351                 { &hf_rr_pkt_imm_ass_2_prm_d_mac_slot_alloc,
2352                   { "MAC-slot Allocation", "gmr1.rr.pkt_imm_ass_2_prm.d.mac_slot_alloc",
2353                     FT_UINT8, BASE_HEX, NULL, 0xff,
2354                     "LSB=slot 0, MSB=slot 7", HFILL }
2355                 },
2356                 { &hf_rr_usf_value,
2357                   { "Uplink state flag (USF)", "gmr1.rr.usf.value",
2358                     FT_UINT8, BASE_HEX, NULL, 0x3f,
2359                     NULL, HFILL }
2360                 },
2361                 { &hf_rr_usf_spare,
2362                   { "Spare", "gmr1.rr.usf.spare",
2363                     FT_UINT24, BASE_DEC, NULL, 0xffffc0,
2364                     NULL, HFILL }
2365                 },
2366                 { &hf_rr_timing_adv_idx_value,
2367                   { "TAI Value", "gmr1.rr.timing_adv_idx.tai",
2368                     FT_UINT8, BASE_DEC, NULL, 0x7f,
2369                     NULL, HFILL }
2370                 },
2371                 { &hf_rr_timing_adv_idx_spare,
2372                   { "Spare", "gmr1.rr.timing_adv_idx.spare",
2373                     FT_UINT8, BASE_DEC, NULL, 0x80,
2374                     NULL, HFILL }
2375                 },
2376                 { &hf_rr_tlli,
2377                   { "TLLI", "gmr1.rr.tlli",
2378                     FT_UINT32, BASE_HEX,  NULL, 0x00,
2379                     NULL, HFILL }
2380                 },
2381                 { &hf_rr_pkt_pwr_ctrl_prm_par,
2382                   { "Power Attenuation Request (PAR)", "gmr1.rr.pkt_pwr_ctrl_prm.par",
2383                     FT_UINT8, BASE_CUSTOM, rr_pkt_pwr_ctrl_prm_par_fmt, 0x3f,
2384                     NULL, HFILL }
2385                 },
2386                 { &hf_rr_pkt_pwr_ctrl_prm_spare,
2387                   { "Spare", "gmr1.rr.pkt_pwr_ctrl_prm.spare",
2388                     FT_UINT8, BASE_DEC, NULL, 0xc0,
2389                     NULL, HFILL }
2390                 },
2391                 { &hf_rr_persistence_lvl[0],
2392                   { "for Radio priority 1", "gmr1.rr.persistence_lvl.p1",
2393                     FT_UINT8, BASE_DEC, NULL, 0xf0,
2394                     NULL, HFILL }
2395                 },
2396                 { &hf_rr_persistence_lvl[1],
2397                   { "for Radio priority 2", "gmr1.rr.persistence_lvl.p2",
2398                     FT_UINT8, BASE_DEC, NULL, 0x0f,
2399                     NULL, HFILL }
2400                 },
2401                 { &hf_rr_persistence_lvl[2],
2402                   { "for Radio priority 3", "gmr1.rr.persistence_lvl.p3",
2403                     FT_UINT8, BASE_DEC, NULL, 0xf0,
2404                     NULL, HFILL }
2405                 },
2406                 { &hf_rr_persistence_lvl[3],
2407                   { "for Radio priority 4", "gmr1.rr.persistence_lvl.p4",
2408                     FT_UINT8, BASE_DEC, NULL, 0x0f,
2409                     NULL, HFILL }
2410                 },
2411         };
2412
2413 #define NUM_INDIVIDUAL_ELEMS 2
2414         static gint *ett[NUM_INDIVIDUAL_ELEMS +
2415                          NUM_GMR1_IE_RR +
2416                          NUM_GMR1_MSG_RR];
2417
2418         unsigned int last_offset, i;
2419
2420         /* Setup protocol subtree array */
2421         ett[0] = &ett_msg_ccch;
2422         ett[1] = &ett_rr_pd;
2423
2424         last_offset = NUM_INDIVIDUAL_ELEMS;
2425
2426         for (i=0; i<NUM_GMR1_IE_RR; i++,last_offset++) {
2427                 ett_gmr1_ie_rr[i] = -1;
2428                 ett[last_offset] = &ett_gmr1_ie_rr[i];
2429         }
2430
2431         for (i=0; i<NUM_GMR1_MSG_RR; i++,last_offset++) {
2432                 ett_msg_rr[i] = -1;
2433                 ett[last_offset] = &ett_msg_rr[i];
2434         }
2435
2436         proto_register_subtree_array(ett, array_length(ett));
2437
2438         /* Register the protocol name and field description */
2439         proto_gmr1_rr = proto_register_protocol("GEO-Mobile Radio (1) RR", "GMR-1 RR", "gmr1.rr");
2440
2441         proto_register_field_array(proto_gmr1_rr, hf, array_length(hf));
2442
2443         /* Register the protocol name and field description */
2444         proto_gmr1_ccch = proto_register_protocol("GEO-Mobile Radio (1) CCCH", "GMR-1 CCCH", "gmr1.ccch");
2445
2446         /* Register dissector */
2447         register_dissector("gmr1_ccch", dissect_gmr1_ccch, proto_gmr1_ccch);
2448 }
2449
2450 void
2451 proto_reg_handoff_gmr1_rr(void)
2452 {
2453         data_handle = find_dissector("data");
2454 }