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