]>
Commit | Line | Data |
---|---|---|
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 | ||
9 | CF_HDR | |
10 | ||
11 | #include "proto/ospf/ospf.h" | |
12 | ||
3fa5722d OF |
13 | CF_DEFINES |
14 | ||
15 | #define OSPF_CFG ((struct ospf_config *) this_proto) | |
b36a0a79 | 16 | static struct ospf_area_config *this_area; |
89d6782d OF |
17 | static struct iface_patt *this_ipatt; |
18 | #define OSPF_PATT ((struct ospf_iface_patt *) this_ipatt) | |
e5b5d18c | 19 | static struct nbma_node *this_nbma; |
c926eee7 | 20 | static struct area_net *this_pref; |
3fa5722d | 21 | |
c1f8dc91 OF |
22 | CF_DECLS |
23 | ||
5919c66e | 24 | CF_KEYWORDS(OSPF, AREA, OSPF_METRIC1, OSPF_METRIC2, OSPF_TAG) |
89d6782d | 25 | CF_KEYWORDS(NEIGHBORS, RFC1583COMPAT, STUB, TICK, COST, RETRANSMIT) |
bd457b8d | 26 | CF_KEYWORDS(HELLO, TRANSMIT, PRIORITY, DEAD, NONBROADCAST, POINTOPOINT, TYPE) |
c926eee7 OF |
27 | CF_KEYWORDS(NONE, SIMPLE, AUTHENTICATION, PASSWORD, STRICT) |
28 | CF_KEYWORDS(ELIGIBLE, POLL, NETWORKS, HIDDEN) | |
c1f8dc91 | 29 | |
c4f0f014 OF |
30 | %type <t> opttext |
31 | ||
c1f8dc91 OF |
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)); | |
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 | ||
44 | ospf_proto: | |
45 | ospf_proto_start proto_name '{' | |
f8032bbd MM |
46 | | ospf_proto ospf_proto_item ';' |
47 | ; | |
48 | ||
49 | ospf_proto_item: | |
50 | proto_item | |
51 | | RFC1583COMPAT bool ';' { OSPF_CFG->rfc1583 = $2; } | |
52 | | ospf_area '}' | |
53 | ; | |
c1f8dc91 | 54 | |
b36a0a79 OF |
55 | ospf_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 | 66 | ospf_area: ospf_area_start ospf_area_opts |
f8032bbd | 67 | ; |
a789d814 OF |
68 | |
69 | ospf_area_opts: | |
f8032bbd MM |
70 | /* empty */ |
71 | | ospf_area_opts ospf_area_item ';' | |
72 | ; | |
a789d814 | 73 | |
b36a0a79 | 74 | ospf_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 | |
81 | ospf_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 |
102 | pref_list: |
103 | /* empty */ | |
104 | | pref_list pref_item | |
105 | ; | |
106 | ||
107 | pref_item: | |
de259a41 | 108 | pref_el |
c926eee7 OF |
109 | | pref_hid; |
110 | ||
111 | pref_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 | ||
120 | pref_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 |
130 | ipa_list: |
131 | /* empty */ | |
132 | | ipa_list ipa_item | |
133 | ; | |
a190e720 OF |
134 | |
135 | ipa_item: | |
de259a41 | 136 | ipa_el |
a190e720 | 137 | | ipa_ne; |
e5b5d18c | 138 | |
a190e720 OF |
139 | ipa_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 | ||
148 | ipa_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 |
158 | ospf_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 | 178 | ospf_iface_opts: |
f8032bbd | 179 | /* empty */ |
89d6782d OF |
180 | | ospf_iface_opts ospf_iface_item ';' |
181 | ; | |
182 | ||
f8032bbd MM |
183 | ospf_iface_opt_list: |
184 | /* empty */ | |
185 | | '{' ospf_iface_opts '}' | |
186 | ; | |
89d6782d | 187 | |
89d6782d OF |
188 | ospf_iface: |
189 | ospf_iface_start iface_patt ospf_iface_opt_list | |
f8032bbd | 190 | ; |
89d6782d OF |
191 | |
192 | ospf_iface_list: | |
f8032bbd | 193 | ospf_iface |
89d6782d OF |
194 | | ospf_iface_list ',' ospf_iface |
195 | ; | |
196 | ||
c4f0f014 OF |
197 | opttext: |
198 | TEXT | |
f8032bbd MM |
199 | | /* empty */ { $$ = NULL; } |
200 | ; | |
c1f8dc91 | 201 | |
5919c66e MM |
202 | CF_ADDTO(dynamic_attr, OSPF_METRIC1 { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_METRIC1); }) |
203 | CF_ADDTO(dynamic_attr, OSPF_METRIC2 { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_METRIC2); }) | |
204 | CF_ADDTO(dynamic_attr, OSPF_TAG { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_TAG); }) | |
205 | ||
ec423cc7 | 206 | CF_CLI(SHOW OSPF, optsym, [<name>], [[Show information about OSPF protocol]]) |
4ab4e977 OF |
207 | { ospf_sh(proto_get_named($3, &proto_ospf)); } ; |
208 | ||
ec423cc7 | 209 | CF_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 | 212 | CF_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 |
215 | CF_CODE |
216 | ||
217 | CF_END |