Fawkes API  Fawkes Development Version
messages.h
1 
2 /***************************************************************************
3  * net_messages.h - BlackBoard Network Messages
4  *
5  * Created: Sat Mar 01 16:08:13 2008
6  * Copyright 2006-2008 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef _BLACKBOARD_NET_MESSAGES_H_
25 #define _BLACKBOARD_NET_MESSAGES_H_
26 
27 #include <interface/interface.h>
28 #include <netcomm/utils/dynamic_buffer.h>
29 
30 #include <stdint.h>
31 
32 namespace fawkes {
33 
34 #pragma pack(push, 4)
35 
36 /** BlackBoard network message types */
37 typedef enum {
38  MSG_BB_LIST_ALL = 0,
39  MSG_BB_INTERFACE_LIST,
40  MSG_BB_OPEN_FOR_READING,
41  MSG_BB_OPEN_FOR_WRITING,
42  MSG_BB_OPEN_SUCCESS,
43  MSG_BB_OPEN_FAILURE,
44  MSG_BB_CLOSE,
45  MSG_BB_WRITE,
46  MSG_BB_INTERFACE_MESSAGE,
47  MSG_BB_DATA_REFRESHED,
48  MSG_BB_DATA_CHANGED,
49  MSG_BB_READER_ADDED,
50  MSG_BB_READER_REMOVED,
51  MSG_BB_WRITER_ADDED,
52  MSG_BB_WRITER_REMOVED,
53  MSG_BB_INTERFACE_CREATED,
54  MSG_BB_INTERFACE_DESTROYED,
55  MSG_BB_LIST
57 
58 /** Error codes */
59 typedef enum {
60  BB_ERR_UNKNOWN_ERR, /**< Unknown error occured. Check log. */
61  BB_ERR_UNKNOWN_TYPE, /**< Requested interface type is unknown. */
62  BB_ERR_HASH_MISMATCH, /**< The hashes of the interfaces do not match. Make sure that
63  * both sides are using the exact same version of the interface. */
64  BB_ERR_WRITER_EXISTS /**< You tried to open an interface for writing but there is already
65  * a writing instance for this interface. */
67 
68 /** Message to transport a list of interfaces. */
69 typedef struct
70 {
71  dynamic_list_t interface_list; /**< dynamic buffer list with interface info */
73 
74 /** Message to request constrained interface list. */
75 typedef struct
76 {
77  char type_pattern[INTERFACE_TYPE_SIZE_]; /**< type pattern */
78  char id_pattern[INTERFACE_ID_SIZE_]; /**< ID pattern */
80 
81 /** Message to identify an interface on open. */
82 typedef struct
83 {
84  char type[INTERFACE_TYPE_SIZE_]; /**< interface type name */
85  char id[INTERFACE_ID_SIZE_]; /**< interface instance ID */
86  unsigned char hash[INTERFACE_HASH_SIZE_]; /**< interface version hash */
88 
89 /** Message for interface info. */
90 typedef struct
91 {
92  char type[INTERFACE_TYPE_SIZE_]; /**< interface type name */
93  char id[INTERFACE_ID_SIZE_]; /**< interface instance ID */
94  unsigned char hash[INTERFACE_HASH_SIZE_]; /**< interface version hash */
95  uint32_t serial; /**< instance serial to uniquely identify
96  * this instance (big endian) */
97  uint32_t writer_readers; /**< combined writer reader
98  * information. First bit (any endian) is
99  1 if writer exists, 0 otherwise. The
100  remaining 31 bits encode the number
101  of readers as big endian number. */
102  int64_t timestamp_sec; /**< data or write timestamp, sec part */
103  int64_t timestamp_usec; /**< data or write timestamp, usec part */
105 
106 /** Message for interface events.
107  * This message is used for MSG_BB_INTERFACE_CREATED and MSG_BB_INTERFACE_REMOVED.
108  */
109 typedef struct
110 {
111  char type[INTERFACE_TYPE_SIZE_]; /**< interface type name */
112  char id[INTERFACE_ID_SIZE_]; /**< interface instance ID */
114 
115 /** Message to identify an interface instance.
116  * This message is used for MSG_BB_CLOSE, MSG_BB_READER_ADDED, MSG_BB_READER_REMOVED,
117  * MSG_BB_WRITER_ADDED, and MSG_BB_READER_REMOVED.
118  */
119 typedef struct
120 {
121  Uuid serial; /**< instance serial to unique identify this instance */
123 
124 /** Message to identify an two interface instances.
125  * This message is used for MSG_BB_READER_ADDED, MSG_BB_READER_REMOVED,
126  * MSG_BB_WRITER_ADDED, and MSG_BB_READER_REMOVED.
127  */
128 typedef struct
129 {
130  Uuid serial; /**< instance serial to unique identify own instance */
131  Uuid event_serial; /**< instance serial to unique identify instance that
132  * caused the event. */
134 
135 /** Interface open success
136  * The serial denotes a unique instance of an interface within the (remote)
137  * BlackBoard.
138  * This message struct is always followed by a data chunk that is of the
139  * size data_size. It contains the current content of the interface.
140  */
141 typedef struct
142 {
143  Uuid serial; /**< instance serial to unique identify this instance */
144  uint32_t writer_readers; /**< combined writer reader information. First
145  * bit (any endian) is 1 if writer exists, 0 otherwise.
146  * The remaining 31 bits encode the number of readers
147  * as big endian number. */
148  uint32_t data_size; /**< size in bytes of the following data. */
150 
151 /** Message to send update data. */
152 typedef struct
153 {
154  uint32_t error_code; /**< Error code. @see blackboard_neterror_t */
156 
157 /** Interface data message.
158  * The serial denotes a unique instance of an interface within the (remote)
159  * BlackBoard.
160  * This message struct is always followed by a data chunk that is of the
161  * size data_size. It contains the current content of the interface.
162  * This message is sent for MSG_BB_WRITE and MSG_BB_DATA_CHANGED.
163  */
164 typedef struct
165 {
166  Uuid serial; /**< instance serial to unique identify this instance */
167  uint32_t data_size; /**< size in bytes of the following data. */
169 
170 /** Interface message.
171  * This type is used to transport interface messages. This struct is always followed
172  * by a data chunk of the size data_size that transports the message data.
173  */
174 typedef struct
175 {
176  Uuid serial; /**< interface instance serial */
177  Uuid source; /**< serial of the original message source */
178  char msg_type[INTERFACE_MESSAGE_TYPE_SIZE_]; /**< message type */
179  uint32_t msgid; /**< message ID */
180  uint32_t hops; /**< number of hops this message already passed */
181  uint32_t data_size; /**< data for message */
183 
184 #pragma pack(pop)
185 
186 } // end namespace fawkes
187 
188 #endif
A convenience class for universally unique identifiers (UUIDs).
Definition: uuid.h:29
Fawkes library namespace.
blackboard_msgid_t
BlackBoard network message types.
Definition: messages.h:37
blackboard_neterror_t
Error codes.
Definition: messages.h:59
@ BB_ERR_UNKNOWN_ERR
Unknown error occured.
Definition: messages.h:60
@ BB_ERR_WRITER_EXISTS
You tried to open an interface for writing but there is already a writing instance for this interface...
Definition: messages.h:64
@ BB_ERR_HASH_MISMATCH
The hashes of the interfaces do not match.
Definition: messages.h:62
@ BB_ERR_UNKNOWN_TYPE
Requested interface type is unknown.
Definition: messages.h:61
Interface data message.
Definition: messages.h:165
uint32_t data_size
size in bytes of the following data.
Definition: messages.h:167
Uuid serial
instance serial to unique identify this instance
Definition: messages.h:166
Message for interface events.
Definition: messages.h:110
Message to identify an two interface instances.
Definition: messages.h:129
Uuid event_serial
instance serial to unique identify instance that caused the event.
Definition: messages.h:131
Uuid serial
instance serial to unique identify own instance
Definition: messages.h:130
Message for interface info.
Definition: messages.h:91
uint32_t writer_readers
combined writer reader information.
Definition: messages.h:97
int64_t timestamp_usec
data or write timestamp, usec part
Definition: messages.h:103
int64_t timestamp_sec
data or write timestamp, sec part
Definition: messages.h:102
uint32_t serial
instance serial to uniquely identify this instance (big endian)
Definition: messages.h:95
Message to transport a list of interfaces.
Definition: messages.h:70
dynamic_list_t interface_list
dynamic buffer list with interface info
Definition: messages.h:71
Message to request constrained interface list.
Definition: messages.h:76
Interface message.
Definition: messages.h:175
Uuid serial
interface instance serial
Definition: messages.h:176
uint32_t msgid
message ID
Definition: messages.h:179
Uuid source
serial of the original message source
Definition: messages.h:177
uint32_t data_size
data for message
Definition: messages.h:181
uint32_t hops
number of hops this message already passed
Definition: messages.h:180
Message to identify an interface on open.
Definition: messages.h:83
Message to send update data.
Definition: messages.h:153
uint32_t error_code
Error code.
Definition: messages.h:154
Interface open success The serial denotes a unique instance of an interface within the (remote) Black...
Definition: messages.h:142
Uuid serial
instance serial to unique identify this instance
Definition: messages.h:143
uint32_t data_size
size in bytes of the following data.
Definition: messages.h:148
uint32_t writer_readers
combined writer reader information.
Definition: messages.h:144
Message to identify an interface instance.
Definition: messages.h:120
Uuid serial
instance serial to unique identify this instance
Definition: messages.h:121
Dynamic list type.