00001 00002 /*************************************************************************** 00003 * config_messages.h - Fawkes Configuration Messages 00004 * 00005 * Created: Sat Jan 06 23:14:59 2007 00006 * Copyright 2006-2007 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 __FAWKES_CONFIG_MESSAGES_H_ 00025 #define __FAWKES_CONFIG_MESSAGES_H_ 00026 00027 #include <stdint.h> 00028 #include <netcomm/utils/dynamic_buffer.h> 00029 00030 #pragma pack(push,4) 00031 00032 namespace fawkes { 00033 00034 #define MSG_CONFIG_GET_FLOAT 1 00035 #define MSG_CONFIG_GET_UINT 2 00036 #define MSG_CONFIG_GET_INT 3 00037 #define MSG_CONFIG_GET_BOOL 4 00038 #define MSG_CONFIG_GET_STRING 5 00039 #define MSG_CONFIG_GET_VALUE 6 00040 #define MSG_CONFIG_GET_COMMENT 7 00041 #define MSG_CONFIG_GET_DEFAULT_COMMENT 8 00042 #define MSG_CONFIG_GET_BEGIN MSG_CONFIG_GET_FLOAT 00043 #define MSG_CONFIG_GET_END MSG_CONFIG_GET_DEFAULT_COMMENT 00044 #define MSG_CONFIG_GET_ALL 9 00045 00046 #define MSG_CONFIG_SET_FLOAT 10 00047 #define MSG_CONFIG_SET_UINT 11 00048 #define MSG_CONFIG_SET_INT 12 00049 #define MSG_CONFIG_SET_BOOL 13 00050 #define MSG_CONFIG_SET_STRING 14 00051 #define MSG_CONFIG_SET_COMMENT 15 00052 #define MSG_CONFIG_SET_DEFAULT_FLOAT 16 00053 #define MSG_CONFIG_SET_DEFAULT_UINT 17 00054 #define MSG_CONFIG_SET_DEFAULT_INT 18 00055 #define MSG_CONFIG_SET_DEFAULT_BOOL 19 00056 #define MSG_CONFIG_SET_DEFAULT_STRING 20 00057 #define MSG_CONFIG_SET_DEFAULT_COMMENT 21 00058 #define MSG_CONFIG_SET_BEGIN MSG_CONFIG_SET_FLOAT 00059 #define MSG_CONFIG_SET_END MSG_CONFIG_SET_DEFAULT_COMMENT 00060 #define MSG_CONFIG_ERASE_VALUE 22 00061 00062 #define MSG_CONFIG_GET_TAGS 25 00063 #define MSG_CONFIG_LOAD_TAG 26 00064 #define MSG_CONFIG_SAVE_TAG 27 00065 #define MSG_CONFIG_INV_TAG 28 00066 #define MSG_CONFIG_DEL_TAG 29 00067 00068 #define MSG_CONFIG_FLOAT_VALUE 30 00069 #define MSG_CONFIG_UINT_VALUE 31 00070 #define MSG_CONFIG_INT_VALUE 32 00071 #define MSG_CONFIG_BOOL_VALUE 33 00072 #define MSG_CONFIG_STRING_VALUE 34 00073 #define MSG_CONFIG_COMMENT_VALUE 35 00074 #define MSG_CONFIG_VALUE_BEGIN MSG_CONFIG_FLOAT_VALUE 00075 #define MSG_CONFIG_VALUE_END MSG_CONFIG_COMMENT_VALUE 00076 #define MSG_CONFIG_INV_VALUE 36 00077 #define MSG_CONFIG_VALUE_ERASED 37 00078 #define MSG_CONFIG_LIST 38 00079 00080 #define MSG_CONFIG_SUBSCRIBE 50 00081 #define MSG_CONFIG_UNSUBSCRIBE 51 00082 00083 00084 /* Length definitions */ 00085 #define CONFIG_MSG_PATH_LENGTH 128 00086 #define CONFIG_MSG_MAX_TAG_LENGTH 64 00087 00088 /** Basic config descriptor. 00089 * Path that defines a unique element in the configuration. 00090 * It is part of most messages. 00091 */ 00092 typedef struct { 00093 char path[CONFIG_MSG_PATH_LENGTH]; /**< path to config value. */ 00094 uint32_t is_default : 1; /**< 1 if value is a default value, 0 00095 * otherwise, only for get response */ 00096 uint32_t reserved : 31; /**< Reserved for future use. */ 00097 } config_descriptor_t; 00098 00099 /** Get value message. */ 00100 typedef struct { 00101 config_descriptor_t cp; /**< value descriptor */ 00102 } config_getval_msg_t; 00103 00104 /** Invalid value request message. */ 00105 typedef struct { 00106 config_descriptor_t cp; /**< value descriptor */ 00107 } config_invval_msg_t; 00108 00109 /** Erase value request. */ 00110 typedef struct { 00111 config_descriptor_t cp; /**< value descriptor */ 00112 } config_erase_value_msg_t; 00113 00114 /** Value erased message. */ 00115 typedef struct { 00116 config_descriptor_t cp; /**< value descriptor */ 00117 } config_value_erased_msg_t; 00118 00119 /** Float value message */ 00120 typedef struct { 00121 config_descriptor_t cp; /**< value descriptor */ 00122 float f; /**< value */ 00123 } config_float_value_msg_t; 00124 00125 /** Unsigned int value message */ 00126 typedef struct { 00127 config_descriptor_t cp; /**< value descriptor */ 00128 uint32_t u; /**< value */ 00129 } config_uint_value_msg_t; 00130 00131 /** Integer value message */ 00132 typedef struct { 00133 config_descriptor_t cp; /**< value descriptor */ 00134 int32_t i; /**< value */ 00135 } config_int_value_msg_t; 00136 00137 /** Boolean value message */ 00138 typedef struct { 00139 config_descriptor_t cp; /**< value descriptor */ 00140 uint32_t b; /**< value */ 00141 } config_bool_value_msg_t; 00142 00143 /** String value message */ 00144 typedef struct { 00145 config_descriptor_t cp; /**< value descriptor */ 00146 uint16_t s_length; /**< Length of following string */ 00147 char s[2]; /**< string value, 0-terminated */ 00148 } config_string_value_msg_t; 00149 00150 00151 /** Comment message */ 00152 typedef struct { 00153 config_descriptor_t cp; /**< value descriptor */ 00154 uint16_t s_length; /**< Length of following string */ 00155 char s[2]; /**< comment, 0-terminated */ 00156 } config_comment_msg_t; 00157 00158 /** Tag message. */ 00159 typedef struct { 00160 config_descriptor_t cp; /**< value descriptor */ 00161 char tag[CONFIG_MSG_MAX_TAG_LENGTH]; /**< tag */ 00162 } config_tag_msg_t; 00163 00164 00165 /** Config list message. */ 00166 typedef struct { 00167 dynamic_list_t config_list; /**< DynamicBuffer for list */ 00168 } config_list_msg_t; 00169 00170 /** Config list entity header. */ 00171 typedef struct { 00172 config_descriptor_t cp; /**< Config descriptor. */ 00173 uint32_t type : 8; /**< type of entity, uses MSG_CONFIG_*_VALUE message IDs */ 00174 uint32_t reserved : 24; /**< reserved for future use */ 00175 } config_list_entity_header_t; 00176 00177 /** Config list float entity. */ 00178 typedef struct { 00179 config_list_entity_header_t header; /**< config entity header */ 00180 float f; /**< float value */ 00181 } config_list_float_entity_t; 00182 00183 /** Config list unsigned int entity. */ 00184 typedef struct { 00185 config_list_entity_header_t header; /**< config entity header */ 00186 uint32_t u; /**< uint value */ 00187 } config_list_uint_entity_t; 00188 00189 /** Config list int entity. */ 00190 typedef struct { 00191 config_list_entity_header_t header; /**< config entity header */ 00192 int32_t i; /**< float value */ 00193 } config_list_int_entity_t; 00194 00195 /** Config list bool entity. */ 00196 typedef struct { 00197 config_list_entity_header_t header; /**< config entity header */ 00198 int32_t b; /**< 0 is false, everything else is true */ 00199 } config_list_bool_entity_t; 00200 00201 /** Config list string entity. */ 00202 typedef struct { 00203 config_list_entity_header_t header; /**< config entity header */ 00204 uint16_t s_length; /**< length of following string value */ 00205 char s[2]; /**< string value, 0-terminated */ 00206 } config_list_string_entity_t; 00207 00208 /** Config list comment entity. */ 00209 typedef struct { 00210 config_list_entity_header_t header; /**< config entity header */ 00211 uint16_t s_length; /**< Length of following comment string */ 00212 char s[2]; /**< Comment value, 0-terminated */ 00213 } config_list_comment_entity_t; 00214 00215 } // end namespace fawkes 00216 00217 #pragma pack(pop) 00218 00219 #endif