1 /* packet-rua-template.c
2 * Routines for UMTS Home Node B RANAP User Adaptation (RUA) 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.468 version 8.1.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 RUA signalling"
50 /* Dissector to use SCTP PPID 19 or a configured SCTP port. IANA assigned port = 29169*/
51 #define SCTP_PORT_RUA 29169;
53 #include "packet-rua-val.h"
55 /* Initialize the protocol and registered fields */
56 static int proto_rua = -1;
58 #include "packet-rua-hf.c"
60 /* Initialize the subtree pointers */
61 static int ett_rua = -1;
63 /* initialise sub-dissector handles */
64 static dissector_handle_t ranap_handle = NULL;
66 #include "packet-rua-ett.c"
68 /* Global variables */
69 static guint32 ProcedureCode;
70 static guint32 ProtocolIE_ID;
71 static guint global_sctp_port = SCTP_PORT_RUA;
73 /* Dissector tables */
74 static dissector_table_t rua_ies_dissector_table;
75 static dissector_table_t rua_extension_dissector_table;
76 static dissector_table_t rua_proc_imsg_dissector_table;
77 static dissector_table_t rua_proc_sout_dissector_table;
78 static dissector_table_t rua_proc_uout_dissector_table;
80 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
81 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
82 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
83 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
84 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
86 void proto_reg_handoff_rua(void);
88 #include "packet-rua-fn.c"
90 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
92 return (dissector_try_uint_new(rua_ies_dissector_table, ProtocolIE_ID, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0;
95 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
97 return (dissector_try_uint_new(rua_extension_dissector_table, ProtocolIE_ID, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0;
100 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
102 return (dissector_try_uint_new(rua_proc_imsg_dissector_table, ProcedureCode, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0;
105 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
107 return (dissector_try_uint_new(rua_proc_sout_dissector_table, ProcedureCode, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0;
110 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
112 return (dissector_try_uint_new(rua_proc_uout_dissector_table, ProcedureCode, tvb, pinfo, tree, FALSE)) ? tvb_length(tvb) : 0;
116 dissect_rua(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
118 proto_item *rua_item = NULL;
119 proto_tree *rua_tree = NULL;
121 /* make entry in the Protocol column on summary display */
122 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RUA");
124 /* create the rua protocol tree */
125 rua_item = proto_tree_add_item(tree, proto_rua, tvb, 0, -1, ENC_NA);
126 rua_tree = proto_item_add_subtree(rua_item, ett_rua);
128 dissect_RUA_PDU_PDU(tvb, pinfo, rua_tree);
131 /*--- proto_register_rua -------------------------------------------*/
132 void proto_register_rua(void) {
133 module_t *rua_module;
137 static hf_register_info hf[] = {
139 #include "packet-rua-hfarr.c"
142 /* List of subtrees */
143 static gint *ett[] = {
145 #include "packet-rua-ettarr.c"
149 /* Register protocol */
150 proto_rua = proto_register_protocol(PNAME, PSNAME, PFNAME);
151 /* Register fields and subtrees */
152 proto_register_field_array(proto_rua, hf, array_length(hf));
153 proto_register_subtree_array(ett, array_length(ett));
155 /* Register dissector */
156 register_dissector("rua", dissect_rua, proto_rua);
158 /* Register dissector tables */
159 rua_ies_dissector_table = register_dissector_table("rua.ies", "RUA-PROTOCOL-IES", FT_UINT32, BASE_DEC);
160 rua_extension_dissector_table = register_dissector_table("rua.extension", "RUA-PROTOCOL-EXTENSION", FT_UINT32, BASE_DEC);
161 rua_proc_imsg_dissector_table = register_dissector_table("rua.proc.imsg", "RUA-ELEMENTARY-PROCEDURE InitiatingMessage", FT_UINT32, BASE_DEC);
162 rua_proc_sout_dissector_table = register_dissector_table("rua.proc.sout", "RUA-ELEMENTARY-PROCEDURE SuccessfulOutcome", FT_UINT32, BASE_DEC);
163 rua_proc_uout_dissector_table = register_dissector_table("rua.proc.uout", "RUA-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", FT_UINT32, BASE_DEC);
165 rua_module = prefs_register_protocol(proto_rua, proto_reg_handoff_rua);
166 prefs_register_uint_preference(rua_module, "port", "RUA SCTP Port", "Set the port for RUA messages (Default of 29169)", 10, &global_sctp_port);
171 /*--- proto_reg_handoff_rua ---------------------------------------*/
173 proto_reg_handoff_rua(void)
175 static gboolean initialized = FALSE;
176 static dissector_handle_t rua_handle;
177 static guint sctp_port;
180 rua_handle = find_dissector("rua");
181 ranap_handle = find_dissector("ranap");
182 dissector_add_uint("sctp.ppi", RUA_PAYLOAD_PROTOCOL_ID, rua_handle);
184 #include "packet-rua-dis-tab.c"
187 dissector_delete_uint("sctp.port", sctp_port, rua_handle);
189 /* Set our port number for future use */
190 sctp_port = global_sctp_port;
191 dissector_add_uint("sctp.port", sctp_port, rua_handle);