2 * DMX SIP 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_SC_SIP 0xCF
45 void proto_register_dmx_sip(void);
47 static int proto_dmx_sip
= -1;
49 static int hf_dmx_sip_byte_count
= -1;
50 static int hf_dmx_sip_control_bit_field
= -1;
51 static int hf_dmx_sip_prev_packet_checksum
= -1;
52 static int hf_dmx_sip_seq_nr
= -1;
53 static int hf_dmx_sip_dmx_universe_nr
= -1;
54 static int hf_dmx_sip_dmx_proc_level
= -1;
55 static int hf_dmx_sip_dmx_software_version
= -1;
56 static int hf_dmx_sip_dmx_packet_len
= -1;
57 static int hf_dmx_sip_dmx_nr_packets
= -1;
58 static int hf_dmx_sip_orig_dev_id
= -1;
59 static int hf_dmx_sip_sec_dev_id
= -1;
60 static int hf_dmx_sip_third_dev_id
= -1;
61 static int hf_dmx_sip_fourth_dev_id
= -1;
62 static int hf_dmx_sip_fifth_dev_id
= -1;
63 static int hf_dmx_sip_reserved
= -1;
64 static int hf_dmx_sip_checksum
= -1;
65 static int hf_dmx_sip_checksum_good
= -1;
66 static int hf_dmx_sip_checksum_bad
= -1;
67 static int hf_dmx_sip_trailer
= -1;
69 static int ett_dmx_sip
= -1;
72 dmx_sip_checksum(tvbuff_t
*tvb
, guint length
)
74 guint8 sum
= DMX_SC_SIP
;
76 for (i
= 0; i
< length
; i
++)
77 sum
+= tvb_get_guint8(tvb
, i
);
82 dissect_dmx_sip(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
84 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "DMX SIP");
85 col_clear(pinfo
->cinfo
, COL_INFO
);
90 guint checksum
, checksum_shouldbe
;
92 proto_tree
*checksum_tree
;
94 proto_tree
*ti
= proto_tree_add_item(tree
, proto_dmx_sip
, tvb
,
96 proto_tree
*dmx_sip_tree
= proto_item_add_subtree(ti
, ett_dmx_sip
);
99 byte_count
= tvb_get_guint8(tvb
, offset
);
100 proto_tree_add_item(dmx_sip_tree
, hf_dmx_sip_byte_count
, tvb
,
101 offset
, 1, ENC_BIG_ENDIAN
);
104 proto_tree_add_item(dmx_sip_tree
, hf_dmx_sip_control_bit_field
, tvb
,
105 offset
, 1, ENC_BIG_ENDIAN
);
108 proto_tree_add_item(dmx_sip_tree
, hf_dmx_sip_prev_packet_checksum
, tvb
,
109 offset
, 2, ENC_BIG_ENDIAN
);
112 proto_tree_add_item(dmx_sip_tree
, hf_dmx_sip_seq_nr
, tvb
,
113 offset
, 1, ENC_BIG_ENDIAN
);
116 proto_tree_add_item(dmx_sip_tree
, hf_dmx_sip_dmx_universe_nr
, tvb
,
117 offset
, 1, ENC_BIG_ENDIAN
);
120 proto_tree_add_item(dmx_sip_tree
, hf_dmx_sip_dmx_proc_level
, tvb
,
121 offset
, 1, ENC_BIG_ENDIAN
);
124 proto_tree_add_item(dmx_sip_tree
, hf_dmx_sip_dmx_software_version
, tvb
,
125 offset
, 1, ENC_BIG_ENDIAN
);
128 proto_tree_add_item(dmx_sip_tree
, hf_dmx_sip_dmx_packet_len
, tvb
,
129 offset
, 2, ENC_BIG_ENDIAN
);
132 proto_tree_add_item(dmx_sip_tree
, hf_dmx_sip_dmx_nr_packets
, tvb
,
133 offset
, 2, ENC_BIG_ENDIAN
);
136 proto_tree_add_item(dmx_sip_tree
, hf_dmx_sip_orig_dev_id
, tvb
,
137 offset
, 2, ENC_BIG_ENDIAN
);
140 proto_tree_add_item(dmx_sip_tree
, hf_dmx_sip_sec_dev_id
, tvb
,
141 offset
, 2, ENC_BIG_ENDIAN
);
144 proto_tree_add_item(dmx_sip_tree
, hf_dmx_sip_third_dev_id
, tvb
,
145 offset
, 2, ENC_BIG_ENDIAN
);
148 proto_tree_add_item(dmx_sip_tree
, hf_dmx_sip_fourth_dev_id
, tvb
,
149 offset
, 2, ENC_BIG_ENDIAN
);
152 proto_tree_add_item(dmx_sip_tree
, hf_dmx_sip_fifth_dev_id
, tvb
,
153 offset
, 2, ENC_BIG_ENDIAN
);
156 if (offset
< byte_count
) {
157 proto_tree_add_item(dmx_sip_tree
, hf_dmx_sip_reserved
, tvb
,
158 offset
, byte_count
- offset
, ENC_BIG_ENDIAN
);
159 offset
+= (byte_count
- offset
);
162 dmx_sip_checksum(tvb
, offset
);
164 checksum_shouldbe
= dmx_sip_checksum(tvb
, offset
);
165 checksum
= tvb_get_guint8(tvb
, offset
);
166 item
= proto_tree_add_item(dmx_sip_tree
, hf_dmx_sip_checksum
, tvb
,
167 offset
, 1, ENC_BIG_ENDIAN
);
168 if (checksum
== checksum_shouldbe
) {
169 proto_item_append_text(item
, " [correct]");
171 checksum_tree
= proto_item_add_subtree(item
, ett_dmx_sip
);
172 item
= proto_tree_add_boolean(checksum_tree
, hf_dmx_sip_checksum_good
, tvb
,
174 PROTO_ITEM_SET_GENERATED(item
);
175 item
= proto_tree_add_boolean(checksum_tree
, hf_dmx_sip_checksum_bad
, tvb
,
177 PROTO_ITEM_SET_GENERATED(item
);
179 proto_item_append_text(item
, " [incorrect, should be 0x%02x]", checksum_shouldbe
);
181 checksum_tree
= proto_item_add_subtree(item
, ett_dmx_sip
);
182 item
= proto_tree_add_boolean(checksum_tree
, hf_dmx_sip_checksum_good
, tvb
,
184 PROTO_ITEM_SET_GENERATED(item
);
185 item
= proto_tree_add_boolean(checksum_tree
, hf_dmx_sip_checksum_bad
, tvb
,
187 PROTO_ITEM_SET_GENERATED(item
);
192 if (offset
< tvb_length(tvb
))
193 proto_tree_add_item(dmx_sip_tree
, hf_dmx_sip_trailer
, tvb
,
199 proto_register_dmx_sip(void)
201 static hf_register_info hf
[] = {
202 { &hf_dmx_sip_byte_count
,
203 { "Byte Count", "dmx_sip.byte_count",
204 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
207 { &hf_dmx_sip_control_bit_field
,
208 { "Control Bit Field", "dmx_sip.control_bit_field",
209 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
212 { &hf_dmx_sip_prev_packet_checksum
,
213 { "Checksum of prev. packet", "dmx_sip.prev_packet_checksum",
214 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
217 { &hf_dmx_sip_seq_nr
,
218 { "SIP sequence nr.", "dmx_sip.seq_nr",
219 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
222 { &hf_dmx_sip_dmx_universe_nr
,
223 { "DMX512 universe nr.", "dmx_sip.dmx_universe_nr",
224 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
227 { &hf_dmx_sip_dmx_proc_level
,
228 { "DMX512 processing level", "dmx_sip.dmx_proc_level",
229 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
232 { &hf_dmx_sip_dmx_software_version
,
233 { "Software Version", "dmx_sip.dmx_software_version",
234 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
237 { &hf_dmx_sip_dmx_packet_len
,
238 { "Standard Packet Len", "dmx_sip.dmx_packet_len",
239 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
242 { &hf_dmx_sip_dmx_nr_packets
,
243 { "Number of Packets", "dmx_sip.dmx_nr_packets",
244 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
247 { &hf_dmx_sip_orig_dev_id
,
248 { "1st Device's ID", "dmx_sip.orig_dev_id",
249 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
252 { &hf_dmx_sip_sec_dev_id
,
253 { "2nd Device's ID", "dmx_sip.sec_dev_id",
254 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
257 { &hf_dmx_sip_third_dev_id
,
258 { "3rd Device's ID", "dmx_sip.third_dev_id",
259 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
262 { &hf_dmx_sip_fourth_dev_id
,
263 { "4th Device's ID", "dmx_sip.fourth_dev_id",
264 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
267 { &hf_dmx_sip_fifth_dev_id
,
268 { "5th Device's ID", "dmx_sip.fifth_dev_id",
269 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
272 { &hf_dmx_sip_reserved
,
273 { "Reserved", "dmx_sip.reserved",
274 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
277 { &hf_dmx_sip_checksum
,
278 { "Checksum", "dmx_sip.checksum",
279 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
282 { &hf_dmx_sip_checksum_good
,
283 { "Good Checksum", "dmx_sip.checksum_good",
284 FT_BOOLEAN
, BASE_NONE
, NULL
, 0x0,
285 "True: checksum matches packet content; False: doesn't match content", HFILL
}},
287 { &hf_dmx_sip_checksum_bad
,
288 { "Bad Checksum", "dmx_sip.checksum_bad",
289 FT_BOOLEAN
, BASE_NONE
, NULL
, 0x0,
290 "True: checksum doesn't match packet content; False: matches content", HFILL
}},
292 { &hf_dmx_sip_trailer
,
293 { "Trailer", "dmx_sip.trailer",
294 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
298 static gint
*ett
[] = {
302 proto_dmx_sip
= proto_register_protocol("DMX SIP", "DMX SIP", "dmx-sip");
303 proto_register_field_array(proto_dmx_sip
, hf
, array_length(hf
));
304 proto_register_subtree_array(ett
, array_length(ett
));
305 register_dissector("dmx-sip", dissect_dmx_sip
, proto_dmx_sip
);