Statistics
| Branch: | Revision:

iof-bird-daemon / proto / static / config.Y @ f4a60a9b

History | View | Annotate | Download (3.52 KB)

1 a1bf6440 Martin Mares
/*
2
 *	BIRD -- Static Protocol Configuration
3
 *
4 e9e3dc26 Martin Mares
 *	(c) 1998--1999 Martin Mares <mj@ucw.cz>
5 a1bf6440 Martin Mares
 *
6
 *	Can be freely distributed and used under the terms of the GNU GPL.
7
 */
8
9
CF_HDR
10
11
#include "proto/static/static.h"
12
13 2edb31b0 Martin Mares
CF_DEFINES
14
15 fe181e7c Ondrej Zajicek
#define STATIC_CFG ((struct static_config *) this_proto)
16 9852f810 Ondrej Zajicek
static struct static_route *this_srt, *this_srt_nh, *last_srt_nh;
17 1321e12a Ondrej Zajicek
static struct f_inst **this_srt_last_cmd;
18 f6bd2066 Martin Mares
19 538264cf Ondrej Zajicek
static void
20
static_route_finish(void)
21
{
22
  struct static_route *r;
23
24
  /* Update undefined use_bfd entries in multipath nexthops */
25
  if (this_srt->dest == RTD_MULTIPATH)
26
    for (r = this_srt->mp_next; r; r = r->mp_next)
27
      if (r->use_bfd < 0)
28
        r->use_bfd = this_srt->use_bfd;
29
}
30
31 a1bf6440 Martin Mares
CF_DECLS
32
33 fe181e7c Ondrej Zajicek
CF_KEYWORDS(STATIC, ROUTE, VIA, DROP, REJECT, PROHIBIT, PREFERENCE, CHECK, LINK)
34 538264cf Ondrej Zajicek
CF_KEYWORDS(MULTIPATH, WEIGHT, RECURSIVE, IGP, TABLE, BLACKHOLE, UNREACHABLE, BFD)
35 9852f810 Ondrej Zajicek
36 a1bf6440 Martin Mares
37
CF_GRAMMAR
38
39
CF_ADDTO(proto, static_proto '}')
40
41 f4a60a9b Ondrej Zajicek (work)
static_proto_start: proto_start STATIC
42
{
43
  this_proto = proto_config_new(&proto_static, $1);
44
  static_init_config(STATIC_CFG);
45
};
46 a1bf6440 Martin Mares
47
static_proto:
48
   static_proto_start proto_name '{'
49
 | static_proto proto_item ';'
50 f4a60a9b Ondrej Zajicek (work)
 | static_proto proto_channel ';' { this_proto->net_type = $2->net_type; }
51 391931d4 Ondrej Zajicek
 | static_proto CHECK LINK bool ';' { STATIC_CFG->check_link = $4; }
52 4116db18 Ondrej Zajicek
 | static_proto IGP TABLE rtable ';' { STATIC_CFG->igp_table = $4; }
53 538264cf Ondrej Zajicek
 | static_proto stat_route stat_route_opt_list ';' { static_route_finish(); }
54 f6bd2066 Martin Mares
 ;
55
56 d44e686e Ondrej Zajicek (work)
stat_route0: ROUTE net_any {
57 f6bd2066 Martin Mares
     this_srt = cfg_allocz(sizeof(struct static_route));
58 fe181e7c Ondrej Zajicek
     add_tail(&STATIC_CFG->other_routes, &this_srt->n);
59 d44e686e Ondrej Zajicek (work)
     this_srt->net = $2;
60 1321e12a Ondrej Zajicek
     this_srt_last_cmd = &(this_srt->cmds);
61 f6bd2066 Martin Mares
  }
62
 ;
63
64 9852f810 Ondrej Zajicek
stat_multipath1:
65 69a8259c Ondrej Zajicek
   VIA ipa ipa_scope {
66 9852f810 Ondrej Zajicek
     last_srt_nh = this_srt_nh;
67
     this_srt_nh = cfg_allocz(sizeof(struct static_route));
68
     this_srt_nh->dest = RTD_NONE;
69
     this_srt_nh->via = $2;
70 69a8259c Ondrej Zajicek
     this_srt_nh->via_if = $3;
71 9852f810 Ondrej Zajicek
     this_srt_nh->if_name = (void *) this_srt; /* really */
72 538264cf Ondrej Zajicek
     this_srt_nh->use_bfd = -1; /* undefined */
73 9852f810 Ondrej Zajicek
   }
74
 | stat_multipath1 WEIGHT expr {
75 d44e686e Ondrej Zajicek (work)
     this_srt_nh->weight = $3 - 1;
76 9852f810 Ondrej Zajicek
     if (($3<1) || ($3>256)) cf_error("Weight must be in range 1-256"); 
77
   }
78 538264cf Ondrej Zajicek
 | stat_multipath1 BFD bool {
79
     this_srt_nh->use_bfd = $3; cf_check_bfd($3);
80
   }
81 9852f810 Ondrej Zajicek
 ;
82
83
stat_multipath:
84
   stat_multipath1 { this_srt->mp_next = this_srt_nh; }
85
 | stat_multipath stat_multipath1 { last_srt_nh->mp_next = this_srt_nh; }
86
 ;
87
88 f6bd2066 Martin Mares
stat_route:
89 69a8259c Ondrej Zajicek
   stat_route0 VIA ipa ipa_scope {
90 f6bd2066 Martin Mares
      this_srt->dest = RTD_ROUTER;
91
      this_srt->via = $3;
92 69a8259c Ondrej Zajicek
      this_srt->via_if = $4;
93 f6bd2066 Martin Mares
   }
94
 | stat_route0 VIA TEXT {
95
      this_srt->dest = RTD_DEVICE;
96
      this_srt->if_name = $3;
97
      rem_node(&this_srt->n);
98 fe181e7c Ondrej Zajicek
      add_tail(&STATIC_CFG->iface_routes, &this_srt->n);
99 f6bd2066 Martin Mares
   }
100 9852f810 Ondrej Zajicek
 | stat_route0 MULTIPATH stat_multipath {
101
      this_srt->dest = RTD_MULTIPATH;
102
   }
103 4116db18 Ondrej Zajicek
 | stat_route0 RECURSIVE ipa {
104
      this_srt->dest = RTDX_RECURSIVE;
105
      this_srt->via = $3;
106
   }
107 80a9cadc Ondrej Zajicek
108
 | stat_route0 DROP		{ this_srt->dest = RTD_BLACKHOLE; }
109
 | stat_route0 REJECT		{ this_srt->dest = RTD_UNREACHABLE; }
110
 | stat_route0 BLACKHOLE	{ this_srt->dest = RTD_BLACKHOLE; }
111
 | stat_route0 UNREACHABLE	{ this_srt->dest = RTD_UNREACHABLE; }
112
 | stat_route0 PROHIBIT		{ this_srt->dest = RTD_PROHIBIT; }
113 a1bf6440 Martin Mares
 ;
114
115 1321e12a Ondrej Zajicek
stat_route_item:
116
   cmd { *this_srt_last_cmd = $1; this_srt_last_cmd = &($1->next); }
117 538264cf Ondrej Zajicek
 | BFD bool ';' { this_srt->use_bfd = $2; cf_check_bfd($2); }
118 1321e12a Ondrej Zajicek
 ;
119
120
stat_route_opts:
121
   /* empty */
122
 | stat_route_opts stat_route_item
123
 ;
124
125
stat_route_opt_list:
126
   /* empty */
127
 | '{' stat_route_opts '}'
128
 ;
129
130
131 feed8226 Martin Mares
CF_CLI(SHOW STATIC, optsym, [<name>], [[Show details of static protocol]])
132
{ static_show(proto_get_named($3, &proto_static)); } ;
133
134 a1bf6440 Martin Mares
CF_CODE
135
136
CF_END