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