2 * Routines for UTRAN Iupc interface Positioning Calculation Application Part (PCAP) packet dissection
4 * Copyright 2008, Anders Broman <anders.broman@ericsson.com>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 * Based on the RANAP dissector
28 * References: ETSI TS 125 453 V7.9.0 (2008-02)
36 #include <epan/packet.h>
37 #include <epan/prefs.h>
39 #include <epan/strutil.h>
40 #include <epan/asn1.h>
42 #include "packet-ber.h"
43 #include "packet-per.h"
44 #include "packet-sccp.h"
47 /* disable: "warning C4146: unary minus operator applied to unsigned type, result still unsigned" */
48 #pragma warning(disable:4146)
51 #define PNAME "UTRAN Iupc interface Positioning Calculation Application Part (PCAP)"
56 static range_t *global_ssn_range;
58 static dissector_table_t sccp_ssn_table;
60 #include "packet-pcap-val.h"
62 static dissector_handle_t pcap_handle = NULL;
64 /* Initialize the protocol and registered fields */
65 static int proto_pcap = -1;
67 #include "packet-pcap-hf.c"
69 /* Initialize the subtree pointers */
70 static int ett_pcap = -1;
72 #include "packet-pcap-ett.c"
74 /* Global variables */
75 static guint32 ProcedureCode;
76 static guint32 ProtocolIE_ID;
77 static guint32 ProtocolExtensionID;
79 /* Dissector tables */
80 static dissector_table_t pcap_ies_dissector_table;
81 static dissector_table_t pcap_ies_p1_dissector_table;
82 static dissector_table_t pcap_ies_p2_dissector_table;
83 static dissector_table_t pcap_extension_dissector_table;
84 static dissector_table_t pcap_proc_imsg_dissector_table;
85 static dissector_table_t pcap_proc_sout_dissector_table;
86 static dissector_table_t pcap_proc_uout_dissector_table;
87 static dissector_table_t pcap_proc_out_dissector_table;
89 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
90 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
91 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
92 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
93 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
94 static int dissect_OutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
96 #include "packet-pcap-fn.c"
98 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
100 return (dissector_try_uint(pcap_ies_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
103 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
105 return (dissector_try_uint(pcap_extension_dissector_table, ProtocolExtensionID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
108 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
110 return (dissector_try_uint(pcap_proc_imsg_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
113 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
115 return (dissector_try_uint(pcap_proc_sout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
118 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
120 return (dissector_try_uint(pcap_proc_uout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
123 static int dissect_OutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
125 return (dissector_try_uint(pcap_proc_out_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
129 dissect_pcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
131 proto_item *pcap_item = NULL;
132 proto_tree *pcap_tree = NULL;
134 /* make entry in the Protocol column on summary display */
135 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PCAP");
137 /* create the pcap protocol tree */
138 pcap_item = proto_tree_add_item(tree, proto_pcap, tvb, 0, -1, FALSE);
139 pcap_tree = proto_item_add_subtree(pcap_item, ett_pcap);
141 dissect_PCAP_PDU_PDU(tvb, pinfo, pcap_tree);
145 static void range_delete_callback(guint32 ssn)
148 dissector_delete_uint("sccp.ssn", ssn, pcap_handle);
152 static void range_add_callback(guint32 ssn)
155 dissector_add_uint("sccp.ssn", ssn, pcap_handle);
159 /*--- proto_reg_handoff_pcap ---------------------------------------*/
161 proto_reg_handoff_pcap(void)
163 static gboolean prefs_initialized = FALSE;
164 static range_t *ssn_range;
166 if (! prefs_initialized) {
167 pcap_handle = find_dissector("pcap");
168 sccp_ssn_table = find_dissector_table("sccp.ssn");
169 prefs_initialized = TRUE;
170 #include "packet-pcap-dis-tab.c"
172 range_foreach(ssn_range, range_delete_callback);
175 ssn_range = range_copy(global_ssn_range);
176 range_foreach(ssn_range, range_add_callback);
179 /*--- proto_register_pcap -------------------------------------------*/
180 void proto_register_pcap(void) {
184 static hf_register_info hf[] = {
186 #include "packet-pcap-hfarr.c"
189 /* List of subtrees */
190 static gint *ett[] = {
192 #include "packet-pcap-ettarr.c"
195 module_t *pcap_module;
197 /* Register protocol */
198 proto_pcap = proto_register_protocol(PNAME, PSNAME, PFNAME);
199 /* Register fields and subtrees */
200 proto_register_field_array(proto_pcap, hf, array_length(hf));
201 proto_register_subtree_array(ett, array_length(ett));
203 pcap_module = prefs_register_protocol(proto_pcap, proto_reg_handoff_pcap);
205 /* Register dissector */
206 register_dissector("pcap", dissect_pcap, proto_pcap);
208 /* Register dissector tables */
209 pcap_ies_dissector_table = register_dissector_table("pcap.ies", "PCAP-PROTOCOL-IES", FT_UINT32, BASE_DEC);
210 pcap_ies_p1_dissector_table = register_dissector_table("pcap.ies.pair.first", "PCAP-PROTOCOL-IES-PAIR FirstValue", FT_UINT32, BASE_DEC);
211 pcap_ies_p2_dissector_table = register_dissector_table("pcap.ies.pair.second", "PCAP-PROTOCOL-IES-PAIR SecondValue", FT_UINT32, BASE_DEC);
212 pcap_extension_dissector_table = register_dissector_table("pcap.extension", "PCAP-PROTOCOL-EXTENSION", FT_UINT32, BASE_DEC);
213 pcap_proc_imsg_dissector_table = register_dissector_table("pcap.proc.imsg", "PCAP-ELEMENTARY-PROCEDURE InitiatingMessage", FT_UINT32, BASE_DEC);
214 pcap_proc_sout_dissector_table = register_dissector_table("pcap.proc.sout", "PCAP-ELEMENTARY-PROCEDURE SuccessfulOutcome", FT_UINT32, BASE_DEC);
215 pcap_proc_uout_dissector_table = register_dissector_table("pcap.proc.uout", "PCAP-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", FT_UINT32, BASE_DEC);
216 pcap_proc_out_dissector_table = register_dissector_table("pcap.proc.out", "PCAP-ELEMENTARY-PROCEDURE Outcome", FT_UINT32, BASE_DEC);
220 /* Set default SSNs */
221 range_convert_str(&global_ssn_range, "", MAX_SSN);
223 prefs_register_range_preference(pcap_module, "ssn", "SCCP SSNs",
224 "SCCP (and SUA) SSNs to decode as PCAP",
225 &global_ssn_range, MAX_SSN);