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