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