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