jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * IS-IS Rout(e)ing protocol - isis_circuit.h |
| 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 | #include <stdlib.h> |
| 23 | #include <stdio.h> |
| 24 | #include <ctype.h> |
| 25 | #include <zebra.h> |
| 26 | #include <net/ethernet.h> |
| 27 | |
| 28 | #include "log.h" |
| 29 | #include "memory.h" |
| 30 | #include "if.h" |
| 31 | #include "linklist.h" |
| 32 | #include "command.h" |
| 33 | #include "thread.h" |
| 34 | #include "hash.h" |
| 35 | #include "prefix.h" |
| 36 | #include "stream.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_tlv.h" |
| 44 | #include "isisd/isis_lsp.h" |
| 45 | #include "isisd/isis_pdu.h" |
| 46 | #include "isisd/isis_network.h" |
| 47 | #include "isisd/isis_misc.h" |
| 48 | #include "isisd/isis_constants.h" |
| 49 | #include "isisd/isis_adjacency.h" |
| 50 | #include "isisd/isis_dr.h" |
| 51 | #include "isisd/isis_flags.h" |
| 52 | #include "isisd/isisd.h" |
| 53 | #include "isisd/isis_csm.h" |
| 54 | #include "isisd/isis_events.h" |
| 55 | |
| 56 | extern struct thread_master *master; |
| 57 | extern struct isis *isis; |
| 58 | |
| 59 | struct isis_circuit * |
| 60 | isis_circuit_new () |
| 61 | { |
| 62 | struct isis_circuit *circuit; |
| 63 | int i; |
| 64 | |
| 65 | circuit = XMALLOC (MTYPE_ISIS_CIRCUIT, sizeof (struct isis_circuit)); |
| 66 | if (circuit) { |
| 67 | memset (circuit, 0, sizeof (struct isis_circuit)); |
| 68 | /* set default metrics for circuit */ |
| 69 | for (i = 0; i < 2; i++) { |
| 70 | circuit->metrics[i].metric_default = DEFAULT_CIRCUIT_METRICS; |
| 71 | circuit->metrics[i].metric_expense = METRICS_UNSUPPORTED; |
| 72 | circuit->metrics[i].metric_error = METRICS_UNSUPPORTED; |
| 73 | circuit->metrics[i].metric_delay = METRICS_UNSUPPORTED; |
| 74 | } |
| 75 | } else { |
| 76 | zlog_err ("Can't malloc isis circuit"); |
| 77 | return NULL; |
| 78 | } |
| 79 | |
| 80 | return circuit; |
| 81 | } |
| 82 | |
| 83 | |
| 84 | void |
| 85 | isis_circuit_configure (struct isis_circuit *circuit, struct isis_area *area) |
| 86 | { |
| 87 | int i; |
| 88 | circuit->area = area; |
| 89 | /* |
| 90 | * The level for the circuit is same as for the area, unless configured |
| 91 | * otherwise. |
| 92 | */ |
| 93 | circuit->circuit_is_type = area->is_type; |
| 94 | /* |
| 95 | * Default values |
| 96 | */ |
| 97 | for (i = 0; i < 2; i++) { |
| 98 | circuit->hello_interval[i] = HELLO_INTERVAL; |
| 99 | circuit->hello_multiplier[i] = HELLO_MULTIPLIER; |
| 100 | circuit->csnp_interval[i] = CSNP_INTERVAL; |
| 101 | circuit->psnp_interval[i] = PSNP_INTERVAL; |
| 102 | circuit->u.bc.priority[i] = DEFAULT_PRIORITY; |
| 103 | } |
| 104 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { |
| 105 | circuit->u.bc.adjdb[0] = list_new (); |
| 106 | circuit->u.bc.adjdb[1] = list_new (); |
| 107 | circuit->u.bc.pad_hellos = 1; |
| 108 | } |
| 109 | circuit->lsp_interval = LSP_INTERVAL; |
| 110 | |
| 111 | /* |
| 112 | * Add the circuit into area |
| 113 | */ |
| 114 | listnode_add (area->circuit_list, circuit); |
| 115 | |
| 116 | circuit->idx = flags_get_index (&area->flags); |
| 117 | circuit->lsp_queue = list_new (); |
| 118 | |
| 119 | return; |
| 120 | } |
| 121 | |
| 122 | void |
| 123 | isis_circuit_deconfigure (struct isis_circuit *circuit, |
| 124 | struct isis_area *area) |
| 125 | { |
| 126 | |
| 127 | /* Remove circuit from area */ |
| 128 | listnode_delete (area->circuit_list, circuit); |
| 129 | /* Free the index of SRM and SSN flags */ |
| 130 | flags_free_index (&area->flags, circuit->idx); |
| 131 | |
| 132 | return; |
| 133 | } |
| 134 | |
| 135 | struct isis_circuit * |
| 136 | circuit_lookup_by_ifp (struct interface *ifp, struct list *list) |
| 137 | { |
| 138 | struct isis_circuit *circuit = NULL; |
| 139 | struct listnode *node; |
| 140 | |
| 141 | if (!list) |
| 142 | return NULL; |
| 143 | |
| 144 | for (node = listhead (list); node; nextnode (node)) { |
| 145 | circuit = getdata (node); |
| 146 | if (circuit->interface == ifp) |
| 147 | return circuit; |
| 148 | } |
| 149 | |
| 150 | return NULL; |
| 151 | } |
| 152 | |
| 153 | struct isis_circuit * |
| 154 | circuit_scan_by_ifp (struct interface *ifp) |
| 155 | { |
| 156 | struct isis_area *area; |
| 157 | struct listnode *node; |
| 158 | struct isis_circuit *circuit; |
| 159 | |
| 160 | if (!isis->area_list) |
| 161 | return NULL; |
| 162 | |
| 163 | for (node = listhead (isis->area_list); node; nextnode (node)) { |
| 164 | area = getdata (node); |
| 165 | circuit = circuit_lookup_by_ifp (ifp, area->circuit_list); |
| 166 | if (circuit) |
| 167 | return circuit; |
| 168 | } |
| 169 | |
| 170 | return circuit_lookup_by_ifp (ifp, isis->init_circ_list); |
| 171 | } |
| 172 | |
| 173 | void |
| 174 | isis_circuit_del (struct isis_circuit *circuit) |
| 175 | { |
| 176 | |
| 177 | if (!circuit) |
| 178 | return; |
| 179 | |
| 180 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { |
| 181 | /* destroy adjacency databases */ |
| 182 | list_delete (circuit->u.bc.adjdb[0]); |
| 183 | list_delete (circuit->u.bc.adjdb[1]); |
| 184 | /* destroy neighbour lists */ |
| 185 | if (circuit->u.bc.lan_neighs[0]) |
| 186 | list_delete (circuit->u.bc.lan_neighs[0]); |
| 187 | if (circuit->u.bc.lan_neighs[1]) |
| 188 | list_delete (circuit->u.bc.lan_neighs[1]); |
| 189 | /* destroy addresses */ |
| 190 | } |
| 191 | if (circuit->ip_addrs) |
| 192 | list_delete (circuit->ip_addrs); |
| 193 | #ifdef HAVE_IPV6 |
| 194 | if (circuit->ipv6_link) |
| 195 | list_delete (circuit->ipv6_link); |
| 196 | if (circuit->ipv6_non_link) |
| 197 | list_delete (circuit->ipv6_non_link); |
| 198 | #endif /* HAVE_IPV6 */ |
| 199 | |
| 200 | /* and lastly the circuit itself */ |
| 201 | XFREE (MTYPE_ISIS_CIRCUIT, circuit); |
| 202 | |
| 203 | return; |
| 204 | } |
| 205 | |
| 206 | void |
| 207 | isis_circuit_add_addr (struct isis_circuit *circuit, |
| 208 | struct connected *conn) |
| 209 | { |
| 210 | struct prefix_ipv4 *ipv4; |
| 211 | u_char buf [BUFSIZ]; |
| 212 | #ifdef HAVE_IPV6 |
| 213 | struct prefix_ipv6 *ipv6; |
| 214 | #endif /* HAVE_IPV6 */ |
| 215 | if (!circuit->ip_addrs) { |
| 216 | circuit->ip_addrs = list_new (); |
| 217 | } |
| 218 | #ifdef HAVE_IPV6 |
| 219 | if (!circuit->ipv6_link) { |
| 220 | circuit->ipv6_link = list_new (); |
| 221 | } |
| 222 | if (!circuit->ipv6_non_link) { |
| 223 | circuit->ipv6_non_link = list_new (); |
| 224 | } |
| 225 | #endif /* HAVE_IPV6 */ |
| 226 | |
| 227 | memset (&buf, 0, BUFSIZ); |
| 228 | if (conn->address->family == AF_INET) { |
| 229 | ipv4 = prefix_ipv4_new (); |
| 230 | ipv4->prefixlen = conn->address->prefixlen; |
| 231 | ipv4->prefix = conn->address->u.prefix4; |
| 232 | listnode_add (circuit->ip_addrs, ipv4); |
| 233 | prefix2str (conn->address, buf, BUFSIZ); |
| 234 | #ifdef EXTREME_DEBUG |
| 235 | zlog_info ("Added IP address %s to circuit %d", buf, |
| 236 | circuit->circuit_id); |
| 237 | #endif /* EXTREME_DEBUG */ |
| 238 | } |
| 239 | #ifdef HAVE_IPV6 |
| 240 | if (conn->address->family == AF_INET6) { |
| 241 | ipv6 = prefix_ipv6_new (); |
| 242 | ipv6->prefixlen = conn->address->prefixlen; |
| 243 | ipv6->prefix = conn->address->u.prefix6; |
| 244 | if (IN6_IS_ADDR_LINKLOCAL(&ipv6->prefix)) { |
| 245 | listnode_add (circuit->ipv6_link, ipv6); |
| 246 | } else { |
| 247 | listnode_add (circuit->ipv6_non_link, ipv6); |
| 248 | } |
| 249 | prefix2str (conn->address, buf, BUFSIZ); |
| 250 | #ifdef EXTREME_DEBUG |
| 251 | zlog_info ("Added IPv6 address %s to circuit %d", buf, |
| 252 | circuit->circuit_id); |
| 253 | #endif /* EXTREME_DEBUG */ |
| 254 | } |
| 255 | #endif /* HAVE_IPV6 */ |
| 256 | |
| 257 | |
| 258 | return; |
| 259 | } |
| 260 | |
| 261 | void |
| 262 | isis_circuit_del_addr (struct isis_circuit *circuit, |
| 263 | struct connected *connected) |
| 264 | { |
| 265 | |
| 266 | } |
| 267 | |
| 268 | void |
| 269 | isis_circuit_if_add (struct isis_circuit *circuit, struct interface *ifp) |
| 270 | { |
| 271 | struct listnode *node; |
| 272 | struct connected *conn; |
| 273 | |
| 274 | circuit->interface = ifp; |
| 275 | ifp->info = circuit; |
| 276 | |
| 277 | circuit->circuit_id = ifp->ifindex % 255; /* FIXME: Why not ? */ |
| 278 | |
| 279 | /* isis_circuit_update_addrs (circuit, ifp); */ |
| 280 | |
| 281 | if (if_is_broadcast (ifp)) { |
| 282 | circuit->circ_type = CIRCUIT_T_BROADCAST; |
| 283 | /* |
| 284 | * Get the Hardware Address |
| 285 | */ |
| 286 | #ifdef HAVE_SOCKADDR_DL |
| 287 | if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN) |
| 288 | zlog_warn ("unsupported link layer"); |
| 289 | else |
| 290 | memcpy (circuit->u.bc.snpa, LLADDR(&circuit->interface->sdl), ETH_ALEN); |
| 291 | #else |
| 292 | if (circuit->interface->hw_addr_len != ETH_ALEN) { |
| 293 | zlog_warn ("unsupported link layer"); |
| 294 | } else { |
| 295 | memcpy (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN); |
| 296 | } |
| 297 | #ifdef EXTREME_DEGUG |
| 298 | zlog_info ("isis_circuit_if_add: if_id %d, isomtu %d snpa %s", |
| 299 | circuit->interface->ifindex, ISO_MTU (circuit), |
| 300 | snpa_print (circuit->u.bc.snpa)); |
| 301 | |
| 302 | #endif /* EXTREME_DEBUG */ |
| 303 | #endif /* HAVE_SOCKADDR_DL */ |
| 304 | } else if (if_is_pointopoint (ifp)) { |
| 305 | circuit->circ_type = CIRCUIT_T_P2P; |
| 306 | } else { |
| 307 | zlog_warn ("isis_circuit_if_add: unsupported media"); |
| 308 | } |
| 309 | |
| 310 | for (node = ifp->connected ? listhead (ifp->connected) : NULL; node; |
| 311 | nextnode (node)) { |
| 312 | conn = getdata (node); |
| 313 | isis_circuit_add_addr (circuit, conn); |
| 314 | } |
| 315 | |
| 316 | return; |
| 317 | } |
| 318 | |
| 319 | void |
| 320 | isis_circuit_update_params (struct isis_circuit *circuit, |
| 321 | struct interface *ifp) |
| 322 | { |
| 323 | assert (circuit); |
| 324 | |
| 325 | if (circuit->circuit_id != ifp->ifindex) { |
| 326 | zlog_warn ("changing circuit_id %d->%d", circuit->circuit_id, |
| 327 | ifp->ifindex); |
| 328 | circuit->circuit_id = ifp->ifindex % 255; |
| 329 | } |
| 330 | |
| 331 | /* FIXME: Why is this needed? shouldn't we compare to the area's mtu */ |
| 332 | /* Ofer, this was here in case someone changes the mtu (e.g. with ifconfig) |
| 333 | The areas MTU is the minimum of mtu's of circuits in the area |
| 334 | now we can't catch the change |
| 335 | if (circuit->mtu != ifp->mtu) { |
| 336 | zlog_warn ("changing circuit mtu %d->%d", circuit->mtu, |
| 337 | ifp->mtu); |
| 338 | circuit->mtu = ifp->mtu; |
| 339 | } |
| 340 | */ |
| 341 | /* |
| 342 | * Get the Hardware Address |
| 343 | */ |
| 344 | #ifdef HAVE_SOCKADDR_DL |
| 345 | if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN) |
| 346 | zlog_warn ("unsupported link layer"); |
| 347 | else |
| 348 | memcpy (circuit->u.bc.snpa, LLADDR(&circuit->interface->sdl), ETH_ALEN); |
| 349 | #else |
| 350 | if (circuit->interface->hw_addr_len != ETH_ALEN) { |
| 351 | zlog_warn ("unsupported link layer"); |
| 352 | } else { |
| 353 | if (memcmp(circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN)) { |
| 354 | zlog_warn ("changing circuit snpa %s->%s", |
| 355 | snpa_print (circuit->u.bc.snpa), |
| 356 | snpa_print (circuit->interface->hw_addr)); |
| 357 | } |
| 358 | } |
| 359 | #endif |
| 360 | |
| 361 | |
| 362 | |
| 363 | if (if_is_broadcast (ifp)) { |
| 364 | circuit->circ_type = CIRCUIT_T_BROADCAST; |
| 365 | } else if (if_is_pointopoint (ifp)) { |
| 366 | circuit->circ_type = CIRCUIT_T_P2P; |
| 367 | } else { |
| 368 | zlog_warn ("isis_circuit_update_params: unsupported media"); |
| 369 | } |
| 370 | |
| 371 | return; |
| 372 | } |
| 373 | |
| 374 | void |
| 375 | isis_circuit_if_del (struct isis_circuit *circuit) |
| 376 | { |
| 377 | circuit->interface->info = NULL; |
| 378 | circuit->interface = NULL; |
| 379 | |
| 380 | return; |
| 381 | } |
| 382 | |
| 383 | void |
| 384 | isis_circuit_up (struct isis_circuit *circuit) |
| 385 | { |
| 386 | |
| 387 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { |
| 388 | if (circuit->area->min_bcast_mtu == 0 || |
| 389 | ISO_MTU(circuit) < circuit->area->min_bcast_mtu ) |
| 390 | circuit->area->min_bcast_mtu = ISO_MTU(circuit); |
| 391 | /* |
| 392 | * ISO 10589 - 8.4.1 Enabling of broadcast circuits |
| 393 | */ |
| 394 | |
| 395 | /* initilizing the hello sending threads |
| 396 | * for a broadcast IF |
| 397 | */ |
| 398 | |
| 399 | /* 8.4.1 a) commence sending of IIH PDUs */ |
| 400 | |
| 401 | if (circuit->circuit_is_type & IS_LEVEL_1) { |
| 402 | thread_add_event (master, send_lan_l1_hello, circuit, 0); |
| 403 | circuit->u.bc.lan_neighs[0] = list_new (); |
| 404 | } |
| 405 | |
| 406 | if (circuit->circuit_is_type & IS_LEVEL_2) { |
| 407 | thread_add_event (master, send_lan_l2_hello, circuit, 0); |
| 408 | circuit->u.bc.lan_neighs[1] = list_new (); |
| 409 | } |
| 410 | |
| 411 | /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */ |
| 412 | /* 8.4.1 c) FIXME: listen for ESH PDUs */ |
| 413 | |
| 414 | /* 8.4.1 d) */ |
| 415 | /* dr election will commence in... */ |
| 416 | if (circuit->circuit_is_type & IS_LEVEL_1) |
| 417 | circuit->u.bc.t_run_dr[0] = |
| 418 | thread_add_timer (master, isis_run_dr_l1, circuit, |
| 419 | 2 * circuit->hello_multiplier[0] * circuit->hello_interval[0]); |
| 420 | if (circuit->circuit_is_type & IS_LEVEL_2) |
| 421 | circuit->u.bc.t_run_dr[1] = |
| 422 | thread_add_timer (master, isis_run_dr_l2, circuit, |
| 423 | 2 * circuit->hello_multiplier[1] * circuit->hello_interval[1]); |
| 424 | } else { |
| 425 | /* initializing the hello send threads |
| 426 | * for a ptp IF |
| 427 | */ |
| 428 | thread_add_event (master, send_p2p_hello, circuit, 0); |
| 429 | |
| 430 | } |
| 431 | |
| 432 | /* initializing PSNP timers */ |
| 433 | if (circuit->circuit_is_type & IS_LEVEL_1) { |
| 434 | circuit->t_send_psnp[0] = thread_add_timer (master, |
| 435 | send_l1_psnp, |
| 436 | circuit, |
| 437 | isis_jitter |
| 438 | (circuit->psnp_interval[0], |
| 439 | PSNP_JITTER)); |
| 440 | } |
| 441 | |
| 442 | if (circuit->circuit_is_type & IS_LEVEL_2) { |
| 443 | circuit->t_send_psnp[1] = thread_add_timer (master, |
| 444 | send_l2_psnp, |
| 445 | circuit, |
| 446 | isis_jitter |
| 447 | (circuit->psnp_interval[1], |
| 448 | PSNP_JITTER)); |
| 449 | |
| 450 | } |
| 451 | |
| 452 | /* initialize the circuit streams */ |
| 453 | if (circuit->rcv_stream == NULL) |
| 454 | circuit->rcv_stream = stream_new (ISO_MTU(circuit)); |
| 455 | |
| 456 | if (circuit->snd_stream == NULL) |
| 457 | circuit->snd_stream = stream_new (ISO_MTU(circuit)); |
| 458 | |
| 459 | /* unified init for circuits */ |
| 460 | isis_sock_init (circuit); |
| 461 | |
| 462 | #ifdef GNU_LINUX |
| 463 | circuit->t_read = thread_add_read (master, isis_receive, circuit, |
| 464 | circuit->fd); |
| 465 | #else |
| 466 | circuit->t_read = thread_add_timer (master, isis_receive, circuit, |
| 467 | circuit->fd); |
| 468 | #endif |
| 469 | return; |
| 470 | } |
| 471 | |
| 472 | void |
| 473 | isis_circuit_down (struct isis_circuit *circuit) |
| 474 | { |
| 475 | /* Cancel all active threads -- FIXME: wrong place*/ |
| 476 | if (circuit->t_read) |
| 477 | thread_cancel (circuit->t_read); |
| 478 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { |
| 479 | if (circuit->u.bc.t_send_lan_hello[0]) |
| 480 | thread_cancel (circuit->u.bc.t_send_lan_hello[0]); |
| 481 | if (circuit->u.bc.t_send_lan_hello[1]) |
| 482 | thread_cancel (circuit->u.bc.t_send_lan_hello[1]); |
| 483 | } else if (circuit->circ_type == CIRCUIT_T_P2P) { |
| 484 | if (circuit->u.p2p.t_send_p2p_hello) |
| 485 | thread_cancel (circuit->u.p2p.t_send_p2p_hello); |
| 486 | } |
| 487 | /* close the socket */ |
| 488 | close (circuit->fd); |
| 489 | |
| 490 | return; |
| 491 | } |
| 492 | |
| 493 | void |
| 494 | circuit_update_nlpids (struct isis_circuit *circuit) |
| 495 | { |
| 496 | circuit->nlpids.count = 0; |
| 497 | |
| 498 | if (circuit->ip_router) { |
| 499 | circuit->nlpids.nlpids[0] = NLPID_IP; |
| 500 | circuit->nlpids.count++; |
| 501 | } |
| 502 | #ifdef HAVE_IPV6 |
| 503 | if (circuit->ipv6_router) { |
| 504 | circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6; |
| 505 | circuit->nlpids.count++; |
| 506 | } |
| 507 | #endif /* HAVE_IPV6 */ |
| 508 | return; |
| 509 | } |
| 510 | |
| 511 | int |
| 512 | isis_interface_config_write (struct vty *vty) |
| 513 | { |
| 514 | |
| 515 | int write = 0; |
| 516 | listnode node; |
| 517 | listnode node2; |
| 518 | listnode node3; |
| 519 | struct interface *ifp; |
| 520 | struct isis_area *area; |
| 521 | struct isis_circuit *c; |
| 522 | struct prefix_ipv4 *ip; |
| 523 | int i; |
| 524 | #ifdef HAVE_IPV6 |
| 525 | struct prefix_ipv6 *ipv6; |
| 526 | #endif /*HAVE_IPV6 */ |
| 527 | |
| 528 | char buf[BUFSIZ]; |
| 529 | |
| 530 | |
| 531 | LIST_LOOP (iflist, ifp, node) |
| 532 | { |
| 533 | /* IF name */ |
| 534 | vty_out (vty, "interface %s%s", ifp->name,VTY_NEWLINE); |
| 535 | write++; |
| 536 | /* IF desc */ |
| 537 | if (ifp->desc) { |
| 538 | vty_out (vty, " description %s%s", ifp->desc,VTY_NEWLINE); |
| 539 | write++; |
| 540 | } |
| 541 | /* ISIS Circuit */ |
| 542 | LIST_LOOP (isis->area_list, area, node2) |
| 543 | { |
| 544 | c = circuit_lookup_by_ifp (ifp, area->circuit_list); |
| 545 | if (c) { |
| 546 | if (c->ip_router) { |
| 547 | vty_out (vty, " ip router isis %s%s",area->area_tag,VTY_NEWLINE); |
| 548 | write++; |
| 549 | } |
| 550 | #ifdef HAVE_IPV6 |
| 551 | if (c->ipv6_router) { |
| 552 | vty_out (vty, " ipv6 router isis %s%s",area->area_tag,VTY_NEWLINE); |
| 553 | write++; |
| 554 | } |
| 555 | #endif /* HAVE_IPV6 */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 556 | |
| 557 | /* ISIS - circuit type */ |
| 558 | if (c->circuit_is_type == IS_LEVEL_1) { |
| 559 | vty_out (vty, " isis circuit-type level-1%s", VTY_NEWLINE); |
| 560 | write ++; |
| 561 | } else {if (c->circuit_is_type == IS_LEVEL_2) { |
| 562 | vty_out (vty, " isis circuit-type level-2-only%s", VTY_NEWLINE); |
| 563 | write ++; |
| 564 | }} |
| 565 | |
| 566 | /* ISIS - CSNP interval - FIXME: compare to cisco*/ |
| 567 | if (c->csnp_interval[0] == c->csnp_interval[1]) { |
| 568 | if (c->csnp_interval[0] != CSNP_INTERVAL) { |
| 569 | vty_out (vty, " isis csnp-interval %d%s", c->csnp_interval[0], |
| 570 | VTY_NEWLINE); |
| 571 | write ++; |
| 572 | } |
| 573 | } else { |
| 574 | for (i=0;i<2;i++) { |
| 575 | if (c->csnp_interval[1] != CSNP_INTERVAL) { |
| 576 | vty_out (vty, " isis csnp-interval %d level-%d%s", |
| 577 | c->csnp_interval[1],i+1, VTY_NEWLINE); |
| 578 | write ++; |
| 579 | } |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | /* ISIS - Hello padding - Defaults to true so only display if false */ |
| 584 | if (c->circ_type == CIRCUIT_T_BROADCAST && !c->u.bc.pad_hellos) { |
| 585 | vty_out (vty, " no isis hello padding%s", VTY_NEWLINE); |
| 586 | write ++; |
| 587 | } |
| 588 | |
| 589 | /* ISIS - Hello interval - FIXME: compare to cisco */ |
| 590 | if (c->hello_interval[0] == c->hello_interval[1]) { |
| 591 | if (c->hello_interval[0] != HELLO_INTERVAL) { |
| 592 | vty_out (vty, " isis hello-interval %d%s", c->hello_interval[0], |
| 593 | VTY_NEWLINE); |
| 594 | write ++; |
| 595 | } |
| 596 | } else { |
| 597 | for (i=0;i<2;i++) { |
| 598 | if (c->hello_interval[i] != HELLO_INTERVAL) { |
| 599 | if (c->hello_interval[i] == HELLO_MINIMAL) { |
| 600 | vty_out (vty, " isis hello-interval minimal level-%d%s", i+1, |
| 601 | VTY_NEWLINE); |
| 602 | } else { |
| 603 | vty_out (vty, " isis hello-interval %d level-%d%s", |
| 604 | c->hello_interval[i],i+1, VTY_NEWLINE); |
| 605 | } |
| 606 | write ++; |
| 607 | } |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | /* ISIS - Hello Multiplier */ |
| 612 | if (c->hello_multiplier[0] == c->hello_multiplier[1]) { |
| 613 | if (c->hello_multiplier[0] != HELLO_MULTIPLIER ) { |
| 614 | vty_out (vty, " isis hello-multiplier %d%s", |
| 615 | c->hello_multiplier[0], VTY_NEWLINE); |
| 616 | write ++; |
| 617 | } |
| 618 | } else { |
| 619 | for (i=0;i<2;i++) { |
| 620 | if (c->hello_multiplier[i] != HELLO_MULTIPLIER) { |
| 621 | vty_out (vty, " isis hello-multiplier %d level-%d%s", |
| 622 | c->hello_multiplier[i],i+1, VTY_NEWLINE); |
| 623 | write ++; |
| 624 | } |
| 625 | } |
| 626 | } |
| 627 | /* ISIS - Priority */ |
| 628 | if (c->circ_type == CIRCUIT_T_BROADCAST) { |
| 629 | if (c->u.bc.priority[0] == c->u.bc.priority[1]) { |
| 630 | if (c->u.bc.priority[0] != DEFAULT_PRIORITY) { |
| 631 | vty_out (vty, " isis priority %d%s", c->u.bc.priority[0], |
| 632 | VTY_NEWLINE); |
| 633 | write ++; |
| 634 | } |
| 635 | } else { |
| 636 | for (i=0;i<2;i++) { |
| 637 | if (c->u.bc.priority[i] != DEFAULT_PRIORITY) { |
| 638 | vty_out (vty, " isis priority %d level-%d%s", |
| 639 | c->u.bc.priority[i],i+1, VTY_NEWLINE); |
| 640 | write ++; |
| 641 | } |
| 642 | } |
| 643 | } |
| 644 | } |
| 645 | /* ISIS - Metric */ |
| 646 | if (c->metrics[0].metric_default == c->metrics[1].metric_default) { |
| 647 | if (c->metrics[0].metric_default != DEFAULT_CIRCUIT_METRICS) { |
| 648 | vty_out (vty, " isis metric %d%s", c->metrics[0].metric_default, |
| 649 | VTY_NEWLINE); |
| 650 | write ++; |
| 651 | } |
| 652 | } else { |
| 653 | for (i=0;i<2;i++) { |
| 654 | if (c->metrics[i].metric_default != DEFAULT_CIRCUIT_METRICS) { |
| 655 | vty_out (vty, " isis metric %d level-%d%s", |
| 656 | c->metrics[i].metric_default,i+1, VTY_NEWLINE); |
| 657 | write ++; |
| 658 | } |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | } |
| 663 | } |
hasso | 2097cd8 | 2003-12-23 11:51:08 +0000 | [diff] [blame^] | 664 | vty_out (vty, "!%s",VTY_NEWLINE); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | return write; |
| 668 | } |
| 669 | |
| 670 | |
| 671 | DEFUN (ip_router_isis, |
| 672 | ip_router_isis_cmd, |
| 673 | "ip router isis WORD", |
| 674 | "Interface Internet Protocol config commands\n" |
| 675 | "IP router interface commands\n" |
| 676 | "IS-IS Routing for IP\n" |
| 677 | "Routing process tag\n" |
| 678 | ) |
| 679 | { |
| 680 | struct isis_circuit *c; |
| 681 | struct interface *ifp; |
| 682 | struct isis_area *area; |
| 683 | |
| 684 | ifp = (struct interface *)vty->index; |
| 685 | assert (ifp); |
| 686 | |
| 687 | area = isis_area_lookup (argv[0]); |
| 688 | |
| 689 | /* Prevent more than one circuit per interface */ |
| 690 | if (area) |
| 691 | c = circuit_lookup_by_ifp (ifp, area->circuit_list); |
| 692 | else c = NULL; |
| 693 | if (c && (ifp->info != NULL)) { |
| 694 | #ifdef HAVE_IPV6 |
| 695 | if (c->ipv6_router == 0) { |
| 696 | #endif /* HAVE_IPV6 */ |
| 697 | vty_out (vty, "ISIS circuit is already defined%s", VTY_NEWLINE); |
| 698 | return CMD_WARNING; |
| 699 | #ifdef HAVE_IPV6 |
| 700 | } |
| 701 | #endif /* HAVE_IPV6 */ |
| 702 | } |
| 703 | |
| 704 | /* this is here for ciscopability */ |
| 705 | if (!area) { |
| 706 | vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); |
| 707 | return CMD_WARNING; |
| 708 | } |
| 709 | |
| 710 | if (!c) { |
| 711 | c = circuit_lookup_by_ifp (ifp, isis->init_circ_list); |
| 712 | c = isis_csm_state_change (ISIS_ENABLE, c, area); |
| 713 | c->interface = ifp; /* this is automatic */ |
| 714 | ifp->info = c; /* hardly related to the FSM */ |
| 715 | } |
| 716 | |
| 717 | if(!c) |
| 718 | return CMD_WARNING; |
| 719 | |
| 720 | c->ip_router = 1; |
| 721 | area->ip_circuits++; |
| 722 | circuit_update_nlpids (c); |
| 723 | |
| 724 | vty->node = INTERFACE_NODE; |
| 725 | |
| 726 | return CMD_SUCCESS; |
| 727 | } |
| 728 | |
| 729 | DEFUN (no_ip_router_isis, |
| 730 | no_ip_router_isis_cmd, |
| 731 | "no ip router isis WORD", |
| 732 | NO_STR |
| 733 | "Interface Internet Protocol config commands\n" |
| 734 | "IP router interface commands\n" |
| 735 | "IS-IS Routing for IP\n" |
| 736 | "Routing process tag\n" |
| 737 | ) |
| 738 | { |
| 739 | struct isis_circuit *circuit = NULL; |
| 740 | struct interface *ifp; |
| 741 | struct isis_area *area; |
| 742 | struct listnode *node; |
| 743 | |
| 744 | ifp = (struct interface *)vty->index; |
| 745 | assert (ifp); |
| 746 | |
| 747 | area = isis_area_lookup (argv[0]); |
| 748 | if (!area) { |
| 749 | vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); |
| 750 | return CMD_WARNING; |
| 751 | } |
| 752 | LIST_LOOP (area->circuit_list, circuit, node) |
| 753 | if (circuit->interface == ifp) |
| 754 | break; |
| 755 | if (!circuit) { |
| 756 | vty_out (vty, "Can't find ISIS interface %s", VTY_NEWLINE); |
| 757 | return CMD_WARNING; |
| 758 | } |
| 759 | circuit->ip_router = 0; |
| 760 | area->ip_circuits--; |
| 761 | #ifdef HAVE_IPV6 |
| 762 | if (circuit->ipv6_router == 0) |
| 763 | #endif |
| 764 | isis_csm_state_change (ISIS_DISABLE, circuit, area); |
| 765 | |
| 766 | return CMD_SUCCESS; |
| 767 | } |
| 768 | |
| 769 | DEFUN (isis_circuit_type, |
| 770 | isis_circuit_type_cmd, |
| 771 | "isis circuit-type (level-1|level-1-2|level-2-only)", |
| 772 | "IS-IS commands\n" |
| 773 | "Configure circuit type for interface\n" |
| 774 | "Level-1 only adjacencies are formed\n" |
| 775 | "Level-1-2 adjacencies are formed\n" |
| 776 | "Level-2 only adjacencies are formed\n" |
| 777 | ) |
| 778 | { |
| 779 | struct isis_circuit *circuit; |
| 780 | struct interface *ifp; |
| 781 | int circuit_t; |
| 782 | int is_type; |
| 783 | |
| 784 | ifp = vty->index; |
| 785 | circuit = ifp->info; |
| 786 | /* UGLY - will remove l8r */ |
| 787 | if (circuit == NULL) { |
| 788 | return CMD_WARNING; |
| 789 | } |
| 790 | |
| 791 | assert (circuit); |
| 792 | |
| 793 | circuit_t = string2circuit_t (argv[0]); |
| 794 | |
| 795 | if (!circuit_t) { |
| 796 | vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE); |
| 797 | return CMD_SUCCESS; |
| 798 | } |
| 799 | |
| 800 | is_type = circuit->area->is_type; |
| 801 | if (is_type == IS_LEVEL_1_AND_2 || is_type == circuit_t) |
| 802 | isis_event_circuit_type_change (circuit, circuit_t); |
| 803 | else { |
| 804 | vty_out (vty, "invalid circuit level for area %s.%s", |
| 805 | circuit->area->area_tag, VTY_NEWLINE); |
| 806 | } |
| 807 | |
| 808 | return CMD_SUCCESS; |
| 809 | } |
| 810 | |
| 811 | DEFUN (no_isis_circuit_type, |
| 812 | no_isis_circuit_type_cmd, |
| 813 | "no isis circuit-type (level-1|level-1-2|level-2-only)", |
| 814 | NO_STR |
| 815 | "IS-IS commands\n" |
| 816 | "Configure circuit type for interface\n" |
| 817 | "Level-1 only adjacencies are formed\n" |
| 818 | "Level-1-2 adjacencies are formed\n" |
| 819 | "Level-2 only adjacencies are formed\n" |
| 820 | ) |
| 821 | { |
| 822 | struct isis_circuit *circuit; |
| 823 | struct interface *ifp; |
| 824 | |
| 825 | ifp = vty->index; |
| 826 | circuit = ifp->info; |
| 827 | if (circuit == NULL) { |
| 828 | return CMD_WARNING; |
| 829 | } |
| 830 | |
| 831 | assert(circuit); |
| 832 | |
| 833 | /* |
| 834 | * Set the circuits level to its default value which is that of the area |
| 835 | */ |
| 836 | isis_event_circuit_type_change (circuit, circuit->area->is_type); |
| 837 | |
| 838 | return CMD_SUCCESS; |
| 839 | } |
| 840 | |
| 841 | DEFUN (isis_passwd, |
| 842 | isis_passwd_cmd, |
| 843 | "isis password WORD", |
| 844 | "IS-IS commands\n" |
| 845 | "Configure the authentication password for interface\n" |
| 846 | "Password\n") |
| 847 | { |
| 848 | struct isis_circuit *circuit; |
| 849 | struct interface *ifp; |
| 850 | int len; |
| 851 | |
| 852 | ifp = vty->index; |
| 853 | circuit = ifp->info; |
| 854 | if (circuit == NULL) { |
| 855 | return CMD_WARNING; |
| 856 | } |
| 857 | |
| 858 | len = strlen (argv[0]); |
| 859 | if (len > 254) { |
| 860 | vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE); |
| 861 | return CMD_WARNING; |
| 862 | } |
| 863 | circuit->passwd.len = len; |
| 864 | circuit->passwd.type = ISIS_PASSWD_TYPE_CLEARTXT; |
| 865 | strncpy (circuit->passwd.passwd, argv[0], 255); |
| 866 | |
| 867 | return CMD_SUCCESS; |
| 868 | } |
| 869 | |
| 870 | DEFUN (no_isis_passwd, |
| 871 | no_isis_passwd_cmd, |
| 872 | "no isis password", |
| 873 | NO_STR |
| 874 | "IS-IS commands\n" |
| 875 | "Configure the authentication password for interface\n") |
| 876 | { |
| 877 | struct isis_circuit *circuit; |
| 878 | struct interface *ifp; |
| 879 | |
| 880 | ifp = vty->index; |
| 881 | circuit = ifp->info; |
| 882 | if (circuit == NULL) { |
| 883 | return CMD_WARNING; |
| 884 | } |
| 885 | |
| 886 | memset (&circuit->passwd, 0, sizeof (struct isis_passwd)); |
| 887 | |
| 888 | return CMD_SUCCESS; |
| 889 | } |
| 890 | |
| 891 | |
| 892 | DEFUN (isis_priority, |
| 893 | isis_priority_cmd, |
| 894 | "isis priority <0-127>", |
| 895 | "IS-IS commands\n" |
| 896 | "Set priority for Designated Router election\n" |
| 897 | "Priority value\n" |
| 898 | ) |
| 899 | { |
| 900 | struct isis_circuit *circuit; |
| 901 | struct interface *ifp; |
| 902 | int prio; |
| 903 | |
| 904 | ifp = vty->index; |
| 905 | circuit = ifp->info; |
| 906 | if (circuit == NULL) { |
| 907 | return CMD_WARNING; |
| 908 | } |
| 909 | assert (circuit); |
| 910 | |
| 911 | prio = atoi (argv[0]); |
| 912 | |
| 913 | circuit->u.bc.priority[0] = prio; |
| 914 | circuit->u.bc.priority[1] = prio; |
| 915 | |
| 916 | return CMD_SUCCESS; |
| 917 | } |
| 918 | |
| 919 | DEFUN (no_isis_priority, |
| 920 | no_isis_priority_cmd, |
| 921 | "no isis priority", |
| 922 | NO_STR |
| 923 | "IS-IS commands\n" |
| 924 | "Set priority for Designated Router election\n" |
| 925 | ) |
| 926 | { |
| 927 | struct isis_circuit *circuit; |
| 928 | struct interface *ifp; |
| 929 | |
| 930 | ifp = vty->index; |
| 931 | circuit = ifp->info; |
| 932 | if (circuit == NULL) { |
| 933 | return CMD_WARNING; |
| 934 | } |
| 935 | assert (circuit); |
| 936 | |
| 937 | circuit->u.bc.priority[0] = DEFAULT_PRIORITY; |
| 938 | circuit->u.bc.priority[1] = DEFAULT_PRIORITY; |
| 939 | |
| 940 | return CMD_SUCCESS; |
| 941 | } |
| 942 | |
| 943 | ALIAS (no_isis_priority, |
| 944 | no_isis_priority_arg_cmd, |
| 945 | "no isis priority <0-127>", |
| 946 | NO_STR |
| 947 | "IS-IS commands\n" |
| 948 | "Set priority for Designated Router election\n" |
| 949 | "Priority value\n" |
| 950 | ) |
| 951 | |
| 952 | DEFUN (isis_priority_l1, |
| 953 | isis_priority_l1_cmd, |
| 954 | "isis priority <0-127> level-1", |
| 955 | "IS-IS commands\n" |
| 956 | "Set priority for Designated Router election\n" |
| 957 | "Priority value\n" |
| 958 | "Specify priority for level-1 routing\n" |
| 959 | ) |
| 960 | { |
| 961 | struct isis_circuit *circuit; |
| 962 | struct interface *ifp; |
| 963 | int prio; |
| 964 | |
| 965 | ifp = vty->index; |
| 966 | circuit = ifp->info; |
| 967 | if (circuit == NULL) { |
| 968 | return CMD_WARNING; |
| 969 | } |
| 970 | assert (circuit); |
| 971 | |
| 972 | prio = atoi (argv[0]); |
| 973 | |
| 974 | circuit->u.bc.priority[0] = prio; |
| 975 | |
| 976 | return CMD_SUCCESS; |
| 977 | } |
| 978 | |
| 979 | DEFUN (no_isis_priority_l1, |
| 980 | no_isis_priority_l1_cmd, |
| 981 | "no isis priority level-1", |
| 982 | NO_STR |
| 983 | "IS-IS commands\n" |
| 984 | "Set priority for Designated Router election\n" |
| 985 | "Specify priority for level-1 routing\n" |
| 986 | ) |
| 987 | { |
| 988 | struct isis_circuit *circuit; |
| 989 | struct interface *ifp; |
| 990 | |
| 991 | ifp = vty->index; |
| 992 | circuit = ifp->info; |
| 993 | if (circuit == NULL) { |
| 994 | return CMD_WARNING; |
| 995 | } |
| 996 | assert (circuit); |
| 997 | |
| 998 | circuit->u.bc.priority[0] = DEFAULT_PRIORITY; |
| 999 | |
| 1000 | return CMD_SUCCESS; |
| 1001 | } |
| 1002 | |
| 1003 | ALIAS (no_isis_priority_l1, |
| 1004 | no_isis_priority_l1_arg_cmd, |
| 1005 | "no isis priority <0-127> level-1", |
| 1006 | NO_STR |
| 1007 | "IS-IS commands\n" |
| 1008 | "Set priority for Designated Router election\n" |
| 1009 | "Priority value\n" |
| 1010 | "Specify priority for level-1 routing\n" |
| 1011 | ) |
| 1012 | |
| 1013 | DEFUN (isis_priority_l2, |
| 1014 | isis_priority_l2_cmd, |
| 1015 | "isis priority <0-127> level-2", |
| 1016 | "IS-IS commands\n" |
| 1017 | "Set priority for Designated Router election\n" |
| 1018 | "Priority value\n" |
| 1019 | "Specify priority for level-2 routing\n" |
| 1020 | ) |
| 1021 | { |
| 1022 | struct isis_circuit *circuit; |
| 1023 | struct interface *ifp; |
| 1024 | int prio; |
| 1025 | |
| 1026 | ifp = vty->index; |
| 1027 | circuit = ifp->info; |
| 1028 | if (circuit == NULL) { |
| 1029 | return CMD_WARNING; |
| 1030 | } |
| 1031 | assert (circuit); |
| 1032 | |
| 1033 | prio = atoi (argv[0]); |
| 1034 | |
| 1035 | circuit->u.bc.priority[1] = prio; |
| 1036 | |
| 1037 | return CMD_SUCCESS; |
| 1038 | } |
| 1039 | |
| 1040 | DEFUN (no_isis_priority_l2, |
| 1041 | no_isis_priority_l2_cmd, |
| 1042 | "no isis priority level-2", |
| 1043 | NO_STR |
| 1044 | "IS-IS commands\n" |
| 1045 | "Set priority for Designated Router election\n" |
| 1046 | "Specify priority for level-2 routing\n" |
| 1047 | ) |
| 1048 | { |
| 1049 | struct isis_circuit *circuit; |
| 1050 | struct interface *ifp; |
| 1051 | |
| 1052 | ifp = vty->index; |
| 1053 | circuit = ifp->info; |
| 1054 | if (circuit == NULL) { |
| 1055 | return CMD_WARNING; |
| 1056 | } |
| 1057 | assert (circuit); |
| 1058 | |
| 1059 | circuit->u.bc.priority[1] = DEFAULT_PRIORITY; |
| 1060 | |
| 1061 | return CMD_SUCCESS; |
| 1062 | } |
| 1063 | |
| 1064 | ALIAS (no_isis_priority_l2, |
| 1065 | no_isis_priority_l2_arg_cmd, |
| 1066 | "no isis priority <0-127> level-2", |
| 1067 | NO_STR |
| 1068 | "IS-IS commands\n" |
| 1069 | "Set priority for Designated Router election\n" |
| 1070 | "Priority value\n" |
| 1071 | "Specify priority for level-2 routing\n" |
| 1072 | ) |
| 1073 | |
| 1074 | /* Metric command */ |
| 1075 | |
| 1076 | DEFUN (isis_metric, |
| 1077 | isis_metric_cmd, |
| 1078 | "isis metric <0-63>", |
| 1079 | "IS-IS commands\n" |
| 1080 | "Set default metric for circuit\n" |
| 1081 | "Default metric value\n" |
| 1082 | ) |
| 1083 | { |
| 1084 | struct isis_circuit *circuit; |
| 1085 | struct interface *ifp; |
| 1086 | int met; |
| 1087 | |
| 1088 | ifp = vty->index; |
| 1089 | circuit = ifp->info; |
| 1090 | if (circuit == NULL) { |
| 1091 | return CMD_WARNING; |
| 1092 | } |
| 1093 | assert (circuit); |
| 1094 | |
| 1095 | met = atoi (argv[0]); |
| 1096 | |
| 1097 | circuit->metrics[0].metric_default = met; |
| 1098 | circuit->metrics[1].metric_default = met; |
| 1099 | |
| 1100 | return CMD_SUCCESS; |
| 1101 | } |
| 1102 | |
| 1103 | DEFUN (no_isis_metric, |
| 1104 | no_isis_metric_cmd, |
| 1105 | "no isis metric", |
| 1106 | NO_STR |
| 1107 | "IS-IS commands\n" |
| 1108 | "Set default metric for circuit\n" |
| 1109 | ) |
| 1110 | { |
| 1111 | struct isis_circuit *circuit; |
| 1112 | struct interface *ifp; |
| 1113 | |
| 1114 | ifp = vty->index; |
| 1115 | circuit = ifp->info; |
| 1116 | if (circuit == NULL) { |
| 1117 | return CMD_WARNING; |
| 1118 | } |
| 1119 | assert (circuit); |
| 1120 | |
| 1121 | circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRICS; |
| 1122 | circuit->metrics[1].metric_default = DEFAULT_CIRCUIT_METRICS; |
| 1123 | |
| 1124 | return CMD_SUCCESS; |
| 1125 | } |
| 1126 | |
| 1127 | ALIAS (no_isis_metric, |
| 1128 | no_isis_metric_arg_cmd, |
| 1129 | "no isis metric <0-127>", |
| 1130 | NO_STR |
| 1131 | "IS-IS commands\n" |
| 1132 | "Set default metric for circuit\n" |
| 1133 | "Default metric value\n" |
| 1134 | ) |
| 1135 | /* end of metrics */ |
| 1136 | |
| 1137 | |
| 1138 | DEFUN (isis_hello_interval, |
| 1139 | isis_hello_interval_cmd, |
| 1140 | "isis hello-interval (<1-65535>|minimal)", |
| 1141 | "IS-IS commands\n" |
| 1142 | "Set Hello interval\n" |
| 1143 | "Hello interval value\n" |
| 1144 | "Holdtime 1 seconds, interval depends on multiplier\n" |
| 1145 | ) |
| 1146 | { |
| 1147 | struct isis_circuit *circuit; |
| 1148 | struct interface *ifp; |
| 1149 | int interval; |
| 1150 | char c; |
| 1151 | |
| 1152 | ifp = vty->index; |
| 1153 | circuit = ifp->info; |
| 1154 | if (circuit == NULL) { |
| 1155 | return CMD_WARNING; |
| 1156 | } |
| 1157 | assert (circuit); |
| 1158 | c = *argv[0]; |
| 1159 | if (isdigit((int)c)) { |
| 1160 | interval = atoi (argv[0]); |
| 1161 | } else |
| 1162 | interval = HELLO_MINIMAL; /* FIXME: should be calculated */ |
| 1163 | |
| 1164 | circuit->hello_interval[0] = (u_int16_t)interval; |
| 1165 | circuit->hello_interval[1] = (u_int16_t)interval; |
| 1166 | |
| 1167 | return CMD_SUCCESS; |
| 1168 | } |
| 1169 | |
| 1170 | DEFUN (no_isis_hello_interval, |
| 1171 | no_isis_hello_interval_cmd, |
| 1172 | "no isis hello-interval", |
| 1173 | NO_STR |
| 1174 | "IS-IS commands\n" |
| 1175 | "Set Hello interval\n" |
| 1176 | ) |
| 1177 | { |
| 1178 | struct isis_circuit *circuit; |
| 1179 | struct interface *ifp; |
| 1180 | |
| 1181 | ifp = vty->index; |
| 1182 | circuit = ifp->info; |
| 1183 | if (circuit == NULL) { |
| 1184 | return CMD_WARNING; |
| 1185 | } |
| 1186 | assert (circuit); |
| 1187 | |
| 1188 | |
| 1189 | circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */ |
| 1190 | circuit->hello_interval[1] = HELLO_INTERVAL; |
| 1191 | |
| 1192 | return CMD_SUCCESS; |
| 1193 | } |
| 1194 | |
| 1195 | ALIAS (no_isis_hello_interval, |
| 1196 | no_isis_hello_interval_arg_cmd, |
| 1197 | "no isis hello-interval (<1-65535>|minimal)", |
| 1198 | NO_STR |
| 1199 | "IS-IS commands\n" |
| 1200 | "Set Hello interval\n" |
| 1201 | "Hello interval value\n" |
| 1202 | "Holdtime 1 second, interval depends on multiplier\n" |
| 1203 | ) |
| 1204 | |
| 1205 | DEFUN (isis_hello_interval_l1, |
| 1206 | isis_hello_interval_l1_cmd, |
| 1207 | "isis hello-interval (<1-65535>|minimal) level-1", |
| 1208 | "IS-IS commands\n" |
| 1209 | "Set Hello interval\n" |
| 1210 | "Hello interval value\n" |
| 1211 | "Holdtime 1 second, interval depends on multiplier\n" |
| 1212 | "Specify hello-interval for level-1 IIHs\n" |
| 1213 | ) |
| 1214 | { |
| 1215 | struct isis_circuit *circuit; |
| 1216 | struct interface *ifp; |
| 1217 | long interval; |
| 1218 | char c; |
| 1219 | |
| 1220 | ifp = vty->index; |
| 1221 | circuit = ifp->info; |
| 1222 | if (circuit == NULL) { |
| 1223 | return CMD_WARNING; |
| 1224 | } |
| 1225 | assert (circuit); |
| 1226 | |
| 1227 | c = *argv[0]; |
| 1228 | if (isdigit((int)c)) { |
| 1229 | interval = atoi (argv[0]); |
| 1230 | } else |
| 1231 | interval = HELLO_MINIMAL; |
| 1232 | |
| 1233 | circuit->hello_interval[0] = (u_int16_t)interval; |
| 1234 | |
| 1235 | return CMD_SUCCESS; |
| 1236 | } |
| 1237 | |
| 1238 | DEFUN (no_isis_hello_interval_l1, |
| 1239 | no_isis_hello_interval_l1_cmd, |
| 1240 | "no isis hello-interval level-1", |
| 1241 | NO_STR |
| 1242 | "IS-IS commands\n" |
| 1243 | "Set Hello interval\n" |
| 1244 | "Specify hello-interval for level-1 IIHs\n" |
| 1245 | ) |
| 1246 | { |
| 1247 | struct isis_circuit *circuit; |
| 1248 | struct interface *ifp; |
| 1249 | |
| 1250 | ifp = vty->index; |
| 1251 | circuit = ifp->info; |
| 1252 | if (circuit == NULL) { |
| 1253 | return CMD_WARNING; |
| 1254 | } |
| 1255 | assert (circuit); |
| 1256 | |
| 1257 | |
| 1258 | circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */ |
| 1259 | |
| 1260 | return CMD_SUCCESS; |
| 1261 | } |
| 1262 | |
| 1263 | ALIAS (no_isis_hello_interval_l1, |
| 1264 | no_isis_hello_interval_l1_arg_cmd, |
| 1265 | "no isis hello-interval (<1-65535>|minimal) level-1", |
| 1266 | NO_STR |
| 1267 | "IS-IS commands\n" |
| 1268 | "Set Hello interval\n" |
| 1269 | "Hello interval value\n" |
| 1270 | "Holdtime 1 second, interval depends on multiplier\n" |
| 1271 | "Specify hello-interval for level-1 IIHs\n" |
| 1272 | ) |
| 1273 | |
| 1274 | DEFUN (isis_hello_interval_l2, |
| 1275 | isis_hello_interval_l2_cmd, |
| 1276 | "isis hello-interval (<1-65535>|minimal) level-2", |
| 1277 | "IS-IS commands\n" |
| 1278 | "Set Hello interval\n" |
| 1279 | "Hello interval value\n" |
| 1280 | "Holdtime 1 second, interval depends on multiplier\n" |
| 1281 | "Specify hello-interval for level-2 IIHs\n" |
| 1282 | ) |
| 1283 | { |
| 1284 | struct isis_circuit *circuit; |
| 1285 | struct interface *ifp; |
| 1286 | long interval; |
| 1287 | char c; |
| 1288 | |
| 1289 | ifp = vty->index; |
| 1290 | circuit = ifp->info; |
| 1291 | if (circuit == NULL) { |
| 1292 | return CMD_WARNING; |
| 1293 | } |
| 1294 | assert (circuit); |
| 1295 | |
| 1296 | c = *argv[0]; |
| 1297 | if (isdigit((int)c)) { |
| 1298 | interval = atoi (argv[0]); |
| 1299 | } else |
| 1300 | interval = HELLO_MINIMAL; |
| 1301 | |
| 1302 | circuit->hello_interval[1] = (u_int16_t)interval; |
| 1303 | |
| 1304 | return CMD_SUCCESS; |
| 1305 | } |
| 1306 | |
| 1307 | DEFUN (no_isis_hello_interval_l2, |
| 1308 | no_isis_hello_interval_l2_cmd, |
| 1309 | "no isis hello-interval level-2", |
| 1310 | NO_STR |
| 1311 | "IS-IS commands\n" |
| 1312 | "Set Hello interval\n" |
| 1313 | "Specify hello-interval for level-2 IIHs\n" |
| 1314 | ) |
| 1315 | { |
| 1316 | struct isis_circuit *circuit; |
| 1317 | struct interface *ifp; |
| 1318 | |
| 1319 | ifp = vty->index; |
| 1320 | circuit = ifp->info; |
| 1321 | if (circuit == NULL) { |
| 1322 | return CMD_WARNING; |
| 1323 | } |
| 1324 | assert (circuit); |
| 1325 | |
| 1326 | |
| 1327 | circuit->hello_interval[1] = HELLO_INTERVAL; /* Default is 1 sec. */ |
| 1328 | |
| 1329 | return CMD_SUCCESS; |
| 1330 | } |
| 1331 | |
| 1332 | ALIAS (no_isis_hello_interval_l2, |
| 1333 | no_isis_hello_interval_l2_arg_cmd, |
| 1334 | "no isis hello-interval (<1-65535>|minimal) level-2", |
| 1335 | NO_STR |
| 1336 | "IS-IS commands\n" |
| 1337 | "Set Hello interval\n" |
| 1338 | "Hello interval value\n" |
| 1339 | "Holdtime 1 second, interval depends on multiplier\n" |
| 1340 | "Specify hello-interval for level-2 IIHs\n" |
| 1341 | ) |
| 1342 | |
| 1343 | |
| 1344 | DEFUN (isis_hello_multiplier, |
| 1345 | isis_hello_multiplier_cmd, |
| 1346 | "isis hello-multiplier <3-1000>", |
| 1347 | "IS-IS commands\n" |
| 1348 | "Set multiplier for Hello holding time\n" |
| 1349 | "Hello multiplier value\n" |
| 1350 | ) |
| 1351 | { |
| 1352 | struct isis_circuit *circuit; |
| 1353 | struct interface *ifp; |
| 1354 | int mult; |
| 1355 | |
| 1356 | ifp = vty->index; |
| 1357 | circuit = ifp->info; |
| 1358 | if (circuit == NULL) { |
| 1359 | return CMD_WARNING; |
| 1360 | } |
| 1361 | assert (circuit); |
| 1362 | |
| 1363 | mult = atoi (argv[0]); |
| 1364 | |
| 1365 | circuit->hello_multiplier[0] = (u_int16_t)mult; |
| 1366 | circuit->hello_multiplier[1] = (u_int16_t)mult; |
| 1367 | |
| 1368 | return CMD_SUCCESS; |
| 1369 | } |
| 1370 | |
| 1371 | DEFUN (no_isis_hello_multiplier, |
| 1372 | no_isis_hello_multiplier_cmd, |
| 1373 | "no isis hello-multiplier", |
| 1374 | NO_STR |
| 1375 | "IS-IS commands\n" |
| 1376 | "Set multiplier for Hello holding time\n" |
| 1377 | ) |
| 1378 | { |
| 1379 | struct isis_circuit *circuit; |
| 1380 | struct interface *ifp; |
| 1381 | |
| 1382 | ifp = vty->index; |
| 1383 | circuit = ifp->info; |
| 1384 | if (circuit == NULL) { |
| 1385 | return CMD_WARNING; |
| 1386 | } |
| 1387 | assert (circuit); |
| 1388 | |
| 1389 | circuit->hello_multiplier[0] = HELLO_MULTIPLIER; |
| 1390 | circuit->hello_multiplier[1] = HELLO_MULTIPLIER; |
| 1391 | |
| 1392 | return CMD_SUCCESS; |
| 1393 | } |
| 1394 | |
| 1395 | ALIAS (no_isis_hello_multiplier, |
| 1396 | no_isis_hello_multiplier_arg_cmd, |
| 1397 | "no isis hello-multiplier <3-1000>", |
| 1398 | NO_STR |
| 1399 | "IS-IS commands\n" |
| 1400 | "Set multiplier for Hello holding time\n" |
| 1401 | "Hello multiplier value\n" |
| 1402 | ) |
| 1403 | |
| 1404 | DEFUN (isis_hello_multiplier_l1, |
| 1405 | isis_hello_multiplier_l1_cmd, |
| 1406 | "isis hello-multiplier <3-1000> level-1", |
| 1407 | "IS-IS commands\n" |
| 1408 | "Set multiplier for Hello holding time\n" |
| 1409 | "Hello multiplier value\n" |
| 1410 | "Specify hello multiplier for level-1 IIHs\n" |
| 1411 | ) |
| 1412 | { |
| 1413 | struct isis_circuit *circuit; |
| 1414 | struct interface *ifp; |
| 1415 | int mult; |
| 1416 | |
| 1417 | ifp = vty->index; |
| 1418 | circuit = ifp->info; |
| 1419 | if (circuit == NULL) { |
| 1420 | return CMD_WARNING; |
| 1421 | } |
| 1422 | assert (circuit); |
| 1423 | |
| 1424 | mult = atoi (argv[0]); |
| 1425 | |
| 1426 | circuit->hello_multiplier[0] = (u_int16_t)mult; |
| 1427 | |
| 1428 | return CMD_SUCCESS; |
| 1429 | } |
| 1430 | |
| 1431 | DEFUN (no_isis_hello_multiplier_l1, |
| 1432 | no_isis_hello_multiplier_l1_cmd, |
| 1433 | "no isis hello-multiplier level-1", |
| 1434 | NO_STR |
| 1435 | "IS-IS commands\n" |
| 1436 | "Set multiplier for Hello holding time\n" |
| 1437 | "Specify hello multiplier for level-1 IIHs\n" |
| 1438 | ) |
| 1439 | { |
| 1440 | struct isis_circuit *circuit; |
| 1441 | struct interface *ifp; |
| 1442 | |
| 1443 | ifp = vty->index; |
| 1444 | circuit = ifp->info; |
| 1445 | if (circuit == NULL) { |
| 1446 | return CMD_WARNING; |
| 1447 | } |
| 1448 | assert (circuit); |
| 1449 | |
| 1450 | circuit->hello_multiplier[0] = HELLO_MULTIPLIER; |
| 1451 | |
| 1452 | return CMD_SUCCESS; |
| 1453 | } |
| 1454 | |
| 1455 | ALIAS (no_isis_hello_multiplier_l1, |
| 1456 | no_isis_hello_multiplier_l1_arg_cmd, |
| 1457 | "no isis hello-multiplier <3-1000> level-1", |
| 1458 | NO_STR |
| 1459 | "IS-IS commands\n" |
| 1460 | "Set multiplier for Hello holding time\n" |
| 1461 | "Hello multiplier value\n" |
| 1462 | "Specify hello multiplier for level-1 IIHs\n" |
| 1463 | ) |
| 1464 | |
| 1465 | DEFUN (isis_hello_multiplier_l2, |
| 1466 | isis_hello_multiplier_l2_cmd, |
| 1467 | "isis hello-multiplier <3-1000> level-2", |
| 1468 | "IS-IS commands\n" |
| 1469 | "Set multiplier for Hello holding time\n" |
| 1470 | "Hello multiplier value\n" |
| 1471 | "Specify hello multiplier for level-2 IIHs\n" |
| 1472 | ) |
| 1473 | { |
| 1474 | struct isis_circuit *circuit; |
| 1475 | struct interface *ifp; |
| 1476 | int mult; |
| 1477 | |
| 1478 | ifp = vty->index; |
| 1479 | circuit = ifp->info; |
| 1480 | if (circuit == NULL) { |
| 1481 | return CMD_WARNING; |
| 1482 | } |
| 1483 | assert (circuit); |
| 1484 | |
| 1485 | mult = atoi (argv[0]); |
| 1486 | |
| 1487 | circuit->hello_multiplier[1] = (u_int16_t)mult; |
| 1488 | |
| 1489 | return CMD_SUCCESS; |
| 1490 | } |
| 1491 | |
| 1492 | DEFUN (no_isis_hello_multiplier_l2, |
| 1493 | no_isis_hello_multiplier_l2_cmd, |
| 1494 | "no isis hello-multiplier level-2", |
| 1495 | NO_STR |
| 1496 | "IS-IS commands\n" |
| 1497 | "Set multiplier for Hello holding time\n" |
| 1498 | "Specify hello multiplier for level-2 IIHs\n" |
| 1499 | ) |
| 1500 | { |
| 1501 | struct isis_circuit *circuit; |
| 1502 | struct interface *ifp; |
| 1503 | |
| 1504 | ifp = vty->index; |
| 1505 | circuit = ifp->info; |
| 1506 | if (circuit == NULL) { |
| 1507 | return CMD_WARNING; |
| 1508 | } |
| 1509 | assert (circuit); |
| 1510 | |
| 1511 | circuit->hello_multiplier[1] = HELLO_MULTIPLIER; |
| 1512 | |
| 1513 | return CMD_SUCCESS; |
| 1514 | } |
| 1515 | |
| 1516 | ALIAS (no_isis_hello_multiplier_l2, |
| 1517 | no_isis_hello_multiplier_l2_arg_cmd, |
| 1518 | "no isis hello-multiplier <3-1000> level-2", |
| 1519 | NO_STR |
| 1520 | "IS-IS commands\n" |
| 1521 | "Set multiplier for Hello holding time\n" |
| 1522 | "Hello multiplier value\n" |
| 1523 | "Specify hello multiplier for level-2 IIHs\n" |
| 1524 | ) |
| 1525 | |
| 1526 | DEFUN (isis_hello, |
| 1527 | isis_hello_cmd, |
| 1528 | "isis hello padding", |
| 1529 | "IS-IS commands\n" |
| 1530 | "Add padding to IS-IS hello packets\n" |
| 1531 | "Pad hello packets\n" |
| 1532 | "<cr>\n") |
| 1533 | { |
| 1534 | struct interface *ifp; |
| 1535 | struct isis_circuit *circuit; |
| 1536 | |
| 1537 | ifp = vty->index; |
| 1538 | circuit = ifp->info; |
| 1539 | if (circuit == NULL) { |
| 1540 | return CMD_WARNING; |
| 1541 | } |
| 1542 | assert (circuit); |
| 1543 | |
| 1544 | circuit->u.bc.pad_hellos = 1; |
| 1545 | |
| 1546 | return CMD_SUCCESS; |
| 1547 | } |
| 1548 | |
| 1549 | DEFUN (ip_address, |
| 1550 | ip_address_cmd, |
| 1551 | "ip address A.B.C.D/A", |
| 1552 | "Interface Internet Protocol config commands\n" |
| 1553 | "Set the IP address of an interface\n" |
| 1554 | "IP address (e.g. 10.0.0.1/8\n") |
| 1555 | |
| 1556 | { |
| 1557 | struct interface *ifp; |
| 1558 | struct isis_circuit *circuit; |
| 1559 | struct prefix_ipv4 *ipv4, *ip; |
| 1560 | struct listnode *node; |
| 1561 | int ret, found = 1; |
| 1562 | |
| 1563 | ifp = vty->index; |
| 1564 | circuit = ifp->info; |
| 1565 | if (circuit == NULL) { |
| 1566 | return CMD_WARNING; |
| 1567 | } |
| 1568 | |
| 1569 | assert (circuit); |
| 1570 | #ifdef HAVE_IPV6 |
| 1571 | zlog_info ("ip_address_cmd circuit %d", circuit->interface->ifindex); |
| 1572 | #endif /* HAVE_IPV6 */ |
| 1573 | |
| 1574 | ipv4 = prefix_ipv4_new (); |
| 1575 | |
| 1576 | ret = str2prefix_ipv4 (argv[0], ipv4); |
| 1577 | if (ret <= 0) { |
| 1578 | zlog_warn ("ip_address_cmd(): malformed address"); |
| 1579 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); |
| 1580 | return CMD_WARNING; |
| 1581 | } |
| 1582 | |
| 1583 | if (!circuit->ip_addrs) |
| 1584 | circuit->ip_addrs = list_new (); |
| 1585 | else { |
| 1586 | for (node = listhead (circuit->ip_addrs); node; nextnode (node)) { |
| 1587 | ip = getdata (node); |
| 1588 | if (prefix_same ((struct prefix *)ip, (struct prefix *)ipv4)) |
| 1589 | found = 1; |
| 1590 | } |
| 1591 | if (found) { |
| 1592 | prefix_ipv4_free (ipv4); |
| 1593 | return CMD_SUCCESS; |
| 1594 | } |
| 1595 | } |
| 1596 | |
| 1597 | |
| 1598 | listnode_add (circuit->ip_addrs, ipv4); |
| 1599 | #ifdef EXTREME_DEBUG |
| 1600 | zlog_info ("added IP address %s to circuit %d", argv[0], |
| 1601 | circuit->interface->ifindex); |
| 1602 | #endif /* EXTREME_DEBUG */ |
| 1603 | return CMD_SUCCESS; |
| 1604 | } |
| 1605 | |
| 1606 | DEFUN (no_ip_address, |
| 1607 | no_ip_address_cmd, |
| 1608 | "no ip address A.B.C.D/A", |
| 1609 | NO_STR |
| 1610 | "Interface Internet Protocol config commands\n" |
| 1611 | "Set the IP address of an interface\n" |
| 1612 | "IP address (e.g. 10.0.0.1/8\n") |
| 1613 | { |
| 1614 | struct interface *ifp; |
| 1615 | struct isis_circuit *circuit; |
| 1616 | struct prefix_ipv4 ipv4, *ip = NULL; |
| 1617 | struct listnode *node; |
| 1618 | int ret; |
| 1619 | |
| 1620 | ifp = vty->index; |
| 1621 | circuit = ifp->info; |
| 1622 | /* UGLY - will remove l8r */ |
| 1623 | if (circuit == NULL) { |
| 1624 | return CMD_WARNING; |
| 1625 | } |
| 1626 | assert (circuit); |
| 1627 | |
| 1628 | if (!circuit->ip_addrs || circuit->ip_addrs->count == 0) { |
| 1629 | vty_out (vty, "Invalid address %s", VTY_NEWLINE); |
| 1630 | return CMD_WARNING; |
| 1631 | } |
| 1632 | ret = str2prefix_ipv4 (argv[0], &ipv4); |
| 1633 | if (ret <= 0) { |
| 1634 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); |
| 1635 | return CMD_WARNING; |
| 1636 | } |
| 1637 | |
| 1638 | for (node = listhead (circuit->ip_addrs); node; nextnode (node)) { |
| 1639 | ip = getdata (node); |
| 1640 | if (prefix_same ((struct prefix *)ip, (struct prefix *)&ipv4)) |
| 1641 | break; |
| 1642 | } |
| 1643 | |
| 1644 | if (ip) { |
| 1645 | listnode_delete (circuit->ip_addrs, ip); |
| 1646 | } else { |
| 1647 | vty_out (vty, "Invalid address %s", VTY_NEWLINE); |
| 1648 | } |
| 1649 | |
| 1650 | return CMD_SUCCESS; |
| 1651 | } |
| 1652 | |
| 1653 | DEFUN (no_isis_hello, |
| 1654 | no_isis_hello_cmd, |
| 1655 | "no isis hello padding", |
| 1656 | NO_STR |
| 1657 | "IS-IS commands\n" |
| 1658 | "Add padding to IS-IS hello packets\n" |
| 1659 | "Pad hello packets\n" |
| 1660 | "<cr>\n") |
| 1661 | { |
| 1662 | struct isis_circuit *circuit; |
| 1663 | struct interface *ifp; |
| 1664 | |
| 1665 | ifp = vty->index; |
| 1666 | circuit = ifp->info; |
| 1667 | if (circuit == NULL) { |
| 1668 | return CMD_WARNING; |
| 1669 | } |
| 1670 | assert (circuit); |
| 1671 | |
| 1672 | circuit->u.bc.pad_hellos = 0; |
| 1673 | |
| 1674 | return CMD_SUCCESS; |
| 1675 | } |
| 1676 | |
| 1677 | DEFUN (csnp_interval, |
| 1678 | csnp_interval_cmd, |
| 1679 | "isis csnp-interval <0-65535>", |
| 1680 | "IS-IS commands\n" |
| 1681 | "Set CSNP interval in seconds\n" |
| 1682 | "CSNP interval value\n") |
| 1683 | { |
| 1684 | struct isis_circuit *circuit; |
| 1685 | struct interface *ifp; |
| 1686 | unsigned long interval; |
| 1687 | |
| 1688 | ifp = vty->index; |
| 1689 | circuit = ifp->info; |
| 1690 | if (circuit == NULL) { |
| 1691 | return CMD_WARNING; |
| 1692 | } |
| 1693 | assert (circuit); |
| 1694 | |
| 1695 | interval = atol (argv[0]); |
| 1696 | |
| 1697 | circuit->csnp_interval[0] = (u_int16_t)interval; |
| 1698 | circuit->csnp_interval[1] = (u_int16_t)interval; |
| 1699 | |
| 1700 | return CMD_SUCCESS; |
| 1701 | } |
| 1702 | |
| 1703 | DEFUN (no_csnp_interval, |
| 1704 | no_csnp_interval_cmd, |
| 1705 | "no isis csnp-interval", |
| 1706 | NO_STR |
| 1707 | "IS-IS commands\n" |
| 1708 | "Set CSNP interval in seconds\n" |
| 1709 | ) |
| 1710 | { |
| 1711 | struct isis_circuit *circuit; |
| 1712 | struct interface *ifp; |
| 1713 | |
| 1714 | ifp = vty->index; |
| 1715 | circuit = ifp->info; |
| 1716 | if (circuit == NULL) { |
| 1717 | return CMD_WARNING; |
| 1718 | } |
| 1719 | assert (circuit); |
| 1720 | |
| 1721 | circuit->csnp_interval[0] = CSNP_INTERVAL; |
| 1722 | circuit->csnp_interval[1] = CSNP_INTERVAL; |
| 1723 | |
| 1724 | return CMD_SUCCESS; |
| 1725 | } |
| 1726 | |
| 1727 | ALIAS (no_csnp_interval, |
| 1728 | no_csnp_interval_arg_cmd, |
| 1729 | "no isis csnp-interval <0-65535>", |
| 1730 | NO_STR |
| 1731 | "IS-IS commands\n" |
| 1732 | "Set CSNP interval in seconds\n" |
| 1733 | "CSNP interval value\n") |
| 1734 | |
| 1735 | |
| 1736 | DEFUN (csnp_interval_l1, |
| 1737 | csnp_interval_l1_cmd, |
| 1738 | "isis csnp-interval <0-65535> level-1", |
| 1739 | "IS-IS commands\n" |
| 1740 | "Set CSNP interval in seconds\n" |
| 1741 | "CSNP interval value\n" |
| 1742 | "Specify interval for level-1 CSNPs\n") |
| 1743 | { |
| 1744 | struct isis_circuit *circuit; |
| 1745 | struct interface *ifp; |
| 1746 | unsigned long interval; |
| 1747 | |
| 1748 | ifp = vty->index; |
| 1749 | circuit = ifp->info; |
| 1750 | if (circuit == NULL) { |
| 1751 | return CMD_WARNING; |
| 1752 | } |
| 1753 | assert (circuit); |
| 1754 | |
| 1755 | interval = atol (argv[0]); |
| 1756 | |
| 1757 | circuit->csnp_interval[0] = (u_int16_t)interval; |
| 1758 | |
| 1759 | return CMD_SUCCESS; |
| 1760 | } |
| 1761 | |
| 1762 | DEFUN (no_csnp_interval_l1, |
| 1763 | no_csnp_interval_l1_cmd, |
| 1764 | "no isis csnp-interval level-1", |
| 1765 | NO_STR |
| 1766 | "IS-IS commands\n" |
| 1767 | "Set CSNP interval in seconds\n" |
| 1768 | "Specify interval for level-1 CSNPs\n") |
| 1769 | { |
| 1770 | struct isis_circuit *circuit; |
| 1771 | struct interface *ifp; |
| 1772 | |
| 1773 | ifp = vty->index; |
| 1774 | circuit = ifp->info; |
| 1775 | if (circuit == NULL) { |
| 1776 | return CMD_WARNING; |
| 1777 | } |
| 1778 | assert (circuit); |
| 1779 | |
| 1780 | circuit->csnp_interval[0] = CSNP_INTERVAL; |
| 1781 | |
| 1782 | return CMD_SUCCESS; |
| 1783 | } |
| 1784 | |
| 1785 | ALIAS (no_csnp_interval_l1, |
| 1786 | no_csnp_interval_l1_arg_cmd, |
| 1787 | "no isis csnp-interval <0-65535> level-1", |
| 1788 | NO_STR |
| 1789 | "IS-IS commands\n" |
| 1790 | "Set CSNP interval in seconds\n" |
| 1791 | "CSNP interval value\n" |
| 1792 | "Specify interval for level-1 CSNPs\n") |
| 1793 | |
| 1794 | |
| 1795 | DEFUN (csnp_interval_l2, |
| 1796 | csnp_interval_l2_cmd, |
| 1797 | "isis csnp-interval <0-65535> level-2", |
| 1798 | "IS-IS commands\n" |
| 1799 | "Set CSNP interval in seconds\n" |
| 1800 | "CSNP interval value\n" |
| 1801 | "Specify interval for level-2 CSNPs\n") |
| 1802 | { |
| 1803 | struct isis_circuit *circuit; |
| 1804 | struct interface *ifp; |
| 1805 | unsigned long interval; |
| 1806 | |
| 1807 | ifp = vty->index; |
| 1808 | circuit = ifp->info; |
| 1809 | if (circuit == NULL) { |
| 1810 | return CMD_WARNING; |
| 1811 | } |
| 1812 | assert (circuit); |
| 1813 | |
| 1814 | interval = atol (argv[0]); |
| 1815 | |
| 1816 | circuit->csnp_interval[1] = (u_int16_t)interval; |
| 1817 | |
| 1818 | return CMD_SUCCESS; |
| 1819 | } |
| 1820 | |
| 1821 | DEFUN (no_csnp_interval_l2, |
| 1822 | no_csnp_interval_l2_cmd, |
| 1823 | "no isis csnp-interval level-2", |
| 1824 | NO_STR |
| 1825 | "IS-IS commands\n" |
| 1826 | "Set CSNP interval in seconds\n" |
| 1827 | "Specify interval for level-2 CSNPs\n") |
| 1828 | { |
| 1829 | struct isis_circuit *circuit; |
| 1830 | struct interface *ifp; |
| 1831 | |
| 1832 | ifp = vty->index; |
| 1833 | circuit = ifp->info; |
| 1834 | if (circuit == NULL) { |
| 1835 | return CMD_WARNING; |
| 1836 | } |
| 1837 | assert (circuit); |
| 1838 | |
| 1839 | circuit->csnp_interval[1] = CSNP_INTERVAL; |
| 1840 | |
| 1841 | return CMD_SUCCESS; |
| 1842 | } |
| 1843 | |
| 1844 | ALIAS (no_csnp_interval_l2, |
| 1845 | no_csnp_interval_l2_arg_cmd, |
| 1846 | "no isis csnp-interval <0-65535> level-2", |
| 1847 | NO_STR |
| 1848 | "IS-IS commands\n" |
| 1849 | "Set CSNP interval in seconds\n" |
| 1850 | "CSNP interval value\n" |
| 1851 | "Specify interval for level-2 CSNPs\n") |
| 1852 | |
| 1853 | |
| 1854 | #ifdef HAVE_IPV6 |
| 1855 | DEFUN (ipv6_router_isis, |
| 1856 | ipv6_router_isis_cmd, |
| 1857 | "ipv6 router isis WORD", |
| 1858 | "IPv6 interface subcommands\n" |
| 1859 | "IPv6 Router interface commands\n" |
| 1860 | "IS-IS Routing for IPv6\n" |
| 1861 | "Routing process tag\n") |
| 1862 | { |
| 1863 | struct isis_circuit *c; |
| 1864 | struct interface *ifp; |
| 1865 | struct isis_area *area; |
| 1866 | |
| 1867 | ifp = (struct interface *)vty->index; |
| 1868 | assert (ifp); |
| 1869 | |
| 1870 | area = isis_area_lookup (argv[0]); |
| 1871 | |
| 1872 | /* Prevent more than one circuit per interface */ |
| 1873 | if (area) |
| 1874 | c = circuit_lookup_by_ifp (ifp, area->circuit_list); |
| 1875 | else c = NULL; |
| 1876 | |
| 1877 | if (c && (ifp->info != NULL)) { |
| 1878 | if (c->ipv6_router == 1) { |
| 1879 | vty_out (vty, "ISIS circuit is already defined for IPv6%s", VTY_NEWLINE); |
| 1880 | return CMD_WARNING; |
| 1881 | } |
| 1882 | } |
| 1883 | |
| 1884 | /* this is here for ciscopability */ |
| 1885 | if (!area) { |
| 1886 | vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); |
| 1887 | return CMD_WARNING; |
| 1888 | } |
| 1889 | |
| 1890 | if (!c) { |
| 1891 | c = circuit_lookup_by_ifp (ifp, isis->init_circ_list); |
| 1892 | c = isis_csm_state_change (ISIS_ENABLE, c, area); |
| 1893 | c->interface = ifp; |
| 1894 | ifp->info = c; |
| 1895 | } |
| 1896 | |
| 1897 | if(!c) |
| 1898 | return CMD_WARNING; |
| 1899 | |
| 1900 | c->ipv6_router = 1; |
| 1901 | area->ipv6_circuits++; |
| 1902 | circuit_update_nlpids (c); |
| 1903 | |
| 1904 | vty->node = INTERFACE_NODE; |
| 1905 | |
| 1906 | return CMD_SUCCESS; |
| 1907 | } |
| 1908 | |
| 1909 | DEFUN (no_ipv6_router_isis, |
| 1910 | no_ipv6_router_isis_cmd, |
| 1911 | "no ipv6 router isis WORD", |
| 1912 | NO_STR |
| 1913 | "IPv6 interface subcommands\n" |
| 1914 | "IPv6 Router interface commands\n" |
| 1915 | "IS-IS Routing for IPv6\n" |
| 1916 | "Routing process tag\n") |
| 1917 | { |
| 1918 | struct isis_circuit *c; |
| 1919 | struct interface *ifp; |
| 1920 | struct isis_area *area; |
| 1921 | |
| 1922 | ifp = (struct interface *)vty->index; |
| 1923 | /* UGLY - will remove l8r |
| 1924 | if (circuit == NULL) { |
| 1925 | return CMD_WARNING; |
| 1926 | } */ |
| 1927 | assert (ifp); |
| 1928 | |
| 1929 | area = isis_area_lookup (argv[0]); |
| 1930 | if (!area) { |
| 1931 | vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); |
| 1932 | return CMD_WARNING; |
| 1933 | } |
| 1934 | |
| 1935 | c = circuit_lookup_by_ifp (ifp, area->circuit_list); |
| 1936 | if (!c) |
| 1937 | return CMD_WARNING; |
| 1938 | |
| 1939 | c->ipv6_router = 0; |
| 1940 | area->ipv6_circuits--; |
| 1941 | if (c->ip_router == 0) |
| 1942 | isis_csm_state_change (ISIS_DISABLE, c, area); |
| 1943 | |
| 1944 | return CMD_SUCCESS; |
| 1945 | } |
| 1946 | |
| 1947 | #if 0 /* Guess we don't really need these */ |
| 1948 | |
| 1949 | DEFUN (ipv6_address, |
| 1950 | ipv6_address_cmd, |
| 1951 | "ipv6 address X:X::X:X/M", |
| 1952 | "Interface Internet Protocol config commands\n" |
| 1953 | "Set the IP address of an interface\n" |
| 1954 | "IPv6 address (e.g. 3ffe:506::1/48)\n") |
| 1955 | { |
| 1956 | struct interface *ifp; |
| 1957 | struct isis_circuit *circuit; |
| 1958 | struct prefix_ipv6 *ipv6, *ip6; |
| 1959 | struct listnode *node; |
| 1960 | int ret, found = 1; |
| 1961 | |
| 1962 | ifp = vty->index; |
| 1963 | circuit = ifp->info; |
| 1964 | /* UGLY - will remove l8r */ |
| 1965 | if (circuit == NULL) { |
| 1966 | return CMD_WARNING; |
| 1967 | } |
| 1968 | assert (circuit); |
| 1969 | #ifdef EXTREME_DEBUG |
| 1970 | zlog_info ("ipv6_address_cmd circuit %d", circuit->idx); |
| 1971 | #endif /* EXTREME_DEBUG */ |
| 1972 | |
| 1973 | if (circuit == NULL) { |
| 1974 | zlog_warn ("ipv6_address_cmd(): no circuit"); |
| 1975 | return CMD_WARNING; |
| 1976 | } |
| 1977 | |
| 1978 | |
| 1979 | ipv6 = prefix_ipv6_new (); |
| 1980 | |
| 1981 | ret = str2prefix_ipv6 (argv[0], ipv6); |
| 1982 | if (ret <= 0) { |
| 1983 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); |
| 1984 | return CMD_WARNING; |
| 1985 | } |
| 1986 | |
| 1987 | if (!circuit->ipv6_addrs) |
| 1988 | circuit->ipv6_addrs = list_new (); |
| 1989 | else { |
| 1990 | for (node = listhead (circuit->ipv6_addrs); node; nextnode (node)) { |
| 1991 | ip6 = getdata (node); |
| 1992 | if (prefix_same ((struct prefix *)ip6, (struct prefix *)ipv6)) |
| 1993 | found = 1; |
| 1994 | } |
| 1995 | if (found) { |
| 1996 | prefix_ipv6_free (ipv6); |
| 1997 | return CMD_SUCCESS; |
| 1998 | } |
| 1999 | } |
| 2000 | |
| 2001 | |
| 2002 | listnode_add (circuit->ipv6_addrs, ipv6); |
| 2003 | #ifdef EXTREME_DEBUG |
| 2004 | zlog_info ("added IPv6 address %s to circuit %d", argv[0], circuit->idx); |
| 2005 | #endif /* EXTREME_DEBUG */ |
| 2006 | |
| 2007 | return CMD_SUCCESS; |
| 2008 | } |
| 2009 | |
| 2010 | DEFUN (no_ipv6_address, |
| 2011 | no_ipv6_address_cmd, |
| 2012 | "no ipv6 address X:X::X:X/M", |
| 2013 | NO_STR |
| 2014 | "Interface Internet Protocol config commands\n" |
| 2015 | "Set the IP address of an interface\n" |
| 2016 | "IPv6 address (e.g. 3ffe:506::1/48)\n") |
| 2017 | { |
| 2018 | struct interface *ifp; |
| 2019 | struct isis_circuit *circuit; |
| 2020 | struct prefix_ipv6 ipv6, *ip6 = NULL; |
| 2021 | struct listnode *node; |
| 2022 | int ret; |
| 2023 | |
| 2024 | ifp = vty->index; |
| 2025 | circuit = ifp->info; |
| 2026 | /* UGLY - will remove l8r */ |
| 2027 | if (circuit == NULL) { |
| 2028 | return CMD_WARNING; |
| 2029 | } |
| 2030 | assert (circuit); |
| 2031 | |
| 2032 | if (!circuit->ipv6_addrs || circuit->ipv6_addrs->count == 0) { |
| 2033 | vty_out (vty, "Invalid address %s", VTY_NEWLINE); |
| 2034 | return CMD_WARNING; |
| 2035 | } |
| 2036 | ret = str2prefix_ipv6 (argv[0], &ipv6); |
| 2037 | if (ret <= 0) { |
| 2038 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); |
| 2039 | return CMD_WARNING; |
| 2040 | } |
| 2041 | |
| 2042 | for (node = listhead (circuit->ipv6_addrs); node; nextnode (node)) { |
| 2043 | ip6 = getdata (node); |
| 2044 | if (prefix_same ((struct prefix *)ip6, (struct prefix *)&ipv6)) |
| 2045 | break; |
| 2046 | } |
| 2047 | |
| 2048 | if (ip6) { |
| 2049 | listnode_delete (circuit->ipv6_addrs, ip6); |
| 2050 | } else { |
| 2051 | vty_out (vty, "Invalid address %s", VTY_NEWLINE); |
| 2052 | } |
| 2053 | |
| 2054 | return CMD_SUCCESS; |
| 2055 | } |
| 2056 | #endif /* 0 */ |
| 2057 | #endif /* HAVE_IPV6 */ |
| 2058 | |
| 2059 | |
| 2060 | struct cmd_node interface_node = |
| 2061 | { |
| 2062 | INTERFACE_NODE, |
| 2063 | "%s(config-if)# ", |
| 2064 | 1, |
| 2065 | }; |
| 2066 | |
| 2067 | |
| 2068 | int |
| 2069 | isis_if_new_hook (struct interface *ifp) |
| 2070 | { |
| 2071 | /* FIXME: Discuss if the circuit should be created here |
| 2072 | ifp->info = XMALLOC (MTYPE_ISIS_IF_INFO, sizeof (struct isis_if_info)); */ |
| 2073 | ifp->info = NULL; |
| 2074 | return 0; |
| 2075 | } |
| 2076 | |
| 2077 | int |
| 2078 | isis_if_delete_hook (struct interface *ifp) |
| 2079 | { |
| 2080 | /* FIXME: Discuss if the circuit should be created here |
| 2081 | XFREE (MTYPE_ISIS_IF_INFO, ifp->info);*/ |
| 2082 | ifp->info = NULL; |
| 2083 | return 0; |
| 2084 | } |
| 2085 | |
| 2086 | |
| 2087 | void |
| 2088 | isis_circuit_init () |
| 2089 | { |
| 2090 | |
| 2091 | /* Initialize Zebra interface data structure */ |
| 2092 | if_init (); |
| 2093 | if_add_hook (IF_NEW_HOOK, isis_if_new_hook); |
| 2094 | if_add_hook (IF_DELETE_HOOK, isis_if_delete_hook); |
| 2095 | |
| 2096 | /* Install interface node */ |
| 2097 | install_node (&interface_node, isis_interface_config_write); |
| 2098 | install_element (CONFIG_NODE, &interface_cmd); |
| 2099 | |
| 2100 | install_default (INTERFACE_NODE); |
| 2101 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 2102 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 2103 | |
| 2104 | install_element (INTERFACE_NODE, &ip_router_isis_cmd); |
| 2105 | install_element (INTERFACE_NODE, &no_ip_router_isis_cmd); |
| 2106 | |
| 2107 | install_element (INTERFACE_NODE, &isis_circuit_type_cmd); |
| 2108 | install_element (INTERFACE_NODE, &no_isis_circuit_type_cmd); |
| 2109 | |
| 2110 | install_element (INTERFACE_NODE, &isis_passwd_cmd); |
| 2111 | install_element (INTERFACE_NODE, &no_isis_passwd_cmd); |
| 2112 | |
| 2113 | install_element (INTERFACE_NODE, &isis_priority_cmd); |
| 2114 | install_element (INTERFACE_NODE, &no_isis_priority_cmd); |
| 2115 | install_element (INTERFACE_NODE, &no_isis_priority_arg_cmd); |
| 2116 | install_element (INTERFACE_NODE, &isis_priority_l1_cmd); |
| 2117 | install_element (INTERFACE_NODE, &no_isis_priority_l1_cmd); |
| 2118 | install_element (INTERFACE_NODE, &no_isis_priority_l1_arg_cmd); |
| 2119 | install_element (INTERFACE_NODE, &isis_priority_l2_cmd); |
| 2120 | install_element (INTERFACE_NODE, &no_isis_priority_l2_cmd); |
| 2121 | install_element (INTERFACE_NODE, &no_isis_priority_l2_arg_cmd); |
| 2122 | |
| 2123 | install_element (INTERFACE_NODE, &isis_metric_cmd); |
| 2124 | install_element (INTERFACE_NODE, &no_isis_metric_cmd); |
| 2125 | install_element (INTERFACE_NODE, &no_isis_metric_arg_cmd); |
| 2126 | |
| 2127 | install_element (INTERFACE_NODE, &isis_hello_interval_cmd); |
| 2128 | install_element (INTERFACE_NODE, &no_isis_hello_interval_cmd); |
| 2129 | install_element (INTERFACE_NODE, &no_isis_hello_interval_arg_cmd); |
| 2130 | install_element (INTERFACE_NODE, &isis_hello_interval_l1_cmd); |
| 2131 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_cmd); |
| 2132 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_arg_cmd); |
| 2133 | install_element (INTERFACE_NODE, &isis_hello_interval_l2_cmd); |
| 2134 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_cmd); |
| 2135 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_arg_cmd); |
| 2136 | |
| 2137 | install_element (INTERFACE_NODE, &isis_hello_multiplier_cmd); |
| 2138 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_cmd); |
| 2139 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_arg_cmd); |
| 2140 | install_element (INTERFACE_NODE, &isis_hello_multiplier_l1_cmd); |
| 2141 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_cmd); |
| 2142 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_arg_cmd); |
| 2143 | install_element (INTERFACE_NODE, &isis_hello_multiplier_l2_cmd); |
| 2144 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_cmd); |
| 2145 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_arg_cmd); |
| 2146 | |
| 2147 | install_element (INTERFACE_NODE, &isis_hello_cmd); |
| 2148 | install_element (INTERFACE_NODE, &no_isis_hello_cmd); |
| 2149 | |
| 2150 | install_element (INTERFACE_NODE, &ip_address_cmd); |
| 2151 | install_element (INTERFACE_NODE, &no_ip_address_cmd); |
| 2152 | |
| 2153 | install_element (INTERFACE_NODE, &csnp_interval_cmd); |
| 2154 | install_element (INTERFACE_NODE, &no_csnp_interval_cmd); |
| 2155 | install_element (INTERFACE_NODE, &no_csnp_interval_arg_cmd); |
| 2156 | install_element (INTERFACE_NODE, &csnp_interval_l1_cmd); |
| 2157 | install_element (INTERFACE_NODE, &no_csnp_interval_l1_cmd); |
| 2158 | install_element (INTERFACE_NODE, &no_csnp_interval_l1_arg_cmd); |
| 2159 | install_element (INTERFACE_NODE, &csnp_interval_l2_cmd); |
| 2160 | install_element (INTERFACE_NODE, &no_csnp_interval_l2_cmd); |
| 2161 | install_element (INTERFACE_NODE, &no_csnp_interval_l2_arg_cmd); |
| 2162 | |
| 2163 | #ifdef HAVE_IPV6 |
| 2164 | install_element (INTERFACE_NODE, &ipv6_router_isis_cmd); |
| 2165 | install_element (INTERFACE_NODE, &no_ipv6_router_isis_cmd); |
| 2166 | #if 0 |
| 2167 | install_element (INTERFACE_NODE, &ipv6_address_cmd); |
| 2168 | install_element (INTERFACE_NODE, &no_ipv6_address_cmd); |
| 2169 | #endif |
| 2170 | #endif |
| 2171 | |
| 2172 | } |