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