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 static int config_write_network(struct vty
*vty
, struct eigrp
*eigrp
)
60 struct route_node
*rn
;
63 /* `network area' print. */
64 for (rn
= route_top(eigrp
->networks
); rn
; rn
= route_next(rn
))
67 vty_out(vty
, " network %s/%d \n",
68 inet_ntoa(rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
71 if (eigrp
->max_paths
!= EIGRP_MAX_PATHS_DEFAULT
)
72 vty_out(vty
, " maximum-paths %d\n", eigrp
->max_paths
);
74 if (eigrp
->variance
!= EIGRP_VARIANCE_DEFAULT
)
75 vty_out(vty
, " variance %d\n", eigrp
->variance
);
77 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
78 if (i
!= zclient
->redist_default
79 && vrf_bitmap_check(zclient
->redist
[AFI_IP
][i
],
81 vty_out(vty
, " redistribute %s\n",
82 zebra_route_string(i
));
84 /*Separate EIGRP configuration from the rest of the config*/
90 static int config_write_interfaces(struct vty
*vty
, struct eigrp
*eigrp
)
92 struct eigrp_interface
*ei
;
93 struct listnode
*node
;
95 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
96 vty_frame(vty
, "interface %s\n", ei
->ifp
->name
);
98 if (ei
->params
.auth_type
== EIGRP_AUTH_TYPE_MD5
) {
99 vty_out(vty
, " ip authentication mode eigrp %d md5\n",
103 if (ei
->params
.auth_type
== EIGRP_AUTH_TYPE_SHA256
) {
105 " ip authentication mode eigrp %d hmac-sha-256\n",
109 if (ei
->params
.auth_keychain
) {
111 " ip authentication key-chain eigrp %d %s\n",
113 ei
->params
.auth_keychain
);
116 if (ei
->params
.v_hello
!= EIGRP_HELLO_INTERVAL_DEFAULT
) {
117 vty_out(vty
, " ip hello-interval eigrp %d\n",
121 if (ei
->params
.v_wait
!= EIGRP_HOLD_INTERVAL_DEFAULT
) {
122 vty_out(vty
, " ip hold-time eigrp %d\n",
126 /*Separate this EIGRP interface configuration from the others*/
127 vty_endframe(vty
, "!\n");
133 static int eigrp_write_interface(struct vty
*vty
)
135 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
136 struct interface
*ifp
;
137 struct eigrp_interface
*ei
;
139 FOR_ALL_INTERFACES (vrf
, ifp
) {
144 vty_frame(vty
, "interface %s\n", ifp
->name
);
147 vty_out(vty
, " description %s\n", ifp
->desc
);
149 if (ei
->params
.bandwidth
!= EIGRP_BANDWIDTH_DEFAULT
)
150 vty_out(vty
, " bandwidth %u\n",
151 ei
->params
.bandwidth
);
152 if (ei
->params
.delay
!= EIGRP_DELAY_DEFAULT
)
153 vty_out(vty
, " delay %u\n", ei
->params
.delay
);
154 if (ei
->params
.v_hello
!= EIGRP_HELLO_INTERVAL_DEFAULT
)
155 vty_out(vty
, " ip hello-interval eigrp %u\n",
157 if (ei
->params
.v_wait
!= EIGRP_HOLD_INTERVAL_DEFAULT
)
158 vty_out(vty
, " ip hold-time eigrp %u\n",
161 vty_endframe(vty
, "!\n");
168 * Writes distribute lists to config
170 static int config_write_eigrp_distribute(struct vty
*vty
, struct eigrp
*eigrp
)
174 /* Distribute configuration. */
175 write
+= config_write_distribute(vty
);
181 * Writes 'router eigrp' section to config
183 static int config_write_eigrp_router(struct vty
*vty
, struct eigrp
*eigrp
)
187 /* `router eigrp' print. */
188 vty_out(vty
, "router eigrp %d\n", eigrp
->AS
);
192 if (!eigrp
->networks
)
195 /* Router ID print. */
196 if (eigrp
->router_id_static
!= 0) {
197 struct in_addr router_id_static
;
198 router_id_static
.s_addr
= htonl(eigrp
->router_id_static
);
199 vty_out(vty
, " eigrp router-id %s\n",
200 inet_ntoa(router_id_static
));
203 /* Network area print. */
204 config_write_network(vty
, eigrp
);
206 /* Distribute-list and default-information print. */
207 config_write_eigrp_distribute(vty
, eigrp
);
209 /*Separate EIGRP configuration from the rest of the config*/
215 DEFUN_NOSH (router_eigrp
,
217 "router eigrp (1-65535)",
218 "Enable a routing process\n"
219 "Start EIGRP configuration\n"
220 "AS Number to use\n")
222 struct eigrp
*eigrp
= eigrp_get(argv
[2]->arg
);
223 VTY_PUSH_CONTEXT(EIGRP_NODE
, eigrp
);
228 DEFUN (no_router_eigrp
,
230 "no router eigrp (1-65535)",
233 "EIGRP configuration\n"
234 "AS number to use\n")
236 vty
->node
= CONFIG_NODE
;
240 eigrp
= eigrp_lookup();
242 vty_out(vty
, " EIGRP Routing Process not enabled\n");
246 if (eigrp
->AS
!= atoi(argv
[3]->arg
)) {
247 vty_out(vty
, "%% Attempting to deconfigure non-existent AS\n");
248 return CMD_WARNING_CONFIG_FAILED
;
251 eigrp_finish_final(eigrp
);
256 DEFUN (eigrp_router_id
,
258 "eigrp router-id A.B.C.D",
259 "EIGRP specific commands\n"
260 "Router ID for this EIGRP process\n"
261 "EIGRP Router-ID in IP address format\n")
263 // struct eigrp *eigrp = vty->index;
269 DEFUN (no_eigrp_router_id
,
270 no_eigrp_router_id_cmd
,
271 "no eigrp router-id A.B.C.D",
273 "EIGRP specific commands\n"
274 "Router ID for this EIGRP process\n"
275 "EIGRP Router-ID in IP address format\n")
277 // struct eigrp *eigrp = vty->index;
283 DEFUN (eigrp_passive_interface
,
284 eigrp_passive_interface_cmd
,
285 "passive-interface IFNAME",
286 "Suppress routing updates on an interface\n"
287 "Interface to suppress on\n")
289 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
290 struct eigrp_interface
*ei
;
291 struct listnode
*node
;
292 char *ifname
= argv
[1]->arg
;
294 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
295 if (strcmp(ifname
, ei
->ifp
->name
) == 0) {
296 ei
->params
.passive_interface
= EIGRP_IF_PASSIVE
;
303 DEFUN (no_eigrp_passive_interface
,
304 no_eigrp_passive_interface_cmd
,
305 "no passive-interface IFNAME",
307 "Suppress routing updates on an interface\n"
308 "Interface to suppress on\n")
310 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
311 struct eigrp_interface
*ei
;
312 struct listnode
*node
;
313 char *ifname
= argv
[2]->arg
;
315 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
316 if (strcmp(ifname
, ei
->ifp
->name
) == 0) {
317 ei
->params
.passive_interface
= EIGRP_IF_ACTIVE
;
325 DEFUN (eigrp_timers_active
,
326 eigrp_timers_active_cmd
,
327 "timers active-time <(1-65535)|disabled>",
328 "Adjust routing timers\n"
329 "Time limit for active state\n"
330 "Active state time limit in minutes\n"
331 "Disable time limit for active state\n")
333 // struct eigrp *eigrp = vty->index;
339 DEFUN (no_eigrp_timers_active
,
340 no_eigrp_timers_active_cmd
,
341 "no timers active-time <(1-65535)|disabled>",
343 "Adjust routing timers\n"
344 "Time limit for active state\n"
345 "Active state time limit in minutes\n"
346 "Disable time limit for active state\n")
348 // struct eigrp *eigrp = vty->index;
355 DEFUN (eigrp_metric_weights
,
356 eigrp_metric_weights_cmd
,
357 "metric weights (0-255) (0-255) (0-255) (0-255) (0-255) ",
358 "Modify metrics and parameters for advertisement\n"
359 "Modify metric coefficients\n"
366 // struct eigrp *eigrp = vty->index;
372 DEFUN (no_eigrp_metric_weights
,
373 no_eigrp_metric_weights_cmd
,
374 "no metric weights <0-255> <0-255> <0-255> <0-255> <0-255>",
376 "Modify metrics and parameters for advertisement\n"
377 "Modify metric coefficients\n"
384 // struct eigrp *eigrp = vty->index;
391 DEFUN (eigrp_network
,
394 "Enable routing on an IP network\n"
395 "EIGRP network prefix\n")
397 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
401 (void)str2prefix(argv
[1]->arg
, &p
);
403 ret
= eigrp_network_set(eigrp
, &p
);
406 vty_out(vty
, "There is already same network statement.\n");
413 DEFUN (no_eigrp_network
,
414 no_eigrp_network_cmd
,
415 "no network A.B.C.D/M",
417 "Disable routing on an IP network\n"
418 "EIGRP network prefix\n")
420 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
424 (void)str2prefix(argv
[2]->arg
, &p
);
426 ret
= eigrp_network_unset(eigrp
, &p
);
429 vty_out(vty
, "Can't find specified network configuration.\n");
430 return CMD_WARNING_CONFIG_FAILED
;
436 DEFUN (eigrp_neighbor
,
439 "Specify a neighbor router\n"
440 "Neighbor address\n")
442 // struct eigrp *eigrp = vty->index;
447 DEFUN (no_eigrp_neighbor
,
448 no_eigrp_neighbor_cmd
,
449 "no neighbor A.B.C.D",
451 "Specify a neighbor router\n"
452 "Neighbor address\n")
454 // struct eigrp *eigrp = vty->index;
459 DEFUN (show_ip_eigrp_topology
,
460 show_ip_eigrp_topology_cmd
,
461 "show ip eigrp topology [all-links]",
464 "IP-EIGRP show commands\n"
465 "IP-EIGRP topology\n"
466 "Show all links in topology table\n")
469 struct listnode
*node
;
470 struct eigrp_prefix_entry
*tn
;
471 struct eigrp_nexthop_entry
*te
;
472 struct route_node
*rn
;
475 eigrp
= eigrp_lookup();
477 vty_out(vty
, " EIGRP Routing Process not enabled\n");
481 show_ip_eigrp_topology_header(vty
, eigrp
);
483 for (rn
= route_top(eigrp
->topology_table
); rn
; rn
= route_next(rn
)) {
489 for (ALL_LIST_ELEMENTS_RO(tn
->entries
, node
, te
)) {
492 & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG
)
493 == EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG
)
495 & EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG
)
496 == EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG
))) {
497 show_ip_eigrp_nexthop_entry(vty
, eigrp
, te
,
507 ALIAS(show_ip_eigrp_topology
, show_ip_eigrp_topology_detail_cmd
,
508 "show ip eigrp topology <A.B.C.D|A.B.C.D/M|detail|summary>",
510 "IP-EIGRP show commands\n"
511 "IP-EIGRP topology\n"
512 "Netwok to display information about\n"
513 "IP prefix <network>/<length>, e.g., 192.168.0.0/16\n"
514 "Show all links in topology table\n"
515 "Show a summary of the topology table\n")
517 DEFUN (show_ip_eigrp_interfaces
,
518 show_ip_eigrp_interfaces_cmd
,
519 "show ip eigrp interfaces [IFNAME] [detail]",
522 "IP-EIGRP show commands\n"
523 "IP-EIGRP interfaces\n"
524 "Interface name to look at\n"
525 "Detailed information\n")
527 struct eigrp_interface
*ei
;
529 struct listnode
*node
;
532 const char *ifname
= NULL
;
534 eigrp
= eigrp_lookup();
536 vty_out(vty
, "EIGRP Routing Process not enabled\n");
540 if (argv_find(argv
, argc
, "IFNAME", &idx
))
541 ifname
= argv
[idx
]->arg
;
543 if (argv_find(argv
, argc
, "detail", &idx
))
547 show_ip_eigrp_interface_header(vty
, eigrp
);
549 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
550 if (!ifname
|| strcmp(ei
->ifp
->name
, ifname
) == 0) {
551 show_ip_eigrp_interface_sub(vty
, eigrp
, ei
);
553 show_ip_eigrp_interface_detail(vty
, eigrp
, ei
);
560 DEFUN (show_ip_eigrp_neighbors
,
561 show_ip_eigrp_neighbors_cmd
,
562 "show ip eigrp neighbors [IFNAME] [detail]",
565 "IP-EIGRP show commands\n"
566 "IP-EIGRP neighbors\n"
567 "Interface to show on\n"
568 "Detailed Information\n")
571 struct eigrp_interface
*ei
;
572 struct listnode
*node
, *node2
, *nnode2
;
573 struct eigrp_neighbor
*nbr
;
576 const char *ifname
= NULL
;
578 eigrp
= eigrp_lookup();
580 vty_out(vty
, " EIGRP Routing Process not enabled\n");
584 if (argv_find(argv
, argc
, "IFNAME", &idx
))
585 ifname
= argv
[idx
]->arg
;
587 detail
= (argv_find(argv
, argc
, "detail", &idx
));
589 show_ip_eigrp_neighbor_header(vty
, eigrp
);
591 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
592 if (!ifname
|| strcmp(ei
->ifp
->name
, ifname
) == 0) {
593 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
594 if (detail
|| (nbr
->state
== EIGRP_NEIGHBOR_UP
))
595 show_ip_eigrp_neighbor_sub(vty
, nbr
,
604 DEFUN (eigrp_if_delay
,
606 "delay (1-16777215)",
607 "Specify interface throughput delay\n"
608 "Throughput delay (tens of microseconds)\n")
610 VTY_DECLVAR_CONTEXT(interface
, ifp
);
611 struct eigrp_interface
*ei
= ifp
->info
;
615 eigrp
= eigrp_lookup();
617 vty_out(vty
, " EIGRP Routing Process not enabled\n");
623 vty_out(vty
, " EIGRP not configured on this interface\n");
626 delay
= atoi(argv
[1]->arg
);
628 ei
->params
.delay
= delay
;
634 DEFUN (no_eigrp_if_delay
,
635 no_eigrp_if_delay_cmd
,
636 "no delay (1-16777215)",
638 "Specify interface throughput delay\n"
639 "Throughput delay (tens of microseconds)\n")
641 VTY_DECLVAR_CONTEXT(interface
, ifp
);
642 struct eigrp_interface
*ei
= ifp
->info
;
645 eigrp
= eigrp_lookup();
647 vty_out(vty
, " EIGRP Routing Process not enabled\n");
652 vty_out(vty
, " EIGRP not configured on this interface\n");
656 ei
->params
.delay
= EIGRP_DELAY_DEFAULT
;
662 DEFUN (eigrp_if_bandwidth
,
663 eigrp_if_bandwidth_cmd
,
664 "eigrp bandwidth (1-10000000)",
665 "EIGRP specific commands\n"
666 "Set bandwidth informational parameter\n"
667 "Bandwidth in kilobits\n")
669 VTY_DECLVAR_CONTEXT(interface
, ifp
);
670 struct eigrp_interface
*ei
= ifp
->info
;
674 eigrp
= eigrp_lookup();
676 vty_out(vty
, " EIGRP Routing Process not enabled\n");
681 vty_out(vty
, " EIGRP not configured on this interface\n");
685 bandwidth
= atoi(argv
[1]->arg
);
687 ei
->params
.bandwidth
= bandwidth
;
693 DEFUN (no_eigrp_if_bandwidth
,
694 no_eigrp_if_bandwidth_cmd
,
695 "no eigrp bandwidth [(1-10000000)]",
697 "EIGRP specific commands\n"
698 "Set bandwidth informational parameter\n"
699 "Bandwidth in kilobits\n")
701 VTY_DECLVAR_CONTEXT(interface
, ifp
);
702 struct eigrp_interface
*ei
= ifp
->info
;
705 eigrp
= eigrp_lookup();
707 vty_out(vty
, " EIGRP Routing Process not enabled\n");
712 vty_out(vty
, " EIGRP not configured on this interface\n");
716 ei
->params
.bandwidth
= EIGRP_BANDWIDTH_DEFAULT
;
722 DEFUN (eigrp_if_ip_hellointerval
,
723 eigrp_if_ip_hellointerval_cmd
,
724 "ip hello-interval eigrp (1-65535)",
725 "Interface Internet Protocol config commands\n"
726 "Configures EIGRP hello interval\n"
727 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
728 "Seconds between hello transmissions\n")
730 VTY_DECLVAR_CONTEXT(interface
, ifp
);
731 struct eigrp_interface
*ei
= ifp
->info
;
735 eigrp
= eigrp_lookup();
737 vty_out(vty
, " EIGRP Routing Process not enabled\n");
742 vty_out(vty
, " EIGRP not configured on this interface\n");
746 hello
= atoi(argv
[3]->arg
);
748 ei
->params
.v_hello
= hello
;
753 DEFUN (no_eigrp_if_ip_hellointerval
,
754 no_eigrp_if_ip_hellointerval_cmd
,
755 "no ip hello-interval eigrp [(1-65535)]",
757 "Interface Internet Protocol config commands\n"
758 "Configures EIGRP hello interval\n"
759 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
760 "Seconds between hello transmissions\n")
762 VTY_DECLVAR_CONTEXT(interface
, ifp
);
763 struct eigrp_interface
*ei
= ifp
->info
;
766 eigrp
= eigrp_lookup();
768 vty_out(vty
, " EIGRP Routing Process not enabled\n");
773 vty_out(vty
, " EIGRP not configured on this interface\n");
777 ei
->params
.v_hello
= EIGRP_HELLO_INTERVAL_DEFAULT
;
779 THREAD_TIMER_OFF(ei
->t_hello
);
780 thread_add_timer(master
, eigrp_hello_timer
, ei
, 1,
786 DEFUN (eigrp_if_ip_holdinterval
,
787 eigrp_if_ip_holdinterval_cmd
,
788 "ip hold-time eigrp (1-65535)",
789 "Interface Internet Protocol config commands\n"
790 "Configures EIGRP IPv4 hold time\n"
791 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
792 "Seconds before neighbor is considered down\n")
794 VTY_DECLVAR_CONTEXT(interface
, ifp
);
795 struct eigrp_interface
*ei
= ifp
->info
;
799 eigrp
= eigrp_lookup();
801 vty_out(vty
, " EIGRP Routing Process not enabled\n");
806 vty_out(vty
, " EIGRP not configured on this interface\n");
810 hold
= atoi(argv
[3]->arg
);
812 ei
->params
.v_wait
= hold
;
817 DEFUN (eigrp_ip_summary_address
,
818 eigrp_ip_summary_address_cmd
,
819 "ip summary-address eigrp (1-65535) A.B.C.D/M",
820 "Interface Internet Protocol config commands\n"
821 "Perform address summarization\n"
822 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
824 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
826 // VTY_DECLVAR_CONTEXT(interface, ifp);
830 eigrp
= eigrp_lookup();
832 vty_out(vty
, " EIGRP Routing Process not enabled\n");
836 // AS = atoi (argv[3]->arg);
843 DEFUN (no_eigrp_ip_summary_address
,
844 no_eigrp_ip_summary_address_cmd
,
845 "no ip summary-address eigrp (1-65535) A.B.C.D/M",
847 "Interface Internet Protocol config commands\n"
848 "Perform address summarization\n"
849 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
851 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
853 // VTY_DECLVAR_CONTEXT(interface, ifp);
857 eigrp
= eigrp_lookup();
859 vty_out(vty
, " EIGRP Routing Process not enabled\n");
863 // AS = atoi (argv[4]->arg);
870 DEFUN (no_eigrp_if_ip_holdinterval
,
871 no_eigrp_if_ip_holdinterval_cmd
,
872 "no ip hold-time eigrp",
874 "Interface Internet Protocol config commands\n"
875 "Configures EIGRP hello interval\n"
876 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n")
878 VTY_DECLVAR_CONTEXT(interface
, ifp
);
879 struct eigrp_interface
*ei
= ifp
->info
;
882 eigrp
= eigrp_lookup();
884 vty_out(vty
, " EIGRP Routing Process not enabled\n");
889 vty_out(vty
, " EIGRP not configured on this interface\n");
893 ei
->params
.v_wait
= EIGRP_HOLD_INTERVAL_DEFAULT
;
898 static int str2auth_type(const char *str
, struct eigrp_interface
*ei
)
902 return CMD_WARNING_CONFIG_FAILED
;
904 if (strncmp(str
, "md5", 3) == 0) {
905 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_MD5
;
907 } else if (strncmp(str
, "hmac-sha-256", 12) == 0) {
908 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_SHA256
;
912 return CMD_WARNING_CONFIG_FAILED
;
915 DEFUN (eigrp_authentication_mode
,
916 eigrp_authentication_mode_cmd
,
917 "ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
918 "Interface Internet Protocol config commands\n"
919 "Authentication subcommands\n"
921 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
922 "Autonomous system number\n"
923 "Keyed message digest\n"
924 "HMAC SHA256 algorithm \n")
926 VTY_DECLVAR_CONTEXT(interface
, ifp
);
927 struct eigrp_interface
*ei
= ifp
->info
;
930 eigrp
= eigrp_lookup();
932 vty_out(vty
, " EIGRP Routing Process not enabled\n");
937 vty_out(vty
, " EIGRP not configured on this interface\n");
941 // if(strncmp(argv[2], "md5",3))
942 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_MD5;
943 // else if(strncmp(argv[2], "hmac-sha-256",12))
944 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_SHA256;
946 return str2auth_type(argv
[5]->arg
, ei
);
949 DEFUN (no_eigrp_authentication_mode
,
950 no_eigrp_authentication_mode_cmd
,
951 "no ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
953 "Interface Internet Protocol config commands\n"
954 "Authentication subcommands\n"
956 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
957 "Autonomous system number\n"
958 "Keyed message digest\n"
959 "HMAC SHA256 algorithm \n")
961 VTY_DECLVAR_CONTEXT(interface
, ifp
);
962 struct eigrp_interface
*ei
= ifp
->info
;
965 eigrp
= eigrp_lookup();
967 vty_out(vty
, " EIGRP Routing Process not enabled\n");
972 vty_out(vty
, " EIGRP not configured on this interface\n");
976 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_NONE
;
981 DEFUN (eigrp_authentication_keychain
,
982 eigrp_authentication_keychain_cmd
,
983 "ip authentication key-chain eigrp (1-65535) WORD",
984 "Interface Internet Protocol config commands\n"
985 "Authentication subcommands\n"
987 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
988 "Autonomous system number\n"
989 "Name of key-chain\n")
991 VTY_DECLVAR_CONTEXT(interface
, ifp
);
992 struct eigrp_interface
*ei
= ifp
->info
;
994 struct keychain
*keychain
;
996 eigrp
= eigrp_lookup();
998 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1003 vty_out(vty
, " EIGRP not configured on this interface\n");
1007 keychain
= keychain_lookup(argv
[4]->arg
);
1008 if (keychain
!= NULL
) {
1009 if (ei
->params
.auth_keychain
) {
1010 free(ei
->params
.auth_keychain
);
1011 ei
->params
.auth_keychain
=
1012 strdup(keychain
->name
);
1014 ei
->params
.auth_keychain
=
1015 strdup(keychain
->name
);
1017 vty_out(vty
, "Key chain with specified name not found\n");
1022 DEFUN (no_eigrp_authentication_keychain
,
1023 no_eigrp_authentication_keychain_cmd
,
1024 "no ip authentication key-chain eigrp (1-65535) WORD",
1026 "Interface Internet Protocol config commands\n"
1027 "Authentication subcommands\n"
1029 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
1030 "Autonomous system number\n"
1031 "Name of key-chain\n")
1033 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1034 struct eigrp_interface
*ei
= ifp
->info
;
1035 struct eigrp
*eigrp
;
1037 eigrp
= eigrp_lookup();
1038 if (eigrp
== NULL
) {
1039 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1044 vty_out(vty
, " EIGRP not configured on this interface\n");
1048 if ((ei
->params
.auth_keychain
!= NULL
)
1049 && (strcmp(ei
->params
.auth_keychain
, argv
[5]->arg
) == 0)) {
1050 free(ei
->params
.auth_keychain
);
1051 ei
->params
.auth_keychain
= NULL
;
1054 "Key chain with specified name not configured on interface\n");
1059 DEFUN (eigrp_redistribute_source_metric
,
1060 eigrp_redistribute_source_metric_cmd
,
1061 "redistribute " FRR_REDIST_STR_EIGRPD
1062 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
1064 FRR_REDIST_HELP_STR_EIGRPD
1065 "Metric for redistributed routes\n"
1066 "Bandwidth metric in Kbits per second\n"
1067 "EIGRP delay metric, in 10 microsecond units\n"
1068 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1069 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1070 "EIGRP MTU of the path\n")
1072 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1073 struct eigrp_metrics metrics_from_command
= {0};
1077 /* Get distribute source. */
1078 argv_find(argv
, argc
, "redistribute", &idx
);
1079 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1081 vty_out(vty
, "%% Invalid route type\n");
1082 return CMD_WARNING_CONFIG_FAILED
;
1085 /* Get metrics values */
1087 return eigrp_redistribute_set(eigrp
, source
, metrics_from_command
);
1090 DEFUN (no_eigrp_redistribute_source_metric
,
1091 no_eigrp_redistribute_source_metric_cmd
,
1092 "no redistribute " FRR_REDIST_STR_EIGRPD
1093 " metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)",
1096 FRR_REDIST_HELP_STR_EIGRPD
1097 "Metric for redistributed routes\n"
1098 "Bandwidth metric in Kbits per second\n"
1099 "EIGRP delay metric, in 10 microsecond units\n"
1100 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1101 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1102 "EIGRP MTU of the path\n")
1104 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1108 /* Get distribute source. */
1109 argv_find(argv
, argc
, "redistribute", &idx
);
1110 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1112 vty_out(vty
, "%% Invalid route type\n");
1113 return CMD_WARNING_CONFIG_FAILED
;
1116 /* Get metrics values */
1118 return eigrp_redistribute_unset(eigrp
, source
);
1121 DEFUN (eigrp_variance
,
1124 "Control load balancing variance\n"
1125 "Metric variance multiplier\n")
1127 struct eigrp
*eigrp
;
1130 eigrp
= eigrp_lookup();
1131 if (eigrp
== NULL
) {
1132 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1135 variance
= atoi(argv
[1]->arg
);
1137 eigrp
->variance
= variance
;
1144 DEFUN (no_eigrp_variance
,
1145 no_eigrp_variance_cmd
,
1146 "no variance (1-128)",
1148 "Control load balancing variance\n"
1149 "Metric variance multiplier\n")
1151 struct eigrp
*eigrp
;
1152 eigrp
= eigrp_lookup();
1153 if (eigrp
== NULL
) {
1154 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1158 eigrp
->variance
= EIGRP_VARIANCE_DEFAULT
;
1165 DEFUN (eigrp_maximum_paths
,
1166 eigrp_maximum_paths_cmd
,
1167 "maximum-paths (1-32)",
1168 "Forward packets over multiple paths\n"
1169 "Number of paths\n")
1171 struct eigrp
*eigrp
;
1174 eigrp
= eigrp_lookup();
1175 if (eigrp
== NULL
) {
1176 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1180 max
= atoi(argv
[1]->arg
);
1182 eigrp
->max_paths
= max
;
1189 DEFUN (no_eigrp_maximum_paths
,
1190 no_eigrp_maximum_paths_cmd
,
1191 "no maximum-paths <1-32>",
1193 "Forward packets over multiple paths\n"
1194 "Number of paths\n")
1196 struct eigrp
*eigrp
;
1198 eigrp
= eigrp_lookup();
1199 if (eigrp
== NULL
) {
1200 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1204 eigrp
->max_paths
= EIGRP_MAX_PATHS_DEFAULT
;
1212 * Execute hard restart for all neighbors
1214 DEFUN (clear_ip_eigrp_neighbors
,
1215 clear_ip_eigrp_neighbors_cmd
,
1216 "clear ip eigrp neighbors",
1220 "Clear IP-EIGRP neighbors\n")
1222 struct eigrp
*eigrp
;
1223 struct eigrp_interface
*ei
;
1224 struct listnode
*node
, *node2
, *nnode2
;
1225 struct eigrp_neighbor
*nbr
;
1227 /* Check if eigrp process is enabled */
1228 eigrp
= eigrp_lookup();
1229 if (eigrp
== NULL
) {
1230 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1234 /* iterate over all eigrp interfaces */
1235 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
1236 /* send Goodbye Hello */
1237 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1239 /* iterate over all neighbors on eigrp interface */
1240 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1241 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1243 "Neighbor %s (%s) is down: manually cleared",
1244 inet_ntoa(nbr
->src
),
1245 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1247 vty_time_print(vty
, 0);
1249 "Neighbor %s (%s) is down: manually cleared\n",
1250 inet_ntoa(nbr
->src
),
1251 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1254 /* set neighbor to DOWN */
1255 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1256 /* delete neighbor */
1257 eigrp_nbr_delete(nbr
);
1266 * Execute hard restart for all neighbors on interface
1268 DEFUN (clear_ip_eigrp_neighbors_int
,
1269 clear_ip_eigrp_neighbors_int_cmd
,
1270 "clear ip eigrp neighbors IFNAME",
1274 "Clear IP-EIGRP neighbors\n"
1275 "Interface's name\n")
1277 struct eigrp
*eigrp
;
1278 struct eigrp_interface
*ei
;
1279 struct listnode
*node2
, *nnode2
;
1280 struct eigrp_neighbor
*nbr
;
1283 /* Check if eigrp process is enabled */
1284 eigrp
= eigrp_lookup();
1285 if (eigrp
== NULL
) {
1286 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1290 /* lookup interface by specified name */
1291 argv_find(argv
, argc
, "IFNAME", &idx
);
1292 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[idx
]->arg
);
1294 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[idx
]->arg
);
1298 /* send Goodbye Hello */
1299 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1301 /* iterate over all neighbors on eigrp interface */
1302 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1303 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1304 zlog_debug("Neighbor %s (%s) is down: manually cleared",
1305 inet_ntoa(nbr
->src
),
1306 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1308 vty_time_print(vty
, 0);
1310 "Neighbor %s (%s) is down: manually cleared\n",
1311 inet_ntoa(nbr
->src
),
1312 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1315 /* set neighbor to DOWN */
1316 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1317 /* delete neighbor */
1318 eigrp_nbr_delete(nbr
);
1326 * Execute hard restart for neighbor specified by IP
1328 DEFUN (clear_ip_eigrp_neighbors_IP
,
1329 clear_ip_eigrp_neighbors_IP_cmd
,
1330 "clear ip eigrp neighbors A.B.C.D",
1334 "Clear IP-EIGRP neighbors\n"
1335 "IP-EIGRP neighbor address\n")
1337 struct eigrp
*eigrp
;
1338 struct eigrp_neighbor
*nbr
;
1339 struct in_addr nbr_addr
;
1341 if (!inet_aton(argv
[4]->arg
, &nbr_addr
)) {
1342 vty_out(vty
, "Unable to parse %s",
1347 /* Check if eigrp process is enabled */
1348 eigrp
= eigrp_lookup();
1349 if (eigrp
== NULL
) {
1350 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1354 /* lookup neighbor in whole process */
1355 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1357 /* if neighbor doesn't exists, notify user and exit */
1359 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1363 /* execute hard reset on neighbor */
1364 eigrp_nbr_hard_restart(nbr
, vty
);
1370 * Execute graceful restart for all neighbors
1372 DEFUN (clear_ip_eigrp_neighbors_soft
,
1373 clear_ip_eigrp_neighbors_soft_cmd
,
1374 "clear ip eigrp neighbors soft",
1378 "Clear IP-EIGRP neighbors\n"
1379 "Resync with peers without adjacency reset\n")
1381 struct eigrp
*eigrp
;
1383 /* Check if eigrp process is enabled */
1384 eigrp
= eigrp_lookup();
1385 if (eigrp
== NULL
) {
1386 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1390 /* execute graceful restart on all neighbors */
1391 eigrp_update_send_process_GR(eigrp
, EIGRP_GR_MANUAL
, vty
);
1397 * Execute graceful restart for all neighbors on interface
1399 DEFUN (clear_ip_eigrp_neighbors_int_soft
,
1400 clear_ip_eigrp_neighbors_int_soft_cmd
,
1401 "clear ip eigrp neighbors IFNAME soft",
1405 "Clear IP-EIGRP neighbors\n"
1406 "Interface's name\n"
1407 "Resync with peer without adjacency reset\n")
1409 struct eigrp
*eigrp
;
1410 struct eigrp_interface
*ei
;
1412 /* Check if eigrp process is enabled */
1413 eigrp
= eigrp_lookup();
1414 if (eigrp
== NULL
) {
1415 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1419 /* lookup interface by specified name */
1420 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[4]->arg
);
1422 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[4]->arg
);
1426 /* execute graceful restart for all neighbors on interface */
1427 eigrp_update_send_interface_GR(ei
, EIGRP_GR_MANUAL
, vty
);
1432 * Execute graceful restart for neighbor specified by IP
1434 DEFUN (clear_ip_eigrp_neighbors_IP_soft
,
1435 clear_ip_eigrp_neighbors_IP_soft_cmd
,
1436 "clear ip eigrp neighbors A.B.C.D soft",
1440 "Clear IP-EIGRP neighbors\n"
1441 "IP-EIGRP neighbor address\n"
1442 "Resync with peer without adjacency reset\n")
1444 struct eigrp
*eigrp
;
1445 struct eigrp_neighbor
*nbr
;
1446 struct in_addr nbr_addr
;
1448 if (!inet_aton(argv
[4]->arg
, &nbr_addr
)) {
1449 vty_out(vty
, "Unable to parse: %s",
1454 /* Check if eigrp process is enabled */
1455 eigrp
= eigrp_lookup();
1456 if (eigrp
== NULL
) {
1457 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1461 /* lookup neighbor in whole process */
1462 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1464 /* if neighbor doesn't exists, notify user and exit */
1466 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1470 /* execute graceful restart on neighbor */
1471 eigrp_update_send_GR(nbr
, EIGRP_GR_MANUAL
, vty
);
1476 static struct cmd_node eigrp_node
= {EIGRP_NODE
, "%s(config-router)# ", 1};
1478 /* Save EIGRP configuration */
1479 static int eigrp_config_write(struct vty
*vty
)
1481 struct eigrp
*eigrp
;
1485 eigrp
= eigrp_lookup();
1486 if (eigrp
!= NULL
) {
1487 /* Writes 'router eigrp' section to config */
1488 config_write_eigrp_router(vty
, eigrp
);
1490 /* Interface config print */
1491 config_write_interfaces(vty
, eigrp
);
1493 // /* static neighbor print. */
1494 // config_write_eigrp_nbr_nbma (vty, eigrp);
1496 // /* Virtual-Link print. */
1497 // config_write_virtual_link (vty, eigrp);
1499 // /* Default metric configuration. */
1500 // config_write_eigrp_default_metric (vty, eigrp);
1502 // /* Distribute-list and default-information print. */
1503 // config_write_eigrp_distribute (vty, eigrp);
1505 // /* Distance configuration. */
1506 // config_write_eigrp_distance (vty, eigrp)
1512 void eigrp_vty_show_init(void)
1514 install_element(VIEW_NODE
, &show_ip_eigrp_interfaces_cmd
);
1516 install_element(VIEW_NODE
, &show_ip_eigrp_neighbors_cmd
);
1518 install_element(VIEW_NODE
, &show_ip_eigrp_topology_cmd
);
1520 install_element(VIEW_NODE
, &show_ip_eigrp_topology_detail_cmd
);
1523 /* eigrpd's interface node. */
1524 static struct cmd_node eigrp_interface_node
= {INTERFACE_NODE
,
1525 "%s(config-if)# ", 1};
1527 void eigrp_vty_if_init(void)
1529 install_node(&eigrp_interface_node
, eigrp_write_interface
);
1532 /* Delay and bandwidth configuration commands*/
1533 install_element(INTERFACE_NODE
, &eigrp_if_delay_cmd
);
1534 install_element(INTERFACE_NODE
, &no_eigrp_if_delay_cmd
);
1535 install_element(INTERFACE_NODE
, &eigrp_if_bandwidth_cmd
);
1536 install_element(INTERFACE_NODE
, &no_eigrp_if_bandwidth_cmd
);
1538 /*Hello-interval and hold-time interval configuration commands*/
1539 install_element(INTERFACE_NODE
, &eigrp_if_ip_holdinterval_cmd
);
1540 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_holdinterval_cmd
);
1541 install_element(INTERFACE_NODE
, &eigrp_if_ip_hellointerval_cmd
);
1542 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_hellointerval_cmd
);
1544 /* "Authentication configuration commands */
1545 install_element(INTERFACE_NODE
, &eigrp_authentication_mode_cmd
);
1546 install_element(INTERFACE_NODE
, &no_eigrp_authentication_mode_cmd
);
1547 install_element(INTERFACE_NODE
, &eigrp_authentication_keychain_cmd
);
1548 install_element(INTERFACE_NODE
, &no_eigrp_authentication_keychain_cmd
);
1550 /*EIGRP Summarization commands*/
1551 install_element(INTERFACE_NODE
, &eigrp_ip_summary_address_cmd
);
1552 install_element(INTERFACE_NODE
, &no_eigrp_ip_summary_address_cmd
);
1555 static void eigrp_vty_zebra_init(void)
1557 install_element(EIGRP_NODE
, &eigrp_redistribute_source_metric_cmd
);
1558 install_element(EIGRP_NODE
, &no_eigrp_redistribute_source_metric_cmd
);
1561 /* Install EIGRP related vty commands. */
1562 void eigrp_vty_init(void)
1564 install_node(&eigrp_node
, eigrp_config_write
);
1566 install_default(EIGRP_NODE
);
1568 install_element(CONFIG_NODE
, &router_eigrp_cmd
);
1569 install_element(CONFIG_NODE
, &no_router_eigrp_cmd
);
1570 install_element(EIGRP_NODE
, &eigrp_network_cmd
);
1571 install_element(EIGRP_NODE
, &no_eigrp_network_cmd
);
1572 install_element(EIGRP_NODE
, &eigrp_variance_cmd
);
1573 install_element(EIGRP_NODE
, &no_eigrp_variance_cmd
);
1574 install_element(EIGRP_NODE
, &eigrp_router_id_cmd
);
1575 install_element(EIGRP_NODE
, &no_eigrp_router_id_cmd
);
1576 install_element(EIGRP_NODE
, &eigrp_passive_interface_cmd
);
1577 install_element(EIGRP_NODE
, &no_eigrp_passive_interface_cmd
);
1578 install_element(EIGRP_NODE
, &eigrp_timers_active_cmd
);
1579 install_element(EIGRP_NODE
, &no_eigrp_timers_active_cmd
);
1580 install_element(EIGRP_NODE
, &eigrp_metric_weights_cmd
);
1581 install_element(EIGRP_NODE
, &no_eigrp_metric_weights_cmd
);
1582 install_element(EIGRP_NODE
, &eigrp_maximum_paths_cmd
);
1583 install_element(EIGRP_NODE
, &no_eigrp_maximum_paths_cmd
);
1584 install_element(EIGRP_NODE
, &eigrp_neighbor_cmd
);
1585 install_element(EIGRP_NODE
, &no_eigrp_neighbor_cmd
);
1587 /* commands for manual hard restart */
1588 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_cmd
);
1589 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_cmd
);
1590 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_cmd
);
1591 /* commands for manual graceful restart */
1592 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_soft_cmd
);
1593 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_soft_cmd
);
1594 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_soft_cmd
);
1596 eigrp_vty_zebra_init();