Annotation of embedaddon/bird2/nest/config.Y, revision 1.1

1.1     ! misho       1: /*
        !             2:  *     BIRD -- Core Configuration
        !             3:  *
        !             4:  *     (c) 1998--2000 Martin Mares <mj@ucw.cz>
        !             5:  *      (c) 2004       Ondrej Filip <feela@network.cz>
        !             6:  *
        !             7:  *     Can be freely distributed and used under the terms of the GNU GPL.
        !             8:  */
        !             9: 
        !            10: CF_HDR
        !            11: 
        !            12: #include "nest/rt-dev.h"
        !            13: #include "nest/password.h"
        !            14: #include "nest/cmds.h"
        !            15: #include "lib/lists.h"
        !            16: #include "lib/mac.h"
        !            17: 
        !            18: CF_DEFINES
        !            19: 
        !            20: static struct proto_config *this_proto;
        !            21: static struct channel_config *this_channel;
        !            22: static struct iface_patt *this_ipatt;
        !            23: static struct iface_patt_node *this_ipn;
        !            24: /* static struct roa_table_config *this_roa_table; */
        !            25: static list *this_p_list;
        !            26: static struct password_item *this_p_item;
        !            27: static int password_id;
        !            28: 
        !            29: static void
        !            30: iface_patt_check(void)
        !            31: {
        !            32:   struct iface_patt_node *pn;
        !            33: 
        !            34:   WALK_LIST(pn, this_ipatt->ipn_list)
        !            35:     if (!pn->pattern || pn->prefix.type)
        !            36:       cf_error("Interface name/mask expected, not IP prefix");
        !            37: }
        !            38: 
        !            39: 
        !            40: static inline void
        !            41: reset_passwords(void)
        !            42: {
        !            43:   this_p_list = NULL;
        !            44: }
        !            45: 
        !            46: static inline list *
        !            47: get_passwords(void)
        !            48: {
        !            49:   list *rv = this_p_list;
        !            50:   this_p_list = NULL;
        !            51:   return rv;
        !            52: }
        !            53: 
        !            54: static void
        !            55: proto_postconfig(void)
        !            56: {
        !            57:   CALL(this_proto->protocol->postconfig, this_proto);
        !            58:   this_channel = NULL;
        !            59:   this_proto = NULL;
        !            60: }
        !            61: 
        !            62: 
        !            63: #define DIRECT_CFG ((struct rt_dev_config *) this_proto)
        !            64: 
        !            65: CF_DECLS
        !            66: 
        !            67: CF_KEYWORDS(ROUTER, ID, PROTOCOL, TEMPLATE, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
        !            68: CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, VRF, DEFAULT, TABLE, STATES, ROUTES, FILTERS)
        !            69: CF_KEYWORDS(IPV4, IPV6, VPN4, VPN6, ROA4, ROA6, FLOW4, FLOW6, SADR, MPLS)
        !            70: CF_KEYWORDS(RECEIVE, LIMIT, ACTION, WARN, BLOCK, RESTART, DISABLE, KEEP, FILTERED)
        !            71: CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES)
        !            72: CF_KEYWORDS(ALGORITHM, KEYED, HMAC, MD5, SHA1, SHA256, SHA384, SHA512)
        !            73: CF_KEYWORDS(PRIMARY, STATS, COUNT, BY, FOR, COMMANDS, PREEXPORT, NOEXPORT, GENERATE)
        !            74: CF_KEYWORDS(BGP, PASSWORDS, DESCRIPTION, SORTED)
        !            75: CF_KEYWORDS(RELOAD, IN, OUT, MRTDUMP, MESSAGES, RESTRICT, MEMORY, IGP_METRIC, CLASS, DSCP)
        !            76: CF_KEYWORDS(TIMEFORMAT, ISO, SHORT, LONG, ROUTE, PROTOCOL, BASE, LOG, S, MS, US)
        !            77: CF_KEYWORDS(GRACEFUL, RESTART, WAIT, MAX, FLUSH, AS)
        !            78: 
        !            79: /* For r_args_channel */
        !            80: CF_KEYWORDS(IPV4, IPV4_MC, IPV4_MPLS, IPV6, IPV6_MC, IPV6_MPLS, IPV6_SADR, VPN4, VPN4_MC, VPN4_MPLS, VPN6, VPN6_MC, VPN6_MPLS, ROA4, ROA6, FLOW4, FLOW6, MPLS, PRI, SEC)
        !            81: 
        !            82: CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT,
        !            83:        RIP, OSPF, OSPF_IA, OSPF_EXT1, OSPF_EXT2, BGP, PIPE, BABEL)
        !            84: CF_ENUM(T_ENUM_SCOPE, SCOPE_, HOST, LINK, SITE, ORGANIZATION, UNIVERSE, UNDEFINED)
        !            85: CF_ENUM(T_ENUM_RTD, RTD_, UNICAST, BLACKHOLE, UNREACHABLE, PROHIBIT)
        !            86: CF_ENUM(T_ENUM_ROA, ROA_, UNKNOWN, VALID, INVALID)
        !            87: 
        !            88: %type <i32> idval
        !            89: %type <f> imexport
        !            90: %type <r> rtable
        !            91: %type <s> optproto
        !            92: %type <ra> r_args
        !            93: %type <sd> sym_args
        !            94: %type <i> proto_start echo_mask echo_size debug_mask debug_list debug_flag mrtdump_mask mrtdump_list mrtdump_flag export_mode limit_action net_type table_sorted tos password_algorithm
        !            95: %type <ps> proto_patt proto_patt2
        !            96: %type <cc> channel_start proto_channel
        !            97: %type <cl> limit_spec
        !            98: %type <net> r_args_for_val
        !            99: %type <net_ptr> r_args_for
        !           100: %type <t> r_args_channel
        !           101: 
        !           102: CF_GRAMMAR
        !           103: 
        !           104: /* Setting of router ID */
        !           105: 
        !           106: conf: rtrid ;
        !           107: 
        !           108: rtrid:
        !           109:    ROUTER ID idval ';' { new_config->router_id = $3; }
        !           110:  | ROUTER ID FROM iface_patt ';' { new_config->router_id_from = this_ipatt; }
        !           111:  ;
        !           112: 
        !           113: idval:
        !           114:    NUM { $$ = $1; }
        !           115:  | '(' term ')' { $$ = f_eval_int(f_linearize($2)); }
        !           116:  | IP4 { $$ = ip4_to_u32($1); }
        !           117:  | CF_SYM_KNOWN {
        !           118:      if ($1->class == (SYM_CONSTANT | T_INT) || $1->class == (SYM_CONSTANT | T_QUAD))
        !           119:        $$ = SYM_VAL($1).i;
        !           120:      else if (($1->class == (SYM_CONSTANT | T_IP)) && ipa_is_ip4(SYM_VAL($1).ip))
        !           121:        $$ = ipa_to_u32(SYM_VAL($1).ip);
        !           122:      else
        !           123:        cf_error("Number or IPv4 address constant expected");
        !           124:    }
        !           125:  ;
        !           126: 
        !           127: conf: gr_opts ;
        !           128: 
        !           129: gr_opts: GRACEFUL RESTART WAIT expr ';' { new_config->gr_wait = $4; } ;
        !           130: 
        !           131: 
        !           132: /* Network types (for tables, channels) */
        !           133: 
        !           134: net_type:
        !           135:    IPV4 { $$ = NET_IP4; }
        !           136:  | IPV6 { $$ = NET_IP6; }
        !           137:  | IPV6 SADR { $$ = NET_IP6_SADR; }
        !           138:  | VPN4 { $$ = NET_VPN4; }
        !           139:  | VPN6 { $$ = NET_VPN6; }
        !           140:  | ROA4 { $$ = NET_ROA4; }
        !           141:  | ROA6 { $$ = NET_ROA6; }
        !           142:  | FLOW4{ $$ = NET_FLOW4; }
        !           143:  | FLOW6{ $$ = NET_FLOW6; }
        !           144:  | MPLS { $$ = NET_MPLS; }
        !           145:  ;
        !           146: 
        !           147: CF_ENUM(T_ENUM_NETTYPE, NET_, IP4, IP6, VPN4, VPN6, ROA4, ROA6, FLOW4, FLOW6, IP6_SADR)
        !           148: 
        !           149: 
        !           150: /* Creation of routing tables */
        !           151: 
        !           152: conf: table ;
        !           153: 
        !           154: table_sorted:
        !           155:          { $$ = 0; }
        !           156:  | SORTED { $$ = 1; }
        !           157:  ;
        !           158: 
        !           159: table: net_type TABLE symbol table_sorted {
        !           160:    struct rtable_config *cf;
        !           161:    cf = rt_new_table($3, $1);
        !           162:    cf->sorted = $4;
        !           163:    }
        !           164:  ;
        !           165: 
        !           166: 
        !           167: /* Definition of protocols */
        !           168: 
        !           169: conf: proto { proto_postconfig(); } ;
        !           170: 
        !           171: proto_start:
        !           172:    PROTOCOL { $$ = SYM_PROTO; }
        !           173:  | TEMPLATE { $$ = SYM_TEMPLATE; }
        !           174:  ;
        !           175: 
        !           176: proto_name:
        !           177:    /* EMPTY */ {
        !           178:      struct symbol *s = cf_default_name(this_proto->protocol->template, &this_proto->protocol->name_counter);
        !           179:      s->class = this_proto->class;
        !           180:      s->proto = this_proto;
        !           181:      this_proto->name = s->name;
        !           182:      }
        !           183:  | symbol {
        !           184:      cf_define_symbol($1, this_proto->class, proto, this_proto);
        !           185:      this_proto->name = $1->name;
        !           186:    }
        !           187:  | FROM CF_SYM_KNOWN {
        !           188:      if (($2->class != SYM_TEMPLATE) && ($2->class != SYM_PROTO)) cf_error("Template or protocol name expected");
        !           189: 
        !           190:      struct symbol *s = cf_default_name(this_proto->protocol->template, &this_proto->protocol->name_counter);
        !           191:      s->class = this_proto->class;
        !           192:      s->proto = this_proto;
        !           193:      this_proto->name = s->name;
        !           194: 
        !           195:      proto_copy_config(this_proto, $2->proto);
        !           196:    }
        !           197:  | symbol FROM CF_SYM_KNOWN {
        !           198:      if (($3->class != SYM_TEMPLATE) && ($3->class != SYM_PROTO)) cf_error("Template or protocol name expected");
        !           199: 
        !           200:      cf_define_symbol($1, this_proto->class, proto, this_proto);
        !           201:      this_proto->name = $1->name;
        !           202: 
        !           203:      proto_copy_config(this_proto, $3->proto);
        !           204:    }
        !           205:  ;
        !           206: 
        !           207: proto_item:
        !           208:    /* EMPTY */
        !           209:  | DISABLED bool { this_proto->disabled = $2; }
        !           210:  | DEBUG debug_mask { this_proto->debug = $2; }
        !           211:  | MRTDUMP mrtdump_mask { this_proto->mrtdump = $2; }
        !           212:  | ROUTER ID idval { this_proto->router_id = $3; }
        !           213:  | DESCRIPTION text { this_proto->dsc = $2; }
        !           214:  | VRF text { this_proto->vrf = if_get_by_name($2); this_proto->vrf_set = 1; }
        !           215:  | VRF DEFAULT { this_proto->vrf = NULL; this_proto->vrf_set = 1; }
        !           216:  ;
        !           217: 
        !           218: 
        !           219: channel_start: net_type
        !           220: {
        !           221:   $$ = this_channel = channel_config_get(NULL, net_label[$1], $1, this_proto);
        !           222: };
        !           223: 
        !           224: channel_item:
        !           225:    TABLE rtable {
        !           226:      if (this_channel->net_type && ($2->addr_type != this_channel->net_type))
        !           227:        cf_error("Incompatible table type");
        !           228:      this_channel->table = $2;
        !           229:    }
        !           230:  | IMPORT imexport { this_channel->in_filter = $2; }
        !           231:  | EXPORT imexport { this_channel->out_filter = $2; }
        !           232:  | RECEIVE LIMIT limit_spec { this_channel->rx_limit = $3; }
        !           233:  | IMPORT LIMIT limit_spec { this_channel->in_limit = $3; }
        !           234:  | EXPORT LIMIT limit_spec { this_channel->out_limit = $3; }
        !           235:  | PREFERENCE expr { this_channel->preference = $2; check_u16($2); }
        !           236:  | IMPORT KEEP FILTERED bool { this_channel->in_keep_filtered = $4; }
        !           237:  ;
        !           238: 
        !           239: channel_opts:
        !           240:    /* empty */
        !           241:  | channel_opts channel_item ';'
        !           242:  ;
        !           243: 
        !           244: channel_opt_list:
        !           245:    /* empty */
        !           246:  | '{' channel_opts '}'
        !           247:  ;
        !           248: 
        !           249: channel_end:
        !           250: {
        !           251:   if (!this_channel->table)
        !           252:     cf_error("Routing table not specified");
        !           253: 
        !           254:   this_channel = NULL;
        !           255: };
        !           256: 
        !           257: proto_channel: channel_start channel_opt_list channel_end;
        !           258: 
        !           259: 
        !           260: rtable: CF_SYM_KNOWN { cf_assert_symbol($1, SYM_TABLE); $$ = $1->table; } ;
        !           261: 
        !           262: imexport:
        !           263:    FILTER filter { $$ = $2; }
        !           264:  | where_filter
        !           265:  | ALL { $$ = FILTER_ACCEPT; }
        !           266:  | NONE { $$ = FILTER_REJECT; }
        !           267:  ;
        !           268: 
        !           269: limit_action:
        !           270:    /* default */ { $$ = PLA_DISABLE; }
        !           271:  | ACTION WARN { $$ = PLA_WARN; }
        !           272:  | ACTION BLOCK { $$ = PLA_BLOCK; }
        !           273:  | ACTION RESTART { $$ = PLA_RESTART; }
        !           274:  | ACTION DISABLE { $$ = PLA_DISABLE; }
        !           275:  ;
        !           276: 
        !           277: limit_spec:
        !           278:    expr limit_action { $$ = (struct channel_limit){ .limit = $1, $$.action = $2 }; }
        !           279:  | OFF { $$ = (struct channel_limit){}; }
        !           280:  ;
        !           281: 
        !           282: 
        !           283: conf: debug_default ;
        !           284: 
        !           285: debug_default:
        !           286:    DEBUG PROTOCOLS debug_mask { new_config->proto_default_debug = $3; }
        !           287:  | DEBUG COMMANDS expr { new_config->cli_debug = $3; }
        !           288:  ;
        !           289: 
        !           290: /* MRTDUMP PROTOCOLS is in systep/unix/config.Y */
        !           291: 
        !           292: conf: timeformat_base ;
        !           293: 
        !           294: timeformat_which:
        !           295:    ROUTE { $$ = &new_config->tf_route; }
        !           296:  | PROTOCOL { $$ = &new_config->tf_proto; }
        !           297:  | BASE { $$ = &new_config->tf_base; }
        !           298:  | LOG { $$ = &new_config->tf_log; }
        !           299:  ;
        !           300: 
        !           301: timeformat_spec:
        !           302:    timeformat_which TEXT { *$1 = (struct timeformat){$2, NULL, 0}; }
        !           303:  | timeformat_which TEXT expr TEXT { *$1 = (struct timeformat){$2, $4, (s64) $3 S_}; }
        !           304:  | timeformat_which ISO SHORT    { *$1 = TM_ISO_SHORT_S; }
        !           305:  | timeformat_which ISO SHORT MS { *$1 = TM_ISO_SHORT_MS; }
        !           306:  | timeformat_which ISO SHORT US { *$1 = TM_ISO_SHORT_US; }
        !           307:  | timeformat_which ISO LONG    { *$1 = TM_ISO_LONG_S; }
        !           308:  | timeformat_which ISO LONG MS { *$1 = TM_ISO_LONG_MS; }
        !           309:  | timeformat_which ISO LONG US { *$1 = TM_ISO_LONG_US; }
        !           310:  ;
        !           311: 
        !           312: timeformat_base:
        !           313:    TIMEFORMAT timeformat_spec ';'
        !           314:  ;
        !           315: 
        !           316: 
        !           317: /* Interface patterns */
        !           318: 
        !           319: iface_patt_node_init:
        !           320:    /* EMPTY */ {
        !           321:      struct iface_patt_node *ipn = cfg_allocz(sizeof(struct iface_patt_node));
        !           322:      add_tail(&this_ipatt->ipn_list, NODE ipn);
        !           323:      this_ipn = ipn;
        !           324:    }
        !           325:  ;
        !           326: 
        !           327: iface_patt_node_body:
        !           328:    TEXT { this_ipn->pattern = $1; /* this_ipn->prefix stays zero */ }
        !           329:  | opttext net_or_ipa { this_ipn->pattern = $1; this_ipn->prefix = $2; }
        !           330:  ;
        !           331: 
        !           332: iface_negate:
        !           333:        { this_ipn->positive = 1; }
        !           334:  | '-' { this_ipn->positive = 0; }
        !           335:  ;
        !           336: 
        !           337: iface_patt_node:
        !           338:    iface_patt_node_init iface_negate iface_patt_node_body
        !           339:  ;
        !           340: 
        !           341: 
        !           342: iface_patt_list:
        !           343:    iface_patt_node
        !           344:  | iface_patt_list ',' iface_patt_node
        !           345:  ;
        !           346: 
        !           347: /* For name/mask-only iface patterns */
        !           348: iface_patt_list_nopx: iface_patt_list { iface_patt_check(); }
        !           349: 
        !           350: iface_patt_init: {
        !           351:    /* Generic this_ipatt init */
        !           352:    this_ipatt = cfg_allocz(sizeof(struct iface_patt));
        !           353:    init_list(&this_ipatt->ipn_list);
        !           354:  }
        !           355:  ;
        !           356: 
        !           357: iface_patt:
        !           358:    iface_patt_init iface_patt_list
        !           359:  ;
        !           360: 
        !           361: tos:
        !           362:    CLASS expr { $$ = $2 & 0xfc;        if ($2 > 255) cf_error("TX class must be in range 0-255"); }
        !           363:  | DSCP expr  { $$ = ($2 & 0x3f) << 2; if ($2 > 63)  cf_error("TX DSCP must be in range 0-63"); }
        !           364:  ;
        !           365: 
        !           366: /* Direct device route protocol */
        !           367: 
        !           368: proto: dev_proto '}' ;
        !           369: 
        !           370: dev_proto_start: proto_start DIRECT {
        !           371:      this_proto = proto_config_new(&proto_device, $1);
        !           372:      init_list(&DIRECT_CFG->iface_list);
        !           373:    }
        !           374:  ;
        !           375: 
        !           376: dev_proto:
        !           377:    dev_proto_start proto_name '{'
        !           378:  | dev_proto proto_item ';'
        !           379:  | dev_proto proto_channel ';'
        !           380:  | dev_proto dev_iface_patt ';'
        !           381:  | dev_proto CHECK LINK bool ';' { DIRECT_CFG->check_link = $4; }
        !           382:  ;
        !           383: 
        !           384: dev_iface_init:
        !           385:    /* EMPTY */ {
        !           386:      this_ipatt = cfg_allocz(sizeof(struct iface_patt));
        !           387:      add_tail(&DIRECT_CFG->iface_list, NODE this_ipatt);
        !           388:      init_list(&this_ipatt->ipn_list);
        !           389:    }
        !           390:  ;
        !           391: 
        !           392: dev_iface_patt:
        !           393:    INTERFACE dev_iface_init iface_patt_list
        !           394:  ;
        !           395: 
        !           396: /* Debug flags */
        !           397: 
        !           398: debug_mask:
        !           399:    ALL { $$ = ~0; }
        !           400:  | OFF { $$ = 0; }
        !           401:  | '{' debug_list '}' { $$ = $2; }
        !           402:  ;
        !           403: 
        !           404: debug_list:
        !           405:    debug_flag
        !           406:  | debug_list ',' debug_flag { $$ = $1 | $3; }
        !           407:  ;
        !           408: 
        !           409: debug_flag:
        !           410:    STATES      { $$ = D_STATES; }
        !           411:  | ROUTES      { $$ = D_ROUTES; }
        !           412:  | FILTERS     { $$ = D_FILTERS; }
        !           413:  | INTERFACES  { $$ = D_IFACES; }
        !           414:  | EVENTS      { $$ = D_EVENTS; }
        !           415:  | PACKETS     { $$ = D_PACKETS; }
        !           416:  ;
        !           417: 
        !           418: /* MRTDump flags */
        !           419: 
        !           420: mrtdump_mask:
        !           421:    ALL { $$ = ~0; }
        !           422:  | OFF { $$ = 0; }
        !           423:  | '{' mrtdump_list '}' { $$ = $2; }
        !           424:  ;
        !           425: 
        !           426: mrtdump_list:
        !           427:    mrtdump_flag
        !           428:  | mrtdump_list ',' mrtdump_flag { $$ = $1 | $3; }
        !           429:  ;
        !           430: 
        !           431: mrtdump_flag:
        !           432:    STATES      { $$ = MD_STATES; }
        !           433:  | MESSAGES    { $$ = MD_MESSAGES; }
        !           434:  ;
        !           435: 
        !           436: /* Password lists */
        !           437: 
        !           438: password_list:
        !           439:    PASSWORDS '{' password_items '}'
        !           440:  | password_item
        !           441: ;
        !           442: 
        !           443: password_items:
        !           444:     /* empty */
        !           445:   | password_item ';' password_items
        !           446: ;
        !           447: 
        !           448: password_item:
        !           449:     password_item_begin '{' password_item_params '}'
        !           450:   | password_item_begin
        !           451: ;
        !           452: 
        !           453: password_item_begin:
        !           454:    PASSWORD text {
        !           455:      if (!this_p_list) {
        !           456:        this_p_list = cfg_alloc(sizeof(list));
        !           457:        init_list(this_p_list);
        !           458:        password_id = 1;
        !           459:      }
        !           460:      this_p_item = cfg_alloc(sizeof (struct password_item));
        !           461:      this_p_item->password = $2;
        !           462:      this_p_item->length = strlen($2);
        !           463:      this_p_item->genfrom = 0;
        !           464:      this_p_item->gento = TIME_INFINITY;
        !           465:      this_p_item->accfrom = 0;
        !           466:      this_p_item->accto = TIME_INFINITY;
        !           467:      this_p_item->id = password_id++;
        !           468:      this_p_item->alg = ALG_UNDEFINED;
        !           469:      add_tail(this_p_list, &this_p_item->n);
        !           470:    }
        !           471: ;
        !           472: 
        !           473: password_item_params:
        !           474:    /* empty */ { }
        !           475:  | GENERATE FROM time ';' password_item_params { this_p_item->genfrom = $3; }
        !           476:  | GENERATE TO time ';' password_item_params { this_p_item->gento = $3; }
        !           477:  | ACCEPT FROM time ';' password_item_params { this_p_item->accfrom = $3; }
        !           478:  | ACCEPT TO time ';' password_item_params { this_p_item->accto = $3; }
        !           479:  | FROM time ';' password_item_params { this_p_item->genfrom = this_p_item->accfrom = $2; }
        !           480:  | TO time ';' password_item_params { this_p_item->gento = this_p_item->accto = $2; }
        !           481:  | ID expr ';' password_item_params { this_p_item->id = $2; if ($2 <= 0) cf_error("Password ID has to be greated than zero."); }
        !           482:  | ALGORITHM password_algorithm ';' password_item_params { this_p_item->alg = $2; }
        !           483:  ;
        !           484: 
        !           485: password_algorithm:
        !           486:    KEYED MD5   { $$ = ALG_MD5; }
        !           487:  | KEYED SHA1  { $$ = ALG_SHA1; }
        !           488:  | KEYED SHA256        { $$ = ALG_SHA256; }
        !           489:  | KEYED SHA384        { $$ = ALG_SHA384; }
        !           490:  | KEYED SHA512        { $$ = ALG_SHA512; }
        !           491:  | HMAC MD5    { $$ = ALG_HMAC_MD5; }
        !           492:  | HMAC SHA1   { $$ = ALG_HMAC_SHA1; }
        !           493:  | HMAC SHA256 { $$ = ALG_HMAC_SHA256; }
        !           494:  | HMAC SHA384 { $$ = ALG_HMAC_SHA384; }
        !           495:  | HMAC SHA512 { $$ = ALG_HMAC_SHA512; }
        !           496:  ;
        !           497: 
        !           498: /* Core commands */
        !           499: CF_CLI_HELP(SHOW, ..., [[Show status information]])
        !           500: 
        !           501: CF_CLI(SHOW STATUS,,, [[Show router status]])
        !           502: { cmd_show_status(); } ;
        !           503: 
        !           504: CF_CLI(SHOW MEMORY,,, [[Show memory usage]])
        !           505: { cmd_show_memory(); } ;
        !           506: 
        !           507: CF_CLI(SHOW PROTOCOLS, proto_patt2, [<protocol> | \"<pattern>\"], [[Show routing protocols]])
        !           508: { proto_apply_cmd($3, proto_cmd_show, 0, 0); } ;
        !           509: 
        !           510: CF_CLI(SHOW PROTOCOLS ALL, proto_patt2, [<protocol> | \"<pattern>\"], [[Show routing protocol details]])
        !           511: { proto_apply_cmd($4, proto_cmd_show, 0, 1); } ;
        !           512: 
        !           513: optproto:
        !           514:    CF_SYM_KNOWN { cf_assert_symbol($1, SYM_PROTO); $$ = $1; }
        !           515:  | /* empty */ { $$ = NULL; }
        !           516:  ;
        !           517: 
        !           518: CF_CLI(SHOW INTERFACES,,, [[Show network interfaces]])
        !           519: { if_show(); } ;
        !           520: 
        !           521: CF_CLI(SHOW INTERFACES SUMMARY,,, [[Show summary of network interfaces]])
        !           522: { if_show_summary(); } ;
        !           523: 
        !           524: CF_CLI_HELP(SHOW ROUTE, ..., [[Show routing table]])
        !           525: CF_CLI(SHOW ROUTE, r_args, [[[<prefix>|for <prefix>|for <ip>] [table <t>] [filter <f>|where <cond>] [all] [primary] [filtered] [(export|preexport|noexport) <p>] [protocol <p>] [stats|count]]], [[Show routing table]])
        !           526: { rt_show($3); } ;
        !           527: 
        !           528: r_args:
        !           529:    /* empty */ {
        !           530:      $$ = cfg_allocz(sizeof(struct rt_show_data));
        !           531:      init_list(&($$->tables));
        !           532:      $$->filter = FILTER_ACCEPT;
        !           533:      $$->running_on_config = new_config->fallback;
        !           534:    }
        !           535:  | r_args net_any {
        !           536:      $$ = $1;
        !           537:      if ($$->addr) cf_error("Only one prefix expected");
        !           538:      $$->addr = $2;
        !           539:    }
        !           540:  | r_args FOR r_args_for {
        !           541:      $$ = $1;
        !           542:      if ($$->addr) cf_error("Only one prefix expected");
        !           543:      $$->show_for = 1;
        !           544:      $$->addr = $3;
        !           545:    }
        !           546:  | r_args TABLE CF_SYM_KNOWN {
        !           547:      cf_assert_symbol($3, SYM_TABLE);
        !           548:      $$ = $1;
        !           549:      rt_show_add_table($$, $3->table->table);
        !           550:      $$->tables_defined_by = RSD_TDB_DIRECT;
        !           551:    }
        !           552:  | r_args TABLE ALL {
        !           553:      struct rtable_config *t;
        !           554:      $$ = $1;
        !           555:      WALK_LIST(t, config->tables)
        !           556:        rt_show_add_table($$, t->table);
        !           557:      $$->tables_defined_by = RSD_TDB_ALL;
        !           558:    }
        !           559:  | r_args IMPORT TABLE CF_SYM_KNOWN '.' r_args_channel {
        !           560:      cf_assert_symbol($4, SYM_PROTO);
        !           561:      $$ = $1;
        !           562:      struct proto_config *cf = $4->proto;
        !           563:      if (!cf->proto) cf_error("%s is not a protocol", $4->name);
        !           564:      struct channel *c = proto_find_channel_by_name(cf->proto, $6);
        !           565:      if (!c) cf_error("Channel %s.%s not found", $4->name, $6);
        !           566:      if (!c->in_table) cf_error("No import table in channel %s.%s", $4->name, $6);
        !           567:      rt_show_add_table($$, c->in_table);
        !           568:      $$->tables_defined_by = RSD_TDB_DIRECT;
        !           569:    }
        !           570:  | r_args EXPORT TABLE CF_SYM_KNOWN '.' r_args_channel {
        !           571:      cf_assert_symbol($4, SYM_PROTO);
        !           572:      $$ = $1;
        !           573:      struct proto_config *cf = $4->proto;
        !           574:      if (!cf->proto) cf_error("%s is not a protocol", $4->name);
        !           575:      struct channel *c = proto_find_channel_by_name(cf->proto, $6);
        !           576:      if (!c) cf_error("Channel %s.%s not found", $4->name, $6);
        !           577:      if (!c->out_table) cf_error("No export table in channel %s.%s", $4->name, $6);
        !           578:      rt_show_add_table($$, c->out_table);
        !           579:      $$->tables_defined_by = RSD_TDB_DIRECT;
        !           580:    }
        !           581:  | r_args FILTER filter {
        !           582:      $$ = $1;
        !           583:      if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice");
        !           584:      $$->filter = $3;
        !           585:    }
        !           586:  | r_args where_filter {
        !           587:      $$ = $1;
        !           588:      if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice");
        !           589:      $$->filter = $2;
        !           590:    }
        !           591:  | r_args ALL {
        !           592:      $$ = $1;
        !           593:      $$->verbose = 1;
        !           594:    }
        !           595:  | r_args PRIMARY {
        !           596:      $$ = $1;
        !           597:      $$->primary_only = 1;
        !           598:    }
        !           599:  | r_args FILTERED {
        !           600:      $$ = $1;
        !           601:      $$->filtered = 1;
        !           602:    }
        !           603:  | r_args export_mode CF_SYM_KNOWN {
        !           604:      cf_assert_symbol($3, SYM_PROTO);
        !           605:      struct proto_config *c = (struct proto_config *) $3->proto;
        !           606:      $$ = $1;
        !           607:      if ($$->export_mode) cf_error("Export specified twice");
        !           608:      if (!c->proto) cf_error("%s is not a protocol", $3->name);
        !           609:      $$->export_mode = $2;
        !           610:      $$->export_protocol = c->proto;
        !           611:      $$->tables_defined_by = RSD_TDB_INDIRECT;
        !           612:    }
        !           613:  | r_args export_mode CF_SYM_KNOWN '.' r_args_channel {
        !           614:      cf_assert_symbol($3, SYM_PROTO);
        !           615:      struct proto_config *c = (struct proto_config *) $3->proto;
        !           616:      $$ = $1;
        !           617:      if ($$->export_mode) cf_error("Export specified twice");
        !           618:      if (!c->proto) cf_error("%s is not a protocol", $3->name);
        !           619:      $$->export_mode = $2;
        !           620:      $$->export_channel = proto_find_channel_by_name(c->proto, $5);
        !           621:      if (!$$->export_channel) cf_error("Export channel not found");
        !           622:      $$->tables_defined_by = RSD_TDB_INDIRECT;
        !           623:    }
        !           624:  | r_args PROTOCOL CF_SYM_KNOWN {
        !           625:      cf_assert_symbol($3, SYM_PROTO);
        !           626:      struct proto_config *c = (struct proto_config *) $3->proto;
        !           627:      $$ = $1;
        !           628:      if ($$->show_protocol) cf_error("Protocol specified twice");
        !           629:      if (!c->proto) cf_error("%s is not a protocol", $3->name);
        !           630:      $$->show_protocol = c->proto;
        !           631:      $$->tables_defined_by = RSD_TDB_INDIRECT;
        !           632:    }
        !           633:  | r_args STATS {
        !           634:      $$ = $1;
        !           635:      $$->stats = 1;
        !           636:    }
        !           637:  | r_args COUNT {
        !           638:      $$ = $1;
        !           639:      $$->stats = 2;
        !           640:    }
        !           641:  ;
        !           642: 
        !           643: r_args_for:
        !           644:   r_args_for_val {
        !           645:     $$ = cfg_alloc($1.length);
        !           646:     net_copy($$, &$1);
        !           647:   }
        !           648:  | net_vpn4_
        !           649:  | net_vpn6_
        !           650:  | net_ip6_sadr_
        !           651:  | VPN_RD IP4 {
        !           652:     $$ = cfg_alloc(sizeof(net_addr_vpn4));
        !           653:     net_fill_vpn4($$, $2, IP4_MAX_PREFIX_LENGTH, $1);
        !           654:   }
        !           655:  | VPN_RD IP6 {
        !           656:     $$ = cfg_alloc(sizeof(net_addr_vpn6));
        !           657:     net_fill_vpn6($$, $2, IP6_MAX_PREFIX_LENGTH, $1);
        !           658:   }
        !           659:  | IP6 FROM IP6 {
        !           660:     $$ = cfg_alloc(sizeof(net_addr_ip6_sadr));
        !           661:     net_fill_ip6_sadr($$, $1, IP6_MAX_PREFIX_LENGTH, $3, IP6_MAX_PREFIX_LENGTH);
        !           662:   }
        !           663:  | CF_SYM_KNOWN {
        !           664:      if ($1->class == (SYM_CONSTANT | T_IP))
        !           665:      {
        !           666:        $$ = cfg_alloc(ipa_is_ip4(SYM_VAL($1).ip) ? sizeof(net_addr_ip4) : sizeof(net_addr_ip6));
        !           667:        net_fill_ip_host($$, SYM_VAL($1).ip);
        !           668:      }
        !           669:      else if (($1->class == (SYM_CONSTANT | T_NET)) && net_type_match(SYM_VAL($1).net, NB_IP | NB_VPN))
        !           670:        $$ = (net_addr *) SYM_VAL($1).net; /* Avoid const warning */
        !           671:      else
        !           672:        cf_error("IP address or network constant expected");
        !           673:    }
        !           674:  ;
        !           675: 
        !           676: r_args_for_val:
        !           677:    net_ip4_
        !           678:  | net_ip6_
        !           679:  | IP4 { net_fill_ip4(&($$), $1, IP4_MAX_PREFIX_LENGTH); }
        !           680:  | IP6 { net_fill_ip6(&($$), $1, IP6_MAX_PREFIX_LENGTH); }
        !           681: 
        !           682: export_mode:
        !           683:    PREEXPORT   { $$ = RSEM_PREEXPORT; }
        !           684:  | EXPORT      { $$ = RSEM_EXPORT; }
        !           685:  | NOEXPORT    { $$ = RSEM_NOEXPORT; }
        !           686:  ;
        !           687: 
        !           688: /* This is ugly hack */
        !           689: r_args_channel:
        !           690:    IPV4                { $$ = "ipv4"; }
        !           691:  | IPV4_MC     { $$ = "ipv4-mc"; }
        !           692:  | IPV4_MPLS   { $$ = "ipv4-mpls"; }
        !           693:  | IPV6                { $$ = "ipv6"; }
        !           694:  | IPV6_MC     { $$ = "ipv6-mc"; }
        !           695:  | IPV6_MPLS   { $$ = "ipv6-mpls"; }
        !           696:  | IPV6_SADR   { $$ = "ipv6-sadr"; }
        !           697:  | VPN4                { $$ = "vpn4"; }
        !           698:  | VPN4_MC     { $$ = "vpn4-mc"; }
        !           699:  | VPN4_MPLS   { $$ = "vpn4-mpls"; }
        !           700:  | VPN6                { $$ = "vpn6"; }
        !           701:  | VPN6_MC     { $$ = "vpn6-mc"; }
        !           702:  | VPN6_MPLS   { $$ = "vpn6-mpls"; }
        !           703:  | ROA4                { $$ = "roa4"; }
        !           704:  | ROA6                { $$ = "roa6"; }
        !           705:  | FLOW4       { $$ = "flow4"; }
        !           706:  | FLOW6       { $$ = "flow6"; }
        !           707:  | MPLS                { $$ = "mpls"; }
        !           708:  | PRI         { $$ = "pri"; }
        !           709:  | SEC         { $$ = "sec"; }
        !           710:  ;
        !           711: 
        !           712: CF_CLI_HELP(SHOW SYMBOLS, ..., [[Show all known symbolic names]])
        !           713: CF_CLI(SHOW SYMBOLS, sym_args, [table|filter|function|protocol|template|<symbol>], [[Show all known symbolic names]])
        !           714: { cmd_show_symbols($3); } ;
        !           715: 
        !           716: sym_args:
        !           717:    /* empty */ {
        !           718:      $$ = cfg_allocz(sizeof(struct sym_show_data));
        !           719:    }
        !           720:  | sym_args TABLE { $$ = $1; $$->type = SYM_TABLE; }
        !           721:  | sym_args FUNCTION { $$ = $1; $$->type = SYM_FUNCTION; }
        !           722:  | sym_args FILTER { $$ = $1; $$->type = SYM_FILTER; }
        !           723:  | sym_args PROTOCOL { $$ = $1; $$->type = SYM_PROTO; }
        !           724:  | sym_args TEMPLATE { $$ = $1; $$->type = SYM_TEMPLATE; }
        !           725:  | sym_args symbol { $$ = $1; $$->sym = $2; }
        !           726:  ;
        !           727: 
        !           728: 
        !           729: CF_CLI_HELP(DUMP, ..., [[Dump debugging information]])
        !           730: CF_CLI(DUMP RESOURCES,,, [[Dump all allocated resource]])
        !           731: { rdump(&root_pool); cli_msg(0, ""); } ;
        !           732: CF_CLI(DUMP SOCKETS,,, [[Dump open sockets]])
        !           733: { sk_dump_all(); cli_msg(0, ""); } ;
        !           734: CF_CLI(DUMP EVENTS,,, [[Dump event log]])
        !           735: { io_log_dump(); cli_msg(0, ""); } ;
        !           736: CF_CLI(DUMP INTERFACES,,, [[Dump interface information]])
        !           737: { if_dump_all(); cli_msg(0, ""); } ;
        !           738: CF_CLI(DUMP NEIGHBORS,,, [[Dump neighbor cache]])
        !           739: { neigh_dump_all(); cli_msg(0, ""); } ;
        !           740: CF_CLI(DUMP ATTRIBUTES,,, [[Dump attribute cache]])
        !           741: { rta_dump_all(); cli_msg(0, ""); } ;
        !           742: CF_CLI(DUMP ROUTES,,, [[Dump routing table]])
        !           743: { rt_dump_all(); cli_msg(0, ""); } ;
        !           744: CF_CLI(DUMP PROTOCOLS,,, [[Dump protocol information]])
        !           745: { protos_dump_all(); cli_msg(0, ""); } ;
        !           746: CF_CLI(DUMP FILTER ALL,,, [[Dump all filters in linearized form]])
        !           747: { filters_dump_all(); cli_msg(0, ""); } ;
        !           748: 
        !           749: CF_CLI(EVAL, term, <expr>, [[Evaluate an expression]])
        !           750: { cmd_eval(f_linearize($2)); } ;
        !           751: 
        !           752: CF_CLI_HELP(ECHO, ..., [[Control echoing of log messages]])
        !           753: CF_CLI(ECHO, echo_mask echo_size, (all | off | { debug|trace|info|remote|warning|error|auth [, ...] }) [<buffer-size>], [[Control echoing of log messages]]) {
        !           754:   cli_set_log_echo(this_cli, $2, $3);
        !           755:   cli_msg(0, "");
        !           756: } ;
        !           757: 
        !           758: echo_mask:
        !           759:    ALL { $$ = ~0; }
        !           760:  | OFF { $$ = 0; }
        !           761:  | '{' log_mask_list '}' { $$ = $2; }
        !           762:  ;
        !           763: 
        !           764: echo_size:
        !           765:    /* empty */ { $$ = 4096; }
        !           766:  | NUM {
        !           767:      if ($1 < 256 || $1 > 65536) cf_error("Invalid log buffer size");
        !           768:      $$ = $1;
        !           769:    }
        !           770:  ;
        !           771: 
        !           772: CF_CLI(DISABLE, proto_patt opttext, (<protocol> | \"<pattern>\" | all) [message], [[Disable protocol]])
        !           773: { proto_apply_cmd($2, proto_cmd_disable, 1, (uintptr_t) $3); } ;
        !           774: CF_CLI(ENABLE, proto_patt opttext, (<protocol> | \"<pattern>\" | all) [message], [[Enable protocol]])
        !           775: { proto_apply_cmd($2, proto_cmd_enable, 1, (uintptr_t) $3); } ;
        !           776: CF_CLI(RESTART, proto_patt opttext, (<protocol> | \"<pattern>\" | all) [message], [[Restart protocol]])
        !           777: { proto_apply_cmd($2, proto_cmd_restart, 1, (uintptr_t) $3); } ;
        !           778: CF_CLI(RELOAD, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol]])
        !           779: { proto_apply_cmd($2, proto_cmd_reload, 1, CMD_RELOAD); } ;
        !           780: CF_CLI(RELOAD IN, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol (just imported routes)]])
        !           781: { proto_apply_cmd($3, proto_cmd_reload, 1, CMD_RELOAD_IN); } ;
        !           782: CF_CLI(RELOAD OUT, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol (just exported routes)]])
        !           783: { proto_apply_cmd($3, proto_cmd_reload, 1, CMD_RELOAD_OUT); } ;
        !           784: 
        !           785: CF_CLI_HELP(DEBUG, ..., [[Control protocol debugging via BIRD logs]])
        !           786: CF_CLI(DEBUG, proto_patt debug_mask, (<protocol> | \"<pattern>\" | all) (all | off | { states|routes|filters|interfaces|events|packets [, ...] }), [[Control protocol debugging via BIRD logs]])
        !           787: { proto_apply_cmd($2, proto_cmd_debug, 1, $3); } ;
        !           788: 
        !           789: CF_CLI_HELP(MRTDUMP, ..., [[Control protocol debugging via MRTdump files]])
        !           790: CF_CLI(MRTDUMP, proto_patt mrtdump_mask, (<protocol> | \"<pattern>\" | all) (all | off | { states|messages [, ...] }), [[Control protocol debugging via MRTdump format]])
        !           791: { proto_apply_cmd($2, proto_cmd_mrtdump, 1, $3); } ;
        !           792: 
        !           793: CF_CLI(RESTRICT,,,[[Restrict current CLI session to safe commands]])
        !           794: { this_cli->restricted = 1; cli_msg(16, "Access restricted"); } ;
        !           795: 
        !           796: proto_patt:
        !           797:    CF_SYM_KNOWN { cf_assert_symbol($1, SYM_PROTO); $$.ptr = $1; $$.patt = 0; }
        !           798:  | ALL  { $$.ptr = NULL; $$.patt = 1; }
        !           799:  | TEXT { $$.ptr = $1; $$.patt = 1; }
        !           800:  ;
        !           801: 
        !           802: proto_patt2:
        !           803:    CF_SYM_KNOWN { cf_assert_symbol($1, SYM_PROTO); $$.ptr = $1; $$.patt = 0; }
        !           804:  |      { $$.ptr = NULL; $$.patt = 1; }
        !           805:  | TEXT { $$.ptr = $1; $$.patt = 1; }
        !           806:  ;
        !           807: 
        !           808: dynamic_attr: IGP_METRIC { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_GEN_IGP_METRIC); } ;
        !           809: 
        !           810: 
        !           811: CF_CODE
        !           812: 
        !           813: CF_END

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