]> git.proxmox.com Git - mirror_frr.git/blob - eigrpd/eigrp_vty.c
Merge pull request #1357 from opensourcerouting/coverity_fixes
[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 (void)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 (void)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_STR
874 "Interface Internet Protocol config commands\n"
875 "Configures EIGRP hello interval\n"
876 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n")
877 {
878 VTY_DECLVAR_CONTEXT(interface, ifp);
879 struct eigrp_interface *ei = ifp->info;
880 struct eigrp *eigrp;
881
882 eigrp = eigrp_lookup();
883 if (eigrp == NULL) {
884 vty_out(vty, " EIGRP Routing Process not enabled\n");
885 return CMD_SUCCESS;
886 }
887
888 if (!ei) {
889 vty_out(vty, " EIGRP not configured on this interface\n");
890 return CMD_SUCCESS;
891 }
892
893 ei->params.v_wait = EIGRP_HOLD_INTERVAL_DEFAULT;
894
895 return CMD_SUCCESS;
896 }
897
898 static int str2auth_type(const char *str, struct eigrp_interface *ei)
899 {
900 /* Sanity check. */
901 if (str == NULL)
902 return CMD_WARNING_CONFIG_FAILED;
903
904 if (strncmp(str, "md5", 3) == 0) {
905 ei->params.auth_type = EIGRP_AUTH_TYPE_MD5;
906 return CMD_SUCCESS;
907 } else if (strncmp(str, "hmac-sha-256", 12) == 0) {
908 ei->params.auth_type = EIGRP_AUTH_TYPE_SHA256;
909 return CMD_SUCCESS;
910 }
911
912 return CMD_WARNING_CONFIG_FAILED;
913 }
914
915 DEFUN (eigrp_authentication_mode,
916 eigrp_authentication_mode_cmd,
917 "ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
918 "Interface Internet Protocol config commands\n"
919 "Authentication subcommands\n"
920 "Mode\n"
921 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
922 "Autonomous system number\n"
923 "Keyed message digest\n"
924 "HMAC SHA256 algorithm \n")
925 {
926 VTY_DECLVAR_CONTEXT(interface, ifp);
927 struct eigrp_interface *ei = ifp->info;
928 struct eigrp *eigrp;
929
930 eigrp = eigrp_lookup();
931 if (eigrp == NULL) {
932 vty_out(vty, " EIGRP Routing Process not enabled\n");
933 return CMD_SUCCESS;
934 }
935
936 if (!ei) {
937 vty_out(vty, " EIGRP not configured on this interface\n");
938 return CMD_SUCCESS;
939 }
940
941 // if(strncmp(argv[2], "md5",3))
942 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_MD5;
943 // else if(strncmp(argv[2], "hmac-sha-256",12))
944 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_SHA256;
945
946 return str2auth_type(argv[5]->arg, ei);
947 }
948
949 DEFUN (no_eigrp_authentication_mode,
950 no_eigrp_authentication_mode_cmd,
951 "no ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
952 "Disable\n"
953 "Interface Internet Protocol config commands\n"
954 "Authentication subcommands\n"
955 "Mode\n"
956 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
957 "Autonomous system number\n"
958 "Keyed message digest\n"
959 "HMAC SHA256 algorithm \n")
960 {
961 VTY_DECLVAR_CONTEXT(interface, ifp);
962 struct eigrp_interface *ei = ifp->info;
963 struct eigrp *eigrp;
964
965 eigrp = eigrp_lookup();
966 if (eigrp == NULL) {
967 vty_out(vty, " EIGRP Routing Process not enabled\n");
968 return CMD_SUCCESS;
969 }
970
971 if (!ei) {
972 vty_out(vty, " EIGRP not configured on this interface\n");
973 return CMD_SUCCESS;
974 }
975
976 ei->params.auth_type = EIGRP_AUTH_TYPE_NONE;
977
978 return CMD_SUCCESS;
979 }
980
981 DEFUN (eigrp_authentication_keychain,
982 eigrp_authentication_keychain_cmd,
983 "ip authentication key-chain eigrp (1-65535) WORD",
984 "Interface Internet Protocol config commands\n"
985 "Authentication subcommands\n"
986 "Key-chain\n"
987 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
988 "Autonomous system number\n"
989 "Name of key-chain\n")
990 {
991 VTY_DECLVAR_CONTEXT(interface, ifp);
992 struct eigrp_interface *ei = ifp->info;
993 struct eigrp *eigrp;
994 struct keychain *keychain;
995
996 eigrp = eigrp_lookup();
997 if (eigrp == NULL) {
998 vty_out(vty, "EIGRP Routing Process not enabled\n");
999 return CMD_SUCCESS;
1000 }
1001
1002 if (!ei) {
1003 vty_out(vty, " EIGRP not configured on this interface\n");
1004 return CMD_SUCCESS;
1005 }
1006
1007 keychain = keychain_lookup(argv[4]->arg);
1008 if (keychain != NULL) {
1009 if (ei->params.auth_keychain) {
1010 free(ei->params.auth_keychain);
1011 ei->params.auth_keychain =
1012 strdup(keychain->name);
1013 } else
1014 ei->params.auth_keychain =
1015 strdup(keychain->name);
1016 } else
1017 vty_out(vty, "Key chain with specified name not found\n");
1018
1019 return CMD_SUCCESS;
1020 }
1021
1022 DEFUN (no_eigrp_authentication_keychain,
1023 no_eigrp_authentication_keychain_cmd,
1024 "no ip authentication key-chain eigrp (1-65535) WORD",
1025 "Disable\n"
1026 "Interface Internet Protocol config commands\n"
1027 "Authentication subcommands\n"
1028 "Key-chain\n"
1029 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
1030 "Autonomous system number\n"
1031 "Name of key-chain\n")
1032 {
1033 VTY_DECLVAR_CONTEXT(interface, ifp);
1034 struct eigrp_interface *ei = ifp->info;
1035 struct eigrp *eigrp;
1036
1037 eigrp = eigrp_lookup();
1038 if (eigrp == NULL) {
1039 vty_out(vty, "EIGRP Routing Process not enabled\n");
1040 return CMD_SUCCESS;
1041 }
1042
1043 if (!ei) {
1044 vty_out(vty, " EIGRP not configured on this interface\n");
1045 return CMD_SUCCESS;
1046 }
1047
1048 if ((ei->params.auth_keychain != NULL)
1049 && (strcmp(ei->params.auth_keychain, argv[5]->arg) == 0)) {
1050 free(ei->params.auth_keychain);
1051 ei->params.auth_keychain = NULL;
1052 } else
1053 vty_out(vty,
1054 "Key chain with specified name not configured on interface\n");
1055
1056 return CMD_SUCCESS;
1057 }
1058
1059 DEFUN (eigrp_redistribute_source_metric,
1060 eigrp_redistribute_source_metric_cmd,
1061 "redistribute " FRR_REDIST_STR_EIGRPD
1062 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
1063 REDIST_STR
1064 FRR_REDIST_HELP_STR_EIGRPD
1065 "Metric for redistributed routes\n"
1066 "Bandwidth metric in Kbits per second\n"
1067 "EIGRP delay metric, in 10 microsecond units\n"
1068 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1069 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1070 "EIGRP MTU of the path\n")
1071 {
1072 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
1073 struct eigrp_metrics metrics_from_command = {0};
1074 int source;
1075 int idx = 0;
1076
1077 /* Get distribute source. */
1078 argv_find(argv, argc, "redistribute", &idx);
1079 source = proto_redistnum(AFI_IP, argv[idx + 1]->text);
1080 if (source < 0) {
1081 vty_out(vty, "%% Invalid route type\n");
1082 return CMD_WARNING_CONFIG_FAILED;
1083 }
1084
1085 /* Get metrics values */
1086
1087 return eigrp_redistribute_set(eigrp, source, metrics_from_command);
1088 }
1089
1090 DEFUN (no_eigrp_redistribute_source_metric,
1091 no_eigrp_redistribute_source_metric_cmd,
1092 "no redistribute " FRR_REDIST_STR_EIGRPD
1093 " metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)",
1094 "Disable\n"
1095 REDIST_STR
1096 FRR_REDIST_HELP_STR_EIGRPD
1097 "Metric for redistributed routes\n"
1098 "Bandwidth metric in Kbits per second\n"
1099 "EIGRP delay metric, in 10 microsecond units\n"
1100 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1101 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1102 "EIGRP MTU of the path\n")
1103 {
1104 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
1105 int source;
1106 int idx = 0;
1107
1108 /* Get distribute source. */
1109 argv_find(argv, argc, "redistribute", &idx);
1110 source = proto_redistnum(AFI_IP, argv[idx + 1]->text);
1111 if (source < 0) {
1112 vty_out(vty, "%% Invalid route type\n");
1113 return CMD_WARNING_CONFIG_FAILED;
1114 }
1115
1116 /* Get metrics values */
1117
1118 return eigrp_redistribute_unset(eigrp, source);
1119 }
1120
1121 DEFUN (eigrp_variance,
1122 eigrp_variance_cmd,
1123 "variance (1-128)",
1124 "Control load balancing variance\n"
1125 "Metric variance multiplier\n")
1126 {
1127 struct eigrp *eigrp;
1128 u_char variance;
1129
1130 eigrp = eigrp_lookup();
1131 if (eigrp == NULL) {
1132 vty_out(vty, "EIGRP Routing Process not enabled\n");
1133 return CMD_SUCCESS;
1134 }
1135 variance = atoi(argv[1]->arg);
1136
1137 eigrp->variance = variance;
1138
1139 /*TODO: */
1140
1141 return CMD_SUCCESS;
1142 }
1143
1144 DEFUN (no_eigrp_variance,
1145 no_eigrp_variance_cmd,
1146 "no variance (1-128)",
1147 "Disable\n"
1148 "Control load balancing variance\n"
1149 "Metric variance multiplier\n")
1150 {
1151 struct eigrp *eigrp;
1152 eigrp = eigrp_lookup();
1153 if (eigrp == NULL) {
1154 vty_out(vty, "EIGRP Routing Process not enabled\n");
1155 return CMD_SUCCESS;
1156 }
1157
1158 eigrp->variance = EIGRP_VARIANCE_DEFAULT;
1159
1160 /*TODO: */
1161
1162 return CMD_SUCCESS;
1163 }
1164
1165 DEFUN (eigrp_maximum_paths,
1166 eigrp_maximum_paths_cmd,
1167 "maximum-paths (1-32)",
1168 "Forward packets over multiple paths\n"
1169 "Number of paths\n")
1170 {
1171 struct eigrp *eigrp;
1172 u_char max;
1173
1174 eigrp = eigrp_lookup();
1175 if (eigrp == NULL) {
1176 vty_out(vty, "EIGRP Routing Process not enabled\n");
1177 return CMD_SUCCESS;
1178 }
1179
1180 max = atoi(argv[1]->arg);
1181
1182 eigrp->max_paths = max;
1183
1184 /*TODO: */
1185
1186 return CMD_SUCCESS;
1187 }
1188
1189 DEFUN (no_eigrp_maximum_paths,
1190 no_eigrp_maximum_paths_cmd,
1191 "no maximum-paths <1-32>",
1192 NO_STR
1193 "Forward packets over multiple paths\n"
1194 "Number of paths\n")
1195 {
1196 struct eigrp *eigrp;
1197
1198 eigrp = eigrp_lookup();
1199 if (eigrp == NULL) {
1200 vty_out(vty, "EIGRP Routing Process not enabled\n");
1201 return CMD_SUCCESS;
1202 }
1203
1204 eigrp->max_paths = EIGRP_MAX_PATHS_DEFAULT;
1205
1206 /*TODO: */
1207
1208 return CMD_SUCCESS;
1209 }
1210
1211 /*
1212 * Execute hard restart for all neighbors
1213 */
1214 DEFUN (clear_ip_eigrp_neighbors,
1215 clear_ip_eigrp_neighbors_cmd,
1216 "clear ip eigrp neighbors",
1217 CLEAR_STR
1218 IP_STR
1219 "Clear IP-EIGRP\n"
1220 "Clear IP-EIGRP neighbors\n")
1221 {
1222 struct eigrp *eigrp;
1223 struct eigrp_interface *ei;
1224 struct listnode *node, *node2, *nnode2;
1225 struct eigrp_neighbor *nbr;
1226
1227 /* Check if eigrp process is enabled */
1228 eigrp = eigrp_lookup();
1229 if (eigrp == NULL) {
1230 vty_out(vty, " EIGRP Routing Process not enabled\n");
1231 return CMD_SUCCESS;
1232 }
1233
1234 /* iterate over all eigrp interfaces */
1235 for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) {
1236 /* send Goodbye Hello */
1237 eigrp_hello_send(ei, EIGRP_HELLO_GRACEFUL_SHUTDOWN, NULL);
1238
1239 /* iterate over all neighbors on eigrp interface */
1240 for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) {
1241 if (nbr->state != EIGRP_NEIGHBOR_DOWN) {
1242 zlog_debug(
1243 "Neighbor %s (%s) is down: manually cleared",
1244 inet_ntoa(nbr->src),
1245 ifindex2ifname(nbr->ei->ifp->ifindex,
1246 VRF_DEFAULT));
1247 vty_time_print(vty, 0);
1248 vty_out(vty,
1249 "Neighbor %s (%s) is down: manually cleared\n",
1250 inet_ntoa(nbr->src),
1251 ifindex2ifname(nbr->ei->ifp->ifindex,
1252 VRF_DEFAULT));
1253
1254 /* set neighbor to DOWN */
1255 nbr->state = EIGRP_NEIGHBOR_DOWN;
1256 /* delete neighbor */
1257 eigrp_nbr_delete(nbr);
1258 }
1259 }
1260 }
1261
1262 return CMD_SUCCESS;
1263 }
1264
1265 /*
1266 * Execute hard restart for all neighbors on interface
1267 */
1268 DEFUN (clear_ip_eigrp_neighbors_int,
1269 clear_ip_eigrp_neighbors_int_cmd,
1270 "clear ip eigrp neighbors IFNAME",
1271 CLEAR_STR
1272 IP_STR
1273 "Clear IP-EIGRP\n"
1274 "Clear IP-EIGRP neighbors\n"
1275 "Interface's name\n")
1276 {
1277 struct eigrp *eigrp;
1278 struct eigrp_interface *ei;
1279 struct listnode *node2, *nnode2;
1280 struct eigrp_neighbor *nbr;
1281 int idx = 0;
1282
1283 /* Check if eigrp process is enabled */
1284 eigrp = eigrp_lookup();
1285 if (eigrp == NULL) {
1286 vty_out(vty, " EIGRP Routing Process not enabled\n");
1287 return CMD_SUCCESS;
1288 }
1289
1290 /* lookup interface by specified name */
1291 argv_find(argv, argc, "IFNAME", &idx);
1292 ei = eigrp_if_lookup_by_name(eigrp, argv[idx]->arg);
1293 if (ei == NULL) {
1294 vty_out(vty, " Interface (%s) doesn't exist\n", argv[idx]->arg);
1295 return CMD_WARNING;
1296 }
1297
1298 /* send Goodbye Hello */
1299 eigrp_hello_send(ei, EIGRP_HELLO_GRACEFUL_SHUTDOWN, NULL);
1300
1301 /* iterate over all neighbors on eigrp interface */
1302 for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) {
1303 if (nbr->state != EIGRP_NEIGHBOR_DOWN) {
1304 zlog_debug("Neighbor %s (%s) is down: manually cleared",
1305 inet_ntoa(nbr->src),
1306 ifindex2ifname(nbr->ei->ifp->ifindex,
1307 VRF_DEFAULT));
1308 vty_time_print(vty, 0);
1309 vty_out(vty,
1310 "Neighbor %s (%s) is down: manually cleared\n",
1311 inet_ntoa(nbr->src),
1312 ifindex2ifname(nbr->ei->ifp->ifindex,
1313 VRF_DEFAULT));
1314
1315 /* set neighbor to DOWN */
1316 nbr->state = EIGRP_NEIGHBOR_DOWN;
1317 /* delete neighbor */
1318 eigrp_nbr_delete(nbr);
1319 }
1320 }
1321
1322 return CMD_SUCCESS;
1323 }
1324
1325 /*
1326 * Execute hard restart for neighbor specified by IP
1327 */
1328 DEFUN (clear_ip_eigrp_neighbors_IP,
1329 clear_ip_eigrp_neighbors_IP_cmd,
1330 "clear ip eigrp neighbors A.B.C.D",
1331 CLEAR_STR
1332 IP_STR
1333 "Clear IP-EIGRP\n"
1334 "Clear IP-EIGRP neighbors\n"
1335 "IP-EIGRP neighbor address\n")
1336 {
1337 struct eigrp *eigrp;
1338 struct eigrp_neighbor *nbr;
1339 struct in_addr nbr_addr;
1340
1341 if (!inet_aton(argv[4]->arg, &nbr_addr)) {
1342 vty_out(vty, "Unable to parse %s",
1343 argv[4]->arg);
1344 return CMD_WARNING;
1345 }
1346
1347 /* Check if eigrp process is enabled */
1348 eigrp = eigrp_lookup();
1349 if (eigrp == NULL) {
1350 vty_out(vty, " EIGRP Routing Process not enabled\n");
1351 return CMD_SUCCESS;
1352 }
1353
1354 /* lookup neighbor in whole process */
1355 nbr = eigrp_nbr_lookup_by_addr_process(eigrp, nbr_addr);
1356
1357 /* if neighbor doesn't exists, notify user and exit */
1358 if (nbr == NULL) {
1359 vty_out(vty, "Neighbor with entered address doesn't exists.\n");
1360 return CMD_WARNING;
1361 }
1362
1363 /* execute hard reset on neighbor */
1364 eigrp_nbr_hard_restart(nbr, vty);
1365
1366 return CMD_SUCCESS;
1367 }
1368
1369 /*
1370 * Execute graceful restart for all neighbors
1371 */
1372 DEFUN (clear_ip_eigrp_neighbors_soft,
1373 clear_ip_eigrp_neighbors_soft_cmd,
1374 "clear ip eigrp neighbors soft",
1375 CLEAR_STR
1376 IP_STR
1377 "Clear IP-EIGRP\n"
1378 "Clear IP-EIGRP neighbors\n"
1379 "Resync with peers without adjacency reset\n")
1380 {
1381 struct eigrp *eigrp;
1382
1383 /* Check if eigrp process is enabled */
1384 eigrp = eigrp_lookup();
1385 if (eigrp == NULL) {
1386 vty_out(vty, " EIGRP Routing Process not enabled\n");
1387 return CMD_SUCCESS;
1388 }
1389
1390 /* execute graceful restart on all neighbors */
1391 eigrp_update_send_process_GR(eigrp, EIGRP_GR_MANUAL, vty);
1392
1393 return CMD_SUCCESS;
1394 }
1395
1396 /*
1397 * Execute graceful restart for all neighbors on interface
1398 */
1399 DEFUN (clear_ip_eigrp_neighbors_int_soft,
1400 clear_ip_eigrp_neighbors_int_soft_cmd,
1401 "clear ip eigrp neighbors IFNAME soft",
1402 CLEAR_STR
1403 IP_STR
1404 "Clear IP-EIGRP\n"
1405 "Clear IP-EIGRP neighbors\n"
1406 "Interface's name\n"
1407 "Resync with peer without adjacency reset\n")
1408 {
1409 struct eigrp *eigrp;
1410 struct eigrp_interface *ei;
1411
1412 /* Check if eigrp process is enabled */
1413 eigrp = eigrp_lookup();
1414 if (eigrp == NULL) {
1415 vty_out(vty, " EIGRP Routing Process not enabled\n");
1416 return CMD_SUCCESS;
1417 }
1418
1419 /* lookup interface by specified name */
1420 ei = eigrp_if_lookup_by_name(eigrp, argv[4]->arg);
1421 if (ei == NULL) {
1422 vty_out(vty, " Interface (%s) doesn't exist\n", argv[4]->arg);
1423 return CMD_WARNING;
1424 }
1425
1426 /* execute graceful restart for all neighbors on interface */
1427 eigrp_update_send_interface_GR(ei, EIGRP_GR_MANUAL, vty);
1428 return CMD_SUCCESS;
1429 }
1430
1431 /*
1432 * Execute graceful restart for neighbor specified by IP
1433 */
1434 DEFUN (clear_ip_eigrp_neighbors_IP_soft,
1435 clear_ip_eigrp_neighbors_IP_soft_cmd,
1436 "clear ip eigrp neighbors A.B.C.D soft",
1437 CLEAR_STR
1438 IP_STR
1439 "Clear IP-EIGRP\n"
1440 "Clear IP-EIGRP neighbors\n"
1441 "IP-EIGRP neighbor address\n"
1442 "Resync with peer without adjacency reset\n")
1443 {
1444 struct eigrp *eigrp;
1445 struct eigrp_neighbor *nbr;
1446 struct in_addr nbr_addr;
1447
1448 if (!inet_aton(argv[4]->arg, &nbr_addr)) {
1449 vty_out(vty, "Unable to parse: %s",
1450 argv[4]->arg);
1451 return CMD_WARNING;
1452 }
1453
1454 /* Check if eigrp process is enabled */
1455 eigrp = eigrp_lookup();
1456 if (eigrp == NULL) {
1457 vty_out(vty, " EIGRP Routing Process not enabled\n");
1458 return CMD_SUCCESS;
1459 }
1460
1461 /* lookup neighbor in whole process */
1462 nbr = eigrp_nbr_lookup_by_addr_process(eigrp, nbr_addr);
1463
1464 /* if neighbor doesn't exists, notify user and exit */
1465 if (nbr == NULL) {
1466 vty_out(vty, "Neighbor with entered address doesn't exists.\n");
1467 return CMD_WARNING;
1468 }
1469
1470 /* execute graceful restart on neighbor */
1471 eigrp_update_send_GR(nbr, EIGRP_GR_MANUAL, vty);
1472
1473 return CMD_SUCCESS;
1474 }
1475
1476 static struct cmd_node eigrp_node = {EIGRP_NODE, "%s(config-router)# ", 1};
1477
1478 /* Save EIGRP configuration */
1479 static int eigrp_config_write(struct vty *vty)
1480 {
1481 struct eigrp *eigrp;
1482
1483 int write = 0;
1484
1485 eigrp = eigrp_lookup();
1486 if (eigrp != NULL) {
1487 /* Writes 'router eigrp' section to config */
1488 config_write_eigrp_router(vty, eigrp);
1489
1490 /* Interface config print */
1491 config_write_interfaces(vty, eigrp);
1492 //
1493 // /* static neighbor print. */
1494 // config_write_eigrp_nbr_nbma (vty, eigrp);
1495 //
1496 // /* Virtual-Link print. */
1497 // config_write_virtual_link (vty, eigrp);
1498 //
1499 // /* Default metric configuration. */
1500 // config_write_eigrp_default_metric (vty, eigrp);
1501 //
1502 // /* Distribute-list and default-information print. */
1503 // config_write_eigrp_distribute (vty, eigrp);
1504 //
1505 // /* Distance configuration. */
1506 // config_write_eigrp_distance (vty, eigrp)
1507 }
1508
1509 return write;
1510 }
1511
1512 void eigrp_vty_show_init(void)
1513 {
1514 install_element(VIEW_NODE, &show_ip_eigrp_interfaces_cmd);
1515
1516 install_element(VIEW_NODE, &show_ip_eigrp_neighbors_cmd);
1517
1518 install_element(VIEW_NODE, &show_ip_eigrp_topology_cmd);
1519
1520 install_element(VIEW_NODE, &show_ip_eigrp_topology_detail_cmd);
1521 }
1522
1523 /* eigrpd's interface node. */
1524 static struct cmd_node eigrp_interface_node = {INTERFACE_NODE,
1525 "%s(config-if)# ", 1};
1526
1527 void eigrp_vty_if_init(void)
1528 {
1529 install_node(&eigrp_interface_node, eigrp_write_interface);
1530 if_cmd_init();
1531
1532 /* Delay and bandwidth configuration commands*/
1533 install_element(INTERFACE_NODE, &eigrp_if_delay_cmd);
1534 install_element(INTERFACE_NODE, &no_eigrp_if_delay_cmd);
1535 install_element(INTERFACE_NODE, &eigrp_if_bandwidth_cmd);
1536 install_element(INTERFACE_NODE, &no_eigrp_if_bandwidth_cmd);
1537
1538 /*Hello-interval and hold-time interval configuration commands*/
1539 install_element(INTERFACE_NODE, &eigrp_if_ip_holdinterval_cmd);
1540 install_element(INTERFACE_NODE, &no_eigrp_if_ip_holdinterval_cmd);
1541 install_element(INTERFACE_NODE, &eigrp_if_ip_hellointerval_cmd);
1542 install_element(INTERFACE_NODE, &no_eigrp_if_ip_hellointerval_cmd);
1543
1544 /* "Authentication configuration commands */
1545 install_element(INTERFACE_NODE, &eigrp_authentication_mode_cmd);
1546 install_element(INTERFACE_NODE, &no_eigrp_authentication_mode_cmd);
1547 install_element(INTERFACE_NODE, &eigrp_authentication_keychain_cmd);
1548 install_element(INTERFACE_NODE, &no_eigrp_authentication_keychain_cmd);
1549
1550 /*EIGRP Summarization commands*/
1551 install_element(INTERFACE_NODE, &eigrp_ip_summary_address_cmd);
1552 install_element(INTERFACE_NODE, &no_eigrp_ip_summary_address_cmd);
1553 }
1554
1555 static void eigrp_vty_zebra_init(void)
1556 {
1557 install_element(EIGRP_NODE, &eigrp_redistribute_source_metric_cmd);
1558 install_element(EIGRP_NODE, &no_eigrp_redistribute_source_metric_cmd);
1559 }
1560
1561 /* Install EIGRP related vty commands. */
1562 void eigrp_vty_init(void)
1563 {
1564 install_node(&eigrp_node, eigrp_config_write);
1565
1566 install_default(EIGRP_NODE);
1567
1568 install_element(CONFIG_NODE, &router_eigrp_cmd);
1569 install_element(CONFIG_NODE, &no_router_eigrp_cmd);
1570 install_element(EIGRP_NODE, &eigrp_network_cmd);
1571 install_element(EIGRP_NODE, &no_eigrp_network_cmd);
1572 install_element(EIGRP_NODE, &eigrp_variance_cmd);
1573 install_element(EIGRP_NODE, &no_eigrp_variance_cmd);
1574 install_element(EIGRP_NODE, &eigrp_router_id_cmd);
1575 install_element(EIGRP_NODE, &no_eigrp_router_id_cmd);
1576 install_element(EIGRP_NODE, &eigrp_passive_interface_cmd);
1577 install_element(EIGRP_NODE, &no_eigrp_passive_interface_cmd);
1578 install_element(EIGRP_NODE, &eigrp_timers_active_cmd);
1579 install_element(EIGRP_NODE, &no_eigrp_timers_active_cmd);
1580 install_element(EIGRP_NODE, &eigrp_metric_weights_cmd);
1581 install_element(EIGRP_NODE, &no_eigrp_metric_weights_cmd);
1582 install_element(EIGRP_NODE, &eigrp_maximum_paths_cmd);
1583 install_element(EIGRP_NODE, &no_eigrp_maximum_paths_cmd);
1584 install_element(EIGRP_NODE, &eigrp_neighbor_cmd);
1585 install_element(EIGRP_NODE, &no_eigrp_neighbor_cmd);
1586
1587 /* commands for manual hard restart */
1588 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_cmd);
1589 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_int_cmd);
1590 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_IP_cmd);
1591 /* commands for manual graceful restart */
1592 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_soft_cmd);
1593 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_int_soft_cmd);
1594 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_IP_soft_cmd);
1595
1596 eigrp_vty_zebra_init();
1597 }