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