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