Open Lighting Architecture  0.10.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
EspNetPackets.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  * EspNetPackets.h
17  * Datagram definitions for EspNet
18  * Copyright (C) 2005 Simon Newton
19  */
20 
21 #ifndef PLUGINS_ESPNET_ESPNETPACKETS_H_
22 #define PLUGINS_ESPNET_ESPNETPACKETS_H_
23 
24 #include <sys/types.h>
25 #include <stdint.h>
26 #ifndef _WIN32
27 #include <netinet/in.h>
28 #endif // _WIN32
29 
30 #include "ola/network/MACAddress.h"
31 #include "ola/Constants.h"
32 
33 namespace ola {
34 namespace plugin {
35 namespace espnet {
36 
37 enum { ESPNET_NAME_LENGTH = 10 };
38 enum { ESPNET_DATA_LENGTH = 200 };
39 
40 // We can't use the PACK macro for enums
41 #ifdef _WIN32
42 #pragma pack(push, 1)
43 #endif // _WIN32
44 enum espnet_packet_type_e {
45  ESPNET_POLL = 'E' << 24 | 'S' << 16 | 'P' << 8 | 'P',
46  ESPNET_REPLY = 'E' << 24 | 'S' << 16 | 'P' << 8 | 'R',
47  ESPNET_DMX = 'E' << 24 | 'S' << 16 | 'D' << 8 | 'D',
48  ESPNET_ACK = 'E' << 24 | 'S' << 16 | 'A' << 8 | 'P'
49 #ifdef _WIN32
50 };
51 #pragma pack(pop)
52 #else
53 } __attribute__((packed));
54 #endif // _WIN32
55 
56 typedef enum espnet_packet_type_e espnet_packet_type_t;
57 
58 /*
59  * poll datagram
60  */
61 PACK(
62 struct espnet_poll_s {
63  uint32_t head;
64  uint8_t type;
65 });
66 
67 typedef struct espnet_poll_s espnet_poll_t;
68 
69 
70 /*
71  * This is used in the poll reply and config
72  */
74  uint8_t listen;
75  uint8_t ip[4];
76  uint8_t universe; // bit bizzare that nodes only listen to one universe??
77 };
78 
80 
81 /*
82  * poll reply
83  */
84 PACK(
85 struct espnet_poll_reply_s {
86  uint32_t head;
87  uint8_t mac[ola::network::MACAddress::LENGTH];
88  uint16_t type;
89  uint8_t version;
90  uint8_t sw;
91  uint8_t name[ESPNET_NAME_LENGTH];
92  uint8_t option;
93  uint8_t tos;
94  uint8_t ttl;
95  espnet_node_config_t config;
96 });
97 
98 typedef struct espnet_poll_reply_s espnet_poll_reply_t;
99 
100 /*
101  * ack datagram
102  */
103 PACK(
104 struct espnet_ack_s {
105  uint32_t head;
106  uint8_t status;
107  uint8_t crc;
108 });
109 
110 typedef struct espnet_ack_s espnet_ack_t;
111 
112 /*
113  * dmx datagram
114  */
115 PACK(
116 struct espnet_data_s {
117  uint32_t head;
118  uint8_t universe;
119  uint8_t start;
120  uint8_t type;
121  uint16_t size;
122  uint8_t data[DMX_UNIVERSE_SIZE];
123 });
124 
125 typedef struct espnet_data_s espnet_data_t;
126 
127 
128 // we need to add the TCP config crap here
129 
130 
131 /*
132  * union of all espnet packets
133  */
134 typedef union {
135  espnet_poll_t poll;
136  espnet_poll_reply_t reply;
137  espnet_ack_t ack;
138  espnet_data_t dmx;
140 } // namespace espnet
141 } // namespace plugin
142 } // namespace ola
143 #endif // PLUGINS_ESPNET_ESPNETPACKETS_H_
#define PACK(__Declaration__)
Pack structures.
Definition: Macro.h:170
Constants used throughout OLA.
Definition: EspNetPackets.h:134
Definition: Constants.h:36
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Definition: EspNetPackets.h:73
Represents a MAC Address.