2005-03-22 15:41:40 +00:00
/* packet-camel-template.c
* Routines for Camel
* Copyright 2004 , Tim Endean < endeant @ hotmail . com >
* Copyright 2005 , Olivier Jacques < olivier . jacques @ hp . com >
2009-03-16 10:14:44 +00:00
* Copyright 2005 , Javier Acuna < javier . acuna @ sixbell . com >
2005-11-25 20:18:36 +00:00
* Updated to ETSI TS 129 07 8 V6 .4 .0 ( 2004 - 3 GPP TS 29.078 version 6.4 .0 Release 6 1 12 )
2010-01-26 16:52:19 +00:00
* Copyright 2005 - 2010 , Anders Broman < anders . broman @ ericsson . com >
2006-12-19 22:07:08 +00:00
* Updated to 3 GPP TS 29.078 version 7.3 .0 Release 7 ( 2006 - 06 )
2005-03-22 15:41:40 +00:00
* Built from the gsm - map dissector Copyright 2004 , Anders Broman < anders . broman @ ericsson . com >
*
2006-05-21 05:12:17 +00:00
* Wireshark - Network traffic analyzer
* By Gerald Combs < gerald @ wireshark . org >
2005-03-22 15:41:40 +00:00
* Copyright 1998 Gerald Combs
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
2012-06-28 22:56:06 +00:00
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA .
2005-03-22 15:41:40 +00:00
* References : ETSI 300 374
*/
2011-10-21 02:10:19 +00:00
/*
* Indentation logic : this file is indented with 2 spaces indentation .
2005-03-22 15:41:40 +00:00
* there are no tabs .
*/
2012-09-20 01:29:52 +00:00
# include "config.h"
2005-03-22 15:41:40 +00:00
2014-12-23 05:32:58 +00:00
# include <stdlib.h>
2005-03-22 15:41:40 +00:00
# include <epan/packet.h>
# include <epan/prefs.h>
2007-08-25 01:14:24 +00:00
# include <epan/oids.h>
2005-03-22 15:41:40 +00:00
# include <epan/tap.h>
Further refactor SRT stats.
Create "common" SRT tap data collection intended for all GUIs. Refactor/merge functionality of existing dissectors that have SRT support (AFP, DCERPC, Diameter, FC, GTP, LDAP, NCP, RPC, SCIS, SMB, and SMB2) for both TShark and GTK.
SMB and DCERPC "tap packet filtering" were different between TShark and GTK, so I went with GTK filter logic.
CAMEL "tap packet filtering" was different between TShark and GTK, so GTK filtering logic was pushed to the dissector and the TShark tap was left alone.
Change-Id: I7d6eaad0673fe628ef337f9165d7ed94f4a5e1cc
Reviewed-on: https://code.wireshark.org/review/8894
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-06-16 21:07:04 +00:00
# include <epan/srt_table.h>
2015-08-04 15:56:28 +00:00
# include <epan/stat_tap_ui.h>
2007-05-13 20:58:29 +00:00
# include <epan/asn1.h>
2009-08-21 20:32:50 +00:00
# include <epan/expert.h>
2005-03-22 15:41:40 +00:00
# include "packet-ber.h"
# include "packet-camel.h"
# include "packet-q931.h"
# include "packet-e164.h"
# include "packet-isup.h"
2005-04-01 09:20:39 +00:00
# include "packet-gsm_map.h"
2011-04-06 06:20:32 +00:00
# include "packet-gsm_a_common.h"
2007-07-05 13:18:28 +00:00
# include "packet-inap.h"
2005-12-17 16:55:45 +00:00
# include "packet-tcap.h"
2005-03-22 15:41:40 +00:00
# define PNAME "Camel"
# define PSNAME "CAMEL"
# define PFNAME "camel"
/* Initialize the protocol and registered fields */
2009-10-11 16:24:29 +00:00
static int proto_camel = - 1 ;
2005-05-08 20:34:57 +00:00
int date_format = 1 ; /*assume european date format */
2006-10-04 16:02:59 +00:00
int camel_tap = - 1 ;
2007-02-17 20:04:10 +00:00
/* Global variables */
static guint32 opcode = 0 ;
static guint32 errorCode = 0 ;
2011-11-02 18:10:34 +00:00
static guint32 camel_ver = 0 ;
2013-12-30 22:07:38 +00:00
/* When several Camel components are received in a single TCAP message,
we have to use several buffers for the stored parameters
because else this data are erased during TAP dissector call */
# define MAX_CAMEL_INSTANCE 10
static int camelsrt_global_current = 0 ;
static struct camelsrt_info_t camelsrt_global_info [ MAX_CAMEL_INSTANCE ] ;
2007-08-29 16:10:47 +00:00
/* ROSE context */
static rose_ctx_t camel_rose_ctx ;
2006-10-04 16:02:59 +00:00
2011-10-21 02:10:19 +00:00
static int hf_digit = - 1 ;
2007-07-05 13:18:28 +00:00
static int hf_camel_extension_code_local = - 1 ;
static int hf_camel_error_code_local = - 1 ;
2005-04-15 08:18:15 +00:00
static int hf_camel_cause_indicator = - 1 ;
2006-01-20 19:34:53 +00:00
static int hf_camel_PDPTypeNumber_etsi = - 1 ;
static int hf_camel_PDPTypeNumber_ietf = - 1 ;
static int hf_camel_PDPAddress_IPv4 = - 1 ;
static int hf_camel_PDPAddress_IPv6 = - 1 ;
2006-01-22 21:16:33 +00:00
static int hf_camel_cellGlobalIdOrServiceAreaIdFixedLength = - 1 ;
2006-08-21 21:58:30 +00:00
static int hf_camel_RP_Cause = - 1 ;
2007-07-24 17:20:44 +00:00
static int hf_camel_CAMEL_AChBillingChargingCharacteristics = - 1 ;
static int hf_camel_CAMEL_FCIBillingChargingCharacteristics = - 1 ;
static int hf_camel_CAMEL_FCIGPRSBillingChargingCharacteristics = - 1 ;
static int hf_camel_CAMEL_FCISMSBillingChargingCharacteristics = - 1 ;
static int hf_camel_CAMEL_SCIBillingChargingCharacteristics = - 1 ;
static int hf_camel_CAMEL_SCIGPRSBillingChargingCharacteristics = - 1 ;
static int hf_camel_CAMEL_CallResult = - 1 ;
2006-08-21 21:58:30 +00:00
2013-12-30 22:07:38 +00:00
/* Used by persistent data */
static int hf_camelsrt_SessionId = - 1 ;
static int hf_camelsrt_RequestNumber = - 1 ;
static int hf_camelsrt_Duplicate = - 1 ;
static int hf_camelsrt_RequestFrame = - 1 ;
static int hf_camelsrt_ResponseFrame = - 1 ;
static int hf_camelsrt_DeltaTime = - 1 ;
static int hf_camelsrt_SessionTime = - 1 ;
static int hf_camelsrt_DeltaTime31 = - 1 ;
static int hf_camelsrt_DeltaTime75 = - 1 ;
static int hf_camelsrt_DeltaTime65 = - 1 ;
static int hf_camelsrt_DeltaTime22 = - 1 ;
static int hf_camelsrt_DeltaTime35 = - 1 ;
static int hf_camelsrt_DeltaTime80 = - 1 ;
2007-07-05 13:18:28 +00:00
# include "packet-camel-hf.c"
2006-10-04 16:02:59 +00:00
static struct camelsrt_info_t * gp_camelsrt_info ;
2007-02-17 20:04:10 +00:00
/* Forward declarations */
2007-05-13 20:58:29 +00:00
static int dissect_invokeData ( proto_tree * tree , tvbuff_t * tvb , int offset , asn1_ctx_t * actx ) ;
static int dissect_returnResultData ( proto_tree * tree , tvbuff_t * tvb , int offset , asn1_ctx_t * actx ) ;
static int dissect_returnErrorData ( proto_tree * tree , tvbuff_t * tvb , int offset , asn1_ctx_t * actx ) ;
2007-07-05 13:18:28 +00:00
static int dissect_camel_CAMEL_AChBillingChargingCharacteristics ( gboolean implicit_tag _U_ , tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) ;
2011-11-02 18:10:34 +00:00
static int dissect_camel_CAMEL_AChBillingChargingCharacteristicsV2 ( gboolean implicit_tag _U_ , tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) ;
2007-07-05 21:29:53 +00:00
static int dissect_camel_CAMEL_CallResult ( gboolean implicit_tag _U_ , tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) ;
2015-08-25 10:45:01 +00:00
static int dissect_camel_EstablishTemporaryConnectionArgV2 ( gboolean implicit_tag _U_ , tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) ;
2005-03-22 15:41:40 +00:00
2013-12-30 22:31:04 +00:00
/* XXX - can we get rid of these and always do the SRT work? */
2013-12-30 22:07:38 +00:00
static gboolean gcamel_HandleSRT = FALSE ;
static gboolean gcamel_PersistentSRT = FALSE ;
static gboolean gcamel_DisplaySRT = FALSE ;
2013-12-30 22:31:04 +00:00
gboolean gcamel_StatSRT = FALSE ;
2006-10-04 16:02:59 +00:00
2005-03-22 15:41:40 +00:00
/* Initialize the subtree pointers */
static gint ett_camel = - 1 ;
static gint ett_camelisup_parameter = - 1 ;
2006-01-17 21:52:30 +00:00
static gint ett_camel_AccessPointName = - 1 ;
2006-01-20 19:34:53 +00:00
static gint ett_camel_pdptypenumber = - 1 ;
2007-07-24 17:20:44 +00:00
static gint ett_camel_cause = - 1 ;
static gint ett_camel_RPcause = - 1 ;
2006-10-04 16:02:59 +00:00
static gint ett_camel_stat = - 1 ;
2011-11-02 18:10:34 +00:00
static gint ett_camel_calledpartybcdnumber = - 1 ;
static gint ett_camel_callingpartynumber = - 1 ;
static gint ett_camel_locationnumber = - 1 ;
2015-02-04 12:24:57 +00:00
static gint ett_camel_additionalcallingpartynumber = - 1 ;
2006-01-17 21:52:30 +00:00
2005-03-22 15:41:40 +00:00
# include "packet-camel-ett.c"
2013-06-03 03:42:36 +00:00
static expert_field ei_camel_unknown_invokeData = EI_INIT ;
static expert_field ei_camel_unknown_returnResultData = EI_INIT ;
static expert_field ei_camel_unknown_returnErrorData = EI_INIT ;
2005-03-22 15:41:40 +00:00
/* Preference settings default */
# define MAX_SSN 254
static range_t * global_ssn_range ;
2006-12-07 20:34:08 +00:00
static dissector_handle_t camel_handle ;
2011-11-02 18:10:34 +00:00
static dissector_handle_t camel_v1_handle ;
static dissector_handle_t camel_v2_handle ;
2005-03-22 15:41:40 +00:00
/* Global variables */
2005-03-28 02:53:49 +00:00
static int application_context_version ;
2006-01-20 19:34:53 +00:00
static guint8 PDPTypeOrganization ;
static guint8 PDPTypeNumber ;
2007-07-05 13:18:28 +00:00
const char * camel_obj_id = NULL ;
gboolean is_ExtensionField = FALSE ;
2013-12-30 22:07:38 +00:00
/* Global hash tables*/
static GHashTable * srt_calls = NULL ;
static guint32 camelsrt_global_SessionId = 1 ;
2007-07-05 13:18:28 +00:00
static int camel_opcode_type ;
# define CAMEL_OPCODE_INVOKE 1
# define CAMEL_OPCODE_RETURN_RESULT 2
# define CAMEL_OPCODE_RETURN_ERROR 3
# define CAMEL_OPCODE_REJECT 4
static const value_string camel_Component_vals [ ] = {
{ 1 , " invoke " } ,
{ 2 , " returnResultLast " } ,
{ 3 , " returnError " } ,
{ 4 , " reject " } ,
{ 0 , NULL }
} ;
2005-03-22 15:41:40 +00:00
2013-12-30 22:07:38 +00:00
const value_string camelSRTtype_naming [ ] = {
{ CAMELSRT_SESSION , " TCAP_Session " } ,
{ CAMELSRT_VOICE_INITIALDP , " InialDP/Continue " } ,
{ CAMELSRT_VOICE_ACR1 , " Slice1_ACR/ACH " } ,
{ CAMELSRT_VOICE_ACR2 , " Slice2_ACR/ACH " } ,
{ CAMELSRT_VOICE_ACR3 , " Slice3_ACR/ACH " } ,
{ CAMELSRT_VOICE_DISC , " EvtRepBSCM/Release " } ,
{ CAMELSRT_SMS_INITIALDP , " InitialDP/ContinueSMS " } ,
{ CAMELSRT_GPRS_INITIALDP , " InitialDP/ContinueGPRS " } ,
{ CAMELSRT_GPRS_REPORT , " EvtRepGPRS/ContinueGPRS " } ,
{ 0 , NULL }
} ;
2013-11-22 14:52:04 +00:00
#if 0
2005-03-22 15:41:40 +00:00
static const true_false_string camel_extension_value = {
" No Extension " ,
" Extension "
} ;
2013-11-22 14:52:04 +00:00
# endif
2005-05-08 20:34:57 +00:00
# define EUROPEAN_DATE 1
# define AMERICAN_DATE 2
2005-09-08 15:01:16 +00:00
# define CAMEL_DATE_AND_TIME_LEN 20 /* 2*5 + 4 + 5 + 1 (HH:MM:SS;mm/dd/yyyy) */
2005-05-08 20:34:57 +00:00
2012-11-29 20:15:37 +00:00
static const enum_val_t date_options [ ] = {
2005-05-08 20:34:57 +00:00
{ " european " , " DD/MM/YYYY " , EUROPEAN_DATE } ,
{ " american " , " MM/DD/YYYY " , AMERICAN_DATE } ,
{ NULL , NULL , 0 }
} ;
static const value_string digit_value [ ] = {
2015-08-20 19:38:19 +00:00
{ 0 , " 0 " } ,
{ 1 , " 1 " } ,
{ 2 , " 2 " } ,
{ 3 , " 3 " } ,
{ 4 , " 4 " } ,
{ 5 , " 5 " } ,
{ 6 , " 6 " } ,
{ 7 , " 7 " } ,
{ 8 , " 8 " } ,
{ 9 , " 9 " } ,
{ 10 , " spare " } ,
{ 11 , " spare " } ,
{ 12 , " spare " } ,
{ 13 , " spare " } ,
{ 0 , NULL }
} ;
2011-10-21 02:10:19 +00:00
2013-11-22 14:52:04 +00:00
#if 0
2005-04-15 08:18:15 +00:00
static const value_string camel_nature_of_addr_indicator_values [ ] = {
2005-03-22 15:41:40 +00:00
{ 0x00 , " unknown " } ,
{ 0x01 , " International Number " } ,
{ 0x02 , " National Significant Number " } ,
{ 0x03 , " Network Specific Number " } ,
{ 0x04 , " Subscriber Number " } ,
{ 0x05 , " Reserved " } ,
{ 0x06 , " Abbreviated Number " } ,
{ 0x07 , " Reserved for extension " } ,
{ 0 , NULL }
} ;
static const value_string camel_number_plan_values [ ] = {
{ 0x00 , " unknown " } ,
{ 0x01 , " ISDN/Telephony Numbering (Rec ITU-T E.164) " } ,
{ 0x02 , " spare " } ,
{ 0x03 , " Data Numbering (ITU-T Rec. X.121) " } ,
{ 0x04 , " Telex Numbering (ITU-T Rec. F.69) " } ,
{ 0x05 , " spare " } ,
{ 0x06 , " Land Mobile Numbering (ITU-T Rec. E.212) " } ,
{ 0x07 , " spare " } ,
{ 0x08 , " National Numbering " } ,
{ 0x09 , " Private Numbering " } ,
{ 0x0f , " Reserved for extension " } ,
{ 0 , NULL }
} ;
2013-11-22 14:52:04 +00:00
# endif
2005-03-22 15:41:40 +00:00
/* End includes from old" packet-camel.c */
2006-08-21 21:58:30 +00:00
static const value_string camel_RP_Cause_values [ ] = {
{ 1 , " Unassigned (unallocated) number " } ,
{ 8 , " Operator determined barring " } ,
{ 10 , " Call barred " } ,
{ 11 , " Reserved " } ,
{ 21 , " Short message transfer rejected " } ,
{ 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 " } ,
{ 22 , " Memory capacity exceeded " } ,
{ 0 , NULL }
} ;
2007-07-07 22:24:37 +00:00
2008-01-03 11:12:38 +00:00
static const value_string camel_holdTreatmentIndicator_values [ ] = {
{ 0x01 , " acceptHoldRequest " } ,
{ 0x02 , " rejectHoldRequest " } ,
{ 0 , NULL }
} ;
static const value_string camel_cwTreatmentIndicator_values [ ] = {
{ 0x01 , " acceptCw " } ,
{ 0x02 , " rejectCw " } ,
{ 0 , NULL }
} ;
static const value_string camel_ectTreatmentIndicator_values [ ] = {
{ 0x01 , " acceptEctRequest " } ,
{ 0x02 , " rejectEctRequest " } ,
{ 0 , NULL }
} ;
2007-07-05 13:18:28 +00:00
# include "packet-camel-val.h"
2006-08-21 21:58:30 +00:00
2007-07-07 22:24:37 +00:00
# include "packet-camel-table.c"
2007-02-17 20:04:10 +00:00
2013-12-30 22:07:38 +00:00
/*
* DEBUG fonctions
*/
# undef DEBUG_CAMELSRT
/* #define DEBUG_CAMELSRT */
# ifdef DEBUG_CAMELSRT
# include <stdio.h>
# include <stdarg.h>
static guint debug_level = 99 ;
static void dbg ( guint level , char * fmt , . . . ) {
va_list ap ;
if ( level > debug_level ) return ;
va_start ( ap , fmt ) ;
vfprintf ( stderr , fmt , ap ) ;
va_end ( ap ) ;
}
# endif
Further refactor SRT stats.
Create "common" SRT tap data collection intended for all GUIs. Refactor/merge functionality of existing dissectors that have SRT support (AFP, DCERPC, Diameter, FC, GTP, LDAP, NCP, RPC, SCIS, SMB, and SMB2) for both TShark and GTK.
SMB and DCERPC "tap packet filtering" were different between TShark and GTK, so I went with GTK filter logic.
CAMEL "tap packet filtering" was different between TShark and GTK, so GTK filtering logic was pushed to the dissector and the TShark tap was left alone.
Change-Id: I7d6eaad0673fe628ef337f9165d7ed94f4a5e1cc
Reviewed-on: https://code.wireshark.org/review/8894
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-06-16 21:07:04 +00:00
static void
camelstat_init ( struct register_srt * srt _U_ , GArray * srt_array , srt_gui_init_cb gui_callback , void * gui_data )
{
srt_stat_table * camel_srt_table ;
gchar * tmp_str ;
guint32 i ;
camel_srt_table = init_srt_table ( " CAMEL Commands " , NULL , srt_array , NB_CAMELSRT_CATEGORY , NULL , NULL , gui_callback , gui_data , NULL ) ;
for ( i = 0 ; i < NB_CAMELSRT_CATEGORY ; i + + )
{
tmp_str = val_to_str_wmem ( NULL , i , camelSRTtype_naming , " Unknown (%d) " ) ;
init_srt_table_row ( camel_srt_table , i , tmp_str ) ;
wmem_free ( NULL , tmp_str ) ;
}
}
2015-08-04 15:56:28 +00:00
static gboolean
Further refactor SRT stats.
Create "common" SRT tap data collection intended for all GUIs. Refactor/merge functionality of existing dissectors that have SRT support (AFP, DCERPC, Diameter, FC, GTP, LDAP, NCP, RPC, SCIS, SMB, and SMB2) for both TShark and GTK.
SMB and DCERPC "tap packet filtering" were different between TShark and GTK, so I went with GTK filter logic.
CAMEL "tap packet filtering" was different between TShark and GTK, so GTK filtering logic was pushed to the dissector and the TShark tap was left alone.
Change-Id: I7d6eaad0673fe628ef337f9165d7ed94f4a5e1cc
Reviewed-on: https://code.wireshark.org/review/8894
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-06-16 21:07:04 +00:00
camelstat_packet ( void * pcamel , packet_info * pinfo , epan_dissect_t * edt _U_ , const void * psi )
{
guint idx = 0 ;
srt_stat_table * camel_srt_table ;
const struct camelsrt_info_t * pi = ( const struct camelsrt_info_t * ) psi ;
srt_data_t * data = ( srt_data_t * ) pcamel ;
int i ;
for ( i = 1 ; i < NB_CAMELSRT_CATEGORY ; i + + ) {
if ( pi - > bool_msginfo [ i ] & &
pi - > msginfo [ i ] . is_delta_time
& & pi - > msginfo [ i ] . request_available
& & ! pi - > msginfo [ i ] . is_duplicate )
{
camel_srt_table = g_array_index ( data - > srt_array , srt_stat_table * , idx ) ;
add_srt_table_data ( camel_srt_table , i , & pi - > msginfo [ i ] . req_time , pinfo ) ;
}
} /* category */
2015-08-04 15:56:28 +00:00
return TRUE ;
Further refactor SRT stats.
Create "common" SRT tap data collection intended for all GUIs. Refactor/merge functionality of existing dissectors that have SRT support (AFP, DCERPC, Diameter, FC, GTP, LDAP, NCP, RPC, SCIS, SMB, and SMB2) for both TShark and GTK.
SMB and DCERPC "tap packet filtering" were different between TShark and GTK, so I went with GTK filter logic.
CAMEL "tap packet filtering" was different between TShark and GTK, so GTK filtering logic was pushed to the dissector and the TShark tap was left alone.
Change-Id: I7d6eaad0673fe628ef337f9165d7ed94f4a5e1cc
Reviewed-on: https://code.wireshark.org/review/8894
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-06-16 21:07:04 +00:00
}
2007-02-17 20:04:10 +00:00
static char camel_number_to_char ( int number )
2005-05-08 20:34:57 +00:00
{
2015-08-04 15:56:28 +00:00
if ( number < 10 )
return ( char ) ( number + 48 ) ; /* this is ASCII specific */
else
return ( char ) ( number + 55 ) ;
2005-05-08 20:34:57 +00:00
}
2005-03-22 15:41:40 +00:00
2006-08-21 21:58:30 +00:00
/*
* 24.011 8.2 .5 .4
2011-10-21 02:10:19 +00:00
*/
2006-08-21 21:58:30 +00:00
static guint8
2006-10-26 21:31:48 +00:00
dissect_RP_cause_ie ( tvbuff_t * tvb , guint32 offset , _U_ guint len ,
2015-08-20 19:38:19 +00:00
proto_tree * tree , int hf_cause_value , guint8 * cause_value )
2006-08-21 21:58:30 +00:00
{
2015-08-20 19:38:19 +00:00
guint8 oct ;
guint32 curr_offset ;
2006-08-21 21:58:30 +00:00
static char a_bigbuf [ 1024 ] ;
2011-10-21 02:10:19 +00:00
2006-08-21 21:58:30 +00:00
curr_offset = offset ;
oct = tvb_get_guint8 ( tvb , curr_offset ) ;
2011-10-21 02:10:19 +00:00
* cause_value = oct & 0x7f ;
2006-08-21 21:58:30 +00:00
other_decode_bitfield_value ( a_bigbuf , oct , 0x7f , 8 ) ;
proto_tree_add_uint_format ( tree , hf_cause_value ,
2015-08-20 19:38:19 +00:00
tvb , curr_offset , 1 , * cause_value ,
" %s : %s " ,
a_bigbuf ,
val_to_str ( * cause_value , camel_RP_Cause_values ,
" Unknown Cause (%u), treated as (41) \" Temporary failure \" for MO-SMS or (111) \" Protocol error,unspecified \" for MT-SMS " ) ) ;
2006-08-21 21:58:30 +00:00
curr_offset + + ;
2011-10-21 02:10:19 +00:00
2006-08-21 21:58:30 +00:00
if ( ( oct & 0x80 ) ) {
oct = tvb_get_guint8 ( tvb , curr_offset ) ;
proto_tree_add_uint_format ( tree , hf_cause_value ,
2015-08-20 19:38:19 +00:00
tvb , curr_offset , 1 , oct ,
" Diagnostic : %u " , oct ) ;
2006-08-21 21:58:30 +00:00
curr_offset + + ;
}
return ( curr_offset - offset ) ;
}
2011-11-02 18:10:34 +00:00
static int dissect_camel_InitialDPArgExtensionV2 ( gboolean implicit_tag _U_ , tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) ;
2007-07-05 13:18:28 +00:00
# include "packet-camel-fn.c"
2005-03-22 15:41:40 +00:00
2007-07-07 22:24:37 +00:00
# include "packet-camel-table2.c"
2005-03-22 15:41:40 +00:00
2013-12-30 22:07:38 +00:00
/*
* Functions needed for Hash - Table
*/
/* compare 2 keys */
static gint
camelsrt_call_equal ( gconstpointer k1 , gconstpointer k2 )
{
const struct camelsrt_call_info_key_t * key1 = ( const struct camelsrt_call_info_key_t * ) k1 ;
const struct camelsrt_call_info_key_t * key2 = ( const struct camelsrt_call_info_key_t * ) k2 ;
return ( key1 - > SessionIdKey = = key2 - > SessionIdKey ) ;
}
/* calculate a hash key */
static guint
camelsrt_call_hash ( gconstpointer k )
{
const struct camelsrt_call_info_key_t * key = ( const struct camelsrt_call_info_key_t * ) k ;
return key - > SessionIdKey ;
}
/*
* Find the dialog by Key and Time
*/
static struct camelsrt_call_t *
find_camelsrt_call ( struct camelsrt_call_info_key_t * p_camelsrt_call_key )
{
struct camelsrt_call_t * p_camelsrt_call = NULL ;
p_camelsrt_call = ( struct camelsrt_call_t * ) g_hash_table_lookup ( srt_calls , p_camelsrt_call_key ) ;
# ifdef DEBUG_CAMELSRT
if ( p_camelsrt_call ) {
dbg ( 10 , " D%d " , p_camelsrt_call - > session_id ) ;
} else {
dbg ( 23 , " Not in hash " ) ;
}
# endif
return p_camelsrt_call ;
}
/*
* Initialize the data per call for the Service Response Time Statistics
* Data are linked to a Camel operation in a TCAP transaction
*/
static void
raz_camelsrt_call ( struct camelsrt_call_t * p_camelsrt_call )
{
memset ( p_camelsrt_call , 0 , sizeof ( struct camelsrt_call_t ) ) ;
}
/*
* New record to create , to identify a new transaction
*/
static struct camelsrt_call_t *
new_camelsrt_call ( struct camelsrt_call_info_key_t * p_camelsrt_call_key )
{
struct camelsrt_call_info_key_t * p_new_camelsrt_call_key ;
struct camelsrt_call_t * p_new_camelsrt_call = NULL ;
/* Register the transaction in the hash table
with the tcap transaction Id as main Key
Once created , this entry will be updated later */
2015-01-16 13:29:57 +00:00
p_new_camelsrt_call_key = wmem_new ( wmem_file_scope ( ) , struct camelsrt_call_info_key_t ) ;
2013-12-30 22:07:38 +00:00
p_new_camelsrt_call_key - > SessionIdKey = p_camelsrt_call_key - > SessionIdKey ;
2015-01-16 13:29:57 +00:00
p_new_camelsrt_call = wmem_new ( wmem_file_scope ( ) , struct camelsrt_call_t ) ;
2013-12-30 22:07:38 +00:00
raz_camelsrt_call ( p_new_camelsrt_call ) ;
p_new_camelsrt_call - > session_id = camelsrt_global_SessionId + + ;
# ifdef DEBUG_CAMELSRT
dbg ( 10 , " D%d " , p_new_camelsrt_call - > session_id ) ;
# endif
/* store it */
g_hash_table_insert ( srt_calls , p_new_camelsrt_call_key , p_new_camelsrt_call ) ;
return p_new_camelsrt_call ;
}
/*
* Routine called when the TAP is initialized .
* so hash table are ( re ) created
*/
2015-06-27 22:33:42 +00:00
static void
2013-12-30 22:07:38 +00:00
camelsrt_init_routine ( void )
{
/* create new hash-table for SRT */
srt_calls = g_hash_table_new ( camelsrt_call_hash , camelsrt_call_equal ) ;
/* Reset the session counter */
camelsrt_global_SessionId = 1 ;
/* The Display of SRT is enable
* 1 ) For wireshark only if Persistent Stat is enable
* 2 ) For Tshark , if the SRT handling is enable
*/
gcamel_DisplaySRT = gcamel_PersistentSRT | | gcamel_HandleSRT & gcamel_StatSRT ;
}
2015-06-27 22:33:42 +00:00
static void
camelsrt_cleanup_routine ( void )
{
/* free hash-table for SRT */
g_hash_table_destroy ( srt_calls ) ;
}
2013-12-30 22:07:38 +00:00
/*
* Update a record with the data of the Request
*/
static void
update_camelsrt_call ( struct camelsrt_call_t * p_camelsrt_call , packet_info * pinfo ,
2015-08-20 19:38:19 +00:00
guint msg_category )
2013-12-30 22:07:38 +00:00
{
p_camelsrt_call - > category [ msg_category ] . req_num = pinfo - > fd - > num ;
p_camelsrt_call - > category [ msg_category ] . rsp_num = 0 ;
p_camelsrt_call - > category [ msg_category ] . responded = FALSE ;
p_camelsrt_call - > category [ msg_category ] . req_time = pinfo - > fd - > abs_ts ;
}
/*
* Update the Camel session info , and close the session .
* Then remove the associated context , if we do not have persistentSRT enable
*/
static void
camelsrt_close_call_matching ( packet_info * pinfo ,
2015-08-20 19:38:19 +00:00
struct camelsrt_info_t * p_camelsrt_info )
2013-12-30 22:07:38 +00:00
{
struct camelsrt_call_t * p_camelsrt_call ;
struct camelsrt_call_info_key_t camelsrt_call_key ;
nstime_t delta ;
p_camelsrt_info - > bool_msginfo [ CAMELSRT_SESSION ] = TRUE ;
# ifdef DEBUG_CAMELSRT
dbg ( 10 , " \n Session end #%u \n " , pinfo - > fd - > num ) ;
# endif
/* look only for matching request, if matching conversation is available. */
camelsrt_call_key . SessionIdKey = p_camelsrt_info - > tcap_session_id ;
# ifdef DEBUG_CAMELSRT
dbg ( 11 , " Search key %lu " , camelsrt_call_key . SessionIdKey ) ;
# endif
p_camelsrt_call = find_camelsrt_call ( & camelsrt_call_key ) ;
if ( p_camelsrt_call ) {
# ifdef DEBUG_CAMELSRT
dbg ( 12 , " Found " ) ;
# endif
/* Calculate Service Response Time */
nstime_delta ( & delta , & pinfo - > fd - > abs_ts , & p_camelsrt_call - > category [ CAMELSRT_SESSION ] . req_time ) ;
p_camelsrt_call - > category [ CAMELSRT_SESSION ] . responded = TRUE ;
p_camelsrt_info - > msginfo [ CAMELSRT_SESSION ] . request_available = TRUE ;
p_camelsrt_info - > msginfo [ CAMELSRT_SESSION ] . is_delta_time = TRUE ;
p_camelsrt_info - > msginfo [ CAMELSRT_SESSION ] . delta_time = delta ; /* give it to tap */
p_camelsrt_info - > msginfo [ CAMELSRT_SESSION ] . req_time = p_camelsrt_call - > category [ CAMELSRT_SESSION ] . req_time ;
if ( ! gcamel_PersistentSRT ) {
g_hash_table_remove ( srt_calls , & camelsrt_call_key ) ;
# ifdef DEBUG_CAMELSRT
dbg ( 20 , " remove hash " ) ;
# endif
} else {
# ifdef DEBUG_CAMELSRT
dbg ( 20 , " keep hash " ) ;
# endif
}
} /* call reference found */
}
/*
* Callback function for the TCAP dissector
* This callback function is used to inform the camel layer , that the session
* has been Closed or Aborted by a TCAP message without Camel component
* So , we can close the context for camel session , and update the stats .
*/
static void
camelsrt_tcap_matching ( tvbuff_t * tvb _U_ , packet_info * pinfo ,
2015-08-20 19:38:19 +00:00
proto_tree * tree _U_ ,
struct tcaphash_context_t * p_tcap_context )
2013-12-30 22:07:38 +00:00
{
struct camelsrt_info_t * p_camelsrt_info ;
# ifdef DEBUG_CAMELSRT
dbg ( 11 , " Camel_CallBack " ) ;
# endif
p_camelsrt_info = camelsrt_razinfo ( ) ;
p_camelsrt_info - > tcap_context = p_tcap_context ;
if ( p_tcap_context ) {
# ifdef DEBUG_CAMELSRT
dbg ( 11 , " Close TCAP " ) ;
# endif
p_camelsrt_info - > tcap_session_id = p_tcap_context - > session_id ;
camelsrt_close_call_matching ( pinfo , p_camelsrt_info ) ;
tap_queue_packet ( camel_tap , pinfo , p_camelsrt_info ) ;
}
}
/*
* Create the record identifiying the Camel session
* As the Tcap session id given by the TCAP dissector is uniq , it will be
* used as main key .
*/
static void
camelsrt_begin_call_matching ( packet_info * pinfo ,
2015-08-20 19:38:19 +00:00
struct camelsrt_info_t * p_camelsrt_info )
2013-12-30 22:07:38 +00:00
{
struct camelsrt_call_t * p_camelsrt_call ;
struct camelsrt_call_info_key_t camelsrt_call_key ;
p_camelsrt_info - > bool_msginfo [ CAMELSRT_SESSION ] = TRUE ;
/* prepare the key data */
camelsrt_call_key . SessionIdKey = p_camelsrt_info - > tcap_session_id ;
/* look up the request */
# ifdef DEBUG_CAMELSRT
dbg ( 10 , " \n Session begin #%u \n " , pinfo - > fd - > num ) ;
dbg ( 11 , " Search key %lu " , camelsrt_call_key . SessionIdKey ) ;
# endif
p_camelsrt_call = ( struct camelsrt_call_t * ) g_hash_table_lookup ( srt_calls , & camelsrt_call_key ) ;
if ( p_camelsrt_call ) {
/* We have seen this request before -> do nothing */
# ifdef DEBUG_CAMELSRT
dbg ( 22 , " Already seen " ) ;
# endif
} else { /* p_camelsrt_call has not been found */
# ifdef DEBUG_CAMELSRT
dbg ( 10 , " New key %lu " , camelsrt_call_key . SessionIdKey ) ;
# endif
p_camelsrt_call = new_camelsrt_call ( & camelsrt_call_key ) ;
p_camelsrt_call - > tcap_context = ( struct tcaphash_context_t * ) p_camelsrt_info - > tcap_context ;
update_camelsrt_call ( p_camelsrt_call , pinfo , CAMELSRT_SESSION ) ;
# ifdef DEBUG_CAMELSRT
dbg ( 11 , " Update Callback " ) ;
# endif
p_camelsrt_call - > tcap_context - > callback = camelsrt_tcap_matching ;
}
}
/*
* Register the request , and try to find the response
*
*/
static void
camelsrt_request_call_matching ( tvbuff_t * tvb , packet_info * pinfo ,
2015-08-20 19:38:19 +00:00
proto_tree * tree ,
struct camelsrt_info_t * p_camelsrt_info ,
guint srt_type )
2013-12-30 22:07:38 +00:00
{
struct camelsrt_call_t * p_camelsrt_call ;
struct camelsrt_call_info_key_t camelsrt_call_key ;
proto_item * ti , * hidden_item ;
# ifdef DEBUG_CAMELSRT
dbg ( 10 , " \n %s #%u \n " , val_to_str_const ( srt_type , camelSRTtype_naming , " Unk " ) , pinfo - > fd - > num ) ;
# endif
/* look only for matching request, if matching conversation is available. */
camelsrt_call_key . SessionIdKey = p_camelsrt_info - > tcap_session_id ;
# ifdef DEBUG_CAMELSRT
dbg ( 11 , " Search key %lu " , camelsrt_call_key . SessionIdKey ) ;
# endif
p_camelsrt_call = find_camelsrt_call ( & camelsrt_call_key ) ;
if ( p_camelsrt_call ) {
# ifdef DEBUG_CAMELSRT
dbg ( 12 , " Found " ) ;
# endif
if ( gcamel_DisplaySRT )
proto_tree_add_uint ( tree , hf_camelsrt_SessionId , tvb , 0 , 0 , p_camelsrt_call - > session_id ) ;
/* Hmm.. As there are several slices ApplyChargingReport/ApplyCharging
* we will prepare the measurement for 3 slices with 3 categories */
if ( srt_type = = CAMELSRT_VOICE_ACR1 ) {
if ( p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR1 ] . req_num = = 0 ) {
2015-08-20 19:38:19 +00:00
srt_type = CAMELSRT_VOICE_ACR1 ;
2013-12-30 22:07:38 +00:00
} else if ( ( p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR2 ] . req_num = = 0 )
2015-08-20 19:38:19 +00:00
& & ( p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR1 ] . rsp_num ! = 0 )
& & ( p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR1 ] . rsp_num < pinfo - > fd - > num ) ) {
srt_type = CAMELSRT_VOICE_ACR2 ;
2013-12-30 22:07:38 +00:00
} else if ( ( p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR3 ] . req_num = = 0 )
2015-08-20 19:38:19 +00:00
& & ( p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR2 ] . rsp_num ! = 0 )
& & ( p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR2 ] . rsp_num < pinfo - > fd - > num ) ) {
srt_type = CAMELSRT_VOICE_ACR3 ;
2013-12-30 22:07:38 +00:00
} else if ( p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR1 ] . rsp_num ! = 0
2015-08-20 19:38:19 +00:00
& & p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR1 ] . rsp_num > pinfo - > fd - > num ) {
srt_type = CAMELSRT_VOICE_ACR1 ;
2013-12-30 22:07:38 +00:00
} else if ( p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR2 ] . rsp_num ! = 0
2015-08-20 19:38:19 +00:00
& & p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR2 ] . rsp_num > pinfo - > fd - > num ) {
srt_type = CAMELSRT_VOICE_ACR2 ;
2013-12-30 22:07:38 +00:00
} else if ( p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR1 ] . rsp_num ! = 0
2015-08-20 19:38:19 +00:00
& & p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR3 ] . rsp_num > pinfo - > fd - > num ) {
srt_type = CAMELSRT_VOICE_ACR3 ;
2013-12-30 22:07:38 +00:00
}
# ifdef DEBUG_CAMELSRT
dbg ( 70 , " Request ACR %u " , srt_type ) ;
dbg ( 70 , " ACR1 %u %u " , p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR1 ] . req_num , p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR1 ] . rsp_num ) ;
dbg ( 70 , " ACR2 %u %u " , p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR2 ] . req_num , p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR2 ] . rsp_num ) ;
dbg ( 70 , " ACR3 %u %u " , p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR3 ] . req_num , p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR3 ] . rsp_num ) ;
# endif
} /* not ACR */
p_camelsrt_info - > bool_msginfo [ srt_type ] = TRUE ;
if ( p_camelsrt_call - > category [ srt_type ] . req_num = = 0 ) {
/* We have not yet seen a request to that call, so this must be the first request
2015-08-20 19:38:19 +00:00
remember its frame number . */
2013-12-30 22:07:38 +00:00
# ifdef DEBUG_CAMELSRT
dbg ( 5 , " Set reqlink #%u " , pinfo - > fd - > num ) ;
# endif
update_camelsrt_call ( p_camelsrt_call , pinfo , srt_type ) ;
} else {
/* We have seen a request to this call - but was it *this* request? */
if ( p_camelsrt_call - > category [ srt_type ] . req_num ! = pinfo - > fd - > num ) {
2015-08-20 19:38:19 +00:00
if ( srt_type ! = CAMELSRT_VOICE_DISC ) {
/* No, so it's a duplicate request. Mark it as such. */
2013-12-30 22:07:38 +00:00
# ifdef DEBUG_CAMELSRT
2015-08-20 19:38:19 +00:00
dbg ( 21 , " Display_duplicate with req %d " , p_camelsrt_call - > category [ srt_type ] . req_num ) ;
2013-12-30 22:07:38 +00:00
# endif
2015-08-20 19:38:19 +00:00
p_camelsrt_info - > msginfo [ srt_type ] . is_duplicate = TRUE ;
if ( gcamel_DisplaySRT ) {
hidden_item = proto_tree_add_uint ( tree , hf_camelsrt_Duplicate , tvb , 0 , 0 , 77 ) ;
PROTO_ITEM_SET_HIDDEN ( hidden_item ) ;
}
} else {
/* Ignore duplicate frame */
if ( pinfo - > fd - > num > p_camelsrt_call - > category [ srt_type ] . req_num ) {
p_camelsrt_call - > category [ srt_type ] . req_num = pinfo - > fd - > num ;
2013-12-30 22:07:38 +00:00
# ifdef DEBUG_CAMELSRT
2015-08-20 19:38:19 +00:00
dbg ( 5 , " DISC Set reqlink #%u " , pinfo - > fd - > num ) ;
2013-12-30 22:07:38 +00:00
# endif
2015-08-20 19:38:19 +00:00
update_camelsrt_call ( p_camelsrt_call , pinfo , srt_type ) ;
} /* greater frame */
} /* DISC */
2013-12-30 22:07:38 +00:00
} /* req_num already seen */
} /* req_num != 0 */
/* add link to response frame, if available */
if ( gcamel_DisplaySRT & &
2015-08-20 19:38:19 +00:00
( p_camelsrt_call - > category [ srt_type ] . rsp_num ! = 0 ) & &
( p_camelsrt_call - > category [ srt_type ] . req_num ! = 0 ) & &
( p_camelsrt_call - > category [ srt_type ] . req_num = = pinfo - > fd - > num ) ) {
2013-12-30 22:07:38 +00:00
# ifdef DEBUG_CAMELSRT
dbg ( 20 , " Display_framersplink %d " , p_camelsrt_call - > category [ srt_type ] . rsp_num ) ;
# endif
ti = proto_tree_add_uint_format ( tree , hf_camelsrt_RequestFrame , tvb , 0 , 0 ,
2015-08-20 19:38:19 +00:00
p_camelsrt_call - > category [ srt_type ] . rsp_num ,
" Linked response %s in frame %u " ,
val_to_str_const ( srt_type , camelSRTtype_naming , " Unk " ) ,
p_camelsrt_call - > category [ srt_type ] . rsp_num ) ;
2013-12-30 22:07:38 +00:00
PROTO_ITEM_SET_GENERATED ( ti ) ;
} /* frame valid */
} /* call reference */
}
/*
* Display the delta time between two messages in a field corresponding
* to the category ( hf_camelsrt_DeltaTimexx ) .
*/
static void
camelsrt_display_DeltaTime ( proto_tree * tree , tvbuff_t * tvb , nstime_t * value_ptr ,
2015-08-20 19:38:19 +00:00
guint category )
2013-12-30 22:07:38 +00:00
{
proto_item * ti ;
if ( gcamel_DisplaySRT ) {
switch ( category ) {
case CAMELSRT_VOICE_INITIALDP :
ti = proto_tree_add_time ( tree , hf_camelsrt_DeltaTime31 , tvb , 0 , 0 , value_ptr ) ;
PROTO_ITEM_SET_GENERATED ( ti ) ;
break ;
case CAMELSRT_VOICE_ACR1 :
case CAMELSRT_VOICE_ACR2 :
case CAMELSRT_VOICE_ACR3 :
ti = proto_tree_add_time ( tree , hf_camelsrt_DeltaTime22 , tvb , 0 , 0 , value_ptr ) ;
PROTO_ITEM_SET_GENERATED ( ti ) ;
break ;
case CAMELSRT_VOICE_DISC :
ti = proto_tree_add_time ( tree , hf_camelsrt_DeltaTime35 , tvb , 0 , 0 , value_ptr ) ;
PROTO_ITEM_SET_GENERATED ( ti ) ;
break ;
case CAMELSRT_GPRS_INITIALDP :
ti = proto_tree_add_time ( tree , hf_camelsrt_DeltaTime75 , tvb , 0 , 0 , value_ptr ) ;
PROTO_ITEM_SET_GENERATED ( ti ) ;
break ;
case CAMELSRT_GPRS_REPORT :
ti = proto_tree_add_time ( tree , hf_camelsrt_DeltaTime80 , tvb , 0 , 0 , value_ptr ) ;
PROTO_ITEM_SET_GENERATED ( ti ) ;
break ;
case CAMELSRT_SMS_INITIALDP :
ti = proto_tree_add_time ( tree , hf_camelsrt_DeltaTime65 , tvb , 0 , 0 , value_ptr ) ;
PROTO_ITEM_SET_GENERATED ( ti ) ;
break ;
default :
break ;
}
}
}
/*
* Check if the received message is a response to a previous request
* registered is the camel session context .
*/
static void
camelsrt_report_call_matching ( tvbuff_t * tvb , packet_info * pinfo ,
2015-08-20 19:38:19 +00:00
proto_tree * tree ,
struct camelsrt_info_t * p_camelsrt_info ,
guint srt_type )
2013-12-30 22:07:38 +00:00
{
struct camelsrt_call_t * p_camelsrt_call ;
struct camelsrt_call_info_key_t camelsrt_call_key ;
nstime_t delta ;
proto_item * ti , * hidden_item ;
# ifdef DEBUG_CAMELSRT
dbg ( 10 , " \n %s #%u \n " , val_to_str_const ( srt_type , camelSRTtype_naming , " Unk " ) , pinfo - > fd - > num ) ;
# endif
camelsrt_call_key . SessionIdKey = p_camelsrt_info - > tcap_session_id ;
/* look only for matching request, if matching conversation is available. */
# ifdef DEBUG_CAMELSRT
dbg ( 11 , " Search key %lu " , camelsrt_call_key . SessionIdKey ) ;
# endif
p_camelsrt_call = find_camelsrt_call ( & camelsrt_call_key ) ;
if ( p_camelsrt_call ) {
# ifdef DEBUG_CAMELSRT
dbg ( 12 , " Found, req=%d " , p_camelsrt_call - > category [ srt_type ] . req_num ) ;
# endif
if ( gcamel_DisplaySRT )
proto_tree_add_uint ( tree , hf_camelsrt_SessionId , tvb , 0 , 0 , p_camelsrt_call - > session_id ) ;
if ( srt_type = = CAMELSRT_VOICE_ACR1 ) {
if ( p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR3 ] . req_num ! = 0
2015-08-20 19:38:19 +00:00
& & p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR3 ] . req_num < pinfo - > fd - > num ) {
srt_type = CAMELSRT_VOICE_ACR1 ;
2013-12-30 22:07:38 +00:00
} else if ( p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR2 ] . req_num ! = 0
2015-08-20 19:38:19 +00:00
& & p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR2 ] . req_num < pinfo - > fd - > num ) {
srt_type = CAMELSRT_VOICE_ACR2 ;
2013-12-30 22:07:38 +00:00
} else if ( p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR1 ] . req_num ! = 0
2015-08-20 19:38:19 +00:00
& & p_camelsrt_call - > category [ CAMELSRT_VOICE_ACR1 ] . req_num < pinfo - > fd - > num ) {
srt_type = CAMELSRT_VOICE_ACR1 ;
2013-12-30 22:07:38 +00:00
}
# ifdef DEBUG_CAMELSRT
dbg ( 70 , " Report ACR %u " , srt_type ) ;
# endif
} /* not ACR */
p_camelsrt_info - > bool_msginfo [ srt_type ] = TRUE ;
if ( p_camelsrt_call - > category [ srt_type ] . rsp_num = = 0 ) {
if ( ( p_camelsrt_call - > category [ srt_type ] . req_num ! = 0 )
2015-08-20 19:38:19 +00:00
& & ( pinfo - > fd - > num > p_camelsrt_call - > category [ srt_type ] . req_num ) ) {
/* We have not yet seen a response to that call, so this must be the first response;
remember its frame number only if response comes after request */
2013-12-30 22:07:38 +00:00
# ifdef DEBUG_CAMELSRT
2015-08-20 19:38:19 +00:00
dbg ( 14 , " Set reslink #%d req %u " , pinfo - > fd - > num , p_camelsrt_call - > category [ srt_type ] . req_num ) ;
2013-12-30 22:07:38 +00:00
# endif
2015-08-20 19:38:19 +00:00
p_camelsrt_call - > category [ srt_type ] . rsp_num = pinfo - > fd - > num ;
2013-12-30 22:07:38 +00:00
} else {
# ifdef DEBUG_CAMELSRT
2015-08-20 19:38:19 +00:00
dbg ( 2 , " badreslink #%u req %u " , pinfo - > fd - > num , p_camelsrt_call - > category [ srt_type ] . req_num ) ;
2013-12-30 22:07:38 +00:00
# endif
} /* req_num != 0 */
} else { /* rsp_num != 0 */
/* We have seen a response to this call - but was it *this* response? */
if ( p_camelsrt_call - > category [ srt_type ] . rsp_num ! = pinfo - > fd - > num ) {
2015-08-20 19:38:19 +00:00
/* No, so it's a duplicate response. Mark it as such. */
2013-12-30 22:07:38 +00:00
# ifdef DEBUG_CAMELSRT
2015-08-20 19:38:19 +00:00
dbg ( 21 , " Display_duplicate rsp=%d " , p_camelsrt_call - > category [ srt_type ] . rsp_num ) ;
2013-12-30 22:07:38 +00:00
# endif
2015-08-20 19:38:19 +00:00
p_camelsrt_info - > msginfo [ srt_type ] . is_duplicate = TRUE ;
if ( gcamel_DisplaySRT ) {
hidden_item = proto_tree_add_uint ( tree , hf_camelsrt_Duplicate , tvb , 0 , 0 , 77 ) ;
PROTO_ITEM_SET_HIDDEN ( hidden_item ) ;
}
2013-12-30 22:07:38 +00:00
}
} /* rsp_num != 0 */
if ( ( p_camelsrt_call - > category [ srt_type ] . req_num ! = 0 ) & &
2015-08-20 19:38:19 +00:00
( p_camelsrt_call - > category [ srt_type ] . rsp_num ! = 0 ) & &
( p_camelsrt_call - > category [ srt_type ] . rsp_num = = pinfo - > fd - > num ) ) {
2013-12-30 22:07:38 +00:00
p_camelsrt_call - > category [ srt_type ] . responded = TRUE ;
p_camelsrt_info - > msginfo [ srt_type ] . request_available = TRUE ;
# ifdef DEBUG_CAMELSRT
dbg ( 20 , " Display_frameReqlink %d " , p_camelsrt_call - > category [ srt_type ] . req_num ) ;
# endif
/* Indicate the frame to which this is a reply. */
if ( gcamel_DisplaySRT ) {
2015-08-20 19:38:19 +00:00
ti = proto_tree_add_uint_format ( tree , hf_camelsrt_ResponseFrame , tvb , 0 , 0 ,
p_camelsrt_call - > category [ srt_type ] . req_num ,
" Linked request %s in frame %u " ,
val_to_str_const ( srt_type , camelSRTtype_naming , " Unk " ) ,
p_camelsrt_call - > category [ srt_type ] . req_num ) ;
PROTO_ITEM_SET_GENERATED ( ti ) ;
2013-12-30 22:07:38 +00:00
}
/* Calculate Service Response Time */
nstime_delta ( & delta , & pinfo - > fd - > abs_ts , & p_camelsrt_call - > category [ srt_type ] . req_time ) ;
p_camelsrt_info - > msginfo [ srt_type ] . is_delta_time = TRUE ;
p_camelsrt_info - > msginfo [ srt_type ] . delta_time = delta ; /* give it to tap */
p_camelsrt_info - > msginfo [ srt_type ] . req_time = p_camelsrt_call - > category [ srt_type ] . req_time ;
/* display Service Response Time and make it filterable */
camelsrt_display_DeltaTime ( tree , tvb , & delta , srt_type ) ;
} /*req_num != 0 && not duplicate */
} /* call reference found */
}
/*
* Service Response Time analyze , called just after the camel dissector
* According to the camel operation , we
* - open / close a context for the camel session
* - look for a request , or look for the corresponding response
*/
void
camelsrt_call_matching ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree ,
2015-08-20 19:38:19 +00:00
struct camelsrt_info_t * p_camelsrt_info )
2013-12-30 22:07:38 +00:00
{
# ifdef DEBUG_CAMELSRT
dbg ( 10 , " tcap_session #%d " , p_camelsrt_info - > tcap_session_id ) ;
# endif
switch ( p_camelsrt_info - > opcode ) {
case 0 : /*InitialDP*/
camelsrt_begin_call_matching ( pinfo , p_camelsrt_info ) ;
camelsrt_request_call_matching ( tvb , pinfo , tree , p_camelsrt_info ,
2015-08-20 19:38:19 +00:00
CAMELSRT_VOICE_INITIALDP ) ;
2013-12-30 22:07:38 +00:00
break ;
case 60 : /*InitialDPSMS*/
camelsrt_begin_call_matching ( pinfo , p_camelsrt_info ) ;
camelsrt_request_call_matching ( tvb , pinfo , tree , p_camelsrt_info ,
2015-08-20 19:38:19 +00:00
CAMELSRT_SMS_INITIALDP ) ;
2013-12-30 22:07:38 +00:00
break ;
case 78 : /*InitialDPGPRS*/
camelsrt_begin_call_matching ( pinfo , p_camelsrt_info ) ;
camelsrt_request_call_matching ( tvb , pinfo , tree , p_camelsrt_info ,
2015-08-20 19:38:19 +00:00
CAMELSRT_GPRS_INITIALDP ) ;
2013-12-30 22:07:38 +00:00
break ;
case 23 : /*RequestReportBCSMEvent*/
break ;
case 63 : /*RequestReportSMSEvent*/
break ;
case 81 : /*RequestReportGPRSEvent*/
break ;
case 24 : /*EventReportBCSMEvent*/
camelsrt_request_call_matching ( tvb , pinfo , tree , p_camelsrt_info ,
2015-08-20 19:38:19 +00:00
CAMELSRT_VOICE_DISC ) ;
2013-12-30 22:07:38 +00:00
break ;
case 64 : /*EventReportSMS*/
/* Session has been explicity closed without TC_END */
camelsrt_close_call_matching ( pinfo , p_camelsrt_info ) ;
tcapsrt_close ( ( struct tcaphash_context_t * ) p_camelsrt_info - > tcap_context , pinfo ) ;
break ;
case 80 : /*EventReportGPRS*/
camelsrt_begin_call_matching ( pinfo , p_camelsrt_info ) ;
camelsrt_request_call_matching ( tvb , pinfo , tree , p_camelsrt_info ,
2015-08-20 19:38:19 +00:00
CAMELSRT_GPRS_REPORT ) ;
2013-12-30 22:07:38 +00:00
break ;
case 35 : /*ApplyCharging*/
camelsrt_report_call_matching ( tvb , pinfo , tree , p_camelsrt_info ,
2015-08-20 19:38:19 +00:00
CAMELSRT_VOICE_ACR1 ) ;
2013-12-30 22:07:38 +00:00
break ;
case 71 : /*ApplyChargingGPRS*/
break ;
case 36 : /*ApplyChargingReport*/
camelsrt_request_call_matching ( tvb , pinfo , tree , p_camelsrt_info ,
2015-08-20 19:38:19 +00:00
CAMELSRT_VOICE_ACR1 ) ;
2013-12-30 22:07:38 +00:00
break ;
case 72 : /*ApplyChargingReportGPRS*/
break ;
case 31 : /*Continue*/
camelsrt_report_call_matching ( tvb , pinfo , tree , p_camelsrt_info ,
2015-08-20 19:38:19 +00:00
CAMELSRT_VOICE_INITIALDP ) ;
2013-12-30 22:07:38 +00:00
break ;
case 65 : /*ContinueSMS*/
camelsrt_report_call_matching ( tvb , pinfo , tree , p_camelsrt_info ,
2015-08-20 19:38:19 +00:00
CAMELSRT_SMS_INITIALDP ) ;
2013-12-30 22:07:38 +00:00
break ;
case 75 : /*ContinueGPRS*/
camelsrt_report_call_matching ( tvb , pinfo , tree , p_camelsrt_info ,
2015-08-20 19:38:19 +00:00
CAMELSRT_GPRS_INITIALDP ) ;
2013-12-30 22:07:38 +00:00
camelsrt_report_call_matching ( tvb , pinfo , tree , p_camelsrt_info ,
2015-08-20 19:38:19 +00:00
CAMELSRT_GPRS_REPORT ) ;
2013-12-30 22:07:38 +00:00
break ;
case 22 : /*ReleaseCall*/
camelsrt_report_call_matching ( tvb , pinfo , tree , p_camelsrt_info ,
2015-08-20 19:38:19 +00:00
CAMELSRT_VOICE_DISC ) ;
2013-12-30 22:07:38 +00:00
/* Session has been closed by Network */
camelsrt_close_call_matching ( pinfo , p_camelsrt_info ) ;
break ;
case 66 : /*ReleaseSMS*/
/* Session has been closed by Network */
camelsrt_close_call_matching ( pinfo , p_camelsrt_info ) ;
tcapsrt_close ( ( struct tcaphash_context_t * ) p_camelsrt_info - > tcap_context , pinfo ) ;
break ;
case 79 : /*ReleaseGPRS*/
/* Session has been closed by Network */
camelsrt_close_call_matching ( pinfo , p_camelsrt_info ) ;
break ;
} /* switch opcode */
}
/*
* Initialize the Message Info used by the main dissector
* Data are linked to a TCAP transaction
*/
struct camelsrt_info_t *
camelsrt_razinfo ( void )
{
struct camelsrt_info_t * p_camelsrt_info ;
/* Global buffer for packet extraction */
camelsrt_global_current + + ;
if ( camelsrt_global_current = = MAX_CAMEL_INSTANCE ) {
camelsrt_global_current = 0 ;
}
p_camelsrt_info = & camelsrt_global_info [ camelsrt_global_current ] ;
memset ( p_camelsrt_info , 0 , sizeof ( struct camelsrt_info_t ) ) ;
p_camelsrt_info - > opcode = 255 ;
return p_camelsrt_info ;
}
2005-03-22 15:41:40 +00:00
static guint8 camel_pdu_type = 0 ;
static guint8 camel_pdu_size = 0 ;
2006-09-01 16:17:48 +00:00
2005-03-22 15:41:40 +00:00
static int
2013-10-28 13:36:49 +00:00
dissect_camel_camelPDU ( gboolean implicit_tag _U_ , tvbuff_t * tvb , int offset , asn1_ctx_t * actx _U_ , proto_tree * tree ,
int hf_index , struct tcap_private_t * p_private_tcap ) {
2005-03-22 15:41:40 +00:00
2011-11-02 18:10:34 +00:00
char * version_ptr ;
opcode = 0 ;
application_context_version = 0 ;
2013-10-28 13:36:49 +00:00
if ( p_private_tcap ! = NULL ) {
2011-11-02 18:10:34 +00:00
if ( p_private_tcap - > acv = = TRUE ) {
2014-01-14 08:30:45 +00:00
version_ptr = strrchr ( ( const char * ) p_private_tcap - > oid , ' . ' ) ;
2011-11-02 18:10:34 +00:00
if ( version_ptr )
application_context_version = atoi ( version_ptr + 1 ) ;
}
gp_camelsrt_info - > tcap_context = p_private_tcap - > context ;
if ( p_private_tcap - > context )
gp_camelsrt_info - > tcap_session_id = ( ( struct tcaphash_context_t * ) ( p_private_tcap - > context ) ) - > session_id ;
}
2005-03-22 15:41:40 +00:00
2011-11-02 18:10:34 +00:00
camel_pdu_type = tvb_get_guint8 ( tvb , offset ) & 0x0f ;
/* Get the length and add 2 */
camel_pdu_size = tvb_get_guint8 ( tvb , offset + 1 ) + 2 ;
2011-10-21 02:10:19 +00:00
2011-11-02 18:10:34 +00:00
/* Populate the info column with PDU type*/
col_add_str ( actx - > pinfo - > cinfo , COL_INFO , val_to_str ( camel_pdu_type , camel_Component_vals , " Unknown Camel (%u) " ) ) ;
col_append_str ( actx - > pinfo - > cinfo , COL_INFO , " " ) ;
2007-05-13 20:58:29 +00:00
2011-11-02 18:10:34 +00:00
is_ExtensionField = FALSE ;
offset = dissect_camel_ROS ( TRUE , tvb , offset , actx , tree , hf_index ) ;
return offset ;
}
2013-10-28 13:36:49 +00:00
static int
dissect_camel_v1 ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * parent_tree , void * data )
2011-11-02 18:10:34 +00:00
{
2014-06-21 01:35:40 +00:00
proto_item * item ;
2013-10-28 16:59:57 +00:00
proto_tree * tree = NULL , * stat_tree = NULL ;
2013-10-28 13:36:49 +00:00
struct tcap_private_t * p_private_tcap = ( struct tcap_private_t * ) data ;
2011-11-02 18:10:34 +00:00
asn1_ctx_t asn1_ctx ;
asn1_ctx_init ( & asn1_ctx , ASN1_ENC_BER , TRUE , pinfo ) ;
col_set_str ( pinfo - > cinfo , COL_PROTOCOL , " Camel-v1 " ) ;
camel_ver = 1 ;
2005-03-22 15:41:40 +00:00
2011-11-02 18:10:34 +00:00
/* create display subtree for the protocol */
if ( parent_tree ) {
item = proto_tree_add_item ( parent_tree , proto_camel , tvb , 0 , - 1 , ENC_NA ) ;
tree = proto_item_add_subtree ( item , ett_camel ) ;
}
/* camelsrt reset counter, and initialise global pointer
to store service response time related data */
gp_camelsrt_info = camelsrt_razinfo ( ) ;
2005-03-22 15:41:40 +00:00
2013-10-28 13:36:49 +00:00
dissect_camel_camelPDU ( FALSE , tvb , 0 , & asn1_ctx , tree , - 1 , p_private_tcap ) ;
2005-03-22 15:41:40 +00:00
2011-11-02 18:10:34 +00:00
/* If a Tcap context is associated to this transaction */
if ( gcamel_HandleSRT & &
gp_camelsrt_info - > tcap_context ) {
if ( gcamel_DisplaySRT & & tree ) {
2014-06-21 01:35:40 +00:00
stat_tree = proto_tree_add_subtree ( tree , tvb , 0 , 0 , ett_camel_stat , NULL , " Stat " ) ;
2011-11-02 18:10:34 +00:00
}
camelsrt_call_matching ( tvb , pinfo , stat_tree , gp_camelsrt_info ) ;
tap_queue_packet ( camel_tap , pinfo , gp_camelsrt_info ) ;
}
2005-03-22 15:41:40 +00:00
2014-06-19 19:27:47 +00:00
return tvb_captured_length ( tvb ) ;
2005-03-22 15:41:40 +00:00
}
2013-10-28 13:36:49 +00:00
static int
dissect_camel_v2 ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * parent_tree , void * data )
2011-11-02 18:10:34 +00:00
{
2014-06-21 01:35:40 +00:00
proto_item * item ;
2013-10-28 16:59:57 +00:00
proto_tree * tree = NULL , * stat_tree = NULL ;
2013-10-28 13:36:49 +00:00
struct tcap_private_t * p_private_tcap = ( struct tcap_private_t * ) data ;
2011-11-02 18:10:34 +00:00
asn1_ctx_t asn1_ctx ;
asn1_ctx_init ( & asn1_ctx , ASN1_ENC_BER , TRUE , pinfo ) ;
col_set_str ( pinfo - > cinfo , COL_PROTOCOL , " Camel-v2 " ) ;
camel_ver = 2 ;
/* create display subtree for the protocol */
if ( parent_tree ) {
item = proto_tree_add_item ( parent_tree , proto_camel , tvb , 0 , - 1 , ENC_NA ) ;
tree = proto_item_add_subtree ( item , ett_camel ) ;
2015-08-25 10:45:01 +00:00
proto_item_append_text ( item , " -V2 " ) ;
2011-11-02 18:10:34 +00:00
}
/* camelsrt reset counter, and initialise global pointer
to store service response time related data */
gp_camelsrt_info = camelsrt_razinfo ( ) ;
2013-10-28 13:36:49 +00:00
dissect_camel_camelPDU ( FALSE , tvb , 0 , & asn1_ctx , tree , - 1 , p_private_tcap ) ;
2011-11-02 18:10:34 +00:00
/* If a Tcap context is associated to this transaction */
if ( gcamel_HandleSRT & &
gp_camelsrt_info - > tcap_context ) {
if ( gcamel_DisplaySRT & & tree ) {
2014-06-21 01:35:40 +00:00
stat_tree = proto_tree_add_subtree ( tree , tvb , 0 , 0 , ett_camel_stat , NULL , " Stat " ) ;
2011-11-02 18:10:34 +00:00
}
camelsrt_call_matching ( tvb , pinfo , stat_tree , gp_camelsrt_info ) ;
tap_queue_packet ( camel_tap , pinfo , gp_camelsrt_info ) ;
}
2014-06-19 19:27:47 +00:00
return tvb_captured_length ( tvb ) ;
2011-11-02 18:10:34 +00:00
}
2007-08-29 16:10:47 +00:00
2013-10-28 13:36:49 +00:00
static int
dissect_camel ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * parent_tree , void * data )
2005-03-22 15:41:40 +00:00
{
2014-06-21 01:35:40 +00:00
proto_item * item ;
2013-10-28 16:59:57 +00:00
proto_tree * tree , * stat_tree = NULL ;
2013-10-28 13:36:49 +00:00
struct tcap_private_t * p_private_tcap = ( struct tcap_private_t * ) data ;
2007-05-13 20:58:29 +00:00
asn1_ctx_t asn1_ctx ;
asn1_ctx_init ( & asn1_ctx , ASN1_ENC_BER , TRUE , pinfo ) ;
2005-03-22 15:41:40 +00:00
2009-08-09 07:59:51 +00:00
col_set_str ( pinfo - > cinfo , COL_PROTOCOL , " Camel " ) ;
2005-03-22 15:41:40 +00:00
2011-11-02 18:10:34 +00:00
/* Unknown camel version */
camel_ver = 0 ;
2005-03-22 15:41:40 +00:00
/* create display subtree for the protocol */
2013-10-28 13:36:49 +00:00
item = proto_tree_add_item ( parent_tree , proto_camel , tvb , 0 , - 1 , ENC_NA ) ;
tree = proto_item_add_subtree ( item , ett_camel ) ;
2006-10-04 16:02:59 +00:00
/* camelsrt reset counter, and initialise global pointer
to store service response time related data */
gp_camelsrt_info = camelsrt_razinfo ( ) ;
2013-10-28 13:36:49 +00:00
dissect_camel_camelPDU ( FALSE , tvb , 0 , & asn1_ctx , tree , - 1 , p_private_tcap ) ;
2011-10-21 02:10:19 +00:00
2006-10-04 16:02:59 +00:00
/* If a Tcap context is associated to this transaction */
if ( gcamel_HandleSRT & &
gp_camelsrt_info - > tcap_context ) {
if ( gcamel_DisplaySRT & & tree ) {
2014-06-21 01:35:40 +00:00
stat_tree = proto_tree_add_subtree ( tree , tvb , 0 , 0 , ett_camel_stat , NULL , " Stat " ) ;
2006-10-04 16:02:59 +00:00
}
camelsrt_call_matching ( tvb , pinfo , stat_tree , gp_camelsrt_info ) ;
tap_queue_packet ( camel_tap , pinfo , gp_camelsrt_info ) ;
}
2013-10-28 13:36:49 +00:00
2014-06-19 19:27:47 +00:00
return tvb_captured_length ( tvb ) ;
2005-03-22 15:41:40 +00:00
}
2015-08-04 15:56:28 +00:00
/* TAP STAT INFO */
typedef enum
{
MESSAGE_TYPE_COLUMN = 0 ,
COUNT_COLUMN
} camel_stat_columns ;
static stat_tap_table_item camel_stat_fields [ ] = { { TABLE_ITEM_STRING , TAP_ALIGN_LEFT , " Message Type or Reason " , " %-25s " } , { TABLE_ITEM_UINT , TAP_ALIGN_RIGHT , " Count " , " %d " } } ;
2015-08-20 17:34:47 +00:00
static void camel_stat_init ( new_stat_tap_ui * new_stat , new_stat_tap_gui_init_cb gui_callback , void * gui_data )
2015-08-04 15:56:28 +00:00
{
int num_fields = sizeof ( camel_stat_fields ) / sizeof ( stat_tap_table_item ) ;
new_stat_tap_table * table = new_stat_tap_init_table ( " CAMEL Message Counters " , num_fields , 0 , NULL , gui_callback , gui_data ) ;
int i ;
stat_tap_table_item_type items [ sizeof ( camel_stat_fields ) / sizeof ( stat_tap_table_item ) ] ;
new_stat_tap_add_table ( new_stat , table ) ;
items [ MESSAGE_TYPE_COLUMN ] . type = TABLE_ITEM_STRING ;
items [ COUNT_COLUMN ] . type = TABLE_ITEM_UINT ;
items [ COUNT_COLUMN ] . value . uint_value = 0 ;
/* Add a row for each value type */
for ( i = 0 ; i < camel_MAX_NUM_OPR_CODES ; i + + )
{
const char * ocs = try_val_to_str ( i , camel_opr_code_strings ) ;
char * col_str ;
if ( ocs ) {
col_str = g_strdup_printf ( " Request %s " , ocs ) ;
} else {
col_str = g_strdup_printf ( " Unknown op code %d " , i ) ;
}
items [ MESSAGE_TYPE_COLUMN ] . value . string_value = col_str ;
new_stat_tap_init_table_row ( table , i , num_fields , items ) ;
}
}
static gboolean
camel_stat_packet ( void * tapdata , packet_info * pinfo _U_ , epan_dissect_t * edt _U_ , const void * csi_ptr )
{
new_stat_data_t * stat_data = ( new_stat_data_t * ) tapdata ;
const struct camelsrt_info_t * csi = ( const struct camelsrt_info_t * ) csi_ptr ;
new_stat_tap_table * table ;
stat_tap_table_item_type * msg_data ;
guint i = 0 ;
table = g_array_index ( stat_data - > new_stat_tap_data - > tables , new_stat_tap_table * , i ) ;
if ( csi - > opcode > = table - > num_elements )
return FALSE ;
msg_data = new_stat_tap_get_field_data ( table , csi - > opcode , COUNT_COLUMN ) ;
msg_data - > value . uint_value + + ;
new_stat_tap_set_field_data ( table , csi - > opcode , COUNT_COLUMN , msg_data ) ;
return TRUE ;
}
static void
camel_stat_reset ( new_stat_tap_table * table )
{
guint element ;
stat_tap_table_item_type * item_data ;
for ( element = 0 ; element < table - > num_elements ; element + + )
{
item_data = new_stat_tap_get_field_data ( table , element , COUNT_COLUMN ) ;
item_data - > value . uint_value = 0 ;
new_stat_tap_set_field_data ( table , element , COUNT_COLUMN , item_data ) ;
}
}
2015-08-06 18:23:55 +00:00
static void
camel_stat_free_table_item ( new_stat_tap_table * table _U_ , guint row _U_ , guint column , stat_tap_table_item_type * field_data )
{
if ( column ! = MESSAGE_TYPE_COLUMN ) return ;
g_free ( ( char * ) field_data - > value . string_value ) ;
}
2015-08-04 15:56:28 +00:00
2005-03-22 15:41:40 +00:00
/*--- proto_reg_handoff_camel ---------------------------------------*/
static void range_delete_callback ( guint32 ssn )
{
if ( ssn ) {
2005-12-17 16:55:45 +00:00
delete_itu_tcap_subdissector ( ssn , camel_handle ) ;
2005-03-22 15:41:40 +00:00
}
}
static void range_add_callback ( guint32 ssn )
{
if ( ssn ) {
2005-12-17 16:55:45 +00:00
add_itu_tcap_subdissector ( ssn , camel_handle ) ;
2005-03-22 15:41:40 +00:00
}
}
void proto_reg_handoff_camel ( void ) {
2008-11-07 17:13:25 +00:00
static gboolean camel_prefs_initialized = FALSE ;
static range_t * ssn_range ;
2005-03-22 15:41:40 +00:00
if ( ! camel_prefs_initialized ) {
2008-11-07 17:13:25 +00:00
2005-03-22 15:41:40 +00:00
camel_prefs_initialized = TRUE ;
2008-11-07 17:13:25 +00:00
camel_handle = find_dissector ( " camel " ) ;
2011-11-02 18:10:34 +00:00
camel_v1_handle = find_dissector ( " camel-v1 " ) ;
camel_v2_handle = find_dissector ( " camel-v2 " ) ;
2006-09-01 16:17:48 +00:00
2007-08-29 16:10:47 +00:00
2011-11-02 18:10:34 +00:00
register_ber_oid_dissector_handle ( " 0.4.0.0.1.0.50.0 " , camel_v1_handle , proto_camel , " CAP-v1-gsmSSF-to-gsmSCF-AC " ) ;
register_ber_oid_dissector_handle ( " 0.4.0.0.1.0.50.1 " , camel_v2_handle , proto_camel , " CAP-v2-gsmSSF-to-gsmSCF-AC " ) ;
register_ber_oid_dissector_handle ( " 0.4.0.0.1.0.51.1 " , camel_v2_handle , proto_camel , " CAP-v2-assist-gsmSSF-to-gsmSCF-AC " ) ;
register_ber_oid_dissector_handle ( " 0.4.0.0.1.0.52.1 " , camel_v2_handle , proto_camel , " CAP-v2-gsmSRF-to-gsmSCF-AC " ) ;
2007-08-29 16:10:47 +00:00
register_ber_oid_dissector_handle ( " 0.4.0.0.1.21.3.50 " , camel_handle , proto_camel , " cap3-gprssf-scfAC " ) ;
register_ber_oid_dissector_handle ( " 0.4.0.0.1.21.3.51 " , camel_handle , proto_camel , " cap3-gsmscf-gprsssfAC " ) ;
register_ber_oid_dissector_handle ( " 0.4.0.0.1.21.3.61 " , camel_handle , proto_camel , " cap3-sms-AC " ) ;
2008-11-07 17:13:25 +00:00
register_ber_oid_dissector_handle ( " 0.4.0.0.1.23.3.4 " , camel_handle , proto_camel , " capssf-scfGenericAC " ) ;
2007-08-29 16:10:47 +00:00
register_ber_oid_dissector_handle ( " 0.4.0.0.1.23.3.61 " , camel_handle , proto_camel , " cap4-sms-AC " ) ;
2011-10-21 02:10:19 +00:00
2007-07-23 23:02:54 +00:00
2007-07-05 13:18:28 +00:00
# include "packet-camel-dis-tab.c"
2005-03-22 15:41:40 +00:00
} else {
range_foreach ( ssn_range , range_delete_callback ) ;
2008-11-07 17:13:25 +00:00
g_free ( ssn_range ) ;
2005-03-22 15:41:40 +00:00
}
ssn_range = range_copy ( global_ssn_range ) ;
range_foreach ( ssn_range , range_add_callback ) ;
2011-10-21 02:10:19 +00:00
2005-03-22 15:41:40 +00:00
}
void proto_register_camel ( void ) {
module_t * camel_module ;
/* List of fields */
static hf_register_info hf [ ] = {
2007-07-05 13:18:28 +00:00
{ & hf_camel_extension_code_local ,
{ " local " , " camel.extension_code_local " ,
FT_INT32 , BASE_DEC , NULL , 0 ,
" Extension local code " , HFILL } } ,
2015-08-20 19:38:19 +00:00
{ & hf_camel_error_code_local ,
2007-07-05 13:18:28 +00:00
{ " local " , " camel.error_code_local " ,
FT_INT32 , BASE_DEC , VALS ( camel_err_code_string_vals ) , 0 ,
" ERROR code " , HFILL } } ,
2008-11-07 17:13:25 +00:00
{ & hf_camel_cause_indicator , /* Currently not enabled */
{ " Cause indicator " , " camel.cause_indicator " ,
2010-11-07 20:51:16 +00:00
FT_UINT8 , BASE_DEC | BASE_EXT_STRING , & q850_cause_code_vals_ext , 0x7f ,
2009-06-24 01:40:54 +00:00
NULL , HFILL } } ,
2008-11-07 17:13:25 +00:00
{ & hf_digit ,
2005-05-08 20:34:57 +00:00
{ " Digit Value " , " camel.digit_value " ,
2009-06-24 01:40:54 +00:00
FT_UINT8 , BASE_DEC , VALS ( digit_value ) , 0 , NULL , HFILL } } ,
2008-11-07 17:13:25 +00:00
{ & hf_camel_PDPTypeNumber_etsi ,
2006-01-20 19:34:53 +00:00
{ " ETSI defined PDP Type Value " , " camel.PDPTypeNumber_etsi " ,
2008-11-07 17:13:25 +00:00
FT_UINT8 , BASE_HEX , VALS ( gsm_map_etsi_defined_pdp_vals ) , 0 ,
2009-06-24 01:40:54 +00:00
NULL , HFILL } } ,
2008-11-07 17:13:25 +00:00
{ & hf_camel_PDPTypeNumber_ietf ,
2006-01-20 19:34:53 +00:00
{ " IETF defined PDP Type Value " , " camel.PDPTypeNumber_ietf " ,
2008-11-07 17:13:25 +00:00
FT_UINT8 , BASE_HEX , VALS ( gsm_map_ietf_defined_pdp_vals ) , 0 ,
2009-06-24 01:40:54 +00:00
NULL , HFILL } } ,
2008-11-07 17:13:25 +00:00
{ & hf_camel_PDPAddress_IPv4 ,
2006-01-20 19:34:53 +00:00
{ " PDPAddress IPv4 " , " camel.PDPAddress_IPv4 " ,
2008-11-07 17:13:25 +00:00
FT_IPv4 , BASE_NONE , NULL , 0 ,
" IPAddress IPv4 " , HFILL } } ,
{ & hf_camel_PDPAddress_IPv6 ,
2006-01-20 19:34:53 +00:00
{ " PDPAddress IPv6 " , " camel.PDPAddress_IPv6 " ,
2008-11-07 17:13:25 +00:00
FT_IPv6 , BASE_NONE , NULL , 0 ,
" IPAddress IPv6 " , HFILL } } ,
{ & hf_camel_cellGlobalIdOrServiceAreaIdFixedLength ,
2006-01-22 21:16:33 +00:00
{ " CellGlobalIdOrServiceAreaIdFixedLength " , " camel.CellGlobalIdOrServiceAreaIdFixedLength " ,
2009-06-24 01:40:54 +00:00
FT_BYTES , BASE_NONE , NULL , 0 ,
2006-01-22 21:16:33 +00:00
" LocationInformationGPRS/CellGlobalIdOrServiceAreaIdOrLAI " , HFILL } } ,
2008-11-07 17:13:25 +00:00
{ & hf_camel_RP_Cause ,
2006-08-21 21:58:30 +00:00
{ " RP Cause " , " camel.RP_Cause " ,
2008-11-07 17:13:25 +00:00
FT_UINT8 , BASE_DEC , NULL , 0 ,
2015-08-20 19:38:19 +00:00
" RP Cause Value " , HFILL } } ,
2011-10-21 02:10:19 +00:00
2008-11-07 17:13:25 +00:00
{ & hf_camel_CAMEL_AChBillingChargingCharacteristics ,
{ " CAMEL-AChBillingChargingCharacteristics " , " camel.CAMEL_AChBillingChargingCharacteristics " ,
FT_UINT32 , BASE_DEC , VALS ( camel_CAMEL_AChBillingChargingCharacteristics_vals ) , 0 ,
2011-10-21 02:10:19 +00:00
NULL , HFILL } } ,
2008-11-07 17:13:25 +00:00
{ & hf_camel_CAMEL_FCIBillingChargingCharacteristics ,
{ " CAMEL-FCIBillingChargingCharacteristics " , " camel.CAMEL_FCIBillingChargingCharacteristics " ,
FT_UINT32 , BASE_DEC , VALS ( camel_CAMEL_FCIBillingChargingCharacteristics_vals ) , 0 ,
2009-06-24 01:40:54 +00:00
NULL , HFILL } } ,
2008-11-07 17:13:25 +00:00
{ & hf_camel_CAMEL_FCIGPRSBillingChargingCharacteristics ,
{ " CAMEL-FCIGPRSBillingChargingCharacteristics " , " camel.CAMEL_FCIGPRSBillingChargingCharacteristics " ,
FT_UINT32 , BASE_DEC , NULL , 0 ,
2009-06-24 01:40:54 +00:00
NULL , HFILL } } ,
2008-11-07 17:13:25 +00:00
{ & hf_camel_CAMEL_FCISMSBillingChargingCharacteristics ,
{ " CAMEL-FCISMSBillingChargingCharacteristics " , " camel.CAMEL_FCISMSBillingChargingCharacteristics " ,
FT_UINT32 , BASE_DEC , VALS ( camel_CAMEL_FCISMSBillingChargingCharacteristics_vals ) , 0 ,
2009-06-24 01:40:54 +00:00
NULL , HFILL } } ,
2008-11-07 17:13:25 +00:00
{ & hf_camel_CAMEL_SCIBillingChargingCharacteristics ,
{ " CAMEL-SCIBillingChargingCharacteristics " , " camel.CAMEL_SCIBillingChargingCharacteristics " ,
FT_UINT32 , BASE_DEC , VALS ( camel_CAMEL_SCIBillingChargingCharacteristics_vals ) , 0 ,
2009-06-24 01:40:54 +00:00
NULL , HFILL } } ,
2008-11-07 17:13:25 +00:00
{ & hf_camel_CAMEL_SCIGPRSBillingChargingCharacteristics ,
{ " CAMEL-SCIGPRSBillingChargingCharacteristics " , " camel.CAMEL_SCIGPRSBillingChargingCharacteristics " ,
FT_UINT32 , BASE_DEC , NULL , 0 ,
" CAMEL-FSCIGPRSBillingChargingCharacteristics " , HFILL } } ,
{ & hf_camel_CAMEL_CallResult ,
{ " CAMEL-CAMEL_CallResult " , " camel.CAMEL_CallResult " ,
FT_UINT32 , BASE_DEC , VALS ( camel_CAMEL_CallResult_vals ) , 0 ,
" CAMEL-CallResult " , HFILL } } ,
2006-01-20 19:34:53 +00:00
2006-10-04 16:02:59 +00:00
/* Camel Service Response Time */
{ & hf_camelsrt_SessionId ,
{ " Session Id " ,
" camel.srt.session_id " ,
FT_UINT32 , BASE_DEC , NULL , 0x0 ,
2009-06-24 01:40:54 +00:00
NULL , HFILL }
2006-10-04 16:02:59 +00:00
} ,
{ & hf_camelsrt_RequestNumber ,
{ " Request Number " ,
" camel.srt.request_number " ,
FT_UINT64 , BASE_DEC , NULL , 0x0 ,
2009-06-24 01:40:54 +00:00
NULL , HFILL }
2006-10-04 16:02:59 +00:00
} ,
{ & hf_camelsrt_Duplicate ,
{ " Request Duplicate " ,
" camel.srt.duplicate " ,
FT_UINT32 , BASE_DEC , NULL , 0x0 ,
2009-06-24 01:40:54 +00:00
NULL , HFILL }
2006-10-04 16:02:59 +00:00
} ,
{ & hf_camelsrt_RequestFrame ,
{ " Requested Frame " ,
" camel.srt.reqframe " ,
FT_FRAMENUM , BASE_NONE , NULL , 0x0 ,
" SRT Request Frame " , HFILL }
} ,
{ & hf_camelsrt_ResponseFrame ,
{ " Response Frame " ,
" camel.srt.rspframe " ,
FT_FRAMENUM , BASE_NONE , NULL , 0x0 ,
" SRT Response Frame " , HFILL }
} ,
{ & hf_camelsrt_DeltaTime ,
{ " Service Response Time " ,
" camel.srt.deltatime " ,
FT_RELATIVE_TIME , BASE_NONE , NULL , 0x0 ,
" DeltaTime between Request and Response " , HFILL }
} ,
{ & hf_camelsrt_SessionTime ,
{ " Session duration " ,
" camel.srt.sessiontime " ,
FT_RELATIVE_TIME , BASE_NONE , NULL , 0x0 ,
" Duration of the TCAP session " , HFILL }
} ,
{ & hf_camelsrt_DeltaTime31 ,
{ " Service Response Time " ,
" camel.srt.deltatime31 " ,
FT_RELATIVE_TIME , BASE_NONE , NULL , 0x0 ,
" DeltaTime between InitialDP and Continue " , HFILL }
} ,
{ & hf_camelsrt_DeltaTime65 ,
{ " Service Response Time " ,
" camel.srt.deltatime65 " ,
FT_RELATIVE_TIME , BASE_NONE , NULL , 0x0 ,
" DeltaTime between InitialDPSMS and ContinueSMS " , HFILL }
} ,
{ & hf_camelsrt_DeltaTime75 ,
{ " Service Response Time " ,
" camel.srt.deltatime75 " ,
FT_RELATIVE_TIME , BASE_NONE , NULL , 0x0 ,
" DeltaTime between InitialDPGPRS and ContinueGPRS " , HFILL }
} ,
{ & hf_camelsrt_DeltaTime35 ,
{ " Service Response Time " ,
" camel.srt.deltatime35 " ,
FT_RELATIVE_TIME , BASE_NONE , NULL , 0x0 ,
" DeltaTime between ApplyCharginReport and ApplyCharging " , HFILL }
} ,
{ & hf_camelsrt_DeltaTime22 ,
{ " Service Response Time " ,
" camel.srt.deltatime22 " ,
FT_RELATIVE_TIME , BASE_NONE , NULL , 0x0 ,
" DeltaTime between EventReport(Disconnect) and Release Call " , HFILL }
} ,
2008-11-07 17:13:25 +00:00
{ & hf_camelsrt_DeltaTime80 ,
2006-10-04 16:02:59 +00:00
{ " Service Response Time " ,
" camel.srt.deltatime80 " ,
FT_RELATIVE_TIME , BASE_NONE , NULL , 0x0 ,
" DeltaTime between EventReportGPRS and ContinueGPRS " , HFILL }
} ,
2005-04-15 08:18:15 +00:00
# ifdef REMOVED
2005-03-22 15:41:40 +00:00
# endif
# include "packet-camel-hfarr.c"
} ;
/* List of subtrees */
static gint * ett [ ] = {
& ett_camel ,
& ett_camelisup_parameter ,
2007-02-17 20:04:10 +00:00
& ett_camel_AccessPointName ,
& ett_camel_pdptypenumber ,
2007-07-24 17:20:44 +00:00
& ett_camel_cause ,
& ett_camel_RPcause ,
2006-10-04 16:02:59 +00:00
& ett_camel_stat ,
2015-08-04 15:56:28 +00:00
& ett_camel_calledpartybcdnumber ,
& ett_camel_callingpartynumber ,
& ett_camel_locationnumber ,
& ett_camel_additionalcallingpartynumber ,
2006-10-04 16:02:59 +00:00
2005-03-22 15:41:40 +00:00
# include "packet-camel-ettarr.c"
} ;
2013-06-03 03:42:36 +00:00
static ei_register_info ei [ ] = {
{ & ei_camel_unknown_invokeData , { " camel.unknown.invokeData " , PI_MALFORMED , PI_WARN , " Unknown invokeData " , EXPFILL } } ,
{ & ei_camel_unknown_returnResultData , { " camel.unknown.returnResultData " , PI_MALFORMED , PI_WARN , " Unknown returnResultData " , EXPFILL } } ,
{ & ei_camel_unknown_returnErrorData , { " camel.unknown.returnErrorData " , PI_MALFORMED , PI_WARN , " Unknown returnResultData " , EXPFILL } } ,
} ;
expert_module_t * expert_camel ;
2015-08-04 15:56:28 +00:00
static tap_param camel_stat_params [ ] = {
{ PARAM_FILTER , " filter " , " Filter " , NULL , TRUE }
} ;
static new_stat_tap_ui camel_stat_table = {
REGISTER_STAT_GROUP_TELEPHONY_GSM ,
" CAMEL Messages and Response Status " ,
PSNAME ,
" camel,counter " ,
camel_stat_init ,
camel_stat_packet ,
camel_stat_reset ,
2015-08-06 18:23:55 +00:00
camel_stat_free_table_item ,
2015-08-04 15:56:28 +00:00
NULL ,
sizeof ( camel_stat_fields ) / sizeof ( stat_tap_table_item ) , camel_stat_fields ,
sizeof ( camel_stat_params ) / sizeof ( tap_param ) , camel_stat_params ,
NULL
} ;
2005-03-22 15:41:40 +00:00
/* Register protocol */
proto_camel = proto_register_protocol ( PNAME , PSNAME , PFNAME ) ;
2013-10-28 13:36:49 +00:00
new_register_dissector ( " camel " , dissect_camel , proto_camel ) ;
new_register_dissector ( " camel-v1 " , dissect_camel_v1 , proto_camel ) ;
new_register_dissector ( " camel-v2 " , dissect_camel_v2 , proto_camel ) ;
2007-04-03 19:08:00 +00:00
2005-03-22 15:41:40 +00:00
proto_register_field_array ( proto_camel , hf , array_length ( hf ) ) ;
proto_register_subtree_array ( ett , array_length ( ett ) ) ;
2013-06-03 03:42:36 +00:00
expert_camel = expert_register_protocol ( proto_camel ) ;
expert_register_field_array ( expert_camel , ei , array_length ( ei ) ) ;
2005-12-16 16:37:03 +00:00
2007-08-29 16:10:47 +00:00
rose_ctx_init ( & camel_rose_ctx ) ;
/* Register dissector tables */
2011-10-21 02:10:19 +00:00
camel_rose_ctx . arg_local_dissector_table = register_dissector_table ( " camel.ros.local.arg " ,
" CAMEL Operation Argument (local opcode) " ,
FT_UINT32 , BASE_HEX ) ;
camel_rose_ctx . res_local_dissector_table = register_dissector_table ( " camel.ros.local.res " ,
" CAMEL Operation Result (local opcode) " ,
FT_UINT32 , BASE_HEX ) ;
camel_rose_ctx . err_local_dissector_table = register_dissector_table ( " camel.ros.local.err " ,
" CAMEL Error (local opcode) " ,
FT_UINT32 , BASE_HEX ) ;
2007-08-29 16:10:47 +00:00
2013-01-15 16:44:02 +00:00
/* Register our configuration options, particularly our SSNs */
2005-03-22 15:41:40 +00:00
/* Set default SSNs */
2013-01-15 16:44:02 +00:00
range_convert_str ( & global_ssn_range , " 146 " , MAX_SSN ) ;
2005-03-22 15:41:40 +00:00
camel_module = prefs_register_protocol ( proto_camel , proto_reg_handoff_camel ) ;
2005-05-09 00:11:03 +00:00
prefs_register_enum_preference ( camel_module , " date.format " , " Date Format " ,
2005-05-08 20:34:57 +00:00
" The date format: (DD/MM) or (MM/DD) " ,
& date_format , date_options , FALSE ) ;
2011-10-21 02:10:19 +00:00
2005-03-22 15:41:40 +00:00
prefs_register_range_preference ( camel_module , " tcap.ssn " ,
" TCAP SSNs " ,
" TCAP Subsystem numbers used for Camel " ,
& global_ssn_range , MAX_SSN ) ;
2006-10-04 16:02:59 +00:00
prefs_register_bool_preference ( camel_module , " srt " ,
2015-08-20 19:38:19 +00:00
" Analyze Service Response Time " ,
" Enable response time analysis " ,
& gcamel_HandleSRT ) ;
2006-10-04 16:02:59 +00:00
prefs_register_bool_preference ( camel_module , " persistentsrt " ,
2015-08-20 19:38:19 +00:00
" Persistent stats for SRT " ,
" Statistics for Response Time " ,
& gcamel_PersistentSRT ) ;
2011-10-21 02:10:19 +00:00
/* Routine for statistic */
2006-10-04 16:02:59 +00:00
register_init_routine ( & camelsrt_init_routine ) ;
2015-06-27 22:33:42 +00:00
register_cleanup_routine ( & camelsrt_cleanup_routine ) ;
2006-10-04 16:02:59 +00:00
camel_tap = register_tap ( PSNAME ) ;
Further refactor SRT stats.
Create "common" SRT tap data collection intended for all GUIs. Refactor/merge functionality of existing dissectors that have SRT support (AFP, DCERPC, Diameter, FC, GTP, LDAP, NCP, RPC, SCIS, SMB, and SMB2) for both TShark and GTK.
SMB and DCERPC "tap packet filtering" were different between TShark and GTK, so I went with GTK filter logic.
CAMEL "tap packet filtering" was different between TShark and GTK, so GTK filtering logic was pushed to the dissector and the TShark tap was left alone.
Change-Id: I7d6eaad0673fe628ef337f9165d7ed94f4a5e1cc
Reviewed-on: https://code.wireshark.org/review/8894
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-06-16 21:07:04 +00:00
2015-08-04 15:56:28 +00:00
register_srt_table ( proto_camel , PSNAME , 1 , camelstat_packet , camelstat_init , NULL ) ;
register_new_stat_tap_ui ( & camel_stat_table ) ;
2005-03-22 15:41:40 +00:00
}
2015-08-20 19:38:19 +00:00
/*
* Editor modelines
*
* Local Variables :
* c - basic - offset : 2
* tab - width : 8
* indent - tabs - mode : nil
* End :
*
* ex : set shiftwidth = 2 tabstop = 8 expandtab :
* : indentSize = 2 : tabSize = 8 : noTabs = true :
*/