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 * SPDX-License-Identifier: GPL-2.0-or-later
12 * Based on the RANAP dissector
14 * References: ETSI TS 125 453 V17.0.0 (2022-04)
19 #include <epan/packet.h>
20 #include <epan/prefs.h>
21 #include <wsutil/array.h>
23 #include <epan/strutil.h>
24 #include <epan/asn1.h>
26 #include "packet-ber.h"
27 #include "packet-per.h"
28 #include "packet-sccp.h"
31 /* disable: "warning C4146: unary minus operator applied to unsigned type, result still unsigned" */
32 #pragma warning(disable:4146)
35 #define PNAME "UTRAN Iupc interface Positioning Calculation Application Part (PCAP)"
41 void proto_register_pcap(void);
42 void proto_reg_handoff_pcap(void);
44 #include "packet-pcap-val.h"
46 static dissector_handle_t pcap_handle
;
48 /* Initialize the protocol and registered fields */
49 static int proto_pcap
;
51 #include "packet-pcap-hf.c"
53 /* Initialize the subtree pointers */
56 #include "packet-pcap-ett.c"
58 /* Global variables */
59 static uint32_t ProcedureCode
;
60 static uint32_t ProtocolIE_ID
;
61 /*static uint32_t ProtocolExtensionID;*/
63 /* Dissector tables */
64 static dissector_table_t pcap_ies_dissector_table
;
65 static dissector_table_t pcap_ies_p1_dissector_table
;
66 static dissector_table_t pcap_ies_p2_dissector_table
;
67 static dissector_table_t pcap_extension_dissector_table
;
68 static dissector_table_t pcap_proc_imsg_dissector_table
;
69 static dissector_table_t pcap_proc_sout_dissector_table
;
70 static dissector_table_t pcap_proc_uout_dissector_table
;
71 static dissector_table_t pcap_proc_out_dissector_table
;
73 static int dissect_ProtocolIEFieldValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *);
74 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *);
75 static int dissect_InitiatingMessageValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *);
76 static int dissect_SuccessfulOutcomeValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *);
77 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *);
78 static int dissect_OutcomeValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *);
80 #include "packet-pcap-fn.c"
82 static int dissect_ProtocolIEFieldValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
84 return (dissector_try_uint(pcap_ies_dissector_table
, ProtocolIE_ID
, tvb
, pinfo
, tree
)) ? tvb_captured_length(tvb
) : 0;
87 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
89 return (dissector_try_uint(pcap_extension_dissector_table
, ProtocolIE_ID
, tvb
, pinfo
, tree
)) ? tvb_captured_length(tvb
) : 0;
92 static int dissect_InitiatingMessageValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
94 return (dissector_try_uint(pcap_proc_imsg_dissector_table
, ProcedureCode
, tvb
, pinfo
, tree
)) ? tvb_captured_length(tvb
) : 0;
97 static int dissect_SuccessfulOutcomeValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
99 return (dissector_try_uint(pcap_proc_sout_dissector_table
, ProcedureCode
, tvb
, pinfo
, tree
)) ? tvb_captured_length(tvb
) : 0;
102 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
104 return (dissector_try_uint(pcap_proc_uout_dissector_table
, ProcedureCode
, tvb
, pinfo
, tree
)) ? tvb_captured_length(tvb
) : 0;
107 static int dissect_OutcomeValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
109 return (dissector_try_uint(pcap_proc_out_dissector_table
, ProcedureCode
, tvb
, pinfo
, tree
)) ? tvb_captured_length(tvb
) : 0;
113 dissect_pcap(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
115 proto_item
*pcap_item
= NULL
;
116 proto_tree
*pcap_tree
= NULL
;
118 /* make entry in the Protocol column on summary display */
119 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "PCAP");
121 /* create the pcap protocol tree */
122 pcap_item
= proto_tree_add_item(tree
, proto_pcap
, tvb
, 0, -1, ENC_NA
);
123 pcap_tree
= proto_item_add_subtree(pcap_item
, ett_pcap
);
125 dissect_PCAP_PDU_PDU(tvb
, pinfo
, pcap_tree
, NULL
);
126 return tvb_captured_length(tvb
);
129 /*--- proto_reg_handoff_pcap ---------------------------------------*/
131 proto_reg_handoff_pcap(void)
133 #include "packet-pcap-dis-tab.c"
134 dissector_add_for_decode_as_with_preference("sccp.ssn", pcap_handle
);
137 /*--- proto_register_pcap -------------------------------------------*/
138 void proto_register_pcap(void) {
142 static hf_register_info hf
[] = {
144 #include "packet-pcap-hfarr.c"
147 /* List of subtrees */
148 static int *ett
[] = {
150 #include "packet-pcap-ettarr.c"
153 /* module_t *pcap_module; */
155 /* Register protocol */
156 proto_pcap
= proto_register_protocol(PNAME
, PSNAME
, PFNAME
);
157 /* Register fields and subtrees */
158 proto_register_field_array(proto_pcap
, hf
, array_length(hf
));
159 proto_register_subtree_array(ett
, array_length(ett
));
161 /* pcap_module = prefs_register_protocol(proto_pcap, NULL); */
163 /* Register dissector */
164 pcap_handle
= register_dissector("pcap", dissect_pcap
, proto_pcap
);
166 /* Register dissector tables */
167 pcap_ies_dissector_table
= register_dissector_table("pcap.ies", "PCAP-PROTOCOL-IES", proto_pcap
, FT_UINT32
, BASE_DEC
);
168 pcap_ies_p1_dissector_table
= register_dissector_table("pcap.ies.pair.first", "PCAP-PROTOCOL-IES-PAIR FirstValue", proto_pcap
, FT_UINT32
, BASE_DEC
);
169 pcap_ies_p2_dissector_table
= register_dissector_table("pcap.ies.pair.second", "PCAP-PROTOCOL-IES-PAIR SecondValue", proto_pcap
, FT_UINT32
, BASE_DEC
);
170 pcap_extension_dissector_table
= register_dissector_table("pcap.extension", "PCAP-PROTOCOL-EXTENSION", proto_pcap
, FT_UINT32
, BASE_DEC
);
171 pcap_proc_imsg_dissector_table
= register_dissector_table("pcap.proc.imsg", "PCAP-ELEMENTARY-PROCEDURE InitiatingMessage", proto_pcap
, FT_UINT32
, BASE_DEC
);
172 pcap_proc_sout_dissector_table
= register_dissector_table("pcap.proc.sout", "PCAP-ELEMENTARY-PROCEDURE SuccessfulOutcome", proto_pcap
, FT_UINT32
, BASE_DEC
);
173 pcap_proc_uout_dissector_table
= register_dissector_table("pcap.proc.uout", "PCAP-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", proto_pcap
, FT_UINT32
, BASE_DEC
);
174 pcap_proc_out_dissector_table
= register_dissector_table("pcap.proc.out", "PCAP-ELEMENTARY-PROCEDURE Outcome", proto_pcap
, FT_UINT32
, BASE_DEC
);