]>
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 | |
406 | ALIAS_HIDDEN(ospf6_router_id, | |
407 | ospf6_router_id_hdn_cmd, | |
408 | "router-id A.B.C.D", | |
409 | "Configure OSPF6 Router-ID\n" | |
410 | V4NOTATION_STR) | |
411 | ||
412 | #if CONFDATE > 20180828 | |
413 | CPP_NOTICE("ospf6: `no router-id A.B.C.D` deprecated 2017/08/28") | |
414 | #endif | |
415 | ALIAS_HIDDEN(no_ospf6_router_id, | |
416 | no_ospf6_router_id_hdn_cmd, | |
417 | "no router-id [A.B.C.D]", | |
418 | NO_STR | |
419 | "Configure OSPF6 Router-ID\n" | |
420 | V4NOTATION_STR) | |
421 | ||
3d35ca48 DD |
422 | DEFUN (ospf6_log_adjacency_changes, |
423 | ospf6_log_adjacency_changes_cmd, | |
424 | "log-adjacency-changes", | |
425 | "Log changes in adjacency state\n") | |
426 | { | |
d62a17ae | 427 | VTY_DECLVAR_CONTEXT(ospf6, ospf6); |
3d35ca48 | 428 | |
d62a17ae | 429 | SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES); |
430 | UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL); | |
431 | return CMD_SUCCESS; | |
3d35ca48 DD |
432 | } |
433 | ||
434 | DEFUN (ospf6_log_adjacency_changes_detail, | |
435 | ospf6_log_adjacency_changes_detail_cmd, | |
436 | "log-adjacency-changes detail", | |
692c7954 | 437 | "Log changes in adjacency state\n" |
3d35ca48 DD |
438 | "Log all state changes\n") |
439 | { | |
d62a17ae | 440 | VTY_DECLVAR_CONTEXT(ospf6, ospf6); |
3d35ca48 | 441 | |
d62a17ae | 442 | SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES); |
443 | SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL); | |
444 | return CMD_SUCCESS; | |
3d35ca48 DD |
445 | } |
446 | ||
447 | DEFUN (no_ospf6_log_adjacency_changes, | |
448 | no_ospf6_log_adjacency_changes_cmd, | |
449 | "no log-adjacency-changes", | |
692c7954 | 450 | NO_STR |
3d35ca48 DD |
451 | "Log changes in adjacency state\n") |
452 | { | |
d62a17ae | 453 | VTY_DECLVAR_CONTEXT(ospf6, ospf6); |
3d35ca48 | 454 | |
d62a17ae | 455 | UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL); |
456 | UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES); | |
457 | return CMD_SUCCESS; | |
3d35ca48 DD |
458 | } |
459 | ||
460 | DEFUN (no_ospf6_log_adjacency_changes_detail, | |
461 | no_ospf6_log_adjacency_changes_detail_cmd, | |
462 | "no log-adjacency-changes detail", | |
692c7954 DW |
463 | NO_STR |
464 | "Log changes in adjacency state\n" | |
3d35ca48 DD |
465 | "Log all state changes\n") |
466 | { | |
d62a17ae | 467 | VTY_DECLVAR_CONTEXT(ospf6, ospf6); |
3d35ca48 | 468 | |
d62a17ae | 469 | UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL); |
470 | return CMD_SUCCESS; | |
3d35ca48 DD |
471 | } |
472 | ||
b6927875 DS |
473 | DEFUN (ospf6_timers_lsa, |
474 | ospf6_timers_lsa_cmd, | |
6147e2c6 | 475 | "timers lsa min-arrival (0-600000)", |
b6927875 DS |
476 | "Adjust routing timers\n" |
477 | "OSPF6 LSA timers\n" | |
478 | "Minimum delay in receiving new version of a LSA\n" | |
479 | "Delay in milliseconds\n") | |
480 | { | |
d62a17ae | 481 | VTY_DECLVAR_CONTEXT(ospf6, ospf); |
482 | int idx_number = 3; | |
483 | unsigned int minarrival; | |
b6927875 | 484 | |
d62a17ae | 485 | minarrival = strtoul(argv[idx_number]->arg, NULL, 10); |
486 | ospf->lsa_minarrival = minarrival; | |
b6927875 | 487 | |
d62a17ae | 488 | return CMD_SUCCESS; |
b6927875 DS |
489 | } |
490 | ||
491 | DEFUN (no_ospf6_timers_lsa, | |
492 | no_ospf6_timers_lsa_cmd, | |
1d68dbfe | 493 | "no timers lsa min-arrival [(0-600000)]", |
b6927875 DS |
494 | NO_STR |
495 | "Adjust routing timers\n" | |
496 | "OSPF6 LSA timers\n" | |
3a2d747c QY |
497 | "Minimum delay in receiving new version of a LSA\n" |
498 | "Delay in milliseconds\n") | |
b6927875 | 499 | { |
d62a17ae | 500 | VTY_DECLVAR_CONTEXT(ospf6, ospf); |
501 | int idx_number = 4; | |
502 | unsigned int minarrival; | |
b6927875 | 503 | |
d62a17ae | 504 | if (argc == 5) { |
505 | minarrival = strtoul(argv[idx_number]->arg, NULL, 10); | |
b6927875 | 506 | |
d62a17ae | 507 | if (ospf->lsa_minarrival != minarrival |
508 | || minarrival == OSPF_MIN_LS_ARRIVAL) | |
509 | return CMD_SUCCESS; | |
510 | } | |
b6927875 | 511 | |
d62a17ae | 512 | ospf->lsa_minarrival = OSPF_MIN_LS_ARRIVAL; |
b6927875 | 513 | |
d62a17ae | 514 | return CMD_SUCCESS; |
b6927875 DS |
515 | } |
516 | ||
b6927875 | 517 | |
baff583e MZ |
518 | DEFUN (ospf6_distance, |
519 | ospf6_distance_cmd, | |
39e92c06 | 520 | "distance (1-255)", |
baff583e MZ |
521 | "Administrative distance\n" |
522 | "OSPF6 Administrative distance\n") | |
523 | { | |
d62a17ae | 524 | VTY_DECLVAR_CONTEXT(ospf6, o); |
baff583e | 525 | |
d62a17ae | 526 | o->distance_all = atoi(argv[1]->arg); |
baff583e | 527 | |
d62a17ae | 528 | return CMD_SUCCESS; |
baff583e MZ |
529 | } |
530 | ||
531 | DEFUN (no_ospf6_distance, | |
532 | no_ospf6_distance_cmd, | |
39e92c06 | 533 | "no distance (1-255)", |
baff583e MZ |
534 | NO_STR |
535 | "Administrative distance\n" | |
536 | "OSPF6 Administrative distance\n") | |
537 | { | |
d62a17ae | 538 | VTY_DECLVAR_CONTEXT(ospf6, o); |
baff583e | 539 | |
d62a17ae | 540 | o->distance_all = 0; |
baff583e | 541 | |
d62a17ae | 542 | return CMD_SUCCESS; |
baff583e MZ |
543 | } |
544 | ||
545 | DEFUN (ospf6_distance_ospf6, | |
546 | ospf6_distance_ospf6_cmd, | |
eaa1ae0d | 547 | "distance ospf6 {intra-area (1-255)|inter-area (1-255)|external (1-255)}", |
baff583e | 548 | "Administrative distance\n" |
eaa1ae0d | 549 | "OSPF6 administrative distance\n" |
39e92c06 QY |
550 | "Intra-area routes\n" |
551 | "Distance for intra-area routes\n" | |
552 | "Inter-area routes\n" | |
553 | "Distance for inter-area routes\n" | |
554 | "External routes\n" | |
baff583e MZ |
555 | "Distance for external routes\n") |
556 | { | |
d62a17ae | 557 | VTY_DECLVAR_CONTEXT(ospf6, o); |
558 | int idx = 0; | |
559 | ||
f89a449b CS |
560 | o->distance_intra = 0; |
561 | o->distance_inter = 0; | |
562 | o->distance_external = 0; | |
563 | ||
d62a17ae | 564 | if (argv_find(argv, argc, "intra-area", &idx)) |
565 | o->distance_intra = atoi(argv[idx + 1]->arg); | |
566 | idx = 0; | |
567 | if (argv_find(argv, argc, "inter-area", &idx)) | |
568 | o->distance_inter = atoi(argv[idx + 1]->arg); | |
569 | idx = 0; | |
570 | if (argv_find(argv, argc, "external", &idx)) | |
571 | o->distance_external = atoi(argv[idx + 1]->arg); | |
39e92c06 | 572 | |
d62a17ae | 573 | return CMD_SUCCESS; |
baff583e MZ |
574 | } |
575 | ||
576 | DEFUN (no_ospf6_distance_ospf6, | |
577 | no_ospf6_distance_ospf6_cmd, | |
eaa1ae0d | 578 | "no distance ospf6 [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]", |
baff583e MZ |
579 | NO_STR |
580 | "Administrative distance\n" | |
581 | "OSPF6 distance\n" | |
582 | "Intra-area routes\n" | |
583 | "Distance for intra-area routes\n" | |
584 | "Inter-area routes\n" | |
585 | "Distance for inter-area routes\n" | |
586 | "External routes\n" | |
587 | "Distance for external routes\n") | |
588 | { | |
d62a17ae | 589 | VTY_DECLVAR_CONTEXT(ospf6, o); |
590 | int idx = 0; | |
baff583e | 591 | |
d62a17ae | 592 | if (argv_find(argv, argc, "intra-area", &idx) || argc == 3) |
593 | idx = o->distance_intra = 0; | |
594 | if (argv_find(argv, argc, "inter-area", &idx) || argc == 3) | |
595 | idx = o->distance_inter = 0; | |
596 | if (argv_find(argv, argc, "external", &idx) || argc == 3) | |
597 | o->distance_external = 0; | |
baff583e | 598 | |
d62a17ae | 599 | return CMD_SUCCESS; |
baff583e MZ |
600 | } |
601 | ||
d7d73ffc | 602 | #if 0 |
baff583e MZ |
603 | DEFUN (ospf6_distance_source, |
604 | ospf6_distance_source_cmd, | |
39e92c06 | 605 | "distance (1-255) X:X::X:X/M [WORD]", |
baff583e MZ |
606 | "Administrative distance\n" |
607 | "Distance value\n" | |
608 | "IP source prefix\n" | |
609 | "Access list name\n") | |
610 | { | |
cdc2d765 | 611 | VTY_DECLVAR_CONTEXT(ospf6, o); |
39e92c06 QY |
612 | char *alname = (argc == 4) ? argv[3]->arg : NULL; |
613 | ospf6_distance_set (vty, o, argv[1]->arg, argv[2]->arg, alname); | |
baff583e MZ |
614 | |
615 | return CMD_SUCCESS; | |
616 | } | |
617 | ||
618 | DEFUN (no_ospf6_distance_source, | |
619 | no_ospf6_distance_source_cmd, | |
39e92c06 | 620 | "no distance (1-255) X:X::X:X/M [WORD]", |
baff583e MZ |
621 | NO_STR |
622 | "Administrative distance\n" | |
623 | "Distance value\n" | |
624 | "IP source prefix\n" | |
625 | "Access list name\n") | |
626 | { | |
cdc2d765 | 627 | VTY_DECLVAR_CONTEXT(ospf6, o); |
39e92c06 QY |
628 | char *alname = (argc == 5) ? argv[4]->arg : NULL; |
629 | ospf6_distance_unset (vty, o, argv[2]->arg, argv[3]->arg, alname); | |
baff583e MZ |
630 | |
631 | return CMD_SUCCESS; | |
632 | } | |
d7d73ffc | 633 | #endif |
baff583e | 634 | |
508e53e2 | 635 | DEFUN (ospf6_interface_area, |
636 | ospf6_interface_area_cmd, | |
637 | "interface IFNAME area A.B.C.D", | |
638 | "Enable routing on an IPv6 interface\n" | |
639 | IFNAME_STR | |
640 | "Specify the OSPF6 area ID\n" | |
641 | "OSPF6 area ID in IPv4 address notation\n" | |
642 | ) | |
718e3744 | 643 | { |
d62a17ae | 644 | VTY_DECLVAR_CONTEXT(ospf6, o); |
645 | int idx_ifname = 1; | |
646 | int idx_ipv4 = 3; | |
647 | struct ospf6_area *oa; | |
648 | struct ospf6_interface *oi; | |
649 | struct interface *ifp; | |
650 | u_int32_t area_id; | |
651 | ||
652 | /* find/create ospf6 interface */ | |
bcc24579 | 653 | ifp = if_get_by_name(argv[idx_ifname]->arg, VRF_DEFAULT, 0); |
d62a17ae | 654 | oi = (struct ospf6_interface *)ifp->info; |
655 | if (oi == NULL) | |
656 | oi = ospf6_interface_create(ifp); | |
657 | if (oi->area) { | |
658 | vty_out(vty, "%s already attached to Area %s\n", | |
659 | oi->interface->name, oi->area->name); | |
660 | return CMD_SUCCESS; | |
661 | } | |
6452df09 | 662 | |
d62a17ae | 663 | /* parse Area-ID */ |
664 | if (inet_pton(AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) { | |
665 | vty_out(vty, "Invalid Area-ID: %s\n", argv[idx_ipv4]->arg); | |
666 | return CMD_SUCCESS; | |
667 | } | |
668 | ||
669 | /* find/create ospf6 area */ | |
670 | oa = ospf6_area_lookup(area_id, o); | |
671 | if (oa == NULL) | |
672 | oa = ospf6_area_create(area_id, o, OSPF6_AREA_FMT_DOTTEDQUAD); | |
673 | ||
674 | /* attach interface to area */ | |
675 | listnode_add(oa->if_list, oi); /* sort ?? */ | |
676 | oi->area = oa; | |
677 | ||
678 | SET_FLAG(oa->flag, OSPF6_AREA_ENABLE); | |
679 | ||
680 | /* ospf6 process is currently disabled, not much more to do */ | |
681 | if (CHECK_FLAG(o->flag, OSPF6_DISABLED)) | |
682 | return CMD_SUCCESS; | |
683 | ||
684 | /* start up */ | |
685 | ospf6_interface_enable(oi); | |
686 | ||
687 | /* If the router is ABR, originate summary routes */ | |
688 | if (ospf6_is_router_abr(o)) | |
689 | ospf6_abr_enable_area(oa); | |
690 | ||
691 | return CMD_SUCCESS; | |
718e3744 | 692 | } |
693 | ||
508e53e2 | 694 | DEFUN (no_ospf6_interface_area, |
695 | no_ospf6_interface_area_cmd, | |
696 | "no interface IFNAME area A.B.C.D", | |
697 | NO_STR | |
698 | "Disable routing on an IPv6 interface\n" | |
699 | IFNAME_STR | |
700 | "Specify the OSPF6 area ID\n" | |
701 | "OSPF6 area ID in IPv4 address notation\n" | |
702 | ) | |
718e3744 | 703 | { |
d62a17ae | 704 | int idx_ifname = 2; |
705 | int idx_ipv4 = 4; | |
706 | struct ospf6_interface *oi; | |
707 | struct ospf6_area *oa; | |
708 | struct interface *ifp; | |
709 | u_int32_t area_id; | |
710 | ||
711 | ifp = if_lookup_by_name(argv[idx_ifname]->arg, VRF_DEFAULT); | |
712 | if (ifp == NULL) { | |
713 | vty_out(vty, "No such interface %s\n", argv[idx_ifname]->arg); | |
714 | return CMD_SUCCESS; | |
715 | } | |
6452df09 | 716 | |
d62a17ae | 717 | oi = (struct ospf6_interface *)ifp->info; |
718 | if (oi == NULL) { | |
719 | vty_out(vty, "Interface %s not enabled\n", ifp->name); | |
720 | return CMD_SUCCESS; | |
721 | } | |
722 | ||
723 | /* parse Area-ID */ | |
724 | if (inet_pton(AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) { | |
725 | vty_out(vty, "Invalid Area-ID: %s\n", argv[idx_ipv4]->arg); | |
726 | return CMD_SUCCESS; | |
727 | } | |
728 | ||
729 | /* Verify Area */ | |
730 | if (oi->area == NULL) { | |
731 | vty_out(vty, "No such Area-ID: %s\n", argv[idx_ipv4]->arg); | |
732 | return CMD_SUCCESS; | |
733 | } | |
734 | ||
735 | if (oi->area->area_id != area_id) { | |
736 | vty_out(vty, "Wrong Area-ID: %s is attached to area %s\n", | |
737 | oi->interface->name, oi->area->name); | |
738 | return CMD_SUCCESS; | |
739 | } | |
740 | ||
741 | thread_execute(master, interface_down, oi, 0); | |
742 | ||
743 | oa = oi->area; | |
744 | listnode_delete(oi->area->if_list, oi); | |
745 | oi->area = (struct ospf6_area *)NULL; | |
746 | ||
747 | /* Withdraw inter-area routes from this area, if necessary */ | |
748 | if (oa->if_list->count == 0) { | |
749 | UNSET_FLAG(oa->flag, OSPF6_AREA_ENABLE); | |
750 | ospf6_abr_disable_area(oa); | |
751 | } | |
752 | ||
753 | return CMD_SUCCESS; | |
718e3744 | 754 | } |
755 | ||
f41b4a02 DD |
756 | DEFUN (ospf6_stub_router_admin, |
757 | ospf6_stub_router_admin_cmd, | |
758 | "stub-router administrative", | |
759 | "Make router a stub router\n" | |
f41b4a02 DD |
760 | "Administratively applied, for an indefinite period\n") |
761 | { | |
d62a17ae | 762 | struct listnode *node; |
763 | struct ospf6_area *oa; | |
764 | ||
765 | if (!CHECK_FLAG(ospf6->flag, OSPF6_STUB_ROUTER)) { | |
766 | for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) { | |
767 | OSPF6_OPT_CLEAR(oa->options, OSPF6_OPT_V6); | |
768 | OSPF6_OPT_CLEAR(oa->options, OSPF6_OPT_R); | |
769 | OSPF6_ROUTER_LSA_SCHEDULE(oa); | |
770 | } | |
771 | SET_FLAG(ospf6->flag, OSPF6_STUB_ROUTER); | |
f41b4a02 | 772 | } |
f41b4a02 | 773 | |
d62a17ae | 774 | return CMD_SUCCESS; |
f41b4a02 DD |
775 | } |
776 | ||
777 | DEFUN (no_ospf6_stub_router_admin, | |
778 | no_ospf6_stub_router_admin_cmd, | |
779 | "no stub-router administrative", | |
780 | NO_STR | |
781 | "Make router a stub router\n" | |
f41b4a02 DD |
782 | "Administratively applied, for an indefinite period\n") |
783 | { | |
d62a17ae | 784 | struct listnode *node; |
785 | struct ospf6_area *oa; | |
786 | ||
787 | if (CHECK_FLAG(ospf6->flag, OSPF6_STUB_ROUTER)) { | |
788 | for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) { | |
789 | OSPF6_OPT_SET(oa->options, OSPF6_OPT_V6); | |
790 | OSPF6_OPT_SET(oa->options, OSPF6_OPT_R); | |
791 | OSPF6_ROUTER_LSA_SCHEDULE(oa); | |
792 | } | |
793 | UNSET_FLAG(ospf6->flag, OSPF6_STUB_ROUTER); | |
f41b4a02 | 794 | } |
f41b4a02 | 795 | |
d62a17ae | 796 | return CMD_SUCCESS; |
f41b4a02 DD |
797 | } |
798 | ||
d7d73ffc | 799 | #if 0 |
f41b4a02 DD |
800 | DEFUN (ospf6_stub_router_startup, |
801 | ospf6_stub_router_startup_cmd, | |
6147e2c6 | 802 | "stub-router on-startup (5-86400)", |
f41b4a02 DD |
803 | "Make router a stub router\n" |
804 | "Advertise inability to be a transit router\n" | |
805 | "Automatically advertise as stub-router on startup of OSPF6\n" | |
806 | "Time (seconds) to advertise self as stub-router\n") | |
807 | { | |
808 | return CMD_SUCCESS; | |
809 | } | |
810 | ||
811 | DEFUN (no_ospf6_stub_router_startup, | |
812 | no_ospf6_stub_router_startup_cmd, | |
813 | "no stub-router on-startup", | |
814 | NO_STR | |
815 | "Make router a stub router\n" | |
816 | "Advertise inability to be a transit router\n" | |
817 | "Automatically advertise as stub-router on startup of OSPF6\n" | |
818 | "Time (seconds) to advertise self as stub-router\n") | |
819 | { | |
820 | return CMD_SUCCESS; | |
821 | } | |
822 | ||
823 | DEFUN (ospf6_stub_router_shutdown, | |
824 | ospf6_stub_router_shutdown_cmd, | |
6147e2c6 | 825 | "stub-router on-shutdown (5-86400)", |
f41b4a02 DD |
826 | "Make router a stub router\n" |
827 | "Advertise inability to be a transit router\n" | |
828 | "Automatically advertise as stub-router before shutdown\n" | |
829 | "Time (seconds) to advertise self as stub-router\n") | |
830 | { | |
831 | return CMD_SUCCESS; | |
832 | } | |
833 | ||
834 | DEFUN (no_ospf6_stub_router_shutdown, | |
835 | no_ospf6_stub_router_shutdown_cmd, | |
836 | "no stub-router on-shutdown", | |
837 | NO_STR | |
838 | "Make router a stub router\n" | |
839 | "Advertise inability to be a transit router\n" | |
840 | "Automatically advertise as stub-router before shutdown\n" | |
841 | "Time (seconds) to advertise self as stub-router\n") | |
842 | { | |
843 | return CMD_SUCCESS; | |
844 | } | |
d7d73ffc | 845 | #endif |
f41b4a02 | 846 | |
d62a17ae | 847 | static void ospf6_show(struct vty *vty, struct ospf6 *o) |
718e3744 | 848 | { |
d62a17ae | 849 | struct listnode *n; |
850 | struct ospf6_area *oa; | |
851 | char router_id[16], duration[32]; | |
852 | struct timeval now, running, result; | |
853 | char buf[32], rbuf[32]; | |
854 | ||
855 | /* process id, router id */ | |
856 | inet_ntop(AF_INET, &o->router_id, router_id, sizeof(router_id)); | |
857 | vty_out(vty, " OSPFv3 Routing Process (0) with Router-ID %s\n", | |
858 | router_id); | |
859 | ||
860 | /* running time */ | |
861 | monotime(&now); | |
862 | timersub(&now, &o->starttime, &running); | |
863 | timerstring(&running, duration, sizeof(duration)); | |
864 | vty_out(vty, " Running %s\n", duration); | |
865 | ||
866 | /* Redistribute configuration */ | |
867 | /* XXX */ | |
868 | ||
869 | vty_out(vty, " LSA minimum arrival %d msecs\n", o->lsa_minarrival); | |
870 | ||
871 | /* Show SPF parameters */ | |
872 | vty_out(vty, | |
873 | " Initial SPF scheduling delay %d millisec(s)\n" | |
874 | " Minimum hold time between consecutive SPFs %d millsecond(s)\n" | |
875 | " Maximum hold time between consecutive SPFs %d millsecond(s)\n" | |
876 | " Hold time multiplier is currently %d\n", | |
877 | o->spf_delay, o->spf_holdtime, o->spf_max_holdtime, | |
878 | o->spf_hold_multiplier); | |
879 | ||
880 | vty_out(vty, " SPF algorithm "); | |
881 | if (o->ts_spf.tv_sec || o->ts_spf.tv_usec) { | |
882 | timersub(&now, &o->ts_spf, &result); | |
883 | timerstring(&result, buf, sizeof(buf)); | |
884 | ospf6_spf_reason_string(o->last_spf_reason, rbuf, sizeof(rbuf)); | |
885 | vty_out(vty, "last executed %s ago, reason %s\n", buf, rbuf); | |
886 | vty_out(vty, " Last SPF duration %lld sec %lld usec\n", | |
887 | (long long)o->ts_spf_duration.tv_sec, | |
888 | (long long)o->ts_spf_duration.tv_usec); | |
889 | } else | |
ab0f1135 | 890 | vty_out(vty, "has not been run\n"); |
d62a17ae | 891 | threadtimer_string(now, o->t_spf_calc, buf, sizeof(buf)); |
892 | vty_out(vty, " SPF timer %s%s\n", (o->t_spf_calc ? "due in " : "is "), | |
893 | buf); | |
894 | ||
895 | if (CHECK_FLAG(o->flag, OSPF6_STUB_ROUTER)) | |
896 | vty_out(vty, " Router Is Stub Router\n"); | |
897 | ||
898 | /* LSAs */ | |
899 | vty_out(vty, " Number of AS scoped LSAs is %u\n", o->lsdb->count); | |
900 | ||
901 | /* Areas */ | |
902 | vty_out(vty, " Number of areas in this router is %u\n", | |
903 | listcount(o->area_list)); | |
904 | ||
905 | if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_CHANGES)) { | |
906 | if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_DETAIL)) | |
907 | vty_out(vty, " All adjacency changes are logged\n"); | |
908 | else | |
909 | vty_out(vty, " Adjacency changes are logged\n"); | |
910 | } | |
911 | ||
912 | vty_out(vty, "\n"); | |
913 | ||
914 | for (ALL_LIST_ELEMENTS_RO(o->area_list, n, oa)) | |
915 | ospf6_area_show(vty, oa); | |
718e3744 | 916 | } |
917 | ||
508e53e2 | 918 | /* show top level structures */ |
919 | DEFUN (show_ipv6_ospf6, | |
920 | show_ipv6_ospf6_cmd, | |
921 | "show ipv6 ospf6", | |
922 | SHOW_STR | |
923 | IP6_STR | |
924 | OSPF6_STR) | |
718e3744 | 925 | { |
d62a17ae | 926 | OSPF6_CMD_CHECK_RUNNING(); |
508e53e2 | 927 | |
d62a17ae | 928 | ospf6_show(vty, ospf6); |
929 | return CMD_SUCCESS; | |
718e3744 | 930 | } |
931 | ||
932 | DEFUN (show_ipv6_ospf6_route, | |
933 | show_ipv6_ospf6_route_cmd, | |
6de69f83 | 934 | "show ipv6 ospf6 route [<intra-area|inter-area|external-1|external-2|X:X::X:X|X:X::X:X/M|detail|summary>]", |
718e3744 | 935 | SHOW_STR |
936 | IP6_STR | |
937 | OSPF6_STR | |
508e53e2 | 938 | ROUTE_STR |
1d68dbfe DW |
939 | "Display Intra-Area routes\n" |
940 | "Display Inter-Area routes\n" | |
941 | "Display Type-1 External routes\n" | |
942 | "Display Type-2 External routes\n" | |
943 | "Specify IPv6 address\n" | |
944 | "Specify IPv6 prefix\n" | |
945 | "Detailed information\n" | |
946 | "Summary of route table\n") | |
718e3744 | 947 | { |
d62a17ae | 948 | OSPF6_CMD_CHECK_RUNNING(); |
b52a8a52 | 949 | |
d62a17ae | 950 | ospf6_route_table_show(vty, 4, argc, argv, ospf6->route_table); |
951 | return CMD_SUCCESS; | |
718e3744 | 952 | } |
953 | ||
508e53e2 | 954 | DEFUN (show_ipv6_ospf6_route_match, |
955 | show_ipv6_ospf6_route_match_cmd, | |
1d68dbfe | 956 | "show ipv6 ospf6 route X:X::X:X/M <match|longer>", |
718e3744 | 957 | SHOW_STR |
958 | IP6_STR | |
959 | OSPF6_STR | |
508e53e2 | 960 | ROUTE_STR |
961 | "Specify IPv6 prefix\n" | |
962 | "Display routes which match the specified route\n" | |
1d68dbfe | 963 | "Display routes longer than the specified route\n") |
718e3744 | 964 | { |
d62a17ae | 965 | OSPF6_CMD_CHECK_RUNNING(); |
b52a8a52 | 966 | |
d62a17ae | 967 | ospf6_route_table_show(vty, 4, argc, argv, ospf6->route_table); |
968 | return CMD_SUCCESS; | |
718e3744 | 969 | } |
970 | ||
508e53e2 | 971 | DEFUN (show_ipv6_ospf6_route_match_detail, |
972 | show_ipv6_ospf6_route_match_detail_cmd, | |
4846ef64 | 973 | "show ipv6 ospf6 route X:X::X:X/M match detail", |
718e3744 | 974 | SHOW_STR |
975 | IP6_STR | |
976 | OSPF6_STR | |
508e53e2 | 977 | ROUTE_STR |
978 | "Specify IPv6 prefix\n" | |
979 | "Display routes which match the specified route\n" | |
718e3744 | 980 | "Detailed information\n" |
981 | ) | |
508e53e2 | 982 | { |
d62a17ae | 983 | OSPF6_CMD_CHECK_RUNNING(); |
b52a8a52 | 984 | |
d62a17ae | 985 | ospf6_route_table_show(vty, 4, argc, argv, ospf6->route_table); |
986 | return CMD_SUCCESS; | |
508e53e2 | 987 | } |
718e3744 | 988 | |
cb4b8845 | 989 | |
4846ef64 | 990 | DEFUN (show_ipv6_ospf6_route_type_detail, |
991 | show_ipv6_ospf6_route_type_detail_cmd, | |
6147e2c6 | 992 | "show ipv6 ospf6 route <intra-area|inter-area|external-1|external-2> detail", |
4846ef64 | 993 | SHOW_STR |
994 | IP6_STR | |
995 | OSPF6_STR | |
996 | ROUTE_STR | |
ea402198 DO |
997 | "Display Intra-Area routes\n" |
998 | "Display Inter-Area routes\n" | |
999 | "Display Type-1 External routes\n" | |
1000 | "Display Type-2 External routes\n" | |
4846ef64 | 1001 | "Detailed information\n" |
1002 | ) | |
1003 | { | |
d62a17ae | 1004 | OSPF6_CMD_CHECK_RUNNING(); |
b52a8a52 | 1005 | |
d62a17ae | 1006 | ospf6_route_table_show(vty, 4, argc, argv, ospf6->route_table); |
1007 | return CMD_SUCCESS; | |
4846ef64 | 1008 | } |
718e3744 | 1009 | |
d62a17ae | 1010 | static void ospf6_stub_router_config_write(struct vty *vty) |
f41b4a02 | 1011 | { |
d62a17ae | 1012 | if (CHECK_FLAG(ospf6->flag, OSPF6_STUB_ROUTER)) { |
1013 | vty_out(vty, " stub-router administrative\n"); | |
1014 | } | |
1015 | return; | |
f41b4a02 DD |
1016 | } |
1017 | ||
d62a17ae | 1018 | static int ospf6_distance_config_write(struct vty *vty) |
baff583e | 1019 | { |
d62a17ae | 1020 | struct route_node *rn; |
1021 | struct ospf6_distance *odistance; | |
1022 | ||
1023 | if (ospf6->distance_all) | |
1024 | vty_out(vty, " distance %u\n", ospf6->distance_all); | |
1025 | ||
1026 | if (ospf6->distance_intra || ospf6->distance_inter | |
1027 | || ospf6->distance_external) { | |
1028 | vty_out(vty, " distance ospf6"); | |
1029 | ||
1030 | if (ospf6->distance_intra) | |
1031 | vty_out(vty, " intra-area %u", ospf6->distance_intra); | |
1032 | if (ospf6->distance_inter) | |
1033 | vty_out(vty, " inter-area %u", ospf6->distance_inter); | |
1034 | if (ospf6->distance_external) | |
1035 | vty_out(vty, " external %u", ospf6->distance_external); | |
1036 | ||
1037 | vty_out(vty, "\n"); | |
1038 | } | |
1039 | ||
1040 | for (rn = route_top(ospf6->distance_table); rn; rn = route_next(rn)) | |
1041 | if ((odistance = rn->info) != NULL) { | |
1042 | char buf[PREFIX_STRLEN]; | |
1043 | ||
1044 | vty_out(vty, " distance %u %s %s\n", | |
1045 | odistance->distance, | |
1046 | prefix2str(&rn->p, buf, sizeof(buf)), | |
1047 | odistance->access_list ? odistance->access_list | |
1048 | : ""); | |
1049 | } | |
1050 | return 0; | |
baff583e MZ |
1051 | } |
1052 | ||
508e53e2 | 1053 | /* OSPF configuration write function. */ |
d62a17ae | 1054 | static int config_write_ospf6(struct vty *vty) |
508e53e2 | 1055 | { |
d62a17ae | 1056 | char router_id[16]; |
1057 | struct listnode *j, *k; | |
1058 | struct ospf6_area *oa; | |
1059 | struct ospf6_interface *oi; | |
1060 | ||
1061 | /* OSPFv3 configuration. */ | |
1062 | if (ospf6 == NULL) | |
1063 | return CMD_SUCCESS; | |
1064 | ||
1065 | inet_ntop(AF_INET, &ospf6->router_id_static, router_id, | |
1066 | sizeof(router_id)); | |
1067 | vty_out(vty, "router ospf6\n"); | |
1068 | if (ospf6->router_id_static != 0) | |
5d1a2ee8 | 1069 | vty_out(vty, " ospf6 router-id %s\n", router_id); |
d62a17ae | 1070 | |
1071 | /* log-adjacency-changes flag print. */ | |
1072 | if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES)) { | |
1073 | if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL)) | |
1074 | vty_out(vty, " log-adjacency-changes detail\n"); | |
1075 | else if (!DFLT_OSPF6_LOG_ADJACENCY_CHANGES) | |
1076 | vty_out(vty, " log-adjacency-changes\n"); | |
1077 | } else if (DFLT_OSPF6_LOG_ADJACENCY_CHANGES) { | |
1078 | vty_out(vty, " no log-adjacency-changes\n"); | |
1079 | } | |
1080 | ||
1081 | if (ospf6->ref_bandwidth != OSPF6_REFERENCE_BANDWIDTH) | |
1082 | vty_out(vty, " auto-cost reference-bandwidth %d\n", | |
1083 | ospf6->ref_bandwidth); | |
1084 | ||
1085 | /* LSA timers print. */ | |
1086 | if (ospf6->lsa_minarrival != OSPF_MIN_LS_ARRIVAL) | |
1087 | vty_out(vty, " timers lsa min-arrival %d\n", | |
1088 | ospf6->lsa_minarrival); | |
1089 | ||
1090 | ospf6_stub_router_config_write(vty); | |
1091 | ospf6_redistribute_config_write(vty); | |
1092 | ospf6_area_config_write(vty); | |
1093 | ospf6_spf_config_write(vty); | |
1094 | ospf6_distance_config_write(vty); | |
1095 | ||
1096 | for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, j, oa)) { | |
1097 | for (ALL_LIST_ELEMENTS_RO(oa->if_list, k, oi)) | |
1098 | vty_out(vty, " interface %s area %s\n", | |
1099 | oi->interface->name, oa->name); | |
1100 | } | |
1101 | vty_out(vty, "!\n"); | |
1102 | return 0; | |
508e53e2 | 1103 | } |
1104 | ||
1105 | /* OSPF6 node structure. */ | |
d62a17ae | 1106 | static struct cmd_node ospf6_node = { |
1107 | OSPF6_NODE, "%s(config-ospf6)# ", 1 /* VTYSH */ | |
508e53e2 | 1108 | }; |
1109 | ||
1110 | /* Install ospf related commands. */ | |
d62a17ae | 1111 | void ospf6_top_init(void) |
718e3744 | 1112 | { |
d62a17ae | 1113 | /* Install ospf6 top node. */ |
1114 | install_node(&ospf6_node, config_write_ospf6); | |
1115 | ||
1116 | install_element(VIEW_NODE, &show_ipv6_ospf6_cmd); | |
1117 | install_element(CONFIG_NODE, &router_ospf6_cmd); | |
1118 | install_element(CONFIG_NODE, &no_router_ospf6_cmd); | |
1119 | ||
1120 | install_element(VIEW_NODE, &show_ipv6_ospf6_route_cmd); | |
1121 | install_element(VIEW_NODE, &show_ipv6_ospf6_route_match_cmd); | |
1122 | install_element(VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd); | |
1123 | install_element(VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd); | |
1124 | ||
1125 | install_default(OSPF6_NODE); | |
1126 | install_element(OSPF6_NODE, &ospf6_router_id_cmd); | |
5d1a2ee8 QY |
1127 | install_element(OSPF6_NODE, &no_ospf6_router_id_cmd); |
1128 | install_element(OSPF6_NODE, &ospf6_router_id_hdn_cmd); | |
1129 | install_element(OSPF6_NODE, &no_ospf6_router_id_hdn_cmd); | |
d62a17ae | 1130 | install_element(OSPF6_NODE, &ospf6_log_adjacency_changes_cmd); |
1131 | install_element(OSPF6_NODE, &ospf6_log_adjacency_changes_detail_cmd); | |
1132 | install_element(OSPF6_NODE, &no_ospf6_log_adjacency_changes_cmd); | |
1133 | install_element(OSPF6_NODE, &no_ospf6_log_adjacency_changes_detail_cmd); | |
1134 | ||
1135 | /* LSA timers commands */ | |
1136 | install_element(OSPF6_NODE, &ospf6_timers_lsa_cmd); | |
1137 | install_element(OSPF6_NODE, &no_ospf6_timers_lsa_cmd); | |
1138 | ||
1139 | install_element(OSPF6_NODE, &ospf6_interface_area_cmd); | |
1140 | install_element(OSPF6_NODE, &no_ospf6_interface_area_cmd); | |
1141 | install_element(OSPF6_NODE, &ospf6_stub_router_admin_cmd); | |
1142 | install_element(OSPF6_NODE, &no_ospf6_stub_router_admin_cmd); | |
1143 | /* For a later time */ | |
34d5ef45 | 1144 | #if 0 |
f41b4a02 DD |
1145 | install_element (OSPF6_NODE, &ospf6_stub_router_startup_cmd); |
1146 | install_element (OSPF6_NODE, &no_ospf6_stub_router_startup_cmd); | |
1147 | install_element (OSPF6_NODE, &ospf6_stub_router_shutdown_cmd); | |
1148 | install_element (OSPF6_NODE, &no_ospf6_stub_router_shutdown_cmd); | |
34d5ef45 | 1149 | #endif |
508e53e2 | 1150 | |
d62a17ae | 1151 | install_element(OSPF6_NODE, &ospf6_distance_cmd); |
1152 | install_element(OSPF6_NODE, &no_ospf6_distance_cmd); | |
1153 | install_element(OSPF6_NODE, &ospf6_distance_ospf6_cmd); | |
1154 | install_element(OSPF6_NODE, &no_ospf6_distance_ospf6_cmd); | |
baff583e MZ |
1155 | #if 0 |
1156 | install_element (OSPF6_NODE, &ospf6_distance_source_cmd); | |
1157 | install_element (OSPF6_NODE, &no_ospf6_distance_source_cmd); | |
1158 | #endif | |
718e3744 | 1159 | } |