1 | /***************************************
2 | $Revision:
3 |
4 | CA module: definitions header file for the configuration module.
5 |
6 | Status: NOT REVIEWED, NOT TESTED
7 |
8 | Author(s): Ambrose Magee
9 |
10 | ******************/ /******************
11 | Modification History:
12 |
13 | ******************/
14 |
15 | /************************************
16 | Copyright (c) 2000 RIPE NCC
17 |
18 | All Rights Reserved
19 |
20 | Permission to use, copy, modify, and distribute this software and its
21 | documentation for any purpose and without fee is hereby granted,
22 | provided that the above copyright notice appear in all copies and that
23 | both that copyright notice and this permission notice appear in
24 | supporting documentation, and that the name of the author not be
25 | used in advertising or publicity pertaining to distribution of the
26 | software without specific, written prior permission.
27 |
28 | THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
29 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
30 | AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
31 | DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
32 | AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
33 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
34 | ***************************************/
35 |
36 | #ifndef CA_DEFS
37 | #define CA_DEFS
38 |
39 | /************************************************************************
40 | * This is the definitions header file for the configuration module. It
41 | * includes the definitions of data structures, external declarations and
42 | * definitions, definitions of sybolic constants.
43 | *
44 | ************************************************************************/
45 |
46 | #include <pthread.h>
47 | #include <glib.h>
48 |
49 | #ifdef __cplusplus
50 | extern "C" {
51 | #endif
52 |
53 | /* Number of configurations variables. */
54 | #define VARS 120
55 |
56 | #define SCOPE_GLOBAL 1
57 | #define SCOPE_LOCAL 99
58 |
59 | /*
60 | * Define the length of a string to be 160 to cope with the
61 | * copyright statement.
62 | *
63 | */
64 | #define STRLENGTH 256
65 |
66 | /*
67 | * Define the length of strings to cope with the values of
68 | * various types of string variables.
69 | */
70 | #define STRLENGTH_XS 40
71 | #define STRLENGTH_S 80
72 | #define STRLENGTH_M 160
73 | #define STRLENGTH_L 320
74 | #define STRLENGTH_XL 640
75 | #define STRLENGTH_XXL 1280
76 |
77 |
78 | /**********************************************
79 | * Default values for the SOURCE variables *
80 | * *
81 | **********************************************/
82 |
83 | #define CA_DEFHOST "rowan"
84 | #define CA_DEFPORT "4343"
85 | #define CA_DEFUSER "dbase"
86 | #define CA_DEFPASSWORD "encrypt1"
87 | #define CA_DEFDBNAME "default-db"
88 |
89 |
90 |
91 | /**********************************************
92 | * Defintion of the dictionary structures. *
93 | * *
94 | **********************************************/
95 |
96 | typedef struct dict_s {
97 | char varName[STRLENGTH];
98 | char varSym[STRLENGTH];
99 | char varType[STRLENGTH];
100 | int varScope;
101 | int varNum;
102 | } dict_t;
103 |
104 | extern dict_t dictionary[];
105 |
106 |
107 |
108 |
109 | /**********************************************
110 | * Definition of the values structures. *
111 | * *
112 | **********************************************/
113 |
114 | typedef struct values_s {
115 | char *strPtr; /* Pointer to the string that contains the value. */
116 | void *valPtr; /* Pointer to the actual value. */
117 | } values_t;
118 |
119 | /*
120 | * "extern" definition of variables that are defined elsewhere.
121 | */
122 |
123 |
124 | extern values_t globals[];
125 | extern values_t locals[];
126 |
127 | /*
128 | * "extern" definition of configuration variables, defined elsewhere.
129 | */
130 | extern values_t confVars[];
131 |
132 | /* Mutex lock; used for synchronising changes. */
133 | pthread_mutex_t Lock;
134 |
135 | /*
136 | * New value of the bindport.
137 | * This must be a global variable.
138 | */
139 |
140 | char newPort[16];
141 |
142 | /*
143 | * The following is needed for the SOURCE variable. First,
144 | * we define the "database" structure. Then, we define the
145 | * structure of an element of the linked list. Lastly, we
146 | * define the linked list itself.
147 | */
148 |
149 | typedef struct ca_database_s {
150 |
151 | char host[64];
152 | int port;
153 | char user[16];
154 | char password[9];
155 | char dbName[16];
156 | } ca_database_t;
157 |
158 | typedef struct ca_mirror_s {
159 | char host[64];
160 | int port;
161 | char log[64];
162 | int delay;
163 | int protocolVer;
164 | char mrName[16];
165 | } ca_mirror_t;
166 |
167 | typedef struct ca_ripadmin_s {
168 | char host[64];
169 | int port;
170 | char user[16];
171 | char password[9];
172 | char tableName[16];
173 | } ca_ripadmin_t;
174 |
175 | extern ca_database_t ripe;
176 | extern ca_database_t arin;
177 | extern ca_database_t radb;
178 |
179 | typedef struct ca_database_list_s {
180 | char name[16];
181 | ca_database_t db;
182 | int opMode;
183 | ca_mirror_t nrtm;
184 | int updPort;
185 | char canupd[2];
186 | char deflook[2];
187 | } ca_database_list_t;
188 |
189 | /*
190 | * Define the type of a source.
191 | * This is the name of a source and
192 | * the details of the database which
193 | * makes this source.
194 | */
195 | typedef struct ca_dbSource_s {
196 | char name[16];
197 | ca_database_t db;
198 | int opMode;
199 | ca_mirror_t nrtm;
200 | int updPort;
201 | char canupd[2];
202 | char deflook[2];
203 | } ca_dbSource_t;
204 |
205 | /*
206 | * Define the source handle:
207 | * this is a pointer to a source;
208 | * i.e. it is of type ca_dbSource_t.
209 | */
210 | typedef ca_dbSource_t ca_SrcHdl_t;
211 |
212 |
213 | /*
214 | * Define an updateSource. This is used by dbupdate.
215 | *
216 | */
217 | typedef struct ca_updDbSource_s {
218 | char name[16];
219 | ca_database_t updDb;
220 | char whoisd_host[32];
221 | int qryPort;
222 | int updPort;
223 | } ca_updDbSource_t;
224 |
225 |
226 |
227 | extern ca_database_list_t ripeComponent;
228 | extern ca_database_list_t arinComponent;
229 | extern ca_database_list_t radbComponent;
230 |
231 | /*
232 | * typedef struct GSList {
233 | * gpointer src;
234 | * GSList *next;
235 | * } ca_source_t;
236 | */
237 | /* gpointer src; This points to a ca_database_list_t varialbe */
238 |
239 |
240 | /*************************************************************
241 | * Definition of the default values for the SOURCE variable. *
242 | * *
243 | *************************************************************/
244 |
245 | /*
246 | * char ca_defHost[64];
247 | * char ca_defPort[16];
248 | * char ca_defUser[16];
249 | * char ca_defPassword[9];
250 | * char ca_defdbName[16];
251 | */
252 |
253 | /*
254 | * extern char ca_defPort[16];
255 | * extern char ca_defHost[64];
256 | * extern char ca_defUser[16];
257 | * extern char ca_defPassword[9];
258 | * extern char ca_defdbName[16];
259 | */
260 |
261 | /*
262 | * The linked-list of sources.
263 | *
264 | */
265 | extern GSList *sourceList;
266 |
267 | /*
268 | * The linked-list of databases and mirrors used by ca_readSources()
269 | */
270 | extern GSList *dbList;
271 | extern GSList *nrtmList;
272 |
273 | /*
274 | */
275 |
276 | /*
277 | * extern ca_source_t *srcList;
278 | */
279 |
280 | /*
281 | * A varialbe of type GSList
282 | */
283 | extern ca_dbSource_t *testSource;
284 |
285 |
286 | /*
287 | * 20000609
288 | * Experiment:
289 | * define the variable mySrcList as type GSList;
290 | * use the extern modifier and put the "real" definition
291 | * of the variable elsewhere.
292 | *
293 | * extern GSList *mySrcList;
294 | */
295 |
296 | /*
297 | * The test configuration file.
298 | * This is defined using a constant string, cf. Oualline, p.145.
299 | */
300 | extern const char *testFile;
301 | extern const char *tempFile;
302 | extern const char *dictFile;
303 | extern const char *confFile;
304 | extern const char *sourcesFile;
305 |
306 | /*
307 | * Value returned by ca_getStorageLocation if the symbol for
308 | * a configuration variable cannot be found.
309 | *
310 | * This value is also returned by ca_getType, if it cannot map
311 | * the name of a configuration variable to a data type.
312 | *
313 | */
314 | #define NOT_FOUND -1
315 |
316 | /*
317 | * Definition of the identifiers used in the sources configuration file.
318 | */
319 | #define DATABASE_KEY "DATABASE"
320 | #define NRTM_KEY "NRTM"
321 | #define SOURCE_KEY "SOURCE"
322 |
323 | /*
324 | * Symbolic constants defined to represent data types.
325 |
326 | * #define CA_INT 11
327 | * #define CA_STRING 12
328 | * #define CA_DIRLIST 13
329 | * #define CA_BOOLEAN 14
330 | * #define CA_SOURCETYPE 15
331 | */
332 |
333 | extern ca_dbSource_t *theSrc;
334 |
335 | #ifdef __cplusplus
336 | }
337 | #endif
338 |
339 |
340 | #endif /* CA_DEFS */