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