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