Remove all $Id$ from top of file
[metze/wireshark/wip.git] / epan / dissectors / packet-gsm_bssmap_le.c
1 /* packet-gsm_bssmap_le.c
2  * Routines for GSM Lb Interface BSSMAP dissection
3  *
4  * Copyright 2008, Johnny Mitrevski <mitrevj@hotmail.com>
5  *
6  * 3GPP TS 49.031 version v7.4.0 (2009-09)
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  */
26
27 #include "config.h"
28
29 #include <glib.h>
30
31 #include <epan/packet.h>
32 #include <epan/tap.h>
33 #include <epan/wmem/wmem.h>
34
35 #include "packet-bssap.h"
36 #include "packet-sccp.h"
37 #include "packet-gsm_a_common.h"
38 #include "packet-e212.h"
39
40 void proto_register_gsm_bssmap_le(void);
41 void proto_reg_handoff_gsm_bssmap_le(void);
42
43 /* PROTOTYPES/FORWARDS */
44
45 /* Message Type definitions */
46 #define BSSMAP_LE_PERFORM_LOCATION_REQUEST              43
47 #define BSSMAP_LE_PERFORM_LOCATION_RESPONSE             45
48 #define BSSMAP_LE_PERFORM_LOCATION_ABORT                46
49 #define BSSMAP_LE_PERFORM_LOCATION_INFORMATION          47
50 #define BSSMAP_LE_CONNECTION_ORIENTED_INFORMATION       42
51 #define BSSMAP_LE_CONNECTIONLESS_INFORMATION            58
52 #define BSSMAP_LE_RESET                                 48
53 #define BSSMAP_LE_RESET_ACKNOWLEDGE                     49
54
55 static const value_string gsm_bssmap_le_msg_strings[] = {
56         { 0, "Reserved" },
57         { 1, "Reserved" },
58         { 2, "Reserved" },
59         { 3, "Reserved" },
60         { 4, "Reserved" },
61         { BSSMAP_LE_PERFORM_LOCATION_REQUEST, "Perform Location Request" },
62         { BSSMAP_LE_PERFORM_LOCATION_RESPONSE, "Perform Location Response" },
63         { BSSMAP_LE_PERFORM_LOCATION_ABORT, "Perform Location Abort" },
64         { BSSMAP_LE_PERFORM_LOCATION_INFORMATION, "Perform Location Information" },
65         { BSSMAP_LE_CONNECTION_ORIENTED_INFORMATION, "Connection Oriented Information" },
66         { BSSMAP_LE_CONNECTIONLESS_INFORMATION, "Connectionless Information" },
67         { BSSMAP_LE_RESET, "Reset" },
68         { BSSMAP_LE_RESET_ACKNOWLEDGE, "Reset Acknowledge" },
69         { 0, NULL }    /*Null terminated list. Make sure we add this to our value/string structures. */
70 };
71
72 /* Information Element definitions */
73 #define BSSMAP_LE_LCS_QOS                                    62
74 #define BSSMAP_LE_LCS_PRIORITY                               67
75 #define BSSMAP_LE_LOCATION_TYPE                              68
76 #define BSSMAP_LE_GANSS_LOCATION_TYPE                        130
77 #define BSSMAP_LE_GEOGRAPHIC_LOCATION                        69
78 #define BSSMAP_LE_POSITIONING_DATA                           70
79 #define BSSMAP_LE_GANSS_POSITIONING_DATA                     131
80 #define BSSMAP_LE_VELOCITY_DATA                              85
81 #define BSSMAP_LE_LCS_CAUSE                                  71
82 #define BSSMAP_LE_LCS_CLIENT_TYPE                            72
83 #define BSSMAP_LE_APDU                                       73
84 #define BSSMAP_LE_NETWORK_ELEMENT_IDENTITY                   74
85 #define BSSMAP_LE_REQUESTED_GPS_ASSISTANCE_DATA              75
86 #define BSSMAP_LE_REQUESTED_GANSS_ASSISTANCE_DATA            65
87 #define BSSMAP_LE_DECIPHERING_KEYS                           76
88 #define BSSMAP_LE_RETURN_ERROR_REQUEST                       77
89 #define BSSMAP_LE_RETURN_ERROR_CAUSE                         78
90 #define BSSMAP_LE_SEGMENTATION                               79
91 #define BSSMAP_LE_CLASSMARK_INFORMATION_TYPE_3               19
92 #define BSSMAP_LE_CAUSE                                      4
93 #define BSSMAP_LE_CELL_IDENTIFIER                            5
94 #define BSSMAP_LE_CHOSEN_CHANNEL                             33
95 #define BSSMAP_LE_IMSI                                       0
96 #define BSSMAP_LE_RESERVED_NOTE1                             1
97 #define BSSMAP_LE_RESERVED_NOTE2                             2
98 #define BSSMAP_LE_RESERVED_NOTE3                             3
99 #define BSSMAP_LE_LCS_CAPABILITY                             80
100 #define BSSMAP_LE_PACKET_MEASUREMENT_REPORT                  81
101 #define BSSMAP_LE_CELL_IDENTITY_LIST                         82
102 #define BSSMAP_LE_IMEI                                       128
103
104 static const value_string gsm_bssmap_le_elem_strings[] = {
105         { DE_BMAPLE_LCSQOS, "LCS QoS" },
106         { DE_BMAPLE_LCS_PRIO, "LCS Priority" },
107         { DE_BMAPLE_LOC_TYPE, "Location Type" },
108         { DE_BMAPLE_GANSS_LOC_TYPE, "GANSS Location Type" },
109         { DE_BMAPLE_GEO_LOC, "Geographic Location" },
110         { DE_BMAPLE_POS_DATA, "Positioning Data" },
111         { DE_BMAPLE_GANSS_POS_DATA, "GANSS Positioning Data" },
112         { DE_BMAPLE_VELOC_DATA, "Velocity Data" },
113         { DE_BMAPLE_LCS_CAUSE, "LCS Cause" },
114         { DE_BMAPLE_LCS_CLIENT_TYPE, "LCS Client Type" },
115         { DE_BMAPLE_APDU, "APDU" },
116         { DE_BMAPLE_NETWORK_ELEM_ID, "Network Element Identity" },
117         { DE_BMAPLE_REQ_GPS_ASSIST_D, "Requested GPS Assistance Data" },
118         { DE_BMAPLE_REQ_GNSS_ASSIST_D, "Requested GANSS Assistance Data" },
119         { DE_BMAPLE_DECIPH_KEYS, "Deciphering Keys" },
120         { DE_BMAPLE_RETURN_ERROR_REQ, "Return Error Request" },
121         { DE_BMAPLE_RETURN_ERROR_CAUSE, "Return Error Cause" },
122         { DE_BMAPLE_SEGMENTATION, "Segmentation" },
123         { DE_BMAPLE_CLASSMARK_TYPE_3, "Classmark Information Type 3" },
124         { DE_BMAPLE_CAUSE, "Cause" },
125         { DE_BMAPLE_CELL_IDENTIFIER, "Cell Identifier" },
126         { DE_BMAPLE_CHOSEN_CHANNEL, "Chosen Channel" },
127         { DE_BMAPLE_IMSI, "IMSI" },
128         { DE_BMAPLE_RES1, "Reserved" },
129         { DE_BMAPLE_RES2, "Reserved" },
130         { DE_BMAPLE_RES3, "Reserved" },
131         { DE_BMAPLE_LCS_CAPABILITY, "LCS Capability" },
132         { DE_BMAPLE_PACKET_MEAS_REP, "Packet Measurement Report" },
133         { DE_BMAPLE_MEAS_CELL_ID, "Cell Identity List" },
134         { DE_BMAPLE_IMEI, "IMEI" },
135         { 0, NULL }
136 };
137 value_string_ext gsm_bssmap_le_elem_strings_ext = VALUE_STRING_EXT_INIT(gsm_bssmap_le_elem_strings);
138
139 static const value_string gsm_apdu_protocol_id_strings[] = {
140         { 0,    "reserved" },
141         { 1,    "BSSLAP" },
142         { 2,    "LLP" },
143         { 3,    "SMLCPP" },
144         { 0, NULL },
145 };
146
147 /* Velocity Requested definitions */
148 static const value_string bssmap_le_velocity_requested_vals[] = {
149         { 0, "do not report velocity" },
150         { 1, "report velocity if available" },
151         { 0, NULL}
152 };
153
154 /* Vertical Coordinate definitions */
155 static const value_string bssmap_le_vertical_coordinate_indicator_vals[] = {
156         { 0, "vertical coordinate not requested" },
157         { 1, "vertical coordinate is requested" },
158         { 0, NULL}
159 };
160
161 /* Horizontal Accuracy definitions */
162 static const value_string bssmap_le_horizontal_accuracy_indicator_vals[] = {
163         { 0, "horizontal accuracy is not specified" },
164         { 1, "horizontal accuracy is specified" },
165         { 0, NULL}
166 };
167
168 /* Vertical Accuracy definitions */
169 static const value_string bssmap_le_vertical_accuracy_indicator_vals[] = {
170         { 0, "vertical accuracy is not specified" },
171         { 1, "vertical accuracy is specified" },
172         { 0, NULL}
173 };
174
175 /* Response Time definitions */
176 static const value_string bssmap_le_response_time_definitions_vals[] = {
177         { 0, "Response Time is not specified" },
178         { 1, "Low Delay" },
179         { 2, "Delay Tolerant" },
180         { 3, "reserved" },
181         { 0, NULL}
182 };
183
184 /* Initialize the protocol and registered fields */
185 static int proto_bssmap_le = -1;
186 int hf_gsm_bssmap_le_elem_id = -1;
187
188 /* The following hf_* variables are used to hold the Wireshark IDs of
189 * our header fields; they are filled out when we call
190 * proto_register_field_array() in proto_register_bssmap_le()
191 */
192 static int hf_gsm_bssmap_le_msg_type = -1;
193 static int hf_gsm_bssmap_le_apdu_protocol_id = -1;
194 static int hf_gsm_bssmap_le_spare = -1;
195 static int hf_gsm_bssmap_le_ciphering_key_flag = -1;
196 static int hf_gsm_bssmap_le_current_deciphering_key_value = -1;
197 static int hf_gsm_bssmap_le_next_deciphering_key_value = -1;
198 static int hf_gsm_bssmap_le_acq_ass = -1;
199 static int hf_gsm_bssmap_le_ref_time = -1;
200 static int hf_gsm_bssmap_le_ref_loc = -1;
201 static int hf_gsm_bssmap_le_dgps_corr = -1;
202 static int hf_gsm_bssmap_le_nav_mod = -1;
203 static int hf_gsm_bssmap_le_iono_mod = -1;
204 static int hf_gsm_bssmap_le_utc_mod = -1;
205 static int hf_gsm_bssmap_le_almanac = -1;
206 static int hf_gsm_bssmap_le_ephemeris_ext_chk = -1;
207 static int hf_gsm_bssmap_le_ephemeris_ext = -1;
208 static int hf_gsm_bssmap_le_real_time_int = -1;
209 static int hf_gsm_bssmap_le_lcs_cause_value =-1;
210 static int hf_gsm_bssmap_le_diagnostic_value = -1;
211 static int hf_gsm_bssmap_le_client_category = -1;
212 static int hf_gsm_bssmap_le_client_subtype = -1;
213 static int hf_gsm_bssmap_le_velocity_requested = -1;
214 static int hf_gsm_bssmap_le_vertical_coordinate_indicator = -1;
215 static int hf_gsm_bssmap_le_horizontal_accuracy_indicator = -1;
216 static int hf_gsm_bssmap_le_horizontal_accuracy = -1;
217 static int hf_gsm_bssmap_le_vertical_accuracy_indicator = -1;
218 static int hf_gsm_bssmap_le_vertical_accuracy = -1;
219 static int hf_gsm_bssmap_le_response_time_category = -1;
220
221 /* Initialize the subtree pointers */
222 static gint ett_bssmap_le_msg = -1;
223
224 static dissector_handle_t gsm_bsslap_handle = NULL;
225
226 static proto_tree *g_tree;
227
228 #define NUM_GSM_BSSMAP_LE_ELEM (sizeof(gsm_bssmap_le_elem_strings)/sizeof(value_string))
229 gint ett_gsm_bssmap_le_elem[NUM_GSM_BSSMAP_LE_ELEM];
230
231 /*
232  * 10.3 APDU
233  */
234
235 static guint16
236 de_bmaple_apdu(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
237 {
238         guint32 curr_offset;
239         guint8  apdu_protocol_id;
240         tvbuff_t *APDU_tvb;
241
242         curr_offset = offset;
243
244         /* curr_offset + 1 is a hack, the length part here is 2 octets and we are off by one */
245         proto_tree_add_text(tree, tvb, curr_offset+1, len, "APDU");
246
247         /*
248          * dissect the embedded APDU message
249          * if someone writes a TS 09.31 dissector
250          *
251          * The APDU octets 4 to n are coded in the same way as the
252          * equivalent octet in the APDU element of 3GPP TS 49.031 BSSAP-LE.
253          */
254
255         apdu_protocol_id = tvb_get_guint8(tvb,curr_offset+1);
256         proto_tree_add_item(tree, hf_gsm_bssmap_le_apdu_protocol_id, tvb, curr_offset+1, 1, ENC_BIG_ENDIAN);
257
258         switch(apdu_protocol_id){
259         case 1:
260                 /* BSSLAP
261                  * the embedded message is as defined in 3GPP TS 08.71(3GPP TS 48.071 version 7.2.0 Release 7)
262                  */
263                 APDU_tvb = tvb_new_subset(tvb, curr_offset+2, len-1, len-1);
264                 if(gsm_bsslap_handle)
265                         call_dissector(gsm_bsslap_handle, APDU_tvb, pinfo, g_tree);
266                 break;
267         case 2:
268                 /* LLP
269                  * The embedded message contains a Facility Information Element as defined in 3GPP TS 04.71
270                  * excluding the Facility IEI and length of Facility IEI octets defined in 3GPP TS 04.71.(3GPP TS 44.071).
271                  */
272                 break;
273         case 3:
274                 /* SMLCPP
275                  * The embedded message is as defined in 3GPP TS 08.31(TS 48.031).
276                  */
277                 break;
278         default:
279                 break;
280         }
281
282         curr_offset += len;
283
284         EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
285
286         return(curr_offset - offset);
287 }
288 /*
289  * 10.4 Cause
290  * coded as the value part of the Cause IE defined in 3GPP TS 48.008
291  */
292 /*
293  * 10.5 Cell Identifier
294  * coded as the value part of the Cell Identifier IE defined in 3GPP TS 48.008
295  */
296 /*
297  * 10.6 Chosen Channel
298  * coded as the value part of the Chosen Channel IE defined in 3GPP TS 48.008
299  */
300 /*
301  * 10.7 Classmark Information Type 3
302  * coded as the value part of the Classmark Information Type 3 IE defined in 3GPP TS 48.008
303  */
304 /*
305  * 10.8 Deciphering Keys
306  */
307 static guint16
308 de_bmaple_decihp_keys(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
309 {
310         gint bit_offset;
311
312         /* Spare bits */
313         bit_offset = (offset<<3);
314         proto_tree_add_bits_item(tree, hf_gsm_bssmap_le_spare, tvb, bit_offset, 7, ENC_BIG_ENDIAN);
315         bit_offset += 7;
316
317         /* Extract the Ciphering Key Flag and add to protocol tree */
318         proto_tree_add_bits_item(tree, hf_gsm_bssmap_le_ciphering_key_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
319         bit_offset++;
320         /*offset++;*/
321
322         /* Extract the Current Deciphering Key Value and add to protocol tree */
323         proto_tree_add_bits_item(tree, hf_gsm_bssmap_le_current_deciphering_key_value, tvb, bit_offset, 56, ENC_NA);
324         bit_offset += 56;
325         /*offset += 7;*/
326
327         /* Extract the Next Deciphering Key Value and add to protocol tree */
328         proto_tree_add_bits_item(tree, hf_gsm_bssmap_le_next_deciphering_key_value, tvb, bit_offset, 56, ENC_NA);
329         /*offset += 7;*/
330
331         return(len);
332 }
333 /*
334  * 10.9 Geographic Location
335  * contains an octet sequence identical to that for Geographical Information
336  * defined in 3GPP TS 23.032..
337  */
338 /*
339  * 10.10 Requested GPS Assistance Data
340  */
341 static guint16
342 de_bmaple_req_gps_ass_data(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
343 {
344         guint32 curr_offset;
345
346         curr_offset = offset;
347
348         /* Octet 3 H G F E D C B A */
349         /* bit H Acquisition Assistance */
350         proto_tree_add_item(tree, hf_gsm_bssmap_le_acq_ass, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
351         /* bit G Reference Time */
352         proto_tree_add_item(tree, hf_gsm_bssmap_le_ref_time, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
353         /* bit F Reference Location */
354         proto_tree_add_item(tree, hf_gsm_bssmap_le_ref_loc, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
355         /* bit E DGPS Corrections */
356         proto_tree_add_item(tree, hf_gsm_bssmap_le_dgps_corr, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
357         /* bit D Navigation Model */
358         proto_tree_add_item(tree, hf_gsm_bssmap_le_nav_mod, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
359         /* bit C Ionospheric Model */
360         proto_tree_add_item(tree, hf_gsm_bssmap_le_iono_mod, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
361         /* bit B UTC Model */
362         proto_tree_add_item(tree, hf_gsm_bssmap_le_utc_mod, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
363         /* bit A Almanac */
364         proto_tree_add_item(tree, hf_gsm_bssmap_le_almanac, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
365         curr_offset++;
366
367         /* Octet 4 P O N M L K J I
368          * bits L through P are Spare bits
369          */
370         /* bit K Ephemeris Extension Check */
371         proto_tree_add_item(tree, hf_gsm_bssmap_le_ephemeris_ext_chk, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
372         /* bit J Ephemeris Extension */
373         proto_tree_add_item(tree, hf_gsm_bssmap_le_ephemeris_ext, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
374         /* bit I Real-Time Integrity */
375         proto_tree_add_item(tree, hf_gsm_bssmap_le_real_time_int, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
376         curr_offset++;
377
378         /* Octet 5 to Octet 8+2n Satellite related data */
379         proto_tree_add_text(tree, tvb, curr_offset, len-2, "Satellite related data Not decoded yet");
380         return(len);
381 }
382 /*
383  * 10.11 IMSI
384  * coded as the value part of the Mobile Identity IE defined in 3GPP TS 24.008 (NOTE 1)
385  * NOTE 1: The Type of identity field in the Mobile Identity IE shall
386  * be ignored by the receiver
387  */
388 /*
389  * 10.12 (void)
390  */
391 /*
392  * 10.13 LCS Cause
393  */
394 static const value_string bssmap_le_lcs_cause_values[] = {
395         { 0, "Unspecified" },
396         { 1, "System Failure" },
397         { 2, "Protocol Error" },
398         { 3, "Data missing in position request" },
399         { 4, "Unexpected data value in position request" },
400         { 5, "Position method failure" },
401         { 6, "Target MS Unreachable" },
402         { 7, "Location request aborted" },
403         { 8, "Facility not supported" },
404         { 9, "Inter-BSC Handover Ongoing" },
405         { 10, "Intra-BSC Handover Complete" },
406         { 11, "Congestion" },
407         { 12, "Inter NSE cell change" },
408         { 13, "Routing Area Update" },
409         { 14, "PTMSI reallocation" },
410         { 15, "Suspension of GPRS services" },
411         { 0, NULL}
412 };
413
414 static const value_string bssmap_le_position_method_failure_diagnostic_vals[] = {
415         { 0, "Congestion" },
416         { 1, "insufficientResources" },
417         { 2, "insufficientMeasurementData" },
418         { 3, "inconsistentMeasurementData" },
419         { 4, "locationProcedureNotCompleted" },
420         { 5, "locationProcedureNotSupportedByTargetMS" },
421         { 6, "qoSNotAttainable" },
422         { 7, "positionMethodNotAvailableInNetwork" },
423         { 8, "positionMethodNotAvailableInLocaitonArea" },
424         { 0, NULL}
425 };
426 static guint16
427 de_bmaple_cause(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
428 {
429         guint32 curr_offset;
430
431         curr_offset = offset;
432
433         /* cause value  */
434         proto_tree_add_item(tree, hf_gsm_bssmap_le_lcs_cause_value, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
435         curr_offset++;
436
437         if (len == 2)
438         {
439                 /* Diagnostic value (note) */
440                 proto_tree_add_item(tree, hf_gsm_bssmap_le_diagnostic_value, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
441                 curr_offset++;
442         }
443
444         return(curr_offset - offset);
445 }
446 /*
447  * 10.14 LCS Client Type
448  */
449 /* Client Category definitions */
450 static const value_string bssmap_le_client_category[] = {
451         { 0, "Value Added Client" },
452         { 2, "PLMN Operator" },
453         { 3, "Emergency Services"},
454         { 4, "Lawful Intercept Services"},
455         { 0, NULL}
456 };
457
458 /* Client Subtype definitions */
459 static const value_string bssmap_le_client_subtype[] = {
460         { 0, "unspecified" },
461         { 1, "broadcast service" },
462         { 2, "O&M" },
463         { 3, "anonymous statistics" },
464         { 4, "Target MS service support" },
465         { 0, NULL}
466 };
467
468 static guint16
469 de_bmaple_client(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
470 {
471         guint32 curr_offset;
472         guint8 bitCount;
473
474         bitCount = offset<<3;
475         curr_offset = offset;
476
477         /* Extract the client category and add to protocol tree */
478         proto_tree_add_bits_item(tree, hf_gsm_bssmap_le_client_category, tvb, bitCount, 4, ENC_BIG_ENDIAN);
479         bitCount = bitCount + 4;
480
481         /* Extract the client subtype and add to protocol tree */
482         proto_tree_add_bits_item(tree, hf_gsm_bssmap_le_client_subtype, tvb, bitCount, 4, ENC_BIG_ENDIAN);
483         /*bitCount = bitCount + 4;*/
484         curr_offset++;
485
486         return(curr_offset - offset);
487 }
488 /*
489  * 10.15 LCS Priority
490  * coded as the LCS-Priority octet in 3GPP TS 29.002
491  */
492 /*
493  * 10.16 LCS QoS
494  */
495 static guint16
496 de_bmaple_lcs_qos(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
497 {
498         guint64 verticalCoordIndicator, velocityRequested, horizontalAccuracyIndicator, verticalAccuracyIndicator;
499         guint16 bitCount;
500
501         bitCount = offset << 3;
502
503         proto_tree_add_bits_item(tree, hf_gsm_bssmap_le_spare, tvb, bitCount, 6, ENC_BIG_ENDIAN);
504         bitCount = bitCount + 6;
505
506         /* Extract Velocity requested element */
507         proto_tree_add_bits_ret_val(tree, hf_gsm_bssmap_le_velocity_requested, tvb, bitCount, 1, &velocityRequested, ENC_BIG_ENDIAN);
508         bitCount++;
509
510         /* Extract vertical coordinator element */
511         proto_tree_add_bits_ret_val(tree, hf_gsm_bssmap_le_vertical_coordinate_indicator, tvb, bitCount, 1, &verticalCoordIndicator, ENC_BIG_ENDIAN);
512         bitCount++;
513
514         /* Extract horizontal accuracy element */
515         proto_tree_add_bits_ret_val(tree, hf_gsm_bssmap_le_horizontal_accuracy_indicator, tvb, bitCount, 1, &horizontalAccuracyIndicator, ENC_BIG_ENDIAN);
516         bitCount++;
517
518         if(horizontalAccuracyIndicator == 1)
519         {
520                 proto_tree_add_bits_item(tree, hf_gsm_bssmap_le_horizontal_accuracy, tvb, bitCount, 7, ENC_BIG_ENDIAN);
521                 bitCount = bitCount + 7;
522         }
523         else
524         {
525                 proto_tree_add_bits_item(tree, hf_gsm_bssmap_le_spare, tvb, bitCount, 7, ENC_BIG_ENDIAN);
526                 bitCount = bitCount + 7;
527         }
528
529         /* Extract vertical accuracy element */
530         proto_tree_add_bits_ret_val(tree, hf_gsm_bssmap_le_vertical_accuracy_indicator, tvb, bitCount, 1, &verticalAccuracyIndicator, ENC_BIG_ENDIAN);
531         bitCount++;
532
533         if(verticalAccuracyIndicator == 1)
534         {
535                 proto_tree_add_bits_item(tree, hf_gsm_bssmap_le_vertical_accuracy, tvb, bitCount, 7, ENC_BIG_ENDIAN);
536                 bitCount = bitCount + 7;
537         }
538         else
539         {
540                 proto_tree_add_bits_item(tree, hf_gsm_bssmap_le_spare, tvb, bitCount, 7, ENC_BIG_ENDIAN);
541                 bitCount = bitCount + 7;
542         }
543
544         proto_tree_add_bits_item(tree, hf_gsm_bssmap_le_response_time_category, tvb, bitCount, 2, ENC_BIG_ENDIAN);
545         /*bitCount = bitCount + 2;*/
546
547         return(len);
548 }
549 /*
550  * 10.17 (void)
551  */
552 /*
553  * 10.18 Location Type
554  */
555 /*
556  * 10.19 Network Element Identity
557  */
558 /*
559  * 10.20 Positioning Data
560  */
561 static guint16
562 de_bmaple_pos_dta(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
563 {
564         tvbuff_t *data_tvb;
565         guint32 curr_offset;
566
567         curr_offset = offset;
568
569         data_tvb = tvb_new_subset(tvb, curr_offset, len, len);
570         dissect_geographical_description(data_tvb, pinfo, tree);
571
572         return(len);
573 }
574 /*
575  * 10.21 Return Error Request
576  */
577 /*
578  * 10.22 Return Error Cause
579  */
580 /*
581  * 10.23 (void)
582  */
583 /*
584  * 10.24 Segmentation
585  */
586 /*
587  * 10.25 (void)
588  */
589 /*
590  * 10.26 LCS Capability
591  * coded as the value part of the LCS Capability
592  * information element in 3GPP TS 48.018, not including
593  * 3GPP TS 48.018 IEI and length indicator
594  */
595 /* Dissector for the LCS Capability element */
596 static guint16
597 be_lcs_capability(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
598 {
599         /* Extract the LCS Capability element and add to protocol tree */
600         proto_tree_add_text(tree, tvb, offset, len, "Not decoded yet");
601         return len;
602 }
603
604 /*
605  * 10.27 Packet Measurement Report
606  * coded as the Packet Measurement Report
607  * message or the Packet Enhanced Measurement Report message
608  * starting with the 6-bit MESSAGE_TYPE (see clause 11 in
609  * 3GPP TS 44.060) and ending with the Non-distribution contents
610  * (i.e. the RLC/MAC padding bits are not included). The end of the
611  * message is padded with 0-bits to the nearest octet boundary.
612  */
613 /* Dissector for the Packet Measurement Report element */
614 static guint16
615 be_packet_meas_rep(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
616 {
617         /* Extract the Packet Measurement Report element and add to protocol tree */
618         proto_tree_add_text(tree, tvb, offset, len, "Not decoded yet");
619
620         return len;
621 }
622
623 /*
624  * 10.28 Cell Identity List
625  * coded as the value part of the Cell Identity List IE
626  * defined in 3GPP TS 48.071.
627  */
628 /* Dissector for the Measured Cell Identity List element */
629 static guint16
630 be_measured_cell_identity(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
631 {
632         /* Extract the Measured Cell Identity List element and add to protocol tree */
633         proto_tree_add_text(tree, tvb, offset, len, "Not decoded yet");
634
635         return len;
636 }
637
638 /*
639  * 10.29 IMEI
640  * IMEI coded as the value part of the Mobile Identity IE defined in
641  * 3GPP TS 24.008 (NOTE 1)
642  * NOTE 1: The Type of identity field in the Mobile Identity IE shall
643  * be ignored by the receiver.
644  */
645 /*
646  * 10.30 Velocity Data
647  * contains an octet sequence identical to that for Description of
648  * Velocity defined in 3GPP TS 23.032.
649  */
650 /*
651  * 10.31 Requested GANSS Assistance Data
652  */
653 /*
654  * 10.32 GANSS Positioning Data
655  */
656 /*
657  * 10.33 GANSS Location Type
658  */
659
660
661 #define NUM_GSM_BSSMAP_LE_MSG (sizeof(gsm_bssmap_le_msg_strings)/sizeof(value_string))
662 static gint ett_gsm_bssmap_le_msg[NUM_GSM_BSSMAP_LE_MSG];
663
664 /*
665 This enum is defined in packet-gsm_a_common.h to
666 make it possible to use element dissecton from this dissector
667 in other dissectors.
668
669 It is shown here as a comment for easier reference.
670
671 Note this enum must be of the same size as the element decoding list below
672
673 typedef enum
674 {
675         DE_BMAPLE_LCSQOS,                       / 10.16 LCS QoS /
676         DE_BMAPLE_LCS_PRIO,                     / LCS Priority /
677         DE_BMAPLE_LOC_TYPE,                     / 10.18 Location Type /
678         DE_BMAPLE_GANSS_LOC_TYPE,       / GANSS Location Type /
679         DE_BMAPLE_GEO_LOC,                      / 10.9 Geographic Location /
680         DE_BMAPLE_POS_DATA,                     / 10.20 Positioning Data /
681         DE_BMAPLE_GANSS_POS_DATA,       / GANSS Positioning Data /
682         DE_BMAPLE_VELOC_DATA,           / Velocity Data /
683         DE_BMAPLE_LCS_CAUSE,            / 10.13 LCS Cause /
684         DE_BMAPLE_LCS_CLIENT_TYPE,      / LCS Client Type /
685         DE_BMAPLE_APDU,                         / 10.3 APDU /
686         DE_BMAPLE_NETWORK_ELEM_ID,      / Network Element Identity /
687         DE_BMAPLE_REQ_GPS_ASSIST_D, / 10.10 Requested GPS Assistance Data /
688         DE_BMAPLE_REQ_GNSS_ASSIST_D,/ Requested GANSS Assistance Data /
689         DE_BMAPLE_DECIPH_KEYS,          / 10.8 Deciphering Keys /
690         DE_BMAPLE_RETURN_ERROR_REQ,     / Return Error Request /
691         DE_BMAPLE_RETURN_ERROR_CAUSE,   / Return Error Cause /
692         DE_BMAPLE_SEGMENTATION,         / Segmentation /
693         DE_BMAPLE_CLASSMARK_TYPE_3,     / 10.7 Classmark Information Type 3 /
694         DE_BMAPLE_CAUSE,                        / 10.4 Cause /
695         DE_BMAPLE_CELL_IDENTIFIER,      / 10.5 Cell Identifier /
696         DE_BMAPLE_CHOSEN_CHANNEL,       / 10.6 Chosen Channel /
697         DE_BMAPLE_IMSI,                         / 10.11 IMSI /
698         DE_BMAPLE_RES1,                         / Reserved /
699         DE_BMAPLE_RES2,                         / Reserved /
700         DE_BMAPLE_RES3,                         / Reserved /
701         DE_BMAPLE_LCS_CAPABILITY,       / LCS Capability /
702         DE_BMAPLE_PACKET_MEAS_REP,      / Packet Measurement Report /
703         DE_BMAPLE_MEAS_CELL_ID,         / Measured Cell Identity /
704         DE_BMAPLE_IMEI,                         / IMEI /
705         BMAPLE_NONE                                     / NONE /
706 }
707 bssmap_le_elem_idx_t;
708 */
709
710
711 guint16 (*bssmap_le_elem_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string, int string_len) = {
712         /* NOTE: The null types below are defined elsewhere. i.e in packet-gsm_a_bssmap.c */
713         de_bmaple_lcs_qos,                              /* 10.16 LCS QoS */
714         NULL,                                                   /* LCS Priority */
715         NULL,                                                   /* 10.18 Location Type */
716         be_ganss_loc_type,                              /* GANSS Location Type */
717         NULL,                                                   /* 10.9 Geographic Location */
718         de_bmaple_pos_dta,                              /* 10.20 Positioning Data */
719         be_ganss_pos_dta,                               /* GANSS Positioning Data */
720         NULL,                                                   /* Velocity Data */
721         de_bmaple_cause,                                /* 10.13 LCS Cause */
722         de_bmaple_client,                               /* LCS Client Type */
723         de_bmaple_apdu,                                 /* APDU */
724         NULL,                                                   /* Network Element Identity */
725         de_bmaple_req_gps_ass_data,             /* 10.10 Requested GPS Assistance Data */
726         be_ganss_ass_dta,                               /* Requested GANSS Assistance Data */
727         de_bmaple_decihp_keys,                  /* 10.8 Deciphering Keys */
728         NULL,                                                   /* Return Error Request */
729         NULL,                                                   /* Return Error Cause */
730         NULL,                                                   /* Segmentation */
731         NULL,                                                   /* 10.7 Classmark Information Type 3 */
732         NULL,                                                   /* Cause */
733         NULL,                                                   /* Cell Identifier */
734         NULL,                                                   /* 10.6 Chosen Channel */
735         de_mid,                                                 /* 10.11 IMSI */
736         NULL,                                                   /* Reserved */
737         NULL,                                                   /* Reserved */
738         NULL,                                                   /* Reserved */
739         be_lcs_capability,                              /* LCS Capability */
740         be_packet_meas_rep,                             /* Packet Measurement Report */
741         be_measured_cell_identity,              /* Measured Cell Identity List */
742         de_mid,                                                 /* IMEI (use same dissector as IMSI) */
743
744         NULL,   /* NONE */
745
746 };
747
748 /*
749  * 9.1 PERFORM LOCATION REQUEST
750  */
751 static void
752 bssmap_le_perf_loc_request(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
753 {
754         guint32 curr_offset;
755         guint32 consumed;
756         guint   curr_len;
757
758         curr_offset = offset;
759         curr_len = len;
760
761         /* Location Type 9.1.1 M 3-n */
762         ELEM_MAND_TLV(BSSMAP_LE_LOCATION_TYPE, GSM_A_PDU_TYPE_BSSMAP, BE_LOC_TYPE, NULL)
763         /* Cell Identifier 9.1.2 O 5-10 */
764         ELEM_MAND_TLV(BSSMAP_LE_CELL_IDENTIFIER, GSM_A_PDU_TYPE_BSSMAP, BE_CELL_ID, NULL);
765         /* Classmark Information Type 3 9.1.3 O 3-14 */
766         ELEM_OPT_TLV(BSSMAP_LE_CLASSMARK_INFORMATION_TYPE_3, GSM_A_PDU_TYPE_BSSMAP, BE_CM_INFO_3, NULL);
767         /* LCS Client Type 9.1.4 C (note 3) 3-n */
768         ELEM_OPT_TLV(BSSMAP_LE_LCS_CLIENT_TYPE, GSM_PDU_TYPE_BSSMAP_LE, DE_BMAPLE_LCS_CLIENT_TYPE, NULL);
769         /* Chosen Channel 9.1.5 O 2 */
770         ELEM_OPT_TV(BSSMAP_LE_CHOSEN_CHANNEL, GSM_A_PDU_TYPE_BSSMAP, BE_CHOSEN_CHAN, NULL);
771         /* LCS Priority 9.1.6 O 3-n */
772         ELEM_OPT_TLV(BSSMAP_LE_LCS_PRIORITY, GSM_A_PDU_TYPE_BSSMAP, BE_LCS_PRIO, NULL);
773         /* LCS QoS 9.1.6a C (note 1) 3-n */
774         ELEM_OPT_TLV(BSSMAP_LE_LCS_QOS, GSM_PDU_TYPE_BSSMAP_LE, DE_BMAPLE_LCSQOS, NULL);
775         /* GPS Assistance Data 9.1.7 C (note 2) 3-n */
776         ELEM_OPT_TLV(BSSMAP_LE_REQUESTED_GPS_ASSISTANCE_DATA, GSM_A_PDU_TYPE_BSSMAP, BE_GPS_ASSIST_DATA, NULL);
777         /* APDU 9.1.8 O 3-n */
778         ELEM_OPT_TLV(BSSMAP_LE_APDU, GSM_PDU_TYPE_BSSMAP_LE, DE_BMAPLE_APDU, NULL);
779         /* LCS Capability 9.1.9 O */
780         ELEM_OPT_TLV(BSSMAP_LE_LCS_CAPABILITY, GSM_PDU_TYPE_BSSMAP_LE, DE_BMAPLE_LCS_CAPABILITY, NULL);
781         /* Packet Measurement Report 9.1.10 O*/
782         ELEM_OPT_TLV(BSSMAP_LE_PACKET_MEASUREMENT_REPORT, GSM_PDU_TYPE_BSSMAP_LE, DE_BMAPLE_PACKET_MEAS_REP, NULL);
783         /* Measured Cell Identity List 9.1.11 O*/
784         ELEM_OPT_TLV(BSSMAP_LE_CELL_IDENTITY_LIST, GSM_PDU_TYPE_BSSMAP_LE, DE_BMAPLE_MEAS_CELL_ID, NULL);
785         /* IMSI 9.1.12  O (note 4)      5-10 */
786         ELEM_OPT_TLV(BSSMAP_LE_IMSI, GSM_PDU_TYPE_BSSMAP_LE, DE_BMAPLE_IMSI, NULL);
787         /* IMEI 9.1.13  O (note 4)      10 (use same decode as IMSI) */
788         ELEM_OPT_TLV(BSSMAP_LE_IMEI, GSM_PDU_TYPE_BSSMAP_LE, DE_BMAPLE_IMEI, NULL);
789         /* GANSS Location Type  9.1.14  C       3 */
790         ELEM_OPT_TLV(BSSMAP_LE_GANSS_LOCATION_TYPE, GSM_PDU_TYPE_BSSMAP_LE, DE_BMAPLE_GANSS_LOC_TYPE, NULL);
791         /* GANSS Assistance Data        9.1.15  C (note 5)      3-n */
792         ELEM_OPT_TLV(BSSMAP_LE_REQUESTED_GANSS_ASSISTANCE_DATA, GSM_PDU_TYPE_BSSMAP_LE, DE_BMAPLE_REQ_GNSS_ASSIST_D, NULL);
793
794         EXTRANEOUS_DATA_CHECK(curr_len, 0);
795
796 }
797
798 /*
799  * 9.2 PERFORM LOCATION RESPONSE
800  */
801 static void
802 bssmap_le_perf_loc_resp(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
803 {
804         guint32 curr_offset;
805         guint32 consumed;
806         guint   curr_len;
807
808         curr_offset = offset;
809         curr_len = len;
810
811         /* Location Estimate 9.2.1 C (note 1) 3-n */
812         ELEM_OPT_TLV(BSSMAP_LE_GEOGRAPHIC_LOCATION, BSSAP_PDU_TYPE_BSSMAP, BE_LOC_EST, NULL);
813         /* Positioning Data 9.2.2 O 3-n */
814         ELEM_OPT_TLV(BSSMAP_LE_POSITIONING_DATA, GSM_PDU_TYPE_BSSMAP_LE, DE_BMAPLE_POS_DATA, NULL);
815         /* Deciphering Keys 9.2.3 C (note 2) 3-n */
816         ELEM_OPT_TLV(BSSMAP_LE_DECIPHERING_KEYS, GSM_PDU_TYPE_BSSMAP_LE, DE_BMAPLE_DECIPH_KEYS, NULL);
817         /* LCS Cause 9.2.4 C (note 3) 3-n */
818         ELEM_OPT_TLV(BSSMAP_LE_LCS_CAUSE, GSM_PDU_TYPE_BSSMAP_LE, DE_BMAPLE_LCS_CAUSE, NULL);
819         /* Velocity Estimate    9.2.5   O       3-n */
820         ELEM_OPT_TLV(BSSMAP_LE_VELOCITY_DATA, BSSAP_PDU_TYPE_BSSMAP, BE_VEL_EST, NULL);
821         /* GANSS Positioning Data       9.2.6   O       3-n */
822         ELEM_OPT_TLV(BSSMAP_LE_GANSS_POSITIONING_DATA, GSM_PDU_TYPE_BSSMAP_LE, DE_BMAPLE_GANSS_POS_DATA, NULL);
823
824         EXTRANEOUS_DATA_CHECK(curr_len, 0);
825 }
826
827 /*
828  * 9.8 CONNECTION ORIENTED INFORMATION
829  */
830 static void
831 bssmap_le_connection_oriented(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
832 {
833         guint32 curr_offset;
834         guint32 consumed;
835         guint   curr_len;
836
837         curr_offset = offset;
838         curr_len = len;
839
840         /* APDU 9.8.1 M 3-n */
841         ELEM_MAND_TLV(BSSMAP_LE_APDU, GSM_PDU_TYPE_BSSMAP_LE, DE_BMAPLE_APDU, NULL);
842         /* Segmentation 9.8.2 */
843         ELEM_OPT_TLV(BSSMAP_LE_SEGMENTATION, BSSAP_PDU_TYPE_BSSMAP, BE_SEG, NULL);
844
845         EXTRANEOUS_DATA_CHECK(curr_len, 0);
846 }
847
848 /*
849  * 9.9  CONNECTIONLESS INFORMATION
850  *
851 Network Element Identity (source)       3.2.2.69        Both    M       3-n
852 Network Element Identity (target)       3.2.2.69        Both    M       3-n
853 APDU    3.2.2.68        Both    M       3-n
854 Segmentation    3.2,2,74        Both    C (note 1)      5
855 Return Error Request    3.2.2.72        Both    C (note 2)      3-n
856 Return Error Cause      3.2.2.73        Both    C (note 3)      3-n
857 */
858
859 /*
860  * 9.11 RESET ACKNOWLEDGE
861  * no data
862  */
863
864 /*
865  * 9.12 PERFORM LOCATION INFORMATION
866  */
867 static void
868 bssmap_le_perf_loc_info(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
869 {
870         guint32 curr_offset;
871         guint32 consumed;
872         guint   curr_len;
873
874         curr_offset = offset;
875         curr_len = len;
876
877         /* Cell Identifier 9.12.1 M */
878         ELEM_MAND_TLV(BSSMAP_LE_CELL_IDENTIFIER, GSM_A_PDU_TYPE_BSSMAP, BE_CELL_ID, NULL);
879         /* APDU 9.1.8 O 3-n */
880         ELEM_OPT_TLV(BSSMAP_LE_APDU, GSM_PDU_TYPE_BSSMAP_LE, DE_BMAPLE_APDU, NULL);
881
882         EXTRANEOUS_DATA_CHECK(curr_len, 0);
883 }
884
885 static void (*bssmap_le_msg_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) = {
886         NULL,
887         NULL,
888         NULL,
889         NULL,
890         NULL,
891         bssmap_le_perf_loc_request,     /* Perform Location Request */
892         bssmap_le_perf_loc_resp,        /* Perform Location Response */
893         bssmap_perf_loc_abort,          /* Abort */
894         bssmap_le_perf_loc_info,        /* Perform Location Information */
895         bssmap_le_connection_oriented,  /* Connection Oriented Information */
896         NULL,                                           /* Connectionless Information */
897         bssmap_reset,                           /* Reset */
898         NULL,           /* Reset Acknowledge */
899
900         NULL,   /* NONE */
901 };
902
903 void
904 dissect_bssmap_le(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
905 {
906         static gsm_a_tap_rec_t  tap_rec[4];
907         static gsm_a_tap_rec_t  *tap_p;
908         static guint                    tap_current=0;
909         guint8  oct;
910         guint32 offset, saved_offset;
911         guint32 len;
912         gint    idx;
913         proto_item      *bssmap_le_item = NULL;
914         proto_tree      *bssmap_le_tree = NULL;
915         const gchar     *str;
916         sccp_msg_info_t* sccp_msg_p;
917
918         sccp_msg_p = pinfo->sccp_info;
919
920         if (!(sccp_msg_p && sccp_msg_p->data.co.assoc)) {
921                 sccp_msg_p = NULL;
922         }
923
924         col_append_str(pinfo->cinfo, COL_INFO, "(BSSMAP LE) ");
925
926         /*
927          * set tap record pointer
928          */
929         tap_current++;
930         if (tap_current >= 4)
931         {
932                 tap_current = 0;
933         }
934         tap_p = &tap_rec[tap_current];
935
936
937         offset = 0;
938         saved_offset = offset;
939
940         g_tree = tree;
941
942         len = tvb_length(tvb);
943
944         /*
945          * add BSSMAP message name
946          */
947         oct = tvb_get_guint8(tvb, offset++);
948
949         str = try_val_to_str_idx((guint32) oct, gsm_bssmap_le_msg_strings, &idx);
950
951         if (sccp_msg_p && !sccp_msg_p->data.co.label) {
952                 sccp_msg_p->data.co.label = wmem_strdup(wmem_file_scope(),
953                                                                                                 val_to_str((guint32) oct,
954                                                                                                 gsm_bssmap_le_msg_strings, "BSSMAP LE(0x%02x)"));
955         }
956
957         /*
958          * create the protocol tree
959          */
960         if (str == NULL)
961         {
962                 bssmap_le_item =
963                 proto_tree_add_protocol_format(tree, proto_bssmap_le, tvb, 0, len,
964                         "Lb - I/F BSSMAP LE - Unknown BSSMAP Message Type (0x%02x)",
965                         oct);
966
967                 bssmap_le_tree = proto_item_add_subtree(bssmap_le_item, ett_bssmap_le_msg);
968         }
969         else
970         {
971                 bssmap_le_item =
972                 proto_tree_add_protocol_format(tree, proto_bssmap_le, tvb, 0, -1,
973                         "Lb - I/F BSSMAP LE - %s",
974                         str);
975
976                 bssmap_le_tree = proto_item_add_subtree(bssmap_le_item, ett_gsm_bssmap_le_msg[idx]);
977
978                 col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", str);
979
980                 /*
981                  * add BSSMAP message name
982                  */
983                 proto_tree_add_uint_format(bssmap_le_tree, hf_gsm_bssmap_le_msg_type,
984                 tvb, saved_offset, 1, oct, "Message Type %s",str);
985         }
986
987         tap_p->pdu_type = BSSAP_PDU_TYPE_BSSMAP;
988         tap_p->message_type = oct;
989
990         tap_queue_packet(gsm_a_tap, pinfo, tap_p);
991
992         if (str == NULL) return;
993
994         if (offset >= len) return;
995
996         /*
997          * decode elements
998          */
999         if (bssmap_le_msg_fcn[idx] == NULL)
1000         {
1001                 proto_tree_add_text(bssmap_le_tree,
1002                         tvb, offset, len - offset,
1003                         "Message Elements");
1004         }
1005         else
1006         {
1007                 (*bssmap_le_msg_fcn[idx])(tvb, bssmap_le_tree, pinfo, offset, len - offset);
1008         }
1009 }
1010
1011 /* Register the protocol with Wireshark */
1012 void
1013 proto_register_gsm_bssmap_le(void)
1014 {
1015         guint           i;
1016         guint           last_offset;
1017
1018         /* Setup list of header fields */
1019         static hf_register_info hf[] = {
1020                 { &hf_gsm_bssmap_le_msg_type,
1021                   { "BSSMAP LE Message Type",   "gsm_bssmap_le.msgtype",
1022                     FT_UINT8, BASE_HEX, VALS(gsm_bssmap_le_msg_strings), 0x0,
1023                     NULL, HFILL }
1024                 },
1025                 { &hf_gsm_bssmap_le_elem_id,
1026                   { "Element ID",       "gsm_bssmap_le.elem_id",
1027                     FT_UINT8, BASE_HEX, NULL, 0,
1028                     NULL, HFILL }
1029                 },
1030                 { &hf_gsm_bssmap_le_apdu_protocol_id,
1031                   { "Protocol ID", "gsm_bssmap_le.apdu_protocol_id",
1032                     FT_UINT8, BASE_DEC, VALS(gsm_apdu_protocol_id_strings), 0x0,
1033                     "APDU embedded protocol id", HFILL }
1034                 },
1035                 { &hf_gsm_bssmap_le_spare,
1036                   { "Spare", "gsm_bssmap_le.spare",
1037                     FT_UINT8, BASE_HEX, NULL, 0x0,
1038                     NULL, HFILL}
1039                 },
1040                 { &hf_gsm_bssmap_le_ciphering_key_flag,
1041                   { "Ciphering Key Flag", "gsm_bssmap_le.decipheringKeys.flag",
1042                     FT_UINT8, BASE_DEC, NULL, 0x0,
1043                     NULL, HFILL}
1044                 },
1045                 { &hf_gsm_bssmap_le_current_deciphering_key_value,
1046                   { "Current Deciphering Key Value", "gsm_bssmap_le.decipheringKeys.current",
1047                     FT_UINT64, BASE_HEX, NULL, 0x0, NULL,
1048                     HFILL}
1049                 },
1050                 { &hf_gsm_bssmap_le_next_deciphering_key_value,
1051                   { "Next Deciphering Key Value", "gsm_bssmap_le.decipheringKeys.next",
1052                     FT_UINT64, BASE_HEX, NULL, 0x0,
1053                     NULL, HFILL}
1054                 },
1055                 { &hf_gsm_bssmap_le_acq_ass,
1056           { "Acquisition Assistance", "gsm_bssmap_le.acq_ass",
1057             FT_BOOLEAN, 8, TFS(&tfs_requested_not_requested), 0x80,
1058             NULL, HFILL }
1059                 },
1060                 { &hf_gsm_bssmap_le_ref_time,
1061           { "Reference Time", "gsm_bssmap_le.ref_time",
1062             FT_BOOLEAN, 8, TFS(&tfs_requested_not_requested), 0x40,
1063             NULL, HFILL }
1064                 },
1065                 { &hf_gsm_bssmap_le_ref_loc,
1066           { "Reference Location", "gsm_bssmap_le.ref_loc",
1067             FT_BOOLEAN, 8, TFS(&tfs_requested_not_requested), 0x20,
1068             NULL, HFILL }
1069                 },
1070                 { &hf_gsm_bssmap_le_dgps_corr,
1071           { "DGPS Corrections", "gsm_bssmap_le.gps_corr",
1072             FT_BOOLEAN, 8, TFS(&tfs_requested_not_requested), 0x08,
1073             NULL, HFILL }
1074                 },
1075                 { &hf_gsm_bssmap_le_nav_mod,
1076           { "Navigation Model", "gsm_bssmap_le.nav_mod",
1077             FT_BOOLEAN, 8, TFS(&tfs_requested_not_requested), 0x10,
1078             NULL, HFILL }
1079                 },
1080                 { &hf_gsm_bssmap_le_iono_mod,
1081           { "Ionospheric Model", "gsm_bssmap_le.iono_mod",
1082             FT_BOOLEAN, 8, TFS(&tfs_requested_not_requested), 0x04,
1083             NULL, HFILL }
1084                 },
1085                 { &hf_gsm_bssmap_le_utc_mod,
1086           { "UTC Model", "gsm_bssmap_le.utc_mod",
1087             FT_BOOLEAN, 8, TFS(&tfs_requested_not_requested), 0x02,
1088             NULL, HFILL }
1089                 },
1090                 { &hf_gsm_bssmap_le_almanac,
1091           { "Almanac", "gsm_bssmap_le.almanac",
1092             FT_BOOLEAN, 8, TFS(&tfs_requested_not_requested), 0x01,
1093             NULL, HFILL }
1094                 },
1095                 { &hf_gsm_bssmap_le_ephemeris_ext_chk,
1096           { "Ephemeris Extension Check", "gsm_bssmap_le.ephemeris_ext_chk",
1097             FT_BOOLEAN, 8, TFS(&tfs_requested_not_requested), 0x04,
1098             NULL, HFILL }
1099                 },
1100                 { &hf_gsm_bssmap_le_ephemeris_ext,
1101           { "Ephemeris Extension", "gsm_bssmap_le.ephemeris_ext",
1102             FT_BOOLEAN, 8, TFS(&tfs_requested_not_requested), 0x02,
1103             NULL, HFILL }
1104                 },
1105                 { &hf_gsm_bssmap_le_real_time_int,
1106           { "Real-Time Integrity", "gsm_bssmap_le.real_time_int",
1107             FT_BOOLEAN, 8, TFS(&tfs_requested_not_requested), 0x01,
1108             NULL, HFILL }
1109                 },
1110                 { &hf_gsm_bssmap_le_lcs_cause_value,
1111                   { "Cause Value", "gsm_bssmap_le.lcsCauseValue",
1112                     FT_UINT8, BASE_HEX, VALS(bssmap_le_lcs_cause_values), 0x0,
1113                     NULL, HFILL}
1114                 },
1115                 { &hf_gsm_bssmap_le_diagnostic_value,
1116                   { "Diagnostic Value", "gsm_bssmap_le.diagnosticValue",
1117                     FT_UINT8, BASE_HEX, VALS(bssmap_le_position_method_failure_diagnostic_vals), 0x0,
1118                     NULL, HFILL}
1119                 },
1120                 { &hf_gsm_bssmap_le_client_category,
1121                   { "Client Category", "gsm_bssmap_le.lcsClientType.clientCategory",
1122                     FT_UINT8, BASE_HEX, VALS(bssmap_le_client_category), 0x0,
1123                     NULL, HFILL}
1124                 },
1125                 { &hf_gsm_bssmap_le_client_subtype,
1126                   { "Client Subtype", "gsm_bssmap_le.lcsClientType.clientSubtype",
1127                     FT_UINT8, BASE_HEX, VALS(bssmap_le_client_subtype), 0x0,
1128                     NULL, HFILL}
1129                 },
1130                 { &hf_gsm_bssmap_le_velocity_requested,
1131                   { "Velocity Requested", "gsm_bssmap_le.lcsQos.velocityRequested",
1132                     FT_UINT8, BASE_HEX, VALS(bssmap_le_velocity_requested_vals), 0x0,
1133                     NULL, HFILL}
1134                 },
1135                 { &hf_gsm_bssmap_le_vertical_coordinate_indicator,
1136                   { "Vertical Coordinate Indicator", "gsm_bssmap_le.lcsQos.verticalCoordinateIndicator",
1137                     FT_UINT8, BASE_HEX, VALS(bssmap_le_vertical_coordinate_indicator_vals), 0x0,
1138                     NULL, HFILL}
1139                 },
1140                 { &hf_gsm_bssmap_le_horizontal_accuracy_indicator,
1141                   { "Horizontal Accuracy Indicator", "gsm_bssmap_le.lcsQos.horizontalAccuracyIndicator",
1142                     FT_UINT8, BASE_HEX, VALS(bssmap_le_horizontal_accuracy_indicator_vals), 0x0,
1143                     NULL, HFILL}
1144                 },
1145                 { &hf_gsm_bssmap_le_horizontal_accuracy,
1146                   { "Horizontal Accuracy", "gsm_bssmap_le.lcsQos.horizontalAccuracy",
1147                     FT_UINT8, BASE_HEX, NULL, 0x0,
1148                     NULL, HFILL}
1149                 },
1150                 { &hf_gsm_bssmap_le_vertical_accuracy,
1151                   { "Vertical Accuracy", "gsm_bssmap_le.lcsQos.verticalAccuracy",
1152                     FT_UINT8, BASE_HEX, NULL, 0x0,
1153                     NULL, HFILL}
1154                 },
1155                 { &hf_gsm_bssmap_le_vertical_accuracy_indicator,
1156                   { "Vertical Accuracy Indicator", "gsm_bssmap_le.lcsQos.verticalAccuracyIndicator",
1157                     FT_UINT8, BASE_HEX, VALS(bssmap_le_vertical_accuracy_indicator_vals), 0x0,
1158                     NULL, HFILL}
1159                 },
1160                 { &hf_gsm_bssmap_le_response_time_category,
1161                   { "Response Time Category", "gsm_bssmap_le.lcsQos.responseTimeCategory",
1162                     FT_UINT8, BASE_HEX, VALS(bssmap_le_response_time_definitions_vals), 0x0,
1163                     NULL, HFILL}
1164                 },
1165
1166         };
1167         /* Setup protocol subtree array */
1168 #define NUM_INDIVIDUAL_ELEMS    1
1169         gint *ett[NUM_INDIVIDUAL_ELEMS + NUM_GSM_BSSMAP_LE_MSG +
1170                   NUM_GSM_BSSMAP_LE_ELEM];
1171
1172         ett[0] = &ett_bssmap_le_msg;
1173
1174         last_offset = NUM_INDIVIDUAL_ELEMS;
1175
1176         for (i=0; i < NUM_GSM_BSSMAP_LE_MSG; i++, last_offset++)
1177         {
1178                 ett_gsm_bssmap_le_msg[i] = -1;
1179                 ett[last_offset] = &ett_gsm_bssmap_le_msg[i];
1180         }
1181
1182         for (i=0; i < NUM_GSM_BSSMAP_LE_ELEM; i++, last_offset++)
1183         {
1184                 ett_gsm_bssmap_le_elem[i] = -1;
1185                 ett[last_offset] = &ett_gsm_bssmap_le_elem[i];
1186         }
1187
1188         /* Register the protocol name and description */
1189
1190         proto_bssmap_le =
1191                 proto_register_protocol("Lb-I/F BSSMAP LE", "GSM BSSMAP LE", "gsm_bssmap_le");
1192
1193         proto_register_field_array(proto_bssmap_le, hf, array_length(hf));
1194
1195         proto_register_subtree_array(ett, array_length(ett));
1196
1197         register_dissector("gsm_bssmap_le", dissect_bssmap_le, proto_bssmap_le);
1198 }
1199
1200 void
1201 proto_reg_handoff_gsm_bssmap_le(void)
1202 {
1203         dissector_handle_t bssmap_le_handle;
1204
1205         bssmap_le_handle = find_dissector("gsm_bssmap_le");
1206
1207         dissector_add_uint("bssap.pdu_type",  BSSAP_PDU_TYPE_BSSMAP, bssmap_le_handle);
1208
1209         gsm_bsslap_handle = find_dissector("gsm_bsslap");
1210 }