From David Wei:

Bug fixes and improvements to Sm (GTPv2) and SGmb (DIAMETER) dissectors.

svn path=/trunk/; revision=42220
This commit is contained in:
Anders Broman 2012-04-24 12:33:00 +00:00
parent 299228b7d7
commit 949079e2b4
2 changed files with 122 additions and 53 deletions

View File

@ -41,6 +41,7 @@
#include "packet-gsm_a_common.h"
#include "packet-e164.h"
#include "packet-e212.h"
#include "packet-ntp.h"
/* Initialize the protocol and registered fields */
static int proto_diameter_3gpp = -1;
@ -105,6 +106,8 @@ static int hf_diameter_3gpp_idr_flags_bit1 = -1;
static int hf_diameter_3gpp_idr_flags_bit2 = -1;
static int hf_diameter_3gpp_idr_flags_bit3 = -1;
static int hf_diameter_3gpp_idr_flags_bit4 = -1;
static int hf_diameter_3gpp_sgsn_ipv6_addr = -1;
static int hf_diameter_3gpp_mbms_abs_time_ofmbms_data_tfer = -1;
static gint diameter_3gpp_path_ett = -1;
static gint diameter_3gpp_msisdn_ett = -1;
static gint diameter_3gpp_feature_list_ett = -1;
@ -121,7 +124,18 @@ static gint diameter_3gpp_idr_flags_ett = -1;
/* Dissector handles */
static dissector_handle_t xml_handle;
/* AVP Code: 15 3GPP-SGSN-IPv6-Address */
static int
dissect_diameter_3gpp_sgsn_ipv6_addr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
{
int offset = 0;
proto_tree_add_item(tree, hf_diameter_3gpp_sgsn_ipv6_addr, tvb, offset, 16, ENC_BIG_ENDIAN);
offset += 16;
return offset;
}
/* AVP Code: 600 Visited-Network-Identifier
@ -365,6 +379,21 @@ dissect_diameter_3gpp_mbms_required_qos(tvbuff_t *tvb, packet_info *pinfo, proto
}
/* AVP Code: 929 MBMS-Data-Transfer-Start */
/* AVP Code: 930 MBMS-Data-Transfer-Stop */
static int
dissect_diameter_3gpp_mbms_abs_time_ofmbms_data_tfer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
{
int offset = 0;
const gchar *time_str;
time_str = tvb_ntp_fmt_ts(tvb, offset);
proto_tree_add_string(tree, hf_diameter_3gpp_mbms_abs_time_ofmbms_data_tfer, tvb, offset, 8, time_str);
offset+=8;
return offset;
}
/* AVP Code: 1405 ULR-Flags */
static int
dissect_diameter_3gpp_ulr_flags(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree) {
@ -605,6 +634,9 @@ proto_reg_handoff_diameter_3gpp(void)
/* AVP Code: 5 3GPP-GPRS Negotiated QoS profile */
/* Registered by packet-gtp.c */
/* AVP Code: 15 3GPP-SGSN-IPv6-Address */
dissector_add_uint("diameter.3gpp", 15, new_create_dissector_handle(dissect_diameter_3gpp_sgsn_ipv6_addr, proto_diameter_3gpp));
/* AVP Code: 22 3GPP-User-Location-Info
* Registered by packet-gtpv2.c
*/
@ -648,6 +680,12 @@ proto_reg_handoff_diameter_3gpp(void)
/* AVP Code: 918 MBMS-BMSC-SSM-IP-Address */
dissector_add_uint("diameter.3gpp", 918, new_create_dissector_handle(dissect_diameter_3gpp_ipaddr, proto_diameter_3gpp));
/* AVP Code: 929 MBMS-Data-Transfer-Start */
dissector_add_uint("diameter.3gpp", 929, new_create_dissector_handle(dissect_diameter_3gpp_mbms_abs_time_ofmbms_data_tfer, proto_diameter_3gpp));
/* AVP Code: 930 MBMS-Data-Transfer-Stop */
dissector_add_uint("diameter.3gpp", 930, new_create_dissector_handle(dissect_diameter_3gpp_mbms_abs_time_ofmbms_data_tfer, proto_diameter_3gpp));
/* AVP Code: 1405 ULR-Flags */
dissector_add_uint("diameter.3gpp", 1405, new_create_dissector_handle(dissect_diameter_3gpp_ulr_flags, proto_diameter_3gpp));
@ -981,6 +1019,16 @@ proto_register_diameter_3gpp(void)
FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
NULL, HFILL }
},
{ &hf_diameter_3gpp_sgsn_ipv6_addr,
{ "SGSN IPv6 Address", "diameter.3gpp.sgsn_ipv6_addr",
FT_IPv6, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_diameter_3gpp_mbms_abs_time_ofmbms_data_tfer,
{ "Absolute Time of MBMS Data Transfer", "diameter.3gpp.mbms_abs_time_ofmbms_data_tfer",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
};
/* Setup protocol subtree array */

View File

@ -33,6 +33,7 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/asn1.h>
#include <epan/prefs.h>
#include "packet-gsm_map.h"
#include "packet-gsm_a_common.h"
@ -215,6 +216,7 @@ static int ett_nas_eps_cmn_add_info = -1;
/* Global variables */
static packet_info *gpinfo;
static gboolean g_nas_eps_dissect_plain = FALSE;
guint8 eps_nas_gen_msg_cont_type = 0;
@ -4491,6 +4493,56 @@ dissect_nas_eps_emm_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
}
}
static void
dissect_nas_eps_plain(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *item;
proto_tree *nas_eps_tree;
guint8 pd;
int offset = 0;
/* Save pinfo */
gpinfo = pinfo;
/* make entry in the Protocol column on summary display */
col_append_str(pinfo->cinfo, COL_PROTOCOL, "/NAS-EPS");
item = proto_tree_add_item(tree, proto_nas_eps, tvb, 0, -1, ENC_NA);
nas_eps_tree = proto_item_add_subtree(item, ett_nas_eps);
pd = tvb_get_guint8(tvb,offset)&0x0f;
switch (pd){
case 2:
/* EPS session management messages.
* Ref 3GPP TS 24.007 version 8.0.0 Release 8, Table 11.2: Protocol discriminator values
*/
disect_nas_eps_esm_msg(tvb, pinfo, nas_eps_tree, offset);
break;
case 7:
/* EPS mobility management messages.
* Ref 3GPP TS 24.007 version 8.0.0 Release 8, Table 11.2: Protocol discriminator values
*/
dissect_nas_eps_emm_msg(tvb, pinfo, nas_eps_tree, offset, TRUE);
break;
case 15:
/* Special conformance testing functions for User Equipment messages.
* Ref 3GPP TS 24.007 version 8.0.0 Release 8, Table 11.2: Protocol discriminator values
*/
if (gsm_a_dtap_handle){
tvbuff_t *new_tvb = tvb_new_subset_remaining(tvb, offset);
call_dissector(gsm_a_dtap_handle, new_tvb,pinfo, nas_eps_tree);
break;
} /* else fall through default */
default:
proto_tree_add_text(nas_eps_tree, tvb, offset, -1, "Not a NAS EPS PD %u(%s)",
pd,
val_to_str_const(pd, protocol_discriminator_vals, "unknown"));
break;
}
}
/* TS 24.301 8.2.1
* 9 General message format and information elements coding
* 9.1 Overview
@ -4532,9 +4584,21 @@ dissect_nas_eps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
guint32 len;
guint32 msg_auth_code;
len = tvb_length(tvb);
/* The protected NAS message header is 6 octets long, and the NAS message header is at least 2 octets long. */
/* If the length of the tvbuffer is less than 8 octets, we can safely conclude the message is not protected. */
if (len < 8) {
dissect_nas_eps_plain(tvb, pinfo, tree);
return;
}
if (g_nas_eps_dissect_plain) {
dissect_nas_eps_plain(tvb, pinfo, tree);
return;
}
/* Save pinfo */
gpinfo = pinfo;
len = tvb_length(tvb);
/* make entry in the Protocol column on summary display */
col_append_str(pinfo->cinfo, COL_PROTOCOL, "/NAS-EPS");
@ -4630,59 +4694,18 @@ dissect_nas_eps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
static void
dissect_nas_eps_plain(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
void
proto_reg_handoff_nas_eps(void)
{
proto_item *item;
proto_tree *nas_eps_tree;
guint8 pd;
int offset = 0;
/* Save pinfo */
gpinfo = pinfo;
/* make entry in the Protocol column on summary display */
col_append_str(pinfo->cinfo, COL_PROTOCOL, "/NAS-EPS");
item = proto_tree_add_item(tree, proto_nas_eps, tvb, 0, -1, ENC_NA);
nas_eps_tree = proto_item_add_subtree(item, ett_nas_eps);
pd = tvb_get_guint8(tvb,offset)&0x0f;
switch (pd){
case 2:
/* EPS session management messages.
* Ref 3GPP TS 24.007 version 8.0.0 Release 8, Table 11.2: Protocol discriminator values
*/
disect_nas_eps_esm_msg(tvb, pinfo, nas_eps_tree, offset);
break;
case 7:
/* EPS mobility management messages.
* Ref 3GPP TS 24.007 version 8.0.0 Release 8, Table 11.2: Protocol discriminator values
*/
dissect_nas_eps_emm_msg(tvb, pinfo, nas_eps_tree, offset, TRUE);
break;
case 15:
/* Special conformance testing functions for User Equipment messages.
* Ref 3GPP TS 24.007 version 8.0.0 Release 8, Table 11.2: Protocol discriminator values
*/
if (gsm_a_dtap_handle){
tvbuff_t *new_tvb = tvb_new_subset_remaining(tvb, offset);
call_dissector(gsm_a_dtap_handle, new_tvb,pinfo, nas_eps_tree);
break;
} /* else fall through default */
default:
proto_tree_add_text(nas_eps_tree, tvb, offset, -1, "Not a NAS EPS PD %u(%s)",
pd,
val_to_str_const(pd, protocol_discriminator_vals, "unknown"));
break;
}
gsm_a_dtap_handle = find_dissector("gsm_a_dtap");
lpp_handle = find_dissector("lpp");
}
void
proto_register_nas_eps(void) {
guint i;
guint last_offset;
module_t *nas_eps_module;
/* List of fields */
@ -5464,11 +5487,9 @@ proto_register_nas_eps(void) {
/* Register dissector */
register_dissector("nas-eps_plain", dissect_nas_eps_plain, proto_nas_eps);
}
void
proto_reg_handoff_nas_eps(void)
{
gsm_a_dtap_handle = find_dissector("gsm_a_dtap");
lpp_handle = find_dissector("lpp");
/* Register configuration options to always dissect as plain messages */
nas_eps_module = prefs_register_protocol(proto_nas_eps, proto_reg_handoff_nas_eps);
prefs_register_bool_preference(nas_eps_module, "dissect_plain", "Force dissect as plain NAS EPS", "Always dissect NAS EPS messages as plain", &g_nas_eps_dissect_plain);
}