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 = 1,
40  MSG_BB_OPEN_FOR_READING = 2,
41  MSG_BB_OPEN_FOR_WRITING = 3,
42  MSG_BB_OPEN_SUCCESS = 4,
43  MSG_BB_OPEN_FAILURE = 5,
44  MSG_BB_CLOSE = 6,
45  MSG_BB_WRITE = 7,
46  MSG_BB_INTERFACE_MESSAGE = 8,
47  MSG_BB_DATA_CHANGED = 9,
48  MSG_BB_READER_ADDED = 10,
49  MSG_BB_READER_REMOVED = 11,
50  MSG_BB_WRITER_ADDED = 12,
51  MSG_BB_WRITER_REMOVED = 13,
52  MSG_BB_INTERFACE_CREATED = 14,
53  MSG_BB_INTERFACE_DESTROYED = 15,
54  MSG_BB_LIST = 16
56 
57 /** Error codes */
58 typedef enum {
59  BB_ERR_UNKNOWN_ERR, /**< Unknown error occured. Check log. */
60  BB_ERR_UNKNOWN_TYPE, /**< Requested interface type is unknown. */
61  BB_ERR_HASH_MISMATCH, /**< The hashes of the interfaces do not match. Make sure that
62  * both sides are using the exact same version of the interface. */
63  BB_ERR_WRITER_EXISTS /**< You tried to open an interface for writing but there is already
64  * a writing instance for this interface. */
66 
67 /** Message to transport a list of interfaces. */
68 typedef struct
69 {
70  dynamic_list_t interface_list; /**< dynamic buffer list with interface info */
72 
73 /** Message to request constrained interface list. */
74 typedef struct
75 {
76  char type_pattern[INTERFACE_TYPE_SIZE_]; /**< type pattern */
77  char id_pattern[INTERFACE_ID_SIZE_]; /**< ID pattern */
79 
80 /** Message to identify an interface on open. */
81 typedef struct
82 {
83  char type[INTERFACE_TYPE_SIZE_]; /**< interface type name */
84  char id[INTERFACE_ID_SIZE_]; /**< interface instance ID */
85  unsigned char hash[INTERFACE_HASH_SIZE_]; /**< interface version hash */
87 
88 /** Message for interface info. */
89 typedef struct
90 {
91  char type[INTERFACE_TYPE_SIZE_]; /**< interface type name */
92  char id[INTERFACE_ID_SIZE_]; /**< interface instance ID */
93  unsigned char hash[INTERFACE_HASH_SIZE_]; /**< interface version hash */
94  uint32_t serial; /**< instance serial to uniquely identify
95  * this instance (big endian) */
96  uint32_t writer_readers; /**< combined writer reader
97  * information. First bit (any endian) is
98  1 if writer exists, 0 otherwise. The
99  remaining 31 bits encode the number
100  of readers as big endian number. */
101  int64_t timestamp_sec; /**< data or write timestamp, sec part */
102  int64_t timestamp_usec; /**< data or write timestamp, usec part */
104 
105 /** Message for interface events.
106  * This message is used for MSG_BB_INTERFACE_CREATED and MSG_BB_INTERFACE_REMOVED.
107  */
108 typedef struct
109 {
110  char type[INTERFACE_TYPE_SIZE_]; /**< interface type name */
111  char id[INTERFACE_ID_SIZE_]; /**< interface instance ID */
113 
114 /** Message to identify an interface instance.
115  * This message is used for MSG_BB_CLOSE, MSG_BB_READER_ADDED, MSG_BB_READER_REMOVED,
116  * MSG_BB_WRITER_ADDED, and MSG_BB_READER_REMOVED.
117  */
118 typedef struct
119 {
120  uint32_t serial; /**< instance serial to unique identify this instance */
122 
123 /** Message to identify an two interface instances.
124  * This message is used for MSG_BB_READER_ADDED, MSG_BB_READER_REMOVED,
125  * MSG_BB_WRITER_ADDED, and MSG_BB_READER_REMOVED.
126  */
127 typedef struct
128 {
129  uint32_t serial; /**< instance serial to unique identify own instance */
130  uint32_t event_serial; /**< instance serial to unique identify instance that
131  * caused the event. */
133 
134 /** Interface open success
135  * The serial denotes a unique instance of an interface within the (remote)
136  * BlackBoard.
137  * This message struct is always followed by a data chunk that is of the
138  * size data_size. It contains the current content of the interface.
139  */
140 typedef struct
141 {
142  uint32_t serial; /**< instance serial to unique identify this instance */
143  uint32_t writer_readers; /**< combined writer reader information. First
144  * bit (any endian) is 1 if writer exists, 0 otherwise.
145  * The remaining 31 bits encode the number of readers
146  * as big endian number. */
147  uint32_t data_size; /**< size in bytes of the following data. */
149 
150 /** Message to send update data. */
151 typedef struct
152 {
153  uint32_t error_code; /**< Error code. @see blackboard_neterror_t */
155 
156 /** Interface data message.
157  * The serial denotes a unique instance of an interface within the (remote)
158  * BlackBoard.
159  * This message struct is always followed by a data chunk that is of the
160  * size data_size. It contains the current content of the interface.
161  * This message is sent for MSG_BB_WRITE and MSG_BB_DATA_CHANGED.
162  */
163 typedef struct
164 {
165  uint32_t serial; /**< instance serial to unique identify this instance */
166  uint32_t data_size; /**< size in bytes of the following data. */
168 
169 /** Interface message.
170  * This type is used to transport interface messages. This struct is always followed
171  * by a data chunk of the size data_size that transports the message data.
172  */
173 typedef struct
174 {
175  uint32_t serial; /**< interface instance serial */
176  char msg_type[INTERFACE_MESSAGE_TYPE_SIZE_]; /**< message type */
177  uint32_t msgid; /**< message ID */
178  uint32_t hops; /**< number of hops this message already passed */
179  uint32_t data_size; /**< data for message */
181 
182 #pragma pack(pop)
183 
184 } // end namespace fawkes
185 
186 #endif
Fawkes library namespace.
blackboard_msgid_t
BlackBoard network message types.
Definition: messages.h:37
blackboard_neterror_t
Error codes.
Definition: messages.h:58
@ BB_ERR_UNKNOWN_ERR
Unknown error occured.
Definition: messages.h:59
@ 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:63
@ BB_ERR_HASH_MISMATCH
The hashes of the interfaces do not match.
Definition: messages.h:61
@ BB_ERR_UNKNOWN_TYPE
Requested interface type is unknown.
Definition: messages.h:60
Interface data message.
Definition: messages.h:164
uint32_t serial
instance serial to unique identify this instance
Definition: messages.h:165
uint32_t data_size
size in bytes of the following data.
Definition: messages.h:166
Message for interface events.
Definition: messages.h:109
Message to identify an two interface instances.
Definition: messages.h:128
uint32_t event_serial
instance serial to unique identify instance that caused the event.
Definition: messages.h:130
uint32_t serial
instance serial to unique identify own instance
Definition: messages.h:129
Message for interface info.
Definition: messages.h:90
uint32_t writer_readers
combined writer reader information.
Definition: messages.h:96
int64_t timestamp_usec
data or write timestamp, usec part
Definition: messages.h:102
int64_t timestamp_sec
data or write timestamp, sec part
Definition: messages.h:101
uint32_t serial
instance serial to uniquely identify this instance (big endian)
Definition: messages.h:94
Message to transport a list of interfaces.
Definition: messages.h:69
dynamic_list_t interface_list
dynamic buffer list with interface info
Definition: messages.h:70
Message to request constrained interface list.
Definition: messages.h:75
Interface message.
Definition: messages.h:174
uint32_t msgid
message ID
Definition: messages.h:177
uint32_t serial
interface instance serial
Definition: messages.h:175
uint32_t data_size
data for message
Definition: messages.h:179
uint32_t hops
number of hops this message already passed
Definition: messages.h:178
Message to identify an interface on open.
Definition: messages.h:82
Message to send update data.
Definition: messages.h:152
uint32_t error_code
Error code.
Definition: messages.h:153
Interface open success The serial denotes a unique instance of an interface within the (remote) Black...
Definition: messages.h:141
uint32_t serial
instance serial to unique identify this instance
Definition: messages.h:142
uint32_t data_size
size in bytes of the following data.
Definition: messages.h:147
uint32_t writer_readers
combined writer reader information.
Definition: messages.h:143
Message to identify an interface instance.
Definition: messages.h:119
uint32_t serial
instance serial to unique identify this instance
Definition: messages.h:120
Dynamic list type.