Open Lighting Architecture  0.9.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PathportPackets.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program 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
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * PathportPackets.h
17  * Datagram definitions for libpathport
18  * Copyright (C) 2006 Simon Newton
19  */
20 
21 #ifndef PLUGINS_PATHPORT_PATHPORTPACKETS_H_
22 #define PLUGINS_PATHPORT_PATHPORTPACKETS_H_
23 
24 #include <sys/types.h>
25 #include <stdint.h>
27 
28 namespace ola {
29 namespace plugin {
30 namespace pathport {
31 
32 
33 /*
34  * Pathport opcodes
35  */
36 // We can't use the PACK macro for enums
37 #ifdef _WIN32
38 #pragma pack(push, 1)
39 #endif
40 enum pathport_packet_type_e {
41  PATHPORT_DATA = 0x0100,
42  PATHPORT_PATCH = 0x0200,
43  PATHPORT_PATCHREP = 0x0210,
44  PATHPORT_GET = 0x0222,
45  PATHPORT_GET_REPLY = 0x0223,
46  PATHPORT_ARP_REQUEST = 0x0301,
47  PATHPORT_ARP_REPLY = 0x0302,
48  PATHPORT_SET = 0x0400,
49 #ifdef _WIN32
50 };
51 #pragma pack(pop)
52 #else
53 } __attribute__((packed));
54 #endif
55 
56 typedef enum pathport_packet_type_e pathport_packet_type_t;
57 
58 
59 /*
60  * Pathport xDmx
61  */
62 PACK(
63 struct pathport_pdu_data_s {
64  uint16_t type;
65  uint16_t channel_count;
66  uint8_t universe; // not used, set to 0
67  uint8_t start_code;
68  uint16_t offset;
69  uint8_t data[0];
70 });
71 
72 typedef struct pathport_pdu_data_s pathport_pdu_data;
73 
74 
75 /*
76  * Pathport get request
77  */
78 PACK(
79 struct pathport_pdu_get_s {
80  uint16_t params[0];
81 });
82 
83 typedef struct pathport_pdu_get_s pathport_pdu_get;
84 
85 
86 /*
87  * Pathport get reply
88  */
89 PACK(
90 struct pathport_pdu_getrep_s {
91  uint8_t params[0];
92 });
93 
94 typedef struct pathport_pdu_getrep_s pathport_pdu_getrep;
95 
96 
98  uint16_t type;
99  uint16_t len;
100  uint8_t val[0];
101 };
103 
104 
105 /*
106  * Pathport arp reply
107  */
108 PACK(
109 struct pathport_pdu_arp_reply_s {
110  uint32_t id;
111  uint8_t ip[ola::network::IPV4Address::LENGTH];
112  uint8_t manufacturer_code; // manufacturer code
113  uint8_t device_class; // device class
114  uint8_t device_type; // device type
115  uint8_t component_count; // number of dmx components
116 });
117 
118 typedef struct pathport_pdu_arp_reply_s pathport_pdu_arp_reply;
119 
120 PACK(
121 struct pathport_pdu_header_s {
122  uint16_t type; // pdu type
123  uint16_t len; // length
124 });
125 
126 typedef struct pathport_pdu_header_s pathport_pdu_header;
127 
128 /*
129  * PDU Header
130  */
131 PACK(
132 struct pathport_packet_pdu_s {
133  pathport_pdu_header head;
134  union {
135  pathport_pdu_data data;
136  pathport_pdu_get get;
137  pathport_pdu_getrep getrep;
138  pathport_pdu_arp_reply arp_reply;
139  } d; // pdu data
140 });
141 
142 typedef struct pathport_packet_pdu_s pathport_packet_pdu;
143 
144 
145 /*
146  * A complete Pathport packet
147  */
148 PACK(
149 struct pathport_packet_header_s {
150  uint16_t protocol;
151  uint8_t version_major;
152  uint8_t version_minor;
153  uint16_t sequence;
154  uint8_t reserved[6]; // set to 0
155  uint32_t source; // src id
156  uint32_t destination; // dst id
157 });
158 
159 typedef struct pathport_packet_header_s pathport_packet_header;
160 
161 
162 /*
163  * The complete pathport packet
164  */
165 PACK(
166 struct pathport_packet_s {
167  pathport_packet_header header;
168  union {
169  uint8_t data[1480]; // 1500 - header size
170  pathport_packet_pdu pdu;
171  } d;
172 });
173 } // namespace pathport
174 } // namespace plugin
175 } // namespace ola
176 #endif // PLUGINS_PATHPORT_PATHPORTPACKETS_H_