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 DEFUN (show_ip_eigrp_topology
,
459 show_ip_eigrp_topology_cmd
,
460 "show ip eigrp topology [all-links]",
463 "IP-EIGRP show commands\n"
464 "IP-EIGRP topology\n"
465 "Show all links in topology table\n")
468 struct listnode
*node
;
469 struct eigrp_prefix_entry
*tn
;
470 struct eigrp_nexthop_entry
*te
;
471 struct route_node
*rn
;
474 eigrp
= eigrp_lookup();
476 vty_out(vty
, " EIGRP Routing Process not enabled\n");
480 show_ip_eigrp_topology_header(vty
, eigrp
);
482 for (rn
= route_top(eigrp
->topology_table
); rn
; rn
= route_next(rn
)) {
488 for (ALL_LIST_ELEMENTS_RO(tn
->entries
, node
, te
)) {
491 & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG
)
492 == EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG
)
494 & EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG
)
495 == EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG
))) {
496 show_ip_eigrp_nexthop_entry(vty
, eigrp
, te
,
506 ALIAS(show_ip_eigrp_topology
, show_ip_eigrp_topology_detail_cmd
,
507 "show ip eigrp topology <A.B.C.D|A.B.C.D/M|detail|summary>",
509 "IP-EIGRP show commands\n"
510 "IP-EIGRP topology\n"
511 "Netwok to display information about\n"
512 "IP prefix <network>/<length>, e.g., 192.168.0.0/16\n"
513 "Show all links in topology table\n"
514 "Show a summary of the topology table\n")
516 DEFUN (show_ip_eigrp_interfaces
,
517 show_ip_eigrp_interfaces_cmd
,
518 "show ip eigrp interfaces [IFNAME] [detail]",
521 "IP-EIGRP show commands\n"
522 "IP-EIGRP interfaces\n"
523 "Interface name to look at\n"
524 "Detailed information\n")
526 struct eigrp_interface
*ei
;
528 struct listnode
*node
;
531 const char *ifname
= NULL
;
533 eigrp
= eigrp_lookup();
535 vty_out(vty
, "EIGRP Routing Process not enabled\n");
539 if (argv_find(argv
, argc
, "IFNAME", &idx
))
540 ifname
= argv
[idx
]->arg
;
542 if (argv_find(argv
, argc
, "detail", &idx
))
546 show_ip_eigrp_interface_header(vty
, eigrp
);
548 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
549 if (!ifname
|| strcmp(ei
->ifp
->name
, ifname
) == 0) {
550 show_ip_eigrp_interface_sub(vty
, eigrp
, ei
);
552 show_ip_eigrp_interface_detail(vty
, eigrp
, ei
);
559 DEFUN (show_ip_eigrp_neighbors
,
560 show_ip_eigrp_neighbors_cmd
,
561 "show ip eigrp neighbors [IFNAME] [detail]",
564 "IP-EIGRP show commands\n"
565 "IP-EIGRP neighbors\n"
566 "Interface to show on\n"
567 "Detailed Information\n")
570 struct eigrp_interface
*ei
;
571 struct listnode
*node
, *node2
, *nnode2
;
572 struct eigrp_neighbor
*nbr
;
575 const char *ifname
= NULL
;
577 eigrp
= eigrp_lookup();
579 vty_out(vty
, " EIGRP Routing Process not enabled\n");
583 if (argv_find(argv
, argc
, "IFNAME", &idx
))
584 ifname
= argv
[idx
]->arg
;
586 detail
= (argv_find(argv
, argc
, "detail", &idx
));
588 show_ip_eigrp_neighbor_header(vty
, eigrp
);
590 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
591 if (!ifname
|| strcmp(ei
->ifp
->name
, ifname
) == 0) {
592 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
593 if (detail
|| (nbr
->state
== EIGRP_NEIGHBOR_UP
))
594 show_ip_eigrp_neighbor_sub(vty
, nbr
,
603 DEFUN (eigrp_if_delay
,
605 "delay (1-16777215)",
606 "Specify interface throughput delay\n"
607 "Throughput delay (tens of microseconds)\n")
609 VTY_DECLVAR_CONTEXT(interface
, ifp
);
610 struct eigrp_interface
*ei
= ifp
->info
;
614 eigrp
= eigrp_lookup();
616 vty_out(vty
, " EIGRP Routing Process not enabled\n");
622 vty_out(vty
, " EIGRP not configured on this interface\n");
625 delay
= atoi(argv
[1]->arg
);
627 ei
->params
.delay
= delay
;
633 DEFUN (no_eigrp_if_delay
,
634 no_eigrp_if_delay_cmd
,
635 "no delay (1-16777215)",
637 "Specify interface throughput delay\n"
638 "Throughput delay (tens of microseconds)\n")
640 VTY_DECLVAR_CONTEXT(interface
, ifp
);
641 struct eigrp_interface
*ei
= ifp
->info
;
644 eigrp
= eigrp_lookup();
646 vty_out(vty
, " EIGRP Routing Process not enabled\n");
651 vty_out(vty
, " EIGRP not configured on this interface\n");
655 ei
->params
.delay
= EIGRP_DELAY_DEFAULT
;
661 DEFPY (eigrp_if_bandwidth
,
662 eigrp_if_bandwidth_cmd
,
663 "eigrp bandwidth (1-10000000)$bw",
664 "EIGRP specific commands\n"
665 "Set bandwidth informational parameter\n"
666 "Bandwidth in kilobits\n")
668 VTY_DECLVAR_CONTEXT(interface
, ifp
);
669 struct eigrp_interface
*ei
= ifp
->info
;
672 eigrp
= eigrp_lookup();
674 vty_out(vty
, " EIGRP Routing Process not enabled\n");
679 vty_out(vty
, " EIGRP not configured on this interface\n");
683 ei
->params
.bandwidth
= bw
;
689 DEFUN (no_eigrp_if_bandwidth
,
690 no_eigrp_if_bandwidth_cmd
,
691 "no eigrp bandwidth [(1-10000000)]",
693 "EIGRP specific commands\n"
694 "Set bandwidth informational parameter\n"
695 "Bandwidth in kilobits\n")
697 VTY_DECLVAR_CONTEXT(interface
, ifp
);
698 struct eigrp_interface
*ei
= ifp
->info
;
701 eigrp
= eigrp_lookup();
703 vty_out(vty
, " EIGRP Routing Process not enabled\n");
708 vty_out(vty
, " EIGRP not configured on this interface\n");
712 ei
->params
.bandwidth
= EIGRP_BANDWIDTH_DEFAULT
;
718 DEFUN (eigrp_if_ip_hellointerval
,
719 eigrp_if_ip_hellointerval_cmd
,
720 "ip hello-interval eigrp (1-65535)",
721 "Interface Internet Protocol config commands\n"
722 "Configures EIGRP hello interval\n"
723 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
724 "Seconds between hello transmissions\n")
726 VTY_DECLVAR_CONTEXT(interface
, ifp
);
727 struct eigrp_interface
*ei
= ifp
->info
;
731 eigrp
= eigrp_lookup();
733 vty_out(vty
, " EIGRP Routing Process not enabled\n");
738 vty_out(vty
, " EIGRP not configured on this interface\n");
742 hello
= atoi(argv
[3]->arg
);
744 ei
->params
.v_hello
= hello
;
749 DEFUN (no_eigrp_if_ip_hellointerval
,
750 no_eigrp_if_ip_hellointerval_cmd
,
751 "no ip hello-interval eigrp [(1-65535)]",
753 "Interface Internet Protocol config commands\n"
754 "Configures EIGRP hello interval\n"
755 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
756 "Seconds between hello transmissions\n")
758 VTY_DECLVAR_CONTEXT(interface
, ifp
);
759 struct eigrp_interface
*ei
= ifp
->info
;
762 eigrp
= eigrp_lookup();
764 vty_out(vty
, " EIGRP Routing Process not enabled\n");
769 vty_out(vty
, " EIGRP not configured on this interface\n");
773 ei
->params
.v_hello
= EIGRP_HELLO_INTERVAL_DEFAULT
;
775 THREAD_TIMER_OFF(ei
->t_hello
);
776 thread_add_timer(master
, eigrp_hello_timer
, ei
, 1, &ei
->t_hello
);
781 DEFUN (eigrp_if_ip_holdinterval
,
782 eigrp_if_ip_holdinterval_cmd
,
783 "ip hold-time eigrp (1-65535)",
784 "Interface Internet Protocol config commands\n"
785 "Configures EIGRP IPv4 hold time\n"
786 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
787 "Seconds before neighbor is considered down\n")
789 VTY_DECLVAR_CONTEXT(interface
, ifp
);
790 struct eigrp_interface
*ei
= ifp
->info
;
794 eigrp
= eigrp_lookup();
796 vty_out(vty
, " EIGRP Routing Process not enabled\n");
801 vty_out(vty
, " EIGRP not configured on this interface\n");
805 hold
= atoi(argv
[3]->arg
);
807 ei
->params
.v_wait
= hold
;
812 DEFUN (eigrp_ip_summary_address
,
813 eigrp_ip_summary_address_cmd
,
814 "ip summary-address eigrp (1-65535) A.B.C.D/M",
815 "Interface Internet Protocol config commands\n"
816 "Perform address summarization\n"
817 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
819 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
821 // VTY_DECLVAR_CONTEXT(interface, ifp);
825 eigrp
= eigrp_lookup();
827 vty_out(vty
, " EIGRP Routing Process not enabled\n");
831 // AS = atoi (argv[3]->arg);
838 DEFUN (no_eigrp_ip_summary_address
,
839 no_eigrp_ip_summary_address_cmd
,
840 "no ip summary-address eigrp (1-65535) A.B.C.D/M",
842 "Interface Internet Protocol config commands\n"
843 "Perform address summarization\n"
844 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
846 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
848 // VTY_DECLVAR_CONTEXT(interface, ifp);
852 eigrp
= eigrp_lookup();
854 vty_out(vty
, " EIGRP Routing Process not enabled\n");
858 // AS = atoi (argv[4]->arg);
865 DEFUN (no_eigrp_if_ip_holdinterval
,
866 no_eigrp_if_ip_holdinterval_cmd
,
867 "no ip hold-time eigrp",
869 "Interface Internet Protocol config commands\n"
870 "Configures EIGRP hello interval\n"
871 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n")
873 VTY_DECLVAR_CONTEXT(interface
, ifp
);
874 struct eigrp_interface
*ei
= ifp
->info
;
877 eigrp
= eigrp_lookup();
879 vty_out(vty
, " EIGRP Routing Process not enabled\n");
884 vty_out(vty
, " EIGRP not configured on this interface\n");
888 ei
->params
.v_wait
= EIGRP_HOLD_INTERVAL_DEFAULT
;
893 static int str2auth_type(const char *str
, struct eigrp_interface
*ei
)
897 return CMD_WARNING_CONFIG_FAILED
;
899 if (strncmp(str
, "md5", 3) == 0) {
900 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_MD5
;
902 } else if (strncmp(str
, "hmac-sha-256", 12) == 0) {
903 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_SHA256
;
907 return CMD_WARNING_CONFIG_FAILED
;
910 DEFUN (eigrp_authentication_mode
,
911 eigrp_authentication_mode_cmd
,
912 "ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
913 "Interface Internet Protocol config commands\n"
914 "Authentication subcommands\n"
916 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
917 "Autonomous system number\n"
918 "Keyed message digest\n"
919 "HMAC SHA256 algorithm \n")
921 VTY_DECLVAR_CONTEXT(interface
, ifp
);
922 struct eigrp_interface
*ei
= ifp
->info
;
925 eigrp
= eigrp_lookup();
927 vty_out(vty
, " EIGRP Routing Process not enabled\n");
932 vty_out(vty
, " EIGRP not configured on this interface\n");
936 // if(strncmp(argv[2], "md5",3))
937 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_MD5;
938 // else if(strncmp(argv[2], "hmac-sha-256",12))
939 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_SHA256;
941 return str2auth_type(argv
[5]->arg
, ei
);
944 DEFUN (no_eigrp_authentication_mode
,
945 no_eigrp_authentication_mode_cmd
,
946 "no ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
948 "Interface Internet Protocol config commands\n"
949 "Authentication subcommands\n"
951 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
952 "Autonomous system number\n"
953 "Keyed message digest\n"
954 "HMAC SHA256 algorithm \n")
956 VTY_DECLVAR_CONTEXT(interface
, ifp
);
957 struct eigrp_interface
*ei
= ifp
->info
;
960 eigrp
= eigrp_lookup();
962 vty_out(vty
, " EIGRP Routing Process not enabled\n");
967 vty_out(vty
, " EIGRP not configured on this interface\n");
971 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_NONE
;
976 DEFPY (eigrp_authentication_keychain
,
977 eigrp_authentication_keychain_cmd
,
978 "[no] ip authentication key-chain eigrp (1-65535)$as WORD$name",
980 "Interface Internet Protocol config commands\n"
981 "Authentication subcommands\n"
983 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
984 "Autonomous system number\n"
985 "Name of key-chain\n")
987 VTY_DECLVAR_CONTEXT(interface
, ifp
);
988 struct eigrp_interface
*ei
= ifp
->info
;
990 struct keychain
*keychain
;
992 eigrp
= eigrp_lookup();
994 vty_out(vty
, "EIGRP Routing Process not enabled\n");
999 vty_out(vty
, " EIGRP not configured on this interface\n");
1004 if ((ei
->params
.auth_keychain
!= NULL
)
1005 && (strcmp(ei
->params
.auth_keychain
, name
) == 0)) {
1006 free(ei
->params
.auth_keychain
);
1007 ei
->params
.auth_keychain
= NULL
;
1010 "Key chain with specified name not configured on interface\n");
1014 keychain
= keychain_lookup(name
);
1015 if (keychain
!= NULL
) {
1016 if (ei
->params
.auth_keychain
) {
1017 free(ei
->params
.auth_keychain
);
1018 ei
->params
.auth_keychain
= strdup(keychain
->name
);
1020 ei
->params
.auth_keychain
= strdup(keychain
->name
);
1023 "Key chain with specified name not found\n");
1024 return CMD_WARNING_CONFIG_FAILED
;
1030 DEFUN (eigrp_redistribute_source_metric
,
1031 eigrp_redistribute_source_metric_cmd
,
1032 "redistribute " FRR_REDIST_STR_EIGRPD
1033 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
1035 FRR_REDIST_HELP_STR_EIGRPD
1036 "Metric for redistributed routes\n"
1037 "Bandwidth metric in Kbits per second\n"
1038 "EIGRP delay metric, in 10 microsecond units\n"
1039 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1040 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1041 "EIGRP MTU of the path\n")
1043 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1044 struct eigrp_metrics metrics_from_command
= {0};
1048 /* Get distribute source. */
1049 argv_find(argv
, argc
, "redistribute", &idx
);
1050 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1052 vty_out(vty
, "%% Invalid route type\n");
1053 return CMD_WARNING_CONFIG_FAILED
;
1056 /* Get metrics values */
1058 return eigrp_redistribute_set(eigrp
, source
, metrics_from_command
);
1061 DEFUN (no_eigrp_redistribute_source_metric
,
1062 no_eigrp_redistribute_source_metric_cmd
,
1063 "no redistribute " FRR_REDIST_STR_EIGRPD
1064 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
1067 FRR_REDIST_HELP_STR_EIGRPD
1068 "Metric for redistributed routes\n"
1069 "Bandwidth metric in Kbits per second\n"
1070 "EIGRP delay metric, in 10 microsecond units\n"
1071 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1072 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1073 "EIGRP MTU of the path\n")
1075 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1079 /* Get distribute source. */
1080 argv_find(argv
, argc
, "redistribute", &idx
);
1081 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1083 vty_out(vty
, "%% Invalid route type\n");
1084 return CMD_WARNING_CONFIG_FAILED
;
1087 /* Get metrics values */
1089 return eigrp_redistribute_unset(eigrp
, source
);
1092 DEFUN (eigrp_variance
,
1095 "Control load balancing variance\n"
1096 "Metric variance multiplier\n")
1098 struct eigrp
*eigrp
;
1101 eigrp
= eigrp_lookup();
1102 if (eigrp
== NULL
) {
1103 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1106 variance
= atoi(argv
[1]->arg
);
1108 eigrp
->variance
= variance
;
1115 DEFUN (no_eigrp_variance
,
1116 no_eigrp_variance_cmd
,
1117 "no variance (1-128)",
1119 "Control load balancing variance\n"
1120 "Metric variance multiplier\n")
1122 struct eigrp
*eigrp
;
1123 eigrp
= eigrp_lookup();
1124 if (eigrp
== NULL
) {
1125 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1129 eigrp
->variance
= EIGRP_VARIANCE_DEFAULT
;
1136 DEFUN (eigrp_maximum_paths
,
1137 eigrp_maximum_paths_cmd
,
1138 "maximum-paths (1-32)",
1139 "Forward packets over multiple paths\n"
1140 "Number of paths\n")
1142 struct eigrp
*eigrp
;
1145 eigrp
= eigrp_lookup();
1146 if (eigrp
== NULL
) {
1147 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1151 max
= atoi(argv
[1]->arg
);
1153 eigrp
->max_paths
= max
;
1160 DEFUN (no_eigrp_maximum_paths
,
1161 no_eigrp_maximum_paths_cmd
,
1162 "no maximum-paths <1-32>",
1164 "Forward packets over multiple paths\n"
1165 "Number of paths\n")
1167 struct eigrp
*eigrp
;
1169 eigrp
= eigrp_lookup();
1170 if (eigrp
== NULL
) {
1171 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1175 eigrp
->max_paths
= EIGRP_MAX_PATHS_DEFAULT
;
1183 * Execute hard restart for all neighbors
1185 DEFUN (clear_ip_eigrp_neighbors
,
1186 clear_ip_eigrp_neighbors_cmd
,
1187 "clear ip eigrp neighbors",
1191 "Clear IP-EIGRP neighbors\n")
1193 struct eigrp
*eigrp
;
1194 struct eigrp_interface
*ei
;
1195 struct listnode
*node
, *node2
, *nnode2
;
1196 struct eigrp_neighbor
*nbr
;
1198 /* Check if eigrp process is enabled */
1199 eigrp
= eigrp_lookup();
1200 if (eigrp
== NULL
) {
1201 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1205 /* iterate over all eigrp interfaces */
1206 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
1207 /* send Goodbye Hello */
1208 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1210 /* iterate over all neighbors on eigrp interface */
1211 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1212 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1214 "Neighbor %s (%s) is down: manually cleared",
1215 inet_ntoa(nbr
->src
),
1216 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1218 vty_time_print(vty
, 0);
1220 "Neighbor %s (%s) is down: manually cleared\n",
1221 inet_ntoa(nbr
->src
),
1222 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1225 /* set neighbor to DOWN */
1226 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1227 /* delete neighbor */
1228 eigrp_nbr_delete(nbr
);
1237 * Execute hard restart for all neighbors on interface
1239 DEFUN (clear_ip_eigrp_neighbors_int
,
1240 clear_ip_eigrp_neighbors_int_cmd
,
1241 "clear ip eigrp neighbors IFNAME",
1245 "Clear IP-EIGRP neighbors\n"
1246 "Interface's name\n")
1248 struct eigrp
*eigrp
;
1249 struct eigrp_interface
*ei
;
1250 struct listnode
*node2
, *nnode2
;
1251 struct eigrp_neighbor
*nbr
;
1254 /* Check if eigrp process is enabled */
1255 eigrp
= eigrp_lookup();
1256 if (eigrp
== NULL
) {
1257 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1261 /* lookup interface by specified name */
1262 argv_find(argv
, argc
, "IFNAME", &idx
);
1263 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[idx
]->arg
);
1265 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[idx
]->arg
);
1269 /* send Goodbye Hello */
1270 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1272 /* iterate over all neighbors on eigrp interface */
1273 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1274 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1275 zlog_debug("Neighbor %s (%s) is down: manually cleared",
1276 inet_ntoa(nbr
->src
),
1277 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1279 vty_time_print(vty
, 0);
1281 "Neighbor %s (%s) is down: manually cleared\n",
1282 inet_ntoa(nbr
->src
),
1283 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1286 /* set neighbor to DOWN */
1287 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1288 /* delete neighbor */
1289 eigrp_nbr_delete(nbr
);
1297 * Execute hard restart for neighbor specified by IP
1299 DEFUN (clear_ip_eigrp_neighbors_IP
,
1300 clear_ip_eigrp_neighbors_IP_cmd
,
1301 "clear ip eigrp neighbors A.B.C.D",
1305 "Clear IP-EIGRP neighbors\n"
1306 "IP-EIGRP neighbor address\n")
1308 struct eigrp
*eigrp
;
1309 struct eigrp_neighbor
*nbr
;
1310 struct in_addr nbr_addr
;
1312 if (!inet_aton(argv
[4]->arg
, &nbr_addr
)) {
1313 vty_out(vty
, "Unable to parse %s", argv
[4]->arg
);
1317 /* Check if eigrp process is enabled */
1318 eigrp
= eigrp_lookup();
1319 if (eigrp
== NULL
) {
1320 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1324 /* lookup neighbor in whole process */
1325 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1327 /* if neighbor doesn't exists, notify user and exit */
1329 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1333 /* execute hard reset on neighbor */
1334 eigrp_nbr_hard_restart(nbr
, vty
);
1340 * Execute graceful restart for all neighbors
1342 DEFUN (clear_ip_eigrp_neighbors_soft
,
1343 clear_ip_eigrp_neighbors_soft_cmd
,
1344 "clear ip eigrp neighbors soft",
1348 "Clear IP-EIGRP neighbors\n"
1349 "Resync with peers without adjacency reset\n")
1351 struct eigrp
*eigrp
;
1353 /* Check if eigrp process is enabled */
1354 eigrp
= eigrp_lookup();
1355 if (eigrp
== NULL
) {
1356 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1360 /* execute graceful restart on all neighbors */
1361 eigrp_update_send_process_GR(eigrp
, EIGRP_GR_MANUAL
, vty
);
1367 * Execute graceful restart for all neighbors on interface
1369 DEFUN (clear_ip_eigrp_neighbors_int_soft
,
1370 clear_ip_eigrp_neighbors_int_soft_cmd
,
1371 "clear ip eigrp neighbors IFNAME soft",
1375 "Clear IP-EIGRP neighbors\n"
1376 "Interface's name\n"
1377 "Resync with peer without adjacency reset\n")
1379 struct eigrp
*eigrp
;
1380 struct eigrp_interface
*ei
;
1382 /* Check if eigrp process is enabled */
1383 eigrp
= eigrp_lookup();
1384 if (eigrp
== NULL
) {
1385 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1389 /* lookup interface by specified name */
1390 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[4]->arg
);
1392 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[4]->arg
);
1396 /* execute graceful restart for all neighbors on interface */
1397 eigrp_update_send_interface_GR(ei
, EIGRP_GR_MANUAL
, vty
);
1402 * Execute graceful restart for neighbor specified by IP
1404 DEFUN (clear_ip_eigrp_neighbors_IP_soft
,
1405 clear_ip_eigrp_neighbors_IP_soft_cmd
,
1406 "clear ip eigrp neighbors A.B.C.D soft",
1410 "Clear IP-EIGRP neighbors\n"
1411 "IP-EIGRP neighbor address\n"
1412 "Resync with peer without adjacency reset\n")
1414 struct eigrp
*eigrp
;
1415 struct eigrp_neighbor
*nbr
;
1416 struct in_addr nbr_addr
;
1418 if (!inet_aton(argv
[4]->arg
, &nbr_addr
)) {
1419 vty_out(vty
, "Unable to parse: %s", argv
[4]->arg
);
1423 /* Check if eigrp process is enabled */
1424 eigrp
= eigrp_lookup();
1425 if (eigrp
== NULL
) {
1426 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1430 /* lookup neighbor in whole process */
1431 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1433 /* if neighbor doesn't exists, notify user and exit */
1435 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1439 /* execute graceful restart on neighbor */
1440 eigrp_update_send_GR(nbr
, EIGRP_GR_MANUAL
, vty
);
1445 static struct cmd_node eigrp_node
= {EIGRP_NODE
, "%s(config-router)# ", 1};
1447 /* Save EIGRP configuration */
1448 static int eigrp_config_write(struct vty
*vty
)
1450 struct eigrp
*eigrp
;
1454 eigrp
= eigrp_lookup();
1455 if (eigrp
!= NULL
) {
1456 /* Writes 'router eigrp' section to config */
1457 config_write_eigrp_router(vty
, eigrp
);
1459 /* Interface config print */
1460 config_write_interfaces(vty
, eigrp
);
1462 // /* static neighbor print. */
1463 // config_write_eigrp_nbr_nbma (vty, eigrp);
1465 // /* Virtual-Link print. */
1466 // config_write_virtual_link (vty, eigrp);
1468 // /* Default metric configuration. */
1469 // config_write_eigrp_default_metric (vty, eigrp);
1471 // /* Distribute-list and default-information print. */
1472 // config_write_eigrp_distribute (vty, eigrp);
1474 // /* Distance configuration. */
1475 // config_write_eigrp_distance (vty, eigrp)
1481 void eigrp_vty_show_init(void)
1483 install_element(VIEW_NODE
, &show_ip_eigrp_interfaces_cmd
);
1485 install_element(VIEW_NODE
, &show_ip_eigrp_neighbors_cmd
);
1487 install_element(VIEW_NODE
, &show_ip_eigrp_topology_cmd
);
1489 install_element(VIEW_NODE
, &show_ip_eigrp_topology_detail_cmd
);
1492 /* eigrpd's interface node. */
1493 static struct cmd_node eigrp_interface_node
= {INTERFACE_NODE
,
1494 "%s(config-if)# ", 1};
1496 void eigrp_vty_if_init(void)
1498 install_node(&eigrp_interface_node
, eigrp_write_interface
);
1501 /* Delay and bandwidth configuration commands*/
1502 install_element(INTERFACE_NODE
, &eigrp_if_delay_cmd
);
1503 install_element(INTERFACE_NODE
, &no_eigrp_if_delay_cmd
);
1504 install_element(INTERFACE_NODE
, &eigrp_if_bandwidth_cmd
);
1505 install_element(INTERFACE_NODE
, &no_eigrp_if_bandwidth_cmd
);
1507 /*Hello-interval and hold-time interval configuration commands*/
1508 install_element(INTERFACE_NODE
, &eigrp_if_ip_holdinterval_cmd
);
1509 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_holdinterval_cmd
);
1510 install_element(INTERFACE_NODE
, &eigrp_if_ip_hellointerval_cmd
);
1511 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_hellointerval_cmd
);
1513 /* "Authentication configuration commands */
1514 install_element(INTERFACE_NODE
, &eigrp_authentication_mode_cmd
);
1515 install_element(INTERFACE_NODE
, &no_eigrp_authentication_mode_cmd
);
1516 install_element(INTERFACE_NODE
, &eigrp_authentication_keychain_cmd
);
1518 /*EIGRP Summarization commands*/
1519 install_element(INTERFACE_NODE
, &eigrp_ip_summary_address_cmd
);
1520 install_element(INTERFACE_NODE
, &no_eigrp_ip_summary_address_cmd
);
1523 static void eigrp_vty_zebra_init(void)
1525 install_element(EIGRP_NODE
, &eigrp_redistribute_source_metric_cmd
);
1526 install_element(EIGRP_NODE
, &no_eigrp_redistribute_source_metric_cmd
);
1529 /* Install EIGRP related vty commands. */
1530 void eigrp_vty_init(void)
1532 install_node(&eigrp_node
, eigrp_config_write
);
1534 install_default(EIGRP_NODE
);
1536 install_element(CONFIG_NODE
, &router_eigrp_cmd
);
1537 install_element(CONFIG_NODE
, &no_router_eigrp_cmd
);
1538 install_element(EIGRP_NODE
, &eigrp_network_cmd
);
1539 install_element(EIGRP_NODE
, &no_eigrp_network_cmd
);
1540 install_element(EIGRP_NODE
, &eigrp_variance_cmd
);
1541 install_element(EIGRP_NODE
, &no_eigrp_variance_cmd
);
1542 install_element(EIGRP_NODE
, &eigrp_router_id_cmd
);
1543 install_element(EIGRP_NODE
, &no_eigrp_router_id_cmd
);
1544 install_element(EIGRP_NODE
, &eigrp_passive_interface_cmd
);
1545 install_element(EIGRP_NODE
, &no_eigrp_passive_interface_cmd
);
1546 install_element(EIGRP_NODE
, &eigrp_timers_active_cmd
);
1547 install_element(EIGRP_NODE
, &no_eigrp_timers_active_cmd
);
1548 install_element(EIGRP_NODE
, &eigrp_metric_weights_cmd
);
1549 install_element(EIGRP_NODE
, &no_eigrp_metric_weights_cmd
);
1550 install_element(EIGRP_NODE
, &eigrp_maximum_paths_cmd
);
1551 install_element(EIGRP_NODE
, &no_eigrp_maximum_paths_cmd
);
1552 install_element(EIGRP_NODE
, &eigrp_neighbor_cmd
);
1553 install_element(EIGRP_NODE
, &no_eigrp_neighbor_cmd
);
1555 /* commands for manual hard restart */
1556 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_cmd
);
1557 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_cmd
);
1558 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_cmd
);
1559 /* commands for manual graceful restart */
1560 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_soft_cmd
);
1561 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_soft_cmd
);
1562 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_soft_cmd
);
1564 eigrp_vty_zebra_init();