2 * Routines for GSM A Interface RP dissection - SMS GSM layer 3
4 * Copyright 2003, Michael Lum <mlum [AT] telostech.com>
5 * In association with Telos Technology Inc.
10 * Point-to-Point (PP) Short Message Service (SMS)
11 * support on mobile radio interface
12 * (3GPP TS 24.011 version 4.1.1 Release 4)
16 * Wireshark - Network traffic analyzer
17 * By Gerald Combs <gerald@wireshark.org>
18 * Copyright 1998 Gerald Combs
20 * This program is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU General Public License
22 * as published by the Free Software Foundation; either version 2
23 * of the License, or (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
44 #include <epan/packet.h>
47 #include "packet-sccp.h"
48 #include "packet-gsm_a_common.h"
50 /* PROTOTYPES/FORWARDS */
52 static const value_string gsm_rp_msg_strings[] = {
53 { 0x00, "RP-DATA (MS to Network)" },
54 { 0x01, "RP-DATA (Network to MS)" },
55 { 0x02, "RP-ACK (MS to Network)" },
56 { 0x03, "RP-ACK (Network to MS)" },
57 { 0x04, "RP-ERROR (MS to Network)" },
58 { 0x05, "RP-ERROR (Network to MS)" },
59 { 0x06, "RP-SMMA (MS to Network)" },
63 const value_string gsm_rp_elem_strings[] = {
64 /* Short Message Service RP Information Elements [5] 8.2 */
65 { 0x00, "RP-Message Reference" },
66 { 0x00, "RP-Origination Address" },
67 { 0x00, "RP-Destination Address" },
68 { 0x00, "RP-User Data" },
73 /* Initialize the protocol and registered fields */
74 static int proto_a_rp = -1;
76 static int hf_gsm_a_rp_msg_type = -1;
77 int hf_gsm_a_rp_elem_id = -1;
79 /* Initialize the subtree pointers */
80 static gint ett_rp_msg = -1;
82 static char a_bigbuf[1024];
84 static dissector_table_t sms_dissector_table; /* SMS TPDU */
86 static packet_info *g_pinfo;
87 static proto_tree *g_tree;
91 /* Short Message Service Information Elements [5] 8.2 */
92 DE_RP_MESSAGE_REF, /* RP-Message Reference */
93 DE_RP_ORIG_ADDR, /* RP-Origination Address */
94 DE_RP_DEST_ADDR, /* RP-Destination Address */
95 DE_RP_USER_DATA, /* RP-User Data */
96 DE_RP_CAUSE, /* RP-Cause */
101 #define NUM_GSM_RP_ELEM (sizeof(gsm_rp_elem_strings)/sizeof(value_string))
102 gint ett_gsm_rp_elem[NUM_GSM_RP_ELEM];
108 de_rp_message_ref(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
113 curr_offset = offset;
115 oct = tvb_get_guint8(tvb, curr_offset);
117 proto_tree_add_text(tree,
119 "RP-Message Reference: 0x%02x (%u)",
125 /* no length check possible */
127 return(curr_offset - offset);
134 de_rp_orig_addr(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
136 return(de_cld_party_bcd_num(tvb, tree, offset, len, add_string, string_len));
143 de_rp_dest_addr(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
145 return(de_cld_party_bcd_num(tvb, tree, offset, len, add_string, string_len));
152 de_rp_user_data(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
157 curr_offset = offset;
159 proto_tree_add_text(tree, tvb, curr_offset, len,
160 "TPDU (not displayed)");
163 * dissect the embedded TPDU message
165 tpdu_tvb = tvb_new_subset(tvb, curr_offset, len, len);
167 dissector_try_port(sms_dissector_table, 0, tpdu_tvb, g_pinfo, g_tree);
171 EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
173 return(curr_offset - offset);
180 de_rp_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
186 curr_offset = offset;
188 oct = tvb_get_guint8(tvb, curr_offset);
190 other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
191 proto_tree_add_text(tree,
193 "%s : Extension: %s",
195 (oct & 0x80) ? "extended" : "not extended");
199 case 1: str = "Unassigned (unallocated) number"; break;
200 case 8: str = "Operator determined barring"; break;
201 case 10: str = "Call barred"; break;
202 case 11: str = "Reserved"; break;
203 case 21: str = "Short message transfer rejected"; break;
204 case 22: str = "Memory capacity exceeded"; break;
205 case 27: str = "Destination out of order"; break;
206 case 28: str = "Unidentified subscriber"; break;
207 case 29: str = "Facility rejected"; break;
208 case 30: str = "Unknown subscriber"; break;
209 case 38: str = "Network out of order"; break;
210 case 41: str = "Temporary failure"; break;
211 case 42: str = "Congestion"; break;
212 case 47: str = "Resources unavailable, unspecified"; break;
213 case 50: str = "Requested facility not subscribed"; break;
214 case 69: str = "Requested facility not implemented"; break;
215 case 81: str = "Invalid short message transfer reference value"; break;
216 case 95: str = "Semantically incorrect message"; break;
217 case 96: str = "Invalid mandatory information"; break;
218 case 97: str = "Message type non-existent or not implemented"; break;
219 case 98: str = "Message not compatible with short message protocol state"; break;
220 case 99: str = "Information element non-existent or not implemented"; break;
221 case 111: str = "Protocol error, unspecified"; break;
222 case 127: str = "Interworking, unspecified"; break;
228 other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
229 proto_tree_add_text(tree,
231 "%s : Cause: (%u) %s",
239 g_snprintf(add_string, string_len, " - (%u) %s", oct & 0x7f, str);
241 NO_MORE_DATA_CHECK(len);
243 proto_tree_add_text(tree,
244 tvb, curr_offset, len - (curr_offset - offset),
247 curr_offset += len - (curr_offset - offset);
249 EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
251 return(curr_offset - offset);
254 guint8 (*rp_elem_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len) = {
255 /* Short Message Service Information Elements [5] 8.2 */
256 de_rp_message_ref, /* RP-Message Reference */
257 de_rp_orig_addr, /* RP-Origination Address */
258 de_rp_dest_addr, /* RP-Destination Address */
259 de_rp_user_data, /* RP-User Data */
260 de_rp_cause, /* RP-Cause */
264 /* MESSAGE FUNCTIONS */
270 rp_data_n_ms(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
276 curr_offset = offset;
279 g_pinfo->p2p_dir = P2P_DIR_SENT;
281 ELEM_MAND_V(GSM_A_PDU_TYPE_RP, DE_RP_MESSAGE_REF);
283 ELEM_MAND_LV(GSM_A_PDU_TYPE_RP, DE_RP_ORIG_ADDR, "");
285 ELEM_MAND_LV(GSM_A_PDU_TYPE_RP, DE_RP_DEST_ADDR, "");
287 ELEM_MAND_LV(GSM_A_PDU_TYPE_RP, DE_RP_USER_DATA, "");
289 EXTRANEOUS_DATA_CHECK(curr_len, 0);
296 rp_data_ms_n(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
302 curr_offset = offset;
305 g_pinfo->p2p_dir = P2P_DIR_RECV;
307 ELEM_MAND_V(GSM_A_PDU_TYPE_RP, DE_RP_MESSAGE_REF);
309 ELEM_MAND_LV(GSM_A_PDU_TYPE_RP, DE_RP_ORIG_ADDR, "");
311 ELEM_MAND_LV(GSM_A_PDU_TYPE_RP, DE_RP_DEST_ADDR, "");
313 ELEM_MAND_LV(GSM_A_PDU_TYPE_RP, DE_RP_USER_DATA, "");
315 EXTRANEOUS_DATA_CHECK(curr_len, 0);
322 rp_smma(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
328 curr_offset = offset;
331 ELEM_MAND_V(GSM_A_PDU_TYPE_RP, DE_RP_MESSAGE_REF);
333 EXTRANEOUS_DATA_CHECK(curr_len, 0);
340 rp_ack_n_ms(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
346 curr_offset = offset;
349 g_pinfo->p2p_dir = P2P_DIR_SENT;
351 ELEM_MAND_V(GSM_A_PDU_TYPE_RP, DE_RP_MESSAGE_REF);
353 ELEM_OPT_TLV(0x41, GSM_A_PDU_TYPE_RP, DE_RP_USER_DATA, "");
355 EXTRANEOUS_DATA_CHECK(curr_len, 0);
362 rp_ack_ms_n(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
368 curr_offset = offset;
371 g_pinfo->p2p_dir = P2P_DIR_RECV;
373 ELEM_MAND_V(GSM_A_PDU_TYPE_RP, DE_RP_MESSAGE_REF);
375 ELEM_OPT_TLV(0x41, GSM_A_PDU_TYPE_RP, DE_RP_USER_DATA, "");
377 EXTRANEOUS_DATA_CHECK(curr_len, 0);
384 rp_error_n_ms(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
390 curr_offset = offset;
393 g_pinfo->p2p_dir = P2P_DIR_SENT;
395 ELEM_MAND_V(GSM_A_PDU_TYPE_RP, DE_RP_MESSAGE_REF);
397 ELEM_MAND_LV(GSM_A_PDU_TYPE_RP, DE_RP_CAUSE, "");
399 ELEM_OPT_TLV(0x41, GSM_A_PDU_TYPE_RP, DE_RP_USER_DATA, "");
401 EXTRANEOUS_DATA_CHECK(curr_len, 0);
408 rp_error_ms_n(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
414 curr_offset = offset;
417 g_pinfo->p2p_dir = P2P_DIR_RECV;
419 ELEM_MAND_V(GSM_A_PDU_TYPE_RP, DE_RP_MESSAGE_REF);
421 ELEM_MAND_LV(GSM_A_PDU_TYPE_RP, DE_RP_CAUSE, "");
423 ELEM_OPT_TLV(0x41, GSM_A_PDU_TYPE_RP, DE_RP_USER_DATA, "");
425 EXTRANEOUS_DATA_CHECK(curr_len, 0);
428 #define NUM_GSM_RP_MSG (sizeof(gsm_rp_msg_strings)/sizeof(value_string))
429 static gint ett_gsm_rp_msg[NUM_GSM_RP_MSG];
430 static void (*rp_msg_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
431 rp_data_ms_n, /* RP-DATA (MS to Network) */
432 rp_data_n_ms, /* RP-DATA (Network to MS */
433 rp_ack_ms_n, /* RP-ACK (MS to Network) */
434 rp_ack_n_ms, /* RP-ACK (Network to MS) */
435 rp_error_ms_n, /* RP-ERROR (MS to Network) */
436 rp_error_n_ms, /* RP-ERROR (Network to MS) */
437 rp_smma, /* RP-SMMA (MS to Network) */
441 /* GENERIC DISSECTOR FUNCTIONS */
444 dissect_rp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
447 guint32 offset, saved_offset;
450 proto_item *rp_item = NULL;
451 proto_tree *rp_tree = NULL;
454 if (check_col(pinfo->cinfo, COL_INFO))
456 col_append_str(pinfo->cinfo, COL_INFO, "(RP) ");
460 * In the interest of speed, if "tree" is NULL, don't do any work
461 * not necessary to generate protocol tree items.
469 saved_offset = offset;
474 len = tvb_length(tvb);
477 * add RP message name
479 oct = tvb_get_guint8(tvb, offset++);
481 str = match_strval_idx((guint32) oct, gsm_rp_msg_strings, &idx);
484 * create the protocol tree
489 proto_tree_add_protocol_format(tree, proto_a_rp, tvb, 0, len,
490 "GSM A-I/F RP - Unknown RP Message Type (0x%02x)",
493 rp_tree = proto_item_add_subtree(rp_item, ett_rp_msg);
498 proto_tree_add_protocol_format(tree, proto_a_rp, tvb, 0, -1,
502 rp_tree = proto_item_add_subtree(rp_item, ett_gsm_rp_msg[idx]);
504 if (check_col(pinfo->cinfo, COL_INFO))
506 col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", str);
511 * add RP message name
513 proto_tree_add_uint_format(rp_tree, hf_gsm_a_rp_msg_type,
514 tvb, saved_offset, 1, oct, "Message Type %s", str ? str : "(Unknown)");
516 if (str == NULL) return;
518 if ((len - offset) <= 0) return;
523 if (rp_msg_fcn[idx] == NULL)
525 proto_tree_add_text(rp_tree,
526 tvb, offset, len - offset,
531 (*rp_msg_fcn[idx])(tvb, rp_tree, offset, len - offset);
535 /* Register the protocol with Wireshark */
537 proto_register_gsm_a_rp(void)
542 /* Setup list of header fields */
544 static hf_register_info hf[] =
546 { &hf_gsm_a_rp_msg_type,
547 { "RP Message Type", "gsm_a.rp_msg_type",
548 FT_UINT8, BASE_HEX, VALS(gsm_rp_msg_strings), 0x0,
551 { &hf_gsm_a_rp_elem_id,
552 { "Element ID", "gsm_a_rp.elem_id",
553 FT_UINT8, BASE_DEC, NULL, 0,
558 /* Setup protocol subtree array */
559 #define NUM_INDIVIDUAL_ELEMS 1
560 static gint *ett[NUM_INDIVIDUAL_ELEMS +
564 ett[0] = &ett_rp_msg;
566 last_offset = NUM_INDIVIDUAL_ELEMS;
568 for (i=0; i < NUM_GSM_RP_MSG; i++, last_offset++)
570 ett_gsm_rp_msg[i] = -1;
571 ett[last_offset] = &ett_gsm_rp_msg[i];
574 for (i=0; i < NUM_GSM_RP_ELEM; i++, last_offset++)
576 ett_gsm_rp_elem[i] = -1;
577 ett[last_offset] = &ett_gsm_rp_elem[i];
580 /* Register the protocol name and description */
583 proto_register_protocol("GSM A-I/F RP", "GSM RP", "gsm_a_rp");
585 proto_register_field_array(proto_a_rp, hf, array_length(hf));
587 sms_dissector_table =
588 register_dissector_table("gsm_a.sms_tpdu", "GSM SMS TPDU",
591 proto_register_subtree_array(ett, array_length(ett));
593 register_dissector("gsm_a_rp", dissect_rp, proto_a_rp);
597 proto_reg_handoff_gsm_a_rp(void)