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