~ubuntu-branches/ubuntu/warty/quagga/warty

« back to all changes in this revision

Viewing changes to isisd/isis_circuit.c

  • Committer: Bazaar Package Importer
  • Author(s): Fabio M. Di Nitto
  • Date: 2004-06-29 09:50:59 UTC
  • Revision ID: james.westby@ubuntu.com-20040629095059-px1m2m108z4qw1mr
Tags: upstream-0.96.5
ImportĀ upstreamĀ versionĀ 0.96.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
      THREAD_TIMER_ON(master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
 
418
          circuit,
 
419
        2 * circuit->hello_multiplier[0] * circuit->hello_interval[0]); 
 
420
    if (circuit->circuit_is_type & IS_LEVEL_2) 
 
421
      THREAD_TIMER_ON(master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
 
422
          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
    THREAD_TIMER_ON(master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
 
435
        isis_jitter(circuit->psnp_interval[0], PSNP_JITTER));
 
436
  }
 
437
  
 
438
  if (circuit->circuit_is_type & IS_LEVEL_2) {
 
439
    THREAD_TIMER_ON(master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
 
440
        isis_jitter(circuit->psnp_interval[1], PSNP_JITTER));
 
441
  }
 
442
  
 
443
  /* initialize the circuit streams */
 
444
  if (circuit->rcv_stream == NULL)
 
445
    circuit->rcv_stream = stream_new (ISO_MTU(circuit));
 
446
 
 
447
  if (circuit->snd_stream == NULL)
 
448
    circuit->snd_stream = stream_new (ISO_MTU(circuit));
 
449
 
 
450
  /* unified init for circuits */
 
451
  isis_sock_init (circuit);
 
452
 
 
453
#ifdef GNU_LINUX
 
454
  THREAD_READ_ON(master, circuit->t_read, isis_receive, circuit,
 
455
                                     circuit->fd);
 
456
#else
 
457
  THREAD_TIMER_ON(master, circuit->t_read, isis_receive, circuit,
 
458
                                      circuit->fd);
 
459
#endif
 
460
  return;
 
461
}
 
462
 
 
463
void
 
464
isis_circuit_down (struct isis_circuit *circuit)
 
465
{
 
466
  /* Cancel all active threads -- FIXME: wrong place*/
 
467
  /* HT: Read thread if GNU_LINUX, TIMER thread otherwise. */
 
468
  THREAD_OFF(circuit->t_read);
 
469
  if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
 
470
    THREAD_TIMER_OFF(circuit->u.bc.t_send_lan_hello[0]);
 
471
    THREAD_TIMER_OFF(circuit->u.bc.t_send_lan_hello[1]);
 
472
  } else if (circuit->circ_type == CIRCUIT_T_P2P) {
 
473
    THREAD_TIMER_OFF(circuit->u.p2p.t_send_p2p_hello);
 
474
  }
 
475
  /* close the socket */
 
476
  close (circuit->fd);
 
477
 
 
478
  return;
 
479
}
 
480
 
 
481
void
 
482
circuit_update_nlpids (struct isis_circuit *circuit)
 
483
{
 
484
  circuit->nlpids.count = 0;
 
485
  
 
486
  if (circuit->ip_router) {
 
487
    circuit->nlpids.nlpids[0] = NLPID_IP;
 
488
    circuit->nlpids.count++;
 
489
  }
 
490
#ifdef HAVE_IPV6
 
491
  if (circuit->ipv6_router) {
 
492
    circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6;
 
493
    circuit->nlpids.count++;
 
494
  }
 
495
#endif /* HAVE_IPV6 */
 
496
  return;
 
497
}
 
498
 
 
499
int
 
500
isis_interface_config_write (struct vty *vty) 
 
501
{
 
502
 
 
503
  int write = 0;
 
504
  listnode node;
 
505
  listnode node2;
 
506
  listnode node3;
 
507
  struct interface *ifp;
 
508
  struct isis_area *area;
 
509
  struct isis_circuit *c;
 
510
  struct prefix_ipv4 *ip;
 
511
  int i;
 
512
#ifdef HAVE_IPV6
 
513
  struct prefix_ipv6 *ipv6;
 
514
#endif /*HAVE_IPV6 */
 
515
 
 
516
  char buf[BUFSIZ];
 
517
 
 
518
 
 
519
  LIST_LOOP (iflist, ifp, node)
 
520
  {
 
521
    /* IF name */
 
522
    vty_out (vty, "interface %s%s", ifp->name,VTY_NEWLINE);
 
523
    write++;
 
524
    /* IF desc */
 
525
    if (ifp->desc) {
 
526
      vty_out (vty, " description %s%s", ifp->desc,VTY_NEWLINE);
 
527
      write++;
 
528
    }
 
529
    /* ISIS Circuit */
 
530
    LIST_LOOP (isis->area_list, area, node2)
 
531
    {
 
532
      c = circuit_lookup_by_ifp (ifp, area->circuit_list);
 
533
      if (c) {
 
534
        if (c->ip_router) {
 
535
          vty_out (vty, " ip router isis %s%s",area->area_tag,VTY_NEWLINE);
 
536
          write++;
 
537
        }
 
538
#ifdef HAVE_IPV6
 
539
        if (c->ipv6_router) {
 
540
          vty_out (vty, " ipv6 router isis %s%s",area->area_tag,VTY_NEWLINE);
 
541
          write++;
 
542
        }
 
543
#endif /* HAVE_IPV6 */
 
544
 
 
545
        /* ISIS - circuit type */
 
546
        if (c->circuit_is_type  == IS_LEVEL_1) {
 
547
          vty_out (vty, " isis circuit-type level-1%s", VTY_NEWLINE);
 
548
          write ++;
 
549
        } else {if (c->circuit_is_type  == IS_LEVEL_2) {
 
550
          vty_out (vty, " isis circuit-type level-2-only%s", VTY_NEWLINE);
 
551
          write ++;
 
552
        }}
 
553
 
 
554
        /* ISIS - CSNP interval - FIXME: compare to cisco*/
 
555
        if (c->csnp_interval[0] == c->csnp_interval[1]) {
 
556
          if (c->csnp_interval[0] != CSNP_INTERVAL) {
 
557
            vty_out (vty, " isis csnp-interval %d%s",  c->csnp_interval[0], 
 
558
                     VTY_NEWLINE);
 
559
            write ++;
 
560
          }
 
561
        } else {
 
562
          for (i=0;i<2;i++) {
 
563
            if (c->csnp_interval[1] != CSNP_INTERVAL) {
 
564
              vty_out (vty, " isis csnp-interval %d level-%d%s",  
 
565
                       c->csnp_interval[1],i+1, VTY_NEWLINE);
 
566
              write ++;
 
567
            }
 
568
          }
 
569
        }
 
570
 
 
571
        /* ISIS - Hello padding - Defaults to true so only display if false */
 
572
        if (c->circ_type == CIRCUIT_T_BROADCAST && !c->u.bc.pad_hellos) {
 
573
          vty_out (vty, " no isis hello padding%s",  VTY_NEWLINE);
 
574
          write ++;
 
575
        }
 
576
 
 
577
        /* ISIS - Hello interval - FIXME: compare to cisco */
 
578
        if (c->hello_interval[0] == c->hello_interval[1]) {
 
579
          if (c->hello_interval[0] != HELLO_INTERVAL) {
 
580
            vty_out (vty, " isis hello-interval %d%s",  c->hello_interval[0], 
 
581
                     VTY_NEWLINE);
 
582
            write ++;
 
583
          }
 
584
        } else {
 
585
          for (i=0;i<2;i++) {
 
586
            if (c->hello_interval[i] != HELLO_INTERVAL) {
 
587
              if (c->hello_interval[i] == HELLO_MINIMAL) {
 
588
                vty_out (vty, " isis hello-interval minimal level-%d%s", i+1, 
 
589
                         VTY_NEWLINE);
 
590
              } else {
 
591
                vty_out (vty, " isis hello-interval %d level-%d%s",  
 
592
                         c->hello_interval[i],i+1, VTY_NEWLINE);
 
593
              }
 
594
              write ++;
 
595
            }
 
596
          }
 
597
        }
 
598
 
 
599
        /* ISIS - Hello Multiplier */
 
600
        if (c->hello_multiplier[0] == c->hello_multiplier[1]) {
 
601
          if (c->hello_multiplier[0] != HELLO_MULTIPLIER ) {
 
602
            vty_out (vty, " isis hello-multiplier %d%s",  
 
603
                     c->hello_multiplier[0], VTY_NEWLINE);
 
604
            write ++;
 
605
          }
 
606
        } else {
 
607
          for (i=0;i<2;i++) {
 
608
            if (c->hello_multiplier[i] != HELLO_MULTIPLIER) {
 
609
              vty_out (vty, " isis hello-multiplier %d level-%d%s",  
 
610
                       c->hello_multiplier[i],i+1, VTY_NEWLINE);
 
611
              write ++;
 
612
            }
 
613
          }
 
614
        }
 
615
        /* ISIS - Priority */
 
616
        if (c->circ_type == CIRCUIT_T_BROADCAST) {
 
617
          if (c->u.bc.priority[0] == c->u.bc.priority[1]) {
 
618
            if (c->u.bc.priority[0] != DEFAULT_PRIORITY) {
 
619
              vty_out (vty, " isis priority %d%s",  c->u.bc.priority[0], 
 
620
                       VTY_NEWLINE);
 
621
              write ++;
 
622
            }
 
623
          } else {
 
624
            for (i=0;i<2;i++) {
 
625
              if (c->u.bc.priority[i] != DEFAULT_PRIORITY) {
 
626
                vty_out (vty, " isis priority %d level-%d%s",  
 
627
                         c->u.bc.priority[i],i+1, VTY_NEWLINE);
 
628
                write ++;
 
629
              }
 
630
            }
 
631
          }
 
632
        }
 
633
        /* ISIS - Metric */
 
634
        if (c->metrics[0].metric_default == c->metrics[1].metric_default) {
 
635
          if (c->metrics[0].metric_default != DEFAULT_CIRCUIT_METRICS) {
 
636
            vty_out (vty, " isis metric %d%s",  c->metrics[0].metric_default, 
 
637
                     VTY_NEWLINE);
 
638
            write ++;
 
639
          }
 
640
        } else {
 
641
          for (i=0;i<2;i++) {
 
642
            if (c->metrics[i].metric_default != DEFAULT_CIRCUIT_METRICS) {
 
643
              vty_out (vty, " isis metric %d level-%d%s",  
 
644
                       c->metrics[i].metric_default,i+1, VTY_NEWLINE);
 
645
              write ++;
 
646
            }
 
647
          }
 
648
        }
 
649
 
 
650
      }
 
651
    }
 
652
    vty_out (vty, "!%s",VTY_NEWLINE);
 
653
  }
 
654
  
 
655
  return write;
 
656
}
 
657
  
 
658
 
 
659
DEFUN (ip_router_isis,
 
660
       ip_router_isis_cmd,
 
661
       "ip router isis WORD",
 
662
       "Interface Internet Protocol config commands\n"
 
663
       "IP router interface commands\n"
 
664
       "IS-IS Routing for IP\n"
 
665
       "Routing process tag\n"
 
666
       )
 
667
{
 
668
  struct isis_circuit *c;
 
669
  struct interface *ifp;
 
670
  struct isis_area *area;
 
671
  
 
672
  ifp = (struct interface *)vty->index;
 
673
  assert (ifp);
 
674
  
 
675
  area = isis_area_lookup (argv[0]);
 
676
 
 
677
  /* Prevent more than one circuit per interface */
 
678
  if (area)
 
679
    c = circuit_lookup_by_ifp (ifp, area->circuit_list);
 
680
  else c = NULL;
 
681
  if (c && (ifp->info != NULL)) {
 
682
#ifdef HAVE_IPV6
 
683
    if (c->ipv6_router == 0) {
 
684
#endif /* HAVE_IPV6 */
 
685
      vty_out (vty, "ISIS circuit is already defined%s", VTY_NEWLINE);
 
686
      return CMD_WARNING;
 
687
#ifdef HAVE_IPV6
 
688
    }
 
689
#endif /* HAVE_IPV6 */
 
690
  }
 
691
  
 
692
  /* this is here for ciscopability */
 
693
  if (!area) {
 
694
    vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
 
695
    return CMD_WARNING;
 
696
  }
 
697
 
 
698
  if (!c) {
 
699
    c = circuit_lookup_by_ifp (ifp, isis->init_circ_list); 
 
700
    c = isis_csm_state_change (ISIS_ENABLE, c, area);
 
701
    c->interface = ifp;  /* this is automatic */
 
702
    ifp->info = c;       /* hardly related to the FSM */
 
703
  }
 
704
 
 
705
  if(!c) 
 
706
    return CMD_WARNING;
 
707
 
 
708
  c->ip_router = 1;
 
709
  area->ip_circuits++;
 
710
  circuit_update_nlpids (c);
 
711
 
 
712
  vty->node = INTERFACE_NODE;
 
713
  
 
714
  return CMD_SUCCESS;
 
715
}
 
716
 
 
717
DEFUN (no_ip_router_isis,
 
718
       no_ip_router_isis_cmd,
 
719
       "no ip router isis WORD",
 
720
       NO_STR
 
721
       "Interface Internet Protocol config commands\n"
 
722
       "IP router interface commands\n"
 
723
       "IS-IS Routing for IP\n"
 
724
       "Routing process tag\n"
 
725
       ) 
 
726
{
 
727
  struct isis_circuit *circuit = NULL;
 
728
  struct interface *ifp;
 
729
  struct isis_area *area;
 
730
  struct listnode *node;
 
731
 
 
732
  ifp = (struct interface *)vty->index;
 
733
  assert (ifp);
 
734
  
 
735
  area = isis_area_lookup (argv[0]);
 
736
  if (!area) {
 
737
    vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
 
738
    return CMD_WARNING;
 
739
  }
 
740
  LIST_LOOP (area->circuit_list, circuit, node)
 
741
    if (circuit->interface == ifp)
 
742
      break;
 
743
  if (!circuit) {
 
744
    vty_out (vty, "Can't find ISIS interface %s", VTY_NEWLINE);
 
745
    return CMD_WARNING;
 
746
  }
 
747
  circuit->ip_router = 0;
 
748
  area->ip_circuits--;
 
749
#ifdef HAVE_IPV6
 
750
  if (circuit->ipv6_router == 0)
 
751
#endif
 
752
    isis_csm_state_change (ISIS_DISABLE, circuit, area);
 
753
  
 
754
  return CMD_SUCCESS;
 
755
}
 
756
 
 
757
DEFUN (isis_circuit_type,
 
758
       isis_circuit_type_cmd,
 
759
       "isis circuit-type (level-1|level-1-2|level-2-only)",
 
760
       "IS-IS commands\n"
 
761
       "Configure circuit type for interface\n"
 
762
       "Level-1 only adjacencies are formed\n"
 
763
       "Level-1-2 adjacencies are formed\n"
 
764
       "Level-2 only adjacencies are formed\n"
 
765
       )
 
766
{
 
767
  struct isis_circuit *circuit;
 
768
  struct interface *ifp;
 
769
  int circuit_t;
 
770
  int is_type;
 
771
  
 
772
  ifp  = vty->index;
 
773
  circuit = ifp->info;
 
774
  /* UGLY - will remove l8r */
 
775
  if (circuit == NULL) {
 
776
    return CMD_WARNING;
 
777
  }
 
778
 
 
779
  assert (circuit);
 
780
 
 
781
  circuit_t = string2circuit_t (argv[0]);
 
782
 
 
783
  if (!circuit_t) { 
 
784
    vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE);
 
785
    return CMD_SUCCESS;
 
786
  }
 
787
  
 
788
  is_type = circuit->area->is_type;
 
789
  if (is_type == IS_LEVEL_1_AND_2 || is_type == circuit_t)
 
790
   isis_event_circuit_type_change (circuit, circuit_t);
 
791
  else {
 
792
    vty_out (vty, "invalid circuit level for area %s.%s", 
 
793
             circuit->area->area_tag, VTY_NEWLINE);
 
794
  }
 
795
  
 
796
  return CMD_SUCCESS;
 
797
}
 
798
 
 
799
DEFUN (no_isis_circuit_type,
 
800
       no_isis_circuit_type_cmd,
 
801
       "no isis circuit-type (level-1|level-1-2|level-2-only)",
 
802
       NO_STR
 
803
       "IS-IS commands\n"
 
804
       "Configure circuit type for interface\n"
 
805
       "Level-1 only adjacencies are formed\n"
 
806
       "Level-1-2 adjacencies are formed\n"
 
807
       "Level-2 only adjacencies are formed\n"
 
808
       )
 
809
{
 
810
  struct isis_circuit *circuit;
 
811
  struct interface *ifp;
 
812
  
 
813
  ifp  = vty->index;
 
814
  circuit = ifp->info;
 
815
  if (circuit == NULL) {
 
816
    return CMD_WARNING;
 
817
  }
 
818
 
 
819
  assert(circuit);
 
820
  
 
821
  /*
 
822
   * Set the circuits level to its default value which is that of the area
 
823
   */
 
824
  isis_event_circuit_type_change (circuit, circuit->area->is_type);
 
825
  
 
826
  return CMD_SUCCESS;
 
827
}
 
828
 
 
829
DEFUN (isis_passwd,
 
830
       isis_passwd_cmd,
 
831
       "isis password WORD",
 
832
       "IS-IS commands\n"
 
833
       "Configure the authentication password for interface\n"
 
834
       "Password\n")
 
835
{
 
836
  struct isis_circuit *circuit;
 
837
  struct interface *ifp;
 
838
  int len;
 
839
 
 
840
  ifp  = vty->index;
 
841
  circuit = ifp->info;
 
842
  if (circuit == NULL) {
 
843
    return CMD_WARNING;
 
844
  }
 
845
  
 
846
  len = strlen (argv[0]);
 
847
  if (len > 254) {
 
848
    vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
 
849
    return CMD_WARNING;
 
850
  }
 
851
  circuit->passwd.len = len;
 
852
  circuit->passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
 
853
  strncpy (circuit->passwd.passwd, argv[0], 255);
 
854
  
 
855
  return CMD_SUCCESS;
 
856
}
 
857
 
 
858
DEFUN (no_isis_passwd,
 
859
       no_isis_passwd_cmd,
 
860
       "no isis password",
 
861
       NO_STR
 
862
       "IS-IS commands\n"
 
863
       "Configure the authentication password for interface\n")
 
864
{
 
865
  struct isis_circuit *circuit;
 
866
  struct interface *ifp;
 
867
  
 
868
  ifp  = vty->index;
 
869
  circuit = ifp->info;
 
870
  if (circuit == NULL) {
 
871
    return CMD_WARNING;
 
872
  }
 
873
    
 
874
  memset (&circuit->passwd, 0, sizeof (struct isis_passwd));
 
875
  
 
876
  return CMD_SUCCESS;
 
877
}
 
878
 
 
879
 
 
880
DEFUN (isis_priority,
 
881
       isis_priority_cmd,
 
882
       "isis priority <0-127>",
 
883
       "IS-IS commands\n"
 
884
       "Set priority for Designated Router election\n"
 
885
       "Priority value\n"
 
886
       )
 
887
{
 
888
  struct isis_circuit *circuit;
 
889
  struct interface *ifp;
 
890
  int prio;
 
891
  
 
892
  ifp  = vty->index;
 
893
  circuit = ifp->info;
 
894
  if (circuit == NULL) {
 
895
    return CMD_WARNING;
 
896
  }
 
897
  assert (circuit);
 
898
 
 
899
  prio = atoi (argv[0]);
 
900
 
 
901
  circuit->u.bc.priority[0] = prio;
 
902
  circuit->u.bc.priority[1] = prio;
 
903
  
 
904
  return CMD_SUCCESS;
 
905
}
 
906
 
 
907
DEFUN (no_isis_priority,
 
908
       no_isis_priority_cmd,
 
909
       "no isis priority",
 
910
       NO_STR
 
911
       "IS-IS commands\n"
 
912
       "Set priority for Designated Router election\n"
 
913
       )
 
914
{
 
915
  struct isis_circuit *circuit;
 
916
  struct interface *ifp;
 
917
 
 
918
  ifp  = vty->index;
 
919
  circuit = ifp->info;
 
920
  if (circuit == NULL) {
 
921
    return CMD_WARNING;
 
922
  }
 
923
  assert (circuit);
 
924
 
 
925
  circuit->u.bc.priority[0] = DEFAULT_PRIORITY;
 
926
  circuit->u.bc.priority[1] = DEFAULT_PRIORITY;
 
927
  
 
928
  return CMD_SUCCESS;
 
929
}
 
930
 
 
931
ALIAS (no_isis_priority,
 
932
       no_isis_priority_arg_cmd,
 
933
       "no isis priority <0-127>",
 
934
       NO_STR
 
935
       "IS-IS commands\n"
 
936
       "Set priority for Designated Router election\n"
 
937
       "Priority value\n"
 
938
       )
 
939
 
 
940
DEFUN (isis_priority_l1,
 
941
       isis_priority_l1_cmd,
 
942
       "isis priority <0-127> level-1", 
 
943
       "IS-IS commands\n"
 
944
       "Set priority for Designated Router election\n"
 
945
       "Priority value\n"
 
946
       "Specify priority for level-1 routing\n"
 
947
       )
 
948
{
 
949
  struct isis_circuit *circuit;
 
950
  struct interface *ifp;
 
951
  int prio;
 
952
  
 
953
  ifp  = vty->index;
 
954
  circuit = ifp->info;
 
955
  if (circuit == NULL) {
 
956
    return CMD_WARNING;
 
957
  }
 
958
  assert (circuit);
 
959
 
 
960
  prio = atoi (argv[0]);
 
961
 
 
962
  circuit->u.bc.priority[0] = prio;
 
963
  
 
964
  return CMD_SUCCESS;
 
965
}
 
966
 
 
967
DEFUN (no_isis_priority_l1,
 
968
       no_isis_priority_l1_cmd,
 
969
       "no isis priority level-1",
 
970
       NO_STR
 
971
       "IS-IS commands\n"
 
972
       "Set priority for Designated Router election\n"
 
973
       "Specify priority for level-1 routing\n"
 
974
       )
 
975
{
 
976
  struct isis_circuit *circuit;
 
977
  struct interface *ifp;
 
978
  
 
979
  ifp  = vty->index;
 
980
  circuit = ifp->info;
 
981
  if (circuit == NULL) {
 
982
    return CMD_WARNING;
 
983
  }
 
984
  assert (circuit);
 
985
  
 
986
  circuit->u.bc.priority[0] = DEFAULT_PRIORITY;
 
987
  
 
988
  return CMD_SUCCESS;
 
989
}
 
990
 
 
991
ALIAS (no_isis_priority_l1,
 
992
       no_isis_priority_l1_arg_cmd,
 
993
       "no isis priority <0-127> level-1",
 
994
       NO_STR
 
995
       "IS-IS commands\n"
 
996
       "Set priority for Designated Router election\n"
 
997
       "Priority value\n"
 
998
       "Specify priority for level-1 routing\n"
 
999
       )
 
1000
 
 
1001
DEFUN (isis_priority_l2,
 
1002
       isis_priority_l2_cmd,
 
1003
       "isis priority <0-127> level-2", 
 
1004
       "IS-IS commands\n"
 
1005
       "Set priority for Designated Router election\n"
 
1006
       "Priority value\n"
 
1007
       "Specify priority for level-2 routing\n"
 
1008
       )
 
1009
{
 
1010
  struct isis_circuit *circuit;
 
1011
  struct interface *ifp;
 
1012
  int prio;
 
1013
  
 
1014
  ifp  = vty->index;
 
1015
  circuit = ifp->info;
 
1016
  if (circuit == NULL) {
 
1017
    return CMD_WARNING;
 
1018
  }
 
1019
  assert (circuit);
 
1020
 
 
1021
  prio = atoi (argv[0]);
 
1022
 
 
1023
  circuit->u.bc.priority[1] = prio;
 
1024
  
 
1025
  return CMD_SUCCESS;
 
1026
}
 
1027
 
 
1028
DEFUN (no_isis_priority_l2,
 
1029
       no_isis_priority_l2_cmd,
 
1030
       "no isis priority level-2",
 
1031
       NO_STR
 
1032
       "IS-IS commands\n"
 
1033
       "Set priority for Designated Router election\n"
 
1034
       "Specify priority for level-2 routing\n"
 
1035
       )
 
1036
{
 
1037
  struct isis_circuit *circuit;
 
1038
  struct interface *ifp;
 
1039
  
 
1040
  ifp  = vty->index;
 
1041
  circuit = ifp->info;
 
1042
  if (circuit == NULL) {
 
1043
    return CMD_WARNING;
 
1044
  }
 
1045
  assert (circuit);
 
1046
  
 
1047
  circuit->u.bc.priority[1] = DEFAULT_PRIORITY;
 
1048
  
 
1049
  return CMD_SUCCESS;
 
1050
}
 
1051
 
 
1052
ALIAS (no_isis_priority_l2,
 
1053
       no_isis_priority_l2_arg_cmd,
 
1054
       "no isis priority <0-127> level-2",
 
1055
       NO_STR
 
1056
       "IS-IS commands\n"
 
1057
       "Set priority for Designated Router election\n"
 
1058
       "Priority value\n"
 
1059
       "Specify priority for level-2 routing\n"
 
1060
       )
 
1061
 
 
1062
/* Metric command */
 
1063
 
 
1064
DEFUN (isis_metric,
 
1065
       isis_metric_cmd,
 
1066
       "isis metric <0-63>",
 
1067
       "IS-IS commands\n"
 
1068
       "Set default metric for circuit\n"
 
1069
       "Default metric value\n"
 
1070
       )
 
1071
{
 
1072
  struct isis_circuit *circuit;
 
1073
  struct interface *ifp;
 
1074
  int met;
 
1075
 
 
1076
  ifp  = vty->index;
 
1077
  circuit = ifp->info;
 
1078
  if (circuit == NULL) {
 
1079
    return CMD_WARNING;
 
1080
  }
 
1081
  assert (circuit);
 
1082
 
 
1083
  met = atoi (argv[0]);
 
1084
 
 
1085
  circuit->metrics[0].metric_default = met;
 
1086
  circuit->metrics[1].metric_default = met;
 
1087
 
 
1088
  return CMD_SUCCESS;
 
1089
}
 
1090
 
 
1091
DEFUN (no_isis_metric,
 
1092
       no_isis_metric_cmd,
 
1093
       "no isis metric",
 
1094
       NO_STR
 
1095
       "IS-IS commands\n"
 
1096
       "Set default metric for circuit\n"
 
1097
       )
 
1098
{
 
1099
  struct isis_circuit *circuit;
 
1100
  struct interface *ifp;
 
1101
 
 
1102
  ifp  = vty->index;
 
1103
  circuit = ifp->info;
 
1104
  if (circuit == NULL) {
 
1105
    return CMD_WARNING;
 
1106
  }
 
1107
  assert (circuit);
 
1108
 
 
1109
  circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRICS;
 
1110
  circuit->metrics[1].metric_default = DEFAULT_CIRCUIT_METRICS;
 
1111
 
 
1112
  return CMD_SUCCESS;
 
1113
}
 
1114
 
 
1115
ALIAS (no_isis_metric,
 
1116
       no_isis_metric_arg_cmd,
 
1117
       "no isis metric <0-127>",
 
1118
       NO_STR
 
1119
       "IS-IS commands\n"
 
1120
       "Set default metric for circuit\n"
 
1121
       "Default metric value\n"
 
1122
       )
 
1123
/* end of metrics */
 
1124
 
 
1125
 
 
1126
DEFUN (isis_hello_interval,
 
1127
       isis_hello_interval_cmd,
 
1128
       "isis hello-interval (<1-65535>|minimal)",
 
1129
       "IS-IS commands\n"
 
1130
       "Set Hello interval\n"
 
1131
       "Hello interval value\n"
 
1132
       "Holdtime 1 seconds, interval depends on multiplier\n"
 
1133
       )
 
1134
{
 
1135
  struct isis_circuit *circuit;
 
1136
  struct interface *ifp;
 
1137
  int interval;
 
1138
  char c;
 
1139
 
 
1140
  ifp  = vty->index;
 
1141
  circuit = ifp->info;
 
1142
  if (circuit == NULL) {
 
1143
    return CMD_WARNING;
 
1144
  }
 
1145
  assert (circuit); 
 
1146
  c = *argv[0];
 
1147
  if (isdigit((int)c)) {
 
1148
    interval = atoi (argv[0]);
 
1149
  } else
 
1150
    interval = HELLO_MINIMAL; /* FIXME: should be calculated */
 
1151
 
 
1152
  circuit->hello_interval[0] = (u_int16_t)interval;
 
1153
  circuit->hello_interval[1] = (u_int16_t)interval;
 
1154
  
 
1155
  return CMD_SUCCESS;
 
1156
}
 
1157
 
 
1158
DEFUN (no_isis_hello_interval,
 
1159
       no_isis_hello_interval_cmd,
 
1160
       "no isis hello-interval",
 
1161
       NO_STR
 
1162
       "IS-IS commands\n"
 
1163
       "Set Hello interval\n"
 
1164
       )
 
1165
{
 
1166
  struct isis_circuit *circuit;
 
1167
  struct interface *ifp;
 
1168
 
 
1169
  ifp  = vty->index;
 
1170
  circuit = ifp->info;
 
1171
  if (circuit == NULL) {
 
1172
    return CMD_WARNING;
 
1173
  }
 
1174
  assert (circuit);
 
1175
  
 
1176
 
 
1177
  circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */
 
1178
  circuit->hello_interval[1] = HELLO_INTERVAL;
 
1179
  
 
1180
  return CMD_SUCCESS;
 
1181
}
 
1182
 
 
1183
ALIAS (no_isis_hello_interval,
 
1184
       no_isis_hello_interval_arg_cmd,
 
1185
       "no isis hello-interval (<1-65535>|minimal)",
 
1186
       NO_STR
 
1187
       "IS-IS commands\n"
 
1188
       "Set Hello interval\n"
 
1189
       "Hello interval value\n"
 
1190
       "Holdtime 1 second, interval depends on multiplier\n"
 
1191
       )
 
1192
 
 
1193
DEFUN (isis_hello_interval_l1,
 
1194
       isis_hello_interval_l1_cmd,
 
1195
       "isis hello-interval (<1-65535>|minimal) level-1",
 
1196
       "IS-IS commands\n"
 
1197
       "Set Hello interval\n"
 
1198
       "Hello interval value\n"
 
1199
       "Holdtime 1 second, interval depends on multiplier\n"
 
1200
       "Specify hello-interval for level-1 IIHs\n"
 
1201
       )
 
1202
{
 
1203
  struct isis_circuit *circuit;
 
1204
  struct interface *ifp;
 
1205
  long interval;
 
1206
  char c;
 
1207
 
 
1208
  ifp  = vty->index;
 
1209
  circuit = ifp->info;
 
1210
  if (circuit == NULL) {
 
1211
    return CMD_WARNING;
 
1212
  }
 
1213
  assert (circuit);
 
1214
 
 
1215
  c = *argv[0];
 
1216
  if (isdigit((int)c)) {
 
1217
    interval = atoi (argv[0]);
 
1218
  } else
 
1219
    interval = HELLO_MINIMAL;
 
1220
 
 
1221
  circuit->hello_interval[0] = (u_int16_t)interval;
 
1222
  
 
1223
  return CMD_SUCCESS;
 
1224
}
 
1225
 
 
1226
DEFUN (no_isis_hello_interval_l1,
 
1227
       no_isis_hello_interval_l1_cmd,
 
1228
       "no isis hello-interval level-1",
 
1229
       NO_STR
 
1230
       "IS-IS commands\n"
 
1231
       "Set Hello interval\n"
 
1232
       "Specify hello-interval for level-1 IIHs\n"
 
1233
       )
 
1234
{
 
1235
  struct isis_circuit *circuit;
 
1236
  struct interface *ifp;
 
1237
 
 
1238
  ifp  = vty->index;
 
1239
  circuit = ifp->info;
 
1240
  if (circuit == NULL) {
 
1241
    return CMD_WARNING;
 
1242
  }
 
1243
  assert (circuit);
 
1244
  
 
1245
 
 
1246
  circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */
 
1247
  
 
1248
  return CMD_SUCCESS;
 
1249
}
 
1250
 
 
1251
ALIAS (no_isis_hello_interval_l1,
 
1252
       no_isis_hello_interval_l1_arg_cmd,
 
1253
       "no isis hello-interval (<1-65535>|minimal) level-1",
 
1254
       NO_STR
 
1255
       "IS-IS commands\n"
 
1256
       "Set Hello interval\n"
 
1257
       "Hello interval value\n"
 
1258
       "Holdtime 1 second, interval depends on multiplier\n"
 
1259
       "Specify hello-interval for level-1 IIHs\n"
 
1260
       )
 
1261
 
 
1262
DEFUN (isis_hello_interval_l2,
 
1263
       isis_hello_interval_l2_cmd,
 
1264
       "isis hello-interval (<1-65535>|minimal) level-2",
 
1265
       "IS-IS commands\n"
 
1266
       "Set Hello interval\n"
 
1267
       "Hello interval value\n"
 
1268
       "Holdtime 1 second, interval depends on multiplier\n"
 
1269
       "Specify hello-interval for level-2 IIHs\n"
 
1270
       )
 
1271
{
 
1272
  struct isis_circuit *circuit;
 
1273
  struct interface *ifp;
 
1274
  long interval;
 
1275
  char c;
 
1276
 
 
1277
  ifp  = vty->index;
 
1278
  circuit = ifp->info;
 
1279
  if (circuit == NULL) {
 
1280
    return CMD_WARNING;
 
1281
  }
 
1282
  assert (circuit);
 
1283
 
 
1284
  c = *argv[0];
 
1285
  if (isdigit((int)c)) {
 
1286
    interval = atoi (argv[0]);
 
1287
  } else
 
1288
    interval = HELLO_MINIMAL;
 
1289
 
 
1290
  circuit->hello_interval[1] = (u_int16_t)interval;
 
1291
  
 
1292
  return CMD_SUCCESS;
 
1293
}
 
1294
 
 
1295
DEFUN (no_isis_hello_interval_l2,
 
1296
       no_isis_hello_interval_l2_cmd,
 
1297
       "no isis hello-interval level-2",
 
1298
       NO_STR
 
1299
       "IS-IS commands\n"
 
1300
       "Set Hello interval\n"
 
1301
       "Specify hello-interval for level-2 IIHs\n"
 
1302
       )
 
1303
{
 
1304
  struct isis_circuit *circuit;
 
1305
  struct interface *ifp;
 
1306
 
 
1307
  ifp  = vty->index;
 
1308
  circuit = ifp->info;
 
1309
  if (circuit == NULL) {
 
1310
    return CMD_WARNING;
 
1311
  }
 
1312
  assert (circuit);
 
1313
  
 
1314
 
 
1315
  circuit->hello_interval[1] = HELLO_INTERVAL; /* Default is 1 sec. */
 
1316
  
 
1317
  return CMD_SUCCESS;
 
1318
}
 
1319
 
 
1320
ALIAS (no_isis_hello_interval_l2,
 
1321
       no_isis_hello_interval_l2_arg_cmd,
 
1322
       "no isis hello-interval (<1-65535>|minimal) level-2",
 
1323
       NO_STR
 
1324
       "IS-IS commands\n"
 
1325
       "Set Hello interval\n"
 
1326
       "Hello interval value\n"
 
1327
       "Holdtime 1 second, interval depends on multiplier\n"
 
1328
       "Specify hello-interval for level-2 IIHs\n"
 
1329
       )
 
1330
 
 
1331
 
 
1332
DEFUN (isis_hello_multiplier,
 
1333
       isis_hello_multiplier_cmd,
 
1334
       "isis hello-multiplier <3-1000>",
 
1335
       "IS-IS commands\n"
 
1336
       "Set multiplier for Hello holding time\n"
 
1337
       "Hello multiplier value\n"
 
1338
       )
 
1339
{
 
1340
  struct isis_circuit *circuit;
 
1341
  struct interface *ifp;
 
1342
  int mult;
 
1343
  
 
1344
  ifp  = vty->index;
 
1345
  circuit = ifp->info;
 
1346
  if (circuit == NULL) {
 
1347
    return CMD_WARNING;
 
1348
  }
 
1349
  assert (circuit);
 
1350
 
 
1351
  mult = atoi (argv[0]);
 
1352
 
 
1353
  circuit->hello_multiplier[0] = (u_int16_t)mult;
 
1354
  circuit->hello_multiplier[1] = (u_int16_t)mult;
 
1355
    
 
1356
  return CMD_SUCCESS;
 
1357
}
 
1358
 
 
1359
DEFUN (no_isis_hello_multiplier,
 
1360
       no_isis_hello_multiplier_cmd,
 
1361
       "no isis hello-multiplier",
 
1362
       NO_STR
 
1363
       "IS-IS commands\n"
 
1364
       "Set multiplier for Hello holding time\n"
 
1365
       )
 
1366
{
 
1367
  struct isis_circuit *circuit;
 
1368
  struct interface *ifp;
 
1369
  
 
1370
  ifp  = vty->index;
 
1371
  circuit = ifp->info;
 
1372
  if (circuit == NULL) {
 
1373
    return CMD_WARNING;
 
1374
  }
 
1375
  assert (circuit);
 
1376
 
 
1377
  circuit->hello_multiplier[0] = HELLO_MULTIPLIER;
 
1378
  circuit->hello_multiplier[1] = HELLO_MULTIPLIER;
 
1379
 
 
1380
  return CMD_SUCCESS;
 
1381
}
 
1382
 
 
1383
ALIAS (no_isis_hello_multiplier,
 
1384
       no_isis_hello_multiplier_arg_cmd,
 
1385
       "no isis hello-multiplier <3-1000>",
 
1386
       NO_STR
 
1387
       "IS-IS commands\n"
 
1388
       "Set multiplier for Hello holding time\n"
 
1389
       "Hello multiplier value\n"
 
1390
       )
 
1391
 
 
1392
DEFUN (isis_hello_multiplier_l1,
 
1393
       isis_hello_multiplier_l1_cmd,
 
1394
       "isis hello-multiplier <3-1000> level-1",
 
1395
       "IS-IS commands\n"
 
1396
       "Set multiplier for Hello holding time\n"
 
1397
       "Hello multiplier value\n"
 
1398
       "Specify hello multiplier for level-1 IIHs\n"
 
1399
       )
 
1400
{
 
1401
  struct isis_circuit *circuit;
 
1402
  struct interface *ifp;
 
1403
  int mult;
 
1404
  
 
1405
  ifp  = vty->index;
 
1406
  circuit = ifp->info;
 
1407
  if (circuit == NULL) {
 
1408
    return CMD_WARNING;
 
1409
  }
 
1410
  assert (circuit);
 
1411
 
 
1412
  mult = atoi (argv[0]);
 
1413
 
 
1414
  circuit->hello_multiplier[0] = (u_int16_t)mult;
 
1415
    
 
1416
  return CMD_SUCCESS;
 
1417
}
 
1418
 
 
1419
DEFUN (no_isis_hello_multiplier_l1,
 
1420
       no_isis_hello_multiplier_l1_cmd,
 
1421
       "no isis hello-multiplier level-1",
 
1422
       NO_STR
 
1423
       "IS-IS commands\n"
 
1424
       "Set multiplier for Hello holding time\n"
 
1425
       "Specify hello multiplier for level-1 IIHs\n"
 
1426
       )
 
1427
{
 
1428
  struct isis_circuit *circuit;
 
1429
  struct interface *ifp;
 
1430
  
 
1431
  ifp  = vty->index;
 
1432
  circuit = ifp->info;
 
1433
  if (circuit == NULL) {
 
1434
    return CMD_WARNING;
 
1435
  }
 
1436
  assert (circuit);
 
1437
 
 
1438
  circuit->hello_multiplier[0] = HELLO_MULTIPLIER;
 
1439
 
 
1440
  return CMD_SUCCESS;
 
1441
}
 
1442
 
 
1443
ALIAS (no_isis_hello_multiplier_l1,
 
1444
       no_isis_hello_multiplier_l1_arg_cmd,
 
1445
       "no isis hello-multiplier <3-1000> level-1",
 
1446
       NO_STR
 
1447
       "IS-IS commands\n"
 
1448
       "Set multiplier for Hello holding time\n"
 
1449
       "Hello multiplier value\n"
 
1450
       "Specify hello multiplier for level-1 IIHs\n"
 
1451
       )
 
1452
 
 
1453
DEFUN (isis_hello_multiplier_l2,
 
1454
       isis_hello_multiplier_l2_cmd,
 
1455
       "isis hello-multiplier <3-1000> level-2",
 
1456
       "IS-IS commands\n"
 
1457
       "Set multiplier for Hello holding time\n"
 
1458
       "Hello multiplier value\n"
 
1459
       "Specify hello multiplier for level-2 IIHs\n"
 
1460
       )
 
1461
{
 
1462
  struct isis_circuit *circuit;
 
1463
  struct interface *ifp;
 
1464
  int mult;
 
1465
  
 
1466
  ifp  = vty->index;
 
1467
  circuit = ifp->info;
 
1468
  if (circuit == NULL) {
 
1469
    return CMD_WARNING;
 
1470
  }
 
1471
  assert (circuit);
 
1472
 
 
1473
  mult = atoi (argv[0]);
 
1474
 
 
1475
  circuit->hello_multiplier[1] = (u_int16_t)mult;
 
1476
    
 
1477
  return CMD_SUCCESS;
 
1478
}
 
1479
 
 
1480
DEFUN (no_isis_hello_multiplier_l2,
 
1481
       no_isis_hello_multiplier_l2_cmd,
 
1482
       "no isis hello-multiplier level-2",
 
1483
       NO_STR
 
1484
       "IS-IS commands\n"
 
1485
       "Set multiplier for Hello holding time\n"
 
1486
       "Specify hello multiplier for level-2 IIHs\n"
 
1487
       )
 
1488
{
 
1489
  struct isis_circuit *circuit;
 
1490
  struct interface *ifp;
 
1491
  
 
1492
  ifp  = vty->index;
 
1493
  circuit = ifp->info;
 
1494
  if (circuit == NULL) {
 
1495
    return CMD_WARNING;
 
1496
  }
 
1497
  assert (circuit);
 
1498
 
 
1499
  circuit->hello_multiplier[1] = HELLO_MULTIPLIER;
 
1500
 
 
1501
  return CMD_SUCCESS;
 
1502
}
 
1503
 
 
1504
ALIAS (no_isis_hello_multiplier_l2,
 
1505
       no_isis_hello_multiplier_l2_arg_cmd,
 
1506
       "no isis hello-multiplier <3-1000> level-2",
 
1507
       NO_STR
 
1508
       "IS-IS commands\n"
 
1509
       "Set multiplier for Hello holding time\n"
 
1510
       "Hello multiplier value\n"
 
1511
       "Specify hello multiplier for level-2 IIHs\n"
 
1512
       )
 
1513
 
 
1514
DEFUN (isis_hello,
 
1515
       isis_hello_cmd,
 
1516
       "isis hello padding",
 
1517
       "IS-IS commands\n"
 
1518
       "Add padding to IS-IS hello packets\n"
 
1519
       "Pad hello packets\n"
 
1520
       "<cr>\n")
 
1521
{
 
1522
  struct interface *ifp;
 
1523
  struct isis_circuit *circuit;
 
1524
  
 
1525
  ifp  = vty->index;
 
1526
  circuit = ifp->info;
 
1527
  if (circuit == NULL) {
 
1528
    return CMD_WARNING;
 
1529
  }
 
1530
  assert (circuit);
 
1531
  
 
1532
  circuit->u.bc.pad_hellos = 1;
 
1533
  
 
1534
  return CMD_SUCCESS;
 
1535
}
 
1536
 
 
1537
#if 0
 
1538
DEFUN (ip_address,
 
1539
       ip_address_cmd,
 
1540
       "ip address A.B.C.D/A",
 
1541
       "Interface Internet Protocol config commands\n"
 
1542
       "Set the IP address of an interface\n"
 
1543
       "IP address (e.g. 10.0.0.1/8\n")
 
1544
  
 
1545
{
 
1546
  struct interface *ifp;
 
1547
  struct isis_circuit *circuit;
 
1548
  struct prefix_ipv4 *ipv4, *ip;
 
1549
  struct listnode *node;
 
1550
  int ret, found = 1;
 
1551
 
 
1552
  ifp  = vty->index;
 
1553
  circuit = ifp->info;
 
1554
  if (circuit == NULL) {
 
1555
    return CMD_WARNING;
 
1556
  }
 
1557
 
 
1558
  assert (circuit);
 
1559
#ifdef HAVE_IPV6
 
1560
  zlog_info ("ip_address_cmd circuit %d", circuit->interface->ifindex);
 
1561
#endif /* HAVE_IPV6 */
 
1562
 
 
1563
  ipv4 = prefix_ipv4_new ();
 
1564
  
 
1565
  ret = str2prefix_ipv4 (argv[0], ipv4);
 
1566
  if (ret <= 0) {
 
1567
    zlog_warn ("ip_address_cmd(): malformed address");
 
1568
    vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
 
1569
    return CMD_WARNING;
 
1570
  }
 
1571
  
 
1572
  if (!circuit->ip_addrs) 
 
1573
    circuit->ip_addrs = list_new ();
 
1574
  else {
 
1575
    for (node = listhead (circuit->ip_addrs); node; nextnode (node)) {
 
1576
      ip = getdata (node);
 
1577
      if (prefix_same ((struct prefix *)ip, (struct prefix *)ipv4))
 
1578
        found = 1;
 
1579
    }
 
1580
    if (found) {
 
1581
    prefix_ipv4_free (ipv4);
 
1582
    return CMD_SUCCESS;
 
1583
    }
 
1584
  }
 
1585
 
 
1586
  
 
1587
  listnode_add (circuit->ip_addrs, ipv4);
 
1588
#ifdef EXTREME_DEBUG  
 
1589
  zlog_info ("added IP address %s to circuit %d", argv[0], 
 
1590
             circuit->interface->ifindex);
 
1591
#endif /* EXTREME_DEBUG */
 
1592
  return CMD_SUCCESS;
 
1593
}
 
1594
 
 
1595
DEFUN (no_ip_address,
 
1596
       no_ip_address_cmd,
 
1597
       "no ip address A.B.C.D/A",
 
1598
       NO_STR
 
1599
       "Interface Internet Protocol config commands\n"
 
1600
       "Set the IP address of an interface\n"
 
1601
       "IP address (e.g. 10.0.0.1/8\n")
 
1602
{
 
1603
  struct interface *ifp;
 
1604
  struct isis_circuit *circuit;
 
1605
  struct prefix_ipv4 ipv4, *ip = NULL;
 
1606
  struct listnode *node;
 
1607
  int ret;
 
1608
 
 
1609
  ifp  = vty->index;
 
1610
  circuit = ifp->info;
 
1611
  /* UGLY - will remove l8r */
 
1612
  if (circuit == NULL) {
 
1613
    return CMD_WARNING;
 
1614
  }
 
1615
  assert (circuit);
 
1616
 
 
1617
  if (!circuit->ip_addrs || circuit->ip_addrs->count == 0) {
 
1618
    vty_out (vty, "Invalid address %s", VTY_NEWLINE);
 
1619
    return CMD_WARNING;
 
1620
  }
 
1621
  ret = str2prefix_ipv4 (argv[0], &ipv4);
 
1622
  if (ret <= 0) {
 
1623
    vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
 
1624
    return CMD_WARNING;
 
1625
  }
 
1626
  
 
1627
  for (node = listhead (circuit->ip_addrs); node; nextnode (node)) {
 
1628
    ip = getdata (node);
 
1629
    if (prefix_same ((struct prefix *)ip, (struct prefix *)&ipv4))
 
1630
      break;
 
1631
  }
 
1632
  
 
1633
  if (ip) {
 
1634
    listnode_delete (circuit->ip_addrs, ip);
 
1635
  } else {
 
1636
    vty_out (vty, "Invalid address %s", VTY_NEWLINE);
 
1637
  }
 
1638
  
 
1639
  return CMD_SUCCESS;
 
1640
}
 
1641
#endif
 
1642
 
 
1643
DEFUN (no_isis_hello,
 
1644
       no_isis_hello_cmd,
 
1645
       "no isis hello padding",
 
1646
       NO_STR
 
1647
       "IS-IS commands\n"
 
1648
       "Add padding to IS-IS hello packets\n"
 
1649
       "Pad hello packets\n"
 
1650
       "<cr>\n")
 
1651
{
 
1652
  struct isis_circuit *circuit;
 
1653
  struct interface *ifp;
 
1654
 
 
1655
  ifp  = vty->index;
 
1656
  circuit = ifp->info;
 
1657
  if (circuit == NULL) {
 
1658
    return CMD_WARNING;
 
1659
  }
 
1660
  assert (circuit);
 
1661
  
 
1662
  circuit->u.bc.pad_hellos = 0;
 
1663
  
 
1664
  return CMD_SUCCESS;
 
1665
}
 
1666
 
 
1667
DEFUN (csnp_interval,
 
1668
       csnp_interval_cmd,
 
1669
       "isis csnp-interval <0-65535>",
 
1670
       "IS-IS commands\n"
 
1671
       "Set CSNP interval in seconds\n"
 
1672
       "CSNP interval value\n")
 
1673
{
 
1674
  struct isis_circuit *circuit;
 
1675
  struct interface *ifp;
 
1676
  unsigned long interval;
 
1677
 
 
1678
  ifp  = vty->index;
 
1679
  circuit = ifp->info;
 
1680
  if (circuit == NULL) {
 
1681
    return CMD_WARNING;
 
1682
  }
 
1683
  assert (circuit);
 
1684
  
 
1685
  interval = atol (argv[0]);
 
1686
 
 
1687
  circuit->csnp_interval[0] = (u_int16_t)interval;
 
1688
  circuit->csnp_interval[1] = (u_int16_t)interval;
 
1689
    
 
1690
  return CMD_SUCCESS;
 
1691
}
 
1692
 
 
1693
DEFUN (no_csnp_interval,
 
1694
       no_csnp_interval_cmd,
 
1695
       "no isis csnp-interval",
 
1696
       NO_STR
 
1697
       "IS-IS commands\n"
 
1698
       "Set CSNP interval in seconds\n"
 
1699
       )
 
1700
{
 
1701
  struct isis_circuit *circuit;
 
1702
  struct interface *ifp;
 
1703
 
 
1704
  ifp  = vty->index;
 
1705
  circuit = ifp->info;
 
1706
  if (circuit == NULL) {
 
1707
    return CMD_WARNING;
 
1708
  }
 
1709
  assert (circuit);
 
1710
    
 
1711
  circuit->csnp_interval[0] = CSNP_INTERVAL;
 
1712
  circuit->csnp_interval[1] = CSNP_INTERVAL;
 
1713
    
 
1714
  return CMD_SUCCESS;
 
1715
}
 
1716
 
 
1717
ALIAS (no_csnp_interval,
 
1718
       no_csnp_interval_arg_cmd,
 
1719
       "no isis csnp-interval <0-65535>",
 
1720
       NO_STR
 
1721
       "IS-IS commands\n"
 
1722
       "Set CSNP interval in seconds\n"
 
1723
       "CSNP interval value\n")
 
1724
 
 
1725
 
 
1726
DEFUN (csnp_interval_l1,
 
1727
       csnp_interval_l1_cmd,
 
1728
       "isis csnp-interval <0-65535> level-1",
 
1729
       "IS-IS commands\n"
 
1730
       "Set CSNP interval in seconds\n"
 
1731
       "CSNP interval value\n"
 
1732
       "Specify interval for level-1 CSNPs\n")
 
1733
{
 
1734
  struct isis_circuit *circuit;
 
1735
  struct interface *ifp;
 
1736
  unsigned long interval;
 
1737
 
 
1738
  ifp  = vty->index;
 
1739
  circuit = ifp->info;
 
1740
  if (circuit == NULL) {
 
1741
    return CMD_WARNING;
 
1742
  }
 
1743
  assert (circuit);
 
1744
  
 
1745
  interval = atol (argv[0]);
 
1746
  
 
1747
  circuit->csnp_interval[0] = (u_int16_t)interval;
 
1748
    
 
1749
  return CMD_SUCCESS;
 
1750
}
 
1751
 
 
1752
DEFUN (no_csnp_interval_l1,
 
1753
       no_csnp_interval_l1_cmd,
 
1754
       "no isis csnp-interval level-1",
 
1755
       NO_STR
 
1756
       "IS-IS commands\n"
 
1757
       "Set CSNP interval in seconds\n"
 
1758
       "Specify interval for level-1 CSNPs\n")
 
1759
{
 
1760
  struct isis_circuit *circuit;
 
1761
  struct interface *ifp;
 
1762
 
 
1763
  ifp  = vty->index;
 
1764
  circuit = ifp->info;
 
1765
  if (circuit == NULL) {
 
1766
    return CMD_WARNING;
 
1767
  }
 
1768
  assert (circuit);
 
1769
  
 
1770
  circuit->csnp_interval[0] = CSNP_INTERVAL;
 
1771
    
 
1772
  return CMD_SUCCESS;
 
1773
}
 
1774
 
 
1775
ALIAS (no_csnp_interval_l1,
 
1776
       no_csnp_interval_l1_arg_cmd,
 
1777
       "no isis csnp-interval <0-65535> level-1",
 
1778
       NO_STR
 
1779
       "IS-IS commands\n"
 
1780
       "Set CSNP interval in seconds\n"
 
1781
       "CSNP interval value\n"
 
1782
       "Specify interval for level-1 CSNPs\n")
 
1783
 
 
1784
 
 
1785
DEFUN (csnp_interval_l2,
 
1786
       csnp_interval_l2_cmd,
 
1787
       "isis csnp-interval <0-65535> level-2",
 
1788
       "IS-IS commands\n"
 
1789
       "Set CSNP interval in seconds\n"
 
1790
       "CSNP interval value\n"
 
1791
       "Specify interval for level-2 CSNPs\n")
 
1792
{
 
1793
  struct isis_circuit *circuit;
 
1794
  struct interface *ifp;
 
1795
  unsigned long interval;
 
1796
 
 
1797
  ifp  = vty->index;
 
1798
  circuit = ifp->info;
 
1799
  if (circuit == NULL) {
 
1800
    return CMD_WARNING;
 
1801
  }
 
1802
  assert (circuit);
 
1803
  
 
1804
  interval = atol (argv[0]);
 
1805
  
 
1806
  circuit->csnp_interval[1] = (u_int16_t)interval;
 
1807
    
 
1808
  return CMD_SUCCESS;
 
1809
}
 
1810
 
 
1811
DEFUN (no_csnp_interval_l2,
 
1812
       no_csnp_interval_l2_cmd,
 
1813
       "no isis csnp-interval level-2",
 
1814
       NO_STR
 
1815
       "IS-IS commands\n"
 
1816
       "Set CSNP interval in seconds\n"
 
1817
       "Specify interval for level-2 CSNPs\n")
 
1818
{
 
1819
  struct isis_circuit *circuit;
 
1820
  struct interface *ifp;
 
1821
 
 
1822
  ifp  = vty->index;
 
1823
  circuit = ifp->info;
 
1824
  if (circuit == NULL) {
 
1825
    return CMD_WARNING;
 
1826
  }
 
1827
  assert (circuit);
 
1828
  
 
1829
  circuit->csnp_interval[1] = CSNP_INTERVAL;
 
1830
    
 
1831
  return CMD_SUCCESS;
 
1832
}
 
1833
 
 
1834
ALIAS (no_csnp_interval_l2,
 
1835
       no_csnp_interval_l2_arg_cmd,
 
1836
       "no isis csnp-interval <0-65535> level-2",
 
1837
       NO_STR
 
1838
       "IS-IS commands\n"
 
1839
       "Set CSNP interval in seconds\n"
 
1840
       "CSNP interval value\n"
 
1841
       "Specify interval for level-2 CSNPs\n")
 
1842
 
 
1843
 
 
1844
#ifdef HAVE_IPV6
 
1845
DEFUN (ipv6_router_isis,
 
1846
       ipv6_router_isis_cmd,
 
1847
       "ipv6 router isis WORD",
 
1848
       "IPv6 interface subcommands\n"
 
1849
       "IPv6 Router interface commands\n"
 
1850
       "IS-IS Routing for IPv6\n"
 
1851
       "Routing process tag\n")
 
1852
{
 
1853
  struct isis_circuit *c;
 
1854
  struct interface *ifp;
 
1855
  struct isis_area *area;
 
1856
  
 
1857
  ifp = (struct interface *)vty->index;
 
1858
  assert (ifp);
 
1859
  
 
1860
  area = isis_area_lookup (argv[0]);
 
1861
 
 
1862
  /* Prevent more than one circuit per interface */
 
1863
  if (area)
 
1864
    c = circuit_lookup_by_ifp (ifp, area->circuit_list);
 
1865
  else  c = NULL;
 
1866
  
 
1867
  if (c && (ifp->info != NULL)) {
 
1868
    if (c->ipv6_router == 1) {
 
1869
      vty_out (vty, "ISIS circuit is already defined for IPv6%s", VTY_NEWLINE);
 
1870
      return CMD_WARNING;
 
1871
    }
 
1872
  }
 
1873
 
 
1874
  /* this is here for ciscopability */
 
1875
  if (!area) {
 
1876
    vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
 
1877
    return CMD_WARNING;
 
1878
  }
 
1879
 
 
1880
  if (!c) {
 
1881
    c = circuit_lookup_by_ifp (ifp, isis->init_circ_list); 
 
1882
    c = isis_csm_state_change (ISIS_ENABLE, c, area);
 
1883
    c->interface = ifp;       
 
1884
    ifp->info = c;               
 
1885
  }
 
1886
 
 
1887
  if(!c) 
 
1888
    return CMD_WARNING;
 
1889
 
 
1890
  c->ipv6_router = 1;
 
1891
  area->ipv6_circuits++;
 
1892
  circuit_update_nlpids (c);
 
1893
 
 
1894
  vty->node = INTERFACE_NODE;
 
1895
 
 
1896
  return CMD_SUCCESS;
 
1897
}
 
1898
 
 
1899
DEFUN (no_ipv6_router_isis,
 
1900
       no_ipv6_router_isis_cmd,
 
1901
       "no ipv6 router isis WORD",
 
1902
       NO_STR
 
1903
       "IPv6 interface subcommands\n"
 
1904
       "IPv6 Router interface commands\n"
 
1905
       "IS-IS Routing for IPv6\n"
 
1906
       "Routing process tag\n")
 
1907
{
 
1908
  struct isis_circuit *c;
 
1909
  struct interface *ifp;
 
1910
  struct isis_area *area;
 
1911
  
 
1912
  ifp = (struct interface *)vty->index;
 
1913
  /* UGLY - will remove l8r
 
1914
     if (circuit == NULL) {
 
1915
  return CMD_WARNING;
 
1916
    } */
 
1917
  assert (ifp);
 
1918
  
 
1919
  area = isis_area_lookup (argv[0]);
 
1920
  if (!area) {
 
1921
    vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
 
1922
    return CMD_WARNING;
 
1923
  }
 
1924
 
 
1925
  c = circuit_lookup_by_ifp (ifp, area->circuit_list);
 
1926
  if (!c)
 
1927
    return CMD_WARNING;
 
1928
 
 
1929
  c->ipv6_router = 0;
 
1930
  area->ipv6_circuits--;
 
1931
  if (c->ip_router == 0)
 
1932
    isis_csm_state_change (ISIS_DISABLE, c, area);
 
1933
 
 
1934
  return CMD_SUCCESS;
 
1935
}
 
1936
 
 
1937
#if 0 /* Guess we don't really need these */
 
1938
 
 
1939
DEFUN (ipv6_address,
 
1940
       ipv6_address_cmd,
 
1941
       "ipv6 address X:X::X:X/M",
 
1942
       "Interface Internet Protocol config commands\n"
 
1943
       "Set the IP address of an interface\n"
 
1944
       "IPv6 address (e.g. 3ffe:506::1/48)\n")
 
1945
{
 
1946
  struct interface *ifp;
 
1947
  struct isis_circuit *circuit;
 
1948
  struct prefix_ipv6 *ipv6, *ip6;
 
1949
  struct listnode *node;
 
1950
  int ret, found = 1;
 
1951
 
 
1952
  ifp  = vty->index;
 
1953
  circuit = ifp->info;
 
1954
  /* UGLY - will remove l8r */
 
1955
  if (circuit == NULL) {
 
1956
    return CMD_WARNING;
 
1957
  }
 
1958
  assert (circuit);
 
1959
#ifdef EXTREME_DEBUG
 
1960
  zlog_info ("ipv6_address_cmd circuit %d", circuit->idx);
 
1961
#endif /* EXTREME_DEBUG */
 
1962
  
 
1963
  if (circuit == NULL) {
 
1964
    zlog_warn ("ipv6_address_cmd(): no circuit");
 
1965
    return CMD_WARNING;
 
1966
  }
 
1967
  
 
1968
  
 
1969
  ipv6 = prefix_ipv6_new ();
 
1970
  
 
1971
  ret = str2prefix_ipv6 (argv[0], ipv6);
 
1972
  if (ret <= 0) {
 
1973
    vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
 
1974
    return CMD_WARNING;
 
1975
  }
 
1976
  
 
1977
  if (!circuit->ipv6_addrs) 
 
1978
    circuit->ipv6_addrs = list_new ();
 
1979
  else {
 
1980
    for (node = listhead (circuit->ipv6_addrs); node; nextnode (node)) {
 
1981
      ip6 = getdata (node);
 
1982
      if (prefix_same ((struct prefix *)ip6, (struct prefix *)ipv6))
 
1983
      found = 1;
 
1984
    }
 
1985
    if (found) {
 
1986
    prefix_ipv6_free (ipv6);
 
1987
    return CMD_SUCCESS;
 
1988
    }
 
1989
  }
 
1990
 
 
1991
  
 
1992
  listnode_add (circuit->ipv6_addrs, ipv6);
 
1993
#ifdef EXTREME_DEBUG
 
1994
  zlog_info ("added IPv6 address %s to circuit %d", argv[0], circuit->idx);
 
1995
#endif /* EXTREME_DEBUG */
 
1996
 
 
1997
  return CMD_SUCCESS;
 
1998
}
 
1999
 
 
2000
DEFUN (no_ipv6_address,
 
2001
       no_ipv6_address_cmd,
 
2002
       "no ipv6 address X:X::X:X/M",              
 
2003
       NO_STR
 
2004
       "Interface Internet Protocol config commands\n"
 
2005
       "Set the IP address of an interface\n"
 
2006
       "IPv6 address (e.g. 3ffe:506::1/48)\n")
 
2007
{
 
2008
  struct interface *ifp;
 
2009
  struct isis_circuit *circuit;
 
2010
  struct prefix_ipv6 ipv6, *ip6 = NULL;
 
2011
  struct listnode *node;
 
2012
  int ret;
 
2013
 
 
2014
  ifp  = vty->index;
 
2015
  circuit = ifp->info;
 
2016
  /* UGLY - will remove l8r */
 
2017
  if (circuit == NULL) {
 
2018
    return CMD_WARNING;
 
2019
  }
 
2020
  assert (circuit);
 
2021
 
 
2022
  if (!circuit->ipv6_addrs || circuit->ipv6_addrs->count == 0) {
 
2023
    vty_out (vty, "Invalid address %s", VTY_NEWLINE);
 
2024
    return CMD_WARNING;
 
2025
  }
 
2026
  ret = str2prefix_ipv6 (argv[0], &ipv6);
 
2027
  if (ret <= 0) {
 
2028
    vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
 
2029
    return CMD_WARNING;
 
2030
  }
 
2031
  
 
2032
  for (node = listhead (circuit->ipv6_addrs); node; nextnode (node)) {
 
2033
    ip6 = getdata (node);
 
2034
    if (prefix_same ((struct prefix *)ip6, (struct prefix *)&ipv6))
 
2035
      break;
 
2036
  }
 
2037
  
 
2038
  if (ip6) {
 
2039
    listnode_delete (circuit->ipv6_addrs, ip6);
 
2040
  } else {
 
2041
    vty_out (vty, "Invalid address %s", VTY_NEWLINE);
 
2042
  }
 
2043
  
 
2044
  return CMD_SUCCESS;
 
2045
}
 
2046
#endif /* 0 */
 
2047
#endif /* HAVE_IPV6 */ 
 
2048
 
 
2049
 
 
2050
struct cmd_node interface_node =
 
2051
{
 
2052
  INTERFACE_NODE,
 
2053
  "%s(config-if)# ",
 
2054
  1,
 
2055
};
 
2056
 
 
2057
 
 
2058
int
 
2059
isis_if_new_hook (struct interface *ifp)
 
2060
{
 
2061
/* FIXME: Discuss if the circuit should be created here
 
2062
  ifp->info = XMALLOC (MTYPE_ISIS_IF_INFO, sizeof (struct isis_if_info)); */
 
2063
  ifp->info = NULL;
 
2064
  return 0;
 
2065
}
 
2066
 
 
2067
int
 
2068
isis_if_delete_hook (struct interface *ifp)
 
2069
{
 
2070
/* FIXME: Discuss if the circuit should be created here
 
2071
  XFREE (MTYPE_ISIS_IF_INFO, ifp->info);*/
 
2072
  ifp->info = NULL;
 
2073
  return 0;
 
2074
}
 
2075
 
 
2076
 
 
2077
void
 
2078
isis_circuit_init ()
 
2079
{
 
2080
  
 
2081
  /* Initialize Zebra interface data structure */
 
2082
  if_init ();
 
2083
  if_add_hook (IF_NEW_HOOK, isis_if_new_hook);
 
2084
  if_add_hook (IF_DELETE_HOOK, isis_if_delete_hook);
 
2085
 
 
2086
  /* Install interface node */
 
2087
  install_node (&interface_node, isis_interface_config_write);
 
2088
  install_element (CONFIG_NODE, &interface_cmd);
 
2089
 
 
2090
  install_default (INTERFACE_NODE);
 
2091
  install_element (INTERFACE_NODE, &interface_desc_cmd);
 
2092
  install_element (INTERFACE_NODE, &no_interface_desc_cmd);
 
2093
 
 
2094
  install_element (INTERFACE_NODE, &ip_router_isis_cmd);
 
2095
  install_element (INTERFACE_NODE, &no_ip_router_isis_cmd);
 
2096
 
 
2097
  install_element (INTERFACE_NODE, &isis_circuit_type_cmd);
 
2098
  install_element (INTERFACE_NODE, &no_isis_circuit_type_cmd);
 
2099
 
 
2100
  install_element (INTERFACE_NODE, &isis_passwd_cmd);
 
2101
  install_element (INTERFACE_NODE, &no_isis_passwd_cmd);
 
2102
 
 
2103
  install_element (INTERFACE_NODE, &isis_priority_cmd);
 
2104
  install_element (INTERFACE_NODE, &no_isis_priority_cmd);
 
2105
  install_element (INTERFACE_NODE, &no_isis_priority_arg_cmd);
 
2106
  install_element (INTERFACE_NODE, &isis_priority_l1_cmd);
 
2107
  install_element (INTERFACE_NODE, &no_isis_priority_l1_cmd);
 
2108
  install_element (INTERFACE_NODE, &no_isis_priority_l1_arg_cmd);
 
2109
  install_element (INTERFACE_NODE, &isis_priority_l2_cmd);
 
2110
  install_element (INTERFACE_NODE, &no_isis_priority_l2_cmd);
 
2111
  install_element (INTERFACE_NODE, &no_isis_priority_l2_arg_cmd);
 
2112
 
 
2113
  install_element (INTERFACE_NODE, &isis_metric_cmd);
 
2114
  install_element (INTERFACE_NODE, &no_isis_metric_cmd);
 
2115
  install_element (INTERFACE_NODE, &no_isis_metric_arg_cmd);
 
2116
 
 
2117
  install_element (INTERFACE_NODE, &isis_hello_interval_cmd);
 
2118
  install_element (INTERFACE_NODE, &no_isis_hello_interval_cmd);
 
2119
  install_element (INTERFACE_NODE, &no_isis_hello_interval_arg_cmd);
 
2120
  install_element (INTERFACE_NODE, &isis_hello_interval_l1_cmd);
 
2121
  install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_cmd);
 
2122
  install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_arg_cmd);
 
2123
  install_element (INTERFACE_NODE, &isis_hello_interval_l2_cmd);
 
2124
  install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_cmd);
 
2125
  install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_arg_cmd);
 
2126
 
 
2127
  install_element (INTERFACE_NODE, &isis_hello_multiplier_cmd);
 
2128
  install_element (INTERFACE_NODE, &no_isis_hello_multiplier_cmd);
 
2129
  install_element (INTERFACE_NODE, &no_isis_hello_multiplier_arg_cmd);
 
2130
  install_element (INTERFACE_NODE, &isis_hello_multiplier_l1_cmd);
 
2131
  install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_cmd);
 
2132
  install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_arg_cmd);
 
2133
  install_element (INTERFACE_NODE, &isis_hello_multiplier_l2_cmd);
 
2134
  install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_cmd);
 
2135
  install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_arg_cmd);
 
2136
 
 
2137
  install_element (INTERFACE_NODE, &isis_hello_cmd);
 
2138
  install_element (INTERFACE_NODE, &no_isis_hello_cmd);
 
2139
#if 0
 
2140
  install_element (INTERFACE_NODE, &ip_address_cmd);
 
2141
  install_element (INTERFACE_NODE, &no_ip_address_cmd);
 
2142
#endif
 
2143
  install_element (INTERFACE_NODE, &csnp_interval_cmd);
 
2144
  install_element (INTERFACE_NODE, &no_csnp_interval_cmd);
 
2145
  install_element (INTERFACE_NODE, &no_csnp_interval_arg_cmd);
 
2146
  install_element (INTERFACE_NODE, &csnp_interval_l1_cmd);
 
2147
  install_element (INTERFACE_NODE, &no_csnp_interval_l1_cmd);
 
2148
  install_element (INTERFACE_NODE, &no_csnp_interval_l1_arg_cmd);
 
2149
  install_element (INTERFACE_NODE, &csnp_interval_l2_cmd);
 
2150
  install_element (INTERFACE_NODE, &no_csnp_interval_l2_cmd);
 
2151
  install_element (INTERFACE_NODE, &no_csnp_interval_l2_arg_cmd);
 
2152
 
 
2153
#ifdef HAVE_IPV6
 
2154
  install_element (INTERFACE_NODE, &ipv6_router_isis_cmd);
 
2155
  install_element (INTERFACE_NODE, &no_ipv6_router_isis_cmd);
 
2156
#if 0
 
2157
  install_element (INTERFACE_NODE, &ipv6_address_cmd);
 
2158
  install_element (INTERFACE_NODE, &no_ipv6_address_cmd);
 
2159
#endif
 
2160
#endif
 
2161
 
 
2162
}