Removed some more "statement not reached" warnings.
[obnox/wireshark/wip.git] / epan / dissectors / packet-uma.c
1 /* packet-uma.c
2  * Routines for Unlicensed Mobile Access(UMA) dissection
3  * Copyright 2005-2006, Anders Broman <anders.broman[at]ericsson.com>
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24  *
25  * References:
26  * http://www.umatechnology.org/
27  * UMA Protocols (Stage 3) R1.0.4 (5/16/2005)
28  *
29  * http://www.3gpp.org/specs/numbering.htm
30  * 3GPP TS 24.008 V6.2.0 (2003-09)
31  * Technical Specification
32  * 3rd Generation Partnership Project;
33  * Technical Specification Group Core Network;
34  * Mobile radio interface Layer 3 specification;
35  * Core network protocols; Stage 3
36  * (Release 6)
37  *
38  * 3GPP TS 44.018 V6.11.0 (2005-01)
39  * 3rd Generation Partnership Project;
40  * Technical Specification Group GSM/EDGE Radio Access Network;
41  * Mobile radio interface layer 3 specification;
42  * Radio Resource Control (RRC) protocol
43  * (Release 6)
44  *
45  * 3GPP TS 45.009 V6.1.0 (2004-02)
46  * 3rd Generation Partnership Project;
47  * Technical Specification Group GSM/EDGE
48  * Radio Access Network;
49  * Link adaptation
50  * (Release 6)
51  *
52  */
53
54 #ifdef HAVE_CONFIG_H
55 # include "config.h"
56 #endif
57
58 #include <stdio.h>
59 #include <stdlib.h>
60 #include <string.h>
61
62 #include <glib.h>
63 #include <epan/conversation.h>
64
65 #include <epan/packet.h>
66 #include <epan/asn1.h>
67
68 #include "prefs.h"
69 #include "packet-bssap.h"
70 #include "packet-gsm_a.h"
71 #include "packet-gsm_map.h"
72 #include "packet-rtp.h"
73 #include "packet-rtcp.h"
74 #include "packet-e212.h"
75 #include <epan/emem.h>
76 #include "packet-tcp.h"
77
78 /* Length field is 2 bytes and comes first */
79 #define UMA_HEADER_SIZE 2
80 gboolean uma_desegment = TRUE;
81
82 static dissector_handle_t uma_tcp_handle = NULL;
83 static dissector_handle_t uma_udp_handle = NULL;
84 static dissector_handle_t data_handle = NULL;
85 static dissector_table_t bssap_pdu_type_table=NULL;
86 static dissector_handle_t rtp_handle = NULL;
87 static dissector_handle_t rtcp_handle = NULL;
88 static dissector_handle_t llc_handle = NULL;
89
90 /* Initialize the protocol and registered fields */
91 static int proto_uma                                    = -1;
92 static int hf_uma_length_indicator              = -1;
93 static int hf_uma_pd                                    = -1;
94 static int hf_uma_skip_ind                              = -1;
95 static int hf_uma_urr_msg_type                  = -1;
96 static int hf_uma_urlc_msg_type                 = -1;
97 static int hf_uma_urlc_TLLI                             = -1;
98 static int hf_uma_urlc_seq_nr                   = -1;
99 static int hf_uma_urr_IE                                = -1;
100 static int hf_uma_urr_IE_len                    = -1;
101 static int hf_uma_urr_mobile_identity_type      = -1;
102 static int hf_uma_urr_odde_even_ind             = -1;
103 static int hf_uma_urr_imsi                              = -1;
104 static int hf_uma_urr_imei                              = -1;
105 static int hf_uma_urr_imeisv                    = -1;
106 static int hf_uma_urr_tmsi_p_tmsi               = -1;
107 static int hf_uma_urr_uri                               = -1;
108 static int hf_uma_urr_radio_type_of_id  = -1;
109 static int hf_uma_urr_radio_id                  = -1;
110 static int hf_uma_urr_cell_id                   = -1;
111 static int hf_uma_urr_mcc                               = -1;
112 static int hf_uma_urr_mnc                               = -1;
113 static int hf_uma_urr_lac                               = -1;
114 static int hf_uma_urr_gci                               = -1;
115 static int hf_uma_urr_tura                              = -1;
116 static int hf_uma_urr_gc                                = -1;
117 static int hf_uma_urr_uc                                = -1;
118 static int hf_uma_urr_rrs                               = -1;
119 static int hf_uma_urr_IP_Address_type   = -1;
120 static int hf_uma_urr_FQDN                              = -1;
121 static int hf_uma_urr_sgw_ipv4                  = -1;
122 static int hf_uma_urr_redirection_counter = -1;
123 static int hf_uma_urr_dis_rej_cau               = -1;
124 static int hf_uma_urr_MSCR                              = -1;
125 static int hf_uma_urr_ATT                               = -1;
126 static int hf_uma_urr_DTM                               = -1;
127 static int hf_uma_urr_GPRS                              = -1;
128 static int hf_uma_urr_NMO                               = -1;
129 static int hf_uma_urr_ECMC                              = -1;
130 static int hf_uma_urr_T3212_timer               = -1;
131 static int hf_uma_urr_RAC                               = -1;
132 static int hf_uma_urr_ap_location               = -1;
133 static int hf_uma_urr_SGSNR                             = -1;
134 static int hf_uma_urr_ECMP                              = -1;
135 static int hf_uma_urr_RE                                = -1;
136 static int hf_uma_urr_PFCFM                             = -1;
137 static int hf_uma_urr_3GECS                             = -1;
138 static int hf_uma_urr_bcc                               = -1;
139 static int hf_uma_urr_ncc                               = -1;
140 static int hf_uma_urr_TU3907_timer              = -1;
141 static int hf_uma_urr_GSM_RR_state              = -1;
142 static int hf_uma_urr_UMA_band                  = -1;
143 static int hf_uma_urr_URR_state                 = -1;
144 static int hf_uma_urr_register_reject_cause = -1;
145 static int hf_uma_urr_TU3906_timer              = -1;
146 static int hf_uma_urr_TU3910_timer              = -1;
147 static int hf_uma_urr_TU3902_timer              = -1;
148 static int hf_uma_urr_communication_port = -1;
149 static int hf_uma_urr_L3_Message                = -1;
150 static int hf_uma_urr_L3_protocol_discriminator = -1;
151 static int hf_uma_urr_sc                                = -1;
152 static int hf_uma_urr_algorithm_id              = -1;
153 static int hf_uma_urr_GPRS_resumption   = -1;
154 static int hf_uma_urr_ULQI                              = -1;
155 static int hf_uma_urr_TU3920_timer              = -1;
156 static int hf_uma_urr_peak_tpt_cls              = -1;
157 static int hf_uma_urr_radio_pri                 = -1;
158 static int hf_uma_urr_rlc_mode                  = -1;
159 static int hf_uma_urr_URLCcause                 = -1;
160 static int hf_uma_urr_udr                               = -1;
161 static int hf_uma_urr_TU4001_timer              = -1;
162 static int hf_uma_urr_LS                                = -1;
163 static int hf_uma_urr_cipher_res                = -1;
164 static int hf_uma_urr_rand_val                  = -1;
165 static int hf_uma_urr_ciphering_command_mac = -1;
166 static int hf_uma_urr_ciphering_key_seq_num = -1;
167 static int hf_uma_urr_sapi_id                   = -1;
168 static int hf_uma_urr_establishment_cause = -1;
169 static int hf_uma_urr_channel                   = -1;
170 static int hf_uma_urr_PDU_in_error              = -1;
171 static int hf_uma_urr_sample_size               = -1;
172 static int hf_uma_urr_payload_type              = -1;
173 static int hf_uma_urr_LLC_PDU                   = -1;
174 static int hf_uma_urr_LBLI                              = -1;
175 static int hf_uma_urr_RI                                = -1;
176 static int hf_uma_urr_TU4003_timer              = -1;
177 static int hf_uma_urr_ap_service_name_type = -1;
178 static int hf_uma_urr_ap_Service_name_value = -1;
179 static int hf_uma_urr_uma_service_zone_icon_ind = -1;
180 static int hf_uma_urr_uma_service_zone_str_len = -1;
181 static int hf_uma_urr_window_size       = -1;
182 static int hf_uma_urr_uma_codec_mode    = -1;
183 static int hf_uma_urr_UTRAN_cell_id_disc = -1;
184 static int hf_uma_urr_ms_radio_id               = -1;
185 static int hf_uma_urr_uma_service_zone_str = -1;
186 static int hf_uma_urr_suti                              = -1;
187 static int hf_uma_urr_uma_mps                   = -1;
188 static int hf_uma_urr_num_of_plms               = -1;
189 static int hf_uma_urr_cbs                               = -1;
190 static int hf_uma_urr_num_of_cbs_frms   = -1;
191 static int hf_uma_urr_unc_ipv4                  = -1;
192 static int hf_uma_unc_FQDN                              = -1;
193 static int hf_uma_urr_GPRS_user_data_transport_ipv4 = -1;
194 static int hf_uma_urr_GPRS_port                 = -1;
195 static int hf_uma_urr_UNC_tcp_port              = -1;
196 static int hf_uma_urr_RTP_port                  = -1;
197 static int hf_uma_urr_RTCP_port                 = -1;
198 static int hf_uma_urr_RXLEV_NCELL               = -1;
199
200 /* Initialize the subtree pointers */
201 static int ett_uma = -1;
202 static int ett_uma_toc = -1;
203 static int ett_urr_ie = -1;
204
205 /* The dynamic payload type which will be dissected as uma */
206
207 static range_t *global_uma_tcp_port_range;
208 static range_t *uma_tcp_port_range;
209 #define DEFAULT_UMA_PORT_RANGE "14001,14001"
210
211 /* Global variables */
212         guint32         sgw_ipv4_address;
213         guint32         unc_ipv4_address;
214         guint32         rtp_ipv4_address;
215         guint32         rtcp_ipv4_address;
216         guint32         GPRS_user_data_ipv4_address;
217
218 /*
219  * Protocol Discriminator (PD)
220  */
221 static const value_string uma_pd_vals[] = {
222         { 0,            "URR_C"},
223         { 1,            "URR"},
224         { 2,            "URLC"},
225         { 0,    NULL }
226 };
227 /*
228  * Message types for Unlicensed Radio Resources management
229  */
230 static const value_string uma_urr_msg_type_vals[] = {
231         { 1,            "URR DISCOVERY REQUEST"},
232         { 2,            "URR DISCOVERY ACCEPT"},
233         { 3,            "URR DISCOVERY REJECT"},
234         { 16,           "URR REGISTER REQUEST"},
235         { 17,           "URR REGISTER ACCEPT"},
236         { 18,           "URR REGISTER REDIRECT"},
237         { 19,           "URR REGISTER REJECT"},
238         { 20,           "URR DEREGISTER"},
239         { 21,           "URR REGISTER UPDATE UPLINK"},
240         { 22,           "URR REGISTER UPDATE DOWNLINK"},
241         { 23,           "URR CELL BROADCAST INFO"},
242         { 32,           "URR CIPHERING MODE COMMAND"},
243         { 33,           "URR CIPHERING MODE COMPLETE"},
244         { 48,           "URR ACTIVATE CHANNEL"},
245         { 49,           "URR ACTIVATE CHANNEL ACK"},
246         { 50,           "URR ACTIVATE CHANNEL COMPLETE"},
247         { 51,           "URR ACTIVATE CHANNEL FAILURE"},
248         { 52,           "URR CHANNEL MODE MODIFY"},
249         { 53,           "URR CHANNEL MODE MODIFY ACKNOWLEDGE"},
250         { 64,           "URR RELEASE"},
251         { 65,           "URR RELEASE COMPLETE"},
252         { 66,           "URR CLEAR REQUEST"},
253         { 80,           "URR HANDOVER ACCESS"},
254         { 81,           "URR HANDOVER COMPLETE"},
255         { 82,           "URR UPLINK QUALITY INDICATION"},
256         { 83,           "URR HANDOVER REQUIRED"},
257         { 84,           "URR HANDOVER COMMAND"},
258         { 85,           "URR HANDOVER FAILURE"},
259         { 96,           "URR PAGING REQUEST"},
260         { 97,           "URR PAGING RESPONSE"},
261         { 112,          "URR UPLINK DIRECT TRANSFER"},
262         { 113,          "URR INITIAL DIRECT TRANSFER"},
263         { 114,          "URR DOWNLINK DIRECT TRANSFER"},
264         { 115,          "URR STATUS"},
265         { 116,          "URR KEEP ALIVE"},
266         { 117,          "URR CLASSMARK ENQUIRY"},
267         { 118,          "URR CLASSMARK CHANGE"},
268         { 119,          "URR GPRS SUSPENSION REQUEST"},
269         { 120,          "URR SYNCHRONIZATION INFORMATION"},
270         { 128,          "URR REQUEST"},
271         { 129,          "URR REQUEST ACCEPT"},
272         { 130,          "URR REQUEST REJECT"},
273         { 0,    NULL }
274 };
275 /*
276  * Message types for URLC signaling
277  */
278 static const value_string uma_urlc_msg_type_vals[] = {
279         { 1,            "URLC-DATA"},
280         { 2,            "URLC UNITDATA"},
281         { 3,            "URLC-PS-PAGE"},
282         { 6,            "URLC-UFC-REQ"},
283         { 7,            "URLC-DFC-REQ"},
284         { 8,            "URLC-ACTIVATE-UTC-REQ"},
285         { 9,            "URLC-ACTIVATE-UTC-ACK"},
286         { 10,           "URLC-DEACTIVATE-UTC-REQ"},
287         { 11,           "URLC-DEACTIVATE-UTC-ACK"},
288         { 12,           "URLC STATUS"},
289         { 0,    NULL }
290 };
291 /*
292  * IE type and identifiers for Unlicensed Radio Resources management
293  */
294 static const value_string uma_urr_IE_type_vals[] = {
295         { 1,            "Mobile Identity"},
296         { 2,            "UMA Release Indicator"},
297         { 3,            "Radio Identity"},
298         { 4,            "GERAN Cell Identity"},
299         { 5,            "Location Area Identification"},
300         { 6,            "GERAN/UTRAN Coverage Indicator"},
301         { 7,            "UMA Classmark"},
302         { 8,            "Geographical Location"},
303         { 9,            "UNC SGW IP Address"},
304         { 10,           "UNC SGW Fully Qualified Domain/Host Name"},
305         { 11,           "Redirection Counter"},
306         { 12,           "Discovery Reject Cause"},
307         { 13,           "UMA Cell Description"},
308         { 14,           "UMA Control Channel Description"},
309         { 15,           "Cell Identifier List"},
310         { 16,           "TU3907 Timer"},
311         { 17,           "GSM RR/UTRAN RRC State"},
312         { 18,           "Routing Area Identification"},
313         { 19,           "UMA Band"},
314         { 20,           "URR State"},
315         { 21,           "Register Reject Cause"},
316         { 22,           "TU3906 Timer"},
317         { 23,           "TU3910 Timer"},
318         { 24,           "TU3902 Timer"},
319         { 25,           "Communication Port Identity"},
320         { 26,           "L3 Message"},
321         { 27,           "Channel Mode"},
322         { 28,           "Mobile Station Classmark 2"},
323         { 29,           "RR Cause"},
324         { 30,           "Cipher Mode Setting"},
325         { 31,           "GPRS Resumption"},
326         { 32,           "Handover From UMAN Command"},
327         { 33,           "UL Quality Indication"},
328         { 34,           "TLLI"},
329         { 35,           "Packet Flow Identifier"},
330         { 36,           "Suspension Cause"},
331         { 37,           "TU3920 Timer"},
332         { 38,           "QoS"},
333         { 39,           "URLC Cause"},
334         { 40,           "User Data Rate"},
335         { 41,           "Routing Area Code"},
336         { 42,           "AP Location"},
337         { 43,           "TU4001 Timer"},
338         { 44,           "Location Status"},
339         { 45,           "Cipher Response"},
340         { 46,           "Ciphering Command RAND"},
341         { 47,           "Ciphering Command MAC"},
342         { 48,           "Ciphering Key Sequence Number"},
343         { 49,           "SAPI ID"},
344         { 50,           "Establishment Cause"},
345         { 51,           "Channel Needed"},
346         { 52,           "PDU in Error"},
347         { 53,           "Sample Size"},
348         { 54,           "Payload Type"},
349         { 55,           "Multi-rate Configuration"},
350         { 56,           "Mobile Station Classmark 3"},
351         { 57,           "LLC-PDU"},
352         { 58,           "Location Black List indicator"},
353         { 59,           "Reset Indicator"},
354         { 60,           "TU4003 Timer"},
355         { 61,           "AP Service Name"},
356         { 62,           "UMA Service Zone Information"},
357         { 63,           "RTP Redundancy Configuration"},
358         { 64,           "UTRAN Classmark"},
359         { 65,           "Classmark Enquiry Mask"},
360         { 66,           "UTRAN Cell Identifier List"},
361         { 67,           "Serving UNC table indicator"},
362         { 68,           "Registration indicators"},
363         { 69,           "UMA PLMN List"},
364         { 70,           "Received Signal Level List"},
365         { 71,           "Required UMA Services"},
366         { 72,           "Broadcast Container"},
367         { 73,           "3G Cell Identity"},
368         { 96,           "MS Radio Identity"},
369         { 97,           "UNC IP Address"},
370         { 98,           "UNC Fully Qualified Domain/Host Name"},
371         { 99,           "IP address for GPRS user data transport"},
372         { 100,          "UDP Port for GPRS user data transport"},
373         { 103,          "UNC TCP port"},
374         { 104,          "RTP UDP port"},
375         { 105,          "RTCP UDP port"},
376         { 106,          "GERAN Received Signal Level List"},
377         { 107,          "UTRAN Received Signal Level List"},
378         { 0,    NULL }
379 };
380
381 static const value_string uma_urr_mobile_identity_type_vals[] = {
382         { 1,            "IMSI"},
383         { 2,            "IMEI"},
384         { 3,            "IMEISV"},
385         { 4,            "TMSI/P-TMSI"},
386         { 0,            "No Identity"},
387         { 0,    NULL }
388 };
389
390 static const value_string uma_urr_oddevenind_vals[] = {
391         { 0,            "Even number of identity digits"},
392         { 1,            "Odd number of identity digits"},
393         { 0,    NULL }
394 };
395
396 static const value_string radio_type_of_id_vals[] = {
397         { 0,            "IEEE MAC-address format"},
398         { 0,    NULL }
399 };
400
401 /* GCI, GSM Coverage Indicator (octet 3) */
402 static const value_string gci_vals[] = {
403         { 0,            "Normal Service in the GERAN"},
404         { 1,            "Limited Service in the GERAN"},
405         { 2,            "MS has not found GSM coverage (LAI information taken from SIM, if available)"},
406         { 3,            "MS has found GSM coverage, service state unknown"},
407         { 0,    NULL }
408 };
409 /* TURA, Type of Unlicensed Radio (octet 3) */
410 static const value_string tura_vals[] = {
411         { 0,            "No radio"},
412         { 1,            "Bluetooth"},
413         { 2,            "WLAN 802.11"},
414         { 15,           "Unspecified"},
415         { 0,    NULL }
416 };
417 /* GC, GERAN Capable (octet 3) */
418 static const value_string gc_vals[] = {
419         { 0,            "The MS is not GERAN capable."},
420         { 1,            "The MS is GERAN capable."},
421         { 0,    NULL }
422 };
423 /* UC, UTRAN Capable (octet 3) */
424 static const value_string uc_vals[] = {
425         { 0,            "The MS is not UTRAN  capable."},
426         { 1,            "The MS is UTRAN  capable."},
427         { 0,    NULL }
428 };
429 /*RRS, RTP Redundancy Support (octet 4)*/
430 static const value_string rrs_vals[] = {
431         { 0,            "RTP Redundancy not supported"},
432         { 1,            "RTP Redundancy supported"},
433         { 0,    NULL }
434 };
435
436 /*IP address type number value (octet 3)*/
437 static const value_string IP_address_type_vals[] = {
438         { 0x21,         "IPv4 address"},
439         { 0x57,         "IPv6 address"},
440         { 0,    NULL }
441 };
442
443 /*Discovery Reject Cause (octet 3) */
444 static const value_string discovery_reject_cause_vals[] = {
445         { 0,            "Network Congestion"},
446         { 1,            "Unspecified"},
447         { 2,            "IMSI not allowed"},
448         { 0,    NULL }
449 };
450 /*EC Emergency Call allowed (octet 3)*/
451 static const value_string EC_vals[] _U_ = {
452         { 0,            "Emergency call allowed in the cell to all MSs"},
453         { 1,            "Emergency call not allowed in the cell except for the MSs that belong to one of the classes between 11 to 15."},
454         { 0,    NULL }
455 };
456 /*ECMC, Early Classmark Sending Control (octet 3)*/
457 static const value_string ECMC_vals[] = {
458         { 0,            "Early Classmark Sending is allowed"},
459         { 1,            "Early Classmark Sending is forbidden"},
460         { 0,    NULL }
461 };
462 /*NMO, Network Mode of Operation (octet 3)*/
463 static const value_string NMO_vals[] = {
464         { 0,            "Network Mode of Operation I"},
465         { 1,            "Network Mode of Operation II"},
466         { 2,            "Network Mode of Operation III"},
467         { 3,            "Reserved"},
468         { 0,    NULL }
469 };
470 /*GPRS, GPRS Availability (octet 3)*/
471 static const value_string GPRS_avail_vals[] = {
472         { 0,            "GPRS available"},
473         { 1,            "GPRS not available"},
474         { 0,    NULL }
475 };
476 /*DTM, Dual Transfer Mode of Operation by network (octet 3)*/
477 static const value_string DTM_vals[] = {
478         { 0,            "Network does not support dual transfer mode"},
479         { 1,            "Network supports dual transfer mode"},
480         { 0,    NULL }
481 };
482 /*ATT, Attach-detach allowed (octet 3)*/
483 static const value_string ATT_vals[] = {
484         { 0,            "MSs in the cell are not allowed to apply IMSI attach and detach procedure."},
485         { 1,            "MSs in the cell shall apply IMSI attach and detach procedure."},
486         { 0,    NULL }
487 };
488 /*MSCR, MSC Release (octet 3)*/
489 static const value_string MSCR_vals[] = {
490         { 0,            "MSC is Release '98 or older"},
491         { 1,            "MSC is Release '99 onwards"},
492         { 0,    NULL }
493 };
494
495 /* SGSNR, SGSN Release (octet 6)*/
496 static const value_string SGSNR_vals[] = {
497         { 0,            "SGSN is Release '98 or older"},
498         { 1,            "SGSN is Release '99 onwards"},
499         { 0,    NULL }
500 };
501 /* ECMP, Emergency Call Mode Preference (octet 6)*/
502
503 static const value_string ECMP_vals[] = {
504         { 0,            "GSM GERAN is preferred for Emergency calls"},
505         { 1,            "UMAN is preferred for Emergency calls"},
506         { 0,    NULL }
507 };
508 /* RE, Call reestablishment allowed (octet 6) */
509 static const value_string RE_vals[] = {
510         { 0,            "Call Reestablishment allowed in the cell"},
511         { 1,            "Call Reestablishment not allowed in the cell"},
512         { 0,    NULL }
513 };
514 /* PFCFM, PFC_FEATURE_MODE (octet 6) */
515 static const value_string PFCFM_vals[] = {
516         { 0,            "The network does not support packet flow context procedures"},
517         { 1,            "The network supports packet flow context procedures"},
518         { 0,    NULL }
519 };
520
521 /* 3GECS, 3G Early Classmark Sending Restriction (octet 6) */
522 static const value_string Three_GECS_vals[] = {
523         { 0,            "UTRAN classmark change message shall be sent with the Early classmark sending"},
524         { 1,            "The sending of UTRAN Classmark Sending messages is controlled by the Early Classmark Sending Control parameter"},
525         { 0,    NULL }
526 };
527
528 /*GRS, GSM RR State (octet 3)*/
529 static const value_string GRS_GSM_RR_State_vals[] = {
530         { 0,            "GSM RR is in IDLE state"},
531         { 1,            "GSM RR is in DEDICATED state"},
532         { 2,            "UTRAN RRC is in IDLE STATE"},
533         { 3,            "UTRAN RRC is in CELL_DCH STATE"},
534         { 4,            "UTRAN RRC is in CELL_FACH STATE"},
535         { 7,            "Unknown"},
536         { 0,    NULL }
537 };
538 /* UMA Band (4 bit field) */
539 static const value_string UMA_band_vals[] = {
540         { 0,            "E-GSM is supported"},
541         { 1,            "P-GSM is supported"},
542         { 2,            "GSM 1800 is supported"},
543         { 3,            "GSM 450 is supported"},
544         { 4,            "GSM 480 is supported"},
545         { 5,            "GSM 850 is supported"},
546         { 6,            "GSM 1900 is supported"},
547         { 7,            "GSM 700 is supported"},
548         { 0,    NULL }
549 };
550 /*URS, URR State (octet 3) */
551 static const value_string URR_state_vals[] = {
552         { 0,            "URR is in URR-IDLE state"},
553         { 1,            "URR is in URR-DEDICATED state"},
554         { 2,            "URR is in URR-REGISTERED state"},
555         { 0,    NULL }
556 };
557
558 /* Register Reject Cause (octet 3) */
559 static const value_string register_reject_cause_vals[] = {
560         { 0,            "Network Congestion"},
561         { 1,            "AP not allowed"},
562         { 2,            "Location not allowed"},
563         { 3,            "Invalid UNC"},
564         { 4,            "Geo Location not known"},
565         { 5,            "IMSI not allowed"},
566         { 6,            "Unspecified"},
567         { 7,            "UNC-SGW certificate not valid"},
568         { 8,            "EAP_SIM authentication failed"},
569         { 9,            "TCP establishment failed"},
570         { 10,           "Redirection"},
571         { 11,           "EAP-AKA authentication failed"},
572         { 0,    NULL }
573 };
574
575 /* L3 Protocol discriminator values according to TS 24 007 (640)  */
576 static const value_string protocol_discriminator_vals[] = {
577         {0x0,           "Group call control"},
578         {0x1,           "Broadcast call control"},
579         {0x2,           "Reserved: was allocated in earlier phases of the protocol"},
580         {0x3,           "Call Control; call related SS messages"},
581         {0x4,           "GPRS Transparent Transport Protocol (GTTP)"},
582         {0x5,           "Mobility Management messages"},
583         {0x6,           "Radio Resources Management messages"},
584         {0x7,           "Unknown"},
585         {0x8,           "GPRS mobility management messages"},
586         {0x9,           "SMS messages"},
587         {0xa,           "GPRS session management messages"},
588         {0xb,           "Non call related SS messages"},
589         {0xc,           "Location services specified in 3GPP TS 44.071 [8a]"},
590         {0xd,           "Unknown"},
591         {0xe,           "Reserved for extension of the PD to one octet length "},
592         {0xf,           "Reserved for tests procedures described in 3GPP TS 44.014 [5a] and 3GPP TS 34.109 [17a]."},
593         { 0,    NULL }
594 };
595
596 /* algorithm identifier
597  * If SC=1 then:
598  * bits
599  * 4 3 2
600  */
601  static const value_string algorithm_identifier_vals[] = {
602         { 0,            "Cipher with algorithm A5/1"},
603         { 1,            "Cipher with algorithm A5/2"},
604         { 2,            "Cipher with algorithm A5/3"},
605         { 3,            "Cipher with algorithm A5/4"},
606         { 4,            "Cipher with algorithm A5/5"},
607         { 5,            "Cipher with algorithm A5/6"},
608         { 6,            "Cipher with algorithm A5/7"},
609         { 7,            "Reserved"},
610         { 0,    NULL }
611 };
612 /*  GPRS Resumption */
613  static const value_string GPRS_resumption_vals[] = {
614         { 0,            "Resumption of GPRS services not successfully acknowledged"},
615         { 1,            "Resumption of GPRS services successfully acknowledged"},
616         { 0,    NULL }
617 };
618 /* SC (octet 1) */
619 static const value_string SC_vals[] = {
620         { 0,            "No ciphering"},
621         { 1,            "Start ciphering"},
622         { 0,    NULL }
623 };
624
625 /* ULQI, UL Quality Indication (octet 3) */
626 static const value_string ULQI_vals[] = {
627         { 0,            "Quality ok"},
628         { 1,            "Radio problem"},
629         { 2,            "Network problem"},
630         { 4,            "Undetermined problem"},
631         { 0,    NULL }
632 };
633
634 static const value_string radio_pri_vals[] = {
635         { 0,            "Radio priority 1"},
636         { 1,            "Radio priority 2"},
637         { 2,            "Radio priority 3"},
638         { 3,            "Radio priority 4"},
639         { 3,            "Radio Priority Unknown"},
640         { 0,    NULL }
641 };
642
643 static const value_string rlc_mode_vals[] = {
644         { 0,            "RLC acknowledged mode"},
645         { 1,            "RLC unacknowledged mode"},
646         { 0,    NULL }
647 };
648
649 /*URLC Cause (octet 3) */
650 static const value_string URLC_cause_vals[] = {
651         { 0,            "success"},
652         { 2,            "no available resources"},
653         { 3,            "UNC failure"},
654         { 4,            "not authorized for data service"},
655         { 5,            "message type non existent or not implemented"},
656         { 6,            "message type not compatible with the protocol state"},
657         { 7,            "invalid mandatory information"},
658         { 8,            "syntactically incorrect message"},
659         { 9,            "GPRS suspended"},
660         { 10,           "normal deactivation"},
661         { 12,           "conditional IE error"},
662         { 13,           "semantically incorrect message"},
663         { 0,    NULL }
664 };
665
666 /* LS, Location Status (octet 3) */
667 static const value_string LS_vals[] = {
668         { 0,            "MS location known"},
669         { 1,            "MS location unknown"},
670         { 0,    NULL }
671 };
672
673 /* CR Cipher Response (octet 1) */
674 static const value_string CR_vals[] = {
675         { 0,            "IMEISV shall not be included"},
676         { 1,            "IMEISV shall be included"},
677         { 0,    NULL }
678 };
679
680 /* SAPI ID, SAPI Identifier (octet 3) */
681 static const value_string sapi_id_vals[] = {
682         { 0,            "SAPI 0 (all other except SMS)"},
683         { 3,            "SAPI 3 (SMS)"},
684         { 0,    NULL }
685 };
686 /*      Sample Size (octet 3)*/
687 static const value_string sample_size_vals[] = {
688         { 20,           "20 ms of CS payload included in each RTP/UDP packet"},
689         { 40,           "40 ms of CS payload included in each RTP/UDP packet"},
690         { 60,           "60 ms of CS payload included in each RTP/UDP packet"},
691         { 80,           "80 ms of CS payload included in each RTP/UDP packet"},
692         { 0,    NULL }
693 };
694
695
696 /* MPS, Manual PLMN Selection indicator (octet 3) */
697 static const value_string mps_vals[] = {
698         { 0,            "The MS is in Automatic PLMN selection mode."},
699         { 1,            "The MS is in Manual PLMN selection mode and request the listof PLMN identities that may provide UMAN service in the current location."},
700         { 2,            "The MS is in Manual PLMN selection mode and tries to register; no PLMN list is needed."},
701         { 0,    NULL }
702 };
703
704 /* CBS Cell Broadcast Service (octet 3) */
705 static const value_string cbs_vals[] = {
706         { 0,            "CBS is not required by the Mobile station"},
707         { 1,            "CBS is required by the mobile station"},
708         { 0,    NULL }
709 };
710
711 /* LBLI, Location Black List indicator (octet 3) */
712 static const value_string LBLI_vals[] = {
713         { 0,            "MCC"},
714         { 1,            "MCC and MNC"},
715         { 2,            "MCC, MNC and LAC"},
716         { 0,    NULL }
717 };
718 /* AP Service Name type */
719 static const value_string ap_service_name_type_vals[] = {
720         { 0,            "SSID"},
721         { 1,            "PAN Service Name"},
722         { 0,    NULL }
723 };
724
725 /* UMA Service Zone Icon Indicator, octet 3 */
726 static const value_string uma_service_zone_icon_ind_vals[] = {
727         { 1,            "Unlimited Calls"},
728         { 0,    NULL }
729 };
730 /*Establishment Cause (octet 3)*/
731 static const value_string establishment_cause_vals[] = {
732         { 0xa0,         "Emergency"},
733         { 0xc0,         "Call re-establishment"},
734         { 0x00,         "Location Update"},
735         { 0x10,         "Other SDCCH procedures including IMSI Detach, SMS, SS, paging response"},
736 /* note: Paging response for SDCCH needed is using codepoint  0001 0000 */
737         { 0x20,         "Paging response (TCH/F needed)"},
738         { 0x30,         "Paging response (TCH/F or TCH/H needed)"},
739         { 0x80,         "Paging response (any channel needed)"},
740         { 0x40,         "Originating speech call from dual-rate mobile station when TCH/H is sufficient"},
741         { 0x50,         "Originating data call from dual-rate mobile station when TCH/H is sufficient"},
742         { 0xe0,         "Originating speech call and TCH/F is needed"},
743         { 0xf0,         "Originating data call and TCH/F is needed"},
744         { 0,    NULL }
745 };
746 /*CHANNEL (octet 3) */
747 static const value_string channel_vals[] = {
748         { 0,            "Any channel"},
749         { 1,            "SDCCH"},
750         { 2,            "TCH/F (Full rate)"},
751         { 3,            "TCH/H or TCH/F (Dual rate)"},
752         { 0,    NULL }
753 };
754
755 /*RI, Reset Indicator (octet 3)*/
756 /*CHANNEL (octet 3) */
757 static const value_string RI_vals[] = {
758         { 0,            "The flow control condition continues to exist"},
759         { 1,            "The flow control condition no longer exists"},
760         { 0,    NULL }
761 };
762
763 /* Window Size (octet 3 to octet n) */
764
765 static const value_string window_size_vals[] = {
766         { 0,            "Window size 1, No redundancy"},
767         { 1,            "Window size 2 (single redundancy)"},
768         { 2,            "Window size 3 (double redundancy)"},
769         { 0,    NULL }
770 };
771
772 static const value_string UTRAN_cell_id_disc_vals[] = {
773         { 0,            "PLMN-ID, LAC and a 28-bit Cell Id are used to identify the target UTRAN cell."},
774         { 0,    NULL }
775 };
776
777 /* SUTI, Serving UNC table indicator indicator (octet 3) */
778
779 static const value_string suti_vals[] = {
780         { 0,            "The MS is not allowed to store information in the stored Serving UNC table."},
781         { 1,            "The MS is allowed to store information in the stored Serving UNC table."},
782         { 0,    NULL }
783 };
784         /* Code to actually dissect the packets */
785
786 static int
787 dissect_uma_IE(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
788 {
789         tvbuff_t        *l3_tvb;
790         tvbuff_t        *llc_tvb;
791         tvbuff_t        *new_tvb;
792         int                     ie_offset;
793         guint8          ie_value;
794         guint16         ie_len = 0;
795         guint8          octet;
796         proto_item      *urr_ie_item;
797         proto_tree      *urr_ie_tree;
798         const guint8    *haddr;
799         char            *string;
800         guint16         GPRS_user_data_transport_UDP_port,UNC_tcp_port,RTP_UDP_port,RTCP_UDP_port, communication_port;
801         guint32         udr;
802         conversation_t *conversation;
803         address dst_addr, null_addr;
804         guint8          str_len;
805         address         src_addr;
806
807         ie_value = tvb_get_guint8(tvb,offset);
808         urr_ie_item = proto_tree_add_text(tree,tvb,offset,-1,"%s",
809                 val_to_str(ie_value, uma_urr_IE_type_vals, "Unknown IE (%u)"));
810         urr_ie_tree = proto_item_add_subtree(urr_ie_item, ett_urr_ie);
811
812         proto_tree_add_item(urr_ie_tree, hf_uma_urr_IE, tvb, offset, 1, FALSE);
813         offset++;
814         /* Some IE:s might have a lengt field of 2 octets */
815         ie_len = tvb_get_guint8(tvb,offset);
816         if ( (ie_len & 0x80) == 0x80 ){
817                 offset++;
818                 ie_len = (ie_len & 0x7f) << 8;
819                 ie_len = ie_len | (tvb_get_guint8(tvb,offset));
820                 proto_item_set_len(urr_ie_item, ie_len + 3);
821                 proto_tree_add_uint(urr_ie_tree, hf_uma_urr_IE_len , tvb, offset-1, 2, ie_len );
822                 ie_offset = offset +1;
823         }else{
824                 proto_item_set_len(urr_ie_item, ie_len + 2);
825                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_IE_len, tvb, offset, 1, FALSE);
826                 ie_offset = offset +1;
827         }
828
829         switch(ie_value){
830         /* 11.2.1 Mobile Identity */
831         case 1:
832         /* Mobile Identity
833          * The rest of the IE is coded as in [TS 24.008] not including IEI and
834          * length, if present.(10.5.1.4)
835          */
836                 de_mid(tvb, urr_ie_tree, ie_offset, ie_len, NULL, 0);
837                 break;
838
839         case 2:
840                 /* UMA Release Indicator */
841                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_uri, tvb, ie_offset, 1, FALSE);
842                 break;
843         case 3:                 /* Radio Identity */
844                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_radio_type_of_id, tvb, ie_offset, 1, FALSE);
845                 octet = tvb_get_guint8(tvb,ie_offset);
846                 if (( octet & 0xf) == 0){ /* IEEE MAC-address format */
847                         ie_offset++;
848                         haddr = tvb_get_ptr(tvb, ie_offset, ie_len);
849                         proto_tree_add_ether(urr_ie_tree, hf_uma_urr_radio_id, tvb, ie_offset, ie_len, haddr);
850                 }else{
851                         proto_tree_add_text(urr_ie_tree, tvb, ie_offset, ie_len,"Unknown format");
852                 }
853                 break;
854         case 4:
855                 /* Cell Identity
856                  * The rest of the IE is coded as in [TS 24.008] not including IEI and length, if present.
857                  */
858                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_cell_id, tvb, ie_offset, 2, FALSE);
859                 break;
860         case 5:
861                 /* Location Area Identification
862                  * The rest of the IE is coded as in [TS 24.008] not including IEI and
863                  * length, if present.
864                  */
865                 de_lai(tvb, urr_ie_tree, ie_offset, ie_len, NULL, 0);
866                 break;
867         case 6:
868                 /* GSM Coverage Indicator */
869                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_gci, tvb, ie_offset, 1, FALSE);
870                 break;
871         case 7:
872                 /* UMA Classmark */
873                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_tura, tvb, ie_offset, 1, FALSE);
874                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_gc, tvb, ie_offset, 1, FALSE);
875                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_uc, tvb, ie_offset, 1, FALSE);
876                 /* UMA Protocols (Stage 3) R1.0.3 */
877                 if(ie_len>1){
878                         ie_offset++;
879                         proto_tree_add_item(urr_ie_tree, hf_uma_urr_rrs, tvb, ie_offset, 1, FALSE);
880                 }               break;
881         case 8:
882                 /* Geographical Location
883                  * The Location Estimate field is composed of 1 or more octets with an internal structure
884                  * according to section 7 in [23.032].
885                  */
886                 new_tvb = tvb_new_subset(tvb, ie_offset,ie_len, ie_len );
887                 dissect_geographical_description(new_tvb, pinfo, urr_ie_tree);
888                 break;
889         case 9:
890                 /* UNC SGW IP Address
891                  * IP Address type
892                  */
893                 octet = tvb_get_guint8(tvb,ie_offset);
894                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_IP_Address_type, tvb, ie_offset, 1, FALSE);
895                 ie_offset++;
896                 if ( octet == 0x57 ){ /* IPv6 */
897
898                 }else{ /* All other values shall be interpreted as Ipv4 address in this version of the protocol.*/
899                         sgw_ipv4_address = tvb_get_ipv4(tvb, ie_offset);
900                         proto_tree_add_ipv4(urr_ie_tree, hf_uma_urr_sgw_ipv4, tvb, ie_offset, 4, sgw_ipv4_address);
901
902                 }
903                 break;
904         case 10:                /* UNC SGW Fully Qualified Domain/Host Name */
905                 if ( ie_len > 0){
906                         string = (gchar*)tvb_get_ephemeral_string(tvb, ie_offset, ie_len);
907                         proto_tree_add_string(urr_ie_tree, hf_uma_urr_FQDN, tvb, ie_offset, ie_len, string);
908                 }else{
909                         proto_tree_add_text(urr_ie_tree,tvb,offset,1,"FQDN not present");
910                 }
911                 break;
912         case 11:                /* Redirection Counter */
913                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_redirection_counter, tvb, ie_offset, 1, FALSE);
914                 break;
915         case 12:                /* Discovery Reject Cause */
916                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_dis_rej_cau, tvb, ie_offset, 1, FALSE);
917                 break;
918         case 13:
919                 /* UMA Cell Description
920                  * The rest of the IE is coded as in [TS 44.018], Cell Description IE, not including IEI and length, if present
921                  */
922                 de_rr_cell_dsc(tvb, urr_ie_tree, ie_offset, ie_len, NULL, 0);
923                 break;
924         case 14:
925                 /* UMA Control Channel Description
926                  */
927                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_ECMC, tvb, ie_offset, 1, FALSE);
928                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_NMO, tvb, ie_offset, 1, FALSE);
929                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_GPRS, tvb, ie_offset, 1, FALSE);
930                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_DTM, tvb, ie_offset, 1, FALSE);
931                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_ATT, tvb, ie_offset, 1, FALSE);
932                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_MSCR, tvb, ie_offset, 1, FALSE);
933                 /* T3212 timeout value */
934                 ie_offset++;
935                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_T3212_timer, tvb, ie_offset, 1, FALSE);
936                 /* RAC, Routing Area Code (octet 5) */
937                 ie_offset++;
938                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_RAC, tvb, ie_offset, 1, FALSE);
939                 ie_offset++;
940                 /* SGSNR, SGSN Release (octet 6) */
941                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_SGSNR, tvb, ie_offset, 1, FALSE);
942                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_ECMP, tvb, ie_offset, 1, FALSE);
943                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_RE, tvb, ie_offset, 1, FALSE);
944                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_PFCFM, tvb, ie_offset, 1, FALSE);
945                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_3GECS, tvb, ie_offset, 1, FALSE);
946                 ie_offset++;
947                 proto_tree_add_text(urr_ie_tree,tvb,ie_offset,2,"Access Control Class N");
948                 /* These fields are specified and described in 3GPP TS 44.018 and 3GPP TS 22.011. */
949                 break;
950         case 15:
951                 /* Cell Identifier List
952                  * The rest of the IE is coded as in [TS 48.008], not including IEI and length, if present
953                  */
954                 be_cell_id_list(tvb, urr_ie_tree, ie_offset, ie_len, NULL, 0);
955                 break;
956         case 16:                /* TU3907 Timer */
957                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_TU3907_timer, tvb, ie_offset, 2, FALSE);
958                 break;
959         case 17:                /* GSM RR State */
960                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_GSM_RR_state, tvb, ie_offset, 1, FALSE);
961                 break;
962         case 18:                /* Routing Area Identification */
963                 /* The rest of the IE is coded as in [TS 24.008] not including IEI and length, if present.*/
964                 de_gmm_rai(tvb, urr_ie_tree, ie_offset, ie_len, NULL, 0);
965                 break;
966         case 19:                /* UMA Band */
967                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_UMA_band, tvb, ie_offset, 1, FALSE);
968                 break;
969         case 20:                /* URR State */
970                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_URR_state, tvb, ie_offset, 1, FALSE);
971                 break;
972         case 21:                /* Register Reject Cause */
973                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_register_reject_cause, tvb, ie_offset, 1, FALSE);
974                 break;
975         case 22:                /* TU3906 Timer */
976                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_TU3906_timer, tvb, ie_offset, 2, FALSE);
977                 break;
978         case 23:                /* TU3910 Timer */
979                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_TU3910_timer, tvb, ie_offset, 2, FALSE);
980                 break;
981         case 24:                /* TU3902 Timer */
982                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_TU3902_timer, tvb, ie_offset, 2, FALSE);
983                 break;
984         case 25:
985                 /* Communication Port Identity */
986                 communication_port = tvb_get_ntohs(tvb,ie_offset);
987                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_communication_port, tvb, ie_offset, 2, FALSE);
988                 break;
989
990         case 26:                /* L3 Message */
991                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_L3_protocol_discriminator, tvb, ie_offset, 1, FALSE);
992                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_L3_Message, tvb, ie_offset, ie_len, FALSE);
993                 l3_tvb = tvb_new_subset(tvb, ie_offset,ie_len, ie_len );
994                 if  (!dissector_try_port(bssap_pdu_type_table,BSSAP_PDU_TYPE_DTAP, l3_tvb, pinfo, urr_ie_tree))
995                                 call_dissector(data_handle, l3_tvb, pinfo, urr_ie_tree);
996                 break;
997         case 27:
998                 /* Channel Mode
999                  * The rest of the IE is coded as in [TS 44.018], not including IEI and length, if present
1000                  */
1001                 de_rr_ch_mode(tvb, urr_ie_tree, ie_offset, ie_len, NULL, 0);
1002                 break;
1003         case 28:
1004                 /* Mobile Station Classmark 2
1005                  * The rest of the IE is coded as in [TS 24.008], not including IEI and length, if present
1006                  */
1007                 de_ms_cm_2(tvb, urr_ie_tree, ie_offset, ie_len, NULL, 0);
1008                 break;
1009         case 29:
1010                 /* RR Cause
1011                  * The rest of the IE is coded as in [TS 44.018], not including IEI and length, if present
1012                  */
1013                 de_rr_cause(tvb, urr_ie_tree, ie_offset, 1, NULL, 0);
1014                 break;
1015         case 30:
1016                 /* Cipher Mode Setting
1017                  * Note: The coding of fields SC and algorithm identifier is defined in [44.018]
1018                  * as part of the Cipher Mode Setting IE.
1019                  */
1020                 de_rr_cip_mode_set(tvb, urr_ie_tree, ie_offset, ie_len, NULL, 0);
1021                 break;
1022         case 31:
1023                 /* GPRS Resumption
1024                  * The rest of the IE is coded as in [TS 44.018], not including IEI and length, if present
1025                  */
1026                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_GPRS_resumption, tvb, ie_offset, 1, FALSE);
1027                 break;
1028         case 32:
1029                 /* Handover From UMAN Command
1030                  * If the target RAT is GERAN, the rest of the IE is coded as HANDOVER COMMAND message in [TS 44.018]
1031                  * If the target RAT is UTRAN, the rest of the IE is coded as
1032                  * HANDOVER TO UTRAN COMMAND message in [TS 25.331].
1033                  */
1034                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_L3_protocol_discriminator, tvb, ie_offset, 1, FALSE);
1035                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_L3_Message, tvb, ie_offset, ie_len, FALSE);
1036                 l3_tvb = tvb_new_subset(tvb, ie_offset,ie_len, ie_len );
1037                 if  (!dissector_try_port(bssap_pdu_type_table,BSSAP_PDU_TYPE_DTAP, l3_tvb, pinfo, urr_ie_tree))
1038                                 call_dissector(data_handle, l3_tvb, pinfo, urr_ie_tree);
1039                 break;
1040         case 33:                /* UL Quality Indication */
1041                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_ULQI, tvb, ie_offset, 1, FALSE);
1042                 break;
1043         case 34:
1044                 /* TLLI
1045                  * The rest of the IE is coded as in [TS 44.018], not including IEI and length, if present.
1046                  * [TS 44.018]:10.5.2.41a
1047                  * The TLLI is encoded as a binary number with a length of 4 octets. TLLI is defined in 3GPP TS 23.003
1048                  */
1049                 de_rr_tlli(tvb, urr_ie_tree, ie_offset, ie_len, NULL, 0);
1050                 break;
1051         case 35:
1052                 /* Packet Flow Identifier
1053                  * The rest of the IE is coded as in [TS 24.008], not including IEI and length, if present.
1054                  */
1055                 de_sm_pflow_id(tvb, urr_ie_tree, ie_offset, ie_len, NULL, 0);
1056                 break;
1057         case 36:
1058                 /* Suspension Cause
1059                  * The rest of the IE is coded as in [TS 44.018], not including IEI and length, if present.
1060                  */
1061                 de_rr_sus_cau(tvb, urr_ie_tree, ie_offset, ie_len, NULL, 0);
1062                 break;
1063         case 37:                /* TU3920 Timer */
1064                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_TU3920_timer, tvb, ie_offset, 2, FALSE);
1065                 break;
1066                 /* 11.2.38 QoS */
1067         case 38:
1068                 /* QoS
1069                  * PEAK_THROUGHPUT_CLASS (octet 3, bits 1-4)
1070                  * This field is coded as PEAK_THROUGHPUT_CLASS field in
1071                  * the Channel Request Description information
1072                  * element specified in [TS 44.060]
1073                  */
1074                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_peak_tpt_cls, tvb, ie_offset, 1, FALSE);
1075                 /* RADIO_PRIORITY (octet 3, bits 5-6) */
1076                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_radio_pri, tvb, ie_offset, 1, FALSE);
1077                 /* RLC_MODE (octet 3, bit 7) */
1078                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_rlc_mode, tvb, ie_offset, 1, FALSE);
1079                 break;
1080         case 39:                /* URLC Cause */
1081                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_URLCcause, tvb, ie_offset, 1, FALSE);
1082                 break;
1083         case 40:                /* User Data Rate */
1084                 udr = tvb_get_ntoh24(tvb, ie_offset) * 100;
1085                 proto_tree_add_uint(urr_ie_tree, hf_uma_urr_udr , tvb, ie_offset, 3, udr );
1086                 break;
1087         case 41:
1088                 /* Routing Area Code
1089                  * The rest of the IE is coded as in [TS 23.003] not including IEI and length, if present.
1090                  */
1091                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_RAC, tvb, ie_offset, 1, FALSE);
1092                 break;
1093         case 42:
1094                 /* AP Location
1095                  * The rest of the IE is coded as in [GEOPRIV], not including IEI and length, if present
1096                  * http://www.ietf.org/internet-drafts/draft-ietf-geopriv-dhcp-civil-05.txt
1097                  */
1098                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_ap_location, tvb, ie_offset, ie_len, FALSE);
1099                 break;
1100         case 43:                /* TU4001 Timer */
1101                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_TU4001_timer, tvb, ie_offset, 2, FALSE);
1102                 break;
1103         case 44:                /* Location Status */
1104                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_LS, tvb, ie_offset, 1, FALSE);
1105                 break;
1106         case 45:                /* Cipher Response */
1107                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_cipher_res, tvb, ie_offset, 1, FALSE);
1108                 break;
1109         case 46:                /* Ciphering Command RAND */
1110                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_rand_val, tvb, ie_offset, ie_len, FALSE);
1111                 break;
1112         case 47:                /* Ciphering Command MAC (Message Authentication Code)*/
1113                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_ciphering_command_mac, tvb, ie_offset, ie_len, FALSE);
1114                 break;
1115         case 48:                /* Ciphering Key Sequence Number */
1116                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_ciphering_key_seq_num, tvb, ie_offset, 1, FALSE);
1117                 break;
1118         case 49:                /* SAPI ID */
1119                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_sapi_id, tvb, ie_offset, 1, FALSE);
1120                 break;
1121         case 50:                /* Establishment Cause */
1122                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_establishment_cause, tvb, ie_offset, 1, FALSE);
1123                 break;
1124         case 51:                /* Channel Needed */
1125                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_channel, tvb, ie_offset, 1, FALSE);
1126                 break;
1127         case 52:                /* PDU in Error */
1128                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_PDU_in_error, tvb, ie_offset, ie_len, FALSE);
1129                 break;
1130         case 53:
1131                 /* Sample Size
1132                  */
1133                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_sample_size, tvb, ie_offset, 1, FALSE);
1134                 break;
1135         case 54:
1136                 /* Payload Type
1137                  * Payload Type (octet 3) Allowed values are between 96 and 127.
1138                  */
1139                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_payload_type, tvb, ie_offset, 1, FALSE);
1140                 break;
1141         /* 11.2.55 Multirate Configuration */
1142         case 55:
1143                 /* Multi-rate Configuration
1144                  * The rest of the IE is coded as in [TS 44.018], not including IEI and length, if present
1145                  */
1146                 de_rr_multirate_conf(tvb, urr_ie_tree, ie_offset, ie_len, NULL, 0);
1147                 break;
1148         case 56:
1149                 /* Mobile Station Classmark 3
1150                  * The rest of the IE is coded as in [TS 24.008], not including IEI and length, if present
1151                  */
1152                 break;
1153         case 57:
1154                 /* LLC-PDU
1155                  * The rest of the IE is coded as in [TS 48.018], not including IEI and length, if present
1156                  */
1157                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_LLC_PDU, tvb, ie_offset, ie_len, FALSE);
1158                 llc_tvb = tvb_new_subset(tvb, ie_offset,ie_len, ie_len );
1159                   if (llc_handle) {
1160                           if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
1161                                         col_append_str(pinfo->cinfo, COL_PROTOCOL, "/");
1162                                         col_set_fence(pinfo->cinfo, COL_PROTOCOL);
1163                           }
1164
1165                           call_dissector(llc_handle, llc_tvb, pinfo, urr_ie_tree);
1166                   }else{
1167                           if (data_handle)
1168                                   call_dissector(data_handle, llc_tvb, pinfo, urr_ie_tree);
1169                   }
1170                 break;
1171         case 58:                /* Location Black List indicator */
1172                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_LBLI, tvb, ie_offset, 1, FALSE);
1173                 break;
1174         case 59:                /* Reset Indicator */
1175                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_RI, tvb, ie_offset, 1, FALSE);
1176                 break;
1177         case 60:                /* TU4003 Timer */
1178                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_TU4003_timer, tvb, ie_offset, 2, FALSE);
1179                 break;
1180         case 61:
1181                 /* AP Service Name */
1182                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_ap_service_name_type, tvb, ie_offset, 1, FALSE);
1183                 ie_offset++;
1184                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_ap_Service_name_value, tvb, ie_offset, ie_len -1, FALSE);
1185                 break;
1186         case 62:
1187                 /* UMA Service Zone Information
1188                  * UMA Service Zone Icon Indicator, octet 3
1189                  */
1190                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_uma_service_zone_icon_ind, tvb, ie_offset, 1, FALSE);
1191                 ie_offset++;
1192                 /* Length of UMA Service Zone string */
1193                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_uma_service_zone_str_len, tvb, ie_offset, 1, FALSE);
1194                 str_len = tvb_get_guint8(tvb,ie_offset);
1195                 ie_offset++;
1196                 /* UMA Service Zone string, 1st character */
1197                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_uma_service_zone_str, tvb, ie_offset, str_len, FALSE);
1198                 break;
1199         /* 11.2.63 RTP Redundancy Configuration */
1200         case 63:
1201                 /* RTP Redundancy Configuration */
1202                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_window_size, tvb, ie_offset, 1, FALSE);
1203                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_uma_codec_mode, tvb, ie_offset, 1, FALSE);
1204                 break;
1205         case 64:
1206                 /* UTRAN Classmark
1207                  * The rest of the IE is the INTER RAT HANDOVER INFO coded as in
1208                  * [TS 25.331], not including IEI and length, if present
1209                  */
1210                 break;
1211         case 65:
1212                 /* Classmark Enquiry Mask
1213                  * The rest of the IE is the Classmark Enquiry Mask coded as in [TS 44.018], not including IEI and length, if present
1214                  */
1215                 de_rr_cm_enq_mask(tvb, urr_ie_tree, offset, ie_len, NULL, 0);
1216                 break;
1217         case 66:
1218                 /* UTRAN Cell Identifier List
1219                  * UTRAN Cell Identification Discriminator
1220                  */
1221                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_UTRAN_cell_id_disc, tvb, ie_offset, 1, FALSE);
1222                 octet = tvb_get_guint8(tvb,ie_offset);
1223                 ie_offset++;
1224                 if ( octet == 0 ){
1225                         ie_offset = dissect_e212_mcc_mnc(tvb, urr_ie_tree, ie_offset);
1226                         proto_tree_add_item(urr_ie_tree, hf_uma_urr_lac, tvb, ie_offset, 2, FALSE);
1227                         ie_offset = ie_offset + 2;
1228                         /* The octets 9-12 are coded as shown in 3GPP TS 25.331, Table 'Cell identity'.
1229                          * 10.3.2.2 Cell identity
1230                          * This information element identifies a cell unambiguously within a PLMN.
1231                          * NOTE: This information element may carry any implementation dependent identity that unambiguously identifies a
1232                          * cell within a PLMN.
1233                          * Cell identity - bit string(28)
1234                          */
1235                 }
1236                 break;
1237         case 67:
1238                 /* Serving UNC table indicator */
1239                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_suti, tvb, ie_offset, 1, FALSE);
1240                 break;
1241         case 68:
1242                 /* Registration indicators */
1243                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_uma_mps, tvb, ie_offset, 1, FALSE);
1244                 break;
1245         case 69:
1246                 /* UMA PLMN List */
1247                 octet = tvb_get_guint8(tvb,ie_offset);
1248                 proto_tree_add_uint(urr_ie_tree, hf_uma_urr_num_of_plms , tvb, ie_offset, 1, octet);
1249                 /* TODO insert while loop here */
1250                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_lac, tvb, ie_offset, 2, FALSE);
1251                 break;
1252         /* 11.2.70 Received Signal Level List */
1253         case 70:
1254                 /* Received Signal Level List */
1255                 while(ie_offset<=(offset + ie_len)){
1256                         proto_tree_add_item(urr_ie_tree, hf_uma_urr_RXLEV_NCELL, tvb, ie_offset, 1, FALSE);
1257                         ie_offset++;
1258                 }
1259                 break;
1260         /* 11.2.71 Required UMA Services */
1261         case 71:
1262                 /* CBS Cell Broadcast Service (octet 3) */
1263                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_cbs, tvb, ie_offset, 1, FALSE);
1264                 break;
1265         /* 11.2.72 Broadcast Container */
1266         case 72:
1267                 octet = tvb_get_guint8(tvb,ie_offset);
1268                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_num_of_cbs_frms , tvb, ie_offset, 1, FALSE);
1269                 proto_tree_add_text(urr_ie_tree, tvb, ie_offset + 1, ie_len-1,"CBS Frames - Not decoded");
1270                 break;
1271         /* 11.2.73 3G Cell Identity */
1272         case 73:
1273                 /* The rest of the IE is coded as in [TS 25.331] not including IEI and length, if present. */
1274                 break;
1275         case 96:                /* MS Radio Identity */
1276                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_radio_type_of_id, tvb, ie_offset, 1, FALSE);
1277                 octet = tvb_get_guint8(tvb,ie_offset);
1278                 if (( octet & 0xf) == 0){ /* IEEE MAC-address format */
1279                         ie_offset++;
1280                         haddr = tvb_get_ptr(tvb, ie_offset, ie_len);
1281                         proto_tree_add_ether(urr_ie_tree, hf_uma_urr_ms_radio_id, tvb, ie_offset, ie_len, haddr);
1282                 }else{
1283                         proto_tree_add_text(urr_ie_tree, tvb, ie_offset, ie_len,"Unknown format");
1284                 }
1285                 break;
1286
1287         case 97:
1288                 /* UNC IP Address
1289                  * IP Address type
1290                  */
1291                 octet = tvb_get_guint8(tvb,ie_offset);
1292                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_IP_Address_type, tvb, ie_offset, 1, FALSE);
1293                 if (ie_len > 4 )
1294                 ie_offset++;
1295                 if ( octet == 0x57 ){ /* IPv6 */
1296
1297                 }else{ /* All other values shall be interpreted as Ipv4 address in this version of the protocol.*/
1298                         unc_ipv4_address = tvb_get_ipv4(tvb, ie_offset);
1299                         proto_tree_add_ipv4(urr_ie_tree, hf_uma_urr_unc_ipv4, tvb, ie_offset, 4, unc_ipv4_address);
1300                 }
1301                 break;
1302         case 98:                /* UNC Fully Qualified Domain/Host Name */
1303                 if ( ie_len > 0){
1304                         string = (gchar*)tvb_get_ephemeral_string(tvb, ie_offset, ie_len);
1305                         proto_tree_add_string(urr_ie_tree, hf_uma_unc_FQDN, tvb, ie_offset, ie_len, string);
1306                 }else{
1307                         proto_tree_add_text(urr_ie_tree,tvb,offset,1,"UNC FQDN not present");
1308                 }
1309                 break;
1310         case 99:
1311                 /* IP address for GPRS user data transport
1312                  * IP Address type
1313                  */
1314                 octet = tvb_get_guint8(tvb,ie_offset);
1315                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_IP_Address_type, tvb, ie_offset, 1, FALSE);
1316                 ie_offset++;
1317                 if ( octet == 0x57 ){ /* IPv6 */
1318
1319                 }else{ /* All other values shall be interpreted as Ipv4 address in this version of the protocol.*/
1320                         GPRS_user_data_ipv4_address = tvb_get_ipv4(tvb, ie_offset);
1321                         proto_tree_add_ipv4(urr_ie_tree, hf_uma_urr_GPRS_user_data_transport_ipv4, tvb, ie_offset, 4, GPRS_user_data_ipv4_address);
1322
1323                 }
1324                 break;
1325         case 100:               /* UDP Port for GPRS user data transport */
1326                 GPRS_user_data_transport_UDP_port = tvb_get_ntohs(tvb,ie_offset);
1327                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_GPRS_port, tvb, ie_offset, 2, FALSE);
1328                 /*
1329                  * If this isn't the first time this packet has been processed,
1330                  * we've already done this work, so we don't need to do it
1331                  * again.
1332                  */
1333                 if (pinfo->fd->flags.visited)
1334                 {
1335                         break;
1336                 }
1337                 SET_ADDRESS(&null_addr, AT_NONE, 0, NULL);
1338
1339                 dst_addr.type=AT_IPv4;
1340                 dst_addr.len=4;
1341                 dst_addr.data=(guint8 *)&GPRS_user_data_ipv4_address;
1342
1343                 conversation = find_conversation(pinfo->fd->num,&dst_addr,
1344                         &null_addr, PT_UDP, GPRS_user_data_transport_UDP_port,
1345                         0, NO_ADDR_B|NO_PORT_B);
1346
1347                 if (conversation == NULL) {
1348                         /* It's not part of any conversation - create a new one. */
1349                         conversation = conversation_new(pinfo->fd->num, &dst_addr,
1350                             &null_addr, PT_UDP,GPRS_user_data_transport_UDP_port ,
1351                             0, NO_ADDR2|NO_PORT2);
1352
1353                 /* Set dissector */
1354                 conversation_set_dissector(conversation, uma_udp_handle);
1355                 }
1356
1357                 break;
1358         case 103:               /* UNC TCP port */
1359                 UNC_tcp_port = tvb_get_ntohs(tvb,ie_offset);
1360                 proto_tree_add_uint(urr_ie_tree, hf_uma_urr_UNC_tcp_port , tvb, ie_offset, 2, UNC_tcp_port);
1361
1362                 /*
1363                  * If this isn't the first time this packet has been processed,
1364                  * we've already done this work, so we don't need to do it
1365                  * again.
1366                  */
1367                 if (pinfo->fd->flags.visited)
1368                 {
1369                         break;
1370                 }
1371                 SET_ADDRESS(&null_addr, AT_NONE, 0, NULL);
1372
1373                 dst_addr.type=AT_IPv4;
1374                 dst_addr.len=4;
1375                 dst_addr.data=(guint8 *)&unc_ipv4_address;
1376
1377                 conversation = find_conversation(pinfo->fd->num,&dst_addr,
1378                         &null_addr, PT_TCP, UNC_tcp_port,
1379                         0, NO_ADDR_B|NO_PORT_B);
1380
1381                 if (conversation == NULL) {
1382                         /* It's not part of any conversation - create a new one. */
1383                         conversation = conversation_new(pinfo->fd->num, &dst_addr,
1384                             &null_addr, PT_TCP,UNC_tcp_port ,
1385                             0, NO_ADDR2|NO_PORT2);
1386                         /* Set dissector */
1387                         conversation_set_dissector(conversation, uma_tcp_handle);
1388                 }
1389
1390                 break;
1391         case 104:               /* RTP UDP port */
1392                 RTP_UDP_port = tvb_get_ntohs(tvb,ie_offset);
1393                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_RTP_port, tvb, ie_offset, 2, FALSE);
1394                 /* TODO find out exactly which element contains IP addr */
1395                 /* Debug
1396                 proto_tree_add_text(urr_ie_tree,tvb,ie_offset,ie_len,"IP %u, Port %u Handle %u",
1397                         rtp_ipv4_address,RTP_UDP_port,rtp_handle);
1398                         */
1399                 if(unc_ipv4_address!=0){
1400                         src_addr.type=AT_IPv4;
1401                         src_addr.len=4;
1402                         src_addr.data=(guint8 *)&unc_ipv4_address;
1403                 }else{
1404                         /* Set Source IP = own IP */
1405                         src_addr = pinfo->src;
1406                 }
1407                 if((!pinfo->fd->flags.visited) && RTP_UDP_port!=0 && rtp_handle){
1408
1409                         rtp_add_address(pinfo, &src_addr, RTP_UDP_port, 0, "UMA", pinfo->fd->num, 0);
1410                         if ((RTP_UDP_port & 0x1) == 0){ /* Even number RTP port RTCP should follow on odd number */
1411                                 RTCP_UDP_port = RTP_UDP_port + 1;
1412                                 rtcp_add_address(pinfo, &src_addr, RTCP_UDP_port, 0, "UMA", pinfo->fd->num);
1413                         }
1414                 }
1415                 break;
1416         case 105:               /* RTCP UDP port */
1417                 RTCP_UDP_port = tvb_get_ntohs(tvb,ie_offset);
1418                 proto_tree_add_item(urr_ie_tree, hf_uma_urr_RTCP_port, tvb, ie_offset, 2, FALSE);
1419                 /* TODO find out exactly which element contains IP addr */
1420                 if((!pinfo->fd->flags.visited) && rtcp_ipv4_address!=0 && RTCP_UDP_port!=0 && rtcp_handle){
1421                         src_addr.type=AT_IPv4;
1422                         src_addr.len=4;
1423                         src_addr.data=(guint8 *)&rtcp_ipv4_address;
1424
1425                         rtcp_add_address(pinfo, &src_addr, RTCP_UDP_port, 0, "UMA", pinfo->fd->num);
1426                 }
1427                 break;
1428         case 106:
1429                 /* 11.2.70 GERAN Received Signal Level List */
1430                 while(ie_offset<=(offset + ie_len)){
1431                         proto_tree_add_item(urr_ie_tree, hf_uma_urr_RXLEV_NCELL, tvb, ie_offset, 1, FALSE);
1432                         ie_offset++;
1433                 }
1434                 break;
1435         case 107:
1436                 /* 11.2.70 UTRAN Received Signal Level List */
1437                 while(ie_offset<=(offset + ie_len)){
1438                         proto_tree_add_item(urr_ie_tree, hf_uma_urr_RXLEV_NCELL, tvb, ie_offset, 1, FALSE);
1439                         ie_offset++;
1440                 }
1441                 break;
1442         default:
1443                 proto_tree_add_text(urr_ie_tree,tvb,ie_offset,ie_len,"DATA");
1444                 break;
1445         }
1446         offset = offset + ie_len;
1447         return offset;
1448 }
1449
1450
1451
1452 static void
1453 dissect_uma(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1454 {
1455         int             offset = 0;
1456         guint8  octet, pd;
1457         guint16 msg_len;
1458
1459 /* Set up structures needed to add the protocol subtree and manage it */
1460         proto_item *ti;
1461         proto_tree *uma_tree;
1462
1463 /* Make entries in Protocol column and Info column on summary display */
1464         if (check_col(pinfo->cinfo, COL_PROTOCOL))
1465                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "UMA");
1466         if (check_col(pinfo->cinfo, COL_INFO))
1467                 col_clear(pinfo->cinfo, COL_INFO);
1468
1469         ti = proto_tree_add_item(tree, proto_uma, tvb, 0, -1, FALSE);
1470         uma_tree = proto_item_add_subtree(ti, ett_uma);
1471
1472 /* add an item to the subtree, see section 1.6 for more information */
1473         msg_len = tvb_get_ntohs(tvb,offset);
1474         proto_tree_add_item(uma_tree, hf_uma_length_indicator, tvb, offset, 2, FALSE);
1475         offset = offset + 2;
1476         octet = tvb_get_guint8(tvb,offset);
1477         pd = octet & 0x0f;
1478         proto_tree_add_item(uma_tree, hf_uma_skip_ind, tvb, offset, 1, FALSE);
1479         if ((octet & 0xf0) != 0 ){
1480                 proto_tree_add_text(uma_tree, tvb,offset,-1,"Skip this message");
1481                 return;
1482         }
1483
1484         proto_tree_add_item(uma_tree, hf_uma_pd, tvb, offset, 1, FALSE);
1485         switch  ( pd ){
1486         case 0: /* URR_C */
1487         case 1: /* URR */
1488                 offset++;
1489                 octet = tvb_get_guint8(tvb,offset);
1490                 proto_tree_add_item(uma_tree, hf_uma_urr_msg_type, tvb, offset, 1, FALSE);
1491                 if (check_col(pinfo->cinfo, COL_INFO))
1492                         col_add_str(pinfo->cinfo, COL_INFO, val_to_str(octet, uma_urr_msg_type_vals, "Unknown URR (%u)"));
1493                 while ((msg_len + 1) > offset ){
1494                         offset++;
1495                         offset = dissect_uma_IE(tvb, pinfo, uma_tree, offset);
1496                 }
1497                 break;
1498         case 2: /* URLC */
1499                 offset++;
1500                 octet = tvb_get_guint8(tvb,offset);
1501                 proto_tree_add_item(uma_tree, hf_uma_urlc_msg_type, tvb, offset, 1, FALSE);
1502                 if (check_col(pinfo->cinfo, COL_INFO)){
1503                         col_add_str(pinfo->cinfo, COL_INFO, val_to_str(octet, uma_urlc_msg_type_vals, "Unknown URLC (%u)"));
1504                         col_set_fence(pinfo->cinfo,COL_INFO);
1505                 }
1506                 offset++;
1507                 proto_tree_add_item(uma_tree, hf_uma_urlc_TLLI, tvb, offset, 4, FALSE);
1508                 offset = offset + 3;
1509                 while ((msg_len + 1) > offset ){
1510                         offset++;
1511                         offset = dissect_uma_IE(tvb, pinfo, uma_tree, offset);
1512                 }
1513                 break;
1514         default:
1515                 proto_tree_add_text(uma_tree, tvb,offset,-1,"Unknown protocol %u",pd);
1516                 break;
1517         }
1518 }
1519
1520 static guint
1521 get_uma_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
1522 {
1523         /* PDU length = Message length + length of length indicator */
1524         return tvb_get_ntohs(tvb,offset)+2;
1525 }
1526
1527 static void
1528 dissect_uma_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1529 {
1530         tcp_dissect_pdus(tvb, pinfo, tree, uma_desegment, UMA_HEADER_SIZE,
1531             get_uma_pdu_len, dissect_uma);
1532 }
1533
1534 static int
1535 dissect_uma_urlc_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1536 {
1537
1538         int             offset = 0;
1539         guint8  octet;
1540         guint16 msg_len;
1541
1542 /* Set up structures needed to add the protocol subtree and manage it */
1543         proto_item *ti;
1544         proto_tree *uma_tree;
1545
1546 /* Make entries in Protocol column and Info column on summary display */
1547         if (check_col(pinfo->cinfo, COL_PROTOCOL))
1548                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "UMA");
1549         if (check_col(pinfo->cinfo, COL_INFO))
1550                 col_clear(pinfo->cinfo, COL_INFO);
1551
1552         ti = proto_tree_add_item(tree, proto_uma, tvb, 0, -1, FALSE);
1553         uma_tree = proto_item_add_subtree(ti, ett_uma);
1554
1555         octet = tvb_get_guint8(tvb,offset);
1556         proto_tree_add_item(uma_tree, hf_uma_urlc_msg_type, tvb, offset, 1, FALSE);
1557         if (check_col(pinfo->cinfo, COL_INFO)){
1558                 col_add_fstr(pinfo->cinfo, COL_INFO, "%s ",val_to_str(octet, uma_urlc_msg_type_vals, "Unknown URLC (%u)"));
1559                 col_set_fence(pinfo->cinfo,COL_INFO);
1560         }
1561         msg_len = tvb_length_remaining(tvb,offset) - 1;
1562
1563         switch  ( octet ){
1564
1565         case 2: /* RLC UNITDATA */
1566         case 6: /* URLC-UFC-REQ */
1567         case 7: /* URLC-DFC-REQ only allowed message types*/
1568                 offset++;
1569                 proto_tree_add_item(uma_tree, hf_uma_urlc_TLLI, tvb, offset, 4, FALSE);
1570                 offset = offset + 4;
1571                 proto_tree_add_item(uma_tree, hf_uma_urlc_seq_nr, tvb, offset, 2, FALSE);
1572                 offset++;
1573                 while (msg_len > offset){
1574                         offset++;
1575                         offset = dissect_uma_IE(tvb, pinfo, uma_tree, offset);
1576                 }
1577                 return offset;
1578         default:
1579                 proto_tree_add_text(uma_tree, tvb,offset,-1,"Wrong message type %u",octet);
1580                 return tvb_length(tvb);
1581
1582         }
1583
1584 }
1585
1586 static void
1587 range_delete_callback(guint32 port)
1588 {
1589     dissector_delete("tcp.port", port, uma_tcp_handle);
1590 }
1591
1592 static void
1593 range_add_callback(guint32 port)
1594 {
1595     dissector_add("tcp.port", port, uma_tcp_handle);
1596 }
1597
1598 /* Register the protocol with Wireshark */
1599 /* If this dissector uses sub-dissector registration add a registration routine.
1600    This format is required because a script is used to find these routines and
1601    create the code that calls these routines.
1602 */
1603 void
1604 proto_reg_handoff_uma(void)
1605 {
1606         static int Initialized=FALSE;
1607
1608         if (!Initialized) {
1609                 uma_tcp_handle = create_dissector_handle(dissect_uma_tcp, proto_uma);
1610                 uma_udp_handle = new_create_dissector_handle(dissect_uma_urlc_udp, proto_uma);
1611                 dissector_add("udp.port", 0, uma_udp_handle);
1612                 Initialized=TRUE;
1613         } else {
1614                 range_foreach(uma_tcp_port_range, range_delete_callback);
1615         }
1616
1617         g_free(uma_tcp_port_range);
1618         uma_tcp_port_range = range_copy(global_uma_tcp_port_range);
1619
1620         range_foreach(uma_tcp_port_range, range_add_callback);
1621
1622         data_handle = find_dissector("data");
1623         rtp_handle = find_dissector("rtp");
1624         rtcp_handle = find_dissector("rtcp");
1625         llc_handle = find_dissector("llcgprs");
1626
1627
1628 }
1629
1630 /* this format is require because a script is used to build the C function
1631    that calls all the protocol registration.
1632 */
1633
1634 void
1635 proto_register_uma(void)
1636 {
1637
1638         module_t *uma_module;
1639
1640 /* Setup list of header fields  See Section 1.6.1 for details*/
1641         static hf_register_info hf[] = {
1642                 { &hf_uma_length_indicator,
1643                         { "Length Indicator","uma.li",
1644                         FT_UINT16, BASE_DEC, NULL, 0x0,
1645                         "Length Indicator", HFILL }
1646                 },
1647                 { &hf_uma_pd,
1648                         { "Protocol Discriminator","uma.pd",
1649                         FT_UINT8, BASE_DEC, VALS(uma_pd_vals), 0x0f,
1650                         "Protocol Discriminator", HFILL }
1651                 },
1652                 { &hf_uma_skip_ind,
1653                         { "Skip Indicator",           "uma.skip.ind",
1654                         FT_UINT8, BASE_DEC, NULL, 0xf0,
1655                         "Skip Indicator", HFILL }
1656                 },
1657                 { &hf_uma_urr_msg_type,
1658                         { "URR Message Type", "uma.urr.msg.type",
1659                         FT_UINT16, BASE_DEC, VALS(uma_urr_msg_type_vals), 0x0,
1660                         "URR Message Type", HFILL }
1661                 },
1662                 { &hf_uma_urlc_msg_type,
1663                         { "URLC Message Type", "uma.urlc.msg.type",
1664                         FT_UINT8, BASE_DEC, VALS(uma_urlc_msg_type_vals), 0x0,
1665                         "URLC Message Type", HFILL }
1666                 },
1667                 { &hf_uma_urlc_TLLI,
1668                         { "Temporary Logical Link Identifier","uma.urlc.tlli",
1669                         FT_BYTES,BASE_DEC,  NULL, 0x0,
1670                         "Temporary Logical Link Identifier", HFILL }
1671                 },
1672                 { &hf_uma_urlc_seq_nr,
1673                         { "Sequence Number","uma.urlc.seq.nr",
1674                         FT_BYTES,BASE_DEC,  NULL, 0x0,
1675                         "Sequence Number", HFILL }
1676                 },
1677                 { &hf_uma_urr_IE,
1678                         { "URR Information Element","uma.urr.ie.type",
1679                         FT_UINT8, BASE_DEC, VALS(uma_urr_IE_type_vals), 0x0,
1680                         "URR Information Element", HFILL }
1681                 },
1682                 { &hf_uma_urr_IE_len,
1683                         { "URR Information Element length","uma.urr.ie.len",
1684                         FT_UINT16, BASE_DEC, NULL, 0x0,
1685                         "URR Information Element length", HFILL }
1686                 },
1687                 { &hf_uma_urr_mobile_identity_type,
1688                         { "Mobile Identity Type","uma.urr.ie.mobileid.type",
1689                         FT_UINT8, BASE_DEC, VALS(uma_urr_mobile_identity_type_vals), 0x07,
1690                         "Mobile Identity Type", HFILL }
1691                 },
1692                 { &hf_uma_urr_odde_even_ind,
1693                         { "Odd/even indication","uma.urr.oddevenind",
1694                         FT_UINT8, BASE_DEC, uma_urr_oddevenind_vals, 0x08,
1695                         "Mobile Identity", HFILL }
1696                 },
1697                 { &hf_uma_urr_imsi,
1698                         { "IMSI", "uma_urr.imsi",
1699                         FT_STRING, BASE_NONE, NULL, 0,
1700                         "IMSI", HFILL }
1701                 },
1702                 { &hf_uma_urr_imei,
1703                         { "IMEI", "uma_urr.imei",
1704                         FT_STRING, BASE_NONE, NULL, 0,
1705                         "IMEI", HFILL }
1706                 },
1707                 { &hf_uma_urr_imeisv,
1708                         { "IMEISV", "uma_urr.imeisv",
1709                         FT_STRING, BASE_NONE, NULL, 0,
1710                         "IMEISV", HFILL }
1711                 },
1712                 { &hf_uma_urr_tmsi_p_tmsi,
1713                         { "TMSI/P-TMSI", "uma_urr.tmsi_p_tmsi",
1714                         FT_STRING, BASE_NONE, NULL, 0,
1715                         "TMSI/P-TMSI", HFILL }
1716                 },
1717                 { &hf_uma_urr_uri,
1718                         { "UMA Release Indicator (URI)","uma.urr.uri",
1719                         FT_UINT8, BASE_DEC, NULL, 0x07,
1720                         "URI", HFILL }
1721                 },
1722                 { &hf_uma_urr_radio_type_of_id,
1723                         { "Type of identity","uma.urr.radio_type_of_id",
1724                         FT_UINT8, BASE_DEC, VALS(radio_type_of_id_vals), 0x0f,
1725                         "Type of identity", HFILL }
1726                 },
1727                 { &hf_uma_urr_radio_id,
1728                         { "Radio Identity","uma.urr.radio_id",
1729                         FT_ETHER, BASE_DEC, NULL, 0x00,
1730                         "Radio Identity", HFILL }
1731                 },
1732
1733                 { &hf_uma_urr_cell_id,
1734                         { "Cell Identity","uma.urr.cell_id",
1735                         FT_UINT16, BASE_DEC, NULL, 0x00,
1736                         "Cell Identity", HFILL }
1737                 },
1738
1739                 { &hf_uma_urr_mcc,
1740                         { "Mobile Country Code","uma.urr.mcc",
1741                         FT_UINT16, BASE_DEC, NULL, 0x0,
1742                         "Mobile Country Code", HFILL }
1743                 },
1744                 { &hf_uma_urr_mnc,
1745                         { "Mobile network code","uma.urr.mnc",
1746                         FT_UINT16, BASE_DEC, NULL, 0x0,
1747                         "Mobile network code ", HFILL }
1748                 },
1749                 { &hf_uma_urr_lac,
1750                         { "Location area code","uma.urr.lac",
1751                         FT_UINT16, BASE_DEC, NULL, 0x0,
1752                         "Location area code", HFILL }
1753                 },
1754                 { &hf_uma_urr_gci,
1755                         { "GCI, GSM Coverage Indicator","uma.urr.gci",
1756                         FT_UINT8, BASE_DEC,  VALS(gci_vals), 0x0,
1757                         "GCI, GSM Coverage Indicator", HFILL }
1758                 },
1759                 { &hf_uma_urr_tura,
1760                         { "TURA, Type of Unlicensed Radio","uma.urr.tura",
1761                         FT_UINT8,BASE_DEC,  VALS(tura_vals), 0xf,
1762                         "TURA, Type of Unlicensed Radio", HFILL }
1763                 },
1764                 { &hf_uma_urr_gc,
1765                         { "GC, GERAN Capable","uma.urr.gc",
1766                         FT_UINT8,BASE_DEC,  VALS(gc_vals), 0x10,
1767                         "GC, GERAN Capable", HFILL }
1768                 },
1769                 { &hf_uma_urr_uc,
1770                         { "UC, UTRAN Capable","uma.urr.uc",
1771                         FT_UINT8,BASE_DEC,  VALS(uc_vals), 0x20,
1772                         "GC, GERAN Capable", HFILL }
1773                 },
1774                 { &hf_uma_urr_rrs,
1775                         { "RTP Redundancy Support(RRS)","uma.urr.rrs",
1776                         FT_UINT8,BASE_DEC, VALS(rrs_vals), 0x01,
1777                         "RTP Redundancy Support(RRS)", HFILL }
1778                 },
1779                 { &hf_uma_urr_IP_Address_type,
1780                         { "IP address type number value","uma.urr.ip_type",
1781                         FT_UINT8,BASE_DEC,  VALS(IP_address_type_vals), 0x0,
1782                         "IP address type number value", HFILL }
1783                 },
1784                 { &hf_uma_urr_FQDN,
1785                        { "Fully Qualified Domain/Host Name (FQDN)", "uma.urr.fqdn",
1786                        FT_STRING, BASE_NONE,NULL,0x0,
1787                         "Fully Qualified Domain/Host Name (FQDN)", HFILL }
1788                 },
1789                 { &hf_uma_urr_sgw_ipv4,
1790                         { "SGW IPv4 address","uma.urr.sgwipv4",
1791                         FT_IPv4,BASE_NONE,  NULL, 0x0,
1792                         "SGW IPv4 address", HFILL }
1793                 },
1794                 { &hf_uma_urr_redirection_counter,
1795                         { "Redirection Counter","uma.urr.redirection_counter",
1796                         FT_UINT8,BASE_DEC,  NULL, 0x0,
1797                         "Redirection Counter", HFILL }
1798                 },
1799                 { &hf_uma_urr_dis_rej_cau,
1800                         { "Discovery Reject Cause","uma.urr.is_rej_cau",
1801                         FT_UINT8,BASE_DEC,  VALS(discovery_reject_cause_vals), 0x0,
1802                         "Discovery Reject Cause", HFILL }
1803                 },
1804                 { &hf_uma_urr_ECMC,
1805                         { "ECMC, Early Classmark Sending Control","uma.urr.is_rej_cau",
1806                         FT_UINT8,BASE_DEC,  VALS(ECMC_vals), 0x2,
1807                         "ECMC, Early Classmark Sending Control", HFILL }
1808                 },
1809                 { &hf_uma_urr_NMO,
1810                         { "NMO, Network Mode of Operation","uma.urr.NMO",
1811                         FT_UINT8,BASE_DEC,  VALS(NMO_vals), 0xc,
1812                         "NMO, Network Mode of Operation", HFILL }
1813                 },
1814                 { &hf_uma_urr_GPRS,
1815                         { "GPRS, GPRS Availability","uma.urr.is_rej_cau",
1816                         FT_UINT8,BASE_DEC,  VALS(GPRS_avail_vals), 0x10,
1817                         "GPRS, GPRS Availability", HFILL }
1818                 },
1819                 { &hf_uma_urr_DTM,
1820                         { "DTM, Dual Transfer Mode of Operation by network","uma.urr.dtm",
1821                         FT_UINT8,BASE_DEC,  VALS(DTM_vals), 0x20,
1822                         "DTM, Dual Transfer Mode of Operation by network", HFILL }
1823                 },
1824                 { &hf_uma_urr_ATT,
1825                         { "ATT, Attach-detach allowed","uma.urr.att",
1826                         FT_UINT8,BASE_DEC,  VALS(ATT_vals), 0x40,
1827                         "ATT, Attach-detach allowed", HFILL }
1828                 },
1829                 { &hf_uma_urr_MSCR,
1830                         { "MSCR, MSC Release","uma.urr.mscr",
1831                         FT_UINT8,BASE_DEC,  VALS(MSCR_vals), 0x80,
1832                         "MSCR, MSC Release", HFILL }
1833                 },
1834                 { &hf_uma_urr_T3212_timer,
1835                         { "T3212 Timer value(seconds)","uma.urr.t3212",
1836                         FT_UINT8,BASE_DEC,  NULL, 0x0,
1837                         "T3212 Timer value(seconds)", HFILL }
1838                 },
1839                 { &hf_uma_urr_RAC,
1840                         { "Routing Area Code","uma.urr.rac",
1841                         FT_UINT8,BASE_DEC,  NULL, 0x0,
1842                         "Routing Area Code", HFILL }
1843                 },
1844                 { &hf_uma_urr_ap_location,
1845                         { "AP Location","uma.urr.ap_location",
1846                         FT_BYTES,BASE_HEX,  NULL, 0x0,
1847                         "AP Location", HFILL }
1848                 },
1849                 { &hf_uma_urr_SGSNR,
1850                         { "SGSN Release","uma.urr.SGSNR",
1851                         FT_UINT8,BASE_DEC,  VALS(SGSNR_vals), 0x01,
1852                         "SGSN Release", HFILL }
1853                 },
1854                 { &hf_uma_urr_ECMP,
1855                         { "ECMP, Emergency Call Mode Preference","uma.urr.ECMP",
1856                         FT_UINT8,BASE_DEC,  VALS(ECMP_vals), 0x02,
1857                         "ECMP, Emergency Call Mode Preference", HFILL }
1858                 },
1859                 { &hf_uma_urr_RE,
1860                         { "RE, Call reestablishment allowed","uma.urr.RE",
1861                         FT_UINT8,BASE_DEC,  VALS(RE_vals), 0x04,
1862                         "RE, Call reestablishment allowed", HFILL }
1863                 },
1864                 { &hf_uma_urr_PFCFM,
1865                         { "PFCFM, PFC_FEATURE_MODE","uma.urr.PFCFM",
1866                         FT_UINT8,BASE_DEC,  VALS(PFCFM_vals), 0x08,
1867                         "PFCFM, PFC_FEATURE_MODE", HFILL }
1868                 },
1869                 { &hf_uma_urr_3GECS,
1870                         { "3GECS, 3G Early Classmark Sending Restriction","uma.urr.3GECS",
1871                         FT_UINT8,BASE_DEC,  VALS(Three_GECS_vals), 0x10,
1872                         "3GECS, 3G Early Classmark Sending Restriction", HFILL }
1873                 },
1874                 { &hf_uma_urr_bcc,
1875                         { "BCC","uma.urr.bcc",
1876                         FT_UINT8,BASE_DEC,  NULL, 0x07,
1877                         "BCC", HFILL }
1878                 },
1879                 { &hf_uma_urr_ncc,
1880                         { "NCC","uma.urr.ncc",
1881                         FT_UINT8,BASE_DEC,  NULL, 0x38,
1882                         "NCC", HFILL }
1883                 },
1884                 { &hf_uma_urr_TU3907_timer,
1885                         { "TU3907 Timer value(seconds)","uma.urr.tu3907",
1886                         FT_UINT16,BASE_DEC,  NULL, 0x0,
1887                         "TU3907 Timer value(seconds)", HFILL }
1888                 },
1889                 { &hf_uma_urr_GSM_RR_state,
1890                         { "GSM RR State value","uma.urr.gsmrrstate",
1891                         FT_UINT8,BASE_DEC,  VALS(GRS_GSM_RR_State_vals), 0x7,
1892                         "GSM RR State value", HFILL }
1893                 },
1894                 { &hf_uma_urr_UMA_band,
1895                         { "UMA Band","uma.urr.umaband",
1896                         FT_UINT8,BASE_DEC,  VALS(UMA_band_vals), 0x0f,
1897                         "UMA Band", HFILL }
1898                 },
1899                 { &hf_uma_urr_URR_state,
1900                         { "URR State","uma.urr.state",
1901                         FT_UINT8,BASE_DEC,  VALS(URR_state_vals), 0x03,
1902                         "URR State", HFILL }
1903                 },
1904                 { &hf_uma_urr_register_reject_cause,
1905                         { "Register Reject Cause","uma.urr.state",
1906                         FT_UINT8,BASE_DEC,  VALS(register_reject_cause_vals), 0x0,
1907                         "Register Reject Cause", HFILL }
1908                 },
1909                 { &hf_uma_urr_TU3906_timer,
1910                         { "TU3907 Timer value(seconds)","uma.urr.tu3906",
1911                         FT_UINT16,BASE_DEC,  NULL, 0x0,
1912                         "TU3906 Timer value(seconds)", HFILL }
1913                 },
1914                 { &hf_uma_urr_TU3910_timer,
1915                         { "TU3907 Timer value(seconds)","uma.urr.tu3910",
1916                         FT_UINT16,BASE_DEC,  NULL, 0x0,
1917                         "TU3910 Timer value(seconds)", HFILL }
1918                 },
1919                 { &hf_uma_urr_TU3902_timer,
1920                         { "TU3902 Timer value(seconds)","uma.urr.tu3902",
1921                         FT_UINT16,BASE_DEC,  NULL, 0x0,
1922                         "TU3902 Timer value(seconds)", HFILL }
1923                 },
1924                 { &hf_uma_urr_communication_port,
1925                         { "Communication Port","uma.urr.communication_port",
1926                         FT_UINT16,BASE_DEC,  NULL, 0x0,
1927                         "Communication Portt", HFILL }
1928                 },
1929                 { &hf_uma_urr_L3_Message,
1930                         { "L3 message contents","uma.urr.l3",
1931                         FT_BYTES,BASE_HEX,  NULL, 0x0,
1932                         "L3 message contents", HFILL }
1933                 },
1934                 { &hf_uma_urr_L3_protocol_discriminator,
1935                         { "Protocol discriminator","uma.urr.L3_protocol_discriminator",
1936                         FT_UINT8,BASE_DEC,  VALS(protocol_discriminator_vals), 0x0f,
1937                         "Protocol discriminator", HFILL }
1938                 },
1939                 { &hf_uma_urr_sc,
1940                         { "SC","uma.urr.SC",
1941                         FT_UINT8,BASE_DEC,  VALS(SC_vals), 0x1,
1942                         "SC", HFILL }
1943                 },
1944                 { &hf_uma_urr_algorithm_id,
1945                         { "Algorithm identifier","uma.urr.algorithm_identifier",
1946                         FT_UINT8,BASE_DEC,  VALS(algorithm_identifier_vals), 0xe,
1947                         "Algorithm_identifier", HFILL }
1948                 },
1949                 { &hf_uma_urr_GPRS_resumption,
1950                         { "GPRS resumption ACK","uma.urr.GPRS_resumption",
1951                         FT_UINT8,BASE_DEC,  VALS(GPRS_resumption_vals), 0x1,
1952                         "GPRS resumption ACK", HFILL }
1953                 },
1954                 { &hf_uma_urr_ULQI,
1955                         { "ULQI, UL Quality Indication","uma.urr.ULQI",
1956                         FT_UINT8,BASE_DEC,  VALS(ULQI_vals), 0x0f,
1957                         "ULQI, UL Quality Indication", HFILL }
1958                 },
1959                 { &hf_uma_urr_TU3920_timer,
1960                         { "TU3920 Timer value(seconds)","uma.urr.tu3920",
1961                         FT_UINT16,BASE_DEC,  NULL, 0x0,
1962                         "TU3920 Timer value(hundreds of of ms)", HFILL }
1963                 },
1964                 { &hf_uma_urr_peak_tpt_cls,
1965                         { "PEAK_THROUGHPUT_CLASS","uma.urr.peak_tpt_cls",
1966                         FT_UINT8,BASE_DEC,  NULL, 0x0f,
1967                         "PEAK_THROUGHPUT_CLASS", HFILL }
1968                 },
1969                 { &hf_uma_urr_radio_pri,
1970                         { "Radio Priority","uma.urr.radio_pri",
1971                         FT_UINT8,BASE_DEC,  VALS(radio_pri_vals), 0x30,
1972                         "RADIO_PRIORITY", HFILL }
1973                 },
1974                 { &hf_uma_urr_rlc_mode,
1975                         { "RLC mode","uma.urr.rrlc_mode",
1976                         FT_UINT8,BASE_DEC,  VALS(rlc_mode_vals), 0x80,
1977                         "RLC mode", HFILL }
1978                 },
1979                 { &hf_uma_urr_URLCcause,
1980                         { "URLC Cause","uma.urr.URLCcause",
1981                         FT_UINT8,BASE_DEC,  VALS(URLC_cause_vals), 0x0,
1982                         "URLC Cause", HFILL }
1983                 },
1984                 { &hf_uma_urr_udr,
1985                         { "User Data Rate value (bits/s)","uma.urr.URLCcause",
1986                         FT_UINT32,BASE_DEC,  NULL, 0x0,
1987                         "User Data Rate value (bits/s)", HFILL }
1988                 },
1989                 { &hf_uma_urr_TU4001_timer,
1990                         { "TU4001 Timer value(seconds)","uma.urr.tu4001",
1991                         FT_UINT16,BASE_DEC,  NULL, 0x0,
1992                         "TU4001 Timer value(seconds)", HFILL }
1993                 },
1994                 { &hf_uma_urr_LS,
1995                         { "Location Status(LS)","uma.urr.LS",
1996                         FT_UINT8,BASE_DEC,  VALS(LS_vals), 0x3,
1997                         "Location Status(LS)", HFILL }
1998                 },
1999                 { &hf_uma_urr_cipher_res,
2000                         { "Cipher Response(CR)","uma.urr.CR",
2001                         FT_UINT8,BASE_DEC,  VALS(CR_vals), 0x3,
2002                         "Cipher Response(CR)", HFILL }
2003                 },
2004                 { &hf_uma_urr_rand_val,
2005                         { "Ciphering Command RAND value","uma.rand_val",
2006                         FT_BYTES,BASE_HEX,  NULL, 0x0,
2007                         "Ciphering Command RAND value", HFILL }
2008                 },
2009                 { &hf_uma_urr_ciphering_command_mac,
2010                         { "Ciphering Command MAC (Message Authentication Code)","uma.ciphering_command_mac",
2011                         FT_BYTES,BASE_HEX,  NULL, 0x0,
2012                         "Ciphering Command MAC (Message Authentication Code)", HFILL }
2013                 },
2014                 { &hf_uma_urr_ciphering_key_seq_num,
2015                         { "Values for the ciphering key","uma.ciphering_key_seq_num",
2016                         FT_UINT8,BASE_DEC,  NULL, 0x7,
2017                         "Values for the ciphering key", HFILL }
2018                 },
2019                 { &hf_uma_urr_sapi_id,
2020                         { "SAPI ID","uma.sapi_id",
2021                         FT_UINT8,BASE_DEC,  VALS(sapi_id_vals), 0x7,
2022                         "SAPI ID", HFILL }
2023                 },
2024                 { &hf_uma_urr_establishment_cause,
2025                         { "Establishment Cause","uma.urr.establishment_cause",
2026                         FT_UINT8,BASE_DEC,  VALS(establishment_cause_vals), 0x0,
2027                         "Establishment Cause", HFILL }
2028                 },
2029                 { &hf_uma_urr_channel,
2030                         { "Channel","uma.urr.establishment_cause",
2031                         FT_UINT8,BASE_DEC,  VALS(channel_vals), 0x3,
2032                         "Channel", HFILL }
2033                 },
2034                 { &hf_uma_urr_PDU_in_error,
2035                         { "PDU in Error,","uma.urr.PDU_in_error",
2036                         FT_BYTES,BASE_HEX,  NULL, 0x0,
2037                         "PDU in Error,", HFILL }
2038                 },
2039                 { &hf_uma_urr_sample_size,
2040                         { "Sample Size","uma.urr.sample_size",
2041                         FT_UINT8,BASE_DEC,  VALS(sample_size_vals), 0x0,
2042                         "Sample Size", HFILL }
2043                 },
2044                 { &hf_uma_urr_payload_type,
2045                         { "Payload Type","uma.urr.sample_size",
2046                         FT_UINT8,BASE_DEC,  NULL, 0x0,
2047                         "Payload Type", HFILL }
2048                 },
2049                 { &hf_uma_urr_LLC_PDU,
2050                         { "LLC-PDU","uma.urr.llc_pdu",
2051                         FT_BYTES,BASE_HEX,  NULL, 0x0,
2052                         "LLC-PDU", HFILL }
2053                 },
2054                 { &hf_uma_urr_LBLI,
2055                         { "LBLI, Location Black List indicator","uma.urr.LBLI",
2056                         FT_UINT8,BASE_DEC,  VALS(LBLI_vals), 0x0,
2057                         "LBLI, Location Black List indicator", HFILL }
2058                 },
2059                 { &hf_uma_urr_RI,
2060                         { "Reset Indicator(RI)","uma.urr.RI",
2061                         FT_UINT8,BASE_DEC,  VALS(RI_vals), 0x1,
2062                         "Reset Indicator(RI)", HFILL }
2063                 },
2064                 { &hf_uma_urr_TU4003_timer,
2065                         { "TU4003 Timer value(seconds)","uma.urr.tu4003",
2066                         FT_UINT16,BASE_DEC,  NULL, 0x0,
2067                         "TU4003 Timer value(seconds)", HFILL }
2068                 },
2069                 { &hf_uma_urr_ap_service_name_type,
2070                         { "AP Service Name type","uma.urr.ap_service_name_type",
2071                         FT_UINT8,BASE_DEC,  VALS(ap_service_name_type_vals), 0x0,
2072                         "AP Service Name type", HFILL }
2073                 },
2074                 { &hf_uma_urr_ap_Service_name_value,
2075                         { "AP Service Name Value","uma.urr.ap_service_name_value",
2076                         FT_STRING,BASE_NONE,  NULL, 0x0,
2077                         "AP Service Name Value", HFILL }
2078                 },
2079                 { &hf_uma_urr_uma_service_zone_icon_ind,
2080                         { "UMA Service Zone Icon Indicator","uma.urr.uma_service_zone_icon_ind",
2081                         FT_UINT8,BASE_DEC,  VALS(uma_service_zone_icon_ind_vals), 0x0,
2082                         "UMA Service Zone Icon Indicator", HFILL }
2083                 },
2084                 { &hf_uma_urr_uma_service_zone_str_len,
2085                         { "Length of UMA Service Zone string","uma.urr.service_zone_str_len",
2086                         FT_UINT8,BASE_DEC,  NULL, 0x0,
2087                         "Length of UMA Service Zone string", HFILL }
2088                 },
2089                 { &hf_uma_urr_window_size,
2090                         { "Window Size","uma.urr.uma_window_size",
2091                         FT_UINT8,BASE_DEC,  VALS(window_size_vals), 0x03,
2092                         "Window Size", HFILL }
2093                 },
2094                 { &hf_uma_urr_uma_codec_mode,
2095                         { "Codec Mode","uma.urr.uma_codec_mode",
2096                         FT_UINT8,BASE_DEC,  NULL, 0xc0,
2097                         "Codec Mode", HFILL }
2098                 },
2099                 { &hf_uma_urr_UTRAN_cell_id_disc,
2100                         { "UTRAN Cell Identification Discriminator","uma.urr.uma_UTRAN_cell_id_disc",
2101                         FT_UINT8,BASE_DEC,  VALS(UTRAN_cell_id_disc_vals), 0x0f,
2102                         "UTRAN Cell Identification Discriminator", HFILL }
2103                 },
2104                 { &hf_uma_urr_suti,
2105                         { "SUTI, Serving UNC table indicator indicator","uma.urr.uma_suti",
2106                         FT_UINT8,BASE_DEC,  VALS(suti_vals), 0x01,
2107                         "SUTI, Serving UNC table indicator indicator", HFILL }
2108                 },
2109                 { &hf_uma_urr_uma_mps,
2110                         { "UMPS, Manual PLMN Selection indicator","uma.urr.mps",
2111                         FT_UINT8,BASE_DEC,  VALS(mps_vals), 0x3,
2112                         "MPS, Manual PLMN Selection indicator", HFILL }
2113                 },
2114                 { &hf_uma_urr_num_of_plms,
2115                         { "Number of PLMN:s","uma.urr.num_of_plms",
2116                         FT_UINT8,BASE_DEC,  NULL, 0x0,
2117                         "Number of PLMN:s", HFILL }
2118                 },
2119                 { &hf_uma_urr_cbs,
2120                         { "CBS Cell Broadcast Service","uma.urr.cbs",
2121                         FT_UINT8,BASE_DEC,  VALS(cbs_vals), 0x01,
2122                         "CBS Cell Broadcast Service", HFILL }
2123                 },
2124                 { &hf_uma_urr_num_of_cbs_frms,
2125                         { "Number of CBS Frames","uma.urr.num_of_cbs_frms",
2126                         FT_UINT8,BASE_DEC,  NULL, 0x0,
2127                         "Number of CBS Frames", HFILL }
2128                 },
2129                 { &hf_uma_urr_ms_radio_id,
2130                         { "MS Radio Identity","uma.urr.ms_radio_id",
2131                         FT_ETHER, BASE_DEC, NULL, 0x00,
2132                         "MS Radio Identity", HFILL }
2133                 },
2134                 { &hf_uma_urr_uma_service_zone_str,
2135                         { "UMA Service Zone string,","uma.urr.uma_service_zone_str",
2136                         FT_STRING,BASE_NONE,  NULL, 0x0,
2137                         "UMA Service Zone string,", HFILL }
2138                 },
2139                 { &hf_uma_urr_unc_ipv4,
2140                         { "UNC IPv4 address","uma.urr.uncipv4",
2141                         FT_IPv4,BASE_NONE,  NULL, 0x0,
2142                         "UNC IPv4 address", HFILL }
2143                 },
2144                 { &hf_uma_unc_FQDN,
2145                        { "UNC Fully Qualified Domain/Host Name (FQDN)", "uma.urr.unc_fqdn",
2146                        FT_STRING, BASE_NONE,NULL,0x0,
2147                         "UNC Fully Qualified Domain/Host Name (FQDN)", HFILL }
2148                 },
2149                 { &hf_uma_urr_GPRS_user_data_transport_ipv4,
2150                         { "IP address for GPRS user data transport","uma.urr.gprs_usr_data_ipv4",
2151                         FT_IPv4,BASE_NONE,  NULL, 0x0,
2152                         "IP address for GPRS user data transport", HFILL }
2153                 },
2154                 { &hf_uma_urr_GPRS_port,
2155                         { "UDP Port for GPRS user data transport","uma.urr.gprs_port",
2156                         FT_UINT16,BASE_DEC,  NULL, 0x0,
2157                         "UDP Port for GPRS user data transport", HFILL }
2158                 },
2159                 { &hf_uma_urr_UNC_tcp_port,
2160                         { "UNC TCP port","uma.urr.gprs_port",
2161                         FT_UINT16,BASE_DEC,  NULL, 0x0,
2162                         "UDP Port for GPRS user data transport", HFILL }
2163                 },
2164                 { &hf_uma_urr_RTP_port,
2165                         { "RTP UDP port","uma.urr.rtp_port",
2166                         FT_UINT16,BASE_DEC,  NULL, 0x0,
2167                         "RTP UDP port", HFILL }
2168                 },
2169                 { &hf_uma_urr_RTCP_port,
2170                         { "RTCP UDP port","uma.urr.rtcp_port",
2171                         FT_UINT16,BASE_DEC,  NULL, 0x0,
2172                         "RTCP UDP port", HFILL }
2173                 },
2174                 { &hf_uma_urr_RXLEV_NCELL,
2175                         { "RX Level","uma.urr.rxlevel",
2176                         FT_UINT8,BASE_DEC,  NULL, 0x0,
2177                         "RX Level", HFILL }
2178                 },
2179         };
2180
2181 /* Setup protocol subtree array */
2182         static gint *ett[] = {
2183                 &ett_uma,
2184                 &ett_uma_toc,
2185                 &ett_urr_ie,
2186         };
2187
2188 /* Register the protocol name and description */
2189         proto_uma = proto_register_protocol("Unlicensed Mobile Access","UMA", "uma");
2190         bssap_pdu_type_table = find_dissector_table("bssap.pdu_type");
2191
2192 /* Required function calls to register the header fields and subtrees used */
2193         proto_register_field_array(proto_uma, hf, array_length(hf));
2194         proto_register_subtree_array(ett, array_length(ett));
2195         /* Register a configuration option for port */
2196
2197
2198         uma_module = prefs_register_protocol(proto_uma, proto_reg_handoff_uma);
2199
2200         /* Set default TCP ports */
2201         range_convert_str(&global_uma_tcp_port_range, DEFAULT_UMA_PORT_RANGE, MAX_UDP_PORT);
2202         uma_tcp_port_range = range_empty();
2203
2204         prefs_register_bool_preference(uma_module, "desegment_ucp_messages",
2205                 "Reassemble UMA messages spanning multiple TCP segments",
2206                 "Whether the UMA dissector should reassemble messages spanning multiple TCP segments."
2207                 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
2208                 &uma_desegment);
2209         prefs_register_obsolete_preference(uma_module, "tcp.port1");
2210         prefs_register_range_preference(uma_module, "udp.ports", "UMA TCP ports",
2211                                   "TCP ports to be decoded as UMA (default: "
2212                                   DEFAULT_UMA_PORT_RANGE ")",
2213                                   &global_uma_tcp_port_range, MAX_UDP_PORT);
2214
2215
2216
2217 }
2218
2219