2 * Routines for LCS-AP packet dissembly.
4 * Copyright (c) 2011 by Spenser Sheng <spenser.sheng@ericsson.com>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1999 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
12 * ETSI TS 129 171 V9.2.0 (2010-10)
19 #include <epan/packet.h>
20 #include <epan/strutil.h>
21 #include <epan/asn1.h>
22 #include <epan/prefs.h>
23 #include <epan/sctpppids.h>
24 #include <epan/expert.h>
25 #include <wsutil/array.h>
27 #include "packet-ber.h"
28 #include "packet-per.h"
29 #include "packet-e212.h"
30 #include "packet-sccp.h"
31 #include "packet-lcsap.h"
34 /* disable: "warning C4146: unary minus operator applied to unsigned type, result still unsigned" */
35 #pragma warning(disable:4146)
38 #define PNAME "LCS Application Protocol"
39 #define PSNAME "LCSAP"
40 #define PFNAME "lcsap"
42 void proto_register_lcsap(void);
43 void proto_reg_handoff_lcsap(void);
45 #define SCTP_PORT_LCSAP 9082
46 #include "packet-lcsap-val.h"
48 /* Initialize the protocol and registered fields */
49 static int proto_lcsap
;
51 static int hf_lcsap_pos_method
;
52 static int hf_lcsap_pos_usage
;
53 static int hf_lcsap_gnss_pos_method
;
54 static int hf_lcsap_gnss_id
;
55 static int hf_lcsap_gnss_pos_usage
;
56 #include "packet-lcsap-hf.c"
58 /* Initialize the subtree pointers */
60 static int ett_lcsap_plmnd_id
;
61 static int ett_lcsap_imsi
;
62 static int ett_lcsap_civic_address
;
64 #include "packet-lcsap-ett.c"
66 static expert_field ei_lcsap_civic_data_not_xml
;
68 /* Global variables */
69 static uint32_t ProcedureCode
;
70 static uint32_t ProtocolIE_ID
;
71 static uint32_t ProtocolExtensionID
;
72 static uint32_t PayloadType
= -1;
74 /* Dissector handles */
75 static dissector_handle_t lcsap_handle
;
76 static dissector_handle_t lpp_handle
;
77 static dissector_handle_t lppa_handle
;
78 static dissector_handle_t xml_handle
;
80 /* Dissector tables */
81 static dissector_table_t lcsap_ies_dissector_table
;
83 static dissector_table_t lcsap_extension_dissector_table
;
84 static dissector_table_t lcsap_proc_imsg_dissector_table
;
85 static dissector_table_t lcsap_proc_sout_dissector_table
;
86 static dissector_table_t lcsap_proc_uout_dissector_table
;
88 static int dissect_ProtocolIEFieldValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *);
90 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *);
91 static int dissect_InitiatingMessageValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *);
92 static int dissect_SuccessfulOutcomeValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *);
93 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *);
96 /* 7.4.13 Positioning Data
97 * Coding of positioning method (bits 8-4)
99 static const value_string lcsap_pos_method_vals
[] = {
101 { 0x01, "Reserved" },
103 { 0x03, "Reserved" },
105 { 0x05, "Reserved" },
106 { 0x06, "Reserved" },
107 { 0x07, "Reserved" },
109 { 0x09, "Reserved" },
110 { 0x0a, "Reserved" },
111 { 0x0b, "Reserved" },
112 { 0x0c, "Reserved for other location technologies" },
113 { 0x0d, "Reserved for other location technologies" },
114 { 0x0e, "Reserved for other location technologies" },
115 { 0x0f, "Reserved for other location technologies" },
116 { 0x10, "Reserved for network specific positioning methods" },
117 { 0x11, "Reserved for network specific positioning methods" },
118 { 0x12, "Reserved for network specific positioning methods" },
119 { 0x13, "Reserved for network specific positioning methods" },
120 { 0x14, "Reserved for network specific positioning methods" },
121 { 0x15, "Reserved for network specific positioning methods" },
122 { 0x16, "Reserved for network specific positioning methods" },
123 { 0x17, "Reserved for network specific positioning methods" },
124 { 0x18, "Reserved for network specific positioning methods" },
125 { 0x19, "Reserved for network specific positioning methods" },
126 { 0x1a, "Reserved for network specific positioning methods" },
127 { 0x1b, "Reserved for network specific positioning methods" },
128 { 0x1c, "Reserved for network specific positioning methods" },
129 { 0x1d, "Reserved for network specific positioning methods" },
130 { 0x1e, "Reserved for network specific positioning methods" },
131 { 0x1f, "Reserved for network specific positioning methods" },
135 /* Coding of usage (bits 3-1)*/
136 static const value_string lcsap_pos_usage_vals
[] = {
137 { 0x00, "Attempted unsuccessfully due to failure or interruption - not used" },
138 { 0x01, "Attempted successfully: results not used to generate location - not used." },
139 { 0x02, "Attempted successfully: results used to verify but not generate location - not used." },
140 { 0x03, "Attempted successfully: results used to generate location" },
141 { 0x04, "Attempted successfully: case where UE supports multiple mobile based positioning methods and the actual method or methods used by the UE cannot be determined." },
142 { 0x05, "Reserved" },
143 { 0x06, "Reserved" },
144 { 0x07, "Reserved" },
148 /* Coding of Method (Bits 8-7) */
149 static const value_string lcsap_gnss_pos_method_vals
[] = {
150 { 0x00, "UE-Based" },
151 { 0x01, "UE-Assisted" },
152 { 0x02, "Conventional" },
153 { 0x03, "Reserved" },
157 /* Coding of GNSS ID (Bits 6-4) */
158 static const value_string lcsap_gnss_id_vals
[] = {
162 { 0x03, "Modernized GPS" },
165 { 0x06, "Reserved" },
166 { 0x07, "Reserved" },
170 /* Coding of usage (bits 3- 1) */
171 static const value_string lcsap_gnss_pos_usage_vals
[] = {
172 { 0x00, "Attempted unsuccessfully due to failure or interruption" },
173 { 0x01, "Attempted successfully: results not used to generate location" },
174 { 0x02, "Attempted successfully: results used to verify but not generate location" },
175 { 0x03, "Attempted successfully: results used to generate location" },
176 { 0x04, "Attempted successfully: case where UE supports multiple mobile based positioning methods and the actual method or methods used by the UE cannot be determined." },
177 { 0x05, "Reserved" },
178 { 0x06, "Reserved" },
179 { 0x07, "Reserved" },
184 #include "packet-lcsap-fn.c"
186 static int dissect_ProtocolIEFieldValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
188 return (dissector_try_uint(lcsap_ies_dissector_table
, ProtocolIE_ID
, tvb
, pinfo
, tree
)) ? tvb_captured_length(tvb
) : 0;
192 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
194 return (dissector_try_uint(lcsap_extension_dissector_table
, ProtocolExtensionID
, tvb
, pinfo
, tree
)) ? tvb_captured_length(tvb
) : 0;
197 static int dissect_InitiatingMessageValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
199 return (dissector_try_uint(lcsap_proc_imsg_dissector_table
, ProcedureCode
, tvb
, pinfo
, tree
)) ? tvb_captured_length(tvb
) : 0;
202 static int dissect_SuccessfulOutcomeValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
204 return (dissector_try_uint(lcsap_proc_sout_dissector_table
, ProcedureCode
, tvb
, pinfo
, tree
)) ? tvb_captured_length(tvb
) : 0;
207 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
209 return (dissector_try_uint(lcsap_proc_uout_dissector_table
, ProcedureCode
, tvb
, pinfo
, tree
)) ? tvb_captured_length(tvb
) : 0;
214 dissect_lcsap(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
216 proto_item
*lcsap_item
= NULL
;
217 proto_tree
*lcsap_tree
= NULL
;
219 /* make entry in the Protocol column on summary display */
220 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "LCSAP");
222 /* create the lcsap protocol tree */
223 lcsap_item
= proto_tree_add_item(tree
, proto_lcsap
, tvb
, 0, -1, ENC_NA
);
224 lcsap_tree
= proto_item_add_subtree(lcsap_item
, ett_lcsap
);
226 dissect_LCS_AP_PDU_PDU(tvb
, pinfo
, lcsap_tree
, NULL
);
227 return tvb_captured_length(tvb
);
230 /*--- proto_reg_handoff_lcsap ---------------------------------------*/
232 proto_reg_handoff_lcsap(void)
234 lpp_handle
= find_dissector_add_dependency("lpp", proto_lcsap
);
235 lppa_handle
= find_dissector_add_dependency("lppa", proto_lcsap
);
236 xml_handle
= find_dissector_add_dependency("xml", proto_lcsap
);
237 dissector_add_uint_with_preference("sctp.port", SCTP_PORT_LCSAP
, lcsap_handle
);
238 dissector_add_uint("sctp.ppi", LCS_AP_PAYLOAD_PROTOCOL_ID
, lcsap_handle
);
239 #include "packet-lcsap-dis-tab.c"
243 /*--- proto_register_lcsap -------------------------------------------*/
244 void proto_register_lcsap(void) {
247 static hf_register_info hf
[] = {
248 /* 7.4.13 Positioning Data */
249 { &hf_lcsap_pos_method
,
250 { "Positioning Method", "lcsap.pos_method",
251 FT_UINT8
, BASE_DEC
, VALS(lcsap_pos_method_vals
), 0xf8,
254 { &hf_lcsap_pos_usage
,
255 { "Positioning usage", "lcsap.pos_usage",
256 FT_UINT8
, BASE_DEC
, VALS(lcsap_pos_usage_vals
), 0x07,
259 { &hf_lcsap_gnss_pos_method
,
260 { "GNSS Positioning Method", "lcsap.gnss_pos_method",
261 FT_UINT8
, BASE_DEC
, VALS(lcsap_gnss_pos_method_vals
), 0xc0,
265 { "GNSS ID", "lcsap.gnss_id",
266 FT_UINT8
, BASE_DEC
, VALS(lcsap_gnss_id_vals
), 0x38,
269 { &hf_lcsap_gnss_pos_usage
,
270 { "GNSS Positioning usage", "lcsap.gnss_pos_usage",
271 FT_UINT8
, BASE_DEC
, VALS(lcsap_gnss_pos_usage_vals
), 0x07,
275 #include "packet-lcsap-hfarr.c"
278 /* List of subtrees */
279 static int *ett
[] = {
283 &ett_lcsap_civic_address
,
284 #include "packet-lcsap-ettarr.c"
287 /* module_t *lcsap_module; */
288 expert_module_t
*expert_lcsap
;
290 static ei_register_info ei
[] = {
291 { &ei_lcsap_civic_data_not_xml
,
292 { "lcsap.civic_data_not_xml", PI_PROTOCOL
, PI_ERROR
, "Should contain a UTF-8 encoded PIDF - LO XML document as defined in IETF RFC 4119", EXPFILL
} },
296 /* Register protocol */
297 proto_lcsap
= proto_register_protocol(PNAME
, PSNAME
, PFNAME
);
299 /* Register fields and subtrees */
300 proto_register_field_array(proto_lcsap
, hf
, array_length(hf
));
301 proto_register_subtree_array(ett
, array_length(ett
));
302 lcsap_handle
= register_dissector("lcsap", dissect_lcsap
, proto_lcsap
);
304 /* Register dissector tables */
305 lcsap_ies_dissector_table
= register_dissector_table("lcsap.ies", "LCS-AP-PROTOCOL-IES", proto_lcsap
, FT_UINT32
, BASE_DEC
);
307 expert_lcsap
= expert_register_protocol(proto_lcsap
);
308 expert_register_field_array(expert_lcsap
, ei
, array_length(ei
));
310 lcsap_extension_dissector_table
= register_dissector_table("lcsap.extension", "LCS-AP-PROTOCOL-EXTENSION", proto_lcsap
, FT_UINT32
, BASE_DEC
);
311 lcsap_proc_imsg_dissector_table
= register_dissector_table("lcsap.proc.imsg", "LCS-AP-ELEMENTARY-PROCEDURE InitiatingMessage", proto_lcsap
, FT_UINT32
, BASE_DEC
);
312 lcsap_proc_sout_dissector_table
= register_dissector_table("lcsap.proc.sout", "LCS-AP-ELEMENTARY-PROCEDURE SuccessfulOutcome", proto_lcsap
, FT_UINT32
, BASE_DEC
);
313 lcsap_proc_uout_dissector_table
= register_dissector_table("lcsap.proc.uout", "LCS-AP-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", proto_lcsap
, FT_UINT32
, BASE_DEC
);
315 /* lcsap_module = prefs_register_protocol(proto_lcsap, NULL); */
325 * indent-tabs-mode: nil
328 * ex: set shiftwidth=2 tabstop=8 expandtab:
329 * :indentSize=2:tabSize=8:noTabs=true: