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