jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * IS-IS Rout(e)ing protocol - isisd.c |
| 3 | * |
| 4 | * Copyright (C) 2001,2002 Sampo Saaristo |
| 5 | * Tampere University of Technology |
| 6 | * Institute of Communications Engineering |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public Licenseas published by the Free |
| 10 | * Software Foundation; either version 2 of the License, or (at your option) |
| 11 | * any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful,but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 16 | * more details. |
| 17 | |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 21 | */ |
| 22 | |
| 23 | #include <string.h> |
| 24 | #include <zebra.h> |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 25 | |
| 26 | #include "thread.h" |
| 27 | #include "vty.h" |
| 28 | #include "command.h" |
| 29 | #include "log.h" |
| 30 | #include "memory.h" |
| 31 | #include "linklist.h" |
| 32 | #include "if.h" |
| 33 | #include "hash.h" |
| 34 | #include "stream.h" |
| 35 | #include "prefix.h" |
| 36 | #include "table.h" |
| 37 | |
| 38 | #include "isisd/dict.h" |
| 39 | #include "isisd/include-netbsd/iso.h" |
| 40 | #include "isisd/isis_constants.h" |
| 41 | #include "isisd/isis_common.h" |
| 42 | #include "isisd/isis_circuit.h" |
| 43 | #include "isisd/isis_flags.h" |
| 44 | #include "isisd/isisd.h" |
| 45 | #include "isisd/isis_dynhn.h" |
| 46 | #include "isisd/isis_adjacency.h" |
| 47 | #include "isisd/isis_pdu.h" |
| 48 | #include "isisd/isis_misc.h" |
| 49 | #include "isisd/isis_constants.h" |
| 50 | #include "isisd/isis_tlv.h" |
| 51 | #include "isisd/isis_lsp.h" |
| 52 | #include "isisd/isis_spf.h" |
| 53 | #include "isisd/isis_route.h" |
| 54 | #include "isisd/isis_zebra.h" |
| 55 | #include "isisd/isis_events.h" |
| 56 | |
| 57 | #ifdef TOPOLOGY_GENERATE |
| 58 | #include "spgrid.h" |
| 59 | u_char DEFAULT_TOPOLOGY_BASEIS[6] = {0xFE, 0xED, 0xFE, 0xED, 0x00, 0x00}; |
| 60 | #endif /* TOPOLOGY_GENERATE */ |
| 61 | |
| 62 | |
| 63 | struct isis *isis = NULL; |
| 64 | struct thread_master *master; |
| 65 | |
| 66 | |
| 67 | void |
| 68 | isis_new (unsigned long process_id) |
| 69 | { |
| 70 | |
| 71 | isis = XMALLOC (MTYPE_ISIS, sizeof(struct isis)); |
| 72 | bzero (isis, sizeof (struct isis)); |
| 73 | /* |
| 74 | * Default values |
| 75 | */ |
| 76 | isis->max_area_addrs = 3; |
| 77 | |
| 78 | isis->process_id = process_id; |
| 79 | isis->area_list = list_new (); |
| 80 | isis->init_circ_list = list_new (); |
| 81 | isis->uptime = time (NULL); |
| 82 | isis->nexthops = list_new (); |
| 83 | #ifdef HAVE_IPV6 |
| 84 | isis->nexthops6 = list_new (); |
| 85 | #endif /* HAVE_IPV6 */ |
| 86 | /* |
| 87 | * uncomment the next line for full debugs |
| 88 | */ |
| 89 | /* isis->debugs = 0xFFFF; */ |
| 90 | } |
| 91 | |
| 92 | struct isis_area * |
| 93 | isis_area_create () |
| 94 | { |
| 95 | |
| 96 | struct isis_area *area; |
| 97 | |
| 98 | area = XMALLOC (MTYPE_ISIS_AREA, sizeof (struct isis_area)); |
| 99 | memset (area, 0, sizeof (struct isis_area)); |
| 100 | |
| 101 | /* |
| 102 | * The first instance is level-1-2 rest are level-1, unless otherwise |
| 103 | * configured |
| 104 | */ |
| 105 | if (listcount (isis->area_list) > 0) |
| 106 | area->is_type = IS_LEVEL_1; |
| 107 | else |
| 108 | area->is_type = IS_LEVEL_1_AND_2; |
| 109 | /* |
| 110 | * intialize the databases |
| 111 | */ |
| 112 | area->lspdb[0] = lsp_db_init (); |
| 113 | area->lspdb[1] = lsp_db_init (); |
| 114 | |
| 115 | spftree_area_init (area); |
| 116 | area->route_table = route_table_init (); |
| 117 | #ifdef HAVE_IPV6 |
| 118 | area->route_table6 = route_table_init (); |
| 119 | #endif /* HAVE_IPV6 */ |
| 120 | area->circuit_list = list_new (); |
| 121 | area->area_addrs = list_new (); |
hasso | d70f99e | 2004-02-11 20:26:31 +0000 | [diff] [blame] | 122 | THREAD_TIMER_ON(master, area->t_tick, lsp_tick, area, 1); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 123 | area->flags.maxindex = -1; |
| 124 | /* |
| 125 | * Default values |
| 126 | */ |
| 127 | area->max_lsp_lifetime[0] = MAX_AGE; /* 1200 */ |
| 128 | area->max_lsp_lifetime[1] = MAX_AGE; /* 1200 */ |
| 129 | area->lsp_gen_interval[0] = LSP_GEN_INTERVAL_DEFAULT; |
| 130 | area->lsp_gen_interval[1] = LSP_GEN_INTERVAL_DEFAULT; |
| 131 | area->lsp_refresh[0] = MAX_LSP_GEN_INTERVAL; /* 900 */ |
| 132 | area->lsp_refresh[1] = MAX_LSP_GEN_INTERVAL; /* 900 */ |
| 133 | area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL; |
| 134 | area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL; |
| 135 | area->dynhostname = 1; |
| 136 | area->lsp_frag_threshold = 90; |
| 137 | #ifdef TOPOLOGY_GENERATE |
| 138 | memcpy (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN); |
| 139 | #endif /* TOPOLOGY_GENERATE */ |
| 140 | |
| 141 | /* FIXME: Think of a better way... */ |
| 142 | area->min_bcast_mtu = 1497; |
| 143 | |
| 144 | return area; |
| 145 | } |
| 146 | |
| 147 | struct isis_area * |
| 148 | isis_area_lookup (char *area_tag) |
| 149 | { |
| 150 | struct isis_area *area; |
| 151 | struct listnode *node; |
| 152 | |
| 153 | LIST_LOOP (isis->area_list, area, node) |
| 154 | if ((area->area_tag == NULL && area_tag == NULL) || |
| 155 | (area->area_tag && area_tag && strcmp (area->area_tag, area_tag) == 0)) |
| 156 | return area; |
| 157 | |
| 158 | return NULL; |
| 159 | } |
| 160 | |
| 161 | int |
| 162 | isis_area_get (struct vty *vty, char *area_tag) |
| 163 | { |
| 164 | |
| 165 | struct isis_area *area; |
| 166 | |
| 167 | area = isis_area_lookup (area_tag); |
| 168 | |
| 169 | if (area) { |
| 170 | vty->node = ISIS_NODE; |
| 171 | vty->index = area; |
| 172 | return CMD_SUCCESS; |
| 173 | } |
| 174 | |
| 175 | area = isis_area_create (); |
| 176 | area->area_tag = strdup (area_tag); |
| 177 | listnode_add (isis->area_list, area); |
| 178 | |
| 179 | zlog_info ("new IS-IS area instance %s", area->area_tag); |
| 180 | |
| 181 | vty->node = ISIS_NODE; |
| 182 | vty->index = area; |
| 183 | |
| 184 | return CMD_SUCCESS; |
| 185 | } |
| 186 | |
| 187 | int |
| 188 | isis_area_destroy (struct vty *vty, char *area_tag) |
| 189 | { |
| 190 | |
| 191 | struct isis_area *area; |
| 192 | struct listnode *node; |
| 193 | struct isis_circuit *circuit; |
| 194 | |
| 195 | area = isis_area_lookup (area_tag); |
| 196 | |
| 197 | if (area == NULL) { |
| 198 | vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); |
| 199 | return CMD_WARNING; |
| 200 | } |
| 201 | |
| 202 | if (area->circuit_list) { |
| 203 | node = listhead (area->circuit_list); |
| 204 | while (node) { |
| 205 | circuit = getdata (node); |
| 206 | nextnode (node); |
| 207 | isis_circuit_del (circuit); |
| 208 | } |
| 209 | list_delete (area->circuit_list); |
| 210 | } |
| 211 | listnode_delete (isis->area_list, area); |
hasso | d70f99e | 2004-02-11 20:26:31 +0000 | [diff] [blame] | 212 | THREAD_TIMER_OFF(area->t_tick); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 213 | if (area->t_remove_aged) |
| 214 | thread_cancel (area->t_remove_aged); |
hasso | d70f99e | 2004-02-11 20:26:31 +0000 | [diff] [blame] | 215 | THREAD_TIMER_OFF(area->t_lsp_refresh[0]); |
| 216 | THREAD_TIMER_OFF(area->t_lsp_refresh[1]); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 217 | |
| 218 | XFREE (MTYPE_ISIS_AREA, area); |
| 219 | |
| 220 | return CMD_SUCCESS; |
| 221 | } |
| 222 | |
| 223 | int |
| 224 | area_net_title (struct vty *vty , char *net_title) |
| 225 | { |
| 226 | |
| 227 | struct isis_area *area; |
| 228 | struct area_addr *addr; |
| 229 | struct area_addr *addrp; |
| 230 | struct listnode *node; |
| 231 | |
| 232 | u_char buff[255]; |
| 233 | area = vty->index; |
| 234 | |
| 235 | if (!area) { |
| 236 | vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); |
| 237 | return CMD_WARNING; |
| 238 | } |
| 239 | |
| 240 | /* We check that we are not over the maximal number of addresses */ |
| 241 | if (listcount (area->area_addrs) >= isis->max_area_addrs) { |
| 242 | vty_out (vty, "Maximum of area addresses (%d) already reached %s", |
| 243 | isis->max_area_addrs, VTY_NEWLINE); |
| 244 | return CMD_WARNING; |
| 245 | } |
| 246 | |
| 247 | addr = XMALLOC (MTYPE_ISIS_AREA_ADDR, sizeof (struct area_addr)); |
| 248 | addr->addr_len = dotformat2buff (buff, net_title); |
| 249 | memcpy (addr->area_addr, buff, addr->addr_len); |
| 250 | #ifdef EXTREME_DEBUG |
| 251 | zlog_info ("added area address %s for area %s (address length %d)", |
| 252 | net_title, area->area_tag, addr->addr_len); |
| 253 | #endif /* EXTREME_DEBUG */ |
| 254 | if (addr->addr_len < 8 || addr->addr_len > 20) { |
| 255 | zlog_warn ("area address must be at least 8..20 octets long (%d)", |
| 256 | addr->addr_len); |
| 257 | XFREE (MTYPE_ISIS_AREA_ADDR, addr); |
| 258 | return CMD_WARNING; |
| 259 | } |
| 260 | |
| 261 | if (isis->sysid_set == 0) { |
| 262 | /* |
| 263 | * First area address - get the SystemID for this router |
| 264 | */ |
| 265 | memcpy (isis->sysid, GETSYSID(addr, ISIS_SYS_ID_LEN), ISIS_SYS_ID_LEN); |
| 266 | isis->sysid_set = 1; |
| 267 | zlog_info ("Router has SystemID %s", sysid_print (isis->sysid)); |
| 268 | } else { |
| 269 | /* |
| 270 | * Check that the SystemID portions match |
| 271 | */ |
| 272 | if (memcmp (isis->sysid, GETSYSID(addr, ISIS_SYS_ID_LEN), |
| 273 | ISIS_SYS_ID_LEN)) { |
| 274 | vty_out (vty, "System ID must not change when defining additional area" |
| 275 | " addresses%s", VTY_NEWLINE); |
| 276 | XFREE (MTYPE_ISIS_AREA_ADDR, addr); |
| 277 | return CMD_WARNING; |
| 278 | } |
| 279 | |
| 280 | /* now we see that we don't already have this address */ |
| 281 | LIST_LOOP (area->area_addrs, addrp, node) { |
| 282 | if ((addrp->addr_len+ ISIS_SYS_ID_LEN + 1) == (addr->addr_len)) { |
| 283 | if (!memcmp (addrp->area_addr, addr->area_addr,addr->addr_len)) { |
| 284 | XFREE (MTYPE_ISIS_AREA_ADDR, addr); |
| 285 | return CMD_SUCCESS; /* silent fail */ |
| 286 | } |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | } |
| 291 | /* |
| 292 | * Forget the systemID part of the address |
| 293 | */ |
| 294 | addr->addr_len -= (ISIS_SYS_ID_LEN + 1); |
| 295 | listnode_add (area->area_addrs, addr); |
| 296 | |
| 297 | /* only now we can safely generate our LSPs for this area */ |
| 298 | if (listcount(area->area_addrs) > 0) { |
| 299 | lsp_l1_generate (area); |
| 300 | lsp_l2_generate (area); |
| 301 | } |
| 302 | |
| 303 | return CMD_SUCCESS; |
| 304 | } |
| 305 | |
| 306 | int |
| 307 | area_clear_net_title (struct vty *vty, char *net_title) |
| 308 | { |
| 309 | struct isis_area *area; |
| 310 | struct area_addr addr, *addrp = NULL; |
| 311 | struct listnode *node; |
| 312 | u_char buff[255]; |
| 313 | |
| 314 | area = vty->index; |
| 315 | if (!area) { |
| 316 | vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); |
| 317 | return CMD_WARNING; |
| 318 | } |
| 319 | |
| 320 | addr.addr_len = dotformat2buff (buff, net_title); |
| 321 | if (addr.addr_len < 8 || addr.addr_len > 20) { |
| 322 | vty_out (vty, "Unsupported area address length %d, should be 8...20 %s", |
| 323 | addr.addr_len, VTY_NEWLINE); |
| 324 | return CMD_WARNING; |
| 325 | } |
| 326 | |
| 327 | memcpy(addr.area_addr, buff, (int)addr.addr_len); |
| 328 | |
| 329 | LIST_LOOP (area->area_addrs, addrp, node) |
| 330 | if (addrp->addr_len == addr.addr_len && |
| 331 | !memcmp (addrp->area_addr, addr.area_addr, addr.addr_len)) |
| 332 | break; |
| 333 | |
| 334 | if (!addrp) { |
| 335 | vty_out (vty, "No area address %s for area %s %s", net_title, |
| 336 | area->area_tag, VTY_NEWLINE); |
| 337 | return CMD_WARNING; |
| 338 | } |
| 339 | |
| 340 | listnode_delete (area->area_addrs, addrp); |
| 341 | |
| 342 | return CMD_SUCCESS; |
| 343 | } |
| 344 | |
| 345 | |
| 346 | /* |
| 347 | * 'show clns neighbors' command |
| 348 | */ |
| 349 | |
| 350 | int |
| 351 | show_clns_neigh (struct vty *vty, char detail) |
| 352 | { |
| 353 | struct listnode *node_area, *node_circ; |
| 354 | struct isis_area *area; |
| 355 | struct isis_circuit *circuit; |
| 356 | struct list *db; |
| 357 | int i; |
| 358 | |
| 359 | if (!isis) { |
| 360 | vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE); |
| 361 | return CMD_SUCCESS; |
| 362 | } |
| 363 | |
| 364 | for (node_area = listhead (isis->area_list); node_area; |
| 365 | nextnode (node_area)) { |
| 366 | area = getdata (node_area); |
| 367 | vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE); |
| 368 | |
| 369 | if (detail==ISIS_UI_LEVEL_BRIEF) |
| 370 | vty_out (vty, " System Id Interface L State " |
| 371 | "Holdtime SNPA%s", VTY_NEWLINE); |
| 372 | |
| 373 | for (node_circ = listhead (area->circuit_list); node_circ; |
| 374 | nextnode (node_circ)) { |
| 375 | circuit = getdata (node_circ); |
| 376 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { |
| 377 | for (i = 0; i < 2; i++) { |
| 378 | db = circuit->u.bc.adjdb[i]; |
| 379 | if (db && db->count) { |
| 380 | if (detail == ISIS_UI_LEVEL_BRIEF) |
| 381 | isis_adjdb_iterate (db, (void (*) (struct isis_adjacency *, |
| 382 | void *)) |
| 383 | isis_adj_print_vty, vty); |
| 384 | if (detail == ISIS_UI_LEVEL_DETAIL) |
| 385 | isis_adjdb_iterate (db, (void (*) (struct isis_adjacency *, |
| 386 | void *)) |
| 387 | isis_adj_print_vty_detail, vty); |
| 388 | if (detail == ISIS_UI_LEVEL_EXTENSIVE) |
| 389 | isis_adjdb_iterate (db, (void (*) (struct isis_adjacency *, |
| 390 | void *)) |
| 391 | isis_adj_print_vty_extensive, vty); |
| 392 | } |
| 393 | } |
| 394 | } else if (circuit->circ_type == CIRCUIT_T_P2P && |
| 395 | circuit->u.p2p.neighbor) { |
| 396 | if (detail==ISIS_UI_LEVEL_BRIEF) |
| 397 | isis_adj_p2p_print_vty (circuit->u.p2p.neighbor, vty); |
| 398 | if (detail==ISIS_UI_LEVEL_DETAIL) |
| 399 | isis_adj_p2p_print_vty_detail (circuit->u.p2p.neighbor, vty); |
| 400 | if (detail==ISIS_UI_LEVEL_EXTENSIVE) |
| 401 | isis_adj_p2p_print_vty_extensive (circuit->u.p2p.neighbor, vty); |
| 402 | } |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | return CMD_SUCCESS; |
| 407 | } |
| 408 | |
| 409 | DEFUN (show_clns_neighbors, |
| 410 | show_clns_neighbors_cmd, |
| 411 | "show clns neighbors", |
| 412 | SHOW_STR |
| 413 | "clns network information\n" |
| 414 | "CLNS neighbor adjacencies\n") |
| 415 | { |
| 416 | return show_clns_neigh(vty, ISIS_UI_LEVEL_BRIEF); |
| 417 | } |
| 418 | |
| 419 | ALIAS (show_clns_neighbors, |
| 420 | show_isis_neighbors_cmd, |
| 421 | "show isis neighbors", |
| 422 | SHOW_STR |
| 423 | "IS-IS network information\n" |
| 424 | "IS-IS neighbor adjacencies\n") |
| 425 | |
| 426 | DEFUN (show_clns_neighbors_detail, |
| 427 | show_clns_neighbors_detail_cmd, |
| 428 | "show clns neighbors detail", |
| 429 | SHOW_STR |
| 430 | "clns network information\n" |
| 431 | "CLNS neighbor adjacencies\n" |
| 432 | "show detailed information\n") |
| 433 | { |
| 434 | return show_clns_neigh(vty, ISIS_UI_LEVEL_DETAIL); |
| 435 | } |
| 436 | |
| 437 | ALIAS (show_clns_neighbors_detail, |
| 438 | show_isis_neighbors_detail_cmd, |
| 439 | "show isis neighbors detail", |
| 440 | SHOW_STR |
| 441 | "IS-IS network information\n" |
| 442 | "IS-IS neighbor adjacencies\n" |
| 443 | "show detailed information\n") |
| 444 | |
| 445 | /* |
| 446 | * 'isis debug', 'show debugging' |
| 447 | */ |
| 448 | |
| 449 | void |
| 450 | print_debug (struct vty *vty, int flags, int onoff) |
| 451 | { |
| 452 | char onoffs[4]; |
| 453 | if (onoff) |
| 454 | strcpy (onoffs,"on"); |
| 455 | else |
| 456 | strcpy (onoffs,"off"); |
| 457 | |
| 458 | if (flags & DEBUG_ADJ_PACKETS) |
| 459 | vty_out (vty,"IS-IS Adjacency related packets debugging is %s%s", onoffs, |
| 460 | VTY_NEWLINE); |
| 461 | if (flags & DEBUG_CHECKSUM_ERRORS) |
| 462 | vty_out (vty,"IS-IS checksum errors debugging is %s%s", onoffs, |
| 463 | VTY_NEWLINE); |
| 464 | if (flags & DEBUG_LOCAL_UPDATES) |
| 465 | vty_out (vty,"IS-IS local updates debugging is %s%s", onoffs, |
| 466 | VTY_NEWLINE); |
| 467 | if (flags & DEBUG_PROTOCOL_ERRORS) |
| 468 | vty_out (vty,"IS-IS protocol errors debugging is %s%s", onoffs, |
| 469 | VTY_NEWLINE); |
| 470 | if (flags & DEBUG_SNP_PACKETS) |
| 471 | vty_out (vty,"IS-IS CSNP/PSNP packets debugging is %s%s", onoffs, |
| 472 | VTY_NEWLINE); |
| 473 | if (flags & DEBUG_SPF_EVENTS) |
| 474 | vty_out (vty,"IS-IS SPF events debugging is %s%s", onoffs, |
| 475 | VTY_NEWLINE); |
| 476 | if (flags & DEBUG_SPF_STATS) |
| 477 | vty_out (vty,"IS-IS SPF Timing and Statistics Data debugging is %s%s", |
| 478 | onoffs, VTY_NEWLINE); |
| 479 | if (flags & DEBUG_SPF_TRIGGERS) |
| 480 | vty_out (vty,"IS-IS SPF triggering events debugging is %s%s", onoffs, |
| 481 | VTY_NEWLINE); |
| 482 | if (flags & DEBUG_UPDATE_PACKETS) |
| 483 | vty_out (vty,"IS-IS Update related packet debugging is %s%s", onoffs, |
| 484 | VTY_NEWLINE); |
| 485 | if (flags & DEBUG_RTE_EVENTS) |
| 486 | vty_out (vty,"IS-IS Route related debuggin is %s%s", onoffs, |
| 487 | VTY_NEWLINE); |
| 488 | if (flags & DEBUG_EVENTS) |
| 489 | vty_out (vty,"IS-IS Event debugging is %s%s", onoffs, |
| 490 | VTY_NEWLINE); |
| 491 | |
| 492 | } |
| 493 | |
| 494 | DEFUN (show_debugging, |
| 495 | show_debugging_cmd, |
| 496 | "show debugging", |
| 497 | SHOW_STR |
| 498 | "State of each debugging option\n") |
| 499 | { |
| 500 | vty_out (vty,"IS-IS:%s", VTY_NEWLINE); |
| 501 | print_debug (vty, isis->debugs, 1); |
| 502 | return CMD_SUCCESS; |
| 503 | } |
| 504 | |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 505 | /* Debug node. */ |
| 506 | static struct cmd_node debug_node = |
| 507 | { |
| 508 | DEBUG_NODE, |
| 509 | "", |
| 510 | 1 |
| 511 | }; |
| 512 | |
| 513 | static int |
| 514 | config_write_debug (struct vty *vty) |
| 515 | { |
| 516 | int write = 0; |
| 517 | int flags = isis->debugs; |
| 518 | |
| 519 | if (flags & DEBUG_ADJ_PACKETS) { |
| 520 | vty_out (vty, "debug isis adj-packets%s", |
| 521 | VTY_NEWLINE); |
| 522 | write++; |
| 523 | } |
| 524 | if (flags & DEBUG_CHECKSUM_ERRORS) { |
| 525 | vty_out (vty, "debug isis checksum-errors%s", |
| 526 | VTY_NEWLINE); |
| 527 | write++; |
| 528 | } |
| 529 | if (flags & DEBUG_LOCAL_UPDATES) { |
| 530 | vty_out (vty, "debug isis local-updates%s", |
| 531 | VTY_NEWLINE); |
| 532 | write++; |
| 533 | } |
| 534 | if (flags & DEBUG_PROTOCOL_ERRORS) { |
| 535 | vty_out (vty, "debug isis protocol-errors%s", |
| 536 | VTY_NEWLINE); |
| 537 | write++; |
| 538 | } |
| 539 | if (flags & DEBUG_SNP_PACKETS) { |
| 540 | vty_out (vty, "debug isis snp-packets%s", |
| 541 | VTY_NEWLINE); |
| 542 | write++; |
| 543 | } |
| 544 | if (flags & DEBUG_SPF_EVENTS) { |
| 545 | vty_out (vty, "debug isis spf-events%s", |
| 546 | VTY_NEWLINE); |
| 547 | write++; |
| 548 | } |
| 549 | if (flags & DEBUG_SPF_STATS) { |
| 550 | vty_out (vty, "debug isis spf-statistics%s", |
| 551 | VTY_NEWLINE); |
| 552 | write++; |
| 553 | } |
| 554 | if (flags & DEBUG_SPF_TRIGGERS) { |
| 555 | vty_out (vty, "debug isis spf-triggers%s", |
| 556 | VTY_NEWLINE); |
| 557 | write++; |
| 558 | } |
| 559 | if (flags & DEBUG_UPDATE_PACKETS) { |
| 560 | vty_out (vty, "debug isis update-packets%s", |
| 561 | VTY_NEWLINE); |
| 562 | write++; |
| 563 | } |
| 564 | if (flags & DEBUG_RTE_EVENTS) { |
| 565 | vty_out (vty, "debug isis route-events%s", |
| 566 | VTY_NEWLINE); |
| 567 | write++; |
| 568 | } |
| 569 | if (flags & DEBUG_EVENTS) { |
| 570 | vty_out (vty, "debug isis events%s", |
| 571 | VTY_NEWLINE); |
| 572 | write++; |
| 573 | } |
| 574 | |
| 575 | return write; |
| 576 | } |
| 577 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 578 | DEFUN (debug_isis_adj, |
| 579 | debug_isis_adj_cmd, |
| 580 | "debug isis adj-packets", |
| 581 | DEBUG_STR |
| 582 | "IS-IS information\n" |
| 583 | "IS-IS Adjacency related packets\n" |
| 584 | ) |
| 585 | { |
| 586 | isis->debugs |= DEBUG_ADJ_PACKETS; |
| 587 | print_debug (vty,DEBUG_ADJ_PACKETS,1); |
| 588 | |
| 589 | return CMD_SUCCESS; |
| 590 | } |
| 591 | |
| 592 | DEFUN (no_debug_isis_adj, |
| 593 | no_debug_isis_adj_cmd, |
| 594 | "no debug isis adj-packets", |
| 595 | UNDEBUG_STR |
| 596 | "IS-IS information\n" |
| 597 | "IS-IS Adjacency related packets\n" |
| 598 | ) |
| 599 | { |
| 600 | |
| 601 | isis->debugs &= ~DEBUG_ADJ_PACKETS; |
| 602 | print_debug (vty, DEBUG_ADJ_PACKETS, 0); |
| 603 | |
| 604 | return CMD_SUCCESS; |
| 605 | } |
| 606 | |
| 607 | |
| 608 | DEFUN (debug_isis_csum, |
| 609 | debug_isis_csum_cmd, |
| 610 | "debug isis checksum-errors", |
| 611 | DEBUG_STR |
| 612 | "IS-IS information\n" |
| 613 | "IS-IS LSP checksum errors\n" |
| 614 | ) |
| 615 | { |
| 616 | isis->debugs |= DEBUG_CHECKSUM_ERRORS; |
| 617 | print_debug (vty, DEBUG_CHECKSUM_ERRORS, 1); |
| 618 | |
| 619 | return CMD_SUCCESS; |
| 620 | } |
| 621 | |
| 622 | DEFUN (no_debug_isis_csum, |
| 623 | no_debug_isis_csum_cmd, |
| 624 | "no debug isis checksum-errors", |
| 625 | UNDEBUG_STR |
| 626 | "IS-IS information\n" |
| 627 | "IS-IS LSP checksum errors\n" |
| 628 | ) |
| 629 | { |
| 630 | isis->debugs &= ~DEBUG_CHECKSUM_ERRORS; |
| 631 | print_debug (vty, DEBUG_CHECKSUM_ERRORS, 0); |
| 632 | |
| 633 | return CMD_SUCCESS; |
| 634 | } |
| 635 | |
| 636 | DEFUN (debug_isis_lupd, |
| 637 | debug_isis_lupd_cmd, |
| 638 | "debug isis local-updates", |
| 639 | DEBUG_STR |
| 640 | "IS-IS information\n" |
| 641 | "IS-IS local update packets\n" |
| 642 | ) |
| 643 | { |
| 644 | isis->debugs |= DEBUG_LOCAL_UPDATES; |
| 645 | print_debug (vty, DEBUG_LOCAL_UPDATES, 1); |
| 646 | |
| 647 | return CMD_SUCCESS; |
| 648 | } |
| 649 | |
| 650 | DEFUN (no_debug_isis_lupd, |
| 651 | no_debug_isis_lupd_cmd, |
| 652 | "no debug isis local-updates", |
| 653 | UNDEBUG_STR |
| 654 | "IS-IS information\n" |
| 655 | "IS-IS local update packets\n" |
| 656 | ) |
| 657 | { |
| 658 | isis->debugs &= ~DEBUG_LOCAL_UPDATES; |
| 659 | print_debug (vty, DEBUG_LOCAL_UPDATES , 0); |
| 660 | |
| 661 | return CMD_SUCCESS; |
| 662 | } |
| 663 | |
| 664 | DEFUN (debug_isis_err, |
| 665 | debug_isis_err_cmd, |
| 666 | "debug isis protocol-errors", |
| 667 | DEBUG_STR |
| 668 | "IS-IS information\n" |
| 669 | "IS-IS LSP protocol errors\n" |
| 670 | ) |
| 671 | { |
| 672 | isis->debugs |= DEBUG_PROTOCOL_ERRORS; |
| 673 | print_debug (vty, DEBUG_PROTOCOL_ERRORS, 1); |
| 674 | |
| 675 | return CMD_SUCCESS; |
| 676 | } |
| 677 | |
| 678 | DEFUN (no_debug_isis_err, |
| 679 | no_debug_isis_err_cmd, |
| 680 | "no debug isis protocol-errors", |
| 681 | UNDEBUG_STR |
| 682 | "IS-IS information\n" |
| 683 | "IS-IS LSP protocol errors\n" |
| 684 | ) |
| 685 | { |
| 686 | isis->debugs &= ~DEBUG_PROTOCOL_ERRORS; |
| 687 | print_debug (vty, DEBUG_PROTOCOL_ERRORS, 0); |
| 688 | |
| 689 | return CMD_SUCCESS; |
| 690 | } |
| 691 | |
| 692 | DEFUN (debug_isis_snp, |
| 693 | debug_isis_snp_cmd, |
| 694 | "debug isis snp-packets", |
| 695 | DEBUG_STR |
| 696 | "IS-IS information\n" |
| 697 | "IS-IS CSNP/PSNP packets\n" |
| 698 | ) |
| 699 | { |
| 700 | isis->debugs |= DEBUG_SNP_PACKETS; |
| 701 | print_debug (vty, DEBUG_SNP_PACKETS, 1); |
| 702 | |
| 703 | return CMD_SUCCESS; |
| 704 | } |
| 705 | |
| 706 | DEFUN (no_debug_isis_snp, |
| 707 | no_debug_isis_snp_cmd, |
| 708 | "no debug isis snp-packets", |
| 709 | UNDEBUG_STR |
| 710 | "IS-IS information\n" |
| 711 | "IS-IS CSNP/PSNP packets\n" |
| 712 | ) |
| 713 | { |
| 714 | isis->debugs &= ~DEBUG_SNP_PACKETS ; |
| 715 | print_debug (vty, DEBUG_SNP_PACKETS, 0); |
| 716 | |
| 717 | return CMD_SUCCESS; |
| 718 | } |
| 719 | |
| 720 | |
| 721 | |
| 722 | DEFUN (debug_isis_upd, |
| 723 | debug_isis_upd_cmd, |
| 724 | "debug isis update-packets", |
| 725 | DEBUG_STR |
| 726 | "IS-IS information\n" |
| 727 | "IS-IS Update related packets\n" |
| 728 | ) |
| 729 | { |
| 730 | isis->debugs |= DEBUG_UPDATE_PACKETS; |
| 731 | print_debug (vty, DEBUG_UPDATE_PACKETS, 1); |
| 732 | |
| 733 | return CMD_SUCCESS; |
| 734 | } |
| 735 | |
| 736 | DEFUN (no_debug_isis_upd, |
| 737 | no_debug_isis_upd_cmd, |
| 738 | "no debug isis update-packets", |
| 739 | UNDEBUG_STR |
| 740 | "IS-IS information\n" |
| 741 | "IS-IS Update related packets\n" |
| 742 | ) |
| 743 | { |
| 744 | isis->debugs &= ~DEBUG_UPDATE_PACKETS; |
| 745 | print_debug (vty, DEBUG_UPDATE_PACKETS, 0); |
| 746 | |
| 747 | return CMD_SUCCESS; |
| 748 | } |
| 749 | |
| 750 | |
| 751 | DEFUN (debug_isis_spfevents, |
| 752 | debug_isis_spfevents_cmd, |
| 753 | "debug isis spf-events", |
| 754 | DEBUG_STR |
| 755 | "IS-IS information\n" |
| 756 | "IS-IS Shortest Path First Events\n" |
| 757 | ) |
| 758 | { |
| 759 | isis->debugs |= DEBUG_SPF_EVENTS; |
| 760 | print_debug (vty, DEBUG_SPF_EVENTS , 1); |
| 761 | |
| 762 | return CMD_SUCCESS; |
| 763 | } |
| 764 | |
| 765 | DEFUN (no_debug_isis_spfevents, |
| 766 | no_debug_isis_spfevents_cmd, |
| 767 | "no debug isis spf-events", |
| 768 | UNDEBUG_STR |
| 769 | "IS-IS information\n" |
| 770 | "IS-IS Shortest Path First Events\n" |
| 771 | ) |
| 772 | { |
| 773 | isis->debugs &= ~DEBUG_SPF_EVENTS; |
| 774 | print_debug (vty, DEBUG_SPF_EVENTS , 0); |
| 775 | |
| 776 | return CMD_SUCCESS; |
| 777 | } |
| 778 | |
| 779 | |
| 780 | DEFUN (debug_isis_spfstats, |
| 781 | debug_isis_spfstats_cmd, |
| 782 | "debug isis spf-statistics ", |
| 783 | DEBUG_STR |
| 784 | "IS-IS information\n" |
| 785 | "IS-IS SPF Timing and Statistic Data\n" |
| 786 | ) |
| 787 | { |
| 788 | isis->debugs |= DEBUG_SPF_STATS; |
| 789 | print_debug (vty, DEBUG_SPF_STATS, 1); |
| 790 | |
| 791 | return CMD_SUCCESS; |
| 792 | } |
| 793 | |
| 794 | DEFUN (no_debug_isis_spfstats, |
| 795 | no_debug_isis_spfstats_cmd, |
| 796 | "no debug isis spf-statistics", |
| 797 | UNDEBUG_STR |
| 798 | "IS-IS information\n" |
| 799 | "IS-IS SPF Timing and Statistic Data\n" |
| 800 | ) |
| 801 | { |
| 802 | isis->debugs &= ~DEBUG_SPF_STATS; |
| 803 | print_debug (vty, DEBUG_SPF_STATS, 0); |
| 804 | |
| 805 | return CMD_SUCCESS; |
| 806 | } |
| 807 | |
| 808 | DEFUN (debug_isis_spftrigg, |
| 809 | debug_isis_spftrigg_cmd, |
| 810 | "debug isis spf-triggers", |
| 811 | DEBUG_STR |
| 812 | "IS-IS information\n" |
| 813 | "IS-IS SPF triggering events\n" |
| 814 | ) |
| 815 | { |
| 816 | isis->debugs |= DEBUG_SPF_TRIGGERS; |
| 817 | print_debug (vty, DEBUG_SPF_TRIGGERS, 1); |
| 818 | |
| 819 | return CMD_SUCCESS; |
| 820 | } |
| 821 | |
| 822 | DEFUN (no_debug_isis_spftrigg, |
| 823 | no_debug_isis_spftrigg_cmd, |
| 824 | "no debug isis spf-triggers", |
| 825 | UNDEBUG_STR |
| 826 | "IS-IS information\n" |
| 827 | "IS-IS SPF triggering events\n" |
| 828 | ) |
| 829 | { |
| 830 | isis->debugs &= ~DEBUG_SPF_TRIGGERS; |
| 831 | print_debug (vty, DEBUG_SPF_TRIGGERS, 0); |
| 832 | |
| 833 | return CMD_SUCCESS; |
| 834 | } |
| 835 | |
| 836 | DEFUN (debug_isis_rtevents, |
| 837 | debug_isis_rtevents_cmd, |
| 838 | "debug isis route-events", |
| 839 | DEBUG_STR |
| 840 | "IS-IS information\n" |
| 841 | "IS-IS Route related events\n" |
| 842 | ) |
| 843 | { |
| 844 | isis->debugs |= DEBUG_RTE_EVENTS; |
| 845 | print_debug (vty, DEBUG_RTE_EVENTS, 1); |
| 846 | |
| 847 | return CMD_SUCCESS; |
| 848 | } |
| 849 | |
| 850 | DEFUN (no_debug_isis_rtevents, |
| 851 | no_debug_isis_rtevents_cmd, |
| 852 | "no debug isis route-events", |
| 853 | UNDEBUG_STR |
| 854 | "IS-IS information\n" |
| 855 | "IS-IS Route related events\n" |
| 856 | ) |
| 857 | { |
| 858 | isis->debugs &= ~DEBUG_RTE_EVENTS; |
| 859 | print_debug (vty, DEBUG_RTE_EVENTS, 0); |
| 860 | |
| 861 | return CMD_SUCCESS; |
| 862 | } |
| 863 | |
| 864 | DEFUN (debug_isis_events, |
| 865 | debug_isis_events_cmd, |
| 866 | "debug isis events", |
| 867 | DEBUG_STR |
| 868 | "IS-IS information\n" |
| 869 | "IS-IS Events\n" |
| 870 | ) |
| 871 | { |
| 872 | isis->debugs |= DEBUG_EVENTS; |
| 873 | print_debug (vty, DEBUG_EVENTS, 1); |
| 874 | |
| 875 | return CMD_SUCCESS; |
| 876 | } |
| 877 | |
| 878 | DEFUN (no_debug_isis_events, |
| 879 | no_debug_isis_events_cmd, |
| 880 | "no debug isis events", |
| 881 | UNDEBUG_STR |
| 882 | "IS-IS information\n" |
| 883 | "IS-IS Events\n" |
| 884 | ) |
| 885 | { |
| 886 | isis->debugs &= ~DEBUG_EVENTS; |
| 887 | print_debug (vty, DEBUG_EVENTS, 0); |
| 888 | |
| 889 | return CMD_SUCCESS; |
| 890 | } |
| 891 | |
| 892 | |
| 893 | DEFUN (show_hostname, |
| 894 | show_hostname_cmd, |
| 895 | "show isis hostname", |
| 896 | SHOW_STR |
| 897 | "IS-IS information\n" |
| 898 | "IS-IS Dynamic hostname mapping\n") |
| 899 | { |
| 900 | dynhn_print_all (vty); |
| 901 | |
| 902 | return CMD_SUCCESS; |
| 903 | } |
| 904 | |
| 905 | |
| 906 | DEFUN (show_database, |
| 907 | show_database_cmd, |
| 908 | "show isis database", |
| 909 | SHOW_STR |
| 910 | "IS-IS information\n" |
| 911 | "IS-IS link state database\n") |
| 912 | { |
| 913 | struct listnode *node; |
| 914 | struct isis_area *area; |
| 915 | int level,lsp_count; |
| 916 | |
| 917 | if (isis->area_list->count == 0) |
| 918 | return CMD_SUCCESS; |
| 919 | |
| 920 | for (node = listhead (isis->area_list); node; nextnode (node)) { |
| 921 | area = getdata (node); |
| 922 | vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null", |
| 923 | VTY_NEWLINE); |
| 924 | for (level=0;level<ISIS_LEVELS;level++) { |
| 925 | if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0) { |
| 926 | vty_out (vty,"IS-IS Level-%d link-state database:%s", level+1, |
| 927 | VTY_NEWLINE); |
| 928 | |
| 929 | lsp_count = lsp_print_all (vty, area->lspdb[level], |
| 930 | ISIS_UI_LEVEL_BRIEF, |
| 931 | area->dynhostname); |
| 932 | |
| 933 | vty_out (vty,"%s %u LSPs%s%s", |
| 934 | VTY_NEWLINE, |
| 935 | lsp_count, |
| 936 | VTY_NEWLINE, |
| 937 | VTY_NEWLINE); |
| 938 | } |
| 939 | } |
| 940 | } |
| 941 | |
| 942 | return CMD_SUCCESS; |
| 943 | } |
| 944 | |
| 945 | |
| 946 | DEFUN (show_database_detail, |
| 947 | show_database_detail_cmd, |
| 948 | "show isis database detail", |
| 949 | SHOW_STR |
| 950 | "IS-IS information\n" |
| 951 | "IS-IS link state database\n") |
| 952 | { |
| 953 | struct listnode *node; |
| 954 | struct isis_area *area; |
| 955 | int level, lsp_count; |
| 956 | |
| 957 | if (isis->area_list->count == 0) |
| 958 | return CMD_SUCCESS; |
| 959 | |
| 960 | for (node = listhead (isis->area_list); node; nextnode (node)) { |
| 961 | area = getdata (node); |
| 962 | vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null", |
| 963 | VTY_NEWLINE); |
| 964 | for (level=0;level<ISIS_LEVELS;level++) { |
| 965 | if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0) { |
| 966 | vty_out (vty,"IS-IS Level-%d Link State Database:%s", level+1, |
| 967 | VTY_NEWLINE); |
| 968 | |
| 969 | lsp_count = lsp_print_all (vty, area->lspdb[level], |
| 970 | ISIS_UI_LEVEL_DETAIL, |
| 971 | area->dynhostname); |
| 972 | |
| 973 | vty_out (vty,"%s %u LSPs%s%s", |
| 974 | VTY_NEWLINE, |
| 975 | lsp_count, |
| 976 | VTY_NEWLINE, |
| 977 | VTY_NEWLINE); |
| 978 | } |
| 979 | } |
| 980 | } |
| 981 | |
| 982 | return CMD_SUCCESS; |
| 983 | } |
| 984 | |
| 985 | /* |
| 986 | * 'router isis' command |
| 987 | */ |
| 988 | DEFUN (router_isis, |
| 989 | router_isis_cmd, |
| 990 | "router isis WORD", |
| 991 | ROUTER_STR |
| 992 | "ISO IS-IS\n" |
| 993 | "ISO Routing area tag") |
| 994 | { |
| 995 | |
| 996 | return isis_area_get (vty, argv[0]); |
| 997 | |
| 998 | } |
| 999 | |
| 1000 | /* |
| 1001 | *'no router isis' command |
| 1002 | */ |
| 1003 | DEFUN (no_router_isis, |
| 1004 | no_router_isis_cmd, |
| 1005 | "no router isis WORD", |
| 1006 | "no\n" |
| 1007 | ROUTER_STR |
| 1008 | "ISO IS-IS\n" |
| 1009 | "ISO Routing area tag") |
| 1010 | |
| 1011 | { |
| 1012 | return isis_area_destroy (vty, argv[0]); |
| 1013 | } |
| 1014 | |
| 1015 | /* |
| 1016 | * 'net' command |
| 1017 | */ |
| 1018 | DEFUN (net, |
| 1019 | net_cmd, |
| 1020 | "net WORD", |
| 1021 | "A Network Entity Title for this process (OSI only)\n" |
| 1022 | "XX.XXXX. ... .XXX.XX Network entity title (NET)\n" ) |
| 1023 | { |
| 1024 | return area_net_title (vty, argv[0]); |
| 1025 | } |
| 1026 | |
| 1027 | |
| 1028 | /* |
| 1029 | * 'no net' command |
| 1030 | */ |
| 1031 | DEFUN (no_net, |
| 1032 | no_net_cmd, |
| 1033 | "no net WORD", |
| 1034 | NO_STR |
| 1035 | "A Network Entity Title for this process (OSI only)\n" |
| 1036 | "XX.XXXX. ... .XXX.XX Network entity title (NET)\n" ) |
| 1037 | { |
| 1038 | return area_clear_net_title (vty, argv[0]); |
| 1039 | } |
| 1040 | |
| 1041 | DEFUN (area_passwd, |
| 1042 | area_passwd_cmd, |
| 1043 | "area-password WORD", |
| 1044 | "Configure the authentication password for an area\n" |
| 1045 | "Area password\n" ) |
| 1046 | { |
| 1047 | struct isis_area *area; |
| 1048 | int len; |
| 1049 | |
| 1050 | area = vty->index; |
| 1051 | |
| 1052 | if (!area) { |
| 1053 | vty_out (vty, "Cant find IS-IS instance%s", VTY_NEWLINE); |
| 1054 | return CMD_WARNING; |
| 1055 | } |
| 1056 | |
| 1057 | len = strlen (argv[0]); |
| 1058 | if (len > 254) { |
| 1059 | vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE); |
| 1060 | return CMD_WARNING; |
| 1061 | } |
| 1062 | area->area_passwd.len = (u_char)len; |
| 1063 | area->area_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT; |
| 1064 | strncpy (area->area_passwd.passwd, argv[0], 255); |
| 1065 | |
| 1066 | return CMD_SUCCESS; |
| 1067 | } |
| 1068 | |
| 1069 | DEFUN (no_area_passwd, |
| 1070 | no_area_passwd_cmd, |
| 1071 | "no area-password", |
| 1072 | NO_STR |
| 1073 | "Configure the authentication password for an area\n") |
| 1074 | { |
| 1075 | struct isis_area *area; |
| 1076 | |
| 1077 | area = vty->index; |
| 1078 | |
| 1079 | if (!area) { |
| 1080 | vty_out (vty, "Cant find IS-IS instance%s", VTY_NEWLINE); |
| 1081 | return CMD_WARNING; |
| 1082 | } |
| 1083 | |
| 1084 | memset (&area->area_passwd, 0, sizeof (struct isis_passwd)); |
| 1085 | |
| 1086 | return CMD_SUCCESS; |
| 1087 | } |
| 1088 | |
| 1089 | |
| 1090 | DEFUN (domain_passwd, |
| 1091 | domain_passwd_cmd, |
| 1092 | "domain-password WORD", |
| 1093 | "Set the authentication password for a routing domain\n" |
| 1094 | "Routing domain password\n" ) |
| 1095 | { |
| 1096 | struct isis_area *area; |
| 1097 | int len; |
| 1098 | |
| 1099 | area = vty->index; |
| 1100 | |
| 1101 | if (!area) { |
| 1102 | vty_out (vty, "Cant find IS-IS instance%s", VTY_NEWLINE); |
| 1103 | return CMD_WARNING; |
| 1104 | } |
| 1105 | |
| 1106 | len = strlen (argv[0]); |
| 1107 | if (len > 254) { |
| 1108 | vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE); |
| 1109 | return CMD_WARNING; |
| 1110 | } |
| 1111 | area->domain_passwd.len = (u_char)len; |
| 1112 | area->domain_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT; |
| 1113 | strncpy (area->domain_passwd.passwd, argv[0], 255); |
| 1114 | |
| 1115 | return CMD_SUCCESS; |
| 1116 | } |
| 1117 | |
| 1118 | |
| 1119 | DEFUN (no_domain_passwd, |
| 1120 | no_domain_passwd_cmd, |
| 1121 | "no domain-password WORD", |
| 1122 | NO_STR |
| 1123 | "Set the authentication password for a routing domain\n") |
| 1124 | { |
| 1125 | struct isis_area *area; |
| 1126 | |
| 1127 | area = vty->index; |
| 1128 | |
| 1129 | if (!area) { |
| 1130 | vty_out (vty, "Cant find IS-IS instance%s", VTY_NEWLINE); |
| 1131 | return CMD_WARNING; |
| 1132 | } |
| 1133 | |
| 1134 | memset (&area->domain_passwd, 0, sizeof (struct isis_passwd)); |
| 1135 | |
| 1136 | return CMD_SUCCESS; |
| 1137 | } |
| 1138 | |
| 1139 | DEFUN (is_type, |
| 1140 | is_type_cmd, |
| 1141 | "is-type (level-1|level-1-2|level-2-only)", |
| 1142 | "IS Level for this routing process (OSI only)\n" |
| 1143 | "Act as a station router only\n" |
| 1144 | "Act as both a station router and an area router\n" |
| 1145 | "Act as an area router only\n") |
| 1146 | { |
| 1147 | struct isis_area *area; |
| 1148 | int type; |
| 1149 | |
| 1150 | area = vty->index; |
| 1151 | |
| 1152 | if (!area) { |
| 1153 | vty_out (vty, "Cant find IS-IS instance%s", VTY_NEWLINE); |
| 1154 | return CMD_WARNING; |
| 1155 | } |
| 1156 | |
| 1157 | type = string2circuit_t (argv[0]); |
| 1158 | if (!type) { |
| 1159 | vty_out (vty, "Unknown IS level %s", VTY_NEWLINE); |
| 1160 | return CMD_SUCCESS; |
| 1161 | } |
| 1162 | |
| 1163 | isis_event_system_type_change (area, type); |
| 1164 | |
| 1165 | return CMD_SUCCESS; |
| 1166 | } |
| 1167 | |
| 1168 | DEFUN (no_is_type, |
| 1169 | no_is_type_cmd, |
| 1170 | "no is-type (level-1|level-1-2|level-2-only)", |
| 1171 | NO_STR |
| 1172 | "IS Level for this routing process (OSI only)\n" |
| 1173 | "Act as a station router only\n" |
| 1174 | "Act as both a station router and an area router\n" |
| 1175 | "Act as an area router only\n") |
| 1176 | { |
| 1177 | |
| 1178 | struct isis_area *area; |
| 1179 | int type; |
| 1180 | |
| 1181 | area = vty->index; |
| 1182 | assert (area); |
| 1183 | |
| 1184 | /* |
| 1185 | * Put the is-type back to default. Which is level-1-2 on first |
| 1186 | * circuit for the area level-1 for the rest |
| 1187 | */ |
| 1188 | if (getdata (listhead (isis->area_list)) == area ) |
| 1189 | type = IS_LEVEL_1_AND_2; |
| 1190 | else |
| 1191 | type = IS_LEVEL_1; |
| 1192 | |
| 1193 | isis_event_system_type_change (area, type); |
| 1194 | |
| 1195 | return CMD_SUCCESS; |
| 1196 | } |
| 1197 | |
| 1198 | DEFUN (lsp_gen_interval, |
| 1199 | lsp_gen_interval_cmd, |
| 1200 | "lsp-gen-interval <1-120>", |
| 1201 | "Minimum interval between regenerating same LSP\n" |
| 1202 | "Minimum interval in seconds\n") |
| 1203 | { |
| 1204 | struct isis_area *area; |
| 1205 | uint16_t interval; |
| 1206 | |
| 1207 | area = vty->index; |
| 1208 | assert (area); |
| 1209 | |
| 1210 | interval = atoi (argv[0]); |
| 1211 | area->lsp_gen_interval[0] = interval; |
| 1212 | area->lsp_gen_interval[1] = interval; |
| 1213 | |
| 1214 | return CMD_SUCCESS; |
| 1215 | } |
| 1216 | |
| 1217 | DEFUN (no_lsp_gen_interval, |
| 1218 | no_lsp_gen_interval_cmd, |
| 1219 | "no lsp-gen-interval", |
| 1220 | NO_STR |
| 1221 | "Minimum interval between regenerating same LSP\n" |
| 1222 | ) |
| 1223 | { |
| 1224 | struct isis_area *area; |
| 1225 | |
| 1226 | area = vty->index; |
| 1227 | assert (area); |
| 1228 | |
| 1229 | area->lsp_gen_interval[0] = LSP_GEN_INTERVAL_DEFAULT; |
| 1230 | area->lsp_gen_interval[1] = LSP_GEN_INTERVAL_DEFAULT; |
| 1231 | |
| 1232 | return CMD_SUCCESS; |
| 1233 | } |
| 1234 | |
| 1235 | ALIAS (no_lsp_gen_interval, |
| 1236 | no_lsp_gen_interval_arg_cmd, |
| 1237 | "no lsp-gen-interval <1-120>", |
| 1238 | NO_STR |
| 1239 | "Minimum interval between regenerating same LSP\n" |
| 1240 | "Minimum interval in seconds\n" |
| 1241 | ) |
| 1242 | |
| 1243 | DEFUN (lsp_gen_interval_l1, |
| 1244 | lsp_gen_interval_l1_cmd, |
| 1245 | "lsp-gen-interval level-1 <1-120>", |
| 1246 | "Minimum interval between regenerating same LSP\n" |
| 1247 | "Set interval for level 1 only\n" |
| 1248 | "Minimum interval in seconds\n" |
| 1249 | ) |
| 1250 | { |
| 1251 | struct isis_area *area; |
| 1252 | uint16_t interval; |
| 1253 | |
| 1254 | area = vty->index; |
| 1255 | assert (area); |
| 1256 | |
| 1257 | interval = atoi (argv[0]); |
| 1258 | area->lsp_gen_interval[0] = interval; |
| 1259 | |
| 1260 | return CMD_SUCCESS; |
| 1261 | } |
| 1262 | |
| 1263 | DEFUN (no_lsp_gen_interval_l1, |
| 1264 | no_lsp_gen_interval_l1_cmd, |
| 1265 | "no lsp-gen-interval level-1", |
| 1266 | NO_STR |
| 1267 | "Minimum interval between regenerating same LSP\n" |
| 1268 | "Set interval for level 1 only\n" |
| 1269 | |
| 1270 | ) |
| 1271 | { |
| 1272 | struct isis_area *area; |
| 1273 | |
| 1274 | area = vty->index; |
| 1275 | assert (area); |
| 1276 | |
| 1277 | area->lsp_gen_interval[0] = LSP_GEN_INTERVAL_DEFAULT; |
| 1278 | |
| 1279 | return CMD_SUCCESS; |
| 1280 | } |
| 1281 | |
| 1282 | ALIAS (no_lsp_gen_interval_l1, |
| 1283 | no_lsp_gen_interval_l1_arg_cmd, |
| 1284 | "no lsp-gen-interval level-1 <1-120>", |
| 1285 | NO_STR |
| 1286 | "Minimum interval between regenerating same LSP\n" |
| 1287 | "Set interval for level 1 only\n" |
| 1288 | "Minimum interval in seconds\n" |
| 1289 | ) |
| 1290 | |
| 1291 | |
| 1292 | DEFUN (lsp_gen_interval_l2, |
| 1293 | lsp_gen_interval_l2_cmd, |
| 1294 | "lsp-gen-interval level-2 <1-120>", |
| 1295 | "Minimum interval between regenerating same LSP\n" |
| 1296 | "Set interval for level 2 only\n" |
| 1297 | "Minimum interval in seconds\n" |
| 1298 | ) |
| 1299 | { |
| 1300 | struct isis_area *area; |
| 1301 | int interval; |
| 1302 | |
| 1303 | area = vty->index; |
| 1304 | assert (area); |
| 1305 | |
| 1306 | interval = atoi (argv[0]); |
| 1307 | area->lsp_gen_interval[1] = interval; |
| 1308 | |
| 1309 | return CMD_SUCCESS; |
| 1310 | } |
| 1311 | |
| 1312 | DEFUN (no_lsp_gen_interval_l2, |
| 1313 | no_lsp_gen_interval_l2_cmd, |
| 1314 | "no lsp-gen-interval level-2", |
| 1315 | NO_STR |
| 1316 | "Minimum interval between regenerating same LSP\n" |
| 1317 | "Set interval for level 2 only\n" |
| 1318 | ) |
| 1319 | { |
| 1320 | struct isis_area *area; |
| 1321 | int interval; |
| 1322 | |
| 1323 | area = vty->index; |
| 1324 | assert (area); |
| 1325 | |
| 1326 | interval = atoi (argv[0]); |
| 1327 | area->lsp_gen_interval[1] = LSP_GEN_INTERVAL_DEFAULT; |
| 1328 | |
| 1329 | return CMD_SUCCESS; |
| 1330 | } |
| 1331 | |
| 1332 | ALIAS (no_lsp_gen_interval_l2, |
| 1333 | no_lsp_gen_interval_l2_arg_cmd, |
| 1334 | "no lsp-gen-interval level-2 <1-120>", |
| 1335 | NO_STR |
| 1336 | "Minimum interval between regenerating same LSP\n" |
| 1337 | "Set interval for level 2 only\n" |
| 1338 | "Minimum interval in seconds\n" |
| 1339 | ) |
| 1340 | |
| 1341 | |
| 1342 | DEFUN (metric_style, |
| 1343 | metric_style_cmd, |
| 1344 | "metric-style (narrow|wide)", |
| 1345 | "Use old-style (ISO 10589) or new-style packet formats\n" |
| 1346 | "Use old style of TLVs with narrow metric\n" |
| 1347 | "Use new style of TLVs to carry wider metric\n") |
| 1348 | { |
| 1349 | struct isis_area *area; |
| 1350 | |
| 1351 | area = vty->index; |
| 1352 | assert (area); |
| 1353 | if (!strcmp(argv[0],"wide")) |
| 1354 | area->newmetric = 1; |
| 1355 | else |
| 1356 | area->newmetric = 0; |
| 1357 | |
| 1358 | return CMD_SUCCESS; |
| 1359 | } |
| 1360 | |
| 1361 | DEFUN (no_metric_style, |
| 1362 | no_metric_style_cmd, |
| 1363 | "no metric-style (narrow|wide)", |
| 1364 | NO_STR |
| 1365 | "Use old-style (ISO 10589) or new-style packet formats\n" |
| 1366 | "Use old style of TLVs with narrow metric\n" |
| 1367 | "Use new style of TLVs to carry wider metric\n") |
| 1368 | { |
| 1369 | struct isis_area *area; |
| 1370 | |
| 1371 | area = vty->index; |
| 1372 | assert (area); |
| 1373 | |
| 1374 | if (!strcmp(argv[0],"wide")) |
| 1375 | area->newmetric = 0; |
| 1376 | else |
| 1377 | area->newmetric = 1; |
| 1378 | |
| 1379 | return CMD_SUCCESS; |
| 1380 | } |
| 1381 | |
| 1382 | DEFUN (dynamic_hostname, |
| 1383 | dynamic_hostname_cmd, |
| 1384 | "hostname dynamic", |
| 1385 | "Dynamic hostname for IS-IS\n" |
| 1386 | "Dynamic hostname\n") |
| 1387 | { |
| 1388 | struct isis_area *area; |
| 1389 | |
| 1390 | area = vty->index; |
| 1391 | assert (area); |
| 1392 | |
| 1393 | area->dynhostname = 1; |
| 1394 | |
| 1395 | return CMD_SUCCESS; |
| 1396 | } |
| 1397 | |
| 1398 | DEFUN (no_dynamic_hostname, |
| 1399 | no_dynamic_hostname_cmd, |
| 1400 | "no hostname dynamic", |
| 1401 | NO_STR |
| 1402 | "Dynamic hostname for IS-IS\n" |
| 1403 | "Dynamic hostname\n") |
| 1404 | { |
| 1405 | struct isis_area *area; |
| 1406 | |
| 1407 | area = vty->index; |
| 1408 | assert (area); |
| 1409 | |
| 1410 | area->dynhostname = 0; |
| 1411 | |
| 1412 | return CMD_SUCCESS; |
| 1413 | } |
| 1414 | |
| 1415 | DEFUN (spf_interval, |
| 1416 | spf_interval_cmd, |
| 1417 | "spf-interval <1-120>", |
hasso | 2097cd8 | 2003-12-23 11:51:08 +0000 | [diff] [blame] | 1418 | "Minimum interval between SPF calculations\n" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1419 | "Minimum interval between consecutive SPFs in seconds\n") |
| 1420 | { |
| 1421 | struct isis_area *area; |
| 1422 | u_int16_t interval; |
| 1423 | |
| 1424 | area = vty->index; |
| 1425 | interval = atoi (argv[0]); |
| 1426 | area->min_spf_interval[0] = interval; |
| 1427 | area->min_spf_interval[1] = interval; |
| 1428 | |
| 1429 | return CMD_SUCCESS; |
| 1430 | } |
| 1431 | |
| 1432 | DEFUN (no_spf_interval, |
| 1433 | no_spf_interval_cmd, |
| 1434 | "no spf-interval", |
| 1435 | NO_STR |
| 1436 | "Minimum interval between SPF calculations\n" |
| 1437 | ) |
| 1438 | { |
| 1439 | struct isis_area *area; |
| 1440 | |
| 1441 | area = vty->index; |
| 1442 | |
| 1443 | area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL; |
| 1444 | area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL; |
| 1445 | |
| 1446 | return CMD_SUCCESS; |
| 1447 | } |
| 1448 | |
| 1449 | ALIAS (no_spf_interval, |
| 1450 | no_spf_interval_arg_cmd, |
| 1451 | "no spf-interval <1-120>", |
| 1452 | NO_STR |
| 1453 | "Minimum interval between SPF calculations\n" |
| 1454 | "Minimum interval between consecutive SPFs in seconds\n" |
| 1455 | ) |
| 1456 | |
| 1457 | DEFUN (spf_interval_l1, |
| 1458 | spf_interval_l1_cmd, |
| 1459 | "spf-interval level-1 <1-120>", |
| 1460 | "Minimum interval between SPF calculations\n" |
| 1461 | "Set interval for level 1 only\n" |
| 1462 | "Minimum interval between consecutive SPFs in seconds\n") |
| 1463 | { |
| 1464 | struct isis_area *area; |
| 1465 | u_int16_t interval; |
| 1466 | |
| 1467 | area = vty->index; |
| 1468 | interval = atoi (argv[0]); |
| 1469 | area->min_spf_interval[0] = interval; |
| 1470 | |
| 1471 | return CMD_SUCCESS; |
| 1472 | } |
| 1473 | |
| 1474 | DEFUN (no_spf_interval_l1, |
| 1475 | no_spf_interval_l1_cmd, |
| 1476 | "no spf-interval level-1", |
| 1477 | NO_STR |
| 1478 | "Minimum interval between SPF calculations\n" |
| 1479 | "Set interval for level 1 only\n") |
| 1480 | { |
| 1481 | struct isis_area *area; |
| 1482 | |
| 1483 | area = vty->index; |
| 1484 | |
| 1485 | area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL; |
| 1486 | |
| 1487 | return CMD_SUCCESS; |
| 1488 | } |
| 1489 | |
| 1490 | ALIAS (no_spf_interval, |
| 1491 | no_spf_interval_l1_arg_cmd, |
| 1492 | "no spf-interval level-1 <1-120>", |
| 1493 | NO_STR |
| 1494 | "Minimum interval between SPF calculations\n" |
| 1495 | "Set interval for level 1 only\n" |
| 1496 | "Minimum interval between consecutive SPFs in seconds\n") |
| 1497 | |
| 1498 | DEFUN (spf_interval_l2, |
| 1499 | spf_interval_l2_cmd, |
| 1500 | "spf-interval level-2 <1-120>", |
| 1501 | "Minimum interval between SPF calculations\n" |
| 1502 | "Set interval for level 2 only\n" |
| 1503 | "Minimum interval between consecutive SPFs in seconds\n") |
| 1504 | { |
| 1505 | struct isis_area *area; |
| 1506 | u_int16_t interval; |
| 1507 | |
| 1508 | area = vty->index; |
| 1509 | interval = atoi (argv[0]); |
| 1510 | area->min_spf_interval[1] = interval; |
| 1511 | |
| 1512 | return CMD_SUCCESS; |
| 1513 | } |
| 1514 | |
| 1515 | DEFUN (no_spf_interval_l2, |
| 1516 | no_spf_interval_l2_cmd, |
| 1517 | "no spf-interval level-2", |
| 1518 | NO_STR |
| 1519 | "Minimum interval between SPF calculations\n" |
| 1520 | "Set interval for level 2 only\n") |
| 1521 | { |
| 1522 | struct isis_area *area; |
| 1523 | |
| 1524 | area = vty->index; |
| 1525 | |
| 1526 | area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL; |
| 1527 | |
| 1528 | return CMD_SUCCESS; |
| 1529 | } |
| 1530 | |
| 1531 | ALIAS (no_spf_interval, |
| 1532 | no_spf_interval_l2_arg_cmd, |
| 1533 | "no spf-interval level-2 <1-120>", |
| 1534 | NO_STR |
| 1535 | "Minimum interval between SPF calculations\n" |
| 1536 | "Set interval for level 2 only\n" |
| 1537 | "Minimum interval between consecutive SPFs in seconds\n") |
| 1538 | |
| 1539 | |
| 1540 | #ifdef TOPOLOGY_GENERATE |
| 1541 | DEFUN (topology_generate_grid, |
| 1542 | topology_generate_grid_cmd, |
| 1543 | "topology generate grid <1-100> <1-100> <1-65000> [param] [param] " |
| 1544 | "[param]", |
| 1545 | "Topology for IS-IS\n" |
| 1546 | "Topology for IS-IS\n" |
| 1547 | "Topology grid for IS-IS\n" |
| 1548 | "X parameter of the grid\n" |
| 1549 | "Y parameter of the grid\n" |
| 1550 | "Random seed\n" |
| 1551 | "Optional param 1\n" |
| 1552 | "Optional param 2\n" |
| 1553 | "Optional param 3\n" |
| 1554 | "Topology\n") |
| 1555 | { |
| 1556 | struct isis_area *area; |
| 1557 | |
| 1558 | area = vty->index; |
| 1559 | assert (area); |
| 1560 | |
| 1561 | if (!spgrid_check_params (vty, argc, argv)) { |
| 1562 | if (area->topology) |
| 1563 | list_delete (area->topology); |
| 1564 | area->topology = list_new(); |
| 1565 | memcpy(area->top_params,vty->buf,200); |
| 1566 | gen_spgrid_topology (vty, area->topology); |
| 1567 | remove_topology_lsps (area); |
| 1568 | generate_topology_lsps (area); |
| 1569 | } |
| 1570 | |
| 1571 | return CMD_SUCCESS; |
| 1572 | } |
| 1573 | |
| 1574 | DEFUN (show_isis_topology, |
| 1575 | show_isis_topology_cmd, |
| 1576 | "show isis topology", |
| 1577 | SHOW_STR |
| 1578 | "clns network information\n" |
| 1579 | "CLNS neighbor adjacencies\n") |
| 1580 | { |
| 1581 | struct isis_area *area; |
| 1582 | struct listnode *node; |
| 1583 | struct listnode *node2; |
| 1584 | struct arc *arc; |
| 1585 | LIST_LOOP (isis->area_list, area, node) { |
| 1586 | if (area->topology) { |
| 1587 | vty_out (vty, "Topology for isis area:%s%s",area->area_tag, VTY_NEWLINE); |
| 1588 | LIST_LOOP (area->topology, arc, node2) { |
| 1589 | vty_out (vty, "a %ld %ld %ld%s",arc->from_node, arc->to_node, |
| 1590 | arc->distance, VTY_NEWLINE); |
| 1591 | } |
| 1592 | } |
| 1593 | } |
| 1594 | return CMD_SUCCESS; |
| 1595 | } |
| 1596 | |
| 1597 | /* |
| 1598 | * 'topology base-is' command |
| 1599 | */ |
| 1600 | DEFUN (topology_baseis , |
| 1601 | topology_baseis_cmd, |
| 1602 | "topology base-is WORD", |
| 1603 | "Topology for IS-IS\n" |
| 1604 | "Topology for IS-IS\n" |
| 1605 | "A Network IS Base for this topology" |
| 1606 | "XX.XXXX.XXXX.XX Network entity title (NET)\n" ) |
| 1607 | { |
| 1608 | struct isis_area *area; |
| 1609 | u_char buff[ISIS_SYS_ID_LEN]; |
| 1610 | |
| 1611 | area = vty->index; |
| 1612 | assert (area); |
| 1613 | |
| 1614 | if (sysid2buff (buff, argv[0])) { |
| 1615 | sysid2buff (area->topology_baseis, argv[0]); |
| 1616 | } |
| 1617 | |
| 1618 | return CMD_SUCCESS; |
| 1619 | } |
| 1620 | |
| 1621 | /* |
| 1622 | * 'no net' command |
| 1623 | */ |
| 1624 | DEFUN (no_topology_baseis, |
| 1625 | no_topology_baseis_cmd, |
| 1626 | "no topology base-is WORD", |
| 1627 | NO_STR |
| 1628 | "A Network Entity Title for this process (OSI only)" |
| 1629 | "XX.XXXX. ... .XXX.XX Network entity title (NET)\n" ) |
| 1630 | { |
| 1631 | struct isis_area *area; |
| 1632 | |
| 1633 | area = vty->index; |
| 1634 | assert (area); |
| 1635 | |
| 1636 | memcpy(area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN); |
| 1637 | return CMD_SUCCESS; |
| 1638 | } |
| 1639 | |
| 1640 | #endif /* TOPOLOGY_GENERATE */ |
| 1641 | |
| 1642 | DEFUN (lsp_lifetime, |
| 1643 | lsp_lifetime_cmd, |
| 1644 | "lsp-lifetime <380-65535>", |
| 1645 | "Maximum LSP lifetime\n" |
| 1646 | "LSP lifetime in seconds\n" |
| 1647 | ) |
| 1648 | { |
| 1649 | struct isis_area *area; |
| 1650 | uint16_t interval; |
| 1651 | |
| 1652 | area = vty->index; |
| 1653 | assert (area); |
| 1654 | |
| 1655 | interval = atoi (argv[0]); |
| 1656 | |
| 1657 | if (interval < ISIS_MIN_LSP_LIFETIME) { |
| 1658 | vty_out (vty, "LSP lifetime (%us) below %us%s", |
| 1659 | interval, |
| 1660 | ISIS_MIN_LSP_LIFETIME, |
| 1661 | VTY_NEWLINE); |
| 1662 | |
| 1663 | return CMD_WARNING; |
| 1664 | } |
| 1665 | |
| 1666 | |
| 1667 | area->max_lsp_lifetime[0] = interval; |
| 1668 | area->max_lsp_lifetime[1] = interval; |
| 1669 | area->lsp_refresh[0] = interval-300; |
| 1670 | area->lsp_refresh[1] = interval-300; |
| 1671 | |
| 1672 | if (area->t_lsp_refresh[0]) { |
| 1673 | thread_cancel (area->t_lsp_refresh[0]); |
| 1674 | thread_execute (master, lsp_refresh_l1, area, 0); |
| 1675 | } |
| 1676 | |
| 1677 | if (area->t_lsp_refresh[1]) { |
| 1678 | thread_cancel (area->t_lsp_refresh[1]); |
| 1679 | thread_execute (master, lsp_refresh_l2, area, 0); |
| 1680 | } |
| 1681 | |
| 1682 | |
| 1683 | return CMD_SUCCESS; |
| 1684 | } |
| 1685 | |
| 1686 | DEFUN (no_lsp_lifetime, |
| 1687 | no_lsp_lifetime_cmd, |
| 1688 | "no lsp-lifetime", |
| 1689 | NO_STR |
| 1690 | "LSP lifetime in seconds\n" |
| 1691 | ) |
| 1692 | { |
| 1693 | struct isis_area *area; |
| 1694 | |
| 1695 | area = vty->index; |
| 1696 | assert (area); |
| 1697 | |
| 1698 | area->max_lsp_lifetime[0] = MAX_AGE; /* 1200s */ |
| 1699 | area->max_lsp_lifetime[1] = MAX_AGE; /* 1200s */ |
| 1700 | area->lsp_refresh[0] = MAX_LSP_GEN_INTERVAL; /* 900s */ |
| 1701 | area->lsp_refresh[1] = MAX_LSP_GEN_INTERVAL; /* 900s */ |
| 1702 | |
| 1703 | return CMD_SUCCESS; |
| 1704 | } |
| 1705 | |
| 1706 | ALIAS (no_lsp_lifetime, |
| 1707 | no_lsp_lifetime_arg_cmd, |
| 1708 | "no lsp-lifetime <380-65535>", |
| 1709 | NO_STR |
| 1710 | "Maximum LSP lifetime\n" |
| 1711 | "LSP lifetime in seconds\n" |
| 1712 | ) |
| 1713 | |
| 1714 | DEFUN (lsp_lifetime_l1, |
| 1715 | lsp_lifetime_l1_cmd, |
| 1716 | "lsp-lifetime level-1 <380-65535>", |
| 1717 | "Maximum LSP lifetime for Level 1 only\n" |
| 1718 | "LSP lifetime for Level 1 only in seconds\n" |
| 1719 | ) |
| 1720 | { |
| 1721 | struct isis_area *area; |
| 1722 | uint16_t interval; |
| 1723 | |
| 1724 | area = vty->index; |
| 1725 | assert (area); |
| 1726 | |
| 1727 | interval = atoi (argv[0]); |
| 1728 | |
| 1729 | if (interval < ISIS_MIN_LSP_LIFETIME) { |
| 1730 | vty_out (vty, "Level-1 LSP lifetime (%us) below %us%s", |
| 1731 | interval, |
| 1732 | ISIS_MIN_LSP_LIFETIME, |
| 1733 | VTY_NEWLINE); |
| 1734 | |
| 1735 | return CMD_WARNING; |
| 1736 | } |
| 1737 | |
| 1738 | |
| 1739 | area->max_lsp_lifetime[0] = interval; |
| 1740 | area->lsp_refresh[0] = interval-300; |
| 1741 | |
| 1742 | return CMD_SUCCESS; |
| 1743 | } |
| 1744 | |
| 1745 | DEFUN (no_lsp_lifetime_l1, |
| 1746 | no_lsp_lifetime_l1_cmd, |
| 1747 | "no lsp-lifetime level-1", |
| 1748 | NO_STR |
| 1749 | "LSP lifetime for Level 1 only in seconds\n" |
| 1750 | ) |
| 1751 | { |
| 1752 | struct isis_area *area; |
| 1753 | |
| 1754 | area = vty->index; |
| 1755 | assert (area); |
| 1756 | |
| 1757 | area->max_lsp_lifetime[0] = MAX_AGE; /* 1200s */ |
| 1758 | area->lsp_refresh[0] = MAX_LSP_GEN_INTERVAL; /* 900s */ |
| 1759 | |
| 1760 | return CMD_SUCCESS; |
| 1761 | } |
| 1762 | |
| 1763 | ALIAS (no_lsp_lifetime_l1, |
| 1764 | no_lsp_lifetime_l1_arg_cmd, |
| 1765 | "no lsp-lifetime level-1 <380-65535>", |
| 1766 | NO_STR |
| 1767 | "Maximum LSP lifetime for Level 1 only\n" |
| 1768 | "LSP lifetime for Level 1 only in seconds\n" |
| 1769 | ) |
| 1770 | |
| 1771 | DEFUN (lsp_lifetime_l2, |
| 1772 | lsp_lifetime_l2_cmd, |
| 1773 | "lsp-lifetime level-2 <380-65535>", |
| 1774 | "Maximum LSP lifetime for Level 2 only\n" |
| 1775 | "LSP lifetime for Level 2 only in seconds\n" |
| 1776 | ) |
| 1777 | { |
| 1778 | struct isis_area *area; |
| 1779 | uint16_t interval; |
| 1780 | |
| 1781 | area = vty->index; |
| 1782 | assert (area); |
| 1783 | |
| 1784 | interval = atoi (argv[0]); |
| 1785 | |
| 1786 | if (interval < ISIS_MIN_LSP_LIFETIME) { |
| 1787 | vty_out (vty, "Level-2 LSP lifetime (%us) below %us%s", |
| 1788 | interval, |
| 1789 | ISIS_MIN_LSP_LIFETIME, |
| 1790 | VTY_NEWLINE); |
| 1791 | |
| 1792 | return CMD_WARNING; |
| 1793 | } |
| 1794 | |
| 1795 | |
| 1796 | area->max_lsp_lifetime[1] = interval; |
| 1797 | area->lsp_refresh[1] = interval - 300; |
| 1798 | |
| 1799 | return CMD_SUCCESS; |
| 1800 | } |
| 1801 | |
| 1802 | DEFUN (no_lsp_lifetime_l2, |
| 1803 | no_lsp_lifetime_l2_cmd, |
| 1804 | "no lsp-lifetime level-2", |
| 1805 | NO_STR |
| 1806 | "LSP lifetime for Level 2 only in seconds\n" |
| 1807 | ) |
| 1808 | { |
| 1809 | struct isis_area *area; |
| 1810 | |
| 1811 | area = vty->index; |
| 1812 | assert (area); |
| 1813 | |
| 1814 | area->max_lsp_lifetime[1] = MAX_AGE; /* 1200s */ |
| 1815 | area->lsp_refresh[1] = MAX_LSP_GEN_INTERVAL; /* 900s */ |
| 1816 | |
| 1817 | return CMD_SUCCESS; |
| 1818 | } |
| 1819 | |
| 1820 | ALIAS (no_lsp_lifetime_l2, |
| 1821 | no_lsp_lifetime_l2_arg_cmd, |
| 1822 | "no lsp-lifetime level-2 <380-65535>", |
| 1823 | NO_STR |
| 1824 | "Maximum LSP lifetime for Level 2 only\n" |
| 1825 | "LSP lifetime for Level 2 only in seconds\n" |
| 1826 | ) |
| 1827 | |
| 1828 | |
| 1829 | |
| 1830 | |
| 1831 | /* IS-IS configuration write function */ |
| 1832 | int |
| 1833 | isis_config_write (struct vty *vty) |
| 1834 | { |
| 1835 | int write = 0; |
| 1836 | |
| 1837 | if (isis != NULL) { |
| 1838 | struct isis_area *area; |
| 1839 | struct listnode *node; |
| 1840 | struct listnode *node2; |
| 1841 | |
| 1842 | LIST_LOOP (isis->area_list, area, node) { |
| 1843 | /* ISIS - Area name */ |
| 1844 | vty_out (vty, "router isis %s%s",area->area_tag, VTY_NEWLINE); |
| 1845 | write++; |
| 1846 | /* ISIS - Net */ |
| 1847 | if (listcount (area->area_addrs) > 0) { |
| 1848 | struct area_addr *area_addr; |
| 1849 | LIST_LOOP (area->area_addrs, area_addr, node2) { |
| 1850 | vty_out (vty, " net %s%s", |
| 1851 | isonet_print (area_addr->area_addr, |
| 1852 | area_addr->addr_len + ISIS_SYS_ID_LEN + 1), |
| 1853 | VTY_NEWLINE); |
| 1854 | write ++; |
| 1855 | } |
| 1856 | } |
| 1857 | /* ISIS - Dynamic hostname - Defaults to true so only display if false*/ |
| 1858 | if (!area->dynhostname) { |
| 1859 | vty_out (vty, " no hostname dynamic%s", VTY_NEWLINE); |
| 1860 | write ++; |
| 1861 | } |
| 1862 | /* ISIS - Metric-Style - when true displays wide */ |
| 1863 | if (area->newmetric) { |
| 1864 | vty_out (vty, " metric-style wide%s", VTY_NEWLINE); |
| 1865 | write ++; |
| 1866 | } |
| 1867 | /* ISIS - Area is-type (level-1-2 is default) */ |
| 1868 | if (area->is_type == IS_LEVEL_1) { |
| 1869 | vty_out (vty, " is-type level-1%s", VTY_NEWLINE); |
| 1870 | write ++; |
| 1871 | } else {if (area->is_type == IS_LEVEL_2) { |
| 1872 | vty_out (vty, " is-type level-2-only%s", VTY_NEWLINE); |
| 1873 | write ++; |
| 1874 | }} |
| 1875 | /* ISIS - Lsp generation interval */ |
| 1876 | if (area->lsp_gen_interval[0] == area->lsp_gen_interval[1]) { |
| 1877 | if (area->lsp_gen_interval[0] != LSP_GEN_INTERVAL_DEFAULT) { |
| 1878 | vty_out (vty, " lsp-gen-interval %d%s", area->lsp_gen_interval[0], |
| 1879 | VTY_NEWLINE); |
| 1880 | write ++; |
| 1881 | }} else { |
| 1882 | if (area->lsp_gen_interval[0] != LSP_GEN_INTERVAL_DEFAULT) { |
| 1883 | vty_out (vty, " lsp-gen-interval level-1 %d%s", |
| 1884 | area->lsp_gen_interval[0], VTY_NEWLINE); |
| 1885 | write ++; |
| 1886 | } |
| 1887 | if (area->lsp_gen_interval[1] != LSP_GEN_INTERVAL_DEFAULT) { |
| 1888 | vty_out (vty, " lsp-gen-interval level-2 %d%s", |
| 1889 | area->lsp_gen_interval[1], VTY_NEWLINE); |
| 1890 | write ++; |
| 1891 | } |
| 1892 | } |
| 1893 | /* ISIS - LSP lifetime */ |
| 1894 | if (area->max_lsp_lifetime[0] == area->max_lsp_lifetime[1]) { |
| 1895 | if (area->max_lsp_lifetime[0] != MAX_AGE) { |
| 1896 | vty_out (vty, " lsp-lifetime %u%s", area->max_lsp_lifetime[0], |
| 1897 | VTY_NEWLINE); |
| 1898 | write ++; |
| 1899 | }} else { |
| 1900 | if (area->max_lsp_lifetime[0] != MAX_AGE) { |
| 1901 | vty_out (vty, " lsp-lifetime level-1 %u%s", area->max_lsp_lifetime[0], |
| 1902 | VTY_NEWLINE); |
| 1903 | write ++; |
| 1904 | } |
| 1905 | if (area->max_lsp_lifetime[1] != MAX_AGE) { |
| 1906 | vty_out (vty, " lsp-lifetime level-2 %u%s", area->max_lsp_lifetime[1], |
| 1907 | VTY_NEWLINE); |
| 1908 | write ++; |
| 1909 | } |
| 1910 | } |
| 1911 | #ifdef TOPOLOGY_GENERATE |
| 1912 | /* seems we save the whole command line here */ |
| 1913 | if (area->top_params) { |
| 1914 | vty_out (vty, " %s%s",area->top_params, VTY_NEWLINE); |
| 1915 | write ++; |
| 1916 | } |
| 1917 | |
| 1918 | if (memcmp(area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, |
| 1919 | ISIS_SYS_ID_LEN)) { |
| 1920 | vty_out (vty, " topology base_is %s%s", |
| 1921 | sysid_print (area->topology_baseis), VTY_NEWLINE); |
| 1922 | write ++; |
| 1923 | } |
| 1924 | |
| 1925 | #endif /* TOPOLOGY_GENERATE */ |
| 1926 | } |
| 1927 | } |
| 1928 | |
| 1929 | return write; |
| 1930 | } |
| 1931 | |
| 1932 | struct cmd_node isis_node = |
| 1933 | { |
| 1934 | ISIS_NODE, |
hasso | 2097cd8 | 2003-12-23 11:51:08 +0000 | [diff] [blame] | 1935 | "%s(config-router)# ", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1936 | 1 |
| 1937 | }; |
| 1938 | |
| 1939 | void |
| 1940 | isis_init () |
| 1941 | { |
| 1942 | |
| 1943 | /* Install IS-IS top node */ |
| 1944 | install_node (&isis_node, isis_config_write); |
| 1945 | |
| 1946 | install_element (VIEW_NODE, &show_clns_neighbors_cmd); |
| 1947 | install_element (VIEW_NODE, &show_isis_neighbors_cmd); |
| 1948 | install_element (VIEW_NODE, &show_clns_neighbors_detail_cmd); |
| 1949 | install_element (VIEW_NODE, &show_isis_neighbors_detail_cmd); |
| 1950 | |
| 1951 | install_element (VIEW_NODE, &show_hostname_cmd); |
| 1952 | install_element (VIEW_NODE, &show_database_cmd); |
| 1953 | install_element (VIEW_NODE, &show_database_detail_cmd); |
| 1954 | |
| 1955 | install_element (ENABLE_NODE, &show_clns_neighbors_cmd); |
| 1956 | install_element (ENABLE_NODE, &show_isis_neighbors_cmd); |
| 1957 | install_element (ENABLE_NODE, &show_clns_neighbors_detail_cmd); |
| 1958 | install_element (ENABLE_NODE, &show_isis_neighbors_detail_cmd); |
| 1959 | |
| 1960 | install_element (ENABLE_NODE, &show_hostname_cmd); |
| 1961 | install_element (ENABLE_NODE, &show_database_cmd); |
| 1962 | install_element (ENABLE_NODE, &show_database_detail_cmd); |
| 1963 | install_element (ENABLE_NODE, &show_debugging_cmd); |
| 1964 | |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 1965 | install_node(&debug_node, config_write_debug); |
| 1966 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1967 | install_element (ENABLE_NODE, &debug_isis_adj_cmd); |
| 1968 | install_element (ENABLE_NODE, &no_debug_isis_adj_cmd); |
| 1969 | install_element (ENABLE_NODE, &debug_isis_csum_cmd); |
| 1970 | install_element (ENABLE_NODE, &no_debug_isis_csum_cmd); |
| 1971 | install_element (ENABLE_NODE, &debug_isis_lupd_cmd); |
| 1972 | install_element (ENABLE_NODE, &no_debug_isis_lupd_cmd); |
| 1973 | install_element (ENABLE_NODE, &debug_isis_err_cmd); |
| 1974 | install_element (ENABLE_NODE, &no_debug_isis_err_cmd); |
| 1975 | install_element (ENABLE_NODE, &debug_isis_snp_cmd); |
| 1976 | install_element (ENABLE_NODE, &no_debug_isis_snp_cmd); |
| 1977 | install_element (ENABLE_NODE, &debug_isis_upd_cmd); |
| 1978 | install_element (ENABLE_NODE, &no_debug_isis_upd_cmd); |
| 1979 | install_element (ENABLE_NODE, &debug_isis_spfevents_cmd); |
| 1980 | install_element (ENABLE_NODE, &no_debug_isis_spfevents_cmd); |
| 1981 | install_element (ENABLE_NODE, &debug_isis_spfstats_cmd); |
| 1982 | install_element (ENABLE_NODE, &no_debug_isis_spfstats_cmd); |
| 1983 | install_element (ENABLE_NODE, &debug_isis_spftrigg_cmd); |
| 1984 | install_element (ENABLE_NODE, &no_debug_isis_spftrigg_cmd); |
| 1985 | install_element (ENABLE_NODE, &debug_isis_rtevents_cmd); |
| 1986 | install_element (ENABLE_NODE, &no_debug_isis_rtevents_cmd); |
| 1987 | install_element (ENABLE_NODE, &debug_isis_events_cmd); |
| 1988 | install_element (ENABLE_NODE, &no_debug_isis_events_cmd); |
| 1989 | |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 1990 | install_element (CONFIG_NODE, &debug_isis_adj_cmd); |
| 1991 | install_element (CONFIG_NODE, &no_debug_isis_adj_cmd); |
| 1992 | install_element (CONFIG_NODE, &debug_isis_csum_cmd); |
| 1993 | install_element (CONFIG_NODE, &no_debug_isis_csum_cmd); |
| 1994 | install_element (CONFIG_NODE, &debug_isis_lupd_cmd); |
| 1995 | install_element (CONFIG_NODE, &no_debug_isis_lupd_cmd); |
| 1996 | install_element (CONFIG_NODE, &debug_isis_err_cmd); |
| 1997 | install_element (CONFIG_NODE, &no_debug_isis_err_cmd); |
| 1998 | install_element (CONFIG_NODE, &debug_isis_snp_cmd); |
| 1999 | install_element (CONFIG_NODE, &no_debug_isis_snp_cmd); |
| 2000 | install_element (CONFIG_NODE, &debug_isis_upd_cmd); |
| 2001 | install_element (CONFIG_NODE, &no_debug_isis_upd_cmd); |
| 2002 | install_element (CONFIG_NODE, &debug_isis_spfevents_cmd); |
| 2003 | install_element (CONFIG_NODE, &no_debug_isis_spfevents_cmd); |
| 2004 | install_element (CONFIG_NODE, &debug_isis_spfstats_cmd); |
| 2005 | install_element (CONFIG_NODE, &no_debug_isis_spfstats_cmd); |
| 2006 | install_element (CONFIG_NODE, &debug_isis_spftrigg_cmd); |
| 2007 | install_element (CONFIG_NODE, &no_debug_isis_spftrigg_cmd); |
| 2008 | install_element (CONFIG_NODE, &debug_isis_rtevents_cmd); |
| 2009 | install_element (CONFIG_NODE, &no_debug_isis_rtevents_cmd); |
| 2010 | install_element (CONFIG_NODE, &debug_isis_events_cmd); |
| 2011 | install_element (CONFIG_NODE, &no_debug_isis_events_cmd); |
| 2012 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2013 | install_element (CONFIG_NODE, &router_isis_cmd); |
| 2014 | install_element (CONFIG_NODE, &no_router_isis_cmd); |
| 2015 | |
| 2016 | install_default (ISIS_NODE); |
| 2017 | |
| 2018 | install_element (ISIS_NODE, &net_cmd); |
| 2019 | install_element (ISIS_NODE, &no_net_cmd); |
| 2020 | |
| 2021 | install_element (ISIS_NODE, &is_type_cmd); |
| 2022 | install_element (ISIS_NODE, &no_is_type_cmd); |
| 2023 | |
| 2024 | install_element (ISIS_NODE, &area_passwd_cmd); |
| 2025 | install_element (ISIS_NODE, &no_area_passwd_cmd); |
| 2026 | |
| 2027 | install_element (ISIS_NODE, &domain_passwd_cmd); |
| 2028 | install_element (ISIS_NODE, &no_domain_passwd_cmd); |
| 2029 | |
| 2030 | install_element (ISIS_NODE, &lsp_gen_interval_cmd); |
| 2031 | install_element (ISIS_NODE, &no_lsp_gen_interval_cmd); |
| 2032 | install_element (ISIS_NODE, &no_lsp_gen_interval_arg_cmd); |
| 2033 | install_element (ISIS_NODE, &lsp_gen_interval_l1_cmd); |
| 2034 | install_element (ISIS_NODE, &no_lsp_gen_interval_l1_cmd); |
| 2035 | install_element (ISIS_NODE, &no_lsp_gen_interval_l1_arg_cmd); |
| 2036 | install_element (ISIS_NODE, &lsp_gen_interval_l2_cmd); |
| 2037 | install_element (ISIS_NODE, &no_lsp_gen_interval_l2_cmd); |
| 2038 | install_element (ISIS_NODE, &no_lsp_gen_interval_l2_arg_cmd); |
| 2039 | |
| 2040 | install_element (ISIS_NODE, &spf_interval_cmd); |
| 2041 | install_element (ISIS_NODE, &no_spf_interval_cmd); |
| 2042 | install_element (ISIS_NODE, &no_spf_interval_arg_cmd); |
| 2043 | install_element (ISIS_NODE, &spf_interval_l1_cmd); |
| 2044 | install_element (ISIS_NODE, &no_spf_interval_l1_cmd); |
| 2045 | install_element (ISIS_NODE, &no_spf_interval_l1_arg_cmd); |
| 2046 | install_element (ISIS_NODE, &spf_interval_l2_cmd); |
| 2047 | install_element (ISIS_NODE, &no_spf_interval_l2_cmd); |
| 2048 | install_element (ISIS_NODE, &no_spf_interval_l2_arg_cmd); |
| 2049 | |
| 2050 | install_element (ISIS_NODE, &lsp_lifetime_cmd); |
| 2051 | install_element (ISIS_NODE, &no_lsp_lifetime_cmd); |
| 2052 | install_element (ISIS_NODE, &no_lsp_lifetime_arg_cmd); |
| 2053 | install_element (ISIS_NODE, &lsp_lifetime_l1_cmd); |
| 2054 | install_element (ISIS_NODE, &no_lsp_lifetime_l1_cmd); |
| 2055 | install_element (ISIS_NODE, &no_lsp_lifetime_l1_arg_cmd); |
| 2056 | install_element (ISIS_NODE, &lsp_lifetime_l2_cmd); |
| 2057 | install_element (ISIS_NODE, &no_lsp_lifetime_l2_cmd); |
| 2058 | install_element (ISIS_NODE, &no_lsp_lifetime_l2_arg_cmd); |
| 2059 | |
| 2060 | install_element (ISIS_NODE, &dynamic_hostname_cmd); |
| 2061 | install_element (ISIS_NODE, &no_dynamic_hostname_cmd); |
| 2062 | |
| 2063 | install_element (ISIS_NODE, &metric_style_cmd); |
| 2064 | install_element (ISIS_NODE, &no_metric_style_cmd); |
| 2065 | #ifdef TOPOLOGY_GENERATE |
| 2066 | install_element (ISIS_NODE, &topology_generate_grid_cmd); |
| 2067 | install_element (ISIS_NODE, &topology_baseis_cmd); |
| 2068 | install_element (ISIS_NODE, &no_topology_baseis_cmd); |
| 2069 | install_element (VIEW_NODE, &show_isis_topology_cmd); |
| 2070 | install_element (ENABLE_NODE, &show_isis_topology_cmd); |
| 2071 | #endif /* TOPOLOGY_GENERATE */ |
| 2072 | |
| 2073 | isis_new(0); |
| 2074 | isis_circuit_init (); |
| 2075 | isis_zebra_init (); |
| 2076 | isis_spf_cmds_init (); |
| 2077 | } |
| 2078 | |
| 2079 | |
| 2080 | |
| 2081 | |
| 2082 | |
| 2083 | |