MSWSP: add ids for another unknown Property Set
[wireshark-wip.git] / epan / dissectors / packet-dmx-test.c
blobe6769b791f6c950f1b9d0ae811639f77c5c41985
1 /* packet-dmx-test.c
2 * DMX Test packet disassembly.
4 * $Id$
6 * This dissector is written by
8 * Erwin Rol <erwin@erwinrol.com>
9 * Copyright 2011 Erwin Rol
11 * Wireshark - Network traffic analyzer
12 * Gerald Combs <gerald@wireshark.org>
13 * Copyright 1999 Gerald Combs
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor
28 * Boston, MA 02110-1301, USA.
32 * This dissector is based on;
33 * American National Standard E1.11 - 2004
34 * Entertainment Technology USITT DMX512-A
35 * Asynchronous Serial Digital Data Transmission Standard
36 * for Controlling Lighting Equipment and Accessories
39 #include "config.h"
41 #include <epan/packet.h>
43 #define DMX_TEST_PACKET_SIZE 512
44 #define DMX_TEST_VALUE 0x55
46 void proto_register_dmx_test(void);
48 static int proto_dmx_test = -1;
50 static int hf_dmx_test_data = -1;
51 static int hf_dmx_test_data_good = -1;
52 static int hf_dmx_test_data_bad = -1;
54 static int ett_dmx_test = -1;
56 static void
57 dissect_dmx_test(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
59 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DMX Test Frame");
60 col_clear(pinfo->cinfo, COL_INFO);
62 if (tree != NULL) {
63 guint offset = 0;
64 guint size, i, test_data_is_ok;
65 proto_tree *test_data_tree;
66 proto_item *item;
68 proto_tree *ti = proto_tree_add_item(tree, proto_dmx_test, tvb,
69 offset, -1, FALSE);
70 proto_tree *dmx_test_tree = proto_item_add_subtree(ti, ett_dmx_test);
72 size = tvb_reported_length_remaining(tvb, offset);
74 item = proto_tree_add_item(dmx_test_tree, hf_dmx_test_data, tvb,
75 offset, size, ENC_BIG_ENDIAN);
76 offset += size;
78 if (size == DMX_TEST_PACKET_SIZE) {
79 test_data_is_ok = TRUE;
80 for (i = 0; i < DMX_TEST_PACKET_SIZE; i++) {
81 if (tvb_get_guint8(tvb, i) != DMX_TEST_VALUE) {
82 test_data_is_ok = FALSE;
83 break;
86 } else {
87 test_data_is_ok = FALSE;
90 if (test_data_is_ok) {
91 proto_item_append_text(ti, ", Data correct");
92 proto_item_append_text(item, " [correct]");
94 test_data_tree = proto_item_add_subtree(item, ett_dmx_test);
95 item = proto_tree_add_boolean(test_data_tree, hf_dmx_test_data_good, tvb,
96 offset, size, TRUE);
97 PROTO_ITEM_SET_GENERATED(item);
98 item = proto_tree_add_boolean(test_data_tree, hf_dmx_test_data_bad, tvb,
99 offset, size, FALSE);
100 PROTO_ITEM_SET_GENERATED(item);
101 } else {
102 proto_item_append_text(ti, ", Data incorrect");
103 proto_item_append_text(item, " [incorrect]");
105 test_data_tree = proto_item_add_subtree(item, ett_dmx_test);
106 item = proto_tree_add_boolean(test_data_tree, hf_dmx_test_data_good, tvb,
107 offset, size, FALSE);
108 PROTO_ITEM_SET_GENERATED(item);
109 item = proto_tree_add_boolean(test_data_tree, hf_dmx_test_data_bad, tvb,
110 offset, size, TRUE);
111 PROTO_ITEM_SET_GENERATED(item);
116 void
117 proto_register_dmx_test(void)
119 static hf_register_info hf[] = {
120 { &hf_dmx_test_data,
121 { "Test Data", "dmx_test.data",
122 FT_BYTES, BASE_NONE, NULL, 0x0,
123 NULL, HFILL }},
125 { &hf_dmx_test_data_good,
126 { "Data Good", "dmx_test.data_good",
127 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
128 "True: test data is correct; False: test data is incorrect", HFILL }},
130 { &hf_dmx_test_data_bad,
131 { "Data Bad", "dmx_test.data_bad",
132 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
133 "True: test data is incorrect; False: test data is correct", HFILL }},
136 static gint *ett[] = {
137 &ett_dmx_test
140 proto_dmx_test = proto_register_protocol("DMX Test Frame", "DMX Test Frame", "dmx-test");
141 proto_register_field_array(proto_dmx_test, hf, array_length(hf));
142 proto_register_subtree_array(ett, array_length(ett));
143 register_dissector("dmx-test", dissect_dmx_test, proto_dmx_test);