File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / bird2 / sysdep / unix / config.Y
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Mon Oct 21 16:03:56 2019 UTC (5 years, 5 months ago) by misho
Branches: bird2, MAIN
CVS tags: v2_0_7p0, HEAD
bird2 ver 2.0.7

    1: /*
    2:  *	BIRD -- UNIX Configuration
    3:  *
    4:  *	(c) 1999--2000 Martin Mares <mj@ucw.cz>
    5:  *
    6:  *	Can be freely distributed and used under the terms of the GNU GPL.
    7:  */
    8: 
    9: CF_HDR
   10: 
   11: #include "sysdep/unix/unix.h"
   12: #include <stdio.h>
   13: 
   14: CF_DEFINES
   15: 
   16: static struct log_config *this_log;
   17: 
   18: CF_DECLS
   19: 
   20: CF_KEYWORDS(LOG, SYSLOG, ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG, STDERR, SOFT)
   21: CF_KEYWORDS(NAME, CONFIRM, UNDO, CHECK, TIMEOUT, DEBUG, LATENCY, LIMIT, WATCHDOG, WARNING, STATUS)
   22: CF_KEYWORDS(GRACEFUL, RESTART)
   23: 
   24: %type <i> log_mask log_mask_list log_cat cfg_timeout
   25: %type <t> cfg_name
   26: %type <tf> timeformat_which
   27: %type <t> syslog_name
   28: 
   29: CF_GRAMMAR
   30: 
   31: conf: log_config ;
   32: 
   33: log_begin: { this_log = cfg_allocz(sizeof(struct log_config)); };
   34: 
   35: log_config: LOG log_begin log_file log_mask ';' {
   36:     this_log->mask = $4;
   37:     add_tail(&new_config->logfiles, &this_log->n);
   38:   }
   39:  ;
   40: 
   41: syslog_name:
   42:    NAME text { $$ = $2; }
   43:  | { $$ = bird_name; }
   44:  ;
   45: 
   46: log_limit:
   47:    /* empty */
   48:  | expr text { this_log->limit = $1; this_log->backup = $2; }
   49:  ;
   50: 
   51: log_file:
   52:    text log_limit {
   53:      this_log->rf = rf_open(new_config->pool, $1, "a");
   54:      if (!this_log->rf) cf_error("Unable to open log file '%s': %m", $1);
   55:      this_log->fh = rf_file(this_log->rf);
   56:      this_log->pos = -1;
   57:      this_log->filename = $1;
   58:    }
   59:  | SYSLOG syslog_name { this_log->fh = NULL; new_config->syslog_name = $2; }
   60:  | STDERR { this_log->fh = stderr; }
   61:  ;
   62: 
   63: log_mask:
   64:    ALL { $$ = ~0; }
   65:  | '{' log_mask_list '}' { $$ = $2; }
   66:  ;
   67: 
   68: log_mask_list:
   69:    log_cat { $$ = 1 << $1; }
   70:  | log_mask_list ',' log_cat { $$ = $1 | (1 << $3); }
   71:  ;
   72: 
   73: log_cat:
   74:    DEBUG { $$ = L_DEBUG[0]; }
   75:  | TRACE { $$ = L_TRACE[0]; }
   76:  | INFO { $$ = L_INFO[0]; }
   77:  | REMOTE { $$ = L_REMOTE[0]; }
   78:  | WARNING { $$ = L_WARN[0]; }
   79:  | ERROR { $$ = L_ERR[0]; }
   80:  | AUTH { $$ = L_AUTH[0]; }
   81:  | FATAL { $$ = L_FATAL[0]; }
   82:  | BUG { $$ = L_BUG[0]; }
   83:  ;
   84: 
   85: 
   86: conf: mrtdump_base ;
   87: 
   88: mrtdump_base:
   89:    MRTDUMP PROTOCOLS mrtdump_mask ';' { new_config->proto_default_mrtdump = $3; }
   90:  | MRTDUMP text ';' {
   91:      struct rfile *f = rf_open(new_config->pool, $2, "a");
   92:      if (!f) cf_error("Unable to open MRTDump file '%s': %m", $2);
   93:      new_config->mrtdump_file = rf_fileno(f);
   94:    }
   95:  ;
   96: 
   97: 
   98: conf: debug_unix ;
   99: 
  100: debug_unix:
  101:    DEBUG LATENCY bool { new_config->latency_debug = $3; }
  102:  | DEBUG LATENCY LIMIT expr_us { new_config->latency_limit = $4; }
  103:  | WATCHDOG WARNING expr_us { new_config->watchdog_warning = $3; }
  104:  | WATCHDOG TIMEOUT expr_us { new_config->watchdog_timeout = ($3 + 999999) TO_S; }
  105:  ;
  106: 
  107: 
  108: /* Unix specific commands */
  109: 
  110: CF_CLI_HELP(CONFIGURE, ..., [[Reload configuration]])
  111: 
  112: CF_CLI(CONFIGURE, cfg_name cfg_timeout, [\"<file>\"] [timeout [<sec>]], [[Reload configuration]])
  113: { cmd_reconfig($2, RECONFIG_HARD, $3); } ;
  114: 
  115: CF_CLI(CONFIGURE SOFT, cfg_name cfg_timeout, [\"<file>\"] [timeout [<sec>]], [[Reload configuration and ignore changes in filters]])
  116: { cmd_reconfig($3, RECONFIG_SOFT, $4); } ;
  117: 
  118: /* Hack to get input completion for 'timeout' */
  119: CF_CLI_CMD(CONFIGURE TIMEOUT, [<sec>], [[Reload configuration with undo timeout]])
  120: CF_CLI_CMD(CONFIGURE SOFT TIMEOUT, [<sec>], [[Reload configuration with undo timeout]])
  121: 
  122: CF_CLI(CONFIGURE CONFIRM,,, [[Confirm last configuration change - deactivate undo timeout]])
  123: { cmd_reconfig_confirm(); } ;
  124: 
  125: CF_CLI(CONFIGURE UNDO,,, [[Undo last configuration change]])
  126: { cmd_reconfig_undo(); } ;
  127: 
  128: CF_CLI(CONFIGURE STATUS,,, [[Show configuration status]])
  129: { cmd_reconfig_status(); } ;
  130: 
  131: CF_CLI(CONFIGURE CHECK, cfg_name, [\"<file>\"], [[Parse configuration and check its validity]])
  132: { cmd_check_config($3); } ;
  133: 
  134: CF_CLI(DOWN,,, [[Shut the daemon down]])
  135: { cmd_shutdown(); } ;
  136: 
  137: CF_CLI_HELP(GRACEFUL, restart, [[Shut the daemon down for graceful restart]])
  138: 
  139: CF_CLI(GRACEFUL RESTART,,, [[Shut the daemon down for graceful restart]])
  140: { cmd_graceful_restart(); } ;
  141: 
  142: 
  143: cfg_name:
  144:    /* empty */ { $$ = NULL; }
  145:  | TEXT
  146:  ;
  147: 
  148: cfg_timeout:
  149:    /* empty */ { $$ = 0; }
  150:  | TIMEOUT { $$ = UNIX_DEFAULT_CONFIGURE_TIMEOUT; }
  151:  | TIMEOUT expr { $$ = $2; }
  152:  ;
  153: 
  154: CF_CODE
  155: 
  156: CF_END

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