1 /* packet-hnbap-template.c
2 * Routines for UMTS Node B Application Part(HNBAP) packet dissection
3 * Copyright 2010 Neil Piercy, ip.access Limited <Neil.Piercy@ipaccess.com>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 * Ref: 3GPP TS 25.469 version 8.4.0 Release 8
33 #include <epan/packet.h>
34 #include <epan/sctpppids.h>
35 #include <epan/asn1.h>
36 #include <epan/prefs.h>
38 #include "packet-per.h"
41 /* disable: "warning C4146: unary minus operator applied to unsigned type, result still unsigned" */
42 #pragma warning(disable:4146)
45 #define PNAME "UTRAN Iuh interface HNBAP signalling"
46 #define PSNAME "HNBAP"
47 #define PFNAME "hnbap"
48 /* Dissector will use SCTP PPID 20 or SCTP port. IANA assigned port = 29169*/
49 #define SCTP_PORT_HNBAP 29169
51 #include "packet-hnbap-val.h"
53 /* Initialize the protocol and registered fields */
54 static int proto_hnbap = -1;
56 #include "packet-hnbap-hf.c"
58 /* Initialize the subtree pointers */
59 static int ett_hnbap = -1;
61 #include "packet-hnbap-ett.c"
63 /* Global variables */
64 static guint32 ProcedureCode;
65 static guint32 ProtocolIE_ID;
66 static guint global_sctp_port = SCTP_PORT_HNBAP;
68 /* Dissector tables */
69 static dissector_table_t hnbap_ies_dissector_table;
70 static dissector_table_t hnbap_extension_dissector_table;
71 static dissector_table_t hnbap_proc_imsg_dissector_table;
72 static dissector_table_t hnbap_proc_sout_dissector_table;
73 static dissector_table_t hnbap_proc_uout_dissector_table;
75 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
76 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
77 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
78 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
79 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
80 void proto_reg_handoff_hnbap(void);
82 #include "packet-hnbap-fn.c"
84 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
86 return (dissector_try_uint_new(hnbap_ies_dissector_table, ProtocolIE_ID, tvb, pinfo, tree, FALSE, NULL)) ? tvb_length(tvb) : 0;
89 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
91 return (dissector_try_uint_new(hnbap_extension_dissector_table, ProtocolIE_ID, tvb, pinfo, tree, FALSE, NULL)) ? tvb_length(tvb) : 0;
94 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
96 if (!ProcedureCode) return 0;
97 return (dissector_try_string(hnbap_proc_imsg_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
100 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
102 if (!ProcedureCode) return 0;
103 return (dissector_try_string(hnbap_proc_sout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
106 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
108 if (!ProcedureCode) return 0;
109 return (dissector_try_string(hnbap_proc_uout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
113 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
115 return (dissector_try_uint_new(hnbap_proc_imsg_dissector_table, ProcedureCode, tvb, pinfo, tree, FALSE, NULL)) ? tvb_length(tvb) : 0;
118 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
120 return (dissector_try_uint_new(hnbap_proc_sout_dissector_table, ProcedureCode, tvb, pinfo, tree, FALSE, NULL)) ? tvb_length(tvb) : 0;
123 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
125 return (dissector_try_uint_new(hnbap_proc_uout_dissector_table, ProcedureCode, tvb, pinfo, tree, FALSE, NULL)) ? tvb_length(tvb) : 0;
129 dissect_hnbap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
131 proto_item *hnbap_item = NULL;
132 proto_tree *hnbap_tree = NULL;
134 /* make entry in the Protocol column on summary display */
135 col_set_str(pinfo->cinfo, COL_PROTOCOL, "HNBAP");
137 /* create the hnbap protocol tree */
138 hnbap_item = proto_tree_add_item(tree, proto_hnbap, tvb, 0, -1, ENC_NA);
139 hnbap_tree = proto_item_add_subtree(hnbap_item, ett_hnbap);
141 dissect_HNBAP_PDU_PDU(tvb, pinfo, hnbap_tree);
144 /*--- proto_register_hnbap -------------------------------------------*/
145 void proto_register_hnbap(void) {
146 module_t *hnbap_module;
150 static hf_register_info hf[] = {
152 #include "packet-hnbap-hfarr.c"
155 /* List of subtrees */
156 static gint *ett[] = {
158 #include "packet-hnbap-ettarr.c"
162 /* Register protocol */
163 proto_hnbap = proto_register_protocol(PNAME, PSNAME, PFNAME);
164 /* Register fields and subtrees */
165 proto_register_field_array(proto_hnbap, hf, array_length(hf));
166 proto_register_subtree_array(ett, array_length(ett));
168 /* Register dissector */
169 register_dissector("hnbap", dissect_hnbap, proto_hnbap);
171 /* Register dissector tables */
172 hnbap_ies_dissector_table = register_dissector_table("hnbap.ies", "HNBAP-PROTOCOL-IES", FT_UINT32, BASE_DEC);
173 hnbap_extension_dissector_table = register_dissector_table("hnbap.extension", "HNBAP-PROTOCOL-EXTENSION", FT_UINT32, BASE_DEC);
174 hnbap_proc_imsg_dissector_table = register_dissector_table("hnbap.proc.imsg", "HNBAP-ELEMENTARY-PROCEDURE InitiatingMessage", FT_UINT32, BASE_DEC);
175 hnbap_proc_sout_dissector_table = register_dissector_table("hnbap.proc.sout", "HNBAP-ELEMENTARY-PROCEDURE SuccessfulOutcome", FT_UINT32, BASE_DEC);
176 hnbap_proc_uout_dissector_table = register_dissector_table("hnbap.proc.uout", "HNBAP-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", FT_UINT32, BASE_DEC);
178 hnbap_module = prefs_register_protocol(proto_hnbap, proto_reg_handoff_hnbap);
179 prefs_register_uint_preference(hnbap_module, "port", "HNBAP SCTP Port", "Set the port for HNBAP messages (Default of 29169)", 10, &global_sctp_port);
183 /*--- proto_reg_handoff_hnbap ---------------------------------------*/
185 proto_reg_handoff_hnbap(void)
187 static gboolean initialized = FALSE;
188 static dissector_handle_t hnbap_handle;
189 static guint sctp_port;
192 hnbap_handle = find_dissector("hnbap");
193 dissector_add_uint("sctp.ppi", HNBAP_PAYLOAD_PROTOCOL_ID, hnbap_handle);
195 #include "packet-hnbap-dis-tab.c"
198 dissector_delete_uint("sctp.port", sctp_port, hnbap_handle);
200 /* Set our port number for future use */
201 sctp_port = global_sctp_port;
202 dissector_add_uint("sctp.port", sctp_port, hnbap_handle);