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