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