Statistics
| Branch: | Revision:

iof-bird-daemon / proto / ospf / config.Y @ 8d94a524

History | View | Annotate | Download (7.69 KB)

1 c1f8dc91 Ondrej Filip
/*
2
 *	BIRD -- OSPF Configuration
3
 *
4 32d3228d Ondrej Filip
 *	(c) 1999--2004 Ondrej Filip <feela@network.cz>
5 c1f8dc91 Ondrej Filip
 *
6
 *	Can be freely distributed and used under the terms of the GNU GPL.
7
 */
8
9
CF_HDR
10
11
#include "proto/ospf/ospf.h"
12
13 3fa5722d Ondrej Filip
CF_DEFINES
14
15
#define OSPF_CFG ((struct ospf_config *) this_proto)
16 b36a0a79 Ondrej Filip
static struct ospf_area_config *this_area;
17 89d6782d Ondrej Filip
static struct iface_patt *this_ipatt;
18
#define OSPF_PATT ((struct ospf_iface_patt *) this_ipatt)
19 e5b5d18c Ondrej Filip
static struct nbma_node *this_nbma;
20 98ac6176 Ondrej Filip
static struct area_net_config *this_pref;
21 3fa5722d Ondrej Filip
22 c1f8dc91 Ondrej Filip
CF_DECLS
23
24 5919c66e Martin Mares
CF_KEYWORDS(OSPF, AREA, OSPF_METRIC1, OSPF_METRIC2, OSPF_TAG)
25 89d6782d Ondrej Filip
CF_KEYWORDS(NEIGHBORS, RFC1583COMPAT, STUB, TICK, COST, RETRANSMIT)
26 bd457b8d Ondrej Filip
CF_KEYWORDS(HELLO, TRANSMIT, PRIORITY, DEAD, NONBROADCAST, POINTOPOINT, TYPE)
27 ea357b8b Ondrej Filip
CF_KEYWORDS(NONE, SIMPLE, AUTHENTICATION, STRICT, CRYPTOGRAPHIC)
28 98ac6176 Ondrej Filip
CF_KEYWORDS(ELIGIBLE, POLL, NETWORKS, HIDDEN, VIRTUAL, LINK)
29 c1f8dc91 Ondrej Filip
30 c4f0f014 Ondrej Filip
%type <t> opttext
31
32 c1f8dc91 Ondrej Filip
CF_GRAMMAR
33
34
CF_ADDTO(proto, ospf_proto '}')
35
36
ospf_proto_start: proto_start OSPF {
37
     this_proto = proto_config_new(&proto_ospf, sizeof(struct ospf_config));
38 916c8c0a Martin Mares
     this_proto->preference = DEF_PREF_OSPF;
39 b36a0a79 Ondrej Filip
     init_list(&OSPF_CFG->area_list);
40 d631698e Ondrej Filip
     OSPF_CFG->rfc1583 = DEFAULT_RFC1583;
41 b8f17cf1 Ondrej Filip
     OSPF_CFG->tick = DEFAULT_OSPFTICK;
42 c1f8dc91 Ondrej Filip
  }
43
 ;
44
45
ospf_proto:
46
   ospf_proto_start proto_name '{'
47 f8032bbd Martin Mares
 | ospf_proto ospf_proto_item ';'
48
 ;
49
50
ospf_proto_item:
51
   proto_item
52 002ecc06 Ondrej Filip
 | RFC1583COMPAT bool { OSPF_CFG->rfc1583 = $2; }
53 b8f17cf1 Ondrej Filip
 | TICK expr { OSPF_CFG->tick = $2 ; if($2<=0) cf_error("Tick must be greater than zero"); }
54 f8032bbd Martin Mares
 | ospf_area '}'
55
 ;
56 c1f8dc91 Ondrej Filip
57 b36a0a79 Ondrej Filip
ospf_area_start: AREA idval '{' {
58
  this_area = cfg_allocz(sizeof(struct ospf_area_config));
59
  add_tail(&OSPF_CFG->area_list, NODE this_area);
60
  this_area->areaid = $2;
61
  this_area->stub = 0;
62 89d6782d Ondrej Filip
  init_list(&this_area->patt_list);
63 3b16080c Ondrej Filip
  init_list(&this_area->vlink_list);
64 c926eee7 Ondrej Filip
  init_list(&this_area->net_list);
65 c1f8dc91 Ondrej Filip
 }
66 f8032bbd Martin Mares
 ;
67 c4f0f014 Ondrej Filip
68 71f7d043 Ondrej Filip
ospf_area: ospf_area_start ospf_area_opts
69 f8032bbd Martin Mares
 ;
70 a789d814 Ondrej Filip
71
ospf_area_opts:
72 f8032bbd Martin Mares
   /* empty */
73
 | ospf_area_opts ospf_area_item ';'
74
 ;
75 a789d814 Ondrej Filip
76 b36a0a79 Ondrej Filip
ospf_area_item:
77 b2bdb406 Ondrej Filip
   STUB COST expr { this_area->stub = $3 ; if($3<=0) cf_error("Stub cost must be greater than zero"); }
78 8d94a524 Ondrej Filip
 | STUB bool {if($2) { if(!this_area->stub) this_area->stub=DEFAULT_STUB_COST;}else{ this_area->stub=0;}}
79 c926eee7 Ondrej Filip
 | NETWORKS '{' pref_list '}'
80 f8032bbd Martin Mares
 | INTERFACE ospf_iface_list
81 3b16080c Ondrej Filip
 | ospf_vlink
82 f8032bbd Martin Mares
 ;
83 89d6782d Ondrej Filip
84 3b16080c Ondrej Filip
ospf_vlink:
85
   ospf_vlink_start '{' ospf_vlink_opts '}'
86
 | ospf_vlink_start
87 98ac6176 Ondrej Filip
 ;
88
89
ospf_vlink_opts:
90
   /* empty */
91
 | ospf_vlink_opts ospf_vlink_item ';'
92
 ;
93
94
ospf_vlink_item:
95 3b16080c Ondrej Filip
 | HELLO expr { OSPF_PATT->helloint = $2 ; if (($2<=0) || ($2>65535)) cf_error("Hello interval must be in range 1-65535"); }
96 98ac6176 Ondrej Filip
 | RETRANSMIT expr { OSPF_PATT->rxmtint = $2 ; if ($2<=0) cf_error("Retransmit int must be greater than zero"); }
97
 | TRANSMIT DELAY expr { OSPF_PATT->inftransdelay = $3 ; if (($3<=0) || ($3>65535)) cf_error("Transmit delay must be in range 1-65535"); }
98
 | WAIT expr { OSPF_PATT->waitint = $2 ; }
99
 | DEAD COUNT expr { OSPF_PATT->deadc = $3 ; if ($3<=1) cf_error("Dead count must be greater than one"); }
100 3e2bd0f1 Ondrej Filip
 | AUTHENTICATION NONE { OSPF_PATT->autype = OSPF_AUTH_NONE ; }
101
 | AUTHENTICATION SIMPLE { OSPF_PATT->autype = OSPF_AUTH_SIMPLE ; }
102 32d3228d Ondrej Filip
 | AUTHENTICATION CRYPTOGRAPHIC { OSPF_PATT->autype = OSPF_AUTH_CRYPT ; }
103 3e2bd0f1 Ondrej Filip
 | password_list {OSPF_PATT->passwords = $1; }
104 98ac6176 Ondrej Filip
 ;
105
106 3b16080c Ondrej Filip
ospf_vlink_start: VIRTUAL LINK idval
107 98ac6176 Ondrej Filip
 {
108
  if (this_area->areaid == 0) cf_error("Virtual link cannot be in backbone");
109
  this_ipatt = cfg_allocz(sizeof(struct ospf_iface_patt));
110 3b16080c Ondrej Filip
  add_tail(&this_area->vlink_list, NODE this_ipatt);
111
  OSPF_PATT->vid = $3;
112 98ac6176 Ondrej Filip
  OSPF_PATT->cost = COST_D;
113
  OSPF_PATT->helloint = HELLOINT_D;
114
  OSPF_PATT->rxmtint = RXMTINT_D;
115
  OSPF_PATT->inftransdelay = INFTRANSDELAY_D;
116
  OSPF_PATT->waitint = WAIT_DMH*HELLOINT_D;
117
  OSPF_PATT->deadc = DEADC_D;
118
  OSPF_PATT->type = OSPF_IT_VLINK;
119 3b16080c Ondrej Filip
  init_list(&OSPF_PATT->nbma_list);
120 3e2bd0f1 Ondrej Filip
  OSPF_PATT->autype = OSPF_AUTH_NONE;
121 98ac6176 Ondrej Filip
 }
122
;
123
124 89d6782d Ondrej Filip
ospf_iface_item:
125 7df86c25 Ondrej Filip
   COST expr { OSPF_PATT->cost = $2 ; if (($2<=0) || ($2>65535)) cf_error("Cost must be in range 1-65535"); }
126
 | HELLO expr { OSPF_PATT->helloint = $2 ; if (($2<=0) || ($2>65535)) cf_error("Hello interval must be in range 1-65535"); }
127
 | POLL expr { OSPF_PATT->pollint = $2 ; if ($2<=0) cf_error("Poll int must be greater than zero"); }
128
 | RETRANSMIT expr { OSPF_PATT->rxmtint = $2 ; if ($2<=0) cf_error("Retransmit int must be greater than zero"); }
129
 | TRANSMIT DELAY expr { OSPF_PATT->inftransdelay = $3 ; if (($3<=0) || ($3>65535)) cf_error("Transmit delay must be in range 1-65535"); }
130
 | PRIORITY expr { OSPF_PATT->priority = $2 ; if (($2<0) || ($2>255)) cf_error("Priority must be in range 0-255")}
131 bd457b8d Ondrej Filip
 | WAIT expr { OSPF_PATT->waitint = $2 ; }
132 7df86c25 Ondrej Filip
 | DEAD COUNT expr { OSPF_PATT->deadc = $3 ; if ($3<=1) cf_error("Dead count must be greater than one"); }
133 aaaff776 Ondrej Filip
 | TYPE BROADCAST { OSPF_PATT->type = OSPF_IT_BCAST ; }
134
 | TYPE NONBROADCAST { OSPF_PATT->type = OSPF_IT_NBMA ; }
135
 | TYPE POINTOPOINT { OSPF_PATT->type = OSPF_IT_PTP ; }
136 a190e720 Ondrej Filip
 | STRICT NONBROADCAST bool { OSPF_PATT->strictnbma = $3 ; }
137 e3bc10fd Ondrej Filip
 | STUB bool { OSPF_PATT->stub = $2 ; }
138 e5b5d18c Ondrej Filip
 | NEIGHBORS '{' ipa_list '}'
139 3e2bd0f1 Ondrej Filip
 | AUTHENTICATION NONE { OSPF_PATT->autype = OSPF_AUTH_NONE ; }
140
 | AUTHENTICATION SIMPLE { OSPF_PATT->autype = OSPF_AUTH_SIMPLE ; }
141 ea357b8b Ondrej Filip
 | AUTHENTICATION CRYPTOGRAPHIC { OSPF_PATT->autype = OSPF_AUTH_CRYPT ; }
142 3e2bd0f1 Ondrej Filip
 | password_list {OSPF_PATT->passwords = $1; }
143 f8032bbd Martin Mares
 ;
144 e5b5d18c Ondrej Filip
145 c926eee7 Ondrej Filip
pref_list:
146
 /* empty */
147
 | pref_list pref_item
148
 ;
149
150
pref_item:
151 de259a41 Ondrej Filip
   pref_el
152 c926eee7 Ondrej Filip
 | pref_hid;
153
154
pref_el: prefix ';'
155
 {
156 98ac6176 Ondrej Filip
   this_pref = cfg_allocz(sizeof(struct area_net_config));
157 c926eee7 Ondrej Filip
   add_tail(&this_area->net_list, NODE this_pref);
158 66261211 Ondrej Filip
   this_pref->px.addr = $1.addr;
159
   this_pref->px.len = $1.len;
160 c926eee7 Ondrej Filip
 }
161
;
162
163
pref_hid: prefix HIDDEN ';'
164
 {
165 98ac6176 Ondrej Filip
   this_pref = cfg_allocz(sizeof(struct area_net_config));
166 c926eee7 Ondrej Filip
   add_tail(&this_area->net_list, NODE this_pref);
167 66261211 Ondrej Filip
   this_pref->px.addr = $1.addr;
168
   this_pref->px.len = $1.len;
169 c926eee7 Ondrej Filip
   this_pref->hidden = 1;
170
 }
171
;
172
173 e5b5d18c Ondrej Filip
ipa_list:
174
 /* empty */
175
 | ipa_list ipa_item
176
 ;
177 a190e720 Ondrej Filip
178
ipa_item:
179 de259a41 Ondrej Filip
    ipa_el
180 a190e720 Ondrej Filip
  | ipa_ne;
181 e5b5d18c Ondrej Filip
 
182 a190e720 Ondrej Filip
ipa_el: IPA ';'
183
 {
184
   this_nbma = cfg_allocz(sizeof(struct nbma_node));
185
   add_tail(&OSPF_PATT->nbma_list, NODE this_nbma);
186
   this_nbma->ip=$1;
187
   this_nbma->eligible=0;
188
 }
189
;
190
191
ipa_ne: IPA ELIGIBLE ';'
192 e5b5d18c Ondrej Filip
 {
193
   this_nbma = cfg_allocz(sizeof(struct nbma_node));
194
   add_tail(&OSPF_PATT->nbma_list, NODE this_nbma);
195
   this_nbma->ip=$1;
196 a190e720 Ondrej Filip
   this_nbma->eligible=1;
197 e5b5d18c Ondrej Filip
 }
198
;
199
200 b36a0a79 Ondrej Filip
 
201 aaaff776 Ondrej Filip
ospf_iface_start:
202
 {
203
  this_ipatt = cfg_allocz(sizeof(struct ospf_iface_patt));
204
  add_tail(&this_area->patt_list, NODE this_ipatt);
205
  OSPF_PATT->cost = COST_D;
206
  OSPF_PATT->helloint = HELLOINT_D;
207 a190e720 Ondrej Filip
  OSPF_PATT->pollint = POLLINT_D;
208 aaaff776 Ondrej Filip
  OSPF_PATT->rxmtint = RXMTINT_D;
209
  OSPF_PATT->inftransdelay = INFTRANSDELAY_D;
210
  OSPF_PATT->priority = PRIORITY_D;
211
  OSPF_PATT->waitint = WAIT_DMH*HELLOINT_D;
212
  OSPF_PATT->deadc = DEADC_D;
213
  OSPF_PATT->type = OSPF_IT_UNDEF;
214 a190e720 Ondrej Filip
  OSPF_PATT->strictnbma = 0;
215 e3bc10fd Ondrej Filip
  OSPF_PATT->stub = 0;
216 e5b5d18c Ondrej Filip
  init_list(&OSPF_PATT->nbma_list);
217 3e2bd0f1 Ondrej Filip
  OSPF_PATT->autype = OSPF_AUTH_NONE;
218 aaaff776 Ondrej Filip
 }
219
;
220
221 89d6782d Ondrej Filip
ospf_iface_opts:
222 f8032bbd Martin Mares
   /* empty */
223 89d6782d Ondrej Filip
 | ospf_iface_opts ospf_iface_item ';'
224
 ;
225
226 f8032bbd Martin Mares
ospf_iface_opt_list:
227
   /* empty */
228
 | '{' ospf_iface_opts '}'
229
 ;
230 89d6782d Ondrej Filip
231
ospf_iface:
232
  ospf_iface_start iface_patt ospf_iface_opt_list
233 f8032bbd Martin Mares
 ;
234 89d6782d Ondrej Filip
235
ospf_iface_list:
236 f8032bbd Martin Mares
   ospf_iface
237 89d6782d Ondrej Filip
 | ospf_iface_list ',' ospf_iface
238
 ;
239
240 c4f0f014 Ondrej Filip
opttext:
241
    TEXT
242 f8032bbd Martin Mares
 | /* empty */ { $$ = NULL; }
243
 ;
244 c1f8dc91 Ondrej Filip
245 5919c66e Martin Mares
CF_ADDTO(dynamic_attr, OSPF_METRIC1 { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_METRIC1); })
246
CF_ADDTO(dynamic_attr, OSPF_METRIC2 { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_METRIC2); })
247
CF_ADDTO(dynamic_attr, OSPF_TAG { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_TAG); })
248
249 ec423cc7 Martin Mares
CF_CLI(SHOW OSPF, optsym, [<name>], [[Show information about OSPF protocol]])
250 4ab4e977 Ondrej Filip
{ ospf_sh(proto_get_named($3, &proto_ospf)); } ;
251
252 ec423cc7 Martin Mares
CF_CLI(SHOW OSPF NEIGHBORS, optsym opttext, [<name>] [\"<interface>\"], [[Show information about OSPF neighbors]])
253 c4f0f014 Ondrej Filip
{ ospf_sh_neigh(proto_get_named($4, &proto_ospf), $5); } ;
254
255 ec423cc7 Martin Mares
CF_CLI(SHOW OSPF INTERFACE, optsym opttext, [<name>] [\"<interface>\"], [[Show information about interface]])
256 c4f0f014 Ondrej Filip
{ ospf_sh_iface(proto_get_named($4, &proto_ospf), $5); };
257 a783e259 Ondrej Filip
258 c1f8dc91 Ondrej Filip
CF_CODE
259
260
CF_END