Coverage Report

Created: 2026-03-30 07:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-rttrp.c
Line
Count
Source
1
/* packet-rttrp.c
2
 * Routines for RTTrP packet disassembly
3
 *
4
 * Copyright (c) 2025 by Matt Morris <mattm.dev.1[AT]gmail.com>
5
 *
6
 * Wireshark - Network traffic analyzer
7
 * By Gerald Combs <gerald@wireshark.org>
8
 * Copyright 1999 Gerald Combs
9
 *
10
 * Specification:
11
 * https://rttrp.github.io/RTTrP-Wiki/index.html
12
 * https://rttrp.github.io/RTTrP-Wiki/RTTrPM.html
13
 * https://rttrp.github.io/RTTrP-Wiki/RTTrPL.html
14
 * https://rttrp.github.io/RTTrP-Wiki/BlackTrax.html
15
 *
16
 * Old Zone Method:
17
 * https://github.com/RTTrP/RTTrP-Wiki/commit/2ddb420fa3e23e2fb7f19b51702a835026b32cf5
18
 *
19
 * SPDX-License-Identifier: GPL-2.0-or-later
20
 */
21
22
23
/* Include files */
24
#include "config.h"
25
#include <epan/packet.h>
26
#include <epan/conversation.h>
27
#include <epan/unit_strings.h>
28
#include <epan/expert.h>
29
30
/* constants */
31
817
#define RTTRP_INT_SIG_LE 0x5441
32
1.63k
#define RTTRP_INT_SIG_BE 0x4154
33
34
10
#define RTTRP_FLOAT_SIG_MOTION_BE   0x4334
35
5
#define RTTRP_FLOAT_SIG_MOTION_LE   0x3443
36
10
#define RTTRP_FLOAT_SIG_LIGHTING_BE 0x4434
37
10
#define RTTRP_FLOAT_SIG_LIGHTING_LE 0x3444
38
39
#define RTTRP_PACKET_FORMAT_RAW      0x00
40
#define RTTRP_PACKET_FORMAT_PROTOBUF 0x01
41
#define RTTRP_PACKET_FORMAT_THRIFT   0x02
42
43
0
#define RTTRP_MODULE_TRACKABLE                    0x01
44
0
#define RTTRP_MODULE_TRACKABLE_WITH_TIMESTAMP     0x51
45
0
#define RTTRP_MODULE_CENTROID_POSITION            0x02
46
0
#define RTTRP_MODULE_ORIENTATION_QUATERNION       0x03
47
0
#define RTTRP_MODULE_ORIENTATION_EULER            0x04
48
0
#define RTTRP_MODULE_TRACKED_POINT_POSITION       0x06
49
0
#define RTTRP_MODULE_CENTROID_ACCEL_VELOCITY      0x20
50
0
#define RTTRP_MODULE_TRACKED_POINT_ACCEL_VELOCITY 0x21
51
0
#define RTTRP_MODULE_ZONE_COLLISION_DETECTION     0x22
52
0
#define RTTRP_MODULE_LIGHTING_OUTPUT              0x07
53
0
#define RTTRP_MODULE_LIGHTING_SYNC                0x08
54
0
#define RTTRP_MODULE_UNIVERSE                     0x09
55
0
#define RTTRP_MODULE_SPOT                         0x0A
56
57
#define RTTRPL_ACTION_SNAPSHOT 0x00
58
#define RTTRPL_ACTION_UPDATE   0x01
59
60
#define RTTRPL_HOLD_TIME_FOREVER 0x00
61
62
static int proto_rttrp;
63
64
static dissector_handle_t rttrp_handle;
65
66
67
/*  Open/Close trees */
68
static int ett_rttrp;
69
70
static int ett_rttrp_module_trackable;
71
static int ett_rttrp_module_tracker_data;
72
static int ett_rttrp_module_lighting;
73
static int ett_rttrp_module_universe;
74
static int ett_rttrp_module_spot;
75
76
static int ett_rttrp_collision_zones;
77
static int ett_rttrp_collision_zone;
78
79
static int ett_rttrp_lighting_spots;
80
static int ett_rttrp_lighting_chan;
81
82
/* Expert Info  */
83
static expert_field ei_rttrp_module_type;
84
static expert_field ei_rttrp_module_size;
85
86
/*  Register fields */
87
88
/* RTTrP Header */
89
static int hf_rttrp_int_signature;
90
static int hf_rttrp_float_signature;
91
static int hf_rttrp_header_version;
92
static int hf_rttrp_packet_id;
93
static int hf_rttrp_packet_format;
94
static int hf_rttrp_packet_size;
95
static int hf_rttrp_packet_context;
96
static int hf_rttrp_packet_module_count;
97
98
static int hf_rttrp_module_trackable;
99
static int hf_rttrp_module_tracker_data;
100
static int hf_rttrp_module_lighting;
101
static int hf_rttrp_module_universe;
102
static int hf_rttrp_module_spot;
103
104
static int hf_rttrp_module_trackable_type;
105
static int hf_rttrp_module_tracker_data_type;
106
static int hf_rttrp_module_lighting_type;
107
static int hf_rttrp_module_universe_type;
108
static int hf_rttrp_module_spot_type;
109
110
static int hf_rttrp_module_trackable_size;
111
static int hf_rttrp_module_tracker_data_size;
112
static int hf_rttrp_module_lighting_size;
113
static int hf_rttrp_module_universe_size;
114
static int hf_rttrp_module_spot_size;
115
116
static int hf_rttrp_module_latency;
117
118
/* Trackable Module */
119
static int hf_rttrp_trackable_name_length;
120
static int hf_rttrp_trackable_name;
121
static int hf_rttrp_trackable_timestamp;
122
static int hf_rttrp_trackable_module_count;
123
static int hf_rttrp_trackable_modules;
124
125
/* Centroid/Point position */
126
static int hf_rttrp_position_x;
127
static int hf_rttrp_position_y;
128
static int hf_rttrp_position_z;
129
static int hf_rttrp_point_index;
130
131
static int hf_rttrp_orientation_qx;
132
static int hf_rttrp_orientation_qy;
133
static int hf_rttrp_orientation_qz;
134
static int hf_rttrp_orientation_qw;
135
static int hf_rttrp_orientation_order;
136
static int hf_rttrp_orientation_r1;
137
static int hf_rttrp_orientation_r2;
138
static int hf_rttrp_orientation_r3;
139
140
static int hf_rttrp_acceleration_x;
141
static int hf_rttrp_acceleration_y;
142
static int hf_rttrp_acceleration_z;
143
static int hf_rttrp_velocity_x;
144
static int hf_rttrp_velocity_y;
145
static int hf_rttrp_velocity_z;
146
147
static int hf_rttrp_zone_count;
148
static int hf_rttrp_zones;
149
static int hf_rttrp_zone;
150
static int hf_rttrp_zone_size;
151
static int hf_rttrp_zone_name_length;
152
static int hf_rttrp_zone_name;
153
static int hf_rttrp_zone_names_delimited_length;
154
155
/* Lighting Output */
156
static int hf_rttrp_lighting_sequence;
157
static int hf_rttrp_lighting_action;
158
static int hf_rttrp_lighting_hold_time;
159
static int hf_rttrp_lighting_universe_count;
160
161
static int hf_rttrp_universe_id;
162
static int hf_rttrp_universe_spot_count;
163
static int hf_rttrp_universe_spots;
164
165
static int hf_rttrp_spot_id;
166
static int hf_rttrp_spot_offset;
167
static int hf_rttrp_spot_channel_count;
168
169
static int hf_rttrp_channel;
170
static int hf_rttrp_channel_offset;
171
static int hf_rttrp_channel_xfade;
172
static int hf_rttrp_channel_value;
173
174
/* Lighting Sync */
175
static int hf_rttrp_sync_device_id;
176
static int hf_rttrp_sync_device_sub_id_0;
177
static int hf_rttrp_sync_device_sub_id_1;
178
static int hf_rttrp_sync_device_sequence_number;
179
180
181
static const value_string rttrp_int_sig_names[] = {
182
    { RTTRP_INT_SIG_BE, "RTTrP Big Endian" },
183
    { RTTRP_INT_SIG_LE, "RTTrP Little Endian" },
184
    { 0,                NULL },
185
};
186
187
static const value_string rttrp_float_sig_names[] = {
188
    { RTTRP_FLOAT_SIG_LIGHTING_BE,   "RTTrP Lighting Big Endian" },
189
    { RTTRP_FLOAT_SIG_LIGHTING_LE,   "RTTrP Lighting Little Endian" },
190
    { RTTRP_FLOAT_SIG_MOTION_BE,     "RTTrP Motion Big Endian" },
191
    { RTTRP_FLOAT_SIG_MOTION_LE,     "RTTrP Motion Little Endian" },
192
    { 0,                          NULL },
193
};
194
195
static const value_string rttrp_packet_format_names[] = {
196
    { RTTRP_PACKET_FORMAT_RAW,        "Raw" },
197
    { RTTRP_PACKET_FORMAT_PROTOBUF,   "Protobuf" },
198
    { RTTRP_PACKET_FORMAT_THRIFT,     "Thrift" },
199
    { 0,                              NULL },
200
};
201
202
static const value_string rttrp_module_names[] = {
203
    { RTTRP_MODULE_TRACKABLE,                    "Trackable Module (without Timestamp)" },
204
    { RTTRP_MODULE_TRACKABLE_WITH_TIMESTAMP,     "Trackable Module (with Timestamp)" },
205
    { RTTRP_MODULE_CENTROID_POSITION,            "Centroid Position Module" },
206
    { RTTRP_MODULE_ORIENTATION_QUATERNION,       "Orientation Module (Quaternion)" },
207
    { RTTRP_MODULE_ORIENTATION_EULER,            "Orientation Module (Euler)" },
208
    { RTTRP_MODULE_TRACKED_POINT_POSITION,       "Tracked Point Position Module" },
209
    { RTTRP_MODULE_CENTROID_ACCEL_VELOCITY,      "Centroid Acceleration and Velocity Module" },
210
    { RTTRP_MODULE_TRACKED_POINT_ACCEL_VELOCITY, "Tracked Point Acceleration and Velocity Module" },
211
    { RTTRP_MODULE_ZONE_COLLISION_DETECTION,     "Zone Collision Detection Module" },
212
    { RTTRP_MODULE_LIGHTING_OUTPUT,              "Lighting Output Module" },
213
    { RTTRP_MODULE_LIGHTING_SYNC,                "Lighting Sync Module" },
214
    { RTTRP_MODULE_UNIVERSE,                     "Universe Module" },
215
    { RTTRP_MODULE_SPOT,                         "Spot Module" },
216
    { 0,                                         NULL },
217
};
218
219
static const value_string rttrp_tracker_data_names[] = {
220
    { RTTRP_MODULE_CENTROID_POSITION,            "Centroid Position" },
221
    { RTTRP_MODULE_ORIENTATION_QUATERNION,       "Orientation (Quaternion)" },
222
    { RTTRP_MODULE_ORIENTATION_EULER,            "Orientation (Euler)" },
223
    { RTTRP_MODULE_TRACKED_POINT_POSITION,       "Tracked Point Position" },
224
    { RTTRP_MODULE_CENTROID_ACCEL_VELOCITY,      "Centroid Acceleration and Velocity" },
225
    { RTTRP_MODULE_TRACKED_POINT_ACCEL_VELOCITY, "Tracked Point Acceleration and Velocity" },
226
    { 0,                                         NULL },
227
};
228
229
static const value_string rttrpm_euler_order_names[] = {
230
    { 0x0111, "X1 X2 X3" },
231
    { 0x0112, "X1 X2 Y3" },
232
    { 0x0113, "X1 X2 Z3" },
233
    { 0x0121, "X1 Y2 X3" },
234
    { 0x0122, "X1 Y2 Y3" },
235
    { 0x0123, "X1 Y2 Z3" },
236
    { 0x0131, "X1 Z2 X3" },
237
    { 0x0132, "X1 Z2 Y3" },
238
    { 0x0133, "X1 Z2 Z3" },
239
240
    { 0x0211, "Y1 X2 X3" },
241
    { 0x0212, "Y1 X2 Y3" },
242
    { 0x0213, "Y1 X2 Z3" },
243
    { 0x0221, "Y1 Y2 X3" },
244
    { 0x0222, "Y1 Y2 Y3" },
245
    { 0x0223, "Y1 Y2 Z3" },
246
    { 0x0231, "Y1 Z2 X3" },
247
    { 0x0232, "Y1 Z2 Y3" },
248
    { 0x0233, "Y1 Z2 Z3" },
249
250
    { 0x0311, "Z1 X2 X3" },
251
    { 0x0312, "Z1 X2 Y3" },
252
    { 0x0313, "Z1 X2 Z3" },
253
    { 0x0321, "Z1 Y2 X3" },
254
    { 0x0322, "Z1 Y2 Y3" },
255
    { 0x0323, "Z1 Y2 Z3" },
256
    { 0x0331, "Z1 Z2 X3" },
257
    { 0x0332, "Z1 Z2 Y3" },
258
    { 0x0333, "Z1 Z2 Z3" },
259
    { 0,      NULL },
260
};
261
262
static const value_string rttrpl_action_names[] = {
263
  { RTTRPL_ACTION_SNAPSHOT, "Snapshot" },
264
  { RTTRPL_ACTION_UPDATE,   "Update" },
265
  { 0,                      NULL },
266
};
267
268
static const value_string rttrpl_hold_time_names[] = {
269
  { RTTRPL_HOLD_TIME_FOREVER, "Do not release" },
270
  { 0,                        NULL },
271
};
272
273
274
/******************************************************************************/
275
/* Dissect protocol                                                           */
276
static proto_tree* dissect_rttrp_module_header(tvbuff_t *tvb, proto_tree *tree, const int endianness_int, proto_item** ti, int* offset, int* module_end,
277
0
    uint32_t* module_type, uint32_t* module_size, const int hf_module, const int ett_module, const int hf_module_type, const int hf_module_size) {
278
    /* add subtree */
279
0
    *ti = proto_tree_add_item(tree, hf_module, tvb, *offset, -1, ENC_NA);
280
0
    proto_tree *mod_tree = proto_item_add_subtree(*ti, ett_module);
281
282
    /* add type and size to tree */
283
0
    proto_tree_add_item_ret_uint(mod_tree, hf_module_type, tvb, *offset, 1, ENC_NA, module_type);
284
0
    *offset += 1;
285
286
0
    proto_tree_add_item_ret_uint(mod_tree, hf_module_size, tvb, *offset, 2, endianness_int, module_size);
287
0
    proto_item_set_len(*ti, *module_size);
288
0
    *offset += 2;
289
290
    /* module_size could be <3, even though it includes these 3 bytes,
291
        so we make it bigger to ensure we keep making progress */
292
0
    *module_end = (*offset)+MAX(*module_size, 3)-3;
293
0
    return mod_tree;
294
0
}
295
296
/** Note that this only dissects the body of the module, not the type or size fields */
297
0
static int dissect_rttrp_module_zone_body(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, const unsigned endianness_int, uint16_t module_size) {
298
0
    uint16_t length = tvb_get_uint16(tvb, offset, endianness_int);
299
300
    /* No way of telling which version we are in to determine which zone method will be used,
301
     * so we guess based on if the fields look ok for the old method
302
    */
303
0
    if (length + 5 == module_size) {
304
        /* We have a 2.4.1.0 zone module ('$' delimited string) */
305
0
        proto_tree_add_item(tree, hf_rttrp_zone_names_delimited_length, tvb, offset, 2, endianness_int);
306
0
        offset += 2;
307
308
0
        if (length == 0) {
309
            /* No names to actually parse */
310
0
            return offset;
311
0
        }
312
0
        proto_item *zone_holder = proto_tree_add_item(tree, hf_rttrp_zones, tvb, offset, length, ENC_NA);
313
0
        proto_tree *zones_tree = proto_item_add_subtree(zone_holder, ett_rttrp_collision_zones);
314
315
        /* Fetch string, with terminating null added */
316
0
        uint8_t* start = tvb_get_string_enc(pinfo->pool, tvb, offset, length, ENC_ASCII);
317
318
        /* parse the delimited string */
319
        /* based on SrvLoc attribute list parser */
320
0
        uint32_t x = 0;
321
0
        uint8_t c = start[x];
322
0
        while (c) {
323
0
            if  (c == '$') {
324
0
                proto_tree_add_item(zones_tree, hf_rttrp_zone_name, tvb, offset, x, ENC_ASCII);
325
0
                offset += x+1;
326
0
                start += x+1;
327
                /* reset string length */
328
0
                x = 0;
329
0
                c = start[x];
330
0
            } else {
331
                /* increment and get next */
332
0
                x++;
333
0
                c = start[x];
334
0
            }
335
0
        }
336
        /* add final zone name */
337
0
        if (x > 0) {
338
0
            proto_tree_add_item(zones_tree, hf_rttrp_zone_name, tvb, offset, x, ENC_ASCII);
339
0
            offset += x+1;
340
0
        }
341
0
    } else {
342
        /* 2.4.2.0 or later zone module */
343
0
        uint32_t zone_count;
344
0
        proto_tree_add_item_ret_uint(tree, hf_rttrp_zone_count, tvb, offset, 1, ENC_NA, &zone_count);
345
0
        offset += 1;
346
347
0
        if (zone_count != 0) {
348
0
            proto_item *zone_holder = proto_tree_add_item(tree, hf_rttrp_zones, tvb, offset, module_size-1-3, ENC_NA);
349
0
            proto_tree *zones_tree = proto_item_add_subtree(zone_holder, ett_rttrp_collision_zones);
350
351
0
            for (unsigned int i = 0; i < zone_count; i++) {
352
0
                uint8_t zone_size = tvb_get_uint8(tvb, offset);
353
354
0
                proto_item *zone = proto_tree_add_item(zones_tree, hf_rttrp_zone, tvb, offset, zone_size, ENC_NA);
355
0
                proto_tree *zone_tree = proto_item_add_subtree(zone, ett_rttrp_collision_zone);
356
357
0
                proto_tree_add_item(zone_tree, hf_rttrp_zone_size, tvb, offset, 1, ENC_NA);
358
0
                offset += 1;
359
360
0
                uint32_t name_length;
361
0
                proto_tree_add_item_ret_uint(zone_tree, hf_rttrp_zone_name_length, tvb, offset, 1, ENC_NA, &name_length);
362
0
                offset += 1;
363
0
                proto_tree_add_item(zone_tree, hf_rttrp_zone_name, tvb, offset, name_length, endianness_int);
364
0
                offset += name_length;
365
0
            }
366
0
        }
367
0
    }
368
369
0
    return offset;
370
0
}
371
372
0
static int dissect_rttrp_module_position(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, const unsigned endianness_int, const unsigned endianness_float) {
373
0
    int module_end;
374
0
    uint32_t module_type, module_size;
375
0
    proto_item* pos_item;
376
0
    proto_tree* pos_tree = dissect_rttrp_module_header(tvb, tree, endianness_int, &pos_item, &offset,
377
0
        &module_end, &module_type, &module_size, hf_rttrp_module_tracker_data, ett_rttrp_module_tracker_data, hf_rttrp_module_tracker_data_type, hf_rttrp_module_tracker_data_size);
378
379
0
    switch (module_type) {
380
0
        case RTTRP_MODULE_CENTROID_POSITION:
381
0
        case RTTRP_MODULE_ORIENTATION_QUATERNION:
382
0
        case RTTRP_MODULE_ORIENTATION_EULER:
383
0
        case RTTRP_MODULE_TRACKED_POINT_POSITION:
384
0
        case RTTRP_MODULE_CENTROID_ACCEL_VELOCITY:
385
0
        case RTTRP_MODULE_TRACKED_POINT_ACCEL_VELOCITY:
386
            /* Continue to dissector */
387
0
            break;
388
0
        case RTTRP_MODULE_ZONE_COLLISION_DETECTION:
389
            /* Call into specialised dissector */
390
0
            proto_item_append_text(pos_item, ": Zone Collision Detection");
391
0
            offset = dissect_rttrp_module_zone_body(tvb, pinfo, pos_tree, offset, endianness_int, module_size);
392
0
            return module_end;
393
0
        default:
394
            /* Module type isn't valid here */
395
0
            expert_add_info(pinfo, pos_tree, &ei_rttrp_module_type);
396
0
            return module_end;
397
0
    }
398
399
0
    const char* module_name = val_to_str_const(module_type, rttrp_tracker_data_names, "Unknown");
400
0
    proto_item_append_text(pos_item, ": %s", module_name);
401
    /* Latency Field */
402
0
    if (module_type == RTTRP_MODULE_CENTROID_POSITION ||
403
0
        module_type == RTTRP_MODULE_TRACKED_POINT_POSITION ||
404
0
        module_type == RTTRP_MODULE_ORIENTATION_QUATERNION ||
405
0
        module_type == RTTRP_MODULE_ORIENTATION_EULER
406
0
    ) {
407
0
        uint32_t latency;
408
0
        proto_tree_add_item_ret_uint(pos_tree, hf_rttrp_module_latency, tvb, offset, 2, endianness_int, &latency);
409
0
        offset += 2;
410
0
        proto_item_append_text(pos_item, ", Latency: %ums", latency);
411
0
    }
412
413
414
0
    if (module_type == RTTRP_MODULE_ORIENTATION_QUATERNION) {
415
0
        proto_tree_add_item(pos_tree, hf_rttrp_orientation_qx, tvb, offset, 8, endianness_float);
416
0
        offset += 8;
417
0
        proto_tree_add_item(pos_tree, hf_rttrp_orientation_qy, tvb, offset, 8, endianness_float);
418
0
        offset += 8;
419
0
        proto_tree_add_item(pos_tree, hf_rttrp_orientation_qz, tvb, offset, 8, endianness_float);
420
0
        offset += 8;
421
0
        proto_tree_add_item(pos_tree, hf_rttrp_orientation_qw, tvb, offset, 8, endianness_float);
422
0
        offset += 8;
423
0
    } else if (module_type == RTTRP_MODULE_ORIENTATION_EULER) {
424
0
        proto_tree_add_item(pos_tree, hf_rttrp_orientation_order, tvb, offset, 2, endianness_int);
425
0
        offset += 2;
426
0
        proto_tree_add_item(pos_tree, hf_rttrp_orientation_r1, tvb, offset, 8, endianness_float);
427
0
        offset += 8;
428
0
        proto_tree_add_item(pos_tree, hf_rttrp_orientation_r2, tvb, offset, 8, endianness_float);
429
0
        offset += 8;
430
0
        proto_tree_add_item(pos_tree, hf_rttrp_orientation_r3, tvb, offset, 8, endianness_float);
431
0
        offset += 8;
432
0
    } else if (module_type == RTTRP_MODULE_CENTROID_POSITION ||
433
0
        module_type == RTTRP_MODULE_TRACKED_POINT_POSITION ||
434
0
        module_type == RTTRP_MODULE_CENTROID_ACCEL_VELOCITY ||
435
0
        module_type == RTTRP_MODULE_TRACKED_POINT_ACCEL_VELOCITY
436
0
    ) {
437
0
        proto_tree_add_item(pos_tree, hf_rttrp_position_x, tvb, offset, 8, endianness_float);
438
0
        offset += 8;
439
0
        proto_tree_add_item(pos_tree, hf_rttrp_position_y, tvb, offset, 8, endianness_float);
440
0
        offset += 8;
441
0
        proto_tree_add_item(pos_tree, hf_rttrp_position_z, tvb, offset, 8, endianness_float);
442
0
        offset += 8;
443
444
0
        if (module_type == RTTRP_MODULE_CENTROID_ACCEL_VELOCITY ||
445
0
            module_type == RTTRP_MODULE_TRACKED_POINT_ACCEL_VELOCITY
446
0
        ) {
447
0
            proto_tree_add_item(pos_tree, hf_rttrp_acceleration_x, tvb, offset, 4, endianness_float);
448
0
            offset += 4;
449
0
            proto_tree_add_item(pos_tree, hf_rttrp_acceleration_y, tvb, offset, 4, endianness_float);
450
0
            offset += 4;
451
0
            proto_tree_add_item(pos_tree, hf_rttrp_acceleration_z, tvb, offset, 4, endianness_float);
452
0
            offset += 4;
453
454
0
            proto_tree_add_item(pos_tree, hf_rttrp_velocity_x, tvb, offset, 4, endianness_float);
455
0
            offset += 4;
456
0
            proto_tree_add_item(pos_tree, hf_rttrp_velocity_y, tvb, offset, 4, endianness_float);
457
0
            offset += 4;
458
0
            proto_tree_add_item(pos_tree, hf_rttrp_velocity_z, tvb, offset, 4, endianness_float);
459
0
            offset += 4;
460
0
        }
461
0
    }
462
463
    /* Point index for point trackers */
464
0
    if (module_type == RTTRP_MODULE_TRACKED_POINT_POSITION ||
465
0
        module_type == RTTRP_MODULE_TRACKED_POINT_ACCEL_VELOCITY
466
0
    ) {
467
0
        uint32_t point_index;
468
0
        proto_tree_add_item_ret_uint(pos_tree, hf_rttrp_point_index, tvb, offset, 1, ENC_NA, &point_index);
469
0
        offset += 1;
470
0
        proto_item_append_text(pos_item, ", Point Index: %u", point_index);
471
0
    }
472
473
0
    if (offset != module_end)
474
0
        expert_add_info(pinfo, pos_tree, &ei_rttrp_module_size);
475
0
    return module_end;
476
0
}
477
478
0
static int dissect_rttrp_module_trackable(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, const unsigned endianness_int, const unsigned endianness_float) {
479
0
    int module_end;
480
0
    uint32_t module_type, module_size;
481
0
    proto_item* track_item;
482
0
    proto_tree* track_tree = dissect_rttrp_module_header(tvb, tree, endianness_int, &track_item, &offset,
483
0
        &module_end, &module_type, &module_size, hf_rttrp_module_trackable, ett_rttrp_module_trackable, hf_rttrp_module_trackable_type, hf_rttrp_module_trackable_size);
484
485
0
    if (module_type != RTTRP_MODULE_TRACKABLE && module_type != RTTRP_MODULE_TRACKABLE_WITH_TIMESTAMP) {
486
0
        expert_add_info(pinfo, track_tree, &ei_rttrp_module_type);
487
0
        return module_end;
488
0
    }
489
490
0
    uint32_t name_length;
491
0
    proto_tree_add_item_ret_uint(track_tree, hf_rttrp_trackable_name_length, tvb, offset, 1, ENC_NA, &name_length);
492
0
    offset += 1;
493
0
    const uint8_t* name;
494
0
    proto_tree_add_item_ret_string(track_tree, hf_rttrp_trackable_name, tvb, offset, name_length, endianness_int, pinfo->pool, &name);
495
0
    offset += name_length;
496
497
0
    if (module_type == RTTRP_MODULE_TRACKABLE_WITH_TIMESTAMP) {
498
0
        proto_item_append_text(track_item, " (with Timestamp)");
499
0
        proto_tree_add_item(track_tree, hf_rttrp_trackable_timestamp, tvb, offset, 4, endianness_int);
500
0
        offset += 4;
501
0
    }
502
503
0
    uint32_t module_count;
504
0
    proto_tree_add_item_ret_uint(track_tree, hf_rttrp_trackable_module_count, tvb, offset, 1, ENC_NA, &module_count);
505
0
    offset += 1;
506
507
0
    proto_item_append_text(track_item, ", Name: %s, %u sub-modules", name, module_count);
508
509
    /* Number of modules is small (about 5 max), so no extra tree */
510
0
    for (unsigned int i = 0; i < module_count; i++) {
511
0
        offset = dissect_rttrp_module_position(tvb, pinfo, track_tree, offset, endianness_int, endianness_float);
512
0
    }
513
514
0
    if (offset != module_end)
515
0
        expert_add_info(pinfo, track_tree, &ei_rttrp_module_size);
516
0
    return module_end;
517
0
}
518
519
520
0
static int dissect_rttrp_module_spot(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, const unsigned endianness_int) {
521
0
    int module_end;
522
0
    uint32_t module_type, module_size;
523
0
    proto_item* spot_item;
524
0
    proto_tree* spot_tree = dissect_rttrp_module_header(tvb, tree, endianness_int, &spot_item, &offset,
525
0
        &module_end, &module_type, &module_size, hf_rttrp_module_spot, ett_rttrp_module_spot, hf_rttrp_module_spot_type, hf_rttrp_module_spot_size);
526
527
0
    if (module_type != RTTRP_MODULE_SPOT) {
528
0
        expert_add_info(pinfo, spot_tree, &ei_rttrp_module_type);
529
0
        return module_end;
530
0
    }
531
532
0
    uint32_t spot_id;
533
0
    proto_tree_add_item_ret_uint(spot_tree, hf_rttrp_spot_id, tvb, offset, 2, endianness_int, &spot_id);
534
0
    offset += 2;
535
0
    proto_tree_add_item(spot_tree, hf_rttrp_spot_offset, tvb, offset, 2, endianness_int);
536
0
    offset += 2;
537
538
0
    uint32_t channel_count;
539
0
    proto_tree_add_item_ret_uint(spot_tree, hf_rttrp_spot_channel_count, tvb, offset, 2, endianness_int, &channel_count);
540
0
    offset += 2;
541
542
0
    proto_item_append_text(spot_item, ", ID: %u, %u channels", spot_id, channel_count);
543
544
    /* Number of channels is small, so we don't add an extra container */
545
0
    for (unsigned int i = 0; i < channel_count; i++) {
546
0
        proto_item *chan_item = proto_tree_add_item(spot_tree, hf_rttrp_channel, tvb, offset, 5, ENC_NA);
547
0
        proto_tree *chan_tree = proto_item_add_subtree(chan_item, ett_rttrp_lighting_chan);
548
549
0
        uint32_t chan_offset;
550
0
        proto_tree_add_item_ret_uint(chan_tree, hf_rttrp_channel_offset, tvb, offset, 2, endianness_int, &chan_offset);
551
0
        offset += 2;
552
0
        proto_tree_add_item(chan_tree, hf_rttrp_channel_xfade, tvb, offset, 2, endianness_int);
553
0
        offset += 2;
554
0
        uint32_t chan_value;
555
0
        proto_tree_add_item_ret_uint(chan_tree, hf_rttrp_channel_value, tvb, offset, 1, endianness_int, &chan_value);
556
0
        offset += 1;
557
558
        /* add some info about the channel (number and intensity) */
559
0
        proto_item_append_text(chan_item, ", %u @ %u", chan_offset, chan_value);
560
0
    }
561
562
0
    if (offset != module_end)
563
0
        expert_add_info(pinfo, spot_tree, &ei_rttrp_module_size);
564
0
    return module_end;
565
0
}
566
567
0
static int dissect_rttrp_module_universe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, const unsigned endianness_int) {
568
0
    int module_end;
569
0
    uint32_t module_type, module_size;
570
0
    proto_item* univ_item;
571
0
    proto_tree* univ_tree = dissect_rttrp_module_header(tvb, tree, endianness_int, &univ_item, &offset,
572
0
        &module_end, &module_type, &module_size, hf_rttrp_module_universe, ett_rttrp_module_universe, hf_rttrp_module_universe_type, hf_rttrp_module_universe_size);
573
574
0
    if (module_type != RTTRP_MODULE_UNIVERSE) {
575
0
        expert_add_info(pinfo, univ_tree, &ei_rttrp_module_type);
576
0
        return module_end;
577
0
    }
578
579
0
    uint32_t universe_id;
580
0
    proto_tree_add_item_ret_uint(univ_tree, hf_rttrp_universe_id, tvb, offset, 2, endianness_int, &universe_id);
581
0
    offset += 2;
582
583
0
    uint32_t spot_count;
584
0
    proto_tree_add_item_ret_uint(univ_tree, hf_rttrp_universe_spot_count, tvb, offset, 2, endianness_int, &spot_count);
585
0
    offset += 2;
586
587
0
    proto_item_append_text(univ_item, ", ID: %u, %u spots", universe_id, spot_count);
588
589
0
    if (spot_count > 0) {
590
0
        proto_item *spot_holder = proto_tree_add_item(univ_tree, hf_rttrp_universe_spots, tvb, offset, module_size-4-3, ENC_NA);
591
0
        proto_tree *spot_tree = proto_item_add_subtree(spot_holder, ett_rttrp_lighting_spots);
592
593
0
        for (unsigned int i = 0; i < spot_count; i++) {
594
0
            offset = dissect_rttrp_module_spot(tvb, pinfo, spot_tree, offset, endianness_int);
595
0
        }
596
0
    }
597
598
0
    if (offset != module_end)
599
0
        expert_add_info(pinfo, univ_tree, &ei_rttrp_module_size);
600
0
    return module_end;
601
0
}
602
603
0
static int dissect_rttrp_module_lighting(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, const unsigned endianness_int) {
604
0
    int module_end;
605
0
    uint32_t module_type, module_size;
606
0
    proto_item* light_item;
607
0
    proto_tree* light_tree = dissect_rttrp_module_header(tvb, tree, endianness_int, &light_item, &offset,
608
0
        &module_end, &module_type, &module_size, hf_rttrp_module_lighting, ett_rttrp_module_lighting, hf_rttrp_module_lighting_type, hf_rttrp_module_lighting_size);
609
610
0
    if (module_type != RTTRP_MODULE_LIGHTING_OUTPUT && module_type != RTTRP_MODULE_LIGHTING_SYNC) {
611
0
        expert_add_info(pinfo, light_tree, &ei_rttrp_module_type);
612
0
        return module_end;
613
0
    }
614
615
0
    if (module_type == RTTRP_MODULE_LIGHTING_SYNC) {
616
0
        proto_tree_add_item(light_tree, hf_rttrp_sync_device_id, tvb, offset, 4, endianness_int);
617
0
        offset += 4;
618
0
        proto_tree_add_item(light_tree, hf_rttrp_sync_device_sub_id_0, tvb, offset, 4, endianness_int);
619
0
        offset += 4;
620
0
        proto_tree_add_item(light_tree, hf_rttrp_sync_device_sub_id_1, tvb, offset, 4, endianness_int);
621
0
        offset += 4;
622
0
        uint32_t sync_sequence;
623
0
        proto_tree_add_item_ret_uint(light_tree, hf_rttrp_sync_device_sequence_number, tvb, offset, 4, endianness_int, &sync_sequence);
624
0
        offset += 4;
625
0
        proto_item_append_text(light_item, ": Sync, Sequence: %u", sync_sequence);
626
627
0
        if (offset != module_end)
628
0
            expert_add_info(pinfo, light_tree, &ei_rttrp_module_size);
629
0
        return module_end;
630
0
    }
631
632
    /* Just lighting output now*/
633
0
    uint32_t lighting_sequence;
634
0
    proto_tree_add_item_ret_uint(light_tree, hf_rttrp_lighting_sequence, tvb, offset, 4, endianness_int, &lighting_sequence);
635
0
    offset += 4;
636
0
    proto_tree_add_item(light_tree, hf_rttrp_lighting_action, tvb, offset, 1, ENC_NA);
637
0
    offset += 1;
638
0
    proto_tree_add_item(light_tree, hf_rttrp_lighting_hold_time, tvb, offset, 4, endianness_int);
639
0
    offset += 4;
640
641
0
    uint32_t universe_count;
642
0
    proto_tree_add_item_ret_uint(light_tree, hf_rttrp_lighting_universe_count, tvb, offset, 2, endianness_int, &universe_count);
643
0
    offset += 2;
644
645
0
    proto_item_append_text(light_item, ": Output, Sequence: %u, %u universes", lighting_sequence, universe_count);
646
647
    /* Number of universes is usually small (1-10), so we don't add an extra container */
648
0
    for (unsigned int i = 0; i < universe_count; i++) {
649
0
        offset = dissect_rttrp_module_universe(tvb, pinfo, light_tree, offset, endianness_int);
650
0
    }
651
652
0
    if (offset != module_end)
653
0
        expert_add_info(pinfo, light_tree, &ei_rttrp_module_size);
654
0
    return module_end;
655
0
}
656
657
658
static int
659
dissect_rttrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
660
0
{
661
0
    if (tvb_reported_length(tvb) < 4) {
662
0
        return 0;
663
0
    }
664
665
0
    uint16_t int_sig = tvb_get_uint16(tvb, 0, ENC_BIG_ENDIAN);
666
0
    uint16_t float_sig = tvb_get_uint16(tvb, 2, ENC_BIG_ENDIAN);
667
668
0
    unsigned endianness_int;
669
0
    unsigned endianness_float;
670
671
0
    if (int_sig == RTTRP_INT_SIG_BE) {
672
0
        endianness_int = ENC_BIG_ENDIAN;
673
0
    } else if (int_sig == RTTRP_INT_SIG_LE) {
674
0
        endianness_int = ENC_LITTLE_ENDIAN;
675
0
    } else { /* We don't have an RTTrP packet */
676
0
        return 0;
677
0
    }
678
0
    if (float_sig == RTTRP_FLOAT_SIG_LIGHTING_BE || float_sig == RTTRP_FLOAT_SIG_MOTION_BE) {
679
0
        endianness_float = ENC_BIG_ENDIAN;
680
0
    } else if (float_sig == RTTRP_FLOAT_SIG_LIGHTING_LE || float_sig == RTTRP_FLOAT_SIG_MOTION_LE) {
681
0
        endianness_float = ENC_LITTLE_ENDIAN;
682
0
    } else {
683
0
        return 0;
684
0
    }
685
686
0
    int offset = 0;
687
0
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTTrP");
688
    /* Clear the info column */
689
0
    col_set_str(pinfo->cinfo, COL_INFO, "RTTrP");
690
691
0
    proto_item *ti = proto_tree_add_item(tree, proto_rttrp, tvb, 0, -1, ENC_NA);
692
0
    proto_tree *rttrp_tree = proto_item_add_subtree(ti, ett_rttrp);
693
694
    /* header values are always in big endian */
695
0
    proto_tree_add_item(rttrp_tree, hf_rttrp_int_signature, tvb, offset, 2, ENC_BIG_ENDIAN);
696
0
    offset += 2;
697
698
0
    proto_tree_add_item(rttrp_tree, hf_rttrp_float_signature, tvb, offset, 2, ENC_BIG_ENDIAN);
699
0
    offset += 2;
700
    /* Rename the protocol tree with additional information */
701
0
    if (float_sig == RTTRP_FLOAT_SIG_MOTION_BE || float_sig == RTTRP_FLOAT_SIG_MOTION_LE ) {
702
0
        proto_item_append_text(ti, " - Motion");
703
0
        col_append_str(pinfo->cinfo, COL_INFO, "M");
704
0
    } else if (float_sig == RTTRP_FLOAT_SIG_LIGHTING_BE || float_sig == RTTRP_FLOAT_SIG_LIGHTING_LE ) {
705
0
        proto_item_append_text(ti, " - Lighting");
706
0
        col_append_str(pinfo->cinfo, COL_INFO, "L");
707
0
    }
708
709
0
    proto_tree_add_item(rttrp_tree, hf_rttrp_header_version, tvb, offset, 2, ENC_BIG_ENDIAN);
710
0
    offset += 2;
711
712
0
    uint32_t packet_id;
713
0
    proto_tree_add_item_ret_uint(rttrp_tree, hf_rttrp_packet_id, tvb, offset, 4, endianness_int, &packet_id);
714
0
    offset += 4;
715
716
0
    proto_tree_add_item(rttrp_tree, hf_rttrp_packet_format, tvb, offset, 1, ENC_NA);
717
0
    offset += 1;
718
719
    /* update the length of the item containing the whole packet */
720
0
    uint32_t size;
721
0
    proto_tree_add_item_ret_uint(rttrp_tree, hf_rttrp_packet_size, tvb, offset, 2, endianness_int, &size);
722
0
    proto_item_set_len(ti, size);
723
0
    offset += 2;
724
725
0
    uint32_t packet_context;
726
0
    proto_tree_add_item_ret_uint(rttrp_tree, hf_rttrp_packet_context, tvb, offset, 4, endianness_int, &packet_context);
727
0
    offset += 4;
728
729
0
    uint32_t module_count;
730
0
    proto_tree_add_item_ret_uint(rttrp_tree, hf_rttrp_packet_module_count, tvb, offset, 1, ENC_NA, &module_count);
731
0
    offset += 1;
732
733
734
0
    if (float_sig == RTTRP_FLOAT_SIG_LIGHTING_LE || float_sig==RTTRP_FLOAT_SIG_LIGHTING_BE) {
735
0
        col_append_fstr(pinfo->cinfo, COL_INFO, ", Packet ID: %5u, %u Modules, Context: 0x%08x", packet_id, module_count, packet_context);
736
0
        for (unsigned int i = 0; i < module_count; i++) {
737
0
            offset = dissect_rttrp_module_lighting(tvb, pinfo, rttrp_tree, offset, endianness_int);
738
0
        }
739
0
    } else {
740
0
        col_append_fstr(pinfo->cinfo, COL_INFO, ", Packet ID: %5u, %u Trackers, Context: 0x%08x", packet_id, module_count, packet_context);
741
0
        for (unsigned int i = 0; i < module_count; i++) {
742
0
            offset = dissect_rttrp_module_trackable(tvb, pinfo, rttrp_tree, offset, endianness_int, endianness_float);
743
0
        }
744
0
    }
745
746
    /* number of bytes read */
747
0
    return offset;
748
0
}
749
750
/* Heuristic Dissector - RTTrPM has no defined port */
751
static bool
752
dissect_rttrp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
753
935
{
754
935
    uint16_t val;
755
756
935
    if (tvb_captured_length(tvb) < 4)
757
116
        return false;
758
759
    /* Check Int Signature */
760
819
    val = tvb_get_uint16(tvb, 0, ENC_BIG_ENDIAN);
761
819
    if (val != RTTRP_INT_SIG_BE && val != RTTRP_INT_SIG_LE)
762
814
        return false;
763
764
    /* Check Float Signature */
765
5
    val = tvb_get_uint16(tvb, 2, ENC_BIG_ENDIAN);
766
5
    if (val != RTTRP_FLOAT_SIG_LIGHTING_BE && val != RTTRP_FLOAT_SIG_LIGHTING_LE
767
5
        && val != RTTRP_FLOAT_SIG_MOTION_BE && val != RTTRP_FLOAT_SIG_MOTION_LE)
768
5
        return false;
769
770
    /* Set for the whole conversation */
771
0
    conversation_t* conversation = find_or_create_conversation(pinfo);
772
0
    conversation_set_dissector(conversation, rttrp_handle);
773
774
0
    dissect_rttrp(tvb, pinfo, tree, data);
775
776
0
    return true;
777
5
}
778
779
/******************************************************************************/
780
/* Register protocol                                                          */
781
void
782
14
proto_register_rttrp(void) {
783
14
    static hf_register_info hf[] = {
784
14
        { &hf_rttrp_int_signature,
785
14
            { "Integer Signature", "rttrp.int_signature",
786
14
            FT_UINT16, BASE_HEX,
787
14
            VALS(rttrp_int_sig_names), 0x0,
788
14
            NULL, HFILL }
789
14
        },
790
14
        { &hf_rttrp_float_signature,
791
14
            { "Float Signature", "rttrp.float_signature",
792
14
            FT_UINT16, BASE_HEX,
793
14
            VALS(rttrp_float_sig_names), 0x0,
794
14
            NULL, HFILL }
795
14
        },
796
14
        { &hf_rttrp_header_version,
797
14
            { "Header Version", "rttrp.header_version",
798
14
            FT_UINT16, BASE_HEX,
799
14
            NULL, 0x0,
800
14
            NULL, HFILL }
801
14
        },
802
14
        { &hf_rttrp_packet_id,
803
14
            { "Packet ID", "rttrp.packet_id",
804
14
            FT_UINT32, BASE_DEC,
805
14
            NULL, 0x0,
806
14
            NULL, HFILL }
807
14
        },
808
14
        { &hf_rttrp_packet_format,
809
14
            { "Packet Format", "rttrp.packet_format",
810
14
            FT_UINT8, BASE_HEX,
811
14
            VALS(rttrp_packet_format_names), 0x0,
812
14
            NULL, HFILL }
813
14
        },
814
14
        { &hf_rttrp_packet_size,
815
14
            { "Size", "rttrp.packet_size",
816
14
            FT_UINT16, BASE_DEC,
817
14
            NULL, 0x0,
818
14
            NULL, HFILL }
819
14
        },
820
14
        { &hf_rttrp_packet_context,
821
14
            { "Context", "rttrp.context",
822
14
            FT_UINT32, BASE_HEX,
823
14
            NULL, 0x0,
824
14
            NULL, HFILL }
825
14
        },
826
14
        { &hf_rttrp_packet_module_count,
827
14
            { "Number of Sub-Modules", "rttrp.module_count",
828
14
            FT_UINT8, BASE_DEC,
829
14
            NULL, 0x0,
830
14
            NULL, HFILL }
831
14
        },
832
833
14
        { &hf_rttrp_module_trackable,
834
14
            { "Trackable Module", "rttrp.trackable",
835
14
            FT_NONE, BASE_NONE,
836
14
            NULL, 0x0,
837
14
            NULL, HFILL }
838
14
        },
839
14
        { &hf_rttrp_module_trackable_type,
840
14
            { "Type", "rttrp.trackable.module_type",
841
14
            FT_UINT8, BASE_HEX,
842
14
            VALS(rttrp_module_names), 0x0,
843
14
            NULL, HFILL }
844
14
        },
845
14
        { &hf_rttrp_module_trackable_size,
846
14
            { "Size", "rttrp.trackable.module_size",
847
14
            FT_UINT16, BASE_DEC,
848
14
            NULL, 0x0,
849
14
            NULL, HFILL }
850
14
        },
851
14
        { &hf_rttrp_module_tracker_data,
852
14
            { "Tracker Data Module", "rttrp.trackable.data",
853
14
            FT_NONE, BASE_NONE,
854
14
            NULL, 0x0,
855
14
            NULL, HFILL }
856
14
        },
857
14
        { &hf_rttrp_module_tracker_data_type,
858
14
            { "Type", "rttrp.trackable.data.module_type",
859
14
            FT_UINT8, BASE_HEX,
860
14
            VALS(rttrp_module_names), 0x0,
861
14
            NULL, HFILL }
862
14
        },
863
14
        { &hf_rttrp_module_tracker_data_size,
864
14
            { "Size", "rttrp.trackable.data.module_size",
865
14
            FT_UINT16, BASE_DEC,
866
14
            NULL, 0x0,
867
14
            NULL, HFILL }
868
14
        },
869
14
        { &hf_rttrp_module_lighting,
870
14
            { "Lighting Module", "rttrp.lighting",
871
14
            FT_NONE, BASE_NONE,
872
14
            NULL, 0x0,
873
14
            NULL, HFILL }
874
14
        },
875
14
        { &hf_rttrp_module_lighting_type,
876
14
            { "Type", "rttrp.lighting.module_type",
877
14
            FT_UINT8, BASE_HEX,
878
14
            VALS(rttrp_module_names), 0x0,
879
14
            NULL, HFILL }
880
14
        },
881
14
        { &hf_rttrp_module_lighting_size,
882
14
            { "Size", "rttrp.lighting.module_size",
883
14
            FT_UINT16, BASE_DEC,
884
14
            NULL, 0x0,
885
14
            NULL, HFILL }
886
14
        },
887
14
        { &hf_rttrp_module_universe,
888
14
            { "Universe Module", "rttrp.lighting.universe",
889
14
            FT_NONE, BASE_NONE,
890
14
            NULL, 0x0,
891
14
            NULL, HFILL }
892
14
        },
893
14
        { &hf_rttrp_module_universe_type,
894
14
            { "Type", "rttrp.lighting.universe.module_type",
895
14
            FT_UINT8, BASE_HEX,
896
14
            VALS(rttrp_module_names), 0x0,
897
14
            NULL, HFILL }
898
14
        },
899
14
        { &hf_rttrp_module_universe_size,
900
14
            { "Size", "rttrp.lighting.universe.module_size",
901
14
            FT_UINT16, BASE_DEC,
902
14
            NULL, 0x0,
903
14
            NULL, HFILL }
904
14
        },
905
14
        { &hf_rttrp_module_spot,
906
14
            { "Spot Module", "rttrp.lighting.universe.spot",
907
14
            FT_NONE, BASE_NONE,
908
14
            NULL, 0x0,
909
14
            NULL, HFILL }
910
14
        },
911
14
        { &hf_rttrp_module_spot_type,
912
14
            { "Type", "rttrp.lighting.universe.spot.module_type",
913
14
            FT_UINT8, BASE_HEX,
914
14
            VALS(rttrp_module_names), 0x0,
915
14
            NULL, HFILL }
916
14
        },
917
14
        { &hf_rttrp_module_spot_size,
918
14
            { "Size", "rttrp.lighting.universe.spot.module_size",
919
14
            FT_UINT16, BASE_DEC,
920
14
            NULL, 0x0,
921
14
            NULL, HFILL }
922
14
        },
923
924
14
        { &hf_rttrp_module_latency,
925
14
            { "Latency", "rttrp.trackable.data.latency",
926
14
            FT_UINT16, BASE_DEC|BASE_UNIT_STRING,
927
14
            UNS(&units_milliseconds), 0x0,
928
14
            NULL, HFILL }
929
14
        },
930
931
14
        { &hf_rttrp_trackable_name_length,
932
14
            { "Name Length", "rttrp.trackable.name_length",
933
14
            FT_UINT8, BASE_DEC,
934
14
            NULL, 0x0,
935
14
            NULL, HFILL }
936
14
        },
937
14
        { &hf_rttrp_trackable_name,
938
14
            { "Name", "rttrp.trackable.name",
939
14
            FT_STRING, BASE_NONE,
940
14
            NULL, 0x0,
941
14
            NULL, HFILL }
942
14
        },
943
        /* No defined unit or reference, description labels it a sequence number */
944
14
        { &hf_rttrp_trackable_timestamp,
945
14
            { "Timestamp", "rttrp.trackable.timestamp",
946
14
            FT_UINT32, BASE_DEC,
947
14
            NULL, 0x0,
948
14
            NULL, HFILL }
949
14
        },
950
14
        { &hf_rttrp_trackable_module_count,
951
14
            { "Number of Sub-Modules", "rttrp.trackable.module_count",
952
14
            FT_UINT8, BASE_DEC,
953
14
            NULL, 0x0,
954
14
            NULL, HFILL }
955
14
        },
956
14
        { &hf_rttrp_trackable_modules,
957
14
            { "Sub-Modules", "rttrp.trackable.modules",
958
14
            FT_NONE, BASE_NONE,
959
14
            NULL, 0x0,
960
14
            NULL, HFILL }
961
14
        },
962
963
14
        { &hf_rttrp_position_x,
964
14
            { "X", "rttrp.position.x",
965
14
            FT_DOUBLE, BASE_NONE,
966
14
            NULL, 0x0,
967
14
            NULL, HFILL }
968
14
        },
969
14
        { &hf_rttrp_position_y,
970
14
            { "Y", "rttrp.position.y",
971
14
            FT_DOUBLE, BASE_NONE,
972
14
            NULL, 0x0,
973
14
            NULL, HFILL }
974
14
        },
975
14
        { &hf_rttrp_position_z,
976
14
            { "Z", "rttrp.position.z",
977
14
            FT_DOUBLE, BASE_NONE,
978
14
            NULL, 0x0,
979
14
            NULL, HFILL }
980
14
        },
981
14
        { &hf_rttrp_point_index,
982
14
            { "Index", "rttrp.trackable.data.point_index",
983
14
            FT_UINT8, BASE_DEC,
984
14
            NULL, 0x0,
985
14
            NULL, HFILL }
986
14
        },
987
988
14
        { &hf_rttrp_orientation_qx,
989
14
            { "Qx", "rttrp.orientation.qx",
990
14
            FT_DOUBLE, BASE_NONE,
991
14
            NULL, 0x0,
992
14
            NULL, HFILL }
993
14
        },
994
14
        { &hf_rttrp_orientation_qy,
995
14
            { "Qy", "rttrp.orientation.qy",
996
14
            FT_DOUBLE, BASE_NONE,
997
14
            NULL, 0x0,
998
14
            NULL, HFILL }
999
14
        },
1000
14
        { &hf_rttrp_orientation_qz,
1001
14
            { "Qz", "rttrp.orientation.qz",
1002
14
            FT_DOUBLE, BASE_NONE,
1003
14
            NULL, 0x0,
1004
14
            NULL, HFILL }
1005
14
        },
1006
14
        { &hf_rttrp_orientation_qw,
1007
14
            { "Qw", "rttrp.orientation.qw",
1008
14
            FT_DOUBLE, BASE_NONE,
1009
14
            NULL, 0x0,
1010
14
            NULL, HFILL }
1011
14
        },
1012
14
        { &hf_rttrp_orientation_order,
1013
14
            { "Order", "rttrp.orientation.order",
1014
14
            FT_UINT16, BASE_HEX,
1015
14
            VALS(rttrpm_euler_order_names), 0x0,
1016
14
            NULL, HFILL }
1017
14
        },
1018
14
        { &hf_rttrp_orientation_r1,
1019
14
            { "R1", "rttrp.orientation.r1",
1020
14
            FT_DOUBLE, BASE_NONE,
1021
14
            NULL, 0x0,
1022
14
            NULL, HFILL }
1023
14
        },
1024
14
        { &hf_rttrp_orientation_r2,
1025
14
            { "R2", "rttrp.orientation.r2",
1026
14
            FT_DOUBLE, BASE_NONE,
1027
14
            NULL, 0x0,
1028
14
            NULL, HFILL }
1029
14
        },
1030
14
        { &hf_rttrp_orientation_r3,
1031
14
            { "R3", "rttrp.orientation.r3",
1032
14
            FT_DOUBLE, BASE_NONE,
1033
14
            NULL, 0x0,
1034
14
            NULL, HFILL }
1035
14
        },
1036
1037
14
        { &hf_rttrp_acceleration_x,
1038
14
            { "Acceleration X", "rttrp.acceleration.x",
1039
14
            FT_FLOAT, BASE_NONE,
1040
14
            NULL, 0x0,
1041
14
            NULL, HFILL }
1042
14
        },
1043
14
        { &hf_rttrp_acceleration_y,
1044
14
            { "Acceleration Y", "rttrp.acceleration.y",
1045
14
            FT_FLOAT, BASE_NONE,
1046
14
            NULL, 0x0,
1047
14
            NULL, HFILL }
1048
14
        },
1049
14
        { &hf_rttrp_acceleration_z,
1050
14
            { "Acceleration Z", "rttrp.acceleration.z",
1051
14
            FT_FLOAT, BASE_NONE,
1052
14
            NULL, 0x0,
1053
14
            NULL, HFILL }
1054
14
        },
1055
14
        { &hf_rttrp_velocity_x,
1056
14
            { "Velocity X", "rttrp.velocity.x",
1057
14
            FT_FLOAT, BASE_NONE,
1058
14
            NULL, 0x0,
1059
14
            NULL, HFILL }
1060
14
        },
1061
14
        { &hf_rttrp_velocity_y,
1062
14
            { "Velocity Y", "rttrp.velocity.y",
1063
14
            FT_FLOAT, BASE_NONE,
1064
14
            NULL, 0x0,
1065
14
            NULL, HFILL }
1066
14
        },
1067
14
        { &hf_rttrp_velocity_z,
1068
14
            { "Velocity Z", "rttrp.velocity.z",
1069
14
            FT_FLOAT, BASE_NONE,
1070
14
            NULL, 0x0,
1071
14
            NULL, HFILL }
1072
14
        },
1073
1074
14
        { &hf_rttrp_zone_count,
1075
14
            { "Number of Zones", "rttrp.trackable.data.zone_count",
1076
14
            FT_UINT8, BASE_DEC,
1077
14
            NULL, 0x0,
1078
14
            NULL, HFILL }
1079
14
        },
1080
14
        { &hf_rttrp_zones,
1081
14
            { "Zones", "rttrp.trackable.data.zones",
1082
14
            FT_NONE, BASE_NONE,
1083
14
            NULL, 0x0,
1084
14
            NULL, HFILL }
1085
14
        },
1086
14
        { &hf_rttrp_zone,
1087
14
            { "Zone", "rttrp.trackable.data.zone",
1088
14
            FT_NONE, BASE_NONE,
1089
14
            NULL, 0x0,
1090
14
            NULL, HFILL }
1091
14
        },
1092
14
        { &hf_rttrp_zone_name_length,
1093
14
            { "Name Length", "rttrp.trackable.data.zone.name_length",
1094
14
            FT_UINT8, BASE_DEC,
1095
14
            NULL, 0x0,
1096
14
            NULL, HFILL }
1097
14
        },
1098
14
        { &hf_rttrp_zone_name,
1099
14
            { "Name", "rttrp.trackable.data.zone.name",
1100
14
            FT_STRING, BASE_NONE,
1101
14
            NULL, 0x0,
1102
14
            NULL, HFILL }
1103
14
        },
1104
14
        { &hf_rttrp_zone_names_delimited_length,
1105
14
            { "Delimited Zone List Length", "rttrp.trackable.data.zone_names_delimited_length",
1106
14
            FT_UINT16, BASE_DEC,
1107
14
            NULL, 0x0,
1108
14
            NULL, HFILL }
1109
14
        },
1110
14
        { &hf_rttrp_zone_size,
1111
14
            { "Size", "rttrp.trackable.data.zone.module_size",
1112
14
            FT_UINT16, BASE_DEC,
1113
14
            NULL, 0x0,
1114
14
            NULL, HFILL }
1115
14
        },
1116
1117
14
        { &hf_rttrp_lighting_sequence,
1118
14
            { "Lighting Sequence", "rttrp.lighting.sequence",
1119
14
            FT_UINT32, BASE_DEC,
1120
14
            NULL, 0x0,
1121
14
            NULL, HFILL }
1122
14
        },
1123
14
        { &hf_rttrp_lighting_action,
1124
14
            { "Action", "rttrp.lighting.action",
1125
14
            FT_UINT8, BASE_HEX,
1126
14
            VALS(rttrpl_action_names), 0x0,
1127
14
            NULL, HFILL }
1128
14
        },
1129
14
        { &hf_rttrp_lighting_hold_time,
1130
14
            { "Hold Time", "rttrp.lighting.hold_time",
1131
14
            FT_UINT32, BASE_DEC | BASE_SPECIAL_VALS,
1132
14
            VALS(rttrpl_hold_time_names), 0x0,
1133
14
            NULL, HFILL }
1134
14
        },
1135
14
        { &hf_rttrp_lighting_universe_count,
1136
14
            { "Number of Universe Modules", "rttrp.lighting.universe_count",
1137
14
            FT_UINT16, BASE_DEC,
1138
14
            NULL, 0x0,
1139
14
            NULL, HFILL }
1140
14
        },
1141
1142
1143
14
        { &hf_rttrp_universe_id,
1144
14
            { "Universe ID", "rttrp.lighting.universe.id",
1145
14
            FT_UINT16, BASE_DEC,
1146
14
            NULL, 0x0,
1147
14
            NULL, HFILL }
1148
14
        },
1149
14
        { &hf_rttrp_universe_spot_count,
1150
14
            { "Number of Spot Modules", "rttrp.lighting.universe.spot_count",
1151
14
            FT_UINT16, BASE_DEC,
1152
14
            NULL, 0x0,
1153
14
            NULL, HFILL }
1154
14
        },
1155
14
        { &hf_rttrp_universe_spots,
1156
14
            { "Spot Modules", "rttrp.lighting.universe.spots",
1157
14
            FT_NONE, BASE_NONE,
1158
14
            NULL, 0x0,
1159
14
            NULL, HFILL }
1160
14
        },
1161
1162
14
        { &hf_rttrp_spot_id,
1163
14
            { "Spot ID", "rttrp.lighting.universe.spot.id",
1164
14
            FT_UINT16, BASE_DEC,
1165
14
            NULL, 0x0,
1166
14
            NULL, HFILL }
1167
14
        },
1168
14
        { &hf_rttrp_spot_offset,
1169
14
            { "Spot Offset", "rttrp.lighting.universe.spot.offset",
1170
14
            FT_UINT16, BASE_DEC,
1171
14
            NULL, 0x0,
1172
14
            NULL, HFILL }
1173
14
        },
1174
14
        { &hf_rttrp_spot_channel_count,
1175
14
            { "Number of Channel Structures", "rttrp.lighting.universe.spot.channel_count",
1176
14
            FT_UINT16, BASE_DEC,
1177
14
            NULL, 0x0,
1178
14
            NULL, HFILL }
1179
14
        },
1180
1181
14
        { &hf_rttrp_channel,
1182
14
            { "Channel", "rttrp.lighting.universe.spot.channel",
1183
14
            FT_NONE, BASE_NONE,
1184
14
            NULL, 0x0,
1185
14
            NULL, HFILL }
1186
14
        },
1187
14
        { &hf_rttrp_channel_offset,
1188
14
            { "Channel Offset", "rttrp.lighting.universe.spot.channel.offset",
1189
14
            FT_UINT16, BASE_DEC,
1190
14
            NULL, 0x0,
1191
14
            NULL, HFILL }
1192
14
        },
1193
14
        { &hf_rttrp_channel_xfade,
1194
14
            { "Xfade", "rttrp.lighting.universe.spot.channel.xfade",
1195
14
            FT_UINT16, BASE_DEC,
1196
14
            NULL, 0x0,
1197
14
            NULL, HFILL }
1198
14
        },
1199
14
        { &hf_rttrp_channel_value,
1200
14
            { "Value", "rttrp.lighting.universe.spot.channel.value",
1201
14
            FT_UINT8, BASE_DEC,
1202
14
            NULL, 0x0,
1203
14
            NULL, HFILL }
1204
14
        },
1205
1206
14
        { &hf_rttrp_sync_device_id,
1207
14
            { "Device ID", "rttrp.lighting.device_id",
1208
14
            FT_UINT32, BASE_DEC,
1209
14
            NULL, 0x0,
1210
14
            NULL, HFILL }
1211
14
        },
1212
14
        { &hf_rttrp_sync_device_sub_id_0,
1213
14
            { "Device Sub ID 0", "rttrp.lighting.device_sub_id_0",
1214
14
            FT_UINT32, BASE_DEC,
1215
14
            NULL, 0x0,
1216
14
            NULL, HFILL }
1217
14
        },
1218
14
        { &hf_rttrp_sync_device_sub_id_1,
1219
14
            { "Device Sub ID 1", "rttrp.lighting.device_sub_id_1",
1220
14
            FT_UINT32, BASE_DEC,
1221
14
            NULL, 0x0,
1222
14
            NULL, HFILL }
1223
14
        },
1224
14
        { &hf_rttrp_sync_device_sequence_number,
1225
14
            { "Sequence Number", "rttrp.lighting.device_sequence_number",
1226
14
            FT_UINT32, BASE_DEC,
1227
14
            NULL, 0x0,
1228
14
            NULL, HFILL }
1229
14
        },
1230
14
    };
1231
1232
    /* Setup protocol subtree array */
1233
14
    static int *ett[] = {
1234
14
        &ett_rttrp,
1235
1236
14
        &ett_rttrp_module_trackable,
1237
14
        &ett_rttrp_module_tracker_data,
1238
14
        &ett_rttrp_module_lighting,
1239
14
        &ett_rttrp_module_universe,
1240
14
        &ett_rttrp_module_spot,
1241
1242
14
        &ett_rttrp_collision_zones,
1243
14
        &ett_rttrp_collision_zone,
1244
1245
14
        &ett_rttrp_lighting_spots,
1246
14
        &ett_rttrp_lighting_chan,
1247
14
    };
1248
1249
14
    static ei_register_info ei[] = {
1250
14
        { &ei_rttrp_module_type, { "rttrp.module_type.invalid_type", PI_PROTOCOL, PI_ERROR, "Invalid module type for this location", EXPFILL }},
1251
14
        { &ei_rttrp_module_size, { "rttrp.module_size.mismatch", PI_PROTOCOL, PI_WARN, "Mismatch between reported module length and consumed data", EXPFILL }},
1252
14
    };
1253
1254
14
    proto_rttrp = proto_register_protocol("Real-Time Tracking Protocol", "RTTrP", "rttrp");
1255
1256
14
    proto_register_field_array(proto_rttrp, hf, array_length(hf));
1257
14
    proto_register_subtree_array(ett, array_length(ett));
1258
14
    expert_module_t* expert_rttrp;
1259
14
    expert_rttrp = expert_register_protocol(proto_rttrp);
1260
14
    expert_register_field_array(expert_rttrp, ei, array_length(ei));
1261
1262
14
    rttrp_handle = register_dissector_with_description(
1263
14
        "rttrp",          /* dissector name           */
1264
14
        "RTTrP",          /* dissector description    */
1265
14
        dissect_rttrp,    /* dissector function       */
1266
14
        proto_rttrp       /* protocol being dissected */
1267
14
    );
1268
14
}
1269
1270
/******************************************************************************/
1271
/* Register handoff                                                           */
1272
void
1273
proto_reg_handoff_rttrp(void)
1274
14
{
1275
14
    dissector_add_for_decode_as_with_preference("udp.port", rttrp_handle);
1276
1277
14
    heur_dissector_add("udp", dissect_rttrp_heur, "RTTrP over UDP", "rttrp_udp", proto_rttrp, HEURISTIC_ENABLE);
1278
14
}
1279
1280
/*
1281
 * Editor modelines
1282
 *
1283
 * Local Variables:
1284
 * c-basic-offset: 4
1285
 * tab-width: 8
1286
 * indent-tabs-mode: nil
1287
 * End:
1288
 *
1289
 * ex: set shiftwidth=4 tabstop=8 expandtab:
1290
 * :indentSize=4:tabSize=8:noTabs=true:
1291
 */