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 DEFUN (eigrp_if_bandwidth
,
665 eigrp_if_bandwidth_cmd
,
666 "eigrp bandwidth (1-10000000)",
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
;
676 eigrp
= eigrp_lookup();
678 vty_out(vty
, " EIGRP Routing Process not enabled\n");
683 vty_out(vty
, " EIGRP not configured on this interface\n");
687 bandwidth
= atoi(argv
[1]->arg
);
689 ei
->params
.bandwidth
= bandwidth
;
695 DEFUN (no_eigrp_if_bandwidth
,
696 no_eigrp_if_bandwidth_cmd
,
697 "no eigrp bandwidth [(1-10000000)]",
699 "EIGRP specific commands\n"
700 "Set bandwidth informational parameter\n"
701 "Bandwidth in kilobits\n")
703 VTY_DECLVAR_CONTEXT(interface
, ifp
);
704 struct eigrp_interface
*ei
= ifp
->info
;
707 eigrp
= eigrp_lookup();
709 vty_out(vty
, " EIGRP Routing Process not enabled\n");
714 vty_out(vty
, " EIGRP not configured on this interface\n");
718 ei
->params
.bandwidth
= EIGRP_BANDWIDTH_DEFAULT
;
724 DEFUN (eigrp_if_ip_hellointerval
,
725 eigrp_if_ip_hellointerval_cmd
,
726 "ip hello-interval eigrp (1-65535)",
727 "Interface Internet Protocol config commands\n"
728 "Configures EIGRP hello interval\n"
729 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
730 "Seconds between hello transmissions\n")
732 VTY_DECLVAR_CONTEXT(interface
, ifp
);
733 struct eigrp_interface
*ei
= ifp
->info
;
737 eigrp
= eigrp_lookup();
739 vty_out(vty
, " EIGRP Routing Process not enabled\n");
744 vty_out(vty
, " EIGRP not configured on this interface\n");
748 hello
= atoi(argv
[3]->arg
);
750 ei
->params
.v_hello
= hello
;
755 DEFUN (no_eigrp_if_ip_hellointerval
,
756 no_eigrp_if_ip_hellointerval_cmd
,
757 "no ip hello-interval eigrp [(1-65535)]",
759 "Interface Internet Protocol config commands\n"
760 "Configures EIGRP hello interval\n"
761 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
762 "Seconds between hello transmissions\n")
764 VTY_DECLVAR_CONTEXT(interface
, ifp
);
765 struct eigrp_interface
*ei
= ifp
->info
;
768 eigrp
= eigrp_lookup();
770 vty_out(vty
, " EIGRP Routing Process not enabled\n");
775 vty_out(vty
, " EIGRP not configured on this interface\n");
779 ei
->params
.v_hello
= EIGRP_HELLO_INTERVAL_DEFAULT
;
781 THREAD_TIMER_OFF(ei
->t_hello
);
782 thread_add_timer(master
, eigrp_hello_timer
, ei
, 1, &ei
->t_hello
);
787 DEFUN (eigrp_if_ip_holdinterval
,
788 eigrp_if_ip_holdinterval_cmd
,
789 "ip hold-time eigrp (1-65535)",
790 "Interface Internet Protocol config commands\n"
791 "Configures EIGRP IPv4 hold time\n"
792 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
793 "Seconds before neighbor is considered down\n")
795 VTY_DECLVAR_CONTEXT(interface
, ifp
);
796 struct eigrp_interface
*ei
= ifp
->info
;
800 eigrp
= eigrp_lookup();
802 vty_out(vty
, " EIGRP Routing Process not enabled\n");
807 vty_out(vty
, " EIGRP not configured on this interface\n");
811 hold
= atoi(argv
[3]->arg
);
813 ei
->params
.v_wait
= hold
;
818 DEFUN (eigrp_ip_summary_address
,
819 eigrp_ip_summary_address_cmd
,
820 "ip summary-address eigrp (1-65535) A.B.C.D/M",
821 "Interface Internet Protocol config commands\n"
822 "Perform address summarization\n"
823 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
825 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
827 // VTY_DECLVAR_CONTEXT(interface, ifp);
831 eigrp
= eigrp_lookup();
833 vty_out(vty
, " EIGRP Routing Process not enabled\n");
837 // AS = atoi (argv[3]->arg);
844 DEFUN (no_eigrp_ip_summary_address
,
845 no_eigrp_ip_summary_address_cmd
,
846 "no ip summary-address eigrp (1-65535) A.B.C.D/M",
848 "Interface Internet Protocol config commands\n"
849 "Perform address summarization\n"
850 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
852 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
854 // VTY_DECLVAR_CONTEXT(interface, ifp);
858 eigrp
= eigrp_lookup();
860 vty_out(vty
, " EIGRP Routing Process not enabled\n");
864 // AS = atoi (argv[4]->arg);
871 DEFUN (no_eigrp_if_ip_holdinterval
,
872 no_eigrp_if_ip_holdinterval_cmd
,
873 "no ip hold-time eigrp",
875 "Interface Internet Protocol config commands\n"
876 "Configures EIGRP hello interval\n"
877 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n")
879 VTY_DECLVAR_CONTEXT(interface
, ifp
);
880 struct eigrp_interface
*ei
= ifp
->info
;
883 eigrp
= eigrp_lookup();
885 vty_out(vty
, " EIGRP Routing Process not enabled\n");
890 vty_out(vty
, " EIGRP not configured on this interface\n");
894 ei
->params
.v_wait
= EIGRP_HOLD_INTERVAL_DEFAULT
;
899 static int str2auth_type(const char *str
, struct eigrp_interface
*ei
)
903 return CMD_WARNING_CONFIG_FAILED
;
905 if (strncmp(str
, "md5", 3) == 0) {
906 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_MD5
;
908 } else if (strncmp(str
, "hmac-sha-256", 12) == 0) {
909 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_SHA256
;
913 return CMD_WARNING_CONFIG_FAILED
;
916 DEFUN (eigrp_authentication_mode
,
917 eigrp_authentication_mode_cmd
,
918 "ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
919 "Interface Internet Protocol config commands\n"
920 "Authentication subcommands\n"
922 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
923 "Autonomous system number\n"
924 "Keyed message digest\n"
925 "HMAC SHA256 algorithm \n")
927 VTY_DECLVAR_CONTEXT(interface
, ifp
);
928 struct eigrp_interface
*ei
= ifp
->info
;
931 eigrp
= eigrp_lookup();
933 vty_out(vty
, " EIGRP Routing Process not enabled\n");
938 vty_out(vty
, " EIGRP not configured on this interface\n");
942 // if(strncmp(argv[2], "md5",3))
943 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_MD5;
944 // else if(strncmp(argv[2], "hmac-sha-256",12))
945 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_SHA256;
947 return str2auth_type(argv
[5]->arg
, ei
);
950 DEFUN (no_eigrp_authentication_mode
,
951 no_eigrp_authentication_mode_cmd
,
952 "no ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
954 "Interface Internet Protocol config commands\n"
955 "Authentication subcommands\n"
957 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
958 "Autonomous system number\n"
959 "Keyed message digest\n"
960 "HMAC SHA256 algorithm \n")
962 VTY_DECLVAR_CONTEXT(interface
, ifp
);
963 struct eigrp_interface
*ei
= ifp
->info
;
966 eigrp
= eigrp_lookup();
968 vty_out(vty
, " EIGRP Routing Process not enabled\n");
973 vty_out(vty
, " EIGRP not configured on this interface\n");
977 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_NONE
;
982 DEFPY (eigrp_authentication_keychain
,
983 eigrp_authentication_keychain_cmd
,
984 "[no] ip authentication key-chain eigrp (1-65535)$as WORD$name",
986 "Interface Internet Protocol config commands\n"
987 "Authentication subcommands\n"
989 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
990 "Autonomous system number\n"
991 "Name of key-chain\n")
993 VTY_DECLVAR_CONTEXT(interface
, ifp
);
994 struct eigrp_interface
*ei
= ifp
->info
;
996 struct keychain
*keychain
;
998 eigrp
= eigrp_lookup();
1000 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1005 vty_out(vty
, " EIGRP not configured on this interface\n");
1010 if ((ei
->params
.auth_keychain
!= NULL
)
1011 && (strcmp(ei
->params
.auth_keychain
, name
) == 0)) {
1012 free(ei
->params
.auth_keychain
);
1013 ei
->params
.auth_keychain
= NULL
;
1016 "Key chain with specified name not configured on interface\n");
1020 keychain
= keychain_lookup(name
);
1021 if (keychain
!= NULL
) {
1022 if (ei
->params
.auth_keychain
) {
1023 free(ei
->params
.auth_keychain
);
1024 ei
->params
.auth_keychain
= strdup(keychain
->name
);
1026 ei
->params
.auth_keychain
= strdup(keychain
->name
);
1029 "Key chain with specified name not found\n");
1030 return CMD_WARNING_CONFIG_FAILED
;
1036 DEFUN (eigrp_redistribute_source_metric
,
1037 eigrp_redistribute_source_metric_cmd
,
1038 "redistribute " FRR_REDIST_STR_EIGRPD
1039 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
1041 FRR_REDIST_HELP_STR_EIGRPD
1042 "Metric for redistributed routes\n"
1043 "Bandwidth metric in Kbits per second\n"
1044 "EIGRP delay metric, in 10 microsecond units\n"
1045 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1046 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1047 "EIGRP MTU of the path\n")
1049 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1050 struct eigrp_metrics metrics_from_command
= {0};
1054 /* Get distribute source. */
1055 argv_find(argv
, argc
, "redistribute", &idx
);
1056 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1058 vty_out(vty
, "%% Invalid route type\n");
1059 return CMD_WARNING_CONFIG_FAILED
;
1062 /* Get metrics values */
1064 return eigrp_redistribute_set(eigrp
, source
, metrics_from_command
);
1067 DEFUN (no_eigrp_redistribute_source_metric
,
1068 no_eigrp_redistribute_source_metric_cmd
,
1069 "no redistribute " FRR_REDIST_STR_EIGRPD
1070 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
1073 FRR_REDIST_HELP_STR_EIGRPD
1074 "Metric for redistributed routes\n"
1075 "Bandwidth metric in Kbits per second\n"
1076 "EIGRP delay metric, in 10 microsecond units\n"
1077 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1078 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1079 "EIGRP MTU of the path\n")
1081 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1085 /* Get distribute source. */
1086 argv_find(argv
, argc
, "redistribute", &idx
);
1087 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1089 vty_out(vty
, "%% Invalid route type\n");
1090 return CMD_WARNING_CONFIG_FAILED
;
1093 /* Get metrics values */
1095 return eigrp_redistribute_unset(eigrp
, source
);
1098 DEFUN (eigrp_variance
,
1101 "Control load balancing variance\n"
1102 "Metric variance multiplier\n")
1104 struct eigrp
*eigrp
;
1107 eigrp
= eigrp_lookup();
1108 if (eigrp
== NULL
) {
1109 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1112 variance
= atoi(argv
[1]->arg
);
1114 eigrp
->variance
= variance
;
1121 DEFUN (no_eigrp_variance
,
1122 no_eigrp_variance_cmd
,
1123 "no variance (1-128)",
1125 "Control load balancing variance\n"
1126 "Metric variance multiplier\n")
1128 struct eigrp
*eigrp
;
1129 eigrp
= eigrp_lookup();
1130 if (eigrp
== NULL
) {
1131 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1135 eigrp
->variance
= EIGRP_VARIANCE_DEFAULT
;
1142 DEFUN (eigrp_maximum_paths
,
1143 eigrp_maximum_paths_cmd
,
1144 "maximum-paths (1-32)",
1145 "Forward packets over multiple paths\n"
1146 "Number of paths\n")
1148 struct eigrp
*eigrp
;
1151 eigrp
= eigrp_lookup();
1152 if (eigrp
== NULL
) {
1153 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1157 max
= atoi(argv
[1]->arg
);
1159 eigrp
->max_paths
= max
;
1166 DEFUN (no_eigrp_maximum_paths
,
1167 no_eigrp_maximum_paths_cmd
,
1168 "no maximum-paths <1-32>",
1170 "Forward packets over multiple paths\n"
1171 "Number of paths\n")
1173 struct eigrp
*eigrp
;
1175 eigrp
= eigrp_lookup();
1176 if (eigrp
== NULL
) {
1177 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1181 eigrp
->max_paths
= EIGRP_MAX_PATHS_DEFAULT
;
1189 * Execute hard restart for all neighbors
1191 DEFUN (clear_ip_eigrp_neighbors
,
1192 clear_ip_eigrp_neighbors_cmd
,
1193 "clear ip eigrp neighbors",
1197 "Clear IP-EIGRP neighbors\n")
1199 struct eigrp
*eigrp
;
1200 struct eigrp_interface
*ei
;
1201 struct listnode
*node
, *node2
, *nnode2
;
1202 struct eigrp_neighbor
*nbr
;
1204 /* Check if eigrp process is enabled */
1205 eigrp
= eigrp_lookup();
1206 if (eigrp
== NULL
) {
1207 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1211 /* iterate over all eigrp interfaces */
1212 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
1213 /* send Goodbye Hello */
1214 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1216 /* iterate over all neighbors on eigrp interface */
1217 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1218 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1220 "Neighbor %s (%s) is down: manually cleared",
1221 inet_ntoa(nbr
->src
),
1222 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1224 vty_time_print(vty
, 0);
1226 "Neighbor %s (%s) is down: manually cleared\n",
1227 inet_ntoa(nbr
->src
),
1228 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1231 /* set neighbor to DOWN */
1232 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1233 /* delete neighbor */
1234 eigrp_nbr_delete(nbr
);
1243 * Execute hard restart for all neighbors on interface
1245 DEFUN (clear_ip_eigrp_neighbors_int
,
1246 clear_ip_eigrp_neighbors_int_cmd
,
1247 "clear ip eigrp neighbors IFNAME",
1251 "Clear IP-EIGRP neighbors\n"
1252 "Interface's name\n")
1254 struct eigrp
*eigrp
;
1255 struct eigrp_interface
*ei
;
1256 struct listnode
*node2
, *nnode2
;
1257 struct eigrp_neighbor
*nbr
;
1260 /* Check if eigrp process is enabled */
1261 eigrp
= eigrp_lookup();
1262 if (eigrp
== NULL
) {
1263 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1267 /* lookup interface by specified name */
1268 argv_find(argv
, argc
, "IFNAME", &idx
);
1269 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[idx
]->arg
);
1271 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[idx
]->arg
);
1275 /* send Goodbye Hello */
1276 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1278 /* iterate over all neighbors on eigrp interface */
1279 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1280 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1281 zlog_debug("Neighbor %s (%s) is down: manually cleared",
1282 inet_ntoa(nbr
->src
),
1283 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1285 vty_time_print(vty
, 0);
1287 "Neighbor %s (%s) is down: manually cleared\n",
1288 inet_ntoa(nbr
->src
),
1289 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1292 /* set neighbor to DOWN */
1293 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1294 /* delete neighbor */
1295 eigrp_nbr_delete(nbr
);
1303 * Execute hard restart for neighbor specified by IP
1305 DEFUN (clear_ip_eigrp_neighbors_IP
,
1306 clear_ip_eigrp_neighbors_IP_cmd
,
1307 "clear ip eigrp neighbors A.B.C.D",
1311 "Clear IP-EIGRP neighbors\n"
1312 "IP-EIGRP neighbor address\n")
1314 struct eigrp
*eigrp
;
1315 struct eigrp_neighbor
*nbr
;
1316 struct in_addr nbr_addr
;
1318 if (!inet_aton(argv
[4]->arg
, &nbr_addr
)) {
1319 vty_out(vty
, "Unable to parse %s", argv
[4]->arg
);
1323 /* Check if eigrp process is enabled */
1324 eigrp
= eigrp_lookup();
1325 if (eigrp
== NULL
) {
1326 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1330 /* lookup neighbor in whole process */
1331 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1333 /* if neighbor doesn't exists, notify user and exit */
1335 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1339 /* execute hard reset on neighbor */
1340 eigrp_nbr_hard_restart(nbr
, vty
);
1346 * Execute graceful restart for all neighbors
1348 DEFUN (clear_ip_eigrp_neighbors_soft
,
1349 clear_ip_eigrp_neighbors_soft_cmd
,
1350 "clear ip eigrp neighbors soft",
1354 "Clear IP-EIGRP neighbors\n"
1355 "Resync with peers without adjacency reset\n")
1357 struct eigrp
*eigrp
;
1359 /* Check if eigrp process is enabled */
1360 eigrp
= eigrp_lookup();
1361 if (eigrp
== NULL
) {
1362 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1366 /* execute graceful restart on all neighbors */
1367 eigrp_update_send_process_GR(eigrp
, EIGRP_GR_MANUAL
, vty
);
1373 * Execute graceful restart for all neighbors on interface
1375 DEFUN (clear_ip_eigrp_neighbors_int_soft
,
1376 clear_ip_eigrp_neighbors_int_soft_cmd
,
1377 "clear ip eigrp neighbors IFNAME soft",
1381 "Clear IP-EIGRP neighbors\n"
1382 "Interface's name\n"
1383 "Resync with peer without adjacency reset\n")
1385 struct eigrp
*eigrp
;
1386 struct eigrp_interface
*ei
;
1388 /* Check if eigrp process is enabled */
1389 eigrp
= eigrp_lookup();
1390 if (eigrp
== NULL
) {
1391 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1395 /* lookup interface by specified name */
1396 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[4]->arg
);
1398 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[4]->arg
);
1402 /* execute graceful restart for all neighbors on interface */
1403 eigrp_update_send_interface_GR(ei
, EIGRP_GR_MANUAL
, vty
);
1408 * Execute graceful restart for neighbor specified by IP
1410 DEFUN (clear_ip_eigrp_neighbors_IP_soft
,
1411 clear_ip_eigrp_neighbors_IP_soft_cmd
,
1412 "clear ip eigrp neighbors A.B.C.D soft",
1416 "Clear IP-EIGRP neighbors\n"
1417 "IP-EIGRP neighbor address\n"
1418 "Resync with peer without adjacency reset\n")
1420 struct eigrp
*eigrp
;
1421 struct eigrp_neighbor
*nbr
;
1422 struct in_addr nbr_addr
;
1424 if (!inet_aton(argv
[4]->arg
, &nbr_addr
)) {
1425 vty_out(vty
, "Unable to parse: %s", argv
[4]->arg
);
1429 /* Check if eigrp process is enabled */
1430 eigrp
= eigrp_lookup();
1431 if (eigrp
== NULL
) {
1432 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1436 /* lookup neighbor in whole process */
1437 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1439 /* if neighbor doesn't exists, notify user and exit */
1441 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1445 /* execute graceful restart on neighbor */
1446 eigrp_update_send_GR(nbr
, EIGRP_GR_MANUAL
, vty
);
1451 static struct cmd_node eigrp_node
= {EIGRP_NODE
, "%s(config-router)# ", 1};
1453 /* Save EIGRP configuration */
1454 static int eigrp_config_write(struct vty
*vty
)
1456 struct eigrp
*eigrp
;
1460 eigrp
= eigrp_lookup();
1461 if (eigrp
!= NULL
) {
1462 /* Writes 'router eigrp' section to config */
1463 config_write_eigrp_router(vty
, eigrp
);
1465 /* Interface config print */
1466 config_write_interfaces(vty
, eigrp
);
1468 // /* static neighbor print. */
1469 // config_write_eigrp_nbr_nbma (vty, eigrp);
1471 // /* Virtual-Link print. */
1472 // config_write_virtual_link (vty, eigrp);
1474 // /* Default metric configuration. */
1475 // config_write_eigrp_default_metric (vty, eigrp);
1477 // /* Distribute-list and default-information print. */
1478 // config_write_eigrp_distribute (vty, eigrp);
1480 // /* Distance configuration. */
1481 // config_write_eigrp_distance (vty, eigrp)
1487 void eigrp_vty_show_init(void)
1489 install_element(VIEW_NODE
, &show_ip_eigrp_interfaces_cmd
);
1491 install_element(VIEW_NODE
, &show_ip_eigrp_neighbors_cmd
);
1493 install_element(VIEW_NODE
, &show_ip_eigrp_topology_cmd
);
1495 install_element(VIEW_NODE
, &show_ip_eigrp_topology_detail_cmd
);
1498 /* eigrpd's interface node. */
1499 static struct cmd_node eigrp_interface_node
= {INTERFACE_NODE
,
1500 "%s(config-if)# ", 1};
1502 void eigrp_vty_if_init(void)
1504 install_node(&eigrp_interface_node
, eigrp_write_interface
);
1507 /* Delay and bandwidth configuration commands*/
1508 install_element(INTERFACE_NODE
, &eigrp_if_delay_cmd
);
1509 install_element(INTERFACE_NODE
, &no_eigrp_if_delay_cmd
);
1510 install_element(INTERFACE_NODE
, &eigrp_if_bandwidth_cmd
);
1511 install_element(INTERFACE_NODE
, &no_eigrp_if_bandwidth_cmd
);
1513 /*Hello-interval and hold-time interval configuration commands*/
1514 install_element(INTERFACE_NODE
, &eigrp_if_ip_holdinterval_cmd
);
1515 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_holdinterval_cmd
);
1516 install_element(INTERFACE_NODE
, &eigrp_if_ip_hellointerval_cmd
);
1517 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_hellointerval_cmd
);
1519 /* "Authentication configuration commands */
1520 install_element(INTERFACE_NODE
, &eigrp_authentication_mode_cmd
);
1521 install_element(INTERFACE_NODE
, &no_eigrp_authentication_mode_cmd
);
1522 install_element(INTERFACE_NODE
, &eigrp_authentication_keychain_cmd
);
1524 /*EIGRP Summarization commands*/
1525 install_element(INTERFACE_NODE
, &eigrp_ip_summary_address_cmd
);
1526 install_element(INTERFACE_NODE
, &no_eigrp_ip_summary_address_cmd
);
1529 static void eigrp_vty_zebra_init(void)
1531 install_element(EIGRP_NODE
, &eigrp_redistribute_source_metric_cmd
);
1532 install_element(EIGRP_NODE
, &no_eigrp_redistribute_source_metric_cmd
);
1535 /* Install EIGRP related vty commands. */
1536 void eigrp_vty_init(void)
1538 install_node(&eigrp_node
, eigrp_config_write
);
1540 install_default(EIGRP_NODE
);
1542 install_element(CONFIG_NODE
, &router_eigrp_cmd
);
1543 install_element(CONFIG_NODE
, &no_router_eigrp_cmd
);
1544 install_element(EIGRP_NODE
, &eigrp_network_cmd
);
1545 install_element(EIGRP_NODE
, &no_eigrp_network_cmd
);
1546 install_element(EIGRP_NODE
, &eigrp_variance_cmd
);
1547 install_element(EIGRP_NODE
, &no_eigrp_variance_cmd
);
1548 install_element(EIGRP_NODE
, &eigrp_router_id_cmd
);
1549 install_element(EIGRP_NODE
, &no_eigrp_router_id_cmd
);
1550 install_element(EIGRP_NODE
, &eigrp_passive_interface_cmd
);
1551 install_element(EIGRP_NODE
, &no_eigrp_passive_interface_cmd
);
1552 install_element(EIGRP_NODE
, &eigrp_timers_active_cmd
);
1553 install_element(EIGRP_NODE
, &no_eigrp_timers_active_cmd
);
1554 install_element(EIGRP_NODE
, &eigrp_metric_weights_cmd
);
1555 install_element(EIGRP_NODE
, &no_eigrp_metric_weights_cmd
);
1556 install_element(EIGRP_NODE
, &eigrp_maximum_paths_cmd
);
1557 install_element(EIGRP_NODE
, &no_eigrp_maximum_paths_cmd
);
1558 install_element(EIGRP_NODE
, &eigrp_neighbor_cmd
);
1559 install_element(EIGRP_NODE
, &no_eigrp_neighbor_cmd
);
1561 /* commands for manual hard restart */
1562 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_cmd
);
1563 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_cmd
);
1564 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_cmd
);
1565 /* commands for manual graceful restart */
1566 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_soft_cmd
);
1567 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_soft_cmd
);
1568 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_soft_cmd
);
1570 eigrp_vty_zebra_init();