Debian Codegraph @

interfaces/artnet/packets.h

raw symbols SCIP
1 /*
2 * This library is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation; either
5 * version 2.1 of the License, or (at your option) any later version.
6 *
7 * This library is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
11 *
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with this library; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15 *
16 * packets.h
17 * Datagram definitions for libartnet
18 * Copyright (C) 2004-2005 Simon Newton
19 */
20
21
22 #ifndef ARTNET_PACKETS_H
23 #define ARTNET_PACKETS_H
24
25 #include <sys/types.h>
26 #include <stdint.h>
27
28 #ifndef WIN32
29 #include <netinet/in.h>
30 #endif
31
32 #include <artnet/common.h>
33
34 enum { ARTNET_MAX_RDM_ADCOUNT = 32 };
35
36 enum { ARTNET_MAX_UID_COUNT = 200 };
37
38 // according to the rdm spec, this should be 278 bytes
39 // we'll set to 512 here, the firmware datagram is still bigger
40 enum { ARTNET_MAX_RDM_DATA = 512 };
41
42 enum { ARTNET_FIRMWARE_SIZE = 512 };
43
44 enum artnet_packet_type_e {
45 ARTNET_POLL = 0x2000,
46 ARTNET_REPLY = 0x2100,
47 ARTNET_DMX = 0x5000,
48 ARTNET_ADDRESS = 0x6000,
49 ARTNET_INPUT = 0x7000,
50 ARTNET_TODREQUEST = 0x8000,
51 ARTNET_TODDATA = 0x8100,
52 ARTNET_TODCONTROL = 0x8200,
53 ARTNET_RDM = 0x8300,
54 ARTNET_VIDEOSTEUP = 0xa010,
55 ARTNET_VIDEOPALETTE = 0xa020,
56 ARTNET_VIDEODATA = 0xa040,
57 ARTNET_MACMASTER = 0xf000,
58 ARTNET_MACSLAVE = 0xf100,
59 ARTNET_FIRMWAREMASTER = 0xf200,
60 ARTNET_FIRMWAREREPLY = 0xf300,
61 ARTNET_IPPROG = 0xf800,
62 ARTNET_IPREPLY = 0xf900,
63 ARTNET_MEDIA = 0x9000,
64 ARTNET_MEDIAPATCH = 0x9200,
65 ARTNET_MEDIACONTROLREPLY = 0x9300
66 }__attribute__((packed));
67
68 typedef enum artnet_packet_type_e artnet_packet_type_t;
69
70
71 struct artnet_poll_s {
72 uint8_t id[8];
73 uint16_t opCode;
74 uint8_t verH;
75 uint8_t ver;
76 uint8_t ttm;
77 uint8_t pad;
78 } __attribute__((packed));
79
80 typedef struct artnet_poll_s artnet_poll_t;
81
82 struct artnet_reply_s {
83 uint8_t id[8];
84 uint16_t opCode;
85 uint8_t ip[4];
86 uint16_t port;
87 uint8_t verH;
88 uint8_t ver;
89 uint8_t subH;
90 uint8_t sub;
91 uint8_t oemH;
92 uint8_t oem;
93 uint8_t ubea;
94 uint8_t status;
95 uint8_t etsaman[2];
96 uint8_t shortname[ARTNET_SHORT_NAME_LENGTH];
97 uint8_t longname[ARTNET_LONG_NAME_LENGTH];
98 uint8_t nodereport[ARTNET_REPORT_LENGTH];
99 uint8_t numbportsH;
100 uint8_t numbports;
101 uint8_t porttypes[ARTNET_MAX_PORTS];
102 uint8_t goodinput[ARTNET_MAX_PORTS];
103 uint8_t goodoutput[ARTNET_MAX_PORTS];
104 uint8_t swin[ARTNET_MAX_PORTS];
105 uint8_t swout[ARTNET_MAX_PORTS];
106 uint8_t swvideo;
107 uint8_t swmacro;
108 uint8_t swremote;
109 uint8_t sp1;
110 uint8_t sp2;
111 uint8_t sp3;
112 uint8_t style;
113 uint8_t mac[ARTNET_MAC_SIZE];
114 uint8_t filler[32];
115 } __attribute__((packed));
116
117 typedef struct artnet_reply_s artnet_reply_t;
118
119 struct artnet_ipprog_s {
120 uint8_t id[8];
121 uint16_t OpCode;
122 uint8_t ProVerH;
123 uint8_t ProVer;
124 uint8_t Filler1;
125 uint8_t Filler2;
126 uint8_t Command;
127 uint8_t Filler4;
128 uint8_t ProgIpHi;
129 uint8_t ProgIp2;
130 uint8_t ProgIp1;
131 uint8_t ProgIpLo;
132 uint8_t ProgSmHi;
133 uint8_t ProgSm2;
134 uint8_t ProgSm1;
135 uint8_t ProgSmLo;
136 uint8_t ProgPortHi;
137 uint8_t ProgPortLo;
138 uint8_t Spare1;
139 uint8_t Spare2;
140 uint8_t Spare3;
141 uint8_t Spare4;
142 uint8_t Spare5;
143 uint8_t Spare6;
144 uint8_t Spare7;
145 uint8_t Spare8;
146
147 } __attribute__((packed));
148
149 typedef struct artnet_ipprog_s artnet_ipprog_t;
150
151 struct artnet_ipprog_reply_s {
152 uint8_t id[8];
153 uint16_t OpCode;
154 uint8_t ProVerH;
155 uint8_t ProVer;
156 uint8_t Filler1;
157 uint8_t Filler2;
158 uint8_t Filler3;
159 uint8_t Filler4;
160 uint8_t ProgIpHi;
161 uint8_t ProgIp2;
162 uint8_t ProgIp1;
163 uint8_t ProgIpLo;
164 uint8_t ProgSmHi;
165 uint8_t ProgSm2;
166 uint8_t ProgSm1;
167 uint8_t ProgSmLo;
168 uint8_t ProgPortHi;
169 uint8_t ProgPortLo;
170 uint8_t Spare1;
171 uint8_t Spare2;
172 uint8_t Spare3;
173 uint8_t Spare4;
174 uint8_t Spare5;
175 uint8_t Spare6;
176 uint8_t Spare7;
177 uint8_t Spare8;
178 } __attribute__((packed));
179
180 typedef struct artnet_ipprog_reply_s artnet_ipprog_reply_t;
181
182
183 struct artnet_address_s {
184 uint8_t id[8];
185 uint16_t opCode;
186 uint8_t verH;
187 uint8_t ver;
188 uint8_t filler1;
189 uint8_t filler2;
190 uint8_t shortname[ARTNET_SHORT_NAME_LENGTH];
191 uint8_t longname[ARTNET_LONG_NAME_LENGTH];
192 uint8_t swin[ARTNET_MAX_PORTS];
193 uint8_t swout[ARTNET_MAX_PORTS];
194 uint8_t subnet;
195 uint8_t swvideo;
196 uint8_t command;
197 } __attribute__((packed));
198
199 typedef struct artnet_address_s artnet_address_t;
200
201
202 struct artnet_dmx_s {
203 uint8_t id[8];
204 uint16_t opCode;
205 uint8_t verH;
206 uint8_t ver;
207 uint8_t sequence;
208 uint8_t physical;
209 uint16_t universe;
210 uint8_t lengthHi;
211 uint8_t length;
212 uint8_t data[ARTNET_DMX_LENGTH];
213 } __attribute__((packed));
214
215 typedef struct artnet_dmx_s artnet_dmx_t;
216
217
218 struct artnet_input_s {
219 uint8_t id[8];
220 uint16_t opCode;
221 uint8_t verH;
222 uint8_t ver;
223 uint8_t filler1;
224 uint8_t filler2;
225 uint8_t numbportsH;
226 uint8_t numbports;
227 uint8_t input[ARTNET_MAX_PORTS];
228 } __attribute__((packed));
229
230 typedef struct artnet_input_s artnet_input_t;
231
232
233 struct artnet_todrequest_s {
234 uint8_t id[8];
235 uint16_t opCode;
236 uint8_t verH;
237 uint8_t ver;
238 uint8_t filler1;
239 uint8_t filler2;
240 uint8_t spare1;
241 uint8_t spare2;
242 uint8_t spare3;
243 uint8_t spare4;
244 uint8_t spare5;
245 uint8_t spare6;
246 uint8_t spare7;
247 uint8_t spare8;
248 uint8_t command;
249 uint8_t adCount;
250 uint8_t address[ARTNET_MAX_RDM_ADCOUNT];
251 } __attribute__((packed));
252
253 typedef struct artnet_todrequest_s artnet_todrequest_t;
254
255
256
257 struct artnet_toddata_s {
258 uint8_t id[8];
259 uint16_t opCode;
260 uint8_t verH;
261 uint8_t ver;
262 uint8_t rdmVer;
263 uint8_t port;
264 uint8_t spare1;
265 uint8_t spare2;
266 uint8_t spare3;
267 uint8_t spare4;
268 uint8_t spare5;
269 uint8_t spare6;
270 uint8_t spare7;
271 uint8_t spare8;
272 uint8_t cmdRes;
273 uint8_t address;
274 uint8_t uidTotalHi;
275 uint8_t uidTotal;
276 uint8_t blockCount;
277 uint8_t uidCount;
278 uint8_t tod[ARTNET_MAX_UID_COUNT][ARTNET_RDM_UID_WIDTH];
279 } __attribute__((packed));
280
281 typedef struct artnet_toddata_s artnet_toddata_t;
282
283 struct artnet_firmware_s {
284 uint8_t id[8];
285 uint16_t opCode;
286 uint8_t verH;
287 uint8_t ver;
288 uint8_t filler1;
289 uint8_t filler2;
290 uint8_t type;
291 uint8_t blockId;
292 uint8_t length[4];
293 uint8_t spare[20];
294 uint16_t data[ARTNET_FIRMWARE_SIZE ];
295 } __attribute__((packed));
296
297 typedef struct artnet_firmware_s artnet_firmware_t;
298
299 struct artnet_todcontrol_s {
300 uint8_t id[8];
301 uint16_t opCode;
302 uint8_t verH;
303 uint8_t ver;
304 uint8_t filler1;
305 uint8_t filler2;
306 uint8_t spare1;
307 uint8_t spare2;
308 uint8_t spare3;
309 uint8_t spare4;
310 uint8_t spare5;
311 uint8_t spare6;
312 uint8_t spare7;
313 uint8_t spare8;
314 uint8_t cmd;
315 uint8_t address;
316 } __attribute__((packed));
317
318
319 typedef struct artnet_todcontrol_s artnet_todcontrol_t;
320
321
322
323 struct artnet_rdm_s {
324 uint8_t id[8];
325 uint16_t opCode;
326 uint8_t verH;
327 uint8_t ver;
328 uint8_t rdmVer;
329 uint8_t filler2;
330 uint8_t spare1;
331 uint8_t spare2;
332 uint8_t spare3;
333 uint8_t spare4;
334 uint8_t spare5;
335 uint8_t spare6;
336 uint8_t spare7;
337 uint8_t spare8;
338 uint8_t cmd;
339 uint8_t address;
340 uint8_t data[ARTNET_MAX_RDM_DATA];
341 } __attribute__((packed));
342
343
344 typedef struct artnet_rdm_s artnet_rdm_t;
345
346
347 struct artnet_firmware_reply_s {
348 uint8_t id[8];
349 uint16_t opCode;
350 uint8_t verH;
351 uint8_t ver;
352 uint8_t filler1;
353 uint8_t filler2;
354 uint8_t type;
355 uint8_t spare[21];
356 } __attribute__((packed));
357
358 typedef struct artnet_firmware_reply_s artnet_firmware_reply_t;
359
360
361
362 // union of all artnet packets
363 typedef union {
364 artnet_poll_t ap;
365 artnet_reply_t ar;
366 artnet_ipprog_t aip;
367 artnet_address_t addr;
368 artnet_dmx_t admx;
369 artnet_input_t ainput;
370 artnet_todrequest_t todreq;
371 artnet_toddata_t toddata;
372 artnet_firmware_t firmware;
373 artnet_firmware_reply_t firmwarer;
374 artnet_todcontrol_t todcontrol;
375 artnet_rdm_t rdm;
376 } artnet_packet_union_t;
377
378
379 // a packet, containing data, length, type and a src/dst address
380 typedef struct {
381 int length;
382 struct in_addr from;
383 struct in_addr to;
384 artnet_packet_type_t type;
385 artnet_packet_union_t data;
386 } artnet_packet_t;
387
388 typedef artnet_packet_t *artnet_packet;
389
390 #endif