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 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 22 | #include <zebra.h> |
| 23 | |
| 24 | #include "log.h" |
| 25 | #include "memory.h" |
| 26 | #include "linklist.h" |
| 27 | #include "thread.h" |
| 28 | #include "vty.h" |
| 29 | #include "command.h" |
| 30 | #include "if.h" |
| 31 | #include "prefix.h" |
| 32 | #include "table.h" |
| 33 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 34 | #include "ospf6_proto.h" |
| 35 | #include "ospf6_lsa.h" |
| 36 | #include "ospf6_lsdb.h" |
| 37 | #include "ospf6_route.h" |
| 38 | #include "ospf6_spf.h" |
| 39 | #include "ospf6_top.h" |
| 40 | #include "ospf6_area.h" |
| 41 | #include "ospf6_interface.h" |
| 42 | #include "ospf6_intra.h" |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 43 | #include "ospf6_abr.h" |
| 44 | #include "ospf6d.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 | int |
| 47 | ospf6_area_cmp (void *va, void *vb) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 48 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 49 | struct ospf6_area *oa = (struct ospf6_area *) va; |
| 50 | struct ospf6_area *ob = (struct ospf6_area *) vb; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame^] | 51 | return (ntohl (oa->area_id) < ntohl (ob->area_id) ? -1 : 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 52 | } |
| 53 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 54 | /* schedule routing table recalculation */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 55 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 56 | ospf6_area_lsdb_hook_add (struct ospf6_lsa *lsa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 57 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 58 | switch (ntohs (lsa->header->type)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 59 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 60 | case OSPF6_LSTYPE_ROUTER: |
| 61 | case OSPF6_LSTYPE_NETWORK: |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame^] | 62 | ospf6_spf_schedule (OSPF6_AREA (lsa->lsdb->data)); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 63 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 64 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 65 | case OSPF6_LSTYPE_INTRA_PREFIX: |
| 66 | ospf6_intra_prefix_lsa_add (lsa); |
| 67 | break; |
| 68 | |
| 69 | case OSPF6_LSTYPE_INTER_PREFIX: |
| 70 | case OSPF6_LSTYPE_INTER_ROUTER: |
| 71 | break; |
| 72 | |
| 73 | default: |
| 74 | if (IS_OSPF6_DEBUG_LSA (RECV)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame^] | 75 | zlog_info ("Unknown LSA in Area %s's lsdb", |
| 76 | OSPF6_AREA (lsa->lsdb->data)->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 77 | break; |
| 78 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 82 | ospf6_area_lsdb_hook_remove (struct ospf6_lsa *lsa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 83 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 84 | switch (ntohs (lsa->header->type)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 85 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 86 | case OSPF6_LSTYPE_ROUTER: |
| 87 | case OSPF6_LSTYPE_NETWORK: |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame^] | 88 | ospf6_spf_schedule (OSPF6_AREA (lsa->lsdb->data)); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 89 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 90 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 91 | case OSPF6_LSTYPE_INTRA_PREFIX: |
| 92 | ospf6_intra_prefix_lsa_remove (lsa); |
| 93 | break; |
| 94 | |
| 95 | case OSPF6_LSTYPE_INTER_PREFIX: |
| 96 | case OSPF6_LSTYPE_INTER_ROUTER: |
| 97 | break; |
| 98 | |
| 99 | default: |
| 100 | if (IS_OSPF6_DEBUG_LSA (RECV)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame^] | 101 | zlog_info ("Unknown LSA in Area %s's lsdb", |
| 102 | OSPF6_AREA (lsa->lsdb->data)->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 103 | break; |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | void |
| 108 | ospf6_area_route_hook_add (struct ospf6_route *route) |
| 109 | { |
| 110 | struct ospf6_route *copy = ospf6_route_copy (route); |
| 111 | ospf6_route_add (copy, ospf6->route_table); |
| 112 | } |
| 113 | |
| 114 | void |
| 115 | ospf6_area_route_hook_remove (struct ospf6_route *route) |
| 116 | { |
| 117 | struct ospf6_route *copy; |
| 118 | |
| 119 | copy = ospf6_route_lookup_identical (route, ospf6->route_table); |
| 120 | if (copy) |
| 121 | ospf6_route_remove (copy, ospf6->route_table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | /* Make new area structure */ |
| 125 | struct ospf6_area * |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 126 | ospf6_area_create (u_int32_t area_id, struct ospf6 *o) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 127 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 128 | struct ospf6_area *oa; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 129 | struct ospf6_route *route; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 130 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 131 | oa = XCALLOC (MTYPE_OSPF6_AREA, sizeof (struct ospf6_area)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 132 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 133 | inet_ntop (AF_INET, &area_id, oa->name, sizeof (oa->name)); |
| 134 | oa->area_id = area_id; |
| 135 | oa->if_list = list_new (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 136 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame^] | 137 | oa->lsdb = ospf6_lsdb_create (oa); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 138 | oa->lsdb->hook_add = ospf6_area_lsdb_hook_add; |
| 139 | oa->lsdb->hook_remove = ospf6_area_lsdb_hook_remove; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame^] | 140 | oa->lsdb_self = ospf6_lsdb_create (oa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 141 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 142 | oa->spf_table = ospf6_route_table_create (); |
| 143 | oa->route_table = ospf6_route_table_create (); |
| 144 | oa->route_table->hook_add = ospf6_area_route_hook_add; |
| 145 | oa->route_table->hook_remove = ospf6_area_route_hook_remove; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 146 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame^] | 147 | oa->range_table = ospf6_route_table_create (); |
| 148 | oa->summary_prefix = ospf6_route_table_create (); |
| 149 | oa->summary_router = ospf6_route_table_create (); |
| 150 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 151 | /* set default options */ |
| 152 | OSPF6_OPT_SET (oa->options, OSPF6_OPT_V6); |
| 153 | OSPF6_OPT_SET (oa->options, OSPF6_OPT_E); |
| 154 | OSPF6_OPT_SET (oa->options, OSPF6_OPT_R); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 155 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 156 | oa->ospf6 = o; |
| 157 | listnode_add_sort (o->area_list, oa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 158 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 159 | /* import athoer area's routes as inter-area routes */ |
| 160 | for (route = ospf6_route_head (o->route_table); route; |
| 161 | route = ospf6_route_next (route)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame^] | 162 | ospf6_abr_originate_summary_to_area (route, oa); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 163 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 164 | return oa; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 168 | ospf6_area_delete (struct ospf6_area *oa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 169 | { |
| 170 | listnode n; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 171 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 172 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame^] | 173 | ospf6_route_table_delete (oa->range_table); |
| 174 | ospf6_route_table_delete (oa->summary_prefix); |
| 175 | ospf6_route_table_delete (oa->summary_router); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 176 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 177 | /* ospf6 interface list */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 178 | for (n = listhead (oa->if_list); n; nextnode (n)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 179 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 180 | oi = (struct ospf6_interface *) getdata (n); |
| 181 | ospf6_interface_delete (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 182 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 183 | list_delete (oa->if_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 184 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 185 | ospf6_lsdb_delete (oa->lsdb); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame^] | 186 | ospf6_lsdb_delete (oa->lsdb_self); |
| 187 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 188 | ospf6_route_table_delete (oa->spf_table); |
| 189 | ospf6_route_table_delete (oa->route_table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 190 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 191 | #if 0 |
| 192 | ospf6_spftree_delete (oa->spf_tree); |
| 193 | ospf6_route_table_delete (oa->topology_table); |
| 194 | #endif /*0*/ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 195 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 196 | THREAD_OFF (oa->thread_spf_calculation); |
| 197 | THREAD_OFF (oa->thread_route_calculation); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 198 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 199 | listnode_delete (oa->ospf6->area_list, oa); |
| 200 | oa->ospf6 = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 201 | |
| 202 | /* free area */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 203 | XFREE (MTYPE_OSPF6_AREA, oa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | struct ospf6_area * |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 207 | ospf6_area_lookup (u_int32_t area_id, struct ospf6 *ospf6) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 208 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 209 | struct ospf6_area *oa; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 210 | listnode n; |
| 211 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 212 | for (n = listhead (ospf6->area_list); n; nextnode (n)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 213 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 214 | oa = (struct ospf6_area *) getdata (n); |
| 215 | if (oa->area_id == area_id) |
| 216 | return oa; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | return (struct ospf6_area *) NULL; |
| 220 | } |
| 221 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame^] | 222 | struct ospf6_area * |
| 223 | ospf6_area_get (u_int32_t area_id, struct ospf6 *o) |
| 224 | { |
| 225 | struct ospf6_area *oa; |
| 226 | oa = ospf6_area_lookup (area_id, o); |
| 227 | if (oa == NULL) |
| 228 | oa = ospf6_area_create (area_id, o); |
| 229 | return oa; |
| 230 | } |
| 231 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 232 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 233 | ospf6_area_enable (struct ospf6_area *oa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 234 | { |
| 235 | listnode i; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 236 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 237 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame^] | 238 | SET_FLAG (oa->flag, OSPF6_AREA_ENABLE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 239 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 240 | for (i = listhead (oa->if_list); i; nextnode (i)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 241 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 242 | oi = (struct ospf6_interface *) getdata (i); |
| 243 | ospf6_interface_enable (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 244 | } |
| 245 | } |
| 246 | |
| 247 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 248 | ospf6_area_disable (struct ospf6_area *oa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 249 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 250 | listnode i; |
| 251 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 252 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame^] | 253 | UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 254 | |
| 255 | for (i = listhead (oa->if_list); i; nextnode (i)) |
| 256 | { |
| 257 | oi = (struct ospf6_interface *) getdata (i); |
| 258 | ospf6_interface_disable (oi); |
| 259 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 260 | } |
| 261 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 262 | |
| 263 | void |
| 264 | ospf6_area_show (struct vty *vty, struct ospf6_area *oa) |
| 265 | { |
| 266 | listnode i; |
| 267 | struct ospf6_interface *oi; |
| 268 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 269 | vty_out (vty, " Area %s%s", oa->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 270 | vty_out (vty, " Number of Area scoped LSAs is %u%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 271 | oa->lsdb->count, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 272 | |
| 273 | vty_out (vty, " Interface attached to this area:"); |
| 274 | for (i = listhead (oa->if_list); i; nextnode (i)) |
| 275 | { |
| 276 | oi = (struct ospf6_interface *) getdata (i); |
| 277 | vty_out (vty, " %s", oi->interface->name); |
| 278 | } |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 279 | vty_out (vty, "%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 283 | #define OSPF6_CMD_AREA_LOOKUP(str, oa) \ |
| 284 | { \ |
| 285 | u_int32_t area_id = 0; \ |
| 286 | if (inet_pton (AF_INET, str, &area_id) != 1) \ |
| 287 | { \ |
| 288 | vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \ |
| 289 | return CMD_SUCCESS; \ |
| 290 | } \ |
| 291 | oa = ospf6_area_lookup (area_id, ospf6); \ |
| 292 | if (oa == NULL) \ |
| 293 | { \ |
| 294 | vty_out (vty, "No such Area: %s%s", str, VNL); \ |
| 295 | return CMD_SUCCESS; \ |
| 296 | } \ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 297 | } |
| 298 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame^] | 299 | #define OSPF6_CMD_AREA_GET(str, oa) \ |
| 300 | { \ |
| 301 | u_int32_t area_id = 0; \ |
| 302 | if (inet_pton (AF_INET, str, &area_id) != 1) \ |
| 303 | { \ |
| 304 | vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \ |
| 305 | return CMD_SUCCESS; \ |
| 306 | } \ |
| 307 | oa = ospf6_area_get (area_id, ospf6); \ |
| 308 | } |
| 309 | |
| 310 | DEFUN (area_range, |
| 311 | area_range_cmd, |
| 312 | "area A.B.C.D range X:X::X:X/M", |
| 313 | "OSPF area parameters\n" |
| 314 | OSPF6_AREA_ID_STR |
| 315 | "Configured address range\n" |
| 316 | "Specify IPv6 prefix\n" |
| 317 | ) |
| 318 | { |
| 319 | int ret; |
| 320 | struct ospf6_area *oa; |
| 321 | struct prefix prefix; |
| 322 | struct ospf6_route *range; |
| 323 | |
| 324 | OSPF6_CMD_AREA_GET (argv[0], oa); |
| 325 | argc--; |
| 326 | argv++; |
| 327 | |
| 328 | ret = str2prefix (argv[0], &prefix); |
| 329 | if (ret != 1 || prefix.family != AF_INET6) |
| 330 | { |
| 331 | vty_out (vty, "Malformed argument: %s%s", argv[0], VNL); |
| 332 | return CMD_SUCCESS; |
| 333 | } |
| 334 | argc--; |
| 335 | argv++; |
| 336 | |
| 337 | range = ospf6_route_lookup (&prefix, oa->range_table); |
| 338 | if (range == NULL) |
| 339 | { |
| 340 | range = ospf6_route_create (); |
| 341 | range->type = OSPF6_DEST_TYPE_RANGE; |
| 342 | range->prefix = prefix; |
| 343 | } |
| 344 | |
| 345 | if (argc) |
| 346 | { |
| 347 | if (! strcmp (argv[0], "not-advertise")) |
| 348 | SET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE); |
| 349 | else if (! strcmp (argv[0], "advertise")) |
| 350 | UNSET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE); |
| 351 | } |
| 352 | |
| 353 | ospf6_route_add (range, oa->range_table); |
| 354 | return CMD_SUCCESS; |
| 355 | } |
| 356 | |
| 357 | ALIAS (area_range, |
| 358 | area_range_advertise_cmd, |
| 359 | "area A.B.C.D range X:X::X:X/M (advertise|not-advertise)", |
| 360 | "OSPF area parameters\n" |
| 361 | OSPF6_AREA_ID_STR |
| 362 | "Configured address range\n" |
| 363 | "Specify IPv6 prefix\n" |
| 364 | ); |
| 365 | |
| 366 | DEFUN (no_area_range, |
| 367 | no_area_range_cmd, |
| 368 | "no area A.B.C.D range X:X::X:X/M", |
| 369 | "OSPF area parameters\n" |
| 370 | OSPF6_AREA_ID_STR |
| 371 | "Configured address range\n" |
| 372 | "Specify IPv6 prefix\n" |
| 373 | ) |
| 374 | { |
| 375 | int ret; |
| 376 | struct ospf6_area *oa; |
| 377 | struct prefix prefix; |
| 378 | struct ospf6_route *range; |
| 379 | |
| 380 | OSPF6_CMD_AREA_GET (argv[0], oa); |
| 381 | argc--; |
| 382 | argv++; |
| 383 | |
| 384 | ret = str2prefix (argv[0], &prefix); |
| 385 | if (ret != 1 || prefix.family != AF_INET6) |
| 386 | { |
| 387 | vty_out (vty, "Malformed argument: %s%s", argv[0], VNL); |
| 388 | return CMD_SUCCESS; |
| 389 | } |
| 390 | |
| 391 | range = ospf6_route_lookup (&prefix, oa->range_table); |
| 392 | if (range == NULL) |
| 393 | { |
| 394 | vty_out (vty, "Range %s does not exists.%s", argv[0], VNL); |
| 395 | return CMD_SUCCESS; |
| 396 | } |
| 397 | |
| 398 | ospf6_route_remove (range, oa->range_table); |
| 399 | return CMD_SUCCESS; |
| 400 | } |
| 401 | |
| 402 | void |
| 403 | ospf6_area_config_write (struct vty *vty) |
| 404 | { |
| 405 | listnode node; |
| 406 | struct ospf6_area *oa; |
| 407 | struct ospf6_route *range; |
| 408 | char buf[128]; |
| 409 | |
| 410 | for (node = listhead (ospf6->area_list); node; nextnode (node)) |
| 411 | { |
| 412 | oa = OSPF6_AREA (getdata (node)); |
| 413 | |
| 414 | for (range = ospf6_route_head (oa->range_table); range; |
| 415 | range = ospf6_route_next (range)) |
| 416 | { |
| 417 | prefix2str (&range->prefix, buf, sizeof (buf)); |
| 418 | vty_out (vty, " area %s range %s%s", oa->name, buf, VNL); |
| 419 | } |
| 420 | } |
| 421 | } |
| 422 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 423 | DEFUN (show_ipv6_ospf6_area_route_intra, |
| 424 | show_ipv6_ospf6_area_route_intra_cmd, |
| 425 | "show ipv6 ospf6 area A.B.C.D route intra-area", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 426 | SHOW_STR |
| 427 | IP6_STR |
| 428 | OSPF6_STR |
| 429 | OSPF6_AREA_STR |
| 430 | OSPF6_AREA_ID_STR |
| 431 | ROUTE_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 432 | "Display Intra-Area routes\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 433 | ) |
| 434 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 435 | struct ospf6_area *oa; |
| 436 | OSPF6_CMD_AREA_LOOKUP (argv[0], oa); |
| 437 | argc--; |
| 438 | argv++; |
| 439 | return ospf6_route_table_show (vty, argc, argv, oa->route_table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 440 | } |
| 441 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 442 | ALIAS (show_ipv6_ospf6_area_route_intra, |
| 443 | show_ipv6_ospf6_area_route_intra_detail_cmd, |
| 444 | "show ipv6 ospf6 area A.B.C.D route intra-area (X::X|X::X/M|detail)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 445 | SHOW_STR |
| 446 | IP6_STR |
| 447 | OSPF6_STR |
| 448 | OSPF6_AREA_STR |
| 449 | OSPF6_AREA_ID_STR |
| 450 | ROUTE_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 451 | "Display Intra-Area routes\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 452 | "Specify IPv6 address\n" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 453 | "Specify IPv6 prefix\n" |
| 454 | "Detailed information\n" |
| 455 | ); |
| 456 | |
| 457 | DEFUN (show_ipv6_ospf6_area_route_intra_match, |
| 458 | show_ipv6_ospf6_area_route_intra_match_cmd, |
| 459 | "show ipv6 ospf6 area A.B.C.D route intra-area X::X/M match", |
| 460 | SHOW_STR |
| 461 | IP6_STR |
| 462 | OSPF6_STR |
| 463 | ROUTE_STR |
| 464 | "Display Intra-Area routes\n" |
| 465 | OSPF6_AREA_STR |
| 466 | OSPF6_AREA_ID_STR |
| 467 | "Specify IPv6 prefix\n" |
| 468 | "Display routes which match the specified route\n" |
| 469 | ) |
| 470 | { |
| 471 | char *sargv[CMD_ARGC_MAX]; |
| 472 | int i, sargc; |
| 473 | struct ospf6_area *oa; |
| 474 | |
| 475 | OSPF6_CMD_AREA_LOOKUP (argv[0], oa); |
| 476 | argc--; |
| 477 | argv++; |
| 478 | |
| 479 | /* copy argv to sargv and then append "match" */ |
| 480 | for (i = 0; i < argc; i++) |
| 481 | sargv[i] = argv[i]; |
| 482 | sargc = argc; |
| 483 | sargv[sargc++] = "match"; |
| 484 | sargv[sargc] = NULL; |
| 485 | |
| 486 | return ospf6_route_table_show (vty, sargc, sargv, oa->route_table); |
| 487 | } |
| 488 | |
| 489 | DEFUN (show_ipv6_ospf6_area_route_intra_match_detail, |
| 490 | show_ipv6_ospf6_area_route_intra_match_detail_cmd, |
| 491 | "show ipv6 ospf6 area A.B.C.D route intra-area X::X/M match detail", |
| 492 | SHOW_STR |
| 493 | IP6_STR |
| 494 | OSPF6_STR |
| 495 | OSPF6_AREA_STR |
| 496 | OSPF6_AREA_ID_STR |
| 497 | ROUTE_STR |
| 498 | "Display Intra-Area routes\n" |
| 499 | "Specify IPv6 prefix\n" |
| 500 | "Display routes which match the specified route\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 501 | "Detailed information\n" |
| 502 | ) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 503 | { |
| 504 | char *sargv[CMD_ARGC_MAX]; |
| 505 | int i, sargc; |
| 506 | struct ospf6_area *oa; |
| 507 | |
| 508 | OSPF6_CMD_AREA_LOOKUP (argv[0], oa); |
| 509 | argc--; |
| 510 | argv++; |
| 511 | |
| 512 | /* copy argv to sargv and then append "match" and "detail" */ |
| 513 | for (i = 0; i < argc; i++) |
| 514 | sargv[i] = argv[i]; |
| 515 | sargc = argc; |
| 516 | sargv[sargc++] = "match"; |
| 517 | sargv[sargc++] = "detail"; |
| 518 | sargv[sargc] = NULL; |
| 519 | |
| 520 | return ospf6_route_table_show (vty, sargc, sargv, oa->route_table); |
| 521 | } |
| 522 | |
| 523 | DEFUN (show_ipv6_ospf6_route_intra, |
| 524 | show_ipv6_ospf6_route_intra_cmd, |
| 525 | "show ipv6 ospf6 route intra-area", |
| 526 | SHOW_STR |
| 527 | IP6_STR |
| 528 | OSPF6_STR |
| 529 | ROUTE_STR |
| 530 | "Display Intra-Area routes\n" |
| 531 | ) |
| 532 | { |
| 533 | listnode node; |
| 534 | struct ospf6_area *oa; |
| 535 | |
| 536 | for (node = listhead (ospf6->area_list); node; nextnode (node)) |
| 537 | { |
| 538 | oa = (struct ospf6_area *) getdata (node); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 539 | vty_out (vty, "Area %s%s", oa->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 540 | ospf6_route_table_show (vty, argc, argv, oa->route_table); |
| 541 | } |
| 542 | |
| 543 | return CMD_SUCCESS; |
| 544 | } |
| 545 | |
| 546 | ALIAS (show_ipv6_ospf6_route_intra, |
| 547 | show_ipv6_ospf6_route_intra_detail_cmd, |
| 548 | "show ipv6 ospf6 route intra-area (X::X|X::X/M|detail|summary)", |
| 549 | SHOW_STR |
| 550 | IP6_STR |
| 551 | OSPF6_STR |
| 552 | ROUTE_STR |
| 553 | "Display Intra-Area routes\n" |
| 554 | "Specify IPv6 address\n" |
| 555 | "Specify IPv6 prefix\n" |
| 556 | "Detailed information\n" |
| 557 | "Summary of route table\n" |
| 558 | ); |
| 559 | |
| 560 | DEFUN (show_ipv6_ospf6_route_intra_match, |
| 561 | show_ipv6_ospf6_route_intra_match_cmd, |
| 562 | "show ipv6 ospf6 route intra-area X::X/M match", |
| 563 | SHOW_STR |
| 564 | IP6_STR |
| 565 | OSPF6_STR |
| 566 | ROUTE_STR |
| 567 | "Display Intra-Area routes\n" |
| 568 | "Specify IPv6 prefix\n" |
| 569 | "Display routes which match the specified route\n" |
| 570 | ) |
| 571 | { |
| 572 | char *sargv[CMD_ARGC_MAX]; |
| 573 | int i, sargc; |
| 574 | listnode node; |
| 575 | struct ospf6_area *oa; |
| 576 | |
| 577 | /* copy argv to sargv and then append "match" */ |
| 578 | for (i = 0; i < argc; i++) |
| 579 | sargv[i] = argv[i]; |
| 580 | sargc = argc; |
| 581 | sargv[sargc++] = "match"; |
| 582 | sargv[sargc] = NULL; |
| 583 | |
| 584 | for (node = listhead (ospf6->area_list); node; nextnode (node)) |
| 585 | { |
| 586 | oa = (struct ospf6_area *) getdata (node); |
| 587 | ospf6_route_table_show (vty, sargc, sargv, oa->route_table); |
| 588 | } |
| 589 | |
| 590 | return CMD_SUCCESS; |
| 591 | } |
| 592 | |
| 593 | DEFUN (show_ipv6_ospf6_route_intra_match_detail, |
| 594 | show_ipv6_ospf6_route_intra_match_detail_cmd, |
| 595 | "show ipv6 ospf6 route intra-area X::X/M match detail", |
| 596 | SHOW_STR |
| 597 | IP6_STR |
| 598 | OSPF6_STR |
| 599 | ROUTE_STR |
| 600 | "Display Intra-Area routes\n" |
| 601 | "Specify IPv6 prefix\n" |
| 602 | "Display routes which match the specified route\n" |
| 603 | "Detailed information\n" |
| 604 | ) |
| 605 | { |
| 606 | char *sargv[CMD_ARGC_MAX]; |
| 607 | int i, sargc; |
| 608 | listnode node; |
| 609 | struct ospf6_area *oa; |
| 610 | |
| 611 | /* copy argv to sargv and then append "match" and "detail" */ |
| 612 | for (i = 0; i < argc; i++) |
| 613 | sargv[i] = argv[i]; |
| 614 | sargc = argc; |
| 615 | sargv[sargc++] = "match"; |
| 616 | sargv[sargc++] = "detail"; |
| 617 | sargv[sargc] = NULL; |
| 618 | |
| 619 | for (node = listhead (ospf6->area_list); node; nextnode (node)) |
| 620 | { |
| 621 | oa = (struct ospf6_area *) getdata (node); |
| 622 | ospf6_route_table_show (vty, sargc, sargv, oa->route_table); |
| 623 | } |
| 624 | |
| 625 | return CMD_SUCCESS; |
| 626 | } |
| 627 | |
| 628 | DEFUN (show_ipv6_ospf6_spf_tree, |
| 629 | show_ipv6_ospf6_spf_tree_cmd, |
| 630 | "show ipv6 ospf6 spf tree", |
| 631 | SHOW_STR |
| 632 | IP6_STR |
| 633 | OSPF6_STR |
| 634 | "Shortest Path First caculation\n" |
| 635 | "Show SPF tree\n") |
| 636 | { |
| 637 | listnode node; |
| 638 | struct ospf6_area *oa; |
| 639 | struct ospf6_vertex *root; |
| 640 | struct ospf6_route *route; |
| 641 | struct prefix prefix; |
| 642 | |
| 643 | ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix); |
| 644 | for (node = listhead (ospf6->area_list); node; nextnode (node)) |
| 645 | { |
| 646 | oa = (struct ospf6_area *) getdata (node); |
| 647 | route = ospf6_route_lookup (&prefix, oa->spf_table); |
| 648 | if (route == NULL) |
| 649 | { |
| 650 | vty_out (vty, "LS entry for root not found in area %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 651 | oa->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 652 | continue; |
| 653 | } |
| 654 | root = (struct ospf6_vertex *) route->route_option; |
| 655 | ospf6_spf_display_subtree (vty, "", 0, root); |
| 656 | } |
| 657 | |
| 658 | return CMD_SUCCESS; |
| 659 | } |
| 660 | |
| 661 | DEFUN (show_ipv6_ospf6_area_spf_tree, |
| 662 | show_ipv6_ospf6_area_spf_tree_cmd, |
| 663 | "show ipv6 ospf6 area A.B.C.D spf tree", |
| 664 | SHOW_STR |
| 665 | IP6_STR |
| 666 | OSPF6_STR |
| 667 | OSPF6_AREA_STR |
| 668 | OSPF6_AREA_ID_STR |
| 669 | "Shortest Path First caculation\n" |
| 670 | "Show SPF tree\n") |
| 671 | { |
| 672 | u_int32_t area_id; |
| 673 | struct ospf6_area *oa; |
| 674 | struct ospf6_vertex *root; |
| 675 | struct ospf6_route *route; |
| 676 | struct prefix prefix; |
| 677 | |
| 678 | ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix); |
| 679 | |
| 680 | if (inet_pton (AF_INET, argv[0], &area_id) != 1) |
| 681 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 682 | vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 683 | return CMD_SUCCESS; |
| 684 | } |
| 685 | oa = ospf6_area_lookup (area_id, ospf6); |
| 686 | if (oa == NULL) |
| 687 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 688 | vty_out (vty, "No such Area: %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 689 | return CMD_SUCCESS; |
| 690 | } |
| 691 | |
| 692 | route = ospf6_route_lookup (&prefix, oa->spf_table); |
| 693 | if (route == NULL) |
| 694 | { |
| 695 | vty_out (vty, "LS entry for root not found in area %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 696 | oa->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 697 | return CMD_SUCCESS; |
| 698 | } |
| 699 | root = (struct ospf6_vertex *) route->route_option; |
| 700 | ospf6_spf_display_subtree (vty, "", 0, root); |
| 701 | |
| 702 | return CMD_SUCCESS; |
| 703 | } |
| 704 | |
| 705 | DEFUN (show_ipv6_ospf6_area_spf_table, |
| 706 | show_ipv6_ospf6_area_spf_table_cmd, |
| 707 | "show ipv6 ospf6 area A.B.C.D spf table", |
| 708 | SHOW_STR |
| 709 | IP6_STR |
| 710 | OSPF6_STR |
| 711 | OSPF6_AREA_STR |
| 712 | OSPF6_AREA_ID_STR |
| 713 | "Shortest Path First caculation\n" |
| 714 | "Show table contains SPF result\n" |
| 715 | ) |
| 716 | { |
| 717 | u_int32_t area_id; |
| 718 | struct ospf6_area *oa; |
| 719 | |
| 720 | if (inet_pton (AF_INET, argv[0], &area_id) != 1) |
| 721 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 722 | vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 723 | return CMD_SUCCESS; |
| 724 | } |
| 725 | oa = ospf6_area_lookup (area_id, ospf6); |
| 726 | if (oa == NULL) |
| 727 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 728 | vty_out (vty, "No such Area: %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 729 | return CMD_SUCCESS; |
| 730 | } |
| 731 | |
| 732 | argc--; |
| 733 | argv++; |
| 734 | |
| 735 | ospf6_lsentry_table_show (vty, argc, argv, oa->spf_table); |
| 736 | return CMD_SUCCESS; |
| 737 | } |
| 738 | |
| 739 | ALIAS (show_ipv6_ospf6_area_spf_table, |
| 740 | show_ipv6_ospf6_area_spf_table_1_cmd, |
| 741 | "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|A.B.C.D/M|detail)", |
| 742 | SHOW_STR |
| 743 | IP6_STR |
| 744 | OSPF6_STR |
| 745 | OSPF6_AREA_STR |
| 746 | OSPF6_AREA_ID_STR |
| 747 | "Shortest Path First caculation\n" |
| 748 | "Show table contains SPF result\n" |
| 749 | "Specify Router-ID\n" |
| 750 | "Display multiple entry by specifying match-prefix of Router-ID\n" |
| 751 | "Display Detail\n" |
| 752 | ); |
| 753 | |
| 754 | ALIAS (show_ipv6_ospf6_area_spf_table, |
| 755 | show_ipv6_ospf6_area_spf_table_2_cmd, |
| 756 | "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|*) (A.B.C.D|A.B.C.D/M|detail)", |
| 757 | SHOW_STR |
| 758 | IP6_STR |
| 759 | OSPF6_STR |
| 760 | OSPF6_AREA_STR |
| 761 | OSPF6_AREA_ID_STR |
| 762 | "Shortest Path First caculation\n" |
| 763 | "Show table contains SPF result\n" |
| 764 | "Specify Router-ID\n" |
| 765 | "Wildcard Router-ID\n" |
| 766 | "Specify Link State ID\n" |
| 767 | "Display multiple entry by specifying match-prefix of Link State ID\n" |
| 768 | "Display Detail\n" |
| 769 | ); |
| 770 | |
| 771 | DEFUN (show_ipv6_ospf6_area_spf_table_3, |
| 772 | show_ipv6_ospf6_area_spf_table_3_cmd, |
| 773 | "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|*) A.B.C.D/M detail", |
| 774 | SHOW_STR |
| 775 | IP6_STR |
| 776 | OSPF6_STR |
| 777 | OSPF6_AREA_STR |
| 778 | OSPF6_AREA_ID_STR |
| 779 | "Shortest Path First caculation\n" |
| 780 | "Show table contains SPF result\n" |
| 781 | "Specify Router-ID\n" |
| 782 | "Wildcard Router-ID\n" |
| 783 | "Display multiple entry by specifying match-prefix of Link State ID\n" |
| 784 | "Display Detail\n" |
| 785 | ) |
| 786 | { |
| 787 | u_int32_t area_id; |
| 788 | struct ospf6_area *oa; |
| 789 | char *sargv[CMD_ARGC_MAX]; |
| 790 | int i, sargc; |
| 791 | |
| 792 | if (inet_pton (AF_INET, argv[0], &area_id) != 1) |
| 793 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 794 | vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 795 | return CMD_SUCCESS; |
| 796 | } |
| 797 | oa = ospf6_area_lookup (area_id, ospf6); |
| 798 | if (oa == NULL) |
| 799 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 800 | vty_out (vty, "No such Area: %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 801 | return CMD_SUCCESS; |
| 802 | } |
| 803 | |
| 804 | argc--; |
| 805 | argv++; |
| 806 | |
| 807 | /* copy argv to sargv and then append "detail" */ |
| 808 | for (i = 0; i < argc; i++) |
| 809 | sargv[i] = argv[i]; |
| 810 | sargc = argc; |
| 811 | sargv[sargc++] = "detail"; |
| 812 | sargv[sargc] = NULL; |
| 813 | |
| 814 | ospf6_lsentry_table_show (vty, sargc, sargv, oa->spf_table); |
| 815 | return CMD_SUCCESS; |
| 816 | } |
| 817 | |
| 818 | DEFUN (show_ipv6_ospf6_spf_table, |
| 819 | show_ipv6_ospf6_spf_table_cmd, |
| 820 | "show ipv6 ospf6 spf table", |
| 821 | SHOW_STR |
| 822 | IP6_STR |
| 823 | OSPF6_STR |
| 824 | "Shortest Path First caculation\n" |
| 825 | "Show table contains SPF result\n" |
| 826 | ) |
| 827 | { |
| 828 | listnode node; |
| 829 | struct ospf6_area *oa; |
| 830 | |
| 831 | for (node = listhead (ospf6->area_list); node; nextnode (node)) |
| 832 | { |
| 833 | oa = (struct ospf6_area *) getdata (node); |
| 834 | ospf6_lsentry_table_show (vty, argc, argv, oa->spf_table); |
| 835 | } |
| 836 | |
| 837 | return CMD_SUCCESS; |
| 838 | } |
| 839 | |
| 840 | ALIAS (show_ipv6_ospf6_spf_table, |
| 841 | show_ipv6_ospf6_spf_table_1_cmd, |
| 842 | "show ipv6 ospf6 spf table (A.B.C.D|A.B.C.D/M|detail)", |
| 843 | SHOW_STR |
| 844 | IP6_STR |
| 845 | OSPF6_STR |
| 846 | "Shortest Path First caculation\n" |
| 847 | "Show table contains SPF result\n" |
| 848 | "Specify Router-ID\n" |
| 849 | "Display multiple entry by specifying match-prefix of Router-ID\n" |
| 850 | "Display Detail\n" |
| 851 | ); |
| 852 | |
| 853 | ALIAS (show_ipv6_ospf6_spf_table, |
| 854 | show_ipv6_ospf6_spf_table_2_cmd, |
| 855 | "show ipv6 ospf6 spf table (A.B.C.D|A.B.C.D/M|*) (A.B.C.D|A.B.C.D/M|detail)", |
| 856 | SHOW_STR |
| 857 | IP6_STR |
| 858 | OSPF6_STR |
| 859 | "Shortest Path First caculation\n" |
| 860 | "Show table contains SPF result\n" |
| 861 | "Specify Router-ID\n" |
| 862 | "Display multiple entry by specifying match-prefix of Router-ID\n" |
| 863 | "Wildcard Router-ID\n" |
| 864 | "Specify Link State ID\n" |
| 865 | "Display multiple entry by specifying match-prefix of Link State ID\n" |
| 866 | "Display Detail\n" |
| 867 | ); |
| 868 | |
| 869 | DEFUN (show_ipv6_ospf6_spf_table_3, |
| 870 | show_ipv6_ospf6_spf_table_3_cmd, |
| 871 | "show ipv6 ospf6 spf table (A.B.C.D|*) A.B.C.D/M detail", |
| 872 | SHOW_STR |
| 873 | IP6_STR |
| 874 | OSPF6_STR |
| 875 | "Shortest Path First caculation\n" |
| 876 | "Show table contains SPF result\n" |
| 877 | "Specify Router-ID\n" |
| 878 | "Wildcard Router-ID\n" |
| 879 | "Display multiple entry by specifying match-prefix of Link State ID\n" |
| 880 | "Display Detail\n" |
| 881 | ) |
| 882 | { |
| 883 | listnode node; |
| 884 | struct ospf6_area *oa; |
| 885 | char *sargv[CMD_ARGC_MAX]; |
| 886 | int i, sargc; |
| 887 | |
| 888 | /* copy argv to sargv and then append "detail" */ |
| 889 | for (i = 0; i < argc; i++) |
| 890 | sargv[i] = argv[i]; |
| 891 | sargc = argc; |
| 892 | sargv[sargc++] = "detail"; |
| 893 | sargv[sargc] = NULL; |
| 894 | |
| 895 | for (node = listhead (ospf6->area_list); node; nextnode (node)) |
| 896 | { |
| 897 | oa = (struct ospf6_area *) getdata (node); |
| 898 | ospf6_lsentry_table_show (vty, sargc, sargv, oa->spf_table); |
| 899 | } |
| 900 | |
| 901 | return CMD_SUCCESS; |
| 902 | } |
| 903 | |
| 904 | DEFUN (show_ipv6_ospf6_simulate_spf_tree_root, |
| 905 | show_ipv6_ospf6_simulate_spf_tree_root_cmd, |
| 906 | "show ipv6 ospf6 simulate spf-tree A.B.C.D area A.B.C.D", |
| 907 | SHOW_STR |
| 908 | IP6_STR |
| 909 | OSPF6_STR |
| 910 | "Shortest Path First caculation\n" |
| 911 | "Show SPF tree\n" |
| 912 | "Specify root's router-id to calculate another router's SPF tree\n") |
| 913 | { |
| 914 | u_int32_t area_id; |
| 915 | struct ospf6_area *oa; |
| 916 | struct ospf6_vertex *root; |
| 917 | struct ospf6_route *route; |
| 918 | struct prefix prefix; |
| 919 | u_int32_t router_id; |
| 920 | struct ospf6_route_table *spf_table; |
| 921 | unsigned char tmp_debug_ospf6_spf = 0; |
| 922 | |
| 923 | inet_pton (AF_INET, argv[0], &router_id); |
| 924 | ospf6_linkstate_prefix (router_id, htonl (0), &prefix); |
| 925 | |
| 926 | if (inet_pton (AF_INET, argv[1], &area_id) != 1) |
| 927 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 928 | vty_out (vty, "Malformed Area-ID: %s%s", argv[1], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 929 | return CMD_SUCCESS; |
| 930 | } |
| 931 | oa = ospf6_area_lookup (area_id, ospf6); |
| 932 | if (oa == NULL) |
| 933 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 934 | vty_out (vty, "No such Area: %s%s", argv[1], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 935 | return CMD_SUCCESS; |
| 936 | } |
| 937 | |
| 938 | tmp_debug_ospf6_spf = conf_debug_ospf6_spf; |
| 939 | conf_debug_ospf6_spf = 0; |
| 940 | |
| 941 | spf_table = ospf6_route_table_create (); |
| 942 | ospf6_spf_calculation (router_id, spf_table, oa); |
| 943 | |
| 944 | conf_debug_ospf6_spf = tmp_debug_ospf6_spf; |
| 945 | |
| 946 | route = ospf6_route_lookup (&prefix, spf_table); |
| 947 | if (route == NULL) |
| 948 | { |
| 949 | ospf6_spf_table_finish (spf_table); |
| 950 | ospf6_route_table_delete (spf_table); |
| 951 | return CMD_SUCCESS; |
| 952 | } |
| 953 | root = (struct ospf6_vertex *) route->route_option; |
| 954 | ospf6_spf_display_subtree (vty, "", 0, root); |
| 955 | |
| 956 | ospf6_spf_table_finish (spf_table); |
| 957 | ospf6_route_table_delete (spf_table); |
| 958 | |
| 959 | return CMD_SUCCESS; |
| 960 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 961 | |
| 962 | void |
| 963 | ospf6_area_init () |
| 964 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 965 | install_element (VIEW_NODE, &show_ipv6_ospf6_spf_tree_cmd); |
| 966 | install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_cmd); |
| 967 | install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_1_cmd); |
| 968 | install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_2_cmd); |
| 969 | install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_3_cmd); |
| 970 | install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_tree_cmd); |
| 971 | install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_cmd); |
| 972 | install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_1_cmd); |
| 973 | install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_2_cmd); |
| 974 | install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_3_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 975 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 976 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_cmd); |
| 977 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_detail_cmd); |
| 978 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_match_cmd); |
| 979 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_match_detail_cmd); |
| 980 | install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_cmd); |
| 981 | install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_detail_cmd); |
| 982 | install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_match_cmd); |
| 983 | install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_match_detail_cmd); |
| 984 | |
| 985 | install_element (VIEW_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd); |
| 986 | |
| 987 | install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_tree_cmd); |
| 988 | install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_cmd); |
| 989 | install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_1_cmd); |
| 990 | install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_2_cmd); |
| 991 | install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_3_cmd); |
| 992 | install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_tree_cmd); |
| 993 | install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_cmd); |
| 994 | install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_1_cmd); |
| 995 | install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_2_cmd); |
| 996 | install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_3_cmd); |
| 997 | |
| 998 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_cmd); |
| 999 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_detail_cmd); |
| 1000 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_match_cmd); |
| 1001 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_match_detail_cmd); |
| 1002 | install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_cmd); |
| 1003 | install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_detail_cmd); |
| 1004 | install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_match_cmd); |
| 1005 | install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_match_detail_cmd); |
| 1006 | |
| 1007 | install_element (ENABLE_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame^] | 1008 | |
| 1009 | install_element (OSPF6_NODE, &area_range_cmd); |
| 1010 | install_element (OSPF6_NODE, &area_range_advertise_cmd); |
| 1011 | install_element (OSPF6_NODE, &no_area_range_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1012 | } |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1013 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame^] | 1014 | |