Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 unique identify
91  * this instance */
92  uint32_t has_writer : 1; /**< 1 if the interface currently has a
93  * writer, 0 otherwise */
94  uint32_t num_readers : 31; /**< number of currently existing readers */
96 
97 
98 /** Message for interface events.
99  * This message is used for MSG_BB_INTERFACE_CREATED and MSG_BB_INTERFACE_REMOVED.
100  */
101 typedef struct {
102  char type[__INTERFACE_TYPE_SIZE]; /**< interface type name */
103  char id[__INTERFACE_ID_SIZE]; /**< interface instance ID */
105 
106 
107 /** Message to identify an interface instance.
108  * This message is used for MSG_BB_CLOSE, MSG_BB_READER_ADDED, MSG_BB_READER_REMOVED,
109  * MSG_BB_WRITER_ADDED, and MSG_BB_READER_REMOVED.
110  */
111 typedef struct {
112  uint32_t serial; /**< instance serial to unique identify this instance */
114 
115 
116 /** Message to identify an two interface instances.
117  * This message is used for MSG_BB_READER_ADDED, MSG_BB_READER_REMOVED,
118  * MSG_BB_WRITER_ADDED, and MSG_BB_READER_REMOVED.
119  */
120 typedef struct {
121  uint32_t serial; /**< instance serial to unique identify own instance */
122  uint32_t event_serial; /**< instance serial to unique identify instance that
123  * caused the event. */
125 
126 
127 /** Interface open success
128  * The serial denotes a unique instance of an interface within the (remote)
129  * BlackBoard.
130  * This message struct is always followed by a data chunk that is of the
131  * size data_size. It contains the current content of the interface.
132  */
133 typedef struct {
134  uint32_t serial; /**< instance serial to unique identify this instance */
135  uint32_t has_writer : 1; /**< 1 if the interface currently has a writer, 0 otherwise */
136  uint32_t num_readers : 31; /**< number of currently existing readers */
137  uint32_t data_size; /**< size in bytes of the following data. */
139 
140 
141 /** Message to send update data. */
142 typedef struct {
143  uint32_t errno; /**< Error code. @see blackboard_neterror_t */
145 
146 
147 /** Interface data message.
148  * The serial denotes a unique instance of an interface within the (remote)
149  * BlackBoard.
150  * This message struct is always followed by a data chunk that is of the
151  * size data_size. It contains the current content of the interface.
152  * This message is sent for MSG_BB_WRITE and MSG_BB_DATA_CHANGED.
153  */
154 typedef struct {
155  uint32_t serial; /**< instance serial to unique identify this instance */
156  uint32_t data_size; /**< size in bytes of the following data. */
158 
159 
160 /** Interface message.
161  * This type is used to transport interface messages. This struct is always followed
162  * by a data chunk of the size data_size that transports the message data.
163  */
164  typedef struct {
165  uint32_t serial; /**< interface instance serial */
166  char msg_type[__INTERFACE_MESSAGE_TYPE_SIZE]; /**< message type */
167  uint32_t msgid; /**< message ID */
168  uint32_t hops; /**< number of hops this message already passed */
169  uint32_t data_size; /**< data for message */
171 
172 #pragma pack(pop)
173 
174 } // end namespace fawkes
175 
176 #endif