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
);
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 if (!eigrp
->networks
)
197 /* Router ID print. */
198 if (eigrp
->router_id_static
!= 0) {
199 struct in_addr router_id_static
;
200 router_id_static
.s_addr
= htonl(eigrp
->router_id_static
);
201 vty_out(vty
, " eigrp router-id %s\n",
202 inet_ntoa(router_id_static
));
205 /* Network area print. */
206 config_write_network(vty
, eigrp
);
208 /* Distribute-list and default-information print. */
209 config_write_eigrp_distribute(vty
, eigrp
);
211 /*Separate EIGRP configuration from the rest of the config*/
217 DEFUN_NOSH (router_eigrp
,
219 "router eigrp (1-65535)",
220 "Enable a routing process\n"
221 "Start EIGRP configuration\n"
222 "AS Number to use\n")
224 struct eigrp
*eigrp
= eigrp_get(argv
[2]->arg
);
225 VTY_PUSH_CONTEXT(EIGRP_NODE
, eigrp
);
230 DEFUN (no_router_eigrp
,
232 "no router eigrp (1-65535)",
235 "EIGRP configuration\n"
236 "AS number to use\n")
238 vty
->node
= CONFIG_NODE
;
242 eigrp
= eigrp_lookup();
244 vty_out(vty
, " EIGRP Routing Process not enabled\n");
248 if (eigrp
->AS
!= atoi(argv
[3]->arg
)) {
249 vty_out(vty
, "%% Attempting to deconfigure non-existent AS\n");
250 return CMD_WARNING_CONFIG_FAILED
;
253 eigrp_finish_final(eigrp
);
258 DEFUN (eigrp_router_id
,
260 "eigrp router-id A.B.C.D",
261 "EIGRP specific commands\n"
262 "Router ID for this EIGRP process\n"
263 "EIGRP Router-ID in IP address format\n")
265 // struct eigrp *eigrp = vty->index;
271 DEFUN (no_eigrp_router_id
,
272 no_eigrp_router_id_cmd
,
273 "no eigrp router-id A.B.C.D",
275 "EIGRP specific commands\n"
276 "Router ID for this EIGRP process\n"
277 "EIGRP Router-ID in IP address format\n")
279 // struct eigrp *eigrp = vty->index;
285 DEFUN (eigrp_passive_interface
,
286 eigrp_passive_interface_cmd
,
287 "passive-interface IFNAME",
288 "Suppress routing updates on an interface\n"
289 "Interface to suppress on\n")
291 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
292 struct eigrp_interface
*ei
;
293 struct listnode
*node
;
294 char *ifname
= argv
[1]->arg
;
296 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
297 if (strcmp(ifname
, ei
->ifp
->name
) == 0) {
298 ei
->params
.passive_interface
= EIGRP_IF_PASSIVE
;
305 DEFUN (no_eigrp_passive_interface
,
306 no_eigrp_passive_interface_cmd
,
307 "no passive-interface IFNAME",
309 "Suppress routing updates on an interface\n"
310 "Interface to suppress on\n")
312 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
313 struct eigrp_interface
*ei
;
314 struct listnode
*node
;
315 char *ifname
= argv
[2]->arg
;
317 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
318 if (strcmp(ifname
, ei
->ifp
->name
) == 0) {
319 ei
->params
.passive_interface
= EIGRP_IF_ACTIVE
;
327 DEFUN (eigrp_timers_active
,
328 eigrp_timers_active_cmd
,
329 "timers active-time <(1-65535)|disabled>",
330 "Adjust routing timers\n"
331 "Time limit for active state\n"
332 "Active state time limit in minutes\n"
333 "Disable time limit for active state\n")
335 // struct eigrp *eigrp = vty->index;
341 DEFUN (no_eigrp_timers_active
,
342 no_eigrp_timers_active_cmd
,
343 "no timers active-time <(1-65535)|disabled>",
345 "Adjust routing timers\n"
346 "Time limit for active state\n"
347 "Active state time limit in minutes\n"
348 "Disable time limit for active state\n")
350 // struct eigrp *eigrp = vty->index;
357 DEFUN (eigrp_metric_weights
,
358 eigrp_metric_weights_cmd
,
359 "metric weights (0-255) (0-255) (0-255) (0-255) (0-255) ",
360 "Modify metrics and parameters for advertisement\n"
361 "Modify metric coefficients\n"
368 // struct eigrp *eigrp = vty->index;
374 DEFUN (no_eigrp_metric_weights
,
375 no_eigrp_metric_weights_cmd
,
376 "no metric weights <0-255> <0-255> <0-255> <0-255> <0-255>",
378 "Modify metrics and parameters for advertisement\n"
379 "Modify metric coefficients\n"
386 // struct eigrp *eigrp = vty->index;
393 DEFUN (eigrp_network
,
396 "Enable routing on an IP network\n"
397 "EIGRP network prefix\n")
399 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
403 (void)str2prefix(argv
[1]->arg
, &p
);
405 ret
= eigrp_network_set(eigrp
, &p
);
408 vty_out(vty
, "There is already same network statement.\n");
415 DEFUN (no_eigrp_network
,
416 no_eigrp_network_cmd
,
417 "no network A.B.C.D/M",
419 "Disable routing on an IP network\n"
420 "EIGRP network prefix\n")
422 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
426 (void)str2prefix(argv
[2]->arg
, &p
);
428 ret
= eigrp_network_unset(eigrp
, &p
);
431 vty_out(vty
, "Can't find specified network configuration.\n");
432 return CMD_WARNING_CONFIG_FAILED
;
438 DEFUN (eigrp_neighbor
,
441 "Specify a neighbor router\n"
442 "Neighbor address\n")
444 // struct eigrp *eigrp = vty->index;
449 DEFUN (no_eigrp_neighbor
,
450 no_eigrp_neighbor_cmd
,
451 "no neighbor A.B.C.D",
453 "Specify a neighbor router\n"
454 "Neighbor address\n")
456 // struct eigrp *eigrp = vty->index;
461 DEFUN (show_ip_eigrp_topology
,
462 show_ip_eigrp_topology_cmd
,
463 "show ip eigrp topology [all-links]",
466 "IP-EIGRP show commands\n"
467 "IP-EIGRP topology\n"
468 "Show all links in topology table\n")
471 struct listnode
*node
;
472 struct eigrp_prefix_entry
*tn
;
473 struct eigrp_nexthop_entry
*te
;
474 struct route_node
*rn
;
477 eigrp
= eigrp_lookup();
479 vty_out(vty
, " EIGRP Routing Process not enabled\n");
483 show_ip_eigrp_topology_header(vty
, eigrp
);
485 for (rn
= route_top(eigrp
->topology_table
); rn
; rn
= route_next(rn
)) {
491 for (ALL_LIST_ELEMENTS_RO(tn
->entries
, node
, te
)) {
494 & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG
)
495 == EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG
)
497 & EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG
)
498 == EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG
))) {
499 show_ip_eigrp_nexthop_entry(vty
, eigrp
, te
,
509 ALIAS(show_ip_eigrp_topology
, show_ip_eigrp_topology_detail_cmd
,
510 "show ip eigrp topology <A.B.C.D|A.B.C.D/M|detail|summary>",
512 "IP-EIGRP show commands\n"
513 "IP-EIGRP topology\n"
514 "Netwok to display information about\n"
515 "IP prefix <network>/<length>, e.g., 192.168.0.0/16\n"
516 "Show all links in topology table\n"
517 "Show a summary of the topology table\n")
519 DEFUN (show_ip_eigrp_interfaces
,
520 show_ip_eigrp_interfaces_cmd
,
521 "show ip eigrp interfaces [IFNAME] [detail]",
524 "IP-EIGRP show commands\n"
525 "IP-EIGRP interfaces\n"
526 "Interface name to look at\n"
527 "Detailed information\n")
529 struct eigrp_interface
*ei
;
531 struct listnode
*node
;
534 const char *ifname
= NULL
;
536 eigrp
= eigrp_lookup();
538 vty_out(vty
, "EIGRP Routing Process not enabled\n");
542 if (argv_find(argv
, argc
, "IFNAME", &idx
))
543 ifname
= argv
[idx
]->arg
;
545 if (argv_find(argv
, argc
, "detail", &idx
))
549 show_ip_eigrp_interface_header(vty
, eigrp
);
551 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
552 if (!ifname
|| strcmp(ei
->ifp
->name
, ifname
) == 0) {
553 show_ip_eigrp_interface_sub(vty
, eigrp
, ei
);
555 show_ip_eigrp_interface_detail(vty
, eigrp
, ei
);
562 DEFUN (show_ip_eigrp_neighbors
,
563 show_ip_eigrp_neighbors_cmd
,
564 "show ip eigrp neighbors [IFNAME] [detail]",
567 "IP-EIGRP show commands\n"
568 "IP-EIGRP neighbors\n"
569 "Interface to show on\n"
570 "Detailed Information\n")
573 struct eigrp_interface
*ei
;
574 struct listnode
*node
, *node2
, *nnode2
;
575 struct eigrp_neighbor
*nbr
;
578 const char *ifname
= NULL
;
580 eigrp
= eigrp_lookup();
582 vty_out(vty
, " EIGRP Routing Process not enabled\n");
586 if (argv_find(argv
, argc
, "IFNAME", &idx
))
587 ifname
= argv
[idx
]->arg
;
589 detail
= (argv_find(argv
, argc
, "detail", &idx
));
591 show_ip_eigrp_neighbor_header(vty
, eigrp
);
593 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
594 if (!ifname
|| strcmp(ei
->ifp
->name
, ifname
) == 0) {
595 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
596 if (detail
|| (nbr
->state
== EIGRP_NEIGHBOR_UP
))
597 show_ip_eigrp_neighbor_sub(vty
, nbr
,
606 DEFUN (eigrp_if_delay
,
608 "delay (1-16777215)",
609 "Specify interface throughput delay\n"
610 "Throughput delay (tens of microseconds)\n")
612 VTY_DECLVAR_CONTEXT(interface
, ifp
);
613 struct eigrp_interface
*ei
= ifp
->info
;
617 eigrp
= eigrp_lookup();
619 vty_out(vty
, " EIGRP Routing Process not enabled\n");
625 vty_out(vty
, " EIGRP not configured on this interface\n");
628 delay
= atoi(argv
[1]->arg
);
630 ei
->params
.delay
= delay
;
636 DEFUN (no_eigrp_if_delay
,
637 no_eigrp_if_delay_cmd
,
638 "no delay (1-16777215)",
640 "Specify interface throughput delay\n"
641 "Throughput delay (tens of microseconds)\n")
643 VTY_DECLVAR_CONTEXT(interface
, ifp
);
644 struct eigrp_interface
*ei
= ifp
->info
;
647 eigrp
= eigrp_lookup();
649 vty_out(vty
, " EIGRP Routing Process not enabled\n");
654 vty_out(vty
, " EIGRP not configured on this interface\n");
658 ei
->params
.delay
= EIGRP_DELAY_DEFAULT
;
664 DEFPY (eigrp_if_bandwidth
,
665 eigrp_if_bandwidth_cmd
,
666 "eigrp bandwidth (1-10000000)$bw",
667 "EIGRP specific commands\n"
668 "Set bandwidth informational parameter\n"
669 "Bandwidth in kilobits\n")
671 VTY_DECLVAR_CONTEXT(interface
, ifp
);
672 struct eigrp_interface
*ei
= ifp
->info
;
675 eigrp
= eigrp_lookup();
677 vty_out(vty
, " EIGRP Routing Process not enabled\n");
682 vty_out(vty
, " EIGRP not configured on this interface\n");
686 ei
->params
.bandwidth
= bw
;
692 DEFUN (no_eigrp_if_bandwidth
,
693 no_eigrp_if_bandwidth_cmd
,
694 "no eigrp bandwidth [(1-10000000)]",
696 "EIGRP specific commands\n"
697 "Set bandwidth informational parameter\n"
698 "Bandwidth in kilobits\n")
700 VTY_DECLVAR_CONTEXT(interface
, ifp
);
701 struct eigrp_interface
*ei
= ifp
->info
;
704 eigrp
= eigrp_lookup();
706 vty_out(vty
, " EIGRP Routing Process not enabled\n");
711 vty_out(vty
, " EIGRP not configured on this interface\n");
715 ei
->params
.bandwidth
= EIGRP_BANDWIDTH_DEFAULT
;
721 DEFUN (eigrp_if_ip_hellointerval
,
722 eigrp_if_ip_hellointerval_cmd
,
723 "ip hello-interval eigrp (1-65535)",
724 "Interface Internet Protocol config commands\n"
725 "Configures EIGRP hello interval\n"
726 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
727 "Seconds between hello transmissions\n")
729 VTY_DECLVAR_CONTEXT(interface
, ifp
);
730 struct eigrp_interface
*ei
= ifp
->info
;
734 eigrp
= eigrp_lookup();
736 vty_out(vty
, " EIGRP Routing Process not enabled\n");
741 vty_out(vty
, " EIGRP not configured on this interface\n");
745 hello
= atoi(argv
[3]->arg
);
747 ei
->params
.v_hello
= hello
;
752 DEFUN (no_eigrp_if_ip_hellointerval
,
753 no_eigrp_if_ip_hellointerval_cmd
,
754 "no ip hello-interval eigrp [(1-65535)]",
756 "Interface Internet Protocol config commands\n"
757 "Configures EIGRP hello interval\n"
758 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
759 "Seconds between hello transmissions\n")
761 VTY_DECLVAR_CONTEXT(interface
, ifp
);
762 struct eigrp_interface
*ei
= ifp
->info
;
765 eigrp
= eigrp_lookup();
767 vty_out(vty
, " EIGRP Routing Process not enabled\n");
772 vty_out(vty
, " EIGRP not configured on this interface\n");
776 ei
->params
.v_hello
= EIGRP_HELLO_INTERVAL_DEFAULT
;
778 THREAD_TIMER_OFF(ei
->t_hello
);
779 thread_add_timer(master
, eigrp_hello_timer
, ei
, 1, &ei
->t_hello
);
784 DEFUN (eigrp_if_ip_holdinterval
,
785 eigrp_if_ip_holdinterval_cmd
,
786 "ip hold-time eigrp (1-65535)",
787 "Interface Internet Protocol config commands\n"
788 "Configures EIGRP IPv4 hold time\n"
789 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
790 "Seconds before neighbor is considered down\n")
792 VTY_DECLVAR_CONTEXT(interface
, ifp
);
793 struct eigrp_interface
*ei
= ifp
->info
;
797 eigrp
= eigrp_lookup();
799 vty_out(vty
, " EIGRP Routing Process not enabled\n");
804 vty_out(vty
, " EIGRP not configured on this interface\n");
808 hold
= atoi(argv
[3]->arg
);
810 ei
->params
.v_wait
= hold
;
815 DEFUN (eigrp_ip_summary_address
,
816 eigrp_ip_summary_address_cmd
,
817 "ip summary-address eigrp (1-65535) A.B.C.D/M",
818 "Interface Internet Protocol config commands\n"
819 "Perform address summarization\n"
820 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
822 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
824 // VTY_DECLVAR_CONTEXT(interface, ifp);
828 eigrp
= eigrp_lookup();
830 vty_out(vty
, " EIGRP Routing Process not enabled\n");
834 // AS = atoi (argv[3]->arg);
841 DEFUN (no_eigrp_ip_summary_address
,
842 no_eigrp_ip_summary_address_cmd
,
843 "no ip summary-address eigrp (1-65535) A.B.C.D/M",
845 "Interface Internet Protocol config commands\n"
846 "Perform address summarization\n"
847 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
849 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
851 // VTY_DECLVAR_CONTEXT(interface, ifp);
855 eigrp
= eigrp_lookup();
857 vty_out(vty
, " EIGRP Routing Process not enabled\n");
861 // AS = atoi (argv[4]->arg);
868 DEFUN (no_eigrp_if_ip_holdinterval
,
869 no_eigrp_if_ip_holdinterval_cmd
,
870 "no ip hold-time eigrp",
872 "Interface Internet Protocol config commands\n"
873 "Configures EIGRP hello interval\n"
874 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n")
876 VTY_DECLVAR_CONTEXT(interface
, ifp
);
877 struct eigrp_interface
*ei
= ifp
->info
;
880 eigrp
= eigrp_lookup();
882 vty_out(vty
, " EIGRP Routing Process not enabled\n");
887 vty_out(vty
, " EIGRP not configured on this interface\n");
891 ei
->params
.v_wait
= EIGRP_HOLD_INTERVAL_DEFAULT
;
896 static int str2auth_type(const char *str
, struct eigrp_interface
*ei
)
900 return CMD_WARNING_CONFIG_FAILED
;
902 if (strncmp(str
, "md5", 3) == 0) {
903 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_MD5
;
905 } else if (strncmp(str
, "hmac-sha-256", 12) == 0) {
906 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_SHA256
;
910 return CMD_WARNING_CONFIG_FAILED
;
913 DEFUN (eigrp_authentication_mode
,
914 eigrp_authentication_mode_cmd
,
915 "ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
916 "Interface Internet Protocol config commands\n"
917 "Authentication subcommands\n"
919 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
920 "Autonomous system number\n"
921 "Keyed message digest\n"
922 "HMAC SHA256 algorithm \n")
924 VTY_DECLVAR_CONTEXT(interface
, ifp
);
925 struct eigrp_interface
*ei
= ifp
->info
;
928 eigrp
= eigrp_lookup();
930 vty_out(vty
, " EIGRP Routing Process not enabled\n");
935 vty_out(vty
, " EIGRP not configured on this interface\n");
939 // if(strncmp(argv[2], "md5",3))
940 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_MD5;
941 // else if(strncmp(argv[2], "hmac-sha-256",12))
942 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_SHA256;
944 return str2auth_type(argv
[5]->arg
, ei
);
947 DEFUN (no_eigrp_authentication_mode
,
948 no_eigrp_authentication_mode_cmd
,
949 "no ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
951 "Interface Internet Protocol config commands\n"
952 "Authentication subcommands\n"
954 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
955 "Autonomous system number\n"
956 "Keyed message digest\n"
957 "HMAC SHA256 algorithm \n")
959 VTY_DECLVAR_CONTEXT(interface
, ifp
);
960 struct eigrp_interface
*ei
= ifp
->info
;
963 eigrp
= eigrp_lookup();
965 vty_out(vty
, " EIGRP Routing Process not enabled\n");
970 vty_out(vty
, " EIGRP not configured on this interface\n");
974 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_NONE
;
979 DEFPY (eigrp_authentication_keychain
,
980 eigrp_authentication_keychain_cmd
,
981 "[no] ip authentication key-chain eigrp (1-65535)$as WORD$name",
983 "Interface Internet Protocol config commands\n"
984 "Authentication subcommands\n"
986 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
987 "Autonomous system number\n"
988 "Name of key-chain\n")
990 VTY_DECLVAR_CONTEXT(interface
, ifp
);
991 struct eigrp_interface
*ei
= ifp
->info
;
993 struct keychain
*keychain
;
995 eigrp
= eigrp_lookup();
997 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1002 vty_out(vty
, " EIGRP not configured on this interface\n");
1007 if ((ei
->params
.auth_keychain
!= NULL
)
1008 && (strcmp(ei
->params
.auth_keychain
, name
) == 0)) {
1009 free(ei
->params
.auth_keychain
);
1010 ei
->params
.auth_keychain
= NULL
;
1013 "Key chain with specified name not configured on interface\n");
1017 keychain
= keychain_lookup(name
);
1018 if (keychain
!= NULL
) {
1019 if (ei
->params
.auth_keychain
) {
1020 free(ei
->params
.auth_keychain
);
1021 ei
->params
.auth_keychain
= strdup(keychain
->name
);
1023 ei
->params
.auth_keychain
= strdup(keychain
->name
);
1026 "Key chain with specified name not found\n");
1027 return CMD_WARNING_CONFIG_FAILED
;
1033 DEFUN (eigrp_redistribute_source_metric
,
1034 eigrp_redistribute_source_metric_cmd
,
1035 "redistribute " FRR_REDIST_STR_EIGRPD
1036 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
1038 FRR_REDIST_HELP_STR_EIGRPD
1039 "Metric for redistributed routes\n"
1040 "Bandwidth metric in Kbits per second\n"
1041 "EIGRP delay metric, in 10 microsecond units\n"
1042 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1043 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1044 "EIGRP MTU of the path\n")
1046 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1047 struct eigrp_metrics metrics_from_command
= {0};
1051 /* Get distribute source. */
1052 argv_find(argv
, argc
, "redistribute", &idx
);
1053 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1055 vty_out(vty
, "%% Invalid route type\n");
1056 return CMD_WARNING_CONFIG_FAILED
;
1059 /* Get metrics values */
1061 return eigrp_redistribute_set(eigrp
, source
, metrics_from_command
);
1064 DEFUN (no_eigrp_redistribute_source_metric
,
1065 no_eigrp_redistribute_source_metric_cmd
,
1066 "no redistribute " FRR_REDIST_STR_EIGRPD
1067 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
1070 FRR_REDIST_HELP_STR_EIGRPD
1071 "Metric for redistributed routes\n"
1072 "Bandwidth metric in Kbits per second\n"
1073 "EIGRP delay metric, in 10 microsecond units\n"
1074 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1075 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1076 "EIGRP MTU of the path\n")
1078 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1082 /* Get distribute source. */
1083 argv_find(argv
, argc
, "redistribute", &idx
);
1084 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1086 vty_out(vty
, "%% Invalid route type\n");
1087 return CMD_WARNING_CONFIG_FAILED
;
1090 /* Get metrics values */
1092 return eigrp_redistribute_unset(eigrp
, source
);
1095 DEFUN (eigrp_variance
,
1098 "Control load balancing variance\n"
1099 "Metric variance multiplier\n")
1101 struct eigrp
*eigrp
;
1104 eigrp
= eigrp_lookup();
1105 if (eigrp
== NULL
) {
1106 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1109 variance
= atoi(argv
[1]->arg
);
1111 eigrp
->variance
= variance
;
1118 DEFUN (no_eigrp_variance
,
1119 no_eigrp_variance_cmd
,
1120 "no variance (1-128)",
1122 "Control load balancing variance\n"
1123 "Metric variance multiplier\n")
1125 struct eigrp
*eigrp
;
1126 eigrp
= eigrp_lookup();
1127 if (eigrp
== NULL
) {
1128 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1132 eigrp
->variance
= EIGRP_VARIANCE_DEFAULT
;
1139 DEFUN (eigrp_maximum_paths
,
1140 eigrp_maximum_paths_cmd
,
1141 "maximum-paths (1-32)",
1142 "Forward packets over multiple paths\n"
1143 "Number of paths\n")
1145 struct eigrp
*eigrp
;
1148 eigrp
= eigrp_lookup();
1149 if (eigrp
== NULL
) {
1150 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1154 max
= atoi(argv
[1]->arg
);
1156 eigrp
->max_paths
= max
;
1163 DEFUN (no_eigrp_maximum_paths
,
1164 no_eigrp_maximum_paths_cmd
,
1165 "no maximum-paths <1-32>",
1167 "Forward packets over multiple paths\n"
1168 "Number of paths\n")
1170 struct eigrp
*eigrp
;
1172 eigrp
= eigrp_lookup();
1173 if (eigrp
== NULL
) {
1174 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1178 eigrp
->max_paths
= EIGRP_MAX_PATHS_DEFAULT
;
1186 * Execute hard restart for all neighbors
1188 DEFUN (clear_ip_eigrp_neighbors
,
1189 clear_ip_eigrp_neighbors_cmd
,
1190 "clear ip eigrp neighbors",
1194 "Clear IP-EIGRP neighbors\n")
1196 struct eigrp
*eigrp
;
1197 struct eigrp_interface
*ei
;
1198 struct listnode
*node
, *node2
, *nnode2
;
1199 struct eigrp_neighbor
*nbr
;
1201 /* Check if eigrp process is enabled */
1202 eigrp
= eigrp_lookup();
1203 if (eigrp
== NULL
) {
1204 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1208 /* iterate over all eigrp interfaces */
1209 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
1210 /* send Goodbye Hello */
1211 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1213 /* iterate over all neighbors on eigrp interface */
1214 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1215 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1217 "Neighbor %s (%s) is down: manually cleared",
1218 inet_ntoa(nbr
->src
),
1219 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1221 vty_time_print(vty
, 0);
1223 "Neighbor %s (%s) is down: manually cleared\n",
1224 inet_ntoa(nbr
->src
),
1225 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1228 /* set neighbor to DOWN */
1229 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1230 /* delete neighbor */
1231 eigrp_nbr_delete(nbr
);
1240 * Execute hard restart for all neighbors on interface
1242 DEFUN (clear_ip_eigrp_neighbors_int
,
1243 clear_ip_eigrp_neighbors_int_cmd
,
1244 "clear ip eigrp neighbors IFNAME",
1248 "Clear IP-EIGRP neighbors\n"
1249 "Interface's name\n")
1251 struct eigrp
*eigrp
;
1252 struct eigrp_interface
*ei
;
1253 struct listnode
*node2
, *nnode2
;
1254 struct eigrp_neighbor
*nbr
;
1257 /* Check if eigrp process is enabled */
1258 eigrp
= eigrp_lookup();
1259 if (eigrp
== NULL
) {
1260 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1264 /* lookup interface by specified name */
1265 argv_find(argv
, argc
, "IFNAME", &idx
);
1266 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[idx
]->arg
);
1268 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[idx
]->arg
);
1272 /* send Goodbye Hello */
1273 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1275 /* iterate over all neighbors on eigrp interface */
1276 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1277 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1278 zlog_debug("Neighbor %s (%s) is down: manually cleared",
1279 inet_ntoa(nbr
->src
),
1280 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1282 vty_time_print(vty
, 0);
1284 "Neighbor %s (%s) is down: manually cleared\n",
1285 inet_ntoa(nbr
->src
),
1286 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1289 /* set neighbor to DOWN */
1290 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1291 /* delete neighbor */
1292 eigrp_nbr_delete(nbr
);
1300 * Execute hard restart for neighbor specified by IP
1302 DEFUN (clear_ip_eigrp_neighbors_IP
,
1303 clear_ip_eigrp_neighbors_IP_cmd
,
1304 "clear ip eigrp neighbors A.B.C.D",
1308 "Clear IP-EIGRP neighbors\n"
1309 "IP-EIGRP neighbor address\n")
1311 struct eigrp
*eigrp
;
1312 struct eigrp_neighbor
*nbr
;
1313 struct in_addr nbr_addr
;
1315 if (!inet_aton(argv
[4]->arg
, &nbr_addr
)) {
1316 vty_out(vty
, "Unable to parse %s", argv
[4]->arg
);
1320 /* Check if eigrp process is enabled */
1321 eigrp
= eigrp_lookup();
1322 if (eigrp
== NULL
) {
1323 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1327 /* lookup neighbor in whole process */
1328 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1330 /* if neighbor doesn't exists, notify user and exit */
1332 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1336 /* execute hard reset on neighbor */
1337 eigrp_nbr_hard_restart(nbr
, vty
);
1343 * Execute graceful restart for all neighbors
1345 DEFUN (clear_ip_eigrp_neighbors_soft
,
1346 clear_ip_eigrp_neighbors_soft_cmd
,
1347 "clear ip eigrp neighbors soft",
1351 "Clear IP-EIGRP neighbors\n"
1352 "Resync with peers without adjacency reset\n")
1354 struct eigrp
*eigrp
;
1356 /* Check if eigrp process is enabled */
1357 eigrp
= eigrp_lookup();
1358 if (eigrp
== NULL
) {
1359 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1363 /* execute graceful restart on all neighbors */
1364 eigrp_update_send_process_GR(eigrp
, EIGRP_GR_MANUAL
, vty
);
1370 * Execute graceful restart for all neighbors on interface
1372 DEFUN (clear_ip_eigrp_neighbors_int_soft
,
1373 clear_ip_eigrp_neighbors_int_soft_cmd
,
1374 "clear ip eigrp neighbors IFNAME soft",
1378 "Clear IP-EIGRP neighbors\n"
1379 "Interface's name\n"
1380 "Resync with peer without adjacency reset\n")
1382 struct eigrp
*eigrp
;
1383 struct eigrp_interface
*ei
;
1385 /* Check if eigrp process is enabled */
1386 eigrp
= eigrp_lookup();
1387 if (eigrp
== NULL
) {
1388 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1392 /* lookup interface by specified name */
1393 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[4]->arg
);
1395 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[4]->arg
);
1399 /* execute graceful restart for all neighbors on interface */
1400 eigrp_update_send_interface_GR(ei
, EIGRP_GR_MANUAL
, vty
);
1405 * Execute graceful restart for neighbor specified by IP
1407 DEFUN (clear_ip_eigrp_neighbors_IP_soft
,
1408 clear_ip_eigrp_neighbors_IP_soft_cmd
,
1409 "clear ip eigrp neighbors A.B.C.D soft",
1413 "Clear IP-EIGRP neighbors\n"
1414 "IP-EIGRP neighbor address\n"
1415 "Resync with peer without adjacency reset\n")
1417 struct eigrp
*eigrp
;
1418 struct eigrp_neighbor
*nbr
;
1419 struct in_addr nbr_addr
;
1421 if (!inet_aton(argv
[4]->arg
, &nbr_addr
)) {
1422 vty_out(vty
, "Unable to parse: %s", argv
[4]->arg
);
1426 /* Check if eigrp process is enabled */
1427 eigrp
= eigrp_lookup();
1428 if (eigrp
== NULL
) {
1429 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1433 /* lookup neighbor in whole process */
1434 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1436 /* if neighbor doesn't exists, notify user and exit */
1438 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1442 /* execute graceful restart on neighbor */
1443 eigrp_update_send_GR(nbr
, EIGRP_GR_MANUAL
, vty
);
1448 static struct cmd_node eigrp_node
= {EIGRP_NODE
, "%s(config-router)# ", 1};
1450 /* Save EIGRP configuration */
1451 static int eigrp_config_write(struct vty
*vty
)
1453 struct eigrp
*eigrp
;
1457 eigrp
= eigrp_lookup();
1458 if (eigrp
!= NULL
) {
1459 /* Writes 'router eigrp' section to config */
1460 config_write_eigrp_router(vty
, eigrp
);
1462 /* Interface config print */
1463 config_write_interfaces(vty
, eigrp
);
1465 // /* static neighbor print. */
1466 // config_write_eigrp_nbr_nbma (vty, eigrp);
1468 // /* Virtual-Link print. */
1469 // config_write_virtual_link (vty, eigrp);
1471 // /* Default metric configuration. */
1472 // config_write_eigrp_default_metric (vty, eigrp);
1474 // /* Distribute-list and default-information print. */
1475 // config_write_eigrp_distribute (vty, eigrp);
1477 // /* Distance configuration. */
1478 // config_write_eigrp_distance (vty, eigrp)
1484 void eigrp_vty_show_init(void)
1486 install_element(VIEW_NODE
, &show_ip_eigrp_interfaces_cmd
);
1488 install_element(VIEW_NODE
, &show_ip_eigrp_neighbors_cmd
);
1490 install_element(VIEW_NODE
, &show_ip_eigrp_topology_cmd
);
1492 install_element(VIEW_NODE
, &show_ip_eigrp_topology_detail_cmd
);
1495 /* eigrpd's interface node. */
1496 static struct cmd_node eigrp_interface_node
= {INTERFACE_NODE
,
1497 "%s(config-if)# ", 1};
1499 void eigrp_vty_if_init(void)
1501 install_node(&eigrp_interface_node
, eigrp_write_interface
);
1504 /* Delay and bandwidth configuration commands*/
1505 install_element(INTERFACE_NODE
, &eigrp_if_delay_cmd
);
1506 install_element(INTERFACE_NODE
, &no_eigrp_if_delay_cmd
);
1507 install_element(INTERFACE_NODE
, &eigrp_if_bandwidth_cmd
);
1508 install_element(INTERFACE_NODE
, &no_eigrp_if_bandwidth_cmd
);
1510 /*Hello-interval and hold-time interval configuration commands*/
1511 install_element(INTERFACE_NODE
, &eigrp_if_ip_holdinterval_cmd
);
1512 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_holdinterval_cmd
);
1513 install_element(INTERFACE_NODE
, &eigrp_if_ip_hellointerval_cmd
);
1514 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_hellointerval_cmd
);
1516 /* "Authentication configuration commands */
1517 install_element(INTERFACE_NODE
, &eigrp_authentication_mode_cmd
);
1518 install_element(INTERFACE_NODE
, &no_eigrp_authentication_mode_cmd
);
1519 install_element(INTERFACE_NODE
, &eigrp_authentication_keychain_cmd
);
1521 /*EIGRP Summarization commands*/
1522 install_element(INTERFACE_NODE
, &eigrp_ip_summary_address_cmd
);
1523 install_element(INTERFACE_NODE
, &no_eigrp_ip_summary_address_cmd
);
1526 static void eigrp_vty_zebra_init(void)
1528 install_element(EIGRP_NODE
, &eigrp_redistribute_source_metric_cmd
);
1529 install_element(EIGRP_NODE
, &no_eigrp_redistribute_source_metric_cmd
);
1532 /* Install EIGRP related vty commands. */
1533 void eigrp_vty_init(void)
1535 install_node(&eigrp_node
, eigrp_config_write
);
1537 install_default(EIGRP_NODE
);
1539 install_element(CONFIG_NODE
, &router_eigrp_cmd
);
1540 install_element(CONFIG_NODE
, &no_router_eigrp_cmd
);
1541 install_element(EIGRP_NODE
, &eigrp_network_cmd
);
1542 install_element(EIGRP_NODE
, &no_eigrp_network_cmd
);
1543 install_element(EIGRP_NODE
, &eigrp_variance_cmd
);
1544 install_element(EIGRP_NODE
, &no_eigrp_variance_cmd
);
1545 install_element(EIGRP_NODE
, &eigrp_router_id_cmd
);
1546 install_element(EIGRP_NODE
, &no_eigrp_router_id_cmd
);
1547 install_element(EIGRP_NODE
, &eigrp_passive_interface_cmd
);
1548 install_element(EIGRP_NODE
, &no_eigrp_passive_interface_cmd
);
1549 install_element(EIGRP_NODE
, &eigrp_timers_active_cmd
);
1550 install_element(EIGRP_NODE
, &no_eigrp_timers_active_cmd
);
1551 install_element(EIGRP_NODE
, &eigrp_metric_weights_cmd
);
1552 install_element(EIGRP_NODE
, &no_eigrp_metric_weights_cmd
);
1553 install_element(EIGRP_NODE
, &eigrp_maximum_paths_cmd
);
1554 install_element(EIGRP_NODE
, &no_eigrp_maximum_paths_cmd
);
1555 install_element(EIGRP_NODE
, &eigrp_neighbor_cmd
);
1556 install_element(EIGRP_NODE
, &no_eigrp_neighbor_cmd
);
1558 /* commands for manual hard restart */
1559 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_cmd
);
1560 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_cmd
);
1561 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_cmd
);
1562 /* commands for manual graceful restart */
1563 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_soft_cmd
);
1564 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_soft_cmd
);
1565 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_soft_cmd
);
1567 eigrp_vty_zebra_init();