HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-ansi_801.c
blob3dba5a5fcb06cf32b6d46d3803bd935cf47d9ae2
1 /* packet-ansi_801.c
2 * Routines for ANSI IS-801 (Location Services (PLD)) dissection
4 * Location Services (Position Determination Service)
5 * 3GPP2 C.S0022-0 v1.0 IS-801
7 * Location Services (Position Determination Service)
8 * 3GPP2 C.S0022-0-1 v1.0 IS-801 Addendum
10 * Copyright 2004, Michael Lum <mlum [AT] telostech.com>
11 * In association with Telos Technology Inc.
12 * Copyright 2007, Michael Lum <michael.lum [AT] utstar.com>
13 * In association with UTStarcom Inc.
15 * $Id$
17 * Wireshark - Network traffic analyzer
18 * By Gerald Combs <gerald@wireshark.org>
19 * Copyright 1998 Gerald Combs
21 * This program is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU General Public License
23 * as published by the Free Software Foundation; either version 2
24 * of the License, or (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
36 #include "config.h"
38 #include <stdlib.h>
40 #include <glib.h>
41 #include <math.h>
43 #include <epan/packet.h>
44 #include <epan/wmem/wmem.h>
45 #include <epan/to_str.h>
47 void proto_register_ansi_801(void);
48 void proto_reg_handoff_ansi_801(void);
50 static const char *ansi_proto_name = "ANSI IS-801 (Location Services (PLD))";
51 static const char *ansi_proto_name_short = "IS-801";
53 #define ANSI_801_FORWARD 0
54 #define ANSI_801_REVERSE 1
57 /* Initialize the subtree pointers */
58 static gint ett_ansi_801 = -1;
60 /* Initialize the protocol and registered fields */
61 static int proto_ansi_801 = -1;
62 static int hf_ansi_801_for_req_type = -1;
63 static int hf_ansi_801_for_rsp_type = -1;
64 static int hf_ansi_801_rev_req_type = -1;
65 static int hf_ansi_801_rev_rsp_type = -1;
66 static int hf_ansi_801_for_sess_tag = -1;
67 static int hf_ansi_801_rev_sess_tag = -1;
68 static int hf_ansi_801_sess_tag = -1;
70 static int hf_ansi_801_time_ref_cdma = -1;
71 static int hf_ansi_801_lat = -1;
72 static int hf_ansi_801_long = -1;
73 static int hf_ansi_801_loc_uncrtnty_ang = -1;
74 static int hf_ansi_801_loc_uncrtnty_a = -1;
75 static int hf_ansi_801_loc_uncrtnty_p = -1;
76 static int hf_ansi_801_fix_type = -1;
77 static int hf_ansi_801_velocity_incl = -1;
78 static int hf_ansi_801_velocity_hor = -1;
79 static int hf_ansi_801_heading = -1;
80 static int hf_ansi_801_velocity_ver = -1;
81 static int hf_ansi_801_clock_incl = -1;
82 static int hf_ansi_801_clock_bias = -1;
83 static int hf_ansi_801_clock_drift = -1;
84 static int hf_ansi_801_height_incl = -1;
85 static int hf_ansi_801_height = -1;
86 static int hf_ansi_801_loc_uncrtnty_v = -1;
87 static int hf_ansi_801_reserved_bits = -1;
89 static int hf_ansi_801_bad_sv_present = -1;
90 static int hf_ansi_801_num_bad_sv = -1;
91 static int hf_ansi_801_bad_sv_prn_num = -1;
92 static int hf_ansi_801_dopp_req = -1;
93 static int hf_ansi_801_add_dopp_req = -1;
94 static int hf_ansi_801_code_ph_par_req = -1;
95 static int hf_ansi_801_az_el_req = -1;
97 static int hf_ansi_801_pref_resp_qual = -1;
98 static int hf_ansi_801_num_fixes = -1;
99 static int hf_ansi_801_t_betw_fixes = -1;
100 static int hf_ansi_801_offset_req = -1;
102 static dissector_handle_t ansi_801_handle;
104 static char bigbuf[1024];
107 /* PARAM FUNCTIONS */
109 #define EXTRANEOUS_DATA_CHECK(edc_len, edc_max_len) \
110 if ((edc_len) > (edc_max_len)) \
112 proto_tree_add_text(tree, tvb, \
113 offset, (edc_len) - (edc_max_len), "Extraneous Data"); \
116 #define SHORT_DATA_CHECK(sdc_len, sdc_min_len) \
117 if ((sdc_len) < (sdc_min_len)) \
119 proto_tree_add_text(tree, tvb, \
120 offset, (sdc_len), "Short Data (?)"); \
121 return; \
124 #define EXACT_DATA_CHECK(edc_len, edc_eq_len) \
125 if ((edc_len) != (edc_eq_len)) \
127 proto_tree_add_text(tree, tvb, \
128 offset, (edc_len), "Unexpected Data Length"); \
129 return; \
134 * Table 3.2-4 for PD_MSG_TYPE = '0000000'
136 static const value_string for_req_type_strings[] = {
137 { 0, "Reserved" },
138 { 2, "Request MS Information" },
139 { 3, "Request Autonomous Measurement Weighting Factors" },
140 { 4, "Request Pseudorange Measurement" },
141 { 5, "Request Pilot Phase Measurement" },
142 { 1, "Request Location Response" },
143 { 6, "Request Time Offset Measurement" },
144 { 7, "Request Cancellation" },
145 { 0, NULL },
147 #define NUM_FOR_REQ_TYPE (sizeof(for_req_type_strings)/sizeof(value_string))
148 static gint ett_for_req_type[NUM_FOR_REQ_TYPE];
150 static const value_string for_rsp_type_strings[] = {
151 { 0, "Reject" },
152 { 2, "Provide BS Capabilities" },
153 { 4, "Provide GPS Acquisition Assistance" },
154 { 6, "Provide GPS Location Assistance Spherical Coordinates" },
155 { 7, "Provide GPS Location Assistance Cartesian Coordinates" },
156 { 5, "Provide GPS Sensitivity Assistance" },
157 { 3, "Provide Base Station Almanac" },
158 { 8, "Provide GPS Almanac" },
159 { 9, "Provide GPS Ephemeris" },
160 { 10, "Provide GPS Navigation Message Bits" },
161 { 1, "Provide Location Response" },
162 { 11, "Provide GPS Almanac Correction" },
163 { 12, "Provide GPS Satellite Health Information" },
164 { 0, NULL },
166 #define NUM_FOR_RSP_TYPE (sizeof(for_rsp_type_strings)/sizeof(value_string))
167 static gint ett_for_rsp_type[NUM_FOR_RSP_TYPE];
170 static const value_string rev_rsp_type_strings[] = {
171 { 0, "Reject" },
172 { 2, "Provide MS Information" },
173 { 3, "Provide Autonomous Measurement Weighting Factors" },
174 { 4, "Provide Pseudorange Measurement" },
175 { 5, "Provide Pilot Phase Measurement" },
176 { 1, "Provide Location Response" },
177 { 6, "Provide Time Offset Measurement" },
178 { 7, "Provide Cancellation Acknowledgement" },
179 { 0, NULL },
181 #define NUM_REV_RSP_TYPE (sizeof(rev_rsp_type_strings)/sizeof(value_string))
182 static gint ett_rev_rsp_type[NUM_REV_RSP_TYPE];
185 * Table 2.2-5 for PD_MSG_TYPE = '0000000'
187 static const value_string rev_req_type_strings[] = {
188 { 0, "Reserved" },
189 { 2, "Request BS Capabilities" },
190 { 4, "Request GPS Acquisition Assistance" },
191 { 6, "Request GPS Location Assistance" },
192 { 7, "Reserved" },
193 { 5, "Request GPS Sensitivity Assistance" },
194 { 3, "Request Base Station Almanac" },
195 { 8, "Request GPS Almanac" },
196 { 9, "Request GPS Ephemeris" },
197 { 10, "Request GPS Navigation Message Bits" },
198 { 1, "Request Location Response" },
199 { 11, "Request GPS Almanac Correction" },
200 { 12, "Request GPS Satellite Health Information" },
201 { 0, NULL },
203 #define NUM_REV_REQ_TYPE (sizeof(rev_req_type_strings)/sizeof(value_string))
204 static gint ett_rev_req_type[NUM_REV_REQ_TYPE];
206 static void
207 for_req_pseudo_meas(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
209 guint32 bit_offset, spare_bits;
210 guint32 saved_offset, value;
212 SHORT_DATA_CHECK(len, 3);
213 saved_offset = offset;
214 bit_offset = offset << 3;
216 /* PREF_RESP_QUAL */
217 proto_tree_add_bits_item(tree, hf_ansi_801_pref_resp_qual, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
218 bit_offset += 3;
220 /* NUM_FIXES */
221 value = tvb_get_bits8(tvb, bit_offset, 8) + 1;
222 proto_tree_add_uint_bits_format_value(tree, hf_ansi_801_num_fixes, tvb, bit_offset, 8, value, "%u", value);
223 bit_offset += 8;
225 /* T_BETW_FIXES */
226 value = tvb_get_bits8(tvb, bit_offset, 8);
227 proto_tree_add_uint_bits_format_value(tree, hf_ansi_801_t_betw_fixes, tvb, bit_offset, 8, value, "%u seconds", value);
228 bit_offset += 8;
230 /* OFFSET_REQ */
231 proto_tree_add_bits_item(tree, hf_ansi_801_offset_req, tvb, bit_offset++, 1, ENC_BIG_ENDIAN);
233 if(bit_offset & 0x07)
235 spare_bits = 8 - (bit_offset & 0x07);
236 proto_tree_add_bits_item(tree, hf_ansi_801_reserved_bits, tvb, bit_offset, spare_bits, ENC_BIG_ENDIAN);
237 bit_offset += spare_bits;
240 offset = bit_offset >> 3;
242 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
246 static void
247 for_req_pilot_ph_meas(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
249 guint32 value;
250 guint32 saved_offset;
252 SHORT_DATA_CHECK(len, 3);
254 saved_offset = offset;
256 value = tvb_get_ntoh24(tvb, offset);
258 other_decode_bitfield_value(bigbuf, value >> 16, 0xe0, 8);
259 proto_tree_add_text(tree, tvb, offset, 1,
260 "%s : Preferred response quality, %u",
261 bigbuf,
262 (value & 0xe00000) >> 21);
264 other_decode_bitfield_value(bigbuf, value >> 16, 0x1f, 8);
265 proto_tree_add_text(tree, tvb, offset, 1,
266 "%s : Number of fixes (MSB), %u",
267 bigbuf,
268 (value & 0x1fe000) >> 13);
270 other_decode_bitfield_value(bigbuf, value >> 8, 0xe0, 8);
271 proto_tree_add_text(tree, tvb, offset, 1,
272 "%s : Number of fixes (LSB)",
273 bigbuf);
275 other_decode_bitfield_value(bigbuf, value >> 8, 0x1f, 8);
276 proto_tree_add_text(tree, tvb, offset, 1,
277 "%s : Time between fixes (MSB), %u",
278 bigbuf,
279 (value & 0x001fe0) >> 5);
281 other_decode_bitfield_value(bigbuf, value, 0xe0, 8);
282 proto_tree_add_text(tree, tvb, offset, 1,
283 "%s : Time between fixes (LSB)",
284 bigbuf);
286 other_decode_bitfield_value(bigbuf, value, 0x10, 8);
287 proto_tree_add_text(tree, tvb, offset, 1,
288 "%s : Offset %srequested",
289 bigbuf,
290 (value & 0x10) ? "" : "not ");
292 other_decode_bitfield_value(bigbuf, value, 0x08, 8);
293 proto_tree_add_text(tree, tvb, offset, 1,
294 "%s : Desired pilot phase resolution: at least %s PN chip resolution",
295 bigbuf,
296 (value & 0x08) ? "1/8th" : "1");
298 other_decode_bitfield_value(bigbuf, value, 0x07, 8);
299 proto_tree_add_text(tree, tvb, offset, 1,
300 "%s : Reserved",
301 bigbuf);
303 offset += 3;
305 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
308 static void
309 for_req_loc_response(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
311 guint32 value;
312 guint32 saved_offset;
314 SHORT_DATA_CHECK(len, 3);
316 saved_offset = offset;
318 value = tvb_get_ntoh24(tvb, offset);
320 other_decode_bitfield_value(bigbuf, value >> 16, 0xe0, 8);
321 proto_tree_add_text(tree, tvb, offset, 1,
322 "%s : Preferred response quality, %u",
323 bigbuf,
324 (value & 0xe00000) >> 21);
326 other_decode_bitfield_value(bigbuf, value >> 16, 0x1f, 8);
327 proto_tree_add_text(tree, tvb, offset, 1,
328 "%s : Number of fixes (MSB), %u",
329 bigbuf,
330 (value & 0x1fe000) >> 13);
332 other_decode_bitfield_value(bigbuf, value >> 8, 0xe0, 8);
333 proto_tree_add_text(tree, tvb, offset, 1,
334 "%s : Number of fixes (LSB)",
335 bigbuf);
337 other_decode_bitfield_value(bigbuf, value >> 8, 0x1f, 8);
338 proto_tree_add_text(tree, tvb, offset, 1,
339 "%s : Time between fixes (MSB), %u",
340 bigbuf,
341 (value & 0x001fe0) >> 5);
343 other_decode_bitfield_value(bigbuf, value, 0xe0, 8);
344 proto_tree_add_text(tree, tvb, offset, 1,
345 "%s : Time between fixes (LSB)",
346 bigbuf);
348 other_decode_bitfield_value(bigbuf, value, 0x10, 8);
349 proto_tree_add_text(tree, tvb, offset, 1,
350 "%s : Height information %srequested",
351 bigbuf,
352 (value & 0x10) ? "" : "not ");
354 other_decode_bitfield_value(bigbuf, value, 0x08, 8);
355 proto_tree_add_text(tree, tvb, offset, 1,
356 "%s : Clock correction for GPS time %srequested",
357 bigbuf,
358 (value & 0x08) ? "" : "not ");
360 other_decode_bitfield_value(bigbuf, value, 0x04, 8);
361 proto_tree_add_text(tree, tvb, offset, 1,
362 "%s : Velocity information %srequested",
363 bigbuf,
364 (value & 0x04) ? "" : "not ");
366 other_decode_bitfield_value(bigbuf, value, 0x03, 8);
367 proto_tree_add_text(tree, tvb, offset, 1,
368 "%s : Reserved",
369 bigbuf);
371 offset += 3;
373 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
376 static void
377 for_req_time_off_meas(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
379 guint8 oct;
380 guint8 bit_mask;
381 guint32 saved_offset;
383 SHORT_DATA_CHECK(len, 1);
385 saved_offset = offset;
387 oct = tvb_get_guint8(tvb, offset);
389 other_decode_bitfield_value(bigbuf, oct, 0x80, 8);
390 proto_tree_add_text(tree, tvb, offset, 1,
391 "%s : Use action time indicator",
392 bigbuf);
394 if (oct & 0x80)
396 other_decode_bitfield_value(bigbuf, oct, 0x7e, 8);
397 proto_tree_add_text(tree, tvb, offset, 1,
398 "%s : Action time, %u",
399 bigbuf,
400 (oct & 0x7e) >> 1);
402 bit_mask = 0x01;
404 else
406 bit_mask = 0x7f;
409 other_decode_bitfield_value(bigbuf, oct, bit_mask, 8);
410 proto_tree_add_text(tree, tvb, offset, 1,
411 "%s : Reserved",
412 bigbuf);
414 offset++;
416 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
419 static void
420 for_req_cancel(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
422 guint8 oct;
423 guint32 saved_offset;
424 const gchar *str = NULL;
425 gint idx;
427 SHORT_DATA_CHECK(len, 1);
429 saved_offset = offset;
431 oct = tvb_get_guint8(tvb, offset);
433 str = try_val_to_str_idx((oct & 0xf0) >> 4, for_req_type_strings, &idx);
434 if (str == NULL)
436 str = "Reserved";
439 other_decode_bitfield_value(bigbuf, oct, 0xf0, 8);
440 proto_tree_add_text(tree, tvb, offset, 1,
441 "%s : Cancellation Type: (%u) %s",
442 bigbuf,
443 (oct & 0xf0) >> 4,
444 str);
446 other_decode_bitfield_value(bigbuf, oct, 0x0f, 8);
447 proto_tree_add_text(tree, tvb, offset, 1,
448 "%s : Reserved",
449 bigbuf);
451 offset++;
453 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
456 static void
457 for_reject(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
459 guint8 oct;
460 guint32 saved_offset;
461 const gchar *str = NULL;
462 gint idx;
464 saved_offset = offset;
466 SHORT_DATA_CHECK(len, 1);
468 oct = tvb_get_guint8(tvb, offset);
470 str = try_val_to_str_idx((oct & 0xf0) >> 4, rev_req_type_strings, &idx);
471 if (str == NULL)
473 str = "Reserved";
476 other_decode_bitfield_value(bigbuf, oct, 0xf0, 8);
477 proto_tree_add_text(tree, tvb, offset, 1,
478 "%s : Reject request type: (%u) %s",
479 bigbuf,
480 (oct & 0xf0) >> 4,
481 str);
483 switch ((oct & 0x0e) >> 1)
485 case 0x00: str = "Capability not supported by the base station"; break;
486 case 0x01: str = "Capability normally supported by the base station but temporarily not available or not enabled"; break;
487 default: str = "Reserved"; break;
490 other_decode_bitfield_value(bigbuf, oct, 0x0e, 8);
491 proto_tree_add_text(tree, tvb, offset, 1,
492 "%s : Reject reason: %s",
493 bigbuf,
494 str);
496 other_decode_bitfield_value(bigbuf, oct, 0x01, 8);
497 proto_tree_add_text(tree, tvb, offset, 1,
498 "%s : Reserved",
499 bigbuf);
501 offset++;
503 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
506 static void
507 for_pr_bs_cap(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
509 guint8 oct;
510 guint32 saved_offset;
512 saved_offset = offset;
514 SHORT_DATA_CHECK(len, 2);
516 oct = tvb_get_guint8(tvb, offset);
518 other_decode_bitfield_value(bigbuf, oct, 0xfc, 8);
519 proto_tree_add_text(tree, tvb, offset, 1,
520 "%s : BS_LS_REV",
521 bigbuf);
523 other_decode_bitfield_value(bigbuf, oct, 0x02, 8);
524 proto_tree_add_text(tree, tvb, offset, 1,
525 "%s : GPSC_ID: GPS capability indicator",
526 bigbuf);
528 other_decode_bitfield_value(bigbuf, oct, 0x01, 8);
529 proto_tree_add_text(tree, tvb, offset, 1,
530 "%s : AFLTC_ID: Advanced forward link trilateration capability indicator",
531 bigbuf);
533 offset++;
535 oct = tvb_get_guint8(tvb, offset);
536 if (oct == 0x00)
538 proto_tree_add_text(tree, tvb, offset, 1,
539 "APDC_ID: Autonomous position determination capability indicator: None");
541 else
543 proto_tree_add_text(tree, tvb, offset, 1,
544 "APDC_ID: Autonomous position determination capability indicator: Autonomous Location Technology Identifier %u",
545 oct);
548 offset++;
550 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
553 static void
554 for_pr_gps_sense_ass(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
556 guint8 oct;
557 guint8 num_dr_p;
558 guint32 value;
559 guint32 saved_offset;
561 saved_offset = offset;
563 SHORT_DATA_CHECK(len, 4);
565 value = tvb_get_ntohs(tvb, offset);
567 other_decode_bitfield_value(bigbuf, value, 0xffe0, 16);
568 proto_tree_add_text(tree, tvb, offset, 2,
569 "%s : REF_BIT_NUM: %u",
570 bigbuf,
571 (value & 0xffe0) >> 5);
573 num_dr_p = (value & 0x001e) >> 1;
575 other_decode_bitfield_value(bigbuf, value, 0x001e, 16);
576 proto_tree_add_text(tree, tvb, offset, 2,
577 "%s : NUM_DR_P: Number of data records in this part: %u",
578 bigbuf,
579 num_dr_p);
581 offset += 2;
582 oct = tvb_get_guint8(tvb, offset);
584 other_decode_bitfield_value(bigbuf, value, 0x0001, 16);
585 value = ((value & 0x0001) << 7) | ((oct & 0xfe) >> 1);
587 proto_tree_add_text(tree, tvb, offset - 2, 2,
588 "%s : DR_SIZE: Data record size in 2-bit units (MSB): %u",
589 bigbuf,
590 value);
592 other_decode_bitfield_value(bigbuf, oct, 0xfe, 8);
593 proto_tree_add_text(tree, tvb, offset, 1,
594 "%s : DR_SIZE: (LSB)",
595 bigbuf);
597 value = oct;
598 offset++;
600 oct = tvb_get_guint8(tvb, offset);
602 other_decode_bitfield_value(bigbuf, value, 0x01, 8);
603 value = ((value & 0x0001) << 2) | ((oct & 0xc0) >> 6);
605 proto_tree_add_text(tree, tvb, offset - 1, 1,
606 "%s : PART_NUM: The part number (MSB): %u",
607 bigbuf,
608 value);
610 other_decode_bitfield_value(bigbuf, oct, 0xc0, 8);
611 proto_tree_add_text(tree, tvb, offset, 1,
612 "%s : PART_NUM: (LSB)",
613 bigbuf);
615 other_decode_bitfield_value(bigbuf, oct, 0x38, 8);
616 proto_tree_add_text(tree, tvb, offset, 1,
617 "%s : TOTAL_PARTS: Total number of parts: %u",
618 bigbuf,
619 (oct & 0x38) >> 3);
621 other_decode_bitfield_value(bigbuf, oct, 0x07, 8);
622 proto_tree_add_text(tree, tvb, offset, 1,
623 "%s : Data records (MSB)",
624 bigbuf);
626 offset++;
628 proto_tree_add_text(tree, tvb, offset, (len - (offset - saved_offset)),
629 "%s : Data records (LSB) + Reserved",
630 bigbuf);
632 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
635 static void
636 for_pr_gps_almanac(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
638 guint8 num_sv;
639 guint32 value;
640 guint32 saved_offset;
642 saved_offset = offset;
644 SHORT_DATA_CHECK(len, 4);
646 value = tvb_get_ntohl(tvb, offset);
647 num_sv = (value & 0xfc000000) >> 26;
649 other_decode_bitfield_value(bigbuf, value, 0xfc000000, 32);
650 proto_tree_add_text(tree, tvb, offset, 4,
651 "%s : NUM_SV_P: Number of satellites in this part: %u",
652 bigbuf,
653 num_sv);
655 other_decode_bitfield_value(bigbuf, value, 0x03fc0000, 32);
656 proto_tree_add_text(tree, tvb, offset, 4,
657 "%s : WEEK_NUM: The GPS week number of the almanac: %u",
658 bigbuf,
659 (value & 0x03fc0000) >> 18);
661 other_decode_bitfield_value(bigbuf, value, 0x0003fc00, 32);
662 proto_tree_add_text(tree, tvb, offset, 4,
663 "%s : TOA: The reference time of the almanac: %u",
664 bigbuf,
665 (value & 0x0003fc00) >> 10);
667 other_decode_bitfield_value(bigbuf, value, 0x000003e0, 32);
668 proto_tree_add_text(tree, tvb, offset, 4,
669 "%s : PART_NUM: The part number: %u",
670 bigbuf,
671 (value & 0x000003e0) >> 5);
673 other_decode_bitfield_value(bigbuf, value, 0x0000001f, 32);
674 proto_tree_add_text(tree, tvb, offset, 4,
675 "%s : TOTAL_PARTS: The total number of parts: %u",
676 bigbuf,
677 (value & 0x0000001f));
679 offset += 4;
681 proto_tree_add_text(tree, tvb, offset, (len - (offset - saved_offset)),
682 "%u Data records + Reserved",
683 num_sv);
685 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
688 static void
689 for_pr_gps_nav_msg_bits(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
691 guint8 num_sv;
692 guint32 value;
693 guint32 saved_offset;
695 saved_offset = offset;
697 SHORT_DATA_CHECK(len, 2);
699 value = tvb_get_ntohs(tvb, offset);
700 num_sv = (value & 0xfc00) >> 10;
702 other_decode_bitfield_value(bigbuf, value, 0xfc00, 16);
703 proto_tree_add_text(tree, tvb, offset, 2,
704 "%s : NUM_SV_P: Number of satellites in this part: %u",
705 bigbuf,
706 num_sv);
708 other_decode_bitfield_value(bigbuf, value, 0x03e0, 16);
709 proto_tree_add_text(tree, tvb, offset, 2,
710 "%s : PART_NUM: The part number: %u",
711 bigbuf,
712 (value & 0x03e0) >> 5);
714 other_decode_bitfield_value(bigbuf, value, 0x001f, 16);
715 proto_tree_add_text(tree, tvb, offset, 2,
716 "%s : TOTAL_PARTS: The total number of parts: %u",
717 bigbuf,
718 (value & 0x001f));
720 offset += 2;
722 proto_tree_add_text(tree, tvb, offset, (len - (offset - saved_offset)),
723 "%u SUBF_4_5_INCL ... Data records + Reserved",
724 num_sv);
726 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
730 * shared for both forward/reverse directions
732 static const true_false_string ansi_801_fix_type_vals = {
733 "3D",
734 "2D"
737 static void
738 pr_loc_response(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
740 guint32 bit_offset, spare_bits;
741 guint32 value;
742 float fl_value;
743 guint32 saved_offset;
744 guint64 fix_type, velocity_incl, clock_incl, height_incl;
745 const gchar *str = NULL;
747 SHORT_DATA_CHECK(len, 11);
748 saved_offset = offset;
749 bit_offset = offset << 3;
751 /* TIME_REF_CDMA */
752 value = tvb_get_bits16(tvb, bit_offset, 14, ENC_BIG_ENDIAN);
753 proto_tree_add_uint_bits_format_value(tree, hf_ansi_801_time_ref_cdma, tvb, bit_offset, 14, value * 50,
754 "%u frames (0x%04x)", value * 50, value);
755 bit_offset += 14;
757 /* LAT */
758 value = tvb_get_bits32(tvb, bit_offset, 25, ENC_BIG_ENDIAN);
759 fl_value = (float)(-90.0 + ((float)value * 180 / 33554432));
760 proto_tree_add_float_bits_format_value(tree, hf_ansi_801_lat, tvb, bit_offset, 25, fl_value,
761 "%.5f degrees %s (0x%08x)", fabs(fl_value), fl_value < 0 ? "South" : "North", value);
762 bit_offset += 25;
764 /* LONG */
765 value = tvb_get_bits32(tvb, bit_offset, 26, ENC_BIG_ENDIAN);
766 fl_value = (float)(-180.0 + ((float)value * 180 / 33554432));
767 proto_tree_add_float_bits_format_value(tree, hf_ansi_801_long, tvb, bit_offset, 26, fl_value,
768 "%.5f degrees %s (0x%08x)", fabs(fl_value), fl_value < 0 ? "West" : "East", value);
769 bit_offset += 26;
771 /* LOC_UNCRTNTY_ANG */
772 value = tvb_get_bits8(tvb, bit_offset, 4);
773 fl_value = (float)(5.625 * value);
774 proto_tree_add_float_bits_format_value(tree, hf_ansi_801_loc_uncrtnty_ang, tvb, bit_offset, 4, fl_value,
775 "%.5f degrees (0x%02x)", fl_value, value);
776 bit_offset += 4;
778 /* LOC_UNCRTNTY_A */
779 value = tvb_get_bits8(tvb, bit_offset, 5);
780 switch (value)
782 case 0x1e: str = "> 12288.00 meters"; break;
783 case 0x1f: str = "Not computable"; break;
784 default:
785 fl_value = (float)(0.5 * (1 << (value >> 1)));
786 if (value & 0x01)
787 fl_value *= 1.5f;
788 str = wmem_strdup_printf(wmem_packet_scope(), "%.2f meters", fl_value);
790 proto_tree_add_uint_bits_format_value(tree, hf_ansi_801_loc_uncrtnty_a, tvb, bit_offset, 5, value,
791 "%s (0x%02x)", str, value);
792 bit_offset += 5;
794 /* LOC_UNCRTNTY_P */
795 value = tvb_get_bits8(tvb, bit_offset, 5);
796 switch (value)
798 case 0x1e: str = "> 12288.00 meters"; break;
799 case 0x1f: str = "Not computable"; break;
800 default:
801 fl_value = (float)(0.5 * (1 << (value >> 1)));
802 if (value & 0x01)
803 fl_value *= 1.5f;
804 str = wmem_strdup_printf(wmem_packet_scope(), "%.2f meters", fl_value);
806 proto_tree_add_uint_bits_format_value(tree, hf_ansi_801_loc_uncrtnty_p, tvb, bit_offset, 5, value,
807 "%s (0x%02x)", str, value);
808 bit_offset += 5;
810 /* FIX_TYPE */
811 proto_tree_add_bits_ret_val(tree, hf_ansi_801_fix_type, tvb, bit_offset++, 1, &fix_type, ENC_BIG_ENDIAN);
813 /* VELOCITY_INCL */
814 proto_tree_add_bits_ret_val(tree, hf_ansi_801_velocity_incl, tvb, bit_offset++, 1, &velocity_incl, ENC_BIG_ENDIAN);
817 if(velocity_incl)
819 /* VELOCITY_HOR */
820 value = tvb_get_bits16(tvb, bit_offset, 9, ENC_BIG_ENDIAN);
821 fl_value = (float)(0.25 * value);
822 proto_tree_add_float_bits_format_value(tree, hf_ansi_801_velocity_hor, tvb, bit_offset, 9, fl_value,
823 "%.2f m/s (0x%04x)", fl_value, value);
824 bit_offset += 9;
826 /* HEADING */
827 value = tvb_get_bits16(tvb, bit_offset, 10, ENC_BIG_ENDIAN);
828 fl_value = (float)value * 360 / 1024;
829 proto_tree_add_float_bits_format_value(tree, hf_ansi_801_heading, tvb, bit_offset, 10, fl_value,
830 "%.3f degrees (0x%04x)", fl_value, value);
831 bit_offset += 10;
833 if(fix_type)
835 /* VELOCITY_VER */
836 value = tvb_get_bits8(tvb, bit_offset, 8);
837 fl_value = (float)(-64 + 0.5 * value);
838 proto_tree_add_float_bits_format_value(tree, hf_ansi_801_velocity_ver, tvb, bit_offset, 8, fl_value,
839 "%.1f m/s (0x%02x)", fl_value, value);
840 bit_offset += 8;
844 /* CLOCK_INCL */
845 proto_tree_add_bits_ret_val(tree, hf_ansi_801_clock_incl, tvb, bit_offset++, 1, &clock_incl, ENC_BIG_ENDIAN);
847 if(clock_incl)
849 /* CLOCK_BIAS */
850 value = tvb_get_bits32(tvb, bit_offset, 18, ENC_BIG_ENDIAN);
851 proto_tree_add_int_bits_format_value(tree, hf_ansi_801_clock_bias, tvb, bit_offset, 18, (gint32)value - 13000,
852 "%d ns (0x%06x)", (gint32)value - 13000, value);
853 bit_offset += 18;
855 /* CLOCK_DRIFT */
856 value = tvb_get_bits16(tvb, bit_offset, 16, ENC_BIG_ENDIAN);
857 proto_tree_add_int_bits_format_value(tree, hf_ansi_801_clock_drift, tvb, bit_offset, 16, (gint16)value,
858 "%d ppb (ns/s) (0x%04x)", (gint16)value, value);
859 bit_offset += 16;
862 /* HEIGHT_INCL */
863 proto_tree_add_bits_ret_val(tree, hf_ansi_801_height_incl, tvb, bit_offset++, 1, &height_incl, ENC_BIG_ENDIAN);
865 if(height_incl)
867 /* HEIGHT */
868 value = tvb_get_bits16(tvb, bit_offset, 14, ENC_BIG_ENDIAN);
869 proto_tree_add_int_bits_format_value(tree, hf_ansi_801_height, tvb, bit_offset, 14, (gint32)value - 500,
870 "%d m (0x%04x)", (gint32)value - 500, value);
871 bit_offset += 14;
873 /* LOC_UNCRTNTY_V */
874 value = tvb_get_bits8(tvb, bit_offset, 5);
875 switch (value)
877 case 0x1e: str = "> 12288.00 meters"; break;
878 case 0x1f: str = "Not computable"; break;
879 default:
880 fl_value = (float)(0.5 * (1 << (value >> 1)));
881 if (value & 0x01)
882 fl_value *= 1.5f;
883 str = wmem_strdup_printf(wmem_packet_scope(), "%.2f meters", fl_value);
885 proto_tree_add_uint_bits_format_value(tree, hf_ansi_801_loc_uncrtnty_v, tvb, bit_offset, 5, value,
886 "%s (0x%02x)", str, value);
887 bit_offset += 5;
890 if(bit_offset & 0x07)
892 spare_bits = 8 - (bit_offset & 0x07);
893 proto_tree_add_bits_item(tree, hf_ansi_801_reserved_bits, tvb, bit_offset, spare_bits, ENC_BIG_ENDIAN);
894 bit_offset += spare_bits;
897 offset = bit_offset >> 3;
899 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
902 static void
903 for_pr_loc_response(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
905 pr_loc_response(tvb, tree, len, offset);
908 static void
909 for_pr_gps_sat_health(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
911 guint32 bit_offset, spare_bits;
912 guint32 i;
913 guint32 saved_offset, num_bad_sv, bad_sv_prn_num;
914 guint64 bad_sv_present;
916 SHORT_DATA_CHECK(len, 1);
917 saved_offset = offset;
918 bit_offset = offset << 3;
920 /* BAD_SV_PRESENT */
921 proto_tree_add_bits_ret_val(tree, hf_ansi_801_bad_sv_present, tvb, bit_offset++, 1, &bad_sv_present, ENC_BIG_ENDIAN);
923 if (bad_sv_present)
925 /* NUM_BAD_SV */
926 num_bad_sv = tvb_get_bits8(tvb, bit_offset, 4) + 1;
927 proto_tree_add_uint_bits_format_value(tree, hf_ansi_801_num_bad_sv, tvb, bit_offset, 4, num_bad_sv,
928 "%u", num_bad_sv);
929 bit_offset += 4;
931 for (i=0; i < num_bad_sv; i++)
933 /* BAD_SV_PRN_NUM */
934 bad_sv_prn_num = tvb_get_bits8(tvb, bit_offset, 5) + 1;
935 proto_tree_add_uint_bits_format_value(tree, hf_ansi_801_bad_sv_prn_num, tvb, bit_offset, 5, bad_sv_prn_num,
936 "%u", bad_sv_prn_num);
937 bit_offset += 5;
941 if(bit_offset & 0x07)
943 spare_bits = 8 - (bit_offset & 0x07);
944 proto_tree_add_bits_item(tree, hf_ansi_801_reserved_bits, tvb, bit_offset, spare_bits, ENC_BIG_ENDIAN);
945 bit_offset += spare_bits;
948 offset = bit_offset >> 3;
950 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
953 static void
954 rev_req_gps_acq_ass(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
956 guint32 saved_offset;
957 guint32 bit_offset;
959 SHORT_DATA_CHECK(len, 1);
960 saved_offset = offset;
961 bit_offset = offset << 3;
963 proto_tree_add_bits_item(tree, hf_ansi_801_dopp_req, tvb, bit_offset++, 1, ENC_BIG_ENDIAN);
964 proto_tree_add_bits_item(tree, hf_ansi_801_add_dopp_req, tvb, bit_offset++, 1, ENC_BIG_ENDIAN);
965 proto_tree_add_bits_item(tree, hf_ansi_801_code_ph_par_req, tvb, bit_offset++, 1, ENC_BIG_ENDIAN);
966 proto_tree_add_bits_item(tree, hf_ansi_801_az_el_req, tvb, bit_offset++, 1, ENC_BIG_ENDIAN);
967 proto_tree_add_bits_item(tree, hf_ansi_801_reserved_bits, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
968 offset++;
970 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
973 static void
974 rev_req_gps_loc_ass(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
976 guint8 oct;
977 guint32 saved_offset;
979 SHORT_DATA_CHECK(len, 1);
981 saved_offset = offset;
983 oct = tvb_get_guint8(tvb, offset);
985 other_decode_bitfield_value(bigbuf, oct, 0x80, 8);
986 proto_tree_add_text(tree, tvb, offset, 1,
987 "%s : Coordinate type requested: %s coordinates",
988 bigbuf,
989 (oct & 0x80) ? "Spherical" : "Cartesian");
991 other_decode_bitfield_value(bigbuf, oct, 0x7f, 8);
992 proto_tree_add_text(tree, tvb, offset, 1,
993 "%s : Reserved",
994 bigbuf);
996 offset++;
998 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
1001 static void
1002 rev_req_bs_alm(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
1004 guint8 oct;
1005 guint32 saved_offset;
1007 SHORT_DATA_CHECK(len, 1);
1009 saved_offset = offset;
1011 oct = tvb_get_guint8(tvb, offset);
1013 other_decode_bitfield_value(bigbuf, oct, 0x80, 8);
1014 proto_tree_add_text(tree, tvb, offset, 1,
1015 "%s : Extended base station almanac %srequested",
1016 bigbuf,
1017 (oct & 0x80) ? "" : "not ");
1019 other_decode_bitfield_value(bigbuf, oct, 0x7f, 8);
1020 proto_tree_add_text(tree, tvb, offset, 1,
1021 "%s : Reserved",
1022 bigbuf);
1024 offset++;
1026 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
1029 static void
1030 rev_req_gps_ephemeris(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
1032 guint8 oct;
1033 guint32 saved_offset;
1035 SHORT_DATA_CHECK(len, 1);
1037 saved_offset = offset;
1039 oct = tvb_get_guint8(tvb, offset);
1041 other_decode_bitfield_value(bigbuf, oct, 0x80, 8);
1042 proto_tree_add_text(tree, tvb, offset, 1,
1043 "%s : Alpha and Beta parameters %srequested",
1044 bigbuf,
1045 (oct & 0x80) ? "" : "not ");
1047 other_decode_bitfield_value(bigbuf, oct, 0x7f, 8);
1048 proto_tree_add_text(tree, tvb, offset, 1,
1049 "%s : Reserved",
1050 bigbuf);
1052 offset++;
1054 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
1057 static void
1058 rev_req_gps_nav_msg_bits(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
1060 guint8 oct;
1061 guint32 saved_offset;
1063 SHORT_DATA_CHECK(len, 1);
1065 saved_offset = offset;
1067 oct = tvb_get_guint8(tvb, offset);
1069 other_decode_bitfield_value(bigbuf, oct, 0x80, 8);
1070 proto_tree_add_text(tree, tvb, offset, 1,
1071 "%s : Subframes 4 and 5 %srequested",
1072 bigbuf,
1073 (oct & 0x80) ? "" : "not ");
1075 other_decode_bitfield_value(bigbuf, oct, 0x7f, 8);
1076 proto_tree_add_text(tree, tvb, offset, 1,
1077 "%s : Reserved",
1078 bigbuf);
1080 offset++;
1082 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
1085 static void
1086 rev_req_loc_response(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
1088 guint8 oct;
1089 guint32 saved_offset;
1091 SHORT_DATA_CHECK(len, 1);
1093 saved_offset = offset;
1095 oct = tvb_get_guint8(tvb, offset);
1097 other_decode_bitfield_value(bigbuf, oct, 0x80, 8);
1098 proto_tree_add_text(tree, tvb, offset, 1,
1099 "%s : Height information %srequested",
1100 bigbuf,
1101 (oct & 0x80) ? "" : "not ");
1103 other_decode_bitfield_value(bigbuf, oct, 0x40, 8);
1104 proto_tree_add_text(tree, tvb, offset, 1,
1105 "%s : Clock correction for GPS time %srequested",
1106 bigbuf,
1107 (oct & 0x40) ? "" : "not ");
1109 other_decode_bitfield_value(bigbuf, oct, 0x20, 8);
1110 proto_tree_add_text(tree, tvb, offset, 1,
1111 "%s : Velocity information %srequested",
1112 bigbuf,
1113 (oct & 0x20) ? "" : "not ");
1115 other_decode_bitfield_value(bigbuf, oct, 0x1f, 8);
1116 proto_tree_add_text(tree, tvb, offset, 1,
1117 "%s : Reserved",
1118 bigbuf);
1120 offset++;
1122 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
1125 static void
1126 rev_req_gps_alm_correction(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
1128 guint32 saved_offset;
1130 SHORT_DATA_CHECK(len, 2);
1132 saved_offset = offset;
1134 proto_tree_add_text(tree, tvb, offset, 1,
1135 "Time of almanac (in units of 4096 seconds)");
1137 offset++;
1138 proto_tree_add_text(tree, tvb, offset, 1,
1139 "GPS week number (8 least significant bits)");
1141 offset++;
1143 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
1146 static void
1147 rev_reject(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
1149 guint8 oct;
1150 guint32 saved_offset;
1151 const gchar *str = NULL;
1152 gint idx;
1154 saved_offset = offset;
1156 SHORT_DATA_CHECK(len, 1);
1158 oct = tvb_get_guint8(tvb, offset);
1160 str = try_val_to_str_idx((oct & 0xf0) >> 4, for_req_type_strings, &idx);
1161 if (str == NULL)
1163 str = "Reserved";
1166 other_decode_bitfield_value(bigbuf, oct, 0xf0, 8);
1167 proto_tree_add_text(tree, tvb, offset, 1,
1168 "%s : Reject request type: (%u) %s",
1169 bigbuf,
1170 (oct & 0xf0) >> 4,
1171 str);
1173 switch ((oct & 0x0e) >> 1)
1175 case 0x00: str = "Capability not supported by the mobile station"; break;
1176 case 0x01: str = "Capability normally supported by the mobile station but temporarily not available or not enabled"; break;
1177 default: str = "Reserved"; break;
1180 other_decode_bitfield_value(bigbuf, oct, 0x0e, 8);
1181 proto_tree_add_text(tree, tvb, offset, 1,
1182 "%s : Reject reason: %s",
1183 bigbuf,
1184 str);
1186 other_decode_bitfield_value(bigbuf, oct, 0x01, 8);
1187 proto_tree_add_text(tree, tvb, offset, 1,
1188 "%s : Reserved",
1189 bigbuf);
1191 offset++;
1193 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
1196 static void
1197 rev_pr_ms_information(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
1199 guint32 value;
1200 guint32 saved_offset;
1201 const gchar *str = NULL;
1203 saved_offset = offset;
1205 SHORT_DATA_CHECK(len, 5);
1207 value = tvb_get_ntohs(tvb, offset);
1209 other_decode_bitfield_value(bigbuf, value, 0xfc00, 16);
1210 proto_tree_add_text(tree, tvb, offset, 2,
1211 "%s : MS_LS_REV",
1212 bigbuf);
1214 other_decode_bitfield_value(bigbuf, value, 0x03c0, 16);
1215 proto_tree_add_text(tree, tvb, offset, 2,
1216 "%s : MS_MODE",
1217 bigbuf);
1219 switch (value & 0x003f)
1221 case 0x00: str = "Full Chip Measurement Capability"; break;
1222 case 0x01: str = "Half Chip Measurement Capability"; break;
1223 case 0x02: str = "Quarter Chip Measurement Capability"; break;
1224 case 0x03: str = "Eighth Chip Measurement Capability"; break;
1225 case 0x04: str = "One Sixteenth Chip Measurement Capability"; break;
1226 default: str = "Reserved"; break;
1229 other_decode_bitfield_value(bigbuf, value, 0x003f, 16);
1230 proto_tree_add_text(tree, tvb, offset, 2,
1231 "%s : PILOT_PH_CAP: (%u) %s",
1232 bigbuf,
1233 value & 0x3f,
1234 str);
1236 offset += 2;
1237 value = tvb_get_ntoh24(tvb, offset);
1239 other_decode_bitfield_value(bigbuf, value, 0xf80000, 24);
1240 proto_tree_add_text(tree, tvb, offset, 3,
1241 "%s : GPS_ACQ_CAP: Reserved",
1242 bigbuf);
1244 other_decode_bitfield_value(bigbuf, value, 0x040000, 24);
1245 proto_tree_add_text(tree, tvb, offset, 3,
1246 "%s : GPS_ACQ_CAP: GPS Autonomous Acquisition Capable",
1247 bigbuf);
1249 other_decode_bitfield_value(bigbuf, value, 0x020000, 24);
1250 proto_tree_add_text(tree, tvb, offset, 3,
1251 "%s : GPS_ACQ_CAP: GPS Almanac Correction",
1252 bigbuf);
1254 other_decode_bitfield_value(bigbuf, value, 0x010000, 24);
1255 proto_tree_add_text(tree, tvb, offset, 3,
1256 "%s : GPS_ACQ_CAP: GPS Navigation Message Bits",
1257 bigbuf);
1259 other_decode_bitfield_value(bigbuf, value, 0x008000, 24);
1260 proto_tree_add_text(tree, tvb, offset, 3,
1261 "%s : GPS_ACQ_CAP: GPS Ephemeris",
1262 bigbuf);
1264 other_decode_bitfield_value(bigbuf, value, 0x004000, 24);
1265 proto_tree_add_text(tree, tvb, offset, 3,
1266 "%s : GPS_ACQ_CAP: GPS Almanac",
1267 bigbuf);
1269 other_decode_bitfield_value(bigbuf, value, 0x002000, 24);
1270 proto_tree_add_text(tree, tvb, offset, 3,
1271 "%s : GPS_ACQ_CAP: GPS Sensitivity Assistance",
1272 bigbuf);
1274 other_decode_bitfield_value(bigbuf, value, 0x001000, 24);
1275 proto_tree_add_text(tree, tvb, offset, 3,
1276 "%s : GPS_ACQ_CAP: GPS Acquisition Assistance",
1277 bigbuf);
1279 other_decode_bitfield_value(bigbuf, value, 0x000800, 24);
1280 proto_tree_add_text(tree, tvb, offset, 3,
1281 "%s : LOC_CALC_CAP: Pre-programmed Location",
1282 bigbuf);
1284 other_decode_bitfield_value(bigbuf, value, 0x000700, 24);
1285 proto_tree_add_text(tree, tvb, offset, 3,
1286 "%s : LOC_CALC_CAP: Reserved",
1287 bigbuf);
1289 other_decode_bitfield_value(bigbuf, value, 0x000080, 24);
1290 proto_tree_add_text(tree, tvb, offset, 3,
1291 "%s : LOC_CALC_CAP: Hybrid GPS and AFLT Location Calculation Capable",
1292 bigbuf);
1294 other_decode_bitfield_value(bigbuf, value, 0x000040, 24);
1295 proto_tree_add_text(tree, tvb, offset, 3,
1296 "%s : LOC_CALC_CAP: Autonomous Location Calculation Capable",
1297 bigbuf);
1299 other_decode_bitfield_value(bigbuf, value, 0x000020, 24);
1300 proto_tree_add_text(tree, tvb, offset, 3,
1301 "%s : LOC_CALC_CAP: Location Calculation Capable using GPS Almanac Correction",
1302 bigbuf);
1304 other_decode_bitfield_value(bigbuf, value, 0x000010, 24);
1305 proto_tree_add_text(tree, tvb, offset, 3,
1306 "%s : LOC_CALC_CAP: Location Calculation Capable using GPS Ephemeris Assistance",
1307 bigbuf);
1309 other_decode_bitfield_value(bigbuf, value, 0x000008, 24);
1310 proto_tree_add_text(tree, tvb, offset, 3,
1311 "%s : LOC_CALC_CAP: Location Calculation Capable using GPS Almanac Assistance",
1312 bigbuf);
1314 other_decode_bitfield_value(bigbuf, value, 0x000004, 24);
1315 proto_tree_add_text(tree, tvb, offset, 3,
1316 "%s : LOC_CALC_CAP: Advanced Forward Link Trilateration (AFLT) Location Calculation Capable",
1317 bigbuf);
1319 other_decode_bitfield_value(bigbuf, value, 0x000002, 24);
1320 proto_tree_add_text(tree, tvb, offset, 3,
1321 "%s : LOC_CALC_CAP: Location Calculation Capable using Location Assistance - Cartesian",
1322 bigbuf);
1324 other_decode_bitfield_value(bigbuf, value, 0x000001, 24);
1325 proto_tree_add_text(tree, tvb, offset, 3,
1326 "%s : LOC_CALC_CAP: Location Calculation Capable using Location Assistance - Spherical",
1327 bigbuf);
1329 offset += 3;
1331 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
1334 static void
1335 rev_pr_loc_response(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
1337 pr_loc_response(tvb, tree, len, offset);
1340 static void
1341 rev_pr_time_off_meas(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
1343 guint32 value;
1344 guint32 saved_offset;
1346 saved_offset = offset;
1348 SHORT_DATA_CHECK(len, 6);
1350 proto_tree_add_text(tree, tvb, offset, 3,
1351 "TIME_REF_MS: The time of validity of the parameters reported in this response element.");
1353 offset += 3;
1354 value = tvb_get_ntoh24(tvb, offset);
1356 other_decode_bitfield_value(bigbuf, value, 0xff8000, 24);
1357 proto_tree_add_text(tree, tvb, offset, 3,
1358 "%s : REF_PN: (%u)",
1359 bigbuf,
1360 (value & 0xff8000) >> 15);
1362 other_decode_bitfield_value(bigbuf, value, 0x007ffe, 24);
1363 proto_tree_add_text(tree, tvb, offset, 3,
1364 "%s : MOB_SYS_T_OFFSET: (%u)",
1365 bigbuf,
1366 (value & 0x007ffe) >> 1);
1368 other_decode_bitfield_value(bigbuf, value, 0x000001, 24);
1369 proto_tree_add_text(tree, tvb, offset, 3,
1370 "%s : Reserved",
1371 bigbuf);
1373 offset += 3;
1375 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
1378 static void
1379 rev_pr_can_ack(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
1381 guint8 oct;
1382 guint32 saved_offset;
1383 const gchar *str = NULL;
1384 gint idx;
1386 saved_offset = offset;
1388 SHORT_DATA_CHECK(len, 1);
1390 oct = tvb_get_guint8(tvb, offset);
1392 str = try_val_to_str_idx((oct & 0xf0) >> 4, for_req_type_strings, &idx);
1393 if (str == NULL)
1395 str = "Reserved";
1398 other_decode_bitfield_value(bigbuf, oct, 0xf0, 8);
1399 proto_tree_add_text(tree, tvb, offset, 1,
1400 "%s : Cancellation Type: (%u) %s",
1401 bigbuf,
1402 (oct & 0xf0) >> 4,
1403 str);
1405 other_decode_bitfield_value(bigbuf, oct, 0x08, 8);
1406 proto_tree_add_text(tree, tvb, offset, 1,
1407 "%s : No outstanding request element",
1408 bigbuf);
1410 other_decode_bitfield_value(bigbuf, oct, 0x07, 8);
1411 proto_tree_add_text(tree, tvb, offset, 1,
1412 "%s : Reserved",
1413 bigbuf);
1415 offset++;
1417 EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
1420 static void (*for_req_type_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset) = {
1421 NULL, /* Reserved */
1422 NULL, /* no data */ /* Request MS Information */
1423 NULL, /* no data */ /* Request Autonomous Measurement Weighting Factors */
1424 for_req_pseudo_meas, /* Request Pseudorange Measurement */
1425 for_req_pilot_ph_meas, /* Request Pilot Phase Measurement */
1426 for_req_loc_response, /* Request Location Response */
1427 for_req_time_off_meas, /* Request Time Offset Measurement */
1428 for_req_cancel, /* Request Cancellation */
1429 NULL, /* NONE */
1432 static void (*for_rsp_type_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset) = {
1433 for_reject, /* Reject */
1434 for_pr_bs_cap, /* Provide BS Capabilities */
1435 NULL, /* Provide GPS Acquisition Assistance */
1436 NULL, /* Provide GPS Location Assistance Spherical Coordinates */
1437 NULL, /* Provide GPS Location Assistance Cartesian Coordinates */
1438 for_pr_gps_sense_ass, /* Provide GPS Sensitivity Assistance */
1439 NULL, /* Provide Base Station Almanac */
1440 for_pr_gps_almanac, /* Provide GPS Almanac */
1441 NULL, /* Provide GPS Ephemeris */
1442 for_pr_gps_nav_msg_bits, /* Provide GPS Navigation Message Bits */
1443 for_pr_loc_response, /* Provide Location Response */
1444 NULL, /* Provide GPS Almanac Correction */
1445 for_pr_gps_sat_health, /* Provide GPS Satellite Health Information */
1446 NULL, /* NONE */
1449 static void (*rev_req_type_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset) = {
1450 NULL, /* Reserved */
1451 NULL, /* no data */ /* Request BS Capabilities */
1452 rev_req_gps_acq_ass, /* Request GPS Acquisition Assistance */
1453 rev_req_gps_loc_ass, /* Request GPS Location Assistance */
1454 NULL, /* Reserved */
1455 NULL, /* no data */ /* Request GPS Sensitivity Assistance */
1456 rev_req_bs_alm, /* Request Base Station Almanac */
1457 NULL, /* no data */ /* Request GPS Almanac */
1458 rev_req_gps_ephemeris, /* Request GPS Ephemeris */
1459 rev_req_gps_nav_msg_bits, /* Request GPS Navigation Message Bits */
1460 rev_req_loc_response, /* Request Location Response */
1461 rev_req_gps_alm_correction, /* Request GPS Almanac Correction */
1462 NULL, /* no data */ /* Request GPS Satellite Health Information */
1463 NULL, /* NONE */
1466 static void (*rev_rsp_type_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset) = {
1467 rev_reject, /* Reject */
1468 rev_pr_ms_information, /* Provide MS Information */
1469 NULL, /* Provide Autonomous Measurement Weighting Factors */
1470 NULL, /* Provide Pseudorange Measurement */
1471 NULL, /* Provide Pilot Phase Measurement */
1472 rev_pr_loc_response, /* Provide Location Response */
1473 rev_pr_time_off_meas, /* Provide Time Offset Measurement */
1474 rev_pr_can_ack, /* Provide Cancellation Acknowledgement */
1475 NULL, /* NONE */
1478 static void
1479 for_request(tvbuff_t *tvb, proto_tree *tree, guint32 *offset_p, guint8 pd_msg_type)
1481 guint32 offset;
1482 guint8 oct;
1483 const gchar *str = NULL;
1484 gint idx;
1485 proto_tree *subtree;
1486 proto_item *item;
1488 offset = *offset_p;
1489 oct = tvb_get_guint8(tvb, offset);
1491 if (pd_msg_type == 0x00)
1493 other_decode_bitfield_value(bigbuf, oct, 0xf0, 8);
1494 proto_tree_add_text(tree, tvb, offset, 1,
1495 "%s : Reserved",
1496 bigbuf);
1498 str = try_val_to_str_idx(oct & 0x0f, for_req_type_strings, &idx);
1499 if (str == NULL)
1501 return;
1504 other_decode_bitfield_value(bigbuf, oct, 0x0f, 8);
1505 item =
1506 proto_tree_add_uint_format(tree, hf_ansi_801_for_req_type, tvb, offset,
1507 1, oct & 0x0f,
1508 "%s : Request Type, %s (%u)",
1509 bigbuf,
1510 str,
1511 oct & 0x0f);
1513 else
1515 /* TBD */
1517 * It is unclear from TIA-801-A how this was meant to be decoded.
1518 * Are the elements supposed to be byte aligned?
1520 return;
1523 subtree = proto_item_add_subtree(item, ett_for_req_type[idx]);
1525 offset++;
1526 oct = tvb_get_guint8(tvb, offset);
1528 proto_tree_add_text(subtree, tvb, offset, 1,
1529 "Length: %u",
1530 oct);
1532 offset++;
1534 if (oct > 0)
1536 if (for_req_type_fcn[idx] != NULL)
1538 (*for_req_type_fcn[idx])(tvb, subtree, oct, offset);
1540 else
1542 proto_tree_add_text(subtree, tvb, offset, oct,
1543 "Data");
1547 *offset_p = offset + oct;
1550 static void
1551 for_response(tvbuff_t *tvb, proto_tree *tree, guint32 *offset_p)
1553 guint32 offset;
1554 guint8 oct;
1555 const gchar *str = NULL;
1556 gint idx;
1557 proto_tree *subtree;
1558 proto_item *item;
1560 offset = *offset_p;
1561 oct = tvb_get_guint8(tvb, offset);
1563 other_decode_bitfield_value(bigbuf, oct, 0xe0, 8);
1564 proto_tree_add_text(tree, tvb, offset, 1,
1565 "%s : Reserved",
1566 bigbuf);
1568 other_decode_bitfield_value(bigbuf, oct, 0x10, 8);
1569 proto_tree_add_text(tree, tvb, offset, 1,
1570 "%s : Unsolicited response indicator",
1571 bigbuf);
1573 str = try_val_to_str_idx(oct & 0x0f, for_rsp_type_strings, &idx);
1575 if (str == NULL)
1577 return;
1580 other_decode_bitfield_value(bigbuf, oct, 0x0f, 8);
1581 item =
1582 proto_tree_add_uint_format(tree, hf_ansi_801_for_rsp_type, tvb, offset,
1583 1, oct & 0x0f,
1584 "%s : Response Type, %s (%u)",
1585 bigbuf,
1586 str,
1587 oct & 0x0f);
1589 subtree = proto_item_add_subtree(item, ett_for_rsp_type[idx]);
1591 offset++;
1592 oct = tvb_get_guint8(tvb, offset);
1594 proto_tree_add_text(subtree, tvb, offset, 1,
1595 "Length: %u",
1596 oct);
1598 offset++;
1600 if (for_rsp_type_fcn[idx] != NULL)
1602 (*for_rsp_type_fcn[idx])(tvb, subtree, oct, offset);
1604 else
1606 proto_tree_add_text(subtree, tvb, offset, oct,
1607 "Data");
1610 *offset_p = offset + oct;
1613 static void
1614 rev_request(tvbuff_t *tvb, proto_tree *tree, guint32 *offset_p, guint8 pd_msg_type)
1616 guint32 offset;
1617 guint8 oct;
1618 const gchar *str = NULL;
1619 gint idx;
1620 proto_tree *subtree;
1621 proto_item *item;
1623 offset = *offset_p;
1624 oct = tvb_get_guint8(tvb, offset);
1626 if (pd_msg_type == 0x00)
1628 other_decode_bitfield_value(bigbuf, oct, 0xf0, 8);
1629 proto_tree_add_text(tree, tvb, offset, 1,
1630 "%s : Reserved",
1631 bigbuf);
1633 str = try_val_to_str_idx(oct & 0x0f, rev_req_type_strings, &idx);
1634 if (str == NULL)
1636 return;
1639 other_decode_bitfield_value(bigbuf, oct, 0x0f, 8);
1640 item =
1641 proto_tree_add_uint_format(tree, hf_ansi_801_rev_req_type, tvb, offset,
1642 1, oct & 0x0f,
1643 "%s : Request Type, %s (%u)",
1644 bigbuf,
1645 str,
1646 oct & 0x0f);
1648 else
1650 /* TBD */
1652 * It is unclear from TIA-801-A how this was meant to be decoded.
1653 * Are the elements supposed to be byte aligned?
1655 return;
1658 subtree = proto_item_add_subtree(item, ett_rev_req_type[idx]);
1660 offset++;
1661 oct = tvb_get_guint8(tvb, offset);
1663 proto_tree_add_text(subtree, tvb, offset, 1,
1664 "Length: %u",
1665 oct);
1667 offset++;
1669 if (rev_req_type_fcn[idx] != NULL)
1671 (*rev_req_type_fcn[idx])(tvb, subtree, oct, offset);
1673 else
1675 proto_tree_add_text(subtree, tvb, offset, oct,
1676 "Data");
1679 *offset_p = offset + oct;
1682 static void
1683 rev_response(tvbuff_t *tvb, proto_tree *tree, guint32 *offset_p)
1685 guint32 offset;
1686 guint8 oct;
1687 const gchar *str = NULL;
1688 gint idx;
1689 proto_tree *subtree;
1690 proto_item *item;
1692 offset = *offset_p;
1693 oct = tvb_get_guint8(tvb, offset);
1695 other_decode_bitfield_value(bigbuf, oct, 0xe0, 8);
1696 proto_tree_add_text(tree, tvb, offset, 1,
1697 "%s : Reserved",
1698 bigbuf);
1700 other_decode_bitfield_value(bigbuf, oct, 0x10, 8);
1701 proto_tree_add_text(tree, tvb, offset, 1,
1702 "%s : Unsolicited response indicator",
1703 bigbuf);
1705 str = try_val_to_str_idx(oct & 0x0f, rev_rsp_type_strings, &idx);
1707 if (str == NULL)
1709 return;
1712 other_decode_bitfield_value(bigbuf, oct, 0x0f, 8);
1713 item =
1714 proto_tree_add_uint_format(tree, hf_ansi_801_rev_rsp_type, tvb, offset,
1715 1, oct & 0x0f,
1716 "%s : Response Type, %s (%u)",
1717 bigbuf,
1718 str,
1719 oct & 0x0f);
1721 subtree = proto_item_add_subtree(item, ett_rev_rsp_type[idx]);
1723 offset++;
1724 oct = tvb_get_guint8(tvb, offset);
1726 proto_tree_add_text(subtree, tvb, offset, 1,
1727 "Length: %u",
1728 oct);
1730 offset++;
1732 if (rev_rsp_type_fcn[idx] != NULL)
1734 (*rev_rsp_type_fcn[idx])(tvb, subtree, oct, offset);
1736 else
1738 proto_tree_add_text(subtree, tvb, offset, oct,
1739 "Data");
1742 *offset_p = offset + oct;
1745 static void
1746 dissect_ansi_801_for_message(tvbuff_t *tvb, proto_tree *tree)
1748 guint32 value;
1749 guint32 offset;
1750 guint8 oct, num_req, num_rsp, pd_msg_type;
1751 guint rem_len;
1752 const gchar *str = NULL;
1753 proto_item *hidden_item;
1755 offset = 0;
1756 oct = tvb_get_guint8(tvb, offset);
1758 other_decode_bitfield_value(bigbuf, oct, 0x80, 8);
1759 proto_tree_add_text(tree, tvb, offset, 1,
1760 "%s : Session Start",
1761 bigbuf);
1763 other_decode_bitfield_value(bigbuf, oct, 0x40, 8);
1764 proto_tree_add_text(tree, tvb, offset, 1,
1765 "%s : Session End",
1766 bigbuf);
1768 other_decode_bitfield_value(bigbuf, oct, 0x20, 8);
1769 proto_tree_add_text(tree, tvb, offset, 1,
1770 "%s : Session Source",
1771 bigbuf);
1773 other_decode_bitfield_value(bigbuf, oct, 0x1f, 8);
1774 proto_tree_add_uint_format(tree, hf_ansi_801_for_sess_tag, tvb, offset,
1775 1, oct & 0x1f,
1776 "%s : Session Tag (%u)",
1777 bigbuf,
1778 oct & 0x1f);
1780 hidden_item = proto_tree_add_uint(tree, hf_ansi_801_sess_tag, tvb, offset,
1781 1, oct & 0x1f);
1782 PROTO_ITEM_SET_HIDDEN(hidden_item);
1784 offset++;
1785 oct = tvb_get_guint8(tvb, offset);
1786 pd_msg_type = oct;
1788 switch (pd_msg_type)
1790 case 0x00: str = "Position Determination Data Message"; break;
1791 case 0x01: str = "Position Determination Data Message"; break;
1792 case 0xff: str = "Reserved"; break;
1793 default:
1794 if (pd_msg_type < 0xc0)
1796 str = "Reserved for future standardization";
1798 else
1800 str =
1801 "Available for manufacturer-specific Position Determination "
1802 "Data Message definition as specified in TSB-58";
1804 break;
1807 other_decode_bitfield_value(bigbuf, pd_msg_type, 0xff, 8);
1808 proto_tree_add_text(tree, tvb, offset, 1,
1809 "%s : PD Message Type, %s (%u)",
1810 bigbuf,
1811 str,
1812 pd_msg_type);
1814 offset++;
1816 if ((pd_msg_type != 0x00) &&
1817 (pd_msg_type != 0x01))
1819 proto_tree_add_text(tree, tvb, offset, -1,
1820 "Reserved/Proprietary/Future Data");
1821 return;
1824 if (pd_msg_type == 0x01)
1826 value = tvb_get_ntohs(tvb, offset);
1828 other_decode_bitfield_value(bigbuf, value, 0xffc0, 16);
1829 proto_tree_add_text(tree, tvb, offset, 2,
1830 "%s : PD Message Length, (%u)",
1831 bigbuf,
1832 (value & 0xffc0) >> 6);
1834 switch ((value & 0x0030) >> 4)
1836 case 0x00: str = "No Regulatory service"; break;
1837 case 0x01: str = "Emergency service"; break;
1838 default: str = "Reserved"; break;
1841 other_decode_bitfield_value(bigbuf, value, 0x0030, 16);
1842 proto_tree_add_text(tree, tvb, offset, 2,
1843 "%s : Regulatory Services Indicator - %s (%u)",
1844 bigbuf,
1845 str,
1846 (value & 0x0030) >> 4);
1848 num_req = value & 0x000f;
1850 other_decode_bitfield_value(bigbuf, value, 0x000f, 16);
1851 proto_tree_add_text(tree, tvb, offset, 2,
1852 "%s : Number Requests (%u)",
1853 bigbuf,
1854 num_req);
1856 offset += 2;
1858 oct = tvb_get_guint8(tvb, offset);
1860 num_rsp = oct & 0xf0;
1862 other_decode_bitfield_value(bigbuf, oct, 0xf0, 8);
1863 proto_tree_add_text(tree, tvb, offset, 1,
1864 "%s : Number Responses (%u)",
1865 bigbuf,
1866 num_rsp);
1868 offset++;
1870 else
1872 oct = tvb_get_guint8(tvb, offset);
1874 num_req = (oct & 0xf0) >> 4;
1875 num_rsp = oct & 0x0f;
1877 other_decode_bitfield_value(bigbuf, oct, 0xf0, 8);
1878 proto_tree_add_text(tree, tvb, offset, 1,
1879 "%s : Number Requests (%u)",
1880 bigbuf,
1881 num_req);
1883 other_decode_bitfield_value(bigbuf, oct, 0x0f, 8);
1884 proto_tree_add_text(tree, tvb, offset, 1,
1885 "%s : Number Responses (%u)",
1886 bigbuf,
1887 num_rsp);
1890 offset++;
1891 rem_len = tvb_length_remaining(tvb, offset);
1893 while ((num_req > 0) &&
1894 (rem_len >= 2))
1896 for_request(tvb, tree, &offset, pd_msg_type);
1898 rem_len = tvb_length_remaining(tvb, offset);
1899 num_req--;
1902 if (num_req != 0)
1904 proto_tree_add_text(tree, tvb,
1905 offset, -1, "Short Data (?)");
1906 return;
1909 while ((num_rsp > 0) &&
1910 (rem_len >= 2))
1912 for_response(tvb, tree, &offset);
1914 rem_len = tvb_length_remaining(tvb, offset);
1915 num_rsp--;
1918 if (num_rsp != 0)
1920 proto_tree_add_text(tree, tvb,
1921 offset, -1, "Short Data (?)");
1922 return;
1925 if (rem_len > 0)
1927 proto_tree_add_text(tree, tvb, offset, rem_len,
1928 "Extraneous Data");
1932 static void
1933 dissect_ansi_801_rev_message(tvbuff_t *tvb, proto_tree *tree)
1935 guint32 value;
1936 guint32 offset;
1937 guint8 oct, num_req, num_rsp, pd_msg_type;
1938 guint rem_len;
1939 const gchar *str = NULL;
1940 proto_item *hidden_item;
1942 offset = 0;
1943 oct = tvb_get_guint8(tvb, offset);
1945 other_decode_bitfield_value(bigbuf, oct, 0x80, 8);
1946 proto_tree_add_text(tree, tvb, offset, 1,
1947 "%s : Session Start",
1948 bigbuf);
1950 other_decode_bitfield_value(bigbuf, oct, 0x40, 8);
1951 proto_tree_add_text(tree, tvb, offset, 1,
1952 "%s : Session End",
1953 bigbuf);
1955 other_decode_bitfield_value(bigbuf, oct, 0x20, 8);
1956 proto_tree_add_text(tree, tvb, offset, 1,
1957 "%s : Session Source",
1958 bigbuf);
1960 other_decode_bitfield_value(bigbuf, oct, 0x1f, 8);
1961 proto_tree_add_uint_format(tree, hf_ansi_801_rev_sess_tag, tvb, offset,
1962 1, oct & 0x1f,
1963 "%s : Session Tag (%u)",
1964 bigbuf,
1965 oct & 0x1f);
1967 hidden_item = proto_tree_add_uint(tree, hf_ansi_801_sess_tag, tvb, offset,
1968 1, oct & 0x1f);
1969 PROTO_ITEM_SET_HIDDEN(hidden_item);
1971 offset++;
1972 oct = tvb_get_guint8(tvb, offset);
1973 pd_msg_type = oct;
1975 switch (pd_msg_type)
1977 case 0x00: str = "Position Determination Data Message"; break;
1978 case 0x01: str = "Position Determination Data Message"; break;
1979 case 0xff: str = "Reserved"; break;
1980 default:
1981 if (pd_msg_type < 0xc0)
1983 str = "Reserved for future standardization";
1985 else
1987 str =
1988 "Available for manufacturer-specific Position Determination "
1989 "Data Message definition as specified in TSB-58";
1991 break;
1994 other_decode_bitfield_value(bigbuf, pd_msg_type, 0xff, 8);
1995 proto_tree_add_text(tree, tvb, offset, 1,
1996 "%s : PD Message Type, %s (%u)",
1997 bigbuf,
1998 str,
1999 pd_msg_type);
2001 offset++;
2003 if ((pd_msg_type != 0x00) &&
2004 (pd_msg_type != 0x01))
2006 proto_tree_add_text(tree, tvb, offset, -1,
2007 "Reserved/Proprietary/Future Data");
2008 return;
2011 if (pd_msg_type == 0x01)
2013 value = tvb_get_ntohs(tvb, offset);
2015 other_decode_bitfield_value(bigbuf, value, 0xffc0, 16);
2016 proto_tree_add_text(tree, tvb, offset, 2,
2017 "%s : PD Message Length, (%u)",
2018 bigbuf,
2019 (value & 0xffc0) >> 6);
2021 switch ((value & 0x0030) >> 4)
2023 case 0x00: str = "No Regulatory service"; break;
2024 case 0x01: str = "Emergency service"; break;
2025 default: str = "Reserved"; break;
2028 other_decode_bitfield_value(bigbuf, value, 0x0030, 16);
2029 proto_tree_add_text(tree, tvb, offset, 2,
2030 "%s : Regulatory Services Indicator - %s (%u)",
2031 bigbuf,
2032 str,
2033 (value & 0x0030) >> 4);
2035 num_req = value & 0x000f;
2037 other_decode_bitfield_value(bigbuf, value, 0x000f, 16);
2038 proto_tree_add_text(tree, tvb, offset, 2,
2039 "%s : Number Requests (%u)",
2040 bigbuf,
2041 num_req);
2043 offset += 2;
2045 oct = tvb_get_guint8(tvb, offset);
2047 num_rsp = oct & 0xf0;
2049 other_decode_bitfield_value(bigbuf, oct, 0xf0, 8);
2050 proto_tree_add_text(tree, tvb, offset, 1,
2051 "%s : Number Responses (%u)",
2052 bigbuf,
2053 num_rsp);
2055 offset++;
2057 else
2059 oct = tvb_get_guint8(tvb, offset);
2061 num_req = (oct & 0xf0) >> 4;
2062 num_rsp = oct & 0x0f;
2064 other_decode_bitfield_value(bigbuf, oct, 0xf0, 8);
2065 proto_tree_add_text(tree, tvb, offset, 1,
2066 "%s : Number Requests (%u)",
2067 bigbuf,
2068 num_req);
2070 other_decode_bitfield_value(bigbuf, oct, 0x0f, 8);
2071 proto_tree_add_text(tree, tvb, offset, 1,
2072 "%s : Number Responses (%u)",
2073 bigbuf,
2074 num_rsp);
2076 offset++;
2079 rem_len = tvb_length_remaining(tvb, offset);
2081 while ((num_req > 0) &&
2082 (rem_len >= 2))
2084 rev_request(tvb, tree, &offset, pd_msg_type);
2086 rem_len = tvb_length_remaining(tvb, offset);
2087 num_req--;
2090 if (num_req != 0)
2092 proto_tree_add_text(tree, tvb,
2093 offset, -1, "Short Data (?)");
2094 return;
2097 while ((num_rsp > 0) &&
2098 (rem_len >= 2))
2100 rev_response(tvb, tree, &offset);
2102 rem_len = tvb_length_remaining(tvb, offset);
2103 num_rsp--;
2106 if (num_rsp != 0)
2108 proto_tree_add_text(tree, tvb,
2109 offset, -1, "Short Data (?)");
2110 return;
2113 if (rem_len > 0)
2115 proto_tree_add_text(tree, tvb, offset, rem_len,
2116 "Extraneous Data");
2120 static void
2121 dissect_ansi_801(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2123 proto_item *ansi_801_item;
2124 proto_tree *ansi_801_tree = NULL;
2126 col_set_str(pinfo->cinfo, COL_PROTOCOL, ansi_proto_name_short);
2128 /* In the interest of speed, if "tree" is NULL, don't do any work not
2129 * necessary to generate protocol tree items.
2131 if (tree)
2134 * create the ansi_801 protocol tree
2136 ansi_801_item =
2137 proto_tree_add_protocol_format(tree, proto_ansi_801, tvb, 0, -1,
2138 "%s %s Link",
2139 ansi_proto_name,
2140 (pinfo->match_uint == ANSI_801_FORWARD) ? "Forward" : "Reverse");
2142 ansi_801_tree =
2143 proto_item_add_subtree(ansi_801_item, ett_ansi_801);
2145 if (pinfo->match_uint == ANSI_801_FORWARD)
2147 dissect_ansi_801_for_message(tvb, ansi_801_tree);
2149 else
2151 dissect_ansi_801_rev_message(tvb, ansi_801_tree);
2157 /* Register the protocol with Wireshark */
2158 void
2159 proto_register_ansi_801(void)
2161 guint i;
2162 gint last_offset;
2164 /* Setup list of header fields */
2165 static hf_register_info hf[] =
2167 { &hf_ansi_801_for_req_type,
2168 { "Forward Request Type", "ansi_801.for_req_type",
2169 FT_UINT8, BASE_DEC, NULL, 0,
2170 NULL, HFILL }
2172 { &hf_ansi_801_for_rsp_type,
2173 { "Forward Response Type", "ansi_801.for_rsp_type",
2174 FT_UINT8, BASE_DEC, NULL, 0,
2175 NULL, HFILL }
2177 { &hf_ansi_801_rev_req_type,
2178 { "Reverse Request Type", "ansi_801.rev_req_type",
2179 FT_UINT8, BASE_DEC, NULL, 0,
2180 NULL, HFILL }
2182 { &hf_ansi_801_rev_rsp_type,
2183 { "Reverse Response Type", "ansi_801.rev_rsp_type",
2184 FT_UINT8, BASE_DEC, NULL, 0,
2185 NULL, HFILL }
2187 { &hf_ansi_801_for_sess_tag,
2188 { "Forward Session Tag", "ansi_801.for_sess_tag",
2189 FT_UINT8, BASE_DEC, NULL, 0,
2190 NULL, HFILL }
2192 { &hf_ansi_801_rev_sess_tag,
2193 { "Reverse Session Tag", "ansi_801.rev_sess_tag",
2194 FT_UINT8, BASE_DEC, NULL, 0,
2195 NULL, HFILL }
2197 { &hf_ansi_801_sess_tag,
2198 { "Session Tag", "ansi_801.sess_tag",
2199 FT_UINT8, BASE_DEC, NULL, 0,
2200 NULL, HFILL }
2202 { &hf_ansi_801_time_ref_cdma,
2203 { "CDMA system time at the time the solution is valid (TIME_REF_CDMA)", "ansi_801.time_ref_cdma",
2204 FT_UINT32, BASE_DEC, NULL, 0x00,
2205 NULL, HFILL }
2207 { &hf_ansi_801_lat,
2208 { "Latitude (LAT)", "ansi_801.lat",
2209 FT_FLOAT, BASE_NONE, NULL, 0x00,
2210 NULL, HFILL }
2212 { &hf_ansi_801_long,
2213 { "Longitude (LONG)", "ansi_801.long",
2214 FT_FLOAT, BASE_NONE, NULL, 0x00,
2215 NULL, HFILL }
2217 { &hf_ansi_801_loc_uncrtnty_ang,
2218 { "Angle of axis with respect to True North for pos uncertainty (LOC_UNCRTNTY_ANG)", "ansi_801.loc_uncrtnty_ang",
2219 FT_FLOAT, BASE_NONE, NULL, 0x00,
2220 NULL, HFILL }
2222 { &hf_ansi_801_loc_uncrtnty_a,
2223 { "Std dev of axis along angle specified for pos uncertainty (LOC_UNCRTNTY_A)", "ansi_801.loc_uncrtnty_a",
2224 FT_UINT8, BASE_DEC, NULL, 0x00,
2225 NULL, HFILL }
2227 { &hf_ansi_801_loc_uncrtnty_p,
2228 { "Std dev of axis perpendicular to angle specified for pos uncertainty (LOC_UNCRTNTY_P)", "ansi_801.loc_uncrtnty_p",
2229 FT_UINT8, BASE_DEC, NULL, 0x00,
2230 NULL, HFILL }
2232 { &hf_ansi_801_fix_type,
2233 { "Fix type (FIX_TYPE)", "ansi_801.fix_type",
2234 FT_BOOLEAN, BASE_NONE, TFS(&ansi_801_fix_type_vals), 0x00,
2235 NULL, HFILL }
2237 { &hf_ansi_801_velocity_incl,
2238 { "Velocity information included (VELOCITY_INCL)", "ansi_801.velocity_incl",
2239 FT_BOOLEAN, BASE_NONE, NULL, 0x00,
2240 NULL, HFILL }
2242 { &hf_ansi_801_velocity_hor,
2243 { "Horizontal velocity magnitude (VELOCITY_HOR)", "ansi_801.velocity_hor",
2244 FT_FLOAT, BASE_NONE, NULL, 0x00,
2245 NULL, HFILL }
2247 { &hf_ansi_801_heading,
2248 { "Heading (HEADING)", "ansi_801.heading",
2249 FT_FLOAT, BASE_NONE, NULL, 0x00,
2250 NULL, HFILL }
2252 { &hf_ansi_801_velocity_ver,
2253 { "Vertical velocity (VELOCITY_VER)", "ansi_801.velocity_ver",
2254 FT_FLOAT, BASE_NONE, NULL, 0x00,
2255 NULL, HFILL }
2257 { &hf_ansi_801_clock_incl,
2258 { "Clock information included (CLOCK_INCL)", "ansi_801.clock_incl",
2259 FT_BOOLEAN, BASE_NONE, NULL, 0x00,
2260 NULL, HFILL }
2262 { &hf_ansi_801_clock_bias,
2263 { "Clock bias (CLOCK_BIAS)", "ansi_801.clock_bias",
2264 FT_INT24, BASE_DEC, NULL, 0x00,
2265 NULL, HFILL }
2267 { &hf_ansi_801_clock_drift,
2268 { "Clock drift (CLOCK_DRIFT)", "ansi_801.clock_drift",
2269 FT_INT16, BASE_DEC, NULL, 0x00,
2270 NULL, HFILL }
2272 { &hf_ansi_801_height_incl,
2273 { "Height information included (HEIGHT_INCL)", "ansi_801.height_incl",
2274 FT_BOOLEAN, BASE_NONE, NULL, 0x00,
2275 NULL, HFILL }
2277 { &hf_ansi_801_height,
2278 { "Height (HEIGHT)", "ansi_801.height",
2279 FT_INT16, BASE_DEC, NULL, 0x00,
2280 NULL, HFILL }
2282 { &hf_ansi_801_loc_uncrtnty_v,
2283 { "Std dev of vertical error for pos uncertainty (LOC_UNCRTNTY_V)", "ansi_801.loc_uncrtnty_v",
2284 FT_UINT8, BASE_DEC, NULL, 0x00,
2285 NULL, HFILL }
2287 { &hf_ansi_801_reserved_bits,
2288 { "Reserved bit(s)","ansi_801.reerved_bits",
2289 FT_UINT8,BASE_DEC, NULL, 0x0,
2290 NULL, HFILL }
2292 { &hf_ansi_801_bad_sv_present,
2293 { "Bad GPS satellites present (BAD_SV_PRESENT)", "ansi_801.bad_sv_present",
2294 FT_BOOLEAN, BASE_NONE, NULL, 0x00,
2295 NULL, HFILL }
2297 { &hf_ansi_801_num_bad_sv,
2298 { "Number of bad GPS satellites (NUM_BAD_SV)", "ansi_801.num_bad_sv",
2299 FT_UINT8, BASE_DEC, NULL, 0x00,
2300 NULL, HFILL }
2302 { &hf_ansi_801_bad_sv_prn_num,
2303 { "Satellite PRN number (SV_PRN_NUM)", "ansi_801.bad_sv_prn_num",
2304 FT_UINT8, BASE_DEC, NULL, 0x00,
2305 NULL, HFILL }
2307 { &hf_ansi_801_dopp_req,
2308 { "Doppler (0th order) term requested (DOPP_REQ)", "ansi_801.dopp_req",
2309 FT_BOOLEAN, BASE_NONE, NULL, 0x00,
2310 NULL, HFILL }
2312 { &hf_ansi_801_add_dopp_req,
2313 { "Additional Doppler terms requested (ADD_DOPP_REQ)", "ansi_801.add_dopp_req",
2314 FT_BOOLEAN, BASE_NONE, NULL, 0x00,
2315 NULL, HFILL }
2317 { &hf_ansi_801_code_ph_par_req,
2318 { "Code phase parameters requested (CODE_PH_PAR_REQ)", "ansi_801.code_ph_par_req",
2319 FT_BOOLEAN, BASE_NONE, NULL, 0x00,
2320 NULL, HFILL }
2322 { &hf_ansi_801_az_el_req,
2323 { "Azimuth and elevation angle requested (AZ_EL_REQ)", "ansi_801.az_el_req",
2324 FT_BOOLEAN, BASE_NONE, NULL, 0x00,
2325 NULL, HFILL }
2327 { &hf_ansi_801_pref_resp_qual,
2328 { "Preferred response quality (PREF_RESP_QUAL)", "ansi_801.pref_resp_qual",
2329 FT_UINT8, BASE_DEC, NULL, 0x00,
2330 NULL, HFILL }
2332 { &hf_ansi_801_num_fixes,
2333 { "Number of fixes (NUM_FIXES)", "ansi_801.num_fixes",
2334 FT_UINT16, BASE_DEC, NULL, 0x00,
2335 NULL, HFILL }
2337 { &hf_ansi_801_t_betw_fixes,
2338 { "Time between fixes (T_BETW_FIXES)", "ansi_801.t_betw_fixes",
2339 FT_UINT8, BASE_DEC, NULL, 0x00,
2340 NULL, HFILL }
2342 { &hf_ansi_801_offset_req,
2343 { "Offset requested (OFFSET_REQ)", "ansi_801.offset_req",
2344 FT_BOOLEAN, BASE_NONE, NULL, 0x00,
2345 NULL, HFILL }
2350 /* Setup protocol subtree array */
2351 #define NUM_INDIVIDUAL_PARAMS 1
2352 gint *ett[NUM_INDIVIDUAL_PARAMS+NUM_FOR_REQ_TYPE+NUM_FOR_RSP_TYPE+NUM_REV_REQ_TYPE+NUM_REV_RSP_TYPE];
2354 ett[0] = &ett_ansi_801;
2356 last_offset = NUM_INDIVIDUAL_PARAMS;
2358 for (i=0; i < NUM_FOR_REQ_TYPE; i++, last_offset++)
2360 ett_for_req_type[i] = -1;
2361 ett[last_offset] = &ett_for_req_type[i];
2364 for (i=0; i < NUM_FOR_RSP_TYPE; i++, last_offset++)
2366 ett_for_rsp_type[i] = -1;
2367 ett[last_offset] = &ett_for_rsp_type[i];
2370 for (i=0; i < NUM_REV_REQ_TYPE; i++, last_offset++)
2372 ett_rev_req_type[i] = -1;
2373 ett[last_offset] = &ett_rev_req_type[i];
2376 for (i=0; i < NUM_REV_RSP_TYPE; i++, last_offset++)
2378 ett_rev_rsp_type[i] = -1;
2379 ett[last_offset] = &ett_rev_rsp_type[i];
2382 /* Register the protocol name and description */
2383 proto_ansi_801 =
2384 proto_register_protocol(ansi_proto_name, "ANSI IS-801 (Location Services (PLD))", "ansi_801");
2386 /* Required function calls to register the header fields and subtrees used */
2387 proto_register_field_array(proto_ansi_801, hf, array_length(hf));
2388 proto_register_subtree_array(ett, array_length(ett));
2390 /* subdissector code */
2391 ansi_801_handle = register_dissector("ansi_801", dissect_ansi_801, proto_ansi_801);
2395 void
2396 proto_reg_handoff_ansi_801(void)
2398 dissector_add_uint("ansi_map.pld", ANSI_801_FORWARD, ansi_801_handle);
2399 dissector_add_uint("ansi_map.pld", ANSI_801_REVERSE, ansi_801_handle);
2400 dissector_add_uint("ansi_a.pld", ANSI_801_FORWARD, ansi_801_handle);
2401 dissector_add_uint("ansi_a.pld", ANSI_801_REVERSE, ansi_801_handle);