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