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