Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (10.2 KB)

1
/*
2
 *	BIRD -- OSPF Configuration
3
 *
4
 *	(c) 1999--2004 Ondrej Filip <feela@network.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/ospf/ospf.h"
12

    
13
CF_DEFINES
14

    
15
#define OSPF_CFG ((struct ospf_config *) this_proto)
16
#define OSPF_PATT ((struct ospf_iface_patt *) this_ipatt)
17

    
18
static struct ospf_area_config *this_area;
19
static struct nbma_node *this_nbma;
20
static struct area_net_config *this_pref;
21
static struct ospf_stubnet_config *this_stubnet; 
22

    
23
#ifdef OSPFv2
24
static void
25
finish_iface_config(struct ospf_iface_patt *ip)
26
{
27
  ip->passwords = get_passwords();
28

    
29
  if ((ip->autype == OSPF_AUTH_CRYPT) && (ip->helloint < 5))
30
    log(L_WARN "Hello or poll interval less that 5 makes cryptographic authenication prone to replay attacks");
31

    
32
  if ((ip->autype == OSPF_AUTH_NONE) && (ip->passwords != NULL))
33
    log(L_WARN "Password option without authentication option does not make sense");
34
}
35
#endif
36

    
37
#ifdef OSPFv3
38
static void
39
finish_iface_config(struct ospf_iface_patt *ip)
40
{
41
  if ((ip->autype != OSPF_AUTH_NONE) || (get_passwords() != NULL))
42
    cf_error("Authentication not supported in OSPFv3");
43
}
44
#endif
45

    
46
CF_DECLS
47

    
48
CF_KEYWORDS(OSPF, AREA, OSPF_METRIC1, OSPF_METRIC2, OSPF_TAG, OSPF_ROUTER_ID)
49
CF_KEYWORDS(BROADCAST, NEIGHBORS, RFC1583COMPAT, STUB, TICK, COST, RETRANSMIT)
50
CF_KEYWORDS(HELLO, TRANSMIT, PRIORITY, DEAD, NONBROADCAST, POINTOPOINT, TYPE)
51
CF_KEYWORDS(NONE, SIMPLE, AUTHENTICATION, STRICT, CRYPTOGRAPHIC)
52
CF_KEYWORDS(ELIGIBLE, POLL, NETWORKS, HIDDEN, VIRTUAL, LINK)
53
CF_KEYWORDS(RX, BUFFER, LARGE, NORMAL, STUBNET, HIDDEN, SUMMARY)
54
CF_KEYWORDS(WAIT, DELAY, LSADB)
55

    
56
%type <t> opttext
57

    
58
CF_GRAMMAR
59

    
60
CF_ADDTO(proto, ospf_proto '}')
61

    
62
ospf_proto_start: proto_start OSPF {
63
     this_proto = proto_config_new(&proto_ospf, sizeof(struct ospf_config));
64
     this_proto->preference = DEF_PREF_OSPF;
65
     init_list(&OSPF_CFG->area_list);
66
     OSPF_CFG->rfc1583 = DEFAULT_RFC1583;
67
     OSPF_CFG->tick = DEFAULT_OSPFTICK;
68
  }
69
 ;
70

    
71
ospf_proto:
72
   ospf_proto_start proto_name '{'
73
 | ospf_proto ospf_proto_item ';'
74
 ;
75

    
76
ospf_proto_item:
77
   proto_item
78
 | RFC1583COMPAT bool { OSPF_CFG->rfc1583 = $2; }
79
 | TICK expr { OSPF_CFG->tick = $2 ; if($2<=0) cf_error("Tick must be greater than zero"); }
80
 | ospf_area '}'
81
 ;
82

    
83
ospf_area_start: AREA idval '{' {
84
  this_area = cfg_allocz(sizeof(struct ospf_area_config));
85
  add_tail(&OSPF_CFG->area_list, NODE this_area);
86
  this_area->areaid = $2;
87
  this_area->stub = 0;
88
  init_list(&this_area->patt_list);
89
  init_list(&this_area->vlink_list);
90
  init_list(&this_area->net_list);
91
  init_list(&this_area->stubnet_list);
92
 }
93
 ;
94

    
95
ospf_area: ospf_area_start ospf_area_opts
96
 ;
97

    
98
ospf_area_opts:
99
   /* empty */
100
 | ospf_area_opts ospf_area_item ';'
101
 ;
102

    
103
ospf_area_item:
104
   STUB COST expr { this_area->stub = $3 ; if($3<=0) cf_error("Stub cost must be greater than zero"); }
105
 | STUB bool {if($2) { if(!this_area->stub) this_area->stub=DEFAULT_STUB_COST;}else{ this_area->stub=0;}}
106
 | NETWORKS '{' pref_list '}'
107
 | STUBNET ospf_stubnet
108
 | INTERFACE ospf_iface
109
 | ospf_vlink
110
 ;
111

    
112
ospf_stubnet:
113
   ospf_stubnet_start '{' ospf_stubnet_opts '}'
114
 | ospf_stubnet_start
115
 ;
116

    
117
ospf_stubnet_start:
118
   prefix {
119
     this_stubnet = cfg_allocz(sizeof(struct ospf_stubnet_config));
120
     add_tail(&this_area->stubnet_list, NODE this_stubnet);
121
     this_stubnet->px = $1;
122
     this_stubnet->cost = COST_D;
123
   } 
124
 ;
125

    
126
ospf_stubnet_opts:
127
   /* empty */
128
 | ospf_stubnet_opts ospf_stubnet_item ';'
129
 ;
130

    
131
ospf_stubnet_item:
132
   HIDDEN bool { this_stubnet->hidden = $2; }
133
 | SUMMARY bool { this_stubnet->summary = $2; }
134
 | COST expr { this_stubnet->cost = $2; }
135
 ;
136

    
137
ospf_vlink:
138
   ospf_vlink_start '{' ospf_vlink_opts '}' { finish_iface_config(OSPF_PATT); }
139
 | ospf_vlink_start
140
 ;
141

    
142
ospf_vlink_opts:
143
   /* empty */
144
 | ospf_vlink_opts ospf_vlink_item ';'
145
 ;
146

    
147
ospf_vlink_item:
148
 | HELLO expr { OSPF_PATT->helloint = $2 ; if (($2<=0) || ($2>65535)) cf_error("Hello interval must be in range 1-65535"); }
149
 | RETRANSMIT expr { OSPF_PATT->rxmtint = $2 ; if ($2<=0) cf_error("Retransmit int must be greater than zero"); }
150
 | TRANSMIT DELAY expr { OSPF_PATT->inftransdelay = $3 ; if (($3<=0) || ($3>65535)) cf_error("Transmit delay must be in range 1-65535"); }
151
 | WAIT expr { OSPF_PATT->waitint = $2 ; }
152
 | DEAD expr { OSPF_PATT->dead = $2 ; if ($2<=1) cf_error("Dead interval must be greater than one"); }
153
 | DEAD COUNT expr { OSPF_PATT->deadc = $3 ; if ($3<=1) cf_error("Dead count must be greater than one"); }
154
 | AUTHENTICATION NONE { OSPF_PATT->autype = OSPF_AUTH_NONE ; }
155
 | AUTHENTICATION SIMPLE { OSPF_PATT->autype = OSPF_AUTH_SIMPLE ; }
156
 | AUTHENTICATION CRYPTOGRAPHIC { OSPF_PATT->autype = OSPF_AUTH_CRYPT ; }
157
 | password_list 
158
 ;
159

    
160
ospf_vlink_start: VIRTUAL LINK idval
161
 {
162
  if (this_area->areaid == 0) cf_error("Virtual link cannot be in backbone");
163
  this_ipatt = cfg_allocz(sizeof(struct ospf_iface_patt));
164
  add_tail(&this_area->vlink_list, NODE this_ipatt);
165
  init_list(&this_ipatt->ipn_list);
166
  OSPF_PATT->vid = $3;
167
  OSPF_PATT->cost = COST_D;
168
  OSPF_PATT->helloint = HELLOINT_D;
169
  OSPF_PATT->rxmtint = RXMTINT_D;
170
  OSPF_PATT->inftransdelay = INFTRANSDELAY_D;
171
  OSPF_PATT->waitint = WAIT_DMH*HELLOINT_D;
172
  OSPF_PATT->deadc = DEADC_D;
173
  OSPF_PATT->dead = 0;
174
  OSPF_PATT->type = OSPF_IT_VLINK;
175
  init_list(&OSPF_PATT->nbma_list);
176
  OSPF_PATT->autype = OSPF_AUTH_NONE;
177
  reset_passwords();
178
 }
179
;
180

    
181
ospf_iface_item:
182
   COST expr { OSPF_PATT->cost = $2 ; if (($2<=0) || ($2>65535)) cf_error("Cost must be in range 1-65535"); }
183
 | HELLO expr { OSPF_PATT->helloint = $2 ; if (($2<=0) || ($2>65535)) cf_error("Hello interval must be in range 1-65535"); }
184
 | POLL expr { OSPF_PATT->pollint = $2 ; if ($2<=0) cf_error("Poll int must be greater than zero"); }
185
 | RETRANSMIT expr { OSPF_PATT->rxmtint = $2 ; if ($2<=0) cf_error("Retransmit int must be greater than zero"); }
186
 | TRANSMIT DELAY expr { OSPF_PATT->inftransdelay = $3 ; if (($3<=0) || ($3>65535)) cf_error("Transmit delay must be in range 1-65535"); }
187
 | PRIORITY expr { OSPF_PATT->priority = $2 ; if (($2<0) || ($2>255)) cf_error("Priority must be in range 0-255"); }
188
 | WAIT expr { OSPF_PATT->waitint = $2 ; }
189
 | DEAD expr { OSPF_PATT->dead = $2 ; if ($2<=1) cf_error("Dead interval must be greater than one"); }
190
 | DEAD COUNT expr { OSPF_PATT->deadc = $3 ; if ($3<=1) cf_error("Dead count must be greater than one"); }
191
 | TYPE BROADCAST { OSPF_PATT->type = OSPF_IT_BCAST ; }
192
 | TYPE NONBROADCAST { OSPF_PATT->type = OSPF_IT_NBMA ; }
193
 | TYPE POINTOPOINT { OSPF_PATT->type = OSPF_IT_PTP ; }
194
 | STRICT NONBROADCAST bool { OSPF_PATT->strictnbma = $3 ; }
195
 | STUB bool { OSPF_PATT->stub = $2 ; }
196
 | NEIGHBORS '{' ipa_list '}'
197
 | AUTHENTICATION NONE { OSPF_PATT->autype = OSPF_AUTH_NONE ; }
198
 | AUTHENTICATION SIMPLE { OSPF_PATT->autype = OSPF_AUTH_SIMPLE ; }
199
 | AUTHENTICATION CRYPTOGRAPHIC { OSPF_PATT->autype = OSPF_AUTH_CRYPT ; }
200
 | RX BUFFER LARGE { OSPF_PATT->rxbuf = OSPF_RXBUF_LARGE ; } 
201
 | RX BUFFER NORMAL { OSPF_PATT->rxbuf = OSPF_RXBUF_NORMAL ; } 
202
 | RX BUFFER expr { OSPF_PATT->rxbuf = $3 ; if ($3 < OSPF_RXBUF_MINSIZE) cf_error("Buffer size is too small") ; } 
203
 | password_list
204
 ;
205

    
206
pref_list:
207
 /* empty */
208
 | pref_list pref_item
209
 ;
210

    
211
pref_item:
212
   pref_el
213
 | pref_hid;
214

    
215
pref_el: prefix ';'
216
 {
217
   this_pref = cfg_allocz(sizeof(struct area_net_config));
218
   add_tail(&this_area->net_list, NODE this_pref);
219
   this_pref->px.addr = $1.addr;
220
   this_pref->px.len = $1.len;
221
 }
222
;
223

    
224
pref_hid: prefix HIDDEN ';'
225
 {
226
   this_pref = cfg_allocz(sizeof(struct area_net_config));
227
   add_tail(&this_area->net_list, NODE this_pref);
228
   this_pref->px.addr = $1.addr;
229
   this_pref->px.len = $1.len;
230
   this_pref->hidden = 1;
231
 }
232
;
233

    
234
ipa_list:
235
 /* empty */
236
 | ipa_list ipa_item
237
 ;
238

    
239
ipa_item:
240
    ipa_el
241
  | ipa_ne;
242
 
243
ipa_el: IPA ';'
244
 {
245
   this_nbma = cfg_allocz(sizeof(struct nbma_node));
246
   add_tail(&OSPF_PATT->nbma_list, NODE this_nbma);
247
   this_nbma->ip=$1;
248
   this_nbma->eligible=0;
249
 }
250
;
251

    
252
ipa_ne: IPA ELIGIBLE ';'
253
 {
254
   this_nbma = cfg_allocz(sizeof(struct nbma_node));
255
   add_tail(&OSPF_PATT->nbma_list, NODE this_nbma);
256
   this_nbma->ip=$1;
257
   this_nbma->eligible=1;
258
 }
259
;
260

    
261
 
262
ospf_iface_start:
263
 {
264
  this_ipatt = cfg_allocz(sizeof(struct ospf_iface_patt));
265
  add_tail(&this_area->patt_list, NODE this_ipatt);
266
  init_list(&this_ipatt->ipn_list);
267
  OSPF_PATT->cost = COST_D;
268
  OSPF_PATT->helloint = HELLOINT_D;
269
  OSPF_PATT->pollint = POLLINT_D;
270
  OSPF_PATT->rxmtint = RXMTINT_D;
271
  OSPF_PATT->inftransdelay = INFTRANSDELAY_D;
272
  OSPF_PATT->priority = PRIORITY_D;
273
  OSPF_PATT->waitint = WAIT_DMH*HELLOINT_D;
274
  OSPF_PATT->deadc = DEADC_D;
275
  OSPF_PATT->dead = 0;
276
  OSPF_PATT->type = OSPF_IT_UNDEF;
277
  OSPF_PATT->strictnbma = 0;
278
  OSPF_PATT->stub = 0;
279
  init_list(&OSPF_PATT->nbma_list);
280
  OSPF_PATT->autype = OSPF_AUTH_NONE;
281
  reset_passwords();
282
 }
283
;
284

    
285
ospf_iface_opts:
286
   /* empty */
287
 | ospf_iface_opts ospf_iface_item ';'
288
 ;
289

    
290
ospf_iface_opt_list:
291
   /* empty */
292
 | '{' ospf_iface_opts '}'
293
 ;
294

    
295
ospf_iface:
296
  ospf_iface_start iface_patt_list ospf_iface_opt_list { finish_iface_config(OSPF_PATT); }
297
 ;
298

    
299
opttext:
300
    TEXT
301
 | /* empty */ { $$ = NULL; }
302
 ;
303

    
304
CF_ADDTO(dynamic_attr, OSPF_METRIC1 { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_METRIC1); })
305
CF_ADDTO(dynamic_attr, OSPF_METRIC2 { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_METRIC2); })
306
CF_ADDTO(dynamic_attr, OSPF_TAG { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_TAG); })
307
CF_ADDTO(dynamic_attr, OSPF_ROUTER_ID { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_ROUTER_ID); })
308

    
309
CF_CLI(SHOW OSPF, optsym, [<name>], [[Show information about OSPF protocol]])
310
{ ospf_sh(proto_get_named($3, &proto_ospf)); };
311

    
312
CF_CLI(SHOW OSPF NEIGHBORS, optsym opttext, [<name>] [\"<interface>\"], [[Show information about OSPF neighbors]])
313
{ ospf_sh_neigh(proto_get_named($4, &proto_ospf), $5); };
314

    
315
CF_CLI(SHOW OSPF INTERFACE, optsym opttext, [<name>] [\"<interface>\"], [[Show information about interface]])
316
{ ospf_sh_iface(proto_get_named($4, &proto_ospf), $5); };
317

    
318
CF_CLI(SHOW OSPF TOPOLOGY, optsym opttext, [<name>], [[Show information about OSPF network topology]])
319
{ ospf_sh_state(proto_get_named($4, &proto_ospf), 0); };
320

    
321
CF_CLI(SHOW OSPF STATE, optsym opttext, [<name>], [[Show information about OSPF network state]])
322
{ ospf_sh_state(proto_get_named($4, &proto_ospf), 1); };
323

    
324
CF_CLI(SHOW OSPF LSADB, optsym opttext, [<name>], [[Show content of OSPF LSA database]])
325
{ ospf_sh_lsadb(proto_get_named($4, &proto_ospf)); };
326

    
327
CF_CODE
328

    
329
CF_END