]>
Commit | Line | Data |
---|---|---|
fe7cec12 MM |
1 | /* |
2 | * BIRD Internet Routing Daemon -- Configuration File Handling | |
3 | * | |
50fe90ed | 4 | * (c) 1998--2000 Martin Mares <mj@ucw.cz> |
fe7cec12 MM |
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" | |
43270902 | 13 | #include "lib/timer.h" |
fe7cec12 | 14 | |
31b3e1bb MM |
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) */ | |
4107df1d | 21 | list tables; /* Configured routing tables (struct rtable_config) */ |
7c0cc76e | 22 | list logfiles; /* Configured log fils (sysdep) */ |
4107df1d | 23 | struct rtable_config *master_rtc; /* Configuration of master routing table */ |
31b3e1bb | 24 | u32 router_id; /* Our Router ID */ |
f30b86f9 | 25 | unsigned int proto_default_debug; /* Default protocol debug mask */ |
4761efdb | 26 | int cli_debug; /* Tracing of CLI connections and commands */ |
31b3e1bb MM |
27 | char *err_msg; /* Parser error message */ |
28 | int err_lino; /* Line containing error */ | |
29 | char *file_name; /* Name of configuration file */ | |
c9aae7f4 MM |
30 | struct symbol **sym_hash; /* Lexer: symbol hash table */ |
31 | struct symbol **sym_fallback; /* Lexer: fallback symbol hash table */ | |
50fe90ed | 32 | int obstacle_count; /* Number of items blocking freeing of this config */ |
bf8558bc | 33 | int shutdown; /* This is a pseudo-config for daemon shutdown */ |
43270902 | 34 | bird_clock_t load_time; /* When we've got this configuration */ |
31b3e1bb MM |
35 | }; |
36 | ||
31b3e1bb | 37 | /* Please don't use these variables in protocols. Use proto_config->global instead. */ |
50fe90ed MM |
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 */ | |
31b3e1bb | 42 | |
bf8558bc | 43 | extern int shutting_down; |
43270902 | 44 | extern bird_clock_t boot_time; |
bf8558bc | 45 | |
31b3e1bb MM |
46 | struct config *config_alloc(byte *name); |
47 | int config_parse(struct config *); | |
bc2fb680 | 48 | int cli_parse(struct config *); |
31b3e1bb | 49 | void config_free(struct config *); |
50fe90ed | 50 | int config_commit(struct config *); |
31b3e1bb | 51 | void cf_error(char *msg, ...) NORET; |
50fe90ed MM |
52 | void config_add_obstacle(struct config *); |
53 | void config_del_obstacle(struct config *); | |
bf8558bc | 54 | void order_shutdown(void); |
50fe90ed MM |
55 | |
56 | #define CONF_DONE 0 | |
57 | #define CONF_PROGRESS 1 | |
58 | #define CONF_QUEUED 2 | |
bf8558bc | 59 | #define CONF_SHUTDOWN 3 |
31b3e1bb | 60 | |
49e4a4d1 MM |
61 | /* Pools */ |
62 | ||
b35d72ac | 63 | extern linpool *cfg_mem; |
fe7cec12 | 64 | |
b35d72ac MM |
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); | |
49e4a4d1 | 69 | |
fe7cec12 MM |
70 | /* Lexer */ |
71 | ||
72 | extern int (*cf_read_hook)(byte *buf, unsigned int max); | |
73 | ||
74 | struct symbol { | |
75 | struct symbol *next; | |
c8f61a01 | 76 | struct sym_scope *scope; |
fe7cec12 | 77 | int class; |
0b62c3a7 | 78 | int aux; |
6542ece9 | 79 | void *aux2; |
fe7cec12 MM |
80 | void *def; |
81 | char name[1]; | |
82 | }; | |
83 | ||
c0b2f646 | 84 | /* Remember to update cf_symbol_class_name() */ |
fe7cec12 | 85 | #define SYM_VOID 0 |
8450be97 | 86 | #define SYM_PROTO 1 |
0b62c3a7 | 87 | #define SYM_NUMBER 2 |
cbc31830 MM |
88 | #define SYM_FUNCTION 3 |
89 | #define SYM_FILTER 4 | |
90 | #define SYM_TABLE 5 | |
e3f2d5fc | 91 | #define SYM_IPA 6 |
fe7cec12 | 92 | |
cbc31830 | 93 | #define SYM_VARIABLE 0x100 /* 0x100-0x1ff are variable types */ |
ba921648 | 94 | |
31b3e1bb MM |
95 | extern int conf_lino; |
96 | ||
fe7cec12 | 97 | int cf_lex(void); |
bc2fb680 | 98 | void cf_lex_init(int is_cli); |
4107df1d | 99 | struct symbol *cf_find_symbol(byte *c); |
d272fe22 | 100 | struct symbol *cf_default_name(char *template, int *counter); |
04dc62a0 | 101 | struct symbol *cf_define_symbol(struct symbol *symbol, int type, void *def); |
df8b85e3 MM |
102 | void cf_push_scope(struct symbol *); |
103 | void cf_pop_scope(void); | |
4b87e256 MM |
104 | struct symbol *cf_walk_symbols(struct config *cf, struct symbol *sym, int *pos); |
105 | char *cf_symbol_class_name(struct symbol *sym); | |
fe7cec12 MM |
106 | |
107 | /* Parser */ | |
108 | ||
109 | int cf_parse(void); | |
110 | ||
7c0cc76e MM |
111 | /* Sysdep hooks */ |
112 | ||
113 | void sysdep_preconfig(struct config *); | |
50fe90ed | 114 | int sysdep_commit(struct config *, struct config *); |
bf8558bc | 115 | void sysdep_shutdown_done(void); |
7c0cc76e | 116 | |
fe7cec12 | 117 | #endif |