2 * Routines for UTRAN Iupc interface Positioning Calculation Application Part (PCAP) packet dissection
4 * Copyright 2008, Anders Broman <anders.broman@ericsson.com>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * Based on the RANAP dissector
26 * References: ETSI TS 125 453 V7.9.0 (2008-02)
31 #include <epan/packet.h>
32 #include <epan/prefs.h>
34 #include <epan/strutil.h>
35 #include <epan/asn1.h>
37 #include "packet-ber.h"
38 #include "packet-per.h"
39 #include "packet-sccp.h"
42 /* disable: "warning C4146: unary minus operator applied to unsigned type, result still unsigned" */
43 #pragma warning(disable:4146)
46 #define PNAME "UTRAN Iupc interface Positioning Calculation Application Part (PCAP)"
52 void proto_register_pcap(void);
53 void proto_reg_handoff_pcap(void);
55 static range_t *global_ssn_range;
57 static dissector_table_t sccp_ssn_table;
59 #include "packet-pcap-val.h"
61 static dissector_handle_t pcap_handle = NULL;
63 /* Initialize the protocol and registered fields */
64 static int proto_pcap = -1;
66 #include "packet-pcap-hf.c"
68 /* Initialize the subtree pointers */
69 static int ett_pcap = -1;
71 #include "packet-pcap-ett.c"
73 /* Global variables */
74 static guint32 ProcedureCode;
75 static guint32 ProtocolIE_ID;
76 /*static guint32 ProtocolExtensionID;*/
78 /* Dissector tables */
79 static dissector_table_t pcap_ies_dissector_table;
80 static dissector_table_t pcap_ies_p1_dissector_table;
81 static dissector_table_t pcap_ies_p2_dissector_table;
82 static dissector_table_t pcap_extension_dissector_table;
83 static dissector_table_t pcap_proc_imsg_dissector_table;
84 static dissector_table_t pcap_proc_sout_dissector_table;
85 static dissector_table_t pcap_proc_uout_dissector_table;
86 static dissector_table_t pcap_proc_out_dissector_table;
88 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
89 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
90 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
91 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
92 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
93 static int dissect_OutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
95 #include "packet-pcap-fn.c"
97 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
99 return (dissector_try_uint(pcap_ies_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_captured_length(tvb) : 0;
102 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
104 return (dissector_try_uint(pcap_extension_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_captured_length(tvb) : 0;
107 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
109 return (dissector_try_uint(pcap_proc_imsg_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_captured_length(tvb) : 0;
112 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
114 return (dissector_try_uint(pcap_proc_sout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_captured_length(tvb) : 0;
117 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
119 return (dissector_try_uint(pcap_proc_uout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_captured_length(tvb) : 0;
122 static int dissect_OutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
124 return (dissector_try_uint(pcap_proc_out_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_captured_length(tvb) : 0;
128 dissect_pcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
130 proto_item *pcap_item = NULL;
131 proto_tree *pcap_tree = NULL;
133 /* make entry in the Protocol column on summary display */
134 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PCAP");
136 /* create the pcap protocol tree */
137 pcap_item = proto_tree_add_item(tree, proto_pcap, tvb, 0, -1, ENC_NA);
138 pcap_tree = proto_item_add_subtree(pcap_item, ett_pcap);
140 dissect_PCAP_PDU_PDU(tvb, pinfo, pcap_tree, NULL);
141 return tvb_captured_length(tvb);
144 /*--- proto_reg_handoff_pcap ---------------------------------------*/
146 proto_reg_handoff_pcap(void)
148 static gboolean prefs_initialized = FALSE;
149 static range_t *ssn_range;
151 if (! prefs_initialized) {
152 pcap_handle = find_dissector("pcap");
153 sccp_ssn_table = find_dissector_table("sccp.ssn");
154 prefs_initialized = TRUE;
155 #include "packet-pcap-dis-tab.c"
157 dissector_delete_uint_range("sccp.ssn", ssn_range, pcap_handle);
160 ssn_range = range_copy(global_ssn_range);
161 dissector_add_uint_range("sccp.ssn", ssn_range, pcap_handle);
164 /*--- proto_register_pcap -------------------------------------------*/
165 void proto_register_pcap(void) {
169 static hf_register_info hf[] = {
171 #include "packet-pcap-hfarr.c"
174 /* List of subtrees */
175 static gint *ett[] = {
177 #include "packet-pcap-ettarr.c"
180 module_t *pcap_module;
182 /* Register protocol */
183 proto_pcap = proto_register_protocol(PNAME, PSNAME, PFNAME);
184 /* Register fields and subtrees */
185 proto_register_field_array(proto_pcap, hf, array_length(hf));
186 proto_register_subtree_array(ett, array_length(ett));
188 pcap_module = prefs_register_protocol(proto_pcap, proto_reg_handoff_pcap);
190 /* Register dissector */
191 register_dissector("pcap", dissect_pcap, proto_pcap);
193 /* Register dissector tables */
194 pcap_ies_dissector_table = register_dissector_table("pcap.ies", "PCAP-PROTOCOL-IES", proto_pcap, FT_UINT32, BASE_DEC, DISSECTOR_TABLE_ALLOW_DUPLICATE);
195 pcap_ies_p1_dissector_table = register_dissector_table("pcap.ies.pair.first", "PCAP-PROTOCOL-IES-PAIR FirstValue", proto_pcap, FT_UINT32, BASE_DEC, DISSECTOR_TABLE_ALLOW_DUPLICATE);
196 pcap_ies_p2_dissector_table = register_dissector_table("pcap.ies.pair.second", "PCAP-PROTOCOL-IES-PAIR SecondValue", proto_pcap, FT_UINT32, BASE_DEC, DISSECTOR_TABLE_ALLOW_DUPLICATE);
197 pcap_extension_dissector_table = register_dissector_table("pcap.extension", "PCAP-PROTOCOL-EXTENSION", proto_pcap, FT_UINT32, BASE_DEC, DISSECTOR_TABLE_ALLOW_DUPLICATE);
198 pcap_proc_imsg_dissector_table = register_dissector_table("pcap.proc.imsg", "PCAP-ELEMENTARY-PROCEDURE InitiatingMessage", proto_pcap, FT_UINT32, BASE_DEC, DISSECTOR_TABLE_ALLOW_DUPLICATE);
199 pcap_proc_sout_dissector_table = register_dissector_table("pcap.proc.sout", "PCAP-ELEMENTARY-PROCEDURE SuccessfulOutcome", proto_pcap, FT_UINT32, BASE_DEC, DISSECTOR_TABLE_ALLOW_DUPLICATE);
200 pcap_proc_uout_dissector_table = register_dissector_table("pcap.proc.uout", "PCAP-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", proto_pcap, FT_UINT32, BASE_DEC, DISSECTOR_TABLE_ALLOW_DUPLICATE);
201 pcap_proc_out_dissector_table = register_dissector_table("pcap.proc.out", "PCAP-ELEMENTARY-PROCEDURE Outcome", proto_pcap, FT_UINT32, BASE_DEC, DISSECTOR_TABLE_ALLOW_DUPLICATE);
205 /* Set default SSNs */
206 range_convert_str(&global_ssn_range, "", MAX_SSN);
208 prefs_register_range_preference(pcap_module, "ssn", "SCCP SSNs",
209 "SCCP (and SUA) SSNs to decode as PCAP",
210 &global_ssn_range, MAX_SSN);