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>
40 #include <epan/strutil.h>
41 #include <epan/asn1.h>
43 #include "packet-ber.h"
44 #include "packet-per.h"
45 #include "packet-sccp.h"
48 /* disable: "warning C4146: unary minus operator applied to unsigned type, result still unsigned" */
49 #pragma warning(disable:4146)
52 #define PNAME "UTRAN Iupc interface Positioning Calculation Application Part (PCAP)"
57 static range_t *global_ssn_range;
59 static dissector_table_t sccp_ssn_table;
61 #include "packet-pcap-val.h"
63 static dissector_handle_t pcap_handle = NULL;
65 /* Initialize the protocol and registered fields */
66 static int proto_pcap = -1;
68 #include "packet-pcap-hf.c"
70 /* Initialize the subtree pointers */
71 static int ett_pcap = -1;
73 #include "packet-pcap-ett.c"
75 /* Global variables */
76 static guint32 ProcedureCode;
77 static guint32 ProtocolIE_ID;
78 static guint32 ProtocolExtensionID;
80 /* Dissector tables */
81 static dissector_table_t pcap_ies_dissector_table;
82 static dissector_table_t pcap_ies_p1_dissector_table;
83 static dissector_table_t pcap_ies_p2_dissector_table;
84 static dissector_table_t pcap_extension_dissector_table;
85 static dissector_table_t pcap_proc_imsg_dissector_table;
86 static dissector_table_t pcap_proc_sout_dissector_table;
87 static dissector_table_t pcap_proc_uout_dissector_table;
88 static dissector_table_t pcap_proc_out_dissector_table;
90 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
91 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
92 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
93 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
94 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
95 static int dissect_OutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
97 #include "packet-pcap-fn.c"
99 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
101 return (dissector_try_port(pcap_ies_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
104 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
106 return (dissector_try_port(pcap_extension_dissector_table, ProtocolExtensionID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
109 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
111 return (dissector_try_port(pcap_proc_imsg_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
114 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
116 return (dissector_try_port(pcap_proc_sout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
119 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
121 return (dissector_try_port(pcap_proc_uout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
124 static int dissect_OutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
126 return (dissector_try_port(pcap_proc_out_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
130 dissect_pcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
132 proto_item *pcap_item = NULL;
133 proto_tree *pcap_tree = NULL;
135 /* make entry in the Protocol column on summary display */
136 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PCAP");
138 /* create the pcap protocol tree */
139 pcap_item = proto_tree_add_item(tree, proto_pcap, tvb, 0, -1, FALSE);
140 pcap_tree = proto_item_add_subtree(pcap_item, ett_pcap);
142 dissect_PCAP_PDU_PDU(tvb, pinfo, pcap_tree);
146 static void range_delete_callback(guint32 ssn)
149 dissector_delete("sccp.ssn", ssn, pcap_handle);
153 static void range_add_callback(guint32 ssn)
156 dissector_add("sccp.ssn", ssn, pcap_handle);
160 /*--- proto_reg_handoff_pcap ---------------------------------------*/
162 proto_reg_handoff_pcap(void)
164 static gboolean prefs_initialized = FALSE;
165 static range_t *ssn_range;
167 if (! prefs_initialized) {
168 pcap_handle = find_dissector("pcap");
169 sccp_ssn_table = find_dissector_table("sccp.ssn");
170 prefs_initialized = TRUE;
171 #include "packet-pcap-dis-tab.c"
173 range_foreach(ssn_range, range_delete_callback);
176 ssn_range = range_copy(global_ssn_range);
177 range_foreach(ssn_range, range_add_callback);
180 /*--- proto_register_pcap -------------------------------------------*/
181 void proto_register_pcap(void) {
185 static hf_register_info hf[] = {
187 #include "packet-pcap-hfarr.c"
190 /* List of subtrees */
191 static gint *ett[] = {
193 #include "packet-pcap-ettarr.c"
196 module_t *pcap_module;
198 /* Register protocol */
199 proto_pcap = proto_register_protocol(PNAME, PSNAME, PFNAME);
200 /* Register fields and subtrees */
201 proto_register_field_array(proto_pcap, hf, array_length(hf));
202 proto_register_subtree_array(ett, array_length(ett));
204 pcap_module = prefs_register_protocol(proto_pcap, proto_reg_handoff_pcap);
206 /* Register dissector */
207 register_dissector("pcap", dissect_pcap, proto_pcap);
209 /* Register dissector tables */
210 pcap_ies_dissector_table = register_dissector_table("pcap.ies", "PCAP-PROTOCOL-IES", FT_UINT32, BASE_DEC);
211 pcap_ies_p1_dissector_table = register_dissector_table("pcap.ies.pair.first", "PCAP-PROTOCOL-IES-PAIR FirstValue", FT_UINT32, BASE_DEC);
212 pcap_ies_p2_dissector_table = register_dissector_table("pcap.ies.pair.second", "PCAP-PROTOCOL-IES-PAIR SecondValue", FT_UINT32, BASE_DEC);
213 pcap_extension_dissector_table = register_dissector_table("pcap.extension", "PCAP-PROTOCOL-EXTENSION", FT_UINT32, BASE_DEC);
214 pcap_proc_imsg_dissector_table = register_dissector_table("pcap.proc.imsg", "PCAP-ELEMENTARY-PROCEDURE InitiatingMessage", FT_UINT32, BASE_DEC);
215 pcap_proc_sout_dissector_table = register_dissector_table("pcap.proc.sout", "PCAP-ELEMENTARY-PROCEDURE SuccessfulOutcome", FT_UINT32, BASE_DEC);
216 pcap_proc_uout_dissector_table = register_dissector_table("pcap.proc.uout", "PCAP-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", FT_UINT32, BASE_DEC);
217 pcap_proc_out_dissector_table = register_dissector_table("pcap.proc.out", "PCAP-ELEMENTARY-PROCEDURE Outcome", FT_UINT32, BASE_DEC);
221 /* Set default SSNs */
222 range_convert_str(&global_ssn_range, "", MAX_SSN);
224 prefs_register_range_preference(pcap_module, "ssn", "SCCP SSNs",
225 "SCCP (and SUA) SSNs to decode as PCAP",
226 &global_ssn_range, MAX_SSN);