2008-08-04 19:44:03 +00:00
/* packet-gsm_a_rp.c
* Routines for GSM A Interface RP dissection - SMS GSM layer 3
*
* Copyright 2003 , Michael Lum < mlum [ AT ] telostech . com >
* In association with Telos Technology Inc .
*
* Title 3 GPP Other
*
* Reference [ 5 ]
* Point - to - Point ( PP ) Short Message Service ( SMS )
* support on mobile radio interface
* ( 3 GPP TS 24.011 version 4.1 .1 Release 4 )
*
* Wireshark - Network traffic analyzer
* By Gerald Combs < gerald @ wireshark . org >
* Copyright 1998 Gerald Combs
*
2018-02-12 11:23:27 +00:00
* SPDX - License - Identifier : GPL - 2.0 - or - later
2008-08-04 19:44:03 +00:00
*/
2012-09-20 02:03:38 +00:00
# include "config.h"
2008-08-04 19:44:03 +00:00
# include <epan/packet.h>
2015-01-02 17:19:10 +00:00
# include <epan/expert.h>
2008-08-04 19:44:03 +00:00
# include "packet-gsm_a_common.h"
2013-12-15 23:44:12 +00:00
void proto_register_gsm_a_rp ( void ) ;
void proto_reg_handoff_gsm_a_rp ( void ) ;
2008-08-04 19:44:03 +00:00
/* PROTOTYPES/FORWARDS */
static const value_string gsm_rp_msg_strings [ ] = {
{ 0x00 , " RP-DATA (MS to Network) " } ,
{ 0x01 , " RP-DATA (Network to MS) " } ,
{ 0x02 , " RP-ACK (MS to Network) " } ,
{ 0x03 , " RP-ACK (Network to MS) " } ,
{ 0x04 , " RP-ERROR (MS to Network) " } ,
{ 0x05 , " RP-ERROR (Network to MS) " } ,
{ 0x06 , " RP-SMMA (MS to Network) " } ,
{ 0 , NULL }
} ;
2013-03-18 20:26:47 +00:00
typedef enum
{
/* Short Message Service Information Elements [5] 8.2 */
DE_RP_MESSAGE_REF , /* RP-Message Reference */
DE_RP_ORIG_ADDR , /* RP-Originator Address */
DE_RP_DEST_ADDR , /* RP-Destination Address */
DE_RP_USER_DATA , /* RP-User Data */
DE_RP_CAUSE , /* RP-Cause */
DE_RP_NONE /* NONE */
}
rp_elem_idx_t ;
2013-03-18 22:21:53 +00:00
static const value_string gsm_rp_elem_strings [ ] = {
2008-08-04 19:44:03 +00:00
/* Short Message Service RP Information Elements [5] 8.2 */
2014-10-04 15:28:35 +00:00
{ DE_RP_MESSAGE_REF , " RP-Message Reference " } ,
{ DE_RP_ORIG_ADDR , " RP-Originator Address " } ,
{ DE_RP_DEST_ADDR , " RP-Destination Address " } ,
{ DE_RP_USER_DATA , " RP-User Data " } ,
{ DE_RP_CAUSE , " RP-Cause " } ,
2008-08-04 19:44:03 +00:00
{ 0 , NULL }
} ;
2013-03-18 22:21:53 +00:00
value_string_ext gsm_rp_elem_strings_ext = VALUE_STRING_EXT_INIT ( gsm_rp_elem_strings ) ;
2008-08-04 19:44:03 +00:00
/* Initialize the protocol and registered fields */
static int proto_a_rp = - 1 ;
static int hf_gsm_a_rp_msg_type = - 1 ;
int hf_gsm_a_rp_elem_id = - 1 ;
2014-10-15 16:55:08 +00:00
/* Generated from convert_proto_tree_add_text.pl */
static int hf_gsm_a_rp_tpdu = - 1 ;
static int hf_gsm_a_rp_extension = - 1 ;
static int hf_gsm_a_rp_diagnostic_field = - 1 ;
static int hf_gsm_a_rp_cause = - 1 ;
static int hf_gsm_a_rp_message_elements = - 1 ;
static int hf_gsm_a_rp_rp_message_reference = - 1 ;
2008-08-04 19:44:03 +00:00
/* Initialize the subtree pointers */
static gint ett_rp_msg = - 1 ;
2015-01-02 17:19:10 +00:00
static expert_field ei_gsm_a_rp_extraneous_data = EI_INIT ;
2017-06-14 18:14:30 +00:00
static expert_field ei_gsm_a_rp_missing_mandatory_element = EI_INIT ;
2015-01-02 17:19:10 +00:00
2013-10-02 18:04:06 +00:00
static dissector_handle_t gsm_sms_handle ; /* SMS TPDU */
2008-08-04 19:44:03 +00:00
static proto_tree * g_tree ;
# define NUM_GSM_RP_ELEM (sizeof(gsm_rp_elem_strings) / sizeof(value_string))
gint ett_gsm_rp_elem [ NUM_GSM_RP_ELEM ] ;
/*
* [ 5 ] 8.2 .3
*/
2008-12-23 20:49:15 +00:00
static guint16
2011-04-04 14:37:25 +00:00
de_rp_message_ref ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len _U_ , gchar * add_string _U_ , int string_len _U_ )
2008-08-04 19:44:03 +00:00
{
guint32 curr_offset ;
curr_offset = offset ;
2014-12-13 21:26:07 +00:00
proto_tree_add_item ( tree , hf_gsm_a_rp_rp_message_reference , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;
2008-08-04 19:44:03 +00:00
curr_offset + + ;
/* no length check possible */
return ( curr_offset - offset ) ;
}
/*
* [ 5 ] 8.2 .5 .1
*/
2008-12-23 20:49:15 +00:00
static guint16
2011-04-04 14:37:25 +00:00
de_rp_orig_addr ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len , gchar * add_string , int string_len )
2008-08-04 19:44:03 +00:00
{
2011-04-04 14:37:25 +00:00
return ( de_cld_party_bcd_num ( tvb , tree , pinfo , offset , len , add_string , string_len ) ) ;
2008-08-04 19:44:03 +00:00
}
/*
* [ 5 ] 8.2 .5 .2
*/
2008-12-23 20:49:15 +00:00
static guint16
2011-04-04 14:37:25 +00:00
de_rp_dest_addr ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len , gchar * add_string , int string_len )
2008-08-04 19:44:03 +00:00
{
2011-04-04 14:37:25 +00:00
return ( de_cld_party_bcd_num ( tvb , tree , pinfo , offset , len , add_string , string_len ) ) ;
2008-08-04 19:44:03 +00:00
}
/*
* [ 5 ] 8.2 .5 .3
*/
2008-12-23 20:49:15 +00:00
static guint16
2011-04-04 14:37:25 +00:00
de_rp_user_data ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo , guint32 offset , guint len , gchar * add_string _U_ , int string_len _U_ )
2008-08-04 19:44:03 +00:00
{
2014-10-04 15:28:35 +00:00
guint32 curr_offset ;
tvbuff_t * tpdu_tvb ;
2008-08-04 19:44:03 +00:00
curr_offset = offset ;
2014-10-15 16:55:08 +00:00
proto_tree_add_bytes_format ( tree , hf_gsm_a_rp_tpdu , tvb , curr_offset , len , NULL , " TPDU (not displayed) " ) ;
2008-08-04 19:44:03 +00:00
/*
* dissect the embedded TPDU message
*/
2014-06-06 14:35:50 +00:00
tpdu_tvb = tvb_new_subset_length ( tvb , curr_offset , len ) ;
2008-08-04 19:44:03 +00:00
2013-10-02 18:04:06 +00:00
call_dissector_only ( gsm_sms_handle , tpdu_tvb , pinfo , g_tree , NULL ) ;
2008-08-04 19:44:03 +00:00
curr_offset + = len ;
2015-01-02 17:19:10 +00:00
EXTRANEOUS_DATA_CHECK ( len , curr_offset - offset , pinfo , & ei_gsm_a_rp_extraneous_data ) ;
2008-08-04 19:44:03 +00:00
return ( curr_offset - offset ) ;
}
/*
* [ 5 ] 8.2 .5 .4
*/
2014-10-15 16:55:08 +00:00
static const value_string gsm_rp_cause_vals [ ] = {
{ 1 , " Unassigned (unallocated) number " } ,
{ 8 , " Operator determined barring " } ,
{ 10 , " Call barred " } ,
{ 11 , " Reserved " } ,
{ 21 , " Short message transfer rejected " } ,
{ 22 , " Memory capacity exceeded " } ,
{ 27 , " Destination out of order " } ,
{ 28 , " Unidentified subscriber " } ,
{ 29 , " Facility rejected " } ,
{ 30 , " Unknown subscriber " } ,
{ 38 , " Network out of order " } ,
{ 41 , " Temporary failure " } ,
{ 42 , " Congestion " } ,
{ 47 , " Resources unavailable, unspecified " } ,
{ 50 , " Requested facility not subscribed " } ,
{ 69 , " Requested facility not implemented " } ,
{ 81 , " Invalid short message transfer reference value " } ,
{ 95 , " Semantically incorrect message " } ,
{ 96 , " Invalid mandatory information " } ,
{ 97 , " Message type non-existent or not implemented " } ,
{ 98 , " Message not compatible with short message protocol state " } ,
{ 99 , " Information element non-existent or not implemented " } ,
{ 111 , " Protocol error, unspecified " } ,
{ 127 , " Interworking, unspecified " } ,
{ 0 , NULL }
} ;
value_string_ext gsm_rp_cause_vals_ext = VALUE_STRING_EXT_INIT ( gsm_rp_cause_vals ) ;
static const true_false_string tfs_extended_no_extension = { " Extended " , " No extension " } ;
2008-12-23 20:49:15 +00:00
static guint16
2011-04-04 14:37:25 +00:00
de_rp_cause ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len , gchar * add_string , int string_len )
2008-08-04 19:44:03 +00:00
{
guint8 oct ;
guint32 curr_offset ;
curr_offset = offset ;
oct = tvb_get_guint8 ( tvb , curr_offset ) ;
2014-10-15 16:55:08 +00:00
proto_tree_add_item ( tree , hf_gsm_a_rp_extension , tvb , curr_offset , 1 , ENC_NA ) ;
2014-12-13 21:26:07 +00:00
proto_tree_add_item ( tree , hf_gsm_a_rp_cause , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;
2008-08-04 19:44:03 +00:00
curr_offset + + ;
if ( add_string )
2014-10-15 16:55:08 +00:00
g_snprintf ( add_string , string_len , " - (%u) %s " , oct & 0x7f , val_to_str_ext_const ( oct & 0x7f , & gsm_rp_cause_vals_ext , " Reserved " ) ) ;
2008-08-04 19:44:03 +00:00
NO_MORE_DATA_CHECK ( len ) ;
2014-10-15 16:55:08 +00:00
proto_tree_add_item ( tree , hf_gsm_a_rp_diagnostic_field , tvb , curr_offset , len - ( curr_offset - offset ) , ENC_NA ) ;
2008-08-04 19:44:03 +00:00
curr_offset + = len - ( curr_offset - offset ) ;
2015-01-02 17:19:10 +00:00
EXTRANEOUS_DATA_CHECK ( len , curr_offset - offset , pinfo , & ei_gsm_a_rp_extraneous_data ) ;
2008-08-04 19:44:03 +00:00
return ( curr_offset - offset ) ;
}
2011-04-04 14:37:25 +00:00
guint16 ( * rp_elem_fcn [ ] ) ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo , guint32 offset , guint len , gchar * add_string , int string_len ) = {
2008-08-04 19:44:03 +00:00
/* Short Message Service Information Elements [5] 8.2 */
2014-10-04 15:28:35 +00:00
de_rp_message_ref , /* RP-Message Reference */
de_rp_orig_addr , /* RP-Originator Address */
de_rp_dest_addr , /* RP-Destination Address */
de_rp_user_data , /* RP-User Data */
de_rp_cause , /* RP-Cause */
2008-08-04 19:44:03 +00:00
NULL , /* NONE */
} ;
/* MESSAGE FUNCTIONS */
/*
* [ 5 ] 7.3 .1 .1
*/
2012-06-12 21:36:55 +00:00
void
2011-04-04 14:37:25 +00:00
rp_data_n_ms ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo , guint32 offset , guint len )
2008-08-04 19:44:03 +00:00
{
guint32 curr_offset ;
guint32 consumed ;
guint curr_len ;
curr_offset = offset ;
curr_len = len ;
2011-04-04 14:37:25 +00:00
pinfo - > p2p_dir = P2P_DIR_SENT ;
2008-08-04 19:44:03 +00:00
2017-06-14 18:14:30 +00:00
ELEM_MAND_V ( GSM_A_PDU_TYPE_RP , DE_RP_MESSAGE_REF , NULL , ei_gsm_a_rp_missing_mandatory_element ) ;
2008-08-04 19:44:03 +00:00
2017-06-14 18:14:30 +00:00
ELEM_MAND_LV ( GSM_A_PDU_TYPE_RP , DE_RP_ORIG_ADDR , NULL , ei_gsm_a_rp_missing_mandatory_element ) ;
2008-08-04 19:44:03 +00:00
2017-06-14 18:14:30 +00:00
ELEM_MAND_LV ( GSM_A_PDU_TYPE_RP , DE_RP_DEST_ADDR , NULL , ei_gsm_a_rp_missing_mandatory_element ) ;
2008-08-04 19:44:03 +00:00
2017-06-14 18:14:30 +00:00
ELEM_MAND_LV ( GSM_A_PDU_TYPE_RP , DE_RP_USER_DATA , NULL , ei_gsm_a_rp_missing_mandatory_element ) ;
2008-08-04 19:44:03 +00:00
2015-01-02 17:19:10 +00:00
EXTRANEOUS_DATA_CHECK ( curr_len , 0 , pinfo , & ei_gsm_a_rp_extraneous_data ) ;
2008-08-04 19:44:03 +00:00
}
/*
* [ 5 ] 7.3 .1 .2
*/
static void
2011-04-04 14:37:25 +00:00
rp_data_ms_n ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo , guint32 offset , guint len )
2008-08-04 19:44:03 +00:00
{
guint32 curr_offset ;
guint32 consumed ;
guint curr_len ;
curr_offset = offset ;
curr_len = len ;
2011-04-04 14:37:25 +00:00
pinfo - > p2p_dir = P2P_DIR_RECV ;
2008-08-04 19:44:03 +00:00
2017-06-14 18:14:30 +00:00
ELEM_MAND_V ( GSM_A_PDU_TYPE_RP , DE_RP_MESSAGE_REF , NULL , ei_gsm_a_rp_missing_mandatory_element ) ;
2008-08-04 19:44:03 +00:00
2017-06-14 18:14:30 +00:00
ELEM_MAND_LV ( GSM_A_PDU_TYPE_RP , DE_RP_ORIG_ADDR , NULL , ei_gsm_a_rp_missing_mandatory_element ) ;
2008-08-04 19:44:03 +00:00
2017-06-14 18:14:30 +00:00
ELEM_MAND_LV ( GSM_A_PDU_TYPE_RP , DE_RP_DEST_ADDR , NULL , ei_gsm_a_rp_missing_mandatory_element ) ;
2008-08-04 19:44:03 +00:00
2017-06-14 18:14:30 +00:00
ELEM_MAND_LV ( GSM_A_PDU_TYPE_RP , DE_RP_USER_DATA , NULL , ei_gsm_a_rp_missing_mandatory_element ) ;
2008-08-04 19:44:03 +00:00
2015-01-02 17:19:10 +00:00
EXTRANEOUS_DATA_CHECK ( curr_len , 0 , pinfo , & ei_gsm_a_rp_extraneous_data ) ;
2008-08-04 19:44:03 +00:00
}
/*
* [ 5 ] 7.3 .2
*/
static void
2011-04-04 14:37:25 +00:00
rp_smma ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len )
2008-08-04 19:44:03 +00:00
{
guint32 curr_offset ;
guint32 consumed ;
guint curr_len ;
curr_offset = offset ;
curr_len = len ;
2017-06-14 18:14:30 +00:00
ELEM_MAND_V ( GSM_A_PDU_TYPE_RP , DE_RP_MESSAGE_REF , NULL , ei_gsm_a_rp_missing_mandatory_element ) ;
2008-08-04 19:44:03 +00:00
2015-01-02 17:19:10 +00:00
EXTRANEOUS_DATA_CHECK ( curr_len , 0 , pinfo , & ei_gsm_a_rp_extraneous_data ) ;
2008-08-04 19:44:03 +00:00
}
/*
* [ 5 ] 7.3 .3
*/
static void
2011-04-04 14:37:25 +00:00
rp_ack_n_ms ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo , guint32 offset , guint len )
2008-08-04 19:44:03 +00:00
{
guint32 curr_offset ;
guint32 consumed ;
guint curr_len ;
curr_offset = offset ;
curr_len = len ;
2011-04-04 14:37:25 +00:00
pinfo - > p2p_dir = P2P_DIR_SENT ;
2008-08-04 19:44:03 +00:00
2017-06-14 18:14:30 +00:00
ELEM_MAND_V ( GSM_A_PDU_TYPE_RP , DE_RP_MESSAGE_REF , NULL , ei_gsm_a_rp_missing_mandatory_element ) ;
2008-08-04 19:44:03 +00:00
2009-08-04 21:05:38 +00:00
ELEM_OPT_TLV ( 0x41 , GSM_A_PDU_TYPE_RP , DE_RP_USER_DATA , NULL ) ;
2008-08-04 19:44:03 +00:00
2015-01-02 17:19:10 +00:00
EXTRANEOUS_DATA_CHECK ( curr_len , 0 , pinfo , & ei_gsm_a_rp_extraneous_data ) ;
2008-08-04 19:44:03 +00:00
}
/*
* [ 5 ] 7.3 .3
*/
static void
2011-04-04 14:37:25 +00:00
rp_ack_ms_n ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo , guint32 offset , guint len )
2008-08-04 19:44:03 +00:00
{
guint32 curr_offset ;
guint32 consumed ;
guint curr_len ;
curr_offset = offset ;
curr_len = len ;
2011-04-04 14:37:25 +00:00
pinfo - > p2p_dir = P2P_DIR_RECV ;
2008-08-04 19:44:03 +00:00
2017-06-14 18:14:30 +00:00
ELEM_MAND_V ( GSM_A_PDU_TYPE_RP , DE_RP_MESSAGE_REF , NULL , ei_gsm_a_rp_missing_mandatory_element ) ;
2008-08-04 19:44:03 +00:00
2009-08-04 21:05:38 +00:00
ELEM_OPT_TLV ( 0x41 , GSM_A_PDU_TYPE_RP , DE_RP_USER_DATA , NULL ) ;
2008-08-04 19:44:03 +00:00
2015-01-02 17:19:10 +00:00
EXTRANEOUS_DATA_CHECK ( curr_len , 0 , pinfo , & ei_gsm_a_rp_extraneous_data ) ;
2008-08-04 19:44:03 +00:00
}
/*
* [ 5 ] 7.3 .4
*/
static void
2011-04-04 14:37:25 +00:00
rp_error_n_ms ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo , guint32 offset , guint len )
2008-08-04 19:44:03 +00:00
{
guint32 curr_offset ;
guint32 consumed ;
guint curr_len ;
curr_offset = offset ;
curr_len = len ;
2011-04-04 14:37:25 +00:00
pinfo - > p2p_dir = P2P_DIR_SENT ;
2008-08-04 19:44:03 +00:00
2017-06-14 18:14:30 +00:00
ELEM_MAND_V ( GSM_A_PDU_TYPE_RP , DE_RP_MESSAGE_REF , NULL , ei_gsm_a_rp_missing_mandatory_element ) ;
2008-08-04 19:44:03 +00:00
2017-06-14 18:14:30 +00:00
ELEM_MAND_LV ( GSM_A_PDU_TYPE_RP , DE_RP_CAUSE , NULL , ei_gsm_a_rp_missing_mandatory_element ) ;
2008-08-04 19:44:03 +00:00
2009-08-04 21:05:38 +00:00
ELEM_OPT_TLV ( 0x41 , GSM_A_PDU_TYPE_RP , DE_RP_USER_DATA , NULL ) ;
2008-08-04 19:44:03 +00:00
2015-01-02 17:19:10 +00:00
EXTRANEOUS_DATA_CHECK ( curr_len , 0 , pinfo , & ei_gsm_a_rp_extraneous_data ) ;
2008-08-04 19:44:03 +00:00
}
/*
* [ 5 ] 7.3 .4
*/
static void
2011-04-04 14:37:25 +00:00
rp_error_ms_n ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo , guint32 offset , guint len )
2008-08-04 19:44:03 +00:00
{
guint32 curr_offset ;
guint32 consumed ;
guint curr_len ;
curr_offset = offset ;
curr_len = len ;
2011-04-04 14:37:25 +00:00
pinfo - > p2p_dir = P2P_DIR_RECV ;
2008-08-04 19:44:03 +00:00
2017-06-14 18:14:30 +00:00
ELEM_MAND_V ( GSM_A_PDU_TYPE_RP , DE_RP_MESSAGE_REF , NULL , ei_gsm_a_rp_missing_mandatory_element ) ;
2008-08-04 19:44:03 +00:00
2017-06-14 18:14:30 +00:00
ELEM_MAND_LV ( GSM_A_PDU_TYPE_RP , DE_RP_CAUSE , NULL , ei_gsm_a_rp_missing_mandatory_element ) ;
2008-08-04 19:44:03 +00:00
2009-08-04 21:05:38 +00:00
ELEM_OPT_TLV ( 0x41 , GSM_A_PDU_TYPE_RP , DE_RP_USER_DATA , NULL ) ;
2008-08-04 19:44:03 +00:00
2015-01-02 17:19:10 +00:00
EXTRANEOUS_DATA_CHECK ( curr_len , 0 , pinfo , & ei_gsm_a_rp_extraneous_data ) ;
2008-08-04 19:44:03 +00:00
}
# define NUM_GSM_RP_MSG (sizeof(gsm_rp_msg_strings) / sizeof(value_string))
static gint ett_gsm_rp_msg [ NUM_GSM_RP_MSG ] ;
2011-04-04 14:37:25 +00:00
static void ( * rp_msg_fcn [ ] ) ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len ) = {
2008-08-04 19:44:03 +00:00
rp_data_ms_n , /* RP-DATA (MS to Network) */
2012-06-12 21:36:55 +00:00
rp_data_n_ms , /* RP-DATA (Network to MS) */
2008-08-04 19:44:03 +00:00
rp_ack_ms_n , /* RP-ACK (MS to Network) */
rp_ack_n_ms , /* RP-ACK (Network to MS) */
rp_error_ms_n , /* RP-ERROR (MS to Network) */
rp_error_n_ms , /* RP-ERROR (Network to MS) */
rp_smma , /* RP-SMMA (MS to Network) */
NULL , /* NONE */
} ;
/* GENERIC DISSECTOR FUNCTIONS */
2015-11-23 03:59:08 +00:00
static int
dissect_rp ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data _U_ )
2008-08-04 19:44:03 +00:00
{
2014-10-04 15:28:35 +00:00
guint8 oct ;
guint32 offset , saved_offset ;
guint32 len ;
gint idx ;
proto_item * rp_item = NULL ;
proto_tree * rp_tree = NULL ;
const gchar * str ;
2008-08-04 19:44:03 +00:00
2009-09-24 20:00:21 +00:00
col_append_str ( pinfo - > cinfo , COL_INFO , " (RP) " ) ;
2008-08-04 19:44:03 +00:00
offset = 0 ;
saved_offset = offset ;
g_tree = tree ;
2014-11-03 15:19:10 +00:00
len = tvb_reported_length ( tvb ) ;
2008-08-04 19:44:03 +00:00
/*
* add RP message name
*/
oct = tvb_get_guint8 ( tvb , offset + + ) ;
2013-03-29 00:26:23 +00:00
str = try_val_to_str_idx ( ( guint32 ) oct , gsm_rp_msg_strings , & idx ) ;
2008-08-04 19:44:03 +00:00
/*
* create the protocol tree
*/
if ( str = = NULL )
{
2008-09-05 05:49:39 +00:00
rp_item =
proto_tree_add_protocol_format ( tree , proto_a_rp , tvb , 0 , len ,
" GSM A-I/F RP - Unknown RP Message Type (0x%02x) " ,
oct ) ;
2008-08-04 19:44:03 +00:00
2008-09-05 05:49:39 +00:00
rp_tree = proto_item_add_subtree ( rp_item , ett_rp_msg ) ;
2008-08-04 19:44:03 +00:00
}
else
{
2008-09-05 05:49:39 +00:00
rp_item =
proto_tree_add_protocol_format ( tree , proto_a_rp , tvb , 0 , - 1 ,
" GSM A-I/F RP - %s " ,
str ) ;
2008-08-04 19:44:03 +00:00
2008-09-05 05:49:39 +00:00
rp_tree = proto_item_add_subtree ( rp_item , ett_gsm_rp_msg [ idx ] ) ;
2008-08-04 19:44:03 +00:00
2011-04-04 14:37:25 +00:00
col_append_fstr ( pinfo - > cinfo , COL_INFO , " %s " , str ) ;
2008-08-04 19:44:03 +00:00
}
/*
* add RP message name
*/
proto_tree_add_uint_format ( rp_tree , hf_gsm_a_rp_msg_type ,
tvb , saved_offset , 1 , oct , " Message Type %s " , str ? str : " (Unknown) " ) ;
2015-11-23 03:59:08 +00:00
if ( str = = NULL ) return offset ;
2008-08-04 19:44:03 +00:00
2015-11-23 03:59:08 +00:00
if ( offset > = len ) return offset ;
2008-08-04 19:44:03 +00:00
/*
* decode elements
*/
if ( rp_msg_fcn [ idx ] = = NULL )
{
2014-10-15 16:55:08 +00:00
proto_tree_add_item ( rp_tree , hf_gsm_a_rp_message_elements , tvb , offset , len - offset , ENC_NA ) ;
2008-08-04 19:44:03 +00:00
}
else
{
2011-04-04 14:37:25 +00:00
( * rp_msg_fcn [ idx ] ) ( tvb , rp_tree , pinfo , offset , len - offset ) ;
2008-08-04 19:44:03 +00:00
}
2015-11-23 03:59:08 +00:00
return tvb_captured_length ( tvb ) ;
2008-08-04 19:44:03 +00:00
}
/* Register the protocol with Wireshark */
void
proto_register_gsm_a_rp ( void )
{
2014-10-04 15:28:35 +00:00
guint i ;
guint last_offset ;
2008-08-04 19:44:03 +00:00
/* Setup list of header fields */
2014-10-04 15:28:35 +00:00
static hf_register_info hf [ ] = {
{ & hf_gsm_a_rp_msg_type ,
{ " RP Message Type " , " gsm_a.rp.msg_type " ,
FT_UINT8 , BASE_HEX , VALS ( gsm_rp_msg_strings ) , 0x0 ,
NULL , HFILL }
} ,
{ & hf_gsm_a_rp_elem_id ,
{ " Element ID " , " gsm_a.rp.elem_id " ,
FT_UINT8 , BASE_HEX , NULL , 0 ,
NULL , HFILL }
} ,
2014-10-15 16:55:08 +00:00
/* Generated from convert_proto_tree_add_text.pl */
{ & hf_gsm_a_rp_rp_message_reference , { " RP-Message Reference " , " gsm_a.rp.rp_message_reference " , FT_UINT8 , BASE_HEX_DEC , NULL , 0x0 , NULL , HFILL } } ,
{ & hf_gsm_a_rp_tpdu , { " TPDU " , " gsm_a.rp.tpdu " , FT_BYTES , BASE_NONE , NULL , 0x0 , NULL , HFILL } } ,
{ & hf_gsm_a_rp_extension , { " Extension " , " gsm_a.rp.extension " , FT_BOOLEAN , 8 , TFS ( & tfs_extended_no_extension ) , 0x80 , NULL , HFILL } } ,
{ & hf_gsm_a_rp_cause , { " Cause " , " gsm_a.rp.cause " , FT_UINT8 , BASE_DEC | BASE_EXT_STRING , & gsm_rp_cause_vals_ext , 0x7F , NULL , HFILL } } ,
{ & hf_gsm_a_rp_diagnostic_field , { " Diagnostic field " , " gsm_a.rp.diagnostic_field " , FT_BYTES , BASE_NONE , NULL , 0x0 , NULL , HFILL } } ,
{ & hf_gsm_a_rp_message_elements , { " Message Elements " , " gsm_a.rp.message_elements " , FT_BYTES , BASE_NONE , NULL , 0x0 , NULL , HFILL } } ,
2008-08-04 19:44:03 +00:00
} ;
2015-01-02 17:19:10 +00:00
static ei_register_info ei [ ] = {
{ & ei_gsm_a_rp_extraneous_data , { " gsm_a.rp.extraneous_data " , PI_PROTOCOL , PI_NOTE , " Extraneous Data, dissector bug or later version spec(report to wireshark.org) " , EXPFILL } } ,
2017-06-14 18:14:30 +00:00
{ & ei_gsm_a_rp_missing_mandatory_element , { " gsm_a.rp.missing_mandatory_element " , PI_PROTOCOL , PI_ERROR , " Missing Mandatory element, rest of dissection is suspect " , EXPFILL } } ,
2015-01-02 17:19:10 +00:00
} ;
expert_module_t * expert_gsm_a_rp ;
2008-08-04 19:44:03 +00:00
/* Setup protocol subtree array */
2008-08-19 08:05:04 +00:00
# define NUM_INDIVIDUAL_ELEMS 1
2009-09-15 17:37:54 +00:00
gint * ett [ NUM_INDIVIDUAL_ELEMS +
NUM_GSM_RP_MSG +
NUM_GSM_RP_ELEM ] ;
2013-10-13 19:56:52 +00:00
2008-08-04 19:44:03 +00:00
ett [ 0 ] = & ett_rp_msg ;
last_offset = NUM_INDIVIDUAL_ELEMS ;
for ( i = 0 ; i < NUM_GSM_RP_MSG ; i + + , last_offset + + )
{
2008-09-05 05:49:39 +00:00
ett_gsm_rp_msg [ i ] = - 1 ;
ett [ last_offset ] = & ett_gsm_rp_msg [ i ] ;
2008-08-04 19:44:03 +00:00
}
for ( i = 0 ; i < NUM_GSM_RP_ELEM ; i + + , last_offset + + )
{
2008-09-05 05:49:39 +00:00
ett_gsm_rp_elem [ i ] = - 1 ;
ett [ last_offset ] = & ett_gsm_rp_elem [ i ] ;
2008-08-04 19:44:03 +00:00
}
/* Register the protocol name and description */
2015-01-02 17:19:10 +00:00
proto_a_rp = proto_register_protocol ( " GSM A-I/F RP " , " GSM RP " , " gsm_a.rp " ) ;
2008-08-04 19:44:03 +00:00
proto_register_field_array ( proto_a_rp , hf , array_length ( hf ) ) ;
proto_register_subtree_array ( ett , array_length ( ett ) ) ;
2015-01-02 17:19:10 +00:00
expert_gsm_a_rp = expert_register_protocol ( proto_a_rp ) ;
expert_register_field_array ( expert_gsm_a_rp , ei , array_length ( ei ) ) ;
2008-08-04 19:44:03 +00:00
2015-12-09 04:04:01 +00:00
register_dissector ( " gsm_a_rp " , dissect_rp , proto_a_rp ) ;
2008-08-04 19:44:03 +00:00
}
void
proto_reg_handoff_gsm_a_rp ( void )
{
2014-10-04 15:28:35 +00:00
dissector_handle_t gsm_a_rp_handle ;
2010-03-01 18:03:37 +00:00
2015-12-09 03:49:44 +00:00
gsm_a_rp_handle = create_dissector_handle ( dissect_rp , proto_a_rp ) ;
2010-03-01 18:03:37 +00:00
/* Dissect messages embedded in SIP */
dissector_add_string ( " media_type " , " application/vnd.3gpp.sms " , gsm_a_rp_handle ) ;
2016-03-16 13:02:52 +00:00
gsm_sms_handle = find_dissector_add_dependency ( " gsm_sms " , proto_a_rp ) ;
2008-08-04 19:44:03 +00:00
}
2014-10-04 15:28:35 +00:00
/*
2019-07-26 18:43:17 +00:00
* Editor modelines - https : //www.wireshark.org/tools/modelines.html
2014-10-04 15:28:35 +00:00
*
* Local variables :
* c - basic - offset : 8
* tab - width : 8
* indent - tabs - mode : t
* End :
*
* vi : set shiftwidth = 8 tabstop = 8 noexpandtab :
* : indentSize = 8 : tabSize = 8 : noTabs = false :
*/