summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-simple.c
blob: e1329a962ba9cc5c13469ec2641a841f88749a03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
/* packet-simple.c
 * Routines for SIMPLE dissection
 * Copyright 2015 Peter Ross
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

/* SIMPLE (Standard Interface for Multiple Platform Link Evaluation)
 * is a protocol for exchanging tactical data link messages, such as Link 16,
 * over Internet Protocols.
 *
 * The protocol is described in STANAG 5602. See:
 * http://assistdoc1.dla.mil/qsDocDetails.aspx?ident_number=213042
 */

#include "config.h"

#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/expert.h>
#include "packet-link16.h"

void proto_reg_handoff_simple(void);

void proto_register_simple(void);

static const range_string Node_Strings[] = {
    { 1, 128, "Unicast" },
    { 129, 129, "Broadcast" },
    { 160, 168, "Multicast" },
    { 169, 169, "Adjacent" },
    { 0, 0, NULL },
};

static const value_string Subnode_Strings[] = {
    { 1, "RTT" },
    { 2, "Terminal-Host Interface" },
    { 4, "File & Mail Transfers" },
    { 5, "Open" },
    { 6, "Status & Control" },
    { 7, "Time Synchronisation" },
    { 202, "Scenario (Script)" },
    { 203, "IJMS" },
    { 204, "Link 4" },
    { 205, "Link 11" },
    { 206, "Link 16" },
    { 207, "Link 22" },
    { 208, "DIS" },
    { 209, "Voice Group A" },
    { 210, "Voice Group B" },
    { 211, "Link 11B" },
    { 0, NULL },
};

enum {
    SIMPLE_LINK16 = 1,
    SIMPLE_STATUS = 61
};

static const value_string PacketType_Strings[] = {
    { SIMPLE_LINK16, "Link 16" },
    { 2, "Link 11" },
    { 3, "Link 4" },
    { 4, "Link 22" },
    { 5, "Interim JTIDS Message Standard (IJMS)" },
    { 8, "Variable Message Format (VMF)" },
    { 10, "MIDS Terminal Specific Messages (MTSM)" },
    { 13, "MIDS/JTIDS Voice" },
    { 20, "Link 11B" },
    { 32, "DIS Protocol Data Unit (PDU)" },
    { SIMPLE_STATUS, "Status/Configuration" },
    { 62, "E-mail/File Transfer Protocol (FTP)" },
    { 63, "Round Trip Timing (RTT)" },
    { 65, "Time Synchronisation" },
    { 66, "TSA Status" },
    { 100, "National Message" },
    { 0, NULL },
};

enum {
    SIMPLE_LINK16_FIXED_FORMAT = 2
};

static const value_string Link16_Subtype_Strings[] = {
    { 0, "Uncoded Free Text" },
    { 1, "Coded Free Text" },
    { SIMPLE_LINK16_FIXED_FORMAT, "Fixed Format" },
    { 0, NULL },
};

static const value_string Status_Subtype_Strings[] = {
    { 1, "Node Status" },
    { 0, NULL },
};

static const value_string Security_Level_Strings[] = {
    { 0, "Unclassified" },
    { 1, "NATO Unclassified" },
    { 2, "Confidential" },
    { 3, "NATO Confidential" },
    { 4, "Secret" },
    { 5, "NATO Secret" },
    { 6, "National Only" },
    { 7, "Level 7" },
    { 8, "Level 8" },
    { 9, "Level 9" },
    { 0, NULL },
};

static const value_string Link16_Terminal_Type[] = {
    { 0, "None" },
    { 1, "US Navy Air (JTIDS)" },
    { 2, "US Navy Ship (JTIDS)" },
    { 3, "US F-15 (JTIDS)" },
    { 4, "US F/A-18 (MIDS)" },
    { 5, "US Army Class 2M (JTIDS)" },
    { 6, "US MCE (JTIDS)" },
    { 7, "E-3 (JTIDS)" },
    { 8, "UK Tornado F3 (JTIDS)" },
    { 9, "UK UKADGE (JTIDS)" },
    { 10, "Low Volume Terminal - Generic (MIDS)" },
    { 11, "Low Volume Terminal - Platform Type A (MIDS)" },
    { 12, "Low Volume Terminal - Platform Type B (MIDS)" },
    { 13, "Low Volume Terminal - Platform Type C (MIDS)" },
    { 14, "Low Volume Terminal - Platform Type D (MIDS)" },
    { 15, "Low Volume Terminal - Platform Type E (MIDS)" },
    { 16, "Low Volume Terminal - Platform Type F (MIDS)" },
    { 17, "Low Volume Terminal - Platform Type G (MIDS)" },
    { 18, "Low Volume Terminal 2, US Army (MIDS)" },
    { 19, "Low Volume Terminal MIDS on Ship (MOS) (MIDS)" },
    { 20, "US Fighter Data Link (FDL) (MIDS)" },
    { 21, "AN/URC-138" },
    { 22, "Low Volume Terminal Platform Type H (MIDS)" },
    { 23, "Low Volume Terminal Platform Type I (MIDS)" },
    { 0, NULL },
};

static const value_string Link16_Role[] = {
    { 0, "None" },
    { 1, "SIMPLE Host (SH)" },
    { 2, "SIMPLE Terminal Emulator (STE)" },
    { 3, "SIMPLE Network Monitor (SNM)" },
    { 4, "SIMPLE Virtual Host (SVH)" },
    { 5, "SIMPLE Virtual Terminal (SVT)" },
    { 0, NULL },
};

static const value_string Link16_Sync_Status[] = {
    { 0, "None" },
    { 1, "Net Entry in Progress" },
    { 2, "Coarse Sync" },
    { 3, "Fine Sync" },
    { 0, NULL },
};

static const value_string Link_Terminal_Host_Status[] = {
    { 0, "Inactive" },
    { 1, "Active" },
    { 0, NULL },
};

static const value_string Link11_DTS_Type[] = {
    { 0, "None" },
    { 1, "MIL-STD-1397 parallel" },
    { 2, "MIL-STD-188-203-1A serial" },
    { 0, NULL },
};

static const value_string Link11_Role[] = {
    { 0, "None"},
    { 1, "SIMPLE DTS EMULATOR (SDE) Picket"},
    { 2, "SDE Net Control Station (NCS)" },
    { 3, "SIMPLE Participating Unit (PU) Emulator (SPE)" },
    { 0, NULL },
};

static int proto_simple;

static dissector_handle_t simple_dissector_handle;
static dissector_handle_t link16_handle;

static int hf_simple_sync_byte_1;
static int hf_simple_sync_byte_2;
static int hf_simple_length;
static int hf_simple_sequence_number;
static int hf_simple_src_node;
static int hf_simple_src_subnode;
static int hf_simple_dst_node;
static int hf_simple_dst_subnode;
static int hf_simple_packet_size;
static int hf_simple_packet_type;
static int hf_simple_transit_time;
static int hf_simple_link16_subtype;
static int hf_simple_link16_rc;
static int hf_simple_link16_network;
static int hf_simple_link16_ssc2;
static int hf_simple_link16_npg;
static int hf_simple_link16_ssc1;
static int hf_simple_link16_stn;
static int hf_simple_link16_word_count;
static int hf_simple_link16_loopback_id;
static int hf_simple_status_subtype;
static int hf_simple_status_word_count;
static int hf_simple_status_name;
static int hf_simple_status_time_hours;
static int hf_simple_status_node_id;
static int hf_simple_status_time_seconds;
static int hf_simple_status_time_minutes;
static int hf_simple_status_security_level;
static int hf_simple_status_node_entry_flag;
static int hf_simple_status_relay_hop;
static int hf_simple_status_dx_flag_system_messages;
static int hf_simple_status_dx_flag_common_tims_bims;
static int hf_simple_status_dx_flag_common_toms_boms;
static int hf_simple_status_dx_flag_simple_receive;
static int hf_simple_status_dx_flag_simple_transmit;
static int hf_simple_status_dx_flag_all_tims_bims;
static int hf_simple_status_dx_flag_all_toms_boms;
static int hf_simple_status_dx_file_id;
static int hf_simple_status_spare_1;
static int hf_simple_status_link16_terminal_type;
static int hf_simple_status_link16_role;
static int hf_simple_status_link16_sync_status;
static int hf_simple_status_link16_terminal_host_status;
static int hf_simple_status_link16_stn;
static int hf_simple_status_spare_2;
static int hf_simple_status_link11_dts_type;
static int hf_simple_status_link11_role;
static int hf_simple_status_link11_pu;
static int hf_simple_status_link11_dts_host_status;
static int hf_simple_status_spare_3;
static int hf_simple_checksum;
static int hf_simple_checksum_status;

static int ett_simple;
static int ett_packet;
static int ett_simple_status_dx_flag;

static expert_field ei_simple_sync_bytes_bad;
static expert_field ei_simple_length_bad;
static expert_field ei_simple_packet_size_bad;
static expert_field ei_simple_checksum_bad;

static void dissect_simple_link16(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
    unsigned subtype, stn, word_count, i;
    Link16State state;
    tvbuff_t *newtvb;

    proto_tree_add_item(tree, hf_simple_link16_subtype, tvb, offset, 1, ENC_NA);
    subtype = tvb_get_uint8(tvb, offset);
    offset++;

    proto_tree_add_item(tree, hf_simple_link16_rc, tvb, offset, 1, ENC_NA);
    offset++;

    proto_tree_add_item(tree, hf_simple_link16_network, tvb, offset, 1, ENC_NA);
    offset++;

    proto_tree_add_item(tree, hf_simple_link16_ssc2, tvb, offset, 1, ENC_NA);
    offset++;

    proto_tree_add_item(tree, hf_simple_link16_npg, tvb, offset, 2, ENC_LITTLE_ENDIAN);
    offset += 2;

    proto_tree_add_item(tree, hf_simple_link16_ssc1, tvb, offset, 2, ENC_LITTLE_ENDIAN);
    offset += 2;

    proto_tree_add_item(tree, hf_simple_link16_stn, tvb, offset, 2, ENC_LITTLE_ENDIAN);
    stn = tvb_get_letohs(tvb, offset);
    offset += 2;

    proto_tree_add_item(tree, hf_simple_link16_word_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
    word_count = tvb_get_uint8(tvb, offset);
    offset += 2;

    proto_tree_add_item(tree, hf_simple_link16_loopback_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
    offset += 2;

    col_append_fstr(pinfo->cinfo, COL_INFO, ", STN: %05o, Words:", stn);

    switch(subtype) {
    case SIMPLE_LINK16_FIXED_FORMAT:
        memset(&state, 0, sizeof(state));
        for (i = 0; i < word_count; i += 5) {
            newtvb = tvb_new_subset_length_caplen(tvb, offset, 10, -1);
            add_new_data_source(pinfo, newtvb, "Link 16 Word");
            call_dissector_with_data(link16_handle, newtvb, pinfo, tree, &state);
            offset += 10;
        }
        break;
    }
}

static int * const simple_status_dx_flag_fields[] = {
    &hf_simple_status_dx_flag_system_messages,
    &hf_simple_status_dx_flag_common_tims_bims,
    &hf_simple_status_dx_flag_common_toms_boms,
    &hf_simple_status_dx_flag_simple_receive,
    &hf_simple_status_dx_flag_simple_transmit,
    &hf_simple_status_dx_flag_all_tims_bims,
    &hf_simple_status_dx_flag_all_toms_boms,
    NULL
};

#define SIMPLE_STATUS_NAME_LEN 10

static void dissect_simple_status(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
    char *name;
    int link16_status, pu;

    proto_tree_add_item(tree, hf_simple_status_subtype, tvb, offset, 1, ENC_NA);
    offset++;

    proto_tree_add_item(tree, hf_simple_status_word_count, tvb, offset, 1, ENC_NA);
    offset++;

    name = tvb_get_stringzpad(pinfo->pool, tvb, offset, SIMPLE_STATUS_NAME_LEN, ENC_ASCII|ENC_NA);
    col_append_fstr(pinfo->cinfo, COL_INFO, ", Name: %s", name);
    proto_tree_add_item(tree, hf_simple_status_name, tvb, offset, SIMPLE_STATUS_NAME_LEN, ENC_ASCII);
    offset += SIMPLE_STATUS_NAME_LEN;

    proto_tree_add_item(tree, hf_simple_status_time_hours, tvb, offset, 1, ENC_NA);
    offset++;

    proto_tree_add_item(tree, hf_simple_status_node_id, tvb, offset, 1, ENC_NA);
    offset++;

    proto_tree_add_item(tree, hf_simple_status_time_seconds, tvb, offset, 1, ENC_NA);
    offset++;

    proto_tree_add_item(tree, hf_simple_status_time_minutes, tvb, offset, 1, ENC_NA);
    offset++;

    proto_tree_add_item(tree, hf_simple_status_security_level, tvb, offset, 1, ENC_NA);
    offset++;

    proto_tree_add_item(tree, hf_simple_status_node_entry_flag, tvb, offset, 1, ENC_NA);
    offset++;

    proto_tree_add_item(tree, hf_simple_status_relay_hop, tvb, offset, 16, ENC_NA);
    offset += 16;

    proto_tree_add_bitmask_text(tree, tvb, offset, 2, "Data Extraction Flags", NULL, ett_simple_status_dx_flag, simple_status_dx_flag_fields, ENC_LITTLE_ENDIAN, 0);
    offset += 2;

    proto_tree_add_item(tree, hf_simple_status_dx_file_id, tvb, offset, 8, ENC_ASCII);
    offset += 8;

    proto_tree_add_item(tree, hf_simple_status_spare_1, tvb, offset, 2, ENC_NA);
    offset += 2;

    proto_tree_add_item(tree, hf_simple_status_link16_terminal_type, tvb, offset, 1, ENC_NA);
    offset++;

    proto_tree_add_item(tree, hf_simple_status_link16_role, tvb, offset, 1, ENC_NA);
    offset++;

    proto_tree_add_item(tree, hf_simple_status_link16_sync_status, tvb, offset, 1, ENC_NA);
    offset++;

    proto_tree_add_item(tree, hf_simple_status_link16_terminal_host_status, tvb, offset, 1, ENC_NA);
    link16_status = tvb_get_uint8(tvb, offset);
    offset++;

    proto_tree_add_item(tree, hf_simple_status_link16_stn, tvb, offset, 2, ENC_LITTLE_ENDIAN);
    if (link16_status)
        col_append_fstr(pinfo->cinfo, COL_INFO, ", STN: %05o", tvb_get_letohs(tvb, offset));
    offset += 2;

    proto_tree_add_item(tree, hf_simple_status_spare_2, tvb, offset, 2, ENC_NA);
    offset += 2;

    proto_tree_add_item(tree, hf_simple_status_link11_dts_type, tvb, offset, 1, ENC_NA);
    offset++;

    proto_tree_add_item(tree, hf_simple_status_link11_role, tvb, offset, 1, ENC_NA);
    offset++;

    proto_tree_add_item(tree, hf_simple_status_link11_pu, tvb, offset, 1, ENC_NA);
    pu = tvb_get_uint8(tvb, offset);
    offset++;

    proto_tree_add_item(tree, hf_simple_status_link11_dts_host_status, tvb, offset, 1, ENC_NA);
    if (tvb_get_uint8(tvb, offset))
        col_append_fstr(pinfo->cinfo, COL_INFO, ", PU: %03o", pu);
    offset++;

    proto_tree_add_item(tree, hf_simple_status_spare_3, tvb, offset, 4, ENC_NA);
}

static void dissect_checksum(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
    const uint8_t * v = tvb_get_ptr(tvb, 0, offset);
    uint16_t expected_checksum = 0;
    int i;

    for (i = 0; i < offset; i++)
        expected_checksum += v[i];

    proto_tree_add_checksum(tree, tvb, offset, hf_simple_checksum, hf_simple_checksum_status, &ei_simple_checksum_bad, pinfo, expected_checksum,
                            ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY);
}

static int dissect_simple(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
    proto_item *simple_item = NULL, *item;
    proto_tree *simple_tree = NULL, *packet_tree = NULL;
    unsigned offset = 0, length, packet_size, packet_type;
    const char *packet_type_string;
    uint8_t sync_bytes_bad = 0;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "SIMPLE");

    if (tree) {
        simple_item = proto_tree_add_item(tree, proto_simple, tvb, 0, -1, ENC_NA);
        simple_tree = proto_item_add_subtree(simple_item, ett_simple);
    }

    proto_tree_add_item(simple_tree, hf_simple_sync_byte_1, tvb, offset, 1, ENC_NA);
    sync_bytes_bad |= tvb_get_uint8(tvb, offset) ^ 0x49;
    offset++;

    proto_tree_add_item(simple_tree, hf_simple_sync_byte_2, tvb, offset, 1, ENC_NA);
    sync_bytes_bad |= tvb_get_uint8(tvb, offset) ^ 0x36;
    offset++;

    if (sync_bytes_bad)
        expert_add_info(pinfo, simple_item, &ei_simple_sync_bytes_bad);

    item = proto_tree_add_item(simple_tree, hf_simple_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
    length = tvb_get_letohs(tvb, offset);
    offset += 2;

    if (length < 16 || length >= 518 || length > tvb_reported_length(tvb))
        expert_add_info(pinfo, item, &ei_simple_length_bad);

    proto_tree_add_item(simple_tree, hf_simple_sequence_number, tvb, offset, 2, ENC_LITTLE_ENDIAN);
    offset += 2;

    proto_tree_add_item(simple_tree, hf_simple_src_node, tvb, offset, 1, ENC_NA);
    offset++;

    proto_tree_add_item(simple_tree, hf_simple_src_subnode, tvb, offset, 1, ENC_NA);
    offset++;

    proto_tree_add_item(simple_tree, hf_simple_dst_node, tvb, offset, 1, ENC_NA);
    offset++;

    proto_tree_add_item(simple_tree, hf_simple_dst_subnode, tvb, offset, 1, ENC_NA);
    offset++;

    item = proto_tree_add_item(simple_tree, hf_simple_packet_size, tvb, offset, 1, ENC_NA);
    packet_size = tvb_get_uint8(tvb, offset) * 2;
    if (packet_size < 8 || packet_size - 8 > tvb_reported_length(tvb))
        expert_add_info(pinfo, item, &ei_simple_packet_size_bad);
    packet_size -= 8;
    offset++;

    proto_tree_add_item(simple_tree, hf_simple_packet_type, tvb, offset, 1, ENC_NA);
    packet_type = tvb_get_uint8(tvb, offset);
    offset++;

    proto_tree_add_item(simple_tree, hf_simple_transit_time, tvb, offset, 2, ENC_LITTLE_ENDIAN);
    offset += 2;

    packet_type_string = val_to_str_const(packet_type, PacketType_Strings, "Unknown");
    col_add_str(pinfo->cinfo, COL_INFO, packet_type_string);
    packet_tree = proto_tree_add_subtree_format(simple_tree, tvb, offset, packet_size, ett_packet, NULL, "%s Packet", packet_type_string);

    switch(packet_type) {
    case SIMPLE_LINK16:
        dissect_simple_link16(tvb, pinfo, packet_tree, offset);
        break;
    case SIMPLE_STATUS:
        dissect_simple_status(tvb, pinfo, packet_tree, offset);
        break;
    }

    dissect_checksum(tvb, pinfo, simple_tree, length - 2);

    return tvb_captured_length(tvb);
}

void proto_register_simple(void)
{
    static hf_register_info hf[] = {
        { &hf_simple_sync_byte_1,
          { "Sync Byte 1", "simple.sync_byte_1", FT_UINT8, BASE_HEX, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_sync_byte_2,
          { "Sync Byte 2", "simple.sync_byte_2", FT_UINT8, BASE_HEX, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_length,
          { "Length", "simple.length", FT_UINT16, BASE_DEC, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_sequence_number,
          { "Sequence Number", "simple.sequence_number", FT_UINT16, BASE_DEC, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_src_node,
          { "Source Node", "simple.src_node", FT_UINT8, BASE_RANGE_STRING | BASE_DEC, RVALS(Node_Strings), 0x0,
            NULL, HFILL }},
        { &hf_simple_src_subnode,
          { "Source Subnode", "simple.src_subnode", FT_UINT8, BASE_DEC, VALS(Subnode_Strings), 0x0,
            NULL, HFILL }},
        { &hf_simple_dst_node,
          { "Destination Node", "simple.dst_node", FT_UINT8, BASE_RANGE_STRING | BASE_DEC, RVALS(Node_Strings), 0x0,
            NULL, HFILL }},
        { &hf_simple_dst_subnode,
          { "Destination Subnode", "simple.dst_subnode", FT_UINT8, BASE_DEC, VALS(Subnode_Strings), 0x0,
            NULL, HFILL }},
        { &hf_simple_packet_size,
          { "Packet Size", "simple.packet_size", FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_packet_type,
          { "Packet Type", "simple.packet_type", FT_UINT8, BASE_DEC, VALS(PacketType_Strings), 0x0,
            NULL, HFILL }},
        { &hf_simple_transit_time,
          { "Transit Time", "simple.transit_time", FT_UINT16, BASE_DEC, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_link16_subtype,
          { "Subtype", "simple.link16.subtype", FT_UINT8, BASE_DEC, VALS(Link16_Subtype_Strings), 0x0,
            NULL, HFILL }},
        { &hf_simple_link16_rc,
          { "R/C Flag", "simple.link16.rc", FT_BOOLEAN, BASE_NONE, TFS(&tfs_required_not_required), 0x0,
            NULL, HFILL }},
        { &hf_simple_link16_network,
          { "Network", "simple.link16.network", FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_link16_ssc2,
          { "Sequential Slot Count 2", "simple.link16.ssc2", FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_link16_npg,
          { "NPG Number", "simple.link16.npg", FT_UINT16, BASE_DEC, VALS(Link16_NPG_Strings), 0x0,
            NULL, HFILL }},
        { &hf_simple_link16_ssc1,
          { "Sequential Slot Count 1", "simple.link16.ssc1", FT_UINT16, BASE_DEC, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_link16_stn,
          { "Source Track Number", "simple.link16.stn", FT_UINT16, BASE_OCT, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_link16_word_count,
          { "Word Count", "simple.link16.word_count", FT_UINT16, BASE_DEC, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_link16_loopback_id,
          { "Loopback ID", "simple.link16.loopback_id", FT_UINT16, BASE_DEC, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_status_subtype,
          { "Subtype", "simple.status.subtype", FT_UINT8, BASE_HEX, VALS(Status_Subtype_Strings), 0x0,
            NULL, HFILL }},
        { &hf_simple_status_word_count,
          { "Word Count", "simple.status.word_count", FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_status_name,
          { "Name", "simple.status.name", FT_STRING, BASE_NONE, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_status_time_hours,
          { "Time (Hours)", "simple.status.time_hours", FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_status_node_id,
          { "Node Id", "simple.status.node_id", FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_status_time_seconds,
          { "Time (Seconds)", "simple.status.time_seconds", FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_status_time_minutes,
          { "Time (Minutes)", "simple.status.time_minutes", FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_status_security_level,
          { "Security Level", "simple.status.security_level", FT_UINT8, BASE_DEC, VALS(Security_Level_Strings), 0x0,
            NULL, HFILL }},
        { &hf_simple_status_node_entry_flag,
          { "Node Entry Flag", "simple.status.node_entry_flag", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_status_relay_hop,
          { "Relay Hop", "simple.status.relay_hop", FT_BYTES, BASE_NONE, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_status_dx_flag_system_messages,
          { "DX System Messages", "simple.status.dx_flag.system_messages", FT_BOOLEAN, 16, NULL, 0x0001,
            NULL, HFILL }},
        { &hf_simple_status_dx_flag_common_tims_bims,
          { "DX Common TIMS/BIMS", "simple.status.dx_flag.common_tims_bims", FT_BOOLEAN, 16, NULL, 0x0002,
            NULL, HFILL }},
        { &hf_simple_status_dx_flag_common_toms_boms,
          { "DX Common TOMS/BOMS", "simple.status.dx_flag.common_toms_boms", FT_BOOLEAN, 16, NULL, 0x0004,
            NULL, HFILL }},
        { &hf_simple_status_dx_flag_simple_receive,
          { "DX SIMPLE Receive", "simple.status.dx_flag.simple_receive", FT_BOOLEAN, 16, NULL, 0x8,
            NULL, HFILL }},
        { &hf_simple_status_dx_flag_simple_transmit,
          { "DX SIMPLE Transmit", "simple.status.dx_flag.simple_transmit", FT_BOOLEAN, 16, NULL, 0x0010,
            NULL, HFILL }},
        { &hf_simple_status_dx_flag_all_tims_bims,
          { "DX All TIMS/BIMS", "simple.status.dx_flag.all_tims_bims", FT_BOOLEAN, 16, NULL, 0x0020,
            NULL, HFILL }},
        { &hf_simple_status_dx_flag_all_toms_boms,
          { "DX All TOMS/BOMS", "simple.status.dx_flag.all_toms_boms", FT_BOOLEAN, 16, NULL, 0x0040,
            NULL, HFILL }},
        { &hf_simple_status_dx_file_id,
          { "DX File Id", "simple.status.dx_file_id", FT_STRING, BASE_NONE, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_status_spare_1,
          { "Spare1", "simple.status.spare_1", FT_BYTES, BASE_NONE, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_status_link16_terminal_type,
          { "Link 16 Type", "simple.status.link16.terminal_type", FT_UINT8, BASE_DEC, VALS(Link16_Terminal_Type), 0x0,
            NULL, HFILL }},
        { &hf_simple_status_link16_role,
          { "Link 16 Role", "simple.status.link16.role", FT_UINT8, BASE_DEC, VALS(Link16_Role), 0x0,
            NULL, HFILL }},
        { &hf_simple_status_link16_sync_status,
          { "Link 16 Sync Status", "simple.status.link16.sync_status", FT_UINT8, BASE_DEC, VALS(Link16_Sync_Status), 0x0,
            NULL, HFILL }},
        { &hf_simple_status_link16_terminal_host_status,
          { "Link 16 Terminal/Host Status", "simple.status.link16.terminal_host_status", FT_UINT8, BASE_DEC, VALS(Link_Terminal_Host_Status), 0x0,
            NULL, HFILL }},
        { &hf_simple_status_link16_stn,
          { "Link 16 STN", "simple.status.link16.stn", FT_UINT16, BASE_OCT, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_status_spare_2,
          { "Spare2", "simple.status.spare_2", FT_BYTES, BASE_NONE, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_status_link11_dts_type,
          { "Link 11 DTS Type", "simple.status.link11.dts_type", FT_UINT8, BASE_DEC, VALS(Link11_DTS_Type), 0x0,
            NULL, HFILL }},
        { &hf_simple_status_link11_role,
          { "Link 11 Role", "simple.status.link11.role", FT_UINT8, BASE_DEC, VALS(Link11_Role), 0x0,
            NULL, HFILL }},
        { &hf_simple_status_link11_pu,
          { "Link 11 PU", "simple.status.link11.pu", FT_UINT8, BASE_OCT, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_status_link11_dts_host_status,
          { "Link 11 DTS/Host Status", "simple.status.link11.dts_host_status", FT_UINT8, BASE_DEC, VALS(Link_Terminal_Host_Status), 0x0,
            NULL, HFILL }},
        { &hf_simple_status_spare_3,
          { "Spare3", "simple.status.spare_3", FT_BYTES, BASE_NONE, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_checksum,
          { "Checksum", "simple.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }},
        { &hf_simple_checksum_status,
          { "Checksum Status", "simple.checksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
            NULL, HFILL }}
    };
    static int *ett[] = {
        &ett_simple,
        &ett_packet,
        &ett_simple_status_dx_flag,
    };
    static ei_register_info ei[] = {
        { &ei_simple_sync_bytes_bad, { "simple.sync_bytes.bad", PI_MALFORMED, PI_ERROR, "Bad sync bytes", EXPFILL }},
        { &ei_simple_length_bad, { "simple.length.bad", PI_MALFORMED, PI_ERROR, "Bad length", EXPFILL }},
        { &ei_simple_packet_size_bad, { "simple.packet_size.bad", PI_MALFORMED, PI_ERROR, "Bad packet length", EXPFILL }},
        { &ei_simple_checksum_bad, { "simple.checksum.bad.expert", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }},
    };
    expert_module_t* expert_simple;

    proto_simple = proto_register_protocol("Standard Interface for Multiple Platform Link Evaluation", "SIMPLE", "simple");
    proto_register_field_array(proto_simple, hf, array_length(hf));
    proto_register_subtree_array(ett, array_length(ett));
    expert_simple = expert_register_protocol(proto_simple);
    expert_register_field_array(expert_simple, ei, array_length(ei));
    simple_dissector_handle = register_dissector("simple", dissect_simple, proto_simple);
}

void proto_reg_handoff_simple(void)
{
    dissector_add_for_decode_as_with_preference("udp.port", simple_dissector_handle);
    dissector_add_for_decode_as_with_preference("tcp.port", simple_dissector_handle);

    link16_handle = find_dissector_add_dependency("link16", proto_simple);
}

/*
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
 *
 * Local variables:
 * c-basic-offset: 4
 * tab-width: 8
 * indent-tabs-mode: nil
 * End:
 *
 * vi: set shiftwidth=4 tabstop=8 expandtab:
 * :indentSize=4:tabSize=8:noTabs=true:
 */