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 | |
hasso | 54301ce | 2004-01-27 10:07:34 +0000 | [diff] [blame^] | 1549 | #if 0 |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1550 | DEFUN (ip_address, |
| 1551 | ip_address_cmd, |
| 1552 | "ip address A.B.C.D/A", |
| 1553 | "Interface Internet Protocol config commands\n" |
| 1554 | "Set the IP address of an interface\n" |
| 1555 | "IP address (e.g. 10.0.0.1/8\n") |
| 1556 | |
| 1557 | { |
| 1558 | struct interface *ifp; |
| 1559 | struct isis_circuit *circuit; |
| 1560 | struct prefix_ipv4 *ipv4, *ip; |
| 1561 | struct listnode *node; |
| 1562 | int ret, found = 1; |
| 1563 | |
| 1564 | ifp = vty->index; |
| 1565 | circuit = ifp->info; |
| 1566 | if (circuit == NULL) { |
| 1567 | return CMD_WARNING; |
| 1568 | } |
| 1569 | |
| 1570 | assert (circuit); |
| 1571 | #ifdef HAVE_IPV6 |
| 1572 | zlog_info ("ip_address_cmd circuit %d", circuit->interface->ifindex); |
| 1573 | #endif /* HAVE_IPV6 */ |
| 1574 | |
| 1575 | ipv4 = prefix_ipv4_new (); |
| 1576 | |
| 1577 | ret = str2prefix_ipv4 (argv[0], ipv4); |
| 1578 | if (ret <= 0) { |
| 1579 | zlog_warn ("ip_address_cmd(): malformed address"); |
| 1580 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); |
| 1581 | return CMD_WARNING; |
| 1582 | } |
| 1583 | |
| 1584 | if (!circuit->ip_addrs) |
| 1585 | circuit->ip_addrs = list_new (); |
| 1586 | else { |
| 1587 | for (node = listhead (circuit->ip_addrs); node; nextnode (node)) { |
| 1588 | ip = getdata (node); |
| 1589 | if (prefix_same ((struct prefix *)ip, (struct prefix *)ipv4)) |
| 1590 | found = 1; |
| 1591 | } |
| 1592 | if (found) { |
| 1593 | prefix_ipv4_free (ipv4); |
| 1594 | return CMD_SUCCESS; |
| 1595 | } |
| 1596 | } |
| 1597 | |
| 1598 | |
| 1599 | listnode_add (circuit->ip_addrs, ipv4); |
| 1600 | #ifdef EXTREME_DEBUG |
| 1601 | zlog_info ("added IP address %s to circuit %d", argv[0], |
| 1602 | circuit->interface->ifindex); |
| 1603 | #endif /* EXTREME_DEBUG */ |
| 1604 | return CMD_SUCCESS; |
| 1605 | } |
| 1606 | |
| 1607 | DEFUN (no_ip_address, |
| 1608 | no_ip_address_cmd, |
| 1609 | "no ip address A.B.C.D/A", |
| 1610 | NO_STR |
| 1611 | "Interface Internet Protocol config commands\n" |
| 1612 | "Set the IP address of an interface\n" |
| 1613 | "IP address (e.g. 10.0.0.1/8\n") |
| 1614 | { |
| 1615 | struct interface *ifp; |
| 1616 | struct isis_circuit *circuit; |
| 1617 | struct prefix_ipv4 ipv4, *ip = NULL; |
| 1618 | struct listnode *node; |
| 1619 | int ret; |
| 1620 | |
| 1621 | ifp = vty->index; |
| 1622 | circuit = ifp->info; |
| 1623 | /* UGLY - will remove l8r */ |
| 1624 | if (circuit == NULL) { |
| 1625 | return CMD_WARNING; |
| 1626 | } |
| 1627 | assert (circuit); |
| 1628 | |
| 1629 | if (!circuit->ip_addrs || circuit->ip_addrs->count == 0) { |
| 1630 | vty_out (vty, "Invalid address %s", VTY_NEWLINE); |
| 1631 | return CMD_WARNING; |
| 1632 | } |
| 1633 | ret = str2prefix_ipv4 (argv[0], &ipv4); |
| 1634 | if (ret <= 0) { |
| 1635 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); |
| 1636 | return CMD_WARNING; |
| 1637 | } |
| 1638 | |
| 1639 | for (node = listhead (circuit->ip_addrs); node; nextnode (node)) { |
| 1640 | ip = getdata (node); |
| 1641 | if (prefix_same ((struct prefix *)ip, (struct prefix *)&ipv4)) |
| 1642 | break; |
| 1643 | } |
| 1644 | |
| 1645 | if (ip) { |
| 1646 | listnode_delete (circuit->ip_addrs, ip); |
| 1647 | } else { |
| 1648 | vty_out (vty, "Invalid address %s", VTY_NEWLINE); |
| 1649 | } |
| 1650 | |
| 1651 | return CMD_SUCCESS; |
| 1652 | } |
hasso | 54301ce | 2004-01-27 10:07:34 +0000 | [diff] [blame^] | 1653 | #endif |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1654 | |
| 1655 | DEFUN (no_isis_hello, |
| 1656 | no_isis_hello_cmd, |
| 1657 | "no isis hello padding", |
| 1658 | NO_STR |
| 1659 | "IS-IS commands\n" |
| 1660 | "Add padding to IS-IS hello packets\n" |
| 1661 | "Pad hello packets\n" |
| 1662 | "<cr>\n") |
| 1663 | { |
| 1664 | struct isis_circuit *circuit; |
| 1665 | struct interface *ifp; |
| 1666 | |
| 1667 | ifp = vty->index; |
| 1668 | circuit = ifp->info; |
| 1669 | if (circuit == NULL) { |
| 1670 | return CMD_WARNING; |
| 1671 | } |
| 1672 | assert (circuit); |
| 1673 | |
| 1674 | circuit->u.bc.pad_hellos = 0; |
| 1675 | |
| 1676 | return CMD_SUCCESS; |
| 1677 | } |
| 1678 | |
| 1679 | DEFUN (csnp_interval, |
| 1680 | csnp_interval_cmd, |
| 1681 | "isis csnp-interval <0-65535>", |
| 1682 | "IS-IS commands\n" |
| 1683 | "Set CSNP interval in seconds\n" |
| 1684 | "CSNP interval value\n") |
| 1685 | { |
| 1686 | struct isis_circuit *circuit; |
| 1687 | struct interface *ifp; |
| 1688 | unsigned long interval; |
| 1689 | |
| 1690 | ifp = vty->index; |
| 1691 | circuit = ifp->info; |
| 1692 | if (circuit == NULL) { |
| 1693 | return CMD_WARNING; |
| 1694 | } |
| 1695 | assert (circuit); |
| 1696 | |
| 1697 | interval = atol (argv[0]); |
| 1698 | |
| 1699 | circuit->csnp_interval[0] = (u_int16_t)interval; |
| 1700 | circuit->csnp_interval[1] = (u_int16_t)interval; |
| 1701 | |
| 1702 | return CMD_SUCCESS; |
| 1703 | } |
| 1704 | |
| 1705 | DEFUN (no_csnp_interval, |
| 1706 | no_csnp_interval_cmd, |
| 1707 | "no isis csnp-interval", |
| 1708 | NO_STR |
| 1709 | "IS-IS commands\n" |
| 1710 | "Set CSNP interval in seconds\n" |
| 1711 | ) |
| 1712 | { |
| 1713 | struct isis_circuit *circuit; |
| 1714 | struct interface *ifp; |
| 1715 | |
| 1716 | ifp = vty->index; |
| 1717 | circuit = ifp->info; |
| 1718 | if (circuit == NULL) { |
| 1719 | return CMD_WARNING; |
| 1720 | } |
| 1721 | assert (circuit); |
| 1722 | |
| 1723 | circuit->csnp_interval[0] = CSNP_INTERVAL; |
| 1724 | circuit->csnp_interval[1] = CSNP_INTERVAL; |
| 1725 | |
| 1726 | return CMD_SUCCESS; |
| 1727 | } |
| 1728 | |
| 1729 | ALIAS (no_csnp_interval, |
| 1730 | no_csnp_interval_arg_cmd, |
| 1731 | "no isis csnp-interval <0-65535>", |
| 1732 | NO_STR |
| 1733 | "IS-IS commands\n" |
| 1734 | "Set CSNP interval in seconds\n" |
| 1735 | "CSNP interval value\n") |
| 1736 | |
| 1737 | |
| 1738 | DEFUN (csnp_interval_l1, |
| 1739 | csnp_interval_l1_cmd, |
| 1740 | "isis csnp-interval <0-65535> level-1", |
| 1741 | "IS-IS commands\n" |
| 1742 | "Set CSNP interval in seconds\n" |
| 1743 | "CSNP interval value\n" |
| 1744 | "Specify interval for level-1 CSNPs\n") |
| 1745 | { |
| 1746 | struct isis_circuit *circuit; |
| 1747 | struct interface *ifp; |
| 1748 | unsigned long interval; |
| 1749 | |
| 1750 | ifp = vty->index; |
| 1751 | circuit = ifp->info; |
| 1752 | if (circuit == NULL) { |
| 1753 | return CMD_WARNING; |
| 1754 | } |
| 1755 | assert (circuit); |
| 1756 | |
| 1757 | interval = atol (argv[0]); |
| 1758 | |
| 1759 | circuit->csnp_interval[0] = (u_int16_t)interval; |
| 1760 | |
| 1761 | return CMD_SUCCESS; |
| 1762 | } |
| 1763 | |
| 1764 | DEFUN (no_csnp_interval_l1, |
| 1765 | no_csnp_interval_l1_cmd, |
| 1766 | "no isis csnp-interval level-1", |
| 1767 | NO_STR |
| 1768 | "IS-IS commands\n" |
| 1769 | "Set CSNP interval in seconds\n" |
| 1770 | "Specify interval for level-1 CSNPs\n") |
| 1771 | { |
| 1772 | struct isis_circuit *circuit; |
| 1773 | struct interface *ifp; |
| 1774 | |
| 1775 | ifp = vty->index; |
| 1776 | circuit = ifp->info; |
| 1777 | if (circuit == NULL) { |
| 1778 | return CMD_WARNING; |
| 1779 | } |
| 1780 | assert (circuit); |
| 1781 | |
| 1782 | circuit->csnp_interval[0] = CSNP_INTERVAL; |
| 1783 | |
| 1784 | return CMD_SUCCESS; |
| 1785 | } |
| 1786 | |
| 1787 | ALIAS (no_csnp_interval_l1, |
| 1788 | no_csnp_interval_l1_arg_cmd, |
| 1789 | "no isis csnp-interval <0-65535> level-1", |
| 1790 | NO_STR |
| 1791 | "IS-IS commands\n" |
| 1792 | "Set CSNP interval in seconds\n" |
| 1793 | "CSNP interval value\n" |
| 1794 | "Specify interval for level-1 CSNPs\n") |
| 1795 | |
| 1796 | |
| 1797 | DEFUN (csnp_interval_l2, |
| 1798 | csnp_interval_l2_cmd, |
| 1799 | "isis csnp-interval <0-65535> level-2", |
| 1800 | "IS-IS commands\n" |
| 1801 | "Set CSNP interval in seconds\n" |
| 1802 | "CSNP interval value\n" |
| 1803 | "Specify interval for level-2 CSNPs\n") |
| 1804 | { |
| 1805 | struct isis_circuit *circuit; |
| 1806 | struct interface *ifp; |
| 1807 | unsigned long interval; |
| 1808 | |
| 1809 | ifp = vty->index; |
| 1810 | circuit = ifp->info; |
| 1811 | if (circuit == NULL) { |
| 1812 | return CMD_WARNING; |
| 1813 | } |
| 1814 | assert (circuit); |
| 1815 | |
| 1816 | interval = atol (argv[0]); |
| 1817 | |
| 1818 | circuit->csnp_interval[1] = (u_int16_t)interval; |
| 1819 | |
| 1820 | return CMD_SUCCESS; |
| 1821 | } |
| 1822 | |
| 1823 | DEFUN (no_csnp_interval_l2, |
| 1824 | no_csnp_interval_l2_cmd, |
| 1825 | "no isis csnp-interval level-2", |
| 1826 | NO_STR |
| 1827 | "IS-IS commands\n" |
| 1828 | "Set CSNP interval in seconds\n" |
| 1829 | "Specify interval for level-2 CSNPs\n") |
| 1830 | { |
| 1831 | struct isis_circuit *circuit; |
| 1832 | struct interface *ifp; |
| 1833 | |
| 1834 | ifp = vty->index; |
| 1835 | circuit = ifp->info; |
| 1836 | if (circuit == NULL) { |
| 1837 | return CMD_WARNING; |
| 1838 | } |
| 1839 | assert (circuit); |
| 1840 | |
| 1841 | circuit->csnp_interval[1] = CSNP_INTERVAL; |
| 1842 | |
| 1843 | return CMD_SUCCESS; |
| 1844 | } |
| 1845 | |
| 1846 | ALIAS (no_csnp_interval_l2, |
| 1847 | no_csnp_interval_l2_arg_cmd, |
| 1848 | "no isis csnp-interval <0-65535> level-2", |
| 1849 | NO_STR |
| 1850 | "IS-IS commands\n" |
| 1851 | "Set CSNP interval in seconds\n" |
| 1852 | "CSNP interval value\n" |
| 1853 | "Specify interval for level-2 CSNPs\n") |
| 1854 | |
| 1855 | |
| 1856 | #ifdef HAVE_IPV6 |
| 1857 | DEFUN (ipv6_router_isis, |
| 1858 | ipv6_router_isis_cmd, |
| 1859 | "ipv6 router isis WORD", |
| 1860 | "IPv6 interface subcommands\n" |
| 1861 | "IPv6 Router interface commands\n" |
| 1862 | "IS-IS Routing for IPv6\n" |
| 1863 | "Routing process tag\n") |
| 1864 | { |
| 1865 | struct isis_circuit *c; |
| 1866 | struct interface *ifp; |
| 1867 | struct isis_area *area; |
| 1868 | |
| 1869 | ifp = (struct interface *)vty->index; |
| 1870 | assert (ifp); |
| 1871 | |
| 1872 | area = isis_area_lookup (argv[0]); |
| 1873 | |
| 1874 | /* Prevent more than one circuit per interface */ |
| 1875 | if (area) |
| 1876 | c = circuit_lookup_by_ifp (ifp, area->circuit_list); |
| 1877 | else c = NULL; |
| 1878 | |
| 1879 | if (c && (ifp->info != NULL)) { |
| 1880 | if (c->ipv6_router == 1) { |
| 1881 | vty_out (vty, "ISIS circuit is already defined for IPv6%s", VTY_NEWLINE); |
| 1882 | return CMD_WARNING; |
| 1883 | } |
| 1884 | } |
| 1885 | |
| 1886 | /* this is here for ciscopability */ |
| 1887 | if (!area) { |
| 1888 | vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); |
| 1889 | return CMD_WARNING; |
| 1890 | } |
| 1891 | |
| 1892 | if (!c) { |
| 1893 | c = circuit_lookup_by_ifp (ifp, isis->init_circ_list); |
| 1894 | c = isis_csm_state_change (ISIS_ENABLE, c, area); |
| 1895 | c->interface = ifp; |
| 1896 | ifp->info = c; |
| 1897 | } |
| 1898 | |
| 1899 | if(!c) |
| 1900 | return CMD_WARNING; |
| 1901 | |
| 1902 | c->ipv6_router = 1; |
| 1903 | area->ipv6_circuits++; |
| 1904 | circuit_update_nlpids (c); |
| 1905 | |
| 1906 | vty->node = INTERFACE_NODE; |
| 1907 | |
| 1908 | return CMD_SUCCESS; |
| 1909 | } |
| 1910 | |
| 1911 | DEFUN (no_ipv6_router_isis, |
| 1912 | no_ipv6_router_isis_cmd, |
| 1913 | "no ipv6 router isis WORD", |
| 1914 | NO_STR |
| 1915 | "IPv6 interface subcommands\n" |
| 1916 | "IPv6 Router interface commands\n" |
| 1917 | "IS-IS Routing for IPv6\n" |
| 1918 | "Routing process tag\n") |
| 1919 | { |
| 1920 | struct isis_circuit *c; |
| 1921 | struct interface *ifp; |
| 1922 | struct isis_area *area; |
| 1923 | |
| 1924 | ifp = (struct interface *)vty->index; |
| 1925 | /* UGLY - will remove l8r |
| 1926 | if (circuit == NULL) { |
| 1927 | return CMD_WARNING; |
| 1928 | } */ |
| 1929 | assert (ifp); |
| 1930 | |
| 1931 | area = isis_area_lookup (argv[0]); |
| 1932 | if (!area) { |
| 1933 | vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); |
| 1934 | return CMD_WARNING; |
| 1935 | } |
| 1936 | |
| 1937 | c = circuit_lookup_by_ifp (ifp, area->circuit_list); |
| 1938 | if (!c) |
| 1939 | return CMD_WARNING; |
| 1940 | |
| 1941 | c->ipv6_router = 0; |
| 1942 | area->ipv6_circuits--; |
| 1943 | if (c->ip_router == 0) |
| 1944 | isis_csm_state_change (ISIS_DISABLE, c, area); |
| 1945 | |
| 1946 | return CMD_SUCCESS; |
| 1947 | } |
| 1948 | |
| 1949 | #if 0 /* Guess we don't really need these */ |
| 1950 | |
| 1951 | DEFUN (ipv6_address, |
| 1952 | ipv6_address_cmd, |
| 1953 | "ipv6 address X:X::X:X/M", |
| 1954 | "Interface Internet Protocol config commands\n" |
| 1955 | "Set the IP address of an interface\n" |
| 1956 | "IPv6 address (e.g. 3ffe:506::1/48)\n") |
| 1957 | { |
| 1958 | struct interface *ifp; |
| 1959 | struct isis_circuit *circuit; |
| 1960 | struct prefix_ipv6 *ipv6, *ip6; |
| 1961 | struct listnode *node; |
| 1962 | int ret, found = 1; |
| 1963 | |
| 1964 | ifp = vty->index; |
| 1965 | circuit = ifp->info; |
| 1966 | /* UGLY - will remove l8r */ |
| 1967 | if (circuit == NULL) { |
| 1968 | return CMD_WARNING; |
| 1969 | } |
| 1970 | assert (circuit); |
| 1971 | #ifdef EXTREME_DEBUG |
| 1972 | zlog_info ("ipv6_address_cmd circuit %d", circuit->idx); |
| 1973 | #endif /* EXTREME_DEBUG */ |
| 1974 | |
| 1975 | if (circuit == NULL) { |
| 1976 | zlog_warn ("ipv6_address_cmd(): no circuit"); |
| 1977 | return CMD_WARNING; |
| 1978 | } |
| 1979 | |
| 1980 | |
| 1981 | ipv6 = prefix_ipv6_new (); |
| 1982 | |
| 1983 | ret = str2prefix_ipv6 (argv[0], ipv6); |
| 1984 | if (ret <= 0) { |
| 1985 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); |
| 1986 | return CMD_WARNING; |
| 1987 | } |
| 1988 | |
| 1989 | if (!circuit->ipv6_addrs) |
| 1990 | circuit->ipv6_addrs = list_new (); |
| 1991 | else { |
| 1992 | for (node = listhead (circuit->ipv6_addrs); node; nextnode (node)) { |
| 1993 | ip6 = getdata (node); |
| 1994 | if (prefix_same ((struct prefix *)ip6, (struct prefix *)ipv6)) |
| 1995 | found = 1; |
| 1996 | } |
| 1997 | if (found) { |
| 1998 | prefix_ipv6_free (ipv6); |
| 1999 | return CMD_SUCCESS; |
| 2000 | } |
| 2001 | } |
| 2002 | |
| 2003 | |
| 2004 | listnode_add (circuit->ipv6_addrs, ipv6); |
| 2005 | #ifdef EXTREME_DEBUG |
| 2006 | zlog_info ("added IPv6 address %s to circuit %d", argv[0], circuit->idx); |
| 2007 | #endif /* EXTREME_DEBUG */ |
| 2008 | |
| 2009 | return CMD_SUCCESS; |
| 2010 | } |
| 2011 | |
| 2012 | DEFUN (no_ipv6_address, |
| 2013 | no_ipv6_address_cmd, |
| 2014 | "no ipv6 address X:X::X:X/M", |
| 2015 | NO_STR |
| 2016 | "Interface Internet Protocol config commands\n" |
| 2017 | "Set the IP address of an interface\n" |
| 2018 | "IPv6 address (e.g. 3ffe:506::1/48)\n") |
| 2019 | { |
| 2020 | struct interface *ifp; |
| 2021 | struct isis_circuit *circuit; |
| 2022 | struct prefix_ipv6 ipv6, *ip6 = NULL; |
| 2023 | struct listnode *node; |
| 2024 | int ret; |
| 2025 | |
| 2026 | ifp = vty->index; |
| 2027 | circuit = ifp->info; |
| 2028 | /* UGLY - will remove l8r */ |
| 2029 | if (circuit == NULL) { |
| 2030 | return CMD_WARNING; |
| 2031 | } |
| 2032 | assert (circuit); |
| 2033 | |
| 2034 | if (!circuit->ipv6_addrs || circuit->ipv6_addrs->count == 0) { |
| 2035 | vty_out (vty, "Invalid address %s", VTY_NEWLINE); |
| 2036 | return CMD_WARNING; |
| 2037 | } |
| 2038 | ret = str2prefix_ipv6 (argv[0], &ipv6); |
| 2039 | if (ret <= 0) { |
| 2040 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); |
| 2041 | return CMD_WARNING; |
| 2042 | } |
| 2043 | |
| 2044 | for (node = listhead (circuit->ipv6_addrs); node; nextnode (node)) { |
| 2045 | ip6 = getdata (node); |
| 2046 | if (prefix_same ((struct prefix *)ip6, (struct prefix *)&ipv6)) |
| 2047 | break; |
| 2048 | } |
| 2049 | |
| 2050 | if (ip6) { |
| 2051 | listnode_delete (circuit->ipv6_addrs, ip6); |
| 2052 | } else { |
| 2053 | vty_out (vty, "Invalid address %s", VTY_NEWLINE); |
| 2054 | } |
| 2055 | |
| 2056 | return CMD_SUCCESS; |
| 2057 | } |
| 2058 | #endif /* 0 */ |
| 2059 | #endif /* HAVE_IPV6 */ |
| 2060 | |
| 2061 | |
| 2062 | struct cmd_node interface_node = |
| 2063 | { |
| 2064 | INTERFACE_NODE, |
| 2065 | "%s(config-if)# ", |
| 2066 | 1, |
| 2067 | }; |
| 2068 | |
| 2069 | |
| 2070 | int |
| 2071 | isis_if_new_hook (struct interface *ifp) |
| 2072 | { |
| 2073 | /* FIXME: Discuss if the circuit should be created here |
| 2074 | ifp->info = XMALLOC (MTYPE_ISIS_IF_INFO, sizeof (struct isis_if_info)); */ |
| 2075 | ifp->info = NULL; |
| 2076 | return 0; |
| 2077 | } |
| 2078 | |
| 2079 | int |
| 2080 | isis_if_delete_hook (struct interface *ifp) |
| 2081 | { |
| 2082 | /* FIXME: Discuss if the circuit should be created here |
| 2083 | XFREE (MTYPE_ISIS_IF_INFO, ifp->info);*/ |
| 2084 | ifp->info = NULL; |
| 2085 | return 0; |
| 2086 | } |
| 2087 | |
| 2088 | |
| 2089 | void |
| 2090 | isis_circuit_init () |
| 2091 | { |
| 2092 | |
| 2093 | /* Initialize Zebra interface data structure */ |
| 2094 | if_init (); |
| 2095 | if_add_hook (IF_NEW_HOOK, isis_if_new_hook); |
| 2096 | if_add_hook (IF_DELETE_HOOK, isis_if_delete_hook); |
| 2097 | |
| 2098 | /* Install interface node */ |
| 2099 | install_node (&interface_node, isis_interface_config_write); |
| 2100 | install_element (CONFIG_NODE, &interface_cmd); |
| 2101 | |
| 2102 | install_default (INTERFACE_NODE); |
| 2103 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 2104 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 2105 | |
| 2106 | install_element (INTERFACE_NODE, &ip_router_isis_cmd); |
| 2107 | install_element (INTERFACE_NODE, &no_ip_router_isis_cmd); |
| 2108 | |
| 2109 | install_element (INTERFACE_NODE, &isis_circuit_type_cmd); |
| 2110 | install_element (INTERFACE_NODE, &no_isis_circuit_type_cmd); |
| 2111 | |
| 2112 | install_element (INTERFACE_NODE, &isis_passwd_cmd); |
| 2113 | install_element (INTERFACE_NODE, &no_isis_passwd_cmd); |
| 2114 | |
| 2115 | install_element (INTERFACE_NODE, &isis_priority_cmd); |
| 2116 | install_element (INTERFACE_NODE, &no_isis_priority_cmd); |
| 2117 | install_element (INTERFACE_NODE, &no_isis_priority_arg_cmd); |
| 2118 | install_element (INTERFACE_NODE, &isis_priority_l1_cmd); |
| 2119 | install_element (INTERFACE_NODE, &no_isis_priority_l1_cmd); |
| 2120 | install_element (INTERFACE_NODE, &no_isis_priority_l1_arg_cmd); |
| 2121 | install_element (INTERFACE_NODE, &isis_priority_l2_cmd); |
| 2122 | install_element (INTERFACE_NODE, &no_isis_priority_l2_cmd); |
| 2123 | install_element (INTERFACE_NODE, &no_isis_priority_l2_arg_cmd); |
| 2124 | |
| 2125 | install_element (INTERFACE_NODE, &isis_metric_cmd); |
| 2126 | install_element (INTERFACE_NODE, &no_isis_metric_cmd); |
| 2127 | install_element (INTERFACE_NODE, &no_isis_metric_arg_cmd); |
| 2128 | |
| 2129 | install_element (INTERFACE_NODE, &isis_hello_interval_cmd); |
| 2130 | install_element (INTERFACE_NODE, &no_isis_hello_interval_cmd); |
| 2131 | install_element (INTERFACE_NODE, &no_isis_hello_interval_arg_cmd); |
| 2132 | install_element (INTERFACE_NODE, &isis_hello_interval_l1_cmd); |
| 2133 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_cmd); |
| 2134 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_arg_cmd); |
| 2135 | install_element (INTERFACE_NODE, &isis_hello_interval_l2_cmd); |
| 2136 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_cmd); |
| 2137 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_arg_cmd); |
| 2138 | |
| 2139 | install_element (INTERFACE_NODE, &isis_hello_multiplier_cmd); |
| 2140 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_cmd); |
| 2141 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_arg_cmd); |
| 2142 | install_element (INTERFACE_NODE, &isis_hello_multiplier_l1_cmd); |
| 2143 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_cmd); |
| 2144 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_arg_cmd); |
| 2145 | install_element (INTERFACE_NODE, &isis_hello_multiplier_l2_cmd); |
| 2146 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_cmd); |
| 2147 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_arg_cmd); |
| 2148 | |
| 2149 | install_element (INTERFACE_NODE, &isis_hello_cmd); |
| 2150 | install_element (INTERFACE_NODE, &no_isis_hello_cmd); |
| 2151 | |
| 2152 | install_element (INTERFACE_NODE, &ip_address_cmd); |
| 2153 | install_element (INTERFACE_NODE, &no_ip_address_cmd); |
| 2154 | |
| 2155 | install_element (INTERFACE_NODE, &csnp_interval_cmd); |
| 2156 | install_element (INTERFACE_NODE, &no_csnp_interval_cmd); |
| 2157 | install_element (INTERFACE_NODE, &no_csnp_interval_arg_cmd); |
| 2158 | install_element (INTERFACE_NODE, &csnp_interval_l1_cmd); |
| 2159 | install_element (INTERFACE_NODE, &no_csnp_interval_l1_cmd); |
| 2160 | install_element (INTERFACE_NODE, &no_csnp_interval_l1_arg_cmd); |
| 2161 | install_element (INTERFACE_NODE, &csnp_interval_l2_cmd); |
| 2162 | install_element (INTERFACE_NODE, &no_csnp_interval_l2_cmd); |
| 2163 | install_element (INTERFACE_NODE, &no_csnp_interval_l2_arg_cmd); |
| 2164 | |
| 2165 | #ifdef HAVE_IPV6 |
| 2166 | install_element (INTERFACE_NODE, &ipv6_router_isis_cmd); |
| 2167 | install_element (INTERFACE_NODE, &no_ipv6_router_isis_cmd); |
| 2168 | #if 0 |
| 2169 | install_element (INTERFACE_NODE, &ipv6_address_cmd); |
| 2170 | install_element (INTERFACE_NODE, &no_ipv6_address_cmd); |
| 2171 | #endif |
| 2172 | #endif |
| 2173 | |
| 2174 | } |