Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-bssap.c
blob99d701f63d181f88e490267efeb595960a8e3dc7
1 /* packet-bssap.c
2 * Routines for Base Station Subsystem Application Part (BSSAP/BSAP) dissection
3 * Specifications from 3GPP2 (www.3gpp2.org) and 3GPP (www.3gpp.org)
4 * IOS 4.0.1 (BSAP)
5 * GSM 08.06 (BSSAP)
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>
13 * Wireshark - Network traffic analyzer
14 * By Gerald Combs <gerald@wireshark.org>
15 * Copyright 1998 Gerald Combs
17 * SPDX-License-Identifier: GPL-2.0-or-later
20 #include "config.h"
22 #include <epan/packet.h>
23 #include <epan/expert.h>
24 #include <epan/prefs.h>
25 #include <epan/proto_data.h>
26 #include <wsutil/str_util.h>
27 #include <epan/tfs.h>
28 #include "packet-bssap.h"
29 #include "packet-gsm_a_common.h"
30 #include "packet-e212.h"
32 void proto_register_bssap(void);
33 void proto_reg_handoff_bssap(void);
35 static dissector_handle_t bssap_handle;
36 static dissector_handle_t bssap_plus_handle;
37 static dissector_handle_t bsap_handle;
38 static dissector_handle_t bssap_le_handle;
40 enum bssap_proto {
41 BSSAP,
42 BSAP,
43 BSSAP_LE,
46 #define PDU_TYPE_OFFSET 0
47 #define PDU_TYPE_LENGTH 1
49 /* Same as below but with names typed out */
50 static const value_string bssap_pdu_type_values[] = {
51 { BSSAP_PDU_TYPE_BSSMAP, "BSS Management" },
52 { BSSAP_PDU_TYPE_DTAP, "Direct Transfer" },
53 { 0, NULL } };
55 static const value_string bsap_pdu_type_values[] = {
56 { BSSAP_PDU_TYPE_BSSMAP, "BS Management" },
57 { BSSAP_PDU_TYPE_DTAP, "Direct Transfer" },
58 { 0, NULL } };
60 /* Same as above but in acronym for (for the Info column) */
61 static const value_string bssap_pdu_type_acro_values[] = {
62 { BSSAP_PDU_TYPE_BSSMAP, "BSSMAP" },
63 { BSSAP_PDU_TYPE_DTAP, "DTAP" },
64 { 0, NULL } };
66 /* Same as above but in acronym for (for the Info column) */
67 static const value_string bsap_pdu_type_acro_values[] = {
68 { BSSAP_PDU_TYPE_BSSMAP, "BSMAP" },
69 { BSSAP_PDU_TYPE_DTAP, "DTAP" },
70 { 0, NULL } };
72 #define PARAMETER_DLCI 0x00
73 #define PARAMETER_LENGTH 0x01
74 #define PARAMETER_DATA 0x02
76 #define DLCI_LENGTH 1
77 #define LENGTH_LENGTH 1
78 #define DATA_LENGTH 1
80 #define CC_MASK 0xc0
81 #define SPARE_MASK 0x38
82 #define SAPI_MASK 0x07
84 #define BSSAP_PLUS_SSN 98
86 static const value_string bssap_cc_values[] = {
87 { 0x00, "not further specified" },
88 { 0x02, "FACCH or SDCCH" },
89 { 0x03, "SACCH" },
90 { 0, NULL } };
92 static const value_string bsap_cc_values[] = {
93 { 0x00, "default for TIA/EIA/IS-2000" },
94 { 0, NULL } };
96 static const value_string bssap_sapi_values[] = {
97 { 0x00, "RR/MM/CC" },
98 { 0x03, "SMS" },
99 { 0, NULL } };
101 static const value_string bsap_sapi_values[] = {
102 { 0x00, "Not used" },
103 { 0, NULL } };
105 #define BSSAP_PAGING_REQUEST 1
106 #define BSSAP_PAGING_REJECT 2 /* 17.1.18 */
107 #define BSSAP_DOWNLINK_TUNNEL_REQUEST 7 /* 17.1.4 */
108 #define BSSAP_UPLINK_TUNNEL_REQUEST 8 /* 17.1.23 */
109 #define BSSAP_LOCATION_UPDATE_REQUEST 9 /* 17.1.11 */
110 #define BSSAP_LOCATION_UPDATE_ACCEPT 10 /* 17.1.9 */
111 #define BSSAP_LOCATION_UPDATE_REJECT 11 /* 17.1.10 */
112 #define BSSAP_TMSI_REALLOCATION_COMPLETE 12 /* 17.1.22 */
113 #define BSSAP_ALERT_REQUEST 13 /* 17.1.3 */
114 #define BSSAP_ALERT_ACK 14 /* 17.1.1 */
115 #define BSSAP_ALERT_REJECT 15 /* 17.1.2 */
116 #define BSSAP_MS_ACTIVITY_INDICATION 16 /* 17.1.14 */
117 #define BSSAP_GPRS_DETACH_INDICATION 17 /* 17.1.6 */
118 #define BSSAP_GPRS_DETACH_ACK 18 /* 17.1.5 */
119 #define BSSAP_IMSI_DETACH_INDICATION 19 /* 17.1.8 */
120 #define BSSAP_IMSI_DETACH_ACK 20 /* 17.1.7 */
121 #define BSSAP_RESET_INDICATION 21 /* 17.1.21 */
122 #define BSSAP_RESET_ACK 22 /* 17.1.20 */
123 #define BSSAP_MS_INFORMATION_REQUEST 23 /* 17.1.15 */
124 #define BSSAP_MS_INFORMATION_RESPONSE 24 /* 17.1.16 */
125 #define BSSAP_MM_INFORMATION_REQUEST 26 /* 17.1.12 */
126 #define BSSAP_MOBILE_STATUS 29 /* 17.1.13 */
127 #define BSSAP_MS_UNREACHABLE 31 /* 17.1.17 */
129 static const value_string bssap_plus_message_type_values[] = {
130 /* 0 */ { 0x00, "Unassigned: treated as an unknown Message type." },
131 /* 1 */ { BSSAP_PAGING_REQUEST, "BSSAP+-PAGING-REQUEST" }, /* 17.1.19 */
132 /* 2 */ { BSSAP_PAGING_REJECT, "BSSAP+-PAGING-REJECT" }, /* 17.1.18 */
133 /* 3 */ { 0x03, "Unassigned: treated as an unknown Message type." },
134 /* 4 */ { 0x04, "Unassigned: treated as an unknown Message type." },
135 /* 5 */ { 0x05, "Unassigned: treated as an unknown Message type." },
136 /* 6 */ { 0x06, "Unassigned: treated as an unknown Message type." },
137 /* 7 */ { BSSAP_DOWNLINK_TUNNEL_REQUEST, "BSSAP+-DOWNLINK-TUNNEL-REQUEST" }, /* 17.1.4 */
138 /* 8 */ { BSSAP_UPLINK_TUNNEL_REQUEST, "BSSAP+-UPLINK-TUNNEL-REQUEST" }, /* 17.1.23 */
139 /* 9 */ { BSSAP_LOCATION_UPDATE_REQUEST, "BSSAP+-LOCATION-UPDATE-REQUEST" }, /* 17.1.11 */
140 /* 10 */ { BSSAP_LOCATION_UPDATE_ACCEPT, "BSSAP+-LOCATION-UPDATE-ACCEPT" }, /* 17.1.9 */
141 /* 11 */ { BSSAP_LOCATION_UPDATE_REJECT, "BSSAP+-LOCATION-UPDATE-REJECT" }, /* 17.1.10 */
142 /* 12 */ { BSSAP_TMSI_REALLOCATION_COMPLETE, "BSSAP+-TMSI-REALLOCATION-COMPLETE" }, /* 17.1.22 */
143 /* 13 */ { BSSAP_ALERT_REQUEST, "BSSAP+-ALERT-REQUEST" }, /* 17.1.3 */
144 /* 14 */ { BSSAP_ALERT_ACK, "BSSAP+-ALERT-ACK" }, /* 17.1.1 */
145 /* 15 */ { BSSAP_ALERT_REJECT, "BSSAP+-ALERT-REJECT" }, /* 17.1.2 */
146 /* 16 */ { BSSAP_MS_ACTIVITY_INDICATION, "BSSAP+-MS-ACTIVITY-INDICATION" }, /* 17.1.14 */
147 /* 17 */ { BSSAP_GPRS_DETACH_INDICATION, "BSSAP+-GPRS-DETACH-INDICATION" }, /* 17.1.6 */
148 /* 18 */ { BSSAP_GPRS_DETACH_ACK, "BSSAP+-GPRS-DETACH-ACK" }, /* 17.1.5 */
149 /* 19 */ { BSSAP_IMSI_DETACH_INDICATION, "BSSAP+-IMSI-DETACH-INDICATION" }, /* 17.1.8 */
150 /* 20 */ { BSSAP_IMSI_DETACH_ACK, "BSSAP+-IMSI-DETACH-ACK" }, /* 17.1.7 */
151 /* 21 */ { BSSAP_RESET_INDICATION, "BSSAP+-RESET-INDICATION" }, /* 17.1.21 */
152 /* 22 */ { BSSAP_RESET_ACK, "BSSAP+-RESET-ACK" }, /* 17.1.20 */
153 /* 23 */ { BSSAP_MS_INFORMATION_REQUEST, "BSSAP+-MS-INFORMATION-REQUEST" }, /* 17.1.15 */
154 /* 24 */ { BSSAP_MS_INFORMATION_RESPONSE, "BSSAP+-MS-INFORMATION-RESPONSE" }, /* 17.1.16 */
155 /* 25 */ { 0x19, "Unassigned: treated as an unknown Message type." },
156 /* 26 */ { BSSAP_MM_INFORMATION_REQUEST, "BSSAP+-MM-INFORMATION-REQUEST" }, /* 17.1.12 */
157 /* 27 */ { 0x1b, "Unassigned: treated as an unknown Message type." },
158 /* 28 */ { 0x1c, "Unassigned: treated as an unknown Message type." },
159 /* 29 */ { BSSAP_MOBILE_STATUS, "BSSAP+-MOBILE-STATUS" }, /* 17.1.13 */
160 /* 30 */ { 0x1e, "Unassigned: treated as an unknown Message type." },
161 /* 31 */ { BSSAP_MS_UNREACHABLE, "BSSAP+-MS-UNREACHABLE" }, /* 17.1.17 */
162 { 0, NULL }
164 static value_string_ext bssap_plus_message_type_values_ext = VALUE_STRING_EXT_INIT(bssap_plus_message_type_values);
166 #define BSSAP_IMSI 1
167 #define BSSAP_VLR_NUMBER 2
168 #define BSSAP_TMSI 3
169 #define BSSAP_LOC_AREA_ID 4
170 #define BSSAP_CHANNEL_NEEDED 5
171 #define BSSAP_EMLPP_PRIORITY 6
172 #define BSSAP_TMSI_STATUS 7
173 #define BSSAP_GS_CAUSE 8
174 #define BSSAP_SGSN_NUMBER 9
175 #define BSSAP_GPRS_LOC_UPD_TYPE 0x0a
176 #define BSSAP_GLOBAL_CN_ID 0x0b
177 #define BSSAP_MOBILE_STN_CLS_MRK1 0x0d
178 #define BSSAP_MOBILE_ID 0x0e
179 #define BSSAP_REJECT_CAUSE 0x0f
180 #define BSSAP_IMSI_DET_FROM_GPRS_SERV_TYPE 0x10
181 #define BSSAP_IMSI_DET_FROM_NON_GPRS_SERV_TYPE 0x11
182 #define BSSAP_INFO_REQ 0x12
183 #define BSSAP_PTMSI 0x13
184 #define BSSAP_IMEI 0x14
185 #define BSSAP_IMEISV 0x15
186 #define BSSAP_MM_INFORMATION 0x17
187 #define BSSAP_CELL_GBL_ID 0x18
188 #define BSSAP_LOC_INF_AGE 0x19
189 #define BSSAP_MOBILE_STN_STATE 0x1a
190 #define BSSAP_ERRONEOUS_MSG 0x1b
191 #define BSSAP_DLINK_TNL_PLD_CTR_AND_INF 0x1c
192 #define BSSAP_ULINK_TNL_PLD_CTR_AND_INF 0x1d
193 #define BSSAP_SERVICE_AREA_ID 0x1e
194 #define BSSAP_MSI_BASED_NRI_CON 0x1f
196 static const value_string bssap_plus_ie_id_values[] = {
197 { BSSAP_IMSI, "IMSI" }, /* 18.4.10 */
198 { BSSAP_VLR_NUMBER, "VLR number" }, /* 18.4.26 */
199 { BSSAP_TMSI, "TMSI" }, /* 18.4.23 */
200 { BSSAP_LOC_AREA_ID, "Location area identifier" }, /* 18.4.14 */
201 { BSSAP_CHANNEL_NEEDED, "Channel Needed" }, /* 18.4.2 */
202 { BSSAP_EMLPP_PRIORITY, "eMLPP Priority" }, /* 18.4.4 */
203 { BSSAP_TMSI_STATUS, "TMSI status" }, /* 18.4.24 */
204 { BSSAP_GS_CAUSE, "Gs cause" }, /* 18.4.7 */
205 { BSSAP_SGSN_NUMBER, "SGSN number" }, /* 18.4.22 */
206 { BSSAP_GPRS_LOC_UPD_TYPE, "GPRS location update type" }, /* 18.4.6 */
207 { BSSAP_GLOBAL_CN_ID, "Global CN-Id" }, /* 18.4.27 */
208 { 0x0c, "Unassigned: treated as an unknown IEI." }, /* 18 and 16 */
209 { BSSAP_MOBILE_STN_CLS_MRK1, "Mobile station classmark 1" }, /* 18.4.18 */
210 { BSSAP_MOBILE_ID, "Mobile identity" }, /* 18.4.17 */
211 { BSSAP_REJECT_CAUSE, "Reject cause" }, /* 18.4.21 */
212 { BSSAP_IMSI_DET_FROM_GPRS_SERV_TYPE, "IMSI detach from GPRS service type" }, /* 18.4.11 */
213 { BSSAP_IMSI_DET_FROM_NON_GPRS_SERV_TYPE, "IMSI detach from non-GPRS service type" }, /* 18.4.12 */
214 { BSSAP_INFO_REQ, "Information requested" }, /* 18.4.13 */
215 { BSSAP_PTMSI, "PTMSI" }, /* 18.4.20 */
216 { BSSAP_IMEI, "IMEI" }, /* 18.4.8 */
217 { BSSAP_IMEISV, "IMEISV" }, /* 18.4.9 */
218 { 0x16, "Unassigned: treated as an unknown IEI." }, /* 18 and 16 */
219 { BSSAP_MM_INFORMATION, "MM information" }, /* 18.4.16 */
220 { BSSAP_CELL_GBL_ID, "Cell Global Identity" }, /* 18.4.1 */
221 { BSSAP_LOC_INF_AGE, "Location information age" }, /* 18.4.15 */
222 { BSSAP_MOBILE_STN_STATE, "Mobile station state" }, /* 18.4.19 */
223 { BSSAP_ERRONEOUS_MSG, "Erroneous message" }, /* 18.4.5 */
224 { BSSAP_DLINK_TNL_PLD_CTR_AND_INF, "Downlink Tunnel Payload Control and Info" }, /* 18.4.3 */
225 { BSSAP_ULINK_TNL_PLD_CTR_AND_INF, "Uplink Tunnel Payload Control and Info" }, /* 18.4.25 */
226 { BSSAP_SERVICE_AREA_ID, "Service Area Identification" }, /* 18.4.21b */
227 { BSSAP_MSI_BASED_NRI_CON, "TMSI based NRI container" }, /* 18.4.28 */
228 { 0, NULL }
230 static value_string_ext bssap_plus_ie_id_values_ext = VALUE_STRING_EXT_INIT(bssap_plus_ie_id_values);
232 /* Initialize the protocol and registered fields */
233 static int proto_bssap;
234 static int proto_bsap;
235 static int proto_bssap_le;
236 static int proto_bssap_plus;
237 static int hf_bssap_pdu_type;
238 static int hf_bsap_pdu_type;
239 static int hf_bssap_dlci_cc;
240 static int hf_bsap_dlci_cc;
241 static int hf_bssap_dlci_spare;
242 static int hf_bsap_dlci_rsvd;
243 static int hf_bssap_dlci_sapi;
244 static int hf_bsap_dlci_sapi;
245 static int hf_bssap_length;
246 static int hf_bssap_plus_ie;
247 static int hf_bssap_plus_ie_len;
249 static int hf_bssap_plus_message_type;
250 static int hf_bssap_imsi_ie;
251 static int hf_bssap_imsi_det_from_gprs_serv_type_ie;
252 static int hf_bssap_imsi_det_from_non_gprs_serv_type_ie;
253 static int hf_bssap_info_req_ie;
254 static int hf_bssap_loc_area_id_ie;
255 static int hf_bssap_loc_inf_age_ie;
256 static int hf_bssap_mm_information_ie;
257 static int hf_bssap_mobile_id_ie;
258 static int hf_bssap_mobile_stn_cls_mrk1_ie;
259 static int hf_bssap_mobile_station_state_ie;
260 static int hf_bssap_ptmsi_ie;
261 static int hf_bssap_reject_cause_ie;
262 static int hf_bssap_service_area_id_ie;
263 static int hf_bssap_sgsn_nr_ie;
264 static int hf_bssap_tmsi_ie;
265 static int hf_bssap_tmsi_status_ie;
266 static int hf_bssap_vlr_number_ie;
267 static int hf_bssap_global_cn_id_ie;
268 static int hf_bssap_plus_ie_data;
270 static int hf_bssap_extension;
271 static int hf_bssap_type_of_number;
272 static int hf_bssap_numbering_plan_id;
273 static int hf_bssap_sgsn_number;
274 static int hf_bssap_vlr_number;
275 static int hf_bssap_call_priority;
276 static int hf_bssap_gprs_loc_upd_type_ie;
277 static int hf_bssap_Gs_cause_ie;
278 static int hf_bssap_imei_ie;
279 static int hf_bssap_imeisv_ie;
280 static int hf_bssap_cell_global_id_ie;
281 static int hf_bssap_channel_needed_ie;
282 static int hf_bssap_dlink_tnl_pld_cntrl_amd_inf_ie;
283 static int hf_bssap_ulink_tnl_pld_cntrl_amd_inf_ie;
284 static int hf_bssap_emlpp_prio_ie;
285 static int hf_bssap_gprs_erroneous_msg_ie;
287 static int hf_bssap_gprs_loc_upd_type;
288 static int hf_bssap_Gs_cause;
289 static int hf_bssap_imei;
290 static int hf_bssap_imeisv;
291 static int hf_bssap_imsi_det_from_gprs_serv_type;
292 static int hf_bssap_info_req;
293 static int hf_bssap_loc_inf_age;
294 static int hf_bssap_mobile_station_state;
295 static int hf_bssap_ptmsi;
296 static int hf_bssap_tmsi;
297 static int hf_bssap_tmsi_status;
298 static int hf_bssap_tom_prot_disc;
299 static int hf_bssap_e_bit;
300 static int hf_bssap_tunnel_prio;
301 static int hf_bssap_global_cn_id;
302 static int hf_bssap_plmn_id;
303 static int hf_bssap_cn_id;
304 static int hf_bssap_cell_global_id;
305 static int hf_bssap_extraneous_data;
306 static int hf_bssap_conditional_ie;
308 /* Initialize the subtree pointers */
309 static int ett_bssap;
310 static int ett_bssap_dlci;
311 static int ett_bssap_imsi;
312 static int ett_bssap_imsi_det_from_gprs_serv_type;
313 static int ett_bssap_imsi_det_from_non_gprs_serv_type;
314 static int ett_bssap_info_req;
315 static int ett_bssap_loc_area_id;
316 static int ett_bssap_loc_inf_age;
317 static int ett_bssap_mm_information;
318 static int ett_bssap_mobile_id;
319 static int ett_bssap_sgsn_nr;
320 static int ett_bssap_tmsi;
321 static int ett_bssap_tmsi_status;
322 static int ett_bssap_vlr_number;
323 static int ett_bssap_global_cn;
324 static int ett_bssap_gprs_loc_upd;
325 static int ett_bassp_Gs_cause;
326 static int ett_bassp_imei;
327 static int ett_bassp_imeisv;
328 static int ett_bssap_cell_global_id;
329 static int ett_bssap_cgi;
330 static int ett_bssap_channel_needed;
331 static int ett_bssap_dlink_tnl_pld_cntrl_amd_inf;
332 static int ett_bssap_ulink_tnl_pld_cntrl_amd_inf;
333 static int ett_bssap_emlpp_prio;
334 static int ett_bssap_erroneous_msg;
335 static int ett_bssap_mobile_stn_cls_mrk1;
336 static int ett_bssap_mobile_station_state;
337 static int ett_bssap_ptmsi;
338 static int ett_bssap_reject_cause;
339 static int ett_bssap_service_area_id;
340 static int ett_bssap_global_cn_id;
341 static int ett_bssap_plmn;
343 static expert_field ei_bssap_unknown_message;
344 static expert_field ei_bssap_unknown_parameter;
345 static expert_field ei_bssap_mandatory_ie;
348 static dissector_handle_t rrlp_handle;
350 static dissector_table_t bssap_dissector_table;
351 static dissector_table_t bsap_dissector_table;
352 static dissector_table_t bssap_le_dissector_table;
354 static dissector_handle_t gsm_bssmap_le_dissector_handle;
355 static dissector_handle_t gsm_a_bssmap_dissector_handle;
358 typedef struct {
359 uint8_t pdu_type;
360 enum bssap_proto proto;
361 } bssap_info_t;
363 static int default_protocol_global = BSSAP;
365 static void
366 dissect_bssap_data_param(tvbuff_t *tvb, packet_info *pinfo,
367 proto_tree *bssap_tree, proto_tree *tree, struct _sccp_msg_info_t* sccp_info)
369 bssap_info_t* bssap_info;
371 bssap_info = (bssap_info_t *)p_get_proto_data(pinfo->pool, pinfo, proto_bssap, 0);
372 uint8_t pdu_type = bssap_info->pdu_type;
374 switch (bssap_info->proto) {
376 case BSSAP:
377 if (dissector_try_uint_with_data(bssap_dissector_table, pdu_type, tvb, pinfo, tree, true, sccp_info))
378 return;
379 break;
381 case BSSAP_LE:
382 if (dissector_try_uint_with_data(bssap_le_dissector_table, pdu_type, tvb, pinfo, tree, true, sccp_info))
383 return;
384 break;
386 case BSAP:
387 if (dissector_try_uint_with_data(bsap_dissector_table, pdu_type, tvb, pinfo, tree, true, sccp_info))
388 return;
389 break;
392 /* No sub-dissection occurred, treat it as raw data */
393 call_data_dissector(tvb, pinfo, bssap_tree);
396 static void
397 dissect_bssap_dlci_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint16_t length)
399 proto_tree *dlci_tree;
400 uint8_t oct;
401 bssap_info_t* bssap_info;
403 bssap_info = (bssap_info_t *)p_get_proto_data(pinfo->pool, pinfo, proto_bssap, 0);
405 dlci_tree =
406 proto_tree_add_subtree(tree, tvb, 0, length,
407 ett_bssap_dlci, NULL, "Data Link Connection Identifier");
409 oct = tvb_get_uint8(tvb, 0);
411 if (bssap_info->proto != BSAP)
413 proto_tree_add_uint(dlci_tree, hf_bssap_dlci_cc, tvb, 0, length, oct);
414 proto_tree_add_uint(dlci_tree, hf_bssap_dlci_spare, tvb, 0, length, oct);
415 proto_tree_add_uint(dlci_tree, hf_bssap_dlci_sapi, tvb, 0, length, oct);
417 else
419 proto_tree_add_uint(dlci_tree, hf_bsap_dlci_cc, tvb, 0, length, oct);
420 proto_tree_add_uint(dlci_tree, hf_bsap_dlci_rsvd, tvb, 0, length, oct);
421 proto_tree_add_uint(dlci_tree, hf_bsap_dlci_sapi, tvb, 0, length, oct);
425 static void
426 dissect_bssap_length_param(tvbuff_t *tvb, proto_tree *tree, uint16_t length)
428 uint8_t data_length;
430 data_length = tvb_get_uint8(tvb, 0);
431 proto_tree_add_uint(tree, hf_bssap_length, tvb, 0, length, data_length);
435 * Dissect a parameter given its type, offset into tvb, and length.
437 static uint16_t
438 dissect_bssap_parameter(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bssap_tree,
439 proto_tree *tree, uint8_t parameter_type, int offset,
440 uint16_t parameter_length, struct _sccp_msg_info_t* sccp_info)
442 tvbuff_t *parameter_tvb;
444 parameter_tvb = tvb_new_subset_length(tvb, offset, parameter_length);
446 switch (parameter_type)
448 case PARAMETER_DLCI:
449 dissect_bssap_dlci_param(parameter_tvb, pinfo, bssap_tree, parameter_length);
450 break;
452 case PARAMETER_LENGTH:
453 dissect_bssap_length_param(parameter_tvb, bssap_tree, parameter_length);
454 break;
456 case PARAMETER_DATA:
457 dissect_bssap_data_param(parameter_tvb, pinfo, bssap_tree, tree, sccp_info);
458 break;
460 default:
461 proto_tree_add_expert_format(bssap_tree, pinfo, &ei_bssap_unknown_parameter, parameter_tvb, 0, parameter_length,
462 "Unknown parameter 0x%x (%u byte%s)", parameter_type, parameter_length, plurality(parameter_length, "", "s"));
463 break;
466 return parameter_length;
469 static uint16_t
470 dissect_bssap_var_parameter(tvbuff_t *tvb, packet_info *pinfo,
471 proto_tree *bssap_tree, proto_tree *tree,
472 uint8_t parameter_type, int offset, struct _sccp_msg_info_t* sccp_info)
474 uint16_t parameter_length;
475 uint8_t length_length;
477 parameter_length = tvb_get_uint8(tvb, offset);
478 length_length = LENGTH_LENGTH;
480 offset += length_length;
482 dissect_bssap_parameter(tvb, pinfo, bssap_tree, tree, parameter_type,
483 offset, parameter_length, sccp_info);
485 return parameter_length + length_length;
488 static int
489 dissect_bssap_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bssap_tree,
490 proto_tree *tree, struct _sccp_msg_info_t* sccp_info)
492 int offset;
493 proto_item* type_item;
494 bssap_info_t* bssap_info;
496 bssap_info = (bssap_info_t *)p_get_proto_data(pinfo->pool, pinfo, proto_bssap, 0);
499 * Extract the PDU type
501 bssap_info->pdu_type = tvb_get_uint8(tvb, PDU_TYPE_OFFSET);
502 offset = PDU_TYPE_LENGTH;
505 * add the message type to the protocol tree
507 type_item = proto_tree_add_uint(bssap_tree,
508 (bssap_info->proto != BSAP) ? hf_bssap_pdu_type : hf_bsap_pdu_type,
509 tvb, PDU_TYPE_OFFSET, PDU_TYPE_LENGTH, bssap_info->pdu_type);
511 /* Starting a new message dissection */
513 switch (bssap_info->pdu_type)
515 case BSSAP_PDU_TYPE_BSSMAP:
516 offset += dissect_bssap_parameter(tvb, pinfo, bssap_tree, tree,
517 PARAMETER_LENGTH, offset,
518 LENGTH_LENGTH, sccp_info);
519 offset += dissect_bssap_var_parameter(tvb, pinfo, bssap_tree, tree,
520 PARAMETER_DATA,
521 (offset - LENGTH_LENGTH), sccp_info);
522 break;
524 case BSSAP_PDU_TYPE_DTAP:
525 offset += dissect_bssap_parameter(tvb, pinfo, bssap_tree, tree,
526 PARAMETER_DLCI,
527 offset, DLCI_LENGTH, sccp_info);
528 offset += dissect_bssap_parameter(tvb, pinfo, bssap_tree, tree,
529 PARAMETER_LENGTH, offset,
530 LENGTH_LENGTH, sccp_info);
531 offset += dissect_bssap_var_parameter(tvb, pinfo, bssap_tree, tree,
532 PARAMETER_DATA,
533 (offset - LENGTH_LENGTH), sccp_info);
534 break;
536 default:
538 uint32_t message_length;
540 col_append_fstr(pinfo->cinfo, COL_INFO, "%s ",
541 val_to_str_const(bssap_info->pdu_type,
542 ((bssap_info->proto != BSAP) ?
543 bssap_pdu_type_acro_values : bsap_pdu_type_acro_values),
544 "Unknown"));
546 message_length = tvb_reported_length(tvb);
548 expert_add_info_format(pinfo, type_item, &ei_bssap_unknown_message, "Unknown message (%u byte%s)",
549 message_length, plurality(message_length, "", "s"));
551 break;
553 return offset;
556 static int
557 dissect_bssap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
559 proto_item *bssap_item;
560 proto_tree *bssap_tree;
561 struct _sccp_msg_info_t* sccp_info = (struct _sccp_msg_info_t*)data;
562 bssap_info_t *bssap_info;
565 * Make entry in the Protocol column on summary display
567 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BSSAP");
569 if (sccp_info && sccp_info->data.co.assoc )
570 sccp_info->data.co.assoc->payload = SCCP_PLOAD_BSSAP;
573 * create the bssap protocol tree
575 bssap_item = proto_tree_add_item(tree, proto_bssap, tvb, 0, -1, ENC_NA);
576 bssap_tree = proto_item_add_subtree(bssap_item, ett_bssap);
578 bssap_info = wmem_new(pinfo->pool, bssap_info_t);
579 bssap_info->proto = BSSAP;
580 p_add_proto_data(pinfo->pool, pinfo, proto_bssap, 0, bssap_info);
582 /* dissect the message */
584 return dissect_bssap_message(tvb, pinfo, bssap_tree, tree, sccp_info);
587 static int
588 dissect_bsap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
590 proto_item *bssap_item;
591 proto_tree *bssap_tree;
592 struct _sccp_msg_info_t* sccp_info = (struct _sccp_msg_info_t*)data;
593 bssap_info_t *bssap_info;
596 * Make entry in the Protocol column on summary display
598 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BSAP");
600 if (sccp_info && sccp_info->data.co.assoc )
601 sccp_info->data.co.assoc->payload = SCCP_PLOAD_BSSAP;
604 * create the bsap protocol tree
606 bssap_item = proto_tree_add_protocol_format(tree, proto_bssap, tvb, 0, -1, "BSAP");
607 bssap_tree = proto_item_add_subtree(bssap_item, ett_bssap);
609 bssap_info = wmem_new(pinfo->pool, bssap_info_t);
610 bssap_info->proto = BSAP;
611 p_add_proto_data(pinfo->pool, pinfo, proto_bssap, 0, bssap_info);
613 /* dissect the message */
615 return dissect_bssap_message(tvb, pinfo, bssap_tree, tree, sccp_info);
618 static int
619 dissect_bssap_le(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
621 proto_item *bssap_item;
622 proto_tree *bssap_tree;
623 struct _sccp_msg_info_t* sccp_info = (struct _sccp_msg_info_t*)data;
624 bssap_info_t *bssap_info;
627 * Make entry in the Protocol column on summary display
629 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BSSAP-LE");
631 if (sccp_info && sccp_info->data.co.assoc )
632 sccp_info->data.co.assoc->payload = SCCP_PLOAD_BSSAP;
635 * create the bssap_le protocol tree
637 bssap_item = proto_tree_add_protocol_format(tree, proto_bssap, tvb, 0, -1, "BSSAP-LE");
638 bssap_tree = proto_item_add_subtree(bssap_item, ett_bssap);
640 bssap_info = wmem_new(pinfo->pool, bssap_info_t);
641 bssap_info->proto = BSSAP_LE;
642 p_add_proto_data(pinfo->pool, pinfo, proto_bssap, 0, bssap_info);
644 /* dissect the message */
646 return dissect_bssap_message(tvb, pinfo, bssap_tree, tree, sccp_info);
650 * BSSAP+ Routines
653 static bool
654 check_ie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset, uint8_t expected_ie)
656 uint8_t ie_type;
657 uint8_t ie_len;
659 ie_type = tvb_get_uint8(tvb, *offset);
660 if (ie_type != expected_ie) {
661 proto_tree_add_expert_format(tree, pinfo, &ei_bssap_mandatory_ie, tvb, *offset, 1, "Mandatory IE %s expected but IE %s Found",
662 val_to_str_ext(expected_ie, &bssap_plus_ie_id_values_ext, "Unknown %u"),
663 val_to_str_ext(ie_type, &bssap_plus_ie_id_values_ext, "Unknown %u"));
664 (*offset)++;
665 ie_len = tvb_get_uint8(tvb, *offset);
666 *offset = *offset + ie_len;
667 return false;
670 return true;
674 static bool
675 check_optional_ie(tvbuff_t *tvb, int offset, uint8_t expected_ie)
677 uint8_t ie_type;
679 ie_type = tvb_get_uint8(tvb, offset);
680 if (ie_type != expected_ie) {
681 return false;
683 return true;
687 /* 18.4.1 Cell global identity */
688 static int
689 dissect_bssap_cell_global_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset)
691 proto_item *item;
692 proto_tree *ie_tree;
693 proto_item *cgi_item;
694 proto_tree *cgi_tree;
695 uint8_t ie_len;
697 ie_len = tvb_get_uint8(tvb, offset+1);
698 item = proto_tree_add_item(tree, hf_bssap_cell_global_id_ie, tvb, offset, ie_len+2, ENC_NA);
699 ie_tree = proto_item_add_subtree(item, ett_bssap_cell_global_id);
701 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
702 offset++;
703 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
704 offset++;
706 * The rest of the information element is coded as the value part
707 * of the cell global id IE defined in 3GPP TS 48.018 (not including
708 * 3GPP TS 48.018 IEI and 3GPP TS 48.018 length indicator).
710 cgi_item = proto_tree_add_item(ie_tree, hf_bssap_cell_global_id, tvb, offset, ie_len, ENC_NA);
711 cgi_tree = proto_item_add_subtree(cgi_item, ett_bssap_cgi);
712 /* octets 3-8 Octets 3 to 8 contain the value part (starting with octet 2) of the
713 * Routing Area Identification IE defined in 3GPP TS 24.008, not
714 * including 3GPP TS 24.008 IEI
716 de_gmm_rai(tvb, cgi_tree, pinfo, offset, ie_len, NULL, 0);
717 /* Octets 9 and 10 contain the value part (starting with octet 2) of the
718 * Cell Identity IE defined in 3GPP TS 24.008, not including
719 * 3GPP TS 24.008 IEI
721 offset = offset + 6;
722 de_cell_id(tvb, cgi_tree, pinfo, offset, ie_len, NULL, 0);
723 offset = offset + 2;
725 return offset;
728 /* 18.4.2 Channel needed */
729 static int
730 dissect_bssap_channel_needed(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset)
732 proto_item *item;
733 proto_tree *ie_tree;
734 uint8_t ie_len;
736 ie_len = tvb_get_uint8(tvb, offset+1);
737 item = proto_tree_add_item(tree, hf_bssap_channel_needed_ie, tvb, offset, ie_len+2, ENC_NA);
738 ie_tree = proto_item_add_subtree(item, ett_bssap_channel_needed);
740 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
741 offset++;
742 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
743 offset++;
745 * The rest of the information element is coded as the IEI part and the
746 * value part of the Channel Needed IE defined in 3GPP TS 44.018.
747 * 10.5.2.8 Channel Needed
749 de_rr_chnl_needed(tvb, ie_tree, pinfo, offset, ie_len, NULL, 0);
751 return offset + ie_len;
754 /* 18.4.3 Downlink Tunnel Payload Control and Info */
755 static int
756 dissect_bssap_dlink_tunnel_payload_control_and_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
758 proto_item *item;
759 proto_tree *ie_tree;
760 tvbuff_t *next_tvb;
761 uint8_t ie_len;
762 uint8_t octet;
763 uint8_t prot_disc;
765 ie_len = tvb_get_uint8(tvb, offset+1);
766 item = proto_tree_add_item(tree, hf_bssap_dlink_tnl_pld_cntrl_amd_inf_ie, tvb, offset, ie_len+2, ENC_NA);
767 ie_tree = proto_item_add_subtree(item, ett_bssap_dlink_tnl_pld_cntrl_amd_inf);
769 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
770 offset++;
771 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
772 offset++;
773 /* Bit 8 Spare */
774 /* Bit 7 - 4
775 * TOM Protocol Discriminator: Identifies the protocol using tunnelling of non-GSM signalling.
776 * For coding, see 3GPP TS 44.064.
779 proto_tree_add_item(ie_tree, hf_bssap_tom_prot_disc, tvb, offset, 1, ENC_BIG_ENDIAN);
780 octet = tvb_get_uint8(tvb, offset);
781 prot_disc = (octet&0x78)>>3;
783 /* octet 3 bit 3 E: Cipher Request. When set to 1 indicates that the SGSN received the payload in ciphered form,
784 * when set to 0 indicates that the SGSN did not receive the payload in ciphered form.
786 proto_tree_add_item(ie_tree, hf_bssap_e_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
788 /* octet 3 bit 2 - 1
789 * Tunnel Priority: Indicates the priority of the Tunnel Payload. For coding, see Table 20.1: Association
790 * between Tunnel Priority and LLC SAPs.
792 proto_tree_add_item(ie_tree, hf_bssap_tunnel_prio, tvb, offset, 1, ENC_BIG_ENDIAN);
793 /* Tunnel payload */
794 next_tvb = tvb_new_subset_length(tvb, offset, ie_len-4);
796 if ((prot_disc == 2)&&(rrlp_handle))
797 call_dissector(rrlp_handle, next_tvb, pinfo, ie_tree);
798 else
799 call_data_dissector(next_tvb, pinfo, ie_tree);
802 return offset + ie_len;
806 /* 18.4.4 eMLPP Priority */
807 /* Call priority */
808 static const value_string bssap_call_priority_values[] = {
809 { 0x00, "No priority applied" },
810 { 0x01, "Call priority level 4" },
811 { 0x02, "Call priority level 3" },
812 { 0x03, "Call priority level 2" },
813 { 0x04, "Call priority level 1" },
814 { 0x05, "Call priority level 0" },
815 { 0x06, "Call priority level B" },
816 { 0x07, "Call priority level A" },
817 { 0, NULL }
819 static int
820 dissect_bssap_emlpp_priority(tvbuff_t *tvb, proto_tree *tree, int offset)
822 proto_item *item;
823 proto_tree *ie_tree;
824 uint8_t ie_len;
826 ie_len = tvb_get_uint8(tvb, offset+1);
827 item = proto_tree_add_item(tree, hf_bssap_emlpp_prio_ie, tvb, offset, ie_len+2, ENC_NA);
828 ie_tree = proto_item_add_subtree(item, ett_bssap_emlpp_prio);
830 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
831 offset++;
832 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
833 offset++;
834 /* The rest of the information element is coded as the value part of
835 the eMLPP-Priority IE defined in 3GPP TS 48.008 (not including
836 3GPP TS 48.008 IEI and 3GPP TS 48.008 length indicator).
837 3.2.2.56 eMLPP Priority
838 The call priority field (bit 3 to 1 of octet 2) is coded in the same way
839 as the call priority field (bit 3 to 1 of octet 5) in the Descriptive group
840 or broadcast call reference information element as defined in 3GPP TS 24.008.
842 proto_tree_add_item(ie_tree, hf_bssap_call_priority, tvb, offset, ie_len, ENC_BIG_ENDIAN);
844 return offset + ie_len;
847 /* 18.4.5 Erroneous message */
848 /* Erroneous message including the message type. */
850 static int
851 dissect_bssap_gprs_erroneous_msg(tvbuff_t *tvb, proto_tree *tree, int offset)
853 proto_item *item;
854 proto_tree *ie_tree;
855 uint8_t ie_len;
857 ie_len = tvb_get_uint8(tvb, offset+1);
858 item = proto_tree_add_item(tree, hf_bssap_gprs_erroneous_msg_ie, tvb, offset, ie_len+2, ENC_NA);
859 ie_tree = proto_item_add_subtree(item, ett_bssap_erroneous_msg);
861 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
862 offset++;
863 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
864 offset++;
866 /* Erroneous message including the message type. */
867 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_data, tvb, offset, ie_len, ENC_NA);
869 return offset + ie_len;
874 static const value_string bssap_plus_GPRS_loc_upd_type_values[] = {
875 { 0x00, "Shall not be sent in this version of the protocol. If received, shall be treated as '00000010'." },
876 { 0x01, "IMSI attach" },
877 { 0x02, "Normal location update" },
878 { 0, NULL }
880 /* 18.4.6 GPRS location update type */
881 static int
882 dissect_bssap_gprs_location_update_type(tvbuff_t *tvb, proto_tree *tree, int offset)
884 proto_item *item;
885 proto_tree *ie_tree;
886 uint8_t ie_len;
888 ie_len = tvb_get_uint8(tvb, offset+1);
889 item = proto_tree_add_item(tree, hf_bssap_gprs_loc_upd_type_ie, tvb, offset, ie_len+2, ENC_NA);
890 ie_tree = proto_item_add_subtree(item, ett_bssap_gprs_loc_upd);
892 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
893 offset++;
894 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
895 offset++;
897 /* GPRS location update type value (octet 3) */
898 proto_tree_add_item(ie_tree, hf_bssap_gprs_loc_upd_type, tvb, offset, ie_len, ENC_BIG_ENDIAN);
900 return offset + ie_len;
903 /* Gs Cause value (octet 3) */
904 static const value_string bssap_Gs_cause_values[] = {
906 { 0x00, "Normal, unspecified in this version of the protocol." },
907 { 0x01, "IMSI detached for GPRS services" },
908 { 0x02, "IMSI detached for GPRS and non-GPRS services" },
909 { 0x03, "IMSI unknown" },
910 { 0x04, "IMSI detached for non-GPRS services" },
911 { 0x05, "IMSI implicitly detached for non-GPRS services" },
912 { 0x06, "MS unreachable" },
913 { 0x07, "Message not compatible with the protocol state" },
914 { 0x08, "Missing mandatory information element" },
915 { 0x09, "Invalid mandatory information" },
916 { 0x0a, "Conditional IE error" },
917 { 0x0b, "Semantically incorrect message" },
918 { 0x0c, "Message unknown" },
919 { 0x0d, "Address error" },
920 { 0x0e, "TOM functionality not supported" },
921 { 0x0f, "Ciphering request cannot be accommodated" },
922 { 0, NULL }
925 /* 18.4.7 Gs cause */
926 static int
927 dissect_bssap_Gs_cause(tvbuff_t *tvb, proto_tree *tree, int offset)
929 proto_item *item;
930 proto_tree *ie_tree;
931 uint8_t ie_len;
933 ie_len = tvb_get_uint8(tvb, offset+1);
934 item = proto_tree_add_item(tree, hf_bssap_Gs_cause_ie, tvb, offset, ie_len+2, ENC_NA);
935 ie_tree = proto_item_add_subtree(item, ett_bassp_Gs_cause);
937 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
938 offset++;
939 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
940 offset++;
941 /* Gs Cause value (octet 3) */
942 proto_tree_add_item(ie_tree, hf_bssap_Gs_cause, tvb, offset, ie_len, ENC_BIG_ENDIAN);
945 return offset + ie_len;
948 /* 18.4.8 IMEI */
949 static int
950 dissect_bssap_imei(tvbuff_t *tvb, proto_tree *tree, int offset)
952 proto_item *item;
953 proto_tree *ie_tree;
954 uint8_t ie_len;
955 tvbuff_t *ie_tvb;
957 ie_len = tvb_get_uint8(tvb, offset+1);
958 item = proto_tree_add_item(tree, hf_bssap_imei_ie, tvb, offset, ie_len+2, ENC_NA);
959 ie_tree = proto_item_add_subtree(item, ett_bassp_imei);
961 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
962 offset++;
963 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
964 offset++;
965 /* The IMEI is coded as a sequence of BCD digits, compressed two into each octet.
966 * The IMEI consists of 15 digits (see 3GPP TS 23.003).
968 ie_tvb = tvb_new_subset_length(tvb, offset, ie_len);
969 proto_tree_add_item(ie_tree, hf_bssap_imei, ie_tvb, 0, -1, ENC_BCD_DIGITS_0_9|ENC_LITTLE_ENDIAN);
971 return offset + ie_len;
974 static int
975 dissect_bssap_imei_dissector(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
977 return dissect_bssap_imei(tvb, tree, 0);
979 /* 18.4.9 IMEISV */
980 static int
981 dissect_bssap_imeisv(tvbuff_t *tvb, proto_tree *tree, int offset)
983 proto_item *item;
984 proto_tree *ie_tree;
985 uint8_t ie_len;
986 tvbuff_t *ie_tvb;
988 ie_len = tvb_get_uint8(tvb, offset+1);
989 item = proto_tree_add_item(tree, hf_bssap_imeisv_ie, tvb, offset, ie_len+2, ENC_NA);
990 ie_tree = proto_item_add_subtree(item, ett_bassp_imeisv);
992 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
993 offset++;
994 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
995 offset++;
996 /* The IMEISV is coded as a sequence of BCD digits, compressed two into each octet.
997 * The IMEISV consists of 16 digits (see 3GPP TS 23.003).
999 ie_tvb = tvb_new_subset_length(tvb, offset, ie_len);
1000 proto_tree_add_item(ie_tree, hf_bssap_imeisv, ie_tvb, 0, -1, ENC_BCD_DIGITS_0_9|ENC_LITTLE_ENDIAN);
1002 return offset + ie_len;
1005 /* 18.4.10 IMSI
1006 * The IMSI is coded as a sequence of BCD digits, compressed two into each octet.
1007 * This is a variable length element, and includes a length indicator.
1008 * The IMSI is defined in 3GPP TS 23.003. It shall not exceed 15 digits (see 3GPP TS 23.003).
1012 static int
1013 dissect_bssap_imsi(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset)
1015 proto_item *item;
1016 proto_tree *ie_tree;
1017 uint8_t ie_len;
1018 tvbuff_t *ie_tvb;
1020 ie_len = tvb_get_uint8(tvb, offset+1);
1021 item = proto_tree_add_item(tree, hf_bssap_imsi_ie, tvb, offset, ie_len+2, ENC_NA);
1022 ie_tree = proto_item_add_subtree(item, ett_bssap_imsi);
1024 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1025 offset++;
1026 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1027 offset++;
1028 ie_tvb = tvb_new_subset_length(tvb, offset, ie_len);
1029 dissect_e212_imsi(ie_tvb, pinfo, tree, 0, ie_len, true);
1031 return offset + ie_len;
1034 static const value_string bssap_imsi_det_from_gprs_serv_type_values[] _U_ = {
1035 { 0x00, "Interpreted as reserved in this version of the protocol" },
1036 { 0x01, "Network initiated IMSI detach from GPRS service" },
1037 { 0x02, "MS initiated IMSI detach from GPRS service" },
1038 { 0x03, "GPRS services not allowed" },
1039 { 0, NULL }
1042 /* 18.4.11 IMSI detach from GPRS service type */
1043 static int
1044 dissect_bssap_imsi_det_from_gprs_serv_type(tvbuff_t *tvb, proto_tree *tree, int offset)
1046 proto_item *item;
1047 proto_tree *ie_tree;
1048 uint8_t ie_len;
1050 ie_len = tvb_get_uint8(tvb, offset+1);
1051 item = proto_tree_add_item(tree, hf_bssap_imsi_det_from_gprs_serv_type_ie, tvb, offset, ie_len+2, ENC_NA);
1052 ie_tree = proto_item_add_subtree(item, ett_bssap_imsi_det_from_gprs_serv_type);
1054 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1055 offset++;
1056 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1057 offset++;
1058 /* IMSI detach from GPRS service type value (octet 3)*/
1059 proto_tree_add_item(ie_tree, hf_bssap_imsi_det_from_gprs_serv_type, tvb, offset, ie_len, ENC_BIG_ENDIAN);
1062 return offset + ie_len;
1065 /* 18.4.12 IMSI detach from non-GPRS service type */
1066 static int
1067 dissect_bssap_imsi_det_from_non_gprs_serv_type(tvbuff_t *tvb, proto_tree *tree, int offset)
1069 proto_item *item;
1070 proto_tree *ie_tree;
1071 uint8_t ie_len;
1073 ie_len = tvb_get_uint8(tvb, offset+1);
1074 item = proto_tree_add_item(tree, hf_bssap_imsi_det_from_non_gprs_serv_type_ie, tvb, offset, ie_len+2, ENC_NA);
1075 ie_tree = proto_item_add_subtree(item, ett_bssap_imsi_det_from_non_gprs_serv_type);
1077 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1078 offset++;
1079 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1080 offset++;
1081 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_data, tvb, offset, ie_len, ENC_NA);
1084 return offset + ie_len;
1087 static const value_string bssap_info_req_values[] = {
1088 { 0x00, "Interpreted as Not supported in this version of the protocol." },
1089 { 0x01, "PTMSI" },
1090 { 0x02, "IMEI" },
1091 { 0x03, "IMEISV" },
1092 { 0x04, "PTMSI and IMEI" },
1093 { 0x05, "PTMSI and IMEISV" },
1094 { 0x06, "IMEI and IMEISV" },
1095 { 0x07, "PTMSI, IMEI, and IMEISV" },
1096 { 0x08, "Mobile location information" },
1097 { 0x09, "TMSI" },
1098 { 0, NULL }
1100 /* 18.4.13 Information requested */
1101 static int
1102 dissect_bssap_info_req(tvbuff_t *tvb, proto_tree *tree, int offset)
1104 proto_item *item;
1105 proto_tree *ie_tree;
1106 uint8_t ie_len;
1108 ie_len = tvb_get_uint8(tvb, offset+1);
1109 item = proto_tree_add_item(tree, hf_bssap_info_req_ie, tvb, offset, ie_len+2, ENC_NA);
1110 ie_tree = proto_item_add_subtree(item, ett_bssap_info_req);
1112 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1113 offset++;
1114 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1115 offset++;
1116 /*Information requested value (octet 3) */
1117 proto_tree_add_item(ie_tree, hf_bssap_info_req, tvb, offset, ie_len, ENC_BIG_ENDIAN);
1120 return offset + ie_len;
1123 /* 18.4.14 Location area identifier */
1124 static int
1125 dissect_bssap_loc_area_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset)
1127 proto_item *item;
1128 proto_tree *ie_tree;
1129 uint8_t ie_len;
1131 ie_len = tvb_get_uint8(tvb, offset+1);
1132 item = proto_tree_add_item(tree, hf_bssap_loc_area_id_ie, tvb, offset, ie_len+2, ENC_NA);
1133 ie_tree = proto_item_add_subtree(item, ett_bssap_loc_area_id);
1135 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1136 offset++;
1137 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1138 offset++;
1139 /* The rest of the information element is coded as the value part of
1140 * the location area identifier IE defined in 3GPP TS 48.018 (not
1141 * including 3GPP TS 48.018 IEI and 3GPP TS 48.018 length
1142 * indicator).
1144 de_lai(tvb, ie_tree, pinfo, offset, ie_len, NULL, 0);
1146 return offset + ie_len;
1149 /* 18.4.15 Location information age */
1150 static int
1151 dissect_bssap_location_information_age(tvbuff_t *tvb, proto_tree *tree, int offset)
1153 proto_item *item;
1154 proto_tree *ie_tree;
1155 uint8_t ie_len;
1157 ie_len = tvb_get_uint8(tvb, offset+1);
1158 item = proto_tree_add_item(tree, hf_bssap_loc_inf_age_ie, tvb, offset, ie_len+2, ENC_NA);
1159 ie_tree = proto_item_add_subtree(item, ett_bssap_loc_inf_age);
1161 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1162 offset++;
1163 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1164 offset++;
1165 /* The rest of the IE is coded as the value part of the
1166 * AgeOfLocationInformation as specified in 3GPP TS 29.002.:
1167 * AgeOfLocationInformation ::= INTEGER (0..32767)
1168 * -- the value represents the elapsed time in minutes since the last
1169 * -- network contact of the mobile station (i.e. the actuality of the
1170 * -- location information).
1171 * -- value '0' indicates that the MS is currently in contact with the
1172 * -- network
1173 * -- value '32767' indicates that the location information is at least
1174 * -- 32767 minutes old
1176 proto_tree_add_item(ie_tree, hf_bssap_loc_inf_age, tvb, offset, ie_len, ENC_BIG_ENDIAN);
1179 return offset + ie_len;
1182 /* 18.4.16 MM information */
1183 static int
1184 dissect_bssap_MM_information(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset)
1186 proto_item *item;
1187 proto_tree *ie_tree;
1188 uint8_t ie_len;
1190 ie_len = tvb_get_uint8(tvb, offset+1);
1191 item = proto_tree_add_item(tree, hf_bssap_mm_information_ie, tvb, offset, ie_len+2, ENC_NA);
1192 ie_tree = proto_item_add_subtree(item, ett_bssap_mm_information);
1194 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1195 offset++;
1196 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1197 offset++;
1198 /* User information: This field is composed of one or more of the
1199 * information elements of the MM information message as defined
1200 * 3GPP TS 24.008, excluding the Protocol discriminator, Skip
1201 * indicator and Message type. This field includes the IEI and length
1202 * indicatior of the other information elements.
1204 dtap_mm_mm_info(tvb, ie_tree, pinfo, offset, ie_len);
1207 return offset + ie_len;
1210 /* 18.4.17 Mobile identity */
1211 static int
1212 dissect_bssap_mobile_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset)
1214 proto_item *item;
1215 proto_tree *ie_tree;
1216 unsigned ie_len;
1218 ie_len = tvb_get_uint8(tvb, offset+1);
1219 item = proto_tree_add_item(tree, hf_bssap_mobile_id_ie, tvb, offset, ie_len+2, ENC_NA);
1220 ie_tree = proto_item_add_subtree(item, ett_bssap_mobile_id);
1222 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1223 offset++;
1224 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1225 offset++;
1226 /* The rest of the information element is coded as the value part of
1227 * the mobile identity IE defined in 3GPP TS 24.008 (not including
1228 * 3GPP TS 24.008 IEI and 3GPP TS 24.008 length indicator).
1230 de_mid(tvb, ie_tree, pinfo, offset, ie_len, NULL, 0);
1233 return offset + ie_len;
1236 /* 18.4.18 Mobile station classmark 1 */
1237 static int
1238 dissect_bssap_mobile_stn_cls_mrk1(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset)
1240 proto_item *item;
1241 proto_tree *ie_tree;
1242 uint8_t ie_len;
1244 ie_len = tvb_get_uint8(tvb, offset+1);
1245 item = proto_tree_add_item(tree, hf_bssap_mobile_stn_cls_mrk1_ie, tvb, offset, ie_len+2, ENC_NA);
1246 ie_tree = proto_item_add_subtree(item, ett_bssap_mobile_stn_cls_mrk1);
1248 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1249 offset++;
1250 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1251 offset++;
1252 /* The rest of the information element is coded as the value part of
1253 * the mobile station classmark 1 IE defined in 3GPP TS 24.008 (not
1254 * including 3GPP TS 24.008 IEI)
1256 de_ms_cm_1(tvb, ie_tree, pinfo, offset, ie_len, NULL, 0);
1258 return offset + ie_len;
1261 /* 18.4.19 Mobile station state */
1262 static const value_string bssap_mobile_station_state_values[] = {
1263 { 0x00, "IDLE or PMM-DETACHED" },
1264 { 0x01, "STANDBY or PMM-IDLE, 0 PDP contexts active" },
1265 { 0x02, "STANDBY or PMM-IDLE, 1 or more PDP contexts active" },
1266 { 0x03, "SUSPENDED, 0 PDP contexts active" },
1267 { 0x04, "SUSPENDED, 1 or more PDP contexts active" },
1268 { 0x05, "READY or PMM-CONNECTED, 0 PDP contexts active" },
1269 { 0x06, "READY or PMM-CONNECTED, 1 or more PDP contexts active" },
1270 { 0x07, "IMSI unknown" },
1271 { 0x08, "Information requested not supported" },
1272 { 0, NULL }
1274 static int
1275 dissect_bssap_mobile_station_state(tvbuff_t *tvb, proto_tree *tree, int offset)
1277 proto_item *item;
1278 proto_tree *ie_tree;
1279 uint8_t ie_len;
1281 ie_len = tvb_get_uint8(tvb, offset+1);
1282 item = proto_tree_add_item(tree, hf_bssap_mobile_station_state_ie, tvb, offset, ie_len+2, ENC_NA);
1283 ie_tree = proto_item_add_subtree(item, ett_bssap_mobile_station_state);
1285 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1286 offset++;
1287 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1288 offset++;
1289 /* Mobile station state value (octet 3) */
1290 proto_tree_add_item(ie_tree, hf_bssap_mobile_station_state, tvb, offset, ie_len, ENC_BIG_ENDIAN);
1292 return offset + ie_len;
1295 /* 18.4.20 PTMSI */
1296 static int
1297 dissect_bssap_ptmsi(tvbuff_t *tvb, proto_tree *tree, int offset)
1299 proto_item *item;
1300 proto_tree *ie_tree;
1301 uint8_t ie_len;
1303 ie_len = tvb_get_uint8(tvb, offset+1);
1304 item = proto_tree_add_item(tree, hf_bssap_ptmsi_ie, tvb, offset, ie_len+2, ENC_NA);
1305 ie_tree = proto_item_add_subtree(item, ett_bssap_ptmsi);
1307 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1308 offset++;
1309 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1310 offset++;
1311 /* The PTMSI consists of 4 octets. It can be coded using a full hexadecimal representation
1312 * (see 3GPP TS 23.003).
1314 proto_tree_add_item(ie_tree, hf_bssap_ptmsi, tvb, offset, ie_len, ENC_NA);
1316 return offset + ie_len;
1319 /* 18.4.21 Reject cause */
1320 static int
1321 dissect_bssap_reject_cause(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset)
1323 proto_item *item;
1324 proto_tree *ie_tree;
1325 uint8_t ie_len;
1327 ie_len = tvb_get_uint8(tvb, offset+1);
1328 item = proto_tree_add_item(tree, hf_bssap_reject_cause_ie, tvb, offset, ie_len+2, ENC_NA);
1329 ie_tree = proto_item_add_subtree(item, ett_bssap_reject_cause);
1331 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1332 offset++;
1333 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1334 offset++;
1335 /* The rest of the information element is coded as the value part of
1336 * the reject cause IE defined in 3GPP TS 24.008, not including
1337 * 3GPP TS 24.008 IEI.
1339 de_rej_cause(tvb, ie_tree, pinfo, offset, ie_len, NULL, 0);
1341 return offset + ie_len;
1345 /* 18.4.21b Service Area Identification */
1346 static int
1347 dissect_bssap_service_area_id(tvbuff_t *tvb, proto_tree *tree, int offset)
1349 proto_item *item;
1350 proto_tree *ie_tree;
1351 uint8_t ie_len;
1353 ie_len = tvb_get_uint8(tvb, offset+1);
1354 item = proto_tree_add_item(tree, hf_bssap_service_area_id_ie, tvb, offset, ie_len+2, ENC_NA);
1355 ie_tree = proto_item_add_subtree(item, ett_bssap_service_area_id);
1357 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1358 offset++;
1359 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1360 offset++;
1361 /* The rest of the information element is coded as the value part
1362 * of the SAI IE defined in 3GPP TS 25.413 (not including
1363 * 3GPP TS 25.413 IEI and 3GPP TS 25.413 length indicator).
1365 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_data, tvb, offset, ie_len, ENC_NA);
1367 return offset + ie_len;
1371 /* 18.4.22 SGSN number */
1373 static int
1374 dissect_bssap_sgsn_number(tvbuff_t *tvb, proto_tree *tree, int offset)
1376 proto_item *item;
1377 proto_tree *ie_tree;
1378 uint8_t ie_len;
1379 tvbuff_t *number_tvb;
1381 ie_len = tvb_get_uint8(tvb, offset+1);
1382 item = proto_tree_add_item(tree, hf_bssap_sgsn_nr_ie, tvb, offset, ie_len+2, ENC_NA);
1383 ie_tree = proto_item_add_subtree(item, ett_bssap_sgsn_nr);
1385 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1386 offset++;
1387 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1388 offset++;
1389 /* The SGSN number is coded as a sequence of TBCD digits (as specified in 3GPP TS 29.002),
1390 * compressed two into each octet. The Number is in international E.164 format as indicated by Octet 3
1391 * which coding is specified in 3GPP TS 29.002. This is a variable length information element,
1392 * and includes a length indicator. The value part of the SGSN number information element
1393 * (not including IEI, Length indicator and Octet 3) shall not exceed 15 digits.
1395 proto_tree_add_item(ie_tree, hf_bssap_extension, tvb, offset, 1, ENC_BIG_ENDIAN);
1396 proto_tree_add_item(ie_tree, hf_bssap_type_of_number, tvb, offset, 1, ENC_BIG_ENDIAN);
1397 proto_tree_add_item(ie_tree, hf_bssap_numbering_plan_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1398 offset++;
1399 number_tvb = tvb_new_subset_length(tvb, offset, ie_len-1);
1400 proto_tree_add_item(ie_tree, hf_bssap_sgsn_number, number_tvb, 0, -1, ENC_BCD_DIGITS_0_9|ENC_LITTLE_ENDIAN);
1403 return offset + ie_len-1;
1406 /* 18.4.23 TMSI */
1407 static int
1408 dissect_bssap_tmsi(tvbuff_t *tvb, proto_tree *tree, int offset)
1410 proto_item *item;
1411 proto_tree *ie_tree;
1412 uint8_t ie_len;
1414 ie_len = tvb_get_uint8(tvb, offset+1);
1415 item = proto_tree_add_item(tree, hf_bssap_tmsi_ie, tvb, offset, ie_len+2, ENC_NA);
1416 ie_tree = proto_item_add_subtree(item, ett_bssap_tmsi);
1418 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1419 offset++;
1420 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1421 offset++;
1422 /* The TMSI consists of 4 octets. It can be coded using a full hexadecimal representation
1423 * (see 3GPP TS 23.003).
1425 proto_tree_add_item(ie_tree, hf_bssap_tmsi, tvb, offset, ie_len, ENC_NA);
1428 return offset + ie_len;
1432 /* 18.4.24 TMSI status */
1433 static const true_false_string bssap_tmsi_flag = {
1434 "Valid TMSI available",
1435 "No valid TMSI available"
1437 static int
1438 dissect_bssap_tmsi_status(tvbuff_t *tvb, proto_tree *tree, int offset)
1440 proto_item *item;
1441 proto_tree *ie_tree;
1442 uint8_t ie_len;
1444 ie_len = tvb_get_uint8(tvb, offset+1);
1445 item = proto_tree_add_item(tree, hf_bssap_tmsi_status_ie, tvb, offset, ie_len+2, ENC_NA);
1446 ie_tree = proto_item_add_subtree(item, ett_bssap_tmsi_status);
1448 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1449 offset++;
1450 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1451 offset++;
1452 /* TMSI flag (octet 3) */
1453 proto_tree_add_item(ie_tree, hf_bssap_tmsi_status, tvb, offset, ie_len, ENC_BIG_ENDIAN);
1456 return offset + ie_len;
1459 /* 18.4.25 Uplink Tunnel Payload Control and Info */
1460 static const true_false_string bssap_E_flag = {
1461 "SGSN received the payload in ciphered",
1462 "SGSN did not receive the payload in ciphered form"
1464 /* 3GPP TS 44.064 B.1.1 TOM Protocol Discriminator */
1465 static const value_string bssap_tom_prot_disc_values[] = {
1466 { 0x00, "Not specified" },
1467 { 0x01, "TIA/EIA-136" },
1468 { 0x02, "RRLP" },
1469 { 0x03, "Reserved for extension" },
1470 { 0, NULL }
1472 static int
1473 dissect_bssap_ulink_tunnel_payload_control_and_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
1475 proto_item *item;
1476 proto_tree *ie_tree;
1477 tvbuff_t *next_tvb;
1478 uint8_t ie_len;
1479 uint8_t octet;
1480 uint8_t prot_disc;
1482 ie_len = tvb_get_uint8(tvb, offset+1);
1483 item = proto_tree_add_item(tree, hf_bssap_ulink_tnl_pld_cntrl_amd_inf_ie, tvb, offset, ie_len+2, ENC_NA);
1484 ie_tree = proto_item_add_subtree(item, ett_bssap_ulink_tnl_pld_cntrl_amd_inf);
1486 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1487 offset++;
1488 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1489 offset++;
1490 /* octet 3 bit 8 Spare */
1491 /* octet 3 bit 7 - 4
1492 * TOM Protocol Discriminator: Identifies the protocol using tunnelling of non-GSM signalling.
1493 * For coding, see 3GPP TS 44.064.
1495 proto_tree_add_item(ie_tree, hf_bssap_tom_prot_disc, tvb, offset, 1, ENC_BIG_ENDIAN);
1496 octet = tvb_get_uint8(tvb, offset);
1497 prot_disc = (octet&0x78)>>3;
1499 /* octet 3 bit 3 E: Cipher Request. When set to 1 indicates that the SGSN received the payload in ciphered form,
1500 * when set to 0 indicates that the SGSN did not receive the payload in ciphered form.
1502 proto_tree_add_item(ie_tree, hf_bssap_e_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
1504 /* octet 3 bit 2 - 1
1505 * Tunnel Priority: Indicates the priority of the Tunnel Payload. For coding, see Table 20.1: Association
1506 * between Tunnel Priority and LLC SAPs.
1508 proto_tree_add_item(ie_tree, hf_bssap_tunnel_prio, tvb, offset, 1, ENC_BIG_ENDIAN);
1509 /* Tunnel payload */
1510 next_tvb = tvb_new_subset_length(tvb, offset, ie_len - 4);
1512 if ((prot_disc == 2)&&(rrlp_handle))
1513 call_dissector(rrlp_handle, next_tvb, pinfo, ie_tree);
1514 else
1515 call_data_dissector(next_tvb, pinfo, ie_tree);
1517 return offset + ie_len;
1521 /* 18.4.26 VLR number */
1522 static int
1523 dissect_bssap_vlr_number(tvbuff_t *tvb, proto_tree *tree, int offset)
1525 proto_item *item;
1526 proto_tree *ie_tree;
1527 uint8_t ie_len;
1528 tvbuff_t *number_tvb;
1530 ie_len = tvb_get_uint8(tvb, offset+1);
1531 item = proto_tree_add_item(tree, hf_bssap_vlr_number_ie, tvb, offset, ie_len+2, ENC_NA);
1532 ie_tree = proto_item_add_subtree(item, ett_bssap_vlr_number);
1534 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1535 offset++;
1536 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1537 offset++;
1538 /* The VLR number is coded as a sequence of TBCD digits (as specified in 3GPP TS 29.002),
1539 * compressed two into each octet. The Number is in international E.164 format as indicated by Octet 3
1540 * which coding is specified in 3GPP TS 29.002. This is a variable length information element,
1541 * and includes a length indicator. The value part of the VLR number information element
1542 * (not including IEI, length indicator and Octet 3), shall not exceed 15 digits.
1545 proto_tree_add_item(ie_tree, hf_bssap_extension, tvb, offset, 1, ENC_BIG_ENDIAN);
1546 proto_tree_add_item(ie_tree, hf_bssap_type_of_number, tvb, offset, 1, ENC_BIG_ENDIAN);
1547 proto_tree_add_item(ie_tree, hf_bssap_numbering_plan_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1548 offset++;
1549 number_tvb = tvb_new_subset_length(tvb, offset, ie_len - 1);
1550 proto_tree_add_item(ie_tree, hf_bssap_vlr_number, number_tvb, 0, -1, ENC_BCD_DIGITS_0_9|ENC_LITTLE_ENDIAN);
1552 return offset + ie_len - 1;
1555 /* 18.4.27 Global CN-Id */
1556 static int
1557 dissect_bssap_global_cn_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
1559 proto_item *item;
1560 proto_tree *ie_tree;
1561 proto_item *plmn_item;
1562 proto_tree *plmn_tree;
1563 proto_item *global_cn_id_item;
1564 proto_tree *global_cn_id_tree;
1565 uint8_t ie_len;
1567 ie_len = tvb_get_uint8(tvb, offset+1);
1568 item = proto_tree_add_item(tree, hf_bssap_global_cn_id_ie, tvb, offset, ie_len+2, ENC_NA);
1569 ie_tree = proto_item_add_subtree(item, ett_bssap_global_cn);
1571 proto_tree_add_item(ie_tree, hf_bssap_plus_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
1572 offset++;
1573 proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1574 offset++;
1575 /* The Global CN-Id consists of a PLMN-Id and a CN-Id, see 3GPP TS 23.003.
1576 * The PLMN-Id consists of MCC and MNC coded according to Location Area Identification
1577 * in 3GPP TS 24.008. The CN-Id is an integer defined by O&M.
1578 * The least significant bit of the CN-Id field is bit 1 of octet 7 and
1579 * the most significant bit is bit 8 of octet 6. If the CN-Id does not fill the field reserved for it,
1580 * the rest of the bits are set to '0'.
1582 global_cn_id_item = proto_tree_add_item(ie_tree, hf_bssap_global_cn_id, tvb, offset, ie_len, ENC_NA);
1583 global_cn_id_tree = proto_item_add_subtree(global_cn_id_item, ett_bssap_global_cn_id);
1584 /* Octet 3 - 5 PLMN-Id Coded as octets 2 to 4 of the Location Area Identification IE,
1585 * defined in 3GPP TS 24.008 (not including 3GPP TS 24.008 IEI and LAC).
1587 plmn_item = proto_tree_add_item(global_cn_id_tree, hf_bssap_plmn_id, tvb, offset, 3, ENC_NA);
1588 plmn_tree = proto_item_add_subtree(plmn_item, ett_bssap_plmn);
1589 dissect_e212_mcc_mnc(tvb, pinfo, plmn_tree, offset, E212_NONE, true);
1590 offset = offset + 3;
1592 /* Octet 6 - 7 CN-Id (INTEGER 0..4095) */
1593 proto_tree_add_item(global_cn_id_tree, hf_bssap_cn_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1594 offset = offset+2;
1596 return offset;
1600 static int dissect_bssap_plus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
1602 proto_item *bssap_item;
1603 proto_tree *bssap_tree;
1604 uint8_t message_type;
1605 int offset = 0;
1606 struct _sccp_msg_info_t* sccp_info = (struct _sccp_msg_info_t*)data;
1609 * Make entry in the Protocol column on summary display
1611 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BSSAP+");
1613 if (sccp_info && sccp_info->data.co.assoc)
1614 sccp_info->data.co.assoc->payload = SCCP_PLOAD_BSSAP;
1616 /* create the BSSAP+ protocol tree */
1617 bssap_item = proto_tree_add_item(tree, proto_bssap_plus, tvb, 0, -1, ENC_NA);
1618 bssap_tree = proto_item_add_subtree(bssap_item, ett_bssap);
1620 message_type = tvb_get_uint8(tvb, offset);
1621 proto_tree_add_item(bssap_tree, hf_bssap_plus_message_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1622 offset++;
1624 col_add_str(pinfo->cinfo, COL_INFO, val_to_str_ext(message_type, &bssap_plus_message_type_values_ext, "Unknown %u"));
1626 switch (message_type) {
1627 case BSSAP_PAGING_REQUEST:
1628 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1629 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
1630 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
1632 /* VLR number VLR number 18.4.26 M TLV 5-11 */
1633 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_VLR_NUMBER))
1634 offset = dissect_bssap_vlr_number(tvb, bssap_tree, offset);
1636 /* End of mandatory elements */
1637 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1638 return tvb_reported_length(tvb);
1640 /* TMSI TMSI 18.4.23 O TLV 6 */
1641 if (check_optional_ie(tvb, offset, BSSAP_TMSI))
1642 offset = dissect_bssap_tmsi(tvb, bssap_tree, offset);
1643 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1644 return tvb_reported_length(tvb);
1646 /* Location area identifier Location area identifier 18.4.14 O TLV 7 */
1647 if (check_optional_ie(tvb, offset, BSSAP_LOC_AREA_ID))
1648 offset = dissect_bssap_loc_area_id(tvb, bssap_tree, pinfo, offset);
1649 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1650 return tvb_reported_length(tvb);
1652 /* Channel needed Channel needed 18.4.2 O TLV 3 */
1653 if (check_optional_ie(tvb, offset, BSSAP_CHANNEL_NEEDED))
1654 offset = dissect_bssap_channel_needed(tvb, bssap_tree, pinfo, offset);
1655 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1656 return tvb_reported_length(tvb);
1658 /* eMLPP Priority eMLPP Priority 18.4.4 O TLV 3 */
1659 if (check_optional_ie(tvb, offset, BSSAP_EMLPP_PRIORITY))
1660 offset = dissect_bssap_emlpp_priority(tvb, bssap_tree, offset);
1661 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1662 return tvb_reported_length(tvb);
1664 /* Global CN-Id Global CN-Id 18.4.27 O TLV 7 */
1665 if (check_optional_ie(tvb, offset, BSSAP_GLOBAL_CN_ID))
1666 offset = dissect_bssap_global_cn_id(tvb, pinfo, bssap_tree, offset);
1667 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1668 return tvb_reported_length(tvb);
1670 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1671 break;
1672 case BSSAP_PAGING_REJECT: /* 17.1.18 */
1673 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1674 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
1675 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
1676 /* Gs Cause Gs Cause 18.4.7 M TLV 3 */
1677 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_GS_CAUSE))
1678 offset = dissect_bssap_Gs_cause(tvb, bssap_tree, offset);
1680 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1681 return tvb_reported_length(tvb);
1682 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1683 break;
1684 case BSSAP_DOWNLINK_TUNNEL_REQUEST: /* 17.1.4 */
1685 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1686 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
1687 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
1689 /* VLR number VLR number 18.4.26 M TLV 5-11 */
1690 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_VLR_NUMBER))
1691 offset = dissect_bssap_vlr_number(tvb, bssap_tree, offset);
1693 /* Downlink Tunnel Payload Control and Info 18.4.3 M TLV 3-223 */
1694 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_DLINK_TNL_PLD_CTR_AND_INF))
1695 offset = dissect_bssap_dlink_tunnel_payload_control_and_info(tvb, pinfo, bssap_tree, offset);
1697 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1698 return tvb_reported_length(tvb);
1699 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1700 break;
1701 case BSSAP_UPLINK_TUNNEL_REQUEST: /* 17.1.23 */
1702 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1703 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
1704 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
1706 /* SGSN number 18.4.22 M TLV 5-11 */
1707 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_SGSN_NUMBER))
1708 offset = dissect_bssap_sgsn_number(tvb, bssap_tree, offset);
1710 /* Uplink Tunnel Payload Control and Info 18.4.25 M TLV 3-223 */
1711 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_ULINK_TNL_PLD_CTR_AND_INF))
1712 offset = dissect_bssap_ulink_tunnel_payload_control_and_info(tvb, pinfo, bssap_tree, offset);
1714 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1715 return tvb_reported_length(tvb);
1716 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1717 break;
1718 case BSSAP_LOCATION_UPDATE_REQUEST: /* 17.1.11 BSSAP+-LOCATION-UPDATE-REQUEST */
1719 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1720 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
1721 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
1723 /* SGSN number SGSN number 18.4.22 M TLV 5-11 */
1724 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_SGSN_NUMBER))
1725 offset = dissect_bssap_sgsn_number(tvb, bssap_tree, offset);
1727 /* Update type GPRS location update type 18.4.6 M TLV 3 */
1728 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_GPRS_LOC_UPD_TYPE))
1729 offset = dissect_bssap_gprs_location_update_type(tvb, bssap_tree, offset);
1731 /* New Cell global identity Cell global identity 18.4.1 M TLV 10 */
1732 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_CELL_GBL_ID))
1733 offset = dissect_bssap_cell_global_id(tvb, bssap_tree, pinfo, offset);
1735 /* Mobile station classmark Mobile station classmark 1 18.4.18 M TLV 3 */
1736 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_MOBILE_STN_CLS_MRK1))
1737 offset = dissect_bssap_mobile_stn_cls_mrk1(tvb, bssap_tree, pinfo, offset);
1738 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1739 return tvb_reported_length(tvb);
1741 /* Old location area identifier Location area identifier 18.4.14 O TLV 7 */
1742 if (check_optional_ie(tvb, offset, BSSAP_LOC_AREA_ID))
1743 offset = dissect_bssap_loc_area_id(tvb, bssap_tree, pinfo, offset);
1744 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1745 return tvb_reported_length(tvb);
1747 /* TMSI status TMSI status 18.4.24 O TLV 3 */
1748 if (check_optional_ie(tvb, offset, BSSAP_TMSI_STATUS))
1749 offset = dissect_bssap_tmsi_status(tvb, bssap_tree, offset);
1750 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1751 return tvb_reported_length(tvb);
1753 /* New service area identification Service area identification 18.4.21b O TLV 9 */
1754 if (check_optional_ie(tvb, offset, BSSAP_SERVICE_AREA_ID))
1755 offset = dissect_bssap_service_area_id(tvb, bssap_tree, offset);
1756 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1757 return tvb_reported_length(tvb);
1759 /* IMEISV IMEISV 18.4.9 O TLV 10 */
1760 if (check_optional_ie(tvb, offset, BSSAP_IMEISV))
1761 offset = dissect_bssap_imeisv(tvb, bssap_tree, offset);
1762 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1763 return tvb_reported_length(tvb);
1764 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1765 break;
1766 case BSSAP_LOCATION_UPDATE_ACCEPT: /* 17.1.9 */
1767 /* IMSI 18.4.10 M TLV 6-10 */
1768 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
1769 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
1771 /* Location area identifier Location area identifier 18.4.14 M TLV 7 */
1772 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_LOC_AREA_ID))
1773 offset = dissect_bssap_loc_area_id(tvb, bssap_tree, pinfo, offset);
1775 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1776 return tvb_reported_length(tvb);
1778 /* New TMSI, or IMSI Mobile identity 18.4.17 O TLV 6-10 */
1779 if (check_optional_ie(tvb, offset, BSSAP_MOBILE_ID))
1780 offset = dissect_bssap_mobile_id(tvb, bssap_tree, pinfo, offset);
1781 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1782 return tvb_reported_length(tvb);
1783 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1784 break;
1785 case BSSAP_LOCATION_UPDATE_REJECT: /* 17.1.10 */
1786 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1787 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
1788 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
1789 /* Reject cause Reject cause 18.4.21 M TLV 3 */
1790 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_REJECT_CAUSE))
1791 offset = dissect_bssap_reject_cause(tvb, bssap_tree, pinfo, offset);
1792 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1793 return tvb_reported_length(tvb);
1794 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1795 break;
1796 case BSSAP_TMSI_REALLOCATION_COMPLETE: /* 17.1.22 */
1797 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1798 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
1799 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
1801 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1802 return tvb_reported_length(tvb);
1804 /* Cell global identity Cell global identity 18.4.1 O TLV 10 */
1805 if (check_optional_ie(tvb, offset, BSSAP_CELL_GBL_ID))
1806 offset = dissect_bssap_cell_global_id(tvb, bssap_tree, pinfo, offset);
1808 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1809 return tvb_reported_length(tvb);
1811 /* Service area identification Service area identification 18.4.21b O TLV 9 */
1812 if (check_optional_ie(tvb, offset, BSSAP_SERVICE_AREA_ID))
1813 offset = dissect_bssap_service_area_id(tvb, bssap_tree, offset);
1814 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1815 return tvb_reported_length(tvb);
1816 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1817 break;
1818 case BSSAP_ALERT_REQUEST: /* 17.1.3 */
1819 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1820 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
1821 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
1823 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1824 return tvb_reported_length(tvb);
1825 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1826 break;
1827 case BSSAP_ALERT_ACK: /* 17.1.1 */
1828 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1829 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
1830 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
1832 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1833 return tvb_reported_length(tvb);
1834 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1835 break;
1836 case BSSAP_ALERT_REJECT: /* 17.1.2 */
1837 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1838 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
1839 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
1841 /* Gs Cause Gs Cause 18.4.7 M TLV 3 */
1842 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_GS_CAUSE))
1843 offset = dissect_bssap_Gs_cause(tvb, bssap_tree, offset);
1845 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1846 return tvb_reported_length(tvb);
1847 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1848 break;
1849 case BSSAP_MS_ACTIVITY_INDICATION: /* 17.1.14 */
1850 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1851 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
1852 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
1854 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1855 return tvb_reported_length(tvb);
1857 /* Cell global identity Cell global identity 18.4.1 O TLV 10 */
1858 if (check_optional_ie(tvb, offset, BSSAP_CELL_GBL_ID))
1859 offset = dissect_bssap_cell_global_id(tvb, bssap_tree, pinfo, offset);
1861 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1862 return tvb_reported_length(tvb);
1864 /* Service area identification Service area identification 18.4.21b O TLV 9 */
1865 if (check_optional_ie(tvb, offset, BSSAP_SERVICE_AREA_ID))
1866 offset = dissect_bssap_service_area_id(tvb, bssap_tree, offset);
1867 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1868 return tvb_reported_length(tvb);
1869 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1870 break;
1871 case BSSAP_GPRS_DETACH_INDICATION: /* 17.1.6 */
1872 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1873 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
1874 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
1876 /* SGSN number SGSN number 18.4.22 M TLV 5-11 */
1877 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_SGSN_NUMBER))
1878 offset = dissect_bssap_sgsn_number(tvb, bssap_tree, offset);
1880 /* IMSI detach from GPRS service type IMSI detach from GPRS service type 18.4.17 M TLV 3 */
1881 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI_DET_FROM_GPRS_SERV_TYPE))
1882 offset = dissect_bssap_imsi_det_from_gprs_serv_type(tvb, bssap_tree, offset);
1884 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1885 return tvb_reported_length(tvb);
1887 /* Cell global identity Cell global identity 18.4.1 O TLV 10 */
1888 if (check_optional_ie(tvb, offset, BSSAP_CELL_GBL_ID))
1889 offset = dissect_bssap_cell_global_id(tvb, bssap_tree, pinfo, offset);
1891 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1892 return tvb_reported_length(tvb);
1894 /* Service area identification Service area identification 18.4.21b O TLV 9 */
1895 if (check_optional_ie(tvb, offset, BSSAP_SERVICE_AREA_ID))
1896 offset = dissect_bssap_service_area_id(tvb, bssap_tree, offset);
1897 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1898 return tvb_reported_length(tvb);
1899 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1900 break;
1901 case BSSAP_GPRS_DETACH_ACK: /* 17.1.5 */
1902 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1903 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
1904 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
1906 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1907 return tvb_reported_length(tvb);
1908 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1909 break;
1910 case BSSAP_IMSI_DETACH_INDICATION: /* 17.1.8 */
1911 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1912 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
1913 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
1915 /* SGSN number SGSN number 18.4.22 M TLV 5-11 */
1916 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_SGSN_NUMBER))
1917 offset = dissect_bssap_sgsn_number(tvb, bssap_tree, offset);
1919 /* Detach type IMSI detach from non-GPRS service type 18.4.11 M TLV 3 */
1920 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI_DET_FROM_NON_GPRS_SERV_TYPE))
1921 offset = dissect_bssap_imsi_det_from_non_gprs_serv_type(tvb, bssap_tree, offset);
1923 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1924 return tvb_reported_length(tvb);
1926 /* Cell global identity Cell global identity 18.4.1 O TLV 10 */
1927 if (check_optional_ie(tvb, offset, BSSAP_CELL_GBL_ID))
1928 offset = dissect_bssap_cell_global_id(tvb, bssap_tree, pinfo, offset);
1930 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1931 return tvb_reported_length(tvb);
1933 /* Location information age Location information age 18.4.14 O TLV 4 */
1934 if (check_optional_ie(tvb, offset, BSSAP_LOC_INF_AGE))
1935 offset = dissect_bssap_location_information_age(tvb, bssap_tree, offset);
1937 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1938 return tvb_reported_length(tvb);
1940 /* Service area identification Service area identification 18.4.21b O TLV 9 */
1941 if (check_optional_ie(tvb, offset, BSSAP_SERVICE_AREA_ID))
1942 offset = dissect_bssap_service_area_id(tvb, bssap_tree, offset);
1943 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1944 return tvb_reported_length(tvb);
1945 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1946 break;
1947 case BSSAP_IMSI_DETACH_ACK: /* 17.1.7 */
1948 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1949 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
1950 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
1952 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1953 return tvb_reported_length(tvb);
1954 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1955 break;
1956 case BSSAP_RESET_INDICATION: /* 17.1.21 */
1957 /* Conditional IE:s */
1958 /* SGSN number SGSN number 18.4.22 C TLV 5-11 */
1959 if (check_optional_ie(tvb, offset, BSSAP_SGSN_NUMBER)) {
1960 offset = dissect_bssap_sgsn_number(tvb, bssap_tree, offset);
1961 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1962 return tvb_reported_length(tvb);
1963 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1964 }else{
1965 /* VLR number VLR number 18.4.26 C TLV 5-11 */
1966 if (check_optional_ie(tvb, offset, BSSAP_VLR_NUMBER)) {
1967 offset = dissect_bssap_vlr_number(tvb, bssap_tree, offset);
1968 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1969 return tvb_reported_length(tvb);
1970 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1973 proto_tree_add_item(tree, hf_bssap_conditional_ie, tvb, offset, -1, ENC_NA);
1974 break;
1975 case BSSAP_RESET_ACK: /* 17.1.20 */
1976 /* Conditional IE:s */
1977 /* SGSN number SGSN number 18.4.22 C TLV 5-11 */
1978 if (check_optional_ie(tvb, offset, BSSAP_SGSN_NUMBER)) {
1979 offset = dissect_bssap_sgsn_number(tvb, bssap_tree, offset);
1980 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1981 return tvb_reported_length(tvb);
1982 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1983 }else{
1984 /* VLR number VLR number 18.4.26 C TLV 5-11 */
1985 if (check_optional_ie(tvb, offset, BSSAP_VLR_NUMBER)) {
1986 offset = dissect_bssap_vlr_number(tvb, bssap_tree, offset);
1987 if (tvb_reported_length_remaining(tvb, offset) <= 0)
1988 return tvb_reported_length(tvb);
1989 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
1992 proto_tree_add_item(tree, hf_bssap_conditional_ie, tvb, offset, -1, ENC_NA);
1993 break;
1994 case BSSAP_MS_INFORMATION_REQUEST: /* 17.1.15 */
1995 /* IMSI IMSI 18.4.10 M TLV 6-10 */
1996 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
1997 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
1999 /* Information requested Information requested 18.4.13 M TLV 3 */
2000 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_INFO_REQ))
2001 offset = dissect_bssap_info_req(tvb, bssap_tree, offset);
2003 if (tvb_reported_length_remaining(tvb, offset) <= 0)
2004 return tvb_reported_length(tvb);
2006 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
2007 break;
2008 case BSSAP_MS_INFORMATION_RESPONSE: /* 17.1.16 */
2009 /* IMSI IMSI 18.4.10 M TLV 6-10 */
2010 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
2011 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
2012 if (tvb_reported_length_remaining(tvb, offset) <= 0)
2013 return tvb_reported_length(tvb);
2015 /* TMSI TMSI 18.4.23 O TLV 6 */
2016 if (check_optional_ie(tvb, offset, BSSAP_TMSI))
2017 offset = dissect_bssap_tmsi(tvb, bssap_tree, offset);
2018 if (tvb_reported_length_remaining(tvb, offset) <= 0)
2019 return tvb_reported_length(tvb);
2021 /* PTMSI PTMSI 18.4.20 O TLV 6 BSSAP_PTMSI*/
2022 if (check_optional_ie(tvb, offset, BSSAP_PTMSI))
2023 offset = dissect_bssap_ptmsi(tvb, bssap_tree, offset);
2024 if (tvb_reported_length_remaining(tvb, offset) <= 0)
2025 return tvb_reported_length(tvb);
2027 /* IMEI IMEI 18.4.8 O TLV 10 */
2028 if (check_optional_ie(tvb, offset, BSSAP_IMEI))
2029 offset = dissect_bssap_imei(tvb, bssap_tree, offset);
2030 if (tvb_reported_length_remaining(tvb, offset) <= 0)
2031 return tvb_reported_length(tvb);
2032 /* IMEISV IMEISV 18.4.9 O TLV 10 BSSAP_IMEISV*/
2033 if (check_optional_ie(tvb, offset, BSSAP_IMEISV))
2034 offset = dissect_bssap_imeisv(tvb, bssap_tree, offset);
2035 if (tvb_reported_length_remaining(tvb, offset) <= 0)
2036 return tvb_reported_length(tvb);
2038 /* Cell global identity Cell global identity 18.4.1 O TLV 10 */
2039 if (check_optional_ie(tvb, offset, BSSAP_CELL_GBL_ID))
2040 offset = dissect_bssap_cell_global_id(tvb, bssap_tree, pinfo, offset);
2042 if (tvb_reported_length_remaining(tvb, offset) <= 0)
2043 return tvb_reported_length(tvb);
2044 /* Location information age Location information age 18.4.15 O TLV 4 */
2045 if (check_optional_ie(tvb, offset, BSSAP_LOC_INF_AGE))
2046 offset = dissect_bssap_location_information_age(tvb, bssap_tree, offset);
2048 if (tvb_reported_length_remaining(tvb, offset) <= 0)
2049 return tvb_reported_length(tvb);
2051 /* Mobile station state Mobile station state 18.4.19 O TLV 3 */
2052 if (check_optional_ie(tvb, offset, BSSAP_MOBILE_STN_STATE))
2053 offset = dissect_bssap_mobile_station_state(tvb, bssap_tree, offset);
2055 if (tvb_reported_length_remaining(tvb, offset) <= 0)
2056 return tvb_reported_length(tvb);
2058 /* Service area identification Service area identification 18.4.21b O TLV 9 */
2059 if (check_optional_ie(tvb, offset, BSSAP_SERVICE_AREA_ID))
2060 offset = dissect_bssap_service_area_id(tvb, bssap_tree, offset);
2061 if (tvb_reported_length_remaining(tvb, offset) <= 0)
2062 return tvb_reported_length(tvb);
2063 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
2064 break;
2065 case BSSAP_MM_INFORMATION_REQUEST: /* 17.1.12 */
2066 /* IMSI IMSI 18.4.10 M TLV 6-10 */
2067 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
2068 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
2070 if (tvb_reported_length_remaining(tvb, offset) <= 0)
2071 return tvb_reported_length(tvb);
2072 /* MM information MM information 18.4.16 O TLV 3-n */
2073 if (check_optional_ie(tvb, offset, BSSAP_MM_INFORMATION))
2074 offset = dissect_bssap_MM_information(tvb, bssap_tree, pinfo, offset);
2075 if (tvb_reported_length_remaining(tvb, offset) <= 0)
2076 return tvb_reported_length(tvb);
2077 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
2078 break;
2079 case BSSAP_MOBILE_STATUS: /* 17.1.13 */
2080 /* IMSI IMSI 18.4.10 O TLV 6-10 */
2081 if (check_optional_ie(tvb, offset, BSSAP_IMSI))
2082 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
2083 /* Gs Cause Gs Cause 18.4.7 M TLV 3 */
2084 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_GS_CAUSE))
2085 offset = dissect_bssap_Gs_cause(tvb, bssap_tree, offset);
2087 /* Erroneous message Erroneous message 18.4.5 M TLV 3-n BSSAP_ERRONEOUS_MSG*/
2088 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_ERRONEOUS_MSG))
2089 offset = dissect_bssap_gprs_erroneous_msg(tvb, bssap_tree, offset);
2091 if (tvb_reported_length_remaining(tvb, offset) <= 0)
2092 return tvb_reported_length(tvb);
2093 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
2094 break;
2095 case BSSAP_MS_UNREACHABLE: /* 17.1.17 */
2096 /* IMSI IMSI 18.4.10 M TLV 6-10 */
2097 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_IMSI))
2098 offset = dissect_bssap_imsi(tvb, bssap_tree, pinfo, offset);
2100 /* Gs Cause Gs Cause 18.4.7 M TLV 3 */
2101 if (check_ie(tvb, pinfo, tree, &offset, BSSAP_GS_CAUSE))
2102 offset = dissect_bssap_Gs_cause(tvb, bssap_tree, offset);
2104 if (tvb_reported_length_remaining(tvb, offset) <= 0)
2105 return tvb_reported_length(tvb);
2106 proto_tree_add_item(tree, hf_bssap_extraneous_data, tvb, offset, -1, ENC_NA);
2107 break;
2108 default:
2109 break;
2112 return tvb_reported_length(tvb);
2115 static bool
2116 dissect_bssap_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
2118 /* Is it a BSSAP/BSAP packet?
2119 * If octet_1 == 0x00 and octet_2 == length(tvb) - 2
2120 * or if octet_1 == 0x01 and octet_3 == length(tvb) - 3
2121 * then we'll assume it is a bssap packet
2122 * If octet_1 == 0x00 a further check is done
2123 * to differentiate a BSSMAP BLOCK message from a
2124 * RANAP DirectTransfer (under certain conditions)
2126 switch (tvb_get_uint8(tvb, 0))
2128 case 0x00:
2129 if (tvb_get_uint8(tvb, 1) != (tvb_reported_length(tvb) - 2)) {
2130 return false;
2132 if (tvb_get_uint8(tvb, 2) == 0x40 && tvb_get_uint8(tvb, 3) != 0x01) {
2133 return false;
2135 break;
2137 case 0x01:
2138 if (tvb_get_uint8(tvb, 2) != (tvb_reported_length(tvb) - 3)) {
2139 return false;
2141 break;
2143 default:
2144 return false;
2147 switch (default_protocol_global) {
2149 case BSSAP:
2150 dissect_bssap(tvb, pinfo, tree, data);
2151 break;
2153 case BSAP:
2154 dissect_bsap(tvb, pinfo, tree, data);
2155 break;
2157 case BSSAP_LE:
2158 dissect_bssap_le(tvb, pinfo, tree, data);
2159 break;
2163 return true;
2166 /* Register the protocol with Wireshark */
2167 void
2168 proto_register_bssap(void)
2170 module_t *bssap_module;
2171 module_t *bssap_plus_module;
2172 expert_module_t* expert_bssap;
2174 /* Setup list of header fields */
2175 static hf_register_info hf[] = {
2176 { &hf_bssap_pdu_type,
2177 { "Message Type", "bssap.pdu_type",
2178 FT_UINT8, BASE_HEX, VALS(bssap_pdu_type_values), 0x0,
2179 NULL, HFILL}},
2181 { &hf_bsap_pdu_type,
2182 { "Message Type", "bsap.pdu_type",
2183 FT_UINT8, BASE_HEX, VALS(bsap_pdu_type_values), 0x0,
2184 NULL, HFILL}},
2186 { &hf_bssap_dlci_cc,
2187 { "Control Channel", "bssap.dlci.cc",
2188 FT_UINT8, BASE_HEX, VALS(bssap_cc_values), CC_MASK,
2189 NULL, HFILL}},
2191 { &hf_bsap_dlci_cc,
2192 { "Control Channel", "bsap.dlci.cc",
2193 FT_UINT8, BASE_HEX, VALS(bsap_cc_values), CC_MASK,
2194 NULL, HFILL}},
2196 { &hf_bssap_dlci_spare,
2197 { "Spare", "bssap.dlci.spare",
2198 FT_UINT8, BASE_HEX, NULL, SPARE_MASK,
2199 NULL, HFILL}},
2201 { &hf_bsap_dlci_rsvd,
2202 { "Reserved", "bsap.dlci.rsvd",
2203 FT_UINT8, BASE_HEX, NULL, SPARE_MASK,
2204 NULL, HFILL}},
2206 { &hf_bssap_dlci_sapi,
2207 { "SAPI", "bssap.dlci.sapi",
2208 FT_UINT8, BASE_HEX, VALS(bssap_sapi_values), SAPI_MASK,
2209 NULL, HFILL}},
2211 { &hf_bsap_dlci_sapi,
2212 { "SAPI", "bsap.dlci.sapi",
2213 FT_UINT8, BASE_HEX, VALS(bsap_sapi_values), SAPI_MASK,
2214 NULL, HFILL}},
2216 { &hf_bssap_length,
2217 { "Length", "bssap.length",
2218 FT_UINT8, BASE_DEC, NULL, 0x0,
2219 NULL, HFILL}},
2222 { &hf_bssap_plus_message_type,
2223 { "Message Type", "bssap_plus.msg_type",
2224 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &bssap_plus_message_type_values_ext, 0x0,
2225 NULL, HFILL}},
2227 { &hf_bssap_plus_ie,
2228 { "IEI", "bssap_plus.iei",
2229 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &bssap_plus_ie_id_values_ext, 0x0,
2230 NULL, HFILL}},
2232 { &hf_bssap_plus_ie_len,
2233 { "Length indicator", "bssap_plus.ie_len",
2234 FT_UINT8, BASE_DEC, NULL, 0x0,
2235 NULL, HFILL}},
2237 { &hf_bssap_extension,
2238 { "Extension", "bssap.extension",
2239 FT_BOOLEAN, 8, TFS(&tfs_no_extension_extension), 0x80,
2240 NULL, HFILL }},
2242 { &hf_bssap_type_of_number,
2243 { "Type of number", "bssap.type_of_number",
2244 FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_type_of_number_values), 0x70,
2245 NULL, HFILL }},
2247 { &hf_bssap_numbering_plan_id,
2248 { "Numbering plan identification", "bssap.number_plan",
2249 FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_numbering_plan_id_values), 0x0f,
2250 NULL, HFILL }},
2252 { &hf_bssap_sgsn_number,
2253 { "SGSN number", "bssap.sgsn_number",
2254 FT_STRING, BASE_NONE, NULL, 0,
2255 NULL, HFILL }},
2257 { &hf_bssap_vlr_number,
2258 { "VLR number", "bssap.vlr_number",
2259 FT_STRING, BASE_NONE, NULL, 0,
2260 NULL, HFILL }},
2262 { &hf_bssap_cell_global_id_ie,
2263 { "Cell global identity IE", "bssap.cell_global_id_ie",
2264 FT_NONE, BASE_NONE, NULL, 0,
2265 NULL, HFILL }},
2267 { &hf_bssap_channel_needed_ie,
2268 { "Channel needed IE", "bssap.channel_needed_ie",
2269 FT_NONE, BASE_NONE, NULL, 0,
2270 NULL, HFILL }},
2272 { &hf_bssap_dlink_tnl_pld_cntrl_amd_inf_ie,
2273 { "Downlink Tunnel Payload Control and Info IE", "bssap.dlink_tnl_pld_cntrl_amd_inf_ie",
2274 FT_NONE, BASE_NONE, NULL, 0,
2275 NULL, HFILL }},
2277 { &hf_bssap_ulink_tnl_pld_cntrl_amd_inf_ie,
2278 { "Uplink Tunnel Payload Control and Info IE", "bssap.ulink_tnl_pld_cntrl_amd_inf_ie",
2279 FT_NONE, BASE_NONE, NULL, 0,
2280 NULL, HFILL }},
2282 { &hf_bssap_emlpp_prio_ie,
2283 { "eMLPP Priority IE", "bssap.emlpp_prio_ie",
2284 FT_NONE, BASE_NONE, NULL, 0,
2285 NULL, HFILL }},
2287 { &hf_bssap_gprs_erroneous_msg_ie,
2288 { "Erroneous message IE", "bssap.erroneous_msg_ie",
2289 FT_NONE, BASE_NONE, NULL, 0,
2290 NULL, HFILL }},
2292 { &hf_bssap_gprs_loc_upd_type_ie,
2293 { "GPRS location update type IE", "bssap.loc_upd_type_ie",
2294 FT_NONE, BASE_NONE, NULL, 0,
2295 NULL, HFILL }},
2297 { &hf_bssap_Gs_cause_ie,
2298 { "Gs Cause IE", "bssap.Gs_cause_ie",
2299 FT_NONE, BASE_NONE, NULL, 0,
2300 NULL, HFILL }},
2302 { &hf_bssap_imei_ie,
2303 { "IMEI IE", "bssap.imei_ie",
2304 FT_NONE, BASE_NONE, NULL, 0,
2305 NULL, HFILL }},
2307 { &hf_bssap_imeisv_ie,
2308 { "IMEISV IE", "bssap.imeisv_ie",
2309 FT_NONE, BASE_NONE, NULL, 0,
2310 NULL, HFILL }},
2312 { &hf_bssap_imsi_ie,
2313 { "IMSI IE", "bssap.imsi_ie",
2314 FT_NONE, BASE_NONE, NULL, 0,
2315 NULL, HFILL }},
2317 { &hf_bssap_imsi_det_from_gprs_serv_type_ie,
2318 { "IMSI detach from GPRS service type IE", "bssap.msi_det_from_gprs_serv_type_ie",
2319 FT_NONE, BASE_NONE, NULL, 0,
2320 NULL, HFILL }},
2322 { &hf_bssap_imsi_det_from_non_gprs_serv_type_ie,
2323 { "IMSI detach from non-GPRS service IE", "bssap.msi_det_from_non_gprs_serv_type_ie",
2324 FT_NONE, BASE_NONE, NULL, 0,
2325 NULL, HFILL }},
2327 { &hf_bssap_info_req_ie,
2328 { "Information requested IE", "bssap.info_req_ie",
2329 FT_NONE, BASE_NONE, NULL, 0,
2330 NULL, HFILL }},
2332 { &hf_bssap_loc_area_id_ie,
2333 { "Location area identifier IE", "bssap.loc_area_id_ie",
2334 FT_NONE, BASE_NONE, NULL, 0,
2335 NULL, HFILL }},
2337 { &hf_bssap_loc_inf_age_ie,
2338 { "Location information age IE", "bssap.loc_inf_age_ie",
2339 FT_NONE, BASE_NONE, NULL, 0,
2340 NULL, HFILL }},
2342 { &hf_bssap_mm_information_ie,
2343 { "MM information IE", "bssap.mm_information",
2344 FT_NONE, BASE_NONE, NULL, 0,
2345 NULL, HFILL }},
2347 { &hf_bssap_mobile_id_ie,
2348 { "Mobile identity IE", "bssap.mobile_id_ie",
2349 FT_NONE, BASE_NONE, NULL, 0,
2350 NULL, HFILL }},
2352 { &hf_bssap_mobile_stn_cls_mrk1_ie,
2353 { "Mobile station classmark 1 IE", "bssap.mobile_stn_cls_mrk1_ie",
2354 FT_NONE, BASE_NONE, NULL, 0,
2355 NULL, HFILL }},
2357 { &hf_bssap_mobile_station_state_ie,
2358 { "Mobile station state IE", "bssap.mobile_station_state_ie",
2359 FT_NONE, BASE_NONE, NULL, 0,
2360 NULL, HFILL }},
2362 { &hf_bssap_ptmsi_ie,
2363 { "PTMSI IE", "bssap.ptmsi_ie",
2364 FT_NONE, BASE_NONE, NULL, 0,
2365 NULL, HFILL }},
2367 { &hf_bssap_reject_cause_ie,
2368 { "Reject cause IE", "bssap.reject_cause_ie",
2369 FT_NONE, BASE_NONE, NULL, 0,
2370 NULL, HFILL }},
2372 { &hf_bssap_service_area_id_ie,
2373 { "Service area identification IE", "bssap.service_area_id_ie",
2374 FT_NONE, BASE_NONE, NULL, 0,
2375 "Mobile station classmark 1", HFILL }},
2377 { &hf_bssap_sgsn_nr_ie,
2378 { "SGSN number IE", "bssap.sgsn_nr_ie",
2379 FT_NONE, BASE_NONE, NULL, 0,
2380 NULL, HFILL }},
2382 { &hf_bssap_tmsi_ie,
2383 { "TMSI IE", "bssap.tmsi_ie",
2384 FT_NONE, BASE_NONE, NULL, 0,
2385 NULL, HFILL }},
2387 { &hf_bssap_tmsi_status_ie,
2388 { "TMSI status IE", "bssap.tmsi_status_ie",
2389 FT_NONE, BASE_NONE, NULL, 0,
2390 NULL, HFILL }},
2392 { &hf_bssap_vlr_number_ie,
2393 { "VLR number IE", "bssap.vlr_number_ie",
2394 FT_NONE, BASE_NONE, NULL, 0,
2395 NULL, HFILL }},
2397 { &hf_bssap_global_cn_id_ie,
2398 { "Global CN-Id IE", "bssap.global_cn_id_ie",
2399 FT_NONE, BASE_NONE, NULL, 0,
2400 NULL, HFILL }},
2402 { &hf_bssap_plus_ie_data,
2403 { "IE Data", "bssap.ie_data",
2404 FT_BYTES, BASE_NONE, NULL, 0,
2405 NULL, HFILL }},
2407 { &hf_bssap_call_priority,
2408 { "eMLPP Priority", "bssap.call_priority",
2409 FT_UINT8, BASE_DEC, VALS(bssap_call_priority_values), 0x07,
2410 NULL, HFILL}},
2412 { &hf_bssap_gprs_loc_upd_type,
2413 { "GPRS location update type", "bssap.gprs_loc_upd_type",
2414 FT_UINT8, BASE_DEC, VALS(bssap_plus_GPRS_loc_upd_type_values), 0x0,
2415 NULL, HFILL}},
2417 { &hf_bssap_Gs_cause,
2418 { "Gs cause", "bssap.Gs_cause",
2419 FT_UINT8, BASE_DEC, VALS(bssap_Gs_cause_values), 0x0,
2420 NULL, HFILL}},
2422 { &hf_bssap_imei,
2423 { "IMEI", "bssap.imei",
2424 FT_STRING, BASE_NONE, NULL, 0,
2425 NULL, HFILL }},
2427 { &hf_bssap_imeisv,
2428 { "IMEISV", "bssap.imeisv",
2429 FT_STRING, BASE_NONE, NULL, 0,
2430 NULL, HFILL }},
2432 { &hf_bssap_imsi_det_from_gprs_serv_type,
2433 { "IMSI detach from GPRS service type", "bssap.imsi_det_from_gprs_serv_type",
2434 FT_UINT8, BASE_DEC, VALS(bssap_Gs_cause_values), 0x0,
2435 NULL, HFILL}},
2437 { &hf_bssap_info_req,
2438 { "Information requested", "bssap.info_req",
2439 FT_UINT8, BASE_DEC, VALS(bssap_info_req_values), 0x0,
2440 NULL, HFILL}},
2442 { &hf_bssap_loc_inf_age,
2443 { "AgeOfLocationInformation in minutes", "bssap.loc_inf_age",
2444 FT_UINT16, BASE_DEC, NULL, 0x0,
2445 NULL, HFILL}},
2447 { &hf_bssap_mobile_station_state,
2448 { "Mobile station state", "bssap.mobile_station_state",
2449 FT_UINT8, BASE_DEC, VALS(bssap_mobile_station_state_values), 0x0,
2450 NULL, HFILL}},
2452 { &hf_bssap_ptmsi,
2453 { "PTMSI", "bssap.ptmsi",
2454 FT_BYTES, BASE_NONE, NULL, 0x0,
2455 NULL, HFILL}},
2457 { &hf_bssap_tmsi,
2458 { "TMSI", "bssap.tmsi",
2459 FT_BYTES, BASE_NONE, NULL, 0x0,
2460 NULL, HFILL}},
2462 { &hf_bssap_tmsi_status,
2463 { "TMSI status", "bssap.tmsi_status",
2464 FT_BOOLEAN, 8, TFS(&bssap_tmsi_flag), 0x01,
2465 NULL, HFILL }},
2467 { &hf_bssap_tom_prot_disc,
2468 { "TOM Protocol Discriminator", "bssap.Tom_prot_disc",
2469 FT_UINT8, BASE_DEC, VALS(bssap_tom_prot_disc_values), 0x78,
2470 NULL, HFILL}},
2472 { &hf_bssap_e_bit,
2473 { "E: Cipher Request", "bssap.e_bit",
2474 FT_BOOLEAN, 8, TFS(&bssap_E_flag), 0x04,
2475 NULL, HFILL }},
2477 { &hf_bssap_tunnel_prio,
2478 { "Tunnel Priority", "bssap.tunnel_prio",
2479 FT_UINT8, BASE_DEC, NULL, 0x0,
2480 NULL, HFILL}},
2482 { &hf_bssap_global_cn_id,
2483 { "Global CN-Id", "bssap.global_cn_id",
2484 FT_BYTES, BASE_NONE, NULL, 0x0,
2485 NULL, HFILL}},
2487 { &hf_bssap_plmn_id,
2488 { "PLMN-Id", "bssap.plmn_id",
2489 FT_BYTES, BASE_NONE, NULL, 0x0,
2490 NULL, HFILL}},
2492 { &hf_bssap_cn_id,
2493 { "CN-Id", "bssap.cn_id",
2494 FT_UINT16, BASE_DEC, NULL, 0x0,
2495 NULL, HFILL}},
2497 { &hf_bssap_cell_global_id,
2498 { "Cell global identity", "bssap.cell_global_id",
2499 FT_BYTES, BASE_NONE, NULL, 0x0,
2500 NULL, HFILL}},
2502 { &hf_bssap_extraneous_data,
2503 { "Extraneous data", "bssap.extraneous_data",
2504 FT_BYTES, BASE_NONE, NULL, 0x0,
2505 NULL, HFILL}},
2507 { &hf_bssap_conditional_ie,
2508 { "Conditional IE", "bssap.conditional_ie",
2509 FT_BYTES, BASE_NONE, NULL, 0x0,
2510 NULL, HFILL}},
2513 /* Setup protocol subtree array */
2514 static int *ett[] = {
2515 &ett_bssap,
2516 &ett_bssap_dlci,
2517 &ett_bssap_imsi,
2518 &ett_bssap_imsi_det_from_gprs_serv_type,
2519 &ett_bssap_imsi_det_from_non_gprs_serv_type,
2520 &ett_bssap_info_req,
2521 &ett_bssap_loc_area_id,
2522 &ett_bssap_loc_inf_age,
2523 &ett_bssap_mm_information,
2524 &ett_bssap_mobile_id,
2525 &ett_bssap_sgsn_nr,
2526 &ett_bssap_tmsi,
2527 &ett_bssap_tmsi_status,
2528 &ett_bssap_vlr_number,
2529 &ett_bssap_global_cn,
2530 &ett_bssap_gprs_loc_upd,
2531 &ett_bassp_Gs_cause,
2532 &ett_bassp_imei,
2533 &ett_bassp_imeisv,
2534 &ett_bssap_cell_global_id,
2535 &ett_bssap_cgi,
2536 &ett_bssap_channel_needed,
2537 &ett_bssap_dlink_tnl_pld_cntrl_amd_inf,
2538 &ett_bssap_ulink_tnl_pld_cntrl_amd_inf,
2539 &ett_bssap_emlpp_prio,
2540 &ett_bssap_erroneous_msg,
2541 &ett_bssap_mobile_stn_cls_mrk1,
2542 &ett_bssap_mobile_station_state,
2543 &ett_bssap_ptmsi,
2544 &ett_bssap_reject_cause,
2545 &ett_bssap_service_area_id,
2546 &ett_bssap_global_cn_id,
2547 &ett_bssap_plmn,
2550 static const enum_val_t default_protocol_options[] = {
2551 { "bssap", "BSSAP (GSM A-I/F)", BSSAP },
2552 { "bsap", "BSAP (CDMA2000 A-I/F)", BSAP },
2553 { "bssap_le", "BSSAP-LE (GSM Lb-I/F)", BSSAP_LE },
2554 { NULL, NULL, 0 }
2557 static ei_register_info ei[] = {
2558 { &ei_bssap_unknown_message, { "bssap.unknown_message", PI_PROTOCOL, PI_WARN, "Unknown message", EXPFILL }},
2559 { &ei_bssap_unknown_parameter, { "bssap.unknown_parameter", PI_PROTOCOL, PI_WARN, "Unknown parameter", EXPFILL }},
2560 { &ei_bssap_mandatory_ie, { "bssap.mandatory_ie", PI_PROTOCOL, PI_WARN, "Mandatory IE expected", EXPFILL }},
2563 /* Register the protocol name and description */
2564 proto_bssap = proto_register_protocol("BSSAP", "BSSAP", "bssap");
2565 proto_bssap_plus = proto_register_protocol("BSSAP2", "BSSAP2", "bssap_plus");
2566 proto_bsap = proto_register_protocol_in_name_only("BSAP", "BSAP", "bsap", proto_bssap, FT_PROTOCOL);
2567 proto_bssap_le = proto_register_protocol_in_name_only("BSSAP-LE", "BSSAP-LE", "bssap_le", proto_bssap, FT_PROTOCOL);
2569 bssap_handle = register_dissector("bssap", dissect_bssap, proto_bssap);
2570 bsap_handle = register_dissector("bsap", dissect_bsap, proto_bsap);
2571 bssap_le_handle = register_dissector("bssap_le", dissect_bssap_le, proto_bssap_le);
2572 register_dissector("bssap.imei", dissect_bssap_imei_dissector, proto_bssap);
2573 bssap_plus_handle = register_dissector("bssap_plus", dissect_bssap_plus, proto_bssap_plus);
2575 /* Required function calls to register the header fields and subtrees used */
2576 proto_register_field_array(proto_bssap, hf, array_length(hf));
2577 proto_register_subtree_array(ett, array_length(ett));
2578 expert_bssap = expert_register_protocol(proto_bssap);
2579 expert_register_field_array(expert_bssap, ei, array_length(ei));
2581 bssap_module = prefs_register_protocol(proto_bssap, NULL);
2583 prefs_register_obsolete_preference(bssap_module, "bsap_or_bssap");
2584 prefs_register_obsolete_preference(bssap_module, "gsm_or_lb_interface");
2586 prefs_register_enum_preference(bssap_module,
2587 "default_protocol",
2588 "Default protocol",
2589 "The default protocol assumed by the heuristic dissector,"
2590 "which does not easily distinguish between BSSAP "
2591 "(on the GSM A interface between the BSC and the MSC), "
2592 "BSSAP-LE (on the GSM Lb interface between the BSC and the SMLC), "
2593 "and BSAP (on the CDMA2000 A interface between the BS and MSC).",
2594 &default_protocol_global,
2595 default_protocol_options,
2596 false);
2598 /* No explicit preferences anymore, but it does have an automatic Decode As
2599 * preference, so we don't register the module itself obsolete */
2600 bssap_plus_module = prefs_register_protocol(proto_bssap_plus, NULL);
2601 prefs_register_obsolete_preference(bssap_plus_module, "ssn");
2603 bssap_dissector_table = register_dissector_table("bssap.pdu_type", "BSSAP Message Type", proto_bssap, FT_UINT8, BASE_DEC);
2604 bsap_dissector_table = register_dissector_table("bsap.pdu_type", "BSAP Message Type", proto_bssap, FT_UINT8, BASE_DEC);
2605 bssap_le_dissector_table = register_dissector_table("bssap_le.pdu_type", "BSSAP Message Type", proto_bssap, FT_UINT8, BASE_DEC);
2608 void
2609 proto_reg_handoff_bssap(void)
2612 heur_dissector_add("sccp", dissect_bssap_heur, "BSSAP over SCCP", "bssap_sccp", proto_bssap, HEURISTIC_ENABLE);
2613 heur_dissector_add("sua", dissect_bssap_heur, "BSSAP over SUA", "bssap_sua", proto_bssap, HEURISTIC_ENABLE);
2614 /* BSSAP+ */
2616 rrlp_handle = find_dissector_add_dependency("rrlp", proto_bssap_plus);
2617 gsm_bssmap_le_dissector_handle = find_dissector_add_dependency("gsm_bssmap_le", proto_bssap);
2618 gsm_a_bssmap_dissector_handle = find_dissector_add_dependency("gsm_a_bssmap", proto_bssap);
2620 dissector_add_for_decode_as("sccp.ssn", bssap_handle);
2621 dissector_add_for_decode_as("sccp.ssn", bsap_handle);
2622 dissector_add_for_decode_as("sccp.ssn", bssap_le_handle);
2623 dissector_add_uint_with_preference("sccp.ssn", BSSAP_PLUS_SSN, bssap_plus_handle);
2627 * Editor modelines - https://www.wireshark.org/tools/modelines.html
2629 * Local variables:
2630 * c-basic-offset: 4
2631 * tab-width: 8
2632 * indent-tabs-mode: nil
2633 * End:
2635 * vi: set shiftwidth=4 tabstop=8 expandtab:
2636 * :indentSize=4:tabSize=8:noTabs=true: