]>
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 | |
48ec367a OF |
15 | #define BIRD_FNAME_MAX 255 /* Would be better to use some UNIX define */ |
16 | ||
31b3e1bb MM |
17 | /* Configuration structure */ |
18 | ||
19 | struct config { | |
20 | pool *pool; /* Pool the configuration is stored in */ | |
21 | linpool *mem; /* Linear pool containing configuration data */ | |
22 | list protos; /* Configured protocol instances (struct proto_config) */ | |
4107df1d | 23 | list tables; /* Configured routing tables (struct rtable_config) */ |
7c0cc76e | 24 | list logfiles; /* Configured log fils (sysdep) */ |
cf31112f | 25 | int mrtdump_file; /* Configured MRTDump file (sysdep, fd in unix) */ |
44d4ab7a | 26 | char *syslog_name; /* Name used for syslog (NULL -> no syslog) */ |
4107df1d | 27 | struct rtable_config *master_rtc; /* Configuration of master routing table */ |
cf31112f | 28 | |
31b3e1bb | 29 | u32 router_id; /* Our Router ID */ |
d72cdff4 OZ |
30 | ip_addr listen_bgp_addr; /* Listening BGP socket should use this address */ |
31 | unsigned listen_bgp_port; /* Listening BGP socket should use this port (0 is default) */ | |
32 | u32 listen_bgp_flags; /* Listening BGP socket should use these flags */ | |
cf31112f OZ |
33 | unsigned proto_default_debug; /* Default protocol debug mask */ |
34 | unsigned proto_default_mrtdump; /* Default protocol mrtdump mask */ | |
c37e7851 OZ |
35 | struct timeformat tf_route; /* Time format for 'show route' */ |
36 | struct timeformat tf_proto; /* Time format for 'show protocol' */ | |
37 | struct timeformat tf_log; /* Time format for the logfile */ | |
38 | struct timeformat tf_base; /* Time format for other purposes */ | |
39 | ||
4761efdb | 40 | int cli_debug; /* Tracing of CLI connections and commands */ |
31b3e1bb MM |
41 | char *err_msg; /* Parser error message */ |
42 | int err_lino; /* Line containing error */ | |
48ec367a OF |
43 | char *err_file_name; /* File name containing error */ |
44 | char *file_name; /* Name of main configuration file */ | |
45 | int file_fd; /* File descriptor of main configuration file */ | |
c9aae7f4 MM |
46 | struct symbol **sym_hash; /* Lexer: symbol hash table */ |
47 | struct symbol **sym_fallback; /* Lexer: fallback symbol hash table */ | |
50fe90ed | 48 | int obstacle_count; /* Number of items blocking freeing of this config */ |
bf8558bc | 49 | int shutdown; /* This is a pseudo-config for daemon shutdown */ |
43270902 | 50 | bird_clock_t load_time; /* When we've got this configuration */ |
31b3e1bb MM |
51 | }; |
52 | ||
31b3e1bb | 53 | /* Please don't use these variables in protocols. Use proto_config->global instead. */ |
50fe90ed MM |
54 | extern struct config *config; /* Currently active configuration */ |
55 | extern struct config *new_config; /* Configuration being parsed */ | |
56 | extern struct config *old_config; /* Old configuration when reconfiguration is in progress */ | |
57 | extern struct config *future_config; /* New config held here if recon requested during recon */ | |
31b3e1bb | 58 | |
bf8558bc | 59 | extern int shutting_down; |
43270902 | 60 | extern bird_clock_t boot_time; |
bf8558bc | 61 | |
31b3e1bb MM |
62 | struct config *config_alloc(byte *name); |
63 | int config_parse(struct config *); | |
bc2fb680 | 64 | int cli_parse(struct config *); |
31b3e1bb | 65 | void config_free(struct config *); |
bf1aec97 OZ |
66 | int config_commit(struct config *, int type); |
67 | #define RECONFIG_HARD 0 | |
68 | #define RECONFIG_SOFT 1 | |
31b3e1bb | 69 | void cf_error(char *msg, ...) NORET; |
50fe90ed MM |
70 | void config_add_obstacle(struct config *); |
71 | void config_del_obstacle(struct config *); | |
bf8558bc | 72 | void order_shutdown(void); |
50fe90ed MM |
73 | |
74 | #define CONF_DONE 0 | |
75 | #define CONF_PROGRESS 1 | |
76 | #define CONF_QUEUED 2 | |
bf8558bc | 77 | #define CONF_SHUTDOWN 3 |
31b3e1bb | 78 | |
49e4a4d1 MM |
79 | /* Pools */ |
80 | ||
b35d72ac | 81 | extern linpool *cfg_mem; |
fe7cec12 | 82 | |
b35d72ac MM |
83 | #define cfg_alloc(size) lp_alloc(cfg_mem, size) |
84 | #define cfg_allocu(size) lp_allocu(cfg_mem, size) | |
85 | #define cfg_allocz(size) lp_allocz(cfg_mem, size) | |
86 | char *cfg_strdup(char *c); | |
a7f23f58 | 87 | void cfg_copy_list(list *dest, list *src, unsigned node_size); |
49e4a4d1 | 88 | |
fe7cec12 MM |
89 | /* Lexer */ |
90 | ||
48ec367a OF |
91 | extern int (*cf_read_hook)(byte *buf, unsigned int max, int fd); |
92 | extern int (*cf_open_hook)(char *filename); | |
fe7cec12 MM |
93 | |
94 | struct symbol { | |
95 | struct symbol *next; | |
c8f61a01 | 96 | struct sym_scope *scope; |
fe7cec12 | 97 | int class; |
0b62c3a7 | 98 | int aux; |
083c43e2 | 99 | void *aux2; |
fe7cec12 MM |
100 | void *def; |
101 | char name[1]; | |
102 | }; | |
103 | ||
c0b2f646 | 104 | /* Remember to update cf_symbol_class_name() */ |
fe7cec12 | 105 | #define SYM_VOID 0 |
8450be97 | 106 | #define SYM_PROTO 1 |
0b62c3a7 | 107 | #define SYM_NUMBER 2 |
cbc31830 MM |
108 | #define SYM_FUNCTION 3 |
109 | #define SYM_FILTER 4 | |
110 | #define SYM_TABLE 5 | |
e3f2d5fc | 111 | #define SYM_IPA 6 |
a7f23f58 | 112 | #define SYM_TEMPLATE 7 |
fe7cec12 | 113 | |
cbc31830 | 114 | #define SYM_VARIABLE 0x100 /* 0x100-0x1ff are variable types */ |
ba921648 | 115 | |
48ec367a OF |
116 | struct include_file_stack { |
117 | void *stack; /* Internal lexer state */ | |
118 | unsigned int conf_lino; /* Current file lineno (at include) */ | |
119 | char conf_fname[BIRD_FNAME_MAX]; /* Current file name */ | |
120 | int conf_fd; /* Current file descriptor */ | |
121 | struct include_file_stack *prev; | |
122 | struct include_file_stack *next; | |
123 | }; | |
124 | ||
9b7fdfc8 | 125 | extern struct include_file_stack *ifs; |
48ec367a | 126 | |
31b3e1bb | 127 | |
fe7cec12 | 128 | int cf_lex(void); |
48ec367a | 129 | void cf_lex_init(int is_cli, struct config *c); |
4107df1d | 130 | struct symbol *cf_find_symbol(byte *c); |
d272fe22 | 131 | struct symbol *cf_default_name(char *template, int *counter); |
04dc62a0 | 132 | struct symbol *cf_define_symbol(struct symbol *symbol, int type, void *def); |
df8b85e3 MM |
133 | void cf_push_scope(struct symbol *); |
134 | void cf_pop_scope(void); | |
4b87e256 MM |
135 | struct symbol *cf_walk_symbols(struct config *cf, struct symbol *sym, int *pos); |
136 | char *cf_symbol_class_name(struct symbol *sym); | |
fe7cec12 MM |
137 | |
138 | /* Parser */ | |
139 | ||
140 | int cf_parse(void); | |
141 | ||
7c0cc76e MM |
142 | /* Sysdep hooks */ |
143 | ||
144 | void sysdep_preconfig(struct config *); | |
50fe90ed | 145 | int sysdep_commit(struct config *, struct config *); |
bf8558bc | 146 | void sysdep_shutdown_done(void); |
7c0cc76e | 147 | |
fe7cec12 | 148 | #endif |