]> git.proxmox.com Git - mirror_frr.git/blame - eigrpd/eigrp_vty.c
*: add indent control files
[mirror_frr.git] / eigrpd / eigrp_vty.c
CommitLineData
7f57883e
DS
1/*
2 * EIGRP VTY Interface.
3 * Copyright (C) 2013-2016
4 * Authors:
5 * Donnie Savage
6 * Jan Janovic
7 * Matej Perina
8 * Peter Orsag
9 * Peter Paluch
10 * Frantisek Gazo
11 * Tomas Hvorkovy
12 * Martin Kontsek
13 * Lukas Koribsky
14 *
15 * This file is part of GNU Zebra.
16 *
17 * GNU Zebra is free software; you can redistribute it and/or modify it
18 * under the terms of the GNU General Public License as published by the
19 * Free Software Foundation; either version 2, or (at your option) any
20 * later version.
21 *
22 * GNU Zebra is distributed in the hope that it will be useful, but
23 * WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * General Public License for more details.
26 *
896014f4
DL
27 * You should have received a copy of the GNU General Public License along
28 * with this program; see the file COPYING; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
7f57883e
DS
30 */
31
32#include <zebra.h>
33
34#include "memory.h"
35#include "thread.h"
36#include "prefix.h"
37#include "table.h"
38#include "vty.h"
39#include "command.h"
40#include "plist.h"
41#include "log.h"
42#include "zclient.h"
43#include "keychain.h"
44#include "linklist.h"
45#include "distribute.h"
46
47#include "eigrpd/eigrp_structs.h"
48#include "eigrpd/eigrpd.h"
49#include "eigrpd/eigrp_interface.h"
50#include "eigrpd/eigrp_neighbor.h"
51#include "eigrpd/eigrp_packet.h"
52#include "eigrpd/eigrp_zebra.h"
53#include "eigrpd/eigrp_vty.h"
54#include "eigrpd/eigrp_network.h"
55#include "eigrpd/eigrp_dump.h"
56#include "eigrpd/eigrp_const.h"
57
7f57883e
DS
58static int
59config_write_network (struct vty *vty, struct eigrp *eigrp)
60{
61 struct route_node *rn;
07ccdc88 62 int i;
7f57883e
DS
63
64 /* `network area' print. */
65 for (rn = route_top (eigrp->networks); rn; rn = route_next (rn))
66 if (rn->info)
67 {
68 /* Network print. */
5c7571d4 69 vty_out (vty, " network %s/%d \n",
96ade3ed 70 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7f57883e
DS
71 }
72
73 if (eigrp->max_paths != EIGRP_MAX_PATHS_DEFAULT)
5c7571d4 74 vty_out (vty, " maximum-paths %d\n", eigrp->max_paths);
7f57883e
DS
75
76 if (eigrp->variance != EIGRP_VARIANCE_DEFAULT)
5c7571d4 77 vty_out (vty, " variance %d\n", eigrp->variance);
7f57883e 78
07ccdc88
DS
79 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
80 if (i != zclient->redist_default &&
81 vrf_bitmap_check (zclient->redist[AFI_IP][i], VRF_DEFAULT))
82 vty_outln (vty, " redistribute %s", zebra_route_string(i));
83
7f57883e 84 /*Separate EIGRP configuration from the rest of the config*/
5c7571d4 85 vty_out (vty, "!\n");
7f57883e
DS
86
87 return 0;
88}
89
90static int
91config_write_interfaces (struct vty *vty, struct eigrp *eigrp)
92{
93 struct eigrp_interface *ei;
94 struct listnode *node;
95
96 for (ALL_LIST_ELEMENTS_RO (eigrp->eiflist, node, ei))
97 {
5c7571d4 98 vty_out (vty, "interface %s\n", ei->ifp->name);
7f57883e
DS
99
100 if ((IF_DEF_PARAMS (ei->ifp)->auth_type) == EIGRP_AUTH_TYPE_MD5)
101 {
5c7571d4 102 vty_out (vty, " ip authentication mode eigrp %d md5\n", eigrp->AS);
7f57883e
DS
103 }
104
105 if ((IF_DEF_PARAMS (ei->ifp)->auth_type) == EIGRP_AUTH_TYPE_SHA256)
106 {
5c7571d4 107 vty_out (vty, " ip authentication mode eigrp %d hmac-sha-256\n",
96ade3ed 108 eigrp->AS);
7f57883e
DS
109 }
110
111 if(IF_DEF_PARAMS (ei->ifp)->auth_keychain)
112 {
5c7571d4 113 vty_out (vty, " ip authentication key-chain eigrp %d %s\n",eigrp->AS,
96ade3ed 114 IF_DEF_PARAMS(ei->ifp)->auth_keychain);
7f57883e
DS
115 }
116
117 if ((IF_DEF_PARAMS (ei->ifp)->v_hello) != EIGRP_HELLO_INTERVAL_DEFAULT)
118 {
5c7571d4 119 vty_out (vty, " ip hello-interval eigrp %d\n",
96ade3ed 120 IF_DEF_PARAMS(ei->ifp)->v_hello);
7f57883e
DS
121 }
122
123 if ((IF_DEF_PARAMS (ei->ifp)->v_wait) != EIGRP_HOLD_INTERVAL_DEFAULT)
124 {
5c7571d4 125 vty_out (vty, " ip hold-time eigrp %d\n",
96ade3ed 126 IF_DEF_PARAMS(ei->ifp)->v_wait);
7f57883e
DS
127 }
128
129 /*Separate this EIGRP interface configuration from the others*/
5c7571d4 130 vty_out (vty, "!\n");
7f57883e
DS
131 }
132
133 return 0;
134}
135
136static int
137eigrp_write_interface (struct vty *vty)
138{
63863c47
RW
139 struct listnode *node;
140 struct interface *ifp;
141
142 for (ALL_LIST_ELEMENTS_RO (vrf_iflist(VRF_DEFAULT), node, ifp)) {
5c7571d4 143 vty_out (vty, "interface %s\n",ifp->name);
63863c47
RW
144
145 if (ifp->desc)
5c7571d4 146 vty_out (vty, " description %s\n",ifp->desc);
63863c47
RW
147
148 if (IF_DEF_PARAMS (ifp)->bandwidth != EIGRP_BANDWIDTH_DEFAULT)
5c7571d4 149 vty_out (vty, " bandwidth %u\n",IF_DEF_PARAMS(ifp)->bandwidth);
63863c47 150 if (IF_DEF_PARAMS (ifp)->delay != EIGRP_DELAY_DEFAULT)
5c7571d4 151 vty_out (vty, " delay %u\n", IF_DEF_PARAMS(ifp)->delay);
63863c47 152 if (IF_DEF_PARAMS (ifp)->v_hello != EIGRP_HELLO_INTERVAL_DEFAULT)
5c7571d4 153 vty_out (vty, " ip hello-interval eigrp %u\n",
96ade3ed 154 IF_DEF_PARAMS(ifp)->v_hello);
63863c47 155 if (IF_DEF_PARAMS (ifp)->v_wait != EIGRP_HOLD_INTERVAL_DEFAULT)
5c7571d4 156 vty_out (vty, " ip hold-time eigrp %u\n",
96ade3ed 157 IF_DEF_PARAMS(ifp)->v_wait);
63863c47 158
5c7571d4 159 vty_out (vty, "!\n");
63863c47 160 }
7f57883e 161
63863c47 162 return 0;
7f57883e
DS
163}
164
165/**
166 * Writes distribute lists to config
167 */
168static int
169config_write_eigrp_distribute (struct vty *vty, struct eigrp *eigrp)
170{
171 int write=0;
172
173 /* Distribute configuration. */
174 write += config_write_distribute (vty);
175
176 return write;
177}
178
179/**
180 * Writes 'router eigrp' section to config
181 */
182static int
183config_write_eigrp_router (struct vty *vty, struct eigrp *eigrp)
184{
185 int write=0;
186
187 /* `router eigrp' print. */
5c7571d4 188 vty_out (vty, "router eigrp %d\n", eigrp->AS);
7f57883e
DS
189
190 write++;
191
192 if (!eigrp->networks)
193 return write;
194
195 /* Router ID print. */
196 if (eigrp->router_id_static != 0)
197 {
198 struct in_addr router_id_static;
199 router_id_static.s_addr = htonl(eigrp->router_id_static);
5c7571d4 200 vty_out (vty, " eigrp router-id %s\n",
96ade3ed 201 inet_ntoa(router_id_static));
7f57883e
DS
202 }
203
204 /* Network area print. */
205 config_write_network (vty, eigrp);
206
207 /* Distribute-list and default-information print. */
208 config_write_eigrp_distribute (vty, eigrp);
209
210 /*Separate EIGRP configuration from the rest of the config*/
5c7571d4 211 vty_out (vty, "!\n");
7f57883e
DS
212
213 return write;
214}
215
c18f84f6 216DEFUN_NOSH (router_eigrp,
f9e5c9ca
DS
217 router_eigrp_cmd,
218 "router eigrp (1-65535)",
219 "Enable a routing process\n"
220 "Start EIGRP configuration\n"
221 "AS Number to use\n")
7f57883e
DS
222{
223 struct eigrp *eigrp = eigrp_get (argv[2]->arg);
224 VTY_PUSH_CONTEXT(EIGRP_NODE, eigrp);
225
226 return CMD_SUCCESS;
227}
228
7f57883e
DS
229DEFUN (no_router_eigrp,
230 no_router_eigrp_cmd,
231 "no router eigrp (1-65535)",
232 NO_STR
233 "Routing process\n"
234 "EIGRP configuration\n"
235 "AS number to use\n")
236{
237 vty->node = CONFIG_NODE;
238
63863c47
RW
239 struct eigrp *eigrp;
240
241 eigrp = eigrp_lookup ();
242 if (eigrp->AS != atoi (argv[3]->arg))
243 {
5c7571d4 244 vty_out (vty,"%% Attempting to deconfigure non-existent AS\n");
f1a05de9 245 return CMD_WARNING_CONFIG_FAILED;
63863c47
RW
246 }
247
248 eigrp_finish_final (eigrp);
7f57883e
DS
249
250 return CMD_SUCCESS;
251}
252
253DEFUN (eigrp_router_id,
254 eigrp_router_id_cmd,
255 "eigrp router-id A.B.C.D",
256 "EIGRP specific commands\n"
257 "Router ID for this EIGRP process\n"
258 "EIGRP Router-ID in IP address format\n")
259{
260 //struct eigrp *eigrp = vty->index;
261 /*TODO: */
262
263 return CMD_SUCCESS;
264}
265
266DEFUN (no_eigrp_router_id,
267 no_eigrp_router_id_cmd,
268 "no eigrp router-id A.B.C.D",
269 NO_STR
270 "EIGRP specific commands\n"
271 "Router ID for this EIGRP process\n"
272 "EIGRP Router-ID in IP address format\n")
273{
274 //struct eigrp *eigrp = vty->index;
275 /*TODO: */
276
277 return CMD_SUCCESS;
278}
279
280DEFUN (eigrp_passive_interface,
281 eigrp_passive_interface_cmd,
dbc56a10 282 "passive-interface IFNAME",
7f57883e 283 "Suppress routing updates on an interface\n"
dbc56a10 284 "Interface to suppress on\n")
7f57883e 285{
be81f272
DS
286 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
287 struct eigrp_interface *ei;
288 struct listnode *node;
289 char *ifname = argv[1]->arg;
7f57883e 290
be81f272
DS
291 for (ALL_LIST_ELEMENTS_RO (eigrp->eiflist, node, ei))
292 {
293 if (strcmp (ifname, ei->ifp->name) == 0)
294 SET_IF_PARAM (IF_DEF_PARAMS (ei->ifp), passive_interface);
295 }
7f57883e
DS
296 return CMD_SUCCESS;
297}
298
299DEFUN (no_eigrp_passive_interface,
300 no_eigrp_passive_interface_cmd,
dbc56a10 301 "no passive-interface IFNAME",
7f57883e
DS
302 NO_STR
303 "Suppress routing updates on an interface\n"
dbc56a10 304 "Interface to suppress on\n")
7f57883e 305{
be81f272
DS
306 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
307 struct eigrp_interface *ei;
308 struct listnode *node;
309 char *ifname = argv[2]->arg;
310
311 for (ALL_LIST_ELEMENTS_RO (eigrp->eiflist, node, ei))
312 {
313 if (strcmp (ifname, ei->ifp->name) == 0)
314 UNSET_IF_PARAM (IF_DEF_PARAMS (ei->ifp), passive_interface);
315 }
7f57883e
DS
316
317 return CMD_SUCCESS;
318}
319
320DEFUN (eigrp_timers_active,
321 eigrp_timers_active_cmd,
322 "timers active-time <(1-65535)|disabled>",
323 "Adjust routing timers\n"
324 "Time limit for active state\n"
325 "Active state time limit in minutes\n"
326 "Disable time limit for active state\n")
327{
328 //struct eigrp *eigrp = vty->index;
329 /*TODO: */
330
331 return CMD_SUCCESS;
332}
333
334DEFUN (no_eigrp_timers_active,
335 no_eigrp_timers_active_cmd,
336 "no timers active-time <(1-65535)|disabled>",
337 NO_STR
338 "Adjust routing timers\n"
339 "Time limit for active state\n"
340 "Active state time limit in minutes\n"
341 "Disable time limit for active state\n")
342{
343 //struct eigrp *eigrp = vty->index;
344 /*TODO: */
345
346 return CMD_SUCCESS;
347}
348
349
350DEFUN (eigrp_metric_weights,
351 eigrp_metric_weights_cmd,
352 "metric weights (0-255) (0-255) (0-255) (0-255) (0-255) ",
353 "Modify metrics and parameters for advertisement\n"
354 "Modify metric coefficients\n"
355 "K1\n"
356 "K2\n"
357 "K3\n"
358 "K4\n"
359 "K5\n")
360{
361 //struct eigrp *eigrp = vty->index;
362 /*TODO: */
363
364 return CMD_SUCCESS;
365}
366
367DEFUN (no_eigrp_metric_weights,
368 no_eigrp_metric_weights_cmd,
369 "no metric weights <0-255> <0-255> <0-255> <0-255> <0-255>",
370 NO_STR
371 "Modify metrics and parameters for advertisement\n"
372 "Modify metric coefficients\n"
373 "K1\n"
374 "K2\n"
375 "K3\n"
376 "K4\n"
377 "K5\n")
378{
379 //struct eigrp *eigrp = vty->index;
380 /*TODO: */
381
382 return CMD_SUCCESS;
383}
384
385
386DEFUN (eigrp_network,
387 eigrp_network_cmd,
388 "network A.B.C.D/M",
389 "Enable routing on an IP network\n"
390 "EIGRP network prefix\n")
391{
f9e5c9ca 392 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
7f57883e
DS
393 struct prefix_ipv4 p;
394 int ret;
395
facfee22 396 str2prefix_ipv4(argv[1]->arg, &p);
7f57883e
DS
397
398 ret = eigrp_network_set (eigrp, &p);
399
400 if (ret == 0)
401 {
5c7571d4 402 vty_out (vty, "There is already same network statement.\n");
f1a05de9 403 return CMD_WARNING_CONFIG_FAILED;
7f57883e
DS
404 }
405
406 return CMD_SUCCESS;
407}
408
409DEFUN (no_eigrp_network,
410 no_eigrp_network_cmd,
411 "no network A.B.C.D/M",
412 NO_STR
413 "Disable routing on an IP network\n"
414 "EIGRP network prefix\n")
415{
416 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
417 struct prefix_ipv4 p;
418 int ret;
419
facfee22 420 str2prefix_ipv4(argv[2]->arg, &p);
7f57883e
DS
421
422 ret = eigrp_network_unset (eigrp, &p);
423
424 if (ret == 0)
425 {
5c7571d4 426 vty_out (vty,"Can't find specified network configuration.\n");
f1a05de9 427 return CMD_WARNING_CONFIG_FAILED;
7f57883e
DS
428 }
429
430 return CMD_SUCCESS;
431}
432
433DEFUN (eigrp_neighbor,
434 eigrp_neighbor_cmd,
dbc56a10 435 "neighbor A.B.C.D",
7f57883e 436 "Specify a neighbor router\n"
dbc56a10 437 "Neighbor address\n")
7f57883e
DS
438{
439 //struct eigrp *eigrp = vty->index;
440
441 return CMD_SUCCESS;
442}
443
444DEFUN (no_eigrp_neighbor,
445 no_eigrp_neighbor_cmd,
dbc56a10 446 "no neighbor A.B.C.D",
7f57883e
DS
447 NO_STR
448 "Specify a neighbor router\n"
dbc56a10 449 "Neighbor address\n")
7f57883e
DS
450{
451 //struct eigrp *eigrp = vty->index;
452
453 return CMD_SUCCESS;
454}
455
456DEFUN (show_ip_eigrp_topology,
457 show_ip_eigrp_topology_cmd,
63863c47 458 "show ip eigrp topology [all-links]",
7f57883e
DS
459 SHOW_STR
460 IP_STR
461 "IP-EIGRP show commands\n"
462 "IP-EIGRP topology\n"
463 "Show all links in topology table\n")
464{
465 struct eigrp *eigrp;
63863c47 466 struct listnode *node, *node2;
7f57883e
DS
467 struct eigrp_prefix_entry *tn;
468 struct eigrp_neighbor_entry *te;
63863c47 469 int first;
7f57883e
DS
470
471 eigrp = eigrp_lookup ();
472 if (eigrp == NULL)
473 {
5c7571d4 474 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
475 return CMD_SUCCESS;
476 }
477
478 show_ip_eigrp_topology_header (vty, eigrp);
479
63863c47 480 for (ALL_LIST_ELEMENTS_RO (eigrp->topology_table, node, tn))
7f57883e 481 {
63863c47
RW
482 first = 1;
483 for (ALL_LIST_ELEMENTS_RO (tn->entries, node2, te))
7f57883e 484 {
63863c47
RW
485 if (argc == 5 ||
486 (((te->flags & EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG) == EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG)||
487 ((te->flags & EIGRP_NEIGHBOR_ENTRY_FSUCCESSOR_FLAG) == EIGRP_NEIGHBOR_ENTRY_FSUCCESSOR_FLAG)))
488 {
489 show_ip_eigrp_neighbor_entry (vty, eigrp, te, &first);
490 first = 0;
491 }
7f57883e
DS
492 }
493 }
494
495 return CMD_SUCCESS;
496}
497
498ALIAS (show_ip_eigrp_topology,
499 show_ip_eigrp_topology_detail_cmd,
500 "show ip eigrp topology <A.B.C.D|A.B.C.D/M|detail|summary>",
501 SHOW_STR
502 IP_STR
503 "IP-EIGRP show commands\n"
504 "IP-EIGRP topology\n"
505 "Netwok to display information about\n"
506 "IP prefix <network>/<length>, e.g., 192.168.0.0/16\n"
507 "Show all links in topology table\n"
508 "Show a summary of the topology table\n")
509
510DEFUN (show_ip_eigrp_interfaces,
511 show_ip_eigrp_interfaces_cmd,
dbc56a10 512 "show ip eigrp interfaces [IFNAME] [detail]",
7f57883e
DS
513 SHOW_STR
514 IP_STR
515 "IP-EIGRP show commands\n"
dbc56a10
DS
516 "IP-EIGRP interfaces\n"
517 "Interface name to look at\n"
518 "Detailed information\n")
7f57883e
DS
519{
520 struct eigrp_interface *ei;
521 struct eigrp *eigrp;
522 struct listnode *node;
dbc56a10
DS
523 int idx = 0;
524 bool detail = false;
525 const char *ifname = NULL;
7f57883e
DS
526
527 eigrp = eigrp_lookup ();
528 if (eigrp == NULL)
529 {
5c7571d4 530 vty_out (vty, "EIGRP Routing Process not enabled\n");
7f57883e
DS
531 return CMD_SUCCESS;
532 }
533
dbc56a10
DS
534 if (argv_find (argv, argc, "IFNAME", &idx))
535 ifname = argv[idx]->arg;
536
537 if (argv_find (argv, argc, "detail", &idx))
538 detail = true;
539
540 if (!ifname)
541 show_ip_eigrp_interface_header (vty, eigrp);
7f57883e 542
7f57883e 543 for (ALL_LIST_ELEMENTS_RO (eigrp->eiflist, node, ei))
f9e5c9ca 544 {
dbc56a10 545 if (!ifname || strcmp (ei->ifp->name, ifname) == 0)
f9e5c9ca 546 {
dbc56a10
DS
547 show_ip_eigrp_interface_sub (vty, eigrp, ei);
548 if (detail)
549 show_ip_eigrp_interface_detail (vty, eigrp, ei);
f9e5c9ca
DS
550 }
551 }
7f57883e
DS
552
553 return CMD_SUCCESS;
554}
555
7f57883e
DS
556DEFUN (show_ip_eigrp_neighbors,
557 show_ip_eigrp_neighbors_cmd,
dbc56a10 558 "show ip eigrp neighbors [IFNAME] [detail]",
7f57883e
DS
559 SHOW_STR
560 IP_STR
561 "IP-EIGRP show commands\n"
dbc56a10
DS
562 "IP-EIGRP neighbors\n"
563 "Interface to show on\n"
564 "Detailed Information\n")
7f57883e
DS
565{
566 struct eigrp *eigrp;
567 struct eigrp_interface *ei;
568 struct listnode *node, *node2, *nnode2;
569 struct eigrp_neighbor *nbr;
dbc56a10 570 bool detail = false;
7f57883e 571 int idx = 0;
dbc56a10 572 const char *ifname = NULL;
7f57883e
DS
573
574 eigrp = eigrp_lookup ();
575 if (eigrp == NULL)
576 {
5c7571d4 577 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
578 return CMD_SUCCESS;
579 }
580
dbc56a10
DS
581 if (argv_find(argv, argc, "IFNAME", &idx))
582 ifname = argv[idx]->arg;
583
7f57883e 584 detail = (argv_find(argv, argc, "detail", &idx));
dbc56a10 585
7f57883e
DS
586 show_ip_eigrp_neighbor_header (vty, eigrp);
587
588 for (ALL_LIST_ELEMENTS_RO (eigrp->eiflist, node, ei))
589 {
dbc56a10 590 if (!ifname || strcmp(ei->ifp->name, ifname) == 0)
7f57883e 591 {
dbc56a10
DS
592 for (ALL_LIST_ELEMENTS (ei->nbrs, node2, nnode2, nbr))
593 {
594 if (detail || (nbr->state == EIGRP_NEIGHBOR_UP))
595 show_ip_eigrp_neighbor_sub (vty, nbr, detail);
596 }
7f57883e
DS
597 }
598 }
599
600 return CMD_SUCCESS;
601}
602
7f57883e
DS
603DEFUN (eigrp_if_delay,
604 eigrp_if_delay_cmd,
605 "delay (1-16777215)",
606 "Specify interface throughput delay\n"
607 "Throughput delay (tens of microseconds)\n")
608{
609 VTY_DECLVAR_CONTEXT(interface, ifp);
610 struct eigrp *eigrp;
611 u_int32_t delay;
612
613 eigrp = eigrp_lookup ();
614 if (eigrp == NULL)
615 {
5c7571d4 616 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
617
618 return CMD_SUCCESS;
619 }
620
621 delay = atoi (argv[1]->arg);
622
623 IF_DEF_PARAMS (ifp)->delay = delay;
63863c47 624 eigrp_if_reset (ifp);
7f57883e
DS
625
626 return CMD_SUCCESS;
627}
628
629DEFUN (no_eigrp_if_delay,
630 no_eigrp_if_delay_cmd,
631 "no delay (1-16777215)",
632 NO_STR
633 "Specify interface throughput delay\n"
634 "Throughput delay (tens of microseconds)\n")
635{
636 VTY_DECLVAR_CONTEXT(interface, ifp);
637 struct eigrp *eigrp;
638
639 eigrp = eigrp_lookup ();
640 if (eigrp == NULL)
641 {
5c7571d4 642 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
643
644 return CMD_SUCCESS;
645 }
646
647 IF_DEF_PARAMS (ifp)->delay = EIGRP_DELAY_DEFAULT;
63863c47 648 eigrp_if_reset (ifp);
7f57883e
DS
649
650 return CMD_SUCCESS;
651}
652
653DEFUN (eigrp_if_bandwidth,
654 eigrp_if_bandwidth_cmd,
a108e6e4
QY
655 "eigrp bandwidth (1-10000000)",
656 "EIGRP specific commands\n"
7f57883e
DS
657 "Set bandwidth informational parameter\n"
658 "Bandwidth in kilobits\n")
659{
660 VTY_DECLVAR_CONTEXT(interface, ifp);
661 u_int32_t bandwidth;
662 struct eigrp *eigrp;
663
664 eigrp = eigrp_lookup ();
665 if (eigrp == NULL)
666 {
5c7571d4 667 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
668 return CMD_SUCCESS;
669 }
670
671 bandwidth = atoi (argv[1]->arg);
672
673 IF_DEF_PARAMS (ifp)->bandwidth = bandwidth;
63863c47 674 eigrp_if_reset (ifp);
7f57883e
DS
675
676 return CMD_SUCCESS;
677}
678
679DEFUN (no_eigrp_if_bandwidth,
680 no_eigrp_if_bandwidth_cmd,
a108e6e4 681 "no eigrp bandwidth [(1-10000000)]",
63863c47 682 NO_STR
a108e6e4 683 "EIGRP specific commands\n"
7f57883e
DS
684 "Set bandwidth informational parameter\n"
685 "Bandwidth in kilobits\n")
686{
687 VTY_DECLVAR_CONTEXT(interface, ifp);
7f57883e 688 struct eigrp *eigrp;
7f57883e
DS
689
690 eigrp = eigrp_lookup ();
691 if (eigrp == NULL)
692 {
5c7571d4 693 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
694 return CMD_SUCCESS;
695 }
696
63863c47
RW
697 IF_DEF_PARAMS (ifp)->bandwidth = EIGRP_BANDWIDTH_DEFAULT;
698 eigrp_if_reset (ifp);
7f57883e
DS
699
700 return CMD_SUCCESS;
701}
702
703DEFUN (eigrp_if_ip_hellointerval,
704 eigrp_if_ip_hellointerval_cmd,
705 "ip hello-interval eigrp (1-65535)",
706 "Interface Internet Protocol config commands\n"
707 "Configures EIGRP hello interval\n"
708 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
709 "Seconds between hello transmissions\n")
710{
711 VTY_DECLVAR_CONTEXT(interface, ifp);
712 u_int32_t hello;
713 struct eigrp *eigrp;
714
715 eigrp = eigrp_lookup ();
716 if (eigrp == NULL)
717 {
5c7571d4 718 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
719 return CMD_SUCCESS;
720 }
721
722 hello = atoi (argv[3]->arg);
723
724 IF_DEF_PARAMS (ifp)->v_hello = hello;
725
726 return CMD_SUCCESS;
727}
728
729DEFUN (no_eigrp_if_ip_hellointerval,
730 no_eigrp_if_ip_hellointerval_cmd,
63863c47 731 "no ip hello-interval eigrp [(1-65535)]",
7f57883e
DS
732 NO_STR
733 "Interface Internet Protocol config commands\n"
734 "Configures EIGRP hello interval\n"
735 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
736 "Seconds between hello transmissions\n")
737{
738 VTY_DECLVAR_CONTEXT(interface, ifp);
739 struct eigrp *eigrp;
63863c47
RW
740 struct eigrp_interface *ei;
741 struct listnode *node, *nnode;
7f57883e
DS
742
743 eigrp = eigrp_lookup ();
744 if (eigrp == NULL)
745 {
5c7571d4 746 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
747 return CMD_SUCCESS;
748 }
749
750 IF_DEF_PARAMS (ifp)->v_hello = EIGRP_HELLO_INTERVAL_DEFAULT;
751
63863c47
RW
752 for (ALL_LIST_ELEMENTS (eigrp->eiflist, node, nnode, ei))
753 {
754 if (ei->ifp == ifp)
755 {
756 THREAD_TIMER_OFF (ei->t_hello);
757 thread_add_timer (master, eigrp_hello_timer, ei, 1, &ei->t_hello);
758 break;
759 }
760 }
761
7f57883e
DS
762 return CMD_SUCCESS;
763}
764
7f57883e
DS
765DEFUN (eigrp_if_ip_holdinterval,
766 eigrp_if_ip_holdinterval_cmd,
767 "ip hold-time eigrp (1-65535)",
768 "Interface Internet Protocol config commands\n"
63863c47 769 "Configures EIGRP IPv4 hold time\n"
7f57883e
DS
770 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
771 "Seconds before neighbor is considered down\n")
772{
773 VTY_DECLVAR_CONTEXT(interface, ifp);
774 u_int32_t hold;
775 struct eigrp *eigrp;
776
777 eigrp = eigrp_lookup ();
778 if (eigrp == NULL)
779 {
5c7571d4 780 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
781 return CMD_SUCCESS;
782 }
783
784 hold = atoi (argv[3]->arg);
785
786 IF_DEF_PARAMS (ifp)->v_wait = hold;
787
788 return CMD_SUCCESS;
789}
790
791DEFUN (eigrp_ip_summary_address,
792 eigrp_ip_summary_address_cmd,
793 "ip summary-address eigrp (1-65535) A.B.C.D/M",
794 "Interface Internet Protocol config commands\n"
795 "Perform address summarization\n"
796 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
797 "AS number\n"
798 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
799{
c68d0348 800 //VTY_DECLVAR_CONTEXT(interface, ifp);
2221f1f6 801 //u_int32_t AS;
7f57883e
DS
802 struct eigrp *eigrp;
803
804 eigrp = eigrp_lookup ();
805 if (eigrp == NULL)
806 {
5c7571d4 807 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
808 return CMD_SUCCESS;
809 }
810
2221f1f6 811 //AS = atoi (argv[3]->arg);
7f57883e
DS
812
813 /*TODO: */
814
815 return CMD_SUCCESS;
816}
817
818DEFUN (no_eigrp_ip_summary_address,
819 no_eigrp_ip_summary_address_cmd,
820 "no ip summary-address eigrp (1-65535) A.B.C.D/M",
821 NO_STR
822 "Interface Internet Protocol config commands\n"
823 "Perform address summarization\n"
824 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
825 "AS number\n"
826 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
827{
c68d0348 828 //VTY_DECLVAR_CONTEXT(interface, ifp);
2221f1f6 829 //u_int32_t AS;
7f57883e
DS
830 struct eigrp *eigrp;
831
832 eigrp = eigrp_lookup ();
833 if (eigrp == NULL)
834 {
5c7571d4 835 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
836 return CMD_SUCCESS;
837 }
838
2221f1f6 839 //AS = atoi (argv[4]->arg);
7f57883e
DS
840
841 /*TODO: */
842
843 return CMD_SUCCESS;
844}
845
7f57883e
DS
846DEFUN (no_eigrp_if_ip_holdinterval,
847 no_eigrp_if_ip_holdinterval_cmd,
848 "no ip hold-time eigrp",
849 "No"
850 "Interface Internet Protocol config commands\n"
851 "Configures EIGRP hello interval\n"
852 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
853 "Seconds before neighbor is considered down\n")
854{
855 VTY_DECLVAR_CONTEXT(interface, ifp);
856 struct eigrp *eigrp;
857
858 eigrp = eigrp_lookup ();
859 if (eigrp == NULL)
860 {
5c7571d4 861 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
862 return CMD_SUCCESS;
863 }
864
865 IF_DEF_PARAMS (ifp)->v_wait = EIGRP_HOLD_INTERVAL_DEFAULT;
866
867 return CMD_SUCCESS;
868}
869
870static int
871str2auth_type (const char *str, struct interface *ifp)
872{
873 /* Sanity check. */
f9e5c9ca 874 if (str == NULL)
f1a05de9 875 return CMD_WARNING_CONFIG_FAILED;
7f57883e
DS
876
877 if(strncmp(str, "md5",3) == 0)
878 {
879 IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_MD5;
880 return CMD_SUCCESS;
881 }
882 else if(strncmp(str, "hmac-sha-256",12) == 0)
883 {
884 IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_SHA256;
885 return CMD_SUCCESS;
886 }
887
f1a05de9 888 return CMD_WARNING_CONFIG_FAILED;
7f57883e
DS
889}
890
891DEFUN (eigrp_authentication_mode,
892 eigrp_authentication_mode_cmd,
893 "ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
894 "Interface Internet Protocol config commands\n"
895 "Authentication subcommands\n"
896 "Mode\n"
897 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
898 "Autonomous system number\n"
899 "Keyed message digest\n"
900 "HMAC SHA256 algorithm \n")
901{
902 VTY_DECLVAR_CONTEXT(interface, ifp);
903 struct eigrp *eigrp;
904
905 eigrp = eigrp_lookup ();
906 if (eigrp == NULL)
907 {
5c7571d4 908 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
909 return CMD_SUCCESS;
910 }
911
f9e5c9ca
DS
912 // if(strncmp(argv[2], "md5",3))
913 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_MD5;
914 // else if(strncmp(argv[2], "hmac-sha-256",12))
915 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_SHA256;
7f57883e
DS
916
917 return str2auth_type(argv[5]->arg, ifp);
918}
919
920DEFUN (no_eigrp_authentication_mode,
921 no_eigrp_authentication_mode_cmd,
922 "no ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
923 "Disable\n"
924 "Interface Internet Protocol config commands\n"
925 "Authentication subcommands\n"
926 "Mode\n"
927 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
928 "Autonomous system number\n"
929 "Keyed message digest\n"
930 "HMAC SHA256 algorithm \n")
931{
932 VTY_DECLVAR_CONTEXT(interface, ifp);
933 struct eigrp *eigrp;
934
935 eigrp = eigrp_lookup ();
936 if (eigrp == NULL)
937 {
5c7571d4 938 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
939 return CMD_SUCCESS;
940 }
941
942 IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_NONE;
943
944 return CMD_SUCCESS;
945}
946
947DEFUN (eigrp_authentication_keychain,
948 eigrp_authentication_keychain_cmd,
949 "ip authentication key-chain eigrp (1-65535) WORD",
950 "Interface Internet Protocol config commands\n"
951 "Authentication subcommands\n"
952 "Key-chain\n"
953 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
954 "Autonomous system number\n"
955 "Name of key-chain\n")
956{
957 VTY_DECLVAR_CONTEXT(interface, ifp);
958 struct eigrp *eigrp;
959 struct keychain *keychain;
960
961 eigrp = eigrp_lookup ();
962 if (eigrp == NULL)
963 {
5c7571d4 964 vty_out (vty, "EIGRP Routing Process not enabled\n");
7f57883e
DS
965 return CMD_SUCCESS;
966 }
967
968 keychain = keychain_lookup (argv[4]->arg);
969 if(keychain != NULL)
970 {
971 if(IF_DEF_PARAMS (ifp)->auth_keychain)
972 {
973 free (IF_DEF_PARAMS (ifp)->auth_keychain);
974 IF_DEF_PARAMS (ifp)->auth_keychain = strdup(keychain->name);
975 }
976 else
977 IF_DEF_PARAMS (ifp)->auth_keychain = strdup(keychain->name);
978 }
979 else
5c7571d4 980 vty_out (vty,"Key chain with specified name not found\n");
7f57883e
DS
981
982 return CMD_SUCCESS;
983}
984
985DEFUN (no_eigrp_authentication_keychain,
986 no_eigrp_authentication_keychain_cmd,
987 "no ip authentication key-chain eigrp (1-65535) WORD",
988 "Disable\n"
989 "Interface Internet Protocol config commands\n"
990 "Authentication subcommands\n"
991 "Key-chain\n"
992 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
993 "Autonomous system number\n"
994 "Name of key-chain\n")
995{
996 VTY_DECLVAR_CONTEXT(interface, ifp);
997 struct eigrp *eigrp;
998
999 eigrp = eigrp_lookup ();
1000 if (eigrp == NULL)
1001 {
5c7571d4 1002 vty_out (vty, "EIGRP Routing Process not enabled\n");
7f57883e
DS
1003 return CMD_SUCCESS;
1004 }
1005
f9e5c9ca
DS
1006 if((IF_DEF_PARAMS (ifp)->auth_keychain != NULL) &&
1007 (strcmp(IF_DEF_PARAMS (ifp)->auth_keychain,argv[5]->arg)==0))
7f57883e
DS
1008 {
1009 free (IF_DEF_PARAMS (ifp)->auth_keychain);
1010 IF_DEF_PARAMS (ifp)->auth_keychain = NULL;
1011 }
1012 else
5c7571d4
DL
1013 vty_out (vty,
1014 "Key chain with specified name not configured on interface\n");
7f57883e
DS
1015
1016 return CMD_SUCCESS;
1017}
1018
7f57883e
DS
1019DEFUN (eigrp_redistribute_source_metric,
1020 eigrp_redistribute_source_metric_cmd,
1021 "redistribute " FRR_REDIST_STR_EIGRPD
63863c47 1022 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
7f57883e
DS
1023 REDIST_STR
1024 FRR_REDIST_HELP_STR_EIGRPD
1025 "Metric for redistributed routes\n"
1026 "Bandwidth metric in Kbits per second\n"
1027 "EIGRP delay metric, in 10 microsecond units\n"
1028 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1029 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1030 "EIGRP MTU of the path\n")
1031{
1032 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
1033 struct eigrp_metrics metrics_from_command = { 0 };
1034 int source;
1035 int idx = 0;
1036
1037 /* Get distribute source. */
1038 argv_find (argv, argc, "redistribute", &idx);
1039 source = proto_redistnum(AFI_IP, argv[idx+1]->arg);
1040 if (source < 0 )
f1a05de9 1041 return CMD_WARNING_CONFIG_FAILED;
7f57883e
DS
1042
1043 /* Get metrics values */
1044
1045 return eigrp_redistribute_set (eigrp, source, metrics_from_command);
1046}
1047
7f57883e 1048DEFUN (no_eigrp_redistribute_source_metric,
f9e5c9ca 1049 no_eigrp_redistribute_source_metric_cmd,
7f57883e 1050 "no redistribute " FRR_REDIST_STR_EIGRPD
f9e5c9ca
DS
1051 " metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)",
1052 "Disable\n"
7f57883e
DS
1053 REDIST_STR
1054 FRR_REDIST_HELP_STR_EIGRPD
1055 "Metric for redistributed routes\n"
1056 "Bandwidth metric in Kbits per second\n"
1057 "EIGRP delay metric, in 10 microsecond units\n"
1058 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1059 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1060 "EIGRP MTU of the path\n")
1061{
1062 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
1063 int source;
1064 int idx = 0;
1065
1066 /* Get distribute source. */
1067 argv_find (argv, argc, "redistribute", &idx);
1068 source = proto_redistnum(AFI_IP, argv[idx+1]->arg);
1069 if (source < 0 )
f1a05de9 1070 return CMD_WARNING_CONFIG_FAILED;
7f57883e
DS
1071
1072 /* Get metrics values */
1073
1074 return eigrp_redistribute_unset (eigrp, source);
1075}
1076
1077DEFUN (eigrp_variance,
1078 eigrp_variance_cmd,
1079 "variance (1-128)",
1080 "Control load balancing variance\n"
1081 "Metric variance multiplier\n")
1082{
1083 struct eigrp *eigrp;
1084 u_char variance;
1085
1086 eigrp = eigrp_lookup ();
1087 if (eigrp == NULL)
1088 {
5c7571d4 1089 vty_out (vty, "EIGRP Routing Process not enabled\n");
7f57883e
DS
1090 return CMD_SUCCESS;
1091 }
1092 variance = atoi(argv[1]->arg);
1093
1094 eigrp->variance = variance;
1095
1096 /*TODO: */
1097
1098 return CMD_SUCCESS;
1099}
1100
7f57883e
DS
1101DEFUN (no_eigrp_variance,
1102 no_eigrp_variance_cmd,
1103 "no variance (1-128)",
1104 "Disable\n"
1105 "Control load balancing variance\n"
1106 "Metric variance multiplier\n")
1107{
1108 struct eigrp *eigrp;
1109 eigrp = eigrp_lookup ();
1110 if (eigrp == NULL)
1111 {
5c7571d4 1112 vty_out (vty, "EIGRP Routing Process not enabled\n");
7f57883e
DS
1113 return CMD_SUCCESS;
1114 }
1115
1116 eigrp->variance = EIGRP_VARIANCE_DEFAULT;
1117
1118 /*TODO: */
1119
1120 return CMD_SUCCESS;
1121}
1122
1123DEFUN (eigrp_maximum_paths,
1124 eigrp_maximum_paths_cmd,
1125 "maximum-paths (1-32)",
1126 "Forward packets over multiple paths\n"
1127 "Number of paths\n")
1128{
1129 struct eigrp *eigrp;
1130 u_char max;
1131
1132 eigrp = eigrp_lookup ();
1133 if (eigrp == NULL)
1134 {
5c7571d4 1135 vty_out (vty, "EIGRP Routing Process not enabled\n");
7f57883e
DS
1136 return CMD_SUCCESS;
1137 }
1138
1139 max = atoi(argv[1]->arg);
1140
1141 eigrp->max_paths = max;
1142
1143 /*TODO: */
1144
1145 return CMD_SUCCESS;
1146}
1147
7f57883e
DS
1148DEFUN (no_eigrp_maximum_paths,
1149 no_eigrp_maximum_paths_cmd,
1150 "no maximum-paths <1-32>",
1151 NO_STR
1152 "Forward packets over multiple paths\n"
1153 "Number of paths\n")
1154{
1155 struct eigrp *eigrp;
1156
1157 eigrp = eigrp_lookup ();
1158 if (eigrp == NULL)
1159 {
5c7571d4 1160 vty_out (vty, "EIGRP Routing Process not enabled\n");
7f57883e
DS
1161 return CMD_SUCCESS;
1162 }
1163
1164 eigrp->max_paths = EIGRP_MAX_PATHS_DEFAULT;
1165
1166 /*TODO: */
1167
1168 return CMD_SUCCESS;
1169}
1170
1171/*
1172 * Execute hard restart for all neighbors
1173 */
1174DEFUN (clear_ip_eigrp_neighbors,
1175 clear_ip_eigrp_neighbors_cmd,
1176 "clear ip eigrp neighbors",
1177 CLEAR_STR
1178 IP_STR
1179 "Clear IP-EIGRP\n"
1180 "Clear IP-EIGRP neighbors\n")
1181{
1182 struct eigrp *eigrp;
1183 struct eigrp_interface *ei;
1184 struct listnode *node, *node2, *nnode2;
1185 struct eigrp_neighbor *nbr;
1186
1187 /* Check if eigrp process is enabled */
1188 eigrp = eigrp_lookup ();
1189 if (eigrp == NULL)
1190 {
5c7571d4 1191 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
1192 return CMD_SUCCESS;
1193 }
1194
1195 /* iterate over all eigrp interfaces */
1196 for (ALL_LIST_ELEMENTS_RO (eigrp->eiflist, node, ei))
1197 {
1198 /* send Goodbye Hello */
1199 eigrp_hello_send(ei, EIGRP_HELLO_GRACEFUL_SHUTDOWN, NULL);
1200
1201 /* iterate over all neighbors on eigrp interface */
1202 for (ALL_LIST_ELEMENTS (ei->nbrs, node2, nnode2, nbr))
1203 {
1204 if (nbr->state != EIGRP_NEIGHBOR_DOWN)
1205 {
1206 zlog_debug ("Neighbor %s (%s) is down: manually cleared",
1207 inet_ntoa (nbr->src),
ca975a87 1208 ifindex2ifname (nbr->ei->ifp->ifindex, VRF_DEFAULT));
7f57883e 1209 vty_time_print (vty, 0);
5c7571d4 1210 vty_out (vty, "Neighbor %s (%s) is down: manually cleared\n",
7f57883e 1211 inet_ntoa (nbr->src),
96ade3ed 1212 ifindex2ifname(nbr->ei->ifp->ifindex, VRF_DEFAULT));
7f57883e
DS
1213
1214 /* set neighbor to DOWN */
1215 nbr->state = EIGRP_NEIGHBOR_DOWN;
1216 /* delete neighbor */
1217 eigrp_nbr_delete (nbr);
1218 }
1219 }
1220 }
1221
1222 return CMD_SUCCESS;
1223}
1224
1225/*
1226 * Execute hard restart for all neighbors on interface
1227 */
1228DEFUN (clear_ip_eigrp_neighbors_int,
1229 clear_ip_eigrp_neighbors_int_cmd,
1230 "clear ip eigrp neighbors IFNAME",
1231 CLEAR_STR
1232 IP_STR
1233 "Clear IP-EIGRP\n"
1234 "Clear IP-EIGRP neighbors\n"
1235 "Interface's name\n")
1236{
1237 struct eigrp *eigrp;
1238 struct eigrp_interface *ei;
1239 struct listnode *node2, *nnode2;
1240 struct eigrp_neighbor *nbr;
1241 int idx = 0;
1242
1243 /* Check if eigrp process is enabled */
1244 eigrp = eigrp_lookup ();
1245 if (eigrp == NULL)
1246 {
5c7571d4 1247 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
1248 return CMD_SUCCESS;
1249 }
1250
1251 /* lookup interface by specified name */
1252 argv_find(argv, argc, "IFNAME", &idx);
1253 ei = eigrp_if_lookup_by_name(eigrp, argv[idx]->arg);
1254 if(ei == NULL)
1255 {
5c7571d4 1256 vty_out (vty, " Interface (%s) doesn't exist\n", argv[idx]->arg);
7f57883e
DS
1257 return CMD_WARNING;
1258 }
1259
1260 /* send Goodbye Hello */
1261 eigrp_hello_send(ei, EIGRP_HELLO_GRACEFUL_SHUTDOWN, NULL);
1262
1263 /* iterate over all neighbors on eigrp interface */
1264 for (ALL_LIST_ELEMENTS (ei->nbrs, node2, nnode2, nbr))
1265 {
1266 if (nbr->state != EIGRP_NEIGHBOR_DOWN)
1267 {
1268 zlog_debug ("Neighbor %s (%s) is down: manually cleared",
1269 inet_ntoa (nbr->src),
ca975a87 1270 ifindex2ifname (nbr->ei->ifp->ifindex, VRF_DEFAULT));
7f57883e 1271 vty_time_print (vty, 0);
5c7571d4 1272 vty_out (vty, "Neighbor %s (%s) is down: manually cleared\n",
7f57883e 1273 inet_ntoa (nbr->src),
96ade3ed 1274 ifindex2ifname(nbr->ei->ifp->ifindex, VRF_DEFAULT));
7f57883e
DS
1275
1276 /* set neighbor to DOWN */
1277 nbr->state = EIGRP_NEIGHBOR_DOWN;
1278 /* delete neighbor */
1279 eigrp_nbr_delete (nbr);
1280 }
1281 }
1282
1283 return CMD_SUCCESS;
1284}
1285
1286/*
1287 * Execute hard restart for neighbor specified by IP
1288 */
1289DEFUN (clear_ip_eigrp_neighbors_IP,
1290 clear_ip_eigrp_neighbors_IP_cmd,
1291 "clear ip eigrp neighbors A.B.C.D",
1292 CLEAR_STR
1293 IP_STR
1294 "Clear IP-EIGRP\n"
1295 "Clear IP-EIGRP neighbors\n"
1296 "IP-EIGRP neighbor address\n")
1297{
1298 struct eigrp *eigrp;
1299 struct eigrp_neighbor *nbr;
1300 struct in_addr nbr_addr;
1301
facfee22 1302 inet_aton(argv[4]->arg, &nbr_addr);
7f57883e
DS
1303
1304 /* Check if eigrp process is enabled */
1305 eigrp = eigrp_lookup ();
1306 if (eigrp == NULL)
1307 {
5c7571d4 1308 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
1309 return CMD_SUCCESS;
1310 }
1311
1312 /* lookup neighbor in whole process */
1313 nbr = eigrp_nbr_lookup_by_addr_process(eigrp, nbr_addr);
1314
1315 /* if neighbor doesn't exists, notify user and exit */
1316 if(nbr == NULL)
1317 {
5c7571d4 1318 vty_out (vty, "Neighbor with entered address doesn't exists.\n");
7f57883e
DS
1319 return CMD_WARNING;
1320 }
1321
1322 /* execute hard reset on neighbor */
1323 eigrp_nbr_hard_restart(nbr, vty);
1324
1325 return CMD_SUCCESS;
1326}
1327
1328/*
1329 * Execute graceful restart for all neighbors
1330 */
1331DEFUN (clear_ip_eigrp_neighbors_soft,
1332 clear_ip_eigrp_neighbors_soft_cmd,
1333 "clear ip eigrp neighbors soft",
1334 CLEAR_STR
1335 IP_STR
1336 "Clear IP-EIGRP\n"
1337 "Clear IP-EIGRP neighbors\n"
1338 "Resync with peers without adjacency reset\n")
1339{
1340 struct eigrp *eigrp;
1341
1342 /* Check if eigrp process is enabled */
1343 eigrp = eigrp_lookup ();
1344 if (eigrp == NULL)
1345 {
5c7571d4 1346 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
1347 return CMD_SUCCESS;
1348 }
1349
1350 /* execute graceful restart on all neighbors */
1351 eigrp_update_send_process_GR(eigrp, EIGRP_GR_MANUAL, vty);
1352
1353 return CMD_SUCCESS;
1354}
1355
1356/*
1357 * Execute graceful restart for all neighbors on interface
1358 */
1359DEFUN (clear_ip_eigrp_neighbors_int_soft,
1360 clear_ip_eigrp_neighbors_int_soft_cmd,
1361 "clear ip eigrp neighbors IFNAME soft",
1362 CLEAR_STR
1363 IP_STR
1364 "Clear IP-EIGRP\n"
1365 "Clear IP-EIGRP neighbors\n"
1366 "Interface's name\n"
1367 "Resync with peer without adjacency reset\n")
1368{
1369 struct eigrp *eigrp;
1370 struct eigrp_interface *ei;
1371
1372 /* Check if eigrp process is enabled */
1373 eigrp = eigrp_lookup ();
1374 if (eigrp == NULL)
1375 {
5c7571d4 1376 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
1377 return CMD_SUCCESS;
1378 }
1379
1380 /* lookup interface by specified name */
1381 ei = eigrp_if_lookup_by_name(eigrp, argv[4]->arg);
1382 if(ei == NULL)
1383 {
5c7571d4 1384 vty_out (vty, " Interface (%s) doesn't exist\n", argv[4]->arg);
7f57883e
DS
1385 return CMD_WARNING;
1386 }
1387
1388 /* execute graceful restart for all neighbors on interface */
1389 eigrp_update_send_interface_GR(ei, EIGRP_GR_MANUAL, vty);
1390 return CMD_SUCCESS;
1391}
1392
1393/*
1394 * Execute graceful restart for neighbor specified by IP
1395 */
1396DEFUN (clear_ip_eigrp_neighbors_IP_soft,
1397 clear_ip_eigrp_neighbors_IP_soft_cmd,
1398 "clear ip eigrp neighbors A.B.C.D soft",
1399 CLEAR_STR
1400 IP_STR
1401 "Clear IP-EIGRP\n"
1402 "Clear IP-EIGRP neighbors\n"
1403 "IP-EIGRP neighbor address\n"
1404 "Resync with peer without adjacency reset\n")
1405{
1406 struct eigrp *eigrp;
1407 struct eigrp_neighbor *nbr;
1408 struct in_addr nbr_addr;
1409
facfee22 1410 inet_aton(argv[4]->arg, &nbr_addr);
7f57883e
DS
1411
1412 /* Check if eigrp process is enabled */
1413 eigrp = eigrp_lookup ();
1414 if (eigrp == NULL)
1415 {
5c7571d4 1416 vty_out (vty, " EIGRP Routing Process not enabled\n");
7f57883e
DS
1417 return CMD_SUCCESS;
1418 }
1419
1420 /* lookup neighbor in whole process */
1421 nbr = eigrp_nbr_lookup_by_addr_process(eigrp, nbr_addr);
1422
1423 /* if neighbor doesn't exists, notify user and exit */
1424 if(nbr == NULL)
1425 {
5c7571d4 1426 vty_out (vty, "Neighbor with entered address doesn't exists.\n");
7f57883e
DS
1427 return CMD_WARNING;
1428 }
1429
1430 /* execute graceful restart on neighbor */
1431 eigrp_update_send_GR(nbr, EIGRP_GR_MANUAL, vty);
1432
1433 return CMD_SUCCESS;
1434}
1435
1436static struct cmd_node eigrp_node =
1437{
1438 EIGRP_NODE,
1439 "%s(config-router)# ",
1440 1
1441};
1442
1443/* Save EIGRP configuration */
1444static int
1445eigrp_config_write (struct vty *vty)
1446{
1447 struct eigrp *eigrp;
1448
1449 int write = 0;
1450
1451 eigrp = eigrp_lookup ();
1452 if (eigrp != NULL)
1453 {
1454 /* Writes 'router eigrp' section to config */
1455 config_write_eigrp_router (vty, eigrp);
1456
1457 /* Interface config print */
1458 config_write_interfaces (vty, eigrp);
1459//
1460// /* static neighbor print. */
1461// config_write_eigrp_nbr_nbma (vty, eigrp);
1462//
1463// /* Virtual-Link print. */
1464// config_write_virtual_link (vty, eigrp);
1465//
1466// /* Default metric configuration. */
1467// config_write_eigrp_default_metric (vty, eigrp);
1468//
1469// /* Distribute-list and default-information print. */
1470// config_write_eigrp_distribute (vty, eigrp);
1471//
1472// /* Distance configuration. */
1473// config_write_eigrp_distance (vty, eigrp)
1474 }
1475
1476 return write;
1477}
1478
1479void
1480eigrp_vty_show_init (void)
1481{
1482 install_element (VIEW_NODE, &show_ip_eigrp_interfaces_cmd);
1483
1484 install_element (VIEW_NODE, &show_ip_eigrp_neighbors_cmd);
1485
1486 install_element (VIEW_NODE, &show_ip_eigrp_topology_cmd);
1487
7f57883e
DS
1488 install_element (VIEW_NODE, &show_ip_eigrp_topology_detail_cmd);
1489
1490}
1491
1492/* eigrpd's interface node. */
1493static struct cmd_node eigrp_interface_node =
1494{
1495 INTERFACE_NODE,
1496 "%s(config-if)# ",
1497 1
1498};
1499
1500void
1501eigrp_vty_if_init (void)
1502{
1503 install_node (&eigrp_interface_node, eigrp_write_interface);
1504 if_cmd_init();
1505
1506 /* Delay and bandwidth configuration commands*/
1507 install_element (INTERFACE_NODE, &eigrp_if_delay_cmd);
1508 install_element (INTERFACE_NODE, &no_eigrp_if_delay_cmd);
1509 install_element (INTERFACE_NODE, &eigrp_if_bandwidth_cmd);
1510 install_element (INTERFACE_NODE, &no_eigrp_if_bandwidth_cmd);
1511
1512 /*Hello-interval and hold-time interval configuration commands*/
1513 install_element (INTERFACE_NODE, &eigrp_if_ip_holdinterval_cmd);
1514 install_element (INTERFACE_NODE, &no_eigrp_if_ip_holdinterval_cmd);
1515 install_element (INTERFACE_NODE, &eigrp_if_ip_hellointerval_cmd);
1516 install_element (INTERFACE_NODE, &no_eigrp_if_ip_hellointerval_cmd);
1517
1518 /* "Authentication configuration commands */
1519 install_element (INTERFACE_NODE, &eigrp_authentication_mode_cmd);
1520 install_element (INTERFACE_NODE, &no_eigrp_authentication_mode_cmd);
1521 install_element (INTERFACE_NODE, &eigrp_authentication_keychain_cmd);
1522 install_element (INTERFACE_NODE, &no_eigrp_authentication_keychain_cmd);
1523
1524 /*EIGRP Summarization commands*/
1525 install_element (INTERFACE_NODE, &eigrp_ip_summary_address_cmd);
1526 install_element (INTERFACE_NODE, &no_eigrp_ip_summary_address_cmd);
7f57883e
DS
1527}
1528
1529static void
1530eigrp_vty_zebra_init (void)
1531{
1532 install_element (EIGRP_NODE, &eigrp_redistribute_source_metric_cmd);
1533 install_element (EIGRP_NODE, &no_eigrp_redistribute_source_metric_cmd);
7f57883e
DS
1534}
1535
1536/* Install EIGRP related vty commands. */
1537void
1538eigrp_vty_init (void)
1539{
1540 install_node (&eigrp_node, eigrp_config_write);
1541
1542 install_default (EIGRP_NODE);
1543
1544 install_element (CONFIG_NODE, &router_eigrp_cmd);
1545 install_element (CONFIG_NODE, &no_router_eigrp_cmd);
1546 install_element (EIGRP_NODE, &eigrp_network_cmd);
1547 install_element (EIGRP_NODE, &no_eigrp_network_cmd);
1548 install_element (EIGRP_NODE, &eigrp_variance_cmd);
1549 install_element (EIGRP_NODE, &no_eigrp_variance_cmd);
1550 install_element (EIGRP_NODE, &eigrp_router_id_cmd);
1551 install_element (EIGRP_NODE, &no_eigrp_router_id_cmd);
1552 install_element (EIGRP_NODE, &eigrp_passive_interface_cmd);
1553 install_element (EIGRP_NODE, &no_eigrp_passive_interface_cmd);
1554 install_element (EIGRP_NODE, &eigrp_timers_active_cmd);
1555 install_element (EIGRP_NODE, &no_eigrp_timers_active_cmd);
1556 install_element (EIGRP_NODE, &eigrp_metric_weights_cmd);
1557 install_element (EIGRP_NODE, &no_eigrp_metric_weights_cmd);
1558 install_element (EIGRP_NODE, &eigrp_maximum_paths_cmd);
1559 install_element (EIGRP_NODE, &no_eigrp_maximum_paths_cmd);
1560 install_element (EIGRP_NODE, &eigrp_neighbor_cmd);
1561 install_element (EIGRP_NODE, &no_eigrp_neighbor_cmd);
1562
1563 /* commands for manual hard restart */
1564 install_element (ENABLE_NODE, &clear_ip_eigrp_neighbors_cmd);
1565 install_element (ENABLE_NODE, &clear_ip_eigrp_neighbors_int_cmd);
1566 install_element (ENABLE_NODE, &clear_ip_eigrp_neighbors_IP_cmd);
1567 /* commands for manual graceful restart */
1568 install_element (ENABLE_NODE, &clear_ip_eigrp_neighbors_soft_cmd);
1569 install_element (ENABLE_NODE, &clear_ip_eigrp_neighbors_int_soft_cmd);
1570 install_element (ENABLE_NODE, &clear_ip_eigrp_neighbors_IP_soft_cmd);
1571
1572 eigrp_vty_zebra_init ();
1573}