]>
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" |
049207c3 | 49 | #include "ospf6d.h" |
718e3744 | 50 | |
51 | /* global ospf6d variable */ | |
52 | struct ospf6 *ospf6; | |
53 | ||
508e53e2 | 54 | void |
55 | ospf6_top_lsdb_hook_add (struct ospf6_lsa *lsa) | |
718e3744 | 56 | { |
508e53e2 | 57 | switch (ntohs (lsa->header->type)) |
718e3744 | 58 | { |
508e53e2 | 59 | case OSPF6_LSTYPE_AS_EXTERNAL: |
60 | ospf6_asbr_lsa_add (lsa); | |
61 | break; | |
62 | ||
63 | default: | |
508e53e2 | 64 | break; |
718e3744 | 65 | } |
66 | } | |
67 | ||
508e53e2 | 68 | void |
69 | ospf6_top_lsdb_hook_remove (struct ospf6_lsa *lsa) | |
718e3744 | 70 | { |
508e53e2 | 71 | switch (ntohs (lsa->header->type)) |
718e3744 | 72 | { |
508e53e2 | 73 | case OSPF6_LSTYPE_AS_EXTERNAL: |
74 | ospf6_asbr_lsa_remove (lsa); | |
75 | break; | |
76 | ||
77 | default: | |
508e53e2 | 78 | break; |
718e3744 | 79 | } |
80 | } | |
81 | ||
049207c3 | 82 | void |
83 | ospf6_top_route_hook_add (struct ospf6_route *route) | |
84 | { | |
6452df09 | 85 | ospf6_abr_originate_summary (route); |
049207c3 | 86 | ospf6_zebra_route_update_add (route); |
87 | } | |
88 | ||
89 | void | |
90 | ospf6_top_route_hook_remove (struct ospf6_route *route) | |
91 | { | |
6452df09 | 92 | ospf6_abr_originate_summary (route); |
049207c3 | 93 | ospf6_zebra_route_update_remove (route); |
94 | } | |
95 | ||
6452df09 | 96 | void |
97 | ospf6_top_brouter_hook_add (struct ospf6_route *route) | |
98 | { | |
ccb59b11 | 99 | ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix)); |
6452df09 | 100 | ospf6_asbr_lsentry_add (route); |
ccb59b11 | 101 | ospf6_abr_originate_summary (route); |
6452df09 | 102 | } |
103 | ||
104 | void | |
105 | ospf6_top_brouter_hook_remove (struct ospf6_route *route) | |
106 | { | |
ccb59b11 | 107 | ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix)); |
6452df09 | 108 | ospf6_asbr_lsentry_remove (route); |
ccb59b11 | 109 | ospf6_abr_originate_summary (route); |
6452df09 | 110 | } |
111 | ||
508e53e2 | 112 | struct ospf6 * |
113 | ospf6_create () | |
718e3744 | 114 | { |
508e53e2 | 115 | struct ospf6 *o; |
718e3744 | 116 | |
508e53e2 | 117 | o = XMALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6)); |
118 | memset (o, 0, sizeof (struct ospf6)); | |
718e3744 | 119 | |
508e53e2 | 120 | /* initialize */ |
121 | gettimeofday (&o->starttime, (struct timezone *) NULL); | |
122 | o->area_list = list_new (); | |
123 | o->area_list->cmp = ospf6_area_cmp; | |
6452df09 | 124 | o->lsdb = ospf6_lsdb_create (o); |
125 | o->lsdb_self = ospf6_lsdb_create (o); | |
508e53e2 | 126 | o->lsdb->hook_add = ospf6_top_lsdb_hook_add; |
127 | o->lsdb->hook_remove = ospf6_top_lsdb_hook_remove; | |
718e3744 | 128 | |
508e53e2 | 129 | o->route_table = ospf6_route_table_create (); |
049207c3 | 130 | o->route_table->hook_add = ospf6_top_route_hook_add; |
131 | o->route_table->hook_remove = ospf6_top_route_hook_remove; | |
718e3744 | 132 | |
049207c3 | 133 | o->brouter_table = ospf6_route_table_create (); |
6452df09 | 134 | o->brouter_table->hook_add = ospf6_top_brouter_hook_add; |
135 | o->brouter_table->hook_remove = ospf6_top_brouter_hook_remove; | |
049207c3 | 136 | |
508e53e2 | 137 | o->external_table = ospf6_route_table_create (); |
138 | o->external_id_table = route_table_init (); | |
718e3744 | 139 | |
508e53e2 | 140 | return o; |
718e3744 | 141 | } |
142 | ||
143 | void | |
508e53e2 | 144 | ospf6_delete (struct ospf6 *o) |
718e3744 | 145 | { |
508e53e2 | 146 | listnode i; |
147 | struct ospf6_area *oa; | |
718e3744 | 148 | |
508e53e2 | 149 | for (i = listhead (o->area_list); i; nextnode (i)) |
150 | { | |
151 | oa = (struct ospf6_area *) getdata (i); | |
152 | ospf6_area_delete (oa); | |
153 | } | |
718e3744 | 154 | |
508e53e2 | 155 | ospf6_lsdb_delete (o->lsdb); |
6452df09 | 156 | ospf6_lsdb_delete (o->lsdb_self); |
718e3744 | 157 | |
508e53e2 | 158 | ospf6_route_table_delete (o->route_table); |
049207c3 | 159 | ospf6_route_table_delete (o->brouter_table); |
718e3744 | 160 | |
508e53e2 | 161 | ospf6_route_table_delete (o->external_table); |
162 | route_table_finish (o->external_id_table); | |
718e3744 | 163 | |
508e53e2 | 164 | XFREE (MTYPE_OSPF6_TOP, o); |
165 | } | |
718e3744 | 166 | |
508e53e2 | 167 | void |
168 | ospf6_enable (struct ospf6 *o) | |
169 | { | |
170 | listnode i; | |
171 | struct ospf6_area *oa; | |
718e3744 | 172 | |
508e53e2 | 173 | if (CHECK_FLAG (o->flag, OSPF6_DISABLED)) |
718e3744 | 174 | { |
508e53e2 | 175 | UNSET_FLAG (o->flag, OSPF6_DISABLED); |
176 | for (i = listhead (o->area_list); i; nextnode (i)) | |
177 | { | |
178 | oa = (struct ospf6_area *) getdata (i); | |
179 | ospf6_area_enable (oa); | |
180 | } | |
718e3744 | 181 | } |
182 | } | |
183 | ||
184 | void | |
508e53e2 | 185 | ospf6_disable (struct ospf6 *o) |
718e3744 | 186 | { |
508e53e2 | 187 | listnode i; |
188 | struct ospf6_area *oa; | |
718e3744 | 189 | |
508e53e2 | 190 | if (! CHECK_FLAG (o->flag, OSPF6_DISABLED)) |
191 | { | |
192 | SET_FLAG (o->flag, OSPF6_DISABLED); | |
193 | for (i = listhead (o->area_list); i; nextnode (i)) | |
194 | { | |
195 | oa = (struct ospf6_area *) getdata (i); | |
196 | ospf6_area_disable (oa); | |
197 | } | |
198 | ||
199 | ospf6_lsdb_remove_all (o->lsdb); | |
200 | ospf6_route_remove_all (o->route_table); | |
6452df09 | 201 | ospf6_route_remove_all (o->brouter_table); |
508e53e2 | 202 | } |
203 | } | |
718e3744 | 204 | |
508e53e2 | 205 | int |
206 | ospf6_maxage_remover (struct thread *thread) | |
207 | { | |
208 | struct ospf6 *o = (struct ospf6 *) THREAD_ARG (thread); | |
209 | struct ospf6_area *oa; | |
210 | struct ospf6_interface *oi; | |
211 | struct ospf6_neighbor *on; | |
212 | listnode i, j, k; | |
718e3744 | 213 | |
508e53e2 | 214 | o->maxage_remover = (struct thread *) NULL; |
718e3744 | 215 | |
508e53e2 | 216 | for (i = listhead (o->area_list); i; nextnode (i)) |
718e3744 | 217 | { |
508e53e2 | 218 | oa = (struct ospf6_area *) getdata (i); |
219 | for (j = listhead (oa->if_list); j; nextnode (j)) | |
220 | { | |
221 | oi = (struct ospf6_interface *) getdata (j); | |
222 | for (k = listhead (oi->neighbor_list); k; nextnode (k)) | |
223 | { | |
224 | on = (struct ospf6_neighbor *) getdata (k); | |
225 | if (on->state != OSPF6_NEIGHBOR_EXCHANGE && | |
226 | on->state != OSPF6_NEIGHBOR_LOADING) | |
227 | continue; | |
228 | ||
508e53e2 | 229 | return 0; |
230 | } | |
231 | } | |
718e3744 | 232 | } |
718e3744 | 233 | |
508e53e2 | 234 | for (i = listhead (o->area_list); i; nextnode (i)) |
235 | { | |
236 | oa = (struct ospf6_area *) getdata (i); | |
237 | for (j = listhead (oa->if_list); j; nextnode (j)) | |
238 | { | |
239 | oi = (struct ospf6_interface *) getdata (j); | |
240 | OSPF6_LSDB_MAXAGE_REMOVER (oi->lsdb); | |
241 | } | |
242 | OSPF6_LSDB_MAXAGE_REMOVER (oa->lsdb); | |
243 | } | |
244 | OSPF6_LSDB_MAXAGE_REMOVER (o->lsdb); | |
245 | ||
508e53e2 | 246 | return 0; |
718e3744 | 247 | } |
248 | ||
249 | void | |
508e53e2 | 250 | ospf6_maxage_remove (struct ospf6 *o) |
718e3744 | 251 | { |
508e53e2 | 252 | if (o && ! o->maxage_remover) |
253 | o->maxage_remover = thread_add_event (master, ospf6_maxage_remover, o, 0); | |
718e3744 | 254 | } |
255 | ||
508e53e2 | 256 | /* start ospf6 */ |
257 | DEFUN (router_ospf6, | |
258 | router_ospf6_cmd, | |
259 | "router ospf6", | |
260 | ROUTER_STR | |
261 | OSPF6_STR) | |
718e3744 | 262 | { |
508e53e2 | 263 | if (ospf6 == NULL) |
264 | ospf6 = ospf6_create (); | |
265 | if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED)) | |
266 | ospf6_enable (ospf6); | |
267 | ||
268 | /* set current ospf point. */ | |
269 | vty->node = OSPF6_NODE; | |
270 | vty->index = ospf6; | |
271 | ||
272 | return CMD_SUCCESS; | |
718e3744 | 273 | } |
274 | ||
508e53e2 | 275 | /* stop ospf6 */ |
276 | DEFUN (no_router_ospf6, | |
277 | no_router_ospf6_cmd, | |
278 | "no router ospf6", | |
279 | NO_STR | |
280 | OSPF6_ROUTER_STR) | |
718e3744 | 281 | { |
508e53e2 | 282 | if (ospf6 == NULL || CHECK_FLAG (ospf6->flag, OSPF6_DISABLED)) |
049207c3 | 283 | vty_out (vty, "OSPFv3 is not running%s", VNL); |
508e53e2 | 284 | else |
285 | ospf6_disable (ospf6); | |
286 | ||
287 | /* return to config node . */ | |
288 | vty->node = CONFIG_NODE; | |
289 | vty->index = NULL; | |
290 | ||
291 | return CMD_SUCCESS; | |
718e3744 | 292 | } |
293 | ||
508e53e2 | 294 | /* change Router_ID commands. */ |
295 | DEFUN (ospf6_router_id, | |
296 | ospf6_router_id_cmd, | |
297 | "router-id A.B.C.D", | |
298 | "Configure OSPF Router-ID\n" | |
299 | V4NOTATION_STR) | |
718e3744 | 300 | { |
508e53e2 | 301 | int ret; |
302 | u_int32_t router_id; | |
303 | struct ospf6 *o; | |
718e3744 | 304 | |
508e53e2 | 305 | o = (struct ospf6 *) vty->index; |
718e3744 | 306 | |
508e53e2 | 307 | ret = inet_pton (AF_INET, argv[0], &router_id); |
308 | if (ret == 0) | |
309 | { | |
049207c3 | 310 | vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[0], VNL); |
508e53e2 | 311 | return CMD_SUCCESS; |
312 | } | |
313 | ||
314 | o->router_id = router_id; | |
315 | return CMD_SUCCESS; | |
718e3744 | 316 | } |
317 | ||
508e53e2 | 318 | DEFUN (ospf6_interface_area, |
319 | ospf6_interface_area_cmd, | |
320 | "interface IFNAME area A.B.C.D", | |
321 | "Enable routing on an IPv6 interface\n" | |
322 | IFNAME_STR | |
323 | "Specify the OSPF6 area ID\n" | |
324 | "OSPF6 area ID in IPv4 address notation\n" | |
325 | ) | |
718e3744 | 326 | { |
508e53e2 | 327 | struct ospf6 *o; |
3b68735f | 328 | struct ospf6_area *oa; |
508e53e2 | 329 | struct ospf6_interface *oi; |
330 | struct interface *ifp; | |
331 | u_int32_t area_id; | |
332 | ||
333 | o = (struct ospf6 *) vty->index; | |
334 | ||
335 | /* find/create ospf6 interface */ | |
336 | ifp = if_get_by_name (argv[0]); | |
337 | oi = (struct ospf6_interface *) ifp->info; | |
338 | if (oi == NULL) | |
339 | oi = ospf6_interface_create (ifp); | |
340 | if (oi->area) | |
341 | { | |
342 | vty_out (vty, "%s already attached to Area %s%s", | |
049207c3 | 343 | oi->interface->name, oi->area->name, VNL); |
508e53e2 | 344 | return CMD_SUCCESS; |
345 | } | |
346 | ||
347 | /* parse Area-ID */ | |
348 | if (inet_pton (AF_INET, argv[1], &area_id) != 1) | |
349 | { | |
049207c3 | 350 | vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL); |
508e53e2 | 351 | return CMD_SUCCESS; |
352 | } | |
e26bbeba | 353 | |
508e53e2 | 354 | /* find/create ospf6 area */ |
355 | oa = ospf6_area_lookup (area_id, o); | |
356 | if (oa == NULL) | |
357 | oa = ospf6_area_create (area_id, o); | |
358 | ||
359 | /* attach interface to area */ | |
360 | listnode_add (oa->if_list, oi); /* sort ?? */ | |
361 | oi->area = oa; | |
362 | ||
6452df09 | 363 | SET_FLAG (oa->flag, OSPF6_AREA_ENABLE); |
364 | ||
508e53e2 | 365 | /* start up */ |
366 | thread_add_event (master, interface_up, oi, 0); | |
6452df09 | 367 | |
3b68735f | 368 | /* If the router is ABR, originate summary routes */ |
369 | if (ospf6_is_router_abr (o)) | |
370 | ospf6_abr_enable_area (oa); | |
6452df09 | 371 | |
508e53e2 | 372 | return CMD_SUCCESS; |
718e3744 | 373 | } |
374 | ||
508e53e2 | 375 | DEFUN (no_ospf6_interface_area, |
376 | no_ospf6_interface_area_cmd, | |
377 | "no interface IFNAME area A.B.C.D", | |
378 | NO_STR | |
379 | "Disable routing on an IPv6 interface\n" | |
380 | IFNAME_STR | |
381 | "Specify the OSPF6 area ID\n" | |
382 | "OSPF6 area ID in IPv4 address notation\n" | |
383 | ) | |
718e3744 | 384 | { |
508e53e2 | 385 | struct ospf6 *o; |
386 | struct ospf6_interface *oi; | |
3b68735f | 387 | struct ospf6_area *oa; |
508e53e2 | 388 | struct interface *ifp; |
389 | u_int32_t area_id; | |
718e3744 | 390 | |
508e53e2 | 391 | o = (struct ospf6 *) vty->index; |
392 | ||
393 | ifp = if_lookup_by_name (argv[0]); | |
394 | if (ifp == NULL) | |
395 | { | |
049207c3 | 396 | vty_out (vty, "No such interface %s%s", argv[0], VNL); |
508e53e2 | 397 | return CMD_SUCCESS; |
398 | } | |
399 | ||
400 | oi = (struct ospf6_interface *) ifp->info; | |
401 | if (oi == NULL) | |
402 | { | |
049207c3 | 403 | vty_out (vty, "Interface %s not enabled%s", ifp->name, VNL); |
508e53e2 | 404 | return CMD_SUCCESS; |
405 | } | |
406 | ||
407 | /* parse Area-ID */ | |
408 | if (inet_pton (AF_INET, argv[1], &area_id) != 1) | |
409 | { | |
049207c3 | 410 | vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL); |
508e53e2 | 411 | return CMD_SUCCESS; |
412 | } | |
413 | ||
414 | if (oi->area->area_id != area_id) | |
415 | { | |
416 | vty_out (vty, "Wrong Area-ID: %s is attached to area %s%s", | |
049207c3 | 417 | oi->interface->name, oi->area->name, VNL); |
508e53e2 | 418 | return CMD_SUCCESS; |
419 | } | |
420 | ||
421 | thread_execute (master, interface_down, oi, 0); | |
422 | ||
6452df09 | 423 | oa = oi->area; |
508e53e2 | 424 | listnode_delete (oi->area->if_list, oi); |
425 | oi->area = (struct ospf6_area *) NULL; | |
426 | ||
6452df09 | 427 | /* Withdraw inter-area routes from this area, if necessary */ |
428 | if (oa->if_list->count == 0) | |
429 | { | |
430 | UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE); | |
3b68735f | 431 | ospf6_abr_disable_area (oa); |
6452df09 | 432 | } |
433 | ||
508e53e2 | 434 | return CMD_SUCCESS; |
718e3744 | 435 | } |
436 | ||
437 | void | |
508e53e2 | 438 | ospf6_show (struct vty *vty, struct ospf6 *o) |
718e3744 | 439 | { |
508e53e2 | 440 | listnode n; |
441 | struct ospf6_area *oa; | |
442 | char router_id[16], duration[32]; | |
443 | struct timeval now, running; | |
444 | ||
445 | /* process id, router id */ | |
446 | inet_ntop (AF_INET, &o->router_id, router_id, sizeof (router_id)); | |
447 | vty_out (vty, " OSPFv3 Routing Process (0) with Router-ID %s%s", | |
049207c3 | 448 | router_id, VNL); |
508e53e2 | 449 | |
450 | /* running time */ | |
451 | gettimeofday (&now, (struct timezone *)NULL); | |
452 | timersub (&now, &o->starttime, &running); | |
453 | timerstring (&running, duration, sizeof (duration)); | |
049207c3 | 454 | vty_out (vty, " Running %s%s", duration, VNL); |
508e53e2 | 455 | |
456 | /* Redistribute configuration */ | |
457 | /* XXX */ | |
458 | ||
459 | /* LSAs */ | |
460 | vty_out (vty, " Number of AS scoped LSAs is %u%s", | |
049207c3 | 461 | o->lsdb->count, VNL); |
718e3744 | 462 | |
508e53e2 | 463 | /* Areas */ |
464 | vty_out (vty, " Number of areas in this router is %u%s", | |
049207c3 | 465 | listcount (o->area_list), VNL); |
508e53e2 | 466 | for (n = listhead (o->area_list); n; nextnode (n)) |
467 | { | |
468 | oa = (struct ospf6_area *) getdata (n); | |
469 | ospf6_area_show (vty, oa); | |
470 | } | |
718e3744 | 471 | } |
472 | ||
508e53e2 | 473 | /* show top level structures */ |
474 | DEFUN (show_ipv6_ospf6, | |
475 | show_ipv6_ospf6_cmd, | |
476 | "show ipv6 ospf6", | |
477 | SHOW_STR | |
478 | IP6_STR | |
479 | OSPF6_STR) | |
718e3744 | 480 | { |
508e53e2 | 481 | OSPF6_CMD_CHECK_RUNNING (); |
482 | ||
483 | ospf6_show (vty, ospf6); | |
484 | return CMD_SUCCESS; | |
718e3744 | 485 | } |
486 | ||
487 | DEFUN (show_ipv6_ospf6_route, | |
488 | show_ipv6_ospf6_route_cmd, | |
489 | "show ipv6 ospf6 route", | |
490 | SHOW_STR | |
491 | IP6_STR | |
492 | OSPF6_STR | |
508e53e2 | 493 | ROUTE_STR |
718e3744 | 494 | ) |
495 | { | |
508e53e2 | 496 | ospf6_route_table_show (vty, argc, argv, ospf6->route_table); |
497 | return CMD_SUCCESS; | |
718e3744 | 498 | } |
499 | ||
500 | ALIAS (show_ipv6_ospf6_route, | |
508e53e2 | 501 | show_ipv6_ospf6_route_detail_cmd, |
4846ef64 | 502 | "show ipv6 ospf6 route (X:X::X:X|X:X::X:X/M|detail|summary)", |
718e3744 | 503 | SHOW_STR |
504 | IP6_STR | |
505 | OSPF6_STR | |
508e53e2 | 506 | ROUTE_STR |
507 | "Specify IPv6 address\n" | |
508 | "Specify IPv6 prefix\n" | |
509 | "Detailed information\n" | |
510 | "Summary of route table\n" | |
511 | ); | |
718e3744 | 512 | |
508e53e2 | 513 | DEFUN (show_ipv6_ospf6_route_match, |
514 | show_ipv6_ospf6_route_match_cmd, | |
4846ef64 | 515 | "show ipv6 ospf6 route X:X::X:X/M match", |
718e3744 | 516 | SHOW_STR |
517 | IP6_STR | |
518 | OSPF6_STR | |
508e53e2 | 519 | ROUTE_STR |
520 | "Specify IPv6 prefix\n" | |
521 | "Display routes which match the specified route\n" | |
718e3744 | 522 | ) |
523 | { | |
508e53e2 | 524 | char *sargv[CMD_ARGC_MAX]; |
525 | int i, sargc; | |
526 | ||
527 | /* copy argv to sargv and then append "match" */ | |
528 | for (i = 0; i < argc; i++) | |
529 | sargv[i] = argv[i]; | |
530 | sargc = argc; | |
531 | sargv[sargc++] = "match"; | |
532 | sargv[sargc] = NULL; | |
533 | ||
534 | ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table); | |
535 | return CMD_SUCCESS; | |
718e3744 | 536 | } |
537 | ||
508e53e2 | 538 | DEFUN (show_ipv6_ospf6_route_match_detail, |
539 | show_ipv6_ospf6_route_match_detail_cmd, | |
4846ef64 | 540 | "show ipv6 ospf6 route X:X::X:X/M match detail", |
718e3744 | 541 | SHOW_STR |
542 | IP6_STR | |
543 | OSPF6_STR | |
508e53e2 | 544 | ROUTE_STR |
545 | "Specify IPv6 prefix\n" | |
546 | "Display routes which match the specified route\n" | |
718e3744 | 547 | "Detailed information\n" |
548 | ) | |
508e53e2 | 549 | { |
550 | char *sargv[CMD_ARGC_MAX]; | |
551 | int i, sargc; | |
552 | ||
553 | /* copy argv to sargv and then append "match" and "detail" */ | |
554 | for (i = 0; i < argc; i++) | |
555 | sargv[i] = argv[i]; | |
556 | sargc = argc; | |
557 | sargv[sargc++] = "match"; | |
558 | sargv[sargc++] = "detail"; | |
559 | sargv[sargc] = NULL; | |
560 | ||
561 | ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table); | |
562 | return CMD_SUCCESS; | |
563 | } | |
718e3744 | 564 | |
4846ef64 | 565 | ALIAS (show_ipv6_ospf6_route, |
566 | show_ipv6_ospf6_route_type_cmd, | |
567 | "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)", | |
568 | SHOW_STR | |
569 | IP6_STR | |
570 | OSPF6_STR | |
571 | ROUTE_STR | |
572 | "Dispaly Intra-Area routes\n" | |
573 | "Dispaly Inter-Area routes\n" | |
574 | "Dispaly Type-1 External routes\n" | |
575 | "Dispaly Type-2 External routes\n" | |
576 | ); | |
577 | ||
578 | DEFUN (show_ipv6_ospf6_route_type_detail, | |
579 | show_ipv6_ospf6_route_type_detail_cmd, | |
580 | "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2) detail", | |
581 | SHOW_STR | |
582 | IP6_STR | |
583 | OSPF6_STR | |
584 | ROUTE_STR | |
585 | "Dispaly Intra-Area routes\n" | |
586 | "Dispaly Inter-Area routes\n" | |
587 | "Dispaly Type-1 External routes\n" | |
588 | "Dispaly Type-2 External routes\n" | |
589 | "Detailed information\n" | |
590 | ) | |
591 | { | |
592 | char *sargv[CMD_ARGC_MAX]; | |
593 | int i, sargc; | |
594 | ||
595 | /* copy argv to sargv and then append "detail" */ | |
596 | for (i = 0; i < argc; i++) | |
597 | sargv[i] = argv[i]; | |
598 | sargc = argc; | |
599 | sargv[sargc++] = "detail"; | |
600 | sargv[sargc] = NULL; | |
601 | ||
602 | ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table); | |
603 | return CMD_SUCCESS; | |
604 | } | |
718e3744 | 605 | |
508e53e2 | 606 | /* OSPF configuration write function. */ |
607 | int | |
608 | config_write_ospf6 (struct vty *vty) | |
609 | { | |
610 | char router_id[16]; | |
611 | listnode j, k; | |
612 | struct ospf6_area *oa; | |
613 | struct ospf6_interface *oi; | |
614 | ||
615 | /* OSPFv6 configuration. */ | |
616 | if (ospf6 == NULL) | |
617 | return CMD_SUCCESS; | |
618 | if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED)) | |
619 | return CMD_SUCCESS; | |
620 | ||
621 | inet_ntop (AF_INET, &ospf6->router_id, router_id, sizeof (router_id)); | |
049207c3 | 622 | vty_out (vty, "router ospf6%s", VNL); |
623 | vty_out (vty, " router-id %s%s", router_id, VNL); | |
508e53e2 | 624 | |
625 | ospf6_redistribute_config_write (vty); | |
6452df09 | 626 | ospf6_area_config_write (vty); |
508e53e2 | 627 | |
628 | for (j = listhead (ospf6->area_list); j; nextnode (j)) | |
629 | { | |
630 | oa = (struct ospf6_area *) getdata (j); | |
631 | for (k = listhead (oa->if_list); k; nextnode (k)) | |
632 | { | |
633 | oi = (struct ospf6_interface *) getdata (k); | |
634 | vty_out (vty, " interface %s area %s%s", | |
049207c3 | 635 | oi->interface->name, oa->name, VNL); |
508e53e2 | 636 | } |
637 | } | |
049207c3 | 638 | vty_out (vty, "!%s", VNL); |
508e53e2 | 639 | return 0; |
640 | } | |
641 | ||
642 | /* OSPF6 node structure. */ | |
643 | struct cmd_node ospf6_node = | |
644 | { | |
645 | OSPF6_NODE, | |
646 | "%s(config-ospf6)# ", | |
69b4a810 | 647 | 1 /* VTYSH */ |
508e53e2 | 648 | }; |
649 | ||
650 | /* Install ospf related commands. */ | |
718e3744 | 651 | void |
652 | ospf6_top_init () | |
653 | { | |
508e53e2 | 654 | /* Install ospf6 top node. */ |
655 | install_node (&ospf6_node, config_write_ospf6); | |
656 | ||
657 | install_element (VIEW_NODE, &show_ipv6_ospf6_cmd); | |
658 | install_element (ENABLE_NODE, &show_ipv6_ospf6_cmd); | |
659 | install_element (CONFIG_NODE, &router_ospf6_cmd); | |
660 | ||
718e3744 | 661 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd); |
508e53e2 | 662 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd); |
663 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd); | |
664 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd); | |
4846ef64 | 665 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd); |
666 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd); | |
718e3744 | 667 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_cmd); |
508e53e2 | 668 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_detail_cmd); |
669 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_cmd); | |
670 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_detail_cmd); | |
4846ef64 | 671 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_cmd); |
672 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_detail_cmd); | |
508e53e2 | 673 | |
674 | install_default (OSPF6_NODE); | |
675 | install_element (OSPF6_NODE, &ospf6_router_id_cmd); | |
676 | install_element (OSPF6_NODE, &ospf6_interface_area_cmd); | |
677 | install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd); | |
678 | install_element (OSPF6_NODE, &no_router_ospf6_cmd); | |
718e3744 | 679 | } |
680 | ||
508e53e2 | 681 |