Statistics
| Branch: | Revision:

iof-bird-daemon / proto / static / config.Y @ 62e64905

History | View | Annotate | Download (3.52 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, *this_snh;
17
static struct f_inst **this_srt_last_cmd;
18

    
19
static struct static_route *
20
static_nexthop_new(void)
21
{
22
  struct static_route *nh;
23

    
24
  if (!this_snh)
25
  {
26
    /* First next hop */
27
    nh = this_srt;
28
    rem_node(&this_srt->n);
29
  }
30
  else
31
  {
32
    /* Additional next hop */
33
    nh = cfg_allocz(sizeof(struct static_route));
34
    nh->net = this_srt->net;
35
    this_snh->mp_next = nh;
36
  }
37

    
38
  nh->dest = RTD_UNICAST;
39
  nh->mp_head = this_srt;
40
  return nh;
41
};
42

    
43
static void
44
static_route_finish(void)
45
{ }
46

    
47
CF_DECLS
48

    
49
CF_KEYWORDS(STATIC, ROUTE, VIA, DROP, REJECT, PROHIBIT, PREFERENCE, CHECK, LINK)
50
CF_KEYWORDS(WEIGHT, RECURSIVE, IGP, TABLE, BLACKHOLE, UNREACHABLE, BFD, MPLS)
51

    
52

    
53
CF_GRAMMAR
54

    
55
CF_ADDTO(proto, static_proto '}')
56

    
57
static_proto_start: proto_start STATIC
58
{
59
  this_proto = proto_config_new(&proto_static, $1);
60
  static_init_config(STATIC_CFG);
61
};
62

    
63
static_proto:
64
   static_proto_start proto_name '{'
65
 | static_proto proto_item ';'
66
 | static_proto proto_channel ';' { this_proto->net_type = $2->net_type; }
67
 | static_proto CHECK LINK bool ';' { STATIC_CFG->check_link = $4; }
68
 | static_proto IGP TABLE rtable ';' { STATIC_CFG->igp_table = $4; }
69
 | static_proto stat_route stat_route_opt_list ';' { static_route_finish(); }
70
 ;
71

    
72
stat_nexthop:
73
    VIA ipa ipa_scope {
74
      this_snh = static_nexthop_new();
75
      this_snh->via = $2;
76
      this_snh->iface = $3;
77
      add_tail(&STATIC_CFG->neigh_routes, &this_snh->n);
78
    }
79
  | VIA TEXT {
80
      this_snh = static_nexthop_new();
81
      this_snh->via = IPA_NONE;
82
      this_snh->if_name = $2;
83
      add_tail(&STATIC_CFG->iface_routes, &this_snh->n);
84
    }
85
  | stat_nexthop MPLS label_stack {
86
    this_snh->label_count = $3[0];
87
    this_snh->label_stack = &($3[1]);
88
  }
89
  | stat_nexthop WEIGHT expr {
90
    this_snh->weight = $3 - 1;
91
    if (($3<1) || ($3>256)) cf_error("Weight must be in range 1-256");
92
  }
93
  | stat_nexthop BFD bool {
94
    this_snh->use_bfd = $3; cf_check_bfd($3);
95
  }
96
;
97

    
98
stat_nexthops:
99
    stat_nexthop
100
  | stat_nexthops stat_nexthop
101
;
102

    
103
stat_route0: ROUTE net_any {
104
     this_srt = cfg_allocz(sizeof(struct static_route));
105
     add_tail(&STATIC_CFG->other_routes, &this_srt->n);
106
     this_srt->net = $2;
107
     this_srt_last_cmd = &(this_srt->cmds);
108
     this_srt->mp_next = NULL;
109
     this_snh = NULL;
110
  }
111
 ;
112

    
113
stat_route:
114
   stat_route0 stat_nexthops
115
 | stat_route0 RECURSIVE ipa {
116
      this_srt->dest = RTDX_RECURSIVE;
117
      this_srt->via = $3;
118
   }
119
 | stat_route0 RECURSIVE ipa MPLS label_stack {
120
      this_srt->dest = RTDX_RECURSIVE;
121
      this_srt->via = $3;
122
      this_srt->label_count = $5[0];
123
      this_srt->label_stack = &($5[1]);
124
   }
125
 | stat_route0 DROP		{ this_srt->dest = RTD_BLACKHOLE; }
126
 | stat_route0 REJECT		{ this_srt->dest = RTD_UNREACHABLE; }
127
 | stat_route0 BLACKHOLE	{ this_srt->dest = RTD_BLACKHOLE; }
128
 | stat_route0 UNREACHABLE	{ this_srt->dest = RTD_UNREACHABLE; }
129
 | stat_route0 PROHIBIT		{ this_srt->dest = RTD_PROHIBIT; }
130
 ;
131

    
132
stat_route_item:
133
   cmd { *this_srt_last_cmd = $1; this_srt_last_cmd = &($1->next); }
134
 ;
135

    
136
stat_route_opts:
137
   /* empty */
138
 | stat_route_opts stat_route_item
139
 ;
140

    
141
stat_route_opt_list:
142
   /* empty */
143
 | '{' stat_route_opts '}'
144
 ;
145

    
146

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

    
150
CF_CODE
151

    
152
CF_END