]> git.proxmox.com Git - mirror_frr.git/blob - eigrpd/eigrp_vty.c
Merge pull request #3715 from qlyoung/fix-systemd-deps
[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 static void eigrp_vty_display_prefix_entry(struct vty *vty,
459 struct eigrp *eigrp,
460 struct eigrp_prefix_entry *pe,
461 bool all)
462 {
463 bool first = true;
464 struct eigrp_nexthop_entry *te;
465 struct listnode *node;
466
467 for (ALL_LIST_ELEMENTS_RO(pe->entries, node, te)) {
468 if (all
469 || (((te->flags
470 & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)
471 == EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)
472 || ((te->flags
473 & EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG)
474 == EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG))) {
475 show_ip_eigrp_nexthop_entry(vty, eigrp, te,
476 &first);
477 first = false;
478 }
479 }
480 }
481
482 DEFPY (show_ip_eigrp_topology_all,
483 show_ip_eigrp_topology_all_cmd,
484 "show ip eigrp topology [all-links$all]",
485 SHOW_STR
486 IP_STR
487 "IP-EIGRP show commands\n"
488 "IP-EIGRP topology\n"
489 "Show all links in topology table\n")
490 {
491 struct eigrp *eigrp;
492 struct eigrp_prefix_entry *tn;
493 struct route_node *rn;
494
495 eigrp = eigrp_lookup();
496 if (eigrp == NULL) {
497 vty_out(vty, " EIGRP Routing Process not enabled\n");
498 return CMD_SUCCESS;
499 }
500
501 show_ip_eigrp_topology_header(vty, eigrp);
502
503 for (rn = route_top(eigrp->topology_table); rn; rn = route_next(rn)) {
504 if (!rn->info)
505 continue;
506
507 tn = rn->info;
508 eigrp_vty_display_prefix_entry(vty, eigrp, tn,
509 all ? true : false);
510 }
511
512 return CMD_SUCCESS;
513
514 }
515
516 DEFPY (show_ip_eigrp_topology,
517 show_ip_eigrp_topology_cmd,
518 "show ip eigrp topology <A.B.C.D$address|A.B.C.D/M$prefix>",
519 SHOW_STR
520 IP_STR
521 "IP-EIGRP show commands\n"
522 "IP-EIGRP topology\n"
523 "For a specific address\n"
524 "For a specific prefix\n")
525 {
526 struct eigrp *eigrp;
527 struct eigrp_prefix_entry *tn;
528 struct route_node *rn;
529 struct prefix cmp;
530
531 eigrp = eigrp_lookup();
532 if (eigrp == NULL) {
533 vty_out(vty, " EIGRP Routing Process not enabled\n");
534 return CMD_SUCCESS;
535 }
536
537 show_ip_eigrp_topology_header(vty, eigrp);
538
539 if (address_str)
540 prefix_str = address_str;
541
542 if (str2prefix(prefix_str, &cmp) < 0) {
543 vty_out(vty, "%% Malformed address\n");
544 return CMD_WARNING;
545 }
546
547 rn = route_node_match(eigrp->topology_table, &cmp);
548 if (!rn) {
549 vty_out(vty, "%% Network not in table\n");
550 return CMD_WARNING;
551 }
552
553 if (!rn->info) {
554 vty_out(vty, "%% Network not in table\n");
555 route_unlock_node(rn);
556 return CMD_WARNING;
557 }
558
559 tn = rn->info;
560 eigrp_vty_display_prefix_entry(vty, eigrp, tn, argc == 5);
561
562 return CMD_SUCCESS;
563 }
564
565 DEFUN (show_ip_eigrp_interfaces,
566 show_ip_eigrp_interfaces_cmd,
567 "show ip eigrp interfaces [IFNAME] [detail]",
568 SHOW_STR
569 IP_STR
570 "IP-EIGRP show commands\n"
571 "IP-EIGRP interfaces\n"
572 "Interface name to look at\n"
573 "Detailed information\n")
574 {
575 struct eigrp_interface *ei;
576 struct eigrp *eigrp;
577 struct listnode *node;
578 int idx = 0;
579 bool detail = false;
580 const char *ifname = NULL;
581
582 eigrp = eigrp_lookup();
583 if (eigrp == NULL) {
584 vty_out(vty, "EIGRP Routing Process not enabled\n");
585 return CMD_SUCCESS;
586 }
587
588 if (argv_find(argv, argc, "IFNAME", &idx))
589 ifname = argv[idx]->arg;
590
591 if (argv_find(argv, argc, "detail", &idx))
592 detail = true;
593
594 if (!ifname)
595 show_ip_eigrp_interface_header(vty, eigrp);
596
597 for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) {
598 if (!ifname || strcmp(ei->ifp->name, ifname) == 0) {
599 show_ip_eigrp_interface_sub(vty, eigrp, ei);
600 if (detail)
601 show_ip_eigrp_interface_detail(vty, eigrp, ei);
602 }
603 }
604
605 return CMD_SUCCESS;
606 }
607
608 DEFUN (show_ip_eigrp_neighbors,
609 show_ip_eigrp_neighbors_cmd,
610 "show ip eigrp neighbors [IFNAME] [detail]",
611 SHOW_STR
612 IP_STR
613 "IP-EIGRP show commands\n"
614 "IP-EIGRP neighbors\n"
615 "Interface to show on\n"
616 "Detailed Information\n")
617 {
618 struct eigrp *eigrp;
619 struct eigrp_interface *ei;
620 struct listnode *node, *node2, *nnode2;
621 struct eigrp_neighbor *nbr;
622 bool detail = false;
623 int idx = 0;
624 const char *ifname = NULL;
625
626 eigrp = eigrp_lookup();
627 if (eigrp == NULL) {
628 vty_out(vty, " EIGRP Routing Process not enabled\n");
629 return CMD_SUCCESS;
630 }
631
632 if (argv_find(argv, argc, "IFNAME", &idx))
633 ifname = argv[idx]->arg;
634
635 detail = (argv_find(argv, argc, "detail", &idx));
636
637 show_ip_eigrp_neighbor_header(vty, eigrp);
638
639 for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) {
640 if (!ifname || strcmp(ei->ifp->name, ifname) == 0) {
641 for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) {
642 if (detail || (nbr->state == EIGRP_NEIGHBOR_UP))
643 show_ip_eigrp_neighbor_sub(vty, nbr,
644 detail);
645 }
646 }
647 }
648
649 return CMD_SUCCESS;
650 }
651
652 DEFUN (eigrp_if_delay,
653 eigrp_if_delay_cmd,
654 "delay (1-16777215)",
655 "Specify interface throughput delay\n"
656 "Throughput delay (tens of microseconds)\n")
657 {
658 VTY_DECLVAR_CONTEXT(interface, ifp);
659 struct eigrp_interface *ei = ifp->info;
660 struct eigrp *eigrp;
661 uint32_t delay;
662
663 eigrp = eigrp_lookup();
664 if (eigrp == NULL) {
665 vty_out(vty, " EIGRP Routing Process not enabled\n");
666
667 return CMD_SUCCESS;
668 }
669
670 if (!ei) {
671 vty_out(vty, " EIGRP not configured on this interface\n");
672 return CMD_SUCCESS;
673 }
674 delay = atoi(argv[1]->arg);
675
676 ei->params.delay = delay;
677 eigrp_if_reset(ifp);
678
679 return CMD_SUCCESS;
680 }
681
682 DEFUN (no_eigrp_if_delay,
683 no_eigrp_if_delay_cmd,
684 "no delay (1-16777215)",
685 NO_STR
686 "Specify interface throughput delay\n"
687 "Throughput delay (tens of microseconds)\n")
688 {
689 VTY_DECLVAR_CONTEXT(interface, ifp);
690 struct eigrp_interface *ei = ifp->info;
691 struct eigrp *eigrp;
692
693 eigrp = eigrp_lookup();
694 if (eigrp == NULL) {
695 vty_out(vty, " EIGRP Routing Process not enabled\n");
696
697 return CMD_SUCCESS;
698 }
699 if (!ei) {
700 vty_out(vty, " EIGRP not configured on this interface\n");
701 return CMD_SUCCESS;
702 }
703
704 ei->params.delay = EIGRP_DELAY_DEFAULT;
705 eigrp_if_reset(ifp);
706
707 return CMD_SUCCESS;
708 }
709
710 DEFPY (eigrp_if_bandwidth,
711 eigrp_if_bandwidth_cmd,
712 "eigrp bandwidth (1-10000000)$bw",
713 "EIGRP specific commands\n"
714 "Set bandwidth informational parameter\n"
715 "Bandwidth in kilobits\n")
716 {
717 VTY_DECLVAR_CONTEXT(interface, ifp);
718 struct eigrp_interface *ei = ifp->info;
719 struct eigrp *eigrp;
720
721 eigrp = eigrp_lookup();
722 if (eigrp == NULL) {
723 vty_out(vty, " EIGRP Routing Process not enabled\n");
724 return CMD_SUCCESS;
725 }
726
727 if (!ei) {
728 vty_out(vty, " EIGRP not configured on this interface\n");
729 return CMD_SUCCESS;
730 }
731
732 ei->params.bandwidth = bw;
733 eigrp_if_reset(ifp);
734
735 return CMD_SUCCESS;
736 }
737
738 DEFUN (no_eigrp_if_bandwidth,
739 no_eigrp_if_bandwidth_cmd,
740 "no eigrp bandwidth [(1-10000000)]",
741 NO_STR
742 "EIGRP specific commands\n"
743 "Set bandwidth informational parameter\n"
744 "Bandwidth in kilobits\n")
745 {
746 VTY_DECLVAR_CONTEXT(interface, ifp);
747 struct eigrp_interface *ei = ifp->info;
748 struct eigrp *eigrp;
749
750 eigrp = eigrp_lookup();
751 if (eigrp == NULL) {
752 vty_out(vty, " EIGRP Routing Process not enabled\n");
753 return CMD_SUCCESS;
754 }
755
756 if (!ei) {
757 vty_out(vty, " EIGRP not configured on this interface\n");
758 return CMD_SUCCESS;
759 }
760
761 ei->params.bandwidth = EIGRP_BANDWIDTH_DEFAULT;
762 eigrp_if_reset(ifp);
763
764 return CMD_SUCCESS;
765 }
766
767 DEFUN (eigrp_if_ip_hellointerval,
768 eigrp_if_ip_hellointerval_cmd,
769 "ip hello-interval eigrp (1-65535)",
770 "Interface Internet Protocol config commands\n"
771 "Configures EIGRP hello interval\n"
772 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
773 "Seconds between hello transmissions\n")
774 {
775 VTY_DECLVAR_CONTEXT(interface, ifp);
776 struct eigrp_interface *ei = ifp->info;
777 uint32_t hello;
778 struct eigrp *eigrp;
779
780 eigrp = eigrp_lookup();
781 if (eigrp == NULL) {
782 vty_out(vty, " EIGRP Routing Process not enabled\n");
783 return CMD_SUCCESS;
784 }
785
786 if (!ei) {
787 vty_out(vty, " EIGRP not configured on this interface\n");
788 return CMD_SUCCESS;
789 }
790
791 hello = atoi(argv[3]->arg);
792
793 ei->params.v_hello = hello;
794
795 return CMD_SUCCESS;
796 }
797
798 DEFUN (no_eigrp_if_ip_hellointerval,
799 no_eigrp_if_ip_hellointerval_cmd,
800 "no ip hello-interval eigrp [(1-65535)]",
801 NO_STR
802 "Interface Internet Protocol config commands\n"
803 "Configures EIGRP hello interval\n"
804 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
805 "Seconds between hello transmissions\n")
806 {
807 VTY_DECLVAR_CONTEXT(interface, ifp);
808 struct eigrp_interface *ei = ifp->info;
809 struct eigrp *eigrp;
810
811 eigrp = eigrp_lookup();
812 if (eigrp == NULL) {
813 vty_out(vty, " EIGRP Routing Process not enabled\n");
814 return CMD_SUCCESS;
815 }
816
817 if (!ei) {
818 vty_out(vty, " EIGRP not configured on this interface\n");
819 return CMD_SUCCESS;
820 }
821
822 ei->params.v_hello = EIGRP_HELLO_INTERVAL_DEFAULT;
823
824 THREAD_TIMER_OFF(ei->t_hello);
825 thread_add_timer(master, eigrp_hello_timer, ei, 1, &ei->t_hello);
826
827 return CMD_SUCCESS;
828 }
829
830 DEFUN (eigrp_if_ip_holdinterval,
831 eigrp_if_ip_holdinterval_cmd,
832 "ip hold-time eigrp (1-65535)",
833 "Interface Internet Protocol config commands\n"
834 "Configures EIGRP IPv4 hold time\n"
835 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
836 "Seconds before neighbor is considered down\n")
837 {
838 VTY_DECLVAR_CONTEXT(interface, ifp);
839 struct eigrp_interface *ei = ifp->info;
840 uint32_t hold;
841 struct eigrp *eigrp;
842
843 eigrp = eigrp_lookup();
844 if (eigrp == NULL) {
845 vty_out(vty, " EIGRP Routing Process not enabled\n");
846 return CMD_SUCCESS;
847 }
848
849 if (!ei) {
850 vty_out(vty, " EIGRP not configured on this interface\n");
851 return CMD_SUCCESS;
852 }
853
854 hold = atoi(argv[3]->arg);
855
856 ei->params.v_wait = hold;
857
858 return CMD_SUCCESS;
859 }
860
861 DEFUN (eigrp_ip_summary_address,
862 eigrp_ip_summary_address_cmd,
863 "ip summary-address eigrp (1-65535) A.B.C.D/M",
864 "Interface Internet Protocol config commands\n"
865 "Perform address summarization\n"
866 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
867 "AS number\n"
868 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
869 {
870 // VTY_DECLVAR_CONTEXT(interface, ifp);
871 // uint32_t AS;
872 struct eigrp *eigrp;
873
874 eigrp = eigrp_lookup();
875 if (eigrp == NULL) {
876 vty_out(vty, " EIGRP Routing Process not enabled\n");
877 return CMD_SUCCESS;
878 }
879
880 // AS = atoi (argv[3]->arg);
881
882 /*TODO: */
883
884 return CMD_SUCCESS;
885 }
886
887 DEFUN (no_eigrp_ip_summary_address,
888 no_eigrp_ip_summary_address_cmd,
889 "no ip summary-address eigrp (1-65535) A.B.C.D/M",
890 NO_STR
891 "Interface Internet Protocol config commands\n"
892 "Perform address summarization\n"
893 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
894 "AS number\n"
895 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
896 {
897 // VTY_DECLVAR_CONTEXT(interface, ifp);
898 // uint32_t AS;
899 struct eigrp *eigrp;
900
901 eigrp = eigrp_lookup();
902 if (eigrp == NULL) {
903 vty_out(vty, " EIGRP Routing Process not enabled\n");
904 return CMD_SUCCESS;
905 }
906
907 // AS = atoi (argv[4]->arg);
908
909 /*TODO: */
910
911 return CMD_SUCCESS;
912 }
913
914 DEFUN (no_eigrp_if_ip_holdinterval,
915 no_eigrp_if_ip_holdinterval_cmd,
916 "no ip hold-time eigrp",
917 NO_STR
918 "Interface Internet Protocol config commands\n"
919 "Configures EIGRP hello interval\n"
920 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n")
921 {
922 VTY_DECLVAR_CONTEXT(interface, ifp);
923 struct eigrp_interface *ei = ifp->info;
924 struct eigrp *eigrp;
925
926 eigrp = eigrp_lookup();
927 if (eigrp == NULL) {
928 vty_out(vty, " EIGRP Routing Process not enabled\n");
929 return CMD_SUCCESS;
930 }
931
932 if (!ei) {
933 vty_out(vty, " EIGRP not configured on this interface\n");
934 return CMD_SUCCESS;
935 }
936
937 ei->params.v_wait = EIGRP_HOLD_INTERVAL_DEFAULT;
938
939 return CMD_SUCCESS;
940 }
941
942 static int str2auth_type(const char *str, struct eigrp_interface *ei)
943 {
944 /* Sanity check. */
945 if (str == NULL)
946 return CMD_WARNING_CONFIG_FAILED;
947
948 if (strncmp(str, "md5", 3) == 0) {
949 ei->params.auth_type = EIGRP_AUTH_TYPE_MD5;
950 return CMD_SUCCESS;
951 } else if (strncmp(str, "hmac-sha-256", 12) == 0) {
952 ei->params.auth_type = EIGRP_AUTH_TYPE_SHA256;
953 return CMD_SUCCESS;
954 }
955
956 return CMD_WARNING_CONFIG_FAILED;
957 }
958
959 DEFUN (eigrp_authentication_mode,
960 eigrp_authentication_mode_cmd,
961 "ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
962 "Interface Internet Protocol config commands\n"
963 "Authentication subcommands\n"
964 "Mode\n"
965 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
966 "Autonomous system number\n"
967 "Keyed message digest\n"
968 "HMAC SHA256 algorithm \n")
969 {
970 VTY_DECLVAR_CONTEXT(interface, ifp);
971 struct eigrp_interface *ei = ifp->info;
972 struct eigrp *eigrp;
973
974 eigrp = eigrp_lookup();
975 if (eigrp == NULL) {
976 vty_out(vty, " EIGRP Routing Process not enabled\n");
977 return CMD_SUCCESS;
978 }
979
980 if (!ei) {
981 vty_out(vty, " EIGRP not configured on this interface\n");
982 return CMD_SUCCESS;
983 }
984
985 // if(strncmp(argv[2], "md5",3))
986 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_MD5;
987 // else if(strncmp(argv[2], "hmac-sha-256",12))
988 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_SHA256;
989
990 return str2auth_type(argv[5]->arg, ei);
991 }
992
993 DEFUN (no_eigrp_authentication_mode,
994 no_eigrp_authentication_mode_cmd,
995 "no ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
996 "Disable\n"
997 "Interface Internet Protocol config commands\n"
998 "Authentication subcommands\n"
999 "Mode\n"
1000 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
1001 "Autonomous system number\n"
1002 "Keyed message digest\n"
1003 "HMAC SHA256 algorithm \n")
1004 {
1005 VTY_DECLVAR_CONTEXT(interface, ifp);
1006 struct eigrp_interface *ei = ifp->info;
1007 struct eigrp *eigrp;
1008
1009 eigrp = eigrp_lookup();
1010 if (eigrp == NULL) {
1011 vty_out(vty, " EIGRP Routing Process not enabled\n");
1012 return CMD_SUCCESS;
1013 }
1014
1015 if (!ei) {
1016 vty_out(vty, " EIGRP not configured on this interface\n");
1017 return CMD_SUCCESS;
1018 }
1019
1020 ei->params.auth_type = EIGRP_AUTH_TYPE_NONE;
1021
1022 return CMD_SUCCESS;
1023 }
1024
1025 DEFPY (eigrp_authentication_keychain,
1026 eigrp_authentication_keychain_cmd,
1027 "[no] ip authentication key-chain eigrp (1-65535)$as WORD$name",
1028 NO_STR
1029 "Interface Internet Protocol config commands\n"
1030 "Authentication subcommands\n"
1031 "Key-chain\n"
1032 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
1033 "Autonomous system number\n"
1034 "Name of key-chain\n")
1035 {
1036 VTY_DECLVAR_CONTEXT(interface, ifp);
1037 struct eigrp_interface *ei = ifp->info;
1038 struct eigrp *eigrp;
1039 struct keychain *keychain;
1040
1041 eigrp = eigrp_lookup();
1042 if (eigrp == NULL) {
1043 vty_out(vty, "EIGRP Routing Process not enabled\n");
1044 return CMD_SUCCESS;
1045 }
1046
1047 if (!ei) {
1048 vty_out(vty, " EIGRP not configured on this interface\n");
1049 return CMD_SUCCESS;
1050 }
1051
1052 if (no) {
1053 if ((ei->params.auth_keychain != NULL)
1054 && (strcmp(ei->params.auth_keychain, name) == 0)) {
1055 free(ei->params.auth_keychain);
1056 ei->params.auth_keychain = NULL;
1057 } else
1058 vty_out(vty,
1059 "Key chain with specified name not configured on interface\n");
1060 return CMD_SUCCESS;
1061 }
1062
1063 keychain = keychain_lookup(name);
1064 if (keychain != NULL) {
1065 if (ei->params.auth_keychain) {
1066 free(ei->params.auth_keychain);
1067 ei->params.auth_keychain = strdup(keychain->name);
1068 } else
1069 ei->params.auth_keychain = strdup(keychain->name);
1070 } else {
1071 vty_out(vty,
1072 "Key chain with specified name not found\n");
1073 return CMD_WARNING_CONFIG_FAILED;
1074 }
1075
1076 return CMD_SUCCESS;
1077 }
1078
1079 DEFUN (eigrp_redistribute_source_metric,
1080 eigrp_redistribute_source_metric_cmd,
1081 "redistribute " FRR_REDIST_STR_EIGRPD
1082 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
1083 REDIST_STR
1084 FRR_REDIST_HELP_STR_EIGRPD
1085 "Metric for redistributed routes\n"
1086 "Bandwidth metric in Kbits per second\n"
1087 "EIGRP delay metric, in 10 microsecond units\n"
1088 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1089 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1090 "EIGRP MTU of the path\n")
1091 {
1092 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
1093 struct eigrp_metrics metrics_from_command = {0};
1094 int source;
1095 int idx = 0;
1096
1097 /* Get distribute source. */
1098 argv_find(argv, argc, "redistribute", &idx);
1099 source = proto_redistnum(AFI_IP, argv[idx + 1]->text);
1100 if (source < 0) {
1101 vty_out(vty, "%% Invalid route type\n");
1102 return CMD_WARNING_CONFIG_FAILED;
1103 }
1104
1105 /* Get metrics values */
1106
1107 return eigrp_redistribute_set(eigrp, source, metrics_from_command);
1108 }
1109
1110 DEFUN (no_eigrp_redistribute_source_metric,
1111 no_eigrp_redistribute_source_metric_cmd,
1112 "no redistribute " FRR_REDIST_STR_EIGRPD
1113 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
1114 "Disable\n"
1115 REDIST_STR
1116 FRR_REDIST_HELP_STR_EIGRPD
1117 "Metric for redistributed routes\n"
1118 "Bandwidth metric in Kbits per second\n"
1119 "EIGRP delay metric, in 10 microsecond units\n"
1120 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1121 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1122 "EIGRP MTU of the path\n")
1123 {
1124 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
1125 int source;
1126 int idx = 0;
1127
1128 /* Get distribute source. */
1129 argv_find(argv, argc, "redistribute", &idx);
1130 source = proto_redistnum(AFI_IP, argv[idx + 1]->text);
1131 if (source < 0) {
1132 vty_out(vty, "%% Invalid route type\n");
1133 return CMD_WARNING_CONFIG_FAILED;
1134 }
1135
1136 /* Get metrics values */
1137
1138 return eigrp_redistribute_unset(eigrp, source);
1139 }
1140
1141 DEFUN (eigrp_variance,
1142 eigrp_variance_cmd,
1143 "variance (1-128)",
1144 "Control load balancing variance\n"
1145 "Metric variance multiplier\n")
1146 {
1147 struct eigrp *eigrp;
1148 uint8_t variance;
1149
1150 eigrp = eigrp_lookup();
1151 if (eigrp == NULL) {
1152 vty_out(vty, "EIGRP Routing Process not enabled\n");
1153 return CMD_SUCCESS;
1154 }
1155 variance = atoi(argv[1]->arg);
1156
1157 eigrp->variance = variance;
1158
1159 /*TODO: */
1160
1161 return CMD_SUCCESS;
1162 }
1163
1164 DEFUN (no_eigrp_variance,
1165 no_eigrp_variance_cmd,
1166 "no variance (1-128)",
1167 "Disable\n"
1168 "Control load balancing variance\n"
1169 "Metric variance multiplier\n")
1170 {
1171 struct eigrp *eigrp;
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->variance = EIGRP_VARIANCE_DEFAULT;
1179
1180 /*TODO: */
1181
1182 return CMD_SUCCESS;
1183 }
1184
1185 DEFUN (eigrp_maximum_paths,
1186 eigrp_maximum_paths_cmd,
1187 "maximum-paths (1-32)",
1188 "Forward packets over multiple paths\n"
1189 "Number of paths\n")
1190 {
1191 struct eigrp *eigrp;
1192 uint8_t max;
1193
1194 eigrp = eigrp_lookup();
1195 if (eigrp == NULL) {
1196 vty_out(vty, "EIGRP Routing Process not enabled\n");
1197 return CMD_SUCCESS;
1198 }
1199
1200 max = atoi(argv[1]->arg);
1201
1202 eigrp->max_paths = max;
1203
1204 /*TODO: */
1205
1206 return CMD_SUCCESS;
1207 }
1208
1209 DEFUN (no_eigrp_maximum_paths,
1210 no_eigrp_maximum_paths_cmd,
1211 "no maximum-paths <1-32>",
1212 NO_STR
1213 "Forward packets over multiple paths\n"
1214 "Number of paths\n")
1215 {
1216 struct eigrp *eigrp;
1217
1218 eigrp = eigrp_lookup();
1219 if (eigrp == NULL) {
1220 vty_out(vty, "EIGRP Routing Process not enabled\n");
1221 return CMD_SUCCESS;
1222 }
1223
1224 eigrp->max_paths = EIGRP_MAX_PATHS_DEFAULT;
1225
1226 /*TODO: */
1227
1228 return CMD_SUCCESS;
1229 }
1230
1231 /*
1232 * Execute hard restart for all neighbors
1233 */
1234 DEFUN (clear_ip_eigrp_neighbors,
1235 clear_ip_eigrp_neighbors_cmd,
1236 "clear ip eigrp neighbors",
1237 CLEAR_STR
1238 IP_STR
1239 "Clear IP-EIGRP\n"
1240 "Clear IP-EIGRP neighbors\n")
1241 {
1242 struct eigrp *eigrp;
1243 struct eigrp_interface *ei;
1244 struct listnode *node, *node2, *nnode2;
1245 struct eigrp_neighbor *nbr;
1246
1247 /* Check if eigrp process is enabled */
1248 eigrp = eigrp_lookup();
1249 if (eigrp == NULL) {
1250 vty_out(vty, " EIGRP Routing Process not enabled\n");
1251 return CMD_SUCCESS;
1252 }
1253
1254 /* iterate over all eigrp interfaces */
1255 for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) {
1256 /* send Goodbye Hello */
1257 eigrp_hello_send(ei, EIGRP_HELLO_GRACEFUL_SHUTDOWN, NULL);
1258
1259 /* iterate over all neighbors on eigrp interface */
1260 for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) {
1261 if (nbr->state != EIGRP_NEIGHBOR_DOWN) {
1262 zlog_debug(
1263 "Neighbor %s (%s) is down: manually cleared",
1264 inet_ntoa(nbr->src),
1265 ifindex2ifname(nbr->ei->ifp->ifindex,
1266 VRF_DEFAULT));
1267 vty_time_print(vty, 0);
1268 vty_out(vty,
1269 "Neighbor %s (%s) is down: manually cleared\n",
1270 inet_ntoa(nbr->src),
1271 ifindex2ifname(nbr->ei->ifp->ifindex,
1272 VRF_DEFAULT));
1273
1274 /* set neighbor to DOWN */
1275 nbr->state = EIGRP_NEIGHBOR_DOWN;
1276 /* delete neighbor */
1277 eigrp_nbr_delete(nbr);
1278 }
1279 }
1280 }
1281
1282 return CMD_SUCCESS;
1283 }
1284
1285 /*
1286 * Execute hard restart for all neighbors on interface
1287 */
1288 DEFUN (clear_ip_eigrp_neighbors_int,
1289 clear_ip_eigrp_neighbors_int_cmd,
1290 "clear ip eigrp neighbors IFNAME",
1291 CLEAR_STR
1292 IP_STR
1293 "Clear IP-EIGRP\n"
1294 "Clear IP-EIGRP neighbors\n"
1295 "Interface's name\n")
1296 {
1297 struct eigrp *eigrp;
1298 struct eigrp_interface *ei;
1299 struct listnode *node2, *nnode2;
1300 struct eigrp_neighbor *nbr;
1301 int idx = 0;
1302
1303 /* Check if eigrp process is enabled */
1304 eigrp = eigrp_lookup();
1305 if (eigrp == NULL) {
1306 vty_out(vty, " EIGRP Routing Process not enabled\n");
1307 return CMD_SUCCESS;
1308 }
1309
1310 /* lookup interface by specified name */
1311 argv_find(argv, argc, "IFNAME", &idx);
1312 ei = eigrp_if_lookup_by_name(eigrp, argv[idx]->arg);
1313 if (ei == NULL) {
1314 vty_out(vty, " Interface (%s) doesn't exist\n", argv[idx]->arg);
1315 return CMD_WARNING;
1316 }
1317
1318 /* send Goodbye Hello */
1319 eigrp_hello_send(ei, EIGRP_HELLO_GRACEFUL_SHUTDOWN, NULL);
1320
1321 /* iterate over all neighbors on eigrp interface */
1322 for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) {
1323 if (nbr->state != EIGRP_NEIGHBOR_DOWN) {
1324 zlog_debug("Neighbor %s (%s) is down: manually cleared",
1325 inet_ntoa(nbr->src),
1326 ifindex2ifname(nbr->ei->ifp->ifindex,
1327 VRF_DEFAULT));
1328 vty_time_print(vty, 0);
1329 vty_out(vty,
1330 "Neighbor %s (%s) is down: manually cleared\n",
1331 inet_ntoa(nbr->src),
1332 ifindex2ifname(nbr->ei->ifp->ifindex,
1333 VRF_DEFAULT));
1334
1335 /* set neighbor to DOWN */
1336 nbr->state = EIGRP_NEIGHBOR_DOWN;
1337 /* delete neighbor */
1338 eigrp_nbr_delete(nbr);
1339 }
1340 }
1341
1342 return CMD_SUCCESS;
1343 }
1344
1345 /*
1346 * Execute hard restart for neighbor specified by IP
1347 */
1348 DEFUN (clear_ip_eigrp_neighbors_IP,
1349 clear_ip_eigrp_neighbors_IP_cmd,
1350 "clear ip eigrp neighbors A.B.C.D",
1351 CLEAR_STR
1352 IP_STR
1353 "Clear IP-EIGRP\n"
1354 "Clear IP-EIGRP neighbors\n"
1355 "IP-EIGRP neighbor address\n")
1356 {
1357 struct eigrp *eigrp;
1358 struct eigrp_neighbor *nbr;
1359 struct in_addr nbr_addr;
1360
1361 if (!inet_aton(argv[4]->arg, &nbr_addr)) {
1362 vty_out(vty, "Unable to parse %s", argv[4]->arg);
1363 return CMD_WARNING;
1364 }
1365
1366 /* Check if eigrp process is enabled */
1367 eigrp = eigrp_lookup();
1368 if (eigrp == NULL) {
1369 vty_out(vty, " EIGRP Routing Process not enabled\n");
1370 return CMD_SUCCESS;
1371 }
1372
1373 /* lookup neighbor in whole process */
1374 nbr = eigrp_nbr_lookup_by_addr_process(eigrp, nbr_addr);
1375
1376 /* if neighbor doesn't exists, notify user and exit */
1377 if (nbr == NULL) {
1378 vty_out(vty, "Neighbor with entered address doesn't exists.\n");
1379 return CMD_WARNING;
1380 }
1381
1382 /* execute hard reset on neighbor */
1383 eigrp_nbr_hard_restart(nbr, vty);
1384
1385 return CMD_SUCCESS;
1386 }
1387
1388 /*
1389 * Execute graceful restart for all neighbors
1390 */
1391 DEFUN (clear_ip_eigrp_neighbors_soft,
1392 clear_ip_eigrp_neighbors_soft_cmd,
1393 "clear ip eigrp neighbors soft",
1394 CLEAR_STR
1395 IP_STR
1396 "Clear IP-EIGRP\n"
1397 "Clear IP-EIGRP neighbors\n"
1398 "Resync with peers without adjacency reset\n")
1399 {
1400 struct eigrp *eigrp;
1401
1402 /* Check if eigrp process is enabled */
1403 eigrp = eigrp_lookup();
1404 if (eigrp == NULL) {
1405 vty_out(vty, " EIGRP Routing Process not enabled\n");
1406 return CMD_SUCCESS;
1407 }
1408
1409 /* execute graceful restart on all neighbors */
1410 eigrp_update_send_process_GR(eigrp, EIGRP_GR_MANUAL, vty);
1411
1412 return CMD_SUCCESS;
1413 }
1414
1415 /*
1416 * Execute graceful restart for all neighbors on interface
1417 */
1418 DEFUN (clear_ip_eigrp_neighbors_int_soft,
1419 clear_ip_eigrp_neighbors_int_soft_cmd,
1420 "clear ip eigrp neighbors IFNAME soft",
1421 CLEAR_STR
1422 IP_STR
1423 "Clear IP-EIGRP\n"
1424 "Clear IP-EIGRP neighbors\n"
1425 "Interface's name\n"
1426 "Resync with peer without adjacency reset\n")
1427 {
1428 struct eigrp *eigrp;
1429 struct eigrp_interface *ei;
1430
1431 /* Check if eigrp process is enabled */
1432 eigrp = eigrp_lookup();
1433 if (eigrp == NULL) {
1434 vty_out(vty, " EIGRP Routing Process not enabled\n");
1435 return CMD_SUCCESS;
1436 }
1437
1438 /* lookup interface by specified name */
1439 ei = eigrp_if_lookup_by_name(eigrp, argv[4]->arg);
1440 if (ei == NULL) {
1441 vty_out(vty, " Interface (%s) doesn't exist\n", argv[4]->arg);
1442 return CMD_WARNING;
1443 }
1444
1445 /* execute graceful restart for all neighbors on interface */
1446 eigrp_update_send_interface_GR(ei, EIGRP_GR_MANUAL, vty);
1447 return CMD_SUCCESS;
1448 }
1449
1450 /*
1451 * Execute graceful restart for neighbor specified by IP
1452 */
1453 DEFUN (clear_ip_eigrp_neighbors_IP_soft,
1454 clear_ip_eigrp_neighbors_IP_soft_cmd,
1455 "clear ip eigrp neighbors A.B.C.D soft",
1456 CLEAR_STR
1457 IP_STR
1458 "Clear IP-EIGRP\n"
1459 "Clear IP-EIGRP neighbors\n"
1460 "IP-EIGRP neighbor address\n"
1461 "Resync with peer without adjacency reset\n")
1462 {
1463 struct eigrp *eigrp;
1464 struct eigrp_neighbor *nbr;
1465 struct in_addr nbr_addr;
1466
1467 if (!inet_aton(argv[4]->arg, &nbr_addr)) {
1468 vty_out(vty, "Unable to parse: %s", argv[4]->arg);
1469 return CMD_WARNING;
1470 }
1471
1472 /* Check if eigrp process is enabled */
1473 eigrp = eigrp_lookup();
1474 if (eigrp == NULL) {
1475 vty_out(vty, " EIGRP Routing Process not enabled\n");
1476 return CMD_SUCCESS;
1477 }
1478
1479 /* lookup neighbor in whole process */
1480 nbr = eigrp_nbr_lookup_by_addr_process(eigrp, nbr_addr);
1481
1482 /* if neighbor doesn't exists, notify user and exit */
1483 if (nbr == NULL) {
1484 vty_out(vty, "Neighbor with entered address doesn't exists.\n");
1485 return CMD_WARNING;
1486 }
1487
1488 /* execute graceful restart on neighbor */
1489 eigrp_update_send_GR(nbr, EIGRP_GR_MANUAL, vty);
1490
1491 return CMD_SUCCESS;
1492 }
1493
1494 static struct cmd_node eigrp_node = {EIGRP_NODE, "%s(config-router)# ", 1};
1495
1496 /* Save EIGRP configuration */
1497 static int eigrp_config_write(struct vty *vty)
1498 {
1499 struct eigrp *eigrp;
1500
1501 int write = 0;
1502
1503 eigrp = eigrp_lookup();
1504 if (eigrp != NULL) {
1505 /* Writes 'router eigrp' section to config */
1506 config_write_eigrp_router(vty, eigrp);
1507
1508 /* Interface config print */
1509 config_write_interfaces(vty, eigrp);
1510 //
1511 // /* static neighbor print. */
1512 // config_write_eigrp_nbr_nbma (vty, eigrp);
1513 //
1514 // /* Virtual-Link print. */
1515 // config_write_virtual_link (vty, eigrp);
1516 //
1517 // /* Default metric configuration. */
1518 // config_write_eigrp_default_metric (vty, eigrp);
1519 //
1520 // /* Distribute-list and default-information print. */
1521 // config_write_eigrp_distribute (vty, eigrp);
1522 //
1523 // /* Distance configuration. */
1524 // config_write_eigrp_distance (vty, eigrp)
1525 }
1526
1527 return write;
1528 }
1529
1530 void eigrp_vty_show_init(void)
1531 {
1532 install_element(VIEW_NODE, &show_ip_eigrp_interfaces_cmd);
1533
1534 install_element(VIEW_NODE, &show_ip_eigrp_neighbors_cmd);
1535
1536 install_element(VIEW_NODE, &show_ip_eigrp_topology_cmd);
1537 install_element(VIEW_NODE, &show_ip_eigrp_topology_all_cmd);
1538 }
1539
1540 /* eigrpd's interface node. */
1541 static struct cmd_node eigrp_interface_node = {INTERFACE_NODE,
1542 "%s(config-if)# ", 1};
1543
1544 void eigrp_vty_if_init(void)
1545 {
1546 install_node(&eigrp_interface_node, eigrp_write_interface);
1547 if_cmd_init();
1548
1549 /* Delay and bandwidth configuration commands*/
1550 install_element(INTERFACE_NODE, &eigrp_if_delay_cmd);
1551 install_element(INTERFACE_NODE, &no_eigrp_if_delay_cmd);
1552 install_element(INTERFACE_NODE, &eigrp_if_bandwidth_cmd);
1553 install_element(INTERFACE_NODE, &no_eigrp_if_bandwidth_cmd);
1554
1555 /*Hello-interval and hold-time interval configuration commands*/
1556 install_element(INTERFACE_NODE, &eigrp_if_ip_holdinterval_cmd);
1557 install_element(INTERFACE_NODE, &no_eigrp_if_ip_holdinterval_cmd);
1558 install_element(INTERFACE_NODE, &eigrp_if_ip_hellointerval_cmd);
1559 install_element(INTERFACE_NODE, &no_eigrp_if_ip_hellointerval_cmd);
1560
1561 /* "Authentication configuration commands */
1562 install_element(INTERFACE_NODE, &eigrp_authentication_mode_cmd);
1563 install_element(INTERFACE_NODE, &no_eigrp_authentication_mode_cmd);
1564 install_element(INTERFACE_NODE, &eigrp_authentication_keychain_cmd);
1565
1566 /*EIGRP Summarization commands*/
1567 install_element(INTERFACE_NODE, &eigrp_ip_summary_address_cmd);
1568 install_element(INTERFACE_NODE, &no_eigrp_ip_summary_address_cmd);
1569 }
1570
1571 static void eigrp_vty_zebra_init(void)
1572 {
1573 install_element(EIGRP_NODE, &eigrp_redistribute_source_metric_cmd);
1574 install_element(EIGRP_NODE, &no_eigrp_redistribute_source_metric_cmd);
1575 }
1576
1577 /* Install EIGRP related vty commands. */
1578 void eigrp_vty_init(void)
1579 {
1580 install_node(&eigrp_node, eigrp_config_write);
1581
1582 install_default(EIGRP_NODE);
1583
1584 install_element(CONFIG_NODE, &router_eigrp_cmd);
1585 install_element(CONFIG_NODE, &no_router_eigrp_cmd);
1586 install_element(EIGRP_NODE, &eigrp_network_cmd);
1587 install_element(EIGRP_NODE, &no_eigrp_network_cmd);
1588 install_element(EIGRP_NODE, &eigrp_variance_cmd);
1589 install_element(EIGRP_NODE, &no_eigrp_variance_cmd);
1590 install_element(EIGRP_NODE, &eigrp_router_id_cmd);
1591 install_element(EIGRP_NODE, &no_eigrp_router_id_cmd);
1592 install_element(EIGRP_NODE, &eigrp_passive_interface_cmd);
1593 install_element(EIGRP_NODE, &no_eigrp_passive_interface_cmd);
1594 install_element(EIGRP_NODE, &eigrp_timers_active_cmd);
1595 install_element(EIGRP_NODE, &no_eigrp_timers_active_cmd);
1596 install_element(EIGRP_NODE, &eigrp_metric_weights_cmd);
1597 install_element(EIGRP_NODE, &no_eigrp_metric_weights_cmd);
1598 install_element(EIGRP_NODE, &eigrp_maximum_paths_cmd);
1599 install_element(EIGRP_NODE, &no_eigrp_maximum_paths_cmd);
1600 install_element(EIGRP_NODE, &eigrp_neighbor_cmd);
1601 install_element(EIGRP_NODE, &no_eigrp_neighbor_cmd);
1602
1603 /* commands for manual hard restart */
1604 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_cmd);
1605 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_int_cmd);
1606 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_IP_cmd);
1607 /* commands for manual graceful restart */
1608 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_soft_cmd);
1609 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_int_soft_cmd);
1610 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_IP_soft_cmd);
1611
1612 eigrp_vty_zebra_init();
1613 }