3 * Copyright (C) 2013-2016
15 * This file is part of GNU Zebra.
17 * GNU Zebra is free software; you can redistribute it and/or modify it
18 * under the terms of the GNU General Public License as published by the
19 * Free Software Foundation; either version 2, or (at your option) any
22 * GNU Zebra is distributed in the hope that it will be useful, but
23 * WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * General Public License for more details.
27 * You should have received a copy of the GNU General Public License along
28 * with this program; see the file COPYING; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
45 #include "distribute.h"
47 #include "eigrpd/eigrp_structs.h"
48 #include "eigrpd/eigrpd.h"
49 #include "eigrpd/eigrp_interface.h"
50 #include "eigrpd/eigrp_neighbor.h"
51 #include "eigrpd/eigrp_packet.h"
52 #include "eigrpd/eigrp_zebra.h"
53 #include "eigrpd/eigrp_vty.h"
54 #include "eigrpd/eigrp_network.h"
55 #include "eigrpd/eigrp_dump.h"
56 #include "eigrpd/eigrp_const.h"
58 static int config_write_network(struct vty
*vty
, struct eigrp
*eigrp
)
60 struct route_node
*rn
;
63 /* `network area' print. */
64 for (rn
= route_top(eigrp
->networks
); rn
; rn
= route_next(rn
))
67 vty_out(vty
, " network %s/%d \n",
68 inet_ntoa(rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
71 if (eigrp
->max_paths
!= EIGRP_MAX_PATHS_DEFAULT
)
72 vty_out(vty
, " maximum-paths %d\n", eigrp
->max_paths
);
74 if (eigrp
->variance
!= EIGRP_VARIANCE_DEFAULT
)
75 vty_out(vty
, " variance %d\n", eigrp
->variance
);
77 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
78 if (i
!= zclient
->redist_default
79 && vrf_bitmap_check(zclient
->redist
[AFI_IP
][i
],
81 vty_out(vty
, " redistribute %s\n",
82 zebra_route_string(i
));
84 /*Separate EIGRP configuration from the rest of the config*/
90 static int config_write_interfaces(struct vty
*vty
, struct eigrp
*eigrp
)
92 struct eigrp_interface
*ei
;
93 struct listnode
*node
;
95 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
96 vty_out(vty
, "interface %s\n", ei
->ifp
->name
);
98 if ((IF_DEF_PARAMS(ei
->ifp
)->auth_type
)
99 == EIGRP_AUTH_TYPE_MD5
) {
100 vty_out(vty
, " ip authentication mode eigrp %d md5\n",
104 if ((IF_DEF_PARAMS(ei
->ifp
)->auth_type
)
105 == EIGRP_AUTH_TYPE_SHA256
) {
107 " ip authentication mode eigrp %d hmac-sha-256\n",
111 if (IF_DEF_PARAMS(ei
->ifp
)->auth_keychain
) {
113 " ip authentication key-chain eigrp %d %s\n",
115 IF_DEF_PARAMS(ei
->ifp
)->auth_keychain
);
118 if ((IF_DEF_PARAMS(ei
->ifp
)->v_hello
)
119 != EIGRP_HELLO_INTERVAL_DEFAULT
) {
120 vty_out(vty
, " ip hello-interval eigrp %d\n",
121 IF_DEF_PARAMS(ei
->ifp
)->v_hello
);
124 if ((IF_DEF_PARAMS(ei
->ifp
)->v_wait
)
125 != EIGRP_HOLD_INTERVAL_DEFAULT
) {
126 vty_out(vty
, " ip hold-time eigrp %d\n",
127 IF_DEF_PARAMS(ei
->ifp
)->v_wait
);
130 /*Separate this EIGRP interface configuration from the others*/
137 static int eigrp_write_interface(struct vty
*vty
)
139 struct listnode
*node
;
140 struct interface
*ifp
;
142 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT
), node
, ifp
)) {
143 vty_out(vty
, "interface %s\n", ifp
->name
);
146 vty_out(vty
, " description %s\n", ifp
->desc
);
148 if (IF_DEF_PARAMS(ifp
)->bandwidth
!= EIGRP_BANDWIDTH_DEFAULT
)
149 vty_out(vty
, " bandwidth %u\n",
150 IF_DEF_PARAMS(ifp
)->bandwidth
);
151 if (IF_DEF_PARAMS(ifp
)->delay
!= EIGRP_DELAY_DEFAULT
)
152 vty_out(vty
, " delay %u\n", IF_DEF_PARAMS(ifp
)->delay
);
153 if (IF_DEF_PARAMS(ifp
)->v_hello
!= EIGRP_HELLO_INTERVAL_DEFAULT
)
154 vty_out(vty
, " ip hello-interval eigrp %u\n",
155 IF_DEF_PARAMS(ifp
)->v_hello
);
156 if (IF_DEF_PARAMS(ifp
)->v_wait
!= EIGRP_HOLD_INTERVAL_DEFAULT
)
157 vty_out(vty
, " ip hold-time eigrp %u\n",
158 IF_DEF_PARAMS(ifp
)->v_wait
);
167 * Writes distribute lists to config
169 static int config_write_eigrp_distribute(struct vty
*vty
, struct eigrp
*eigrp
)
173 /* Distribute configuration. */
174 write
+= config_write_distribute(vty
);
180 * Writes 'router eigrp' section to config
182 static int config_write_eigrp_router(struct vty
*vty
, struct eigrp
*eigrp
)
186 /* `router eigrp' print. */
187 vty_out(vty
, "router eigrp %d\n", eigrp
->AS
);
191 if (!eigrp
->networks
)
194 /* Router ID print. */
195 if (eigrp
->router_id_static
!= 0) {
196 struct in_addr router_id_static
;
197 router_id_static
.s_addr
= htonl(eigrp
->router_id_static
);
198 vty_out(vty
, " eigrp router-id %s\n",
199 inet_ntoa(router_id_static
));
202 /* Network area print. */
203 config_write_network(vty
, eigrp
);
205 /* Distribute-list and default-information print. */
206 config_write_eigrp_distribute(vty
, eigrp
);
208 /*Separate EIGRP configuration from the rest of the config*/
214 DEFUN_NOSH (router_eigrp
,
216 "router eigrp (1-65535)",
217 "Enable a routing process\n"
218 "Start EIGRP configuration\n"
219 "AS Number to use\n")
221 struct eigrp
*eigrp
= eigrp_get(argv
[2]->arg
);
222 VTY_PUSH_CONTEXT(EIGRP_NODE
, eigrp
);
227 DEFUN (no_router_eigrp
,
229 "no router eigrp (1-65535)",
232 "EIGRP configuration\n"
233 "AS number to use\n")
235 vty
->node
= CONFIG_NODE
;
239 eigrp
= eigrp_lookup();
240 if (eigrp
->AS
!= atoi(argv
[3]->arg
)) {
241 vty_out(vty
, "%% Attempting to deconfigure non-existent AS\n");
242 return CMD_WARNING_CONFIG_FAILED
;
245 eigrp_finish_final(eigrp
);
250 DEFUN (eigrp_router_id
,
252 "eigrp router-id A.B.C.D",
253 "EIGRP specific commands\n"
254 "Router ID for this EIGRP process\n"
255 "EIGRP Router-ID in IP address format\n")
257 // struct eigrp *eigrp = vty->index;
263 DEFUN (no_eigrp_router_id
,
264 no_eigrp_router_id_cmd
,
265 "no eigrp router-id A.B.C.D",
267 "EIGRP specific commands\n"
268 "Router ID for this EIGRP process\n"
269 "EIGRP Router-ID in IP address format\n")
271 // struct eigrp *eigrp = vty->index;
277 DEFUN (eigrp_passive_interface
,
278 eigrp_passive_interface_cmd
,
279 "passive-interface IFNAME",
280 "Suppress routing updates on an interface\n"
281 "Interface to suppress on\n")
283 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
284 struct eigrp_interface
*ei
;
285 struct listnode
*node
;
286 char *ifname
= argv
[1]->arg
;
288 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
289 if (strcmp(ifname
, ei
->ifp
->name
) == 0)
290 SET_IF_PARAM(IF_DEF_PARAMS(ei
->ifp
), passive_interface
);
295 DEFUN (no_eigrp_passive_interface
,
296 no_eigrp_passive_interface_cmd
,
297 "no passive-interface IFNAME",
299 "Suppress routing updates on an interface\n"
300 "Interface to suppress on\n")
302 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
303 struct eigrp_interface
*ei
;
304 struct listnode
*node
;
305 char *ifname
= argv
[2]->arg
;
307 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
308 if (strcmp(ifname
, ei
->ifp
->name
) == 0)
309 UNSET_IF_PARAM(IF_DEF_PARAMS(ei
->ifp
),
316 DEFUN (eigrp_timers_active
,
317 eigrp_timers_active_cmd
,
318 "timers active-time <(1-65535)|disabled>",
319 "Adjust routing timers\n"
320 "Time limit for active state\n"
321 "Active state time limit in minutes\n"
322 "Disable time limit for active state\n")
324 // struct eigrp *eigrp = vty->index;
330 DEFUN (no_eigrp_timers_active
,
331 no_eigrp_timers_active_cmd
,
332 "no timers active-time <(1-65535)|disabled>",
334 "Adjust routing timers\n"
335 "Time limit for active state\n"
336 "Active state time limit in minutes\n"
337 "Disable time limit for active state\n")
339 // struct eigrp *eigrp = vty->index;
346 DEFUN (eigrp_metric_weights
,
347 eigrp_metric_weights_cmd
,
348 "metric weights (0-255) (0-255) (0-255) (0-255) (0-255) ",
349 "Modify metrics and parameters for advertisement\n"
350 "Modify metric coefficients\n"
357 // struct eigrp *eigrp = vty->index;
363 DEFUN (no_eigrp_metric_weights
,
364 no_eigrp_metric_weights_cmd
,
365 "no metric weights <0-255> <0-255> <0-255> <0-255> <0-255>",
367 "Modify metrics and parameters for advertisement\n"
368 "Modify metric coefficients\n"
375 // struct eigrp *eigrp = vty->index;
382 DEFUN (eigrp_network
,
385 "Enable routing on an IP network\n"
386 "EIGRP network prefix\n")
388 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
389 struct prefix_ipv4 p
;
392 str2prefix_ipv4(argv
[1]->arg
, &p
);
394 ret
= eigrp_network_set(eigrp
, &p
);
397 vty_out(vty
, "There is already same network statement.\n");
398 return CMD_WARNING_CONFIG_FAILED
;
404 DEFUN (no_eigrp_network
,
405 no_eigrp_network_cmd
,
406 "no network A.B.C.D/M",
408 "Disable routing on an IP network\n"
409 "EIGRP network prefix\n")
411 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
412 struct prefix_ipv4 p
;
415 str2prefix_ipv4(argv
[2]->arg
, &p
);
417 ret
= eigrp_network_unset(eigrp
, &p
);
420 vty_out(vty
, "Can't find specified network configuration.\n");
421 return CMD_WARNING_CONFIG_FAILED
;
427 DEFUN (eigrp_neighbor
,
430 "Specify a neighbor router\n"
431 "Neighbor address\n")
433 // struct eigrp *eigrp = vty->index;
438 DEFUN (no_eigrp_neighbor
,
439 no_eigrp_neighbor_cmd
,
440 "no neighbor A.B.C.D",
442 "Specify a neighbor router\n"
443 "Neighbor address\n")
445 // struct eigrp *eigrp = vty->index;
450 DEFUN (show_ip_eigrp_topology
,
451 show_ip_eigrp_topology_cmd
,
452 "show ip eigrp topology [all-links]",
455 "IP-EIGRP show commands\n"
456 "IP-EIGRP topology\n"
457 "Show all links in topology table\n")
460 struct listnode
*node
, *node2
;
461 struct eigrp_prefix_entry
*tn
;
462 struct eigrp_neighbor_entry
*te
;
465 eigrp
= eigrp_lookup();
467 vty_out(vty
, " EIGRP Routing Process not enabled\n");
471 show_ip_eigrp_topology_header(vty
, eigrp
);
473 for (ALL_LIST_ELEMENTS_RO(eigrp
->topology_table
, node
, tn
)) {
475 for (ALL_LIST_ELEMENTS_RO(tn
->entries
, node2
, te
)) {
478 & EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG
)
479 == EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG
)
481 & EIGRP_NEIGHBOR_ENTRY_FSUCCESSOR_FLAG
)
482 == EIGRP_NEIGHBOR_ENTRY_FSUCCESSOR_FLAG
))) {
483 show_ip_eigrp_neighbor_entry(vty
, eigrp
, te
,
493 ALIAS(show_ip_eigrp_topology
, show_ip_eigrp_topology_detail_cmd
,
494 "show ip eigrp topology <A.B.C.D|A.B.C.D/M|detail|summary>",
496 "IP-EIGRP show commands\n"
497 "IP-EIGRP topology\n"
498 "Netwok to display information about\n"
499 "IP prefix <network>/<length>, e.g., 192.168.0.0/16\n"
500 "Show all links in topology table\n"
501 "Show a summary of the topology table\n")
503 DEFUN (show_ip_eigrp_interfaces
,
504 show_ip_eigrp_interfaces_cmd
,
505 "show ip eigrp interfaces [IFNAME] [detail]",
508 "IP-EIGRP show commands\n"
509 "IP-EIGRP interfaces\n"
510 "Interface name to look at\n"
511 "Detailed information\n")
513 struct eigrp_interface
*ei
;
515 struct listnode
*node
;
518 const char *ifname
= NULL
;
520 eigrp
= eigrp_lookup();
522 vty_out(vty
, "EIGRP Routing Process not enabled\n");
526 if (argv_find(argv
, argc
, "IFNAME", &idx
))
527 ifname
= argv
[idx
]->arg
;
529 if (argv_find(argv
, argc
, "detail", &idx
))
533 show_ip_eigrp_interface_header(vty
, eigrp
);
535 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
536 if (!ifname
|| strcmp(ei
->ifp
->name
, ifname
) == 0) {
537 show_ip_eigrp_interface_sub(vty
, eigrp
, ei
);
539 show_ip_eigrp_interface_detail(vty
, eigrp
, ei
);
546 DEFUN (show_ip_eigrp_neighbors
,
547 show_ip_eigrp_neighbors_cmd
,
548 "show ip eigrp neighbors [IFNAME] [detail]",
551 "IP-EIGRP show commands\n"
552 "IP-EIGRP neighbors\n"
553 "Interface to show on\n"
554 "Detailed Information\n")
557 struct eigrp_interface
*ei
;
558 struct listnode
*node
, *node2
, *nnode2
;
559 struct eigrp_neighbor
*nbr
;
562 const char *ifname
= NULL
;
564 eigrp
= eigrp_lookup();
566 vty_out(vty
, " EIGRP Routing Process not enabled\n");
570 if (argv_find(argv
, argc
, "IFNAME", &idx
))
571 ifname
= argv
[idx
]->arg
;
573 detail
= (argv_find(argv
, argc
, "detail", &idx
));
575 show_ip_eigrp_neighbor_header(vty
, eigrp
);
577 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
578 if (!ifname
|| strcmp(ei
->ifp
->name
, ifname
) == 0) {
579 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
580 if (detail
|| (nbr
->state
== EIGRP_NEIGHBOR_UP
))
581 show_ip_eigrp_neighbor_sub(vty
, nbr
,
590 DEFUN (eigrp_if_delay
,
592 "delay (1-16777215)",
593 "Specify interface throughput delay\n"
594 "Throughput delay (tens of microseconds)\n")
596 VTY_DECLVAR_CONTEXT(interface
, ifp
);
600 eigrp
= eigrp_lookup();
602 vty_out(vty
, " EIGRP Routing Process not enabled\n");
607 delay
= atoi(argv
[1]->arg
);
609 IF_DEF_PARAMS(ifp
)->delay
= delay
;
615 DEFUN (no_eigrp_if_delay
,
616 no_eigrp_if_delay_cmd
,
617 "no delay (1-16777215)",
619 "Specify interface throughput delay\n"
620 "Throughput delay (tens of microseconds)\n")
622 VTY_DECLVAR_CONTEXT(interface
, ifp
);
625 eigrp
= eigrp_lookup();
627 vty_out(vty
, " EIGRP Routing Process not enabled\n");
632 IF_DEF_PARAMS(ifp
)->delay
= EIGRP_DELAY_DEFAULT
;
638 DEFUN (eigrp_if_bandwidth
,
639 eigrp_if_bandwidth_cmd
,
640 "eigrp bandwidth (1-10000000)",
641 "EIGRP specific commands\n"
642 "Set bandwidth informational parameter\n"
643 "Bandwidth in kilobits\n")
645 VTY_DECLVAR_CONTEXT(interface
, ifp
);
649 eigrp
= eigrp_lookup();
651 vty_out(vty
, " EIGRP Routing Process not enabled\n");
655 bandwidth
= atoi(argv
[1]->arg
);
657 IF_DEF_PARAMS(ifp
)->bandwidth
= bandwidth
;
663 DEFUN (no_eigrp_if_bandwidth
,
664 no_eigrp_if_bandwidth_cmd
,
665 "no 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
);
674 eigrp
= eigrp_lookup();
676 vty_out(vty
, " EIGRP Routing Process not enabled\n");
680 IF_DEF_PARAMS(ifp
)->bandwidth
= EIGRP_BANDWIDTH_DEFAULT
;
686 DEFUN (eigrp_if_ip_hellointerval
,
687 eigrp_if_ip_hellointerval_cmd
,
688 "ip hello-interval eigrp (1-65535)",
689 "Interface Internet Protocol config commands\n"
690 "Configures EIGRP hello interval\n"
691 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
692 "Seconds between hello transmissions\n")
694 VTY_DECLVAR_CONTEXT(interface
, ifp
);
698 eigrp
= eigrp_lookup();
700 vty_out(vty
, " EIGRP Routing Process not enabled\n");
704 hello
= atoi(argv
[3]->arg
);
706 IF_DEF_PARAMS(ifp
)->v_hello
= hello
;
711 DEFUN (no_eigrp_if_ip_hellointerval
,
712 no_eigrp_if_ip_hellointerval_cmd
,
713 "no ip hello-interval eigrp [(1-65535)]",
715 "Interface Internet Protocol config commands\n"
716 "Configures EIGRP hello interval\n"
717 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
718 "Seconds between hello transmissions\n")
720 VTY_DECLVAR_CONTEXT(interface
, ifp
);
722 struct eigrp_interface
*ei
;
723 struct listnode
*node
, *nnode
;
725 eigrp
= eigrp_lookup();
727 vty_out(vty
, " EIGRP Routing Process not enabled\n");
731 IF_DEF_PARAMS(ifp
)->v_hello
= EIGRP_HELLO_INTERVAL_DEFAULT
;
733 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
, ei
)) {
734 if (ei
->ifp
== ifp
) {
735 THREAD_TIMER_OFF(ei
->t_hello
);
736 thread_add_timer(master
, eigrp_hello_timer
, ei
, 1,
745 DEFUN (eigrp_if_ip_holdinterval
,
746 eigrp_if_ip_holdinterval_cmd
,
747 "ip hold-time eigrp (1-65535)",
748 "Interface Internet Protocol config commands\n"
749 "Configures EIGRP IPv4 hold time\n"
750 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
751 "Seconds before neighbor is considered down\n")
753 VTY_DECLVAR_CONTEXT(interface
, ifp
);
757 eigrp
= eigrp_lookup();
759 vty_out(vty
, " EIGRP Routing Process not enabled\n");
763 hold
= atoi(argv
[3]->arg
);
765 IF_DEF_PARAMS(ifp
)->v_wait
= hold
;
770 DEFUN (eigrp_ip_summary_address
,
771 eigrp_ip_summary_address_cmd
,
772 "ip summary-address eigrp (1-65535) A.B.C.D/M",
773 "Interface Internet Protocol config commands\n"
774 "Perform address summarization\n"
775 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
777 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
779 // VTY_DECLVAR_CONTEXT(interface, ifp);
783 eigrp
= eigrp_lookup();
785 vty_out(vty
, " EIGRP Routing Process not enabled\n");
789 // AS = atoi (argv[3]->arg);
796 DEFUN (no_eigrp_ip_summary_address
,
797 no_eigrp_ip_summary_address_cmd
,
798 "no ip summary-address eigrp (1-65535) A.B.C.D/M",
800 "Interface Internet Protocol config commands\n"
801 "Perform address summarization\n"
802 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
804 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
806 // VTY_DECLVAR_CONTEXT(interface, ifp);
810 eigrp
= eigrp_lookup();
812 vty_out(vty
, " EIGRP Routing Process not enabled\n");
816 // AS = atoi (argv[4]->arg);
823 DEFUN (no_eigrp_if_ip_holdinterval
,
824 no_eigrp_if_ip_holdinterval_cmd
,
825 "no ip hold-time eigrp",
827 "Interface Internet Protocol config commands\n"
828 "Configures EIGRP hello interval\n"
829 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
830 "Seconds before neighbor is considered down\n")
832 VTY_DECLVAR_CONTEXT(interface
, ifp
);
835 eigrp
= eigrp_lookup();
837 vty_out(vty
, " EIGRP Routing Process not enabled\n");
841 IF_DEF_PARAMS(ifp
)->v_wait
= EIGRP_HOLD_INTERVAL_DEFAULT
;
846 static int str2auth_type(const char *str
, struct interface
*ifp
)
850 return CMD_WARNING_CONFIG_FAILED
;
852 if (strncmp(str
, "md5", 3) == 0) {
853 IF_DEF_PARAMS(ifp
)->auth_type
= EIGRP_AUTH_TYPE_MD5
;
855 } else if (strncmp(str
, "hmac-sha-256", 12) == 0) {
856 IF_DEF_PARAMS(ifp
)->auth_type
= EIGRP_AUTH_TYPE_SHA256
;
860 return CMD_WARNING_CONFIG_FAILED
;
863 DEFUN (eigrp_authentication_mode
,
864 eigrp_authentication_mode_cmd
,
865 "ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
866 "Interface Internet Protocol config commands\n"
867 "Authentication subcommands\n"
869 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
870 "Autonomous system number\n"
871 "Keyed message digest\n"
872 "HMAC SHA256 algorithm \n")
874 VTY_DECLVAR_CONTEXT(interface
, ifp
);
877 eigrp
= eigrp_lookup();
879 vty_out(vty
, " EIGRP Routing Process not enabled\n");
883 // if(strncmp(argv[2], "md5",3))
884 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_MD5;
885 // else if(strncmp(argv[2], "hmac-sha-256",12))
886 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_SHA256;
888 return str2auth_type(argv
[5]->arg
, ifp
);
891 DEFUN (no_eigrp_authentication_mode
,
892 no_eigrp_authentication_mode_cmd
,
893 "no ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
895 "Interface Internet Protocol config commands\n"
896 "Authentication subcommands\n"
898 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
899 "Autonomous system number\n"
900 "Keyed message digest\n"
901 "HMAC SHA256 algorithm \n")
903 VTY_DECLVAR_CONTEXT(interface
, ifp
);
906 eigrp
= eigrp_lookup();
908 vty_out(vty
, " EIGRP Routing Process not enabled\n");
912 IF_DEF_PARAMS(ifp
)->auth_type
= EIGRP_AUTH_TYPE_NONE
;
917 DEFUN (eigrp_authentication_keychain
,
918 eigrp_authentication_keychain_cmd
,
919 "ip authentication key-chain eigrp (1-65535) WORD",
920 "Interface Internet Protocol config commands\n"
921 "Authentication subcommands\n"
923 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
924 "Autonomous system number\n"
925 "Name of key-chain\n")
927 VTY_DECLVAR_CONTEXT(interface
, ifp
);
929 struct keychain
*keychain
;
931 eigrp
= eigrp_lookup();
933 vty_out(vty
, "EIGRP Routing Process not enabled\n");
937 keychain
= keychain_lookup(argv
[4]->arg
);
938 if (keychain
!= NULL
) {
939 if (IF_DEF_PARAMS(ifp
)->auth_keychain
) {
940 free(IF_DEF_PARAMS(ifp
)->auth_keychain
);
941 IF_DEF_PARAMS(ifp
)->auth_keychain
=
942 strdup(keychain
->name
);
944 IF_DEF_PARAMS(ifp
)->auth_keychain
=
945 strdup(keychain
->name
);
947 vty_out(vty
, "Key chain with specified name not found\n");
952 DEFUN (no_eigrp_authentication_keychain
,
953 no_eigrp_authentication_keychain_cmd
,
954 "no ip authentication key-chain eigrp (1-65535) WORD",
956 "Interface Internet Protocol config commands\n"
957 "Authentication subcommands\n"
959 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
960 "Autonomous system number\n"
961 "Name of key-chain\n")
963 VTY_DECLVAR_CONTEXT(interface
, ifp
);
966 eigrp
= eigrp_lookup();
968 vty_out(vty
, "EIGRP Routing Process not enabled\n");
972 if ((IF_DEF_PARAMS(ifp
)->auth_keychain
!= NULL
)
973 && (strcmp(IF_DEF_PARAMS(ifp
)->auth_keychain
, argv
[5]->arg
) == 0)) {
974 free(IF_DEF_PARAMS(ifp
)->auth_keychain
);
975 IF_DEF_PARAMS(ifp
)->auth_keychain
= NULL
;
978 "Key chain with specified name not configured on interface\n");
983 DEFUN (eigrp_redistribute_source_metric
,
984 eigrp_redistribute_source_metric_cmd
,
985 "redistribute " FRR_REDIST_STR_EIGRPD
986 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
988 FRR_REDIST_HELP_STR_EIGRPD
989 "Metric for redistributed routes\n"
990 "Bandwidth metric in Kbits per second\n"
991 "EIGRP delay metric, in 10 microsecond units\n"
992 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
993 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
994 "EIGRP MTU of the path\n")
996 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
997 struct eigrp_metrics metrics_from_command
= {0};
1001 /* Get distribute source. */
1002 argv_find(argv
, argc
, "redistribute", &idx
);
1003 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->arg
);
1005 return CMD_WARNING_CONFIG_FAILED
;
1007 /* Get metrics values */
1009 return eigrp_redistribute_set(eigrp
, source
, metrics_from_command
);
1012 DEFUN (no_eigrp_redistribute_source_metric
,
1013 no_eigrp_redistribute_source_metric_cmd
,
1014 "no redistribute " FRR_REDIST_STR_EIGRPD
1015 " metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)",
1018 FRR_REDIST_HELP_STR_EIGRPD
1019 "Metric for redistributed routes\n"
1020 "Bandwidth metric in Kbits per second\n"
1021 "EIGRP delay metric, in 10 microsecond units\n"
1022 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1023 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1024 "EIGRP MTU of the path\n")
1026 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1030 /* Get distribute source. */
1031 argv_find(argv
, argc
, "redistribute", &idx
);
1032 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->arg
);
1034 return CMD_WARNING_CONFIG_FAILED
;
1036 /* Get metrics values */
1038 return eigrp_redistribute_unset(eigrp
, source
);
1041 DEFUN (eigrp_variance
,
1044 "Control load balancing variance\n"
1045 "Metric variance multiplier\n")
1047 struct eigrp
*eigrp
;
1050 eigrp
= eigrp_lookup();
1051 if (eigrp
== NULL
) {
1052 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1055 variance
= atoi(argv
[1]->arg
);
1057 eigrp
->variance
= variance
;
1064 DEFUN (no_eigrp_variance
,
1065 no_eigrp_variance_cmd
,
1066 "no variance (1-128)",
1068 "Control load balancing variance\n"
1069 "Metric variance multiplier\n")
1071 struct eigrp
*eigrp
;
1072 eigrp
= eigrp_lookup();
1073 if (eigrp
== NULL
) {
1074 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1078 eigrp
->variance
= EIGRP_VARIANCE_DEFAULT
;
1085 DEFUN (eigrp_maximum_paths
,
1086 eigrp_maximum_paths_cmd
,
1087 "maximum-paths (1-32)",
1088 "Forward packets over multiple paths\n"
1089 "Number of paths\n")
1091 struct eigrp
*eigrp
;
1094 eigrp
= eigrp_lookup();
1095 if (eigrp
== NULL
) {
1096 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1100 max
= atoi(argv
[1]->arg
);
1102 eigrp
->max_paths
= max
;
1109 DEFUN (no_eigrp_maximum_paths
,
1110 no_eigrp_maximum_paths_cmd
,
1111 "no maximum-paths <1-32>",
1113 "Forward packets over multiple paths\n"
1114 "Number of paths\n")
1116 struct eigrp
*eigrp
;
1118 eigrp
= eigrp_lookup();
1119 if (eigrp
== NULL
) {
1120 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1124 eigrp
->max_paths
= EIGRP_MAX_PATHS_DEFAULT
;
1132 * Execute hard restart for all neighbors
1134 DEFUN (clear_ip_eigrp_neighbors
,
1135 clear_ip_eigrp_neighbors_cmd
,
1136 "clear ip eigrp neighbors",
1140 "Clear IP-EIGRP neighbors\n")
1142 struct eigrp
*eigrp
;
1143 struct eigrp_interface
*ei
;
1144 struct listnode
*node
, *node2
, *nnode2
;
1145 struct eigrp_neighbor
*nbr
;
1147 /* Check if eigrp process is enabled */
1148 eigrp
= eigrp_lookup();
1149 if (eigrp
== NULL
) {
1150 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1154 /* iterate over all eigrp interfaces */
1155 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
1156 /* send Goodbye Hello */
1157 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1159 /* iterate over all neighbors on eigrp interface */
1160 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1161 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1163 "Neighbor %s (%s) is down: manually cleared",
1164 inet_ntoa(nbr
->src
),
1165 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1167 vty_time_print(vty
, 0);
1169 "Neighbor %s (%s) is down: manually cleared\n",
1170 inet_ntoa(nbr
->src
),
1171 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1174 /* set neighbor to DOWN */
1175 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1176 /* delete neighbor */
1177 eigrp_nbr_delete(nbr
);
1186 * Execute hard restart for all neighbors on interface
1188 DEFUN (clear_ip_eigrp_neighbors_int
,
1189 clear_ip_eigrp_neighbors_int_cmd
,
1190 "clear ip eigrp neighbors IFNAME",
1194 "Clear IP-EIGRP neighbors\n"
1195 "Interface's name\n")
1197 struct eigrp
*eigrp
;
1198 struct eigrp_interface
*ei
;
1199 struct listnode
*node2
, *nnode2
;
1200 struct eigrp_neighbor
*nbr
;
1203 /* Check if eigrp process is enabled */
1204 eigrp
= eigrp_lookup();
1205 if (eigrp
== NULL
) {
1206 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1210 /* lookup interface by specified name */
1211 argv_find(argv
, argc
, "IFNAME", &idx
);
1212 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[idx
]->arg
);
1214 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[idx
]->arg
);
1218 /* send Goodbye Hello */
1219 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1221 /* iterate over all neighbors on eigrp interface */
1222 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1223 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1224 zlog_debug("Neighbor %s (%s) is down: manually cleared",
1225 inet_ntoa(nbr
->src
),
1226 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1228 vty_time_print(vty
, 0);
1230 "Neighbor %s (%s) is down: manually cleared\n",
1231 inet_ntoa(nbr
->src
),
1232 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1235 /* set neighbor to DOWN */
1236 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1237 /* delete neighbor */
1238 eigrp_nbr_delete(nbr
);
1246 * Execute hard restart for neighbor specified by IP
1248 DEFUN (clear_ip_eigrp_neighbors_IP
,
1249 clear_ip_eigrp_neighbors_IP_cmd
,
1250 "clear ip eigrp neighbors A.B.C.D",
1254 "Clear IP-EIGRP neighbors\n"
1255 "IP-EIGRP neighbor address\n")
1257 struct eigrp
*eigrp
;
1258 struct eigrp_neighbor
*nbr
;
1259 struct in_addr nbr_addr
;
1261 inet_aton(argv
[4]->arg
, &nbr_addr
);
1263 /* Check if eigrp process is enabled */
1264 eigrp
= eigrp_lookup();
1265 if (eigrp
== NULL
) {
1266 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1270 /* lookup neighbor in whole process */
1271 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1273 /* if neighbor doesn't exists, notify user and exit */
1275 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1279 /* execute hard reset on neighbor */
1280 eigrp_nbr_hard_restart(nbr
, vty
);
1286 * Execute graceful restart for all neighbors
1288 DEFUN (clear_ip_eigrp_neighbors_soft
,
1289 clear_ip_eigrp_neighbors_soft_cmd
,
1290 "clear ip eigrp neighbors soft",
1294 "Clear IP-EIGRP neighbors\n"
1295 "Resync with peers without adjacency reset\n")
1297 struct eigrp
*eigrp
;
1299 /* Check if eigrp process is enabled */
1300 eigrp
= eigrp_lookup();
1301 if (eigrp
== NULL
) {
1302 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1306 /* execute graceful restart on all neighbors */
1307 eigrp_update_send_process_GR(eigrp
, EIGRP_GR_MANUAL
, vty
);
1313 * Execute graceful restart for all neighbors on interface
1315 DEFUN (clear_ip_eigrp_neighbors_int_soft
,
1316 clear_ip_eigrp_neighbors_int_soft_cmd
,
1317 "clear ip eigrp neighbors IFNAME soft",
1321 "Clear IP-EIGRP neighbors\n"
1322 "Interface's name\n"
1323 "Resync with peer without adjacency reset\n")
1325 struct eigrp
*eigrp
;
1326 struct eigrp_interface
*ei
;
1328 /* Check if eigrp process is enabled */
1329 eigrp
= eigrp_lookup();
1330 if (eigrp
== NULL
) {
1331 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1335 /* lookup interface by specified name */
1336 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[4]->arg
);
1338 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[4]->arg
);
1342 /* execute graceful restart for all neighbors on interface */
1343 eigrp_update_send_interface_GR(ei
, EIGRP_GR_MANUAL
, vty
);
1348 * Execute graceful restart for neighbor specified by IP
1350 DEFUN (clear_ip_eigrp_neighbors_IP_soft
,
1351 clear_ip_eigrp_neighbors_IP_soft_cmd
,
1352 "clear ip eigrp neighbors A.B.C.D soft",
1356 "Clear IP-EIGRP neighbors\n"
1357 "IP-EIGRP neighbor address\n"
1358 "Resync with peer without adjacency reset\n")
1360 struct eigrp
*eigrp
;
1361 struct eigrp_neighbor
*nbr
;
1362 struct in_addr nbr_addr
;
1364 inet_aton(argv
[4]->arg
, &nbr_addr
);
1366 /* Check if eigrp process is enabled */
1367 eigrp
= eigrp_lookup();
1368 if (eigrp
== NULL
) {
1369 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1373 /* lookup neighbor in whole process */
1374 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1376 /* if neighbor doesn't exists, notify user and exit */
1378 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1382 /* execute graceful restart on neighbor */
1383 eigrp_update_send_GR(nbr
, EIGRP_GR_MANUAL
, vty
);
1388 static struct cmd_node eigrp_node
= {EIGRP_NODE
, "%s(config-router)# ", 1};
1390 /* Save EIGRP configuration */
1391 static int eigrp_config_write(struct vty
*vty
)
1393 struct eigrp
*eigrp
;
1397 eigrp
= eigrp_lookup();
1398 if (eigrp
!= NULL
) {
1399 /* Writes 'router eigrp' section to config */
1400 config_write_eigrp_router(vty
, eigrp
);
1402 /* Interface config print */
1403 config_write_interfaces(vty
, eigrp
);
1405 // /* static neighbor print. */
1406 // config_write_eigrp_nbr_nbma (vty, eigrp);
1408 // /* Virtual-Link print. */
1409 // config_write_virtual_link (vty, eigrp);
1411 // /* Default metric configuration. */
1412 // config_write_eigrp_default_metric (vty, eigrp);
1414 // /* Distribute-list and default-information print. */
1415 // config_write_eigrp_distribute (vty, eigrp);
1417 // /* Distance configuration. */
1418 // config_write_eigrp_distance (vty, eigrp)
1424 void eigrp_vty_show_init(void)
1426 install_element(VIEW_NODE
, &show_ip_eigrp_interfaces_cmd
);
1428 install_element(VIEW_NODE
, &show_ip_eigrp_neighbors_cmd
);
1430 install_element(VIEW_NODE
, &show_ip_eigrp_topology_cmd
);
1432 install_element(VIEW_NODE
, &show_ip_eigrp_topology_detail_cmd
);
1435 /* eigrpd's interface node. */
1436 static struct cmd_node eigrp_interface_node
= {INTERFACE_NODE
,
1437 "%s(config-if)# ", 1};
1439 void eigrp_vty_if_init(void)
1441 install_node(&eigrp_interface_node
, eigrp_write_interface
);
1444 /* Delay and bandwidth configuration commands*/
1445 install_element(INTERFACE_NODE
, &eigrp_if_delay_cmd
);
1446 install_element(INTERFACE_NODE
, &no_eigrp_if_delay_cmd
);
1447 install_element(INTERFACE_NODE
, &eigrp_if_bandwidth_cmd
);
1448 install_element(INTERFACE_NODE
, &no_eigrp_if_bandwidth_cmd
);
1450 /*Hello-interval and hold-time interval configuration commands*/
1451 install_element(INTERFACE_NODE
, &eigrp_if_ip_holdinterval_cmd
);
1452 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_holdinterval_cmd
);
1453 install_element(INTERFACE_NODE
, &eigrp_if_ip_hellointerval_cmd
);
1454 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_hellointerval_cmd
);
1456 /* "Authentication configuration commands */
1457 install_element(INTERFACE_NODE
, &eigrp_authentication_mode_cmd
);
1458 install_element(INTERFACE_NODE
, &no_eigrp_authentication_mode_cmd
);
1459 install_element(INTERFACE_NODE
, &eigrp_authentication_keychain_cmd
);
1460 install_element(INTERFACE_NODE
, &no_eigrp_authentication_keychain_cmd
);
1462 /*EIGRP Summarization commands*/
1463 install_element(INTERFACE_NODE
, &eigrp_ip_summary_address_cmd
);
1464 install_element(INTERFACE_NODE
, &no_eigrp_ip_summary_address_cmd
);
1467 static void eigrp_vty_zebra_init(void)
1469 install_element(EIGRP_NODE
, &eigrp_redistribute_source_metric_cmd
);
1470 install_element(EIGRP_NODE
, &no_eigrp_redistribute_source_metric_cmd
);
1473 /* Install EIGRP related vty commands. */
1474 void eigrp_vty_init(void)
1476 install_node(&eigrp_node
, eigrp_config_write
);
1478 install_default(EIGRP_NODE
);
1480 install_element(CONFIG_NODE
, &router_eigrp_cmd
);
1481 install_element(CONFIG_NODE
, &no_router_eigrp_cmd
);
1482 install_element(EIGRP_NODE
, &eigrp_network_cmd
);
1483 install_element(EIGRP_NODE
, &no_eigrp_network_cmd
);
1484 install_element(EIGRP_NODE
, &eigrp_variance_cmd
);
1485 install_element(EIGRP_NODE
, &no_eigrp_variance_cmd
);
1486 install_element(EIGRP_NODE
, &eigrp_router_id_cmd
);
1487 install_element(EIGRP_NODE
, &no_eigrp_router_id_cmd
);
1488 install_element(EIGRP_NODE
, &eigrp_passive_interface_cmd
);
1489 install_element(EIGRP_NODE
, &no_eigrp_passive_interface_cmd
);
1490 install_element(EIGRP_NODE
, &eigrp_timers_active_cmd
);
1491 install_element(EIGRP_NODE
, &no_eigrp_timers_active_cmd
);
1492 install_element(EIGRP_NODE
, &eigrp_metric_weights_cmd
);
1493 install_element(EIGRP_NODE
, &no_eigrp_metric_weights_cmd
);
1494 install_element(EIGRP_NODE
, &eigrp_maximum_paths_cmd
);
1495 install_element(EIGRP_NODE
, &no_eigrp_maximum_paths_cmd
);
1496 install_element(EIGRP_NODE
, &eigrp_neighbor_cmd
);
1497 install_element(EIGRP_NODE
, &no_eigrp_neighbor_cmd
);
1499 /* commands for manual hard restart */
1500 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_cmd
);
1501 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_cmd
);
1502 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_cmd
);
1503 /* commands for manual graceful restart */
1504 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_soft_cmd
);
1505 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_soft_cmd
);
1506 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_soft_cmd
);
1508 eigrp_vty_zebra_init();