]> git.ipfire.org Git - thirdparty/bird.git/blame - conf/conf.h
Add CLI command to test reconfiguration status
[thirdparty/bird.git] / conf / conf.h
CommitLineData
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
9b0a0ba9
OZ
12#include "sysdep/config.h"
13#include "lib/ip.h"
b7761af3 14#include "lib/hash.h"
fe7cec12 15#include "lib/resource.h"
a6f79ca5 16#include "lib/timer.h"
fe7cec12 17
31b3e1bb
MM
18/* Configuration structure */
19
20struct config {
21 pool *pool; /* Pool the configuration is stored in */
22 linpool *mem; /* Linear pool containing configuration data */
23 list protos; /* Configured protocol instances (struct proto_config) */
4107df1d 24 list tables; /* Configured routing tables (struct rtable_config) */
c8cafc8e 25 list logfiles; /* Configured log files (sysdep) */
bd795877 26 list tests; /* Configured unit tests (f_bt_test_suite) */
af582c48 27
cf31112f 28 int mrtdump_file; /* Configured MRTDump file (sysdep, fd in unix) */
44d4ab7a 29 char *syslog_name; /* Name used for syslog (NULL -> no syslog) */
f4a60a9b 30 struct rtable_config *def_tables[NET_MAX]; /* Default routing tables for each network */
79b4e12e 31 struct iface_patt *router_id_from; /* Configured list of router ID iface patterns */
cf31112f 32
31b3e1bb 33 u32 router_id; /* Our Router ID */
cf31112f
OZ
34 unsigned proto_default_debug; /* Default protocol debug mask */
35 unsigned proto_default_mrtdump; /* Default protocol mrtdump mask */
c37e7851
OZ
36 struct timeformat tf_route; /* Time format for 'show route' */
37 struct timeformat tf_proto; /* Time format for 'show protocol' */
38 struct timeformat tf_log; /* Time format for the logfile */
39 struct timeformat tf_base; /* Time format for other purposes */
3e405fb1 40 u32 gr_wait; /* Graceful restart wait timeout (sec) */
c37e7851 41
4761efdb 42 int cli_debug; /* Tracing of CLI connections and commands */
8bcb5fb1
OZ
43 int latency_debug; /* I/O loop tracks duration of each event */
44 u32 latency_limit; /* Events with longer duration are logged (us) */
45 u32 watchdog_warning; /* I/O loop watchdog limit for warning (us) */
46 u32 watchdog_timeout; /* Watchdog timeout (in seconds, 0 = disabled) */
31b3e1bb
MM
47 char *err_msg; /* Parser error message */
48 int err_lino; /* Line containing error */
d50b0bc4 49 int err_chno; /* Character where the parser stopped */
48ec367a
OF
50 char *err_file_name; /* File name containing error */
51 char *file_name; /* Name of main configuration file */
52 int file_fd; /* File descriptor of main configuration file */
b7761af3
OZ
53 HASH(struct symbol) sym_hash; /* Lexer: symbol hash table */
54 struct config *fallback; /* Link to regular config for CLI parsing */
e0835db4 55 struct sym_scope *root_scope; /* Scope for root symbols */
50fe90ed 56 int obstacle_count; /* Number of items blocking freeing of this config */
bf8558bc 57 int shutdown; /* This is a pseudo-config for daemon shutdown */
f047271c 58 btime load_time; /* When we've got this configuration */
31b3e1bb
MM
59};
60
31b3e1bb 61/* Please don't use these variables in protocols. Use proto_config->global instead. */
50fe90ed
MM
62extern struct config *config; /* Currently active configuration */
63extern struct config *new_config; /* Configuration being parsed */
bf8558bc 64
9b0a0ba9 65struct config *config_alloc(const char *name);
31b3e1bb 66int config_parse(struct config *);
bc2fb680 67int cli_parse(struct config *);
31b3e1bb 68void config_free(struct config *);
3e405fb1 69int config_commit(struct config *, int type, uint timeout);
a92cf57d
OZ
70int config_confirm(void);
71int config_undo(void);
9106a750
OZ
72int config_status(void);
73btime config_timer_status(void);
a92cf57d 74void config_init(void);
1a7daab1 75void cf_error(const char *msg, ...) NORET;
50fe90ed
MM
76void config_add_obstacle(struct config *);
77void config_del_obstacle(struct config *);
bf8558bc 78void order_shutdown(void);
50fe90ed 79
a92cf57d
OZ
80#define RECONFIG_NONE 0
81#define RECONFIG_HARD 1
82#define RECONFIG_SOFT 2
83#define RECONFIG_UNDO 3
84
85#define CONF_DONE 0
86#define CONF_PROGRESS 1
87#define CONF_QUEUED 2
88#define CONF_UNQUEUED 3
89#define CONF_CONFIRM 4
90#define CONF_SHUTDOWN -1
91#define CONF_NOTHING -2
92
31b3e1bb 93
49e4a4d1
MM
94/* Pools */
95
b35d72ac 96extern linpool *cfg_mem;
fe7cec12 97
b35d72ac
MM
98#define cfg_alloc(size) lp_alloc(cfg_mem, size)
99#define cfg_allocu(size) lp_allocu(cfg_mem, size)
100#define cfg_allocz(size) lp_allocz(cfg_mem, size)
c8cafc8e 101char *cfg_strdup(const char *c);
a7f23f58 102void cfg_copy_list(list *dest, list *src, unsigned node_size);
49e4a4d1 103
fe7cec12
MM
104/* Lexer */
105
ae80a2de 106extern int (*cf_read_hook)(byte *buf, uint max, int fd);
fe7cec12
MM
107
108struct symbol {
109 struct symbol *next;
c8f61a01 110 struct sym_scope *scope;
fe7cec12 111 int class;
0b62c3a7 112 int aux;
083c43e2 113 void *aux2;
fe7cec12
MM
114 void *def;
115 char name[1];
116};
117
b7761af3
OZ
118struct sym_scope {
119 struct sym_scope *next; /* Next on scope stack */
120 struct symbol *name; /* Name of this scope */
121 int active; /* Currently entered */
122};
123
bc7f4e0e
OZ
124#define SYM_MAX_LEN 64
125
c0b2f646 126/* Remember to update cf_symbol_class_name() */
fe7cec12 127#define SYM_VOID 0
8450be97 128#define SYM_PROTO 1
1103b32e 129#define SYM_TEMPLATE 2
cbc31830
MM
130#define SYM_FUNCTION 3
131#define SYM_FILTER 4
132#define SYM_TABLE 5
265419a3 133#define SYM_ATTRIBUTE 6
fe7cec12 134
cbc31830 135#define SYM_VARIABLE 0x100 /* 0x100-0x1ff are variable types */
265419a3 136#define SYM_VARIABLE_RANGE SYM_VARIABLE ... (SYM_VARIABLE | 0xff)
1103b32e 137#define SYM_CONSTANT 0x200 /* 0x200-0x2ff are variable types */
265419a3 138#define SYM_CONSTANT_RANGE SYM_CONSTANT ... (SYM_CONSTANT | 0xff)
1103b32e
OZ
139
140#define SYM_TYPE(s) (((struct f_val *) (s)->def)->type)
141#define SYM_VAL(s) (((struct f_val *) (s)->def)->val)
ba921648 142
48ec367a 143struct include_file_stack {
4be266a9
OZ
144 void *buffer; /* Internal lexer state */
145 char *file_name; /* File name */
146 int fd; /* File descriptor */
147 int lino; /* Current line num */
d50b0bc4
JMM
148 int chno; /* Current char num (on current line) */
149 int toklen; /* Current token length */
4be266a9
OZ
150 int depth; /* Include depth, 0 = cannot include */
151
152 struct include_file_stack *prev; /* Previous record in stack */
153 struct include_file_stack *up; /* Parent (who included this file) */
48ec367a
OF
154};
155
9b7fdfc8 156extern struct include_file_stack *ifs;
48ec367a 157
e0835db4
OZ
158extern struct sym_scope *conf_this_scope;
159
fe7cec12 160int cf_lex(void);
48ec367a 161void cf_lex_init(int is_cli, struct config *c);
0c3d9dac
OZ
162void cf_lex_unwind(void);
163
9b9a7143
OZ
164struct symbol *cf_find_symbol(struct config *cfg, byte *c);
165
166struct symbol *cf_get_symbol(byte *c);
d272fe22 167struct symbol *cf_default_name(char *template, int *counter);
04dc62a0 168struct symbol *cf_define_symbol(struct symbol *symbol, int type, void *def);
df8b85e3
MM
169void cf_push_scope(struct symbol *);
170void cf_pop_scope(void);
4b87e256 171char *cf_symbol_class_name(struct symbol *sym);
fe7cec12 172
b2f00837
OZ
173static inline int cf_symbol_is_constant(struct symbol *sym)
174{ return (sym->class & 0xff00) == SYM_CONSTANT; }
175
176
fe7cec12
MM
177/* Parser */
178
9b0a0ba9 179extern char *cf_text;
fe7cec12
MM
180int cf_parse(void);
181
7c0cc76e
MM
182/* Sysdep hooks */
183
184void sysdep_preconfig(struct config *);
50fe90ed 185int sysdep_commit(struct config *, struct config *);
bf8558bc 186void sysdep_shutdown_done(void);
7c0cc76e 187
fe7cec12 188#endif