]> git.proxmox.com Git - mirror_frr.git/blob - eigrpd/eigrp_vty.c
a0c4fa887a879fa01266b0a787b93d52b10eb228
[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 DEFPY (eigrp_if_bandwidth,
665 eigrp_if_bandwidth_cmd,
666 "eigrp bandwidth (1-10000000)$bw",
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 struct eigrp *eigrp;
674
675 eigrp = eigrp_lookup();
676 if (eigrp == NULL) {
677 vty_out(vty, " EIGRP Routing Process not enabled\n");
678 return CMD_SUCCESS;
679 }
680
681 if (!ei) {
682 vty_out(vty, " EIGRP not configured on this interface\n");
683 return CMD_SUCCESS;
684 }
685
686 ei->params.bandwidth = bw;
687 eigrp_if_reset(ifp);
688
689 return CMD_SUCCESS;
690 }
691
692 DEFUN (no_eigrp_if_bandwidth,
693 no_eigrp_if_bandwidth_cmd,
694 "no eigrp bandwidth [(1-10000000)]",
695 NO_STR
696 "EIGRP specific commands\n"
697 "Set bandwidth informational parameter\n"
698 "Bandwidth in kilobits\n")
699 {
700 VTY_DECLVAR_CONTEXT(interface, ifp);
701 struct eigrp_interface *ei = ifp->info;
702 struct eigrp *eigrp;
703
704 eigrp = eigrp_lookup();
705 if (eigrp == NULL) {
706 vty_out(vty, " EIGRP Routing Process not enabled\n");
707 return CMD_SUCCESS;
708 }
709
710 if (!ei) {
711 vty_out(vty, " EIGRP not configured on this interface\n");
712 return CMD_SUCCESS;
713 }
714
715 ei->params.bandwidth = EIGRP_BANDWIDTH_DEFAULT;
716 eigrp_if_reset(ifp);
717
718 return CMD_SUCCESS;
719 }
720
721 DEFUN (eigrp_if_ip_hellointerval,
722 eigrp_if_ip_hellointerval_cmd,
723 "ip hello-interval eigrp (1-65535)",
724 "Interface Internet Protocol config commands\n"
725 "Configures EIGRP hello interval\n"
726 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
727 "Seconds between hello transmissions\n")
728 {
729 VTY_DECLVAR_CONTEXT(interface, ifp);
730 struct eigrp_interface *ei = ifp->info;
731 uint32_t hello;
732 struct eigrp *eigrp;
733
734 eigrp = eigrp_lookup();
735 if (eigrp == NULL) {
736 vty_out(vty, " EIGRP Routing Process not enabled\n");
737 return CMD_SUCCESS;
738 }
739
740 if (!ei) {
741 vty_out(vty, " EIGRP not configured on this interface\n");
742 return CMD_SUCCESS;
743 }
744
745 hello = atoi(argv[3]->arg);
746
747 ei->params.v_hello = hello;
748
749 return CMD_SUCCESS;
750 }
751
752 DEFUN (no_eigrp_if_ip_hellointerval,
753 no_eigrp_if_ip_hellointerval_cmd,
754 "no ip hello-interval eigrp [(1-65535)]",
755 NO_STR
756 "Interface Internet Protocol config commands\n"
757 "Configures EIGRP hello interval\n"
758 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
759 "Seconds between hello transmissions\n")
760 {
761 VTY_DECLVAR_CONTEXT(interface, ifp);
762 struct eigrp_interface *ei = ifp->info;
763 struct eigrp *eigrp;
764
765 eigrp = eigrp_lookup();
766 if (eigrp == NULL) {
767 vty_out(vty, " EIGRP Routing Process not enabled\n");
768 return CMD_SUCCESS;
769 }
770
771 if (!ei) {
772 vty_out(vty, " EIGRP not configured on this interface\n");
773 return CMD_SUCCESS;
774 }
775
776 ei->params.v_hello = EIGRP_HELLO_INTERVAL_DEFAULT;
777
778 THREAD_TIMER_OFF(ei->t_hello);
779 thread_add_timer(master, eigrp_hello_timer, ei, 1, &ei->t_hello);
780
781 return CMD_SUCCESS;
782 }
783
784 DEFUN (eigrp_if_ip_holdinterval,
785 eigrp_if_ip_holdinterval_cmd,
786 "ip hold-time eigrp (1-65535)",
787 "Interface Internet Protocol config commands\n"
788 "Configures EIGRP IPv4 hold time\n"
789 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
790 "Seconds before neighbor is considered down\n")
791 {
792 VTY_DECLVAR_CONTEXT(interface, ifp);
793 struct eigrp_interface *ei = ifp->info;
794 uint32_t hold;
795 struct eigrp *eigrp;
796
797 eigrp = eigrp_lookup();
798 if (eigrp == NULL) {
799 vty_out(vty, " EIGRP Routing Process not enabled\n");
800 return CMD_SUCCESS;
801 }
802
803 if (!ei) {
804 vty_out(vty, " EIGRP not configured on this interface\n");
805 return CMD_SUCCESS;
806 }
807
808 hold = atoi(argv[3]->arg);
809
810 ei->params.v_wait = hold;
811
812 return CMD_SUCCESS;
813 }
814
815 DEFUN (eigrp_ip_summary_address,
816 eigrp_ip_summary_address_cmd,
817 "ip summary-address eigrp (1-65535) A.B.C.D/M",
818 "Interface Internet Protocol config commands\n"
819 "Perform address summarization\n"
820 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
821 "AS number\n"
822 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
823 {
824 // VTY_DECLVAR_CONTEXT(interface, ifp);
825 // uint32_t AS;
826 struct eigrp *eigrp;
827
828 eigrp = eigrp_lookup();
829 if (eigrp == NULL) {
830 vty_out(vty, " EIGRP Routing Process not enabled\n");
831 return CMD_SUCCESS;
832 }
833
834 // AS = atoi (argv[3]->arg);
835
836 /*TODO: */
837
838 return CMD_SUCCESS;
839 }
840
841 DEFUN (no_eigrp_ip_summary_address,
842 no_eigrp_ip_summary_address_cmd,
843 "no ip summary-address eigrp (1-65535) A.B.C.D/M",
844 NO_STR
845 "Interface Internet Protocol config commands\n"
846 "Perform address summarization\n"
847 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
848 "AS number\n"
849 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
850 {
851 // VTY_DECLVAR_CONTEXT(interface, ifp);
852 // uint32_t AS;
853 struct eigrp *eigrp;
854
855 eigrp = eigrp_lookup();
856 if (eigrp == NULL) {
857 vty_out(vty, " EIGRP Routing Process not enabled\n");
858 return CMD_SUCCESS;
859 }
860
861 // AS = atoi (argv[4]->arg);
862
863 /*TODO: */
864
865 return CMD_SUCCESS;
866 }
867
868 DEFUN (no_eigrp_if_ip_holdinterval,
869 no_eigrp_if_ip_holdinterval_cmd,
870 "no ip hold-time eigrp",
871 NO_STR
872 "Interface Internet Protocol config commands\n"
873 "Configures EIGRP hello interval\n"
874 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n")
875 {
876 VTY_DECLVAR_CONTEXT(interface, ifp);
877 struct eigrp_interface *ei = ifp->info;
878 struct eigrp *eigrp;
879
880 eigrp = eigrp_lookup();
881 if (eigrp == NULL) {
882 vty_out(vty, " EIGRP Routing Process not enabled\n");
883 return CMD_SUCCESS;
884 }
885
886 if (!ei) {
887 vty_out(vty, " EIGRP not configured on this interface\n");
888 return CMD_SUCCESS;
889 }
890
891 ei->params.v_wait = EIGRP_HOLD_INTERVAL_DEFAULT;
892
893 return CMD_SUCCESS;
894 }
895
896 static int str2auth_type(const char *str, struct eigrp_interface *ei)
897 {
898 /* Sanity check. */
899 if (str == NULL)
900 return CMD_WARNING_CONFIG_FAILED;
901
902 if (strncmp(str, "md5", 3) == 0) {
903 ei->params.auth_type = EIGRP_AUTH_TYPE_MD5;
904 return CMD_SUCCESS;
905 } else if (strncmp(str, "hmac-sha-256", 12) == 0) {
906 ei->params.auth_type = EIGRP_AUTH_TYPE_SHA256;
907 return CMD_SUCCESS;
908 }
909
910 return CMD_WARNING_CONFIG_FAILED;
911 }
912
913 DEFUN (eigrp_authentication_mode,
914 eigrp_authentication_mode_cmd,
915 "ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
916 "Interface Internet Protocol config commands\n"
917 "Authentication subcommands\n"
918 "Mode\n"
919 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
920 "Autonomous system number\n"
921 "Keyed message digest\n"
922 "HMAC SHA256 algorithm \n")
923 {
924 VTY_DECLVAR_CONTEXT(interface, ifp);
925 struct eigrp_interface *ei = ifp->info;
926 struct eigrp *eigrp;
927
928 eigrp = eigrp_lookup();
929 if (eigrp == NULL) {
930 vty_out(vty, " EIGRP Routing Process not enabled\n");
931 return CMD_SUCCESS;
932 }
933
934 if (!ei) {
935 vty_out(vty, " EIGRP not configured on this interface\n");
936 return CMD_SUCCESS;
937 }
938
939 // if(strncmp(argv[2], "md5",3))
940 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_MD5;
941 // else if(strncmp(argv[2], "hmac-sha-256",12))
942 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_SHA256;
943
944 return str2auth_type(argv[5]->arg, ei);
945 }
946
947 DEFUN (no_eigrp_authentication_mode,
948 no_eigrp_authentication_mode_cmd,
949 "no ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
950 "Disable\n"
951 "Interface Internet Protocol config commands\n"
952 "Authentication subcommands\n"
953 "Mode\n"
954 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
955 "Autonomous system number\n"
956 "Keyed message digest\n"
957 "HMAC SHA256 algorithm \n")
958 {
959 VTY_DECLVAR_CONTEXT(interface, ifp);
960 struct eigrp_interface *ei = ifp->info;
961 struct eigrp *eigrp;
962
963 eigrp = eigrp_lookup();
964 if (eigrp == NULL) {
965 vty_out(vty, " EIGRP Routing Process not enabled\n");
966 return CMD_SUCCESS;
967 }
968
969 if (!ei) {
970 vty_out(vty, " EIGRP not configured on this interface\n");
971 return CMD_SUCCESS;
972 }
973
974 ei->params.auth_type = EIGRP_AUTH_TYPE_NONE;
975
976 return CMD_SUCCESS;
977 }
978
979 DEFPY (eigrp_authentication_keychain,
980 eigrp_authentication_keychain_cmd,
981 "[no] ip authentication key-chain eigrp (1-65535)$as WORD$name",
982 NO_STR
983 "Interface Internet Protocol config commands\n"
984 "Authentication subcommands\n"
985 "Key-chain\n"
986 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
987 "Autonomous system number\n"
988 "Name of key-chain\n")
989 {
990 VTY_DECLVAR_CONTEXT(interface, ifp);
991 struct eigrp_interface *ei = ifp->info;
992 struct eigrp *eigrp;
993 struct keychain *keychain;
994
995 eigrp = eigrp_lookup();
996 if (eigrp == NULL) {
997 vty_out(vty, "EIGRP Routing Process not enabled\n");
998 return CMD_SUCCESS;
999 }
1000
1001 if (!ei) {
1002 vty_out(vty, " EIGRP not configured on this interface\n");
1003 return CMD_SUCCESS;
1004 }
1005
1006 if (no) {
1007 if ((ei->params.auth_keychain != NULL)
1008 && (strcmp(ei->params.auth_keychain, name) == 0)) {
1009 free(ei->params.auth_keychain);
1010 ei->params.auth_keychain = NULL;
1011 } else
1012 vty_out(vty,
1013 "Key chain with specified name not configured on interface\n");
1014 return CMD_SUCCESS;
1015 }
1016
1017 keychain = keychain_lookup(name);
1018 if (keychain != NULL) {
1019 if (ei->params.auth_keychain) {
1020 free(ei->params.auth_keychain);
1021 ei->params.auth_keychain = strdup(keychain->name);
1022 } else
1023 ei->params.auth_keychain = strdup(keychain->name);
1024 } else {
1025 vty_out(vty,
1026 "Key chain with specified name not found\n");
1027 return CMD_WARNING_CONFIG_FAILED;
1028 }
1029
1030 return CMD_SUCCESS;
1031 }
1032
1033 DEFUN (eigrp_redistribute_source_metric,
1034 eigrp_redistribute_source_metric_cmd,
1035 "redistribute " FRR_REDIST_STR_EIGRPD
1036 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
1037 REDIST_STR
1038 FRR_REDIST_HELP_STR_EIGRPD
1039 "Metric for redistributed routes\n"
1040 "Bandwidth metric in Kbits per second\n"
1041 "EIGRP delay metric, in 10 microsecond units\n"
1042 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1043 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1044 "EIGRP MTU of the path\n")
1045 {
1046 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
1047 struct eigrp_metrics metrics_from_command = {0};
1048 int source;
1049 int idx = 0;
1050
1051 /* Get distribute source. */
1052 argv_find(argv, argc, "redistribute", &idx);
1053 source = proto_redistnum(AFI_IP, argv[idx + 1]->text);
1054 if (source < 0) {
1055 vty_out(vty, "%% Invalid route type\n");
1056 return CMD_WARNING_CONFIG_FAILED;
1057 }
1058
1059 /* Get metrics values */
1060
1061 return eigrp_redistribute_set(eigrp, source, metrics_from_command);
1062 }
1063
1064 DEFUN (no_eigrp_redistribute_source_metric,
1065 no_eigrp_redistribute_source_metric_cmd,
1066 "no redistribute " FRR_REDIST_STR_EIGRPD
1067 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
1068 "Disable\n"
1069 REDIST_STR
1070 FRR_REDIST_HELP_STR_EIGRPD
1071 "Metric for redistributed routes\n"
1072 "Bandwidth metric in Kbits per second\n"
1073 "EIGRP delay metric, in 10 microsecond units\n"
1074 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1075 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1076 "EIGRP MTU of the path\n")
1077 {
1078 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
1079 int source;
1080 int idx = 0;
1081
1082 /* Get distribute source. */
1083 argv_find(argv, argc, "redistribute", &idx);
1084 source = proto_redistnum(AFI_IP, argv[idx + 1]->text);
1085 if (source < 0) {
1086 vty_out(vty, "%% Invalid route type\n");
1087 return CMD_WARNING_CONFIG_FAILED;
1088 }
1089
1090 /* Get metrics values */
1091
1092 return eigrp_redistribute_unset(eigrp, source);
1093 }
1094
1095 DEFUN (eigrp_variance,
1096 eigrp_variance_cmd,
1097 "variance (1-128)",
1098 "Control load balancing variance\n"
1099 "Metric variance multiplier\n")
1100 {
1101 struct eigrp *eigrp;
1102 uint8_t variance;
1103
1104 eigrp = eigrp_lookup();
1105 if (eigrp == NULL) {
1106 vty_out(vty, "EIGRP Routing Process not enabled\n");
1107 return CMD_SUCCESS;
1108 }
1109 variance = atoi(argv[1]->arg);
1110
1111 eigrp->variance = variance;
1112
1113 /*TODO: */
1114
1115 return CMD_SUCCESS;
1116 }
1117
1118 DEFUN (no_eigrp_variance,
1119 no_eigrp_variance_cmd,
1120 "no variance (1-128)",
1121 "Disable\n"
1122 "Control load balancing variance\n"
1123 "Metric variance multiplier\n")
1124 {
1125 struct eigrp *eigrp;
1126 eigrp = eigrp_lookup();
1127 if (eigrp == NULL) {
1128 vty_out(vty, "EIGRP Routing Process not enabled\n");
1129 return CMD_SUCCESS;
1130 }
1131
1132 eigrp->variance = EIGRP_VARIANCE_DEFAULT;
1133
1134 /*TODO: */
1135
1136 return CMD_SUCCESS;
1137 }
1138
1139 DEFUN (eigrp_maximum_paths,
1140 eigrp_maximum_paths_cmd,
1141 "maximum-paths (1-32)",
1142 "Forward packets over multiple paths\n"
1143 "Number of paths\n")
1144 {
1145 struct eigrp *eigrp;
1146 uint8_t max;
1147
1148 eigrp = eigrp_lookup();
1149 if (eigrp == NULL) {
1150 vty_out(vty, "EIGRP Routing Process not enabled\n");
1151 return CMD_SUCCESS;
1152 }
1153
1154 max = atoi(argv[1]->arg);
1155
1156 eigrp->max_paths = max;
1157
1158 /*TODO: */
1159
1160 return CMD_SUCCESS;
1161 }
1162
1163 DEFUN (no_eigrp_maximum_paths,
1164 no_eigrp_maximum_paths_cmd,
1165 "no maximum-paths <1-32>",
1166 NO_STR
1167 "Forward packets over multiple paths\n"
1168 "Number of paths\n")
1169 {
1170 struct eigrp *eigrp;
1171
1172 eigrp = eigrp_lookup();
1173 if (eigrp == NULL) {
1174 vty_out(vty, "EIGRP Routing Process not enabled\n");
1175 return CMD_SUCCESS;
1176 }
1177
1178 eigrp->max_paths = EIGRP_MAX_PATHS_DEFAULT;
1179
1180 /*TODO: */
1181
1182 return CMD_SUCCESS;
1183 }
1184
1185 /*
1186 * Execute hard restart for all neighbors
1187 */
1188 DEFUN (clear_ip_eigrp_neighbors,
1189 clear_ip_eigrp_neighbors_cmd,
1190 "clear ip eigrp neighbors",
1191 CLEAR_STR
1192 IP_STR
1193 "Clear IP-EIGRP\n"
1194 "Clear IP-EIGRP neighbors\n")
1195 {
1196 struct eigrp *eigrp;
1197 struct eigrp_interface *ei;
1198 struct listnode *node, *node2, *nnode2;
1199 struct eigrp_neighbor *nbr;
1200
1201 /* Check if eigrp process is enabled */
1202 eigrp = eigrp_lookup();
1203 if (eigrp == NULL) {
1204 vty_out(vty, " EIGRP Routing Process not enabled\n");
1205 return CMD_SUCCESS;
1206 }
1207
1208 /* iterate over all eigrp interfaces */
1209 for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) {
1210 /* send Goodbye Hello */
1211 eigrp_hello_send(ei, EIGRP_HELLO_GRACEFUL_SHUTDOWN, NULL);
1212
1213 /* iterate over all neighbors on eigrp interface */
1214 for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) {
1215 if (nbr->state != EIGRP_NEIGHBOR_DOWN) {
1216 zlog_debug(
1217 "Neighbor %s (%s) is down: manually cleared",
1218 inet_ntoa(nbr->src),
1219 ifindex2ifname(nbr->ei->ifp->ifindex,
1220 VRF_DEFAULT));
1221 vty_time_print(vty, 0);
1222 vty_out(vty,
1223 "Neighbor %s (%s) is down: manually cleared\n",
1224 inet_ntoa(nbr->src),
1225 ifindex2ifname(nbr->ei->ifp->ifindex,
1226 VRF_DEFAULT));
1227
1228 /* set neighbor to DOWN */
1229 nbr->state = EIGRP_NEIGHBOR_DOWN;
1230 /* delete neighbor */
1231 eigrp_nbr_delete(nbr);
1232 }
1233 }
1234 }
1235
1236 return CMD_SUCCESS;
1237 }
1238
1239 /*
1240 * Execute hard restart for all neighbors on interface
1241 */
1242 DEFUN (clear_ip_eigrp_neighbors_int,
1243 clear_ip_eigrp_neighbors_int_cmd,
1244 "clear ip eigrp neighbors IFNAME",
1245 CLEAR_STR
1246 IP_STR
1247 "Clear IP-EIGRP\n"
1248 "Clear IP-EIGRP neighbors\n"
1249 "Interface's name\n")
1250 {
1251 struct eigrp *eigrp;
1252 struct eigrp_interface *ei;
1253 struct listnode *node2, *nnode2;
1254 struct eigrp_neighbor *nbr;
1255 int idx = 0;
1256
1257 /* Check if eigrp process is enabled */
1258 eigrp = eigrp_lookup();
1259 if (eigrp == NULL) {
1260 vty_out(vty, " EIGRP Routing Process not enabled\n");
1261 return CMD_SUCCESS;
1262 }
1263
1264 /* lookup interface by specified name */
1265 argv_find(argv, argc, "IFNAME", &idx);
1266 ei = eigrp_if_lookup_by_name(eigrp, argv[idx]->arg);
1267 if (ei == NULL) {
1268 vty_out(vty, " Interface (%s) doesn't exist\n", argv[idx]->arg);
1269 return CMD_WARNING;
1270 }
1271
1272 /* send Goodbye Hello */
1273 eigrp_hello_send(ei, EIGRP_HELLO_GRACEFUL_SHUTDOWN, NULL);
1274
1275 /* iterate over all neighbors on eigrp interface */
1276 for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) {
1277 if (nbr->state != EIGRP_NEIGHBOR_DOWN) {
1278 zlog_debug("Neighbor %s (%s) is down: manually cleared",
1279 inet_ntoa(nbr->src),
1280 ifindex2ifname(nbr->ei->ifp->ifindex,
1281 VRF_DEFAULT));
1282 vty_time_print(vty, 0);
1283 vty_out(vty,
1284 "Neighbor %s (%s) is down: manually cleared\n",
1285 inet_ntoa(nbr->src),
1286 ifindex2ifname(nbr->ei->ifp->ifindex,
1287 VRF_DEFAULT));
1288
1289 /* set neighbor to DOWN */
1290 nbr->state = EIGRP_NEIGHBOR_DOWN;
1291 /* delete neighbor */
1292 eigrp_nbr_delete(nbr);
1293 }
1294 }
1295
1296 return CMD_SUCCESS;
1297 }
1298
1299 /*
1300 * Execute hard restart for neighbor specified by IP
1301 */
1302 DEFUN (clear_ip_eigrp_neighbors_IP,
1303 clear_ip_eigrp_neighbors_IP_cmd,
1304 "clear ip eigrp neighbors A.B.C.D",
1305 CLEAR_STR
1306 IP_STR
1307 "Clear IP-EIGRP\n"
1308 "Clear IP-EIGRP neighbors\n"
1309 "IP-EIGRP neighbor address\n")
1310 {
1311 struct eigrp *eigrp;
1312 struct eigrp_neighbor *nbr;
1313 struct in_addr nbr_addr;
1314
1315 if (!inet_aton(argv[4]->arg, &nbr_addr)) {
1316 vty_out(vty, "Unable to parse %s", argv[4]->arg);
1317 return CMD_WARNING;
1318 }
1319
1320 /* Check if eigrp process is enabled */
1321 eigrp = eigrp_lookup();
1322 if (eigrp == NULL) {
1323 vty_out(vty, " EIGRP Routing Process not enabled\n");
1324 return CMD_SUCCESS;
1325 }
1326
1327 /* lookup neighbor in whole process */
1328 nbr = eigrp_nbr_lookup_by_addr_process(eigrp, nbr_addr);
1329
1330 /* if neighbor doesn't exists, notify user and exit */
1331 if (nbr == NULL) {
1332 vty_out(vty, "Neighbor with entered address doesn't exists.\n");
1333 return CMD_WARNING;
1334 }
1335
1336 /* execute hard reset on neighbor */
1337 eigrp_nbr_hard_restart(nbr, vty);
1338
1339 return CMD_SUCCESS;
1340 }
1341
1342 /*
1343 * Execute graceful restart for all neighbors
1344 */
1345 DEFUN (clear_ip_eigrp_neighbors_soft,
1346 clear_ip_eigrp_neighbors_soft_cmd,
1347 "clear ip eigrp neighbors soft",
1348 CLEAR_STR
1349 IP_STR
1350 "Clear IP-EIGRP\n"
1351 "Clear IP-EIGRP neighbors\n"
1352 "Resync with peers without adjacency reset\n")
1353 {
1354 struct eigrp *eigrp;
1355
1356 /* Check if eigrp process is enabled */
1357 eigrp = eigrp_lookup();
1358 if (eigrp == NULL) {
1359 vty_out(vty, " EIGRP Routing Process not enabled\n");
1360 return CMD_SUCCESS;
1361 }
1362
1363 /* execute graceful restart on all neighbors */
1364 eigrp_update_send_process_GR(eigrp, EIGRP_GR_MANUAL, vty);
1365
1366 return CMD_SUCCESS;
1367 }
1368
1369 /*
1370 * Execute graceful restart for all neighbors on interface
1371 */
1372 DEFUN (clear_ip_eigrp_neighbors_int_soft,
1373 clear_ip_eigrp_neighbors_int_soft_cmd,
1374 "clear ip eigrp neighbors IFNAME soft",
1375 CLEAR_STR
1376 IP_STR
1377 "Clear IP-EIGRP\n"
1378 "Clear IP-EIGRP neighbors\n"
1379 "Interface's name\n"
1380 "Resync with peer without adjacency reset\n")
1381 {
1382 struct eigrp *eigrp;
1383 struct eigrp_interface *ei;
1384
1385 /* Check if eigrp process is enabled */
1386 eigrp = eigrp_lookup();
1387 if (eigrp == NULL) {
1388 vty_out(vty, " EIGRP Routing Process not enabled\n");
1389 return CMD_SUCCESS;
1390 }
1391
1392 /* lookup interface by specified name */
1393 ei = eigrp_if_lookup_by_name(eigrp, argv[4]->arg);
1394 if (ei == NULL) {
1395 vty_out(vty, " Interface (%s) doesn't exist\n", argv[4]->arg);
1396 return CMD_WARNING;
1397 }
1398
1399 /* execute graceful restart for all neighbors on interface */
1400 eigrp_update_send_interface_GR(ei, EIGRP_GR_MANUAL, vty);
1401 return CMD_SUCCESS;
1402 }
1403
1404 /*
1405 * Execute graceful restart for neighbor specified by IP
1406 */
1407 DEFUN (clear_ip_eigrp_neighbors_IP_soft,
1408 clear_ip_eigrp_neighbors_IP_soft_cmd,
1409 "clear ip eigrp neighbors A.B.C.D soft",
1410 CLEAR_STR
1411 IP_STR
1412 "Clear IP-EIGRP\n"
1413 "Clear IP-EIGRP neighbors\n"
1414 "IP-EIGRP neighbor address\n"
1415 "Resync with peer without adjacency reset\n")
1416 {
1417 struct eigrp *eigrp;
1418 struct eigrp_neighbor *nbr;
1419 struct in_addr nbr_addr;
1420
1421 if (!inet_aton(argv[4]->arg, &nbr_addr)) {
1422 vty_out(vty, "Unable to parse: %s", argv[4]->arg);
1423 return CMD_WARNING;
1424 }
1425
1426 /* Check if eigrp process is enabled */
1427 eigrp = eigrp_lookup();
1428 if (eigrp == NULL) {
1429 vty_out(vty, " EIGRP Routing Process not enabled\n");
1430 return CMD_SUCCESS;
1431 }
1432
1433 /* lookup neighbor in whole process */
1434 nbr = eigrp_nbr_lookup_by_addr_process(eigrp, nbr_addr);
1435
1436 /* if neighbor doesn't exists, notify user and exit */
1437 if (nbr == NULL) {
1438 vty_out(vty, "Neighbor with entered address doesn't exists.\n");
1439 return CMD_WARNING;
1440 }
1441
1442 /* execute graceful restart on neighbor */
1443 eigrp_update_send_GR(nbr, EIGRP_GR_MANUAL, vty);
1444
1445 return CMD_SUCCESS;
1446 }
1447
1448 static struct cmd_node eigrp_node = {EIGRP_NODE, "%s(config-router)# ", 1};
1449
1450 /* Save EIGRP configuration */
1451 static int eigrp_config_write(struct vty *vty)
1452 {
1453 struct eigrp *eigrp;
1454
1455 int write = 0;
1456
1457 eigrp = eigrp_lookup();
1458 if (eigrp != NULL) {
1459 /* Writes 'router eigrp' section to config */
1460 config_write_eigrp_router(vty, eigrp);
1461
1462 /* Interface config print */
1463 config_write_interfaces(vty, eigrp);
1464 //
1465 // /* static neighbor print. */
1466 // config_write_eigrp_nbr_nbma (vty, eigrp);
1467 //
1468 // /* Virtual-Link print. */
1469 // config_write_virtual_link (vty, eigrp);
1470 //
1471 // /* Default metric configuration. */
1472 // config_write_eigrp_default_metric (vty, eigrp);
1473 //
1474 // /* Distribute-list and default-information print. */
1475 // config_write_eigrp_distribute (vty, eigrp);
1476 //
1477 // /* Distance configuration. */
1478 // config_write_eigrp_distance (vty, eigrp)
1479 }
1480
1481 return write;
1482 }
1483
1484 void eigrp_vty_show_init(void)
1485 {
1486 install_element(VIEW_NODE, &show_ip_eigrp_interfaces_cmd);
1487
1488 install_element(VIEW_NODE, &show_ip_eigrp_neighbors_cmd);
1489
1490 install_element(VIEW_NODE, &show_ip_eigrp_topology_cmd);
1491
1492 install_element(VIEW_NODE, &show_ip_eigrp_topology_detail_cmd);
1493 }
1494
1495 /* eigrpd's interface node. */
1496 static struct cmd_node eigrp_interface_node = {INTERFACE_NODE,
1497 "%s(config-if)# ", 1};
1498
1499 void eigrp_vty_if_init(void)
1500 {
1501 install_node(&eigrp_interface_node, eigrp_write_interface);
1502 if_cmd_init();
1503
1504 /* Delay and bandwidth configuration commands*/
1505 install_element(INTERFACE_NODE, &eigrp_if_delay_cmd);
1506 install_element(INTERFACE_NODE, &no_eigrp_if_delay_cmd);
1507 install_element(INTERFACE_NODE, &eigrp_if_bandwidth_cmd);
1508 install_element(INTERFACE_NODE, &no_eigrp_if_bandwidth_cmd);
1509
1510 /*Hello-interval and hold-time interval configuration commands*/
1511 install_element(INTERFACE_NODE, &eigrp_if_ip_holdinterval_cmd);
1512 install_element(INTERFACE_NODE, &no_eigrp_if_ip_holdinterval_cmd);
1513 install_element(INTERFACE_NODE, &eigrp_if_ip_hellointerval_cmd);
1514 install_element(INTERFACE_NODE, &no_eigrp_if_ip_hellointerval_cmd);
1515
1516 /* "Authentication configuration commands */
1517 install_element(INTERFACE_NODE, &eigrp_authentication_mode_cmd);
1518 install_element(INTERFACE_NODE, &no_eigrp_authentication_mode_cmd);
1519 install_element(INTERFACE_NODE, &eigrp_authentication_keychain_cmd);
1520
1521 /*EIGRP Summarization commands*/
1522 install_element(INTERFACE_NODE, &eigrp_ip_summary_address_cmd);
1523 install_element(INTERFACE_NODE, &no_eigrp_ip_summary_address_cmd);
1524 }
1525
1526 static void eigrp_vty_zebra_init(void)
1527 {
1528 install_element(EIGRP_NODE, &eigrp_redistribute_source_metric_cmd);
1529 install_element(EIGRP_NODE, &no_eigrp_redistribute_source_metric_cmd);
1530 }
1531
1532 /* Install EIGRP related vty commands. */
1533 void eigrp_vty_init(void)
1534 {
1535 install_node(&eigrp_node, eigrp_config_write);
1536
1537 install_default(EIGRP_NODE);
1538
1539 install_element(CONFIG_NODE, &router_eigrp_cmd);
1540 install_element(CONFIG_NODE, &no_router_eigrp_cmd);
1541 install_element(EIGRP_NODE, &eigrp_network_cmd);
1542 install_element(EIGRP_NODE, &no_eigrp_network_cmd);
1543 install_element(EIGRP_NODE, &eigrp_variance_cmd);
1544 install_element(EIGRP_NODE, &no_eigrp_variance_cmd);
1545 install_element(EIGRP_NODE, &eigrp_router_id_cmd);
1546 install_element(EIGRP_NODE, &no_eigrp_router_id_cmd);
1547 install_element(EIGRP_NODE, &eigrp_passive_interface_cmd);
1548 install_element(EIGRP_NODE, &no_eigrp_passive_interface_cmd);
1549 install_element(EIGRP_NODE, &eigrp_timers_active_cmd);
1550 install_element(EIGRP_NODE, &no_eigrp_timers_active_cmd);
1551 install_element(EIGRP_NODE, &eigrp_metric_weights_cmd);
1552 install_element(EIGRP_NODE, &no_eigrp_metric_weights_cmd);
1553 install_element(EIGRP_NODE, &eigrp_maximum_paths_cmd);
1554 install_element(EIGRP_NODE, &no_eigrp_maximum_paths_cmd);
1555 install_element(EIGRP_NODE, &eigrp_neighbor_cmd);
1556 install_element(EIGRP_NODE, &no_eigrp_neighbor_cmd);
1557
1558 /* commands for manual hard restart */
1559 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_cmd);
1560 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_int_cmd);
1561 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_IP_cmd);
1562 /* commands for manual graceful restart */
1563 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_soft_cmd);
1564 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_int_soft_cmd);
1565 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_IP_soft_cmd);
1566
1567 eigrp_vty_zebra_init();
1568 }