2 * DMX Test packet disassembly.
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
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;
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
);
64 guint size
, i
, test_data_is_ok
;
65 proto_tree
*test_data_tree
;
68 proto_tree
*ti
= proto_tree_add_item(tree
, proto_dmx_test
, tvb
,
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
);
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
;
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
,
97 PROTO_ITEM_SET_GENERATED(item
);
98 item
= proto_tree_add_boolean(test_data_tree
, hf_dmx_test_data_bad
, tvb
,
100 PROTO_ITEM_SET_GENERATED(item
);
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
,
111 PROTO_ITEM_SET_GENERATED(item
);
117 proto_register_dmx_test(void)
119 static hf_register_info hf
[] = {
121 { "Test Data", "dmx_test.data",
122 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
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
[] = {
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
);