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