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