Statistics
| Branch: | Revision:

iof-bird-daemon / proto / ospf / config.Y @ b21f68b4

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