]> git.ipfire.org Git - thirdparty/bird.git/blob - conf/conf.h
Nested scopes could never have worked. My fault I wrote such a buggy code,
[thirdparty/bird.git] / conf / conf.h
1 /*
2 * BIRD Internet Routing Daemon -- Configuration File Handling
3 *
4 * (c) 1998--2000 Martin Mares <mj@ucw.cz>
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
9 #ifndef _BIRD_CONF_H_
10 #define _BIRD_CONF_H_
11
12 #include "lib/resource.h"
13 #include "lib/timer.h"
14
15 /* Configuration structure */
16
17 struct config {
18 pool *pool; /* Pool the configuration is stored in */
19 linpool *mem; /* Linear pool containing configuration data */
20 list protos; /* Configured protocol instances (struct proto_config) */
21 list tables; /* Configured routing tables (struct rtable_config) */
22 list logfiles; /* Configured log fils (sysdep) */
23 struct rtable_config *master_rtc; /* Configuration of master routing table */
24 u32 router_id; /* Our Router ID */
25 unsigned int proto_default_debug; /* Default protocol debug mask */
26 int cli_debug; /* Tracing of CLI connections and commands */
27 char *err_msg; /* Parser error message */
28 int err_lino; /* Line containing error */
29 char *file_name; /* Name of configuration file */
30 struct symbol **sym_hash; /* Lexer: symbol hash table */
31 struct symbol **sym_fallback; /* Lexer: fallback symbol hash table */
32 int obstacle_count; /* Number of items blocking freeing of this config */
33 int shutdown; /* This is a pseudo-config for daemon shutdown */
34 bird_clock_t load_time; /* When we've got this configuration */
35 };
36
37 /* Please don't use these variables in protocols. Use proto_config->global instead. */
38 extern struct config *config; /* Currently active configuration */
39 extern struct config *new_config; /* Configuration being parsed */
40 extern struct config *old_config; /* Old configuration when reconfiguration is in progress */
41 extern struct config *future_config; /* New config held here if recon requested during recon */
42
43 extern int shutting_down;
44 extern bird_clock_t boot_time;
45
46 struct config *config_alloc(byte *name);
47 int config_parse(struct config *);
48 int cli_parse(struct config *);
49 void config_free(struct config *);
50 int config_commit(struct config *);
51 void cf_error(char *msg, ...) NORET;
52 void config_add_obstacle(struct config *);
53 void config_del_obstacle(struct config *);
54 void order_shutdown(void);
55
56 #define CONF_DONE 0
57 #define CONF_PROGRESS 1
58 #define CONF_QUEUED 2
59 #define CONF_SHUTDOWN 3
60
61 /* Pools */
62
63 extern linpool *cfg_mem;
64
65 #define cfg_alloc(size) lp_alloc(cfg_mem, size)
66 #define cfg_allocu(size) lp_allocu(cfg_mem, size)
67 #define cfg_allocz(size) lp_allocz(cfg_mem, size)
68 char *cfg_strdup(char *c);
69
70 /* Lexer */
71
72 extern int (*cf_read_hook)(byte *buf, unsigned int max);
73
74 struct symbol {
75 struct symbol *next;
76 struct sym_scope *scope;
77 int class;
78 int aux;
79 void *aux2;
80 void *def;
81 char name[1];
82 };
83
84 /* Remember to update cf_symbol_class_name() */
85 #define SYM_VOID 0
86 #define SYM_PROTO 1
87 #define SYM_NUMBER 2
88 #define SYM_FUNCTION 3
89 #define SYM_FILTER 4
90 #define SYM_TABLE 5
91 #define SYM_IPA 6
92
93 #define SYM_VARIABLE 0x100 /* 0x100-0x1ff are variable types */
94
95 extern int conf_lino;
96
97 int cf_lex(void);
98 void cf_lex_init(int is_cli);
99 struct symbol *cf_find_symbol(byte *c);
100 struct symbol *cf_default_name(char *template, int *counter);
101 struct symbol *cf_define_symbol(struct symbol *symbol, int type, void *def);
102 void cf_push_scope(struct symbol *);
103 void cf_pop_scope(void);
104 struct symbol *cf_walk_symbols(struct config *cf, struct symbol *sym, int *pos);
105 char *cf_symbol_class_name(struct symbol *sym);
106
107 /* Parser */
108
109 int cf_parse(void);
110
111 /* Sysdep hooks */
112
113 void sysdep_preconfig(struct config *);
114 int sysdep_commit(struct config *, struct config *);
115 void sysdep_shutdown_done(void);
116
117 #endif