conf.h 3.41 KB
Newer Older
1 2 3
/*
 *	BIRD Internet Routing Daemon -- Configuration File Handling
 *
4
 *	(c) 1998--2000 Martin Mares <mj@ucw.cz>
5 6 7 8 9 10 11 12
 *
 *	Can be freely distributed and used under the terms of the GNU GPL.
 */

#ifndef _BIRD_CONF_H_
#define _BIRD_CONF_H_

#include "lib/resource.h"
13
#include "lib/timer.h"
14

15 16 17 18 19 20
/* Configuration structure */

struct config {
  pool *pool;				/* Pool the configuration is stored in */
  linpool *mem;				/* Linear pool containing configuration data */
  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 27 28
  char *err_msg;			/* Parser error message */
  int err_lino;				/* Line containing error */
  char *file_name;			/* Name of configuration file */
29 30
  struct symbol **sym_hash;		/* Lexer: symbol hash table */
  struct symbol **sym_fallback;		/* Lexer: fallback symbol hash table */
31
  int obstacle_count;			/* Number of items blocking freeing of this config */
32
  int shutdown;				/* This is a pseudo-config for daemon shutdown */
33
  bird_clock_t load_time;		/* When we've got this configuration */
34 35 36
};

/* Please don't use these variables in protocols. Use proto_config->global instead. */
37 38 39 40
extern struct config *config;		/* Currently active configuration */
extern struct config *new_config;	/* Configuration being parsed */
extern struct config *old_config;	/* Old configuration when reconfiguration is in progress */
extern struct config *future_config;	/* New config held here if recon requested during recon */
41

42
extern int shutting_down;
43
extern bird_clock_t boot_time;
44

45 46
struct config *config_alloc(byte *name);
int config_parse(struct config *);
47
int cli_parse(struct config *);
48
void config_free(struct config *);
49
int config_commit(struct config *);
50
void cf_error(char *msg, ...) NORET;
51 52
void config_add_obstacle(struct config *);
void config_del_obstacle(struct config *);
53
void order_shutdown(void);
54 55 56 57

#define CONF_DONE 0
#define CONF_PROGRESS 1
#define CONF_QUEUED 2
58
#define CONF_SHUTDOWN 3
59

60 61
/* Pools */

62
extern linpool *cfg_mem;
63

64 65 66 67
#define cfg_alloc(size) lp_alloc(cfg_mem, size)
#define cfg_allocu(size) lp_allocu(cfg_mem, size)
#define cfg_allocz(size) lp_allocz(cfg_mem, size)
char *cfg_strdup(char *c);
68

69 70 71 72 73 74
/* Lexer */

extern int (*cf_read_hook)(byte *buf, unsigned int max);

struct symbol {
  struct symbol *next;
Martin Mareš's avatar
Martin Mareš committed
75
  struct sym_scope *scope;
76
  int class;
77
  int aux;
78
  void *aux2; 
79 80 81 82 83
  void *def;
  char name[1];
};

#define SYM_VOID 0
84
#define SYM_PROTO 1
85
#define SYM_NUMBER 2
Martin Mareš's avatar
Martin Mareš committed
86 87 88
#define SYM_FUNCTION 3
#define SYM_FILTER 4
#define SYM_TABLE 5
89
#define SYM_IPA 6
90

Martin Mareš's avatar
Martin Mareš committed
91
#define SYM_VARIABLE 0x100	/* 0x100-0x1ff are variable types */
92

93 94
extern int conf_lino;

95
int cf_lex(void);
96
void cf_lex_init(int is_cli);
97
struct symbol *cf_find_symbol(byte *c);
98
struct symbol *cf_default_name(char *template, int *counter);
99
void cf_define_symbol(struct symbol *symbol, int type, void *def);
Martin Mareš's avatar
Martin Mareš committed
100 101
void cf_push_scope(struct symbol *);
void cf_pop_scope(void);
102 103
struct symbol *cf_walk_symbols(struct config *cf, struct symbol *sym, int *pos);
char *cf_symbol_class_name(struct symbol *sym);
104 105 106 107 108

/* Parser */

int cf_parse(void);

109 110 111
/* Sysdep hooks */

void sysdep_preconfig(struct config *);
112
int sysdep_commit(struct config *, struct config *);
113
void sysdep_shutdown_done(void);
114

115
#endif