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