Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (7.69 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

    
30
%type <t> opttext
31

    
32
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
     this_proto->preference = DEF_PREF_OSPF;
39
     init_list(&OSPF_CFG->area_list);
40
     OSPF_CFG->rfc1583 = DEFAULT_RFC1583;
41
     OSPF_CFG->tick = DEFAULT_OSPFTICK;
42
  }
43
 ;
44

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

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

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

    
68
ospf_area: ospf_area_start ospf_area_opts
69
 ;
70

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

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

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

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

    
94
ospf_vlink_item:
95
 | HELLO expr { OSPF_PATT->helloint = $2 ; if (($2<=0) || ($2>65535)) cf_error("Hello interval must be in range 1-65535"); }
96
 | 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
 | AUTHENTICATION NONE { OSPF_PATT->autype = OSPF_AUTH_NONE ; }
101
 | AUTHENTICATION SIMPLE { OSPF_PATT->autype = OSPF_AUTH_SIMPLE ; }
102
 | AUTHENTICATION CRYPTOGRAPHIC { OSPF_PATT->autype = OSPF_AUTH_CRYPT ; }
103
 | password_list {OSPF_PATT->passwords = $1; }
104
 ;
105

    
106
ospf_vlink_start: VIRTUAL LINK idval
107
 {
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
  add_tail(&this_area->vlink_list, NODE this_ipatt);
111
  OSPF_PATT->vid = $3;
112
  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
  init_list(&OSPF_PATT->nbma_list);
120
  OSPF_PATT->autype = OSPF_AUTH_NONE;
121
 }
122
;
123

    
124
ospf_iface_item:
125
   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
 | WAIT expr { OSPF_PATT->waitint = $2 ; }
132
 | DEAD COUNT expr { OSPF_PATT->deadc = $3 ; if ($3<=1) cf_error("Dead count must be greater than one"); }
133
 | 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
 | STRICT NONBROADCAST bool { OSPF_PATT->strictnbma = $3 ; }
137
 | STUB bool { OSPF_PATT->stub = $2 ; }
138
 | NEIGHBORS '{' ipa_list '}'
139
 | AUTHENTICATION NONE { OSPF_PATT->autype = OSPF_AUTH_NONE ; }
140
 | AUTHENTICATION SIMPLE { OSPF_PATT->autype = OSPF_AUTH_SIMPLE ; }
141
 | AUTHENTICATION CRYPTOGRAPHIC { OSPF_PATT->autype = OSPF_AUTH_CRYPT ; }
142
 | password_list {OSPF_PATT->passwords = $1; }
143
 ;
144

    
145
pref_list:
146
 /* empty */
147
 | pref_list pref_item
148
 ;
149

    
150
pref_item:
151
   pref_el
152
 | pref_hid;
153

    
154
pref_el: prefix ';'
155
 {
156
   this_pref = cfg_allocz(sizeof(struct area_net_config));
157
   add_tail(&this_area->net_list, NODE this_pref);
158
   this_pref->px.addr = $1.addr;
159
   this_pref->px.len = $1.len;
160
 }
161
;
162

    
163
pref_hid: prefix HIDDEN ';'
164
 {
165
   this_pref = cfg_allocz(sizeof(struct area_net_config));
166
   add_tail(&this_area->net_list, NODE this_pref);
167
   this_pref->px.addr = $1.addr;
168
   this_pref->px.len = $1.len;
169
   this_pref->hidden = 1;
170
 }
171
;
172

    
173
ipa_list:
174
 /* empty */
175
 | ipa_list ipa_item
176
 ;
177

    
178
ipa_item:
179
    ipa_el
180
  | ipa_ne;
181
 
182
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
 {
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
   this_nbma->eligible=1;
197
 }
198
;
199

    
200
 
201
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
  OSPF_PATT->pollint = POLLINT_D;
208
  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
  OSPF_PATT->strictnbma = 0;
215
  OSPF_PATT->stub = 0;
216
  init_list(&OSPF_PATT->nbma_list);
217
  OSPF_PATT->autype = OSPF_AUTH_NONE;
218
 }
219
;
220

    
221
ospf_iface_opts:
222
   /* empty */
223
 | ospf_iface_opts ospf_iface_item ';'
224
 ;
225

    
226
ospf_iface_opt_list:
227
   /* empty */
228
 | '{' ospf_iface_opts '}'
229
 ;
230

    
231
ospf_iface:
232
  ospf_iface_start iface_patt ospf_iface_opt_list
233
 ;
234

    
235
ospf_iface_list:
236
   ospf_iface
237
 | ospf_iface_list ',' ospf_iface
238
 ;
239

    
240
opttext:
241
    TEXT
242
 | /* empty */ { $$ = NULL; }
243
 ;
244

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

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

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

    
258
CF_CODE
259

    
260
CF_END