2000-07-30 07:16:11 +00:00
/* packet-diameter.c
2001-11-01 21:52:44 +00:00
* Routines for Diameter packet disassembly
2000-07-30 07:16:11 +00:00
*
2001-02-19 23:14:02 +00:00
* Copyright ( c ) 2001 by David Frascone < dave @ frascone . com >
2008-08-05 21:03:46 +00:00
* Copyright ( c ) 2007 by Luis E . Garcia Ontanon < luis @ ontanon . org >
2000-07-30 07:16:11 +00:00
*
2010-04-26 22:19:34 +00:00
* Support for Request - Answer tracking and Tapping
2008-11-15 15:52:39 +00:00
* introduced by Abhik Sarkar
*
2006-05-21 04:49:01 +00:00
* Wireshark - Network traffic analyzer
* By Gerald Combs < gerald @ wireshark . org >
2001-05-27 21:38:46 +00:00
* Copyright 1998 Gerald Combs
*
2018-02-12 11:23:27 +00:00
* SPDX - License - Identifier : GPL - 2.0 - or - later
2017-08-15 18:31:05 +00:00
*
2004-03-21 23:10:31 +00:00
* References :
2017-08-15 18:31:05 +00:00
*
* RFC 3588 , " Diameter Base Protocol " ( now RFC 6733 )
* draft - ietf - aaa - diameter - mobileip - 16 , " Diameter Mobile IPv4 Application "
* ( now RFC 4004 )
* draft - ietf - aaa - diameter - nasreq - 14 , " Diameter Network Access Server
* Application " (now RFC 4005)
* drafts / draft - ietf - aaa - diameter - cc - 03 , " Diameter Credit-Control
* Application " (now RFC 4006)
* draft - ietf - aaa - diameter - sip - app - 01 , " Diameter Session Initiation
* Protocol ( SIP ) Application " (now RFC 4740)
2019-05-30 18:26:24 +00:00
* RFC 5779 , " Diameter Proxy Mobile IPv6: Mobile Access Gateway and
* Local Mobility Anchor Interaction with Diameter Server "
* 3 GPP TS 29.273 , V15 .2 .0
2004-03-21 23:10:31 +00:00
* http : //www.ietf.org/html.charters/aaa-charter.html
2017-08-15 18:31:05 +00:00
* http : //www.iana.org/assignments/radius-types
2004-09-28 17:52:36 +00:00
* http : //www.iana.org/assignments/address-family-numbers
* http : //www.iana.org/assignments/enterprise-numbers
2004-10-08 09:35:56 +00:00
* http : //www.iana.org/assignments/aaa-parameters
2004-09-28 17:52:36 +00:00
*/
2000-07-30 07:16:11 +00:00
# include "config.h"
2002-01-21 07:37:49 +00:00
# include <epan/packet.h>
2013-11-10 15:59:37 +00:00
# include <epan/exceptions.h>
2004-09-27 22:55:15 +00:00
# include <epan/prefs.h>
2004-09-30 20:27:47 +00:00
# include <epan/sminmpec.h>
2017-06-24 13:25:41 +00:00
# include <epan/addr_resolv.h>
2006-07-03 21:18:36 +00:00
# include <epan/expert.h>
2008-11-15 15:52:39 +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>
2013-05-20 18:30:32 +00:00
# include <epan/exported_pdu.h>
2009-08-21 20:25:24 +00:00
# include <epan/diam_dict.h>
2012-08-14 20:44:58 +00:00
# include <epan/sctpppids.h>
2013-07-18 15:08:15 +00:00
# include <epan/show_exception.h>
2014-03-16 17:57:18 +00:00
# include <epan/to_str.h>
2021-12-18 23:22:27 +00:00
# include <epan/strutil.h>
2020-10-12 08:34:49 +00:00
# include <epan/afn.h>
2014-12-24 15:44:03 +00:00
# include <wsutil/filesystem.h>
2017-04-08 19:45:19 +00:00
# include <wsutil/report_message.h>
2004-02-21 10:29:52 +00:00
# include "packet-tcp.h"
2008-11-15 15:52:39 +00:00
# include "packet-diameter.h"
2014-08-20 19:08:21 +00:00
# include "packet-e212.h"
2014-08-21 02:47:22 +00:00
# include "packet-e164.h"
2000-07-30 07:16:11 +00:00
2013-12-14 10:29:26 +00:00
void proto_register_diameter ( void ) ;
void proto_reg_handoff_diameter ( void ) ;
2007-07-16 05:41:58 +00:00
/* Diameter Header Flags */
2010-10-18 15:56:06 +00:00
/* RPETrrrrCCCCCCCCCCCCCCCCCCCCCCCC */
2007-07-16 05:41:58 +00:00
# define DIAM_FLAGS_R 0x80
# define DIAM_FLAGS_P 0x40
# define DIAM_FLAGS_E 0x20
# define DIAM_FLAGS_T 0x10
# define DIAM_FLAGS_RESERVED4 0x08
# define DIAM_FLAGS_RESERVED5 0x04
# define DIAM_FLAGS_RESERVED6 0x02
# define DIAM_FLAGS_RESERVED7 0x01
# define DIAM_FLAGS_RESERVED 0x0f
2013-12-20 16:03:24 +00:00
#if 0
2007-07-16 05:41:58 +00:00
# define DIAM_LENGTH_MASK 0x00ffffffl
# define DIAM_COMMAND_MASK DIAM_LENGTH_MASK
# define DIAM_GET_FLAGS(dh) ((dh.flagsCmdCode & ~DIAM_COMMAND_MASK) >> 24)
# define DIAM_GET_VERSION(dh) ((dh.versionLength & (~DIAM_LENGTH_MASK)) >> 24)
# define DIAM_GET_COMMAND(dh) (dh.flagsCmdCode & DIAM_COMMAND_MASK)
# define DIAM_GET_LENGTH(dh) (dh.versionLength & DIAM_LENGTH_MASK)
2013-12-20 16:03:24 +00:00
# endif
2007-07-16 05:41:58 +00:00
/* Diameter AVP Flags */
# define AVP_FLAGS_P 0x20
# define AVP_FLAGS_V 0x80
# define AVP_FLAGS_M 0x40
# define AVP_FLAGS_RESERVED3 0x10
# define AVP_FLAGS_RESERVED4 0x08
# define AVP_FLAGS_RESERVED5 0x04
# define AVP_FLAGS_RESERVED6 0x02
# define AVP_FLAGS_RESERVED7 0x01
# define AVP_FLAGS_RESERVED 0x1f /* 00011111 -- V M P X X X X X */
# define DIAMETER_V16 16
# define DIAMETER_RFC 1
2013-05-20 18:30:32 +00:00
static gint exported_pdu_tap = - 1 ;
2012-12-16 01:12:59 +00:00
/* Conversation Info */
typedef struct _diameter_conv_info_t {
2016-03-11 02:03:52 +00:00
wmem_map_t * pdu_trees ;
2012-12-16 01:12:59 +00:00
} diameter_conv_info_t ;
2007-07-16 05:41:58 +00:00
typedef struct _diam_ctx_t {
2012-12-16 01:12:59 +00:00
proto_tree * tree ;
packet_info * pinfo ;
2013-09-04 21:06:56 +00:00
wmem_tree_t * avps ;
2007-07-16 05:41:58 +00:00
gboolean version_rfc ;
} diam_ctx_t ;
typedef struct _diam_avp_t diam_avp_t ;
typedef struct _avp_type_t avp_type_t ;
2013-10-28 15:59:26 +00:00
typedef const char * ( * diam_avp_dissector_t ) ( diam_ctx_t * , diam_avp_t * , tvbuff_t * , diam_sub_dis_t * ) ;
2007-07-16 05:41:58 +00:00
2007-07-17 22:19:54 +00:00
typedef struct _diam_vnd_t {
2013-11-21 18:46:40 +00:00
guint32 code ;
2016-02-18 10:30:41 +00:00
wmem_array_t * vs_avps ;
2014-07-25 16:29:04 +00:00
value_string_ext * vs_avps_ext ;
2016-02-18 10:30:41 +00:00
wmem_array_t * vs_cmds ;
2007-07-17 22:19:54 +00:00
} diam_vnd_t ;
2007-07-16 05:41:58 +00:00
struct _diam_avp_t {
guint32 code ;
2014-01-14 03:24:37 +00:00
diam_vnd_t * vendor ;
2007-07-16 05:41:58 +00:00
diam_avp_dissector_t dissector_v16 ;
diam_avp_dissector_t dissector_rfc ;
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
gint ett ;
int hf_value ;
2012-12-16 01:12:59 +00:00
void * type_data ;
2001-11-01 21:52:44 +00:00
} ;
2016-02-18 10:30:41 +00:00
# define VND_AVP_VS(v) ((value_string *)(void *)(wmem_array_get_raw((v)->vs_avps)))
# define VND_AVP_VS_LEN(v) (wmem_array_get_count((v)->vs_avps))
# define VND_CMD_VS(v) ((value_string *)(void *)(wmem_array_get_raw((v)->vs_cmds)))
2007-07-16 05:41:58 +00:00
typedef struct _diam_dictionary_t {
2013-09-04 21:06:56 +00:00
wmem_tree_t * avps ;
wmem_tree_t * vnds ;
2015-04-20 22:14:35 +00:00
value_string_ext * applications ;
2012-12-16 01:12:59 +00:00
value_string * commands ;
2007-07-16 05:41:58 +00:00
} diam_dictionary_t ;
2014-01-14 03:24:37 +00:00
typedef diam_avp_t * ( * avp_constructor_t ) ( const avp_type_t * , guint32 , diam_vnd_t * , const char * , const value_string * , void * ) ;
2007-07-16 05:41:58 +00:00
struct _avp_type_t {
2012-12-16 01:12:59 +00:00
const char * name ;
2007-07-16 05:41:58 +00:00
diam_avp_dissector_t v16 ;
diam_avp_dissector_t rfc ;
enum ftenum ft ;
2011-04-22 17:25:25 +00:00
int base ;
2007-07-16 05:41:58 +00:00
avp_constructor_t build ;
} ;
2000-07-30 07:16:11 +00:00
2007-07-16 05:41:58 +00:00
struct _build_dict {
2013-07-06 12:45:33 +00:00
wmem_array_t * hf ;
GPtrArray * ett ;
GHashTable * types ;
GHashTable * avps ;
2007-07-16 05:41:58 +00:00
} ;
2000-07-30 07:16:11 +00:00
2007-07-17 22:19:54 +00:00
typedef struct _address_avp_t {
gint ett ;
int hf_address_type ;
int hf_ipv4 ;
int hf_ipv6 ;
2020-10-12 08:34:49 +00:00
int hf_e164_str ;
2007-07-17 22:19:54 +00:00
int hf_other ;
} address_avp_t ;
2007-07-20 00:15:17 +00:00
typedef enum {
REASEMBLE_NEVER = 0 ,
2007-10-24 16:32:51 +00:00
REASEMBLE_AT_END ,
2007-07-20 00:15:17 +00:00
REASEMBLE_BY_LENGTH
} avp_reassemble_mode_t ;
typedef struct _proto_avp_t {
2012-12-16 01:12:59 +00:00
char * name ;
2007-07-20 00:15:17 +00:00
dissector_handle_t handle ;
2007-10-24 16:32:51 +00:00
avp_reassemble_mode_t reassemble_mode ;
2007-07-20 00:15:17 +00:00
} proto_avp_t ;
2013-10-28 15:59:26 +00:00
static const char * simple_avp ( diam_ctx_t * , diam_avp_t * , tvbuff_t * , diam_sub_dis_t * ) ;
2000-07-30 07:16:11 +00:00
2012-04-23 01:36:57 +00:00
static diam_vnd_t unknown_vendor = { 0xffffffff , NULL , NULL , NULL } ;
2010-05-24 14:20:53 +00:00
static diam_vnd_t no_vnd = { 0 , NULL , NULL , NULL } ;
2007-07-17 22:19:54 +00:00
static diam_avp_t unknown_avp = { 0 , & unknown_vendor , simple_avp , simple_avp , - 1 , - 1 , NULL } ;
2012-12-16 01:12:59 +00:00
static GArray * all_cmds ;
2007-07-16 05:41:58 +00:00
static diam_dictionary_t dictionary = { NULL , NULL , NULL , NULL } ;
static struct _build_dict build_dict ;
2012-12-16 01:12:59 +00:00
static const value_string * vnd_short_vs ;
2007-07-20 00:15:17 +00:00
static dissector_handle_t data_handle ;
2009-06-26 05:48:03 +00:00
static dissector_handle_t eap_handle ;
2007-07-20 00:15:17 +00:00
2007-07-17 22:19:54 +00:00
static const value_string diameter_avp_data_addrfamily_vals [ ] = {
{ 1 , " IPv4 " } ,
{ 2 , " IPv6 " } ,
{ 3 , " NSAP " } ,
{ 4 , " HDLC " } ,
{ 5 , " BBN " } ,
{ 6 , " IEEE-802 " } ,
{ 7 , " E-163 " } ,
{ 8 , " E-164 " } ,
{ 9 , " F-69 " } ,
{ 10 , " X-121 " } ,
{ 11 , " IPX " } ,
{ 12 , " Appletalk " } ,
{ 13 , " Decnet4 " } ,
{ 14 , " Vines " } ,
{ 15 , " E-164-NSAP " } ,
{ 16 , " DNS " } ,
{ 17 , " DistinguishedName " } ,
{ 18 , " AS " } ,
{ 19 , " XTPoIPv4 " } ,
{ 20 , " XTPoIPv6 " } ,
{ 21 , " XTPNative " } ,
{ 22 , " FibrePortName " } ,
{ 23 , " FibreNodeName " } ,
{ 24 , " GWID " } ,
{ 0 , NULL }
} ;
2010-12-06 23:20:21 +00:00
static value_string_ext diameter_avp_data_addrfamily_vals_ext = VALUE_STRING_EXT_INIT ( diameter_avp_data_addrfamily_vals ) ;
2007-07-17 22:19:54 +00:00
2000-07-30 07:16:11 +00:00
static int proto_diameter = - 1 ;
static int hf_diameter_length = - 1 ;
static int hf_diameter_code = - 1 ;
2001-04-10 21:49:23 +00:00
static int hf_diameter_hopbyhopid = - 1 ;
static int hf_diameter_endtoendid = - 1 ;
2001-02-19 23:14:02 +00:00
static int hf_diameter_version = - 1 ;
static int hf_diameter_vendor_id = - 1 ;
2004-10-08 09:35:56 +00:00
static int hf_diameter_application_id = - 1 ;
2001-07-30 20:08:44 +00:00
static int hf_diameter_flags = - 1 ;
static int hf_diameter_flags_request = - 1 ;
static int hf_diameter_flags_proxyable = - 1 ;
static int hf_diameter_flags_error = - 1 ;
2004-03-21 23:10:31 +00:00
static int hf_diameter_flags_T = - 1 ;
2001-07-30 20:08:44 +00:00
static int hf_diameter_flags_reserved4 = - 1 ;
static int hf_diameter_flags_reserved5 = - 1 ;
static int hf_diameter_flags_reserved6 = - 1 ;
static int hf_diameter_flags_reserved7 = - 1 ;
2001-02-19 23:14:02 +00:00
2007-07-10 17:45:11 +00:00
static int hf_diameter_avp = - 1 ;
2007-07-16 05:41:58 +00:00
static int hf_diameter_avp_len = - 1 ;
2001-02-19 23:14:02 +00:00
static int hf_diameter_avp_code = - 1 ;
static int hf_diameter_avp_flags = - 1 ;
2001-07-30 20:08:44 +00:00
static int hf_diameter_avp_flags_vendor_specific = - 1 ;
static int hf_diameter_avp_flags_mandatory = - 1 ;
static int hf_diameter_avp_flags_protected = - 1 ;
static int hf_diameter_avp_flags_reserved3 = - 1 ;
static int hf_diameter_avp_flags_reserved4 = - 1 ;
static int hf_diameter_avp_flags_reserved5 = - 1 ;
static int hf_diameter_avp_flags_reserved6 = - 1 ;
static int hf_diameter_avp_flags_reserved7 = - 1 ;
2001-02-19 23:14:02 +00:00
static int hf_diameter_avp_vendor_id = - 1 ;
2007-07-27 18:32:09 +00:00
static int hf_diameter_avp_data_wrong_length = - 1 ;
2013-03-22 18:13:31 +00:00
static int hf_diameter_avp_pad = - 1 ;
2001-02-19 23:14:02 +00:00
2008-11-15 15:52:39 +00:00
static int hf_diameter_answer_in = - 1 ;
static int hf_diameter_answer_to = - 1 ;
static int hf_diameter_answer_time = - 1 ;
2012-03-13 15:06:40 +00:00
/* AVPs with special/extra decoding */
static int hf_framed_ipv6_prefix_reserved = - 1 ;
static int hf_framed_ipv6_prefix_length = - 1 ;
static int hf_framed_ipv6_prefix_bytes = - 1 ;
static int hf_framed_ipv6_prefix_ipv6 = - 1 ;
2013-12-04 20:55:52 +00:00
static int hf_diameter_3gpp2_exp_res = - 1 ;
2015-10-26 20:44:18 +00:00
static int hf_diameter_other_vendor_exp_res = - 1 ;
2019-05-30 18:26:24 +00:00
static int hf_diameter_mip6_feature_vector = - 1 ;
static int hf_diameter_mip6_feature_vector_mip6_integrated = - 1 ;
static int hf_diameter_mip6_feature_vector_local_home_agent_assignment = - 1 ;
static int hf_diameter_mip6_feature_vector_pmip6_supported = - 1 ;
static int hf_diameter_mip6_feature_vector_ip4_hoa_supported = - 1 ;
static int hf_diameter_mip6_feature_vector_local_mag_routing_supported = - 1 ;
static int hf_diameter_3gpp_mip6_feature_vector = - 1 ;
static int hf_diameter_3gpp_mip6_feature_vector_assign_local_ip = - 1 ;
static int hf_diameter_3gpp_mip6_feature_vector_mip4_supported = - 1 ;
static int hf_diameter_3gpp_mip6_feature_vector_optimized_idle_mode_mobility = - 1 ;
static int hf_diameter_3gpp_mip6_feature_vector_gtpv2_supported = - 1 ;
2019-11-03 11:12:19 +00:00
static int hf_diameter_user_equipment_info_imeisv = - 1 ;
static int hf_diameter_user_equipment_info_mac = - 1 ;
static int hf_diameter_user_equipment_info_eui64 = - 1 ;
static int hf_diameter_user_equipment_info_modified_eui64 = - 1 ;
2012-03-13 15:06:40 +00:00
2000-07-30 07:16:11 +00:00
static gint ett_diameter = - 1 ;
2001-07-30 20:08:44 +00:00
static gint ett_diameter_flags = - 1 ;
static gint ett_diameter_avp_flags = - 1 ;
2000-07-30 07:16:11 +00:00
static gint ett_diameter_avpinfo = - 1 ;
2007-07-17 22:19:54 +00:00
static gint ett_unknown = - 1 ;
static gint ett_err = - 1 ;
2019-05-30 18:26:24 +00:00
static gint ett_diameter_mip6_feature_vector = - 1 ;
static gint ett_diameter_3gpp_mip6_feature_vector = - 1 ;
2013-08-05 01:54:15 +00:00
static expert_field ei_diameter_reserved_bit_set = EI_INIT ;
2013-09-01 13:05:27 +00:00
static expert_field ei_diameter_avp_len = EI_INIT ;
static expert_field ei_diameter_avp_no_data = EI_INIT ;
static expert_field ei_diameter_application_id = EI_INIT ;
static expert_field ei_diameter_version = EI_INIT ;
static expert_field ei_diameter_avp_pad = EI_INIT ;
2019-08-14 23:19:33 +00:00
static expert_field ei_diameter_avp_pad_missing = EI_INIT ;
2013-09-01 13:05:27 +00:00
static expert_field ei_diameter_code = EI_INIT ;
static expert_field ei_diameter_avp_code = EI_INIT ;
static expert_field ei_diameter_avp_vendor_id = EI_INIT ;
2015-11-28 10:45:24 +00:00
static expert_field ei_diameter_invalid_ipv6_prefix_len = EI_INIT ;
2016-08-30 12:55:54 +00:00
static expert_field ei_diameter_invalid_avp_len = EI_INIT ;
2019-11-03 11:12:19 +00:00
static expert_field ei_diameter_invalid_user_equipment_info_value_len = EI_INIT ;
2013-08-05 01:54:15 +00:00
2008-11-15 15:52:39 +00:00
/* Tap for Diameter */
static int diameter_tap = - 1 ;
/* For conversations */
2013-08-22 17:21:20 +00:00
static dissector_handle_t diameter_udp_handle ;
2007-10-24 15:04:01 +00:00
static dissector_handle_t diameter_tcp_handle ;
2010-10-18 15:56:06 +00:00
static dissector_handle_t diameter_sctp_handle ;
static range_t * global_diameter_sctp_port_range ;
/* This is used for TCP and SCTP */
2008-09-19 17:39:44 +00:00
# define DEFAULT_DIAMETER_PORT_RANGE "3868"
2007-10-24 15:04:01 +00:00
2001-11-03 12:19:56 +00:00
/* desegmentation of Diameter over TCP */
static gboolean gbl_diameter_desegment = TRUE ;
2008-01-27 21:06:33 +00:00
/* Dissector tables */
2008-01-28 19:55:20 +00:00
static dissector_table_t diameter_dissector_table ;
2008-01-27 21:06:33 +00:00
static dissector_table_t diameter_3gpp_avp_dissector_table ;
2010-05-07 11:08:56 +00:00
static dissector_table_t diameter_ericsson_avp_dissector_table ;
2017-04-27 11:03:42 +00:00
static dissector_table_t diameter_verizon_avp_dissector_table ;
2013-12-04 20:55:52 +00:00
static dissector_table_t diameter_expr_result_vnd_table ;
2008-01-27 21:06:33 +00:00
2012-12-16 01:12:59 +00:00
static const char * avpflags_str [ ] = {
2007-07-16 05:41:58 +00:00
" --- " ,
" --P " ,
" -M- " ,
" -MP " ,
" V-- " ,
" V-P " ,
" VM- " ,
" VMP " ,
} ;
2002-08-28 21:04:11 +00:00
2014-08-20 19:08:21 +00:00
# define SUBSCRIPTION_ID_TYPE_E164 0
# define SUBSCRIPTION_ID_TYPE_IMSI 1
# define SUBSCRIPTION_ID_TYPE_SIP_URI 2
# define SUBSCRIPTION_ID_TYPE_NAI 3
# define SUBSCRIPTION_ID_TYPE_PRIVATE 4
2014-08-21 21:40:04 +00:00
# define SUBSCRIPTION_ID_TYPE_UNKNOWN (guint32)-1
2019-11-03 11:12:19 +00:00
# define USER_EQUIPMENT_INFO_TYPE_IMEISV 0
# define USER_EQUIPMENT_INFO_TYPE_MAC 1
# define USER_EQUIPMENT_INFO_TYPE_EUI64 2
# define USER_EQUIPMENT_INFO_TYPE_MODIFIED_EUI64 3
# define USER_EQUIPMENT_INFO_TYPE_UNKNOWN (guint32)-1
2014-08-20 19:08:21 +00:00
2013-05-20 18:30:32 +00:00
static void
export_diameter_pdu ( packet_info * pinfo , tvbuff_t * tvb )
{
2016-06-24 03:10:08 +00:00
exp_pdu_data_t * exp_pdu_data = export_pdu_create_common_tags ( pinfo , " diameter " , EXP_PDU_TAG_PROTO_NAME ) ;
2013-05-20 18:30:32 +00:00
2014-03-18 22:01:22 +00:00
exp_pdu_data - > tvb_captured_length = tvb_captured_length ( tvb ) ;
exp_pdu_data - > tvb_reported_length = tvb_reported_length ( tvb ) ;
2013-11-21 18:46:40 +00:00
exp_pdu_data - > pdu_tvb = tvb ;
2013-05-20 18:30:32 +00:00
2013-11-21 18:46:40 +00:00
tap_queue_packet ( exported_pdu_tap , pinfo , exp_pdu_data ) ;
2013-05-20 18:30:32 +00:00
}
2013-07-06 18:01:57 +00:00
static int
compare_avps ( const void * a , const void * b )
2010-05-24 14:20:53 +00:00
{
2013-07-06 18:01:57 +00:00
const value_string * vsa = ( const value_string * ) a ;
const value_string * vsb = ( const value_string * ) b ;
2010-05-24 14:20:53 +00:00
2013-11-21 18:46:40 +00:00
if ( vsa - > value > vsb - > value )
2010-05-24 14:20:53 +00:00
return 1 ;
2013-11-21 18:46:40 +00:00
if ( vsa - > value < vsb - > value )
2010-05-24 14:20:53 +00:00
return - 1 ;
return 0 ;
}
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 GHashTable * diameterstat_cmd_str_hash = NULL ;
# define DIAMETER_NUM_PROCEDURES 1
static void
2018-05-13 19:45:16 +00:00
diameterstat_init ( struct register_srt * srt _U_ , GArray * srt_array )
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
{
srt_stat_table * diameter_srt_table ;
int * idx ;
2016-01-06 00:58:42 +00:00
/* XXX - This is a hack/workaround support so resetting/freeing parameters at the dissector
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
level doesn ' t need to be supported . */
if ( diameterstat_cmd_str_hash ! = NULL )
{
g_hash_table_destroy ( diameterstat_cmd_str_hash ) ;
}
2020-05-07 12:35:45 +00:00
idx = wmem_new0 ( wmem_epan_scope ( ) , int ) ;
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
diameterstat_cmd_str_hash = g_hash_table_new ( g_str_hash , g_str_equal ) ;
2015-11-21 23:48:27 +00:00
g_hash_table_insert ( diameterstat_cmd_str_hash , " Unknown " , idx ) ;
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
/** @todo the filter to use in stead of NULL is "diameter.cmd.code"
2016-01-06 00:58:42 +00:00
* to enable the filter popup in the service response time dialogue
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
* Note to make it work the command code must be stored rather than the
* index .
*/
2018-05-13 19:45:16 +00:00
diameter_srt_table = init_srt_table ( " Diameter Requests " , NULL , srt_array , DIAMETER_NUM_PROCEDURES , NULL , NULL , NULL ) ;
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
init_srt_table_row ( diameter_srt_table , 0 , " Unknown " ) ;
}
2019-01-01 03:36:12 +00:00
static tap_packet_status
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
diameterstat_packet ( void * pss , packet_info * pinfo , epan_dissect_t * edt _U_ , const void * prv )
{
guint i = 0 ;
srt_stat_table * diameter_srt_table ;
srt_data_t * data = ( srt_data_t * ) pss ;
const diameter_req_ans_pair_t * diameter = ( const diameter_req_ans_pair_t * ) prv ;
int * idx = NULL ;
/* Process only answers where corresponding request is found.
2016-01-06 00:58:42 +00:00
* Unpaired diameter messages are currently not supported by statistics .
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
* Return 0 , since redraw is not needed . */
if ( ! diameter | | diameter - > processing_request | | ! diameter - > req_frame )
2019-01-01 03:36:12 +00:00
return TAP_PACKET_DONT_REDRAW ;
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
diameter_srt_table = g_array_index ( data - > srt_array , srt_stat_table * , i ) ;
idx = ( int * ) g_hash_table_lookup ( diameterstat_cmd_str_hash , diameter - > cmd_str ) ;
if ( idx = = NULL ) {
2020-05-07 12:35:45 +00:00
idx = wmem_new ( wmem_epan_scope ( ) , int ) ;
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
* idx = ( int ) g_hash_table_size ( diameterstat_cmd_str_hash ) ;
g_hash_table_insert ( diameterstat_cmd_str_hash , ( gchar * ) diameter - > cmd_str , idx ) ;
init_srt_table_row ( diameter_srt_table , * idx , ( const char * ) diameter - > cmd_str ) ;
}
add_srt_table_data ( diameter_srt_table , * idx , & diameter - > req_time , pinfo ) ;
2019-01-01 03:36:12 +00:00
return TAP_PACKET_REDRAW ;
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
}
2013-04-02 18:15:42 +00:00
/* Special decoding of some AVPs */
2008-01-28 19:55:20 +00:00
static int
2012-09-10 21:40:21 +00:00
dissect_diameter_vendor_id ( tvbuff_t * tvb , packet_info * pinfo _U_ , proto_tree * tree , void * data _U_ )
2008-07-15 21:06:31 +00:00
{
2008-01-28 19:55:20 +00:00
int offset = 0 ;
2011-10-06 03:35:44 +00:00
proto_tree_add_item ( tree , hf_diameter_vendor_id , tvb , 0 , 4 , ENC_BIG_ENDIAN ) ;
2008-01-28 19:55:20 +00:00
offset + + ;
return offset ;
}
2009-06-26 05:48:03 +00:00
static int
2012-09-10 21:40:21 +00:00
dissect_diameter_eap_payload ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data _U_ )
2010-10-18 15:56:06 +00:00
{
2009-06-26 05:48:03 +00:00
gboolean save_writable ;
/* Ensure the packet is displayed as Diameter, not EAP */
2016-06-14 15:55:08 +00:00
save_writable = col_get_writable ( pinfo - > cinfo , COL_PROTOCOL ) ;
col_set_writable ( pinfo - > cinfo , COL_PROTOCOL , FALSE ) ;
2009-06-26 05:48:03 +00:00
call_dissector ( eap_handle , tvb , pinfo , tree ) ;
2016-06-14 15:55:08 +00:00
col_set_writable ( pinfo - > cinfo , COL_PROTOCOL , save_writable ) ;
2014-07-28 18:18:49 +00:00
return tvb_reported_length ( tvb ) ;
2009-06-26 05:48:03 +00:00
}
2008-01-28 19:55:20 +00:00
2020-04-10 11:04:46 +00:00
/* https://www.3gpp2.org/Public_html/X/VSA-VSE.cfm */
2013-12-04 20:55:52 +00:00
static const value_string diameter_3gpp2_exp_res_vals [ ] = {
{ 5001 , " Diameter_Error_User_No_WLAN_Subscription " } ,
{ 5002 , " Diameter_Error_Roaming_Not_Allowed(Obsoleted) " } ,
{ 5003 , " Diameter_Error_User_No_FAP_Subscription " } ,
{ 0 , NULL }
} ;
static int
2015-10-26 20:44:18 +00:00
dissect_diameter_3gpp2_exp_res ( tvbuff_t * tvb , packet_info * pinfo _U_ , proto_tree * tree , void * data )
{
2013-12-04 20:55:52 +00:00
proto_item * pi ;
2013-12-10 03:25:04 +00:00
diam_sub_dis_t * diam_sub_dis ;
/* Reject the packet if data is NULL */
if ( data = = NULL )
return 0 ;
diam_sub_dis = ( diam_sub_dis_t * ) data ;
2013-12-04 20:55:52 +00:00
2015-08-12 17:57:20 +00:00
if ( tree ) {
pi = proto_tree_add_item ( tree , hf_diameter_3gpp2_exp_res , tvb , 0 , 4 , ENC_BIG_ENDIAN ) ;
diam_sub_dis - > avp_str = ( char * ) wmem_alloc ( wmem_packet_scope ( ) , ITEM_LABEL_LENGTH + 1 ) ;
proto_item_fill_label ( PITEM_FINFO ( pi ) , diam_sub_dis - > avp_str ) ;
diam_sub_dis - > avp_str = strstr ( diam_sub_dis - > avp_str , " : " ) + 2 ;
}
2013-12-04 20:55:52 +00:00
return 4 ;
}
2015-10-26 20:44:18 +00:00
static void
dissect_diameter_other_vendor_exp_res ( tvbuff_t * tvb , proto_tree * tree , diam_sub_dis_t * diam_sub_dis )
{
proto_item * pi ;
if ( tree ) {
pi = proto_tree_add_item ( tree , hf_diameter_other_vendor_exp_res , tvb , 0 , 4 , ENC_BIG_ENDIAN ) ;
diam_sub_dis - > avp_str = ( char * ) wmem_alloc ( wmem_packet_scope ( ) , ITEM_LABEL_LENGTH + 1 ) ;
proto_item_fill_label ( PITEM_FINFO ( pi ) , diam_sub_dis - > avp_str ) ;
diam_sub_dis - > avp_str = strstr ( diam_sub_dis - > avp_str , " : " ) + 2 ;
}
}
2012-03-13 15:06:40 +00:00
/* From RFC 3162 section 2.3 */
static int
2016-04-15 17:39:06 +00:00
dissect_diameter_base_framed_ipv6_prefix ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data )
2012-03-13 15:06:40 +00:00
{
2014-03-16 17:57:18 +00:00
diam_sub_dis_t * diam_sub_dis = ( diam_sub_dis_t * ) data ;
2018-01-04 13:14:43 +00:00
guint32 prefix_len , prefix_len_bytes ;
2015-11-28 10:45:24 +00:00
proto_item * pi ;
2012-03-13 15:06:40 +00:00
2012-04-26 16:05:05 +00:00
proto_tree_add_item ( tree , hf_framed_ipv6_prefix_reserved , tvb , 0 , 1 , ENC_BIG_ENDIAN ) ;
2018-01-04 13:14:43 +00:00
pi = proto_tree_add_item_ret_uint ( tree , hf_framed_ipv6_prefix_length , tvb , 1 , 1 , ENC_BIG_ENDIAN , & prefix_len ) ;
2012-03-13 15:06:40 +00:00
2015-11-28 10:45:24 +00:00
if ( prefix_len > 128 ) {
expert_add_info ( pinfo , pi , & ei_diameter_invalid_ipv6_prefix_len ) ;
}
2012-04-26 16:05:05 +00:00
prefix_len_bytes = prefix_len / 8 ;
if ( prefix_len % 8 )
prefix_len_bytes + + ;
2012-03-13 15:06:40 +00:00
2012-04-26 16:05:05 +00:00
proto_tree_add_item ( tree , hf_framed_ipv6_prefix_bytes , tvb , 2 , prefix_len_bytes , ENC_NA ) ;
2012-03-13 15:06:40 +00:00
2012-04-26 16:05:05 +00:00
/* If we have a fully IPv6 address, display it as such */
2014-08-19 13:01:43 +00:00
if ( prefix_len_bytes = = 16 ) {
2012-04-26 16:05:05 +00:00
proto_tree_add_item ( tree , hf_framed_ipv6_prefix_ipv6 , tvb , 2 , prefix_len_bytes , ENC_NA ) ;
2015-11-28 10:45:24 +00:00
} else if ( prefix_len_bytes < 16 ) {
2017-10-26 08:50:00 +00:00
ws_in6_addr value ;
2014-12-21 17:38:13 +00:00
address addr ;
2014-03-14 12:55:34 +00:00
memset ( & value . bytes , 0 , sizeof ( value ) ) ;
tvb_memcpy ( tvb , ( guint8 * ) & value . bytes , 2 , prefix_len_bytes ) ;
value . bytes [ prefix_len_bytes ] = value . bytes [ prefix_len_bytes ] & ( 0xff < < ( prefix_len % 8 ) ) ;
2015-10-05 21:43:46 +00:00
proto_tree_add_ipv6 ( tree , hf_framed_ipv6_prefix_ipv6 , tvb , 2 , prefix_len_bytes , & value ) ;
2015-10-21 19:04:16 +00:00
set_address ( & addr , AT_IPv6 , 16 , value . bytes ) ;
2014-12-21 17:38:13 +00:00
diam_sub_dis - > avp_str = wmem_strdup_printf ( wmem_packet_scope ( ) , " %s/%u " , address_to_str ( wmem_packet_scope ( ) , & addr ) , prefix_len ) ;
2014-03-14 12:55:34 +00:00
}
2012-03-13 15:06:40 +00:00
2012-04-26 16:05:05 +00:00
return ( prefix_len_bytes + 2 ) ;
2012-03-13 15:06:40 +00:00
}
2014-08-20 19:08:21 +00:00
/* AVP Code: 1 User-Name */
/* Do special decoding of the User-Name depending on the interface */
static int
dissect_diameter_user_name ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data )
{
2014-10-06 16:55:18 +00:00
diam_sub_dis_t * diam_sub_dis = ( diam_sub_dis_t * ) data ;
guint32 application_id = 0 , str_len ;
if ( diam_sub_dis ) {
application_id = diam_sub_dis - > application_id ;
}
switch ( application_id ) {
case DIAM_APPID_3GPP_S6A_S6D :
case DIAM_APPID_3GPP_SLH :
case DIAM_APPID_3GPP_S7A :
str_len = tvb_reported_length ( tvb ) ;
dissect_e212_utf8_imsi ( tvb , pinfo , tree , 0 , str_len ) ;
return str_len ;
}
return 0 ;
2014-08-20 19:08:21 +00:00
}
2019-05-30 18:26:24 +00:00
/* AVP Code: 124 MIP6-Feature-Vector */
/* RFC 5447, 5779 */
/* 3GPP TS 29.273, V15.2.0 */
static int
dissect_diameter_mip6_feature_vector ( tvbuff_t * tvb , packet_info * pinfo _U_ , proto_tree * tree , void * data )
{
2020-06-19 01:14:46 +00:00
static int * const flags_rfc [ ] = {
2019-05-30 18:26:24 +00:00
& hf_diameter_mip6_feature_vector_mip6_integrated ,
& hf_diameter_mip6_feature_vector_local_home_agent_assignment ,
& hf_diameter_mip6_feature_vector_pmip6_supported ,
& hf_diameter_mip6_feature_vector_ip4_hoa_supported ,
& hf_diameter_mip6_feature_vector_local_mag_routing_supported ,
NULL
} ;
2020-06-19 01:14:46 +00:00
static int * const flags_3gpp [ ] = {
& hf_diameter_3gpp_mip6_feature_vector_assign_local_ip ,
2019-05-30 18:26:24 +00:00
& hf_diameter_3gpp_mip6_feature_vector_mip4_supported ,
& hf_diameter_3gpp_mip6_feature_vector_optimized_idle_mode_mobility ,
& hf_diameter_3gpp_mip6_feature_vector_gtpv2_supported ,
NULL
} ;
guint32 application_id = 0 ;
diam_sub_dis_t * diam_sub_dis_inf = ( diam_sub_dis_t * ) data ;
2021-06-05 23:54:29 +00:00
DISSECTOR_ASSERT ( diam_sub_dis_inf ) ;
2019-05-30 18:26:24 +00:00
2021-06-05 23:54:29 +00:00
application_id = diam_sub_dis_inf - > application_id ;
2019-05-30 18:26:24 +00:00
/* Hide the item created in packet-diameter.c and only show the one created here */
proto_item_set_hidden ( diam_sub_dis_inf - > item ) ;
/* Dissect values defined in RFC 5447, 5779 */
proto_tree_add_bitmask ( tree , tvb , 0 , hf_diameter_mip6_feature_vector , ett_diameter_mip6_feature_vector , flags_rfc , ENC_BIG_ENDIAN ) ;
switch ( application_id ) {
case DIAM_APPID_3GPP_STA :
case DIAM_APPID_3GPP_SWM :
case DIAM_APPID_3GPP_SWX :
case DIAM_APPID_3GPP_S6B :
/* Dissect values defined in TGPP TS 29.273, V15.2.0 */
proto_tree_add_bitmask ( tree , tvb , 0 , hf_diameter_3gpp_mip6_feature_vector , ett_diameter_3gpp_mip6_feature_vector , flags_3gpp , ENC_BIG_ENDIAN ) ;
break ;
}
return 8 ;
}
2014-08-20 19:08:21 +00:00
/* AVP Code: 443 Subscription-Id */
static int
2019-11-03 11:12:19 +00:00
dissect_diameter_subscription_id ( tvbuff_t * tvb _U_ , packet_info * pinfo _U_ , proto_tree * tree _U_ , void * data )
2014-08-20 19:08:21 +00:00
{
2014-10-06 16:55:18 +00:00
/* Just reset our global subscription-id-type variable */
2019-11-03 11:12:19 +00:00
diam_sub_dis_t * diam_sub_dis_inf = ( diam_sub_dis_t * ) data ;
diam_sub_dis_inf - > subscription_id_type = SUBSCRIPTION_ID_TYPE_UNKNOWN ;
2014-08-20 19:08:21 +00:00
2014-10-06 16:55:18 +00:00
return 0 ;
2014-08-20 19:08:21 +00:00
}
/* AVP Code: 450 Subscription-Id-Type */
static int
2019-11-03 11:12:19 +00:00
dissect_diameter_subscription_id_type ( tvbuff_t * tvb , packet_info * pinfo _U_ , proto_tree * tree _U_ , void * data )
2014-08-20 19:08:21 +00:00
{
2019-11-03 11:12:19 +00:00
diam_sub_dis_t * diam_sub_dis_inf = ( diam_sub_dis_t * ) data ;
diam_sub_dis_inf - > subscription_id_type = tvb_get_ntohl ( tvb , 0 ) ;
2014-08-20 19:08:21 +00:00
2014-10-06 16:55:18 +00:00
return 0 ;
2014-08-20 19:08:21 +00:00
}
/* AVP Code: 444 Subscription-Id-Data */
static int
2019-11-03 11:12:19 +00:00
dissect_diameter_subscription_id_data ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data )
2014-08-20 19:08:21 +00:00
{
2014-10-06 16:55:18 +00:00
guint32 str_len ;
2019-11-03 11:12:19 +00:00
diam_sub_dis_t * diam_sub_dis_inf = ( diam_sub_dis_t * ) data ;
guint32 subscription_id_type = diam_sub_dis_inf - > subscription_id_type ;
2014-08-20 19:08:21 +00:00
2014-10-06 16:55:18 +00:00
switch ( subscription_id_type ) {
2014-08-20 19:08:21 +00:00
case SUBSCRIPTION_ID_TYPE_IMSI :
2014-10-06 16:55:18 +00:00
str_len = tvb_reported_length ( tvb ) ;
dissect_e212_utf8_imsi ( tvb , pinfo , tree , 0 , str_len ) ;
return str_len ;
2014-08-20 19:08:21 +00:00
case SUBSCRIPTION_ID_TYPE_E164 :
2014-10-06 16:55:18 +00:00
str_len = tvb_reported_length ( tvb ) ;
dissect_e164_msisdn ( tvb , tree , 0 , str_len , E164_ENC_UTF8 ) ;
return str_len ;
2019-11-03 11:12:19 +00:00
}
return 0 ;
}
/* AVP Code: 458 User-Equipment-Info */
static int
dissect_diameter_user_equipment_info ( tvbuff_t * tvb _U_ , packet_info * pinfo _U_ , proto_tree * tree _U_ , void * data )
{
/* Just reset our global subscription-id-type variable */
diam_sub_dis_t * diam_sub_dis_inf = ( diam_sub_dis_t * ) data ;
diam_sub_dis_inf - > user_equipment_info_type = USER_EQUIPMENT_INFO_TYPE_UNKNOWN ;
return 0 ;
}
/* AVP Code: 459 User-Equipment-Info-Type */
/* RFC 8506 section 8.50 */
static int
dissect_diameter_user_equipment_info_type ( tvbuff_t * tvb , packet_info * pinfo _U_ , proto_tree * tree _U_ , void * data )
{
diam_sub_dis_t * diam_sub_dis_inf = ( diam_sub_dis_t * ) data ;
diam_sub_dis_inf - > user_equipment_info_type = tvb_get_ntohl ( tvb , 0 ) ;
return 0 ;
}
/* AVP Code: 460 User-Equipment-Info-Value */
/* RFC 8506 section 8.51 */
static int
dissect_diameter_user_equipment_info_value ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data )
{
guint32 len ;
diam_sub_dis_t * diam_sub_dis_inf = ( diam_sub_dis_t * ) data ;
guint32 user_equipment_info_type = diam_sub_dis_inf - > user_equipment_info_type ;
switch ( user_equipment_info_type ) {
case USER_EQUIPMENT_INFO_TYPE_IMEISV :
/* RFC 8506 section 8.53, 3GPP TS 23.003 */
len = tvb_reported_length ( tvb ) ;
2021-03-31 21:58:30 +00:00
/* IMEISV is 16 digits, but often transmitted BCD coded in 8 octets. */
if ( len = = 8 ) {
proto_tree_add_item ( tree , hf_diameter_user_equipment_info_imeisv , tvb , 0 , len , ENC_BCD_DIGITS_0_9 | ENC_NA ) ;
return len ;
} else if ( len = = 16 ) {
proto_tree_add_item ( tree , hf_diameter_user_equipment_info_imeisv , tvb , 0 , len , ENC_ASCII | ENC_NA ) ;
return len ;
}
proto_tree_add_expert ( tree , pinfo , & ei_diameter_invalid_user_equipment_info_value_len , tvb , 0 , len ) ;
break ;
2019-11-03 11:12:19 +00:00
case USER_EQUIPMENT_INFO_TYPE_MAC :
/* RFC 8506 section 8.54, RFC 5777 section 4.1.7.8 */
len = tvb_reported_length ( tvb ) ;
2021-03-31 21:58:30 +00:00
if ( len = = FT_ETHER_LEN ) {
2019-11-03 11:12:19 +00:00
proto_tree_add_item ( tree , hf_diameter_user_equipment_info_mac , tvb , 0 , len , ENC_NA ) ;
return len ;
}
proto_tree_add_expert ( tree , pinfo , & ei_diameter_invalid_user_equipment_info_value_len , tvb , 0 , len ) ;
break ;
case USER_EQUIPMENT_INFO_TYPE_EUI64 :
/* RFC 8506 section 8.55 */
len = tvb_reported_length ( tvb ) ;
2021-03-31 21:58:30 +00:00
if ( len = = FT_EUI64_LEN ) {
2019-11-03 11:12:19 +00:00
proto_tree_add_item ( tree , hf_diameter_user_equipment_info_eui64 , tvb , 0 , len , ENC_BIG_ENDIAN ) ;
return len ;
}
proto_tree_add_expert ( tree , pinfo , & ei_diameter_invalid_user_equipment_info_value_len , tvb , 0 , len ) ;
break ;
case USER_EQUIPMENT_INFO_TYPE_MODIFIED_EUI64 :
/* RFC 8506 section 8.56, RFC 4291 */
len = tvb_reported_length ( tvb ) ;
2021-03-31 21:58:30 +00:00
if ( len = = FT_EUI64_LEN ) {
proto_tree_add_item ( tree , hf_diameter_user_equipment_info_modified_eui64 , tvb , 0 , len , ENC_BIG_ENDIAN ) ;
2019-11-03 11:12:19 +00:00
return len ;
}
proto_tree_add_expert ( tree , pinfo , & ei_diameter_invalid_user_equipment_info_value_len , tvb , 0 , len ) ;
2014-10-06 16:55:18 +00:00
break ;
}
2014-08-20 19:08:21 +00:00
2014-10-06 16:55:18 +00:00
return 0 ;
2014-08-20 19:08:21 +00:00
}
2013-07-18 15:08:15 +00:00
/* Call subdissectors for AVPs.
* This is a separate function to avoid having any local variables that might
* get clobbered by the exception longjmp ( ) ( without having to declare the
* variables as volatile and deal with casting them ) .
*/
static void
2013-10-28 15:59:26 +00:00
call_avp_subdissector ( guint32 vendorid , guint32 code , tvbuff_t * subtvb , packet_info * pinfo , proto_tree * avp_tree , diam_sub_dis_t * diam_sub_dis_inf )
2013-07-18 15:08:15 +00:00
{
TRY {
switch ( vendorid ) {
case 0 :
2014-03-13 20:08:57 +00:00
dissector_try_uint_new ( diameter_dissector_table , code , subtvb , pinfo , avp_tree , FALSE , diam_sub_dis_inf ) ;
2013-07-18 15:08:15 +00:00
break ;
case VENDOR_ERICSSON :
2014-03-13 20:08:57 +00:00
dissector_try_uint_new ( diameter_ericsson_avp_dissector_table , code , subtvb , pinfo , avp_tree , FALSE , diam_sub_dis_inf ) ;
2013-07-18 15:08:15 +00:00
break ;
2017-04-27 11:03:42 +00:00
case VENDOR_VERIZON :
dissector_try_uint_new ( diameter_verizon_avp_dissector_table , code , subtvb , pinfo , avp_tree , FALSE , diam_sub_dis_inf ) ;
break ;
2013-07-18 15:08:15 +00:00
case VENDOR_THE3GPP :
2013-10-28 15:59:26 +00:00
dissector_try_uint_new ( diameter_3gpp_avp_dissector_table , code , subtvb , pinfo , avp_tree , FALSE , diam_sub_dis_inf ) ;
2013-07-18 15:08:15 +00:00
break ;
default :
break ;
}
/* Debug
2014-08-04 01:10:24 +00:00
proto_tree_add_subtree ( avp_tree , subtvb , 0 , - 1 , " AVP %u data, Vendor Id %u " , code , vendorid ) ;
2013-07-18 15:08:15 +00:00
*/
}
CATCH_NONFATAL_ERRORS {
show_exception ( subtvb , pinfo , avp_tree , EXCEPT_CODE , GET_MESSAGE ) ;
}
ENDTRY ;
}
2007-07-27 18:32:09 +00:00
/* Dissect an AVP at offset */
2008-07-15 21:06:31 +00:00
static int
2019-08-14 01:47:09 +00:00
dissect_diameter_avp ( diam_ctx_t * c , tvbuff_t * tvb , int offset , diam_sub_dis_t * diam_sub_dis_inf , gboolean update_col_info )
2008-07-15 21:06:31 +00:00
{
2010-10-14 17:50:35 +00:00
guint32 code = tvb_get_ntohl ( tvb , offset ) ;
guint32 len = tvb_get_ntohl ( tvb , offset + 4 ) ;
guint32 vendor_flag = len & 0x80000000 ;
2007-07-16 05:41:58 +00:00
guint32 flags_bits_idx = ( len & 0xE0000000 ) > > 29 ;
2010-10-14 17:50:35 +00:00
guint32 flags_bits = ( len & 0xFF000000 ) > > 24 ;
guint32 vendorid = vendor_flag ? tvb_get_ntohl ( tvb , offset + 8 ) : 0 ;
2014-01-15 19:29:03 +00:00
wmem_tree_key_t k [ 3 ] ;
2014-01-17 18:55:49 +00:00
diam_avp_t * a ;
2007-07-16 05:41:58 +00:00
proto_item * pi , * avp_item ;
proto_tree * avp_tree , * save_tree ;
2012-12-16 01:12:59 +00:00
tvbuff_t * subtvb ;
diam_vnd_t * vendor ;
const char * code_str ;
2013-12-04 21:32:16 +00:00
const char * avp_str = NULL ;
2013-03-22 18:13:31 +00:00
guint8 pad_len ;
2014-01-15 19:29:03 +00:00
k [ 0 ] . length = 1 ;
k [ 0 ] . key = & code ;
k [ 1 ] . length = 1 ;
k [ 1 ] . key = & vendorid ;
k [ 2 ] . length = 0 ;
k [ 2 ] . key = NULL ;
2014-01-17 18:55:49 +00:00
a = ( diam_avp_t * ) wmem_tree_lookup32_array ( dictionary . avps , k ) ;
2007-07-16 05:41:58 +00:00
len & = 0x00ffffff ;
2013-03-22 18:13:31 +00:00
pad_len = ( len % 4 ) ? 4 - ( len % 4 ) : 0 ;
2002-08-28 21:04:11 +00:00
2007-07-17 22:19:54 +00:00
if ( ! a ) {
a = & unknown_avp ;
2007-10-24 16:32:51 +00:00
if ( vendor_flag ) {
2013-09-04 21:06:56 +00:00
if ( ! ( vendor = ( diam_vnd_t * ) wmem_tree_lookup32 ( dictionary . vnds , vendorid ) ) )
2007-07-17 22:19:54 +00:00
vendor = & unknown_vendor ;
} else {
vendor = & no_vnd ;
}
} else {
2010-10-14 17:50:35 +00:00
vendor = ( diam_vnd_t * ) a - > vendor ;
2007-07-17 22:19:54 +00:00
}
2007-07-17 21:29:18 +00:00
2013-11-21 18:46:40 +00:00
if ( vendor - > vs_avps_ext = = NULL ) {
2016-02-18 10:30:41 +00:00
wmem_array_sort ( vendor - > vs_avps , compare_avps ) ;
2013-11-21 18:46:40 +00:00
vendor - > vs_avps_ext = value_string_ext_new ( VND_AVP_VS ( vendor ) ,
VND_AVP_VS_LEN ( vendor ) + 1 ,
2016-08-31 08:16:24 +00:00
wmem_strdup_printf ( wmem_epan_scope ( ) , " diameter_vendor_%s " ,
2017-06-24 13:25:41 +00:00
enterprises_lookup ( vendorid , " Unknown " ) ) ) ;
2010-05-24 14:20:53 +00:00
#if 0
2010-10-14 17:50:35 +00:00
{ /* Debug code */
2013-11-21 18:46:40 +00:00
value_string * vendor_avp_vs = VALUE_STRING_EXT_VS_P ( vendor - > vs_avps_ext ) ;
2010-10-14 17:50:35 +00:00
gint i = 0 ;
2013-11-21 18:46:40 +00:00
while ( vendor_avp_vs [ i ] . strptr ! = NULL ) {
2021-06-15 15:03:55 +00:00
ws_warning ( " %u %s " , vendor_avp_vs [ i ] . value , vendor_avp_vs [ i ] . strptr ) ;
2010-10-14 17:50:35 +00:00
i + + ;
}
2010-05-24 14:20:53 +00:00
}
# endif
}
2016-08-30 12:55:54 +00:00
/* Check if the length is sane */
if ( len > ( guint32 ) tvb_reported_length_remaining ( tvb , offset ) ) {
proto_tree_add_expert_format ( c - > tree , c - > pinfo , & ei_diameter_invalid_avp_len , tvb , offset + 4 , 4 ,
" Wrong AVP(%u) length %u " ,
code ,
len ) ;
return tvb_reported_length ( tvb ) ;
}
2007-07-17 21:29:18 +00:00
2019-08-14 23:19:33 +00:00
/*
* Workaround for a MS - CHAPv2 capture from Bug 15603 that lacks padding .
*/
if ( tvb_reported_length_remaining ( tvb , offset + len ) < pad_len ) {
pad_len = ( guint32 ) tvb_reported_length_remaining ( tvb , offset + len ) ;
}
2007-07-27 18:32:09 +00:00
/* Add root of tree for this AVP */
2013-04-02 18:15:42 +00:00
avp_item = proto_tree_add_item ( c - > tree , hf_diameter_avp , tvb , offset , len + pad_len , ENC_NA ) ;
avp_tree = proto_item_add_subtree ( avp_item , a - > ett ) ;
2007-07-17 21:29:18 +00:00
2011-10-06 03:35:44 +00:00
pi = proto_tree_add_item ( avp_tree , hf_diameter_avp_code , tvb , offset , 4 , ENC_BIG_ENDIAN ) ;
2010-10-14 17:50:35 +00:00
code_str = val_to_str_ext_const ( code , vendor - > vs_avps_ext , " Unknown " ) ;
2007-07-16 05:41:58 +00:00
proto_item_append_text ( pi , " %s " , code_str ) ;
2007-07-17 22:19:54 +00:00
2007-07-27 18:32:09 +00:00
/* Code */
2007-07-17 22:19:54 +00:00
if ( a = = & unknown_avp ) {
2012-12-16 01:12:59 +00:00
proto_tree * tu = proto_item_add_subtree ( pi , ett_unknown ) ;
2013-09-01 13:05:27 +00:00
proto_tree_add_expert_format ( tu , c - > pinfo , & ei_diameter_avp_code , tvb , offset , 4 ,
" Unknown AVP %u (vendor=%s), if you know what this is you can add it to dictionary.xml " , code ,
2017-06-24 13:25:41 +00:00
enterprises_lookup ( vendorid , " Unknown " ) ) ;
2007-07-17 22:19:54 +00:00
}
2007-10-24 16:32:51 +00:00
2007-07-16 05:41:58 +00:00
offset + = 4 ;
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
proto_item_set_text ( avp_item , " AVP: %s(%u) l=%u f=%s " , code_str , code , len , avpflags_str [ flags_bits_idx ] ) ;
2019-08-14 01:47:09 +00:00
if ( update_col_info ) {
col_append_fstr ( c - > pinfo - > cinfo , COL_INFO , " %s " , code_str ) ;
}
2007-07-17 21:29:18 +00:00
2007-07-27 18:32:09 +00:00
/* Flags */
2007-07-16 05:41:58 +00:00
{
2020-06-19 01:14:46 +00:00
static int * const diameter_avp_flags [ ] = {
2018-01-04 13:14:43 +00:00
& hf_diameter_avp_flags_vendor_specific ,
& hf_diameter_avp_flags_mandatory ,
& hf_diameter_avp_flags_protected ,
& hf_diameter_avp_flags_reserved3 ,
& hf_diameter_avp_flags_reserved4 ,
& hf_diameter_avp_flags_reserved5 ,
& hf_diameter_avp_flags_reserved6 ,
& hf_diameter_avp_flags_reserved7 ,
NULL
} ;
pi = proto_tree_add_bitmask_with_flags ( avp_tree , tvb , offset , hf_diameter_avp_flags ,
ett_diameter_avp_flags , diameter_avp_flags , ENC_BIG_ENDIAN , BMT_NO_FALSE | BMT_NO_INT ) ;
if ( flags_bits & 0x1f ) expert_add_info ( c - > pinfo , pi , & ei_diameter_reserved_bit_set ) ;
2001-11-01 21:52:44 +00:00
}
2007-07-16 05:41:58 +00:00
offset + = 1 ;
2007-07-17 21:29:18 +00:00
2007-07-27 18:32:09 +00:00
/* Length */
2011-10-06 03:35:44 +00:00
proto_tree_add_item ( avp_tree , hf_diameter_avp_len , tvb , offset , 3 , ENC_BIG_ENDIAN ) ;
2007-07-16 05:41:58 +00:00
offset + = 3 ;
2007-07-17 21:29:18 +00:00
2007-07-27 18:32:09 +00:00
/* Vendor flag */
2007-07-16 05:41:58 +00:00
if ( vendor_flag ) {
proto_item_append_text ( avp_item , " vnd=%s " , val_to_str ( vendorid , vnd_short_vs , " %d " ) ) ;
2011-10-06 03:35:44 +00:00
pi = proto_tree_add_item ( avp_tree , hf_diameter_avp_vendor_id , tvb , offset , 4 , ENC_BIG_ENDIAN ) ;
2007-07-17 22:19:54 +00:00
if ( vendor = = & unknown_vendor ) {
2012-12-16 01:12:59 +00:00
proto_tree * tu = proto_item_add_subtree ( pi , ett_unknown ) ;
2013-09-01 13:05:27 +00:00
proto_tree_add_expert ( tu , c - > pinfo , & ei_diameter_avp_vendor_id , tvb , offset , 4 ) ;
2007-07-18 13:18:41 +00:00
}
2007-07-16 05:41:58 +00:00
offset + = 4 ;
2001-11-01 21:52:44 +00:00
}
2007-07-17 21:29:18 +00:00
2007-07-27 18:32:09 +00:00
if ( len = = ( guint32 ) ( vendor_flag ? 12 : 8 ) ) {
/* Data is empty so return now */
2013-09-01 13:05:27 +00:00
proto_tree_add_expert ( avp_tree , c - > pinfo , & ei_diameter_avp_no_data , tvb , offset , 0 ) ;
2013-03-22 18:13:31 +00:00
/* pad_len is always 0 in this case, but kept here for consistency */
return len + pad_len ;
2007-07-27 18:32:09 +00:00
}
2013-12-04 20:55:52 +00:00
/* If we are dissecting a grouped AVP and find a Vendor Id AVP(266), save it */
2015-05-06 20:03:15 +00:00
if ( ( diam_sub_dis_inf - > dis_gouped ) & & ( ! vendor_flag ) & & ( code = = 266 ) ) {
2013-12-04 20:55:52 +00:00
diam_sub_dis_inf - > vendor_id = tvb_get_ntohl ( tvb , offset ) ;
}
2007-07-17 21:29:18 +00:00
2014-06-06 14:35:50 +00:00
subtvb = tvb_new_subset_length ( tvb , offset , len - ( 8 + ( vendor_flag ? 4 : 0 ) ) ) ;
2013-03-22 18:13:31 +00:00
offset + = len - ( 8 + ( vendor_flag ? 4 : 0 ) ) ;
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
save_tree = c - > tree ;
c - > tree = avp_tree ;
2013-12-04 20:55:52 +00:00
2015-05-06 20:03:15 +00:00
/* The Experimental-Result-Code AVP (298) comes inside the Experimental-Result
* grouped AVP ( 297 ) . The Vendor - ID AVP in the Experimental - Result specifies the
* name space of the Experimental - Result - Code . Unfortunately we don ' t have a way
* to specify , in XML , different Experimental - Result - Code enum values for different
* Vendor - IDs so we choose a Vendor - ID whose values get to go in XML ( we chose
* 3 GPP ) and handle other Vendor - IDs through the " diameter.vnd_exp_res " dissector
* table .
2013-12-04 20:55:52 +00:00
*/
2015-05-06 20:03:15 +00:00
if ( ( diam_sub_dis_inf - > dis_gouped )
& & ( ! vendor_flag )
& & ( code = = 298 )
& & ( diam_sub_dis_inf - > vendor_id ! = 0 )
& & ( diam_sub_dis_inf - > vendor_id ! = VENDOR_THE3GPP ) )
2013-12-04 20:55:52 +00:00
{
/* call subdissector */
2015-10-26 20:44:18 +00:00
if ( ! dissector_try_uint_new ( diameter_expr_result_vnd_table , diam_sub_dis_inf - > vendor_id ,
subtvb , c - > pinfo , avp_tree , FALSE , diam_sub_dis_inf ) ) {
/* No subdissector for this vendor ID, use the generic one */
dissect_diameter_other_vendor_exp_res ( subtvb , avp_tree , diam_sub_dis_inf ) ;
}
2015-05-06 20:03:15 +00:00
if ( diam_sub_dis_inf - > avp_str ) {
2013-12-04 20:55:52 +00:00
proto_item_append_text ( avp_item , " val=%s " , diam_sub_dis_inf - > avp_str ) ;
}
2015-05-06 20:03:15 +00:00
} else if ( c - > version_rfc ) {
2013-10-28 15:59:26 +00:00
avp_str = a - > dissector_rfc ( c , a , subtvb , diam_sub_dis_inf ) ;
2007-07-16 05:41:58 +00:00
} else {
2013-10-28 15:59:26 +00:00
avp_str = a - > dissector_v16 ( c , a , subtvb , diam_sub_dis_inf ) ;
2005-11-19 15:59:30 +00:00
}
2007-07-16 05:41:58 +00:00
c - > tree = save_tree ;
2007-07-17 21:29:18 +00:00
2014-03-16 17:57:18 +00:00
diam_sub_dis_inf - > avp_str = NULL ;
2013-10-28 15:59:26 +00:00
call_avp_subdissector ( vendorid , code , subtvb , c - > pinfo , avp_tree , diam_sub_dis_inf ) ;
2008-01-27 21:06:33 +00:00
2014-03-16 17:57:18 +00:00
/* Let the subdissector have precedence filling in the avp_item string */
2015-08-12 17:57:20 +00:00
if ( diam_sub_dis_inf - > avp_str ) {
2014-03-16 17:57:18 +00:00
proto_item_append_text ( avp_item , " val=%s " , diam_sub_dis_inf - > avp_str ) ;
2015-08-12 17:57:20 +00:00
} else if ( avp_str ) {
2014-03-16 17:57:18 +00:00
proto_item_append_text ( avp_item , " val=%s " , avp_str ) ;
}
2013-03-22 18:13:31 +00:00
if ( pad_len ) {
guint8 i ;
pi = proto_tree_add_item ( avp_tree , hf_diameter_avp_pad , tvb , offset , pad_len , ENC_NA ) ;
for ( i = 0 ; i < pad_len ; i + + ) {
if ( tvb_get_guint8 ( tvb , offset + + ) ! = 0 ) {
2013-09-01 13:05:27 +00:00
expert_add_info ( c - > pinfo , pi , & ei_diameter_avp_pad ) ;
2013-03-22 18:13:31 +00:00
break ;
}
}
}
2019-08-14 23:19:33 +00:00
if ( ( len + pad_len ) % 4 ) {
proto_tree_add_expert ( avp_tree , c - > pinfo , & ei_diameter_avp_pad_missing , tvb , offset , pad_len ) ;
}
2013-03-22 18:13:31 +00:00
return len + pad_len ;
2007-07-16 05:41:58 +00:00
}
2002-08-28 21:04:11 +00:00
2012-12-16 01:12:59 +00:00
static const char *
2013-10-28 15:59:26 +00:00
address_rfc_avp ( diam_ctx_t * c , diam_avp_t * a , tvbuff_t * tvb , diam_sub_dis_t * diam_sub_dis_inf _U_ )
2008-07-15 21:06:31 +00:00
{
2015-08-12 17:57:20 +00:00
char * label = NULL ;
2013-03-02 19:21:38 +00:00
address_avp_t * t = ( address_avp_t * ) a - > type_data ;
2014-10-06 16:55:18 +00:00
gint len = tvb_reported_length ( tvb ) ;
2014-09-10 13:13:46 +00:00
proto_item * pi = proto_tree_add_item ( c - > tree , a - > hf_value , tvb , 0 , len , ENC_BIG_ENDIAN ) ;
2012-12-16 01:12:59 +00:00
proto_tree * pt = proto_item_add_subtree ( pi , t - > ett ) ;
2018-01-04 13:14:43 +00:00
guint32 addr_type ;
2014-09-10 13:13:46 +00:00
len = len - 2 ;
2007-07-17 22:19:54 +00:00
2020-10-12 08:34:49 +00:00
proto_tree_add_item_ret_uint ( pt , t - > hf_address_type , tvb , 0 , 2 , ENC_NA , & addr_type ) ;
/* See afn.h and https://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml */
2007-07-17 22:19:54 +00:00
switch ( addr_type ) {
2020-10-12 08:34:49 +00:00
case AFNUM_INET :
2007-07-17 22:19:54 +00:00
if ( len ! = 4 ) {
2013-09-01 13:05:27 +00:00
proto_tree_add_expert_format ( pt , c - > pinfo , & ei_diameter_avp_len , tvb , 2 , len , " Wrong length for IPv4 Address: %d instead of 4 " , len ) ;
2007-07-17 22:19:54 +00:00
return " [Malformed] " ;
}
2011-11-02 01:53:37 +00:00
pi = proto_tree_add_item ( pt , t - > hf_ipv4 , tvb , 2 , 4 , ENC_BIG_ENDIAN ) ;
2007-07-17 22:19:54 +00:00
break ;
2020-10-12 08:34:49 +00:00
case AFNUM_INET6 :
2007-07-17 22:19:54 +00:00
if ( len ! = 16 ) {
2013-09-01 13:05:27 +00:00
proto_tree_add_expert_format ( pt , c - > pinfo , & ei_diameter_avp_len , tvb , 2 , len , " Wrong length for IPv6 Address: %d instead of 16 " , len ) ;
2007-07-17 22:19:54 +00:00
return " [Malformed] " ;
}
2011-10-31 07:05:52 +00:00
pi = proto_tree_add_item ( pt , t - > hf_ipv6 , tvb , 2 , 16 , ENC_NA ) ;
2007-07-17 22:19:54 +00:00
break ;
2020-10-12 08:34:49 +00:00
case AFNUM_E164 :
/* It's unclear what format the e164 address would be encoded in but AVP 3GPP 2008 has
* . . . value 8 , E .164 , and the address information is UTF8 encoded .
*/
if ( tvb_ascii_isprint ( tvb , 2 , len ) ) {
pi = proto_tree_add_item ( pt , t - > hf_e164_str , tvb , 2 , len , ENC_ASCII | ENC_NA ) ;
} else {
pi = proto_tree_add_item ( pt , t - > hf_other , tvb , 2 , - 1 , ENC_BIG_ENDIAN ) ;
}
break ;
2007-07-17 22:19:54 +00:00
default :
2011-10-31 07:05:52 +00:00
pi = proto_tree_add_item ( pt , t - > hf_other , tvb , 2 , - 1 , ENC_BIG_ENDIAN ) ;
2007-07-17 22:19:54 +00:00
break ;
}
2007-10-24 16:32:51 +00:00
2015-08-12 17:57:20 +00:00
if ( c - > tree ) {
label = ( char * ) wmem_alloc ( wmem_packet_scope ( ) , ITEM_LABEL_LENGTH + 1 ) ;
proto_item_fill_label ( PITEM_FINFO ( pi ) , label ) ;
label = strstr ( label , " : " ) + 2 ;
}
2007-07-17 22:19:54 +00:00
return label ;
}
2012-12-16 01:12:59 +00:00
static const char *
2013-10-28 15:59:26 +00:00
proto_avp ( diam_ctx_t * c , diam_avp_t * a , tvbuff_t * tvb , diam_sub_dis_t * diam_sub_dis_inf )
2007-07-20 00:15:17 +00:00
{
2013-03-02 19:21:38 +00:00
proto_avp_t * t = ( proto_avp_t * ) a - > type_data ;
2007-10-24 16:32:51 +00:00
2016-06-14 15:55:08 +00:00
col_set_writable ( c - > pinfo - > cinfo , COL_PROTOCOL , FALSE ) ;
col_set_writable ( c - > pinfo - > cinfo , COL_INFO , FALSE ) ;
2007-07-20 00:15:17 +00:00
if ( ! t - > handle ) {
t - > handle = find_dissector ( t - > name ) ;
2013-11-21 18:46:40 +00:00
if ( ! t - > handle ) t - > handle = data_handle ;
2007-07-20 00:15:17 +00:00
}
2007-10-24 16:32:51 +00:00
2013-07-18 15:08:15 +00:00
TRY {
2013-10-28 15:59:26 +00:00
call_dissector_with_data ( t - > handle , tvb , c - > pinfo , c - > tree , diam_sub_dis_inf ) ;
2013-07-18 15:08:15 +00:00
}
CATCH_NONFATAL_ERRORS {
show_exception ( tvb , c - > pinfo , c - > tree , EXCEPT_CODE , GET_MESSAGE ) ;
}
ENDTRY ;
2007-10-24 16:32:51 +00:00
2007-07-20 00:15:17 +00:00
return " " ;
}
2012-12-16 01:12:59 +00:00
static const char *
2013-10-28 15:59:26 +00:00
time_avp ( diam_ctx_t * c , diam_avp_t * a , tvbuff_t * tvb , diam_sub_dis_t * diam_sub_dis_inf _U_ )
2008-07-15 21:06:31 +00:00
{
2014-07-28 18:18:49 +00:00
int len = tvb_reported_length ( tvb ) ;
2015-08-12 17:57:20 +00:00
char * label = NULL ;
2012-12-16 01:12:59 +00:00
proto_item * pi ;
2007-10-24 16:32:51 +00:00
2007-07-20 00:15:17 +00:00
if ( len ! = 4 ) {
2013-09-01 13:05:27 +00:00
proto_tree_add_expert_format ( c - > tree , c - > pinfo , & ei_diameter_avp_len , tvb , 0 , 4 ,
" Bad Timestamp Length: %d instead of 4 " , len ) ;
2007-07-20 00:15:17 +00:00
return " [Malformed] " ;
}
2007-10-24 16:32:51 +00:00
2015-08-12 17:57:20 +00:00
if ( c - > tree ) {
label = ( char * ) wmem_alloc ( wmem_packet_scope ( ) , ITEM_LABEL_LENGTH + 1 ) ;
2017-03-28 10:17:48 +00:00
pi = proto_tree_add_item ( c - > tree , ( a - > hf_value ) , tvb , 0 , 4 , ENC_TIME_SECS_NTP | ENC_BIG_ENDIAN ) ;
2015-08-12 17:57:20 +00:00
proto_item_fill_label ( PITEM_FINFO ( pi ) , label ) ;
label = strstr ( label , " : " ) + 2 ;
}
2007-07-20 00:15:17 +00:00
return label ;
}
2012-12-16 01:12:59 +00:00
static const char *
2013-10-28 15:59:26 +00:00
address_v16_avp ( diam_ctx_t * c , diam_avp_t * a , tvbuff_t * tvb , diam_sub_dis_t * diam_sub_dis_inf _U_ )
2008-07-15 21:06:31 +00:00
{
2015-08-12 17:57:20 +00:00
char * label = NULL ;
2013-03-02 19:21:38 +00:00
address_avp_t * t = ( address_avp_t * ) a - > type_data ;
2014-07-28 18:18:49 +00:00
proto_item * pi = proto_tree_add_item ( c - > tree , a - > hf_value , tvb , 0 , tvb_reported_length ( tvb ) , ENC_BIG_ENDIAN ) ;
2012-12-16 01:12:59 +00:00
proto_tree * pt = proto_item_add_subtree ( pi , t - > ett ) ;
2014-07-28 18:18:49 +00:00
guint32 len = tvb_reported_length ( tvb ) ;
2007-10-24 16:32:51 +00:00
2007-07-17 22:19:54 +00:00
switch ( len ) {
case 4 :
2011-11-02 01:53:37 +00:00
pi = proto_tree_add_item ( pt , t - > hf_ipv4 , tvb , 0 , 4 , ENC_BIG_ENDIAN ) ;
2007-07-17 22:19:54 +00:00
break ;
case 16 :
2011-10-31 07:05:52 +00:00
pi = proto_tree_add_item ( pt , t - > hf_ipv6 , tvb , 0 , 16 , ENC_NA ) ;
2007-07-17 22:19:54 +00:00
break ;
default :
2011-10-31 07:05:52 +00:00
pi = proto_tree_add_item ( pt , t - > hf_other , tvb , 0 , len , ENC_BIG_ENDIAN ) ;
2013-09-09 00:44:09 +00:00
expert_add_info_format ( c - > pinfo , pi , & ei_diameter_avp_len ,
2013-09-01 13:05:27 +00:00
" Bad Address Length (%u) " , len ) ;
2007-10-24 16:32:51 +00:00
2007-07-17 22:19:54 +00:00
break ;
}
2007-10-24 16:32:51 +00:00
2015-08-12 17:57:20 +00:00
if ( c - > tree ) {
label = ( char * ) wmem_alloc ( wmem_packet_scope ( ) , ITEM_LABEL_LENGTH + 1 ) ;
proto_item_fill_label ( PITEM_FINFO ( pi ) , label ) ;
label = strstr ( label , " : " ) + 2 ;
}
2007-07-17 22:19:54 +00:00
return label ;
}
2012-12-16 01:12:59 +00:00
static const char *
2013-10-28 15:59:26 +00:00
simple_avp ( diam_ctx_t * c , diam_avp_t * a , tvbuff_t * tvb , diam_sub_dis_t * diam_sub_dis_inf _U_ )
2008-07-15 21:06:31 +00:00
{
2015-08-12 17:57:20 +00:00
char * label = NULL ;
if ( c - > tree ) {
proto_item * pi = proto_tree_add_item ( c - > tree , a - > hf_value , tvb , 0 , tvb_reported_length ( tvb ) , ENC_BIG_ENDIAN ) ;
label = ( char * ) wmem_alloc ( wmem_packet_scope ( ) , ITEM_LABEL_LENGTH + 1 ) ;
proto_item_fill_label ( PITEM_FINFO ( pi ) , label ) ;
label = strstr ( label , " : " ) + 2 ;
}
2011-10-31 07:05:52 +00:00
return label ;
}
2012-12-16 01:12:59 +00:00
static const char *
2013-10-28 15:59:26 +00:00
utf8_avp ( diam_ctx_t * c , diam_avp_t * a , tvbuff_t * tvb , diam_sub_dis_t * diam_sub_dis_inf _U_ )
2011-10-31 07:05:52 +00:00
{
2015-08-12 17:57:20 +00:00
char * label = NULL ;
if ( c - > tree ) {
proto_item * pi = proto_tree_add_item ( c - > tree , a - > hf_value , tvb , 0 , tvb_reported_length ( tvb ) , ENC_UTF_8 | ENC_BIG_ENDIAN ) ;
label = ( char * ) wmem_alloc ( wmem_packet_scope ( ) , ITEM_LABEL_LENGTH + 1 ) ;
proto_item_fill_label ( PITEM_FINFO ( pi ) , label ) ;
label = strstr ( label , " : " ) + 2 ;
}
2007-07-16 05:41:58 +00:00
return label ;
}
2005-04-26 08:15:45 +00:00
2012-12-16 01:12:59 +00:00
static const char *
2013-10-28 15:59:26 +00:00
integer32_avp ( diam_ctx_t * c , diam_avp_t * a , tvbuff_t * tvb , diam_sub_dis_t * diam_sub_dis_inf _U_ )
2008-07-15 21:06:31 +00:00
{
2015-08-12 17:57:20 +00:00
char * label = NULL ;
2012-12-16 01:12:59 +00:00
proto_item * pi ;
2007-07-27 18:32:09 +00:00
/* Verify length before adding */
2014-09-10 13:13:46 +00:00
gint length = tvb_reported_length ( tvb ) ;
2007-07-27 18:32:09 +00:00
if ( length = = 4 ) {
2015-08-12 17:57:20 +00:00
if ( c - > tree ) {
pi = proto_tree_add_item ( c - > tree , a - > hf_value , tvb , 0 , length , ENC_BIG_ENDIAN ) ;
label = ( char * ) wmem_alloc ( wmem_packet_scope ( ) , ITEM_LABEL_LENGTH + 1 ) ;
proto_item_fill_label ( PITEM_FINFO ( pi ) , label ) ;
label = strstr ( label , " : " ) + 2 ;
}
2007-07-27 18:32:09 +00:00
}
else {
pi = proto_tree_add_bytes_format ( c - > tree , hf_diameter_avp_data_wrong_length ,
Modify proto_tree_add_bytes_format() and proto_tree_add_bytes_format_value()
so that if the start_ptr is NULL the bytes are extracted from the given TVB
using the given offset and length.
Replace a bunch of:
proto_tree_add_bytes_format*(tree, hf, tvb, offset, length, tvb_get_ptr(tvb, offset, length), [...])
with:
proto_tree_add_bytes_format*(tree, hf, tvb, offset, length, NULL, [...])
svn path=/trunk/; revision=35896
2011-02-10 16:31:00 +00:00
tvb , 0 , length , NULL ,
2008-07-15 21:06:31 +00:00
" Error! Bad Integer32 Length " ) ;
2013-09-09 00:44:09 +00:00
expert_add_info_format ( c - > pinfo , pi , & ei_diameter_avp_len ,
2013-09-01 13:05:27 +00:00
" Bad Integer32 Length (%u) " , length ) ;
2019-04-03 21:32:30 +00:00
proto_item_set_generated ( pi ) ;
2007-07-27 18:32:09 +00:00
}
2015-08-12 17:57:20 +00:00
2007-07-27 18:32:09 +00:00
return label ;
}
2012-12-16 01:12:59 +00:00
static const char *
2013-10-28 15:59:26 +00:00
integer64_avp ( diam_ctx_t * c , diam_avp_t * a , tvbuff_t * tvb , diam_sub_dis_t * diam_sub_dis_inf _U_ )
2011-01-03 03:30:20 +00:00
{
2015-08-12 17:57:20 +00:00
char * label = NULL ;
2012-12-16 01:12:59 +00:00
proto_item * pi ;
2011-01-03 03:30:20 +00:00
/* Verify length before adding */
2014-09-10 13:13:46 +00:00
gint length = tvb_reported_length ( tvb ) ;
2011-01-03 03:30:20 +00:00
if ( length = = 8 ) {
2015-08-12 17:57:20 +00:00
if ( c - > tree ) {
pi = proto_tree_add_item ( c - > tree , a - > hf_value , tvb , 0 , length , ENC_BIG_ENDIAN ) ;
label = ( char * ) wmem_alloc ( wmem_packet_scope ( ) , ITEM_LABEL_LENGTH + 1 ) ;
proto_item_fill_label ( PITEM_FINFO ( pi ) , label ) ;
label = strstr ( label , " : " ) + 2 ;
}
2011-01-03 03:30:20 +00:00
}
else {
pi = proto_tree_add_bytes_format ( c - > tree , hf_diameter_avp_data_wrong_length ,
Modify proto_tree_add_bytes_format() and proto_tree_add_bytes_format_value()
so that if the start_ptr is NULL the bytes are extracted from the given TVB
using the given offset and length.
Replace a bunch of:
proto_tree_add_bytes_format*(tree, hf, tvb, offset, length, tvb_get_ptr(tvb, offset, length), [...])
with:
proto_tree_add_bytes_format*(tree, hf, tvb, offset, length, NULL, [...])
svn path=/trunk/; revision=35896
2011-02-10 16:31:00 +00:00
tvb , 0 , length , NULL ,
2011-01-03 03:30:20 +00:00
" Error! Bad Integer64 Length " ) ;
2013-09-09 00:44:09 +00:00
expert_add_info_format ( c - > pinfo , pi , & ei_diameter_avp_len ,
2013-09-01 13:05:27 +00:00
" Bad Integer64 Length (%u) " , length ) ;
2019-04-03 21:32:30 +00:00
proto_item_set_generated ( pi ) ;
2011-01-03 03:30:20 +00:00
}
2015-08-12 17:57:20 +00:00
2011-01-03 03:30:20 +00:00
return label ;
}
2012-12-16 01:12:59 +00:00
static const char *
2019-04-17 08:58:35 +00:00
unsigned32_avp ( diam_ctx_t * c , diam_avp_t * a , tvbuff_t * tvb , diam_sub_dis_t * diam_sub_dis_inf )
2011-01-03 03:30:20 +00:00
{
2015-08-12 17:57:20 +00:00
char * label = NULL ;
2012-12-16 01:12:59 +00:00
proto_item * pi ;
2011-01-03 03:30:20 +00:00
/* Verify length before adding */
2014-09-10 13:13:46 +00:00
gint length = tvb_reported_length ( tvb ) ;
2011-01-03 03:30:20 +00:00
if ( length = = 4 ) {
2015-08-12 17:57:20 +00:00
if ( c - > tree ) {
2019-04-17 08:58:35 +00:00
diam_sub_dis_inf - > item = pi = proto_tree_add_item ( c - > tree , a - > hf_value , tvb , 0 , length , ENC_BIG_ENDIAN ) ;
2015-08-12 17:57:20 +00:00
label = ( char * ) wmem_alloc ( wmem_packet_scope ( ) , ITEM_LABEL_LENGTH + 1 ) ;
proto_item_fill_label ( PITEM_FINFO ( pi ) , label ) ;
label = strstr ( label , " : " ) + 2 ;
}
2011-01-03 03:30:20 +00:00
}
else {
pi = proto_tree_add_bytes_format ( c - > tree , hf_diameter_avp_data_wrong_length ,
Modify proto_tree_add_bytes_format() and proto_tree_add_bytes_format_value()
so that if the start_ptr is NULL the bytes are extracted from the given TVB
using the given offset and length.
Replace a bunch of:
proto_tree_add_bytes_format*(tree, hf, tvb, offset, length, tvb_get_ptr(tvb, offset, length), [...])
with:
proto_tree_add_bytes_format*(tree, hf, tvb, offset, length, NULL, [...])
svn path=/trunk/; revision=35896
2011-02-10 16:31:00 +00:00
tvb , 0 , length , NULL ,
2011-01-03 03:30:20 +00:00
" Error! Bad Unsigned32 Length " ) ;
2013-09-09 00:44:09 +00:00
expert_add_info_format ( c - > pinfo , pi , & ei_diameter_avp_len ,
2013-09-01 13:05:27 +00:00
" Bad Unsigned32 Length (%u) " , length ) ;
2019-04-03 21:32:30 +00:00
proto_item_set_generated ( pi ) ;
2011-01-03 03:30:20 +00:00
}
2015-08-12 17:57:20 +00:00
2011-01-03 03:30:20 +00:00
return label ;
}
2012-12-16 01:12:59 +00:00
static const char *
2013-10-28 15:59:26 +00:00
unsigned64_avp ( diam_ctx_t * c , diam_avp_t * a , tvbuff_t * tvb , diam_sub_dis_t * diam_sub_dis_inf _U_ )
2011-01-03 03:30:20 +00:00
{
2015-08-12 17:57:20 +00:00
char * label = NULL ;
2012-12-16 01:12:59 +00:00
proto_item * pi ;
2011-01-03 03:30:20 +00:00
/* Verify length before adding */
2014-09-10 13:13:46 +00:00
gint length = tvb_reported_length ( tvb ) ;
2011-01-03 03:30:20 +00:00
if ( length = = 8 ) {
2015-08-12 17:57:20 +00:00
if ( c - > tree ) {
pi = proto_tree_add_item ( c - > tree , a - > hf_value , tvb , 0 , length , ENC_BIG_ENDIAN ) ;
label = ( char * ) wmem_alloc ( wmem_packet_scope ( ) , ITEM_LABEL_LENGTH + 1 ) ;
proto_item_fill_label ( PITEM_FINFO ( pi ) , label ) ;
label = strstr ( label , " : " ) + 2 ;
}
2011-01-03 03:30:20 +00:00
}
else {
pi = proto_tree_add_bytes_format ( c - > tree , hf_diameter_avp_data_wrong_length ,
Modify proto_tree_add_bytes_format() and proto_tree_add_bytes_format_value()
so that if the start_ptr is NULL the bytes are extracted from the given TVB
using the given offset and length.
Replace a bunch of:
proto_tree_add_bytes_format*(tree, hf, tvb, offset, length, tvb_get_ptr(tvb, offset, length), [...])
with:
proto_tree_add_bytes_format*(tree, hf, tvb, offset, length, NULL, [...])
svn path=/trunk/; revision=35896
2011-02-10 16:31:00 +00:00
tvb , 0 , length , NULL ,
2011-01-03 03:30:20 +00:00
" Error! Bad Unsigned64 Length " ) ;
2013-09-09 00:44:09 +00:00
expert_add_info_format ( c - > pinfo , pi , & ei_diameter_avp_len ,
2013-09-01 13:05:27 +00:00
" Bad Unsigned64 Length (%u) " , length ) ;
2019-04-03 21:32:30 +00:00
proto_item_set_generated ( pi ) ;
2011-01-03 03:30:20 +00:00
}
2015-08-12 17:57:20 +00:00
2011-01-03 03:30:20 +00:00
return label ;
}
2012-12-16 01:12:59 +00:00
static const char *
2013-10-28 15:59:26 +00:00
float32_avp ( diam_ctx_t * c , diam_avp_t * a , tvbuff_t * tvb , diam_sub_dis_t * diam_sub_dis_inf _U_ )
2011-01-03 03:30:20 +00:00
{
2015-08-12 17:57:20 +00:00
char * label = NULL ;
2012-12-16 01:12:59 +00:00
proto_item * pi ;
2011-01-03 03:30:20 +00:00
/* Verify length before adding */
2014-09-10 13:13:46 +00:00
gint length = tvb_reported_length ( tvb ) ;
2011-01-03 03:30:20 +00:00
if ( length = = 4 ) {
2015-08-12 17:57:20 +00:00
if ( c - > tree ) {
pi = proto_tree_add_item ( c - > tree , a - > hf_value , tvb , 0 , length , ENC_BIG_ENDIAN ) ;
label = ( char * ) wmem_alloc ( wmem_packet_scope ( ) , ITEM_LABEL_LENGTH + 1 ) ;
proto_item_fill_label ( PITEM_FINFO ( pi ) , label ) ;
label = strstr ( label , " : " ) + 2 ;
}
2011-01-03 03:30:20 +00:00
}
else {
pi = proto_tree_add_bytes_format ( c - > tree , hf_diameter_avp_data_wrong_length ,
Modify proto_tree_add_bytes_format() and proto_tree_add_bytes_format_value()
so that if the start_ptr is NULL the bytes are extracted from the given TVB
using the given offset and length.
Replace a bunch of:
proto_tree_add_bytes_format*(tree, hf, tvb, offset, length, tvb_get_ptr(tvb, offset, length), [...])
with:
proto_tree_add_bytes_format*(tree, hf, tvb, offset, length, NULL, [...])
svn path=/trunk/; revision=35896
2011-02-10 16:31:00 +00:00
tvb , 0 , length , NULL ,
2011-01-03 03:30:20 +00:00
" Error! Bad Float32 Length " ) ;
2013-09-09 00:44:09 +00:00
expert_add_info_format ( c - > pinfo , pi , & ei_diameter_avp_len ,
2013-09-01 13:05:27 +00:00
" Bad Float32 Length (%u) " , length ) ;
2019-04-03 21:32:30 +00:00
proto_item_set_generated ( pi ) ;
2011-01-03 03:30:20 +00:00
}
2015-08-12 17:57:20 +00:00
2011-01-03 03:30:20 +00:00
return label ;
}
2012-12-16 01:12:59 +00:00
static const char *
2013-10-28 15:59:26 +00:00
float64_avp ( diam_ctx_t * c , diam_avp_t * a , tvbuff_t * tvb , diam_sub_dis_t * diam_sub_dis_inf _U_ )
2011-01-03 03:30:20 +00:00
{
2015-08-12 17:57:20 +00:00
char * label = NULL ;
2012-12-16 01:12:59 +00:00
proto_item * pi ;
2011-01-03 03:30:20 +00:00
/* Verify length before adding */
2014-09-10 13:13:46 +00:00
gint length = tvb_reported_length ( tvb ) ;
2011-01-03 03:30:20 +00:00
if ( length = = 8 ) {
2015-08-12 17:57:20 +00:00
if ( c - > tree ) {
pi = proto_tree_add_item ( c - > tree , a - > hf_value , tvb , 0 , length , ENC_BIG_ENDIAN ) ;
label = ( char * ) wmem_alloc ( wmem_packet_scope ( ) , ITEM_LABEL_LENGTH + 1 ) ;
proto_item_fill_label ( PITEM_FINFO ( pi ) , label ) ;
label = strstr ( label , " : " ) + 2 ;
}
2011-01-03 03:30:20 +00:00
}
else {
pi = proto_tree_add_bytes_format ( c - > tree , hf_diameter_avp_data_wrong_length ,
Modify proto_tree_add_bytes_format() and proto_tree_add_bytes_format_value()
so that if the start_ptr is NULL the bytes are extracted from the given TVB
using the given offset and length.
Replace a bunch of:
proto_tree_add_bytes_format*(tree, hf, tvb, offset, length, tvb_get_ptr(tvb, offset, length), [...])
with:
proto_tree_add_bytes_format*(tree, hf, tvb, offset, length, NULL, [...])
svn path=/trunk/; revision=35896
2011-02-10 16:31:00 +00:00
tvb , 0 , length , NULL ,
2011-01-03 03:30:20 +00:00
" Error! Bad Float64 Length " ) ;
2013-09-09 00:44:09 +00:00
expert_add_info_format ( c - > pinfo , pi , & ei_diameter_avp_len ,
2013-09-01 13:05:27 +00:00
" Bad Float64 Length (%u) " , length ) ;
2019-04-03 21:32:30 +00:00
proto_item_set_generated ( pi ) ;
2011-01-03 03:30:20 +00:00
}
2015-08-12 17:57:20 +00:00
2011-01-03 03:30:20 +00:00
return label ;
}
2012-12-16 01:12:59 +00:00
static const char *
2013-10-28 15:59:26 +00:00
grouped_avp ( diam_ctx_t * c , diam_avp_t * a , tvbuff_t * tvb , diam_sub_dis_t * diam_sub_dis_inf )
2008-07-15 21:06:31 +00:00
{
2007-07-16 05:41:58 +00:00
int offset = 0 ;
2014-07-28 18:18:49 +00:00
int len = tvb_reported_length ( tvb ) ;
2012-12-16 01:12:59 +00:00
proto_item * pi = proto_tree_add_item ( c - > tree , a - > hf_value , tvb , 0 , - 1 , ENC_BIG_ENDIAN ) ;
proto_tree * pt = c - > tree ;
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
c - > tree = proto_item_add_subtree ( pi , a - > ett ) ;
2007-07-17 21:29:18 +00:00
2013-12-04 20:55:52 +00:00
/* Set the flag that we are dissecting a grouped AVP */
diam_sub_dis_inf - > dis_gouped = TRUE ;
2007-07-16 05:41:58 +00:00
while ( offset < len ) {
2019-08-14 01:47:09 +00:00
offset + = dissect_diameter_avp ( c , tvb , offset , diam_sub_dis_inf , FALSE ) ;
2001-11-01 21:52:44 +00:00
}
2013-12-04 20:55:52 +00:00
/* Clear info collected in grouped AVP */
2013-12-10 03:25:04 +00:00
diam_sub_dis_inf - > vendor_id = 0 ;
2013-12-04 20:55:52 +00:00
diam_sub_dis_inf - > dis_gouped = FALSE ;
diam_sub_dis_inf - > avp_str = NULL ;
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
c - > tree = pt ;
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
return NULL ;
}
2001-11-01 21:52:44 +00:00
2012-12-16 01:12:59 +00:00
static const char * msgflags_str [ ] = {
2007-07-17 22:19:54 +00:00
" ---- " , " ---T " , " --E- " , " --ET " ,
" -P-- " , " -P-T " , " -PE- " , " -PET " ,
" R--- " , " R--T " , " R-E- " , " R-ET " ,
" RP-- " , " RP-T " , " RPE- " , " RPET "
} ;
2020-06-19 01:14:46 +00:00
static int * const diameter_flags_fields [ ] = {
2015-02-16 14:13:25 +00:00
& hf_diameter_flags_request ,
& hf_diameter_flags_proxyable ,
& hf_diameter_flags_error ,
& hf_diameter_flags_T ,
& hf_diameter_flags_reserved4 ,
& hf_diameter_flags_reserved5 ,
& hf_diameter_flags_reserved6 ,
& hf_diameter_flags_reserved7 ,
NULL
} ;
2013-11-09 17:46:28 +00:00
static int
dissect_diameter_common ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data _U_ )
2008-07-15 21:06:31 +00:00
{
2018-01-04 13:14:43 +00:00
guint32 version ;
guint64 flags_bits ;
int packet_len ;
2007-07-20 11:39:09 +00:00
proto_item * pi , * cmd_item , * app_item , * version_item ;
2012-06-08 19:59:33 +00:00
proto_tree * diam_tree ;
2020-05-07 12:35:45 +00:00
diam_ctx_t * c = wmem_new0 ( wmem_packet_scope ( ) , diam_ctx_t ) ;
2007-07-16 05:41:58 +00:00
int offset ;
2012-06-08 19:59:33 +00:00
value_string * cmd_vs ;
const char * cmd_str ;
2018-01-04 13:14:43 +00:00
guint32 cmd ;
2012-12-16 01:12:59 +00:00
guint32 hop_by_hop_id , end_to_end_id ;
2008-11-15 15:52:39 +00:00
conversation_t * conversation ;
diameter_conv_info_t * diameter_conv_info ;
2012-12-16 02:37:06 +00:00
diameter_req_ans_pair_t * diameter_pair = NULL ;
2013-08-31 15:58:15 +00:00
wmem_tree_t * pdus_tree ;
2008-11-15 15:52:39 +00:00
proto_item * it ;
nstime_t ns ;
2013-09-14 10:53:29 +00:00
diam_sub_dis_t * diam_sub_dis_inf = wmem_new0 ( wmem_packet_scope ( ) , diam_sub_dis_t ) ;
2013-07-22 20:44:01 +00:00
2019-11-03 11:12:19 +00:00
/* Set default value Subscription-Id-Type and User-Equipment-Info-Type as XXX_UNKNOWN */
diam_sub_dis_inf - > subscription_id_type = SUBSCRIPTION_ID_TYPE_UNKNOWN ;
diam_sub_dis_inf - > user_equipment_info_type = USER_EQUIPMENT_INFO_TYPE_UNKNOWN ;
2016-04-13 03:01:18 +00:00
/* Load header fields if not already done */
if ( hf_diameter_code = = - 1 )
2016-06-13 19:28:16 +00:00
proto_registrar_get_byname ( " diameter.code " ) ;
2013-07-22 20:44:01 +00:00
2009-08-09 06:26:46 +00:00
col_set_str ( pinfo - > cinfo , COL_PROTOCOL , " DIAMETER " ) ;
2007-07-17 21:29:18 +00:00
2016-05-03 16:36:10 +00:00
if ( have_tap_listener ( exported_pdu_tap ) ) {
export_diameter_pdu ( pinfo , tvb ) ;
}
2011-10-21 02:10:19 +00:00
pi = proto_tree_add_item ( tree , proto_diameter , tvb , 0 , - 1 , ENC_NA ) ;
2007-07-17 22:19:54 +00:00
diam_tree = proto_item_add_subtree ( pi , ett_diameter ) ;
2007-07-17 21:29:18 +00:00
2007-07-17 22:19:54 +00:00
c - > tree = diam_tree ;
c - > pinfo = pinfo ;
2007-07-17 21:29:18 +00:00
2018-01-04 13:14:43 +00:00
version_item = proto_tree_add_item_ret_uint ( diam_tree , hf_diameter_version , tvb , 0 , 1 , ENC_BIG_ENDIAN , & version ) ;
proto_tree_add_item_ret_uint ( diam_tree , hf_diameter_length , tvb , 1 , 3 , ENC_BIG_ENDIAN , & packet_len ) ;
2007-07-17 21:29:18 +00:00
2018-01-04 13:14:43 +00:00
pi = proto_tree_add_bitmask_ret_uint64 ( diam_tree , tvb , 4 , hf_diameter_flags , ett_diameter_flags , diameter_flags_fields , ENC_BIG_ENDIAN , & flags_bits ) ;
if ( flags_bits & 0x0f ) {
expert_add_info ( c - > pinfo , pi , & ei_diameter_reserved_bit_set ) ;
}
2007-07-17 21:29:18 +00:00
2018-01-04 13:14:43 +00:00
cmd_item = proto_tree_add_item_ret_uint ( diam_tree , hf_diameter_code , tvb , 5 , 3 , ENC_BIG_ENDIAN , & cmd ) ;
2018-11-09 13:02:24 +00:00
diam_sub_dis_inf - > cmd_code = cmd ;
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
switch ( version ) {
case DIAMETER_V16 : {
2018-01-04 13:14:43 +00:00
guint32 vendorid ;
2012-12-16 01:12:59 +00:00
diam_vnd_t * vendor ;
2007-07-17 21:29:18 +00:00
2018-01-04 13:14:43 +00:00
proto_tree_add_item_ret_uint ( diam_tree , hf_diameter_vendor_id , tvb , 8 , 4 , ENC_BIG_ENDIAN , & vendorid ) ;
diam_sub_dis_inf - > application_id = vendorid ;
2013-09-04 21:06:56 +00:00
if ( ! ( vendor = ( diam_vnd_t * ) wmem_tree_lookup32 ( dictionary . vnds , vendorid ) ) ) {
2007-07-16 05:41:58 +00:00
vendor = & unknown_vendor ;
}
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
cmd_vs = VND_CMD_VS ( vendor ) ;
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
c - > version_rfc = FALSE ;
2005-11-19 15:59:30 +00:00
break ;
2007-07-16 05:41:58 +00:00
}
case DIAMETER_RFC : {
2012-06-08 19:59:33 +00:00
2012-12-16 01:12:59 +00:00
cmd_vs = ( value_string * ) ( void * ) all_cmds - > data ;
2012-06-08 19:59:33 +00:00
2018-01-04 13:14:43 +00:00
app_item = proto_tree_add_item_ret_uint ( diam_tree , hf_diameter_application_id , tvb , 8 , 4 ,
ENC_BIG_ENDIAN , & diam_sub_dis_inf - > application_id ) ;
2013-07-22 20:44:01 +00:00
2015-04-20 22:14:35 +00:00
if ( try_val_to_str_ext ( diam_sub_dis_inf - > application_id , dictionary . applications ) = = NULL ) {
2012-06-08 19:59:33 +00:00
proto_tree * tu = proto_item_add_subtree ( app_item , ett_unknown ) ;
2013-09-01 13:05:27 +00:00
proto_tree_add_expert_format ( tu , c - > pinfo , & ei_diameter_application_id , tvb , 8 , 4 ,
" Unknown Application Id (%u), if you know what this is you can add it to dictionary.xml " , diam_sub_dis_inf - > application_id ) ;
2007-07-20 11:39:09 +00:00
}
2007-07-16 05:41:58 +00:00
c - > version_rfc = TRUE ;
2005-11-19 15:59:30 +00:00
break ;
2007-07-16 05:41:58 +00:00
}
2005-11-19 15:59:30 +00:00
default :
2007-07-17 22:19:54 +00:00
{
2012-12-16 01:12:59 +00:00
proto_tree * pt = proto_item_add_subtree ( version_item , ett_err ) ;
2013-09-01 13:05:27 +00:00
proto_tree_add_expert ( pt , pinfo , & ei_diameter_version , tvb , 0 , 1 ) ;
2007-07-16 05:41:58 +00:00
c - > version_rfc = TRUE ;
cmd_vs = VND_CMD_VS ( & no_vnd ) ;
break ;
2007-07-17 22:19:54 +00:00
}
2005-11-19 15:59:30 +00:00
}
2012-08-10 22:55:02 +00:00
cmd_str = val_to_str_const ( cmd , cmd_vs , " Unknown " ) ;
2007-07-17 21:29:18 +00:00
2007-07-20 11:39:09 +00:00
/* Append name to command item, warn if unknown */
2007-07-16 05:41:58 +00:00
proto_item_append_text ( cmd_item , " %s " , cmd_str ) ;
2007-07-20 11:39:09 +00:00
if ( strcmp ( cmd_str , " Unknown " ) = = 0 ) {
2012-12-16 01:12:59 +00:00
proto_tree * tu = proto_item_add_subtree ( cmd_item , ett_unknown ) ;
2013-09-01 13:05:27 +00:00
proto_tree_add_expert ( tu , c - > pinfo , & ei_diameter_code , tvb , 5 , 3 ) ;
2007-07-20 11:39:09 +00:00
}
2001-11-01 21:52:44 +00:00
2010-04-26 22:19:34 +00:00
2018-01-04 13:14:43 +00:00
proto_tree_add_item_ret_uint ( diam_tree , hf_diameter_hopbyhopid , tvb , 12 , 4 , ENC_BIG_ENDIAN , & hop_by_hop_id ) ;
proto_tree_add_item_ret_uint ( diam_tree , hf_diameter_endtoendid , tvb , 16 , 4 , ENC_BIG_ENDIAN , & end_to_end_id ) ;
col_add_fstr ( pinfo - > cinfo , COL_INFO ,
" cmd=%s%s(%d) flags=%s %s=%s(%d) h2h=%x e2e=%x " ,
cmd_str ,
( ( flags_bits > > 4 ) & 0x08 ) ? " Request " : " Answer " ,
cmd ,
msgflags_str [ ( ( flags_bits > > 4 ) & 0x0f ) ] ,
c - > version_rfc ? " appl " : " vend " ,
c - > version_rfc ? val_to_str_ext_const ( diam_sub_dis_inf - > application_id , dictionary . applications , " Unknown " ) :
val_to_str_const ( diam_sub_dis_inf - > application_id , vnd_short_vs , " Unknown " ) ,
diam_sub_dis_inf - > application_id ,
hop_by_hop_id ,
end_to_end_id ) ;
col_append_str ( pinfo - > cinfo , COL_INFO , " | " ) ;
col_set_fence ( pinfo - > cinfo , COL_INFO ) ;
2007-07-17 22:19:54 +00:00
2008-11-15 15:52:39 +00:00
/* Conversation tracking stuff */
2010-04-26 22:19:34 +00:00
/*
2013-09-01 13:05:27 +00:00
* FIXME : Looking at epan / conversation . c it seems unlikely that this will work properly in
2008-11-15 15:52:39 +00:00
* multi - homed SCTP connections . This will probably need to be fixed at some point .
*/
2010-05-13 18:28:34 +00:00
conversation = find_or_create_conversation ( pinfo ) ;
2008-11-15 15:52:39 +00:00
2013-03-02 19:21:38 +00:00
diameter_conv_info = ( diameter_conv_info_t * ) conversation_get_proto_data ( conversation , proto_diameter ) ;
2008-11-15 15:52:39 +00:00
if ( ! diameter_conv_info ) {
2013-08-31 15:58:15 +00:00
diameter_conv_info = wmem_new ( wmem_file_scope ( ) , diameter_conv_info_t ) ;
2016-03-11 02:03:52 +00:00
diameter_conv_info - > pdu_trees = wmem_map_new ( wmem_file_scope ( ) , g_direct_hash , g_direct_equal ) ;
2008-11-15 15:52:39 +00:00
conversation_add_proto_data ( conversation , proto_diameter , diameter_conv_info ) ;
}
2013-08-31 15:58:15 +00:00
/* pdus_tree is an wmem_tree keyed by frame number (in order to handle hop-by-hop collisions */
2016-03-11 02:03:52 +00:00
pdus_tree = ( wmem_tree_t * ) wmem_map_lookup ( diameter_conv_info - > pdu_trees , GUINT_TO_POINTER ( hop_by_hop_id ) ) ;
2012-12-16 01:12:59 +00:00
if ( pdus_tree = = NULL & & ( flags_bits & DIAM_FLAGS_R ) ) {
/* This is the first request we've seen with this hop-by-hop id */
2013-08-31 15:58:15 +00:00
pdus_tree = wmem_tree_new ( wmem_file_scope ( ) ) ;
2016-03-11 02:03:52 +00:00
wmem_map_insert ( diameter_conv_info - > pdu_trees , GUINT_TO_POINTER ( hop_by_hop_id ) , pdus_tree ) ;
2012-12-16 01:12:59 +00:00
}
if ( pdus_tree ) {
2018-12-27 02:26:24 +00:00
if ( ! pinfo - > fd - > visited ) {
2012-12-16 01:12:59 +00:00
if ( flags_bits & DIAM_FLAGS_R ) {
/* This is a request */
2013-08-31 15:58:15 +00:00
diameter_pair = wmem_new ( wmem_file_scope ( ) , diameter_req_ans_pair_t ) ;
2012-12-16 01:12:59 +00:00
diameter_pair - > hop_by_hop_id = hop_by_hop_id ;
diameter_pair - > end_to_end_id = end_to_end_id ;
diameter_pair - > cmd_code = cmd ;
diameter_pair - > result_code = 0 ;
diameter_pair - > cmd_str = cmd_str ;
2016-01-24 03:40:51 +00:00
diameter_pair - > req_frame = pinfo - > num ;
2012-12-16 01:12:59 +00:00
diameter_pair - > ans_frame = 0 ;
2016-01-23 03:50:21 +00:00
diameter_pair - > req_time = pinfo - > abs_ts ;
2016-01-24 03:40:51 +00:00
wmem_tree_insert32 ( pdus_tree , pinfo - > num , ( void * ) diameter_pair ) ;
2012-12-16 01:12:59 +00:00
} else {
/* Look for a request which occurs earlier in the trace than this answer. */
2016-01-24 03:40:51 +00:00
diameter_pair = ( diameter_req_ans_pair_t * ) wmem_tree_lookup32_le ( pdus_tree , pinfo - > num ) ;
2012-12-16 01:12:59 +00:00
/* Verify the end-to-end-id matches before declaring a match */
if ( diameter_pair & & diameter_pair - > end_to_end_id = = end_to_end_id ) {
2016-01-24 03:40:51 +00:00
diameter_pair - > ans_frame = pinfo - > num ;
2012-12-16 01:12:59 +00:00
}
2008-11-15 15:52:39 +00:00
}
2012-12-16 01:12:59 +00:00
} else {
/* Look for a request which occurs earlier in the trace than this answer. */
2016-01-24 03:40:51 +00:00
diameter_pair = ( diameter_req_ans_pair_t * ) wmem_tree_lookup32_le ( pdus_tree , pinfo - > num ) ;
2012-12-16 01:12:59 +00:00
/* If the end-to-end ID doesn't match then this is not the request we were
* looking for .
*/
if ( diameter_pair & & diameter_pair - > end_to_end_id ! = end_to_end_id )
diameter_pair = NULL ;
2008-11-15 15:52:39 +00:00
}
}
if ( ! diameter_pair ) {
/* create a "fake" diameter_pair structure */
2020-05-07 12:35:45 +00:00
diameter_pair = wmem_new ( wmem_packet_scope ( ) , diameter_req_ans_pair_t ) ;
2010-03-06 20:54:58 +00:00
diameter_pair - > hop_by_hop_id = hop_by_hop_id ;
diameter_pair - > cmd_code = cmd ;
diameter_pair - > result_code = 0 ;
diameter_pair - > cmd_str = cmd_str ;
2008-11-15 15:52:39 +00:00
diameter_pair - > req_frame = 0 ;
diameter_pair - > ans_frame = 0 ;
2016-01-23 03:50:21 +00:00
diameter_pair - > req_time = pinfo - > abs_ts ;
2008-11-15 15:52:39 +00:00
}
2014-08-12 14:09:03 +00:00
diameter_pair - > processing_request = ( flags_bits & DIAM_FLAGS_R ) ! = 0 ;
2008-11-15 15:52:39 +00:00
2015-08-12 17:57:20 +00:00
/* print state tracking info in the tree */
if ( flags_bits & DIAM_FLAGS_R ) {
/* This is a request */
if ( diameter_pair - > ans_frame ) {
it = proto_tree_add_uint ( diam_tree , hf_diameter_answer_in ,
tvb , 0 , 0 , diameter_pair - > ans_frame ) ;
2019-04-03 21:32:30 +00:00
proto_item_set_generated ( it ) ;
2015-08-12 17:57:20 +00:00
}
} else {
/* This is an answer */
if ( diameter_pair - > req_frame ) {
it = proto_tree_add_uint ( diam_tree , hf_diameter_answer_to ,
tvb , 0 , 0 , diameter_pair - > req_frame ) ;
2019-04-03 21:32:30 +00:00
proto_item_set_generated ( it ) ;
2015-08-12 17:57:20 +00:00
2016-01-23 03:50:21 +00:00
nstime_delta ( & ns , & pinfo - > abs_ts , & diameter_pair - > req_time ) ;
2015-08-12 17:57:20 +00:00
diameter_pair - > srt_time = ns ;
it = proto_tree_add_time ( diam_tree , hf_diameter_answer_time , tvb , 0 , 0 , & ns ) ;
2019-04-03 21:32:30 +00:00
proto_item_set_generated ( it ) ;
2015-08-12 17:57:20 +00:00
/* TODO: Populate result_code in tap record from AVP 268 */
2008-11-15 15:52:39 +00:00
}
2015-08-12 17:57:20 +00:00
}
2013-11-21 18:46:40 +00:00
2015-08-12 17:57:20 +00:00
offset = 20 ;
2013-11-21 18:46:40 +00:00
2015-08-12 17:57:20 +00:00
/* Dissect AVPs until the end of the packet is reached */
while ( offset < packet_len ) {
2019-08-14 01:47:09 +00:00
offset + = dissect_diameter_avp ( c , tvb , offset , diam_sub_dis_inf , FALSE ) ;
2013-10-28 18:59:33 +00:00
}
2013-11-21 18:46:40 +00:00
2013-10-28 15:59:26 +00:00
/* Handle requests for which no answers were found and
2016-01-06 00:58:42 +00:00
* answers for which no requests were found in the tap listener .
2013-10-28 15:59:26 +00:00
* In case if you don ' t need unpaired requests / answers use :
2013-11-21 18:46:40 +00:00
* if ( diameter_pair - > processing_request | | ! diameter_pair - > req_frame )
2013-10-28 15:59:26 +00:00
* return ;
*/
tap_queue_packet ( diameter_tap , pinfo , diameter_pair ) ;
2014-07-28 18:18:49 +00:00
return tvb_reported_length ( tvb ) ;
2007-07-16 05:41:58 +00:00
}
2001-11-01 21:52:44 +00:00
2007-07-16 05:41:58 +00:00
static guint
2015-01-25 19:30:13 +00:00
get_diameter_pdu_len ( packet_info * pinfo _U_ , tvbuff_t * tvb ,
int offset , void * data _U_ )
2001-11-01 21:52:44 +00:00
{
2007-07-16 05:41:58 +00:00
/* Get the length of the Diameter packet. */
return tvb_get_ntoh24 ( tvb , offset + 1 ) ;
}
2001-11-01 21:52:44 +00:00
2015-05-11 19:45:04 +00:00
# define NOT_DIAMETER 0
# define IS_DIAMETER 1
# define NOT_ENOUGH_DATA 2
static gint
2007-07-16 05:41:58 +00:00
check_diameter ( tvbuff_t * tvb )
2001-11-01 21:52:44 +00:00
{
2014-04-06 23:59:52 +00:00
guint8 flags ;
2007-07-17 21:29:18 +00:00
2014-04-03 17:57:15 +00:00
/* Ensure we don't throw an exception trying to do these heuristics */
2014-07-28 18:18:49 +00:00
if ( tvb_captured_length ( tvb ) < 5 )
2015-05-11 19:45:04 +00:00
return NOT_ENOUGH_DATA ;
2014-04-03 17:57:15 +00:00
/* Check if the Diameter version is 1 */
2007-07-16 05:41:58 +00:00
if ( tvb_get_guint8 ( tvb , 0 ) ! = 1 )
2015-05-11 19:45:04 +00:00
return NOT_DIAMETER ;
2014-04-03 17:57:15 +00:00
2014-08-12 14:09:03 +00:00
/* Diameter minimum message length:
*
* Version + Length - 4 bytes
* Flags + CC - 4 bytes
* AppID - 4 bytes
* HbH - 4 bytes
* E2E - 4 bytes
* 2 AVPs ( Orig - Host , Orig - Realm ) , each including :
* * AVP code - 4 bytes
* * AVP flags + length - 4 bytes
* * ( no data - what would a reasonable minimum be ? )
*
* - - > 36 bytes
*/
2018-11-23 17:00:03 +00:00
if ( tvb_get_ntoh24 ( tvb , 1 ) < 36 )
2015-05-11 19:45:04 +00:00
return NOT_DIAMETER ;
2014-08-12 14:09:03 +00:00
2014-04-06 23:59:52 +00:00
flags = tvb_get_guint8 ( tvb , 4 ) ;
2014-04-03 17:57:15 +00:00
/* Check if any of the Reserved flag bits are set */
2014-04-06 23:59:52 +00:00
if ( flags & 0x0f )
2015-05-11 19:45:04 +00:00
return NOT_DIAMETER ;
2014-04-06 23:59:52 +00:00
/* Check if both the R- and E-bits are set */
if ( ( flags & DIAM_FLAGS_R ) & & ( flags & DIAM_FLAGS_E ) )
2015-05-11 19:45:04 +00:00
return NOT_DIAMETER ;
2007-07-17 21:29:18 +00:00
2015-05-11 19:45:04 +00:00
return IS_DIAMETER ;
2007-07-16 05:41:58 +00:00
}
2001-11-01 21:52:44 +00:00
2014-04-06 23:59:52 +00:00
/*****************************************************************/
/* Main dissection function */
/* Checks if the message looks like Diameter before accepting it */
/*****************************************************************/
2001-11-01 21:52:44 +00:00
static int
2013-11-09 17:46:28 +00:00
dissect_diameter ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data )
2001-11-01 21:52:44 +00:00
{
2015-05-11 19:45:04 +00:00
if ( check_diameter ( tvb ) ! = IS_DIAMETER )
2007-07-16 05:41:58 +00:00
return 0 ;
2013-11-09 17:46:28 +00:00
return dissect_diameter_common ( tvb , pinfo , tree , data ) ;
2007-07-16 05:41:58 +00:00
}
2001-11-01 21:52:44 +00:00
2013-11-09 17:46:28 +00:00
static int
2014-04-06 23:59:52 +00:00
dissect_diameter_tcp ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data )
2001-11-01 21:52:44 +00:00
{
2015-05-11 19:45:04 +00:00
gint is_diam = check_diameter ( tvb ) ;
if ( is_diam = = NOT_DIAMETER ) {
/* We've probably been given a frame that's not the start of
* a PDU .
*/
2011-06-21 11:53:33 +00:00
col_set_str ( pinfo - > cinfo , COL_PROTOCOL , " DIAMETER " ) ;
col_set_str ( pinfo - > cinfo , COL_INFO , " Continuation " ) ;
call_dissector ( data_handle , tvb , pinfo , tree ) ;
2015-05-11 19:45:04 +00:00
} else if ( is_diam = = NOT_ENOUGH_DATA ) {
/* Since we're doing our heuristic checks before
2021-12-31 03:03:45 +00:00
* tcp_dissect_pdus ( ) ( since we can ' t do heuristics once
2015-05-11 19:45:04 +00:00
* we ' re in there ) we sometimes have to ask for more data . . .
*/
pinfo - > desegment_offset = 0 ;
pinfo - > desegment_len = DESEGMENT_ONE_MORE_SEGMENT ;
2012-03-13 15:06:40 +00:00
} else {
2011-06-21 11:53:33 +00:00
tcp_dissect_pdus ( tvb , pinfo , tree , gbl_diameter_desegment , 4 ,
2013-11-09 17:46:28 +00:00
get_diameter_pdu_len , dissect_diameter_common , data ) ;
2011-06-21 11:53:33 +00:00
}
2013-11-09 17:46:28 +00:00
2014-07-28 18:18:49 +00:00
return tvb_reported_length ( tvb ) ;
2010-10-18 15:56:06 +00:00
}
2001-11-01 21:52:44 +00:00
2019-08-14 01:47:09 +00:00
static int
dissect_diameter_avps ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data _U_ )
{
proto_item * pi ;
proto_tree * diam_tree ;
int offset = 0 ;
2020-05-07 12:35:45 +00:00
diam_ctx_t * c = wmem_new0 ( wmem_packet_scope ( ) , diam_ctx_t ) ;
2019-08-14 01:47:09 +00:00
diam_sub_dis_t * diam_sub_dis_inf = wmem_new0 ( wmem_packet_scope ( ) , diam_sub_dis_t ) ;
/* Load header fields if not already done */
if ( hf_diameter_code = = - 1 )
proto_registrar_get_byname ( " diameter.code " ) ;
col_set_str ( pinfo - > cinfo , COL_PROTOCOL , " DIAMETER " ) ;
col_set_str ( pinfo - > cinfo , COL_INFO , " AVPs: " ) ;
pi = proto_tree_add_item ( tree , proto_diameter , tvb , 0 , - 1 , ENC_NA ) ;
diam_tree = proto_item_add_subtree ( pi , ett_diameter ) ;
c - > tree = diam_tree ;
c - > pinfo = pinfo ;
c - > version_rfc = TRUE ;
/* Dissect AVPs until the end of the packet is reached */
while ( tvb_reported_length_remaining ( tvb , offset ) ) {
offset + = dissect_diameter_avp ( c , tvb , offset , diam_sub_dis_inf , TRUE ) ;
}
return tvb_reported_length ( tvb ) ;
}
2002-01-07 20:05:20 +00:00
2012-12-16 01:12:59 +00:00
static char *
alnumerize ( char * name )
2008-07-15 21:06:31 +00:00
{
2012-12-16 01:12:59 +00:00
char * r = name ;
char * w = name ;
2007-07-16 05:41:58 +00:00
char c ;
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
for ( ; ( c = * r ) ; r + + ) {
2014-10-20 06:14:50 +00:00
if ( g_ascii_isalnum ( c ) | | c = = ' _ ' | | c = = ' - ' | | c = = ' . ' ) {
2007-07-16 05:41:58 +00:00
* ( w + + ) = c ;
2001-11-01 21:52:44 +00:00
}
2001-07-30 20:08:44 +00:00
}
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
* w = ' \0 ' ;
2001-02-19 23:14:02 +00:00
2007-07-16 05:41:58 +00:00
return name ;
2004-02-21 10:29:52 +00:00
}
2001-07-30 20:08:44 +00:00
2008-07-15 21:06:31 +00:00
static guint
2012-12-16 01:12:59 +00:00
reginfo ( int * hf_ptr , const char * name , const char * abbr , const char * desc ,
2014-07-25 16:29:04 +00:00
enum ftenum ft , field_display_e base , value_string_ext * vs_ext ,
2008-07-15 21:06:31 +00:00
guint32 mask )
{
2014-01-17 18:58:50 +00:00
hf_register_info hf ;
2014-08-12 14:09:03 +00:00
hf . p_id = hf_ptr ;
2014-01-17 18:58:50 +00:00
hf . hfinfo . name = name ;
hf . hfinfo . abbrev = abbr ;
hf . hfinfo . type = ft ;
hf . hfinfo . display = base ;
hf . hfinfo . strings = NULL ;
hf . hfinfo . bitmask = mask ;
hf . hfinfo . blurb = desc ;
/* HFILL */
2014-01-19 09:40:04 +00:00
HFILL_INIT ( hf ) ;
2007-07-17 21:29:18 +00:00
2013-11-21 18:46:40 +00:00
if ( vs_ext ) {
2010-11-15 21:05:03 +00:00
hf . hfinfo . strings = vs_ext ;
}
2013-07-06 12:45:33 +00:00
wmem_array_append_one ( build_dict . hf , hf ) ;
return wmem_array_get_count ( build_dict . hf ) ;
2007-07-16 05:41:58 +00:00
}
2001-02-19 23:14:02 +00:00
2008-07-15 21:06:31 +00:00
static void
2012-12-16 01:12:59 +00:00
basic_avp_reginfo ( diam_avp_t * a , const char * name , enum ftenum ft ,
2014-07-25 16:29:04 +00:00
field_display_e base , value_string_ext * vs_ext )
2008-07-15 21:06:31 +00:00
{
2014-01-17 18:58:50 +00:00
hf_register_info hf ;
2012-12-16 01:12:59 +00:00
gint * ettp = & ( a - > ett ) ;
2007-07-17 21:29:18 +00:00
2014-08-12 14:09:03 +00:00
hf . p_id = & ( a - > hf_value ) ;
2014-01-17 18:58:50 +00:00
hf . hfinfo . name = NULL ;
hf . hfinfo . abbrev = NULL ;
hf . hfinfo . type = ft ;
hf . hfinfo . display = base ;
hf . hfinfo . strings = NULL ;
hf . hfinfo . bitmask = 0x0 ;
hf . hfinfo . blurb = a - > vendor - > code ?
2014-08-12 14:09:03 +00:00
wmem_strdup_printf ( wmem_epan_scope ( ) , " vendor=%d code=%d " , a - > vendor - > code , a - > code )
: wmem_strdup_printf ( wmem_epan_scope ( ) , " code=%d " , a - > code ) ;
2014-01-17 18:58:50 +00:00
/* HFILL */
2014-01-19 09:40:04 +00:00
HFILL_INIT ( hf ) ;
2014-01-17 18:58:50 +00:00
2016-04-01 19:48:22 +00:00
hf . hfinfo . name = wmem_strdup ( wmem_epan_scope ( ) , name ) ;
hf . hfinfo . abbrev = alnumerize ( wmem_strconcat ( wmem_epan_scope ( ) , " diameter. " , name , NULL ) ) ;
2013-11-21 18:46:40 +00:00
if ( vs_ext ) {
2014-01-17 18:58:50 +00:00
hf . hfinfo . strings = vs_ext ;
2010-11-10 20:11:38 +00:00
}
2007-07-17 21:29:18 +00:00
2014-01-17 18:58:50 +00:00
wmem_array_append ( build_dict . hf , & hf , 1 ) ;
2008-07-16 08:08:17 +00:00
g_ptr_array_add ( build_dict . ett , ettp ) ;
2007-07-16 05:41:58 +00:00
}
2002-08-28 21:04:11 +00:00
2012-12-16 01:12:59 +00:00
static diam_avp_t *
build_address_avp ( const avp_type_t * type _U_ , guint32 code ,
2014-01-14 03:24:37 +00:00
diam_vnd_t * vendor , const char * name ,
2012-12-16 01:12:59 +00:00
const value_string * vs _U_ , void * data _U_ )
2008-07-15 21:06:31 +00:00
{
2013-09-04 21:06:56 +00:00
diam_avp_t * a = wmem_new0 ( wmem_epan_scope ( ) , diam_avp_t ) ;
address_avp_t * t = wmem_new ( wmem_epan_scope ( ) , address_avp_t ) ;
2012-12-16 01:12:59 +00:00
gint * ettp = & ( t - > ett ) ;
2007-10-24 16:32:51 +00:00
2007-07-17 22:19:54 +00:00
a - > code = code ;
a - > vendor = vendor ;
2007-11-08 22:36:19 +00:00
/*
2013-04-02 18:15:42 +00:00
* It seems like the radius AVPs 1 - 255 will use the defs from RADIUS in which case :
2020-04-13 11:06:37 +00:00
* https : //tools.ietf.org/html/rfc2685
2013-04-02 18:15:42 +00:00
* Address
* The Address field is four octets . The value 0xFFFFFFFF indicates
* that the NAS Should allow the user to select an address ( e . g .
* Negotiated ) . The value 0xFFFFFFFE indicates that the NAS should
* select an address for the user ( e . g . Assigned from a pool of
* addresses kept by the NAS ) . Other valid values indicate that the
* NAS should use that value as the user ' s IP address .
*
* Where as in Diameter :
* RFC3588
* Address
* The Address format is derived from the OctetString AVP Base
* Format . It is a discriminated union , representing , for example a
* 32 - bit ( IPv4 ) [ IPV4 ] or 128 - bit ( IPv6 ) [ IPV6 ] address , most
* significant octet first . The first two octets of the Address
* AVP represents the AddressType , which contains an Address Family
* defined in [ IANAADFAM ] . The AddressType is used to discriminate
* the content and format of the remaining octets .
*/
2007-07-17 22:19:54 +00:00
a - > dissector_v16 = address_v16_avp ;
2008-07-15 21:06:31 +00:00
if ( code < 256 ) {
2007-11-08 22:36:19 +00:00
a - > dissector_rfc = address_v16_avp ;
2008-07-15 21:06:31 +00:00
} else {
2007-11-08 22:36:19 +00:00
a - > dissector_rfc = address_rfc_avp ;
}
2007-07-17 22:19:54 +00:00
a - > ett = - 1 ;
a - > hf_value = - 1 ;
a - > type_data = t ;
2007-10-24 16:32:51 +00:00
2007-07-17 22:19:54 +00:00
t - > ett = - 1 ;
t - > hf_address_type = - 1 ;
t - > hf_ipv4 = - 1 ;
t - > hf_ipv6 = - 1 ;
2020-10-12 08:34:49 +00:00
t - > hf_e164_str = - 1 ;
2007-07-17 22:19:54 +00:00
t - > hf_other = - 1 ;
2007-10-24 16:32:51 +00:00
2013-11-21 18:46:40 +00:00
basic_avp_reginfo ( a , name , FT_BYTES , BASE_NONE , NULL ) ;
2007-10-24 16:32:51 +00:00
2016-04-07 20:05:27 +00:00
reginfo ( & ( t - > hf_address_type ) , wmem_strconcat ( wmem_epan_scope ( ) , name , " Address Family " , NULL ) ,
alnumerize ( wmem_strconcat ( wmem_epan_scope ( ) , " diameter. " , name , " .addr_family " , NULL ) ) ,
2013-12-07 10:41:42 +00:00
NULL , FT_UINT16 , ( field_display_e ) ( BASE_DEC | BASE_EXT_STRING ) , & diameter_avp_data_addrfamily_vals_ext , 0 ) ;
2007-10-24 16:32:51 +00:00
2016-04-07 20:05:27 +00:00
reginfo ( & ( t - > hf_ipv4 ) , wmem_strconcat ( wmem_epan_scope ( ) , name , " Address " , NULL ) ,
alnumerize ( wmem_strconcat ( wmem_epan_scope ( ) , " diameter. " , name , " .IPv4 " , NULL ) ) ,
2009-06-24 02:17:12 +00:00
NULL , FT_IPv4 , BASE_NONE , NULL , 0 ) ;
2007-10-24 16:32:51 +00:00
2016-04-07 20:05:27 +00:00
reginfo ( & ( t - > hf_ipv6 ) , wmem_strconcat ( wmem_epan_scope ( ) , name , " Address " , NULL ) ,
alnumerize ( wmem_strconcat ( wmem_epan_scope ( ) , " diameter. " , name , " .IPv6 " , NULL ) ) ,
2009-06-24 02:17:12 +00:00
NULL , FT_IPv6 , BASE_NONE , NULL , 0 ) ;
2007-10-24 16:32:51 +00:00
2020-10-12 08:34:49 +00:00
reginfo ( & ( t - > hf_e164_str ) , wmem_strconcat ( wmem_epan_scope ( ) , name , " Address " , NULL ) ,
alnumerize ( wmem_strconcat ( wmem_epan_scope ( ) , " diameter. " , name , " .E164 " , NULL ) ) ,
NULL , FT_STRING , BASE_NONE , NULL , 0 ) ;
2016-04-07 20:05:27 +00:00
reginfo ( & ( t - > hf_other ) , wmem_strconcat ( wmem_epan_scope ( ) , name , " Address " , NULL ) ,
alnumerize ( wmem_strconcat ( wmem_epan_scope ( ) , " diameter. " , name , " .Bytes " , NULL ) ) ,
2009-06-24 02:17:12 +00:00
NULL , FT_BYTES , BASE_NONE , NULL , 0 ) ;
2007-10-24 16:32:51 +00:00
2008-07-16 08:08:17 +00:00
g_ptr_array_add ( build_dict . ett , ettp ) ;
2007-10-24 16:32:51 +00:00
2007-07-17 22:19:54 +00:00
return a ;
}
2012-12-16 01:12:59 +00:00
static diam_avp_t *
build_proto_avp ( const avp_type_t * type _U_ , guint32 code ,
2014-01-14 03:24:37 +00:00
diam_vnd_t * vendor , const char * name _U_ ,
2012-12-16 01:12:59 +00:00
const value_string * vs _U_ , void * data )
2008-07-15 21:06:31 +00:00
{
2020-05-07 12:35:45 +00:00
diam_avp_t * a = wmem_new0 ( wmem_epan_scope ( ) , diam_avp_t ) ;
proto_avp_t * t = wmem_new0 ( wmem_epan_scope ( ) , proto_avp_t ) ;
2012-12-16 01:12:59 +00:00
gint * ettp = & ( a - > ett ) ;
2007-10-24 16:32:51 +00:00
2007-07-20 00:15:17 +00:00
a - > code = code ;
a - > vendor = vendor ;
a - > dissector_v16 = proto_avp ;
a - > dissector_rfc = proto_avp ;
a - > ett = - 1 ;
a - > hf_value = - 2 ;
a - > type_data = t ;
2007-10-24 16:32:51 +00:00
2013-03-02 19:21:38 +00:00
t - > name = ( char * ) data ;
2007-07-20 00:15:17 +00:00
t - > handle = NULL ;
2013-03-02 19:21:38 +00:00
t - > reassemble_mode = REASEMBLE_NEVER ;
2007-10-24 16:32:51 +00:00
2008-07-16 08:08:17 +00:00
g_ptr_array_add ( build_dict . ett , ettp ) ;
2007-10-24 16:32:51 +00:00
2007-07-20 00:15:17 +00:00
return a ;
}
2007-07-17 22:19:54 +00:00
2012-12-16 01:12:59 +00:00
static diam_avp_t *
2014-01-14 03:24:37 +00:00
build_simple_avp ( const avp_type_t * type , guint32 code , diam_vnd_t * vendor ,
2012-12-16 01:12:59 +00:00
const char * name , const value_string * vs , void * data _U_ )
2008-07-15 21:06:31 +00:00
{
2012-12-16 01:12:59 +00:00
diam_avp_t * a ;
2014-07-25 16:29:04 +00:00
value_string_ext * vs_ext = NULL ;
2013-12-07 10:41:42 +00:00
field_display_e base ;
2010-11-10 20:11:38 +00:00
guint i = 0 ;
2007-11-27 01:41:42 +00:00
/*
* Only 32 - bit or shorter integral types can have a list of values .
*/
2013-12-07 10:41:42 +00:00
base = ( field_display_e ) type - > base ;
2007-11-27 01:41:42 +00:00
if ( vs ! = NULL ) {
switch ( type - > ft ) {
case FT_UINT8 :
case FT_UINT16 :
case FT_UINT32 :
case FT_INT8 :
case FT_INT16 :
case FT_INT32 :
break ;
default :
2015-11-13 01:39:39 +00:00
report_failure ( " Diameter Dictionary: AVP '%s' has a list of values but isn't of a 32-bit or shorter integral type (%s) \n " ,
name , ftype_name ( type - > ft ) ) ;
2007-11-27 01:41:42 +00:00
return NULL ;
}
2010-11-10 20:11:38 +00:00
while ( vs [ i ] . strptr ) {
i + + ;
}
2016-04-07 20:05:27 +00:00
vs_ext = value_string_ext_new ( vs , i + 1 , wmem_strconcat ( wmem_epan_scope ( ) , name , " _vals_ext " , NULL ) ) ;
2013-12-07 10:41:42 +00:00
base = ( field_display_e ) ( base | BASE_EXT_STRING ) ;
2007-11-27 01:41:42 +00:00
}
2020-05-07 12:35:45 +00:00
a = wmem_new0 ( wmem_epan_scope ( ) , diam_avp_t ) ;
2007-07-16 05:41:58 +00:00
a - > code = code ;
a - > vendor = vendor ;
a - > dissector_v16 = type - > v16 ;
a - > dissector_rfc = type - > rfc ;
a - > ett = - 1 ;
a - > hf_value = - 1 ;
2007-07-17 21:29:18 +00:00
2013-11-21 18:46:40 +00:00
basic_avp_reginfo ( a , name , type - > ft , base , vs_ext ) ;
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
return a ;
}
2002-08-28 21:04:11 +00:00
2015-04-20 22:14:35 +00:00
static diam_avp_t *
build_appid_avp ( const avp_type_t * type , guint32 code , diam_vnd_t * vendor ,
2016-04-15 17:39:06 +00:00
const char * name , const value_string * vs , void * data _U_ )
2015-04-20 22:14:35 +00:00
{
diam_avp_t * a ;
field_display_e base ;
2001-11-03 12:19:56 +00:00
2020-05-07 12:35:45 +00:00
a = wmem_new0 ( wmem_epan_scope ( ) , diam_avp_t ) ;
2015-04-20 22:14:35 +00:00
a - > code = code ;
a - > vendor = vendor ;
a - > dissector_v16 = type - > v16 ;
a - > dissector_rfc = type - > rfc ;
a - > ett = - 1 ;
a - > hf_value = - 1 ;
if ( vs ! = NULL ) {
report_failure ( " Diameter Dictionary: AVP '%s' (of type AppId) has a list of values but the list won't be used \n " ,
name ) ;
}
base = ( field_display_e ) ( type - > base | BASE_EXT_STRING ) ;
basic_avp_reginfo ( a , name , type - > ft , base , dictionary . applications ) ;
return a ;
}
2007-07-20 00:15:17 +00:00
2007-07-16 05:41:58 +00:00
static const avp_type_t basic_types [ ] = {
2020-09-16 10:44:06 +00:00
{ " octetstring " , simple_avp , simple_avp , FT_BYTES , BASE_NONE , build_simple_avp } ,
{ " octetstringorutf8 " , simple_avp , simple_avp , FT_BYTES , BASE_SHOW_ASCII_PRINTABLE , build_simple_avp } ,
{ " utf8string " , utf8_avp , utf8_avp , FT_STRING , BASE_NONE , build_simple_avp } ,
{ " grouped " , grouped_avp , grouped_avp , FT_BYTES , BASE_NONE , build_simple_avp } ,
{ " integer32 " , integer32_avp , integer32_avp , FT_INT32 , BASE_DEC , build_simple_avp } ,
{ " unsigned32 " , unsigned32_avp , unsigned32_avp , FT_UINT32 , BASE_DEC , build_simple_avp } ,
{ " integer64 " , integer64_avp , integer64_avp , FT_INT64 , BASE_DEC , build_simple_avp } ,
{ " unsigned64 " , unsigned64_avp , unsigned64_avp , FT_UINT64 , BASE_DEC , build_simple_avp } ,
{ " float32 " , float32_avp , float32_avp , FT_FLOAT , BASE_NONE , build_simple_avp } ,
{ " float64 " , float64_avp , float64_avp , FT_DOUBLE , BASE_NONE , build_simple_avp } ,
{ " ipaddress " , NULL , NULL , FT_NONE , BASE_NONE , build_address_avp } ,
{ " diameteruri " , utf8_avp , utf8_avp , FT_STRING , BASE_NONE , build_simple_avp } ,
{ " diameteridentity " , utf8_avp , utf8_avp , FT_STRING , BASE_NONE , build_simple_avp } ,
{ " ipfilterrule " , utf8_avp , utf8_avp , FT_STRING , BASE_NONE , build_simple_avp } ,
{ " qosfilterrule " , utf8_avp , utf8_avp , FT_STRING , BASE_NONE , build_simple_avp } ,
{ " time " , time_avp , time_avp , FT_ABSOLUTE_TIME , ABSOLUTE_TIME_UTC , build_simple_avp } ,
{ " AppId " , simple_avp , simple_avp , FT_UINT32 , BASE_DEC , build_appid_avp } ,
2007-07-16 05:41:58 +00:00
{ NULL , NULL , NULL , FT_NONE , BASE_NONE , NULL }
} ;
2004-02-21 10:29:52 +00:00
2007-07-20 00:15:17 +00:00
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
/*
* This is like g_str_hash ( ) ( as of GLib 2.4 .8 ) , but it maps all
* upper - case ASCII characters to their ASCII lower - case equivalents .
* We can ' t use g_strdown ( ) , as that doesn ' t do an ASCII mapping ;
* in Turkish locales , for example , there are two lower - case " i " s
* and two upper - case " I " s , with and without dots - the ones with
* dots map between each other , as do the ones without dots , so " I "
* doesn ' t map to " i " .
*/
2008-07-15 21:06:31 +00:00
static guint
strcase_hash ( gconstpointer key )
{
2013-03-02 19:21:38 +00:00
const char * p = ( const char * ) key ;
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
guint h = * p ;
char c ;
if ( h ) {
if ( h > = ' A ' & & h < = ' Z ' )
h = h - ' A ' + ' a ' ;
for ( p + = 1 ; * p ! = ' \0 ' ; p + + ) {
c = * p ;
if ( c > = ' A ' & & c < = ' Z ' )
c = c - ' A ' + ' a ' ;
h = ( h < < 5 ) - h + c ;
}
}
return h ;
2001-11-03 12:19:56 +00:00
}
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
/*
* Again , use g_ascii_strcasecmp ( ) , not strcasecmp ( ) , so that only ASCII
* letters are mapped , and they ' re mapped to the lower - case ASCII
* equivalents .
*/
2008-07-15 21:06:31 +00:00
static gboolean
strcase_equal ( gconstpointer ka , gconstpointer kb )
{
2013-03-02 19:21:38 +00:00
const char * a = ( const char * ) ka ;
const char * b = ( const char * ) kb ;
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
return g_ascii_strcasecmp ( a , b ) = = 0 ;
2004-02-21 10:29:52 +00:00
}
2001-11-03 12:19:56 +00:00
2016-08-31 08:16:24 +00:00
static gboolean
ddict_cleanup_cb ( wmem_allocator_t * allocator _U_ , wmem_cb_event_t event _U_ , void * user_data )
{
ddict_t * d = ( ddict_t * ) user_data ;
ddict_free ( d ) ;
return FALSE ;
}
2010-05-24 14:20:53 +00:00
2012-04-23 01:36:57 +00:00
/* Note: Dynamic "value string arrays" (e.g., vs_cmds, vs_avps, ...) are constructed using */
/* "zero-terminated" GArrays so that they will have the same form as standard */
/* value_string arrays created at compile time. Since the last entry in a */
/* value_string array must be {0, NULL}, we are assuming that NULL == 0 (hackish). */
2008-07-15 21:06:31 +00:00
static int
dictionary_load ( void )
2008-04-05 05:41:59 +00:00
{
2012-12-16 01:12:59 +00:00
ddict_t * d ;
ddict_application_t * p ;
ddict_vendor_t * v ;
ddict_cmd_t * c ;
ddict_typedefn_t * t ;
ddict_avp_t * a ;
2007-07-17 22:19:54 +00:00
gboolean do_debug_parser = getenv ( " WIRESHARK_DEBUG_DIAM_DICT_PARSER " ) ? TRUE : FALSE ;
gboolean do_dump_dict = getenv ( " WIRESHARK_DUMP_DIAM_DICT " ) ? TRUE : FALSE ;
2013-12-23 21:09:26 +00:00
char * dir ;
2012-12-16 01:12:59 +00:00
const avp_type_t * type ;
const avp_type_t * octetstring = & basic_types [ 0 ] ;
diam_avp_t * avp ;
GHashTable * vendors = g_hash_table_new ( strcase_hash , strcase_equal ) ;
diam_vnd_t * vnd ;
GArray * vnd_shrt_arr = g_array_new ( TRUE , TRUE , sizeof ( value_string ) ) ;
2001-02-19 23:14:02 +00:00
2016-10-03 07:59:52 +00:00
/* Pre allocate the arrays big enough to hold the hf:s and etts:s*/
build_dict . hf = wmem_array_sized_new ( wmem_epan_scope ( ) , sizeof ( hf_register_info ) , 4096 ) ;
build_dict . ett = g_ptr_array_sized_new ( 4096 ) ;
2007-07-16 05:41:58 +00:00
build_dict . types = g_hash_table_new ( strcase_hash , strcase_equal ) ;
build_dict . avps = g_hash_table_new ( strcase_hash , strcase_equal ) ;
2007-07-17 21:29:18 +00:00
2013-09-04 21:06:56 +00:00
dictionary . vnds = wmem_tree_new ( wmem_epan_scope ( ) ) ;
dictionary . avps = wmem_tree_new ( wmem_epan_scope ( ) ) ;
2007-07-17 21:29:18 +00:00
2016-02-18 10:30:41 +00:00
unknown_vendor . vs_cmds = wmem_array_new ( wmem_epan_scope ( ) , sizeof ( value_string ) ) ;
wmem_array_set_null_terminator ( unknown_vendor . vs_cmds ) ;
wmem_array_bzero ( unknown_vendor . vs_cmds ) ;
unknown_vendor . vs_avps = wmem_array_new ( wmem_epan_scope ( ) , sizeof ( value_string ) ) ;
wmem_array_set_null_terminator ( unknown_vendor . vs_avps ) ;
wmem_array_bzero ( unknown_vendor . vs_avps ) ;
no_vnd . vs_cmds = wmem_array_new ( wmem_epan_scope ( ) , sizeof ( value_string ) ) ;
wmem_array_set_null_terminator ( no_vnd . vs_cmds ) ;
wmem_array_bzero ( no_vnd . vs_cmds ) ;
no_vnd . vs_avps = wmem_array_new ( wmem_epan_scope ( ) , sizeof ( value_string ) ) ;
wmem_array_set_null_terminator ( no_vnd . vs_avps ) ;
wmem_array_bzero ( no_vnd . vs_avps ) ;
2007-07-17 21:29:18 +00:00
2007-07-20 11:39:09 +00:00
all_cmds = g_array_new ( TRUE , TRUE , sizeof ( value_string ) ) ;
2013-09-04 21:06:56 +00:00
wmem_tree_insert32 ( dictionary . vnds , 0 , & no_vnd ) ;
2015-11-21 23:48:27 +00:00
g_hash_table_insert ( vendors , " None " , & no_vnd ) ;
2001-11-02 10:09:51 +00:00
2007-07-16 05:41:58 +00:00
/* initialize the types hash with the known basic types */
for ( type = basic_types ; type - > name ; type + + ) {
2012-12-16 01:12:59 +00:00
g_hash_table_insert ( build_dict . types , ( gchar * ) type - > name , ( void * ) type ) ;
2007-07-16 05:41:58 +00:00
}
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
/* load the dictionary */
2016-06-12 23:00:37 +00:00
dir = wmem_strdup_printf ( NULL , " %s " G_DIR_SEPARATOR_S " diameter " G_DIR_SEPARATOR_S , get_datafile_dir ( ) ) ;
2007-10-24 16:32:51 +00:00
d = ddict_scan ( dir , " dictionary.xml " , do_debug_parser ) ;
2016-06-12 23:00:37 +00:00
wmem_free ( NULL , dir ) ;
2007-07-17 22:19:54 +00:00
if ( d = = NULL ) {
2015-06-25 16:54:06 +00:00
g_hash_table_destroy ( vendors ) ;
g_array_free ( vnd_shrt_arr , TRUE ) ;
2007-07-17 21:29:18 +00:00
return 0 ;
}
2016-08-31 08:16:24 +00:00
wmem_register_callback ( wmem_epan_scope ( ) , ddict_cleanup_cb , d ) ;
2007-07-17 21:29:18 +00:00
2007-07-17 22:19:54 +00:00
if ( do_dump_dict ) ddict_print ( stdout , d ) ;
2007-10-24 16:32:51 +00:00
2007-07-16 05:41:58 +00:00
/* populate the types */
for ( t = d - > typedefns ; t ; t = t - > next ) {
2012-12-16 01:12:59 +00:00
const avp_type_t * parent = NULL ;
2007-07-16 05:41:58 +00:00
/* try to get the parent type */
2007-07-17 21:29:18 +00:00
2012-03-19 17:12:04 +00:00
if ( t - > name = = NULL ) {
2014-12-24 15:44:03 +00:00
report_failure ( " Diameter Dictionary: Invalid Type (empty name): parent==%s \n " ,
2012-03-19 17:12:04 +00:00
t - > parent ? t - > parent : " (null) " ) ;
continue ;
}
2007-07-16 05:41:58 +00:00
if ( g_hash_table_lookup ( build_dict . types , t - > name ) )
continue ;
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
if ( t - > parent ) {
2013-03-02 19:21:38 +00:00
parent = ( avp_type_t * ) g_hash_table_lookup ( build_dict . types , t - > parent ) ;
2002-01-31 01:55:14 +00:00
}
2007-07-17 21:29:18 +00:00
2007-11-27 01:41:42 +00:00
if ( ! parent ) parent = octetstring ;
2007-07-17 21:29:18 +00:00
/* insert the parent type for this type */
2012-12-16 01:12:59 +00:00
g_hash_table_insert ( build_dict . types , t - > name , ( void * ) parent ) ;
2007-07-16 05:41:58 +00:00
}
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
/* populate the applications */
if ( ( p = d - > applications ) ) {
2014-08-19 13:01:43 +00:00
wmem_array_t * arr = wmem_array_new ( wmem_epan_scope ( ) , sizeof ( value_string ) ) ;
2015-07-07 02:06:34 +00:00
value_string term [ 1 ] ;
term [ 0 ] . value = 0 ;
term [ 0 ] . strptr = NULL ;
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
for ( ; p ; p = p - > next ) {
2014-01-15 19:29:03 +00:00
value_string item [ 1 ] ;
item [ 0 ] . value = p - > code ;
item [ 0 ] . strptr = p - > name ;
2015-02-03 02:28:01 +00:00
if ( ! p - > name ) {
report_failure ( " Diameter Dictionary: Invalid Application (empty name): id=%d \n " , p - > code ) ;
continue ;
}
2014-07-28 18:18:49 +00:00
wmem_array_append_one ( arr , item ) ;
2002-01-31 01:55:14 +00:00
}
2007-07-17 21:29:18 +00:00
2014-07-28 18:18:49 +00:00
wmem_array_sort ( arr , compare_avps ) ;
wmem_array_append_one ( arr , term ) ;
2014-07-28 17:35:02 +00:00
2014-08-19 13:01:43 +00:00
/* TODO: Remove duplicates */
2014-07-28 17:35:02 +00:00
2015-04-20 22:14:35 +00:00
dictionary . applications = value_string_ext_new ( ( value_string * ) wmem_array_get_raw ( arr ) ,
wmem_array_get_count ( arr ) ,
2016-04-07 20:05:27 +00:00
wmem_strdup ( wmem_epan_scope ( ) , " applications_vals_ext " ) ) ;
2007-07-16 05:41:58 +00:00
}
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
if ( ( v = d - > vendors ) ) {
for ( ; v ; v = v - > next ) {
2014-01-15 19:29:03 +00:00
value_string item [ 1 ] ;
item [ 0 ] . value = v - > code ;
item [ 0 ] . strptr = v - > name ;
2007-07-17 21:29:18 +00:00
2012-03-19 17:12:04 +00:00
if ( v - > name = = NULL ) {
2015-02-03 02:28:01 +00:00
report_failure ( " Diameter Dictionary: Invalid Vendor (empty name): code==%d \n " , v - > code ) ;
2012-03-19 17:12:04 +00:00
continue ;
}
2007-07-16 05:41:58 +00:00
if ( g_hash_table_lookup ( vendors , v - > name ) )
continue ;
2001-07-30 20:08:44 +00:00
2007-07-16 05:41:58 +00:00
g_array_append_val ( vnd_shrt_arr , item ) ;
2004-03-21 23:19:36 +00:00
2013-09-04 21:06:56 +00:00
vnd = wmem_new ( wmem_epan_scope ( ) , diam_vnd_t ) ;
2007-07-16 05:41:58 +00:00
vnd - > code = v - > code ;
2016-02-18 10:30:41 +00:00
vnd - > vs_cmds = wmem_array_new ( wmem_epan_scope ( ) , sizeof ( value_string ) ) ;
wmem_array_set_null_terminator ( vnd - > vs_cmds ) ;
wmem_array_bzero ( vnd - > vs_cmds ) ;
vnd - > vs_avps = wmem_array_new ( wmem_epan_scope ( ) , sizeof ( value_string ) ) ;
wmem_array_set_null_terminator ( vnd - > vs_avps ) ;
wmem_array_bzero ( vnd - > vs_avps ) ;
2010-10-14 17:50:35 +00:00
vnd - > vs_avps_ext = NULL ;
2013-09-04 21:06:56 +00:00
wmem_tree_insert32 ( dictionary . vnds , vnd - > code , vnd ) ;
2007-07-16 05:41:58 +00:00
g_hash_table_insert ( vendors , v - > name , vnd ) ;
2001-11-01 21:52:44 +00:00
}
2007-07-16 05:41:58 +00:00
}
2007-07-17 21:29:18 +00:00
2018-05-09 20:37:41 +00:00
vnd_short_vs = ( value_string * ) g_array_free ( vnd_shrt_arr , FALSE ) ;
2007-07-16 05:41:58 +00:00
if ( ( c = d - > cmds ) ) {
for ( ; c ; c = c - > next ) {
2012-03-19 17:12:04 +00:00
if ( c - > vendor = = NULL ) {
2014-12-24 15:44:03 +00:00
report_failure ( " Diameter Dictionary: Invalid Vendor (empty name) for command %s \n " ,
2012-03-19 17:12:04 +00:00
c - > name ? c - > name : " (null) " ) ;
continue ;
}
2013-03-02 19:21:38 +00:00
if ( ( vnd = ( diam_vnd_t * ) g_hash_table_lookup ( vendors , c - > vendor ) ) ) {
2014-01-15 19:29:03 +00:00
value_string item [ 1 ] ;
item [ 0 ] . value = c - > code ;
item [ 0 ] . strptr = c - > name ;
2016-02-18 10:30:41 +00:00
wmem_array_append_one ( vnd - > vs_cmds , item ) ;
2007-07-20 11:39:09 +00:00
/* Also add to all_cmds as used by RFC version */
g_array_append_val ( all_cmds , item ) ;
2007-07-16 05:41:58 +00:00
} else {
2014-12-24 15:44:03 +00:00
report_failure ( " Diameter Dictionary: No Vendor: %s \n " , c - > vendor ) ;
2006-07-03 21:18:36 +00:00
}
2007-07-16 05:41:58 +00:00
}
}
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
for ( a = d - > avps ; a ; a = a - > next ) {
2012-12-16 01:12:59 +00:00
ddict_enum_t * e ;
value_string * vs = NULL ;
const char * vend = a - > vendor ? a - > vendor : " None " ;
ddict_xmlpi_t * x ;
void * avp_data = NULL ;
2007-10-24 16:32:51 +00:00
2012-03-19 17:12:04 +00:00
if ( a - > name = = NULL ) {
2014-12-24 15:44:03 +00:00
report_failure ( " Diameter Dictionary: Invalid AVP (empty name) \n " ) ;
2012-03-19 17:12:04 +00:00
continue ;
}
2013-03-02 19:21:38 +00:00
if ( ( vnd = ( diam_vnd_t * ) g_hash_table_lookup ( vendors , vend ) ) ) {
2014-01-15 19:29:03 +00:00
value_string vndvs [ 1 ] ;
vndvs [ 0 ] . value = a - > code ;
vndvs [ 0 ] . strptr = a - > name ;
2015-07-07 02:06:34 +00:00
2016-02-18 10:30:41 +00:00
wmem_array_append_one ( vnd - > vs_avps , vndvs ) ;
2007-07-16 05:41:58 +00:00
} else {
2014-12-24 15:44:03 +00:00
report_failure ( " Diameter Dictionary: No Vendor: %s \n " , vend ) ;
2007-07-16 05:41:58 +00:00
vnd = & unknown_vendor ;
}
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
if ( ( e = a - > enums ) ) {
2013-07-06 18:01:57 +00:00
wmem_array_t * arr = wmem_array_new ( wmem_epan_scope ( ) , sizeof ( value_string ) ) ;
2015-07-07 02:06:34 +00:00
value_string term [ 1 ] ;
term [ 0 ] . value = 0 ;
term [ 0 ] . strptr = NULL ;
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
for ( ; e ; e = e - > next ) {
2014-01-15 19:29:03 +00:00
value_string item [ 1 ] ;
item [ 0 ] . value = e - > code ;
item [ 0 ] . strptr = e - > name ;
2013-07-06 18:01:57 +00:00
wmem_array_append_one ( arr , item ) ;
2007-07-16 05:41:58 +00:00
}
2013-07-06 18:01:57 +00:00
wmem_array_sort ( arr , compare_avps ) ;
wmem_array_append_one ( arr , term ) ;
vs = ( value_string * ) wmem_array_get_raw ( arr ) ;
2007-07-16 05:41:58 +00:00
}
2007-07-17 21:29:18 +00:00
2007-07-20 00:15:17 +00:00
type = NULL ;
for ( x = d - > xmlpis ; x ; x = x - > next ) {
if ( ( strcase_equal ( x - > name , " avp-proto " ) & & strcase_equal ( x - > key , a - > name ) )
| | ( a - > type & & strcase_equal ( x - > name , " type-proto " ) & & strcase_equal ( x - > key , a - > type ) )
) {
2012-06-09 17:56:08 +00:00
static avp_type_t proto_type = { " proto " , proto_avp , proto_avp , FT_UINT32 , BASE_HEX , build_proto_avp } ;
2007-07-20 00:15:17 +00:00
type = & proto_type ;
2007-10-24 16:32:51 +00:00
2007-07-20 00:15:17 +00:00
avp_data = x - > value ;
break ;
}
2007-07-16 05:41:58 +00:00
}
2007-07-17 21:29:18 +00:00
2007-07-20 00:15:17 +00:00
if ( ( ! type ) & & a - > type )
2013-03-02 19:21:38 +00:00
type = ( avp_type_t * ) g_hash_table_lookup ( build_dict . types , a - > type ) ;
2007-10-24 16:32:51 +00:00
2007-11-27 01:41:42 +00:00
if ( ! type ) type = octetstring ;
2007-07-20 00:15:17 +00:00
avp = type - > build ( type , a - > code , vnd , a - > name , vs , avp_data ) ;
2007-11-27 01:41:42 +00:00
if ( avp ! = NULL ) {
g_hash_table_insert ( build_dict . avps , a - > name , avp ) ;
{
2014-01-15 19:29:03 +00:00
wmem_tree_key_t k [ 3 ] ;
k [ 0 ] . length = 1 ;
k [ 0 ] . key = & ( a - > code ) ;
k [ 1 ] . length = 1 ;
k [ 1 ] . key = & ( vnd - > code ) ;
k [ 2 ] . length = 0 ;
k [ 2 ] . key = NULL ;
2013-09-04 21:06:56 +00:00
wmem_tree_insert32_array ( dictionary . avps , k , avp ) ;
2007-11-27 01:41:42 +00:00
}
2007-07-16 05:41:58 +00:00
}
}
g_hash_table_destroy ( build_dict . types ) ;
g_hash_table_destroy ( build_dict . avps ) ;
g_hash_table_destroy ( vendors ) ;
2007-07-17 21:29:18 +00:00
2007-07-16 05:41:58 +00:00
return 1 ;
}
2001-02-23 19:26:26 +00:00
2012-11-28 23:11:08 +00:00
/*
2016-04-13 03:01:18 +00:00
* This does most of the registration work ; see register_diameter_fields ( )
2012-11-28 23:11:08 +00:00
* for the reason why we split it off .
*/
static void
2016-04-13 03:01:18 +00:00
real_register_diameter_fields ( void )
2000-07-30 07:16:11 +00:00
{
2013-08-05 01:54:15 +00:00
expert_module_t * expert_diameter ;
2008-07-15 21:06:31 +00:00
guint i , ett_length ;
2008-04-05 05:41:59 +00:00
2007-07-16 05:41:58 +00:00
hf_register_info hf_base [ ] = {
{ & hf_diameter_version ,
2001-07-30 20:08:44 +00:00
{ " Version " , " diameter.version " , FT_UINT8 , BASE_HEX , NULL , 0x00 ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_length ,
2001-07-30 20:08:44 +00:00
{ " Length " , " diameter.length " , FT_UINT24 , BASE_DEC , NULL , 0x0 ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_flags ,
2001-07-30 20:08:44 +00:00
{ " Flags " , " diameter.flags " , FT_UINT8 , BASE_HEX , NULL , 0x0 ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_flags_request ,
2009-07-07 14:54:15 +00:00
{ " Request " , " diameter.flags.request " , FT_BOOLEAN , 8 , TFS ( & tfs_set_notset ) , DIAM_FLAGS_R ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_flags_proxyable ,
2009-07-07 14:54:15 +00:00
{ " Proxyable " , " diameter.flags.proxyable " , FT_BOOLEAN , 8 , TFS ( & tfs_set_notset ) , DIAM_FLAGS_P ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_flags_error ,
2009-07-07 14:54:15 +00:00
{ " Error " , " diameter.flags.error " , FT_BOOLEAN , 8 , TFS ( & tfs_set_notset ) , DIAM_FLAGS_E ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_flags_T ,
2012-11-28 22:45:31 +00:00
{ " T(Potentially re-transmitted message) " , " diameter.flags.T " , FT_BOOLEAN , 8 , TFS ( & tfs_set_notset ) , DIAM_FLAGS_T ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_flags_reserved4 ,
2009-04-07 12:20:41 +00:00
{ " Reserved " , " diameter.flags.reserved4 " , FT_BOOLEAN , 8 , TFS ( & tfs_set_notset ) ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
DIAM_FLAGS_RESERVED4 , NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_flags_reserved5 ,
2009-04-07 12:20:41 +00:00
{ " Reserved " , " diameter.flags.reserved5 " , FT_BOOLEAN , 8 , TFS ( & tfs_set_notset ) ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
DIAM_FLAGS_RESERVED5 , NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_flags_reserved6 ,
2009-04-07 12:20:41 +00:00
{ " Reserved " , " diameter.flags.reserved6 " , FT_BOOLEAN , 8 , TFS ( & tfs_set_notset ) ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
DIAM_FLAGS_RESERVED6 , NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_flags_reserved7 ,
2009-04-07 12:20:41 +00:00
{ " Reserved " , " diameter.flags.reserved7 " , FT_BOOLEAN , 8 , TFS ( & tfs_set_notset ) ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
DIAM_FLAGS_RESERVED7 , NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_vendor_id ,
2017-06-24 13:25:41 +00:00
{ " VendorId " , " diameter.vendorId " , FT_UINT32 , BASE_ENTERPRISES , STRINGS_ENTERPRISES ,
2012-11-28 22:45:31 +00:00
0x0 , NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_application_id ,
2015-04-23 13:10:38 +00:00
{ " ApplicationId " , " diameter.applicationId " , FT_UINT32 , BASE_DEC | BASE_EXT_STRING , VALS_EXT_PTR ( dictionary . applications ) ,
2012-11-28 22:45:31 +00:00
0x0 , NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_hopbyhopid ,
2001-04-10 21:49:23 +00:00
{ " Hop-by-Hop Identifier " , " diameter.hopbyhopid " , FT_UINT32 ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
BASE_HEX , NULL , 0x0 , NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_endtoendid ,
2002-08-28 21:04:11 +00:00
{ " End-to-End Identifier " , " diameter.endtoendid " , FT_UINT32 ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
BASE_HEX , NULL , 0x0 , NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_avp ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
{ " AVP " , " diameter.avp " , FT_BYTES , BASE_NONE ,
NULL , 0x0 , NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_avp_len ,
{ " AVP Length " , " diameter.avp.len " , FT_UINT24 , BASE_DEC ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
NULL , 0x0 , NULL , HFILL } } ,
2013-03-22 18:13:31 +00:00
{ & hf_diameter_avp_code ,
{ " AVP Code " , " diameter.avp.code " , FT_UINT32 , BASE_DEC , NULL , 0 , NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_avp_flags ,
2001-02-19 23:14:02 +00:00
{ " AVP Flags " , " diameter.avp.flags " , FT_UINT8 , BASE_HEX ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
NULL , 0x0 , NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_avp_flags_vendor_specific ,
2009-07-07 14:54:15 +00:00
{ " Vendor-Specific " , " diameter.flags.vendorspecific " , FT_BOOLEAN , 8 , TFS ( & tfs_set_notset ) , AVP_FLAGS_V ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_avp_flags_mandatory ,
2009-07-07 14:54:15 +00:00
{ " Mandatory " , " diameter.flags.mandatory " , FT_BOOLEAN , 8 , TFS ( & tfs_set_notset ) , AVP_FLAGS_M ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_avp_flags_protected ,
2009-07-07 14:54:15 +00:00
{ " Protected " , " diameter.avp.flags.protected " , FT_BOOLEAN , 8 , TFS ( & tfs_set_notset ) , AVP_FLAGS_P ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_avp_flags_reserved3 ,
2009-04-07 12:20:41 +00:00
{ " Reserved " , " diameter.avp.flags.reserved3 " , FT_BOOLEAN , 8 , TFS ( & tfs_set_notset ) ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
AVP_FLAGS_RESERVED3 , NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_avp_flags_reserved4 ,
2009-04-07 12:20:41 +00:00
{ " Reserved " , " diameter.avp.flags.reserved4 " , FT_BOOLEAN , 8 , TFS ( & tfs_set_notset ) ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
AVP_FLAGS_RESERVED4 , NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_avp_flags_reserved5 ,
2009-04-07 12:20:41 +00:00
{ " Reserved " , " diameter.avp.flags.reserved5 " , FT_BOOLEAN , 8 , TFS ( & tfs_set_notset ) ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
AVP_FLAGS_RESERVED5 , NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_avp_flags_reserved6 ,
2009-04-07 12:20:41 +00:00
{ " Reserved " , " diameter.avp.flags.reserved6 " , FT_BOOLEAN , 8 , TFS ( & tfs_set_notset ) ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
AVP_FLAGS_RESERVED6 , NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_avp_flags_reserved7 ,
2009-04-07 12:20:41 +00:00
{ " Reserved " , " diameter.avp.flags.reserved7 " , FT_BOOLEAN , 8 , TFS ( & tfs_set_notset ) ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
AVP_FLAGS_RESERVED7 , NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_avp_vendor_id ,
2017-06-24 13:25:41 +00:00
{ " AVP Vendor Id " , " diameter.avp.vendorId " , FT_UINT32 , BASE_ENTERPRISES , STRINGS_ENTERPRISES ,
0x0 , NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & ( unknown_avp . hf_value ) ,
2013-03-22 18:13:31 +00:00
{ " Value " , " diameter.avp.unknown " , FT_BYTES , BASE_NONE , NULL , 0x0 , NULL , HFILL } } ,
2007-07-27 18:32:09 +00:00
{ & hf_diameter_avp_data_wrong_length ,
2013-03-22 18:13:31 +00:00
{ " Data " , " diameter.avp.invalid-data " , FT_BYTES , BASE_NONE , NULL , 0x0 , NULL , HFILL } } ,
{ & hf_diameter_avp_pad ,
{ " Padding " , " diameter.avp.pad " , FT_BYTES , BASE_NONE , NULL , 0x0 , NULL , HFILL } } ,
2007-07-16 05:41:58 +00:00
{ & hf_diameter_code ,
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
{ " Command Code " , " diameter.cmd.code " , FT_UINT32 , BASE_DEC , NULL , 0 , NULL , HFILL } } ,
2008-11-15 15:52:39 +00:00
{ & hf_diameter_answer_in ,
2015-03-06 23:31:41 +00:00
{ " Answer In " , " diameter.answer_in " , FT_FRAMENUM , BASE_NONE , FRAMENUM_TYPE ( FT_FRAMENUM_RESPONSE ) , 0x0 ,
2008-11-15 15:52:39 +00:00
" The answer to this diameter request is in this frame " , HFILL } } ,
{ & hf_diameter_answer_to ,
2015-03-06 23:31:41 +00:00
{ " Request In " , " diameter.answer_to " , FT_FRAMENUM , BASE_NONE , FRAMENUM_TYPE ( FT_FRAMENUM_REQUEST ) , 0x0 ,
2008-11-15 15:52:39 +00:00
" This is an answer to the diameter request in this frame " , HFILL } } ,
{ & hf_diameter_answer_time ,
{ " Response Time " , " diameter.resp_time " , FT_RELATIVE_TIME , BASE_NONE , NULL , 0x0 ,
" The time between the request and the answer " , HFILL } } ,
2012-03-13 15:06:40 +00:00
{ & hf_framed_ipv6_prefix_reserved ,
{ " Framed IPv6 Prefix Reserved byte " , " diameter.framed_ipv6_prefix_reserved " ,
2013-03-22 18:13:31 +00:00
FT_UINT8 , BASE_HEX , NULL , 0 , NULL , HFILL } } ,
2012-03-13 15:06:40 +00:00
{ & hf_framed_ipv6_prefix_length ,
{ " Framed IPv6 Prefix length (in bits) " , " diameter.framed_ipv6_prefix_length " ,
2013-03-22 18:13:31 +00:00
FT_UINT8 , BASE_DEC , NULL , 0 , NULL , HFILL } } ,
2012-03-13 15:06:40 +00:00
{ & hf_framed_ipv6_prefix_bytes ,
{ " Framed IPv6 Prefix as a bytestring " , " diameter.framed_ipv6_prefix_bytes " ,
2013-03-22 18:13:31 +00:00
FT_BYTES , BASE_NONE , NULL , 0 , NULL , HFILL } } ,
2012-03-13 15:06:40 +00:00
{ & hf_framed_ipv6_prefix_ipv6 ,
{ " Framed IPv6 Prefix as an IPv6 address " , " diameter.framed_ipv6_prefix_ipv6 " ,
2013-12-04 20:55:52 +00:00
FT_IPv6 , BASE_NONE , NULL , 0 , " This field is present only if the prefix length is 128 " , HFILL } } ,
{ & hf_diameter_3gpp2_exp_res ,
2014-01-04 23:41:22 +00:00
{ " Experimental-Result-Code " , " diameter.3gpp2.exp_res " ,
2015-10-26 20:44:18 +00:00
FT_UINT32 , BASE_DEC , VALS ( diameter_3gpp2_exp_res_vals ) , 0x0 , NULL , HFILL } } ,
{ & hf_diameter_other_vendor_exp_res ,
{ " Experimental-Result-Code " , " diameter.other_vendor.Experimental-Result-Code " ,
2019-05-30 18:26:24 +00:00
FT_UINT32 , BASE_DEC , NULL , 0x0 , NULL , HFILL } } ,
{ & hf_diameter_mip6_feature_vector ,
{ " MIP6-Feature-Vector " , " diameter.mip6_feature_vector " ,
FT_UINT64 , BASE_HEX , NULL , 0x0 , NULL , HFILL } } ,
{ & hf_diameter_mip6_feature_vector_mip6_integrated ,
{ " MIP6_INTEGRATED " , " diameter.mip6_feature_vector.mip6_integrated.mip6_integrated " ,
FT_BOOLEAN , 64 , TFS ( & tfs_set_notset ) , 0x0000000000000001 , NULL , HFILL } } ,
{ & hf_diameter_mip6_feature_vector_local_home_agent_assignment ,
{ " LOCAL_HOME_AGENT_ASSIGNMENT " , " diameter.mip6_feature_vector.local_home_agent_assignment " ,
FT_BOOLEAN , 64 , TFS ( & tfs_set_notset ) , 0x0000000000000002 , NULL , HFILL } } ,
{ & hf_diameter_mip6_feature_vector_pmip6_supported ,
{ " PMIP6_SUPPORTED " , " diameter.mip6_feature_vector.pmip6_supported " ,
FT_BOOLEAN , 64 , TFS ( & tfs_set_notset ) , 0x0000010000000000 , NULL , HFILL } } ,
{ & hf_diameter_mip6_feature_vector_ip4_hoa_supported ,
{ " IP4_HOA_SUPPORTED " , " diameter.mip6_feature_vector.ip4_hoa_supported " ,
FT_BOOLEAN , 64 , TFS ( & tfs_set_notset ) , 0x0000020000000000 , NULL , HFILL } } ,
{ & hf_diameter_mip6_feature_vector_local_mag_routing_supported ,
{ " LOCAL_MAG_ROUTING_SUPPORTED " , " diameter.mip6_feature_vector.local_mag_routing_supported " ,
FT_BOOLEAN , 64 , TFS ( & tfs_set_notset ) , 0x0000040000000000 , NULL , HFILL } } ,
{ & hf_diameter_3gpp_mip6_feature_vector ,
{ " MIP6-Feature-Vector [3GPP] " , " diameter.3gpp.mip6_feature_vector " ,
FT_UINT64 , BASE_HEX , NULL , 0x0 , NULL , HFILL } } ,
{ & hf_diameter_3gpp_mip6_feature_vector_assign_local_ip ,
{ " MIP6_INTEGRATED " , " diameter.3gpp.mip6_feature_vector.assign_local_ip " ,
FT_BOOLEAN , 64 , TFS ( & tfs_set_notset ) , 0x0000080000000000 , NULL , HFILL } } ,
{ & hf_diameter_3gpp_mip6_feature_vector_mip4_supported ,
{ " PMIP6_SUPPORTED " , " diameter.3gpp.mip6_feature_vector.mip4_supported " ,
FT_BOOLEAN , 64 , TFS ( & tfs_set_notset ) , 0x0000100000000000 , NULL , HFILL } } ,
{ & hf_diameter_3gpp_mip6_feature_vector_optimized_idle_mode_mobility ,
{ " OPTIMIZED_IDLE_MODE_MOBILITY " , " diameter.3gpp.mip6_feature_vector.optimized_idle_mode_mobility " ,
FT_BOOLEAN , 64 , TFS ( & tfs_set_notset ) , 0x0000200000000000 , NULL , HFILL } } ,
{ & hf_diameter_3gpp_mip6_feature_vector_gtpv2_supported ,
{ " GTPv2_SUPPORTED " , " diameter.3gpp.mip6_feature_vector.gtpv2_supported " ,
2019-11-03 11:12:19 +00:00
FT_BOOLEAN , 64 , TFS ( & tfs_set_notset ) , 0x0000400000000000 , NULL , HFILL } } ,
{ & hf_diameter_user_equipment_info_imeisv ,
{ " IMEISV " , " diameter.user_equipment_info.imeisv " , FT_STRING , BASE_NONE , NULL , 0x0 , NULL , HFILL } } ,
{ & hf_diameter_user_equipment_info_mac ,
{ " MAC " , " diameter.user_equipment_info.mac " , FT_ETHER , BASE_NONE , NULL , 0x0 , NULL , HFILL } } ,
{ & hf_diameter_user_equipment_info_eui64 ,
{ " EUI64 " , " diameter.user_equipment_info.eui64 " , FT_EUI64 , BASE_NONE , NULL , 0x0 , NULL , HFILL } } ,
{ & hf_diameter_user_equipment_info_modified_eui64 ,
2021-03-31 21:58:30 +00:00
{ " Modified EUI64 " , " diameter.user_equipment_info.modified_eui64 " , FT_EUI64 , BASE_NONE , NULL , 0x0 , NULL , HFILL } }
2000-07-30 07:16:11 +00:00
} ;
2008-11-15 15:52:39 +00:00
2007-07-16 05:41:58 +00:00
gint * ett_base [ ] = {
2000-07-30 07:16:11 +00:00
& ett_diameter ,
2001-07-30 20:08:44 +00:00
& ett_diameter_flags ,
& ett_diameter_avp_flags ,
2007-07-16 05:41:58 +00:00
& ett_diameter_avpinfo ,
2007-07-17 22:19:54 +00:00
& ett_unknown ,
& ett_err ,
2019-05-30 18:26:24 +00:00
& ett_diameter_mip6_feature_vector ,
& ett_diameter_3gpp_mip6_feature_vector ,
2007-07-16 05:41:58 +00:00
& ( unknown_avp . ett )
2000-07-30 07:16:11 +00:00
} ;
2007-07-17 21:29:18 +00:00
2013-08-05 01:54:15 +00:00
static ei_register_info ei [ ] = {
{ & ei_diameter_reserved_bit_set , { " diameter.reserved_bit_set " , PI_MALFORMED , PI_WARN , " Reserved bit set " , EXPFILL } } ,
2013-09-01 13:05:27 +00:00
{ & ei_diameter_avp_code , { " diameter.avp.code.unknown " , PI_UNDECODED , PI_WARN , " Unknown AVP, if you know what this is you can add it to dictionary.xml " , EXPFILL } } ,
{ & ei_diameter_avp_vendor_id , { " diameter.unknown_vendor " , PI_UNDECODED , PI_WARN , " Unknown Vendor, if you know whose this is you can add it to dictionary.xml " , EXPFILL } } ,
{ & ei_diameter_avp_no_data , { " diameter.avp.no_data " , PI_UNDECODED , PI_WARN , " Data is empty " , EXPFILL } } ,
{ & ei_diameter_avp_pad , { " diameter.avp.pad.non_zero " , PI_MALFORMED , PI_NOTE , " Padding is non-zero " , EXPFILL } } ,
2019-08-14 23:19:33 +00:00
{ & ei_diameter_avp_pad_missing , { " diameter.avp.pad.missing " , PI_MALFORMED , PI_NOTE , " Padding is missing " , EXPFILL } } ,
2013-09-01 13:05:27 +00:00
{ & ei_diameter_avp_len , { " diameter.avp.invalid-len " , PI_MALFORMED , PI_WARN , " Wrong length " , EXPFILL } } ,
{ & ei_diameter_application_id , { " diameter.applicationId.unknown " , PI_UNDECODED , PI_WARN , " Unknown Application Id, if you know what this is you can add it to dictionary.xml " , EXPFILL } } ,
{ & ei_diameter_version , { " diameter.version.unknown " , PI_UNDECODED , PI_WARN , " Unknown Diameter Version (decoding as RFC 3588) " , EXPFILL } } ,
{ & ei_diameter_code , { " diameter.cmd.code.unknown " , PI_UNDECODED , PI_WARN , " Unknown command, if you know what this is you can add it to dictionary.xml " , EXPFILL } } ,
2016-08-30 12:55:54 +00:00
{ & ei_diameter_invalid_ipv6_prefix_len , { " diameter.invalid_ipv6_prefix_len " , PI_MALFORMED , PI_ERROR , " Invalid IPv6 Prefix length " , EXPFILL } } ,
2019-11-03 11:12:19 +00:00
{ & ei_diameter_invalid_avp_len , { " diameter.invalid_avp_len " , PI_MALFORMED , PI_ERROR , " Invalid AVP length " , EXPFILL } } ,
{ & ei_diameter_invalid_user_equipment_info_value_len , { " diameter.invalid_user_equipment_info_value_len " , PI_MALFORMED , PI_ERROR , " Invalid User-Equipment-Info-Value length " , EXPFILL } }
2013-08-05 01:54:15 +00:00
} ;
2013-07-06 12:45:33 +00:00
wmem_array_append ( build_dict . hf , hf_base , array_length ( hf_base ) ) ;
2008-07-15 21:06:31 +00:00
ett_length = array_length ( ett_base ) ;
2012-11-28 22:45:31 +00:00
for ( i = 0 ; i < ett_length ; i + + ) {
2008-07-16 08:08:17 +00:00
g_ptr_array_add ( build_dict . ett , ett_base [ i ] ) ;
2008-07-15 21:06:31 +00:00
}
2007-07-17 21:29:18 +00:00
2013-07-06 12:45:33 +00:00
proto_register_field_array ( proto_diameter , ( hf_register_info * ) wmem_array_get_raw ( build_dict . hf ) , wmem_array_get_count ( build_dict . hf ) ) ;
2012-12-16 01:12:59 +00:00
proto_register_subtree_array ( ( gint * * ) build_dict . ett - > pdata , build_dict . ett - > len ) ;
2013-08-05 01:54:15 +00:00
expert_diameter = expert_register_protocol ( proto_diameter ) ;
expert_register_field_array ( expert_diameter , ei , array_length ( ei ) ) ;
2007-07-17 21:29:18 +00:00
2008-07-15 21:06:31 +00:00
g_ptr_array_free ( build_dict . ett , TRUE ) ;
2001-01-03 06:56:03 +00:00
2016-04-13 03:01:18 +00:00
}
static void
register_diameter_fields ( const char * unused _U_ )
{
/*
* The hf_base [ ] array for Diameter refers to a variable
* that is set by dictionary_load ( ) , so we need to call
* dictionary_load ( ) before hf_base [ ] is initialized .
*
* To ensure that , we call dictionary_load ( ) and then
* call a routine that defines hf_base [ ] and does all
* the registration work .
*/
dictionary_load ( ) ;
real_register_diameter_fields ( ) ;
}
void
proto_register_diameter ( void )
{
module_t * diameter_module ;
2020-03-14 22:17:39 +00:00
proto_diameter = proto_register_protocol ( " Diameter Protocol " , " Diameter " , " diameter " ) ;
2016-04-13 03:01:18 +00:00
2006-05-23 05:48:00 +00:00
/* Allow dissector to find be found by name. */
2016-12-17 01:06:11 +00:00
diameter_sctp_handle = register_dissector ( " diameter " , dissect_diameter , proto_diameter ) ;
2019-08-14 01:47:09 +00:00
/* Diameter AVPs without Diameter header, for EAP-TTLS (RFC 5281, Section 10) */
register_dissector ( " diameter_avps " , dissect_diameter_avps , proto_diameter ) ;
2008-04-05 05:41:59 +00:00
2016-04-13 03:01:18 +00:00
/* Delay registration of Diameter fields */
proto_register_prefix ( " diameter " , register_diameter_fields ) ;
2013-04-02 18:15:42 +00:00
/* Register dissector table(s) to do sub dissection of AVPs (OctetStrings) */
2017-01-07 02:49:50 +00:00
diameter_dissector_table = register_dissector_table ( " diameter.base " , " Diameter Base AVP " , proto_diameter , FT_UINT32 , BASE_DEC ) ;
diameter_3gpp_avp_dissector_table = register_dissector_table ( " diameter.3gpp " , " Diameter 3GPP AVP " , proto_diameter , FT_UINT32 , BASE_DEC ) ;
diameter_ericsson_avp_dissector_table = register_dissector_table ( " diameter.ericsson " , " Diameter Ericsson AVP " , proto_diameter , FT_UINT32 , BASE_DEC ) ;
2017-04-27 11:03:42 +00:00
diameter_verizon_avp_dissector_table = register_dissector_table ( " diameter.verizon " , " DIAMETER_VERIZON_AVPS " , proto_diameter , FT_UINT32 , BASE_DEC ) ;
2006-05-23 05:48:00 +00:00
2017-01-07 02:49:50 +00:00
diameter_expr_result_vnd_table = register_dissector_table ( " diameter.vnd_exp_res " , " Diameter Experimental-Result-Code " , proto_diameter , FT_UINT32 , BASE_DEC ) ;
2013-12-04 20:55:52 +00:00
2007-10-24 15:04:01 +00:00
/* Set default TCP ports */
2016-12-22 20:12:27 +00:00
range_convert_str ( wmem_epan_scope ( ) , & global_diameter_sctp_port_range , DEFAULT_DIAMETER_PORT_RANGE , MAX_SCTP_PORT ) ;
2007-10-24 15:04:01 +00:00
2008-04-05 05:41:59 +00:00
/* Register configuration options for ports */
2016-10-05 20:33:54 +00:00
diameter_module = prefs_register_protocol ( proto_diameter , proto_reg_handoff_diameter ) ;
2018-09-29 03:23:39 +00:00
/* For reading older preference files with "Diameter." preferences */
prefs_register_module_alias ( " Diameter " , diameter_module ) ;
2007-07-16 05:41:58 +00:00
2010-10-18 15:56:06 +00:00
prefs_register_range_preference ( diameter_module , " sctp.ports " ,
" Diameter SCTP Ports " ,
" SCTP ports to be decoded as Diameter (default: "
DEFAULT_DIAMETER_PORT_RANGE " ) " ,
& global_diameter_sctp_port_range , MAX_SCTP_PORT ) ;
2006-03-15 06:16:12 +00:00
2001-11-03 12:19:56 +00:00
/* Desegmentation */
2002-01-15 10:01:21 +00:00
prefs_register_bool_preference ( diameter_module , " desegment " ,
2016-09-20 21:11:29 +00:00
" Reassemble Diameter messages spanning multiple TCP segments " ,
2008-07-15 21:06:31 +00:00
" Whether the Diameter dissector should reassemble messages spanning multiple TCP segments. "
" To use this option, you must also enable \" Allow subdissectors to reassemble TCP streams \" in the TCP protocol settings. " ,
& gbl_diameter_desegment ) ;
2007-07-17 21:29:18 +00:00
2008-07-15 21:06:31 +00:00
/* Register some preferences we no longer support, so we can report
* them as obsolete rather than just illegal .
*/
2007-10-24 15:04:01 +00:00
prefs_register_obsolete_preference ( diameter_module , " version " ) ;
2010-10-18 15:56:06 +00:00
prefs_register_obsolete_preference ( diameter_module , " sctp.port " ) ;
Allow a dissector to register preferences that it no longer supports as
obsolete; we silently ignore attempts to set those in a preferences
file, so that we don't spam the user with error messages caused by them
having saved preferences in an earlier release that contained those
preferences.
Make the Diameter and iSCSI dissectors register obsolete preferences.
Crash if some code tries to register a preferences module with a name
that contains something other than lower-case ASCII letters, numbers, or
underscores, or that has already been registered, or if some code tries
to register a preference with a name that contains something other than
lower-case ASCII letters, numbers, underscores, or periods, or that has
already been registered, so that we don't put code like that in a
release and have to shovel code into "prefs.c" to fix it up later. (The
problem with multiple modules or preferences with the same name should
be obvious; the problem with names with blanks, or upper-case letters,
or punctuation, is that they're a pain to type on the command line.)
svn path=/trunk/; revision=4148
2001-11-04 02:50:21 +00:00
prefs_register_obsolete_preference ( diameter_module , " command_in_header " ) ;
2007-07-16 05:41:58 +00:00
prefs_register_obsolete_preference ( diameter_module , " dictionary.name " ) ;
prefs_register_obsolete_preference ( diameter_module , " dictionary.use " ) ;
prefs_register_obsolete_preference ( diameter_module , " allow_zero_as_app_id " ) ;
prefs_register_obsolete_preference ( diameter_module , " suppress_console_output " ) ;
2007-07-17 21:29:18 +00:00
2008-11-15 15:52:39 +00:00
/* Register tap */
diameter_tap = register_tap ( " diameter " ) ;
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
register_srt_table ( proto_diameter , NULL , 1 , diameterstat_packet , diameterstat_init , NULL ) ;
2008-11-15 15:52:39 +00:00
2001-11-01 21:52:44 +00:00
} /* proto_register_diameter */
2007-07-16 05:41:58 +00:00
2010-04-26 22:19:34 +00:00
void
proto_reg_handoff_diameter ( void )
{
static gboolean Initialized = FALSE ;
2010-10-18 15:56:06 +00:00
static range_t * diameter_sctp_port_range ;
2010-04-26 22:19:34 +00:00
if ( ! Initialized ) {
2015-12-09 03:49:44 +00:00
diameter_tcp_handle = create_dissector_handle ( dissect_diameter_tcp ,
2010-04-26 22:19:34 +00:00
proto_diameter ) ;
2015-12-09 03:49:44 +00:00
diameter_udp_handle = create_dissector_handle ( dissect_diameter , proto_diameter ) ;
2010-04-26 22:19:34 +00:00
data_handle = find_dissector ( " data " ) ;
2016-03-16 13:02:52 +00:00
eap_handle = find_dissector_add_dependency ( " eap " , proto_diameter ) ;
2012-03-13 15:06:40 +00:00
2012-08-14 20:44:58 +00:00
dissector_add_uint ( " sctp.ppi " , DIAMETER_PROTOCOL_ID , diameter_sctp_handle ) ;
2013-04-02 18:15:42 +00:00
/* Register special decoding for some AVPs */
2014-08-20 19:08:21 +00:00
/* AVP Code: 1 User-Name */
2015-12-09 03:49:44 +00:00
dissector_add_uint ( " diameter.base " , 1 , create_dissector_handle ( dissect_diameter_user_name , proto_diameter ) ) ;
2014-08-20 19:08:21 +00:00
2019-08-14 01:47:09 +00:00
/* AVP Code: 79 EAP-Message (defined in RFC 2869, but used for EAP-TTLS, RFC 5281) */
dissector_add_uint ( " diameter.base " , 79 , create_dissector_handle ( dissect_diameter_eap_payload , proto_diameter ) ) ;
2012-03-13 15:06:40 +00:00
/* AVP Code: 97 Framed-IPv6-Address */
2015-12-09 03:49:44 +00:00
dissector_add_uint ( " diameter.base " , 97 , create_dissector_handle ( dissect_diameter_base_framed_ipv6_prefix , proto_diameter ) ) ;
2014-08-20 19:08:21 +00:00
2019-05-30 18:26:24 +00:00
/* AVP Code: 124 MIP6-Feature-Vector */
dissector_add_uint ( " diameter.base " , 124 , create_dissector_handle ( dissect_diameter_mip6_feature_vector , proto_diameter ) ) ;
2016-01-06 00:58:42 +00:00
/* AVP Code: 265 Supported-Vendor-Id */
2015-12-09 03:49:44 +00:00
dissector_add_uint ( " diameter.base " , 265 , create_dissector_handle ( dissect_diameter_vendor_id , proto_diameter ) ) ;
2015-05-22 10:29:53 +00:00
2010-04-26 22:19:34 +00:00
/* AVP Code: 266 Vendor-Id */
2015-12-09 03:49:44 +00:00
dissector_add_uint ( " diameter.base " , 266 , create_dissector_handle ( dissect_diameter_vendor_id , proto_diameter ) ) ;
2014-08-20 19:08:21 +00:00
/* AVP Code: 443 Subscription-Id */
2015-12-09 03:49:44 +00:00
dissector_add_uint ( " diameter.base " , 443 , create_dissector_handle ( dissect_diameter_subscription_id , proto_diameter ) ) ;
2014-08-20 19:08:21 +00:00
/* AVP Code: 450 Subscription-Id-Type */
2015-12-09 03:49:44 +00:00
dissector_add_uint ( " diameter.base " , 450 , create_dissector_handle ( dissect_diameter_subscription_id_type , proto_diameter ) ) ;
2014-08-20 19:08:21 +00:00
/* AVP Code: 444 Subscription-Id-Data */
2015-12-09 03:49:44 +00:00
dissector_add_uint ( " diameter.base " , 444 , create_dissector_handle ( dissect_diameter_subscription_id_data , proto_diameter ) ) ;
2014-08-20 19:08:21 +00:00
2019-11-03 11:12:19 +00:00
/* AVP Code: 458 User-Equipment-Info */
dissector_add_uint ( " diameter.base " , 458 , create_dissector_handle ( dissect_diameter_user_equipment_info , proto_diameter ) ) ;
/* AVP Code: 459 User-Equipment-Info-Type */
dissector_add_uint ( " diameter.base " , 459 , create_dissector_handle ( dissect_diameter_user_equipment_info_type , proto_diameter ) ) ;
/* AVP Code: 460 User-Equipment-Info-Value */
dissector_add_uint ( " diameter.base " , 460 , create_dissector_handle ( dissect_diameter_user_equipment_info_value , proto_diameter ) ) ;
2010-04-26 22:19:34 +00:00
/* AVP Code: 462 EAP-Payload */
2015-12-09 03:49:44 +00:00
dissector_add_uint ( " diameter.base " , 462 , create_dissector_handle ( dissect_diameter_eap_payload , proto_diameter ) ) ;
2010-04-26 22:19:34 +00:00
/* AVP Code: 463 EAP-Reissued-Payload */
2015-12-09 03:49:44 +00:00
dissector_add_uint ( " diameter.base " , 463 , create_dissector_handle ( dissect_diameter_eap_payload , proto_diameter ) ) ;
2010-04-26 22:19:34 +00:00
2014-08-20 19:08:21 +00:00
/* Register dissector for Experimental result code, with 3GPP2's vendor Id */
2015-12-09 03:49:44 +00:00
dissector_add_uint ( " diameter.vnd_exp_res " , VENDOR_THE3GPP2 , create_dissector_handle ( dissect_diameter_3gpp2_exp_res , proto_diameter ) ) ;
2013-12-04 20:55:52 +00:00
2016-10-05 20:33:54 +00:00
dissector_add_uint_range_with_preference ( " tcp.port " , DEFAULT_DIAMETER_PORT_RANGE , diameter_tcp_handle ) ;
dissector_add_uint_range_with_preference ( " udp.port " , " " , diameter_udp_handle ) ;
2010-04-26 22:19:34 +00:00
Initialized = TRUE ;
} else {
2013-08-25 18:48:26 +00:00
dissector_delete_uint_range ( " sctp.port " , diameter_sctp_port_range , diameter_sctp_handle ) ;
2016-12-22 20:12:27 +00:00
wmem_free ( wmem_epan_scope ( ) , diameter_sctp_port_range ) ;
2010-04-26 22:19:34 +00:00
}
/* set port for future deletes */
2016-12-22 20:12:27 +00:00
diameter_sctp_port_range = range_copy ( wmem_epan_scope ( ) , global_diameter_sctp_port_range ) ;
2013-08-25 18:48:26 +00:00
dissector_add_uint_range ( " sctp.port " , diameter_sctp_port_range , diameter_sctp_handle ) ;
2013-05-20 18:30:32 +00:00
exported_pdu_tap = find_tap_id ( EXPORT_PDU_TAP_NAME_LAYER_7 ) ;
2010-04-26 22:19:34 +00:00
}
2013-11-21 18:46:40 +00:00
/*
2019-07-26 18:43:17 +00:00
* Editor modelines - https : //www.wireshark.org/tools/modelines.html
2013-11-21 18:46:40 +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 :
*/