Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (3.39 KB)

1
/*
2
 *	BIRD -- Static Protocol Configuration
3
 *
4
 *	(c) 1998--1999 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 "proto/static/static.h"
12

    
13
CF_DEFINES
14

    
15
#define STATIC_CFG ((struct static_config *) this_proto)
16
static struct static_route *this_srt, *last_srt;
17
static struct f_inst **this_srt_last_cmd;
18

    
19
static void
20
static_route_finish(void)
21
{ }
22

    
23
CF_DECLS
24

    
25
CF_KEYWORDS(STATIC, ROUTE, VIA, DROP, REJECT, PROHIBIT, PREFERENCE, CHECK, LINK)
26
CF_KEYWORDS(WEIGHT, RECURSIVE, IGP, TABLE, BLACKHOLE, UNREACHABLE, BFD, MPLS)
27

    
28

    
29
CF_GRAMMAR
30

    
31
CF_ADDTO(proto, static_proto '}')
32

    
33
static_proto_start: proto_start STATIC
34
{
35
  this_proto = proto_config_new(&proto_static, $1);
36
  static_init_config(STATIC_CFG);
37
};
38

    
39
static_proto:
40
   static_proto_start proto_name '{'
41
 | static_proto proto_item ';'
42
 | static_proto proto_channel ';' { this_proto->net_type = $2->net_type; }
43
 | static_proto CHECK LINK bool ';' { STATIC_CFG->check_link = $4; }
44
 | static_proto IGP TABLE rtable ';' { STATIC_CFG->igp_table = $4; }
45
 | static_proto stat_route stat_route_opt_list ';' { static_route_finish(); }
46
 ;
47

    
48
stat_nexthop_via: VIA
49
{
50
  if (last_srt)
51
  {
52
    last_srt = (last_srt->mp_next = cfg_allocz(sizeof(struct static_route)));
53
    last_srt->net = this_srt->net;
54
  }
55
  else
56
  {
57
    last_srt = this_srt;
58
    rem_node(&this_srt->n);
59
  }
60

    
61
  last_srt->mp_head = this_srt;
62
  last_srt->dest = RTD_UNICAST;
63
};
64

    
65
stat_nexthop_ident:
66
    stat_nexthop_via ipa ipa_scope {
67
      last_srt->via = $2;
68
      last_srt->iface = $3;
69
      add_tail(&STATIC_CFG->neigh_routes, &last_srt->n);
70
    }
71
  | stat_nexthop_via TEXT {
72
      last_srt->via = IPA_NONE;
73
      last_srt->if_name = $2;
74
      add_tail(&STATIC_CFG->iface_routes, &last_srt->n);
75
    }
76
  | stat_nexthop_ident MPLS label_stack {
77
    last_srt->label_count = $3[0];
78
    last_srt->label_stack = &($3[1]);
79
  }
80
  | stat_nexthop_ident WEIGHT expr {
81
    last_srt->weight = $3 - 1;
82
    if (($3<1) || ($3>256)) cf_error("Weight must be in range 1-256");
83
  }
84
  | stat_nexthop_ident BFD bool { last_srt->use_bfd = $3; cf_check_bfd($3); }
85
;
86

    
87
stat_nexthop:
88
    stat_nexthop_ident
89
  | stat_nexthop stat_nexthop_ident
90
;
91

    
92
stat_route0: ROUTE net_any {
93
     this_srt = cfg_allocz(sizeof(struct static_route));
94
     add_tail(&STATIC_CFG->other_routes, &this_srt->n);
95
     this_srt->net = $2;
96
     this_srt_last_cmd = &(this_srt->cmds);
97
     this_srt->mp_next = NULL;
98
     last_srt = NULL;
99
  }
100
 ;
101

    
102
stat_route:
103
   stat_route0 stat_nexthop
104
 | stat_route0 RECURSIVE ipa {
105
      this_srt->dest = RTDX_RECURSIVE;
106
      this_srt->via = $3;
107
   }
108
 | stat_route0 RECURSIVE ipa MPLS label_stack {
109
      this_srt->dest = RTDX_RECURSIVE;
110
      this_srt->via = $3;
111
      this_srt->label_count = $5[0];
112
      this_srt->label_stack = &($5[1]);
113
   }
114
 | stat_route0 DROP		{ this_srt->dest = RTD_BLACKHOLE; }
115
 | stat_route0 REJECT		{ this_srt->dest = RTD_UNREACHABLE; }
116
 | stat_route0 BLACKHOLE	{ this_srt->dest = RTD_BLACKHOLE; }
117
 | stat_route0 UNREACHABLE	{ this_srt->dest = RTD_UNREACHABLE; }
118
 | stat_route0 PROHIBIT		{ this_srt->dest = RTD_PROHIBIT; }
119
 ;
120

    
121
stat_route_item:
122
   cmd { *this_srt_last_cmd = $1; this_srt_last_cmd = &($1->next); }
123
 ;
124

    
125
stat_route_opts:
126
   /* empty */
127
 | stat_route_opts stat_route_item
128
 ;
129

    
130
stat_route_opt_list:
131
   /* empty */
132
 | '{' stat_route_opts '}'
133
 ;
134

    
135

    
136
CF_CLI(SHOW STATIC, optsym, [<name>], [[Show details of static protocol]])
137
{ static_show(proto_get_named($3, &proto_static)); } ;
138

    
139
CF_CODE
140

    
141
CF_END