-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathpackets.h
More file actions
408 lines (343 loc) · 8.22 KB
/
packets.h
File metadata and controls
408 lines (343 loc) · 8.22 KB
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
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* packets.h
* Datagram definitions for libartnet
* Copyright (C) 2004-2005 Simon Newton
*/
#ifndef ARTNET_PACKETS_H
#define ARTNET_PACKETS_H
#include <sys/types.h>
#include <stdint.h>
#ifndef WIN32
#include <netinet/in.h>
#endif
#include <artnet/common.h>
#ifdef _MSC_VER
#define PACKED
#pragma pack(push,1)
#else
#define PACKED __attribute__((packed))
#endif
enum { ARTNET_MAX_RDM_ADCOUNT = 32 };
enum { ARTNET_MAX_UID_COUNT = 200 };
// according to the rdm spec, this should be 278 bytes
// we'll set to 512 here, the firmware datagram is still bigger
enum { ARTNET_MAX_RDM_DATA = 512 };
enum { ARTNET_FIRMWARE_SIZE = 512 };
enum artnet_packet_type_e {
ARTNET_POLL = 0x2000,
ARTNET_REPLY = 0x2100,
ARTNET_DMX = 0x5000,
ARTNET_ADDRESS = 0x6000,
ARTNET_INPUT = 0x7000,
ARTNET_TODREQUEST = 0x8000,
ARTNET_TODDATA = 0x8100,
ARTNET_TODCONTROL = 0x8200,
ARTNET_RDM = 0x8300,
ARTNET_VIDEOSTEUP = 0xa010,
ARTNET_VIDEOPALETTE = 0xa020,
ARTNET_VIDEODATA = 0xa040,
ARTNET_MACMASTER = 0xf000,
ARTNET_MACSLAVE = 0xf100,
ARTNET_FIRMWAREMASTER = 0xf200,
ARTNET_FIRMWAREREPLY = 0xf300,
ARTNET_IPPROG = 0xf800,
ARTNET_IPREPLY = 0xf900,
ARTNET_MEDIA = 0x9000,
ARTNET_MEDIAPATCH = 0x9200,
ARTNET_MEDIACONTROLREPLY = 0x9300
} PACKED;
typedef enum artnet_packet_type_e artnet_packet_type_t;
struct artnet_poll_s {
uint8_t id[8];
uint16_t opCode;
uint8_t verH;
uint8_t ver;
uint8_t ttm;
uint8_t pad;
} PACKED;
typedef struct artnet_poll_s artnet_poll_t;
struct artnet_reply_s {
uint8_t id[8];
uint16_t opCode;
uint8_t ip[4];
uint16_t port;
uint8_t verH;
uint8_t ver;
uint8_t net;
uint8_t sub;
uint8_t oemH;
uint8_t oem;
uint8_t ubea;
uint8_t status;
uint8_t etsaman[2];
uint8_t shortname[ARTNET_SHORT_NAME_LENGTH];
uint8_t longname[ARTNET_LONG_NAME_LENGTH];
uint8_t nodereport[ARTNET_REPORT_LENGTH];
uint8_t numbportsH;
uint8_t numbports;
uint8_t porttypes[ARTNET_MAX_PORTS];
uint8_t goodinput[ARTNET_MAX_PORTS];
uint8_t goodoutput[ARTNET_MAX_PORTS];
uint8_t swin[ARTNET_MAX_PORTS];
uint8_t swout[ARTNET_MAX_PORTS];
uint8_t swvideo;
uint8_t swmacro;
uint8_t swremote;
uint8_t sp1;
uint8_t sp2;
uint8_t sp3;
uint8_t style;
uint8_t mac[ARTNET_MAC_SIZE];
uint8_t filler[32];
} PACKED;
typedef struct artnet_reply_s artnet_reply_t;
struct artnet_ipprog_s {
uint8_t id[8];
uint16_t OpCode;
uint8_t ProVerH;
uint8_t ProVer;
uint8_t Filler1;
uint8_t Filler2;
uint8_t Command;
uint8_t Filler4;
uint8_t ProgIpHi;
uint8_t ProgIp2;
uint8_t ProgIp1;
uint8_t ProgIpLo;
uint8_t ProgSmHi;
uint8_t ProgSm2;
uint8_t ProgSm1;
uint8_t ProgSmLo;
uint8_t ProgPortHi;
uint8_t ProgPortLo;
uint8_t Spare1;
uint8_t Spare2;
uint8_t Spare3;
uint8_t Spare4;
uint8_t Spare5;
uint8_t Spare6;
uint8_t Spare7;
uint8_t Spare8;
} PACKED;
typedef struct artnet_ipprog_s artnet_ipprog_t;
struct artnet_ipprog_reply_s {
uint8_t id[8];
uint16_t OpCode;
uint8_t ProVerH;
uint8_t ProVer;
uint8_t Filler1;
uint8_t Filler2;
uint8_t Filler3;
uint8_t Filler4;
uint8_t ProgIpHi;
uint8_t ProgIp2;
uint8_t ProgIp1;
uint8_t ProgIpLo;
uint8_t ProgSmHi;
uint8_t ProgSm2;
uint8_t ProgSm1;
uint8_t ProgSmLo;
uint8_t ProgPortHi;
uint8_t ProgPortLo;
uint8_t Spare1;
uint8_t Spare2;
uint8_t Spare3;
uint8_t Spare4;
uint8_t Spare5;
uint8_t Spare6;
uint8_t Spare7;
uint8_t Spare8;
} PACKED;
typedef struct artnet_ipprog_reply_s artnet_ipprog_reply_t;
struct artnet_address_s {
uint8_t id[8];
uint16_t opCode;
uint8_t verH;
uint8_t ver;
uint8_t net;
uint8_t filler2;
uint8_t shortname[ARTNET_SHORT_NAME_LENGTH];
uint8_t longname[ARTNET_LONG_NAME_LENGTH];
uint8_t swin[ARTNET_MAX_PORTS];
uint8_t swout[ARTNET_MAX_PORTS];
uint8_t subnet;
uint8_t swvideo;
uint8_t command;
} PACKED;
typedef struct artnet_address_s artnet_address_t;
struct artnet_dmx_s {
uint8_t id[8];
uint16_t opCode;
uint8_t verH;
uint8_t ver;
uint8_t sequence;
uint8_t physical;
uint16_t universe;
uint8_t lengthHi;
uint8_t length;
uint8_t data[ARTNET_DMX_LENGTH];
} PACKED;
typedef struct artnet_dmx_s artnet_dmx_t;
struct artnet_input_s {
uint8_t id[8];
uint16_t opCode;
uint8_t verH;
uint8_t ver;
uint8_t filler1;
uint8_t filler2;
uint8_t numbportsH;
uint8_t numbports;
uint8_t input[ARTNET_MAX_PORTS];
} PACKED;
typedef struct artnet_input_s artnet_input_t;
struct artnet_todrequest_s {
uint8_t id[8];
uint16_t opCode;
uint8_t verH;
uint8_t ver;
uint8_t filler1;
uint8_t filler2;
uint8_t spare1;
uint8_t spare2;
uint8_t spare3;
uint8_t spare4;
uint8_t spare5;
uint8_t spare6;
uint8_t spare7;
uint8_t net;
uint8_t command;
uint8_t adCount;
uint8_t address[ARTNET_MAX_RDM_ADCOUNT];
} PACKED;
typedef struct artnet_todrequest_s artnet_todrequest_t;
struct artnet_toddata_s {
uint8_t id[8];
uint16_t opCode;
uint8_t verH;
uint8_t ver;
uint8_t rdmVer;
uint8_t port;
uint8_t spare1;
uint8_t spare2;
uint8_t spare3;
uint8_t spare4;
uint8_t spare5;
uint8_t spare6;
uint8_t spare7;
uint8_t net;
uint8_t cmdRes;
uint8_t address;
uint8_t uidTotalHi;
uint8_t uidTotal;
uint8_t blockCount;
uint8_t uidCount;
uint8_t tod[ARTNET_MAX_UID_COUNT][ARTNET_RDM_UID_WIDTH];
} PACKED;
typedef struct artnet_toddata_s artnet_toddata_t;
struct artnet_firmware_s {
uint8_t id[8];
uint16_t opCode;
uint8_t verH;
uint8_t ver;
uint8_t filler1;
uint8_t filler2;
uint8_t type;
uint8_t blockId;
uint8_t length[4];
uint8_t spare[20];
uint16_t data[ARTNET_FIRMWARE_SIZE ];
} PACKED;
typedef struct artnet_firmware_s artnet_firmware_t;
struct artnet_todcontrol_s {
uint8_t id[8];
uint16_t opCode;
uint8_t verH;
uint8_t ver;
uint8_t filler1;
uint8_t filler2;
uint8_t spare1;
uint8_t spare2;
uint8_t spare3;
uint8_t spare4;
uint8_t spare5;
uint8_t spare6;
uint8_t spare7;
uint8_t spare8;
uint8_t cmd;
uint8_t address;
} PACKED;
typedef struct artnet_todcontrol_s artnet_todcontrol_t;
struct artnet_rdm_s {
uint8_t id[8];
uint16_t opCode;
uint8_t verH;
uint8_t ver;
uint8_t rdmVer;
uint8_t filler2;
uint8_t spare1;
uint8_t spare2;
uint8_t spare3;
uint8_t spare4;
uint8_t spare5;
uint8_t spare6;
uint8_t spare7;
uint8_t spare8;
uint8_t cmd;
uint8_t address;
uint8_t data[ARTNET_MAX_RDM_DATA];
} PACKED;
typedef struct artnet_rdm_s artnet_rdm_t;
struct artnet_firmware_reply_s {
uint8_t id[8];
uint16_t opCode;
uint8_t verH;
uint8_t ver;
uint8_t filler1;
uint8_t filler2;
uint8_t type;
uint8_t spare[21];
} PACKED;
typedef struct artnet_firmware_reply_s artnet_firmware_reply_t;
// union of all artnet packets
typedef union {
artnet_poll_t ap;
artnet_reply_t ar;
artnet_ipprog_t aip;
artnet_address_t addr;
artnet_dmx_t admx;
artnet_input_t ainput;
artnet_todrequest_t todreq;
artnet_toddata_t toddata;
artnet_firmware_t firmware;
artnet_firmware_reply_t firmwarer;
artnet_todcontrol_t todcontrol;
artnet_rdm_t rdm;
} artnet_packet_union_t;
// a packet, containing data, length, type and a src/dst address
typedef struct {
int length;
struct in_addr from;
struct in_addr to;
artnet_packet_type_t type;
artnet_packet_union_t data;
} artnet_packet_t;
typedef artnet_packet_t *artnet_packet;
#ifdef _MSC_VER
#pragma pack(pop)
#endif
#undef PACKED
#endif