1998-12-07 02:21:23 +08:00
|
|
|
/*
|
|
|
|
* BIRD -- Static Protocol Configuration
|
|
|
|
*
|
1999-02-06 05:38:22 +08:00
|
|
|
* (c) 1998--1999 Martin Mares <mj@ucw.cz>
|
1998-12-07 02:21:23 +08:00
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
CF_HDR
|
|
|
|
|
|
|
|
#include "proto/static/static.h"
|
|
|
|
|
2000-04-28 23:11:10 +08:00
|
|
|
CF_DEFINES
|
|
|
|
|
2010-11-11 19:24:27 +08:00
|
|
|
#define STATIC_CFG ((struct static_config *) this_proto)
|
2017-02-20 09:26:45 +08:00
|
|
|
static struct static_route *this_srt, *this_snh;
|
2015-07-20 17:12:02 +08:00
|
|
|
static struct f_inst **this_srt_last_cmd;
|
1998-12-07 07:13:31 +08:00
|
|
|
|
2017-02-20 09:26:45 +08:00
|
|
|
static struct static_route *
|
|
|
|
static_nexthop_new(void)
|
|
|
|
{
|
2017-03-08 01:42:41 +08:00
|
|
|
struct static_route *nh = this_srt;
|
2017-02-20 09:26:45 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
if (this_snh)
|
2017-02-20 09:26:45 +08:00
|
|
|
{
|
|
|
|
/* Additional next hop */
|
|
|
|
nh = cfg_allocz(sizeof(struct static_route));
|
|
|
|
nh->net = this_srt->net;
|
|
|
|
this_snh->mp_next = nh;
|
|
|
|
}
|
|
|
|
|
|
|
|
nh->dest = RTD_UNICAST;
|
|
|
|
nh->mp_head = this_srt;
|
|
|
|
return nh;
|
|
|
|
};
|
|
|
|
|
2015-07-25 00:02:07 +08:00
|
|
|
static void
|
|
|
|
static_route_finish(void)
|
2016-06-13 21:49:53 +08:00
|
|
|
{ }
|
2015-07-25 00:02:07 +08:00
|
|
|
|
1998-12-07 02:21:23 +08:00
|
|
|
CF_DECLS
|
|
|
|
|
2010-11-11 19:24:27 +08:00
|
|
|
CF_KEYWORDS(STATIC, ROUTE, VIA, DROP, REJECT, PROHIBIT, PREFERENCE, CHECK, LINK)
|
2016-06-13 21:49:53 +08:00
|
|
|
CF_KEYWORDS(WEIGHT, RECURSIVE, IGP, TABLE, BLACKHOLE, UNREACHABLE, BFD, MPLS)
|
2010-12-08 06:34:36 +08:00
|
|
|
|
1998-12-07 02:21:23 +08:00
|
|
|
|
|
|
|
CF_GRAMMAR
|
|
|
|
|
|
|
|
CF_ADDTO(proto, static_proto '}')
|
|
|
|
|
2016-01-26 18:48:58 +08:00
|
|
|
static_proto_start: proto_start STATIC
|
|
|
|
{
|
|
|
|
this_proto = proto_config_new(&proto_static, $1);
|
2017-03-08 01:42:41 +08:00
|
|
|
init_list(&STATIC_CFG->routes);
|
2016-01-26 18:48:58 +08:00
|
|
|
};
|
1998-12-07 02:21:23 +08:00
|
|
|
|
|
|
|
static_proto:
|
|
|
|
static_proto_start proto_name '{'
|
|
|
|
| static_proto proto_item ';'
|
2016-01-26 18:48:58 +08:00
|
|
|
| static_proto proto_channel ';' { this_proto->net_type = $2->net_type; }
|
2010-11-19 20:46:21 +08:00
|
|
|
| static_proto CHECK LINK bool ';' { STATIC_CFG->check_link = $4; }
|
2011-09-24 08:21:52 +08:00
|
|
|
| static_proto IGP TABLE rtable ';' { STATIC_CFG->igp_table = $4; }
|
2015-07-25 00:02:07 +08:00
|
|
|
| static_proto stat_route stat_route_opt_list ';' { static_route_finish(); }
|
1998-12-07 07:13:31 +08:00
|
|
|
;
|
|
|
|
|
2017-02-20 09:26:45 +08:00
|
|
|
stat_nexthop:
|
|
|
|
VIA ipa ipa_scope {
|
|
|
|
this_snh = static_nexthop_new();
|
|
|
|
this_snh->via = $2;
|
|
|
|
this_snh->iface = $3;
|
2016-06-13 21:49:53 +08:00
|
|
|
}
|
2017-02-20 09:26:45 +08:00
|
|
|
| VIA TEXT {
|
|
|
|
this_snh = static_nexthop_new();
|
|
|
|
this_snh->via = IPA_NONE;
|
2017-03-08 01:42:41 +08:00
|
|
|
this_snh->iface = if_get_by_name($2);
|
2016-06-13 21:49:53 +08:00
|
|
|
}
|
2017-02-20 09:26:45 +08:00
|
|
|
| stat_nexthop MPLS label_stack {
|
|
|
|
this_snh->label_count = $3[0];
|
|
|
|
this_snh->label_stack = &($3[1]);
|
2016-06-13 21:49:53 +08:00
|
|
|
}
|
2017-02-20 09:26:45 +08:00
|
|
|
| stat_nexthop WEIGHT expr {
|
|
|
|
this_snh->weight = $3 - 1;
|
2016-06-13 21:49:53 +08:00
|
|
|
if (($3<1) || ($3>256)) cf_error("Weight must be in range 1-256");
|
|
|
|
}
|
2017-02-20 09:26:45 +08:00
|
|
|
| stat_nexthop BFD bool {
|
|
|
|
this_snh->use_bfd = $3; cf_check_bfd($3);
|
|
|
|
}
|
2016-06-13 21:49:53 +08:00
|
|
|
;
|
|
|
|
|
2017-02-20 09:26:45 +08:00
|
|
|
stat_nexthops:
|
|
|
|
stat_nexthop
|
|
|
|
| stat_nexthops stat_nexthop
|
2016-06-13 21:49:53 +08:00
|
|
|
;
|
|
|
|
|
2015-11-12 09:03:59 +08:00
|
|
|
stat_route0: ROUTE net_any {
|
1998-12-07 07:13:31 +08:00
|
|
|
this_srt = cfg_allocz(sizeof(struct static_route));
|
2017-03-08 01:42:41 +08:00
|
|
|
add_tail(&STATIC_CFG->routes, &this_srt->n);
|
2015-11-12 09:03:59 +08:00
|
|
|
this_srt->net = $2;
|
2015-07-20 17:12:02 +08:00
|
|
|
this_srt_last_cmd = &(this_srt->cmds);
|
2016-05-06 21:48:35 +08:00
|
|
|
this_srt->mp_next = NULL;
|
2017-02-20 09:26:45 +08:00
|
|
|
this_snh = NULL;
|
1998-12-07 07:13:31 +08:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
stat_route:
|
2017-02-20 09:26:45 +08:00
|
|
|
stat_route0 stat_nexthops
|
2011-09-24 08:21:52 +08:00
|
|
|
| stat_route0 RECURSIVE ipa {
|
|
|
|
this_srt->dest = RTDX_RECURSIVE;
|
|
|
|
this_srt->via = $3;
|
|
|
|
}
|
2016-08-09 20:47:51 +08:00
|
|
|
| stat_route0 RECURSIVE ipa MPLS label_stack {
|
|
|
|
this_srt->dest = RTDX_RECURSIVE;
|
|
|
|
this_srt->via = $3;
|
|
|
|
this_srt->label_count = $5[0];
|
|
|
|
this_srt->label_stack = &($5[1]);
|
|
|
|
}
|
2012-11-27 09:08:04 +08:00
|
|
|
| stat_route0 DROP { this_srt->dest = RTD_BLACKHOLE; }
|
|
|
|
| stat_route0 REJECT { this_srt->dest = RTD_UNREACHABLE; }
|
|
|
|
| stat_route0 BLACKHOLE { this_srt->dest = RTD_BLACKHOLE; }
|
|
|
|
| stat_route0 UNREACHABLE { this_srt->dest = RTD_UNREACHABLE; }
|
|
|
|
| stat_route0 PROHIBIT { this_srt->dest = RTD_PROHIBIT; }
|
1998-12-07 02:21:23 +08:00
|
|
|
;
|
|
|
|
|
2015-07-20 17:12:02 +08:00
|
|
|
stat_route_item:
|
|
|
|
cmd { *this_srt_last_cmd = $1; this_srt_last_cmd = &($1->next); }
|
|
|
|
;
|
|
|
|
|
|
|
|
stat_route_opts:
|
|
|
|
/* empty */
|
|
|
|
| stat_route_opts stat_route_item
|
|
|
|
;
|
|
|
|
|
|
|
|
stat_route_opt_list:
|
|
|
|
/* empty */
|
|
|
|
| '{' stat_route_opts '}'
|
|
|
|
;
|
|
|
|
|
|
|
|
|
1999-12-03 19:41:23 +08:00
|
|
|
CF_CLI(SHOW STATIC, optsym, [<name>], [[Show details of static protocol]])
|
|
|
|
{ static_show(proto_get_named($3, &proto_static)); } ;
|
|
|
|
|
1998-12-07 02:21:23 +08:00
|
|
|
CF_CODE
|
|
|
|
|
|
|
|
CF_END
|