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