]> rtime.felk.cvut.cz Git - orte.git/blob - orte/include/orte/typedefs_defines_rtps.h
Reformat the sources with orte/uncrustify script
[orte.git] / orte / include / orte / typedefs_defines_rtps.h
1 /*
2  *  $Id: typedefs_defines_rtps.h,v 0.0.0.1 2003/08/21
3  *
4  *  -------------------------------------------------------------------
5  *                                ORTE
6  *                      Open Real-Time Ethernet
7  *
8  *                      Copyright (C) 2001-2006
9  *  Department of Control Engineering FEE CTU Prague, Czech Republic
10  *                      http://dce.felk.cvut.cz
11  *                      http://www.ocera.org
12  *
13  *  Author:              Petr Smolik    petr@smoliku.cz
14  *  Advisor:             Pavel Pisa
15  *  Project Responsible: Zdenek Hanzalek
16  *  --------------------------------------------------------------------
17  *
18  *  This program is free software; you can redistribute it and/or modify
19  *  it under the terms of the GNU General Public License as published by
20  *  the Free Software Foundation; either version 2 of the License, or
21  *  (at your option) any later version.
22  *
23  *  This program is distributed in the hope that it will be useful,
24  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
25  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  *  GNU General Public License for more details.
27  *
28  */
29
30 #ifndef _TYPEDEFS_DEFINES_RTPS_H
31 #define _TYPEDEFS_DEFINES_RTPS_H
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #define RTPS_HEADER_LENGTH   16
38
39 #define MAX_PATHNAME         128
40 #define MAX_TYPENAME         128
41 #define ORTE_TRUE            1
42 #define ORTE_FALSE           0
43
44 typedef int8_t                   Boolean;
45
46 typedef int8_t                   PathName[MAX_PATHNAME];
47 typedef int8_t                   TypeName[MAX_TYPENAME];
48
49 typedef int32_t                  TypeChecksum;
50
51 /*****************************************************************/
52 /*             Wire Protocol Specification (WPS)                 */
53 /*****************************************************************/
54
55
56 /*
57   Host identifier.
58
59   for example: IP address working nodes
60 */
61 typedef uint32_t                 HostId;
62 #define HID_UNKNOWN              0x00
63
64 /*
65   Application identifier.
66
67   composed from: 3 bytes - instance Id
68                  1 byte  - appKind (1 - ManagedApplication, 2 - Manager)
69 */
70 typedef uint32_t                 AppId;
71 #define AID_UNKNOWN              0x00
72 #define MANAGEDAPPLICATION       0x01
73 #define MANAGER                  0x02
74
75 /*
76   Object identifier.
77
78   composed from: 3 bytes - instance Id
79                  1 byte  - objKind
80 */
81 typedef uint32_t                 ObjectId;
82
83 #define OID_UNKNOWN              0x00000000
84 #define OID_APP                  0x000001C1
85 #define OID_WRITE_APPSELF        0x000008C2
86 #define OID_READ_APPSELF         0x000008C7
87 #define OID_WRITE_APP            0x000001C2
88 #define OID_READ_APP             0x000001C7
89 #define OID_WRITE_MGR            0x000007C2
90 #define OID_READ_MGR             0x000007C7
91 #define OID_WRITE_PUBL           0x000003C2
92 #define OID_READ_PUBL            0x000003C7
93 #define OID_WRITE_SUBS           0x000004C2
94 #define OID_READ_SUBS            0x000004C7
95 //Kind
96 #define OID_APPLICATION      0x01
97 #define OID_CSTWRITER        0x02
98 #define OID_PUBLICATION      0x03
99 #define OID_SUBSCRIPTION     0x04
100 #define OID_CSTREADER        0x07
101 //
102 #define OID_USEROBJ          0x00
103 #define OID_RESUSEROBJ       0x40
104 #define OID_METAOBJ          0x80
105 #define OID_RESMETAOBJ       0xC0
106
107 typedef struct {
108   HostId                hid;
109   AppId                 aid;
110   ObjectId              oid;
111 } GUID_RTPS;
112
113 typedef struct {
114   int8_t                major;
115   int8_t                minor;
116 } VendorId;
117
118 #define VENDOR_ID_UNKNOWN(id)    {id.major = 0; id.minor = 0; }
119 #define VENDOR_ID_RTI(id)        {id.major = 1; id.minor = 1; }
120 #define VENDOR_ID_OCERA(id)      {id.major = 0; id.minor = 0; }
121
122 typedef struct {
123   int8_t                major;
124   int8_t                minor;
125 } ProtocolVersion;
126
127 #define PROTOCOL_VERSION_1_0(pv) {pv.major = 1; pv.minor = 0; }
128
129 typedef struct {
130   int32_t               high;
131   int32_t               low;
132 } SequenceNumber;
133
134
135 #define SEQUENCE_NUMBER_NONE(sn)    {sn.high = 0; sn.low = 0; }
136 #define SEQUENCE_NUMBER_UNKNOWN(sn) {sn.high = 0x7fffffff; sn.low = 0xffffffff; }
137
138
139 typedef struct {
140   int32_t               seconds;         /* time in seconds */
141   uint32_t              fraction;        /* time in seconds / 2^32 */
142 } NtpTime;
143
144 #define NTPTIME_ZERO(t)          {t.seconds = 0; t.fraction = 0; }
145 #define NTPTIME_BUILD(t, s)       {t.seconds = s; t.fraction = 0; }
146 #define NTPTIME_INFINITE(t)      {t.seconds = 0xffffffff; t.fraction = 0; }
147
148 typedef uint32_t                 IPAddress;
149
150 #define IPADDRESS_INVALID        0
151
152 typedef uint32_t                 Port;
153
154 #define PORT_INVALID             0
155
156 typedef enum {
157   PAD                       = 0x01,
158   VAR                       = 0x02,
159   ISSUE                     = 0x03,
160   ACK                       = 0x06,
161   HEARTBEAT                 = 0x07,
162   GAP                       = 0x08,
163   INFO_TS                   = 0x09,
164   INFO_SRC                  = 0x0c,
165   INFO_REPLY                = 0x0d,
166   INFO_DST                  = 0x0e,
167   APP_QUIT                  = 0x90
168 } SubmessageId;
169
170 typedef struct {
171   ProtocolVersion           sourceVersion;
172   VendorId                  sourceVendorId;
173   HostId                    sourceHostId;
174   AppId                     sourceAppId;
175   HostId                    destHostId;
176   AppId                     destAppId;
177   IPAddress                 unicastReplyIPAddress;
178   Port                      unicastReplyPort;
179   IPAddress                 multicastReplyIPAddress;
180   Port                      multicastReplyPort;
181   Boolean                   haveTimestamp;
182   NtpTime                   timestamp;
183 } MessageInterpret;
184
185
186 #define PID_PAD                             0x00
187 #define PID_SENTINEL                        0x01
188 #define PID_EXPIRATION_TIME                 0x02
189 #define PID_PERSISTENCE                     0x03
190 #define PID_MINIMUM_SEPARATION              0x04
191 #define PID_TOPIC                           0x05
192 #define PID_STRENGTH                        0x06
193 #define PID_TYPE_NAME                       0x07
194 #define PID_TYPE_CHECKSUM                   0x08
195 #define RTPS_PID_TYPE2_NAME                 0x09
196 #define RTPS_PID_TYPE2_CHECKSUM             0x0a
197 #define PID_MATATRAFFIC_MULTICAST_IPADDRESS 0x0b
198 #define PID_APP_IPADDRESS                   0x0c
199 #define PID_METATRAFFIC_UNICAST_PORT        0x0d
200 #define PID_USERDATA_UNICAST_PORT           0x0e
201 #define PID_IS_RELIABLE                     0x0f
202 #define PID_EXPECTS_ACK                     0x10
203 #define PID_USERDATA_MULTICAST_IPADDRESS    0x11
204 #define PID_MANAGER_KEY                     0x12
205 #define PID_SEND_QUEUE_SIZE                 0x13
206 #define PID_RELIABILITY_ENABLED             0x14
207 #define PID_PROTOCOL_VERSION                0x15
208 #define PID_VENDOR_ID                       0x16
209 #define PID_VARGAPPS_SEQUENCE_NUMBER_LAST   0x17
210 #define PID_RECV_QUEUE_SIZE                 0x18
211 #define PID_RELIABILITY_OFFERED             0x19
212 #define PID_RELIABILITY_REQUESTED           0x1a
213
214 /* possible values for PID_RELIABILITY_REQUEST */
215 #define PID_VALUE_RELIABILITY_BEST_EFFORTS  0x01
216 #define PID_VALUE_RELIABILITY_STRICT        0x02
217
218 typedef uint16_t ParameterId;
219 typedef uint16_t ParameterLength;
220
221 /* State Machines */
222 typedef enum {
223   MAYSENDHB                           = 0x01,
224   MUSTSENDHB                          = 0x02,
225   SENDHB                              = 0x03
226 } StateMachineHB;
227
228 typedef enum {
229   NOTHNIGTOSEND                       = 0x01,
230   MUSTSENDDATA                        = 0x02
231 } StateMachineSend;
232
233 typedef enum {
234   NEW                                 = 0x01,
235   TOSEND                              = 0x02,
236   UNDERWAY                            = 0x03,
237   UNACKNOWLEDGED                      = 0x04,
238   ANNOUCED                            = 0x05,
239   ACKNOWLEDGED                        = 0x06
240 } StateMachineChFReader;
241
242 typedef enum {
243   WAITING                             = 0x01,
244   PULLING                             = 0x02,
245   ACKPENDING                          = 0x03
246 } StateMachineACK;
247
248 typedef enum {
249   FUTURE                              = 0x01,
250   REQUESTED                           = 0x02,
251   MISSING                             = 0x03,
252   RECEIVED                            = 0x04
253 } StateMachineChFWriter;
254
255 #ifdef __cplusplus
256 } /* extern "C"*/
257 #endif
258
259 #endif /* _TYPEDEFS_DEFINES_RTPS_H */