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