1998-12-06 18:21:23 +00:00
|
|
|
/*
|
|
|
|
* BIRD -- Static Protocol Configuration
|
|
|
|
*
|
1999-02-05 21:38:22 +00:00
|
|
|
* (c) 1998--1999 Martin Mares <mj@ucw.cz>
|
1998-12-06 18:21:23 +00:00
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
CF_HDR
|
|
|
|
|
|
|
|
#include "proto/static/static.h"
|
|
|
|
|
2000-04-28 15:11:10 +00:00
|
|
|
CF_DEFINES
|
|
|
|
|
2010-11-11 11:24:27 +00:00
|
|
|
#define STATIC_CFG ((struct static_config *) this_proto)
|
2010-12-07 22:34:36 +00:00
|
|
|
static struct static_route *this_srt, *this_srt_nh, *last_srt_nh;
|
1998-12-06 23:13:31 +00:00
|
|
|
|
1998-12-06 18:21:23 +00:00
|
|
|
CF_DECLS
|
|
|
|
|
2010-11-11 11:24:27 +00:00
|
|
|
CF_KEYWORDS(STATIC, ROUTE, VIA, DROP, REJECT, PROHIBIT, PREFERENCE, CHECK, LINK)
|
2012-11-27 01:08:04 +00:00
|
|
|
CF_KEYWORDS(MULTIPATH, WEIGHT, RECURSIVE, IGP, TABLE, BLACKHOLE, UNREACHABLE)
|
2010-12-07 22:34:36 +00:00
|
|
|
|
1998-12-06 18:21:23 +00:00
|
|
|
|
|
|
|
CF_GRAMMAR
|
|
|
|
|
|
|
|
CF_ADDTO(proto, static_proto '}')
|
|
|
|
|
|
|
|
static_proto_start: proto_start STATIC {
|
2011-11-06 23:31:23 +00:00
|
|
|
this_proto = proto_config_new(&proto_static, sizeof(struct static_config), $1);
|
1999-02-05 21:38:22 +00:00
|
|
|
static_init_config((struct static_config *) this_proto);
|
1998-12-06 18:21:23 +00:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
static_proto:
|
|
|
|
static_proto_start proto_name '{'
|
|
|
|
| static_proto proto_item ';'
|
2010-11-19 12:46:21 +00:00
|
|
|
| static_proto CHECK LINK bool ';' { STATIC_CFG->check_link = $4; }
|
2011-09-24 00:21:52 +00:00
|
|
|
| static_proto IGP TABLE rtable ';' { STATIC_CFG->igp_table = $4; }
|
1998-12-06 23:13:31 +00:00
|
|
|
| static_proto stat_route ';'
|
|
|
|
;
|
|
|
|
|
2000-05-13 11:17:49 +00:00
|
|
|
stat_route0: ROUTE prefix {
|
1998-12-06 23:13:31 +00:00
|
|
|
this_srt = cfg_allocz(sizeof(struct static_route));
|
2010-11-11 11:24:27 +00:00
|
|
|
add_tail(&STATIC_CFG->other_routes, &this_srt->n);
|
2000-05-13 11:17:49 +00:00
|
|
|
this_srt->net = $2.addr;
|
|
|
|
this_srt->masklen = $2.len;
|
1998-12-06 23:13:31 +00:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2010-12-07 22:34:36 +00:00
|
|
|
stat_multipath1:
|
2012-01-01 11:02:20 +00:00
|
|
|
VIA ipa ipa_scope {
|
2010-12-07 22:34:36 +00:00
|
|
|
last_srt_nh = this_srt_nh;
|
|
|
|
this_srt_nh = cfg_allocz(sizeof(struct static_route));
|
|
|
|
this_srt_nh->dest = RTD_NONE;
|
|
|
|
this_srt_nh->via = $2;
|
2012-01-01 11:02:20 +00:00
|
|
|
this_srt_nh->via_if = $3;
|
2010-12-07 22:34:36 +00:00
|
|
|
this_srt_nh->if_name = (void *) this_srt; /* really */
|
|
|
|
}
|
|
|
|
| stat_multipath1 WEIGHT expr {
|
|
|
|
this_srt_nh->masklen = $3 - 1; /* really */
|
|
|
|
if (($3<1) || ($3>256)) cf_error("Weight must be in range 1-256");
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
stat_multipath:
|
|
|
|
stat_multipath1 { this_srt->mp_next = this_srt_nh; }
|
|
|
|
| stat_multipath stat_multipath1 { last_srt_nh->mp_next = this_srt_nh; }
|
|
|
|
;
|
|
|
|
|
1998-12-06 23:13:31 +00:00
|
|
|
stat_route:
|
2012-01-01 11:02:20 +00:00
|
|
|
stat_route0 VIA ipa ipa_scope {
|
1998-12-06 23:13:31 +00:00
|
|
|
this_srt->dest = RTD_ROUTER;
|
|
|
|
this_srt->via = $3;
|
2012-01-01 11:02:20 +00:00
|
|
|
this_srt->via_if = $4;
|
1998-12-06 23:13:31 +00:00
|
|
|
}
|
|
|
|
| stat_route0 VIA TEXT {
|
|
|
|
this_srt->dest = RTD_DEVICE;
|
|
|
|
this_srt->if_name = $3;
|
|
|
|
rem_node(&this_srt->n);
|
2010-11-11 11:24:27 +00:00
|
|
|
add_tail(&STATIC_CFG->iface_routes, &this_srt->n);
|
1998-12-06 23:13:31 +00:00
|
|
|
}
|
2010-12-07 22:34:36 +00:00
|
|
|
| stat_route0 MULTIPATH stat_multipath {
|
|
|
|
this_srt->dest = RTD_MULTIPATH;
|
|
|
|
}
|
2011-09-24 00:21:52 +00:00
|
|
|
| stat_route0 RECURSIVE ipa {
|
|
|
|
this_srt->dest = RTDX_RECURSIVE;
|
|
|
|
this_srt->via = $3;
|
|
|
|
}
|
2012-11-27 01:08:04 +00: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-06 18:21:23 +00:00
|
|
|
;
|
|
|
|
|
1999-12-03 11:41:23 +00:00
|
|
|
CF_CLI(SHOW STATIC, optsym, [<name>], [[Show details of static protocol]])
|
|
|
|
{ static_show(proto_get_named($3, &proto_static)); } ;
|
|
|
|
|
1998-12-06 18:21:23 +00:00
|
|
|
CF_CODE
|
|
|
|
|
|
|
|
CF_END
|