00001 /*! \file config.h
00002 Header file for config.c.
00003 */
00004
00005 #ifdef __cplusplus
00006 extern "C" {
00007 #endif
00008
00009 #ifndef CONFIG_HD
00010
00011 /*! \brief Maximum number of modems' configuration records.
00012 */
00013
00014 #define MODEM_CONF_MAX_ENTRY 256
00015
00016 /*! \brief Maximum number of bytes (including the final 0) for the buffer used to store the constructor's signature.
00017 */
00018
00019 #define MODEM_CONF_IDENTIFIER_SIZE 7
00020
00021 /*! \brief Maximum number of bytes (including the final 0) for the label that represents the constructor.
00022 */
00023
00024 #define MODEM_CONF_TAG_NAME_SIZE 256
00025
00026 /*! \brief Maximum number of bytes (including the final 0) for the auto-configuration tag ("yes" or "no").
00027 */
00028
00029 #define MODEM_CONF_AUTOCONF_SIZE 4
00030
00031 /*! \brief Maximum number of bytes (including the final 0) for the path to the dinamically loadable module
00032 that implements the calculation of the MAC address.
00033 */
00034
00035 #define MODEM_CONF_ACTION_SIZE 256
00036
00037
00038 /*! \brief This structure contains the modems' configuration data.
00039 */
00040
00041 struct modem_conf_struct {
00042 /*! \brief Modem's ID (this is the index in the array).
00043 */
00044
00045 int id;
00046
00047 /*! \brief 6 first bytes of the modem's MAC address. This is called the manufacturor's sugnature.
00048 */
00049
00050 char identifier[MODEM_CONF_IDENTIFIER_SIZE];
00051
00052 /*! \brief Arbitrary string that represents the modem's constructor. This is the trademark.
00053 */
00054
00055 char tag_name[MODEM_CONF_TAG_NAME_SIZE];
00056
00057 /*! \brief This string represents the auto-configuration capability. Value can be:
00058 <ul>
00059 <li>"yes": the modem suports auto-configuration.
00060 <li>"no": the modem does not support auto-configuration.
00061 </ul>
00062 */
00063
00064 char autoconf[MODEM_CONF_AUTOCONF_SIZE];
00065
00066 /*! \brief Path to the dinamically loadable module used to process the MAC address.
00067 */
00068
00069 char action[MODEM_CONF_ACTION_SIZE];
00070
00071 /*! \brief Handle to the dinamically loadable module.
00072 */
00073
00074 void *dll;
00075
00076 /*! \brief Pointer to the function (within the dinamically loadable module) that is called to
00077 process the MAC address.
00078 */
00079
00080 char* (*calculate_mac_address)(char*);
00081 };
00082
00083
00084 #ifdef PRIVATE_CODE_ONLY
00085
00086 /*! \brief Thei FLEX configuration file is not valid.
00087 */
00088
00089 #define CONF_PARSER_SYNTAX_ERROR -1
00090
00091 /*! \brief The FLEX configuration parser could not allocate memory.
00092 */
00093
00094 #define CONF_PARSER_NO_MEM -2
00095
00096 /*! \brief The FLEX configuration parser found a duplicated tag in the configuration file.
00097 */
00098
00099 #define CONF_PARSER_DUPLICATED_TAG -3
00100
00101 /*! \brief The FLEX configuration parser found a modem's manufacturor MAC signature that is too long.
00102 */
00103
00104 #define CONF_PARSER_IDENTIFIER_TOO_LONG -4
00105
00106 /*! \brief The FLEX configuration parser found a modem's manufacturor label that is too long.
00107 */
00108
00109 #define CONF_PARSER_TAG_NAME_TOO_LONG -5
00110
00111 /*! \brief The FLEX configuration parser found a modem's autoconfiguration tag that is too long.
00112 */
00113
00114 #define CONF_PARSER_AUTOCONF_TOO_LONG -6
00115
00116 /*! \brief The FLEX configuration parser found a modem's plugins that is too long.
00117 */
00118
00119 #define CONF_PARSER_ACTION_TOO_LONG -7
00120
00121 /*! \brief the configuration file contains too many modem's information.
00122 */
00123
00124 #define CONF_PARSER_TOO_MANY_ENTRIES -8
00125
00126 /*! \brief The configuration file has been successfully parsed.
00127 */
00128
00129 #define CONF_PARSER_OK 0
00130
00131 /*! \brief Data structure used to store the couples (tag, value).
00132 */
00133
00134 struct user_data {
00135 char *tag;
00136 char *value;
00137 };
00138
00139 #endif
00140
00141 /*! \brief configuration parser could not open the configuration file.
00142 */
00143
00144 #define PARSE_CONFIGURATION_FILE_NOT_FOUND -1
00145
00146 /*! \brief configuration parser could not allocate memory.
00147 */
00148
00149 #define PARSE_CONFIGURATION_NO_MEM -2
00150
00151 /*! \brief configuration parser found an invalid line.
00152 */
00153
00154 #define PARSE_CONFIGURATION_SYNTAX_ERROR -3
00155
00156 /*! \brief configuration parser found a duplicated tag.
00157 */
00158
00159 #define PARSE_CONFIGURATION_DUPLICATED_TAG -4
00160
00161 /*! \brief Could not load the DLL.
00162 */
00163
00164 #define PARSE_CONFIGURATION_DLL_OPEN_ERROR -5
00165
00166 /*! \brief The DLL is not valid.
00167 */
00168
00169 #define PARSE_CONFIGURATION_DLL_INVALID -6
00170
00171 /*! \brief One record that represents a modem's configuration is not valid.
00172 */
00173
00174 #define PARSE_CONFIGURATION_MODEM_CONF_NOT_VALID -7
00175
00176 /*! \brief configuration parser terminated successfully.
00177 */
00178
00179 #define PARSE_CONFIGURATION_OK 0
00180
00181
00182 int parse_configuration_file (char *path, int *err);
00183 void free_all_configuration_data();
00184 int get_value (char *tag, char **value);
00185 char* dummy_mac_processor (char* addr);
00186 char* conf_get_last_error();
00187
00188
00189 int get_number_of_modem_conf();
00190 int modem_conf_get_id (char *mac);
00191 char* modem_conf_get_tag_name (int id);
00192 int modem_conf_is_autoconf (int id);
00193 void* modem_conf_get_function (int id);
00194
00195
00196 #define CONFIG_HD
00197
00198 #endif
00199
00200 #ifdef __cplusplus
00201 }
00202 #endif
00203
1.2.15