2 * Routines for Base Station Subsystem Application Part (BSSAP/BSAP) dissection
3 * Specifications from 3GPP2 (www.3gpp2.org) and 3GPP (www.3gpp.org)
7 * Copyright 2003, Michael Lum <mlum [AT] telostech.com>
8 * In association with Telos Technology Inc.
10 * Added BSSAP+ according to ETSI TS 129 018 V6.3.0 (2005-3GPP TS 29.018 version 6.3.0 Release 6)
11 * Copyright 2006, Anders Broman <Anders.Broman [AT] ericsson.com>
15 * Wireshark - Network traffic analyzer
16 * By Gerald Combs <gerald@wireshark.org>
17 * Copyright 1998 Gerald Combs
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version 2
22 * of the License, or (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
40 #ifdef HAVE_SYS_TYPES_H
41 # include <sys/types.h>
44 #ifdef HAVE_NETINET_IN_H
45 # include <netinet/in.h>
48 #include <epan/packet.h>
49 #include <epan/prefs.h>
50 #include <epan/emem.h>
52 #include "packet-bssap.h"
53 #include "packet-sccp.h"
54 #include "packet-gsm_a_common.h"
55 #include "packet-e212.h"
57 void proto_reg_handoff_bssap(void);
62 #define GSM_INTERFACE 0
63 #define LB_INTERFACE 1
65 #define BSSAP_OR_BSAP_DEFAULT BSSAP
67 #define GSM_OR_LB_INTERFACE_DEFAULT GSM_INTERFACE
69 #define PDU_TYPE_OFFSET 0
70 #define PDU_TYPE_LENGTH 1
72 /* Same as below but with names typed out */
73 static const value_string bssap_pdu_type_values[] = {
74 { BSSAP_PDU_TYPE_BSSMAP, "BSS Management" },
75 { BSSAP_PDU_TYPE_DTAP, "Direct Transfer" },
78 static const value_string bsap_pdu_type_values[] = {
79 { BSSAP_PDU_TYPE_BSSMAP, "BS Management" },
80 { BSSAP_PDU_TYPE_DTAP, "Direct Transfer" },
83 /* Same as above but in acronym for (for the Info column) */
84 static const value_string bssap_pdu_type_acro_values[] = {
85 { BSSAP_PDU_TYPE_BSSMAP, "BSSMAP" },
86 { BSSAP_PDU_TYPE_DTAP, "DTAP" },
89 /* Same as above but in acronym for (for the Info column) */
90 static const value_string bsap_pdu_type_acro_values[] = {
91 { BSSAP_PDU_TYPE_BSSMAP, "BSMAP" },
92 { BSSAP_PDU_TYPE_DTAP, "DTAP" },
95 #define PARAMETER_DLCI 0x00
96 #define PARAMETER_LENGTH 0x01
97 #define PARAMETER_DATA 0x02
100 #define LENGTH_LENGTH 1
101 #define DATA_LENGTH 1
104 #define SPARE_MASK 0x38
105 #define SAPI_MASK 0x07
107 static guint global_bssap_ssn = 98;
109 static const value_string bssap_cc_values[] = {
110 { 0x00, "not further specified" },
111 { 0x80, "FACCH or SDCCH" },
115 static const value_string bsap_cc_values[] = {
116 { 0x00, "default for TIA/EIA/IS-2000" },
119 static const value_string bssap_sapi_values[] = {
120 { 0x00, "RR/MM/CC" },
124 static const value_string bsap_sapi_values[] = {
125 { 0x00, "Not used" },
128 #define BSSAP_PAGING_REQUEST 1
129 #define BSSAP_PAGING_REJECT 2 /* 17.1.18 */
130 #define BSSAP_DOWNLINK_TUNNEL_REQUEST 7 /* 17.1.4 */
131 #define BSSAP_UPLINK_TUNNEL_REQUEST 8 /* 17.1.23 */
132 #define BSSAP_LOCATION_UPDATE_REQUEST 9 /* 17.1.11 */
133 #define BSSAP_LOCATION_UPDATE_ACCEPT 10 /* 17.1.9 */
134 #define BSSAP_LOCATION_UPDATE_REJECT 11 /* 17.1.10 */
135 #define BSSAP_TMSI_REALLOCATION_COMPLETE 12 /* 17.1.22 */
136 #define BSSAP_ALERT_REQUEST 13 /* 17.1.3 */
137 #define BSSAP_ALERT_ACK 14 /* 17.1.1 */
138 #define BSSAP_ALERT_REJECT 15 /* 17.1.2 */
139 #define BSSAP_MS_ACTIVITY_INDICATION 16 /* 17.1.14 */
140 #define BSSAP_GPRS_DETACH_INDICATION 17 /* 17.1.6 */
141 #define BSSAP_GPRS_DETACH_ACK 18 /* 17.1.5 */
142 #define BSSAP_IMSI_DETACH_INDICATION 19 /* 17.1.8 */
143 #define BSSAP_IMSI_DETACH_ACK 20 /* 17.1.7 */
144 #define BSSAP_RESET_INDICATION 21 /* 17.1.21 */
145 #define BSSAP_RESET_ACK 22 /* 17.1.20 */
146 #define BSSAP_MS_INFORMATION_REQUEST 23 /* 17.1.15 */
147 #define BSSAP_MS_INFORMATION_RESPONSE 24 /* 17.1.16 */
148 #define BSSAP_MM_INFORMATION_REQUEST 26 /* 17.1.12 */
149 #define BSSAP_MOBILE_STATUS 29 /* 17.1.13 */
150 #define BSSAP_MS_UNREACHABLE 31 /* 17.1.17 */
152 static const value_string bssap_plus_message_type_values[] = {
153 { 0x00, "Unassigned: treated as an unknown Message type." },
154 { BSSAP_PAGING_REQUEST, "BSSAP+-PAGING-REQUEST" }, /* 17.1.19 */
155 { BSSAP_PAGING_REJECT, "BSSAP+-PAGING-REJECT" }, /* 17.1.18 */
156 { 0x03, "Unassigned: treated as an unknown Message type." },
157 { 0x04, "Unassigned: treated as an unknown Message type." },
158 { 0x05, "Unassigned: treated as an unknown Message type." },
159 { 0x06, "Unassigned: treated as an unknown Message type." },
160 { BSSAP_DOWNLINK_TUNNEL_REQUEST, "BSSAP+-DOWNLINK-TUNNEL-REQUEST" }, /* 17.1.4 */
161 { BSSAP_UPLINK_TUNNEL_REQUEST, "BSSAP+-UPLINK-TUNNEL-REQUEST" }, /* 17.1.23 */
162 { BSSAP_LOCATION_UPDATE_REQUEST, "BSSAP+-LOCATION-UPDATE-REQUEST" }, /* 17.1.11 */
163 { BSSAP_LOCATION_UPDATE_ACCEPT, "BSSAP+-LOCATION-UPDATE-ACCEPT" }, /* 17.1.9 */
164 { BSSAP_LOCATION_UPDATE_REJECT, "BSSAP+-LOCATION-UPDATE-REJECT" }, /* 17.1.10 */
165 { BSSAP_TMSI_REALLOCATION_COMPLETE, "BSSAP+-TMSI-REALLOCATION-COMPLETE" }, /* 17.1.22 */
166 { BSSAP_ALERT_REQUEST, "BSSAP+-ALERT-REQUEST" }, /* 17.1.3 */
167 { BSSAP_ALERT_ACK, "BSSAP+-ALERT-ACK" }, /* 17.1.1 */
168 { BSSAP_ALERT_REJECT, "BSSAP+-ALERT-REJECT" }, /* 17.1.2 */
169 { BSSAP_MS_ACTIVITY_INDICATION, "BSSAP+-MS-ACTIVITY-INDICATION" }, /* 17.1.14 */
170 { BSSAP_GPRS_DETACH_INDICATION, "BSSAP+-GPRS-DETACH-INDICATION" }, /* 17.1.6 */
171 { BSSAP_GPRS_DETACH_ACK, "BSSAP+-GPRS-DETACH-ACK" }, /* 17.1.5 */
172 { BSSAP_IMSI_DETACH_INDICATION, "BSSAP+-IMSI-DETACH-INDICATION" }, /* 17.1.8 */
173 { BSSAP_IMSI_DETACH_ACK, "BSSAP+-IMSI-DETACH-ACK" }, /* 17.1.7 */
174 { BSSAP_RESET_INDICATION, "BSSAP+-RESET-INDICATION" }, /* 17.1.21 */
175 { BSSAP_RESET_ACK, "BSSAP+-RESET-ACK" }, /* 17.1.20 */
176 { BSSAP_MS_INFORMATION_REQUEST, "BSSAP+-MS-INFORMATION-REQUEST" }, /* 17.1.15 */
177 { BSSAP_MS_INFORMATION_RESPONSE, "BSSAP+-MS-INFORMATION-RESPONSE" }, /* 17.1.16 */
178 { 0x19, "Unassigned: treated as an unknown Message type." },
179 { BSSAP_MM_INFORMATION_REQUEST, "BSSAP+-MM-INFORMATION-REQUEST" }, /* 17.1.12 */
180 { BSSAP_MOBILE_STATUS, "BSSAP+-MOBILE-STATUS" }, /* 17.1.13 */
181 { 0x1e, "Unassigned: treated as an unknown Message type." },
182 { BSSAP_MS_UNREACHABLE, "BSSAP+-MS-UNREACHABLE" }, /* 17.1.17 */
187 #define BSSAP_VLR_NUMBER 2
189 #define BSSAP_LOC_AREA_ID 4
190 #define BSSAP_CHANNEL_NEEDED 5
191 #define BSSAP_EMLPP_PRIORITY 6
192 #define BSSAP_TMSI_STATUS 7
193 #define BSSAP_GS_CAUSE 8
194 #define BSSAP_SGSN_NUMBER 9
195 #define BSSAP_GPRS_LOC_UPD_TYPE 0x0a
196 #define BSSAP_GLOBAL_CN_ID 0x0b
197 #define BSSAP_MOBILE_STN_CLS_MRK1 0x0d
198 #define BSSAP_MOBILE_ID 0x0e
199 #define BSSAP_REJECT_CAUSE 0x0f
200 #define BSSAP_IMSI_DET_FROM_GPRS_SERV_TYPE 0x10
201 #define BSSAP_IMSI_DET_FROM_NON_GPRS_SERV_TYPE 0x11
202 #define BSSAP_INFO_REQ 0x12
203 #define BSSAP_PTMSI 0x13
204 #define BSSAP_IMEI 0x14
205 #define BSSAP_IMEISV 0x15
206 #define BSSAP_MM_INFORMATION 0x17
207 #define BSSAP_CELL_GBL_ID 0x18
208 #define BSSAP_LOC_INF_AGE 0x19
209 #define BSSAP_MOBILE_STN_STATE 0x1a
210 #define BSSAP_SERVICE_AREA_ID 0x1e
211 #define BSSAP_ERRONEOUS_MSG 0x1b
212 #define BSSAP_DLINK_TNL_PLD_CTR_AND_INF 0x1c
213 #define BSSAP_ULINK_TNL_PLD_CTR_AND_INF 0x1d
217 static const value_string bssap_plus_ie_id_values[] = {
218 { BSSAP_IMSI, "IMSI" }, /* 18.4.10 */
219 { BSSAP_VLR_NUMBER, "VLR number" }, /* 18.4.26 */
220 { BSSAP_TMSI, "TMSI" }, /* 18.4.23 */
221 { BSSAP_LOC_AREA_ID, "Location area identifier" }, /* 18.4.14 */
222 { BSSAP_CHANNEL_NEEDED, "Channel Needed" }, /* 18.4.2 */
223 { BSSAP_EMLPP_PRIORITY, "eMLPP Priority" }, /* 18.4.4 */
224 { BSSAP_TMSI_STATUS, "TMSI status" }, /* 18.4.24 */
225 { BSSAP_GS_CAUSE, "Gs cause" }, /* 18.4.7 */
226 { BSSAP_SGSN_NUMBER, "SGSN number" }, /* 18.4.22 */
227 { BSSAP_GPRS_LOC_UPD_TYPE, "GPRS location update type" }, /* 18.4.6 */
228 { BSSAP_GLOBAL_CN_ID, "Global CN-Id" }, /* 18.4.27 */
229 { 0x0c, "Unassigned: treated as an unknown IEI." }, /* 18 and 16 */
230 { BSSAP_MOBILE_STN_CLS_MRK1, "Mobile station classmark 1" }, /* 18.4.18 */
231 { BSSAP_MOBILE_ID, "Mobile identity" }, /* 18.4.17 */
232 { BSSAP_REJECT_CAUSE, "Reject cause" }, /* 18.4.21 */
233 { BSSAP_IMSI_DET_FROM_GPRS_SERV_TYPE, "IMSI detach from GPRS service type" }, /* 18.4.11 */
234 { BSSAP_IMSI_DET_FROM_NON_GPRS_SERV_TYPE, "IMSI detach from non-GPRS service type" }, /* 18.4.12 */
235 { BSSAP_INFO_REQ, "Information requested" }, /* 18.4.13 */
236 { BSSAP_PTMSI, "PTMSI" }, /* 18.4.20 */
237 { BSSAP_IMEI, "IMEI" }, /* 18.4.8 */
238 { BSSAP_IMEISV, "IMEISV" }, /* 18.4.9 */
239 { 0x16, "Unassigned: treated as an unknown IEI." }, /* 18 and 16 */
240 { BSSAP_MM_INFORMATION, "MM information" }, /* 18.4.16 */
241 { BSSAP_CELL_GBL_ID, "Cell Global Identity" }, /* 18.4.1 */
242 { BSSAP_LOC_INF_AGE, "Location information age" }, /* 18.4.15 */
243 { BSSAP_MOBILE_STN_STATE, "Mobile station state" }, /* 18.4.19 */
244 { BSSAP_ERRONEOUS_MSG, "Erroneous message" }, /* 18.4.5 */
245 { BSSAP_DLINK_TNL_PLD_CTR_AND_INF, "Downlink Tunnel Payload Control and Info" }, /* 18.4.3 */
246 { BSSAP_ULINK_TNL_PLD_CTR_AND_INF, "Uplink Tunnel Payload Control and Info" }, /* 18.4.25 */
247 { BSSAP_SERVICE_AREA_ID, "Service Area Identification" }, /* 18.4.21b */
251 /* Initialize the protocol and registered fields */
252 static int proto_bssap = -1;
253 /*static int proto_bssap_plus = -1;*/
254 static int hf_bssap_pdu_type = -1;
255 static int hf_bsap_pdu_type = -1;
256 static int hf_bssap_dlci_cc = -1;
257 static int hf_bsap_dlci_cc = -1;
258 static int hf_bssap_dlci_spare = -1;
259 static int hf_bsap_dlci_rsvd = -1;
260 static int hf_bssap_dlci_sapi = -1;
261 static int hf_bsap_dlci_sapi = -1;
262 static int hf_bssap_length = -1;
263 static int hf_bssap_plus_ie = -1;
264 static int hf_bssap_plus_ie_len = -1;
266 static int hf_bssap_plus_message_type = -1;
267 static int hf_bssap_imsi_ie = -1;
268 static int hf_bssap_imsi_det_from_gprs_serv_type_ie = -1;
269 static int hf_bssap_imsi_det_from_non_gprs_serv_type_ie = -1;
270 static int hf_bssap_info_req_ie = -1;
271 static int hf_bssap_loc_area_id_ie = -1;
272 static int hf_bssap_loc_inf_age_ie = -1;
273 static int hf_bssap_mm_information_ie = -1;
274 static int hf_bssap_mobile_id_ie = -1;
275 static int hf_bssap_mobile_stn_cls_mrk1_ie = -1;
276 static int hf_bssap_mobile_station_state_ie = -1;
277 static int hf_bssap_ptmsi_ie = -1;
278 static int hf_bssap_reject_cause_ie = -1;
279 static int hf_bssap_service_area_id_ie = -1;
280 static int hf_bssap_sgsn_nr_ie = -1;
281 static int hf_bssap_tmsi_ie = -1;
282 static int hf_bssap_tmsi_status_ie = -1;
283 static int hf_bssap_vlr_number_ie = -1;
284 static int hf_bssap_global_cn_id_ie = -1;
285 static int hf_bssap_plus_ie_data = -1;
287 static int hf_bssap_extension = -1;
288 static int hf_bssap_type_of_number = -1;
289 static int hf_bssap_numbering_plan_id = -1;
290 static int hf_bssap_sgsn_number = -1;
291 static int hf_bssap_vlr_number = -1;
292 static int hf_bssap_call_priority = -1;
293 static int hf_bssap_gprs_loc_upd_type_ie = -1;
294 static int hf_bssap_Gs_cause_ie = -1;
295 static int hf_bssap_imei_ie = -1;
296 static int hf_bssap_imesiv_ie = -1;
297 static int hf_bssap_cell_global_id_ie = -1;
298 static int hf_bssap_channel_needed_ie = -1;
299 static int hf_bssap_dlink_tnl_pld_cntrl_amd_inf_ie = -1;
300 static int hf_bssap_ulink_tnl_pld_cntrl_amd_inf_ie = -1;
301 static int hf_bssap_emlpp_prio_ie = -1;
302 static int hf_bssap_gprs_erroneous_msg_ie = -1;
304 static int hf_bssap_gprs_loc_upd_type = -1;
305 static int hf_bssap_Gs_cause = -1;
306 static int hf_bssap_imei = -1;
307 static int hf_bssap_imeisv = -1;
308 static int hf_bssap_imsi = -1;
309 static int hf_bssap_imsi_det_from_gprs_serv_type = -1;
310 static int hf_bssap_info_req = -1;
311 static int hf_bssap_loc_inf_age = -1;
312 static int hf_bssap_mobile_station_state = -1;
313 static int hf_bssap_ptmsi = -1;
314 static int hf_bssap_tmsi = -1;
315 static int hf_bssap_tmsi_status = -1;
316 static int hf_bssap_tom_prot_disc = -1;
317 static int hf_bssap_e_bit = -1;
318 static int hf_bssap_tunnel_prio = -1;
319 static int hf_bssap_global_cn_id = -1;
320 static int hf_bssap_plmn_id = -1;
321 static int hf_bssap_cn_id = -1;
322 static int hf_bssap_cell_global_id = -1;
324 /* Initialize the subtree pointers */
325 static gint ett_bssap = -1;
326 static gint ett_bssap_dlci = -1;
327 static gint ett_bssap_imsi = -1;
328 static gint ett_bssap_imsi_det_from_gprs_serv_type = -1;
329 static gint ett_bssap_imsi_det_from_non_gprs_serv_type = -1;
330 static gint ett_bssap_info_req = -1;
331 static gint ett_bssap_loc_area_id = -1;
332 static gint ett_bssap_loc_inf_age = -1;
333 static gint ett_bssap_mm_information = -1;
334 static gint ett_bssap_mobile_id = -1;
335 static gint ett_bssap_sgsn_nr = -1;
336 static gint ett_bssap_tmsi = -1;
337 static gint ett_bssap_tmsi_status = -1;
338 static gint ett_bssap_vlr_number = -1;
339 static gint ett_bssap_global_cn = -1;
340 static gint ett_bssap_gprs_loc_upd = -1;
341 static gint ett_bassp_Gs_cause = -1;
342 static gint ett_bassp_imei = -1;
343 static gint ett_bassp_imesiv = -1;
344 static gint ett_bssap_cell_global_id = -1;
345 static gint ett_bssap_cgi = -1;
346 static gint ett_bssap_channel_needed = -1;
347 static gint ett_bssap_dlink_tnl_pld_cntrl_amd_inf = -1;
348 static gint ett_bssap_ulink_tnl_pld_cntrl_amd_inf = -1;
349 static gint ett_bssap_emlpp_prio = -1;
350 static gint ett_bssap_erroneous_msg = -1;
351 static gint ett_bssap_mobile_stn_cls_mrk1 = -1;
352 static gint ett_bssap_mobile_station_state = -1;
353 static gint ett_bssap_ptmsi = -1;
354 static gint ett_bssap_reject_cause = -1;
355 static gint ett_bssap_service_area_id =-1;
356 static gint ett_bssap_global_cn_id = -1;
357 static gint ett_bssap_plmn = -1;
359 static dissector_handle_t data_handle;
360 static dissector_handle_t rrlp_handle;
362 static dissector_table_t bssap_dissector_table;
363 static dissector_table_t bsap_dissector_table;
365 static dissector_handle_t bsap_dissector_handle;
368 * Keep track of pdu_type so we can call appropriate sub-dissector
370 static guint8 pdu_type = 0xFF;
372 static gint bssap_or_bsap_global = BSSAP_OR_BSAP_DEFAULT;
374 static gint gsm_or_lb_interface_global = GSM_OR_LB_INTERFACE_DEFAULT;
377 dissect_bssap_unknown_message(tvbuff_t *message_tvb, proto_tree *bssap_tree)
379 guint32 message_length;
381 message_length = tvb_length(message_tvb);
383 proto_tree_add_text(bssap_tree, message_tvb, 0, message_length,
384 "Unknown message (%u byte%s)",
385 message_length, plurality(message_length, "", "s"));
389 dissect_bssap_unknown_param(tvbuff_t *tvb, proto_tree *tree, guint8 type, guint16 length)
391 proto_tree_add_text(tree, tvb, 0, length,
392 "Unknown parameter 0x%x (%u byte%s)",
393 type, length, plurality(length, "", "s"));
397 dissect_bssap_data_param(tvbuff_t *tvb, packet_info *pinfo,
398 proto_tree *bssap_tree, proto_tree *tree)
400 if ((pdu_type <= 0x01))
402 if (bssap_or_bsap_global == BSSAP)
405 if((gsm_or_lb_interface_global == LB_INTERFACE) && (pdu_type == BSSAP_PDU_TYPE_BSSMAP))
407 bsap_dissector_handle = find_dissector("gsm_bssmap_le");
409 if(bsap_dissector_handle == NULL) return;
411 call_dissector(bsap_dissector_handle, tvb, pinfo, tree);
415 else if((gsm_or_lb_interface_global == GSM_INTERFACE) && (pdu_type == BSSAP_PDU_TYPE_BSSMAP))
417 bsap_dissector_handle = find_dissector("gsm_a_bssmap");
419 if(bsap_dissector_handle == NULL) return;
421 call_dissector(bsap_dissector_handle, tvb, pinfo, tree);
427 if (dissector_try_uint(bssap_dissector_table, pdu_type, tvb, pinfo, tree)) return;
433 if (dissector_try_uint(bsap_dissector_table, pdu_type, tvb, pinfo, tree))
438 /* No sub-dissection occured, treat it as raw data */
439 call_dissector(data_handle, tvb, pinfo, bssap_tree);
443 dissect_bssap_dlci_param(tvbuff_t *tvb, proto_tree *tree, guint16 length)
445 proto_item *dlci_item = 0;
446 proto_tree *dlci_tree = 0;
450 proto_tree_add_text(tree, tvb, 0, length,
451 "Data Link Connection Identifier");
453 dlci_tree = proto_item_add_subtree(dlci_item, ett_bssap_dlci);
455 oct = tvb_get_guint8(tvb, 0);
457 if (bssap_or_bsap_global == BSSAP)
459 proto_tree_add_uint(dlci_tree, hf_bssap_dlci_cc, tvb, 0, length, oct);
460 proto_tree_add_uint(dlci_tree, hf_bssap_dlci_spare, tvb, 0, length, oct);
461 proto_tree_add_uint(dlci_tree, hf_bssap_dlci_sapi, tvb, 0, length, oct);
465 proto_tree_add_uint(dlci_tree, hf_bsap_dlci_cc, tvb, 0, length, oct);
466 proto_tree_add_uint(dlci_tree, hf_bsap_dlci_rsvd, tvb, 0, length, oct);
467 proto_tree_add_uint(dlci_tree, hf_bsap_dlci_sapi, tvb, 0, length, oct);
472 dissect_bssap_length_param(tvbuff_t *tvb, proto_tree *tree, guint16 length)
476 data_length = tvb_get_guint8(tvb, 0);
477 proto_tree_add_uint(tree, hf_bssap_length, tvb, 0, length, data_length);
481 * Dissect a parameter given its type, offset into tvb, and length.
484 dissect_bssap_parameter(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bssap_tree,
485 proto_tree *tree, guint8 parameter_type, gint offset,
486 guint16 parameter_length)
488 tvbuff_t *parameter_tvb;
490 parameter_tvb = tvb_new_subset(tvb, offset, parameter_length, parameter_length);
492 switch (parameter_type)
495 dissect_bssap_dlci_param(parameter_tvb, bssap_tree, parameter_length);
498 case PARAMETER_LENGTH:
499 dissect_bssap_length_param(parameter_tvb, bssap_tree, parameter_length);
503 dissect_bssap_data_param(parameter_tvb, pinfo, bssap_tree, tree);
507 dissect_bssap_unknown_param(parameter_tvb, bssap_tree, parameter_type,
512 return(parameter_length);
516 dissect_bssap_var_parameter(tvbuff_t *tvb, packet_info *pinfo,
517 proto_tree *bssap_tree, proto_tree *tree,
518 guint8 parameter_type, gint offset)
520 guint16 parameter_length;
521 guint8 length_length;
523 parameter_length = tvb_get_guint8(tvb, offset);
524 length_length = LENGTH_LENGTH;
526 offset += length_length;
528 dissect_bssap_parameter(tvb, pinfo, bssap_tree, tree, parameter_type,
529 offset, parameter_length);
531 return(parameter_length + length_length);
535 dissect_bssap_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bssap_tree,
541 * Extract the PDU type
543 pdu_type = tvb_get_guint8(tvb, PDU_TYPE_OFFSET);
544 offset = PDU_TYPE_LENGTH;
549 * add the message type to the protocol tree
551 proto_tree_add_uint(bssap_tree,
552 (bssap_or_bsap_global == BSSAP) ? hf_bssap_pdu_type : hf_bsap_pdu_type,
553 tvb, PDU_TYPE_OFFSET, PDU_TYPE_LENGTH, pdu_type);
556 /* Starting a new message dissection */
560 case BSSAP_PDU_TYPE_BSSMAP:
561 offset += dissect_bssap_parameter(tvb, pinfo, bssap_tree, tree,
562 PARAMETER_LENGTH, offset,
564 offset += dissect_bssap_var_parameter(tvb, pinfo, bssap_tree, tree,
566 (offset - LENGTH_LENGTH));
569 case BSSAP_PDU_TYPE_DTAP:
570 offset += dissect_bssap_parameter(tvb, pinfo, bssap_tree, tree,
572 offset, DLCI_LENGTH);
573 offset += dissect_bssap_parameter(tvb, pinfo, bssap_tree, tree,
574 PARAMETER_LENGTH, offset,
576 offset += dissect_bssap_var_parameter(tvb, pinfo, bssap_tree, tree,
578 (offset - LENGTH_LENGTH));
582 col_append_fstr(pinfo->cinfo, COL_INFO, "%s ",
583 val_to_str(pdu_type, ((bssap_or_bsap_global == BSSAP) ?
584 bssap_pdu_type_acro_values : bsap_pdu_type_acro_values),
586 dissect_bssap_unknown_message(tvb, bssap_tree);
592 dissect_bssap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
594 proto_item *bssap_item, *hidden_item;
595 proto_tree *bssap_tree = NULL;
598 * Make entry in the Protocol column on summary display
600 col_set_str(pinfo->cinfo, COL_PROTOCOL, ((bssap_or_bsap_global == BSSAP) ? "BSSAP" : "BSAP"));
602 if ( pinfo->sccp_info && pinfo->sccp_info->data.co.assoc )
603 pinfo->sccp_info->data.co.assoc->payload = SCCP_PLOAD_BSSAP;
606 * create the bssap protocol tree
608 hidden_item = proto_tree_add_item(tree, proto_bssap, tvb, 0, -1, ENC_BIG_ENDIAN);
609 PROTO_ITEM_SET_HIDDEN(hidden_item);
610 bssap_item = proto_tree_add_text(tree, tvb, 0, -1, (bssap_or_bsap_global == BSSAP) ? "BSSAP" : "BSAP");
611 bssap_tree = proto_item_add_subtree(bssap_item, ett_bssap);
613 /* dissect the message */
615 dissect_bssap_message(tvb, pinfo, bssap_tree, tree);
624 static dgt_set_t Dgt_tbcd = {
626 /* 0 1 2 3 4 5 6 7 8 9 a b c d e */
627 '0','1','2','3','4','5','6','7','8','9','?','B','C','*','#'
632 static dgt_set_t Dgt1_9_bcd = {
634 /* 0 1 2 3 4 5 6 7 8 9 a b c d e */
635 '0','1','2','3','4','5','6','7','8','9','?','?','?','?','?'
638 /* Assumes the rest of the tvb contains the digits to be turned into a string
641 unpack_digits(tvbuff_t *tvb, int offset,dgt_set_t *dgt,gboolean skip_first){
648 length = tvb_length(tvb);
651 digit_str = ep_alloc((length - offset)*2+1);
653 while ( offset < length ){
655 octet = tvb_get_guint8(tvb,offset);
657 digit_str[i] = dgt->out[octet & 0x0f];
663 * unpack second value in byte
667 if (octet == 0x0f) /* odd number bytes - hit filler */
670 digit_str[i] = dgt->out[octet & 0x0f];
680 check_ie(tvbuff_t *tvb, proto_tree *tree, int *offset, guint8 expected_ie){
684 ie_type = tvb_get_guint8(tvb,*offset);
685 if (ie_type != expected_ie){
686 proto_tree_add_text(tree, tvb, *offset, 1, "Mandatory IE %s expected but IE %s Found",
687 val_to_str(expected_ie,bssap_plus_ie_id_values,"Unknown %u"),
688 val_to_str(ie_type,bssap_plus_ie_id_values,"Unknown %u"));
690 ie_len = tvb_get_guint8(tvb,*offset);
691 *offset = *offset + ie_len;
700 check_optional_ie(tvbuff_t *tvb, int offset, guint8 expected_ie){
703 ie_type = tvb_get_guint8(tvb,offset);
704 if (ie_type != expected_ie){
711 /* 18.4.1 Cell global identity */
713 dissect_bssap_cell_global_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset)
715 proto_item *item = NULL;
716 proto_tree *ie_tree = NULL;
717 proto_item *cgi_item = NULL;
718 proto_tree *cgi_tree = NULL;
721 ie_len = tvb_get_guint8(tvb,offset+1);
722 item = proto_tree_add_item(tree, hf_bssap_cell_global_id_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
723 ie_tree = proto_item_add_subtree(item, ett_bssap_cell_global_id);
725 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
727 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
730 * The rest of the information element is coded as the the value part
731 * of the cell global id IE defined in 3GPP TS 48.018 (not including
732 * 3GPP TS 48.018 IEI and 3GPP TS 48.018 length indicator).
734 cgi_item= proto_tree_add_item(ie_tree, hf_bssap_cell_global_id, tvb, offset, ie_len, ENC_BIG_ENDIAN);
735 cgi_tree = proto_item_add_subtree(cgi_item, ett_bssap_cgi);
736 /* octets 3-8 Octets 3 to 8 contain the value part (starting with octet 2) of the
737 * Routing Area Identification IE defined in 3GPP TS 24.008, not
738 * including 3GPP TS 24.008 IEI
740 de_gmm_rai(tvb, cgi_tree, pinfo, offset, ie_len, NULL, 0);
741 /* Octets 9 and 10 contain the value part (starting with octet 2) of the
742 * Cell Identity IE defined in 3GPP TS 24.008, not including
746 de_cell_id(tvb, cgi_tree, pinfo, offset, ie_len, NULL, 0);
752 /* 18.4.2 Channel needed */
754 dissect_bssap_channel_needed(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset)
756 proto_item *item = NULL;
757 proto_tree *ie_tree = NULL;
760 ie_len = tvb_get_guint8(tvb,offset+1);
761 item = proto_tree_add_item(tree, hf_bssap_channel_needed_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
762 ie_tree = proto_item_add_subtree(item, ett_bssap_channel_needed);
764 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
766 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
769 * The rest of the information element is coded as the IEI part and the
770 * value part of the Channel Needed IE defined in 3GPP TS 44.018.
771 * 10.5.2.8 Channel Needed
773 de_rr_chnl_needed(tvb, ie_tree, pinfo, offset, ie_len, NULL, 0);
775 return offset + ie_len;
778 /* 18.4.3 Downlink Tunnel Payload Control and Info */
780 dissect_bssap_dlink_tunnel_payload_control_and_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
782 proto_item *item = NULL;
783 proto_tree *ie_tree = NULL;
789 ie_len = tvb_get_guint8(tvb,offset+1);
790 item = proto_tree_add_item(tree, hf_bssap_dlink_tnl_pld_cntrl_amd_inf_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
791 ie_tree = proto_item_add_subtree(item, ett_bssap_dlink_tnl_pld_cntrl_amd_inf);
793 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
795 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
799 * TOM Protocol Discriminator: Identifies the protocol using tunnelling of non-GSM signalling.
800 * For coding, see 3GPP TS 44.064.
803 proto_tree_add_item(ie_tree, hf_bssap_tom_prot_disc, tvb, offset, 1, ENC_BIG_ENDIAN);
804 octet = tvb_get_guint8(tvb,offset);
805 prot_disc = (octet&0x78)>>3;
807 /* octet 3 bit 3 E: Cipher Request. When set to 1 indicates that the SGSN received the payload in ciphered form,
808 * when set to 0 indicates that the SGSN did not receive the payload in ciphered form.
810 proto_tree_add_item(ie_tree, hf_bssap_e_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
813 * Tunnel Priority: Indicates the priority of the Tunnel Payload. For coding, see Table 20.1: Association
814 * between Tunnel Priority and LLC SAPs.
816 proto_tree_add_item(ie_tree, hf_bssap_tunnel_prio, tvb, offset, 1, ENC_BIG_ENDIAN);
818 next_tvb = tvb_new_subset(tvb, offset, ie_len-4, ie_len-4);
820 if ((prot_disc == 2)&&(rrlp_handle))
821 call_dissector(rrlp_handle, next_tvb, pinfo, ie_tree);
823 call_dissector(data_handle, next_tvb, pinfo, ie_tree);
826 return offset + ie_len;
830 /* 18.4.4 eMLPP Priority */
832 static const value_string bssap_call_priority_values[] = {
833 { 0x00, "No priority applied" },
834 { 0x01, "Call priority level 4" },
835 { 0x02, "Call priority level 3" },
836 { 0x03, "Call priority level 2" },
837 { 0x04, "Call priority level 1" },
838 { 0x05, "Call priority level 0" },
839 { 0x06, "Call priority level B" },
840 { 0x07, "Call priority level A" },
844 dissect_bssap_emlpp_priority(tvbuff_t *tvb, proto_tree *tree, int offset)
846 proto_item *item = NULL;
847 proto_tree *ie_tree = NULL;
850 ie_len = tvb_get_guint8(tvb,offset+1);
851 item = proto_tree_add_item(tree, hf_bssap_emlpp_prio_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
852 ie_tree = proto_item_add_subtree(item, ett_bssap_emlpp_prio);
854 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
856 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
858 /* The rest of the information element is coded as the value part of
859 the eMLPP-Priority IE defined in 3GPP TS 48.008 (not including
860 3GPP TS 48.008 IEI and 3GPP TS 48.008 length indicator).
861 3.2.2.56 eMLPP Priority
862 The call priority field (bit 3 to 1 of octet 2) is coded in the same way
863 as the call priority field (bit 3 to 1 of octet 5) in the Descriptive group
864 or broadcast call reference information element as defined in 3GPP TS 24.008.
866 proto_tree_add_item(ie_tree, hf_bssap_call_priority, tvb, offset, ie_len, ENC_BIG_ENDIAN);
868 return offset + ie_len;
871 /* 18.4.5 Erroneous message */
872 /* Erroneous message including the message type. */
875 dissect_bssap_gprs_erroneous_msg(tvbuff_t *tvb, proto_tree *tree, int offset)
877 proto_item *item = NULL;
878 proto_tree *ie_tree = NULL;
881 ie_len = tvb_get_guint8(tvb,offset+1);
882 item = proto_tree_add_item(tree, hf_bssap_gprs_erroneous_msg_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
883 ie_tree = proto_item_add_subtree(item, ett_bssap_erroneous_msg);
885 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
887 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
890 /* Erroneous message including the message type. */
891 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_data, tvb, offset, ie_len, ENC_BIG_ENDIAN);
893 return offset + ie_len;
898 static const value_string bssap_plus_GPRS_loc_upd_type_values[] = {
899 { 0x00, "Shall not be sent in this version of the protocol. If received, shall be treated as '00000010'." },
900 { 0x01, "IMSI attach" },
901 { 0x02, "Normal location update" },
904 /* 18.4.6 GPRS location update type */
906 dissect_bssap_gprs_location_update_type(tvbuff_t *tvb, proto_tree *tree, int offset)
908 proto_item *item = NULL;
909 proto_tree *ie_tree = NULL;
912 ie_len = tvb_get_guint8(tvb,offset+1);
913 item = proto_tree_add_item(tree, hf_bssap_gprs_loc_upd_type_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
914 ie_tree = proto_item_add_subtree(item, ett_bssap_gprs_loc_upd);
916 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
918 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
921 /* GPRS location update type value (octet 3) */
922 proto_tree_add_item(ie_tree, hf_bssap_gprs_loc_upd_type, tvb, offset, ie_len, ENC_BIG_ENDIAN);
924 return offset + ie_len;
927 /* Gs Cause value (octet 3) */
928 static const value_string bssap_Gs_cause_values[] = {
930 { 0x00, "Normal, unspecified in this version of the protocol." },
931 { 0x01, "IMSI detached for GPRS services" },
932 { 0x02, "IMSI detached for GPRS and non-GPRS services" },
933 { 0x03, "IMSI unknown" },
934 { 0x04, "IMSI detached for non-GPRS services" },
935 { 0x05, "IMSI implicitly detached for non-GPRS services" },
936 { 0x06, "MS unreachable" },
937 { 0x07, "Message not compatible with the protocol state" },
938 { 0x08, "Missing mandatory information element" },
939 { 0x09, "Invalid mandatory information" },
940 { 0x0a, "Conditional IE error" },
941 { 0x0b, "Semantically incorrect message" },
942 { 0x0c, "Message unknown" },
943 { 0x0d, "Address error" },
944 { 0x0e, "TOM functionality not supported" },
945 { 0x0f, "Ciphering request cannot be accommodated" },
949 /* 18.4.7 Gs cause */
951 dissect_bssap_Gs_cause(tvbuff_t *tvb, proto_tree *tree, int offset)
953 proto_item *item = NULL;
954 proto_tree *ie_tree = NULL;
957 ie_len = tvb_get_guint8(tvb,offset+1);
958 item = proto_tree_add_item(tree, hf_bssap_Gs_cause_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
959 ie_tree = proto_item_add_subtree(item, ett_bassp_Gs_cause);
961 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
963 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
965 /* Gs Cause value (octet 3) */
966 proto_tree_add_item(ie_tree, hf_bssap_Gs_cause, tvb, offset, ie_len, ENC_BIG_ENDIAN);
969 return offset + ie_len;
974 dissect_bssap_imei(tvbuff_t *tvb, proto_tree *tree, int offset)
976 proto_item *item = NULL;
977 proto_tree *ie_tree = NULL;
980 const char *digit_str;
982 ie_len = tvb_get_guint8(tvb,offset+1);
983 item = proto_tree_add_item(tree, hf_bssap_imei_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
984 ie_tree = proto_item_add_subtree(item, ett_bassp_imei);
986 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
988 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
990 /* The IMEI is coded as a sequence of BCD digits, compressed two into each octet.
991 * The IMEI consists of 15 digits (see 3GPP TS 23.003).
993 ie_tvb = tvb_new_subset(tvb, offset, ie_len, ie_len);
994 digit_str = unpack_digits(ie_tvb, 0, &Dgt1_9_bcd, ENC_BIG_ENDIAN);
995 proto_tree_add_string(ie_tree, hf_bssap_imei, ie_tvb, 0, -1, digit_str);
997 return offset + ie_len;
1002 dissect_bssap_imesiv(tvbuff_t *tvb, proto_tree *tree, int offset)
1004 proto_item *item = NULL;
1005 proto_tree *ie_tree = NULL;
1008 const char *digit_str;
1010 ie_len = tvb_get_guint8(tvb,offset+1);
1011 item = proto_tree_add_item(tree, hf_bssap_imesiv_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1012 ie_tree = proto_item_add_subtree(item, ett_bassp_imesiv);
1014 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1016 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1018 /* The IMEISV is coded as a sequence of BCD digits, compressed two into each octet.
1019 * The IMEISV consists of 16 digits (see 3GPP TS 23.003).
1021 ie_tvb = tvb_new_subset(tvb, offset, ie_len, ie_len);
1022 digit_str = unpack_digits(ie_tvb, 0, &Dgt1_9_bcd, ENC_BIG_ENDIAN);
1023 proto_tree_add_string(ie_tree, hf_bssap_imeisv, ie_tvb, 0, -1, digit_str);
1025 return offset + ie_len;
1029 * The IMSI is coded as a sequence of BCD digits, compressed two into each octet.
1030 * This is a variable length element, and includes a length indicator.
1031 * The IMSI is defined in 3GPP TS 23.003. It shall not exceed 15 digits (see 3GPP TS 23.003).
1036 dissect_bssap_imsi(tvbuff_t *tvb, proto_tree *tree, int offset)
1038 proto_item *item = NULL;
1039 proto_tree *ie_tree = NULL;
1042 const char *digit_str;
1044 ie_len = tvb_get_guint8(tvb,offset+1);
1045 item = proto_tree_add_item(tree, hf_bssap_imsi_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1046 ie_tree = proto_item_add_subtree(item, ett_bssap_imsi);
1048 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1050 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1052 ie_tvb = tvb_new_subset(tvb, offset, ie_len,ie_len);
1053 digit_str = unpack_digits(ie_tvb, 0, &Dgt1_9_bcd, TRUE);
1054 proto_tree_add_string(ie_tree, hf_bssap_imsi, ie_tvb, 0, -1, digit_str);
1056 return offset + ie_len;
1059 static const value_string bssap_imsi_det_from_gprs_serv_type_values[] _U_ = {
1060 { 0x00, "Interpreted as reserved in this version of the protocol" },
1061 { 0x01, "Network initiated IMSI detach from GPRS service" },
1062 { 0x02, "MS initiated IMSI detach from GPRS service" },
1063 { 0x03, "GPRS services not allowed" },
1067 /* 18.4.11 IMSI detach from GPRS service type */
1069 dissect_bssap_imsi_det_from_gprs_serv_type(tvbuff_t *tvb, proto_tree *tree, int offset)
1071 proto_item *item = NULL;
1072 proto_tree *ie_tree = NULL;
1075 ie_len = tvb_get_guint8(tvb,offset+1);
1076 item = proto_tree_add_item(tree, hf_bssap_imsi_det_from_gprs_serv_type_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1077 ie_tree = proto_item_add_subtree(item, ett_bssap_imsi_det_from_gprs_serv_type);
1079 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1081 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1083 /* IMSI detach from GPRS service type value (octet 3)*/
1084 proto_tree_add_item(ie_tree, hf_bssap_imsi_det_from_gprs_serv_type, tvb, offset, ie_len, ENC_BIG_ENDIAN);
1087 return offset + ie_len;
1090 /* 18.4.12 IMSI detach from non-GPRS service type */
1092 dissect_bssap_imsi_det_from_non_gprs_serv_type(tvbuff_t *tvb, proto_tree *tree, int offset)
1094 proto_item *item = NULL;
1095 proto_tree *ie_tree = NULL;
1098 ie_len = tvb_get_guint8(tvb,offset+1);
1099 item = proto_tree_add_item(tree, hf_bssap_imsi_det_from_non_gprs_serv_type_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1100 ie_tree = proto_item_add_subtree(item, ett_bssap_imsi_det_from_non_gprs_serv_type);
1102 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1104 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1106 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_data, tvb, offset, ie_len, ENC_BIG_ENDIAN);
1109 return offset + ie_len;
1112 static const value_string bssap_info_req_values[] = {
1113 { 0x00, "Interpreted as Not supported in this version of the protocol." },
1117 { 0x04, "PTMSI and IMEI" },
1118 { 0x05, "PTMSI and IMEISV" },
1119 { 0x06, "IMEI and IMEISV" },
1120 { 0x07, "PTMSI, IMEI, and IMEISV" },
1121 { 0x08, "Mobile location information" },
1125 /* 18.4.13 Information requested */
1127 dissect_bssap_info_req(tvbuff_t *tvb, proto_tree *tree, int offset)
1129 proto_item *item = NULL;
1130 proto_tree *ie_tree = NULL;
1133 ie_len = tvb_get_guint8(tvb,offset+1);
1134 item = proto_tree_add_item(tree, hf_bssap_info_req_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1135 ie_tree = proto_item_add_subtree(item, ett_bssap_info_req);
1137 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1139 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1141 /*Information requested value (octet 3) */
1142 proto_tree_add_item(ie_tree, hf_bssap_info_req, tvb, offset, ie_len, ENC_BIG_ENDIAN);
1145 return offset + ie_len;
1148 /* 18.4.14 Location area identifier */
1150 dissect_bssap_loc_area_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset)
1152 proto_item *item = NULL;
1153 proto_tree *ie_tree = NULL;
1156 ie_len = tvb_get_guint8(tvb,offset+1);
1157 item = proto_tree_add_item(tree, hf_bssap_loc_area_id_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1158 ie_tree = proto_item_add_subtree(item, ett_bssap_loc_area_id);
1160 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1162 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1164 /* The rest of the information element is coded as the value part of
1165 * the location area identifier IE defined in 3GPP TS 48.018 (not
1166 * including 3GPP TS 48.018 IEI and 3GPP TS 48.018 length
1169 de_lai(tvb, ie_tree, pinfo, offset, ie_len, NULL, 0);
1171 return offset + ie_len;
1174 /* 18.4.15 Location information age */
1176 dissect_bssap_location_information_age(tvbuff_t *tvb, proto_tree *tree, int offset)
1178 proto_item *item = NULL;
1179 proto_tree *ie_tree = NULL;
1182 ie_len = tvb_get_guint8(tvb,offset+1);
1183 item = proto_tree_add_item(tree, hf_bssap_loc_inf_age_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1184 ie_tree = proto_item_add_subtree(item, ett_bssap_loc_inf_age);
1186 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1188 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1190 /* The rest of the IE is coded as the value part of the
1191 * AgeOfLocationInformation as specified in 3GPP TS 29.002.:
1192 * AgeOfLocationInformation ::= INTEGER (0..32767)
1193 * -- the value represents the elapsed time in minutes since the last
1194 * -- network contact of the mobile station (i.e. the actuality of the
1195 * -- location information).
1196 * -- value '0' indicates that the MS is currently in contact with the
1198 * -- value '32767' indicates that the location information is at least
1199 * -- 32767 minutes old
1201 proto_tree_add_item(ie_tree, hf_bssap_loc_inf_age, tvb, offset, ie_len, ENC_BIG_ENDIAN);
1204 return offset + ie_len;
1207 /* 18.4.16 MM information */
1209 dissect_bssap_MM_information(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset)
1211 proto_item *item = NULL;
1212 proto_tree *ie_tree = NULL;
1215 ie_len = tvb_get_guint8(tvb,offset+1);
1216 item = proto_tree_add_item(tree, hf_bssap_mm_information_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1217 ie_tree = proto_item_add_subtree(item, ett_bssap_mm_information);
1219 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1221 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1223 /* User information: This field is composed of one or more of the
1224 * information elements of the MM information message as defined
1225 * 3GPP TS 24.008, excluding the Protocol discriminator, Skip
1226 * indicator and Message type. This field includes the IEI and length
1227 * indicatior of the other information elements.
1229 dtap_mm_mm_info(tvb, ie_tree, pinfo, offset, ie_len);
1232 return offset + ie_len;
1235 /* 18.4.17 Mobile identity */
1237 dissect_bssap_mobile_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset)
1239 proto_item *item = NULL;
1240 proto_tree *ie_tree = NULL;
1243 ie_len = tvb_get_guint8(tvb,offset+1);
1244 item = proto_tree_add_item(tree, hf_bssap_mobile_id_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1245 ie_tree = proto_item_add_subtree(item, ett_bssap_mobile_id);
1247 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1249 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1251 /* The rest of the information element is coded as the value part of
1252 * the mobile identity IE defined in 3GPP TS 24.008 (not including
1253 * 3GPP TS 24.008 IEI and 3GPP TS 24.008 length indicator).
1255 de_mid(tvb, ie_tree, pinfo, offset, ie_len, NULL, 0);
1258 return offset + ie_len;
1261 /* 18.4.18 Mobile station classmark 1 */
1263 dissect_bssap_mobile_stn_cls_mrk1(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset)
1265 proto_item *item = NULL;
1266 proto_tree *ie_tree = NULL;
1269 ie_len = tvb_get_guint8(tvb,offset+1);
1270 item = proto_tree_add_item(tree, hf_bssap_mobile_stn_cls_mrk1_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1271 ie_tree = proto_item_add_subtree(item, ett_bssap_mobile_stn_cls_mrk1);
1273 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1275 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1277 /* The rest of the information element is coded as the value part of
1278 * the mobile station classmark 1 IE defined in 3GPP TS 24.008 (not
1279 * including 3GPP TS 24.008 IEI)
1281 de_ms_cm_1(tvb, ie_tree, pinfo, offset, ie_len, NULL, 0);
1283 return offset + ie_len;
1286 /* 18.4.19 Mobile station state */
1287 static const value_string bssap_mobile_station_state_values[] = {
1288 { 0x00, "IDLE or PMM-DETACHED" },
1289 { 0x01, "STANDBY or PMM-IDLE, 0 PDP contexts active" },
1290 { 0x02, "STANDBY or PMM-IDLE, 1 or more PDP contexts active" },
1291 { 0x03, "SUSPENDED, 0 PDP contexts active" },
1292 { 0x04, "SUSPENDED, 1 or more PDP contexts active" },
1293 { 0x05, "READY or PMM-CONNECTED, 0 PDP contexts active" },
1294 { 0x06, "READY or PMM-CONNECTED, 1 or more PDP contexts active" },
1295 { 0x07, "IMSI unknown" },
1296 { 0x08, "Information requested not supported" },
1300 dissect_bssap_mobile_station_state(tvbuff_t *tvb, proto_tree *tree, int offset)
1302 proto_item *item = NULL;
1303 proto_tree *ie_tree = NULL;
1306 ie_len = tvb_get_guint8(tvb,offset+1);
1307 item = proto_tree_add_item(tree, hf_bssap_mobile_station_state_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1308 ie_tree = proto_item_add_subtree(item, ett_bssap_mobile_station_state);
1310 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1312 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1314 /* Mobile station state value (octet 3) */
1315 proto_tree_add_item(ie_tree, hf_bssap_mobile_station_state, tvb, offset, ie_len, ENC_BIG_ENDIAN);
1317 return offset + ie_len;
1322 dissect_bssap_ptmsi(tvbuff_t *tvb, proto_tree *tree, int offset)
1324 proto_item *item = NULL;
1325 proto_tree *ie_tree = NULL;
1328 ie_len = tvb_get_guint8(tvb,offset+1);
1329 item = proto_tree_add_item(tree, hf_bssap_ptmsi_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1330 ie_tree = proto_item_add_subtree(item, ett_bssap_ptmsi);
1332 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1334 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1336 /* The PTMSI consists of 4 octets. It can be coded using a full hexadecimal representation
1337 * (see 3GPP TS 23.003).
1339 proto_tree_add_item(ie_tree, hf_bssap_ptmsi, tvb, offset, ie_len, ENC_BIG_ENDIAN);
1341 return offset + ie_len;
1344 /* 18.4.21 Reject cause */
1346 dissect_bssap_reject_cause(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset)
1348 proto_item *item = NULL;
1349 proto_tree *ie_tree = NULL;
1352 ie_len = tvb_get_guint8(tvb,offset+1);
1353 item = proto_tree_add_item(tree, hf_bssap_reject_cause_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1354 ie_tree = proto_item_add_subtree(item, ett_bssap_reject_cause);
1356 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1358 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1360 /* The rest of the information element is coded as the value part of
1361 * the reject cause IE defined in 3GPP TS 24.008, not including
1362 * 3GPP TS 24.008 IEI.
1364 de_rej_cause(tvb, ie_tree, pinfo, offset, ie_len, NULL, 0);
1366 return offset + ie_len;
1370 /* 18.4.21b Service Area Identification */
1372 dissect_bssap_service_area_id(tvbuff_t *tvb, proto_tree *tree, int offset)
1374 proto_item *item = NULL;
1375 proto_tree *ie_tree = NULL;
1378 ie_len = tvb_get_guint8(tvb,offset+1);
1379 item = proto_tree_add_item(tree, hf_bssap_service_area_id_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1380 ie_tree = proto_item_add_subtree(item, ett_bssap_service_area_id);
1382 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1384 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1386 /* The rest of the information element is coded as the the value part
1387 * of the SAI IE defined in 3GPP TS 25.413 (not including
1388 * 3GPP TS 25.413 IEI and 3GPP TS 25.413 length indicator).
1390 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_data, tvb, offset, ie_len, ENC_BIG_ENDIAN);
1392 return offset + ie_len;
1396 /* 18.4.22 SGSN number */
1398 static const true_false_string bssap_extension_value = {
1404 dissect_bssap_sgsn_number(tvbuff_t *tvb, proto_tree *tree, int offset)
1406 proto_item *item = NULL;
1407 proto_tree *ie_tree = NULL;
1409 tvbuff_t *number_tvb;
1410 const char *digit_str;
1412 ie_len = tvb_get_guint8(tvb,offset+1);
1413 item = proto_tree_add_item(tree, hf_bssap_sgsn_nr_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1414 ie_tree = proto_item_add_subtree(item, ett_bssap_sgsn_nr);
1416 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1418 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1420 /* The SGSN number is coded as a sequence of TBCD digits (as specified in 3GPP TS 29.002),
1421 * compressed two into each octet. The Number is in international E.164 format as indicated by Octet 3
1422 * which coding is specified in 3GPP TS 29.002. This is a variable length information element,
1423 * and includes a length indicator. The value part of the SGSN number information element
1424 * (not including IEI, Length indicator and Octet 3) shall not exceed 15 digits.
1426 proto_tree_add_item(ie_tree, hf_bssap_extension, tvb, offset, 1, ENC_BIG_ENDIAN);
1427 proto_tree_add_item(ie_tree, hf_bssap_type_of_number, tvb, offset, 1, ENC_BIG_ENDIAN);
1428 proto_tree_add_item(ie_tree, hf_bssap_numbering_plan_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1430 number_tvb = tvb_new_subset(tvb, offset, ie_len-1,ie_len-1);
1431 digit_str = unpack_digits(number_tvb, 0, &Dgt1_9_bcd, ENC_BIG_ENDIAN);
1432 proto_tree_add_string(ie_tree, hf_bssap_sgsn_number, number_tvb, 0, -1, digit_str);
1435 return offset + ie_len-1;
1440 dissect_bssap_tmsi(tvbuff_t *tvb, proto_tree *tree, int offset)
1442 proto_item *item = NULL;
1443 proto_tree *ie_tree = NULL;
1446 ie_len = tvb_get_guint8(tvb,offset+1);
1447 item = proto_tree_add_item(tree, hf_bssap_tmsi_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1448 ie_tree = proto_item_add_subtree(item, ett_bssap_tmsi);
1450 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1452 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1454 /* The TMSI consists of 4 octets. It can be coded using a full hexadecimal representation
1455 * (see 3GPP TS 23.003).
1457 proto_tree_add_item(ie_tree, hf_bssap_tmsi, tvb, offset, ie_len, ENC_BIG_ENDIAN);
1460 return offset + ie_len;
1464 /* 18.4.24 TMSI status */
1465 static const true_false_string bssap_tmsi_flag = {
1466 "Valid TMSI available",
1467 "No valid TMSI available"
1470 dissect_bssap_tmsi_status(tvbuff_t *tvb, proto_tree *tree, int offset)
1472 proto_item *item = NULL;
1473 proto_tree *ie_tree = NULL;
1476 ie_len = tvb_get_guint8(tvb,offset+1);
1477 item = proto_tree_add_item(tree, hf_bssap_tmsi_status_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1478 ie_tree = proto_item_add_subtree(item, ett_bssap_tmsi_status);
1480 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1482 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1484 /* TMSI flag (octet 3) */
1485 proto_tree_add_item(ie_tree, hf_bssap_tmsi_status, tvb, offset, ie_len, ENC_BIG_ENDIAN);
1488 return offset + ie_len;
1491 /* 18.4.25 Uplink Tunnel Payload Control and Info */
1492 static const true_false_string bssap_E_flag = {
1493 "SGSN received the payload in ciphered",
1494 "SGSN did not receive the payload in ciphered form"
1496 /* 3GPP TS 44.064 B.1.1 TOM Protocol Discriminator */
1497 static const value_string bssap_tom_prot_disc_values[] = {
1498 { 0x00, "Not specified" },
1499 { 0x01, "TIA/EIA-136" },
1501 { 0x03, "Reserved for extension" },
1505 dissect_bssap_ulink_tunnel_payload_control_and_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
1507 proto_item *item = NULL;
1508 proto_tree *ie_tree = NULL;
1514 ie_len = tvb_get_guint8(tvb,offset+1);
1515 item = proto_tree_add_item(tree, hf_bssap_ulink_tnl_pld_cntrl_amd_inf_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1516 ie_tree = proto_item_add_subtree(item, ett_bssap_ulink_tnl_pld_cntrl_amd_inf);
1518 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1520 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1522 /* octet 3 bit 8 Spare */
1523 /* octet 3 bit 7 - 4
1524 * TOM Protocol Discriminator: Identifies the protocol using tunnelling of non-GSM signalling.
1525 * For coding, see 3GPP TS 44.064.
1527 proto_tree_add_item(ie_tree, hf_bssap_tom_prot_disc, tvb, offset, 1, ENC_BIG_ENDIAN);
1528 octet = tvb_get_guint8(tvb,offset);
1529 prot_disc = (octet&0x78)>>3;
1531 /* octet 3 bit 3 E: Cipher Request. When set to 1 indicates that the SGSN received the payload in ciphered form,
1532 * when set to 0 indicates that the SGSN did not receive the payload in ciphered form.
1534 proto_tree_add_item(ie_tree, hf_bssap_e_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
1536 /* octet 3 bit 2 - 1
1537 * Tunnel Priority: Indicates the priority of the Tunnel Payload. For coding, see Table 20.1: Association
1538 * between Tunnel Priority and LLC SAPs.
1540 proto_tree_add_item(ie_tree, hf_bssap_tunnel_prio, tvb, offset, 1, ENC_BIG_ENDIAN);
1541 /* Tunnel payload */
1542 next_tvb = tvb_new_subset(tvb, offset, ie_len-4, ie_len-4);
1544 if ((prot_disc == 2)&&(rrlp_handle))
1545 call_dissector(rrlp_handle, next_tvb, pinfo, ie_tree);
1547 call_dissector(data_handle, next_tvb, pinfo, ie_tree);
1549 return offset + ie_len;
1553 /* 18.4.26 VLR number */
1555 dissect_bssap_vlr_number(tvbuff_t *tvb, proto_tree *tree, int offset)
1557 proto_item *item = NULL;
1558 proto_tree *ie_tree = NULL;
1560 tvbuff_t *number_tvb;
1561 const char *digit_str;
1563 ie_len = tvb_get_guint8(tvb,offset+1);
1564 item = proto_tree_add_item(tree, hf_bssap_vlr_number_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1565 ie_tree = proto_item_add_subtree(item, ett_bssap_vlr_number);
1567 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1569 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1571 /* The VLR number is coded as a sequence of TBCD digits (as specified in 3GPP TS 29.002),
1572 * compressed two into each octet. The Number is in international E.164 format as indicated by Octet 3
1573 * which coding is specified in 3GPP TS 29.002. This is a variable length information element,
1574 * and includes a length indicator. The value part of the VLR number information element
1575 * (not including IEI, length indicator and Octet 3), shall not exceed 15 digits.
1578 proto_tree_add_item(ie_tree, hf_bssap_extension, tvb, offset, 1, ENC_BIG_ENDIAN);
1579 proto_tree_add_item(ie_tree, hf_bssap_type_of_number, tvb, offset, 1, ENC_BIG_ENDIAN);
1580 proto_tree_add_item(ie_tree, hf_bssap_numbering_plan_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1582 number_tvb = tvb_new_subset(tvb, offset, ie_len-1,ie_len-1);
1583 digit_str = unpack_digits(number_tvb, 0, &Dgt1_9_bcd, ENC_BIG_ENDIAN);
1584 proto_tree_add_string(ie_tree, hf_bssap_sgsn_number, number_tvb, 0, -1, digit_str);
1586 return offset + ie_len-1;
1589 /* 18.4.27 Global CN-Id */
1591 dissect_bssap_global_cn_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
1593 proto_item *item = NULL;
1594 proto_tree *ie_tree = NULL;
1595 proto_item *plmn_item = NULL;
1596 proto_tree *plmn_tree = NULL;
1597 proto_item *global_cn_id_item = NULL;
1598 proto_tree *global_cn_id_tree = NULL;
1601 ie_len = tvb_get_guint8(tvb,offset+1);
1602 item = proto_tree_add_item(tree, hf_bssap_global_cn_id_ie, tvb, offset, ie_len+2, ENC_BIG_ENDIAN);
1603 ie_tree = proto_item_add_subtree(item, ett_bssap_global_cn);
1605 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1607 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1609 /* The Global CN-Id consists of a PLMN-Id and a CN-Id, see 3GPP TS 23.003.
1610 * The PLMN-Id consists of MCC and MNC coded according to Location Area Identification
1611 * in 3GPP TS 24.008. The CN-Id is an integer defined by O&M.
1612 * The least significant bit of the CN-Id field is bit 1 of octet 7 and
1613 * the most significant bit is bit 8 of octet 6. If the CN-Id does not fill the field reserved for it,
1614 * the rest of the bits are set to '0'.
1616 global_cn_id_item = proto_tree_add_item(ie_tree, hf_bssap_global_cn_id, tvb, offset, ie_len, ENC_BIG_ENDIAN);
1617 global_cn_id_tree = proto_item_add_subtree(global_cn_id_item, ett_bssap_global_cn_id);
1618 /* Octet 3 - 5 PLMN-Id Coded as octets 2 to 4 of the Location Area Identification IE,
1619 * defined in 3GPP TS 24.008 (not including 3GPP TS 24.008 IEI and LAC).
1621 plmn_item = proto_tree_add_item(global_cn_id_tree, hf_bssap_plmn_id, tvb, offset, 3, ENC_BIG_ENDIAN);
1622 plmn_tree = proto_item_add_subtree(plmn_item, ett_bssap_plmn);
1623 dissect_e212_mcc_mnc(tvb, pinfo, plmn_tree, offset, TRUE);
1624 offset = offset + 3;
1626 /* Octet 6 - 7 CN-Id (INTEGER 0..4095) */
1627 proto_tree_add_item(global_cn_id_tree, hf_bssap_cn_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1634 static void dissect_bssap_plus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1636 proto_item *bssap_item;
1637 proto_tree *bssap_tree = NULL;
1638 guint8 message_type;
1642 * Make entry in the Protocol column on summary display
1644 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BSSAP+");
1646 if (pinfo->sccp_info && pinfo->sccp_info->data.co.assoc)
1647 pinfo->sccp_info->data.co.assoc->payload = SCCP_PLOAD_BSSAP;
1649 /* create the BSSAP+ protocol tree */
1650 bssap_item = proto_tree_add_item(tree, proto_bssap, tvb, 0, -1, ENC_BIG_ENDIAN);
1651 bssap_tree = proto_item_add_subtree(bssap_item, ett_bssap);
1653 message_type = tvb_get_guint8(tvb,offset);
1654 proto_tree_add_item(bssap_tree, hf_bssap_plus_message_type, tvb, offset, 1,ENC_BIG_ENDIAN);
1657 col_add_str(pinfo->cinfo,COL_INFO, val_to_str(message_type,bssap_plus_message_type_values,"Unknown %u"));
1659 switch(message_type){
1660 case BSSAP_PAGING_REQUEST:
1661 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1662 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
1663 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
1665 /* VLR number VLR number 18.4.26 M TLV 5-11 */
1666 if ( check_ie(tvb, tree, &offset, BSSAP_VLR_NUMBER))
1667 offset = dissect_bssap_vlr_number(tvb, bssap_tree, offset);
1669 /* End of mandatory elements */
1670 if (tvb_length_remaining(tvb,offset) == 0)
1673 /* TMSI TMSI 18.4.23 O TLV 6 */
1674 if ( check_optional_ie(tvb, offset, BSSAP_TMSI))
1675 offset = dissect_bssap_tmsi(tvb, bssap_tree, offset);
1676 if (tvb_length_remaining(tvb,offset) == 0)
1679 /* Location area identifier Location area identifier 18.4.14 O TLV 7 */
1680 if ( check_optional_ie(tvb, offset, BSSAP_LOC_AREA_ID))
1681 offset = dissect_bssap_loc_area_id(tvb, bssap_tree, pinfo, offset);
1682 if (tvb_length_remaining(tvb,offset) == 0)
1685 /* Channel needed Channel needed 18.4.2 O TLV 3 */
1686 if ( check_optional_ie(tvb, offset, BSSAP_CHANNEL_NEEDED))
1687 offset = dissect_bssap_channel_needed(tvb, bssap_tree, pinfo, offset);
1688 if (tvb_length_remaining(tvb,offset) == 0)
1691 /* eMLPP Priority eMLPP Priority 18.4.4 O TLV 3 */
1692 if ( check_optional_ie(tvb, offset, BSSAP_EMLPP_PRIORITY))
1693 offset = dissect_bssap_emlpp_priority(tvb, bssap_tree, offset);
1694 if (tvb_length_remaining(tvb,offset) == 0)
1697 /* Global CN-Id Global CN-Id 18.4.27 O TLV 7 */
1698 if ( check_optional_ie(tvb, offset, BSSAP_GLOBAL_CN_ID))
1699 offset = dissect_bssap_global_cn_id(tvb, pinfo, bssap_tree, offset);
1700 if (tvb_length_remaining(tvb,offset) == 0)
1703 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
1705 case BSSAP_PAGING_REJECT: /* 17.1.18 */
1706 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1707 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
1708 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
1709 /* Gs Cause Gs Cause 18.4.7 M TLV 3 */
1710 if ( check_ie(tvb, tree, &offset, BSSAP_GS_CAUSE))
1711 offset = dissect_bssap_Gs_cause(tvb, bssap_tree, offset);
1713 if (tvb_length_remaining(tvb,offset) == 0)
1715 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
1717 case BSSAP_DOWNLINK_TUNNEL_REQUEST: /* 17.1.4 */
1718 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1719 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
1720 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
1722 /* VLR number VLR number 18.4.26 M TLV 5-11 */
1723 if ( check_ie(tvb, tree, &offset, BSSAP_VLR_NUMBER))
1724 offset = dissect_bssap_vlr_number(tvb, bssap_tree, offset);
1726 /* Downlink Tunnel Payload Control and Info 18.4.3 M TLV 3-223 */
1727 if ( check_ie(tvb, tree, &offset, BSSAP_DLINK_TNL_PLD_CTR_AND_INF))
1728 offset = dissect_bssap_dlink_tunnel_payload_control_and_info(tvb, pinfo, bssap_tree, offset);
1730 if (tvb_length_remaining(tvb,offset) == 0)
1732 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
1734 case BSSAP_UPLINK_TUNNEL_REQUEST: /* 17.1.23 */
1735 /* SGSN number 18.4.22 M TLV 5-11 */
1736 if ( check_ie(tvb, tree, &offset, BSSAP_SGSN_NUMBER))
1737 offset = dissect_bssap_sgsn_number(tvb, bssap_tree, offset);
1739 /* Uplink Tunnel Payload Control and Info 18.4.25 M TLV 3-223 */
1740 if ( check_ie(tvb, tree, &offset, BSSAP_ULINK_TNL_PLD_CTR_AND_INF))
1741 offset = dissect_bssap_ulink_tunnel_payload_control_and_info(tvb, pinfo, bssap_tree, offset);
1743 if (tvb_length_remaining(tvb,offset) == 0)
1745 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
1747 case BSSAP_LOCATION_UPDATE_REQUEST: /* 17.1.11 BSSAP+-LOCATION-UPDATE-REQUEST */
1748 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1749 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
1750 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
1752 /* SGSN number SGSN number 18.4.22 M TLV 5-11 */
1753 if ( check_ie(tvb, tree, &offset, BSSAP_SGSN_NUMBER))
1754 offset = dissect_bssap_sgsn_number(tvb, bssap_tree, offset);
1756 /* Update type GPRS location update type 18.4.6 M TLV 3 */
1757 if ( check_ie(tvb, tree, &offset, BSSAP_GPRS_LOC_UPD_TYPE))
1758 offset = dissect_bssap_gprs_location_update_type(tvb, bssap_tree, offset);
1760 /* New Cell global identity Cell global identity 18.4.1 M TLV 10 */
1761 if ( check_ie(tvb, tree, &offset, BSSAP_CELL_GBL_ID))
1762 offset = dissect_bssap_cell_global_id(tvb, bssap_tree, pinfo, offset);
1764 /* Mobile station classmark Mobile station classmark 1 18.4.18 M TLV 3 */
1765 if ( check_ie(tvb, tree, &offset, BSSAP_MOBILE_STN_CLS_MRK1))
1766 offset = dissect_bssap_mobile_stn_cls_mrk1(tvb, bssap_tree, pinfo, offset);
1767 if (tvb_length_remaining(tvb,offset) == 0)
1770 /* Old location area identifier Location area identifier 18.4.14 O TLV 7 */
1771 if ( check_optional_ie(tvb, offset, BSSAP_LOC_AREA_ID))
1772 offset = dissect_bssap_loc_area_id(tvb, bssap_tree, pinfo, offset);
1773 if (tvb_length_remaining(tvb,offset) == 0)
1776 /* TMSI status TMSI status 18.4.24 O TLV 3 */
1777 if ( check_optional_ie(tvb, offset, BSSAP_TMSI_STATUS))
1778 offset = dissect_bssap_tmsi_status(tvb, bssap_tree, offset);
1779 if (tvb_length_remaining(tvb,offset) == 0)
1782 /* New service area identification Service area identification 18.4.21b O TLV 9 */
1783 if ( check_optional_ie(tvb, offset, BSSAP_SERVICE_AREA_ID))
1784 offset = dissect_bssap_service_area_id(tvb, bssap_tree, offset);
1785 if (tvb_length_remaining(tvb,offset) == 0)
1788 /* IMEISV IMEISV 18.4.9 O TLV 10 */
1789 if ( check_optional_ie(tvb, offset, BSSAP_IMEISV))
1790 offset = dissect_bssap_imesiv(tvb, bssap_tree, offset);
1791 if (tvb_length_remaining(tvb,offset) == 0)
1793 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
1795 case BSSAP_LOCATION_UPDATE_ACCEPT: /* 17.1.9 */
1796 /* IMSI 18.4.10 M TLV 6-10 */
1797 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
1798 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
1800 /* Location area identifier Location area identifier 18.4.14 M TLV 7 */
1801 if ( check_ie(tvb, tree, &offset, BSSAP_LOC_AREA_ID))
1802 offset = dissect_bssap_loc_area_id(tvb, bssap_tree, pinfo, offset);
1804 if (tvb_length_remaining(tvb,offset) == 0)
1807 /* New TMSI, or IMSI Mobile identity 18.4.17 O TLV 6-10 */
1808 if ( check_optional_ie(tvb, offset, BSSAP_MOBILE_ID))
1809 offset = dissect_bssap_mobile_id(tvb, bssap_tree, pinfo, offset);
1810 if (tvb_length_remaining(tvb,offset) == 0)
1812 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
1814 case BSSAP_LOCATION_UPDATE_REJECT: /* 17.1.10 */
1815 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1816 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
1817 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
1818 /* Reject cause Reject cause 18.4.21 M TLV 3 */
1819 if ( check_ie(tvb, tree, &offset, BSSAP_REJECT_CAUSE))
1820 offset = dissect_bssap_reject_cause(tvb, bssap_tree, pinfo, offset);
1821 if (tvb_length_remaining(tvb,offset) == 0)
1823 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
1825 case BSSAP_TMSI_REALLOCATION_COMPLETE: /* 17.1.22 */
1826 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1827 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
1828 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
1830 if (tvb_length_remaining(tvb,offset) == 0)
1833 /* Cell global identity Cell global identity 18.4.1 O TLV 10 */
1834 if ( check_optional_ie(tvb, offset, BSSAP_CELL_GBL_ID))
1835 offset = dissect_bssap_cell_global_id(tvb, bssap_tree, pinfo, offset);
1837 if (tvb_length_remaining(tvb,offset) == 0)
1840 /* Service area identification Service area identification 18.4.21b O TLV 9 */
1841 if ( check_optional_ie(tvb, offset, BSSAP_SERVICE_AREA_ID))
1842 offset = dissect_bssap_service_area_id(tvb, bssap_tree, offset);
1843 if (tvb_length_remaining(tvb,offset) == 0)
1845 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
1847 case BSSAP_ALERT_REQUEST: /* 17.1.3 */
1848 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1849 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
1850 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
1852 if (tvb_length_remaining(tvb,offset) == 0)
1854 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
1856 case BSSAP_ALERT_ACK: /* 17.1.1 */
1857 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1858 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
1859 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
1861 if (tvb_length_remaining(tvb,offset) == 0)
1863 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
1865 case BSSAP_ALERT_REJECT: /* 17.1.2 */
1866 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1867 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
1868 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
1870 /* Gs Cause Gs Cause 18.4.7 M TLV 3 */
1871 if ( check_ie(tvb, tree, &offset, BSSAP_GS_CAUSE))
1872 offset = dissect_bssap_Gs_cause(tvb, bssap_tree, offset);
1874 if (tvb_length_remaining(tvb,offset) == 0)
1876 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
1878 case BSSAP_MS_ACTIVITY_INDICATION: /* 17.1.14 */
1879 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1880 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
1881 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
1883 if (tvb_length_remaining(tvb,offset) == 0)
1886 /* Cell global identity Cell global identity 18.4.1 O TLV 10 */
1887 if ( check_optional_ie(tvb, offset, BSSAP_CELL_GBL_ID))
1888 offset = dissect_bssap_cell_global_id(tvb, bssap_tree, pinfo, offset);
1890 if (tvb_length_remaining(tvb,offset) == 0)
1893 /* Service area identification Service area identification 18.4.21b O TLV 9 */
1894 if ( check_optional_ie(tvb, offset, BSSAP_SERVICE_AREA_ID))
1895 offset = dissect_bssap_service_area_id(tvb, bssap_tree, offset);
1896 if (tvb_length_remaining(tvb,offset) == 0)
1898 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
1900 case BSSAP_GPRS_DETACH_INDICATION: /* 17.1.6 */
1901 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1902 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
1903 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
1905 /* SGSN number SGSN number 18.4.22 M TLV 5-11 */
1906 if ( check_ie(tvb, tree, &offset, BSSAP_SGSN_NUMBER))
1907 offset = dissect_bssap_sgsn_number(tvb, bssap_tree, offset);
1909 /* IMSI detach from GPRS service type IMSI detach from GPRS service type 18.4.17 M TLV 3 */
1910 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI_DET_FROM_GPRS_SERV_TYPE))
1911 offset = dissect_bssap_imsi_det_from_gprs_serv_type(tvb, bssap_tree, offset);
1913 if (tvb_length_remaining(tvb,offset) == 0)
1916 /* Cell global identity Cell global identity 18.4.1 O TLV 10 */
1917 if ( check_optional_ie(tvb, offset, BSSAP_CELL_GBL_ID))
1918 offset = dissect_bssap_cell_global_id(tvb, bssap_tree, pinfo, offset);
1920 if (tvb_length_remaining(tvb,offset) == 0)
1923 /* Service area identification Service area identification 18.4.21b O TLV 9 */
1924 if ( check_optional_ie(tvb, offset, BSSAP_SERVICE_AREA_ID))
1925 offset = dissect_bssap_service_area_id(tvb, bssap_tree, offset);
1926 if (tvb_length_remaining(tvb,offset) == 0)
1928 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
1930 case BSSAP_GPRS_DETACH_ACK: /* 17.1.5 */
1931 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1932 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
1933 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
1935 if (tvb_length_remaining(tvb,offset) == 0)
1937 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
1939 case BSSAP_IMSI_DETACH_INDICATION: /* 17.1.8 */
1940 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1941 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
1942 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
1944 /* SGSN number SGSN number 18.4.22 M TLV 5-11 */
1945 if ( check_ie(tvb, tree, &offset, BSSAP_SGSN_NUMBER))
1946 offset = dissect_bssap_sgsn_number(tvb, bssap_tree, offset);
1948 /* Detach type IMSI detach from non-GPRS service type 18.4.11 M TLV 3 */
1949 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI_DET_FROM_NON_GPRS_SERV_TYPE))
1950 offset = dissect_bssap_imsi_det_from_non_gprs_serv_type(tvb, bssap_tree, offset);
1952 if (tvb_length_remaining(tvb,offset) == 0)
1955 /* Cell global identity Cell global identity 18.4.1 O TLV 10 */
1956 if ( check_optional_ie(tvb, offset, BSSAP_CELL_GBL_ID))
1957 offset = dissect_bssap_cell_global_id(tvb, bssap_tree, pinfo, offset);
1959 if (tvb_length_remaining(tvb,offset) == 0)
1962 /* Location information age Location information age 18.4.14 O TLV 4 */
1963 if ( check_optional_ie(tvb, offset, BSSAP_LOC_INF_AGE))
1964 offset = dissect_bssap_location_information_age(tvb, bssap_tree, offset);
1966 if (tvb_length_remaining(tvb,offset) == 0)
1969 /* Service area identification Service area identification 18.4.21b O TLV 9 */
1970 if ( check_optional_ie(tvb, offset, BSSAP_SERVICE_AREA_ID))
1971 offset = dissect_bssap_service_area_id(tvb, bssap_tree, offset);
1972 if (tvb_length_remaining(tvb,offset) == 0)
1974 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
1976 case BSSAP_IMSI_DETACH_ACK: /* 17.1.7 */
1977 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1978 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
1979 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
1981 if (tvb_length_remaining(tvb,offset) == 0)
1983 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
1985 case BSSAP_RESET_INDICATION: /* 17.1.21 */
1986 /* Conditional IE:s */
1987 /* SGSN number SGSN number 18.4.22 C TLV 5-11 */
1988 if ( check_optional_ie(tvb, offset, BSSAP_SGSN_NUMBER)){
1989 offset = dissect_bssap_sgsn_number(tvb, bssap_tree, offset);
1990 if (tvb_length_remaining(tvb,offset) == 0)
1992 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
1994 /* VLR number VLR number 18.4.26 C TLV 5-11 */
1995 if ( check_optional_ie(tvb, offset, BSSAP_VLR_NUMBER)){
1996 offset = dissect_bssap_vlr_number(tvb, bssap_tree, offset);
1997 if (tvb_length_remaining(tvb,offset) == 0)
1999 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
2002 proto_tree_add_text(tree, tvb, offset, -1, "Conditional IE");
2004 case BSSAP_RESET_ACK: /* 17.1.20 */
2005 /* Conditional IE:s */
2006 /* SGSN number SGSN number 18.4.22 C TLV 5-11 */
2007 if ( check_optional_ie(tvb, offset, BSSAP_SGSN_NUMBER)){
2008 offset = dissect_bssap_sgsn_number(tvb, bssap_tree, offset);
2009 if (tvb_length_remaining(tvb,offset) == 0)
2011 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
2013 /* VLR number VLR number 18.4.26 C TLV 5-11 */
2014 if ( check_optional_ie(tvb, offset, BSSAP_VLR_NUMBER)){
2015 offset = dissect_bssap_vlr_number(tvb, bssap_tree, offset);
2016 if (tvb_length_remaining(tvb,offset) == 0)
2018 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
2021 proto_tree_add_text(tree, tvb, offset, -1, "Conditional IE");
2023 case BSSAP_MS_INFORMATION_REQUEST: /* 17.1.15 */
2024 /* IMSI IMSI 18.4.10 M TLV 6-10 */
2025 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
2026 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
2028 /* Information requested Information requested 18.4.13 M TLV 3 */
2029 if ( check_ie(tvb, tree, &offset, BSSAP_INFO_REQ))
2030 offset = dissect_bssap_info_req(tvb, bssap_tree, offset);
2032 if (tvb_length_remaining(tvb,offset) == 0)
2035 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
2037 case BSSAP_MS_INFORMATION_RESPONSE: /* 17.1.16 */
2038 /* IMSI IMSI 18.4.10 M TLV 6-10 */
2039 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
2040 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
2041 if (tvb_length_remaining(tvb,offset) == 0)
2044 /* TMSI TMSI 18.4.23 O TLV 6 */
2045 if ( check_optional_ie(tvb, offset, BSSAP_TMSI))
2046 offset = dissect_bssap_tmsi(tvb, bssap_tree, offset);
2047 if (tvb_length_remaining(tvb,offset) == 0)
2050 /* PTMSI PTMSI 18.4.20 O TLV 6 BSSAP_PTMSI*/
2051 if ( check_optional_ie(tvb, offset, BSSAP_PTMSI))
2052 offset = dissect_bssap_ptmsi(tvb, bssap_tree, offset);
2053 if (tvb_length_remaining(tvb,offset) == 0)
2056 /* IMEI IMEI 18.4.8 O TLV 10 */
2057 if ( check_optional_ie(tvb, offset, BSSAP_IMEI))
2058 offset = dissect_bssap_imei(tvb, bssap_tree, offset);
2059 if (tvb_length_remaining(tvb,offset) == 0)
2061 /* IMEISV IMEISV 18.4.9 O TLV 10 BSSAP_IMEISV*/
2062 if ( check_optional_ie(tvb, offset, BSSAP_IMEISV))
2063 offset = dissect_bssap_imesiv(tvb, bssap_tree, offset);
2064 if (tvb_length_remaining(tvb,offset) == 0)
2067 /* Cell global identity Cell global identity 18.4.1 O TLV 10 */
2068 if ( check_optional_ie(tvb, offset, BSSAP_CELL_GBL_ID))
2069 offset = dissect_bssap_cell_global_id(tvb, bssap_tree, pinfo, offset);
2071 if (tvb_length_remaining(tvb,offset) == 0)
2073 /* Location information age Location information age 18.4.15 O TLV 4 */
2074 if ( check_optional_ie(tvb, offset, BSSAP_LOC_INF_AGE))
2075 offset = dissect_bssap_location_information_age(tvb, bssap_tree, offset);
2077 if (tvb_length_remaining(tvb,offset) == 0)
2080 /* Mobile station state Mobile station state 18.4.19 O TLV 3 */
2081 if ( check_optional_ie(tvb, offset, BSSAP_MOBILE_STN_STATE))
2082 offset = dissect_bssap_mobile_station_state(tvb, bssap_tree, offset);
2084 if (tvb_length_remaining(tvb,offset) == 0)
2087 /* Service area identification Service area identification 18.4.21b O TLV 9 */
2088 if ( check_optional_ie(tvb, offset, BSSAP_SERVICE_AREA_ID))
2089 offset = dissect_bssap_service_area_id(tvb, bssap_tree, offset);
2090 if (tvb_length_remaining(tvb,offset) == 0)
2092 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
2094 case BSSAP_MM_INFORMATION_REQUEST: /* 17.1.12 */
2095 /* IMSI IMSI 18.4.10 M TLV 6-10 */
2096 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
2097 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
2099 if (tvb_length_remaining(tvb,offset) == 0)
2101 /* MM information MM information 18.4.16 O TLV 3-n */
2102 if ( check_optional_ie(tvb, offset, BSSAP_MM_INFORMATION))
2103 offset = dissect_bssap_MM_information(tvb, bssap_tree, pinfo, offset);
2104 if (tvb_length_remaining(tvb,offset) == 0)
2106 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
2108 case BSSAP_MOBILE_STATUS: /* 17.1.13 */
2109 /* IMSI IMSI 18.4.10 O TLV 6-10 */
2110 if ( check_optional_ie(tvb, offset, BSSAP_IMSI))
2111 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
2112 /* Gs Cause Gs Cause 18.4.7 M TLV 3 */
2113 if ( check_ie(tvb, tree, &offset, BSSAP_GS_CAUSE))
2114 offset = dissect_bssap_Gs_cause(tvb, bssap_tree, offset);
2116 /* Erroneous message Erroneous message 18.4.5 M TLV 3-n BSSAP_ERRONEOUS_MSG*/
2117 if ( check_ie(tvb, tree, &offset, BSSAP_ERRONEOUS_MSG))
2118 offset = dissect_bssap_gprs_erroneous_msg(tvb, bssap_tree, offset);
2120 if (tvb_length_remaining(tvb,offset) == 0)
2122 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
2124 case BSSAP_MS_UNREACHABLE: /* 17.1.17 */
2125 /* IMSI IMSI 18.4.10 M TLV 6-10 */
2126 if ( check_ie(tvb, tree, &offset, BSSAP_IMSI))
2127 offset = dissect_bssap_imsi(tvb, bssap_tree, offset);
2129 /* Gs Cause Gs Cause 18.4.7 M TLV 3 */
2130 if ( check_ie(tvb, tree, &offset, BSSAP_GS_CAUSE))
2131 offset = dissect_bssap_Gs_cause(tvb, bssap_tree, offset);
2133 if (tvb_length_remaining(tvb,offset) == 0)
2135 proto_tree_add_text(tree, tvb, offset, -1, "Extraneous data");
2143 dissect_bssap_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2145 /* Is it a BSSAP/BSAP packet?
2146 * If octet_1 == 0x00 and octet_2 == length(tvb) - 2
2147 * or if octet_1 == 0x01 and octet_3 == length(tvb) - 3
2148 * then we'll assume it is a bssap packet
2149 * If octet_1 == 0x00 a further check is done
2150 * to differentiate a BSSMAP BLOCK message from a
2151 * RANAP DirectTransfer (under certain conditions)
2153 switch (tvb_get_guint8(tvb, 0))
2156 if (tvb_get_guint8(tvb, 1) != (tvb_length(tvb) - 2)) { return(ENC_BIG_ENDIAN); }
2157 if (tvb_get_guint8(tvb, 2) == 0x40 && tvb_get_guint8(tvb, 3) != 0x01) {
2158 return(ENC_BIG_ENDIAN); }
2162 if (tvb_get_guint8(tvb, 2) != (tvb_length(tvb) - 3)) { return(ENC_BIG_ENDIAN); }
2166 return(ENC_BIG_ENDIAN);
2169 dissect_bssap(tvb, pinfo, tree);
2174 /* Register the protocol with Wireshark */
2176 proto_register_bssap(void)
2178 module_t *bssap_module;
2180 /* Setup list of header fields */
2181 static hf_register_info hf[] = {
2182 { &hf_bssap_pdu_type,
2183 { "Message Type", "bssap.pdu_type",
2184 FT_UINT8, BASE_HEX, VALS(bssap_pdu_type_values), 0x0,
2186 { &hf_bsap_pdu_type,
2187 { "Message Type", "bsap.pdu_type",
2188 FT_UINT8, BASE_HEX, VALS(bsap_pdu_type_values), 0x0,
2190 { &hf_bssap_dlci_cc,
2191 { "Control Channel", "bssap.dlci.cc",
2192 FT_UINT8, BASE_HEX, VALS(bssap_cc_values), CC_MASK,
2195 { "Control Channel", "bsap.dlci.cc",
2196 FT_UINT8, BASE_HEX, VALS(bsap_cc_values), CC_MASK,
2198 { &hf_bssap_dlci_spare,
2199 { "Spare", "bssap.dlci.spare",
2200 FT_UINT8, BASE_HEX, NULL, SPARE_MASK,
2202 { &hf_bsap_dlci_rsvd,
2203 { "Reserved", "bsap.dlci.rsvd",
2204 FT_UINT8, BASE_HEX, NULL, SPARE_MASK,
2206 { &hf_bssap_dlci_sapi,
2207 { "SAPI", "bssap.dlci.sapi",
2208 FT_UINT8, BASE_HEX, VALS(bssap_sapi_values), SAPI_MASK,
2210 { &hf_bsap_dlci_sapi,
2211 { "SAPI", "bsap.dlci.sapi",
2212 FT_UINT8, BASE_HEX, VALS(bsap_sapi_values), SAPI_MASK,
2215 { "Length", "bssap.length",
2216 FT_UINT8, BASE_DEC, NULL, 0x0,
2219 { &hf_bssap_plus_message_type,
2220 { "Message Type", "bssap_plus.msg_type",
2221 FT_UINT8, BASE_DEC, VALS(bssap_plus_message_type_values), 0x0,
2223 { &hf_bssap_plus_ie,
2224 { "IEI", "bssap_plus.iei",
2225 FT_UINT8, BASE_DEC, VALS(bssap_plus_ie_id_values), 0x0,
2227 { &hf_bssap_plus_ie_len,
2228 { "Length indicator", "bssap_plus.iei",
2229 FT_UINT8, BASE_DEC, NULL, 0x0,
2231 { &hf_bssap_extension,
2232 { "Extension", "bssap.extension",
2233 FT_BOOLEAN, 8, TFS(&bssap_extension_value), 0x80,
2235 { &hf_bssap_type_of_number,
2236 { "Type of number", "bssap.type_of_number",
2237 FT_UINT8, BASE_HEX, VALS(gsm_a_type_of_number_values), 0x70,
2239 { &hf_bssap_numbering_plan_id,
2240 { "Numbering plan identification", "bssap.number_plan",
2241 FT_UINT8, BASE_HEX, VALS(gsm_a_numbering_plan_id_values), 0x0f,
2243 { &hf_bssap_sgsn_number,
2244 { "SGSN number", "bssap.sgsn_number",
2245 FT_STRING, BASE_NONE, NULL, 0,
2247 { &hf_bssap_vlr_number,
2248 { "VLR number", "bssap.vlr_number",
2249 FT_STRING, BASE_NONE, NULL, 0,
2251 { &hf_bssap_cell_global_id_ie,
2252 { "Cell global identity IE", "bssap.cell_global_id_ie",
2253 FT_NONE, BASE_NONE, NULL, 0,
2255 { &hf_bssap_channel_needed_ie,
2256 { "Channel needed IE", "bssap.cell_global_id_ie",
2257 FT_NONE, BASE_NONE, NULL, 0,
2259 { &hf_bssap_dlink_tnl_pld_cntrl_amd_inf_ie,
2260 { "Downlink Tunnel Payload Control and Info IE", "bssap.dlink_tnl_pld_cntrl_amd_inf_ie",
2261 FT_NONE, BASE_NONE, NULL, 0,
2263 { &hf_bssap_ulink_tnl_pld_cntrl_amd_inf_ie,
2264 { "Uplink Tunnel Payload Control and Info IE", "bssap.ulink_tnl_pld_cntrl_amd_inf_ie",
2265 FT_NONE, BASE_NONE, NULL, 0,
2267 { &hf_bssap_emlpp_prio_ie,
2268 { "eMLPP Priority IE", "bssap.emlpp_prio_ie",
2269 FT_NONE, BASE_NONE, NULL, 0,
2271 { &hf_bssap_gprs_erroneous_msg_ie,
2272 { "Erroneous message IE", "bssap.erroneous_msg_ie",
2273 FT_NONE, BASE_NONE, NULL, 0,
2275 { &hf_bssap_gprs_loc_upd_type_ie,
2276 { "GPRS location update type IE", "bssap.loc_upd_type_ie",
2277 FT_NONE, BASE_NONE, NULL, 0,
2279 { &hf_bssap_Gs_cause_ie,
2280 { "Gs Cause IE", "bssap.Gs_cause_ie",
2281 FT_NONE, BASE_NONE, NULL, 0,
2283 { &hf_bssap_imei_ie,
2284 { "IMEI IE", "bssap.imei_ie",
2285 FT_NONE, BASE_NONE, NULL, 0,
2287 { &hf_bssap_imesiv_ie,
2288 { "IMEISV IE", "bssap.imesiv",
2289 FT_NONE, BASE_NONE, NULL, 0,
2291 { &hf_bssap_imsi_ie,
2292 { "IMSI IE", "bssap.imsi_ie",
2293 FT_NONE, BASE_NONE, NULL, 0,
2295 { &hf_bssap_imsi_det_from_gprs_serv_type_ie,
2296 { "IMSI detach from GPRS service type IE", "bssap.msi_det_from_gprs_serv_type_ie",
2297 FT_NONE, BASE_NONE, NULL, 0,
2299 { &hf_bssap_imsi_det_from_non_gprs_serv_type_ie,
2300 { "IMSI detach from non-GPRS service IE", "bssap.msi_det_from_non_gprs_serv_type_ie",
2301 FT_NONE, BASE_NONE, NULL, 0,
2303 { &hf_bssap_info_req_ie,
2304 { "Information requested IE", "bssap.info_req_ie",
2305 FT_NONE, BASE_NONE, NULL, 0,
2307 { &hf_bssap_loc_area_id_ie,
2308 { "Location area identifier IE", "bssap.loc_area_id_ie",
2309 FT_NONE, BASE_NONE, NULL, 0,
2311 { &hf_bssap_loc_inf_age_ie,
2312 { "Location information age IE", "bssap.loc_inf_age_ie",
2313 FT_NONE, BASE_NONE, NULL, 0,
2315 { &hf_bssap_mm_information_ie,
2316 { "MM information IE", "bssap.mm_information",
2317 FT_NONE, BASE_NONE, NULL, 0,
2319 { &hf_bssap_mobile_id_ie,
2320 { "Mobile identity IE", "bssap.mobile_id_ie",
2321 FT_NONE, BASE_NONE, NULL, 0,
2323 { &hf_bssap_mobile_stn_cls_mrk1_ie,
2324 { "Mobile station classmark 1 IE", "bssap.mobile_stn_cls_mrk1_ie",
2325 FT_NONE, BASE_NONE, NULL, 0,
2327 { &hf_bssap_mobile_station_state_ie,
2328 { "Mobile station state IE", "bssap.mobile_station_state_ie",
2329 FT_NONE, BASE_NONE, NULL, 0,
2331 { &hf_bssap_ptmsi_ie,
2332 { "PTMSI IE", "bssap.ptmsi_ie",
2333 FT_NONE, BASE_NONE, NULL, 0,
2335 { &hf_bssap_reject_cause_ie,
2336 { "Reject cause IE", "bssap.reject_cause_ie",
2337 FT_NONE, BASE_NONE, NULL, 0,
2339 { &hf_bssap_service_area_id_ie,
2340 { "Service area identification IE", "bssap.mobile_stn_cls_mrk1_ie",
2341 FT_NONE, BASE_NONE, NULL, 0,
2342 "Mobile station classmark 1", HFILL }},
2343 { &hf_bssap_sgsn_nr_ie,
2344 { "SGSN number IE", "bssap.imsi_ie",
2345 FT_NONE, BASE_NONE, NULL, 0,
2347 { &hf_bssap_tmsi_ie,
2348 { "TMSI IE", "bssap.tmsi_ie",
2349 FT_NONE, BASE_NONE, NULL, 0,
2351 { &hf_bssap_tmsi_status_ie,
2352 { "TMSI status IE", "bssap.tmsi_status_ie",
2353 FT_NONE, BASE_NONE, NULL, 0,
2355 { &hf_bssap_vlr_number_ie,
2356 { "VLR number IE", "bssap.vlr_number_ie",
2357 FT_NONE, BASE_NONE, NULL, 0,
2359 { &hf_bssap_global_cn_id_ie,
2360 { "Global CN-Id IE", "bssap.global_cn_id_ie",
2361 FT_NONE, BASE_NONE, NULL, 0,
2364 { &hf_bssap_plus_ie_data,
2365 { "IE Data", "bssap.ie_data",
2366 FT_BYTES, BASE_NONE, NULL, 0,
2369 { &hf_bssap_call_priority,
2370 { "eMLPP Priority", "bssap.gprs_loc_upd_type",
2371 FT_UINT8, BASE_DEC, VALS(bssap_call_priority_values), 0x07,
2373 { &hf_bssap_gprs_loc_upd_type,
2374 { "GPRS location update type", "bssap.gprs_loc_upd_type",
2375 FT_UINT8, BASE_DEC, VALS(bssap_plus_GPRS_loc_upd_type_values), 0x0,
2377 { &hf_bssap_Gs_cause,
2378 { "Gs cause", "bssap.gprs_loc_upd_type",
2379 FT_UINT8, BASE_DEC, VALS(bssap_Gs_cause_values), 0x0,
2382 { "IMEI", "bssap.imei",
2383 FT_STRING, BASE_NONE, NULL, 0,
2386 { "IMEISV", "bssap.imeisv",
2387 FT_STRING, BASE_NONE, NULL, 0,
2390 { "IMSI", "bssap.imsi",
2391 FT_STRING, BASE_NONE, NULL, 0,
2393 { &hf_bssap_imsi_det_from_gprs_serv_type,
2394 { "IMSI detach from GPRS service type", "bssap.imsi_det_from_gprs_serv_type",
2395 FT_UINT8, BASE_DEC, VALS(bssap_Gs_cause_values), 0x0,
2397 { &hf_bssap_info_req,
2398 { "Information requested", "bssap.info_req",
2399 FT_UINT8, BASE_DEC, VALS(bssap_info_req_values), 0x0,
2401 { &hf_bssap_loc_inf_age,
2402 { "AgeOfLocationInformation in minutes", "bssap.loc_inf_age",
2403 FT_UINT16, BASE_DEC, NULL, 0x0,
2405 { &hf_bssap_mobile_station_state,
2406 { "Mobile station state", "bssap.mobile_station_state",
2407 FT_UINT8, BASE_DEC, VALS(bssap_mobile_station_state_values), 0x0,
2410 { "PTMSI", "bssap.ptmsi",
2411 FT_BYTES, BASE_NONE, NULL, 0x0,
2414 { "TMSI", "bssap.tmsi",
2415 FT_BYTES, BASE_NONE, NULL, 0x0,
2417 { &hf_bssap_tmsi_status,
2418 { "TMSI status", "bssap.tmsi_status",
2419 FT_BOOLEAN, 8, TFS(&bssap_tmsi_flag), 0x01,
2421 { &hf_bssap_tom_prot_disc,
2422 { "TOM Protocol Discriminator", "bssap.Tom_prot_disc",
2423 FT_UINT8, BASE_DEC, VALS(bssap_tom_prot_disc_values), 0x78,
2426 { "E: Cipher Request", "bssap.tmsi_status",
2427 FT_BOOLEAN, 8, TFS(&bssap_E_flag), 0x04,
2429 { &hf_bssap_tunnel_prio,
2430 { "Tunnel Priority", "bssap.tunnel_prio",
2431 FT_UINT8, BASE_DEC, NULL, 0x0,
2433 { &hf_bssap_global_cn_id,
2434 { "Global CN-Id", "bssap.global_cn_id",
2435 FT_BYTES, BASE_NONE, NULL, 0x0,
2437 { &hf_bssap_plmn_id,
2438 { "PLMN-Id", "bssap.plmn_id",
2439 FT_BYTES, BASE_NONE, NULL, 0x0,
2442 { "CN-Id", "bssap.cn_id",
2443 FT_UINT16, BASE_DEC, NULL, 0x0,
2445 { &hf_bssap_cell_global_id,
2446 { "Cell global identity", "bssap.plmn_id",
2447 FT_BYTES, BASE_NONE, NULL, 0x0,
2451 /* Setup protocol subtree array */
2452 static gint *ett[] = {
2456 &ett_bssap_imsi_det_from_gprs_serv_type,
2457 &ett_bssap_imsi_det_from_non_gprs_serv_type,
2458 &ett_bssap_info_req,
2459 &ett_bssap_loc_area_id,
2460 &ett_bssap_loc_inf_age,
2461 &ett_bssap_mm_information,
2462 &ett_bssap_mobile_id,
2465 &ett_bssap_tmsi_status,
2466 &ett_bssap_vlr_number,
2467 &ett_bssap_global_cn,
2468 &ett_bssap_gprs_loc_upd,
2469 &ett_bassp_Gs_cause,
2472 &ett_bssap_cell_global_id,
2474 &ett_bssap_channel_needed,
2475 &ett_bssap_dlink_tnl_pld_cntrl_amd_inf,
2476 &ett_bssap_ulink_tnl_pld_cntrl_amd_inf,
2477 &ett_bssap_emlpp_prio,
2478 &ett_bssap_erroneous_msg,
2479 &ett_bssap_mobile_stn_cls_mrk1,
2480 &ett_bssap_mobile_station_state,
2482 &ett_bssap_reject_cause,
2483 &ett_bssap_service_area_id,
2484 &ett_bssap_global_cn_id,
2488 static enum_val_t gsm_or_lb_interface_options[] = {
2489 { "gsm a", "GSM A", GSM_INTERFACE },
2490 { "lb", "Lb", LB_INTERFACE },
2494 static enum_val_t bssap_or_bsap_options[] = {
2495 { "bssap", "BSSAP", BSSAP },
2496 { "bsap", "BSAP", BSAP },
2501 /* Register the protocol name and description */
2502 proto_bssap = proto_register_protocol("BSSAP/BSAP", "BSSAP", "bssap");
2503 /*proto_bssap_plus = proto_register_protocol("BSSAP2", "BSSAP2", "bssap2");*/
2505 register_dissector("bssap", dissect_bssap, proto_bssap);
2507 /* Required function calls to register the header fields and subtrees used */
2508 proto_register_field_array(proto_bssap, hf, array_length(hf));
2509 proto_register_subtree_array(ett, array_length(ett));
2511 bssap_module = prefs_register_protocol(proto_bssap, proto_reg_handoff_bssap);
2513 prefs_register_enum_preference(bssap_module,
2515 "Identify to sub-dissector as",
2516 "For the sake of sub-dissectors registering to accept data "
2517 "from the BSSAP/BSAP dissector, this defines whether it is "
2518 "identified as BSSAP or BSAP.",
2519 &bssap_or_bsap_global,
2520 bssap_or_bsap_options,
2523 prefs_register_enum_preference(bssap_module,
2524 "gsm_or_lb_interface",
2525 "Identify the BSSAP interface",
2526 "GSM-A is the interface between the BSC and the MSC. Lb is the interface between the BSC and the SMLC.",
2527 &gsm_or_lb_interface_global,
2528 gsm_or_lb_interface_options,
2531 prefs_register_uint_preference(bssap_module, "ssn",
2532 "Subsystem number used for BSSAP",
2533 "Set Subsystem number used for BSSAP/BSSAP+",
2534 10, &global_bssap_ssn);
2535 bssap_dissector_table = register_dissector_table("bssap.pdu_type", "BSSAP Message Type", FT_UINT8, BASE_DEC);
2536 bsap_dissector_table = register_dissector_table("bsap.pdu_type", "BSAP Message Type", FT_UINT8, BASE_DEC);
2540 proto_reg_handoff_bssap(void)
2542 static gboolean initialized = FALSE;
2543 static dissector_handle_t bssap_plus_handle;
2544 static guint old_bssap_ssn;
2547 heur_dissector_add("sccp", dissect_bssap_heur, proto_bssap);
2548 heur_dissector_add("sua", dissect_bssap_heur, proto_bssap);
2550 bssap_plus_handle = create_dissector_handle(dissect_bssap_plus, proto_bssap);
2552 data_handle = find_dissector("data");
2553 rrlp_handle = find_dissector("rrlp");
2556 dissector_delete_uint("sccp.ssn", old_bssap_ssn, bssap_plus_handle);
2559 dissector_add_uint("sccp.ssn", global_bssap_ssn, bssap_plus_handle);
2560 old_bssap_ssn = global_bssap_ssn;