messages.h

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,
00038   MSG_BB_INTERFACE_LIST,
00039   MSG_BB_OPEN_FOR_READING,
00040   MSG_BB_OPEN_FOR_WRITING,
00041   MSG_BB_OPEN_SUCCESS,
00042   MSG_BB_OPEN_FAILURE,
00043   MSG_BB_CLOSE,
00044   MSG_BB_WRITE,
00045   MSG_BB_INTERFACE_MESSAGE,
00046   MSG_BB_DATA_CHANGED,
00047   MSG_BB_READER_ADDED,
00048   MSG_BB_READER_REMOVED,
00049   MSG_BB_WRITER_ADDED,
00050   MSG_BB_WRITER_REMOVED,
00051   MSG_BB_INTERFACE_CREATED,
00052   MSG_BB_INTERFACE_DESTROYED
00053 } blackboard_msgid_t;
00054 
00055 /** Error codes */
00056 typedef enum {
00057   BB_ERR_UNKNOWN_ERR,   /**< Unknown error occured. Check log. */
00058   BB_ERR_UNKNOWN_TYPE,  /**< Requested interface type is unknown. */
00059   BB_ERR_HASH_MISMATCH, /**< The hashes of the interfaces do not match. Make sure that
00060                          * both sides are using the exact same version of the interface. */
00061   BB_ERR_WRITER_EXISTS  /**< You tried to open an interface for writing but there is already
00062                          * a writing instance for this interface. */
00063 } blackboard_neterror_t;
00064 
00065 /** Message to transport a list of interfaces. */
00066 typedef struct {
00067   dynamic_list_t interface_list;        /**< dynamic buffer list with interface info */
00068 } bb_ilist_msg_t;
00069 
00070 /** Message to identify an interface on open. */
00071 typedef struct {
00072   char          type[__INTERFACE_TYPE_SIZE];    /**< interface type name */
00073   char          id[__INTERFACE_ID_SIZE];        /**< interface instance ID */
00074   unsigned char hash[__INTERFACE_HASH_SIZE];    /**< interface version hash */
00075 } bb_iopen_msg_t;
00076 
00077 
00078 /** Message for interface info. */
00079 typedef struct {
00080   char          type[__INTERFACE_TYPE_SIZE];    /**< interface type name */
00081   char          id[__INTERFACE_ID_SIZE];        /**< interface instance ID */
00082   unsigned char hash[__INTERFACE_HASH_SIZE];    /**< interface version hash */
00083   uint32_t      serial;                         /**< instance serial to unique identify
00084                                                  * this instance */
00085   uint32_t      has_writer  :  1;               /**< 1 if the interface currently has a
00086                                                  * writer, 0 otherwise */
00087   uint32_t      num_readers : 31;               /**< number of currently existing readers */
00088 } bb_iinfo_msg_t;
00089 
00090 
00091 /** Message to identify an interface instance.
00092  * This message is used for MSG_BB_CLOSE, MSG_BB_READER_ADDED, MSG_BB_READER_REMOVED,
00093  * MSG_BB_WRITER_ADDED, and MSG_BB_READER_REMOVED.
00094  */
00095 typedef struct {
00096   uint32_t  serial;     /**< instance serial to unique identify this instance */
00097 } bb_iserial_msg_t;
00098 
00099 
00100 /** Message to identify an two interface instances.
00101  * This message is used for MSG_BB_READER_ADDED, MSG_BB_READER_REMOVED,
00102  * MSG_BB_WRITER_ADDED, and MSG_BB_READER_REMOVED.
00103  */
00104 typedef struct {
00105   uint32_t  serial;             /**< instance serial to unique identify own instance */
00106   uint32_t  event_serial;       /**< instance serial to unique identify instance that
00107                                  * caused the event. */
00108 } bb_ieventserial_msg_t;
00109 
00110 
00111 /** Interface open success
00112  * The serial denotes a unique instance of an interface within the (remote)
00113  * BlackBoard.
00114  * This message struct is always followed by a data chunk that is of the
00115  * size data_size. It contains the current content of the interface.
00116  */
00117 typedef struct {
00118   uint32_t serial;              /**< instance serial to unique identify this instance */
00119   uint32_t has_writer  :  1;    /**< 1 if the interface currently has a writer, 0 otherwise */
00120   uint32_t num_readers : 31;    /**< number of currently existing readers */
00121   uint32_t data_size;           /**< size in bytes of the following data. */
00122 } bb_iopensucc_msg_t;
00123 
00124 
00125 /** Message to send update data. */
00126 typedef struct {
00127   uint32_t  errno;      /**< Error code. @see blackboard_neterror_t */
00128 } bb_iopenfail_msg_t;
00129 
00130 
00131 /** Interface data message.
00132  * The serial denotes a unique instance of an interface within the (remote)
00133  * BlackBoard.
00134  * This message struct is always followed by a data chunk that is of the
00135  * size data_size. It contains the current content of the interface.
00136  * This message is sent for MSG_BB_WRITE and MSG_BB_DATA_CHANGED.
00137  */
00138 typedef struct {
00139   uint32_t serial;      /**< instance serial to unique identify this instance */
00140   uint32_t data_size;   /**< size in bytes of the following data. */
00141 } bb_idata_msg_t;
00142 
00143 
00144 /** Interface message.
00145  * This type is used to transport interface messages. This struct is always followed
00146  * by a data chunk of the size data_size that transports the message data.
00147  */
00148  typedef struct {
00149   uint32_t serial;                                      /**< interface instance serial */
00150   char     msg_type[__INTERFACE_MESSAGE_TYPE_SIZE];     /**< message type */
00151   uint32_t msgid;                                       /**< message ID */
00152   uint32_t hops;                                        /**< number of hops this message already passed */
00153   uint32_t data_size;                                   /**< data for message */
00154 } bb_imessage_msg_t;
00155 
00156 #pragma pack(pop)
00157 
00158 } // end namespace fawkes
00159 
00160 #endif

Generated on Tue Feb 22 13:31:25 2011 for Fawkes API by  doxygen 1.4.7