/src/wireshark/epan/dissectors/packet-ppi-sensor.c
Line | Count | Source |
1 | | /* packet-ppi-sensor.c |
2 | | * Routines for PPI-GEOLOCATION-SENSOR dissection |
3 | | * Copyright 2010, Harris Corp, jellch@harris.com |
4 | | * |
5 | | * Wireshark - Network traffic analyzer |
6 | | * By Gerald Combs <gerald@wireshark.org> |
7 | | * Copyright 1998 Gerald Combs |
8 | | * |
9 | | * Copied from packet-ppi-antenna.c |
10 | | * |
11 | | * SPDX-License-Identifier: GPL-2.0-or-later |
12 | | */ |
13 | | |
14 | | #include "config.h" |
15 | | |
16 | | #include <epan/packet.h> |
17 | | #include <epan/expert.h> |
18 | | #include "packet-ppi-geolocation-common.h" |
19 | | |
20 | | enum ppi_sensor_type { |
21 | | PPI_SENSOR_SENSORTYPE = 0, /* Velocity, Acceleration, etc */ |
22 | | PPI_SENSOR_SCALEFACTOR = 1, /* 10^scalefactor applied to all values */ |
23 | | PPI_SENSOR_VAL_X = 2, /* X-dimension reading */ |
24 | | PPI_SENSOR_VAL_Y = 3, /* Y-dimension reading */ |
25 | | PPI_SENSOR_VAL_Z = 4, /* Z-dimension reading */ |
26 | | PPI_SENSOR_VAL_T = 5, /* Total reading */ |
27 | | PPI_SENSOR_VAL_E = 6, /* Error reading */ |
28 | | PPI_SENSOR_DESCSTR = 28, /*32 bytes, fixed length, null terminated description of what the sensor is for */ |
29 | | PPI_SENSOR_APPID = 29, /*4-byte identifier*/ |
30 | | PPI_SENSOR_APPDATA = 30, /* 60-byte app-id specific data*/ |
31 | | PPI_SENSOR_EXT = 31 /* Indicates n extended bitmap follows */ |
32 | | }; |
33 | 0 | #define PPI_SENSOR_MAXTAGLEN 127 /* Increase as fields are added */ |
34 | | |
35 | | |
36 | | /*Sensor types */ |
37 | | #define SENSOR_RESERVED0 0 |
38 | | /*The values of these sensors corresponds to the order of their derivatives. double geek win */ |
39 | | #define SENSOR_VELOCITY 1 |
40 | | #define SENSOR_ACCELERATION 2 |
41 | | #define SENSOR_JERK 3 |
42 | | #define SENSOR_ROTATION 100 |
43 | | #define SENSOR_MAGNETIC 101 |
44 | | #define SENSOR_TEMPERATURE 1000 |
45 | | #define SENSOR_BAROMETER 1001 |
46 | | #define SENSOR_HUMIDITY 1002 |
47 | | #define SENSOR_TDOA_CLOCK 2000 |
48 | | #define SENSOR_PHASE 2001 |
49 | | |
50 | | static const value_string sensor_type_str[] = { |
51 | | { SENSOR_RESERVED0, "Reserved" }, |
52 | | { SENSOR_VELOCITY, "Velocity"}, |
53 | | { SENSOR_ACCELERATION, "Acceleration"}, |
54 | | { SENSOR_JERK, "Jerk"}, |
55 | | { SENSOR_ROTATION, "Rotation"}, |
56 | | { SENSOR_MAGNETIC, "Magnetic"}, |
57 | | { SENSOR_TEMPERATURE, "Temperature"}, |
58 | | { SENSOR_BAROMETER, "Barometer"}, |
59 | | { SENSOR_HUMIDITY, "Humidity"}, |
60 | | { SENSOR_TDOA_CLOCK, "TDOA_Clock"}, |
61 | | { SENSOR_PHASE, "Phase"}, |
62 | | { 0, NULL} |
63 | | }; |
64 | | |
65 | | static const value_string sensor_unit_str[] = { |
66 | | { SENSOR_RESERVED0, "Reserved" }, |
67 | | { SENSOR_VELOCITY, "Meters/sec"}, |
68 | | { SENSOR_ACCELERATION, "Meters/sec/sec"}, |
69 | | { SENSOR_JERK, "Meters/sec/sec/sec"}, |
70 | | { SENSOR_ROTATION, "Degrees/sec"}, |
71 | | { SENSOR_MAGNETIC, "Tesla"}, |
72 | | { SENSOR_TEMPERATURE, "Degrees Celsius"}, |
73 | | { SENSOR_BAROMETER, "Pascal"}, |
74 | | { SENSOR_HUMIDITY, "Humidity"}, |
75 | | { SENSOR_TDOA_CLOCK, "Seconds"}, |
76 | | { SENSOR_PHASE, "Degrees"}, |
77 | | { 0, NULL} |
78 | | }; |
79 | | |
80 | | void proto_register_ppi_sensor(void); |
81 | | /* protocol */ |
82 | | static int proto_ppi_sensor; |
83 | | |
84 | | static int hf_ppi_sensor_version; |
85 | | static int hf_ppi_sensor_pad; |
86 | | static int hf_ppi_sensor_length; |
87 | | static int hf_ppi_sensor_present; |
88 | | static int hf_ppi_sensor_sensortype; |
89 | | static int hf_ppi_sensor_scalefactor; |
90 | | static int hf_ppi_sensor_val_x; |
91 | | static int hf_ppi_sensor_val_y; |
92 | | static int hf_ppi_sensor_val_z; |
93 | | static int hf_ppi_sensor_val_t; |
94 | | static int hf_ppi_sensor_val_e; |
95 | | static int hf_ppi_sensor_descstr; |
96 | | static int hf_ppi_sensor_appspecific_num; /* 4-byte tag no */ |
97 | | static int hf_ppi_sensor_appspecific_data; /* 60 byte arbitrary data */ |
98 | | |
99 | | |
100 | | /* "Present" flags */ |
101 | | /* These represent decoded-bits in the gui */ |
102 | | static int hf_ppi_sensor_present_sensortype; |
103 | | static int hf_ppi_sensor_present_scalefactor; |
104 | | static int hf_ppi_sensor_present_val_x; |
105 | | static int hf_ppi_sensor_present_val_y; |
106 | | static int hf_ppi_sensor_present_val_z; |
107 | | static int hf_ppi_sensor_present_val_t; |
108 | | static int hf_ppi_sensor_present_val_e; |
109 | | static int hf_ppi_sensor_present_descstr; |
110 | | static int hf_ppi_sensor_present_appspecific_num; |
111 | | static int hf_ppi_sensor_present_appspecific_data; |
112 | | static int hf_ppi_sensor_present_ext; |
113 | | |
114 | | |
115 | | /* These represent arrow-dropdownthings in the gui */ |
116 | | static int ett_ppi_sensor; |
117 | | static int ett_ppi_sensor_present; |
118 | | |
119 | | static expert_field ei_ppi_sensor_present_bit; |
120 | | static expert_field ei_ppi_sensor_version; |
121 | | static expert_field ei_ppi_sensor_length; |
122 | | |
123 | | /* used with ScaleFactor */ |
124 | | static double |
125 | | base_10_expt(int power) |
126 | 0 | { |
127 | 0 | double ret = 1; |
128 | 0 | int provide_frac = 0; |
129 | |
|
130 | 0 | if (power == 0) /* likely*/ |
131 | 0 | return 1; |
132 | | |
133 | | /* if negative, negate when we return*/ |
134 | 0 | if (power < 0) |
135 | 0 | { |
136 | 0 | power *= -1; |
137 | 0 | provide_frac = 1; |
138 | 0 | } |
139 | 0 | while (power > 0) |
140 | 0 | { |
141 | 0 | ret = ret * 10; |
142 | 0 | power--; |
143 | 0 | } |
144 | 0 | if (! provide_frac) |
145 | 0 | return ret; |
146 | 0 | else |
147 | 0 | return (1.0/ret); |
148 | 0 | } |
149 | | |
150 | | static int |
151 | 0 | dissect_ppi_sensor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { |
152 | | /* The fixed values up front */ |
153 | 0 | uint32_t version; |
154 | 0 | unsigned length; |
155 | 0 | unsigned length_remaining; |
156 | |
|
157 | 0 | proto_tree *ppi_sensor_tree = NULL; |
158 | 0 | proto_tree *pt, *my_pt; |
159 | 0 | proto_item *version_item, *length_item; |
160 | 0 | proto_tree *sensor_line; |
161 | | /* sensor type in english */ |
162 | 0 | const char *type_str = "Unknown sensor"; |
163 | 0 | const char *unit_str = "Unknown unit"; |
164 | |
|
165 | 0 | static int * const ppi_sensor_present_flags[] = { |
166 | 0 | &hf_ppi_sensor_present_sensortype, |
167 | 0 | &hf_ppi_sensor_present_scalefactor, |
168 | 0 | &hf_ppi_sensor_present_val_x, |
169 | 0 | &hf_ppi_sensor_present_val_y, |
170 | 0 | &hf_ppi_sensor_present_val_z, |
171 | 0 | &hf_ppi_sensor_present_val_t, |
172 | 0 | &hf_ppi_sensor_present_val_e, |
173 | 0 | &hf_ppi_sensor_present_descstr, |
174 | 0 | &hf_ppi_sensor_present_appspecific_num, |
175 | 0 | &hf_ppi_sensor_present_appspecific_data, |
176 | 0 | &hf_ppi_sensor_present_ext, |
177 | 0 | NULL |
178 | 0 | }; |
179 | | |
180 | | /* bits*/ |
181 | 0 | int bit; |
182 | 0 | uint32_t present, next_present; |
183 | 0 | unsigned offset = 0; |
184 | | /* values actually read out, for displaying */ |
185 | 0 | uint16_t sensortype =0; |
186 | 0 | char scalefactor = 0; |
187 | 0 | double c_val=0; /*curr val */ |
188 | 0 | uint32_t val_t=0; /*temp curr val*/ |
189 | 0 | uint32_t t_appspecific_num; /* temporary conversions */ |
190 | |
|
191 | 0 | double curr_native_val; /* this will have scaling_factor applied. displayed in sensor line */ |
192 | 0 | char* curr_str; |
193 | | |
194 | | |
195 | | |
196 | | /* Clear out stuff in the info column */ |
197 | 0 | col_clear(pinfo->cinfo,COL_INFO); |
198 | | |
199 | | /* pull out the first three fields of the BASE-GEOTAG-HEADER */ |
200 | 0 | version = tvb_get_uint8(tvb, offset); |
201 | 0 | length = tvb_get_letohs(tvb, offset+2); |
202 | 0 | present = tvb_get_letohl(tvb, offset+4); |
203 | | |
204 | | /* Setup basic column info */ |
205 | 0 | col_add_fstr(pinfo->cinfo, COL_INFO, "PPI Sensor info v%u, Length %u ", |
206 | 0 | version, length); |
207 | | |
208 | | /* Create the basic dissection tree*/ |
209 | 0 | sensor_line = proto_tree_add_protocol_format(tree, proto_ppi_sensor, |
210 | 0 | tvb, 0, length, "PPI Sensor Header v%u, Length %u", version, length); |
211 | | /*Add in the fixed ppi-geotagging-header fields: ver, pad, len */ |
212 | 0 | ppi_sensor_tree = proto_item_add_subtree(sensor_line, ett_ppi_sensor); |
213 | 0 | version_item = proto_tree_add_uint(ppi_sensor_tree, hf_ppi_sensor_version, |
214 | 0 | tvb, offset, 1, version); |
215 | 0 | proto_tree_add_item(ppi_sensor_tree, hf_ppi_sensor_pad, |
216 | 0 | tvb, offset + 1, 1, ENC_BIG_ENDIAN); |
217 | 0 | length_item = proto_tree_add_uint(ppi_sensor_tree, hf_ppi_sensor_length, |
218 | 0 | tvb, offset + 2, 2, length); |
219 | | /*fixed ppi-geotagging-header fields finished, move onto the fields marked present*/ |
220 | | |
221 | | /* We support v1 and v2 of Sensor tags (identical) */ |
222 | 0 | if (! (version == 1 || version == 2) ) { |
223 | 0 | expert_add_info_format(pinfo, version_item, &ei_ppi_sensor_version, "Invalid version (got %d, expected 1 or 2)", version); |
224 | 0 | } |
225 | |
|
226 | 0 | length_remaining = length; |
227 | | /* minimum length check, should at least be a fixed-size geotagging-base header*/ |
228 | 0 | if (length_remaining < PPI_GEOBASE_MIN_HEADER_LEN) { |
229 | | /* |
230 | | * Base-geotag-header (Radiotap lookalike) is shorter than the fixed-length portion |
231 | | * plus one "present" bitset. |
232 | | */ |
233 | 0 | expert_add_info_format(pinfo, length_item, &ei_ppi_sensor_length, "Invalid PPI-Sensor length - minimum length is 8"); |
234 | 0 | return 2; |
235 | 0 | } |
236 | | |
237 | | /* perform max length sanity checking */ |
238 | 0 | if (length > PPI_SENSOR_MAXTAGLEN ) { |
239 | 0 | expert_add_info_format(pinfo, length_item, &ei_ppi_sensor_length, "Invalid PPI-Sensor length (got %d, %d max\n)", length, PPI_SENSOR_MAXTAGLEN); |
240 | 0 | return 2; |
241 | 0 | } |
242 | | |
243 | | /* Subtree for the "present flags" bitfield. */ |
244 | 0 | pt = proto_tree_add_bitmask(ppi_sensor_tree, tvb, offset + 4, hf_ppi_sensor_present, ett_ppi_sensor_present, ppi_sensor_present_flags, ENC_LITTLE_ENDIAN); |
245 | |
|
246 | 0 | offset += PPI_GEOBASE_MIN_HEADER_LEN; |
247 | 0 | length_remaining -= PPI_GEOBASE_MIN_HEADER_LEN; |
248 | | |
249 | | /* Now all of the fixed length, fixed location stuff is over. Loop over the bits */ |
250 | 0 | for (; present; present = next_present) { |
251 | | /* clear the least significant bit that is set */ |
252 | 0 | next_present = present & (present - 1); |
253 | | /* extract the least significant bit that is set */ |
254 | 0 | bit = BITNO_32(present ^ next_present); |
255 | 0 | switch (bit) { |
256 | 0 | case PPI_SENSOR_SENSORTYPE: |
257 | 0 | if (length_remaining < 2) |
258 | 0 | break; |
259 | 0 | sensortype= tvb_get_letohs(tvb, offset); |
260 | 0 | type_str = val_to_str_const (sensortype, sensor_type_str, "Unknown Sensor type"); |
261 | 0 | unit_str = val_to_str_const (sensortype, sensor_unit_str, "Unknown Unit"); |
262 | |
|
263 | 0 | if (tree) { |
264 | 0 | my_pt = proto_tree_add_uint(ppi_sensor_tree, hf_ppi_sensor_sensortype, tvb, offset , 2, sensortype); |
265 | 0 | proto_item_append_text (my_pt, " %s", type_str); |
266 | 0 | proto_item_set_text(sensor_line, "Sensor: %s", type_str); |
267 | 0 | } |
268 | 0 | offset+=2; |
269 | 0 | length_remaining-=2; |
270 | 0 | break; |
271 | 0 | case PPI_SENSOR_SCALEFACTOR: |
272 | 0 | if (length_remaining < 1) |
273 | 0 | break; |
274 | 0 | scalefactor = (char) tvb_get_uint8(tvb, offset); |
275 | 0 | proto_tree_add_int(ppi_sensor_tree, hf_ppi_sensor_scalefactor, tvb, offset, 1, scalefactor); |
276 | 0 | offset+=1; |
277 | 0 | length_remaining-=1; |
278 | 0 | break; |
279 | 0 | case PPI_SENSOR_VAL_X: |
280 | 0 | if (length_remaining < 4) |
281 | 0 | break; |
282 | 0 | val_t = tvb_get_letohl(tvb, offset); |
283 | 0 | c_val = ppi_fixed6_4_to_double(val_t); |
284 | 0 | if (tree) { |
285 | 0 | my_pt = proto_tree_add_double(ppi_sensor_tree, hf_ppi_sensor_val_x, tvb, offset, 4, c_val); |
286 | 0 | proto_item_append_text (my_pt, " %s", unit_str); |
287 | 0 | curr_native_val = c_val * base_10_expt(scalefactor); /* this will almost always be equal to the original val */ |
288 | 0 | proto_item_set_text(sensor_line, "Sensor: %s %f %s", type_str, curr_native_val, unit_str); |
289 | 0 | } |
290 | 0 | offset+=4; |
291 | 0 | length_remaining-=4; |
292 | 0 | break; |
293 | 0 | case PPI_SENSOR_VAL_Y: |
294 | 0 | if (length_remaining < 4) |
295 | 0 | break; |
296 | 0 | val_t = tvb_get_letohl(tvb, offset); |
297 | 0 | c_val = ppi_fixed6_4_to_double(val_t); |
298 | 0 | if (tree) { |
299 | 0 | my_pt = proto_tree_add_double(ppi_sensor_tree, hf_ppi_sensor_val_y, tvb, offset, 4, c_val); |
300 | 0 | proto_item_append_text (my_pt, " %s", unit_str); |
301 | 0 | curr_native_val = c_val * base_10_expt(scalefactor); /* this will almost always be equal to the original val */ |
302 | 0 | proto_item_set_text(sensor_line, "Sensor: %s %f %s", type_str, curr_native_val, unit_str); |
303 | |
|
304 | 0 | } |
305 | 0 | offset+=4; |
306 | 0 | length_remaining-=4; |
307 | 0 | break; |
308 | 0 | case PPI_SENSOR_VAL_Z: |
309 | 0 | if (length_remaining < 4) |
310 | 0 | break; |
311 | 0 | val_t = tvb_get_letohl(tvb, offset); |
312 | 0 | c_val = ppi_fixed6_4_to_double(val_t); |
313 | 0 | if (tree) { |
314 | 0 | my_pt = proto_tree_add_double(ppi_sensor_tree, hf_ppi_sensor_val_z, tvb, offset, 4, c_val); |
315 | 0 | proto_item_append_text (my_pt, " %s", unit_str); |
316 | 0 | curr_native_val = c_val * base_10_expt(scalefactor); /* this will almost always be equal to the original val */ |
317 | 0 | proto_item_set_text(sensor_line, "Sensor: %s %f %s", type_str, curr_native_val, unit_str); |
318 | 0 | } |
319 | 0 | offset+=4; |
320 | 0 | length_remaining-=4; |
321 | 0 | break; |
322 | 0 | case PPI_SENSOR_VAL_T: |
323 | 0 | if (length_remaining < 4) |
324 | 0 | break; |
325 | 0 | val_t = tvb_get_letohl(tvb, offset); |
326 | 0 | c_val = ppi_fixed6_4_to_double(val_t); |
327 | 0 | if (tree) { |
328 | 0 | my_pt = proto_tree_add_double(ppi_sensor_tree, hf_ppi_sensor_val_t, tvb, offset, 4, c_val); |
329 | 0 | proto_item_append_text (my_pt, " %s", unit_str); |
330 | 0 | curr_native_val = c_val * base_10_expt(scalefactor); /* this will almost always be equal to the original val */ |
331 | 0 | proto_item_set_text(sensor_line, "Sensor: %s %f %s", type_str, curr_native_val, unit_str); |
332 | 0 | } |
333 | 0 | offset+=4; |
334 | 0 | length_remaining-=4; |
335 | 0 | break; |
336 | 0 | case PPI_SENSOR_VAL_E: |
337 | 0 | if (length_remaining < 4) |
338 | 0 | break; |
339 | 0 | val_t = tvb_get_letohl(tvb, offset); |
340 | 0 | c_val = ppi_fixed6_4_to_double(val_t); |
341 | 0 | if (tree) { |
342 | 0 | my_pt = proto_tree_add_double(ppi_sensor_tree, hf_ppi_sensor_val_e, tvb, offset, 4, c_val); |
343 | 0 | proto_item_append_text (my_pt, " %s", unit_str); |
344 | 0 | } |
345 | 0 | offset+=4; |
346 | 0 | length_remaining-=4; |
347 | 0 | break; |
348 | | |
349 | 0 | case PPI_SENSOR_DESCSTR: |
350 | 0 | if (length_remaining < 32) |
351 | 0 | break; |
352 | 0 | if (tree) |
353 | 0 | { |
354 | | /* proto_tree_add_item(ppi_vector_tree, hf_ppi_vector_descstr, tvb, offset, 32, ENC_NA); */ |
355 | 0 | curr_str = tvb_format_stringzpad(pinfo->pool, tvb, offset, 32); |
356 | 0 | proto_tree_add_string(ppi_sensor_tree, hf_ppi_sensor_descstr, tvb, offset, 32, curr_str); |
357 | 0 | proto_item_append_text(sensor_line, " (%s)", curr_str); |
358 | 0 | } |
359 | 0 | offset+=32; |
360 | 0 | length_remaining-=32; |
361 | 0 | break; |
362 | 0 | case PPI_SENSOR_APPID: |
363 | 0 | if (length_remaining < 4) |
364 | 0 | break; |
365 | 0 | t_appspecific_num = tvb_get_letohl(tvb, offset); /* application specific parsers may switch on this later */ |
366 | 0 | proto_tree_add_uint(ppi_sensor_tree, hf_ppi_sensor_appspecific_num, tvb, offset, 4, t_appspecific_num); |
367 | 0 | offset+=4; |
368 | 0 | length_remaining-=4; |
369 | 0 | break; |
370 | 0 | case PPI_SENSOR_APPDATA: |
371 | 0 | if (length_remaining < 60) |
372 | 0 | break; |
373 | 0 | proto_tree_add_item(ppi_sensor_tree, hf_ppi_sensor_appspecific_data, tvb, offset, 60, ENC_NA); |
374 | 0 | offset+=60; |
375 | 0 | length_remaining-=60; |
376 | 0 | break; |
377 | 0 | default: |
378 | | /* |
379 | | * This indicates a field whose size we do not |
380 | | * know, so we cannot proceed. |
381 | | */ |
382 | 0 | expert_add_info_format(pinfo, pt, &ei_ppi_sensor_present_bit, "Error: PPI-SENSOR: unknown bit (%d) set in present field.", bit); |
383 | 0 | next_present = 0; |
384 | 0 | continue; |
385 | 0 | } |
386 | |
|
387 | 0 | }; |
388 | 0 | return tvb_captured_length(tvb); |
389 | 0 | } |
390 | | |
391 | | void |
392 | 14 | proto_register_ppi_sensor(void) { |
393 | | /* The following array initializes those header fields declared above to the values displayed */ |
394 | 14 | static hf_register_info hf[] = { |
395 | 14 | { &hf_ppi_sensor_version, |
396 | 14 | { "Header revision", "ppi_sensor.version", |
397 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
398 | 14 | "Version of ppi_sensor header format", HFILL } }, |
399 | 14 | { &hf_ppi_sensor_pad, |
400 | 14 | { "Header pad", "ppi_sensor.pad", |
401 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
402 | 14 | "Padding", HFILL } }, |
403 | 14 | { &hf_ppi_sensor_length, |
404 | 14 | { "Header length", "ppi_sensor.length", |
405 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
406 | 14 | "Length of header including version, pad, length and data fields", HFILL } }, |
407 | 14 | { &hf_ppi_sensor_present, |
408 | 14 | { "Present", "ppi_sensor.present", |
409 | 14 | FT_UINT32, BASE_HEX, NULL, 0x0, "Bitmask indicating which fields are present", HFILL } }, |
410 | | |
411 | | /* This first set is for the base_tag_header.it_present bitfield */ |
412 | 14 | #define PPI_SENSOR_MASK_SENSORTYPE 0x00000001 /* 0 */ |
413 | 14 | #define PPI_SENSOR_MASK_SCALEFACTOR 0x00000002 /* 1 */ |
414 | 14 | #define PPI_SENSOR_MASK_VAL_X 0x00000004 /* 2 */ |
415 | 14 | #define PPI_SENSOR_MASK_VAL_Y 0x00000008 /* 3 */ |
416 | 14 | #define PPI_SENSOR_MASK_VAL_Z 0x00000010 /* 4 */ |
417 | 14 | #define PPI_SENSOR_MASK_VAL_T 0x00000020 /* 5 */ |
418 | 14 | #define PPI_SENSOR_MASK_VAL_E 0x00000040 /* 6 */ |
419 | 14 | #define PPI_SENSOR_MASK_SERIALNUM 0x04000000 /* 26 */ |
420 | 14 | #define PPI_SENSOR_MASK_MODELSTR 0x08000000 /* 27 */ |
421 | 14 | #define PPI_SENSOR_MASK_DESCSTR 0x10000000 /* 28 */ |
422 | 14 | #define PPI_SENSOR_MASK_APPID 0x20000000 /* 29 */ |
423 | 14 | #define PPI_SENSOR_MASK_APPDATA 0x40000000 /* 30 */ |
424 | 14 | #define PPI_SENSOR_MASK_EXT 0x80000000 /* 31 */ |
425 | | |
426 | | /* Boolean 'present' flags */ |
427 | 14 | { &hf_ppi_sensor_present_sensortype, |
428 | 14 | { "sensortype", "ppi_sensor.present.sensortype", |
429 | 14 | FT_BOOLEAN, 32, NULL, PPI_SENSOR_MASK_SENSORTYPE, |
430 | 14 | "Specifies if the sensor type field is present", HFILL } }, |
431 | 14 | { &hf_ppi_sensor_present_scalefactor, |
432 | 14 | { "scalefactor", "ppi_sensor.present.scalefactor", |
433 | 14 | FT_BOOLEAN, 32, NULL, PPI_SENSOR_MASK_SCALEFACTOR, |
434 | 14 | "Specifies if the sensor scale factor field is present", HFILL } }, |
435 | | |
436 | 14 | { &hf_ppi_sensor_present_val_x, |
437 | 14 | { "val_x", "ppi_sensor.present.val_x", |
438 | 14 | FT_BOOLEAN, 32, NULL, PPI_SENSOR_MASK_VAL_X, |
439 | 14 | "Specifies if the sensor val_x field is present", HFILL } }, |
440 | 14 | { &hf_ppi_sensor_present_val_y, |
441 | 14 | { "val_y", "ppi_sensor.present.val_y", |
442 | 14 | FT_BOOLEAN, 32, NULL, PPI_SENSOR_MASK_VAL_Y, |
443 | 14 | "Specifies if the sensor val_y field is present", HFILL } }, |
444 | 14 | { &hf_ppi_sensor_present_val_z, |
445 | 14 | { "val_z", "ppi_sensor.present.val_z", |
446 | 14 | FT_BOOLEAN, 32, NULL, PPI_SENSOR_MASK_VAL_Z, |
447 | 14 | "Specifies if the BeamID field is present", HFILL } }, |
448 | | |
449 | 14 | { &hf_ppi_sensor_present_val_t, |
450 | 14 | { "val_t", "ppi_sensor.present.val_t", |
451 | 14 | FT_BOOLEAN, 32, NULL, PPI_SENSOR_MASK_VAL_T, |
452 | 14 | "Specifies if the val_t field is present", HFILL } }, |
453 | 14 | { &hf_ppi_sensor_present_val_e, |
454 | 14 | { "val_e", "ppi_sensor.present.val_e", |
455 | 14 | FT_BOOLEAN, 32, NULL, PPI_SENSOR_MASK_VAL_E, |
456 | 14 | "Specifies if the val_e field is present", HFILL } }, |
457 | | |
458 | 14 | { &hf_ppi_sensor_present_descstr, |
459 | 14 | { "Description", "ppi_sensor.present.descr", |
460 | 14 | FT_BOOLEAN, 32, NULL, PPI_SENSOR_MASK_DESCSTR, |
461 | 14 | "Specifies if the description string is present", HFILL } }, |
462 | 14 | { &hf_ppi_sensor_present_appspecific_num, |
463 | 14 | { "appid", "ppi_sensor.present.appid", |
464 | 14 | FT_BOOLEAN, 32, NULL, PPI_SENSOR_MASK_APPID, |
465 | 14 | "Specifies if the application specific field id is present", HFILL } }, |
466 | 14 | { &hf_ppi_sensor_present_appspecific_data, |
467 | 14 | { "appdata", "ppi_sensor.present.appdata", |
468 | 14 | FT_BOOLEAN, 32, NULL, PPI_SENSOR_MASK_APPDATA, |
469 | 14 | "Specifies if the application specific data field is present", HFILL } }, |
470 | 14 | { &hf_ppi_sensor_present_ext, |
471 | 14 | { "ext", "ppi_sensor.present.ext", |
472 | 14 | FT_BOOLEAN, 32, NULL, PPI_SENSOR_MASK_EXT, |
473 | 14 | "Specifies if there are any extensions to the header present", HFILL } }, |
474 | | |
475 | | |
476 | | /* Now we get to the actual data fields */ |
477 | 14 | { &hf_ppi_sensor_sensortype, |
478 | 14 | { "SensorType", "ppi_sensor.sensortype", |
479 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
480 | 14 | "Type of sensor", HFILL } }, |
481 | 14 | { &hf_ppi_sensor_scalefactor, |
482 | 14 | { "ScaleFactor", "ppi_sensor.scalefactor", |
483 | 14 | FT_INT8, BASE_DEC, NULL, 0x0, |
484 | 14 | "Scaling factor", HFILL } }, |
485 | 14 | { &hf_ppi_sensor_val_x, |
486 | 14 | { "Val_X", "ppi_sensor.val_x", |
487 | 14 | FT_DOUBLE, BASE_NONE, NULL, 0x0, |
488 | 14 | "Value in X-dimesion", HFILL } }, |
489 | 14 | { &hf_ppi_sensor_val_y, |
490 | 14 | { "Val_Y", "ppi_sensor.val_y", |
491 | 14 | FT_DOUBLE, BASE_NONE, NULL, 0x0, |
492 | 14 | "Value in Y-dimension", HFILL } }, |
493 | 14 | { &hf_ppi_sensor_val_z, |
494 | 14 | { "Val_Z", "ppi_sensor.val_z", |
495 | 14 | FT_DOUBLE, BASE_NONE, NULL, 0x0, |
496 | 14 | "Value in Z-dimension", HFILL } }, |
497 | 14 | { &hf_ppi_sensor_val_t, |
498 | 14 | { "Val_T", "ppi_sensor.val_t", |
499 | 14 | FT_DOUBLE, BASE_NONE, NULL, 0x0, |
500 | 14 | "Value total (dimensionless)", HFILL } }, |
501 | 14 | { &hf_ppi_sensor_val_e, |
502 | 14 | { "Val_E", "ppi_sensor.val_e", |
503 | 14 | FT_DOUBLE, BASE_NONE, NULL, 0x0, |
504 | 14 | "Margin of error", HFILL } }, |
505 | | |
506 | | |
507 | 14 | { &hf_ppi_sensor_descstr, |
508 | 14 | { "Description", "ppi_sensor.descr", |
509 | 14 | FT_STRING, BASE_NONE, NULL, 0x0, |
510 | 14 | NULL, HFILL } } , |
511 | 14 | { &hf_ppi_sensor_appspecific_num, |
512 | 14 | { "Application Specific id", "ppi_sensor.appid", |
513 | 14 | FT_UINT32, BASE_HEX, NULL, 0x0, |
514 | 14 | "Application-specific identifier", HFILL } }, |
515 | 14 | { &hf_ppi_sensor_appspecific_data, |
516 | 14 | { "Application specific data", "ppi_sensor.appdata", |
517 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
518 | 14 | "Application-specific data", HFILL } }, |
519 | 14 | }; |
520 | 14 | static int *ett[] = { |
521 | 14 | &ett_ppi_sensor, |
522 | 14 | &ett_ppi_sensor_present, |
523 | 14 | }; |
524 | | |
525 | 14 | static ei_register_info ei[] = { |
526 | 14 | { &ei_ppi_sensor_present_bit, { "ppi_sensor.present.unknown_bit", PI_PROTOCOL, PI_WARN, "Error: PPI-ANTENNA: unknown bit set in present field.", EXPFILL }}, |
527 | 14 | { &ei_ppi_sensor_version, { "ppi_sensor.version.unsupported", PI_PROTOCOL, PI_WARN, "Invalid version", EXPFILL }}, |
528 | 14 | { &ei_ppi_sensor_length, { "ppi_sensor.length.invalid", PI_MALFORMED, PI_ERROR, "Invalid length", EXPFILL }}, |
529 | 14 | }; |
530 | | |
531 | 14 | expert_module_t* expert_ppi_sensor; |
532 | | |
533 | 14 | proto_ppi_sensor = proto_register_protocol("PPI sensor decoder", "PPI sensor Decoder", "ppi_sensor"); |
534 | 14 | proto_register_field_array(proto_ppi_sensor, hf, array_length(hf)); |
535 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
536 | 14 | expert_ppi_sensor = expert_register_protocol(proto_ppi_sensor); |
537 | 14 | expert_register_field_array(expert_ppi_sensor, ei, array_length(ei)); |
538 | 14 | register_dissector("ppi_sensor", dissect_ppi_sensor, proto_ppi_sensor); |
539 | | |
540 | 14 | } |
541 | | |
542 | | /* |
543 | | * Editor modelines |
544 | | * |
545 | | * Local Variables: |
546 | | * c-basic-offset: 4 |
547 | | * tab-width: 8 |
548 | | * indent-tabs-mode: nil |
549 | | * End: |
550 | | * |
551 | | * ex: set shiftwidth=4 tabstop=8 expandtab: |
552 | | * :indentSize=4:tabSize=8:noTabs=true: |
553 | | */ |
554 | | |
555 | | |