Annotation of embedaddon/bird/conf/conf.h, revision 1.1.1.2

1.1       misho       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"
1.1.1.2 ! misho      14: #include "lib/hash.h"
1.1       misho      15: 
                     16: 
                     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) */
                     23:   list tables;                         /* Configured routing tables (struct rtable_config) */
                     24:   list roa_tables;                     /* Configured ROA tables (struct roa_table_config) */
                     25:   list logfiles;                       /* Configured log files (sysdep) */
                     26: 
                     27:   int mrtdump_file;                    /* Configured MRTDump file (sysdep, fd in unix) */
                     28:   char *syslog_name;                   /* Name used for syslog (NULL -> no syslog) */
                     29:   struct rtable_config *master_rtc;    /* Configuration of master routing table */
                     30:   struct iface_patt *router_id_from;   /* Configured list of router ID iface patterns */
                     31: 
                     32:   u32 router_id;                       /* Our Router ID */
                     33:   ip_addr listen_bgp_addr;             /* Listening BGP socket should use this address */
                     34:   unsigned listen_bgp_port;            /* Listening BGP socket should use this port (0 is default) */
                     35:   u32 listen_bgp_flags;                        /* Listening BGP socket should use these flags */
                     36:   unsigned proto_default_debug;                /* Default protocol debug mask */
                     37:   unsigned proto_default_mrtdump;      /* Default protocol mrtdump mask */
                     38:   struct timeformat tf_route;          /* Time format for 'show route' */
                     39:   struct timeformat tf_proto;          /* Time format for 'show protocol' */
                     40:   struct timeformat tf_log;            /* Time format for the logfile */
                     41:   struct timeformat tf_base;           /* Time format for other purposes */
                     42:   u32 gr_wait;                         /* Graceful restart wait timeout */
                     43: 
                     44:   int cli_debug;                       /* Tracing of CLI connections and commands */
                     45:   int latency_debug;                   /* I/O loop tracks duration of each event */
                     46:   u32 latency_limit;                   /* Events with longer duration are logged (us) */
                     47:   u32 watchdog_warning;                        /* I/O loop watchdog limit for warning (us) */
                     48:   u32 watchdog_timeout;                        /* Watchdog timeout (in seconds, 0 = disabled) */
                     49:   char *err_msg;                       /* Parser error message */
                     50:   int err_lino;                                /* Line containing error */
1.1.1.2 ! misho      51:   int err_chno;                                /* Character where the parser stopped */
1.1       misho      52:   char *err_file_name;                 /* File name containing error */
                     53:   char *file_name;                     /* Name of main configuration file */
                     54:   int file_fd;                         /* File descriptor of main configuration file */
1.1.1.2 ! misho      55:   HASH(struct symbol) sym_hash;                /* Lexer: symbol hash table */
        !            56:   struct config *fallback;             /* Link to regular config for CLI parsing */
1.1       misho      57:   int obstacle_count;                  /* Number of items blocking freeing of this config */
                     58:   int shutdown;                                /* This is a pseudo-config for daemon shutdown */
                     59:   bird_clock_t load_time;              /* When we've got this configuration */
                     60: };
                     61: 
                     62: /* Please don't use these variables in protocols. Use proto_config->global instead. */
                     63: extern struct config *config;          /* Currently active configuration */
                     64: extern struct config *new_config;      /* Configuration being parsed */
                     65: 
                     66: struct config *config_alloc(const byte *name);
                     67: int config_parse(struct config *);
                     68: int cli_parse(struct config *);
                     69: void config_free(struct config *);
                     70: int config_commit(struct config *, int type, int timeout);
                     71: int config_confirm(void);
                     72: int config_undo(void);
                     73: void config_init(void);
                     74: void cf_error(char *msg, ...) NORET;
                     75: void config_add_obstacle(struct config *);
                     76: void config_del_obstacle(struct config *);
                     77: void order_shutdown(void);
                     78: 
                     79: #define RECONFIG_NONE  0
                     80: #define RECONFIG_HARD  1
                     81: #define RECONFIG_SOFT  2
                     82: #define RECONFIG_UNDO  3
                     83: 
                     84: #define CONF_DONE      0
                     85: #define CONF_PROGRESS  1
                     86: #define CONF_QUEUED    2
                     87: #define CONF_UNQUEUED  3
                     88: #define CONF_CONFIRM   4
                     89: #define CONF_SHUTDOWN  -1
                     90: #define CONF_NOTHING   -2
                     91: 
                     92: 
                     93: /* Pools */
                     94: 
                     95: extern linpool *cfg_mem;
                     96: 
                     97: #define cfg_alloc(size) lp_alloc(cfg_mem, size)
                     98: #define cfg_allocu(size) lp_allocu(cfg_mem, size)
                     99: #define cfg_allocz(size) lp_allocz(cfg_mem, size)
                    100: char *cfg_strdup(const char *c);
                    101: void cfg_copy_list(list *dest, list *src, unsigned node_size);
                    102: 
                    103: /* Lexer */
                    104: 
                    105: extern int (*cf_read_hook)(byte *buf, uint max, int fd);
                    106: 
                    107: struct symbol {
                    108:   struct symbol *next;
                    109:   struct sym_scope *scope;
                    110:   int class;
                    111:   int aux;
                    112:   void *aux2;
                    113:   void *def;
                    114:   char name[1];
                    115: };
                    116: 
1.1.1.2 ! misho     117: struct sym_scope {
        !           118:   struct sym_scope *next;              /* Next on scope stack */
        !           119:   struct symbol *name;                 /* Name of this scope */
        !           120:   int active;                          /* Currently entered */
        !           121: };
        !           122: 
1.1       misho     123: #define SYM_MAX_LEN 64
                    124: 
                    125: /* Remember to update cf_symbol_class_name() */
                    126: #define SYM_VOID 0
                    127: #define SYM_PROTO 1
                    128: #define SYM_TEMPLATE 2
                    129: #define SYM_FUNCTION 3
                    130: #define SYM_FILTER 4
                    131: #define SYM_TABLE 5
                    132: #define SYM_ROA 6
                    133: 
                    134: #define SYM_VARIABLE 0x100     /* 0x100-0x1ff are variable types */
                    135: #define SYM_CONSTANT 0x200     /* 0x200-0x2ff are variable types */
                    136: 
                    137: #define SYM_TYPE(s) (((struct f_val *) (s)->def)->type)
                    138: #define SYM_VAL(s) (((struct f_val *) (s)->def)->val)
                    139: 
                    140: struct include_file_stack {
                    141:   void *buffer;                                /* Internal lexer state */
                    142:   char *file_name;                     /* File name */
                    143:   int fd;                              /* File descriptor */
                    144:   int lino;                            /* Current line num */
1.1.1.2 ! misho     145:   int chno;                            /* Current char num (on current line) */
        !           146:   int toklen;                          /* Current token length */
1.1       misho     147:   int depth;                           /* Include depth, 0 = cannot include */
                    148: 
                    149:   struct include_file_stack *prev;     /* Previous record in stack */
                    150:   struct include_file_stack *up;       /* Parent (who included this file) */
                    151: };
                    152: 
                    153: extern struct include_file_stack *ifs;
                    154: 
                    155: int cf_lex(void);
                    156: void cf_lex_init(int is_cli, struct config *c);
                    157: void cf_lex_unwind(void);
                    158: 
                    159: struct symbol *cf_find_symbol(struct config *cfg, byte *c);
                    160: 
                    161: struct symbol *cf_get_symbol(byte *c);
                    162: struct symbol *cf_default_name(char *template, int *counter);
                    163: struct symbol *cf_define_symbol(struct symbol *symbol, int type, void *def);
                    164: void cf_push_scope(struct symbol *);
                    165: void cf_pop_scope(void);
                    166: char *cf_symbol_class_name(struct symbol *sym);
                    167: 
                    168: static inline int cf_symbol_is_constant(struct symbol *sym)
                    169: { return (sym->class & 0xff00) == SYM_CONSTANT; }
                    170: 
                    171: 
                    172: /* Parser */
                    173: 
                    174: int cf_parse(void);
                    175: 
                    176: /* Sysdep hooks */
                    177: 
                    178: void sysdep_preconfig(struct config *);
                    179: int sysdep_commit(struct config *, struct config *);
                    180: void sysdep_shutdown_done(void);
                    181: 
                    182: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>