epan/dissectors/pidl/ C99 drsuapi
[wireshark-sm.git] / epan / dissectors / packet-sgsap.c
blobec07d68083f3499168f093db35aa963f1006a18b
1 /* packet-sgsap.c
2 * Routines for SGs Application Part (SGsAP) protocol dissection
4 * Copyright 2010 - 2017, Anders Broman <anders.broman@ericsson.com>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
12 * References: 3GPP TS 29.118 V10.2.0 (2010-12)
15 #include "config.h"
17 #include <epan/packet.h>
18 #include <epan/tfs.h>
19 #include <epan/expert.h>
20 #include <epan/exceptions.h>
21 #include <epan/show_exception.h>
23 #include <wsutil/array.h>
24 #include "packet-gsm_a_common.h"
25 #include "packet-e212.h"
27 #define PNAME "SGs Application Part (SGsAP)"
28 #define PSNAME "SGSAP"
29 #define PFNAME "sgsap"
32 void proto_register_sgsap(void);
33 void proto_reg_handoff_sgsap(void);
35 /* Global variables */
36 static dissector_handle_t gsm_a_dtap_handle;
38 /* The registered SCTP port number for SGsAP is 29118.
39 * The payload protocol identifier to be used for SGsAP is 0.
41 #define SGSAP_SCTP_PORT_RANGE "29118"
43 /* Initialize the protocol and registered fields */
44 static int proto_sgsap;
46 static int hf_sgsap_msg_type;
47 int hf_sgsap_elem_id;
48 static int hf_sgsap_eps_location_update_type;
49 static int hf_sgsap_service_indicator_value;
50 static int hf_sgsap_sgs_cause;
51 static int hf_sgsap_ue_emm_mode;
52 static int hf_sgsap_eci;
53 static int hf_sgsap_cn_id;
54 static int hf_sgsap_imsi_det_eps;
55 static int hf_sgsap_imsi_det_non_eps;
56 static int hf_sgsap_lcs_indic;
57 static int hf_sgsap_mme_name;
58 static int hf_sgsap_vlr_name;
59 static int hf_sgsap_imeisv;
60 static int hf_sgsap_unknown_msg;
61 static int hf_sgsap_message_elements;
62 static int hf_sgsap_csri;
63 static int hf_sgsap_sel_cs_dmn_op;
65 static int ett_sgsap;
66 static int ett_sgsap_sel_cs_dmn_op;
68 static expert_field ei_sgsap_extraneous_data;
69 static expert_field ei_sgsap_missing_mandatory_element;
71 static dissector_handle_t sgsap_handle;
73 static void get_sgsap_msg_params(uint8_t oct, const char **msg_str, int *ett_tree, int *hf_idx, msg_fcn *msg_fcn_p);
76 * 9.4 Information elements
79 * 9.4.1 CLI
83 * Octets 3 to 14 contain the value part of the Calling party BCD number information element
84 * defined in subclause 10.5.4.9 of 3GPP TS 24.008 [8] (octets 3 to 14, i.e. not including
85 * 3GPP TS 24.008 IEI and 3GPP TS 24.008 length indicator)
86 * ( packet-gsm_a_dtap.c )
89 * 9.4.2 EPS location update type
92 /* EPS location update type value (octet 3) */
93 static const value_string sgsap_eps_location_update_type_values[] = {
94 { 0x00, "Shall not be sent in this version of the protocol" },
95 { 0x01, "IMSI attach" },
96 { 0x02, "Normal location update" },
97 { 0, NULL }
100 static uint16_t
101 de_sgsap_eps_loc_upd_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len _U_, char *add_string _U_, int string_len _U_)
103 uint32_t curr_offset;
104 uint8_t oct;
106 curr_offset = offset;
108 /* Octet 3 EPS location update type value */
109 proto_tree_add_item(tree, hf_sgsap_eps_location_update_type, tvb, offset, 1, ENC_BIG_ENDIAN);
110 if (add_string) {
111 oct = tvb_get_uint8(tvb, curr_offset);
112 snprintf(add_string, string_len, " - %s", val_to_str_const(oct, sgsap_eps_location_update_type_values, "Reserved"));
115 curr_offset++;
117 return curr_offset - offset;
120 * 9.4.3 Erroneous message
122 * See subclause 18.4.5 in 3GPP TS 29.018 [16].
124 static uint16_t
125 de_sgsap_err_msg(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, uint32_t offset, unsigned len, char *add_string , int string_len)
127 const char *msg_str;
128 int ett_tree;
129 int hf_idx;
130 void(*msg_fcn_p)(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, uint32_t offset, unsigned len);
131 uint8_t oct;
133 /* 18.4.5 Erroneous message
134 * The Erroneous message IE is a TLV IE that encapsulates the message in error.
135 * Octet 3 - Octet n
136 * Erroneous message including the message type.
138 /* Message type IE*/
139 oct = tvb_get_uint8(tvb, offset);
140 msg_fcn_p = NULL;
141 ett_tree = -1;
142 hf_idx = -1;
143 msg_str = NULL;
145 proto_tree_add_item(tree, hf_sgsap_msg_type, tvb, offset, 1, ENC_BIG_ENDIAN);
147 get_sgsap_msg_params(oct, &msg_str, &ett_tree, &hf_idx, &msg_fcn_p);
148 if (msg_str) {
149 if (add_string)
150 snprintf(add_string, string_len, " - %s", msg_str);
153 if (msg_fcn_p){
154 volatile uint32_t curr_offset = offset + 1;
155 TRY {
156 /*let's try to decode erroneous message and catch exceptions as it could be malformed */
157 (*msg_fcn_p)(tvb, tree, pinfo, curr_offset, len - 1);
158 } CATCH_BOUNDS_ERRORS {
159 show_exception(tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
160 } ENDTRY
164 return len;
167 * 9.4.3a E-UTRAN Cell Global Identity
169 * The coding of the E-UTRAN Cell Global Identity value is according to ECGI field information element
170 * as specified in subclause 8.21.5 of 3GPP TS 29.274 [17A] (GTPv2-C)
172 uint16_t
173 de_sgsap_ecgi(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, uint32_t offset, unsigned len _U_, char *add_string _U_, int string_len _U_)
175 uint32_t curr_offset;
177 curr_offset = offset;
179 dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, E212_ECGI, true);
180 curr_offset += 3;
182 proto_tree_add_item(tree, hf_sgsap_eci, tvb, curr_offset, 4, ENC_BIG_ENDIAN);
183 curr_offset += 4;
185 return curr_offset-offset;
188 * 9.4.4 Global CN-Id
190 * See subclause 18.4.27 in 3GPP TS 29.018 [16].
191 * 18.4.27 Global CN-Id
192 * The Global CN-Id consists of a PLMN-Id and a CN-Id, see 3GPP TS 23.003. The PLMN-Id consists of MCC and MNC
193 * coded according to Location Area Identification in 3GPP TS 24.008. The CN-Id is an integer defined by O&M. The
194 * least significant bit of the CN-Id field is bit 1 of octet 7 and the most significant bit is bit 8 of octet 6. If the CN-Id does
195 * not fill the field reserved for it, the rest of the bits are set to '0'.
197 static uint16_t
198 de_sgsap_g_cn_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, uint32_t offset, unsigned len _U_, char *add_string _U_, int string_len _U_)
200 uint32_t curr_offset;
202 curr_offset = offset;
204 dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, E212_NONE, true);
205 curr_offset += 3;
207 proto_tree_add_item(tree, hf_sgsap_cn_id, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
208 curr_offset += 2;
210 return curr_offset-offset;
213 * 9.4.5 IMEISV
214 * See subclause 18.4.9 in 3GPP TS 29.018 [16].
215 * The IMEISV is coded as a sequence of BCD digits, compressed two into each octet.
216 * The IMEISV consists of 16 digits
217 * (see 3GPP TS 23.003).
219 static uint16_t
220 de_sgsap_imeisv(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len _U_, char *add_string _U_, int string_len _U_)
222 char *imeisv_str;
223 uint32_t curr_offset;
225 curr_offset = offset;
227 proto_tree_add_item_ret_display_string(tree, hf_sgsap_imeisv, tvb, curr_offset, len, ENC_BCD_DIGITS_0_9|ENC_LITTLE_ENDIAN, pinfo->pool, &imeisv_str);
228 if (add_string) {
229 /* (len<<2)+4 = the maximum number of bytes to produce (including the terminating nul character). */
230 snprintf(add_string, (len<<2)+4, " - %s", imeisv_str);
233 return len;
237 * 9.4.6 IMSI
238 * See subclause 18.4.10 in 3GPP TS 29.018 [16].
240 /* The IMSI is coded as a sequence of BCD digits, compressed two into each octet.
241 * This is a variable length element, and includes a length indicator.
242 * The IMSI is defined in 3GPP TS 23.003. It shall not exceed 15 digits (see 3GPP TS 23.003).
245 * 9.4.7 IMSI detach from EPS service type
248 /* IMSI detach from EPS service type value (octet 3) */
249 static const value_string sgsap_imsi_det_from_eps_serv_type_values[] = {
250 { 0x00, "Interpreted as reserved in this version of the protocol" },
251 { 0x01, "Network initiated IMSI detach from EPS services" },
252 { 0x02, "UE initiated IMSI detach from EPS services" },
253 { 0x03, "EPS services not allowed" },
254 { 0, NULL }
257 static uint16_t
258 de_sgsap_imsi_det_eps(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len _U_, char *add_string _U_, int string_len _U_)
260 uint32_t curr_offset;
262 curr_offset = offset;
264 proto_tree_add_item(tree, hf_sgsap_imsi_det_eps, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
265 curr_offset += 1;
267 return curr_offset-offset;
270 * 9.4.8 IMSI detach from non-EPS service type
272 /* IMSI detach from non-EPS service type value (octet 3)*/
273 static const value_string sgsap_imsi_det_from_non_eps_serv_type_values[] = {
274 { 0x00, "Interpreted as reserved in this version of the protocol" },
275 { 0x01, "Explicit UE initiated IMSI detach from non-EPS services" },
276 { 0x02, "Combined UE initiated IMSI detach from EPS and non-EPS services" },
277 { 0x03, "Implicit network initiated IMSI detach from non-EPS services" },
278 { 0, NULL }
281 static uint16_t
282 de_sgsap_imsi_det_non_eps(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len _U_, char *add_string _U_, int string_len _U_)
284 uint32_t curr_offset;
286 curr_offset = offset;
288 proto_tree_add_item(tree, hf_sgsap_imsi_det_non_eps, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
289 curr_offset += 1;
291 return curr_offset-offset;
294 * 9.4.9 LCS client identity
295 * The coding of the LCS client identity value is according to LCS-ClientID
296 * as specified in subclause 17.7.13 of 3GPP TS 29.002 [15]
297 * (packet-nas_eps.c)
300 * 9.4.10 LCS indicator
302 static const value_string sgsap_lcs_indic_values[] = {
303 { 0x00, "Normal, unspecified in this version of the protocol" },
304 { 0x01, "MT-LR" },
305 { 0, NULL }
308 static uint16_t
309 de_sgsap_lcs_indic(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len _U_, char *add_string _U_, int string_len _U_)
311 uint32_t curr_offset;
313 curr_offset = offset;
315 proto_tree_add_item(tree, hf_sgsap_lcs_indic, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
316 curr_offset += 1;
318 return curr_offset-offset;
321 * 9.4.11 Location area identifier
323 * Octets 3 to 7 contain the value part of the Location area identification information element
324 * defined in 3GPP TS 24.008 [8] (starting with octet 2, i.e. not including 3GPP TS 24.008 IEI)
325 *(packet-gsm_a_common.c)
328 * 9.4.12 MM information
329 * For the coding see subclause 18.4.16 in 3GPP TS 29.018 [16].
330 * User information: This field is composed of one or more of the
331 * information elements of the MM information message as defined in
332 * 3GPP TS 24.008, excluding the Protocol discriminator, Skip
333 * indicator and Message type. This field includes the IEI and length
334 * indicatior of the other information elements.
336 static uint16_t
337 de_sgsap_mm_info(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len, char *add_string _U_, int string_len _U_)
339 uint32_t curr_offset;
341 curr_offset = offset;
343 dtap_mm_mm_info(tvb, tree, pinfo, curr_offset, len);
345 return len;
349 * 9.4.13 MME name
351 static uint16_t
352 de_sgsap_mme_name(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len _U_, char *add_string _U_, int string_len _U_)
354 unsigned name_len;
355 uint8_t *fqdn = NULL;
357 /* The MME name information element specifies the MME name and is coded as shown in figure 9.4.13.1. Octets 3
358 * through n contain the name in the form of a fully qualified domain name (FQDN) as specified in 3GPP TS 23.003 [3].
359 * The value part of the MME name information element (not including IEI and length indicator) shall have a length of 55
360 * octets.
362 if (len > 0) {
363 name_len = tvb_get_uint8(tvb, offset);
365 if (name_len < 0x20) {
366 fqdn = tvb_get_string_enc(pinfo->pool, tvb, offset, len, ENC_APN_STR);
367 } else{
368 fqdn = tvb_get_string_enc(pinfo->pool, tvb, offset, len, ENC_ASCII);
370 proto_tree_add_string(tree, hf_sgsap_mme_name, tvb, offset, len, fqdn);
371 if (add_string)
372 snprintf(add_string, string_len, " - %s", fqdn);
376 return len;
379 * 9.4.14 Mobile identity
380 * See subclause 18.4.17 in 3GPP TS 29.018 [16].
381 * (packet-gsm_a_common.c)
384 * 9.4.14a Mobile Station Classmark 2
385 * With the exception of the IEI, the contents are specified in subclause 10.5.1.6 in 3GPP TS 24.008 [8].
386 * (packet-gsm_a_common.c)
389 * 9.4.15 NAS message container
390 * Octets 3 to 253 contain the SMS message (i.e. CP DATA, CP ACK or CP ERROR)
391 * as defined in subclause 7.2 of 3GPP TS 24.011 [10]
393 static uint16_t
394 de_sgsap_nas_msg_container(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, uint32_t offset, unsigned len, char *add_string _U_, int string_len _U_)
396 tvbuff_t *new_tvb;
397 uint32_t curr_offset;
399 curr_offset = offset;
401 /* Octets 3 to 253 contain the SMS message (i.e. CP DATA, CP ACK or CP ERROR)
402 * as defined in subclause 7.2 of 3GPP TS 24.011 [10]
404 new_tvb = tvb_new_subset_length(tvb, curr_offset, len);
405 if (gsm_a_dtap_handle) {
406 call_dissector(gsm_a_dtap_handle, new_tvb, pinfo, tree);
409 return len;
412 * 9.4.16 Reject cause
413 * See subclause 18.4.21 in 3GPP TS 29.018 [16].
414 * The rest of the information element is coded as the value part of
415 * the reject cause IE defined in 3GPP TS 24.008, not including
416 * 3GPP TS 24.008 IEI.
417 * (packet-gsm_a_dtap.c)
420 * 9.4.17 Service indicator
423 /* Octet 3 Service indicator value */
424 static const value_string sgsap_service_indicator_values[] = {
425 { 0x00, "Shall not be sent in this version of the protocol" },
426 { 0x01, "CS call indicator" },
427 { 0x02, "SMS indicator" },
428 { 0, NULL }
431 static uint16_t
432 de_sgsap_serv_indic(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len _U_, char *add_string _U_, int string_len _U_)
434 uint32_t curr_offset;
435 uint8_t oct;
437 curr_offset = offset;
439 /* Octet 3 Service indicator value */
440 proto_tree_add_item(tree, hf_sgsap_service_indicator_value, tvb, offset, 1, ENC_BIG_ENDIAN);
441 if (add_string) {
442 oct = tvb_get_uint8(tvb, curr_offset);
443 snprintf(add_string, string_len, " - %s", val_to_str_const(oct, sgsap_service_indicator_values, "Reserved"));
445 curr_offset++;
447 return curr_offset-offset;
450 * 9.4.18 SGs cause
453 /* SGs cause value (octet 3) */
454 static const value_string sgsap_sgs_cause_values[] = {
455 { 0x00, "Normal, unspecified in this version of the protocol" },
456 { 0x01, "IMSI detached for EPS services" },
457 { 0x02, "IMSI detached for EPS and non-EPS services" },
458 { 0x03, "IMSI unknown" },
459 { 0x04, "IMSI detached for non-EPS services" },
460 { 0x05, "IMSI implicitly detached for non-EPS services" },
461 { 0x06, "UE unreachable" },
462 { 0x07, "Message not compatible with the protocol state" },
463 { 0x08, "Missing mandatory information element" },
464 { 0x09, "Invalid mandatory information" },
465 { 0x0a, "Conditional information element error" },
466 { 0x0b, "Semantically incorrect message" },
467 { 0x0c, "Message unknown" },
468 { 0x0d, "Mobile terminating CS fallback call rejected by the user" },
469 { 0x0e, "UE temporarily unreachable" },
470 { 0, NULL }
473 static value_string_ext sgsap_sgs_cause_values_ext = VALUE_STRING_EXT_INIT(sgsap_sgs_cause_values);
475 static uint16_t
476 de_sgsap_sgs_cause(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len _U_, char *add_string _U_, int string_len _U_)
478 uint32_t curr_offset;
479 uint8_t oct;
481 curr_offset = offset;
483 proto_tree_add_item(tree, hf_sgsap_sgs_cause, tvb, offset, 1, ENC_BIG_ENDIAN);
484 if (add_string) {
485 oct = tvb_get_uint8(tvb, curr_offset);
486 snprintf(add_string, string_len, " - %s", val_to_str_ext_const(oct, &sgsap_sgs_cause_values_ext, "Reserved"));
488 curr_offset++;
490 return curr_offset-offset;
493 * 9.4.19 SS code
494 * The coding of the SS code value is according to SS-Code as specified in
495 * subclause 17.7.5 of 3GPP TS 29.002 [15]
496 * ( packet-nas_eps.c)
499 * 9.4.20 TMSI
500 * See subclause 18.4.23 in 3GPP TS 29.018 [16].
501 * (packet-gsm_a_bssmap.c)
505 * 9.4.21 TMSI status
507 * See subclause 18.4.24 in 3GPP TS 29.018 [16].
508 * (packet-gsm_a_gm.c)
511 * 9.4.21a Tracking Area Identity
512 * Octets 3 to 7 contain the value part of the Tracking Area Identity information element defined in 3GPP TS 24.301 [14]
513 * (starting with octet 2, i.e. not including 3GPP TS 24.301 IEI)
514 * (packet-nas_eps.c)
517 * 9.4.21b UE Time Zone
518 * The coding of the UE Time Zone value is according to value part of the Time Zone information element as specified
519 * in subclause 10.5.3.8 of 3GPP TS 24.008 [8] (i.e. not including 3GPP TS 24.008 IEI)
520 * (packet-gsm_a_dtap.c)
523 * 9.4.21c UE EMM mode
525 static const value_string sgsap_ue_emm_mode_values[] = {
526 { 0x00, "EMM-IDLE" },
527 { 0x01, "EMM-CONNECTED" },
528 { 0, NULL }
531 static uint16_t
532 de_sgsap_ue_emm_mode(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len _U_, char *add_string _U_, int string_len _U_)
534 uint32_t curr_offset;
536 curr_offset = offset;
538 proto_tree_add_item(tree, hf_sgsap_ue_emm_mode, tvb, offset, 1, ENC_BIG_ENDIAN);
539 curr_offset += 1;
541 return curr_offset-offset;
544 * 9.4.22 VLR name
546 static uint16_t
547 de_sgsap_vlr_name(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len _U_, char *add_string _U_, int string_len _U_)
549 unsigned name_len;
550 uint8_t *fqdn = NULL;
552 /* The VLR name information element specifies the VLR name and is coded as shown in figure 9.4.22.1.
553 * Octets 3 through n contain the VLR name in the form of a fully qualified domain name (FQDN)
554 * as specified in IETF RFC 1035 [21].
556 if (len > 0) {
557 name_len = tvb_get_uint8(tvb, offset);
559 if (name_len < 0x20) {
560 fqdn = tvb_get_string_enc(pinfo->pool, tvb, offset, len, ENC_APN_STR);
561 } else{
562 fqdn = tvb_get_string_enc(pinfo->pool, tvb, offset, len, ENC_ASCII);
564 proto_tree_add_string(tree, hf_sgsap_vlr_name, tvb, offset, len, fqdn);
565 if (add_string)
566 snprintf(add_string, string_len, " - %s", fqdn);
569 return len;
573 * 9.4.23 Channel needed
574 * See subclause 18.4.2 in 3GPP TS 29.018 [16].
575 * The rest of the information element is coded as the IEI part and the
576 * value part of the Channel Needed IE defined in 3GPP TS 44.018
577 * (packet-gsm_a_bssmap.c)
580 * 9.4.24 eMLPP priority
581 * See subclause 18.4.4 in 3GPP TS 29.018 [16].
582 * The rest of the information element is coded as the value part of
583 * the eMLPP-Priority IE defined in 3GPP TS 48.008 (not including
584 * 3GPP TS 48.008 IEI and 3GPP TS 48.008 length indicator).
585 * (packet-gsm_a_bssmap.c)
591 static uint16_t
592 de_sgsap_add_paging_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len _U_, char *add_string _U_, int string_len _U_)
594 /* Octet 3 0 0 0 0 0 0 0 CSRI */
595 proto_tree_add_item(tree, hf_sgsap_csri, tvb, offset, 1, ENC_BIG_ENDIAN);
597 return len;
600 #if 0
601 Reuse GSM_A_PDU_TYPE_GM, DE_NET_RES_ID_CONT
603 * 9.4.26 TMSI based NRI container
605 static uint16_t
606 de_sgsap_tmsi_based_nri_cont(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len _U_, char *add_string _U_, int string_len _U_)
609 /* See subclause 18.4.28 in 3GPP TS 29.018 [16].
610 * Which says The TMSI based NRI container value value consists of 10 bits which correspond to bits 23 to 14 of the valid TMSI
611 * (3GPP TS 23.236 and
612 * Octet 3 and Octet 4 The rest of the information element is coded as the value part of the Network resource identifier container IE
613 * defined in 3GPP TS 24.008.
615 return len;
617 #endif
619 * 9.4.27 Selected CS domain operator
621 static uint16_t
622 de_sgsap_selected_cs_dmn_op(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len _U_, char *add_string _U_, int string_len _U_)
624 proto_item *item;
625 proto_tree *sub_tree;
626 /* Coded as octets 2 to 4 of the Location Area Identification IE,
627 * defined in 3GPP TS 24.008 [8] (not including 3GPP TS 24.008 IEI
628 * and LAC).(10.5.1.3 Location Area Identification)
629 * MCC digit 2 MCC digit 1 octet 2
630 * MNC digit 3 MCC digit 3 octet 3
631 * MNC digit 2 MNC digit 1 octet 4
633 item = proto_tree_add_item(tree, hf_sgsap_sel_cs_dmn_op, tvb, offset, 1, ENC_NA);
634 sub_tree = proto_item_add_subtree(item, ett_sgsap_sel_cs_dmn_op);
636 dissect_e212_mcc_mnc_wmem_packet_str(tvb, pinfo, sub_tree, offset, E212_LAI, true);
638 return len;
641 static const value_string sgsap_elem_strings[] = {
642 { DE_SGSAP_IMSI, "IMSI" }, /* 9.4.6 */
643 { DE_SGSAP_VLR_NAME, "VLR name" }, /* 9.4.22 */
644 { DE_SGSAP_TMSI, "TMSI" }, /* 9.4.20 */
645 { DE_SGSAP_LOC_AREA_ID, "Location area identifier" }, /* 9.4.11 */
646 { DE_SGSAP_CH_NEEDED, "Channel Needed" }, /* 9.4.23 */
647 { DE_SGSAP_EMLPP_PRIO, "eMLPP Priority" }, /* 9.4.24 */
648 { DE_SGSAP_TMSI_STATUS, "TMSI status" }, /* 9.4.21 */
649 { DE_SGSAP_SGS_CAUSE, "SGs cause" }, /* 9.4.18 */
650 { DE_SGSAP_MME_NAME, "MME name" }, /* 9.4.13 */
651 { DE_SGSAP_EPS_LOC_UPD_TYPE, "EPS location update type" }, /* 9.4.2 */
652 { DE_SGSAP_GLOBAL_CN_ID, "Global CN-Id" }, /* 9.4.4 */
654 { DE_SGSAP_UDEF_11, "Undefined" }, /* */
655 { DE_SGSAP_UDEF_12, "Undefined" }, /* */
657 { DE_SGSAP_MID, "Mobile identity" }, /* 9.4.14 */
658 { DE_SGSAP_REJ_CAUSE, "Reject cause" }, /* 9.4.16 */
659 { DE_SGSAP_IMSI_DET_EPS, "IMSI detach from EPS service type" }, /* 9.4.7 */
660 { DE_SGSAP_IMSI_DET_NON_EPS, "IMSI detach from non-EPS service type" }, /* 9.4.8 */
662 { DE_SGSAP_IMEISV, "IMEISV" }, /* 9.4.5 */
663 { DE_SGSAP_NAS_MSG_CONTAINER, "NAS message container" }, /* 9.4.15 */
664 { DE_SGSAP_MM_INFO, "MM information" }, /* 9.4.12 */
666 { DE_SGSAP_UDEF_20, "Undefined" }, /* */
667 { DE_SGSAP_UDEF_21, "Undefined" }, /* */
668 { DE_SGSAP_UDEF_22, "Undefined" }, /* */
670 { DE_SGSAP_ERR_MSG, "Erroneous message" }, /* 9.4.3 */
671 { DE_SGSAP_CLI, "CLI" }, /* 9.4.1 */
672 { DE_SGSAP_LCS_CLIENT_ID, "LCS client identity" }, /* 9.4.9 */
673 { DE_SGSAP_LCS_INDIC, "LCS indicator" }, /* 9.4.10 */
674 { DE_SGSAP_SS_CODE, "SS code" }, /* 9.4.19 */
675 { DE_SGSAP_SERV_INDIC, "Service indicator" }, /* 9.4.17 */
676 { DE_SGSAP_UE_TZ, "UE Time Zone" }, /* 9.4.21b */
677 { DE_SGSAP_MSC_2, "Mobile Station Classmark 2" }, /* 9.4.14a */
678 { DE_SGSAP_TAID, "Tracking Area Identity" }, /* 9.4.21a */
679 { DE_SGSAP_ECGI, "E-UTRAN Cell Global Identity" }, /* 9.4.3a */
680 { DE_SGSAP_UE_EMM_MODE, "UE EMM mode" }, /* 9.4.21c */
681 { DE_SGSAP_ADD_PAGING_IND, "Additional paging indicators" }, /* 9.4.25 */
682 { DE_SGSAP_TMSI_BASED_NRI_CONT, "TMSI based NRI container" }, /* 9.4.26 */
683 { DE_SGSAP_SELECTED_CS_DMN_OP, "Selected CS domain operator" }, /* 9.4.27 */
684 { 0, NULL }
686 value_string_ext sgsap_elem_strings_ext = VALUE_STRING_EXT_INIT(sgsap_elem_strings);
688 #define NUM_SGSAP_ELEM array_length(sgsap_elem_strings)
689 int ett_sgsap_elem[NUM_SGSAP_ELEM];
690 #if 0
691 This enum has been moved to packet-gsm_a_common to
692 make it possible to use element dissecton from this dissector
693 in other dissectors.
694 It is left here as a comment for easier reference.
696 Note this enum must be of the same size as the element decoding list
698 typedef enum
701 DE_SGSAP_IMSI, /. 9.4.6 IMSI./
702 DE_SGSAP_VLR_NAME, /. 9.4.22 VLR name./
703 DE_SGSAP_TMSI, /. 9.4.20 TMSI ./
704 DE_SGSAP_LOC_AREA_ID, /. 9.4.11 Location area identifier ./
705 DE_SGSAP_CH_NEEDED, /. 9.4.23 Channel Needed ./
706 DE_SGSAP_EMLPP_PRIO, /. 9.4.24 eMLPP Priority./
707 DE_SGSAP_TMSI_STATUS, /. 9.4.21 TMSI status ./
708 DE_SGSAP_SGS_CAUSE, /. 9.4.18 SGs cause./
709 DE_SGSAP_MME_NAME, /. 9.4.13 MME name./
710 DE_SGSAP_EPS_LOC_UPD_TYPE, /. 9.4.2 EPS location update type./
711 DE_SGSAP_GLOBAL_CN_ID, /. 9.4.4 Global CN-Id./
713 DE_SGSAP_UDEF_11, /. Undefined ./
714 DE_SGSAP_UDEF_12, /. Undefined ./
716 DE_SGSAP_MID, /. 9.4.14 Mobile identity./
717 DE_SGSAP_REJ_CAUSE, /. 9.4.16 Reject cause ./
718 DE_SGSAP_IMSI_DET_EPS, /. 9.4.7 IMSI detach from EPS service type ./
719 DE_SGSAP_IMSI_DET_NON_EPS, /. 9.4.8 IMSI detach from non-EPS service type ./
721 DE_SGSAP_IMEISV, /. 9.4.5 IMEISV ./
722 DE_SGSAP_NAS_MSG_CONTAINER, /. 9.4.15 NAS message container./
723 DE_SGSAP_MM_INFO, /. 9.4.12 MM information./
725 DE_SGSAP_UDEF_20, /. Undefined ./
726 DE_SGSAP_UDEF_21, /. Undefined ./
727 DE_SGSAP_UDEF_22, /. Undefined ./
729 DE_SGSAP_ERR_MSG, /. 9.4.3 Erroneous message./
730 DE_SGSAP_CLI, /. 9.4.1 CLI ./
731 DE_SGSAP_LCS_CLIENT_ID, /. 9.4.9 LCS client identity ./
732 DE_SGSAP_LCS_INDIC, /. 9.4.10 LCS indicator ./
733 DE_SGSAP_SS_CODE, /. 9.4.19 SS code ./
734 DE_SGSAP_SERV_INDIC, /. 9.4.17 Service indicator ./
735 DE_SGSAP_UE_TZ, /. 9.4.21b UE Time Zone ./
736 DE_SGSAP_MSC_2, /. 9.4.14a Mobile Station Classmark 2 ./
737 DE_SGSAP_TAID, /. 9.4.21a Tracking Area Identity ./
738 DE_SGSAP_ECGI, /. 9.4.3a E-UTRAN Cell Global Identity ./
739 DE_SGSAP_UE_EMM_MODE, /. 9.4.21c UE EMM mode./
740 DE_SGSAP_ADD_PAGING_IND, /. 9.4.25 Additional paging indicators ./
741 DE_SGSAP_TMSI_BASED_NRI_CONT, /. 9.4.26 TMSI based NRI container ./
742 DE_SGSAP_SELECTED_CS_DMN_OP, /. 9.4.27 Selected CS domain operator ./
744 DE_SGAP_NONE /. NONE ./
746 sgsap_elem_idx_t;
747 #endif /* 0 */
749 uint16_t (*sgsap_elem_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len, char *add_string, int string_len) = {
750 NULL/*DE_SGSAP_IMSI*/, /* 9.4.6 IMSI*/
751 de_sgsap_vlr_name, /* 9.4.22 VLR name*/
752 NULL/*DE_SGSAP_TMSI*/, /* 9.4.20 TMSI */
753 NULL/*DE_SGSAP_LOC_AREA_ID*/, /* 9.4.11 Location area identifier */
754 NULL/*DE_SGSAP_CH_NEEDED*/, /* 9.4.23 Channel Needed */
755 NULL/*DE_SGSAP_EMLPP_PRIO*/, /* 9.4.24 eMLPP Priority*/
756 NULL/*DE_SGSAP_TMSI_STATUS*/, /* 9.4.21 TMSI status */
757 de_sgsap_sgs_cause, /* 9.4.18 SGs cause*/
758 de_sgsap_mme_name, /* 9.4.13 MME name*/
759 de_sgsap_eps_loc_upd_type, /* 9.4.2 EPS location update type*/
760 de_sgsap_g_cn_id, /* 9.4.4 Global CN-Id*/
762 NULL/*DE_SGSAP_UDEF_11*/, /* Undefined */
763 NULL/*DE_SGSAP_UDEF_12*/, /* Undefined */
765 NULL/*DE_SGSAP_MID*/, /* 9.4.14 Mobile identity*/
766 NULL/*DE_SGSAP_REJ_CAUSE*/, /* 9.4.16 Reject cause */
767 de_sgsap_imsi_det_eps, /* 9.4.7 IMSI detach from EPS service type */
768 de_sgsap_imsi_det_non_eps, /* 9.4.8 IMSI detach from non-EPS service type */
770 de_sgsap_imeisv, /* 9.4.5 IMEISV */
771 de_sgsap_nas_msg_container, /* 9.4.15 NAS message container*/
772 de_sgsap_mm_info, /* 9.4.12 MM information*/
774 NULL/*DE_SGSAP_UDEF_20*/, /* Undefined */
775 NULL/*DE_SGSAP_UDEF_21*/, /* Undefined */
776 NULL/*DE_SGSAP_UDEF_22*/, /* Undefined */
778 de_sgsap_err_msg, /* 9.4.3 Erroneous message*/
779 NULL/*DE_SGSAP_CLI*/, /* 9.4.1 CLI */
780 NULL/*DE_SGSAP_LCS_CLIENT_ID*/, /* 9.4.9 LCS client identity */
781 de_sgsap_lcs_indic, /* 9.4.10 LCS indicator */
782 NULL/*DE_SGSAP_SS_CODE*/, /* 9.4.19 SS code */
783 de_sgsap_serv_indic, /* 9.4.17 Service indicator */
784 NULL/*DE_SGSAP_UE_TZ*/, /* 9.4.21b UE Time Zone */
785 NULL/*DE_SGSAP_MSC_2*/, /* 9.4.14a Mobile Station Classmark 2 */
786 NULL/*DE_SGSAP_TAID*/, /* 9.4.21a Tracking Area Identity */
787 de_sgsap_ecgi, /* 9.4.3a E-UTRAN Cell Global Identity */
788 de_sgsap_ue_emm_mode, /* 9.4.21c UE EMM mode*/
789 de_sgsap_add_paging_ind, /* 9.4.25 Additional paging indicators */
790 NULL/*DE_SGSAP_TMSI_BASED_NRI_CONT */, /* 9.4.26 TMSI based NRI container (Reuse GSM_A_PDU_TYPE_GM, DE_NET_RES_ID_CONT */
791 de_sgsap_selected_cs_dmn_op, /* 9.4.27 Selected CS domain operator */
792 NULL, /* NONE */
795 /* MESSAGE FUNCTIONS */
798 * 8.1 SGsAP-ALERT-ACK message
800 static void
801 sgsap_alert_ack(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
803 uint32_t curr_offset;
804 uint32_t consumed;
805 unsigned curr_len;
807 curr_offset = offset;
808 curr_len = len;
810 /* IMSI IMSI 9.4.6 M TLV 6-10 */
811 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
813 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
817 * 8.2 SGsAP-ALERT-REJECT message
819 static void
820 sgsap_alert_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
822 uint32_t curr_offset;
823 uint32_t consumed;
824 unsigned curr_len;
826 curr_offset = offset;
827 curr_len = len;
829 /* IMSI IMSI 9.4.6 M TLV 6-10 */
830 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
831 /* SGs Cause SGs cause 9.4.18 M TLV 3 */
832 ELEM_MAND_TLV(0x08, SGSAP_PDU_TYPE, DE_SGSAP_SGS_CAUSE, NULL, ei_sgsap_missing_mandatory_element);
834 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
838 * 8.3 SGsAP-ALERT-REQUEST message
840 static void
841 sgsap_alert_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
843 uint32_t curr_offset;
844 uint32_t consumed;
845 unsigned curr_len;
847 curr_offset = offset;
848 curr_len = len;
850 /* IMSI IMSI 9.4.6 M TLV 6-10 */
851 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
853 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
857 * 8.4 SGsAP-DOWNLINK-UNITDATA message
859 static void
860 sgsap_dl_unitdata(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
862 uint32_t curr_offset;
863 uint32_t consumed;
864 unsigned curr_len;
866 curr_offset = offset;
867 curr_len = len;
870 /* IMSI IMSI 9.4.6 M TLV 6-10 */
871 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
872 /* NAS message container NAS message container 9.4.15 M TLV 4-253 */
873 ELEM_MAND_TLV(0x16, SGSAP_PDU_TYPE, DE_SGSAP_NAS_MSG_CONTAINER, NULL, ei_sgsap_missing_mandatory_element);
875 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
879 * 8.5 SGsAP-EPS-DETACH-ACK message
882 static void
883 sgsap_eps_det_ack(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
885 uint32_t curr_offset;
886 uint32_t consumed;
887 unsigned curr_len;
889 curr_offset = offset;
890 curr_len = len;
892 /* IMSI IMSI 9.4.6 M TLV 6-10 */
893 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
895 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
898 * 8.6 SGsAP-EPS-DETACH-INDICATION message
901 static void
902 sgsap_eps_det_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
904 uint32_t curr_offset;
905 uint32_t consumed;
906 unsigned curr_len;
908 curr_offset = offset;
909 curr_len = len;
911 /* IMSI IMSI 9.4.6 M TLV 6-10 */
912 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
913 /* MME name MME name 9.4.13 M TLV 57 */
914 ELEM_MAND_TLV(0x09, SGSAP_PDU_TYPE, DE_SGSAP_MME_NAME, NULL, ei_sgsap_missing_mandatory_element);
915 /* IMSI detach from EPS service type IMSI detach from EPS service type 9.4.7 M TLV 3 */
916 ELEM_MAND_TLV(0x10, SGSAP_PDU_TYPE, DE_SGSAP_IMSI_DET_EPS, NULL, ei_sgsap_missing_mandatory_element);
918 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
922 * 8.7 SGsAP-IMSI-DETACH-ACK message
924 static void
925 sgsap_imsi_det_ack(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
927 uint32_t curr_offset;
928 uint32_t consumed;
929 unsigned curr_len;
931 curr_offset = offset;
932 curr_len = len;
934 /* IMSI IMSI 9.4.6 M TLV 6-10 */
935 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
937 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
940 * 8.8 SGsAP-IMSI-DETACH-INDICATION message
942 static void
943 sgsap_imsi_det_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
945 uint32_t curr_offset;
946 uint32_t consumed;
947 unsigned curr_len;
949 curr_offset = offset;
950 curr_len = len;
952 /* IMSI IMSI 9.4.6 M TLV 6-10 */
953 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
954 /* MME name MME name 9.4.13 M TLV 57 */
955 ELEM_MAND_TLV(0x09, SGSAP_PDU_TYPE, DE_SGSAP_MME_NAME, NULL, ei_sgsap_missing_mandatory_element);
956 /* IMSI Detach from non-EPS service type IMSI detach from non-EPS service type 9.4.8 M TLV 3 */
957 ELEM_MAND_TLV(0x11, SGSAP_PDU_TYPE, DE_SGSAP_IMSI_DET_NON_EPS, NULL, ei_sgsap_missing_mandatory_element);
959 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
963 * 8.9 SGsAP-LOCATION-UPDATE-ACCEPT message
965 static void
966 sgsap_imsi_loc_update_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
968 uint32_t curr_offset;
969 uint32_t consumed;
970 unsigned curr_len;
972 curr_offset = offset;
973 curr_len = len;
975 /* IMSI IMSI 9.4.6 M TLV 6-10 */
976 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
977 /* Location area identifier Location area identifier 9.4.11 M TLV 7 */
978 ELEM_MAND_TLV(0x04, GSM_A_PDU_TYPE_COMMON, DE_LAI, NULL, ei_sgsap_missing_mandatory_element);
979 /* New TMSI, or IMSI Mobile identity 9.4.14 O TLV 6-10 */
980 ELEM_OPT_TLV(0x0e, GSM_A_PDU_TYPE_COMMON, DE_MID, " - New TMSI, or IMSI");
982 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
986 * 8.10 SGsAP-LOCATION-UPDATE-REJECT message
988 static void
989 sgsap_imsi_loc_update_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
991 uint32_t curr_offset;
992 uint32_t consumed;
993 unsigned curr_len;
995 curr_offset = offset;
996 curr_len = len;
998 /* IMSI IMSI 9.4.6 M TLV 6-10 */
999 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
1000 /* Reject cause Reject cause 9.4.16 M TLV 3 */
1001 ELEM_MAND_TLV(0x0f, GSM_A_PDU_TYPE_DTAP, DE_REJ_CAUSE, NULL, ei_sgsap_missing_mandatory_element);
1002 /* Location area identifier Location area identifier 9.4.11 O TLV 7 */
1003 ELEM_OPT_TLV(0x04, GSM_A_PDU_TYPE_COMMON, DE_LAI, NULL);
1005 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
1009 * 8.11 SGsAP-LOCATION-UPDATE-REQUEST message
1012 static void
1013 sgsap_imsi_loc_update_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
1015 uint32_t curr_offset;
1016 uint32_t consumed;
1017 unsigned curr_len;
1019 curr_offset = offset;
1020 curr_len = len;
1022 /* IMSI IMSI 9.4.6 M TLV 6-10 */
1023 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
1024 /* MME name MME name 9.4.13 M TLV 57 */
1025 ELEM_MAND_TLV(0x09, SGSAP_PDU_TYPE, DE_SGSAP_MME_NAME, NULL, ei_sgsap_missing_mandatory_element);
1026 /* EPS location update type EPS location update type 9.4.2 M TLV 3 */
1027 ELEM_MAND_TLV(0x0a, SGSAP_PDU_TYPE, DE_SGSAP_EPS_LOC_UPD_TYPE, NULL, ei_sgsap_missing_mandatory_element);
1028 /* New location area identifier Location area identifier 9.4.11 M TLV 7 */
1029 ELEM_MAND_TLV(0x04, GSM_A_PDU_TYPE_COMMON, DE_LAI, NULL, ei_sgsap_missing_mandatory_element);
1030 /* Old location area identifier Location area identifier 9.4.11 O TLV 7 */
1031 ELEM_OPT_TLV(0x04, GSM_A_PDU_TYPE_COMMON, DE_LAI, " - Old location area identifier");
1032 /* TMSI status TMSI status 9.4.21 O TLV 3 */
1033 ELEM_OPT_TLV( 0x07 , GSM_A_PDU_TYPE_GM, DE_TMSI_STAT , NULL );
1034 /* IMEISV IMEISV 9.4.5 O TLV 10 */
1035 ELEM_OPT_TLV(0x15, SGSAP_PDU_TYPE, DE_SGSAP_IMEISV, NULL);
1036 /* TAI Tracking Area Identity 9.4.21a O TLV 7 */
1037 ELEM_OPT_TLV(0x23, NAS_PDU_TYPE_EMM, DE_EMM_TRAC_AREA_ID, NULL);
1038 /* E-CGI E-UTRAN Cell Global Identity 9.4.3a O TLV 9 */
1039 ELEM_OPT_TLV(0x24, SGSAP_PDU_TYPE, DE_SGSAP_ECGI, NULL);
1040 /* TMSI based NRI container TMSI based NRI container 9.4.26 O TLV 4 */
1041 ELEM_OPT_TLV(0x27, GSM_A_PDU_TYPE_GM, DE_NET_RES_ID_CONT, " - TMSI based NRI container");
1042 /* Selected CS domain operator Selected CS domain operator 9.4.27 O TLV 5 */
1043 ELEM_OPT_TLV(0x28, SGSAP_PDU_TYPE, DE_SGSAP_SELECTED_CS_DMN_OP, NULL);
1045 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
1049 * 8.12 SGsAP-MM-INFORMATION-REQUEST
1051 static void
1052 sgsap_mm_info_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
1054 uint32_t curr_offset;
1055 uint32_t consumed;
1056 unsigned curr_len;
1058 curr_offset = offset;
1059 curr_len = len;
1061 /* IMSI IMSI 9.4.6 M TLV 6-10 */
1062 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
1063 /* MM information MM information 9.4.12 M TLV 3-n */
1064 ELEM_MAND_TLV(0x17, SGSAP_PDU_TYPE, DE_SGSAP_MM_INFO, NULL, ei_sgsap_missing_mandatory_element);
1066 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
1070 * 8.13 SGsAP-PAGING-REJECT message
1072 static void
1073 sgsap_paging_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
1075 uint32_t curr_offset;
1076 uint32_t consumed;
1077 unsigned curr_len;
1079 curr_offset = offset;
1080 curr_len = len;
1082 /* IMSI IMSI 9.4.6 M TLV 6-10 */
1083 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
1084 /* SGs Cause SGs Cause 9.4.18 M TLV 3 */
1085 ELEM_MAND_TLV(0x08, SGSAP_PDU_TYPE, DE_SGSAP_SGS_CAUSE, NULL, ei_sgsap_missing_mandatory_element);
1087 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
1090 * 8.14 SGsAP-PAGING-REQUEST message
1092 static void
1093 sgsap_paging_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
1095 uint32_t curr_offset;
1096 uint32_t consumed;
1097 unsigned curr_len;
1099 curr_offset = offset;
1100 curr_len = len;
1102 /* IMSI IMSI 9.4.6 M TLV 6-10 */
1103 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
1104 /* VLR name VLR name 9.4.22 M TLV 3-n */
1105 ELEM_MAND_TLV(0x02, SGSAP_PDU_TYPE, DE_SGSAP_VLR_NAME, NULL, ei_sgsap_missing_mandatory_element);
1106 /* Service indicator Service indicator 9.4.17 M TLV 3 */
1107 ELEM_MAND_TLV(0x20, SGSAP_PDU_TYPE, DE_SGSAP_SERV_INDIC, NULL, ei_sgsap_missing_mandatory_element);
1108 /* TMSI TMSI 9.4.20 O TLV 6 */
1109 ELEM_OPT_TLV(0x03, GSM_A_PDU_TYPE_BSSMAP, BE_TMSI, NULL);
1110 /* CLI CLI 9.4.1 O TLV 3-14 */
1111 ELEM_OPT_TLV(0x1c, GSM_A_PDU_TYPE_DTAP, DE_CLG_PARTY_BCD_NUM, " - CLI");
1112 /* Location area identifier Location area identifier 9.4.11 O TLV 7 */
1113 ELEM_OPT_TLV(0x04, GSM_A_PDU_TYPE_COMMON, DE_LAI, NULL);
1114 /* Global CN-Id Global CN-Id 9.4.4 O TLV 7 */
1115 ELEM_OPT_TLV(0x0b, SGSAP_PDU_TYPE, DE_SGSAP_GLOBAL_CN_ID, NULL);
1116 /* SS code SS code 9.4.19 O TLV 3 */
1117 ELEM_OPT_TLV(0x1f, NAS_PDU_TYPE_EMM, DE_EMM_SS_CODE, NULL);
1118 /* LCS indicator LCS indicator 9.4.10 O TLV 3 */
1119 ELEM_OPT_TLV(0x1e, SGSAP_PDU_TYPE, DE_SGSAP_LCS_INDIC, NULL);
1120 /* LCS client identity LCS client identity 9.4.9 O TLV 3-n */
1121 ELEM_OPT_TLV(0x1d, NAS_PDU_TYPE_EMM, DE_EMM_LCS_CLIENT_ID, NULL);
1122 /* Channel needed Channel needed 9.4.23 O TLV 3 */
1123 ELEM_OPT_TLV(0x05, GSM_A_PDU_TYPE_BSSMAP, BE_CHAN_NEEDED, NULL);
1124 /* eMLPP Priority eMLPP Priority 9.4.24 O TLV 3 */
1125 ELEM_OPT_TLV(0x06, GSM_A_PDU_TYPE_BSSMAP, BE_EMLPP_PRIO, NULL);
1126 /* Additional paging indicators Additional paging indicators 9.4.25 O TLV 3 */
1127 ELEM_OPT_TLV(0x26, SGSAP_PDU_TYPE, DE_SGSAP_ADD_PAGING_IND, NULL);
1129 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
1132 * 8.15 SGsAP-RESET-ACK message
1134 static void
1135 sgsap_reset_ack(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
1137 uint32_t curr_offset;
1138 uint32_t consumed;
1139 unsigned curr_len;
1141 curr_offset = offset;
1142 curr_len = len;
1144 /* MME name MME name 9.4.13 C TLV 57 */
1145 ELEM_OPT_TLV(0x09, SGSAP_PDU_TYPE, DE_SGSAP_MME_NAME, NULL);
1146 /* VLR name VLR name 9.4.22 C TLV 3-n */
1147 ELEM_OPT_TLV(0x02, SGSAP_PDU_TYPE, DE_SGSAP_VLR_NAME, NULL);
1149 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
1153 * 8.16 SGsAP-RESET-INDICATION message
1155 static void
1156 sgsap_reset_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
1158 uint32_t curr_offset;
1159 uint32_t consumed;
1160 unsigned curr_len;
1162 curr_offset = offset;
1163 curr_len = len;
1165 /* MME name MME name 9.4.13 C TLV 57 */
1166 ELEM_OPT_TLV(0x09, SGSAP_PDU_TYPE, DE_SGSAP_MME_NAME, NULL);
1167 /* VLR name VLR name 9.4.22 C TLV 3-n */
1168 ELEM_OPT_TLV(0x02, SGSAP_PDU_TYPE, DE_SGSAP_VLR_NAME, NULL);
1170 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
1173 * 8.17 SGsAP-SERVICE-REQUEST message
1175 static void
1176 sgsap_service_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
1178 uint32_t curr_offset;
1179 uint32_t consumed;
1180 unsigned curr_len;
1182 curr_offset = offset;
1183 curr_len = len;
1185 /*IMSI IMSI 9.4.6 M TLV 6-10 */
1186 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
1187 /* Service indicator Service indicator 9.4.17 M TLV 3 */
1188 ELEM_MAND_TLV(0x20, SGSAP_PDU_TYPE, DE_SGSAP_SERV_INDIC, NULL, ei_sgsap_missing_mandatory_element);
1189 /* IMEISV IMEISV 9.4.5 O TLV 10 */
1190 ELEM_OPT_TLV(0x15, SGSAP_PDU_TYPE, DE_SGSAP_IMEISV, NULL);
1191 /* UE Time Zone UE Time Zone 9.4.21b O TLV 3 */
1192 ELEM_OPT_TLV(0x21, GSM_A_PDU_TYPE_DTAP, DE_TIME_ZONE, " - UE Time Zone");
1193 /* Mobile Station Classmark 2 Mobile Station Classmark 2 9.4.14a O TLV 5 */
1194 ELEM_OPT_TLV(0x22 , GSM_A_PDU_TYPE_COMMON, DE_MS_CM_2, NULL);
1195 /* TAI Tracking Area Identity 9.4.21a O TLV 7 */
1196 ELEM_OPT_TLV(0x23, NAS_PDU_TYPE_EMM, DE_EMM_TRAC_AREA_ID, NULL);
1197 /* E-CGI E-UTRAN Cell Global Identity 9.4.3a O TLV 9 */
1198 ELEM_OPT_TLV(0x24, SGSAP_PDU_TYPE, DE_SGSAP_ECGI, NULL);
1199 /* UE EMM Mode UE EMM mode 9.4.21c O TLV 3 */
1200 ELEM_OPT_TLV(0x25, SGSAP_PDU_TYPE, DE_SGSAP_UE_EMM_MODE, NULL);
1202 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
1206 * 8.18 SGsAP-STATUS message
1208 static void
1209 sgsap_status(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
1211 uint32_t curr_offset;
1212 uint32_t consumed;
1213 unsigned curr_len;
1215 curr_offset = offset;
1216 curr_len = len;
1218 /* IMSI IMSI 9.4.6 O TLV 6-10 */
1219 ELEM_OPT_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL);
1220 /* SGs cause SGs cause 9.4.18 M TLV 3 */
1221 ELEM_MAND_TLV(0x08, SGSAP_PDU_TYPE, DE_SGSAP_SGS_CAUSE, NULL, ei_sgsap_missing_mandatory_element);
1222 /* Erroneous message Erroneous message 9.4.3 M TLV 3-n */
1223 ELEM_OPT_TLV(0x1b, SGSAP_PDU_TYPE, DE_SGSAP_ERR_MSG, NULL);
1225 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
1229 * 8.19 SGsAP-TMSI-REALLOCATION-COMPLETE message
1231 static void
1232 sgsap_tmsi_realloc_comp(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
1234 uint32_t curr_offset;
1235 uint32_t consumed;
1236 unsigned curr_len;
1238 curr_offset = offset;
1239 curr_len = len;
1241 /*IMSI IMSI 9.4.6 M TLV 6-10 */
1242 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
1244 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
1248 * 8.20 SGsAP-UE-ACTIVITY-INDICATION message
1250 static void
1251 sgsap_ue_act_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
1253 uint32_t curr_offset;
1254 uint32_t consumed;
1255 unsigned curr_len;
1257 curr_offset = offset;
1258 curr_len = len;
1260 /* IMSI IMSI 9.4.6 M TLV 6-10 */
1261 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
1263 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
1267 * 8.21 SGsAP-UE-UNREACHABLE message
1269 static void
1270 sgsap_ue_unreachable(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
1272 uint32_t curr_offset;
1273 uint32_t consumed;
1274 unsigned curr_len;
1276 curr_offset = offset;
1277 curr_len = len;
1280 /* IMSI IMSI 9.4.6 M TLV 6-10 */
1281 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
1282 /* SGs cause SGs cause 9.4.18 M TLV 3 */
1283 ELEM_MAND_TLV(0x08, SGSAP_PDU_TYPE, DE_SGSAP_SGS_CAUSE, NULL, ei_sgsap_missing_mandatory_element);
1285 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
1288 * 8.22 SGsAP-UPLINK-UNITDATA message
1290 static void
1291 sgsap_ue_ul_unitdata(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
1293 uint32_t curr_offset;
1294 uint32_t consumed;
1295 unsigned curr_len;
1297 curr_offset = offset;
1298 curr_len = len;
1300 /* IMSI IMSI 9.4.6 M TLV 6-10 */
1301 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
1302 /* NAS message container NAS message container 9.4.15 M TLV 4-253 */
1303 ELEM_MAND_TLV(0x16, SGSAP_PDU_TYPE, DE_SGSAP_NAS_MSG_CONTAINER, NULL, ei_sgsap_missing_mandatory_element);
1304 /* IMEISV IMEISV 9.4.5 O TLV 10 */
1305 ELEM_OPT_TLV(0x15, SGSAP_PDU_TYPE, DE_SGSAP_IMEISV, NULL);
1306 /* UE Time Zone UE Time Zone 9.4.21b O TLV 3 */
1307 ELEM_OPT_TLV(0x21, GSM_A_PDU_TYPE_DTAP, DE_TIME_ZONE, " - UE Time Zone");
1308 /* Mobile Station Classmark 2 Mobile Station Classmark 2 9.4.14a O TLV 5 */
1309 ELEM_OPT_TLV(0x22 , GSM_A_PDU_TYPE_COMMON, DE_MS_CM_2, NULL);
1310 /* TAI Tracking Area Identity 9.4.21a O TLV 7 */
1311 ELEM_OPT_TLV(0x23, NAS_PDU_TYPE_EMM, DE_EMM_TRAC_AREA_ID, NULL);
1312 /* E-CGI E-UTRAN Cell Global Identity 9.4.3a O TLV 9 */
1313 ELEM_OPT_TLV(0x24, SGSAP_PDU_TYPE, DE_SGSAP_ECGI, NULL);
1315 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
1318 * 8.23 SGsAP-RELEASE-REQUEST message
1320 static void
1321 sgsap_release_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
1323 uint32_t curr_offset;
1324 uint32_t consumed;
1325 unsigned curr_len;
1327 curr_offset = offset;
1328 curr_len = len;
1330 /* IMSI IMSI 9.4.6 M TLV 6-10 */
1331 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
1332 /* SGs cause SGs cause 9.4.18 O TLV 3 */
1333 ELEM_OPT_TLV(0x08, SGSAP_PDU_TYPE, DE_SGSAP_SGS_CAUSE, NULL);
1335 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
1339 * 8.24 SGsAP-SERVICE-ABORT-REQUEST message
1341 static void
1342 sgsap_service_abort_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
1344 uint32_t curr_offset;
1345 uint32_t consumed;
1346 unsigned curr_len;
1348 curr_offset = offset;
1349 curr_len = len;
1351 /* IMSI IMSI 9.4.6 M TLV 6-10 */
1352 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
1354 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
1358 * 8.25 SGsAP-MO-CSFB-INDICATION message
1360 static void
1361 sgsap_mo_csfb_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len)
1363 uint32_t curr_offset;
1364 uint32_t consumed;
1365 unsigned curr_len;
1367 curr_offset = offset;
1368 curr_len = len;
1370 /* IMSI IMSI 9.4.6 M TLV 6-10 */
1371 ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL, ei_sgsap_missing_mandatory_element);
1372 /* TAI Tracking Area Identity 9.4.21a O TLV 7 */
1373 ELEM_OPT_TLV(0x23, NAS_PDU_TYPE_EMM, DE_EMM_TRAC_AREA_ID, NULL);
1374 /* E-CGI E-UTRAN Cell Global Identity 9.4.3a O TLV 9 */
1375 ELEM_OPT_TLV(0x24, SGSAP_PDU_TYPE, DE_SGSAP_ECGI, NULL);
1377 EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_sgsap_extraneous_data);
1380 * 9.2 Message type
1382 static const value_string sgsap_msg_strings[] = {
1383 { 0x01, "SGsAP-PAGING-REQUEST"}, /* 8.14 */
1384 { 0x02, "SGsAP-PAGING-REJECT"}, /* 8.13 */
1386 * 0 0 0 0 0 0 1 1
1387 * to
1388 * 0 0 0 0 0 1 0 1
1389 * Unassigned: treated as an unknown Message type
1391 { 0x03, "Unassigned"}, /* 7 */
1392 { 0x04, "Unassigned"}, /* 7 */
1393 { 0x05, "Unassigned"}, /* 7 */
1395 { 0x06, "SGsAP-SERVICE-REQUEST"}, /* 8.17 */
1396 { 0x07, "SGsAP-DOWNLINK-UNITDATA"}, /* 8.4 */
1397 { 0x08, "SGsAP-UPLINK-UNITDATA"}, /* 8.22 */
1398 { 0x09, "SGsAP-LOCATION-UPDATE-REQUEST"}, /* 8.11 */
1399 { 0x0a, "SGsAP-LOCATION-UPDATE-ACCEPT"}, /* 8.9 */
1400 { 0x0b, "SGsAP-LOCATION-UPDATE-REJECT"}, /* 8.10 */
1401 { 0x0c, "SGsAP-TMSI-REALLOCATION-COMPLETE"}, /* 8.19 */
1402 { 0x0d, "SGsAP-ALERT-REQUEST"}, /* 8.3 */
1403 { 0x0e, "SGsAP-ALERT-ACK"}, /* 8.1 */
1404 { 0x0f, "SGsAP-ALERT-REJECT"}, /* 8.2 */
1405 { 0x10, "SGsAP-UE-ACTIVITY-INDICATION"}, /* 8.20 */
1406 { 0x11, "SGsAP-EPS-DETACH-INDICATION"}, /* 8.6 */
1407 { 0x12, "SGsAP-EPS-DETACH-ACK"}, /* 8.5 */
1408 { 0x13, "SGsAP-IMSI-DETACH-INDICATION"}, /* 8.8 */
1409 { 0x14, "SGsAP-IMSI-DETACH-ACK"}, /* 8.7 */
1410 { 0x15, "SGsAP-RESET-INDICATION"}, /* 8.16 */
1411 { 0x16, "SGsAP-RESET-ACK"}, /* 8.15 */
1412 { 0x17, "SGsAP-SERVICE-ABORT-REQUEST"}, /* 8.24 */
1413 { 0x18, "SGsAP-MO-CSFB-INDICATION"}, /* 8.25 */
1415 * 0 0 0 1 1 0 0 0
1416 * to
1417 * 0 0 0 1 1 0 0 1
1418 * Unassigned: treated as an unknown Message type
1420 { 0x19, "Unassigned"},
1422 { 0x1a, "SGsAP-MM-INFORMATION-REQUEST"}, /* 8.12 */
1423 { 0x1b, "SGsAP-RELEASE-REQUEST"}, /* 8.23 */
1425 * 0 0 0 1 1 1 0 0 Unassigned: treated as an unknown Message type 7
1427 { 0x1c, "Unassigned"}, /* 7 */
1429 { 0x1d, "SGsAP-STATUS"}, /* 8.18 */
1430 { 0x1e, "Unassigned"}, /* 7 */
1431 { 0x1f, "SGsAP-UE-UNREACHABLE"}, /* 8.21 */
1432 { 0, NULL }
1434 static value_string_ext sgsap_msg_strings_ext = VALUE_STRING_EXT_INIT(sgsap_msg_strings);
1436 #define NUM_SGSAP_MSG array_length(sgsap_msg_strings)
1437 static int ett_sgsap_msg[NUM_SGSAP_MSG];
1438 static void (*sgsap_msg_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, uint32_t offset, unsigned len) = {
1439 sgsap_paging_req, /* 0x01, "SGsAP-PAGING-REQUEST" 8.14 */
1440 sgsap_paging_rej, /* 0x02, "SGsAP-PAGING-REJECT" 8.13 */
1442 * 0 0 0 0 0 0 1 1
1443 * to
1444 * 0 0 0 0 0 1 0 1
1445 * Unassigned: treated as an unknown Message type
1447 NULL, /* 0x03, "Unassigned" 7 */
1448 NULL, /* 0x04, "Unassigned" 7 */
1449 NULL, /* 0x05, "Unassigned" 7 */
1451 sgsap_service_req, /* 0x06, "SGsAP-SERVICE-REQUEST" 8.17 */
1452 sgsap_dl_unitdata, /* 0x07, "SGsAP-DOWNLINK-UNITDATA" 8.4 */
1453 sgsap_ue_ul_unitdata, /* 0x08, "SGsAP-UPLINK-UNITDATA" 8.22 */
1454 sgsap_imsi_loc_update_req, /* 0x09, "SGsAP-LOCATION-UPDATE-REQUEST" 8.11 */
1455 sgsap_imsi_loc_update_acc, /* 0x0a, "SGsAP-LOCATION-UPDATE-ACCEPT" 8.9 */
1456 sgsap_imsi_loc_update_rej, /* 0x0b, "SGsAP-LOCATION-UPDATE-REJECT" 8.10 */
1457 sgsap_tmsi_realloc_comp, /* 0x0c, "SGsAP-TMSI-REALLOCATION-COMPLETE" 8.19 */
1458 sgsap_alert_req, /* 0x0d, "SGsAP-ALERT-REQUEST" 8.3 */
1459 sgsap_alert_ack, /* 0x0e, "SGsAP-ALERT-ACK" 8.1 */
1460 sgsap_alert_rej, /* 0x0f, "SGsAP-ALERT-REJECT" 8.2 */
1461 sgsap_ue_act_ind, /* 0x10, "SGsAP-UE-ACTIVITY-INDICATION" 8.20 */
1462 sgsap_eps_det_ind, /* 0x11, "SGsAP-EPS-DETACH-INDICATION" 8.6 */
1463 sgsap_eps_det_ack, /* 0x12, "SGsAP-EPS-DETACH-ACK" 8.5 */
1464 sgsap_imsi_det_ind, /* 0x13, "SGsAP-IMSI-DETACH-INDICATION" 8.8 */
1465 sgsap_imsi_det_ack, /* 0x14, "SGsAP-IMSI-DETACH-ACK" 8.7 */
1466 sgsap_reset_ind, /* 0x15, "SGsAP-RESET-INDICATION" 8.16 */
1467 sgsap_reset_ack, /* 0x16, "SGsAP-RESET-ACK" 8.15 */
1468 sgsap_service_abort_req, /* 0x17, "SGsAP-SERVICE-ABORT-REQUEST" 8.24 */
1469 sgsap_mo_csfb_ind, /* 0x18, "SGsAP-MO-CSFB-INDICATION" 8.25 */
1471 * 0 0 0 1 1 0 0 1
1472 * to
1473 * 0 0 0 1 1 0 0 1
1474 * Unassigned: treated as an unknown Message type
1476 NULL, /* 0x19, "Unassigned" */
1478 sgsap_mm_info_req, /* 0x1a, "SGsAP-MM-INFORMATION-REQUEST" 8.12 */
1479 sgsap_release_req, /* 0x1b, "SGsAP-RELEASE-REQUEST" 8.23 */
1481 * 0 0 0 1 1 1 0 0 Unassigned: treated as an unknown Message type 7
1483 NULL, /* 0x1c, "Unassigned" */
1485 sgsap_status, /* 0x1d, "SGsAP-STATUS" 8.18 */
1486 NULL, /* 0x1e, "Unassigned" */
1487 sgsap_ue_unreachable, /* 0x1f, "SGsAP-UE-UNREACHABLE" 8.21 */
1489 NULL, /* NONE */
1492 static void get_sgsap_msg_params(uint8_t oct, const char **msg_str, int *ett_tree, int *hf_idx, msg_fcn *msg_fcn_p)
1494 int idx;
1496 *msg_str = try_val_to_str_idx_ext((uint32_t) (oct & 0xff), &sgsap_msg_strings_ext, &idx);
1497 *hf_idx = hf_sgsap_msg_type;
1498 if (*msg_str != NULL) {
1499 *ett_tree = ett_sgsap_msg[idx];
1500 *msg_fcn_p = sgsap_msg_fcn[idx];
1503 return;
1507 static int
1508 dissect_sgsap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
1510 proto_item *item;
1511 proto_tree *sgsap_tree;
1512 int offset = 0;
1513 uint32_t len;
1514 const char *msg_str;
1515 int ett_tree;
1516 int hf_idx;
1517 void (*msg_fcn_p)(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, uint32_t offset, unsigned len);
1518 uint8_t oct;
1520 len = tvb_reported_length(tvb);
1522 /* Make entry in the Protocol column on summary display */
1523 col_set_str(pinfo->cinfo, COL_PROTOCOL, PSNAME);
1525 item = proto_tree_add_item(tree, proto_sgsap, tvb, 0, -1, ENC_NA);
1526 sgsap_tree = proto_item_add_subtree(item, ett_sgsap);
1528 /* Message type IE*/
1529 oct = tvb_get_uint8(tvb, offset);
1530 msg_fcn_p = NULL;
1531 ett_tree = -1;
1532 hf_idx = -1;
1533 msg_str = NULL;
1535 get_sgsap_msg_params(oct, &msg_str, &ett_tree, &hf_idx, &msg_fcn_p);
1537 if (msg_str) {
1538 col_add_str(pinfo->cinfo, COL_INFO, msg_str);
1539 }else{
1540 proto_tree_add_item(tree, hf_sgsap_unknown_msg, tvb, offset, 1, ENC_BIG_ENDIAN);
1541 return tvb_captured_length(tvb);
1545 * Add SGSAP message name
1547 proto_tree_add_item(sgsap_tree, hf_idx, tvb, offset, 1, ENC_BIG_ENDIAN);
1548 offset++;
1552 * decode elements
1554 if (msg_fcn_p == NULL)
1556 proto_tree_add_item(sgsap_tree, hf_sgsap_message_elements, tvb, offset, len - offset, ENC_NA);
1558 else
1560 (*msg_fcn_p)(tvb, sgsap_tree, pinfo, offset, len - offset);
1563 return tvb_captured_length(tvb);
1568 void proto_register_sgsap(void) {
1569 unsigned i;
1570 unsigned last_offset;
1572 /* List of fields */
1574 static hf_register_info hf[] = {
1575 { &hf_sgsap_msg_type,
1576 { "SGSAP Message Type", "sgsap.msg_type",
1577 FT_UINT8, BASE_HEX|BASE_EXT_STRING, &sgsap_msg_strings_ext, 0x0,
1578 NULL, HFILL }
1580 { &hf_sgsap_elem_id,
1581 { "Element ID", "sgsap.elem_id",
1582 FT_UINT8, BASE_HEX, NULL, 0x0,
1583 NULL, HFILL }
1585 { &hf_sgsap_eps_location_update_type,
1586 { "EPS location update type", "sgsap.eps_location_update_type",
1587 FT_UINT8, BASE_DEC, VALS(sgsap_eps_location_update_type_values), 0x0,
1588 NULL, HFILL }
1590 { &hf_sgsap_service_indicator_value,
1591 { "Service indicator", "sgsap.service_indicator",
1592 FT_UINT8, BASE_DEC, VALS(sgsap_service_indicator_values), 0x0,
1593 NULL, HFILL }
1595 { &hf_sgsap_sgs_cause,
1596 { "SGs cause", "sgsap.sgs_cause",
1597 FT_UINT8, BASE_DEC|BASE_EXT_STRING, &sgsap_sgs_cause_values_ext, 0x0,
1598 NULL, HFILL }
1600 { &hf_sgsap_ue_emm_mode,
1601 { "UE EMM mode", "sgsap.ue_emm_mode",
1602 FT_UINT8, BASE_DEC, VALS(sgsap_ue_emm_mode_values), 0x0,
1603 NULL, HFILL }
1605 { &hf_sgsap_eci,
1606 {"ECI (E-UTRAN Cell Identifier)", "sgsap.eci",
1607 FT_UINT32, BASE_DEC, NULL, 0x0fffffff,
1608 NULL, HFILL}
1610 { &hf_sgsap_cn_id,
1611 {"CN_ID", "sgsap.cn_id",
1612 FT_UINT16, BASE_DEC, NULL, 0x0,
1613 NULL, HFILL}
1615 { &hf_sgsap_imsi_det_eps,
1616 { "IMSI detach from EPS service type", "sgsap.imsi_det_eps",
1617 FT_UINT8, BASE_DEC, VALS(sgsap_imsi_det_from_eps_serv_type_values), 0x0,
1618 NULL, HFILL }
1620 { &hf_sgsap_imsi_det_non_eps,
1621 { "IMSI detach from non-EPS service type", "sgsap.imsi_det_non_eps",
1622 FT_UINT8, BASE_DEC, VALS(sgsap_imsi_det_from_non_eps_serv_type_values), 0x0,
1623 NULL, HFILL }
1625 { &hf_sgsap_lcs_indic,
1626 { "LCS indicator", "sgsap.lcs_indicator",
1627 FT_UINT8, BASE_DEC, VALS(sgsap_lcs_indic_values), 0x0,
1628 NULL, HFILL }
1630 { &hf_sgsap_mme_name,
1631 {"MME name", "sgsap.mme_name",
1632 FT_STRING, BASE_NONE, NULL, 0x0,
1633 NULL, HFILL}
1635 { &hf_sgsap_vlr_name,
1636 {"VLR name", "sgsap.vlr_name",
1637 FT_STRING, BASE_NONE, NULL, 0x0,
1638 NULL, HFILL}
1640 { &hf_sgsap_imeisv,
1641 {"IMEISV", "sgsap.imeisv",
1642 FT_STRING, BASE_NONE, NULL, 0x0,
1643 NULL, HFILL}
1645 { &hf_sgsap_unknown_msg,
1646 { "Unknown message", "sgsap.unknown_msg",
1647 FT_UINT8, BASE_HEX, NULL, 0x0,
1648 NULL, HFILL }
1650 { &hf_sgsap_message_elements,
1651 {"Message Elements", "sgsap.message_elements",
1652 FT_BYTES, BASE_NONE, NULL, 0x0,
1653 NULL, HFILL}
1655 { &hf_sgsap_csri,
1656 {"CS restoration indicator (CSRI)", "sgsap.csri",
1657 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x01,
1658 NULL, HFILL }
1660 { &hf_sgsap_sel_cs_dmn_op,
1661 { "Selected CS domain operator", "sgsap.sel_cs_dmn_op",
1662 FT_BYTES, BASE_NONE, NULL, 0x0,
1663 NULL, HFILL }
1667 static ei_register_info ei[] = {
1668 { &ei_sgsap_extraneous_data, { "sgsap.extraneous_data", PI_PROTOCOL, PI_NOTE, "Extraneous Data, dissector bug or later version spec(report to wireshark.org)", EXPFILL }},
1669 { &ei_sgsap_missing_mandatory_element, { "sgsap.missing_mandatory_element", PI_PROTOCOL, PI_WARN, "Missing Mandatory element, rest of dissection is suspect", EXPFILL }},
1672 expert_module_t* expert_sgsap;
1674 /* Setup protocol subtree array */
1675 #define NUM_INDIVIDUAL_ELEMS 2
1676 int *ett[NUM_INDIVIDUAL_ELEMS +
1677 NUM_SGSAP_ELEM +
1678 NUM_SGSAP_MSG];
1680 ett[0] = &ett_sgsap;
1681 ett[1] = &ett_sgsap_sel_cs_dmn_op;
1683 last_offset = NUM_INDIVIDUAL_ELEMS;
1685 for (i=0; i < NUM_SGSAP_ELEM; i++, last_offset++)
1687 ett[last_offset] = &ett_sgsap_elem[i];
1690 for (i=0; i < NUM_SGSAP_MSG; i++, last_offset++)
1692 ett[last_offset] = &ett_sgsap_msg[i];
1695 /* Register protocol */
1696 proto_sgsap = proto_register_protocol(PNAME, PSNAME, PFNAME);
1697 /* Register fields and subtrees */
1698 proto_register_field_array(proto_sgsap, hf, array_length(hf));
1699 proto_register_subtree_array(ett, array_length(ett));
1700 expert_sgsap = expert_register_protocol(proto_sgsap);
1701 expert_register_field_array(expert_sgsap, ei, array_length(ei));
1703 /* Register dissector */
1704 sgsap_handle = register_dissector(PFNAME, dissect_sgsap, proto_sgsap);
1706 /* sgsap_module = prefs_register_protocol(proto_sgsap, NULL); */
1710 void
1711 proto_reg_handoff_sgsap(void)
1713 /* The registered SCTP port number for SGsAP is 29118.
1714 * The payload protocol identifier to be used for SGsAP is 0.
1716 gsm_a_dtap_handle = find_dissector_add_dependency("gsm_a_dtap", proto_sgsap);
1717 dissector_add_uint_range_with_preference("sctp.port", SGSAP_SCTP_PORT_RANGE, sgsap_handle);
1721 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1723 * Local variables:
1724 * c-basic-offset: 4
1725 * tab-width: 8
1726 * indent-tabs-mode: nil
1727 * End:
1729 * vi: set shiftwidth=4 tabstop=8 expandtab:
1730 * :indentSize=4:tabSize=8:noTabs=true: