]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
508e53e2 | 2 | * Copyright (C) 2003 Yasuhiro Ohara |
718e3744 | 3 | * |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
896014f4 DL |
16 | * You should have received a copy of the GNU General Public License along |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
718e3744 | 19 | */ |
20 | ||
21 | #include <zebra.h> | |
22 | ||
23 | #include "log.h" | |
24 | #include "memory.h" | |
25 | #include "vty.h" | |
26 | #include "linklist.h" | |
27 | #include "prefix.h" | |
28 | #include "table.h" | |
29 | #include "thread.h" | |
30 | #include "command.h" | |
8efe88ea | 31 | #include "defaults.h" |
718e3744 | 32 | |
718e3744 | 33 | #include "ospf6_proto.h" |
508e53e2 | 34 | #include "ospf6_message.h" |
718e3744 | 35 | #include "ospf6_lsa.h" |
36 | #include "ospf6_lsdb.h" | |
718e3744 | 37 | #include "ospf6_route.h" |
38 | #include "ospf6_zebra.h" | |
39 | ||
508e53e2 | 40 | #include "ospf6_top.h" |
41 | #include "ospf6_area.h" | |
42 | #include "ospf6_interface.h" | |
43 | #include "ospf6_neighbor.h" | |
718e3744 | 44 | |
6452df09 | 45 | #include "ospf6_flood.h" |
508e53e2 | 46 | #include "ospf6_asbr.h" |
049207c3 | 47 | #include "ospf6_abr.h" |
6452df09 | 48 | #include "ospf6_intra.h" |
3810e06e | 49 | #include "ospf6_spf.h" |
049207c3 | 50 | #include "ospf6d.h" |
718e3744 | 51 | |
ae19c240 DL |
52 | DEFINE_QOBJ_TYPE(ospf6) |
53 | ||
718e3744 | 54 | /* global ospf6d variable */ |
55 | struct ospf6 *ospf6; | |
56 | ||
d62a17ae | 57 | static void ospf6_disable(struct ospf6 *o); |
ae2254aa | 58 | |
d62a17ae | 59 | static void ospf6_top_lsdb_hook_add(struct ospf6_lsa *lsa) |
718e3744 | 60 | { |
d62a17ae | 61 | switch (ntohs(lsa->header->type)) { |
62 | case OSPF6_LSTYPE_AS_EXTERNAL: | |
63 | ospf6_asbr_lsa_add(lsa); | |
64 | break; | |
65 | ||
66 | default: | |
67 | break; | |
68 | } | |
718e3744 | 69 | } |
70 | ||
d62a17ae | 71 | static void ospf6_top_lsdb_hook_remove(struct ospf6_lsa *lsa) |
718e3744 | 72 | { |
d62a17ae | 73 | switch (ntohs(lsa->header->type)) { |
74 | case OSPF6_LSTYPE_AS_EXTERNAL: | |
07b37f93 | 75 | ospf6_asbr_lsa_remove(lsa, NULL); |
d62a17ae | 76 | break; |
77 | ||
78 | default: | |
79 | break; | |
80 | } | |
718e3744 | 81 | } |
82 | ||
d62a17ae | 83 | static void ospf6_top_route_hook_add(struct ospf6_route *route) |
049207c3 | 84 | { |
d62a17ae | 85 | ospf6_abr_originate_summary(route); |
86 | ospf6_zebra_route_update_add(route); | |
049207c3 | 87 | } |
88 | ||
d62a17ae | 89 | static void ospf6_top_route_hook_remove(struct ospf6_route *route) |
049207c3 | 90 | { |
d62a17ae | 91 | route->flag |= OSPF6_ROUTE_REMOVE; |
92 | ospf6_abr_originate_summary(route); | |
93 | ospf6_zebra_route_update_remove(route); | |
049207c3 | 94 | } |
95 | ||
d62a17ae | 96 | static void ospf6_top_brouter_hook_add(struct ospf6_route *route) |
6452df09 | 97 | { |
064d4355 | 98 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { |
07b37f93 CS |
99 | uint32_t brouter_id; |
100 | char brouter_name[16]; | |
101 | ||
102 | brouter_id = ADV_ROUTER_IN_PREFIX(&route->prefix); | |
103 | inet_ntop(AF_INET, &brouter_id, brouter_name, | |
104 | sizeof(brouter_name)); | |
105 | zlog_debug("%s: brouter %s add with adv router %x nh count %u", | |
106 | __PRETTY_FUNCTION__, brouter_name, | |
107 | route->path.origin.adv_router, | |
108 | listcount(route->nh_list)); | |
064d4355 | 109 | } |
d62a17ae | 110 | ospf6_abr_examin_brouter(ADV_ROUTER_IN_PREFIX(&route->prefix)); |
111 | ospf6_asbr_lsentry_add(route); | |
112 | ospf6_abr_originate_summary(route); | |
6452df09 | 113 | } |
114 | ||
d62a17ae | 115 | static void ospf6_top_brouter_hook_remove(struct ospf6_route *route) |
6452df09 | 116 | { |
064d4355 | 117 | if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { |
07b37f93 CS |
118 | uint32_t brouter_id; |
119 | char brouter_name[16]; | |
064d4355 | 120 | |
07b37f93 CS |
121 | brouter_id = ADV_ROUTER_IN_PREFIX(&route->prefix); |
122 | inet_ntop(AF_INET, &brouter_id, brouter_name, | |
123 | sizeof(brouter_name)); | |
064d4355 | 124 | zlog_debug("%s: brouter %s del with nh count %u", |
07b37f93 CS |
125 | __PRETTY_FUNCTION__, brouter_name, |
126 | listcount(route->nh_list)); | |
064d4355 | 127 | } |
d62a17ae | 128 | route->flag |= OSPF6_ROUTE_REMOVE; |
129 | ospf6_abr_examin_brouter(ADV_ROUTER_IN_PREFIX(&route->prefix)); | |
130 | ospf6_asbr_lsentry_remove(route); | |
131 | ospf6_abr_originate_summary(route); | |
6452df09 | 132 | } |
133 | ||
d62a17ae | 134 | static struct ospf6 *ospf6_create(void) |
718e3744 | 135 | { |
d62a17ae | 136 | struct ospf6 *o; |
718e3744 | 137 | |
d62a17ae | 138 | o = XCALLOC(MTYPE_OSPF6_TOP, sizeof(struct ospf6)); |
718e3744 | 139 | |
d62a17ae | 140 | /* initialize */ |
141 | monotime(&o->starttime); | |
142 | o->area_list = list_new(); | |
143 | o->area_list->cmp = ospf6_area_cmp; | |
144 | o->lsdb = ospf6_lsdb_create(o); | |
145 | o->lsdb_self = ospf6_lsdb_create(o); | |
146 | o->lsdb->hook_add = ospf6_top_lsdb_hook_add; | |
147 | o->lsdb->hook_remove = ospf6_top_lsdb_hook_remove; | |
718e3744 | 148 | |
d62a17ae | 149 | o->spf_delay = OSPF_SPF_DELAY_DEFAULT; |
150 | o->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT; | |
151 | o->spf_max_holdtime = OSPF_SPF_MAX_HOLDTIME_DEFAULT; | |
152 | o->spf_hold_multiplier = 1; | |
3810e06e | 153 | |
d62a17ae | 154 | /* LSA timers value init */ |
155 | o->lsa_minarrival = OSPF_MIN_LS_ARRIVAL; | |
b6927875 | 156 | |
d62a17ae | 157 | o->route_table = OSPF6_ROUTE_TABLE_CREATE(GLOBAL, ROUTES); |
158 | o->route_table->scope = o; | |
159 | o->route_table->hook_add = ospf6_top_route_hook_add; | |
160 | o->route_table->hook_remove = ospf6_top_route_hook_remove; | |
718e3744 | 161 | |
d62a17ae | 162 | o->brouter_table = OSPF6_ROUTE_TABLE_CREATE(GLOBAL, BORDER_ROUTERS); |
163 | o->brouter_table->scope = o; | |
164 | o->brouter_table->hook_add = ospf6_top_brouter_hook_add; | |
165 | o->brouter_table->hook_remove = ospf6_top_brouter_hook_remove; | |
049207c3 | 166 | |
d62a17ae | 167 | o->external_table = OSPF6_ROUTE_TABLE_CREATE(GLOBAL, EXTERNAL_ROUTES); |
168 | o->external_table->scope = o; | |
cf1ce250 | 169 | |
d62a17ae | 170 | o->external_id_table = route_table_init(); |
718e3744 | 171 | |
d62a17ae | 172 | o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH; |
fd500689 | 173 | |
d62a17ae | 174 | o->distance_table = route_table_init(); |
baff583e | 175 | |
d62a17ae | 176 | /* Enable "log-adjacency-changes" */ |
8efe88ea | 177 | #if DFLT_OSPF6_LOG_ADJACENCY_CHANGES |
d62a17ae | 178 | SET_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_CHANGES); |
8efe88ea | 179 | #endif |
692c7954 | 180 | |
d62a17ae | 181 | QOBJ_REG(o, ospf6); |
692c7954 | 182 | |
d62a17ae | 183 | return o; |
718e3744 | 184 | } |
185 | ||
d62a17ae | 186 | void ospf6_delete(struct ospf6 *o) |
718e3744 | 187 | { |
d62a17ae | 188 | struct listnode *node, *nnode; |
189 | struct ospf6_area *oa; | |
718e3744 | 190 | |
d62a17ae | 191 | QOBJ_UNREG(o); |
76249532 CS |
192 | |
193 | ospf6_flush_self_originated_lsas_now(); | |
d62a17ae | 194 | ospf6_disable(ospf6); |
ae2254aa | 195 | |
d62a17ae | 196 | for (ALL_LIST_ELEMENTS(o->area_list, node, nnode, oa)) |
197 | ospf6_area_delete(oa); | |
d9628728 CF |
198 | |
199 | ||
affe9e99 | 200 | list_delete_and_null(&o->area_list); |
718e3744 | 201 | |
d62a17ae | 202 | ospf6_lsdb_delete(o->lsdb); |
203 | ospf6_lsdb_delete(o->lsdb_self); | |
718e3744 | 204 | |
d62a17ae | 205 | ospf6_route_table_delete(o->route_table); |
206 | ospf6_route_table_delete(o->brouter_table); | |
718e3744 | 207 | |
d62a17ae | 208 | ospf6_route_table_delete(o->external_table); |
209 | route_table_finish(o->external_id_table); | |
718e3744 | 210 | |
d62a17ae | 211 | ospf6_distance_reset(o); |
212 | route_table_finish(o->distance_table); | |
baff583e | 213 | |
d62a17ae | 214 | XFREE(MTYPE_OSPF6_TOP, o); |
508e53e2 | 215 | } |
718e3744 | 216 | |
d62a17ae | 217 | static void ospf6_disable(struct ospf6 *o) |
718e3744 | 218 | { |
d62a17ae | 219 | struct listnode *node, *nnode; |
220 | struct ospf6_area *oa; | |
221 | ||
222 | if (!CHECK_FLAG(o->flag, OSPF6_DISABLED)) { | |
223 | SET_FLAG(o->flag, OSPF6_DISABLED); | |
224 | ||
225 | for (ALL_LIST_ELEMENTS(o->area_list, node, nnode, oa)) | |
226 | ospf6_area_disable(oa); | |
227 | ||
228 | /* XXX: This also changes persistent settings */ | |
229 | ospf6_asbr_redistribute_reset(); | |
230 | ||
231 | ospf6_lsdb_remove_all(o->lsdb); | |
232 | ospf6_route_remove_all(o->route_table); | |
233 | ospf6_route_remove_all(o->brouter_table); | |
234 | ||
235 | THREAD_OFF(o->maxage_remover); | |
236 | THREAD_OFF(o->t_spf_calc); | |
237 | THREAD_OFF(o->t_ase_calc); | |
856ae1eb | 238 | THREAD_OFF(o->t_distribute_update); |
d62a17ae | 239 | } |
508e53e2 | 240 | } |
718e3744 | 241 | |
d62a17ae | 242 | static int ospf6_maxage_remover(struct thread *thread) |
508e53e2 | 243 | { |
d62a17ae | 244 | struct ospf6 *o = (struct ospf6 *)THREAD_ARG(thread); |
245 | struct ospf6_area *oa; | |
246 | struct ospf6_interface *oi; | |
247 | struct ospf6_neighbor *on; | |
248 | struct listnode *i, *j, *k; | |
249 | int reschedule = 0; | |
250 | ||
251 | o->maxage_remover = (struct thread *)NULL; | |
252 | ||
253 | for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) { | |
254 | for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) { | |
255 | for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, k, on)) { | |
256 | if (on->state != OSPF6_NEIGHBOR_EXCHANGE | |
257 | && on->state != OSPF6_NEIGHBOR_LOADING) | |
258 | continue; | |
259 | ||
260 | ospf6_maxage_remove(o); | |
261 | return 0; | |
262 | } | |
263 | } | |
2449fcd6 | 264 | } |
d62a17ae | 265 | |
266 | for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) { | |
267 | for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) { | |
268 | if (ospf6_lsdb_maxage_remover(oi->lsdb)) { | |
269 | reschedule = 1; | |
270 | } | |
271 | } | |
272 | ||
273 | if (ospf6_lsdb_maxage_remover(oa->lsdb)) { | |
274 | reschedule = 1; | |
275 | } | |
2449fcd6 | 276 | } |
2449fcd6 | 277 | |
d62a17ae | 278 | if (ospf6_lsdb_maxage_remover(o->lsdb)) { |
279 | reschedule = 1; | |
280 | } | |
2449fcd6 | 281 | |
d62a17ae | 282 | if (reschedule) { |
283 | ospf6_maxage_remove(o); | |
284 | } | |
508e53e2 | 285 | |
d62a17ae | 286 | return 0; |
718e3744 | 287 | } |
288 | ||
d62a17ae | 289 | void ospf6_maxage_remove(struct ospf6 *o) |
718e3744 | 290 | { |
d62a17ae | 291 | if (o) |
292 | thread_add_timer(master, ospf6_maxage_remover, o, | |
293 | OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT, | |
294 | &o->maxage_remover); | |
718e3744 | 295 | } |
296 | ||
508e53e2 | 297 | /* start ospf6 */ |
505e5056 | 298 | DEFUN_NOSH (router_ospf6, |
508e53e2 | 299 | router_ospf6_cmd, |
300 | "router ospf6", | |
301 | ROUTER_STR | |
302 | OSPF6_STR) | |
718e3744 | 303 | { |
d62a17ae | 304 | if (ospf6 == NULL) |
305 | ospf6 = ospf6_create(); | |
508e53e2 | 306 | |
d62a17ae | 307 | /* set current ospf point. */ |
308 | VTY_PUSH_CONTEXT(OSPF6_NODE, ospf6); | |
508e53e2 | 309 | |
d62a17ae | 310 | return CMD_SUCCESS; |
718e3744 | 311 | } |
312 | ||
508e53e2 | 313 | /* stop ospf6 */ |
314 | DEFUN (no_router_ospf6, | |
315 | no_router_ospf6_cmd, | |
316 | "no router ospf6", | |
317 | NO_STR | |
16cedbb0 QY |
318 | ROUTER_STR |
319 | OSPF6_STR) | |
718e3744 | 320 | { |
d62a17ae | 321 | if (ospf6 == NULL) |
322 | vty_out(vty, "OSPFv3 is not configured\n"); | |
323 | else { | |
324 | ospf6_delete(ospf6); | |
325 | ospf6 = NULL; | |
326 | } | |
34288970 | 327 | |
d62a17ae | 328 | /* return to config node . */ |
329 | VTY_PUSH_CONTEXT_NULL(CONFIG_NODE); | |
508e53e2 | 330 | |
d62a17ae | 331 | return CMD_SUCCESS; |
718e3744 | 332 | } |
333 | ||
508e53e2 | 334 | /* change Router_ID commands. */ |
60466a63 QY |
335 | DEFUN(ospf6_router_id, |
336 | ospf6_router_id_cmd, | |
337 | "ospf6 router-id A.B.C.D", | |
338 | OSPF6_STR | |
339 | "Configure OSPF6 Router-ID\n" | |
340 | V4NOTATION_STR) | |
718e3744 | 341 | { |
d62a17ae | 342 | VTY_DECLVAR_CONTEXT(ospf6, o); |
5d1a2ee8 | 343 | int idx = 0; |
d62a17ae | 344 | int ret; |
5d1a2ee8 | 345 | const char *router_id_str; |
d62a17ae | 346 | u_int32_t router_id; |
d6927cf3 CS |
347 | struct ospf6_area *oa; |
348 | struct listnode *node; | |
d62a17ae | 349 | |
5d1a2ee8 QY |
350 | argv_find(argv, argc, "A.B.C.D", &idx); |
351 | router_id_str = argv[idx]->arg; | |
352 | ||
353 | ret = inet_pton(AF_INET, router_id_str, &router_id); | |
d62a17ae | 354 | if (ret == 0) { |
60466a63 | 355 | vty_out(vty, "malformed OSPF Router-ID: %s\n", router_id_str); |
d62a17ae | 356 | return CMD_SUCCESS; |
357 | } | |
508e53e2 | 358 | |
d62a17ae | 359 | o->router_id_static = router_id; |
d6927cf3 CS |
360 | |
361 | for (ALL_LIST_ELEMENTS_RO(o->area_list, node, oa)) { | |
362 | if (oa->full_nbrs) { | |
363 | vty_out(vty, | |
364 | "For this router-id change to take effect," | |
365 | " save config and restart ospf6d\n"); | |
366 | return CMD_SUCCESS; | |
367 | } | |
368 | } | |
369 | ||
370 | o->router_id = router_id; | |
c8a440ec | 371 | |
d62a17ae | 372 | return CMD_SUCCESS; |
718e3744 | 373 | } |
374 | ||
60466a63 QY |
375 | DEFUN(no_ospf6_router_id, |
376 | no_ospf6_router_id_cmd, | |
377 | "no ospf6 router-id [A.B.C.D]", | |
378 | NO_STR OSPF6_STR | |
379 | "Configure OSPF6 Router-ID\n" | |
380 | V4NOTATION_STR) | |
5d1a2ee8 QY |
381 | { |
382 | VTY_DECLVAR_CONTEXT(ospf6, o); | |
d6927cf3 CS |
383 | struct ospf6_area *oa; |
384 | struct listnode *node; | |
385 | ||
5d1a2ee8 | 386 | o->router_id_static = 0; |
d6927cf3 CS |
387 | |
388 | for (ALL_LIST_ELEMENTS_RO(o->area_list, node, oa)) { | |
389 | if (oa->full_nbrs) { | |
390 | vty_out(vty, | |
391 | "For this router-id change to take effect," | |
392 | " save config and restart ospf6d\n"); | |
393 | return CMD_SUCCESS; | |
394 | } | |
395 | } | |
5d1a2ee8 | 396 | o->router_id = 0; |
d6927cf3 CS |
397 | if (o->router_id_zebra.s_addr) |
398 | o->router_id = (uint32_t)o->router_id_zebra.s_addr; | |
5d1a2ee8 QY |
399 | |
400 | return CMD_SUCCESS; | |
401 | } | |
402 | ||
403 | #if CONFDATE > 20180828 | |
404 | CPP_NOTICE("ospf6: `router-id A.B.C.D` deprecated 2017/08/28") | |
405 | #endif | |
996c9314 LB |
406 | ALIAS_HIDDEN(ospf6_router_id, ospf6_router_id_hdn_cmd, "router-id A.B.C.D", |
407 | "Configure OSPF6 Router-ID\n" V4NOTATION_STR) | |
5d1a2ee8 QY |
408 | |
409 | #if CONFDATE > 20180828 | |
410 | CPP_NOTICE("ospf6: `no router-id A.B.C.D` deprecated 2017/08/28") | |
411 | #endif | |
996c9314 | 412 | ALIAS_HIDDEN(no_ospf6_router_id, no_ospf6_router_id_hdn_cmd, |
5d1a2ee8 | 413 | "no router-id [A.B.C.D]", |
996c9314 | 414 | NO_STR "Configure OSPF6 Router-ID\n" V4NOTATION_STR) |
5d1a2ee8 | 415 | |
3d35ca48 DD |
416 | DEFUN (ospf6_log_adjacency_changes, |
417 | ospf6_log_adjacency_changes_cmd, | |
418 | "log-adjacency-changes", | |
419 | "Log changes in adjacency state\n") | |
420 | { | |
d62a17ae | 421 | VTY_DECLVAR_CONTEXT(ospf6, ospf6); |
3d35ca48 | 422 | |
d62a17ae | 423 | SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES); |
424 | UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL); | |
425 | return CMD_SUCCESS; | |
3d35ca48 DD |
426 | } |
427 | ||
428 | DEFUN (ospf6_log_adjacency_changes_detail, | |
429 | ospf6_log_adjacency_changes_detail_cmd, | |
430 | "log-adjacency-changes detail", | |
692c7954 | 431 | "Log changes in adjacency state\n" |
3d35ca48 DD |
432 | "Log all state changes\n") |
433 | { | |
d62a17ae | 434 | VTY_DECLVAR_CONTEXT(ospf6, ospf6); |
3d35ca48 | 435 | |
d62a17ae | 436 | SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES); |
437 | SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL); | |
438 | return CMD_SUCCESS; | |
3d35ca48 DD |
439 | } |
440 | ||
441 | DEFUN (no_ospf6_log_adjacency_changes, | |
442 | no_ospf6_log_adjacency_changes_cmd, | |
443 | "no log-adjacency-changes", | |
692c7954 | 444 | NO_STR |
3d35ca48 DD |
445 | "Log changes in adjacency state\n") |
446 | { | |
d62a17ae | 447 | VTY_DECLVAR_CONTEXT(ospf6, ospf6); |
3d35ca48 | 448 | |
d62a17ae | 449 | UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL); |
450 | UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES); | |
451 | return CMD_SUCCESS; | |
3d35ca48 DD |
452 | } |
453 | ||
454 | DEFUN (no_ospf6_log_adjacency_changes_detail, | |
455 | no_ospf6_log_adjacency_changes_detail_cmd, | |
456 | "no log-adjacency-changes detail", | |
692c7954 DW |
457 | NO_STR |
458 | "Log changes in adjacency state\n" | |
3d35ca48 DD |
459 | "Log all state changes\n") |
460 | { | |
d62a17ae | 461 | VTY_DECLVAR_CONTEXT(ospf6, ospf6); |
3d35ca48 | 462 | |
d62a17ae | 463 | UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL); |
464 | return CMD_SUCCESS; | |
3d35ca48 DD |
465 | } |
466 | ||
b6927875 DS |
467 | DEFUN (ospf6_timers_lsa, |
468 | ospf6_timers_lsa_cmd, | |
6147e2c6 | 469 | "timers lsa min-arrival (0-600000)", |
b6927875 DS |
470 | "Adjust routing timers\n" |
471 | "OSPF6 LSA timers\n" | |
472 | "Minimum delay in receiving new version of a LSA\n" | |
473 | "Delay in milliseconds\n") | |
474 | { | |
d62a17ae | 475 | VTY_DECLVAR_CONTEXT(ospf6, ospf); |
476 | int idx_number = 3; | |
477 | unsigned int minarrival; | |
b6927875 | 478 | |
d62a17ae | 479 | minarrival = strtoul(argv[idx_number]->arg, NULL, 10); |
480 | ospf->lsa_minarrival = minarrival; | |
b6927875 | 481 | |
d62a17ae | 482 | return CMD_SUCCESS; |
b6927875 DS |
483 | } |
484 | ||
485 | DEFUN (no_ospf6_timers_lsa, | |
486 | no_ospf6_timers_lsa_cmd, | |
1d68dbfe | 487 | "no timers lsa min-arrival [(0-600000)]", |
b6927875 DS |
488 | NO_STR |
489 | "Adjust routing timers\n" | |
490 | "OSPF6 LSA timers\n" | |
3a2d747c QY |
491 | "Minimum delay in receiving new version of a LSA\n" |
492 | "Delay in milliseconds\n") | |
b6927875 | 493 | { |
d62a17ae | 494 | VTY_DECLVAR_CONTEXT(ospf6, ospf); |
495 | int idx_number = 4; | |
496 | unsigned int minarrival; | |
b6927875 | 497 | |
d62a17ae | 498 | if (argc == 5) { |
499 | minarrival = strtoul(argv[idx_number]->arg, NULL, 10); | |
b6927875 | 500 | |
d62a17ae | 501 | if (ospf->lsa_minarrival != minarrival |
502 | || minarrival == OSPF_MIN_LS_ARRIVAL) | |
503 | return CMD_SUCCESS; | |
504 | } | |
b6927875 | 505 | |
d62a17ae | 506 | ospf->lsa_minarrival = OSPF_MIN_LS_ARRIVAL; |
b6927875 | 507 | |
d62a17ae | 508 | return CMD_SUCCESS; |
b6927875 DS |
509 | } |
510 | ||
b6927875 | 511 | |
baff583e MZ |
512 | DEFUN (ospf6_distance, |
513 | ospf6_distance_cmd, | |
39e92c06 | 514 | "distance (1-255)", |
baff583e MZ |
515 | "Administrative distance\n" |
516 | "OSPF6 Administrative distance\n") | |
517 | { | |
d62a17ae | 518 | VTY_DECLVAR_CONTEXT(ospf6, o); |
baff583e | 519 | |
d62a17ae | 520 | o->distance_all = atoi(argv[1]->arg); |
baff583e | 521 | |
d62a17ae | 522 | return CMD_SUCCESS; |
baff583e MZ |
523 | } |
524 | ||
525 | DEFUN (no_ospf6_distance, | |
526 | no_ospf6_distance_cmd, | |
39e92c06 | 527 | "no distance (1-255)", |
baff583e MZ |
528 | NO_STR |
529 | "Administrative distance\n" | |
530 | "OSPF6 Administrative distance\n") | |
531 | { | |
d62a17ae | 532 | VTY_DECLVAR_CONTEXT(ospf6, o); |
baff583e | 533 | |
d62a17ae | 534 | o->distance_all = 0; |
baff583e | 535 | |
d62a17ae | 536 | return CMD_SUCCESS; |
baff583e MZ |
537 | } |
538 | ||
539 | DEFUN (ospf6_distance_ospf6, | |
540 | ospf6_distance_ospf6_cmd, | |
eaa1ae0d | 541 | "distance ospf6 {intra-area (1-255)|inter-area (1-255)|external (1-255)}", |
baff583e | 542 | "Administrative distance\n" |
eaa1ae0d | 543 | "OSPF6 administrative distance\n" |
39e92c06 QY |
544 | "Intra-area routes\n" |
545 | "Distance for intra-area routes\n" | |
546 | "Inter-area routes\n" | |
547 | "Distance for inter-area routes\n" | |
548 | "External routes\n" | |
baff583e MZ |
549 | "Distance for external routes\n") |
550 | { | |
d62a17ae | 551 | VTY_DECLVAR_CONTEXT(ospf6, o); |
552 | int idx = 0; | |
553 | ||
f89a449b CS |
554 | o->distance_intra = 0; |
555 | o->distance_inter = 0; | |
556 | o->distance_external = 0; | |
557 | ||
d62a17ae | 558 | if (argv_find(argv, argc, "intra-area", &idx)) |
559 | o->distance_intra = atoi(argv[idx + 1]->arg); | |
560 | idx = 0; | |
561 | if (argv_find(argv, argc, "inter-area", &idx)) | |
562 | o->distance_inter = atoi(argv[idx + 1]->arg); | |
563 | idx = 0; | |
564 | if (argv_find(argv, argc, "external", &idx)) | |
565 | o->distance_external = atoi(argv[idx + 1]->arg); | |
39e92c06 | 566 | |
d62a17ae | 567 | return CMD_SUCCESS; |
baff583e MZ |
568 | } |
569 | ||
570 | DEFUN (no_ospf6_distance_ospf6, | |
571 | no_ospf6_distance_ospf6_cmd, | |
eaa1ae0d | 572 | "no distance ospf6 [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]", |
baff583e MZ |
573 | NO_STR |
574 | "Administrative distance\n" | |
575 | "OSPF6 distance\n" | |
576 | "Intra-area routes\n" | |
577 | "Distance for intra-area routes\n" | |
578 | "Inter-area routes\n" | |
579 | "Distance for inter-area routes\n" | |
580 | "External routes\n" | |
581 | "Distance for external routes\n") | |
582 | { | |
d62a17ae | 583 | VTY_DECLVAR_CONTEXT(ospf6, o); |
584 | int idx = 0; | |
baff583e | 585 | |
d62a17ae | 586 | if (argv_find(argv, argc, "intra-area", &idx) || argc == 3) |
587 | idx = o->distance_intra = 0; | |
588 | if (argv_find(argv, argc, "inter-area", &idx) || argc == 3) | |
589 | idx = o->distance_inter = 0; | |
590 | if (argv_find(argv, argc, "external", &idx) || argc == 3) | |
591 | o->distance_external = 0; | |
baff583e | 592 | |
d62a17ae | 593 | return CMD_SUCCESS; |
baff583e MZ |
594 | } |
595 | ||
d7d73ffc | 596 | #if 0 |
baff583e MZ |
597 | DEFUN (ospf6_distance_source, |
598 | ospf6_distance_source_cmd, | |
39e92c06 | 599 | "distance (1-255) X:X::X:X/M [WORD]", |
baff583e MZ |
600 | "Administrative distance\n" |
601 | "Distance value\n" | |
602 | "IP source prefix\n" | |
603 | "Access list name\n") | |
604 | { | |
cdc2d765 | 605 | VTY_DECLVAR_CONTEXT(ospf6, o); |
39e92c06 QY |
606 | char *alname = (argc == 4) ? argv[3]->arg : NULL; |
607 | ospf6_distance_set (vty, o, argv[1]->arg, argv[2]->arg, alname); | |
baff583e MZ |
608 | |
609 | return CMD_SUCCESS; | |
610 | } | |
611 | ||
612 | DEFUN (no_ospf6_distance_source, | |
613 | no_ospf6_distance_source_cmd, | |
39e92c06 | 614 | "no distance (1-255) X:X::X:X/M [WORD]", |
baff583e MZ |
615 | NO_STR |
616 | "Administrative distance\n" | |
617 | "Distance value\n" | |
618 | "IP source prefix\n" | |
619 | "Access list name\n") | |
620 | { | |
cdc2d765 | 621 | VTY_DECLVAR_CONTEXT(ospf6, o); |
39e92c06 QY |
622 | char *alname = (argc == 5) ? argv[4]->arg : NULL; |
623 | ospf6_distance_unset (vty, o, argv[2]->arg, argv[3]->arg, alname); | |
baff583e MZ |
624 | |
625 | return CMD_SUCCESS; | |
626 | } | |
d7d73ffc | 627 | #endif |
baff583e | 628 | |
508e53e2 | 629 | DEFUN (ospf6_interface_area, |
630 | ospf6_interface_area_cmd, | |
631 | "interface IFNAME area A.B.C.D", | |
632 | "Enable routing on an IPv6 interface\n" | |
633 | IFNAME_STR | |
634 | "Specify the OSPF6 area ID\n" | |
635 | "OSPF6 area ID in IPv4 address notation\n" | |
636 | ) | |
718e3744 | 637 | { |
d62a17ae | 638 | VTY_DECLVAR_CONTEXT(ospf6, o); |
639 | int idx_ifname = 1; | |
640 | int idx_ipv4 = 3; | |
641 | struct ospf6_area *oa; | |
642 | struct ospf6_interface *oi; | |
643 | struct interface *ifp; | |
644 | u_int32_t area_id; | |
645 | ||
646 | /* find/create ospf6 interface */ | |
bcc24579 | 647 | ifp = if_get_by_name(argv[idx_ifname]->arg, VRF_DEFAULT, 0); |
d62a17ae | 648 | oi = (struct ospf6_interface *)ifp->info; |
649 | if (oi == NULL) | |
650 | oi = ospf6_interface_create(ifp); | |
651 | if (oi->area) { | |
652 | vty_out(vty, "%s already attached to Area %s\n", | |
653 | oi->interface->name, oi->area->name); | |
654 | return CMD_SUCCESS; | |
655 | } | |
6452df09 | 656 | |
d62a17ae | 657 | /* parse Area-ID */ |
658 | if (inet_pton(AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) { | |
659 | vty_out(vty, "Invalid Area-ID: %s\n", argv[idx_ipv4]->arg); | |
660 | return CMD_SUCCESS; | |
661 | } | |
662 | ||
663 | /* find/create ospf6 area */ | |
664 | oa = ospf6_area_lookup(area_id, o); | |
665 | if (oa == NULL) | |
666 | oa = ospf6_area_create(area_id, o, OSPF6_AREA_FMT_DOTTEDQUAD); | |
667 | ||
668 | /* attach interface to area */ | |
669 | listnode_add(oa->if_list, oi); /* sort ?? */ | |
670 | oi->area = oa; | |
671 | ||
672 | SET_FLAG(oa->flag, OSPF6_AREA_ENABLE); | |
673 | ||
674 | /* ospf6 process is currently disabled, not much more to do */ | |
675 | if (CHECK_FLAG(o->flag, OSPF6_DISABLED)) | |
676 | return CMD_SUCCESS; | |
677 | ||
678 | /* start up */ | |
679 | ospf6_interface_enable(oi); | |
680 | ||
681 | /* If the router is ABR, originate summary routes */ | |
682 | if (ospf6_is_router_abr(o)) | |
683 | ospf6_abr_enable_area(oa); | |
684 | ||
685 | return CMD_SUCCESS; | |
718e3744 | 686 | } |
687 | ||
508e53e2 | 688 | DEFUN (no_ospf6_interface_area, |
689 | no_ospf6_interface_area_cmd, | |
690 | "no interface IFNAME area A.B.C.D", | |
691 | NO_STR | |
692 | "Disable routing on an IPv6 interface\n" | |
693 | IFNAME_STR | |
694 | "Specify the OSPF6 area ID\n" | |
695 | "OSPF6 area ID in IPv4 address notation\n" | |
696 | ) | |
718e3744 | 697 | { |
d62a17ae | 698 | int idx_ifname = 2; |
699 | int idx_ipv4 = 4; | |
700 | struct ospf6_interface *oi; | |
701 | struct ospf6_area *oa; | |
702 | struct interface *ifp; | |
703 | u_int32_t area_id; | |
704 | ||
705 | ifp = if_lookup_by_name(argv[idx_ifname]->arg, VRF_DEFAULT); | |
706 | if (ifp == NULL) { | |
707 | vty_out(vty, "No such interface %s\n", argv[idx_ifname]->arg); | |
708 | return CMD_SUCCESS; | |
709 | } | |
6452df09 | 710 | |
d62a17ae | 711 | oi = (struct ospf6_interface *)ifp->info; |
712 | if (oi == NULL) { | |
713 | vty_out(vty, "Interface %s not enabled\n", ifp->name); | |
714 | return CMD_SUCCESS; | |
715 | } | |
716 | ||
717 | /* parse Area-ID */ | |
718 | if (inet_pton(AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) { | |
719 | vty_out(vty, "Invalid Area-ID: %s\n", argv[idx_ipv4]->arg); | |
720 | return CMD_SUCCESS; | |
721 | } | |
722 | ||
723 | /* Verify Area */ | |
724 | if (oi->area == NULL) { | |
725 | vty_out(vty, "No such Area-ID: %s\n", argv[idx_ipv4]->arg); | |
726 | return CMD_SUCCESS; | |
727 | } | |
728 | ||
729 | if (oi->area->area_id != area_id) { | |
730 | vty_out(vty, "Wrong Area-ID: %s is attached to area %s\n", | |
731 | oi->interface->name, oi->area->name); | |
732 | return CMD_SUCCESS; | |
733 | } | |
734 | ||
735 | thread_execute(master, interface_down, oi, 0); | |
736 | ||
737 | oa = oi->area; | |
738 | listnode_delete(oi->area->if_list, oi); | |
739 | oi->area = (struct ospf6_area *)NULL; | |
740 | ||
741 | /* Withdraw inter-area routes from this area, if necessary */ | |
742 | if (oa->if_list->count == 0) { | |
743 | UNSET_FLAG(oa->flag, OSPF6_AREA_ENABLE); | |
744 | ospf6_abr_disable_area(oa); | |
745 | } | |
746 | ||
747 | return CMD_SUCCESS; | |
718e3744 | 748 | } |
749 | ||
f41b4a02 DD |
750 | DEFUN (ospf6_stub_router_admin, |
751 | ospf6_stub_router_admin_cmd, | |
752 | "stub-router administrative", | |
753 | "Make router a stub router\n" | |
f41b4a02 DD |
754 | "Administratively applied, for an indefinite period\n") |
755 | { | |
d62a17ae | 756 | struct listnode *node; |
757 | struct ospf6_area *oa; | |
758 | ||
759 | if (!CHECK_FLAG(ospf6->flag, OSPF6_STUB_ROUTER)) { | |
760 | for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) { | |
761 | OSPF6_OPT_CLEAR(oa->options, OSPF6_OPT_V6); | |
762 | OSPF6_OPT_CLEAR(oa->options, OSPF6_OPT_R); | |
763 | OSPF6_ROUTER_LSA_SCHEDULE(oa); | |
764 | } | |
765 | SET_FLAG(ospf6->flag, OSPF6_STUB_ROUTER); | |
f41b4a02 | 766 | } |
f41b4a02 | 767 | |
d62a17ae | 768 | return CMD_SUCCESS; |
f41b4a02 DD |
769 | } |
770 | ||
771 | DEFUN (no_ospf6_stub_router_admin, | |
772 | no_ospf6_stub_router_admin_cmd, | |
773 | "no stub-router administrative", | |
774 | NO_STR | |
775 | "Make router a stub router\n" | |
f41b4a02 DD |
776 | "Administratively applied, for an indefinite period\n") |
777 | { | |
d62a17ae | 778 | struct listnode *node; |
779 | struct ospf6_area *oa; | |
780 | ||
781 | if (CHECK_FLAG(ospf6->flag, OSPF6_STUB_ROUTER)) { | |
782 | for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) { | |
783 | OSPF6_OPT_SET(oa->options, OSPF6_OPT_V6); | |
784 | OSPF6_OPT_SET(oa->options, OSPF6_OPT_R); | |
785 | OSPF6_ROUTER_LSA_SCHEDULE(oa); | |
786 | } | |
787 | UNSET_FLAG(ospf6->flag, OSPF6_STUB_ROUTER); | |
f41b4a02 | 788 | } |
f41b4a02 | 789 | |
d62a17ae | 790 | return CMD_SUCCESS; |
f41b4a02 DD |
791 | } |
792 | ||
d7d73ffc | 793 | #if 0 |
f41b4a02 DD |
794 | DEFUN (ospf6_stub_router_startup, |
795 | ospf6_stub_router_startup_cmd, | |
6147e2c6 | 796 | "stub-router on-startup (5-86400)", |
f41b4a02 DD |
797 | "Make router a stub router\n" |
798 | "Advertise inability to be a transit router\n" | |
799 | "Automatically advertise as stub-router on startup of OSPF6\n" | |
800 | "Time (seconds) to advertise self as stub-router\n") | |
801 | { | |
802 | return CMD_SUCCESS; | |
803 | } | |
804 | ||
805 | DEFUN (no_ospf6_stub_router_startup, | |
806 | no_ospf6_stub_router_startup_cmd, | |
807 | "no stub-router on-startup", | |
808 | NO_STR | |
809 | "Make router a stub router\n" | |
810 | "Advertise inability to be a transit router\n" | |
811 | "Automatically advertise as stub-router on startup of OSPF6\n" | |
812 | "Time (seconds) to advertise self as stub-router\n") | |
813 | { | |
814 | return CMD_SUCCESS; | |
815 | } | |
816 | ||
817 | DEFUN (ospf6_stub_router_shutdown, | |
818 | ospf6_stub_router_shutdown_cmd, | |
6147e2c6 | 819 | "stub-router on-shutdown (5-86400)", |
f41b4a02 DD |
820 | "Make router a stub router\n" |
821 | "Advertise inability to be a transit router\n" | |
822 | "Automatically advertise as stub-router before shutdown\n" | |
823 | "Time (seconds) to advertise self as stub-router\n") | |
824 | { | |
825 | return CMD_SUCCESS; | |
826 | } | |
827 | ||
828 | DEFUN (no_ospf6_stub_router_shutdown, | |
829 | no_ospf6_stub_router_shutdown_cmd, | |
830 | "no stub-router on-shutdown", | |
831 | NO_STR | |
832 | "Make router a stub router\n" | |
833 | "Advertise inability to be a transit router\n" | |
834 | "Automatically advertise as stub-router before shutdown\n" | |
835 | "Time (seconds) to advertise self as stub-router\n") | |
836 | { | |
837 | return CMD_SUCCESS; | |
838 | } | |
d7d73ffc | 839 | #endif |
f41b4a02 | 840 | |
d62a17ae | 841 | static void ospf6_show(struct vty *vty, struct ospf6 *o) |
718e3744 | 842 | { |
d62a17ae | 843 | struct listnode *n; |
844 | struct ospf6_area *oa; | |
845 | char router_id[16], duration[32]; | |
846 | struct timeval now, running, result; | |
847 | char buf[32], rbuf[32]; | |
848 | ||
849 | /* process id, router id */ | |
850 | inet_ntop(AF_INET, &o->router_id, router_id, sizeof(router_id)); | |
851 | vty_out(vty, " OSPFv3 Routing Process (0) with Router-ID %s\n", | |
852 | router_id); | |
853 | ||
854 | /* running time */ | |
855 | monotime(&now); | |
856 | timersub(&now, &o->starttime, &running); | |
857 | timerstring(&running, duration, sizeof(duration)); | |
858 | vty_out(vty, " Running %s\n", duration); | |
859 | ||
860 | /* Redistribute configuration */ | |
861 | /* XXX */ | |
862 | ||
863 | vty_out(vty, " LSA minimum arrival %d msecs\n", o->lsa_minarrival); | |
864 | ||
865 | /* Show SPF parameters */ | |
866 | vty_out(vty, | |
867 | " Initial SPF scheduling delay %d millisec(s)\n" | |
868 | " Minimum hold time between consecutive SPFs %d millsecond(s)\n" | |
869 | " Maximum hold time between consecutive SPFs %d millsecond(s)\n" | |
870 | " Hold time multiplier is currently %d\n", | |
871 | o->spf_delay, o->spf_holdtime, o->spf_max_holdtime, | |
872 | o->spf_hold_multiplier); | |
873 | ||
874 | vty_out(vty, " SPF algorithm "); | |
875 | if (o->ts_spf.tv_sec || o->ts_spf.tv_usec) { | |
876 | timersub(&now, &o->ts_spf, &result); | |
877 | timerstring(&result, buf, sizeof(buf)); | |
878 | ospf6_spf_reason_string(o->last_spf_reason, rbuf, sizeof(rbuf)); | |
879 | vty_out(vty, "last executed %s ago, reason %s\n", buf, rbuf); | |
880 | vty_out(vty, " Last SPF duration %lld sec %lld usec\n", | |
881 | (long long)o->ts_spf_duration.tv_sec, | |
882 | (long long)o->ts_spf_duration.tv_usec); | |
883 | } else | |
ab0f1135 | 884 | vty_out(vty, "has not been run\n"); |
d62a17ae | 885 | threadtimer_string(now, o->t_spf_calc, buf, sizeof(buf)); |
886 | vty_out(vty, " SPF timer %s%s\n", (o->t_spf_calc ? "due in " : "is "), | |
887 | buf); | |
888 | ||
889 | if (CHECK_FLAG(o->flag, OSPF6_STUB_ROUTER)) | |
890 | vty_out(vty, " Router Is Stub Router\n"); | |
891 | ||
892 | /* LSAs */ | |
893 | vty_out(vty, " Number of AS scoped LSAs is %u\n", o->lsdb->count); | |
894 | ||
895 | /* Areas */ | |
896 | vty_out(vty, " Number of areas in this router is %u\n", | |
897 | listcount(o->area_list)); | |
898 | ||
899 | if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_CHANGES)) { | |
900 | if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_DETAIL)) | |
901 | vty_out(vty, " All adjacency changes are logged\n"); | |
902 | else | |
903 | vty_out(vty, " Adjacency changes are logged\n"); | |
904 | } | |
905 | ||
906 | vty_out(vty, "\n"); | |
907 | ||
908 | for (ALL_LIST_ELEMENTS_RO(o->area_list, n, oa)) | |
909 | ospf6_area_show(vty, oa); | |
718e3744 | 910 | } |
911 | ||
508e53e2 | 912 | /* show top level structures */ |
913 | DEFUN (show_ipv6_ospf6, | |
914 | show_ipv6_ospf6_cmd, | |
915 | "show ipv6 ospf6", | |
916 | SHOW_STR | |
917 | IP6_STR | |
918 | OSPF6_STR) | |
718e3744 | 919 | { |
d62a17ae | 920 | OSPF6_CMD_CHECK_RUNNING(); |
508e53e2 | 921 | |
d62a17ae | 922 | ospf6_show(vty, ospf6); |
923 | return CMD_SUCCESS; | |
718e3744 | 924 | } |
925 | ||
926 | DEFUN (show_ipv6_ospf6_route, | |
927 | show_ipv6_ospf6_route_cmd, | |
6de69f83 | 928 | "show ipv6 ospf6 route [<intra-area|inter-area|external-1|external-2|X:X::X:X|X:X::X:X/M|detail|summary>]", |
718e3744 | 929 | SHOW_STR |
930 | IP6_STR | |
931 | OSPF6_STR | |
508e53e2 | 932 | ROUTE_STR |
1d68dbfe DW |
933 | "Display Intra-Area routes\n" |
934 | "Display Inter-Area routes\n" | |
935 | "Display Type-1 External routes\n" | |
936 | "Display Type-2 External routes\n" | |
937 | "Specify IPv6 address\n" | |
938 | "Specify IPv6 prefix\n" | |
939 | "Detailed information\n" | |
940 | "Summary of route table\n") | |
718e3744 | 941 | { |
d62a17ae | 942 | OSPF6_CMD_CHECK_RUNNING(); |
b52a8a52 | 943 | |
d62a17ae | 944 | ospf6_route_table_show(vty, 4, argc, argv, ospf6->route_table); |
945 | return CMD_SUCCESS; | |
718e3744 | 946 | } |
947 | ||
508e53e2 | 948 | DEFUN (show_ipv6_ospf6_route_match, |
949 | show_ipv6_ospf6_route_match_cmd, | |
1d68dbfe | 950 | "show ipv6 ospf6 route X:X::X:X/M <match|longer>", |
718e3744 | 951 | SHOW_STR |
952 | IP6_STR | |
953 | OSPF6_STR | |
508e53e2 | 954 | ROUTE_STR |
955 | "Specify IPv6 prefix\n" | |
956 | "Display routes which match the specified route\n" | |
1d68dbfe | 957 | "Display routes longer than the specified route\n") |
718e3744 | 958 | { |
d62a17ae | 959 | OSPF6_CMD_CHECK_RUNNING(); |
b52a8a52 | 960 | |
d62a17ae | 961 | ospf6_route_table_show(vty, 4, argc, argv, ospf6->route_table); |
962 | return CMD_SUCCESS; | |
718e3744 | 963 | } |
964 | ||
508e53e2 | 965 | DEFUN (show_ipv6_ospf6_route_match_detail, |
966 | show_ipv6_ospf6_route_match_detail_cmd, | |
4846ef64 | 967 | "show ipv6 ospf6 route X:X::X:X/M match detail", |
718e3744 | 968 | SHOW_STR |
969 | IP6_STR | |
970 | OSPF6_STR | |
508e53e2 | 971 | ROUTE_STR |
972 | "Specify IPv6 prefix\n" | |
973 | "Display routes which match the specified route\n" | |
718e3744 | 974 | "Detailed information\n" |
975 | ) | |
508e53e2 | 976 | { |
d62a17ae | 977 | OSPF6_CMD_CHECK_RUNNING(); |
b52a8a52 | 978 | |
d62a17ae | 979 | ospf6_route_table_show(vty, 4, argc, argv, ospf6->route_table); |
980 | return CMD_SUCCESS; | |
508e53e2 | 981 | } |
718e3744 | 982 | |
cb4b8845 | 983 | |
4846ef64 | 984 | DEFUN (show_ipv6_ospf6_route_type_detail, |
985 | show_ipv6_ospf6_route_type_detail_cmd, | |
6147e2c6 | 986 | "show ipv6 ospf6 route <intra-area|inter-area|external-1|external-2> detail", |
4846ef64 | 987 | SHOW_STR |
988 | IP6_STR | |
989 | OSPF6_STR | |
990 | ROUTE_STR | |
ea402198 DO |
991 | "Display Intra-Area routes\n" |
992 | "Display Inter-Area routes\n" | |
993 | "Display Type-1 External routes\n" | |
994 | "Display Type-2 External routes\n" | |
4846ef64 | 995 | "Detailed information\n" |
996 | ) | |
997 | { | |
d62a17ae | 998 | OSPF6_CMD_CHECK_RUNNING(); |
b52a8a52 | 999 | |
d62a17ae | 1000 | ospf6_route_table_show(vty, 4, argc, argv, ospf6->route_table); |
1001 | return CMD_SUCCESS; | |
4846ef64 | 1002 | } |
718e3744 | 1003 | |
d62a17ae | 1004 | static void ospf6_stub_router_config_write(struct vty *vty) |
f41b4a02 | 1005 | { |
d62a17ae | 1006 | if (CHECK_FLAG(ospf6->flag, OSPF6_STUB_ROUTER)) { |
1007 | vty_out(vty, " stub-router administrative\n"); | |
1008 | } | |
1009 | return; | |
f41b4a02 DD |
1010 | } |
1011 | ||
d62a17ae | 1012 | static int ospf6_distance_config_write(struct vty *vty) |
baff583e | 1013 | { |
d62a17ae | 1014 | struct route_node *rn; |
1015 | struct ospf6_distance *odistance; | |
1016 | ||
1017 | if (ospf6->distance_all) | |
1018 | vty_out(vty, " distance %u\n", ospf6->distance_all); | |
1019 | ||
1020 | if (ospf6->distance_intra || ospf6->distance_inter | |
1021 | || ospf6->distance_external) { | |
1022 | vty_out(vty, " distance ospf6"); | |
1023 | ||
1024 | if (ospf6->distance_intra) | |
1025 | vty_out(vty, " intra-area %u", ospf6->distance_intra); | |
1026 | if (ospf6->distance_inter) | |
1027 | vty_out(vty, " inter-area %u", ospf6->distance_inter); | |
1028 | if (ospf6->distance_external) | |
1029 | vty_out(vty, " external %u", ospf6->distance_external); | |
1030 | ||
1031 | vty_out(vty, "\n"); | |
1032 | } | |
1033 | ||
1034 | for (rn = route_top(ospf6->distance_table); rn; rn = route_next(rn)) | |
1035 | if ((odistance = rn->info) != NULL) { | |
1036 | char buf[PREFIX_STRLEN]; | |
1037 | ||
1038 | vty_out(vty, " distance %u %s %s\n", | |
1039 | odistance->distance, | |
1040 | prefix2str(&rn->p, buf, sizeof(buf)), | |
1041 | odistance->access_list ? odistance->access_list | |
1042 | : ""); | |
1043 | } | |
1044 | return 0; | |
baff583e MZ |
1045 | } |
1046 | ||
508e53e2 | 1047 | /* OSPF configuration write function. */ |
d62a17ae | 1048 | static int config_write_ospf6(struct vty *vty) |
508e53e2 | 1049 | { |
d62a17ae | 1050 | char router_id[16]; |
1051 | struct listnode *j, *k; | |
1052 | struct ospf6_area *oa; | |
1053 | struct ospf6_interface *oi; | |
1054 | ||
1055 | /* OSPFv3 configuration. */ | |
1056 | if (ospf6 == NULL) | |
1057 | return CMD_SUCCESS; | |
1058 | ||
1059 | inet_ntop(AF_INET, &ospf6->router_id_static, router_id, | |
1060 | sizeof(router_id)); | |
1061 | vty_out(vty, "router ospf6\n"); | |
1062 | if (ospf6->router_id_static != 0) | |
5d1a2ee8 | 1063 | vty_out(vty, " ospf6 router-id %s\n", router_id); |
d62a17ae | 1064 | |
1065 | /* log-adjacency-changes flag print. */ | |
1066 | if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES)) { | |
1067 | if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL)) | |
1068 | vty_out(vty, " log-adjacency-changes detail\n"); | |
1069 | else if (!DFLT_OSPF6_LOG_ADJACENCY_CHANGES) | |
1070 | vty_out(vty, " log-adjacency-changes\n"); | |
1071 | } else if (DFLT_OSPF6_LOG_ADJACENCY_CHANGES) { | |
1072 | vty_out(vty, " no log-adjacency-changes\n"); | |
1073 | } | |
1074 | ||
1075 | if (ospf6->ref_bandwidth != OSPF6_REFERENCE_BANDWIDTH) | |
1076 | vty_out(vty, " auto-cost reference-bandwidth %d\n", | |
1077 | ospf6->ref_bandwidth); | |
1078 | ||
1079 | /* LSA timers print. */ | |
1080 | if (ospf6->lsa_minarrival != OSPF_MIN_LS_ARRIVAL) | |
1081 | vty_out(vty, " timers lsa min-arrival %d\n", | |
1082 | ospf6->lsa_minarrival); | |
1083 | ||
1084 | ospf6_stub_router_config_write(vty); | |
1085 | ospf6_redistribute_config_write(vty); | |
1086 | ospf6_area_config_write(vty); | |
1087 | ospf6_spf_config_write(vty); | |
1088 | ospf6_distance_config_write(vty); | |
1089 | ||
1090 | for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, j, oa)) { | |
1091 | for (ALL_LIST_ELEMENTS_RO(oa->if_list, k, oi)) | |
1092 | vty_out(vty, " interface %s area %s\n", | |
1093 | oi->interface->name, oa->name); | |
1094 | } | |
1095 | vty_out(vty, "!\n"); | |
1096 | return 0; | |
508e53e2 | 1097 | } |
1098 | ||
1099 | /* OSPF6 node structure. */ | |
d62a17ae | 1100 | static struct cmd_node ospf6_node = { |
1101 | OSPF6_NODE, "%s(config-ospf6)# ", 1 /* VTYSH */ | |
508e53e2 | 1102 | }; |
1103 | ||
1104 | /* Install ospf related commands. */ | |
d62a17ae | 1105 | void ospf6_top_init(void) |
718e3744 | 1106 | { |
d62a17ae | 1107 | /* Install ospf6 top node. */ |
1108 | install_node(&ospf6_node, config_write_ospf6); | |
1109 | ||
1110 | install_element(VIEW_NODE, &show_ipv6_ospf6_cmd); | |
1111 | install_element(CONFIG_NODE, &router_ospf6_cmd); | |
1112 | install_element(CONFIG_NODE, &no_router_ospf6_cmd); | |
1113 | ||
1114 | install_element(VIEW_NODE, &show_ipv6_ospf6_route_cmd); | |
1115 | install_element(VIEW_NODE, &show_ipv6_ospf6_route_match_cmd); | |
1116 | install_element(VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd); | |
1117 | install_element(VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd); | |
1118 | ||
1119 | install_default(OSPF6_NODE); | |
1120 | install_element(OSPF6_NODE, &ospf6_router_id_cmd); | |
5d1a2ee8 QY |
1121 | install_element(OSPF6_NODE, &no_ospf6_router_id_cmd); |
1122 | install_element(OSPF6_NODE, &ospf6_router_id_hdn_cmd); | |
1123 | install_element(OSPF6_NODE, &no_ospf6_router_id_hdn_cmd); | |
d62a17ae | 1124 | install_element(OSPF6_NODE, &ospf6_log_adjacency_changes_cmd); |
1125 | install_element(OSPF6_NODE, &ospf6_log_adjacency_changes_detail_cmd); | |
1126 | install_element(OSPF6_NODE, &no_ospf6_log_adjacency_changes_cmd); | |
1127 | install_element(OSPF6_NODE, &no_ospf6_log_adjacency_changes_detail_cmd); | |
1128 | ||
1129 | /* LSA timers commands */ | |
1130 | install_element(OSPF6_NODE, &ospf6_timers_lsa_cmd); | |
1131 | install_element(OSPF6_NODE, &no_ospf6_timers_lsa_cmd); | |
1132 | ||
1133 | install_element(OSPF6_NODE, &ospf6_interface_area_cmd); | |
1134 | install_element(OSPF6_NODE, &no_ospf6_interface_area_cmd); | |
1135 | install_element(OSPF6_NODE, &ospf6_stub_router_admin_cmd); | |
1136 | install_element(OSPF6_NODE, &no_ospf6_stub_router_admin_cmd); | |
1137 | /* For a later time */ | |
34d5ef45 | 1138 | #if 0 |
f41b4a02 DD |
1139 | install_element (OSPF6_NODE, &ospf6_stub_router_startup_cmd); |
1140 | install_element (OSPF6_NODE, &no_ospf6_stub_router_startup_cmd); | |
1141 | install_element (OSPF6_NODE, &ospf6_stub_router_shutdown_cmd); | |
1142 | install_element (OSPF6_NODE, &no_ospf6_stub_router_shutdown_cmd); | |
34d5ef45 | 1143 | #endif |
508e53e2 | 1144 | |
d62a17ae | 1145 | install_element(OSPF6_NODE, &ospf6_distance_cmd); |
1146 | install_element(OSPF6_NODE, &no_ospf6_distance_cmd); | |
1147 | install_element(OSPF6_NODE, &ospf6_distance_ospf6_cmd); | |
1148 | install_element(OSPF6_NODE, &no_ospf6_distance_ospf6_cmd); | |
baff583e MZ |
1149 | #if 0 |
1150 | install_element (OSPF6_NODE, &ospf6_distance_source_cmd); | |
1151 | install_element (OSPF6_NODE, &no_ospf6_distance_source_cmd); | |
1152 | #endif | |
718e3744 | 1153 | } |