diff options
Diffstat (limited to 'asn1/ranap/packet-ranap-template.c')
-rw-r--r-- | asn1/ranap/packet-ranap-template.c | 80 |
1 files changed, 70 insertions, 10 deletions
diff --git a/asn1/ranap/packet-ranap-template.c b/asn1/ranap/packet-ranap-template.c index f9eb6be7ff..9d62d9f60b 100644 --- a/asn1/ranap/packet-ranap-template.c +++ b/asn1/ranap/packet-ranap-template.c @@ -57,6 +57,9 @@ #define PSNAME "RANAP" #define PFNAME "ranap" +/* Higest Ranap_ProcedureCode_value, use in heuristics */ +#define RANAP_MAX_PC 45 /* id_RANAPenhancedRelocation = 45 */ + #include "packet-ranap-val.h" /* Initialize the protocol and registered fields */ @@ -66,10 +69,14 @@ static int proto_ranap = -1; static dissector_handle_t rrc_handle = NULL; static int hf_ranap_imsi_digits = -1; +static int hf_ranap_transportLayerAddress_ipv4 = -1; +static int hf_ranap_transportLayerAddress_ipv6 = -1; + #include "packet-ranap-hf.c" /* Initialize the subtree pointers */ static int ett_ranap = -1; +static int ett_ranap_TransportLayerAddress = -1; #include "packet-ranap-ett.c" @@ -126,12 +133,12 @@ static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto int ret; - ret = (dissector_try_port(ranap_ies_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0; + ret = (dissector_try_port_new(ranap_ies_dissector_table, ProtocolIE_ID, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0; if (ret == 0) { int key = pdu_type || ProtocolIE_ID; - ret = (dissector_try_port(ranap_ies_dissector_table, key, tvb, pinfo, tree)) ? tvb_length(tvb) : 0; + ret = (dissector_try_port_new(ranap_ies_dissector_table, key, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0; } @@ -140,41 +147,41 @@ static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto static int dissect_ProtocolIEFieldPairFirstValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - return (dissector_try_port(ranap_ies_p1_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0; + return (dissector_try_port_new(ranap_ies_p1_dissector_table, ProtocolIE_ID, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0; } static int dissect_ProtocolIEFieldPairSecondValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - return (dissector_try_port(ranap_ies_p2_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0; + return (dissector_try_port_new(ranap_ies_p2_dissector_table, ProtocolIE_ID, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0; } static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - return (dissector_try_port(ranap_extension_dissector_table, ProtocolExtensionID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0; + return (dissector_try_port_new(ranap_extension_dissector_table, ProtocolExtensionID, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0; } static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { pdu_type = IMSG; - return (dissector_try_port(ranap_proc_imsg_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0; + return (dissector_try_port_new(ranap_proc_imsg_dissector_table, ProcedureCode, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0; pdu_type = 0; } static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { pdu_type = SOUT; - return (dissector_try_port(ranap_proc_sout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0; + return (dissector_try_port_new(ranap_proc_sout_dissector_table, ProcedureCode, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0; pdu_type = 0; } static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - return (dissector_try_port(ranap_proc_uout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0; + return (dissector_try_port_new(ranap_proc_uout_dissector_table, ProcedureCode, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0; } static int dissect_OutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - return (dissector_try_port(ranap_proc_out_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0; + return (dissector_try_port_new(ranap_proc_out_dissector_table, ProcedureCode, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0; } static void @@ -207,6 +214,44 @@ dissect_ranap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } } +static gboolean +dissect_sccp_ranap_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + guint8 temp; + asn1_ctx_t asn1_ctx; + guint length; + int offset; + + asn1_ctx_init(&asn1_ctx, ASN1_ENC_PER, TRUE, pinfo); + + /* Is it a ranap packet? + * + * 4th octet should be the length of the rest of the message. + * 2nd octet is the message-type e Z[0, 28] + * (obviously there must be at least four octets) + * + * If both hold true we'll assume its RANAP + */ + + #define LENGTH_OFFSET 3 + #define MSG_TYPE_OFFSET 1 + if (tvb_length(tvb) < 4) { return FALSE; } + /*if (tvb_get_guint8(tvb, LENGTH_OFFSET) != (tvb_length(tvb) - 4)) { return FALSE; }*/ + /* Read the length NOTE offset in bits */ + offset = dissect_per_length_determinant(tvb, LENGTH_OFFSET<<3, &asn1_ctx, tree, -1, &length); + offset = offset>>3; + if (length!= (tvb_length(tvb) - offset)){ + return FALSE; + } + + temp = tvb_get_guint8(tvb, MSG_TYPE_OFFSET); + if (temp > RANAP_MAX_PC) { return FALSE; } + + dissect_ranap(tvb, pinfo, tree); + + return TRUE; +} + /*--- proto_register_ranap -------------------------------------------*/ void proto_register_ranap(void) { module_t *ranap_module; @@ -218,6 +263,15 @@ void proto_register_ranap(void) { { "IMSI digits", "ranap.imsi_digits", FT_STRING, BASE_NONE, NULL, 0, "IMSI digits", HFILL }}, + { &hf_ranap_transportLayerAddress_ipv4, + { "transportLayerAddress IPv4", "ranap.transportLayerAddress_ipv4", + FT_IPv4, BASE_NONE, NULL, 0, + NULL, HFILL }}, + { &hf_ranap_transportLayerAddress_ipv6, + { "transportLayerAddress IPv6", "ranap.transportLayerAddress_ipv6", + FT_IPv6, BASE_NONE, NULL, 0, + NULL, HFILL }}, + #include "packet-ranap-hfarr.c" }; @@ -225,6 +279,7 @@ void proto_register_ranap(void) { /* List of subtrees */ static gint *ett[] = { &ett_ranap, + &ett_ranap_TransportLayerAddress, #include "packet-ranap-ettarr.c" }; @@ -276,7 +331,12 @@ proto_reg_handoff_ranap(void) dissector_add("sccp.ssn", global_ranap_sccp_ssn, ranap_handle); local_ranap_sccp_ssn = global_ranap_sccp_ssn; - + /* Add heuristic dissector + * Perhaps we want a preference whether the heuristic dissector + * is or isn't enabled + */ + heur_dissector_add("sccp", dissect_sccp_ranap_heur, proto_ranap); + heur_dissector_add("sua", dissect_sccp_ranap_heur, proto_ranap); } |