Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * net_messages.h - BlackBoard Network Messages 00004 * 00005 * Created: Sat Mar 01 16:08:13 2008 00006 * Copyright 2006-2008 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __BLACKBOARD_NET_MESSAGES_H_ 00025 #define __BLACKBOARD_NET_MESSAGES_H_ 00026 00027 #include <stdint.h> 00028 #include <netcomm/utils/dynamic_buffer.h> 00029 #include <interface/interface.h> 00030 00031 namespace fawkes { 00032 00033 #pragma pack(push,4) 00034 00035 /** BlackBoard network message types */ 00036 typedef enum { 00037 MSG_BB_LIST_ALL = 0, 00038 MSG_BB_INTERFACE_LIST = 1, 00039 MSG_BB_OPEN_FOR_READING = 2, 00040 MSG_BB_OPEN_FOR_WRITING = 3, 00041 MSG_BB_OPEN_SUCCESS = 4, 00042 MSG_BB_OPEN_FAILURE = 5, 00043 MSG_BB_CLOSE = 6, 00044 MSG_BB_WRITE = 7, 00045 MSG_BB_INTERFACE_MESSAGE = 8, 00046 MSG_BB_DATA_CHANGED = 9, 00047 MSG_BB_READER_ADDED = 10, 00048 MSG_BB_READER_REMOVED = 11, 00049 MSG_BB_WRITER_ADDED = 12, 00050 MSG_BB_WRITER_REMOVED = 13, 00051 MSG_BB_INTERFACE_CREATED = 14, 00052 MSG_BB_INTERFACE_DESTROYED = 15, 00053 MSG_BB_LIST = 16 00054 } blackboard_msgid_t; 00055 00056 /** Error codes */ 00057 typedef enum { 00058 BB_ERR_UNKNOWN_ERR, /**< Unknown error occured. Check log. */ 00059 BB_ERR_UNKNOWN_TYPE, /**< Requested interface type is unknown. */ 00060 BB_ERR_HASH_MISMATCH, /**< The hashes of the interfaces do not match. Make sure that 00061 * both sides are using the exact same version of the interface. */ 00062 BB_ERR_WRITER_EXISTS /**< You tried to open an interface for writing but there is already 00063 * a writing instance for this interface. */ 00064 } blackboard_neterror_t; 00065 00066 /** Message to transport a list of interfaces. */ 00067 typedef struct { 00068 dynamic_list_t interface_list; /**< dynamic buffer list with interface info */ 00069 } bb_ilist_msg_t; 00070 00071 /** Message to request constrained interface list. */ 00072 typedef struct { 00073 char type_pattern[__INTERFACE_TYPE_SIZE]; /**< type pattern */ 00074 char id_pattern[__INTERFACE_ID_SIZE]; /**< ID pattern */ 00075 } bb_ilistreq_msg_t; 00076 00077 /** Message to identify an interface on open. */ 00078 typedef struct { 00079 char type[__INTERFACE_TYPE_SIZE]; /**< interface type name */ 00080 char id[__INTERFACE_ID_SIZE]; /**< interface instance ID */ 00081 unsigned char hash[__INTERFACE_HASH_SIZE]; /**< interface version hash */ 00082 } bb_iopen_msg_t; 00083 00084 00085 /** Message for interface info. */ 00086 typedef struct { 00087 char type[__INTERFACE_TYPE_SIZE]; /**< interface type name */ 00088 char id[__INTERFACE_ID_SIZE]; /**< interface instance ID */ 00089 unsigned char hash[__INTERFACE_HASH_SIZE]; /**< interface version hash */ 00090 uint32_t serial; /**< instance serial to unique identify 00091 * this instance */ 00092 uint32_t has_writer : 1; /**< 1 if the interface currently has a 00093 * writer, 0 otherwise */ 00094 uint32_t num_readers : 31; /**< number of currently existing readers */ 00095 } bb_iinfo_msg_t; 00096 00097 00098 /** Message for interface events. 00099 * This message is used for MSG_BB_INTERFACE_CREATED and MSG_BB_INTERFACE_REMOVED. 00100 */ 00101 typedef struct { 00102 char type[__INTERFACE_TYPE_SIZE]; /**< interface type name */ 00103 char id[__INTERFACE_ID_SIZE]; /**< interface instance ID */ 00104 } bb_ievent_msg_t; 00105 00106 00107 /** Message to identify an interface instance. 00108 * This message is used for MSG_BB_CLOSE, MSG_BB_READER_ADDED, MSG_BB_READER_REMOVED, 00109 * MSG_BB_WRITER_ADDED, and MSG_BB_READER_REMOVED. 00110 */ 00111 typedef struct { 00112 uint32_t serial; /**< instance serial to unique identify this instance */ 00113 } bb_iserial_msg_t; 00114 00115 00116 /** Message to identify an two interface instances. 00117 * This message is used for MSG_BB_READER_ADDED, MSG_BB_READER_REMOVED, 00118 * MSG_BB_WRITER_ADDED, and MSG_BB_READER_REMOVED. 00119 */ 00120 typedef struct { 00121 uint32_t serial; /**< instance serial to unique identify own instance */ 00122 uint32_t event_serial; /**< instance serial to unique identify instance that 00123 * caused the event. */ 00124 } bb_ieventserial_msg_t; 00125 00126 00127 /** Interface open success 00128 * The serial denotes a unique instance of an interface within the (remote) 00129 * BlackBoard. 00130 * This message struct is always followed by a data chunk that is of the 00131 * size data_size. It contains the current content of the interface. 00132 */ 00133 typedef struct { 00134 uint32_t serial; /**< instance serial to unique identify this instance */ 00135 uint32_t has_writer : 1; /**< 1 if the interface currently has a writer, 0 otherwise */ 00136 uint32_t num_readers : 31; /**< number of currently existing readers */ 00137 uint32_t data_size; /**< size in bytes of the following data. */ 00138 } bb_iopensucc_msg_t; 00139 00140 00141 /** Message to send update data. */ 00142 typedef struct { 00143 uint32_t errno; /**< Error code. @see blackboard_neterror_t */ 00144 } bb_iopenfail_msg_t; 00145 00146 00147 /** Interface data message. 00148 * The serial denotes a unique instance of an interface within the (remote) 00149 * BlackBoard. 00150 * This message struct is always followed by a data chunk that is of the 00151 * size data_size. It contains the current content of the interface. 00152 * This message is sent for MSG_BB_WRITE and MSG_BB_DATA_CHANGED. 00153 */ 00154 typedef struct { 00155 uint32_t serial; /**< instance serial to unique identify this instance */ 00156 uint32_t data_size; /**< size in bytes of the following data. */ 00157 } bb_idata_msg_t; 00158 00159 00160 /** Interface message. 00161 * This type is used to transport interface messages. This struct is always followed 00162 * by a data chunk of the size data_size that transports the message data. 00163 */ 00164 typedef struct { 00165 uint32_t serial; /**< interface instance serial */ 00166 char msg_type[__INTERFACE_MESSAGE_TYPE_SIZE]; /**< message type */ 00167 uint32_t msgid; /**< message ID */ 00168 uint32_t hops; /**< number of hops this message already passed */ 00169 uint32_t data_size; /**< data for message */ 00170 } bb_imessage_msg_t; 00171 00172 #pragma pack(pop) 00173 00174 } // end namespace fawkes 00175 00176 #endif