]>
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); |
d631698e | 40 | OSPF_CFG->rfc1583 = DEFAULT_RFC1583; |
b8f17cf1 | 41 | OSPF_CFG->tick = DEFAULT_OSPFTICK; |
c1f8dc91 OF |
42 | } |
43 | ; | |
44 | ||
45 | ospf_proto: | |
46 | ospf_proto_start proto_name '{' | |
f8032bbd MM |
47 | | ospf_proto ospf_proto_item ';' |
48 | ; | |
49 | ||
50 | ospf_proto_item: | |
51 | proto_item | |
52 | | RFC1583COMPAT bool ';' { OSPF_CFG->rfc1583 = $2; } | |
b8f17cf1 | 53 | | TICK expr { OSPF_CFG->tick = $2 ; if($2<=0) cf_error("Tick must be greater than zero"); } |
f8032bbd MM |
54 | | ospf_area '}' |
55 | ; | |
c1f8dc91 | 56 | |
b36a0a79 OF |
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; | |
b8f17cf1 | 61 | this_area->tick = DEFAULT_AREATICK; |
b36a0a79 | 62 | this_area->stub = 0; |
89d6782d | 63 | init_list(&this_area->patt_list); |
c926eee7 | 64 | init_list(&this_area->net_list); |
c1f8dc91 | 65 | } |
f8032bbd | 66 | ; |
c4f0f014 | 67 | |
71f7d043 | 68 | ospf_area: ospf_area_start ospf_area_opts |
f8032bbd | 69 | ; |
a789d814 OF |
70 | |
71 | ospf_area_opts: | |
f8032bbd MM |
72 | /* empty */ |
73 | | ospf_area_opts ospf_area_item ';' | |
74 | ; | |
a789d814 | 75 | |
b36a0a79 | 76 | ospf_area_item: |
b2bdb406 | 77 | STUB COST expr { this_area->stub = $3 ; if($3<=0) cf_error("Stub cost must be greater than zero"); } |
bd457b8d | 78 | | TICK expr { this_area->tick = $2 ; if($2<=0) cf_error("Tick must be greater than zero"); } |
c926eee7 | 79 | | NETWORKS '{' pref_list '}' |
f8032bbd MM |
80 | | INTERFACE ospf_iface_list |
81 | ; | |
89d6782d OF |
82 | |
83 | ospf_iface_item: | |
7df86c25 OF |
84 | COST expr { OSPF_PATT->cost = $2 ; if (($2<=0) || ($2>65535)) cf_error("Cost must be in range 1-65535"); } |
85 | | HELLO expr { OSPF_PATT->helloint = $2 ; if (($2<=0) || ($2>65535)) cf_error("Hello interval must be in range 1-65535"); } | |
86 | | POLL expr { OSPF_PATT->pollint = $2 ; if ($2<=0) cf_error("Poll int must be greater than zero"); } | |
87 | | RETRANSMIT expr { OSPF_PATT->rxmtint = $2 ; if ($2<=0) cf_error("Retransmit int must be greater than zero"); } | |
88 | | TRANSMIT DELAY expr { OSPF_PATT->inftransdelay = $3 ; if (($3<=0) || ($3>65535)) cf_error("Transmit delay must be in range 1-65535"); } | |
89 | | PRIORITY expr { OSPF_PATT->priority = $2 ; if (($2<0) || ($2>255)) cf_error("Priority must be in range 0-255")} | |
bd457b8d | 90 | | WAIT expr { OSPF_PATT->waitint = $2 ; } |
7df86c25 | 91 | | DEAD COUNT expr { OSPF_PATT->deadc = $3 ; if ($3<=1) cf_error("Dead count must be greater than one"); } |
aaaff776 OF |
92 | | TYPE BROADCAST { OSPF_PATT->type = OSPF_IT_BCAST ; } |
93 | | TYPE NONBROADCAST { OSPF_PATT->type = OSPF_IT_NBMA ; } | |
94 | | TYPE POINTOPOINT { OSPF_PATT->type = OSPF_IT_PTP ; } | |
a190e720 | 95 | | STRICT NONBROADCAST bool { OSPF_PATT->strictnbma = $3 ; } |
e3bc10fd | 96 | | STUB bool { OSPF_PATT->stub = $2 ; } |
e5b5d18c | 97 | | NEIGHBORS '{' ipa_list '}' |
c1824c4d OF |
98 | | AUTHENTICATION NONE { OSPF_PATT->autype=AU_NONE ; } |
99 | | AUTHENTICATION SIMPLE { OSPF_PATT->autype=AU_SIMPLE ; } | |
100 | | PASSWORD TEXT { memcpy(OSPF_PATT->password, $2, 8); } | |
f8032bbd | 101 | ; |
e5b5d18c | 102 | |
c926eee7 OF |
103 | pref_list: |
104 | /* empty */ | |
105 | | pref_list pref_item | |
106 | ; | |
107 | ||
108 | pref_item: | |
de259a41 | 109 | pref_el |
c926eee7 OF |
110 | | pref_hid; |
111 | ||
112 | pref_el: prefix ';' | |
113 | { | |
114 | this_pref = cfg_allocz(sizeof(struct area_net)); | |
115 | add_tail(&this_area->net_list, NODE this_pref); | |
66261211 OF |
116 | this_pref->px.addr = $1.addr; |
117 | this_pref->px.len = $1.len; | |
c926eee7 OF |
118 | } |
119 | ; | |
120 | ||
121 | pref_hid: prefix HIDDEN ';' | |
122 | { | |
123 | this_pref = cfg_allocz(sizeof(struct area_net)); | |
124 | add_tail(&this_area->net_list, NODE this_pref); | |
66261211 OF |
125 | this_pref->px.addr = $1.addr; |
126 | this_pref->px.len = $1.len; | |
c926eee7 OF |
127 | this_pref->hidden = 1; |
128 | } | |
129 | ; | |
130 | ||
e5b5d18c OF |
131 | ipa_list: |
132 | /* empty */ | |
133 | | ipa_list ipa_item | |
134 | ; | |
a190e720 OF |
135 | |
136 | ipa_item: | |
de259a41 | 137 | ipa_el |
a190e720 | 138 | | ipa_ne; |
e5b5d18c | 139 | |
a190e720 OF |
140 | ipa_el: IPA ';' |
141 | { | |
142 | this_nbma = cfg_allocz(sizeof(struct nbma_node)); | |
143 | add_tail(&OSPF_PATT->nbma_list, NODE this_nbma); | |
144 | this_nbma->ip=$1; | |
145 | this_nbma->eligible=0; | |
146 | } | |
147 | ; | |
148 | ||
149 | ipa_ne: IPA ELIGIBLE ';' | |
e5b5d18c OF |
150 | { |
151 | this_nbma = cfg_allocz(sizeof(struct nbma_node)); | |
152 | add_tail(&OSPF_PATT->nbma_list, NODE this_nbma); | |
153 | this_nbma->ip=$1; | |
a190e720 | 154 | this_nbma->eligible=1; |
e5b5d18c OF |
155 | } |
156 | ; | |
157 | ||
b36a0a79 | 158 | |
aaaff776 OF |
159 | ospf_iface_start: |
160 | { | |
161 | this_ipatt = cfg_allocz(sizeof(struct ospf_iface_patt)); | |
162 | add_tail(&this_area->patt_list, NODE this_ipatt); | |
163 | OSPF_PATT->cost = COST_D; | |
164 | OSPF_PATT->helloint = HELLOINT_D; | |
a190e720 | 165 | OSPF_PATT->pollint = POLLINT_D; |
aaaff776 OF |
166 | OSPF_PATT->rxmtint = RXMTINT_D; |
167 | OSPF_PATT->inftransdelay = INFTRANSDELAY_D; | |
168 | OSPF_PATT->priority = PRIORITY_D; | |
169 | OSPF_PATT->waitint = WAIT_DMH*HELLOINT_D; | |
170 | OSPF_PATT->deadc = DEADC_D; | |
171 | OSPF_PATT->type = OSPF_IT_UNDEF; | |
a190e720 | 172 | OSPF_PATT->strictnbma = 0; |
e3bc10fd | 173 | OSPF_PATT->stub = 0; |
e5b5d18c | 174 | init_list(&OSPF_PATT->nbma_list); |
c1824c4d | 175 | OSPF_PATT->autype=AU_NONE; |
aaaff776 OF |
176 | } |
177 | ; | |
178 | ||
89d6782d | 179 | ospf_iface_opts: |
f8032bbd | 180 | /* empty */ |
89d6782d OF |
181 | | ospf_iface_opts ospf_iface_item ';' |
182 | ; | |
183 | ||
f8032bbd MM |
184 | ospf_iface_opt_list: |
185 | /* empty */ | |
186 | | '{' ospf_iface_opts '}' | |
187 | ; | |
89d6782d | 188 | |
89d6782d OF |
189 | ospf_iface: |
190 | ospf_iface_start iface_patt ospf_iface_opt_list | |
f8032bbd | 191 | ; |
89d6782d OF |
192 | |
193 | ospf_iface_list: | |
f8032bbd | 194 | ospf_iface |
89d6782d OF |
195 | | ospf_iface_list ',' ospf_iface |
196 | ; | |
197 | ||
c4f0f014 OF |
198 | opttext: |
199 | TEXT | |
f8032bbd MM |
200 | | /* empty */ { $$ = NULL; } |
201 | ; | |
c1f8dc91 | 202 | |
5919c66e MM |
203 | CF_ADDTO(dynamic_attr, OSPF_METRIC1 { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_METRIC1); }) |
204 | CF_ADDTO(dynamic_attr, OSPF_METRIC2 { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_METRIC2); }) | |
205 | CF_ADDTO(dynamic_attr, OSPF_TAG { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_TAG); }) | |
206 | ||
ec423cc7 | 207 | CF_CLI(SHOW OSPF, optsym, [<name>], [[Show information about OSPF protocol]]) |
4ab4e977 OF |
208 | { ospf_sh(proto_get_named($3, &proto_ospf)); } ; |
209 | ||
ec423cc7 | 210 | CF_CLI(SHOW OSPF NEIGHBORS, optsym opttext, [<name>] [\"<interface>\"], [[Show information about OSPF neighbors]]) |
c4f0f014 OF |
211 | { ospf_sh_neigh(proto_get_named($4, &proto_ospf), $5); } ; |
212 | ||
ec423cc7 | 213 | CF_CLI(SHOW OSPF INTERFACE, optsym opttext, [<name>] [\"<interface>\"], [[Show information about interface]]) |
c4f0f014 | 214 | { ospf_sh_iface(proto_get_named($4, &proto_ospf), $5); }; |
a783e259 | 215 | |
c1f8dc91 OF |
216 | CF_CODE |
217 | ||
218 | CF_END |