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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 * Ref: 3GPP TS 25.469 version 8.4.0 Release 8
35 #include <epan/packet.h>
36 #include <epan/sctpppids.h>
37 #include <epan/asn1.h>
38 #include <epan/prefs.h>
40 #include "packet-per.h"
43 /* disable: "warning C4146: unary minus operator applied to unsigned type, result still unsigned" */
44 #pragma warning(disable:4146)
47 #define PNAME "UTRAN Iuh interface HNBAP signalling"
48 #define PSNAME "HNBAP"
49 #define PFNAME "hnbap"
50 /* Dissector will use SCTP PPID 20 or SCTP port. IANA assigned port = 29169*/
51 #define SCTP_PORT_HNBAP 29169
53 #include "packet-hnbap-val.h"
55 /* Initialize the protocol and registered fields */
56 static int proto_hnbap = -1;
58 #include "packet-hnbap-hf.c"
60 /* Initialize the subtree pointers */
61 static int ett_hnbap = -1;
63 #include "packet-hnbap-ett.c"
65 /* Global variables */
66 static guint32 ProcedureCode;
67 static guint32 ProtocolIE_ID;
68 static guint global_sctp_port = SCTP_PORT_HNBAP;
70 /* Dissector tables */
71 static dissector_table_t hnbap_ies_dissector_table;
72 static dissector_table_t hnbap_extension_dissector_table;
73 static dissector_table_t hnbap_proc_imsg_dissector_table;
74 static dissector_table_t hnbap_proc_sout_dissector_table;
75 static dissector_table_t hnbap_proc_uout_dissector_table;
77 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
78 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
79 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
80 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
81 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
82 void proto_reg_handoff_hnbap(void);
84 #include "packet-hnbap-fn.c"
86 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
88 return (dissector_try_uint_new(hnbap_ies_dissector_table, ProtocolIE_ID, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0;
91 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
93 return (dissector_try_uint_new(hnbap_extension_dissector_table, ProtocolIE_ID, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0;
96 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
98 if (!ProcedureCode) return 0;
99 return (dissector_try_string(hnbap_proc_imsg_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
102 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
104 if (!ProcedureCode) return 0;
105 return (dissector_try_string(hnbap_proc_sout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
108 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
110 if (!ProcedureCode) return 0;
111 return (dissector_try_string(hnbap_proc_uout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
115 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
117 return (dissector_try_uint_new(hnbap_proc_imsg_dissector_table, ProcedureCode, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0;
120 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
122 return (dissector_try_uint_new(hnbap_proc_sout_dissector_table, ProcedureCode, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0;
125 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
127 return (dissector_try_uint_new(hnbap_proc_uout_dissector_table, ProcedureCode, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0;
131 dissect_hnbap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
133 proto_item *hnbap_item = NULL;
134 proto_tree *hnbap_tree = NULL;
136 /* make entry in the Protocol column on summary display */
137 col_set_str(pinfo->cinfo, COL_PROTOCOL, "HNBAP");
139 /* create the hnbap protocol tree */
140 hnbap_item = proto_tree_add_item(tree, proto_hnbap, tvb, 0, -1, FALSE);
141 hnbap_tree = proto_item_add_subtree(hnbap_item, ett_hnbap);
143 dissect_HNBAP_PDU_PDU(tvb, pinfo, hnbap_tree);
146 /*--- proto_register_hnbap -------------------------------------------*/
147 void proto_register_hnbap(void) {
148 module_t *hnbap_module;
152 static hf_register_info hf[] = {
154 #include "packet-hnbap-hfarr.c"
157 /* List of subtrees */
158 static gint *ett[] = {
160 #include "packet-hnbap-ettarr.c"
164 /* Register protocol */
165 proto_hnbap = proto_register_protocol(PNAME, PSNAME, PFNAME);
166 /* Register fields and subtrees */
167 proto_register_field_array(proto_hnbap, hf, array_length(hf));
168 proto_register_subtree_array(ett, array_length(ett));
170 /* Register dissector */
171 register_dissector("hnbap", dissect_hnbap, proto_hnbap);
173 /* Register dissector tables */
174 hnbap_ies_dissector_table = register_dissector_table("hnbap.ies", "HNBAP-PROTOCOL-IES", FT_UINT32, BASE_DEC);
175 hnbap_extension_dissector_table = register_dissector_table("hnbap.extension", "HNBAP-PROTOCOL-EXTENSION", FT_UINT32, BASE_DEC);
176 hnbap_proc_imsg_dissector_table = register_dissector_table("hnbap.proc.imsg", "HNBAP-ELEMENTARY-PROCEDURE InitiatingMessage", FT_UINT32, BASE_DEC);
177 hnbap_proc_sout_dissector_table = register_dissector_table("hnbap.proc.sout", "HNBAP-ELEMENTARY-PROCEDURE SuccessfulOutcome", FT_UINT32, BASE_DEC);
178 hnbap_proc_uout_dissector_table = register_dissector_table("hnbap.proc.uout", "HNBAP-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", FT_UINT32, BASE_DEC);
180 hnbap_module = prefs_register_protocol(proto_hnbap, proto_reg_handoff_hnbap);
181 prefs_register_uint_preference(hnbap_module, "port", "HNBAP SCTP Port", "Set the port for HNBAP messages (Default of 29169)", 10, &global_sctp_port);
185 /*--- proto_reg_handoff_hnbap ---------------------------------------*/
187 proto_reg_handoff_hnbap(void)
189 static gboolean initialized = FALSE;
190 static dissector_handle_t hnbap_handle;
191 static guint sctp_port;
194 hnbap_handle = find_dissector("hnbap");
195 dissector_add_uint("sctp.ppi", HNBAP_PAYLOAD_PROTOCOL_ID, hnbap_handle);
197 #include "packet-hnbap-dis-tab.c"
200 dissector_delete_uint("sctp.port", sctp_port, hnbap_handle);
202 /* Set our port number for future use */
203 sctp_port = global_sctp_port;
204 dissector_add_uint("sctp.port", sctp_port, hnbap_handle);