/* packet-hnbap-template.c * Routines for UMTS Node B Application Part(HNBAP) packet dissection * Copyright 2010 Neil Piercy, ip.access Limited * * Wireshark - Network traffic analyzer * By Gerald Combs * Copyright 1998 Gerald Combs * * SPDX-License-Identifier: GPL-2.0-or-later * * Ref: 3GPP TS 25.469 version 8.4.0 Release 8 */ #include "config.h" #include #include #include #include #include #include "packet-per.h" #include "packet-e212.h" #ifdef _MSC_VER /* disable: "warning C4146: unary minus operator applied to unsigned type, result still unsigned" */ #pragma warning(disable:4146) #endif #define PNAME "UTRAN Iuh interface HNBAP signalling" #define PSNAME "HNBAP" #define PFNAME "hnbap" /* Dissector will use SCTP PPID 20 or SCTP port. IANA assigned port = 29169*/ #define SCTP_PORT_HNBAP 29169 void proto_register_hnbap(void); #include "packet-hnbap-val.h" /* Initialize the protocol and registered fields */ static int proto_hnbap = -1; #include "packet-hnbap-hf.c" /* Initialize the subtree pointers */ static int ett_hnbap = -1; static int ett_hnbap_imsi = -1; #include "packet-hnbap-ett.c" struct hnbap_private_data { e212_number_type_t number_type; }; /* Global variables */ static guint32 ProcedureCode; static guint32 ProtocolIE_ID; /* Dissector tables */ static dissector_table_t hnbap_ies_dissector_table; static dissector_table_t hnbap_extension_dissector_table; static dissector_table_t hnbap_proc_imsg_dissector_table; static dissector_table_t hnbap_proc_sout_dissector_table; static dissector_table_t hnbap_proc_uout_dissector_table; static dissector_handle_t hnbap_handle; static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *); static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *); static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *); static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *); static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *); void proto_reg_handoff_hnbap(void); static struct hnbap_private_data* hnbap_get_private_data(packet_info *pinfo) { struct hnbap_private_data *hnbap_data = (struct hnbap_private_data*)p_get_proto_data(pinfo->pool, pinfo, proto_hnbap, 0); if (!hnbap_data) { hnbap_data = wmem_new0(pinfo->pool, struct hnbap_private_data); p_add_proto_data(pinfo->pool, pinfo, proto_hnbap, 0, hnbap_data); } return hnbap_data; } #include "packet-hnbap-fn.c" static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { return (dissector_try_uint_new(hnbap_ies_dissector_table, ProtocolIE_ID, tvb, pinfo, tree, FALSE, NULL)) ? tvb_captured_length(tvb) : 0; } static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { return (dissector_try_uint_new(hnbap_extension_dissector_table, ProtocolIE_ID, tvb, pinfo, tree, FALSE, NULL)) ? tvb_captured_length(tvb) : 0; } #if 0 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { if (!ProcedureCode) return 0; return (dissector_try_string(hnbap_proc_imsg_dissector_table, ProcedureCode, tvb, pinfo, tree, NULL)) ? tvb_captured_length(tvb) : 0; } static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { if (!ProcedureCode) return 0; return (dissector_try_string(hnbap_proc_sout_dissector_table, ProcedureCode, tvb, pinfo, tree, NULL)) ? tvb_captured_length(tvb) : 0; } static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { if (!ProcedureCode) return 0; return (dissector_try_string(hnbap_proc_uout_dissector_table, ProcedureCode, tvb, pinfo, tree, NULL)) ? tvb_captured_length(tvb) : 0; } #endif static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { return (dissector_try_uint_new(hnbap_proc_imsg_dissector_table, ProcedureCode, tvb, pinfo, tree, FALSE, NULL)) ? tvb_captured_length(tvb) : 0; } static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { return (dissector_try_uint_new(hnbap_proc_sout_dissector_table, ProcedureCode, tvb, pinfo, tree, FALSE, NULL)) ? tvb_captured_length(tvb) : 0; } static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { return (dissector_try_uint_new(hnbap_proc_uout_dissector_table, ProcedureCode, tvb, pinfo, tree, FALSE, NULL)) ? tvb_captured_length(tvb) : 0; } static int dissect_hnbap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { proto_item *hnbap_item = NULL; proto_tree *hnbap_tree = NULL; /* make entry in the Protocol column on summary display */ col_set_str(pinfo->cinfo, COL_PROTOCOL, "HNBAP"); /* create the hnbap protocol tree */ hnbap_item = proto_tree_add_item(tree, proto_hnbap, tvb, 0, -1, ENC_NA); hnbap_tree = proto_item_add_subtree(hnbap_item, ett_hnbap); return dissect_HNBAP_PDU_PDU(tvb, pinfo, hnbap_tree, data); } /*--- proto_register_hnbap -------------------------------------------*/ void proto_register_hnbap(void) { /* List of fields */ static hf_register_info hf[] = { #include "packet-hnbap-hfarr.c" }; /* List of subtrees */ static gint *ett[] = { &ett_hnbap, &ett_hnbap_imsi, #include "packet-hnbap-ettarr.c" }; /* Register protocol */ proto_hnbap = proto_register_protocol(PNAME, PSNAME, PFNAME); /* Register fields and subtrees */ proto_register_field_array(proto_hnbap, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); /* Register dissector */ hnbap_handle = register_dissector("hnbap", dissect_hnbap, proto_hnbap); /* Register dissector tables */ hnbap_ies_dissector_table = register_dissector_table("hnbap.ies", "HNBAP-PROTOCOL-IES", proto_hnbap, FT_UINT32, BASE_DEC); hnbap_extension_dissector_table = register_dissector_table("hnbap.extension", "HNBAP-PROTOCOL-EXTENSION", proto_hnbap, FT_UINT32, BASE_DEC); hnbap_proc_imsg_dissector_table = register_dissector_table("hnbap.proc.imsg", "HNBAP-ELEMENTARY-PROCEDURE InitiatingMessage", proto_hnbap, FT_UINT32, BASE_DEC); hnbap_proc_sout_dissector_table = register_dissector_table("hnbap.proc.sout", "HNBAP-ELEMENTARY-PROCEDURE SuccessfulOutcome", proto_hnbap, FT_UINT32, BASE_DEC); hnbap_proc_uout_dissector_table = register_dissector_table("hnbap.proc.uout", "HNBAP-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", proto_hnbap, FT_UINT32, BASE_DEC); /* hnbap_module = prefs_register_protocol(proto_hnbap, NULL); */ } /*--- proto_reg_handoff_hnbap ---------------------------------------*/ void proto_reg_handoff_hnbap(void) { dissector_add_uint("sctp.ppi", HNBAP_PAYLOAD_PROTOCOL_ID, hnbap_handle); dissector_add_uint_with_preference("sctp.port", SCTP_PORT_HNBAP, hnbap_handle); #include "packet-hnbap-dis-tab.c" }