Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (8.51 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
static struct ospf_area_config *this_area;
17
static struct iface_patt *this_ipatt;
18
#define OSPF_PATT ((struct ospf_iface_patt *) this_ipatt)
19
static struct nbma_node *this_nbma;
20
static struct area_net_config *this_pref;
21

    
22
CF_DECLS
23

    
24
CF_KEYWORDS(OSPF, AREA, OSPF_METRIC1, OSPF_METRIC2, OSPF_TAG)
25
CF_KEYWORDS(NEIGHBORS, RFC1583COMPAT, STUB, TICK, COST, RETRANSMIT)
26
CF_KEYWORDS(HELLO, TRANSMIT, PRIORITY, DEAD, NONBROADCAST, POINTOPOINT, TYPE)
27
CF_KEYWORDS(NONE, SIMPLE, AUTHENTICATION, STRICT, CRYPTOGRAPHIC)
28
CF_KEYWORDS(ELIGIBLE, POLL, NETWORKS, HIDDEN, VIRTUAL, LINK)
29
CF_KEYWORDS(RX, BUFFER, LARGE, NORMAL)
30

    
31
%type <t> opttext
32

    
33
CF_GRAMMAR
34

    
35
CF_ADDTO(proto, ospf_proto '}' { OSPF_PATT->passwords = get_passwords(); } )
36

    
37
ospf_proto_start: proto_start OSPF {
38
     this_proto = proto_config_new(&proto_ospf, sizeof(struct ospf_config));
39
     this_proto->preference = DEF_PREF_OSPF;
40
     init_list(&OSPF_CFG->area_list);
41
     OSPF_CFG->rfc1583 = DEFAULT_RFC1583;
42
     OSPF_CFG->tick = DEFAULT_OSPFTICK;
43
  }
44
 ;
45

    
46
ospf_proto:
47
   ospf_proto_start proto_name '{'
48
 | ospf_proto ospf_proto_item ';'
49
 ;
50

    
51
ospf_proto_item:
52
   proto_item
53
 | RFC1583COMPAT bool { OSPF_CFG->rfc1583 = $2; }
54
 | TICK expr { OSPF_CFG->tick = $2 ; if($2<=0) cf_error("Tick must be greater than zero"); }
55
 | ospf_area '}'
56
 ;
57

    
58
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
  init_list(&this_area->patt_list);
64
  init_list(&this_area->vlink_list);
65
  init_list(&this_area->net_list);
66
 }
67
 ;
68

    
69
ospf_area: ospf_area_start ospf_area_opts
70
 ;
71

    
72
ospf_area_opts:
73
   /* empty */
74
 | ospf_area_opts ospf_area_item ';'
75
 ;
76

    
77
ospf_area_item:
78
   STUB COST expr { this_area->stub = $3 ; if($3<=0) cf_error("Stub cost must be greater than zero"); }
79
 | STUB bool {if($2) { if(!this_area->stub) this_area->stub=DEFAULT_STUB_COST;}else{ this_area->stub=0;}}
80
 | NETWORKS '{' pref_list '}'
81
 | INTERFACE ospf_iface_list
82
 | ospf_vlink
83
 ;
84

    
85
ospf_vlink:
86
   ospf_vlink_start '{' ospf_vlink_opts '}'
87
 | ospf_vlink_start
88
 ;
89

    
90
ospf_vlink_opts:
91
   /* empty */
92
 | ospf_vlink_opts ospf_vlink_item ';'
93
 ;
94

    
95
ospf_vlink_item:
96
 | HELLO expr { OSPF_PATT->helloint = $2 ; if (($2<=0) || ($2>65535)) cf_error("Hello interval must be in range 1-65535"); }
97
 | 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
 | DEAD expr { OSPF_PATT->dead = $2 ; if ($2<=1) cf_error("Dead interval must be greater than one"); }
101
 | DEAD COUNT expr { OSPF_PATT->deadc = $3 ; if ($3<=1) cf_error("Dead count must be greater than one"); }
102
 | AUTHENTICATION NONE { OSPF_PATT->autype = OSPF_AUTH_NONE ; }
103
 | AUTHENTICATION SIMPLE { OSPF_PATT->autype = OSPF_AUTH_SIMPLE ; }
104
 | AUTHENTICATION CRYPTOGRAPHIC { OSPF_PATT->autype = OSPF_AUTH_CRYPT ; }
105
 | password_list 
106
 ;
107

    
108
ospf_vlink_start: VIRTUAL LINK idval
109
 {
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
  add_tail(&this_area->vlink_list, NODE this_ipatt);
113
  OSPF_PATT->vid = $3;
114
  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
  OSPF_PATT->dead = 0;
121
  OSPF_PATT->type = OSPF_IT_VLINK;
122
  init_list(&OSPF_PATT->nbma_list);
123
  OSPF_PATT->autype = OSPF_AUTH_NONE;
124
 }
125
;
126

    
127
ospf_iface_item:
128
   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
 | PRIORITY expr { OSPF_PATT->priority = $2 ; if (($2<0) || ($2>255)) cf_error("Priority must be in range 0-255"); }
134
 | WAIT expr { OSPF_PATT->waitint = $2 ; }
135
 | DEAD expr { OSPF_PATT->dead = $2 ; if ($2<=1) cf_error("Dead interval must be greater than one"); }
136
 | DEAD COUNT expr { OSPF_PATT->deadc = $3 ; if ($3<=1) cf_error("Dead count must be greater than one"); }
137
 | 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
 | STRICT NONBROADCAST bool { OSPF_PATT->strictnbma = $3 ; }
141
 | STUB bool { OSPF_PATT->stub = $2 ; }
142
 | NEIGHBORS '{' ipa_list '}'
143
 | AUTHENTICATION NONE { OSPF_PATT->autype = OSPF_AUTH_NONE ; }
144
 | AUTHENTICATION SIMPLE { OSPF_PATT->autype = OSPF_AUTH_SIMPLE ; }
145
 | AUTHENTICATION CRYPTOGRAPHIC { OSPF_PATT->autype = OSPF_AUTH_CRYPT ; }
146
 | 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
 | password_list
150
 ;
151

    
152
pref_list:
153
 /* empty */
154
 | pref_list pref_item
155
 ;
156

    
157
pref_item:
158
   pref_el
159
 | pref_hid;
160

    
161
pref_el: prefix ';'
162
 {
163
   this_pref = cfg_allocz(sizeof(struct area_net_config));
164
   add_tail(&this_area->net_list, NODE this_pref);
165
   this_pref->px.addr = $1.addr;
166
   this_pref->px.len = $1.len;
167
 }
168
;
169

    
170
pref_hid: prefix HIDDEN ';'
171
 {
172
   this_pref = cfg_allocz(sizeof(struct area_net_config));
173
   add_tail(&this_area->net_list, NODE this_pref);
174
   this_pref->px.addr = $1.addr;
175
   this_pref->px.len = $1.len;
176
   this_pref->hidden = 1;
177
 }
178
;
179

    
180
ipa_list:
181
 /* empty */
182
 | ipa_list ipa_item
183
 ;
184

    
185
ipa_item:
186
    ipa_el
187
  | ipa_ne;
188
 
189
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
 {
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
   this_nbma->eligible=1;
204
 }
205
;
206

    
207
 
208
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
  OSPF_PATT->pollint = POLLINT_D;
215
  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
  OSPF_PATT->dead = 0;
221
  OSPF_PATT->type = OSPF_IT_UNDEF;
222
  OSPF_PATT->strictnbma = 0;
223
  OSPF_PATT->stub = 0;
224
  init_list(&OSPF_PATT->nbma_list);
225
  OSPF_PATT->autype = OSPF_AUTH_NONE;
226
 }
227
;
228

    
229
ospf_iface_opts:
230
   /* empty */
231
 | ospf_iface_opts ospf_iface_item ';'
232
 ;
233

    
234
ospf_iface_opt_list:
235
   /* empty */
236
 | '{' ospf_iface_opts '}'
237
 ;
238

    
239
ospf_iface:
240
  ospf_iface_start iface_patt ospf_iface_opt_list
241
 ;
242

    
243
ospf_iface_list:
244
   ospf_iface
245
 | ospf_iface_list ',' ospf_iface
246
 ;
247

    
248
opttext:
249
    TEXT
250
 | /* empty */ { $$ = NULL; }
251
 ;
252

    
253
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
CF_CLI(SHOW OSPF, optsym, [<name>], [[Show information about OSPF protocol]])
258
{ ospf_sh(proto_get_named($3, &proto_ospf)); };
259

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

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

    
266
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
CF_CODE
273

    
274
CF_END