3 * Copyright (C) 2013-2016
15 * This file is part of GNU Zebra.
17 * GNU Zebra is free software; you can redistribute it and/or modify it
18 * under the terms of the GNU General Public License as published by the
19 * Free Software Foundation; either version 2, or (at your option) any
22 * GNU Zebra is distributed in the hope that it will be useful, but
23 * WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * General Public License for more details.
27 * You should have received a copy of the GNU General Public License along
28 * with this program; see the file COPYING; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
45 #include "distribute.h"
47 #include "eigrpd/eigrp_structs.h"
48 #include "eigrpd/eigrpd.h"
49 #include "eigrpd/eigrp_interface.h"
50 #include "eigrpd/eigrp_neighbor.h"
51 #include "eigrpd/eigrp_packet.h"
52 #include "eigrpd/eigrp_zebra.h"
53 #include "eigrpd/eigrp_vty.h"
54 #include "eigrpd/eigrp_network.h"
55 #include "eigrpd/eigrp_dump.h"
56 #include "eigrpd/eigrp_const.h"
58 #ifndef VTYSH_EXTRACT_PL
59 #include "eigrpd/eigrp_vty_clippy.c"
62 static int config_write_network(struct vty
*vty
, struct eigrp
*eigrp
)
64 struct route_node
*rn
;
67 /* `network area' print. */
68 for (rn
= route_top(eigrp
->networks
); rn
; rn
= route_next(rn
))
71 vty_out(vty
, " network %s/%d \n",
72 inet_ntoa(rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
75 if (eigrp
->max_paths
!= EIGRP_MAX_PATHS_DEFAULT
)
76 vty_out(vty
, " maximum-paths %d\n", eigrp
->max_paths
);
78 if (eigrp
->variance
!= EIGRP_VARIANCE_DEFAULT
)
79 vty_out(vty
, " variance %d\n", eigrp
->variance
);
81 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
82 if (i
!= zclient
->redist_default
83 && vrf_bitmap_check(zclient
->redist
[AFI_IP
][i
],
85 vty_out(vty
, " redistribute %s\n",
86 zebra_route_string(i
));
88 /*Separate EIGRP configuration from the rest of the config*/
94 static int config_write_interfaces(struct vty
*vty
, struct eigrp
*eigrp
)
96 struct eigrp_interface
*ei
;
97 struct listnode
*node
;
99 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
100 vty_frame(vty
, "interface %s\n", ei
->ifp
->name
);
102 if (ei
->params
.auth_type
== EIGRP_AUTH_TYPE_MD5
) {
103 vty_out(vty
, " ip authentication mode eigrp %d md5\n",
107 if (ei
->params
.auth_type
== EIGRP_AUTH_TYPE_SHA256
) {
109 " ip authentication mode eigrp %d hmac-sha-256\n",
113 if (ei
->params
.auth_keychain
) {
115 " ip authentication key-chain eigrp %d %s\n",
116 eigrp
->AS
, ei
->params
.auth_keychain
);
119 if (ei
->params
.v_hello
!= EIGRP_HELLO_INTERVAL_DEFAULT
) {
120 vty_out(vty
, " ip hello-interval eigrp %d\n",
124 if (ei
->params
.v_wait
!= EIGRP_HOLD_INTERVAL_DEFAULT
) {
125 vty_out(vty
, " ip hold-time eigrp %d\n",
129 /*Separate this EIGRP interface configuration from the others*/
130 vty_endframe(vty
, "!\n");
136 static int eigrp_write_interface(struct vty
*vty
)
138 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
139 struct interface
*ifp
;
140 struct eigrp_interface
*ei
;
142 FOR_ALL_INTERFACES (vrf
, ifp
) {
147 vty_frame(vty
, "interface %s\n", ifp
->name
);
150 vty_out(vty
, " description %s\n", ifp
->desc
);
152 if (ei
->params
.bandwidth
!= EIGRP_BANDWIDTH_DEFAULT
)
153 vty_out(vty
, " bandwidth %u\n", ei
->params
.bandwidth
);
154 if (ei
->params
.delay
!= EIGRP_DELAY_DEFAULT
)
155 vty_out(vty
, " delay %u\n", ei
->params
.delay
);
156 if (ei
->params
.v_hello
!= EIGRP_HELLO_INTERVAL_DEFAULT
)
157 vty_out(vty
, " ip hello-interval eigrp %u\n",
159 if (ei
->params
.v_wait
!= EIGRP_HOLD_INTERVAL_DEFAULT
)
160 vty_out(vty
, " ip hold-time eigrp %u\n",
163 vty_endframe(vty
, "!\n");
170 * Writes distribute lists to config
172 static int config_write_eigrp_distribute(struct vty
*vty
, struct eigrp
*eigrp
)
176 /* Distribute configuration. */
177 write
+= config_write_distribute(vty
, eigrp
->distribute_ctx
);
183 * Writes 'router eigrp' section to config
185 static int config_write_eigrp_router(struct vty
*vty
, struct eigrp
*eigrp
)
189 /* `router eigrp' print. */
190 vty_out(vty
, "router eigrp %d\n", eigrp
->AS
);
194 /* Router ID print. */
195 if (eigrp
->router_id_static
.s_addr
!= 0) {
196 vty_out(vty
, " eigrp router-id %s\n",
197 inet_ntoa(eigrp
->router_id_static
));
200 /* Network area print. */
201 config_write_network(vty
, eigrp
);
203 /* Distribute-list and default-information print. */
204 config_write_eigrp_distribute(vty
, eigrp
);
206 /*Separate EIGRP configuration from the rest of the config*/
212 DEFUN_NOSH (router_eigrp
,
214 "router eigrp (1-65535)",
215 "Enable a routing process\n"
216 "Start EIGRP configuration\n"
217 "AS Number to use\n")
219 struct eigrp
*eigrp
= eigrp_get(argv
[2]->arg
);
220 VTY_PUSH_CONTEXT(EIGRP_NODE
, eigrp
);
225 DEFUN (no_router_eigrp
,
227 "no router eigrp (1-65535)",
230 "EIGRP configuration\n"
231 "AS number to use\n")
233 vty
->node
= CONFIG_NODE
;
237 eigrp
= eigrp_lookup();
239 vty_out(vty
, " EIGRP Routing Process not enabled\n");
243 if (eigrp
->AS
!= atoi(argv
[3]->arg
)) {
244 vty_out(vty
, "%% Attempting to deconfigure non-existent AS\n");
245 return CMD_WARNING_CONFIG_FAILED
;
248 eigrp_finish_final(eigrp
);
253 DEFPY (eigrp_router_id
,
255 "eigrp router-id A.B.C.D$addr",
256 "EIGRP specific commands\n"
257 "Router ID for this EIGRP process\n"
258 "EIGRP Router-ID in IP address format\n")
260 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
262 eigrp
->router_id_static
= addr
;
267 DEFPY (no_eigrp_router_id
,
268 no_eigrp_router_id_cmd
,
269 "no eigrp router-id [A.B.C.D$addr]",
271 "EIGRP specific commands\n"
272 "Router ID for this EIGRP process\n"
273 "EIGRP Router-ID in IP address format\n")
275 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
277 eigrp
->router_id_static
.s_addr
= 0;
282 DEFUN (eigrp_passive_interface
,
283 eigrp_passive_interface_cmd
,
284 "passive-interface IFNAME",
285 "Suppress routing updates on an interface\n"
286 "Interface to suppress on\n")
288 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
289 struct eigrp_interface
*ei
;
290 struct listnode
*node
;
291 char *ifname
= argv
[1]->arg
;
293 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
294 if (strcmp(ifname
, ei
->ifp
->name
) == 0) {
295 ei
->params
.passive_interface
= EIGRP_IF_PASSIVE
;
302 DEFUN (no_eigrp_passive_interface
,
303 no_eigrp_passive_interface_cmd
,
304 "no passive-interface IFNAME",
306 "Suppress routing updates on an interface\n"
307 "Interface to suppress on\n")
309 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
310 struct eigrp_interface
*ei
;
311 struct listnode
*node
;
312 char *ifname
= argv
[2]->arg
;
314 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
315 if (strcmp(ifname
, ei
->ifp
->name
) == 0) {
316 ei
->params
.passive_interface
= EIGRP_IF_ACTIVE
;
324 DEFUN (eigrp_timers_active
,
325 eigrp_timers_active_cmd
,
326 "timers active-time <(1-65535)|disabled>",
327 "Adjust routing timers\n"
328 "Time limit for active state\n"
329 "Active state time limit in minutes\n"
330 "Disable time limit for active state\n")
332 // struct eigrp *eigrp = vty->index;
338 DEFUN (no_eigrp_timers_active
,
339 no_eigrp_timers_active_cmd
,
340 "no timers active-time <(1-65535)|disabled>",
342 "Adjust routing timers\n"
343 "Time limit for active state\n"
344 "Active state time limit in minutes\n"
345 "Disable time limit for active state\n")
347 // struct eigrp *eigrp = vty->index;
354 DEFUN (eigrp_metric_weights
,
355 eigrp_metric_weights_cmd
,
356 "metric weights (0-255) (0-255) (0-255) (0-255) (0-255) ",
357 "Modify metrics and parameters for advertisement\n"
358 "Modify metric coefficients\n"
365 // struct eigrp *eigrp = vty->index;
371 DEFUN (no_eigrp_metric_weights
,
372 no_eigrp_metric_weights_cmd
,
373 "no metric weights <0-255> <0-255> <0-255> <0-255> <0-255>",
375 "Modify metrics and parameters for advertisement\n"
376 "Modify metric coefficients\n"
383 // struct eigrp *eigrp = vty->index;
390 DEFUN (eigrp_network
,
393 "Enable routing on an IP network\n"
394 "EIGRP network prefix\n")
396 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
400 (void)str2prefix(argv
[1]->arg
, &p
);
402 ret
= eigrp_network_set(eigrp
, &p
);
405 vty_out(vty
, "There is already same network statement.\n");
412 DEFUN (no_eigrp_network
,
413 no_eigrp_network_cmd
,
414 "no network A.B.C.D/M",
416 "Disable routing on an IP network\n"
417 "EIGRP network prefix\n")
419 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
423 (void)str2prefix(argv
[2]->arg
, &p
);
425 ret
= eigrp_network_unset(eigrp
, &p
);
428 vty_out(vty
, "Can't find specified network configuration.\n");
429 return CMD_WARNING_CONFIG_FAILED
;
435 DEFUN (eigrp_neighbor
,
438 "Specify a neighbor router\n"
439 "Neighbor address\n")
441 // struct eigrp *eigrp = vty->index;
446 DEFUN (no_eigrp_neighbor
,
447 no_eigrp_neighbor_cmd
,
448 "no neighbor A.B.C.D",
450 "Specify a neighbor router\n"
451 "Neighbor address\n")
453 // struct eigrp *eigrp = vty->index;
458 static void eigrp_vty_display_prefix_entry(struct vty
*vty
,
460 struct eigrp_prefix_entry
*pe
,
464 struct eigrp_nexthop_entry
*te
;
465 struct listnode
*node
;
467 for (ALL_LIST_ELEMENTS_RO(pe
->entries
, node
, te
)) {
470 & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG
)
471 == EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG
)
473 & EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG
)
474 == EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG
))) {
475 show_ip_eigrp_nexthop_entry(vty
, eigrp
, te
,
482 DEFPY (show_ip_eigrp_topology_all
,
483 show_ip_eigrp_topology_all_cmd
,
484 "show ip eigrp topology [all-links$all]",
487 "IP-EIGRP show commands\n"
488 "IP-EIGRP topology\n"
489 "Show all links in topology table\n")
492 struct eigrp_prefix_entry
*tn
;
493 struct route_node
*rn
;
495 eigrp
= eigrp_lookup();
497 vty_out(vty
, " EIGRP Routing Process not enabled\n");
501 show_ip_eigrp_topology_header(vty
, eigrp
);
503 for (rn
= route_top(eigrp
->topology_table
); rn
; rn
= route_next(rn
)) {
508 eigrp_vty_display_prefix_entry(vty
, eigrp
, tn
,
516 DEFPY (show_ip_eigrp_topology
,
517 show_ip_eigrp_topology_cmd
,
518 "show ip eigrp topology <A.B.C.D$address|A.B.C.D/M$prefix>",
521 "IP-EIGRP show commands\n"
522 "IP-EIGRP topology\n"
523 "For a specific address\n"
524 "For a specific prefix\n")
527 struct eigrp_prefix_entry
*tn
;
528 struct route_node
*rn
;
531 eigrp
= eigrp_lookup();
533 vty_out(vty
, " EIGRP Routing Process not enabled\n");
537 show_ip_eigrp_topology_header(vty
, eigrp
);
540 prefix_str
= address_str
;
542 if (str2prefix(prefix_str
, &cmp
) < 0) {
543 vty_out(vty
, "%% Malformed address\n");
547 rn
= route_node_match(eigrp
->topology_table
, &cmp
);
549 vty_out(vty
, "%% Network not in table\n");
554 vty_out(vty
, "%% Network not in table\n");
555 route_unlock_node(rn
);
560 eigrp_vty_display_prefix_entry(vty
, eigrp
, tn
, argc
== 5);
562 route_unlock_node(rn
);
566 DEFUN (show_ip_eigrp_interfaces
,
567 show_ip_eigrp_interfaces_cmd
,
568 "show ip eigrp interfaces [IFNAME] [detail]",
571 "IP-EIGRP show commands\n"
572 "IP-EIGRP interfaces\n"
573 "Interface name to look at\n"
574 "Detailed information\n")
576 struct eigrp_interface
*ei
;
578 struct listnode
*node
;
581 const char *ifname
= NULL
;
583 eigrp
= eigrp_lookup();
585 vty_out(vty
, "EIGRP Routing Process not enabled\n");
589 if (argv_find(argv
, argc
, "IFNAME", &idx
))
590 ifname
= argv
[idx
]->arg
;
592 if (argv_find(argv
, argc
, "detail", &idx
))
596 show_ip_eigrp_interface_header(vty
, eigrp
);
598 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
599 if (!ifname
|| strcmp(ei
->ifp
->name
, ifname
) == 0) {
600 show_ip_eigrp_interface_sub(vty
, eigrp
, ei
);
602 show_ip_eigrp_interface_detail(vty
, eigrp
, ei
);
609 DEFUN (show_ip_eigrp_neighbors
,
610 show_ip_eigrp_neighbors_cmd
,
611 "show ip eigrp neighbors [IFNAME] [detail]",
614 "IP-EIGRP show commands\n"
615 "IP-EIGRP neighbors\n"
616 "Interface to show on\n"
617 "Detailed Information\n")
620 struct eigrp_interface
*ei
;
621 struct listnode
*node
, *node2
, *nnode2
;
622 struct eigrp_neighbor
*nbr
;
625 const char *ifname
= NULL
;
627 eigrp
= eigrp_lookup();
629 vty_out(vty
, " EIGRP Routing Process not enabled\n");
633 if (argv_find(argv
, argc
, "IFNAME", &idx
))
634 ifname
= argv
[idx
]->arg
;
636 detail
= (argv_find(argv
, argc
, "detail", &idx
));
638 show_ip_eigrp_neighbor_header(vty
, eigrp
);
640 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
641 if (!ifname
|| strcmp(ei
->ifp
->name
, ifname
) == 0) {
642 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
643 if (detail
|| (nbr
->state
== EIGRP_NEIGHBOR_UP
))
644 show_ip_eigrp_neighbor_sub(vty
, nbr
,
653 DEFUN (eigrp_if_delay
,
655 "delay (1-16777215)",
656 "Specify interface throughput delay\n"
657 "Throughput delay (tens of microseconds)\n")
659 VTY_DECLVAR_CONTEXT(interface
, ifp
);
660 struct eigrp_interface
*ei
= ifp
->info
;
664 eigrp
= eigrp_lookup();
666 vty_out(vty
, " EIGRP Routing Process not enabled\n");
672 vty_out(vty
, " EIGRP not configured on this interface\n");
675 delay
= atoi(argv
[1]->arg
);
677 ei
->params
.delay
= delay
;
683 DEFUN (no_eigrp_if_delay
,
684 no_eigrp_if_delay_cmd
,
685 "no delay (1-16777215)",
687 "Specify interface throughput delay\n"
688 "Throughput delay (tens of microseconds)\n")
690 VTY_DECLVAR_CONTEXT(interface
, ifp
);
691 struct eigrp_interface
*ei
= ifp
->info
;
694 eigrp
= eigrp_lookup();
696 vty_out(vty
, " EIGRP Routing Process not enabled\n");
701 vty_out(vty
, " EIGRP not configured on this interface\n");
705 ei
->params
.delay
= EIGRP_DELAY_DEFAULT
;
711 DEFPY (eigrp_if_bandwidth
,
712 eigrp_if_bandwidth_cmd
,
713 "eigrp bandwidth (1-10000000)$bw",
714 "EIGRP specific commands\n"
715 "Set bandwidth informational parameter\n"
716 "Bandwidth in kilobits\n")
718 VTY_DECLVAR_CONTEXT(interface
, ifp
);
719 struct eigrp_interface
*ei
= ifp
->info
;
722 eigrp
= eigrp_lookup();
724 vty_out(vty
, " EIGRP Routing Process not enabled\n");
729 vty_out(vty
, " EIGRP not configured on this interface\n");
733 ei
->params
.bandwidth
= bw
;
739 DEFUN (no_eigrp_if_bandwidth
,
740 no_eigrp_if_bandwidth_cmd
,
741 "no eigrp bandwidth [(1-10000000)]",
743 "EIGRP specific commands\n"
744 "Set bandwidth informational parameter\n"
745 "Bandwidth in kilobits\n")
747 VTY_DECLVAR_CONTEXT(interface
, ifp
);
748 struct eigrp_interface
*ei
= ifp
->info
;
751 eigrp
= eigrp_lookup();
753 vty_out(vty
, " EIGRP Routing Process not enabled\n");
758 vty_out(vty
, " EIGRP not configured on this interface\n");
762 ei
->params
.bandwidth
= EIGRP_BANDWIDTH_DEFAULT
;
768 DEFUN (eigrp_if_ip_hellointerval
,
769 eigrp_if_ip_hellointerval_cmd
,
770 "ip hello-interval eigrp (1-65535)",
771 "Interface Internet Protocol config commands\n"
772 "Configures EIGRP hello interval\n"
773 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
774 "Seconds between hello transmissions\n")
776 VTY_DECLVAR_CONTEXT(interface
, ifp
);
777 struct eigrp_interface
*ei
= ifp
->info
;
781 eigrp
= eigrp_lookup();
783 vty_out(vty
, " EIGRP Routing Process not enabled\n");
788 vty_out(vty
, " EIGRP not configured on this interface\n");
792 hello
= atoi(argv
[3]->arg
);
794 ei
->params
.v_hello
= hello
;
799 DEFUN (no_eigrp_if_ip_hellointerval
,
800 no_eigrp_if_ip_hellointerval_cmd
,
801 "no ip hello-interval eigrp [(1-65535)]",
803 "Interface Internet Protocol config commands\n"
804 "Configures EIGRP hello interval\n"
805 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
806 "Seconds between hello transmissions\n")
808 VTY_DECLVAR_CONTEXT(interface
, ifp
);
809 struct eigrp_interface
*ei
= ifp
->info
;
812 eigrp
= eigrp_lookup();
814 vty_out(vty
, " EIGRP Routing Process not enabled\n");
819 vty_out(vty
, " EIGRP not configured on this interface\n");
823 ei
->params
.v_hello
= EIGRP_HELLO_INTERVAL_DEFAULT
;
825 THREAD_TIMER_OFF(ei
->t_hello
);
826 thread_add_timer(master
, eigrp_hello_timer
, ei
, 1, &ei
->t_hello
);
831 DEFUN (eigrp_if_ip_holdinterval
,
832 eigrp_if_ip_holdinterval_cmd
,
833 "ip hold-time eigrp (1-65535)",
834 "Interface Internet Protocol config commands\n"
835 "Configures EIGRP IPv4 hold time\n"
836 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
837 "Seconds before neighbor is considered down\n")
839 VTY_DECLVAR_CONTEXT(interface
, ifp
);
840 struct eigrp_interface
*ei
= ifp
->info
;
844 eigrp
= eigrp_lookup();
846 vty_out(vty
, " EIGRP Routing Process not enabled\n");
851 vty_out(vty
, " EIGRP not configured on this interface\n");
855 hold
= atoi(argv
[3]->arg
);
857 ei
->params
.v_wait
= hold
;
862 DEFUN (eigrp_ip_summary_address
,
863 eigrp_ip_summary_address_cmd
,
864 "ip summary-address eigrp (1-65535) A.B.C.D/M",
865 "Interface Internet Protocol config commands\n"
866 "Perform address summarization\n"
867 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
869 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
871 // VTY_DECLVAR_CONTEXT(interface, ifp);
875 eigrp
= eigrp_lookup();
877 vty_out(vty
, " EIGRP Routing Process not enabled\n");
881 // AS = atoi (argv[3]->arg);
888 DEFUN (no_eigrp_ip_summary_address
,
889 no_eigrp_ip_summary_address_cmd
,
890 "no ip summary-address eigrp (1-65535) A.B.C.D/M",
892 "Interface Internet Protocol config commands\n"
893 "Perform address summarization\n"
894 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
896 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
898 // VTY_DECLVAR_CONTEXT(interface, ifp);
902 eigrp
= eigrp_lookup();
904 vty_out(vty
, " EIGRP Routing Process not enabled\n");
908 // AS = atoi (argv[4]->arg);
915 DEFUN (no_eigrp_if_ip_holdinterval
,
916 no_eigrp_if_ip_holdinterval_cmd
,
917 "no ip hold-time eigrp",
919 "Interface Internet Protocol config commands\n"
920 "Configures EIGRP hello interval\n"
921 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n")
923 VTY_DECLVAR_CONTEXT(interface
, ifp
);
924 struct eigrp_interface
*ei
= ifp
->info
;
927 eigrp
= eigrp_lookup();
929 vty_out(vty
, " EIGRP Routing Process not enabled\n");
934 vty_out(vty
, " EIGRP not configured on this interface\n");
938 ei
->params
.v_wait
= EIGRP_HOLD_INTERVAL_DEFAULT
;
943 static int str2auth_type(const char *str
, struct eigrp_interface
*ei
)
947 return CMD_WARNING_CONFIG_FAILED
;
949 if (strncmp(str
, "md5", 3) == 0) {
950 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_MD5
;
952 } else if (strncmp(str
, "hmac-sha-256", 12) == 0) {
953 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_SHA256
;
957 return CMD_WARNING_CONFIG_FAILED
;
960 DEFUN (eigrp_authentication_mode
,
961 eigrp_authentication_mode_cmd
,
962 "ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
963 "Interface Internet Protocol config commands\n"
964 "Authentication subcommands\n"
966 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
967 "Autonomous system number\n"
968 "Keyed message digest\n"
969 "HMAC SHA256 algorithm \n")
971 VTY_DECLVAR_CONTEXT(interface
, ifp
);
972 struct eigrp_interface
*ei
= ifp
->info
;
975 eigrp
= eigrp_lookup();
977 vty_out(vty
, " EIGRP Routing Process not enabled\n");
982 vty_out(vty
, " EIGRP not configured on this interface\n");
986 // if(strncmp(argv[2], "md5",3))
987 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_MD5;
988 // else if(strncmp(argv[2], "hmac-sha-256",12))
989 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_SHA256;
991 return str2auth_type(argv
[5]->arg
, ei
);
994 DEFUN (no_eigrp_authentication_mode
,
995 no_eigrp_authentication_mode_cmd
,
996 "no ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
998 "Interface Internet Protocol config commands\n"
999 "Authentication subcommands\n"
1001 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
1002 "Autonomous system number\n"
1003 "Keyed message digest\n"
1004 "HMAC SHA256 algorithm \n")
1006 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1007 struct eigrp_interface
*ei
= ifp
->info
;
1008 struct eigrp
*eigrp
;
1010 eigrp
= eigrp_lookup();
1011 if (eigrp
== NULL
) {
1012 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1017 vty_out(vty
, " EIGRP not configured on this interface\n");
1021 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_NONE
;
1026 DEFPY (eigrp_authentication_keychain
,
1027 eigrp_authentication_keychain_cmd
,
1028 "[no] ip authentication key-chain eigrp (1-65535)$as WORD$name",
1030 "Interface Internet Protocol config commands\n"
1031 "Authentication subcommands\n"
1033 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
1034 "Autonomous system number\n"
1035 "Name of key-chain\n")
1037 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1038 struct eigrp_interface
*ei
= ifp
->info
;
1039 struct eigrp
*eigrp
;
1040 struct keychain
*keychain
;
1042 eigrp
= eigrp_lookup();
1043 if (eigrp
== NULL
) {
1044 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1049 vty_out(vty
, " EIGRP not configured on this interface\n");
1054 if ((ei
->params
.auth_keychain
!= NULL
)
1055 && (strcmp(ei
->params
.auth_keychain
, name
) == 0)) {
1056 free(ei
->params
.auth_keychain
);
1057 ei
->params
.auth_keychain
= NULL
;
1060 "Key chain with specified name not configured on interface\n");
1064 keychain
= keychain_lookup(name
);
1065 if (keychain
!= NULL
) {
1066 if (ei
->params
.auth_keychain
) {
1067 free(ei
->params
.auth_keychain
);
1068 ei
->params
.auth_keychain
= strdup(keychain
->name
);
1070 ei
->params
.auth_keychain
= strdup(keychain
->name
);
1073 "Key chain with specified name not found\n");
1074 return CMD_WARNING_CONFIG_FAILED
;
1080 DEFUN (eigrp_redistribute_source_metric
,
1081 eigrp_redistribute_source_metric_cmd
,
1082 "redistribute " FRR_REDIST_STR_EIGRPD
1083 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
1085 FRR_REDIST_HELP_STR_EIGRPD
1086 "Metric for redistributed routes\n"
1087 "Bandwidth metric in Kbits per second\n"
1088 "EIGRP delay metric, in 10 microsecond units\n"
1089 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1090 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1091 "EIGRP MTU of the path\n")
1093 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1094 struct eigrp_metrics metrics_from_command
= {0};
1098 /* Get distribute source. */
1099 argv_find(argv
, argc
, "redistribute", &idx
);
1100 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1102 vty_out(vty
, "%% Invalid route type\n");
1103 return CMD_WARNING_CONFIG_FAILED
;
1106 /* Get metrics values */
1108 return eigrp_redistribute_set(eigrp
, source
, metrics_from_command
);
1111 DEFUN (no_eigrp_redistribute_source_metric
,
1112 no_eigrp_redistribute_source_metric_cmd
,
1113 "no redistribute " FRR_REDIST_STR_EIGRPD
1114 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
1117 FRR_REDIST_HELP_STR_EIGRPD
1118 "Metric for redistributed routes\n"
1119 "Bandwidth metric in Kbits per second\n"
1120 "EIGRP delay metric, in 10 microsecond units\n"
1121 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1122 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1123 "EIGRP MTU of the path\n")
1125 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1129 /* Get distribute source. */
1130 argv_find(argv
, argc
, "redistribute", &idx
);
1131 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1133 vty_out(vty
, "%% Invalid route type\n");
1134 return CMD_WARNING_CONFIG_FAILED
;
1137 /* Get metrics values */
1139 return eigrp_redistribute_unset(eigrp
, source
);
1142 DEFUN (eigrp_variance
,
1145 "Control load balancing variance\n"
1146 "Metric variance multiplier\n")
1148 struct eigrp
*eigrp
;
1151 eigrp
= eigrp_lookup();
1152 if (eigrp
== NULL
) {
1153 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1156 variance
= atoi(argv
[1]->arg
);
1158 eigrp
->variance
= variance
;
1165 DEFUN (no_eigrp_variance
,
1166 no_eigrp_variance_cmd
,
1167 "no variance (1-128)",
1169 "Control load balancing variance\n"
1170 "Metric variance multiplier\n")
1172 struct eigrp
*eigrp
;
1173 eigrp
= eigrp_lookup();
1174 if (eigrp
== NULL
) {
1175 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1179 eigrp
->variance
= EIGRP_VARIANCE_DEFAULT
;
1186 DEFUN (eigrp_maximum_paths
,
1187 eigrp_maximum_paths_cmd
,
1188 "maximum-paths (1-32)",
1189 "Forward packets over multiple paths\n"
1190 "Number of paths\n")
1192 struct eigrp
*eigrp
;
1195 eigrp
= eigrp_lookup();
1196 if (eigrp
== NULL
) {
1197 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1201 max
= atoi(argv
[1]->arg
);
1203 eigrp
->max_paths
= max
;
1210 DEFUN (no_eigrp_maximum_paths
,
1211 no_eigrp_maximum_paths_cmd
,
1212 "no maximum-paths <1-32>",
1214 "Forward packets over multiple paths\n"
1215 "Number of paths\n")
1217 struct eigrp
*eigrp
;
1219 eigrp
= eigrp_lookup();
1220 if (eigrp
== NULL
) {
1221 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1225 eigrp
->max_paths
= EIGRP_MAX_PATHS_DEFAULT
;
1233 * Execute hard restart for all neighbors
1235 DEFUN (clear_ip_eigrp_neighbors
,
1236 clear_ip_eigrp_neighbors_cmd
,
1237 "clear ip eigrp neighbors",
1241 "Clear IP-EIGRP neighbors\n")
1243 struct eigrp
*eigrp
;
1244 struct eigrp_interface
*ei
;
1245 struct listnode
*node
, *node2
, *nnode2
;
1246 struct eigrp_neighbor
*nbr
;
1248 /* Check if eigrp process is enabled */
1249 eigrp
= eigrp_lookup();
1250 if (eigrp
== NULL
) {
1251 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1255 /* iterate over all eigrp interfaces */
1256 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
1257 /* send Goodbye Hello */
1258 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1260 /* iterate over all neighbors on eigrp interface */
1261 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1262 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1264 "Neighbor %s (%s) is down: manually cleared",
1265 inet_ntoa(nbr
->src
),
1266 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1268 vty_time_print(vty
, 0);
1270 "Neighbor %s (%s) is down: manually cleared\n",
1271 inet_ntoa(nbr
->src
),
1272 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1275 /* set neighbor to DOWN */
1276 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1277 /* delete neighbor */
1278 eigrp_nbr_delete(nbr
);
1287 * Execute hard restart for all neighbors on interface
1289 DEFUN (clear_ip_eigrp_neighbors_int
,
1290 clear_ip_eigrp_neighbors_int_cmd
,
1291 "clear ip eigrp neighbors IFNAME",
1295 "Clear IP-EIGRP neighbors\n"
1296 "Interface's name\n")
1298 struct eigrp
*eigrp
;
1299 struct eigrp_interface
*ei
;
1300 struct listnode
*node2
, *nnode2
;
1301 struct eigrp_neighbor
*nbr
;
1304 /* Check if eigrp process is enabled */
1305 eigrp
= eigrp_lookup();
1306 if (eigrp
== NULL
) {
1307 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1311 /* lookup interface by specified name */
1312 argv_find(argv
, argc
, "IFNAME", &idx
);
1313 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[idx
]->arg
);
1315 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[idx
]->arg
);
1319 /* send Goodbye Hello */
1320 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1322 /* iterate over all neighbors on eigrp interface */
1323 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1324 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1325 zlog_debug("Neighbor %s (%s) is down: manually cleared",
1326 inet_ntoa(nbr
->src
),
1327 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1329 vty_time_print(vty
, 0);
1331 "Neighbor %s (%s) is down: manually cleared\n",
1332 inet_ntoa(nbr
->src
),
1333 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1336 /* set neighbor to DOWN */
1337 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1338 /* delete neighbor */
1339 eigrp_nbr_delete(nbr
);
1347 * Execute hard restart for neighbor specified by IP
1349 DEFUN (clear_ip_eigrp_neighbors_IP
,
1350 clear_ip_eigrp_neighbors_IP_cmd
,
1351 "clear ip eigrp neighbors A.B.C.D",
1355 "Clear IP-EIGRP neighbors\n"
1356 "IP-EIGRP neighbor address\n")
1358 struct eigrp
*eigrp
;
1359 struct eigrp_neighbor
*nbr
;
1360 struct in_addr nbr_addr
;
1362 if (!inet_aton(argv
[4]->arg
, &nbr_addr
)) {
1363 vty_out(vty
, "Unable to parse %s", argv
[4]->arg
);
1367 /* Check if eigrp process is enabled */
1368 eigrp
= eigrp_lookup();
1369 if (eigrp
== NULL
) {
1370 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1374 /* lookup neighbor in whole process */
1375 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1377 /* if neighbor doesn't exists, notify user and exit */
1379 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1383 /* execute hard reset on neighbor */
1384 eigrp_nbr_hard_restart(nbr
, vty
);
1390 * Execute graceful restart for all neighbors
1392 DEFUN (clear_ip_eigrp_neighbors_soft
,
1393 clear_ip_eigrp_neighbors_soft_cmd
,
1394 "clear ip eigrp neighbors soft",
1398 "Clear IP-EIGRP neighbors\n"
1399 "Resync with peers without adjacency reset\n")
1401 struct eigrp
*eigrp
;
1403 /* Check if eigrp process is enabled */
1404 eigrp
= eigrp_lookup();
1405 if (eigrp
== NULL
) {
1406 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1410 /* execute graceful restart on all neighbors */
1411 eigrp_update_send_process_GR(eigrp
, EIGRP_GR_MANUAL
, vty
);
1417 * Execute graceful restart for all neighbors on interface
1419 DEFUN (clear_ip_eigrp_neighbors_int_soft
,
1420 clear_ip_eigrp_neighbors_int_soft_cmd
,
1421 "clear ip eigrp neighbors IFNAME soft",
1425 "Clear IP-EIGRP neighbors\n"
1426 "Interface's name\n"
1427 "Resync with peer without adjacency reset\n")
1429 struct eigrp
*eigrp
;
1430 struct eigrp_interface
*ei
;
1432 /* Check if eigrp process is enabled */
1433 eigrp
= eigrp_lookup();
1434 if (eigrp
== NULL
) {
1435 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1439 /* lookup interface by specified name */
1440 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[4]->arg
);
1442 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[4]->arg
);
1446 /* execute graceful restart for all neighbors on interface */
1447 eigrp_update_send_interface_GR(ei
, EIGRP_GR_MANUAL
, vty
);
1452 * Execute graceful restart for neighbor specified by IP
1454 DEFUN (clear_ip_eigrp_neighbors_IP_soft
,
1455 clear_ip_eigrp_neighbors_IP_soft_cmd
,
1456 "clear ip eigrp neighbors A.B.C.D soft",
1460 "Clear IP-EIGRP neighbors\n"
1461 "IP-EIGRP neighbor address\n"
1462 "Resync with peer without adjacency reset\n")
1464 struct eigrp
*eigrp
;
1465 struct eigrp_neighbor
*nbr
;
1466 struct in_addr nbr_addr
;
1468 if (!inet_aton(argv
[4]->arg
, &nbr_addr
)) {
1469 vty_out(vty
, "Unable to parse: %s", argv
[4]->arg
);
1473 /* Check if eigrp process is enabled */
1474 eigrp
= eigrp_lookup();
1475 if (eigrp
== NULL
) {
1476 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1480 /* lookup neighbor in whole process */
1481 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1483 /* if neighbor doesn't exists, notify user and exit */
1485 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1489 /* execute graceful restart on neighbor */
1490 eigrp_update_send_GR(nbr
, EIGRP_GR_MANUAL
, vty
);
1495 static struct cmd_node eigrp_node
= {EIGRP_NODE
, "%s(config-router)# ", 1};
1497 /* Save EIGRP configuration */
1498 static int eigrp_config_write(struct vty
*vty
)
1500 struct eigrp
*eigrp
;
1504 eigrp
= eigrp_lookup();
1505 if (eigrp
!= NULL
) {
1506 /* Writes 'router eigrp' section to config */
1507 config_write_eigrp_router(vty
, eigrp
);
1509 /* Interface config print */
1510 config_write_interfaces(vty
, eigrp
);
1512 // /* static neighbor print. */
1513 // config_write_eigrp_nbr_nbma (vty, eigrp);
1515 // /* Virtual-Link print. */
1516 // config_write_virtual_link (vty, eigrp);
1518 // /* Default metric configuration. */
1519 // config_write_eigrp_default_metric (vty, eigrp);
1521 // /* Distribute-list and default-information print. */
1522 // config_write_eigrp_distribute (vty, eigrp);
1524 // /* Distance configuration. */
1525 // config_write_eigrp_distance (vty, eigrp)
1531 void eigrp_vty_show_init(void)
1533 install_element(VIEW_NODE
, &show_ip_eigrp_interfaces_cmd
);
1535 install_element(VIEW_NODE
, &show_ip_eigrp_neighbors_cmd
);
1537 install_element(VIEW_NODE
, &show_ip_eigrp_topology_cmd
);
1538 install_element(VIEW_NODE
, &show_ip_eigrp_topology_all_cmd
);
1541 /* eigrpd's interface node. */
1542 static struct cmd_node eigrp_interface_node
= {INTERFACE_NODE
,
1543 "%s(config-if)# ", 1};
1545 void eigrp_vty_if_init(void)
1547 install_node(&eigrp_interface_node
, eigrp_write_interface
);
1550 /* Delay and bandwidth configuration commands*/
1551 install_element(INTERFACE_NODE
, &eigrp_if_delay_cmd
);
1552 install_element(INTERFACE_NODE
, &no_eigrp_if_delay_cmd
);
1553 install_element(INTERFACE_NODE
, &eigrp_if_bandwidth_cmd
);
1554 install_element(INTERFACE_NODE
, &no_eigrp_if_bandwidth_cmd
);
1556 /*Hello-interval and hold-time interval configuration commands*/
1557 install_element(INTERFACE_NODE
, &eigrp_if_ip_holdinterval_cmd
);
1558 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_holdinterval_cmd
);
1559 install_element(INTERFACE_NODE
, &eigrp_if_ip_hellointerval_cmd
);
1560 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_hellointerval_cmd
);
1562 /* "Authentication configuration commands */
1563 install_element(INTERFACE_NODE
, &eigrp_authentication_mode_cmd
);
1564 install_element(INTERFACE_NODE
, &no_eigrp_authentication_mode_cmd
);
1565 install_element(INTERFACE_NODE
, &eigrp_authentication_keychain_cmd
);
1567 /*EIGRP Summarization commands*/
1568 install_element(INTERFACE_NODE
, &eigrp_ip_summary_address_cmd
);
1569 install_element(INTERFACE_NODE
, &no_eigrp_ip_summary_address_cmd
);
1572 static void eigrp_vty_zebra_init(void)
1574 install_element(EIGRP_NODE
, &eigrp_redistribute_source_metric_cmd
);
1575 install_element(EIGRP_NODE
, &no_eigrp_redistribute_source_metric_cmd
);
1578 /* Install EIGRP related vty commands. */
1579 void eigrp_vty_init(void)
1581 install_node(&eigrp_node
, eigrp_config_write
);
1583 install_default(EIGRP_NODE
);
1585 install_element(CONFIG_NODE
, &router_eigrp_cmd
);
1586 install_element(CONFIG_NODE
, &no_router_eigrp_cmd
);
1587 install_element(EIGRP_NODE
, &eigrp_network_cmd
);
1588 install_element(EIGRP_NODE
, &no_eigrp_network_cmd
);
1589 install_element(EIGRP_NODE
, &eigrp_variance_cmd
);
1590 install_element(EIGRP_NODE
, &no_eigrp_variance_cmd
);
1591 install_element(EIGRP_NODE
, &eigrp_router_id_cmd
);
1592 install_element(EIGRP_NODE
, &no_eigrp_router_id_cmd
);
1593 install_element(EIGRP_NODE
, &eigrp_passive_interface_cmd
);
1594 install_element(EIGRP_NODE
, &no_eigrp_passive_interface_cmd
);
1595 install_element(EIGRP_NODE
, &eigrp_timers_active_cmd
);
1596 install_element(EIGRP_NODE
, &no_eigrp_timers_active_cmd
);
1597 install_element(EIGRP_NODE
, &eigrp_metric_weights_cmd
);
1598 install_element(EIGRP_NODE
, &no_eigrp_metric_weights_cmd
);
1599 install_element(EIGRP_NODE
, &eigrp_maximum_paths_cmd
);
1600 install_element(EIGRP_NODE
, &no_eigrp_maximum_paths_cmd
);
1601 install_element(EIGRP_NODE
, &eigrp_neighbor_cmd
);
1602 install_element(EIGRP_NODE
, &no_eigrp_neighbor_cmd
);
1604 /* commands for manual hard restart */
1605 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_cmd
);
1606 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_cmd
);
1607 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_cmd
);
1608 /* commands for manual graceful restart */
1609 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_soft_cmd
);
1610 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_soft_cmd
);
1611 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_soft_cmd
);
1613 eigrp_vty_zebra_init();