3 * Copyright (C) 2013-2016
15 * This file is part of GNU Zebra.
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
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.
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
45 #include "distribute.h"
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"
58 #ifndef VTYSH_EXTRACT_PL
59 #include "eigrpd/eigrp_vty_clippy.c"
62 static int config_write_network(struct vty
*vty
, struct eigrp
*eigrp
)
64 struct route_node
*rn
;
67 /* `network area' print. */
68 for (rn
= route_top(eigrp
->networks
); rn
; rn
= route_next(rn
))
71 vty_out(vty
, " network %s/%d \n",
72 inet_ntoa(rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
75 if (eigrp
->max_paths
!= EIGRP_MAX_PATHS_DEFAULT
)
76 vty_out(vty
, " maximum-paths %d\n", eigrp
->max_paths
);
78 if (eigrp
->variance
!= EIGRP_VARIANCE_DEFAULT
)
79 vty_out(vty
, " variance %d\n", eigrp
->variance
);
81 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
82 if (i
!= zclient
->redist_default
83 && vrf_bitmap_check(zclient
->redist
[AFI_IP
][i
],
85 vty_out(vty
, " redistribute %s\n",
86 zebra_route_string(i
));
88 /*Separate EIGRP configuration from the rest of the config*/
94 static int config_write_interfaces(struct vty
*vty
, struct eigrp
*eigrp
)
96 struct eigrp_interface
*ei
;
97 struct listnode
*node
;
99 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
100 vty_frame(vty
, "interface %s\n", ei
->ifp
->name
);
102 if (ei
->params
.auth_type
== EIGRP_AUTH_TYPE_MD5
) {
103 vty_out(vty
, " ip authentication mode eigrp %d md5\n",
107 if (ei
->params
.auth_type
== EIGRP_AUTH_TYPE_SHA256
) {
109 " ip authentication mode eigrp %d hmac-sha-256\n",
113 if (ei
->params
.auth_keychain
) {
115 " ip authentication key-chain eigrp %d %s\n",
116 eigrp
->AS
, ei
->params
.auth_keychain
);
119 if (ei
->params
.v_hello
!= EIGRP_HELLO_INTERVAL_DEFAULT
) {
120 vty_out(vty
, " ip hello-interval eigrp %d\n",
124 if (ei
->params
.v_wait
!= EIGRP_HOLD_INTERVAL_DEFAULT
) {
125 vty_out(vty
, " ip hold-time eigrp %d\n",
129 /*Separate this EIGRP interface configuration from the others*/
130 vty_endframe(vty
, "!\n");
136 static int eigrp_write_interface(struct vty
*vty
)
138 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
139 struct interface
*ifp
;
140 struct eigrp_interface
*ei
;
142 FOR_ALL_INTERFACES (vrf
, ifp
) {
147 vty_frame(vty
, "interface %s\n", ifp
->name
);
150 vty_out(vty
, " description %s\n", ifp
->desc
);
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",
159 if (ei
->params
.v_wait
!= EIGRP_HOLD_INTERVAL_DEFAULT
)
160 vty_out(vty
, " ip hold-time eigrp %u\n",
163 vty_endframe(vty
, "!\n");
170 * Writes distribute lists to config
172 static int config_write_eigrp_distribute(struct vty
*vty
, struct eigrp
*eigrp
)
176 /* Distribute configuration. */
177 write
+= config_write_distribute(vty
, eigrp
->distribute_ctx
);
183 * Writes 'router eigrp' section to config
185 static int config_write_eigrp_router(struct vty
*vty
, struct eigrp
*eigrp
)
189 /* `router eigrp' print. */
190 vty_out(vty
, "router eigrp %d\n", eigrp
->AS
);
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
));
200 /* Network area print. */
201 config_write_network(vty
, eigrp
);
203 /* Distribute-list and default-information print. */
204 config_write_eigrp_distribute(vty
, eigrp
);
206 /*Separate EIGRP configuration from the rest of the config*/
212 DEFUN_NOSH (router_eigrp
,
214 "router eigrp (1-65535)",
215 "Enable a routing process\n"
216 "Start EIGRP configuration\n"
217 "AS Number to use\n")
219 struct eigrp
*eigrp
= eigrp_get(argv
[2]->arg
);
220 VTY_PUSH_CONTEXT(EIGRP_NODE
, eigrp
);
225 DEFUN (no_router_eigrp
,
227 "no router eigrp (1-65535)",
230 "EIGRP configuration\n"
231 "AS number to use\n")
233 vty
->node
= CONFIG_NODE
;
237 eigrp
= eigrp_lookup();
239 vty_out(vty
, " EIGRP Routing Process not enabled\n");
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
;
248 eigrp_finish_final(eigrp
);
253 DEFPY (eigrp_router_id
,
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")
260 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
262 eigrp
->router_id_static
= addr
;
267 DEFPY (no_eigrp_router_id
,
268 no_eigrp_router_id_cmd
,
269 "no eigrp router-id [A.B.C.D$addr]",
271 "EIGRP specific commands\n"
272 "Router ID for this EIGRP process\n"
273 "EIGRP Router-ID in IP address format\n")
275 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
277 eigrp
->router_id_static
.s_addr
= 0;
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")
288 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
289 struct eigrp_interface
*ei
;
290 struct listnode
*node
;
291 char *ifname
= argv
[1]->arg
;
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
;
302 DEFUN (no_eigrp_passive_interface
,
303 no_eigrp_passive_interface_cmd
,
304 "no passive-interface IFNAME",
306 "Suppress routing updates on an interface\n"
307 "Interface to suppress on\n")
309 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
310 struct eigrp_interface
*ei
;
311 struct listnode
*node
;
312 char *ifname
= argv
[2]->arg
;
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
;
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")
332 // struct eigrp *eigrp = vty->index;
338 DEFUN (no_eigrp_timers_active
,
339 no_eigrp_timers_active_cmd
,
340 "no timers active-time <(1-65535)|disabled>",
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")
347 // struct eigrp *eigrp = vty->index;
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"
365 // struct eigrp *eigrp = vty->index;
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>",
375 "Modify metrics and parameters for advertisement\n"
376 "Modify metric coefficients\n"
383 // struct eigrp *eigrp = vty->index;
390 DEFUN (eigrp_network
,
393 "Enable routing on an IP network\n"
394 "EIGRP network prefix\n")
396 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
400 (void)str2prefix(argv
[1]->arg
, &p
);
402 ret
= eigrp_network_set(eigrp
, &p
);
405 vty_out(vty
, "There is already same network statement.\n");
412 DEFUN (no_eigrp_network
,
413 no_eigrp_network_cmd
,
414 "no network A.B.C.D/M",
416 "Disable routing on an IP network\n"
417 "EIGRP network prefix\n")
419 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
423 (void)str2prefix(argv
[2]->arg
, &p
);
425 ret
= eigrp_network_unset(eigrp
, &p
);
428 vty_out(vty
, "Can't find specified network configuration.\n");
429 return CMD_WARNING_CONFIG_FAILED
;
435 DEFUN (eigrp_neighbor
,
438 "Specify a neighbor router\n"
439 "Neighbor address\n")
441 // struct eigrp *eigrp = vty->index;
446 DEFUN (no_eigrp_neighbor
,
447 no_eigrp_neighbor_cmd
,
448 "no neighbor A.B.C.D",
450 "Specify a neighbor router\n"
451 "Neighbor address\n")
453 // struct eigrp *eigrp = vty->index;
458 static void eigrp_vty_display_prefix_entry(struct vty
*vty
,
460 struct eigrp_prefix_entry
*pe
,
464 struct eigrp_nexthop_entry
*te
;
465 struct listnode
*node
;
467 for (ALL_LIST_ELEMENTS_RO(pe
->entries
, node
, te
)) {
470 & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG
)
471 == EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG
)
473 & EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG
)
474 == EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG
))) {
475 show_ip_eigrp_nexthop_entry(vty
, eigrp
, te
,
482 DEFPY (show_ip_eigrp_topology_all
,
483 show_ip_eigrp_topology_all_cmd
,
484 "show ip eigrp topology [all-links$all]",
487 "IP-EIGRP show commands\n"
488 "IP-EIGRP topology\n"
489 "Show all links in topology table\n")
492 struct eigrp_prefix_entry
*tn
;
493 struct route_node
*rn
;
495 eigrp
= eigrp_lookup();
497 vty_out(vty
, " EIGRP Routing Process not enabled\n");
501 show_ip_eigrp_topology_header(vty
, eigrp
);
503 for (rn
= route_top(eigrp
->topology_table
); rn
; rn
= route_next(rn
)) {
508 eigrp_vty_display_prefix_entry(vty
, eigrp
, tn
,
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>",
521 "IP-EIGRP show commands\n"
522 "IP-EIGRP topology\n"
523 "For a specific address\n"
524 "For a specific prefix\n")
527 struct eigrp_prefix_entry
*tn
;
528 struct route_node
*rn
;
531 eigrp
= eigrp_lookup();
533 vty_out(vty
, " EIGRP Routing Process not enabled\n");
537 show_ip_eigrp_topology_header(vty
, eigrp
);
540 prefix_str
= address_str
;
542 if (str2prefix(prefix_str
, &cmp
) < 0) {
543 vty_out(vty
, "%% Malformed address\n");
547 rn
= route_node_match(eigrp
->topology_table
, &cmp
);
549 vty_out(vty
, "%% Network not in table\n");
554 vty_out(vty
, "%% Network not in table\n");
555 route_unlock_node(rn
);
560 eigrp_vty_display_prefix_entry(vty
, eigrp
, tn
, argc
== 5);
565 DEFUN (show_ip_eigrp_interfaces
,
566 show_ip_eigrp_interfaces_cmd
,
567 "show ip eigrp interfaces [IFNAME] [detail]",
570 "IP-EIGRP show commands\n"
571 "IP-EIGRP interfaces\n"
572 "Interface name to look at\n"
573 "Detailed information\n")
575 struct eigrp_interface
*ei
;
577 struct listnode
*node
;
580 const char *ifname
= NULL
;
582 eigrp
= eigrp_lookup();
584 vty_out(vty
, "EIGRP Routing Process not enabled\n");
588 if (argv_find(argv
, argc
, "IFNAME", &idx
))
589 ifname
= argv
[idx
]->arg
;
591 if (argv_find(argv
, argc
, "detail", &idx
))
595 show_ip_eigrp_interface_header(vty
, eigrp
);
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
);
601 show_ip_eigrp_interface_detail(vty
, eigrp
, ei
);
608 DEFUN (show_ip_eigrp_neighbors
,
609 show_ip_eigrp_neighbors_cmd
,
610 "show ip eigrp neighbors [IFNAME] [detail]",
613 "IP-EIGRP show commands\n"
614 "IP-EIGRP neighbors\n"
615 "Interface to show on\n"
616 "Detailed Information\n")
619 struct eigrp_interface
*ei
;
620 struct listnode
*node
, *node2
, *nnode2
;
621 struct eigrp_neighbor
*nbr
;
624 const char *ifname
= NULL
;
626 eigrp
= eigrp_lookup();
628 vty_out(vty
, " EIGRP Routing Process not enabled\n");
632 if (argv_find(argv
, argc
, "IFNAME", &idx
))
633 ifname
= argv
[idx
]->arg
;
635 detail
= (argv_find(argv
, argc
, "detail", &idx
));
637 show_ip_eigrp_neighbor_header(vty
, eigrp
);
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
,
652 DEFUN (eigrp_if_delay
,
654 "delay (1-16777215)",
655 "Specify interface throughput delay\n"
656 "Throughput delay (tens of microseconds)\n")
658 VTY_DECLVAR_CONTEXT(interface
, ifp
);
659 struct eigrp_interface
*ei
= ifp
->info
;
663 eigrp
= eigrp_lookup();
665 vty_out(vty
, " EIGRP Routing Process not enabled\n");
671 vty_out(vty
, " EIGRP not configured on this interface\n");
674 delay
= atoi(argv
[1]->arg
);
676 ei
->params
.delay
= delay
;
682 DEFUN (no_eigrp_if_delay
,
683 no_eigrp_if_delay_cmd
,
684 "no delay (1-16777215)",
686 "Specify interface throughput delay\n"
687 "Throughput delay (tens of microseconds)\n")
689 VTY_DECLVAR_CONTEXT(interface
, ifp
);
690 struct eigrp_interface
*ei
= ifp
->info
;
693 eigrp
= eigrp_lookup();
695 vty_out(vty
, " EIGRP Routing Process not enabled\n");
700 vty_out(vty
, " EIGRP not configured on this interface\n");
704 ei
->params
.delay
= EIGRP_DELAY_DEFAULT
;
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")
717 VTY_DECLVAR_CONTEXT(interface
, ifp
);
718 struct eigrp_interface
*ei
= ifp
->info
;
721 eigrp
= eigrp_lookup();
723 vty_out(vty
, " EIGRP Routing Process not enabled\n");
728 vty_out(vty
, " EIGRP not configured on this interface\n");
732 ei
->params
.bandwidth
= bw
;
738 DEFUN (no_eigrp_if_bandwidth
,
739 no_eigrp_if_bandwidth_cmd
,
740 "no eigrp bandwidth [(1-10000000)]",
742 "EIGRP specific commands\n"
743 "Set bandwidth informational parameter\n"
744 "Bandwidth in kilobits\n")
746 VTY_DECLVAR_CONTEXT(interface
, ifp
);
747 struct eigrp_interface
*ei
= ifp
->info
;
750 eigrp
= eigrp_lookup();
752 vty_out(vty
, " EIGRP Routing Process not enabled\n");
757 vty_out(vty
, " EIGRP not configured on this interface\n");
761 ei
->params
.bandwidth
= EIGRP_BANDWIDTH_DEFAULT
;
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")
775 VTY_DECLVAR_CONTEXT(interface
, ifp
);
776 struct eigrp_interface
*ei
= ifp
->info
;
780 eigrp
= eigrp_lookup();
782 vty_out(vty
, " EIGRP Routing Process not enabled\n");
787 vty_out(vty
, " EIGRP not configured on this interface\n");
791 hello
= atoi(argv
[3]->arg
);
793 ei
->params
.v_hello
= hello
;
798 DEFUN (no_eigrp_if_ip_hellointerval
,
799 no_eigrp_if_ip_hellointerval_cmd
,
800 "no ip hello-interval eigrp [(1-65535)]",
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")
807 VTY_DECLVAR_CONTEXT(interface
, ifp
);
808 struct eigrp_interface
*ei
= ifp
->info
;
811 eigrp
= eigrp_lookup();
813 vty_out(vty
, " EIGRP Routing Process not enabled\n");
818 vty_out(vty
, " EIGRP not configured on this interface\n");
822 ei
->params
.v_hello
= EIGRP_HELLO_INTERVAL_DEFAULT
;
824 THREAD_TIMER_OFF(ei
->t_hello
);
825 thread_add_timer(master
, eigrp_hello_timer
, ei
, 1, &ei
->t_hello
);
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")
838 VTY_DECLVAR_CONTEXT(interface
, ifp
);
839 struct eigrp_interface
*ei
= ifp
->info
;
843 eigrp
= eigrp_lookup();
845 vty_out(vty
, " EIGRP Routing Process not enabled\n");
850 vty_out(vty
, " EIGRP not configured on this interface\n");
854 hold
= atoi(argv
[3]->arg
);
856 ei
->params
.v_wait
= hold
;
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"
868 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
870 // VTY_DECLVAR_CONTEXT(interface, ifp);
874 eigrp
= eigrp_lookup();
876 vty_out(vty
, " EIGRP Routing Process not enabled\n");
880 // AS = atoi (argv[3]->arg);
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",
891 "Interface Internet Protocol config commands\n"
892 "Perform address summarization\n"
893 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
895 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
897 // VTY_DECLVAR_CONTEXT(interface, ifp);
901 eigrp
= eigrp_lookup();
903 vty_out(vty
, " EIGRP Routing Process not enabled\n");
907 // AS = atoi (argv[4]->arg);
914 DEFUN (no_eigrp_if_ip_holdinterval
,
915 no_eigrp_if_ip_holdinterval_cmd
,
916 "no ip hold-time eigrp",
918 "Interface Internet Protocol config commands\n"
919 "Configures EIGRP hello interval\n"
920 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n")
922 VTY_DECLVAR_CONTEXT(interface
, ifp
);
923 struct eigrp_interface
*ei
= ifp
->info
;
926 eigrp
= eigrp_lookup();
928 vty_out(vty
, " EIGRP Routing Process not enabled\n");
933 vty_out(vty
, " EIGRP not configured on this interface\n");
937 ei
->params
.v_wait
= EIGRP_HOLD_INTERVAL_DEFAULT
;
942 static int str2auth_type(const char *str
, struct eigrp_interface
*ei
)
946 return CMD_WARNING_CONFIG_FAILED
;
948 if (strncmp(str
, "md5", 3) == 0) {
949 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_MD5
;
951 } else if (strncmp(str
, "hmac-sha-256", 12) == 0) {
952 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_SHA256
;
956 return CMD_WARNING_CONFIG_FAILED
;
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"
965 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
966 "Autonomous system number\n"
967 "Keyed message digest\n"
968 "HMAC SHA256 algorithm \n")
970 VTY_DECLVAR_CONTEXT(interface
, ifp
);
971 struct eigrp_interface
*ei
= ifp
->info
;
974 eigrp
= eigrp_lookup();
976 vty_out(vty
, " EIGRP Routing Process not enabled\n");
981 vty_out(vty
, " EIGRP not configured on this interface\n");
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;
990 return str2auth_type(argv
[5]->arg
, ei
);
993 DEFUN (no_eigrp_authentication_mode
,
994 no_eigrp_authentication_mode_cmd
,
995 "no ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
997 "Interface Internet Protocol config commands\n"
998 "Authentication subcommands\n"
1000 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
1001 "Autonomous system number\n"
1002 "Keyed message digest\n"
1003 "HMAC SHA256 algorithm \n")
1005 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1006 struct eigrp_interface
*ei
= ifp
->info
;
1007 struct eigrp
*eigrp
;
1009 eigrp
= eigrp_lookup();
1010 if (eigrp
== NULL
) {
1011 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1016 vty_out(vty
, " EIGRP not configured on this interface\n");
1020 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_NONE
;
1025 DEFPY (eigrp_authentication_keychain
,
1026 eigrp_authentication_keychain_cmd
,
1027 "[no] ip authentication key-chain eigrp (1-65535)$as WORD$name",
1029 "Interface Internet Protocol config commands\n"
1030 "Authentication subcommands\n"
1032 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
1033 "Autonomous system number\n"
1034 "Name of key-chain\n")
1036 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1037 struct eigrp_interface
*ei
= ifp
->info
;
1038 struct eigrp
*eigrp
;
1039 struct keychain
*keychain
;
1041 eigrp
= eigrp_lookup();
1042 if (eigrp
== NULL
) {
1043 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1048 vty_out(vty
, " EIGRP not configured on this interface\n");
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
;
1059 "Key chain with specified name not configured on interface\n");
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
);
1069 ei
->params
.auth_keychain
= strdup(keychain
->name
);
1072 "Key chain with specified name not found\n");
1073 return CMD_WARNING_CONFIG_FAILED
;
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)]",
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")
1092 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1093 struct eigrp_metrics metrics_from_command
= {0};
1097 /* Get distribute source. */
1098 argv_find(argv
, argc
, "redistribute", &idx
);
1099 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1101 vty_out(vty
, "%% Invalid route type\n");
1102 return CMD_WARNING_CONFIG_FAILED
;
1105 /* Get metrics values */
1107 return eigrp_redistribute_set(eigrp
, source
, metrics_from_command
);
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)]",
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")
1124 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1128 /* Get distribute source. */
1129 argv_find(argv
, argc
, "redistribute", &idx
);
1130 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1132 vty_out(vty
, "%% Invalid route type\n");
1133 return CMD_WARNING_CONFIG_FAILED
;
1136 /* Get metrics values */
1138 return eigrp_redistribute_unset(eigrp
, source
);
1141 DEFUN (eigrp_variance
,
1144 "Control load balancing variance\n"
1145 "Metric variance multiplier\n")
1147 struct eigrp
*eigrp
;
1150 eigrp
= eigrp_lookup();
1151 if (eigrp
== NULL
) {
1152 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1155 variance
= atoi(argv
[1]->arg
);
1157 eigrp
->variance
= variance
;
1164 DEFUN (no_eigrp_variance
,
1165 no_eigrp_variance_cmd
,
1166 "no variance (1-128)",
1168 "Control load balancing variance\n"
1169 "Metric variance multiplier\n")
1171 struct eigrp
*eigrp
;
1172 eigrp
= eigrp_lookup();
1173 if (eigrp
== NULL
) {
1174 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1178 eigrp
->variance
= EIGRP_VARIANCE_DEFAULT
;
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")
1191 struct eigrp
*eigrp
;
1194 eigrp
= eigrp_lookup();
1195 if (eigrp
== NULL
) {
1196 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1200 max
= atoi(argv
[1]->arg
);
1202 eigrp
->max_paths
= max
;
1209 DEFUN (no_eigrp_maximum_paths
,
1210 no_eigrp_maximum_paths_cmd
,
1211 "no maximum-paths <1-32>",
1213 "Forward packets over multiple paths\n"
1214 "Number of paths\n")
1216 struct eigrp
*eigrp
;
1218 eigrp
= eigrp_lookup();
1219 if (eigrp
== NULL
) {
1220 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1224 eigrp
->max_paths
= EIGRP_MAX_PATHS_DEFAULT
;
1232 * Execute hard restart for all neighbors
1234 DEFUN (clear_ip_eigrp_neighbors
,
1235 clear_ip_eigrp_neighbors_cmd
,
1236 "clear ip eigrp neighbors",
1240 "Clear IP-EIGRP neighbors\n")
1242 struct eigrp
*eigrp
;
1243 struct eigrp_interface
*ei
;
1244 struct listnode
*node
, *node2
, *nnode2
;
1245 struct eigrp_neighbor
*nbr
;
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");
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
);
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
) {
1263 "Neighbor %s (%s) is down: manually cleared",
1264 inet_ntoa(nbr
->src
),
1265 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1267 vty_time_print(vty
, 0);
1269 "Neighbor %s (%s) is down: manually cleared\n",
1270 inet_ntoa(nbr
->src
),
1271 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1274 /* set neighbor to DOWN */
1275 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1276 /* delete neighbor */
1277 eigrp_nbr_delete(nbr
);
1286 * Execute hard restart for all neighbors on interface
1288 DEFUN (clear_ip_eigrp_neighbors_int
,
1289 clear_ip_eigrp_neighbors_int_cmd
,
1290 "clear ip eigrp neighbors IFNAME",
1294 "Clear IP-EIGRP neighbors\n"
1295 "Interface's name\n")
1297 struct eigrp
*eigrp
;
1298 struct eigrp_interface
*ei
;
1299 struct listnode
*node2
, *nnode2
;
1300 struct eigrp_neighbor
*nbr
;
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");
1310 /* lookup interface by specified name */
1311 argv_find(argv
, argc
, "IFNAME", &idx
);
1312 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[idx
]->arg
);
1314 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[idx
]->arg
);
1318 /* send Goodbye Hello */
1319 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
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
,
1328 vty_time_print(vty
, 0);
1330 "Neighbor %s (%s) is down: manually cleared\n",
1331 inet_ntoa(nbr
->src
),
1332 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1335 /* set neighbor to DOWN */
1336 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1337 /* delete neighbor */
1338 eigrp_nbr_delete(nbr
);
1346 * Execute hard restart for neighbor specified by IP
1348 DEFUN (clear_ip_eigrp_neighbors_IP
,
1349 clear_ip_eigrp_neighbors_IP_cmd
,
1350 "clear ip eigrp neighbors A.B.C.D",
1354 "Clear IP-EIGRP neighbors\n"
1355 "IP-EIGRP neighbor address\n")
1357 struct eigrp
*eigrp
;
1358 struct eigrp_neighbor
*nbr
;
1359 struct in_addr nbr_addr
;
1361 if (!inet_aton(argv
[4]->arg
, &nbr_addr
)) {
1362 vty_out(vty
, "Unable to parse %s", argv
[4]->arg
);
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");
1373 /* lookup neighbor in whole process */
1374 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1376 /* if neighbor doesn't exists, notify user and exit */
1378 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1382 /* execute hard reset on neighbor */
1383 eigrp_nbr_hard_restart(nbr
, vty
);
1389 * Execute graceful restart for all neighbors
1391 DEFUN (clear_ip_eigrp_neighbors_soft
,
1392 clear_ip_eigrp_neighbors_soft_cmd
,
1393 "clear ip eigrp neighbors soft",
1397 "Clear IP-EIGRP neighbors\n"
1398 "Resync with peers without adjacency reset\n")
1400 struct eigrp
*eigrp
;
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");
1409 /* execute graceful restart on all neighbors */
1410 eigrp_update_send_process_GR(eigrp
, EIGRP_GR_MANUAL
, vty
);
1416 * Execute graceful restart for all neighbors on interface
1418 DEFUN (clear_ip_eigrp_neighbors_int_soft
,
1419 clear_ip_eigrp_neighbors_int_soft_cmd
,
1420 "clear ip eigrp neighbors IFNAME soft",
1424 "Clear IP-EIGRP neighbors\n"
1425 "Interface's name\n"
1426 "Resync with peer without adjacency reset\n")
1428 struct eigrp
*eigrp
;
1429 struct eigrp_interface
*ei
;
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");
1438 /* lookup interface by specified name */
1439 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[4]->arg
);
1441 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[4]->arg
);
1445 /* execute graceful restart for all neighbors on interface */
1446 eigrp_update_send_interface_GR(ei
, EIGRP_GR_MANUAL
, vty
);
1451 * Execute graceful restart for neighbor specified by IP
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",
1459 "Clear IP-EIGRP neighbors\n"
1460 "IP-EIGRP neighbor address\n"
1461 "Resync with peer without adjacency reset\n")
1463 struct eigrp
*eigrp
;
1464 struct eigrp_neighbor
*nbr
;
1465 struct in_addr nbr_addr
;
1467 if (!inet_aton(argv
[4]->arg
, &nbr_addr
)) {
1468 vty_out(vty
, "Unable to parse: %s", argv
[4]->arg
);
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");
1479 /* lookup neighbor in whole process */
1480 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1482 /* if neighbor doesn't exists, notify user and exit */
1484 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1488 /* execute graceful restart on neighbor */
1489 eigrp_update_send_GR(nbr
, EIGRP_GR_MANUAL
, vty
);
1494 static struct cmd_node eigrp_node
= {EIGRP_NODE
, "%s(config-router)# ", 1};
1496 /* Save EIGRP configuration */
1497 static int eigrp_config_write(struct vty
*vty
)
1499 struct eigrp
*eigrp
;
1503 eigrp
= eigrp_lookup();
1504 if (eigrp
!= NULL
) {
1505 /* Writes 'router eigrp' section to config */
1506 config_write_eigrp_router(vty
, eigrp
);
1508 /* Interface config print */
1509 config_write_interfaces(vty
, eigrp
);
1511 // /* static neighbor print. */
1512 // config_write_eigrp_nbr_nbma (vty, eigrp);
1514 // /* Virtual-Link print. */
1515 // config_write_virtual_link (vty, eigrp);
1517 // /* Default metric configuration. */
1518 // config_write_eigrp_default_metric (vty, eigrp);
1520 // /* Distribute-list and default-information print. */
1521 // config_write_eigrp_distribute (vty, eigrp);
1523 // /* Distance configuration. */
1524 // config_write_eigrp_distance (vty, eigrp)
1530 void eigrp_vty_show_init(void)
1532 install_element(VIEW_NODE
, &show_ip_eigrp_interfaces_cmd
);
1534 install_element(VIEW_NODE
, &show_ip_eigrp_neighbors_cmd
);
1536 install_element(VIEW_NODE
, &show_ip_eigrp_topology_cmd
);
1537 install_element(VIEW_NODE
, &show_ip_eigrp_topology_all_cmd
);
1540 /* eigrpd's interface node. */
1541 static struct cmd_node eigrp_interface_node
= {INTERFACE_NODE
,
1542 "%s(config-if)# ", 1};
1544 void eigrp_vty_if_init(void)
1546 install_node(&eigrp_interface_node
, eigrp_write_interface
);
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
);
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
);
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
);
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
);
1571 static void eigrp_vty_zebra_init(void)
1573 install_element(EIGRP_NODE
, &eigrp_redistribute_source_metric_cmd
);
1574 install_element(EIGRP_NODE
, &no_eigrp_redistribute_source_metric_cmd
);
1577 /* Install EIGRP related vty commands. */
1578 void eigrp_vty_init(void)
1580 install_node(&eigrp_node
, eigrp_config_write
);
1582 install_default(EIGRP_NODE
);
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
);
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
);
1612 eigrp_vty_zebra_init();