3 * Copyright (C) 2013-2016
15 * This file is part of GNU Zebra.
17 * GNU Zebra is free software; you can redistribute it and/or modify it
18 * under the terms of the GNU General Public License as published by the
19 * Free Software Foundation; either version 2, or (at your option) any
22 * GNU Zebra is distributed in the hope that it will be useful, but
23 * WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * General Public License for more details.
27 * You should have received a copy of the GNU General Public License along
28 * with this program; see the file COPYING; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
45 #include "distribute.h"
47 #include "eigrpd/eigrp_structs.h"
48 #include "eigrpd/eigrpd.h"
49 #include "eigrpd/eigrp_interface.h"
50 #include "eigrpd/eigrp_neighbor.h"
51 #include "eigrpd/eigrp_packet.h"
52 #include "eigrpd/eigrp_zebra.h"
53 #include "eigrpd/eigrp_vty.h"
54 #include "eigrpd/eigrp_network.h"
55 #include "eigrpd/eigrp_dump.h"
56 #include "eigrpd/eigrp_const.h"
58 static int config_write_network(struct vty
*vty
, struct eigrp
*eigrp
)
60 struct route_node
*rn
;
63 /* `network area' print. */
64 for (rn
= route_top(eigrp
->networks
); rn
; rn
= route_next(rn
))
67 vty_out(vty
, " network %s/%d \n",
68 inet_ntoa(rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
71 if (eigrp
->max_paths
!= EIGRP_MAX_PATHS_DEFAULT
)
72 vty_out(vty
, " maximum-paths %d\n", eigrp
->max_paths
);
74 if (eigrp
->variance
!= EIGRP_VARIANCE_DEFAULT
)
75 vty_out(vty
, " variance %d\n", eigrp
->variance
);
77 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
78 if (i
!= zclient
->redist_default
79 && vrf_bitmap_check(zclient
->redist
[AFI_IP
][i
],
81 vty_out(vty
, " redistribute %s\n",
82 zebra_route_string(i
));
84 /*Separate EIGRP configuration from the rest of the config*/
90 static int config_write_interfaces(struct vty
*vty
, struct eigrp
*eigrp
)
92 struct eigrp_interface
*ei
;
93 struct listnode
*node
;
95 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
96 vty_frame(vty
, "interface %s\n", ei
->ifp
->name
);
98 if (ei
->params
.auth_type
== EIGRP_AUTH_TYPE_MD5
) {
99 vty_out(vty
, " ip authentication mode eigrp %d md5\n",
103 if (ei
->params
.auth_type
== EIGRP_AUTH_TYPE_SHA256
) {
105 " ip authentication mode eigrp %d hmac-sha-256\n",
109 if (ei
->params
.auth_keychain
) {
111 " ip authentication key-chain eigrp %d %s\n",
112 eigrp
->AS
, ei
->params
.auth_keychain
);
115 if (ei
->params
.v_hello
!= EIGRP_HELLO_INTERVAL_DEFAULT
) {
116 vty_out(vty
, " ip hello-interval eigrp %d\n",
120 if (ei
->params
.v_wait
!= EIGRP_HOLD_INTERVAL_DEFAULT
) {
121 vty_out(vty
, " ip hold-time eigrp %d\n",
125 /*Separate this EIGRP interface configuration from the others*/
126 vty_endframe(vty
, "!\n");
132 static int eigrp_write_interface(struct vty
*vty
)
134 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
135 struct interface
*ifp
;
136 struct eigrp_interface
*ei
;
138 FOR_ALL_INTERFACES (vrf
, ifp
) {
143 vty_frame(vty
, "interface %s\n", ifp
->name
);
146 vty_out(vty
, " description %s\n", ifp
->desc
);
148 if (ei
->params
.bandwidth
!= EIGRP_BANDWIDTH_DEFAULT
)
149 vty_out(vty
, " bandwidth %u\n", ei
->params
.bandwidth
);
150 if (ei
->params
.delay
!= EIGRP_DELAY_DEFAULT
)
151 vty_out(vty
, " delay %u\n", ei
->params
.delay
);
152 if (ei
->params
.v_hello
!= EIGRP_HELLO_INTERVAL_DEFAULT
)
153 vty_out(vty
, " ip hello-interval eigrp %u\n",
155 if (ei
->params
.v_wait
!= EIGRP_HOLD_INTERVAL_DEFAULT
)
156 vty_out(vty
, " ip hold-time eigrp %u\n",
159 vty_endframe(vty
, "!\n");
166 * Writes distribute lists to config
168 static int config_write_eigrp_distribute(struct vty
*vty
, struct eigrp
*eigrp
)
172 /* Distribute configuration. */
173 write
+= config_write_distribute(vty
);
179 * Writes 'router eigrp' section to config
181 static int config_write_eigrp_router(struct vty
*vty
, struct eigrp
*eigrp
)
185 /* `router eigrp' print. */
186 vty_out(vty
, "router eigrp %d\n", eigrp
->AS
);
190 if (!eigrp
->networks
)
193 /* Router ID print. */
194 if (eigrp
->router_id_static
!= 0) {
195 struct in_addr router_id_static
;
196 router_id_static
.s_addr
= htonl(eigrp
->router_id_static
);
197 vty_out(vty
, " eigrp router-id %s\n",
198 inet_ntoa(router_id_static
));
201 /* Network area print. */
202 config_write_network(vty
, eigrp
);
204 /* Distribute-list and default-information print. */
205 config_write_eigrp_distribute(vty
, eigrp
);
207 /*Separate EIGRP configuration from the rest of the config*/
213 DEFUN_NOSH (router_eigrp
,
215 "router eigrp (1-65535)",
216 "Enable a routing process\n"
217 "Start EIGRP configuration\n"
218 "AS Number to use\n")
220 struct eigrp
*eigrp
= eigrp_get(argv
[2]->arg
);
221 VTY_PUSH_CONTEXT(EIGRP_NODE
, eigrp
);
226 DEFUN (no_router_eigrp
,
228 "no router eigrp (1-65535)",
231 "EIGRP configuration\n"
232 "AS number to use\n")
234 vty
->node
= CONFIG_NODE
;
238 eigrp
= eigrp_lookup();
240 vty_out(vty
, " EIGRP Routing Process not enabled\n");
244 if (eigrp
->AS
!= atoi(argv
[3]->arg
)) {
245 vty_out(vty
, "%% Attempting to deconfigure non-existent AS\n");
246 return CMD_WARNING_CONFIG_FAILED
;
249 eigrp_finish_final(eigrp
);
254 DEFUN (eigrp_router_id
,
256 "eigrp router-id A.B.C.D",
257 "EIGRP specific commands\n"
258 "Router ID for this EIGRP process\n"
259 "EIGRP Router-ID in IP address format\n")
261 // struct eigrp *eigrp = vty->index;
267 DEFUN (no_eigrp_router_id
,
268 no_eigrp_router_id_cmd
,
269 "no eigrp router-id A.B.C.D",
271 "EIGRP specific commands\n"
272 "Router ID for this EIGRP process\n"
273 "EIGRP Router-ID in IP address format\n")
275 // struct eigrp *eigrp = vty->index;
281 DEFUN (eigrp_passive_interface
,
282 eigrp_passive_interface_cmd
,
283 "passive-interface IFNAME",
284 "Suppress routing updates on an interface\n"
285 "Interface to suppress on\n")
287 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
288 struct eigrp_interface
*ei
;
289 struct listnode
*node
;
290 char *ifname
= argv
[1]->arg
;
292 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
293 if (strcmp(ifname
, ei
->ifp
->name
) == 0) {
294 ei
->params
.passive_interface
= EIGRP_IF_PASSIVE
;
301 DEFUN (no_eigrp_passive_interface
,
302 no_eigrp_passive_interface_cmd
,
303 "no passive-interface IFNAME",
305 "Suppress routing updates on an interface\n"
306 "Interface to suppress on\n")
308 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
309 struct eigrp_interface
*ei
;
310 struct listnode
*node
;
311 char *ifname
= argv
[2]->arg
;
313 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
314 if (strcmp(ifname
, ei
->ifp
->name
) == 0) {
315 ei
->params
.passive_interface
= EIGRP_IF_ACTIVE
;
323 DEFUN (eigrp_timers_active
,
324 eigrp_timers_active_cmd
,
325 "timers active-time <(1-65535)|disabled>",
326 "Adjust routing timers\n"
327 "Time limit for active state\n"
328 "Active state time limit in minutes\n"
329 "Disable time limit for active state\n")
331 // struct eigrp *eigrp = vty->index;
337 DEFUN (no_eigrp_timers_active
,
338 no_eigrp_timers_active_cmd
,
339 "no timers active-time <(1-65535)|disabled>",
341 "Adjust routing timers\n"
342 "Time limit for active state\n"
343 "Active state time limit in minutes\n"
344 "Disable time limit for active state\n")
346 // struct eigrp *eigrp = vty->index;
353 DEFUN (eigrp_metric_weights
,
354 eigrp_metric_weights_cmd
,
355 "metric weights (0-255) (0-255) (0-255) (0-255) (0-255) ",
356 "Modify metrics and parameters for advertisement\n"
357 "Modify metric coefficients\n"
364 // struct eigrp *eigrp = vty->index;
370 DEFUN (no_eigrp_metric_weights
,
371 no_eigrp_metric_weights_cmd
,
372 "no metric weights <0-255> <0-255> <0-255> <0-255> <0-255>",
374 "Modify metrics and parameters for advertisement\n"
375 "Modify metric coefficients\n"
382 // struct eigrp *eigrp = vty->index;
389 DEFUN (eigrp_network
,
392 "Enable routing on an IP network\n"
393 "EIGRP network prefix\n")
395 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
399 (void)str2prefix(argv
[1]->arg
, &p
);
401 ret
= eigrp_network_set(eigrp
, &p
);
404 vty_out(vty
, "There is already same network statement.\n");
411 DEFUN (no_eigrp_network
,
412 no_eigrp_network_cmd
,
413 "no network A.B.C.D/M",
415 "Disable routing on an IP network\n"
416 "EIGRP network prefix\n")
418 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
422 (void)str2prefix(argv
[2]->arg
, &p
);
424 ret
= eigrp_network_unset(eigrp
, &p
);
427 vty_out(vty
, "Can't find specified network configuration.\n");
428 return CMD_WARNING_CONFIG_FAILED
;
434 DEFUN (eigrp_neighbor
,
437 "Specify a neighbor router\n"
438 "Neighbor address\n")
440 // struct eigrp *eigrp = vty->index;
445 DEFUN (no_eigrp_neighbor
,
446 no_eigrp_neighbor_cmd
,
447 "no neighbor A.B.C.D",
449 "Specify a neighbor router\n"
450 "Neighbor address\n")
452 // struct eigrp *eigrp = vty->index;
457 DEFUN (show_ip_eigrp_topology
,
458 show_ip_eigrp_topology_cmd
,
459 "show ip eigrp topology [all-links]",
462 "IP-EIGRP show commands\n"
463 "IP-EIGRP topology\n"
464 "Show all links in topology table\n")
467 struct listnode
*node
;
468 struct eigrp_prefix_entry
*tn
;
469 struct eigrp_nexthop_entry
*te
;
470 struct route_node
*rn
;
473 eigrp
= eigrp_lookup();
475 vty_out(vty
, " EIGRP Routing Process not enabled\n");
479 show_ip_eigrp_topology_header(vty
, eigrp
);
481 for (rn
= route_top(eigrp
->topology_table
); rn
; rn
= route_next(rn
)) {
487 for (ALL_LIST_ELEMENTS_RO(tn
->entries
, node
, te
)) {
490 & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG
)
491 == EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG
)
493 & EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG
)
494 == EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG
))) {
495 show_ip_eigrp_nexthop_entry(vty
, eigrp
, te
,
505 ALIAS(show_ip_eigrp_topology
, show_ip_eigrp_topology_detail_cmd
,
506 "show ip eigrp topology <A.B.C.D|A.B.C.D/M|detail|summary>",
508 "IP-EIGRP show commands\n"
509 "IP-EIGRP topology\n"
510 "Netwok to display information about\n"
511 "IP prefix <network>/<length>, e.g., 192.168.0.0/16\n"
512 "Show all links in topology table\n"
513 "Show a summary of the topology table\n")
515 DEFUN (show_ip_eigrp_interfaces
,
516 show_ip_eigrp_interfaces_cmd
,
517 "show ip eigrp interfaces [IFNAME] [detail]",
520 "IP-EIGRP show commands\n"
521 "IP-EIGRP interfaces\n"
522 "Interface name to look at\n"
523 "Detailed information\n")
525 struct eigrp_interface
*ei
;
527 struct listnode
*node
;
530 const char *ifname
= NULL
;
532 eigrp
= eigrp_lookup();
534 vty_out(vty
, "EIGRP Routing Process not enabled\n");
538 if (argv_find(argv
, argc
, "IFNAME", &idx
))
539 ifname
= argv
[idx
]->arg
;
541 if (argv_find(argv
, argc
, "detail", &idx
))
545 show_ip_eigrp_interface_header(vty
, eigrp
);
547 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
548 if (!ifname
|| strcmp(ei
->ifp
->name
, ifname
) == 0) {
549 show_ip_eigrp_interface_sub(vty
, eigrp
, ei
);
551 show_ip_eigrp_interface_detail(vty
, eigrp
, ei
);
558 DEFUN (show_ip_eigrp_neighbors
,
559 show_ip_eigrp_neighbors_cmd
,
560 "show ip eigrp neighbors [IFNAME] [detail]",
563 "IP-EIGRP show commands\n"
564 "IP-EIGRP neighbors\n"
565 "Interface to show on\n"
566 "Detailed Information\n")
569 struct eigrp_interface
*ei
;
570 struct listnode
*node
, *node2
, *nnode2
;
571 struct eigrp_neighbor
*nbr
;
574 const char *ifname
= NULL
;
576 eigrp
= eigrp_lookup();
578 vty_out(vty
, " EIGRP Routing Process not enabled\n");
582 if (argv_find(argv
, argc
, "IFNAME", &idx
))
583 ifname
= argv
[idx
]->arg
;
585 detail
= (argv_find(argv
, argc
, "detail", &idx
));
587 show_ip_eigrp_neighbor_header(vty
, eigrp
);
589 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
590 if (!ifname
|| strcmp(ei
->ifp
->name
, ifname
) == 0) {
591 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
592 if (detail
|| (nbr
->state
== EIGRP_NEIGHBOR_UP
))
593 show_ip_eigrp_neighbor_sub(vty
, nbr
,
602 DEFUN (eigrp_if_delay
,
604 "delay (1-16777215)",
605 "Specify interface throughput delay\n"
606 "Throughput delay (tens of microseconds)\n")
608 VTY_DECLVAR_CONTEXT(interface
, ifp
);
609 struct eigrp_interface
*ei
= ifp
->info
;
613 eigrp
= eigrp_lookup();
615 vty_out(vty
, " EIGRP Routing Process not enabled\n");
621 vty_out(vty
, " EIGRP not configured on this interface\n");
624 delay
= atoi(argv
[1]->arg
);
626 ei
->params
.delay
= delay
;
632 DEFUN (no_eigrp_if_delay
,
633 no_eigrp_if_delay_cmd
,
634 "no delay (1-16777215)",
636 "Specify interface throughput delay\n"
637 "Throughput delay (tens of microseconds)\n")
639 VTY_DECLVAR_CONTEXT(interface
, ifp
);
640 struct eigrp_interface
*ei
= ifp
->info
;
643 eigrp
= eigrp_lookup();
645 vty_out(vty
, " EIGRP Routing Process not enabled\n");
650 vty_out(vty
, " EIGRP not configured on this interface\n");
654 ei
->params
.delay
= EIGRP_DELAY_DEFAULT
;
660 DEFUN (eigrp_if_bandwidth
,
661 eigrp_if_bandwidth_cmd
,
662 "eigrp bandwidth (1-10000000)",
663 "EIGRP specific commands\n"
664 "Set bandwidth informational parameter\n"
665 "Bandwidth in kilobits\n")
667 VTY_DECLVAR_CONTEXT(interface
, ifp
);
668 struct eigrp_interface
*ei
= ifp
->info
;
672 eigrp
= eigrp_lookup();
674 vty_out(vty
, " EIGRP Routing Process not enabled\n");
679 vty_out(vty
, " EIGRP not configured on this interface\n");
683 bandwidth
= atoi(argv
[1]->arg
);
685 ei
->params
.bandwidth
= bandwidth
;
691 DEFUN (no_eigrp_if_bandwidth
,
692 no_eigrp_if_bandwidth_cmd
,
693 "no eigrp bandwidth [(1-10000000)]",
695 "EIGRP specific commands\n"
696 "Set bandwidth informational parameter\n"
697 "Bandwidth in kilobits\n")
699 VTY_DECLVAR_CONTEXT(interface
, ifp
);
700 struct eigrp_interface
*ei
= ifp
->info
;
703 eigrp
= eigrp_lookup();
705 vty_out(vty
, " EIGRP Routing Process not enabled\n");
710 vty_out(vty
, " EIGRP not configured on this interface\n");
714 ei
->params
.bandwidth
= EIGRP_BANDWIDTH_DEFAULT
;
720 DEFUN (eigrp_if_ip_hellointerval
,
721 eigrp_if_ip_hellointerval_cmd
,
722 "ip hello-interval eigrp (1-65535)",
723 "Interface Internet Protocol config commands\n"
724 "Configures EIGRP hello interval\n"
725 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
726 "Seconds between hello transmissions\n")
728 VTY_DECLVAR_CONTEXT(interface
, ifp
);
729 struct eigrp_interface
*ei
= ifp
->info
;
733 eigrp
= eigrp_lookup();
735 vty_out(vty
, " EIGRP Routing Process not enabled\n");
740 vty_out(vty
, " EIGRP not configured on this interface\n");
744 hello
= atoi(argv
[3]->arg
);
746 ei
->params
.v_hello
= hello
;
751 DEFUN (no_eigrp_if_ip_hellointerval
,
752 no_eigrp_if_ip_hellointerval_cmd
,
753 "no ip hello-interval eigrp [(1-65535)]",
755 "Interface Internet Protocol config commands\n"
756 "Configures EIGRP hello interval\n"
757 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
758 "Seconds between hello transmissions\n")
760 VTY_DECLVAR_CONTEXT(interface
, ifp
);
761 struct eigrp_interface
*ei
= ifp
->info
;
764 eigrp
= eigrp_lookup();
766 vty_out(vty
, " EIGRP Routing Process not enabled\n");
771 vty_out(vty
, " EIGRP not configured on this interface\n");
775 ei
->params
.v_hello
= EIGRP_HELLO_INTERVAL_DEFAULT
;
777 THREAD_TIMER_OFF(ei
->t_hello
);
778 thread_add_timer(master
, eigrp_hello_timer
, ei
, 1, &ei
->t_hello
);
783 DEFUN (eigrp_if_ip_holdinterval
,
784 eigrp_if_ip_holdinterval_cmd
,
785 "ip hold-time eigrp (1-65535)",
786 "Interface Internet Protocol config commands\n"
787 "Configures EIGRP IPv4 hold time\n"
788 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
789 "Seconds before neighbor is considered down\n")
791 VTY_DECLVAR_CONTEXT(interface
, ifp
);
792 struct eigrp_interface
*ei
= ifp
->info
;
796 eigrp
= eigrp_lookup();
798 vty_out(vty
, " EIGRP Routing Process not enabled\n");
803 vty_out(vty
, " EIGRP not configured on this interface\n");
807 hold
= atoi(argv
[3]->arg
);
809 ei
->params
.v_wait
= hold
;
814 DEFUN (eigrp_ip_summary_address
,
815 eigrp_ip_summary_address_cmd
,
816 "ip summary-address eigrp (1-65535) A.B.C.D/M",
817 "Interface Internet Protocol config commands\n"
818 "Perform address summarization\n"
819 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
821 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
823 // VTY_DECLVAR_CONTEXT(interface, ifp);
827 eigrp
= eigrp_lookup();
829 vty_out(vty
, " EIGRP Routing Process not enabled\n");
833 // AS = atoi (argv[3]->arg);
840 DEFUN (no_eigrp_ip_summary_address
,
841 no_eigrp_ip_summary_address_cmd
,
842 "no ip summary-address eigrp (1-65535) A.B.C.D/M",
844 "Interface Internet Protocol config commands\n"
845 "Perform address summarization\n"
846 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
848 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
850 // VTY_DECLVAR_CONTEXT(interface, ifp);
854 eigrp
= eigrp_lookup();
856 vty_out(vty
, " EIGRP Routing Process not enabled\n");
860 // AS = atoi (argv[4]->arg);
867 DEFUN (no_eigrp_if_ip_holdinterval
,
868 no_eigrp_if_ip_holdinterval_cmd
,
869 "no ip hold-time eigrp",
871 "Interface Internet Protocol config commands\n"
872 "Configures EIGRP hello interval\n"
873 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n")
875 VTY_DECLVAR_CONTEXT(interface
, ifp
);
876 struct eigrp_interface
*ei
= ifp
->info
;
879 eigrp
= eigrp_lookup();
881 vty_out(vty
, " EIGRP Routing Process not enabled\n");
886 vty_out(vty
, " EIGRP not configured on this interface\n");
890 ei
->params
.v_wait
= EIGRP_HOLD_INTERVAL_DEFAULT
;
895 static int str2auth_type(const char *str
, struct eigrp_interface
*ei
)
899 return CMD_WARNING_CONFIG_FAILED
;
901 if (strncmp(str
, "md5", 3) == 0) {
902 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_MD5
;
904 } else if (strncmp(str
, "hmac-sha-256", 12) == 0) {
905 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_SHA256
;
909 return CMD_WARNING_CONFIG_FAILED
;
912 DEFUN (eigrp_authentication_mode
,
913 eigrp_authentication_mode_cmd
,
914 "ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
915 "Interface Internet Protocol config commands\n"
916 "Authentication subcommands\n"
918 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
919 "Autonomous system number\n"
920 "Keyed message digest\n"
921 "HMAC SHA256 algorithm \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 // if(strncmp(argv[2], "md5",3))
939 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_MD5;
940 // else if(strncmp(argv[2], "hmac-sha-256",12))
941 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_SHA256;
943 return str2auth_type(argv
[5]->arg
, ei
);
946 DEFUN (no_eigrp_authentication_mode
,
947 no_eigrp_authentication_mode_cmd
,
948 "no ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
950 "Interface Internet Protocol config commands\n"
951 "Authentication subcommands\n"
953 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
954 "Autonomous system number\n"
955 "Keyed message digest\n"
956 "HMAC SHA256 algorithm \n")
958 VTY_DECLVAR_CONTEXT(interface
, ifp
);
959 struct eigrp_interface
*ei
= ifp
->info
;
962 eigrp
= eigrp_lookup();
964 vty_out(vty
, " EIGRP Routing Process not enabled\n");
969 vty_out(vty
, " EIGRP not configured on this interface\n");
973 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_NONE
;
978 DEFUN (eigrp_authentication_keychain
,
979 eigrp_authentication_keychain_cmd
,
980 "ip authentication key-chain eigrp (1-65535) WORD",
981 "Interface Internet Protocol config commands\n"
982 "Authentication subcommands\n"
984 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
985 "Autonomous system number\n"
986 "Name of key-chain\n")
988 VTY_DECLVAR_CONTEXT(interface
, ifp
);
989 struct eigrp_interface
*ei
= ifp
->info
;
991 struct keychain
*keychain
;
993 eigrp
= eigrp_lookup();
995 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1000 vty_out(vty
, " EIGRP not configured on this interface\n");
1004 keychain
= keychain_lookup(argv
[4]->arg
);
1005 if (keychain
!= NULL
) {
1006 if (ei
->params
.auth_keychain
) {
1007 free(ei
->params
.auth_keychain
);
1008 ei
->params
.auth_keychain
= strdup(keychain
->name
);
1010 ei
->params
.auth_keychain
= strdup(keychain
->name
);
1012 vty_out(vty
, "Key chain with specified name not found\n");
1017 DEFUN (no_eigrp_authentication_keychain
,
1018 no_eigrp_authentication_keychain_cmd
,
1019 "no ip authentication key-chain eigrp (1-65535) WORD",
1021 "Interface Internet Protocol config commands\n"
1022 "Authentication subcommands\n"
1024 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
1025 "Autonomous system number\n"
1026 "Name of key-chain\n")
1028 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1029 struct eigrp_interface
*ei
= ifp
->info
;
1030 struct eigrp
*eigrp
;
1032 eigrp
= eigrp_lookup();
1033 if (eigrp
== NULL
) {
1034 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1039 vty_out(vty
, " EIGRP not configured on this interface\n");
1043 if ((ei
->params
.auth_keychain
!= NULL
)
1044 && (strcmp(ei
->params
.auth_keychain
, argv
[5]->arg
) == 0)) {
1045 free(ei
->params
.auth_keychain
);
1046 ei
->params
.auth_keychain
= NULL
;
1049 "Key chain with specified name not configured on interface\n");
1054 DEFUN (eigrp_redistribute_source_metric
,
1055 eigrp_redistribute_source_metric_cmd
,
1056 "redistribute " FRR_REDIST_STR_EIGRPD
1057 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
1059 FRR_REDIST_HELP_STR_EIGRPD
1060 "Metric for redistributed routes\n"
1061 "Bandwidth metric in Kbits per second\n"
1062 "EIGRP delay metric, in 10 microsecond units\n"
1063 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1064 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1065 "EIGRP MTU of the path\n")
1067 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1068 struct eigrp_metrics metrics_from_command
= {0};
1072 /* Get distribute source. */
1073 argv_find(argv
, argc
, "redistribute", &idx
);
1074 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1076 vty_out(vty
, "%% Invalid route type\n");
1077 return CMD_WARNING_CONFIG_FAILED
;
1080 /* Get metrics values */
1082 return eigrp_redistribute_set(eigrp
, source
, metrics_from_command
);
1085 DEFUN (no_eigrp_redistribute_source_metric
,
1086 no_eigrp_redistribute_source_metric_cmd
,
1087 "no redistribute " FRR_REDIST_STR_EIGRPD
1088 " metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)",
1091 FRR_REDIST_HELP_STR_EIGRPD
1092 "Metric for redistributed routes\n"
1093 "Bandwidth metric in Kbits per second\n"
1094 "EIGRP delay metric, in 10 microsecond units\n"
1095 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1096 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1097 "EIGRP MTU of the path\n")
1099 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1103 /* Get distribute source. */
1104 argv_find(argv
, argc
, "redistribute", &idx
);
1105 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1107 vty_out(vty
, "%% Invalid route type\n");
1108 return CMD_WARNING_CONFIG_FAILED
;
1111 /* Get metrics values */
1113 return eigrp_redistribute_unset(eigrp
, source
);
1116 DEFUN (eigrp_variance
,
1119 "Control load balancing variance\n"
1120 "Metric variance multiplier\n")
1122 struct eigrp
*eigrp
;
1125 eigrp
= eigrp_lookup();
1126 if (eigrp
== NULL
) {
1127 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1130 variance
= atoi(argv
[1]->arg
);
1132 eigrp
->variance
= variance
;
1139 DEFUN (no_eigrp_variance
,
1140 no_eigrp_variance_cmd
,
1141 "no variance (1-128)",
1143 "Control load balancing variance\n"
1144 "Metric variance multiplier\n")
1146 struct eigrp
*eigrp
;
1147 eigrp
= eigrp_lookup();
1148 if (eigrp
== NULL
) {
1149 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1153 eigrp
->variance
= EIGRP_VARIANCE_DEFAULT
;
1160 DEFUN (eigrp_maximum_paths
,
1161 eigrp_maximum_paths_cmd
,
1162 "maximum-paths (1-32)",
1163 "Forward packets over multiple paths\n"
1164 "Number of paths\n")
1166 struct eigrp
*eigrp
;
1169 eigrp
= eigrp_lookup();
1170 if (eigrp
== NULL
) {
1171 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1175 max
= atoi(argv
[1]->arg
);
1177 eigrp
->max_paths
= max
;
1184 DEFUN (no_eigrp_maximum_paths
,
1185 no_eigrp_maximum_paths_cmd
,
1186 "no maximum-paths <1-32>",
1188 "Forward packets over multiple paths\n"
1189 "Number of paths\n")
1191 struct eigrp
*eigrp
;
1193 eigrp
= eigrp_lookup();
1194 if (eigrp
== NULL
) {
1195 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1199 eigrp
->max_paths
= EIGRP_MAX_PATHS_DEFAULT
;
1207 * Execute hard restart for all neighbors
1209 DEFUN (clear_ip_eigrp_neighbors
,
1210 clear_ip_eigrp_neighbors_cmd
,
1211 "clear ip eigrp neighbors",
1215 "Clear IP-EIGRP neighbors\n")
1217 struct eigrp
*eigrp
;
1218 struct eigrp_interface
*ei
;
1219 struct listnode
*node
, *node2
, *nnode2
;
1220 struct eigrp_neighbor
*nbr
;
1222 /* Check if eigrp process is enabled */
1223 eigrp
= eigrp_lookup();
1224 if (eigrp
== NULL
) {
1225 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1229 /* iterate over all eigrp interfaces */
1230 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
1231 /* send Goodbye Hello */
1232 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1234 /* iterate over all neighbors on eigrp interface */
1235 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1236 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1238 "Neighbor %s (%s) is down: manually cleared",
1239 inet_ntoa(nbr
->src
),
1240 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1242 vty_time_print(vty
, 0);
1244 "Neighbor %s (%s) is down: manually cleared\n",
1245 inet_ntoa(nbr
->src
),
1246 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1249 /* set neighbor to DOWN */
1250 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1251 /* delete neighbor */
1252 eigrp_nbr_delete(nbr
);
1261 * Execute hard restart for all neighbors on interface
1263 DEFUN (clear_ip_eigrp_neighbors_int
,
1264 clear_ip_eigrp_neighbors_int_cmd
,
1265 "clear ip eigrp neighbors IFNAME",
1269 "Clear IP-EIGRP neighbors\n"
1270 "Interface's name\n")
1272 struct eigrp
*eigrp
;
1273 struct eigrp_interface
*ei
;
1274 struct listnode
*node2
, *nnode2
;
1275 struct eigrp_neighbor
*nbr
;
1278 /* Check if eigrp process is enabled */
1279 eigrp
= eigrp_lookup();
1280 if (eigrp
== NULL
) {
1281 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1285 /* lookup interface by specified name */
1286 argv_find(argv
, argc
, "IFNAME", &idx
);
1287 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[idx
]->arg
);
1289 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[idx
]->arg
);
1293 /* send Goodbye Hello */
1294 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1296 /* iterate over all neighbors on eigrp interface */
1297 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1298 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1299 zlog_debug("Neighbor %s (%s) is down: manually cleared",
1300 inet_ntoa(nbr
->src
),
1301 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1303 vty_time_print(vty
, 0);
1305 "Neighbor %s (%s) is down: manually cleared\n",
1306 inet_ntoa(nbr
->src
),
1307 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1310 /* set neighbor to DOWN */
1311 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1312 /* delete neighbor */
1313 eigrp_nbr_delete(nbr
);
1321 * Execute hard restart for neighbor specified by IP
1323 DEFUN (clear_ip_eigrp_neighbors_IP
,
1324 clear_ip_eigrp_neighbors_IP_cmd
,
1325 "clear ip eigrp neighbors A.B.C.D",
1329 "Clear IP-EIGRP neighbors\n"
1330 "IP-EIGRP neighbor address\n")
1332 struct eigrp
*eigrp
;
1333 struct eigrp_neighbor
*nbr
;
1334 struct in_addr nbr_addr
;
1336 if (!inet_aton(argv
[4]->arg
, &nbr_addr
)) {
1337 vty_out(vty
, "Unable to parse %s", argv
[4]->arg
);
1341 /* Check if eigrp process is enabled */
1342 eigrp
= eigrp_lookup();
1343 if (eigrp
== NULL
) {
1344 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1348 /* lookup neighbor in whole process */
1349 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1351 /* if neighbor doesn't exists, notify user and exit */
1353 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1357 /* execute hard reset on neighbor */
1358 eigrp_nbr_hard_restart(nbr
, vty
);
1364 * Execute graceful restart for all neighbors
1366 DEFUN (clear_ip_eigrp_neighbors_soft
,
1367 clear_ip_eigrp_neighbors_soft_cmd
,
1368 "clear ip eigrp neighbors soft",
1372 "Clear IP-EIGRP neighbors\n"
1373 "Resync with peers without adjacency reset\n")
1375 struct eigrp
*eigrp
;
1377 /* Check if eigrp process is enabled */
1378 eigrp
= eigrp_lookup();
1379 if (eigrp
== NULL
) {
1380 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1384 /* execute graceful restart on all neighbors */
1385 eigrp_update_send_process_GR(eigrp
, EIGRP_GR_MANUAL
, vty
);
1391 * Execute graceful restart for all neighbors on interface
1393 DEFUN (clear_ip_eigrp_neighbors_int_soft
,
1394 clear_ip_eigrp_neighbors_int_soft_cmd
,
1395 "clear ip eigrp neighbors IFNAME soft",
1399 "Clear IP-EIGRP neighbors\n"
1400 "Interface's name\n"
1401 "Resync with peer without adjacency reset\n")
1403 struct eigrp
*eigrp
;
1404 struct eigrp_interface
*ei
;
1406 /* Check if eigrp process is enabled */
1407 eigrp
= eigrp_lookup();
1408 if (eigrp
== NULL
) {
1409 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1413 /* lookup interface by specified name */
1414 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[4]->arg
);
1416 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[4]->arg
);
1420 /* execute graceful restart for all neighbors on interface */
1421 eigrp_update_send_interface_GR(ei
, EIGRP_GR_MANUAL
, vty
);
1426 * Execute graceful restart for neighbor specified by IP
1428 DEFUN (clear_ip_eigrp_neighbors_IP_soft
,
1429 clear_ip_eigrp_neighbors_IP_soft_cmd
,
1430 "clear ip eigrp neighbors A.B.C.D soft",
1434 "Clear IP-EIGRP neighbors\n"
1435 "IP-EIGRP neighbor address\n"
1436 "Resync with peer without adjacency reset\n")
1438 struct eigrp
*eigrp
;
1439 struct eigrp_neighbor
*nbr
;
1440 struct in_addr nbr_addr
;
1442 if (!inet_aton(argv
[4]->arg
, &nbr_addr
)) {
1443 vty_out(vty
, "Unable to parse: %s", argv
[4]->arg
);
1447 /* Check if eigrp process is enabled */
1448 eigrp
= eigrp_lookup();
1449 if (eigrp
== NULL
) {
1450 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1454 /* lookup neighbor in whole process */
1455 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1457 /* if neighbor doesn't exists, notify user and exit */
1459 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1463 /* execute graceful restart on neighbor */
1464 eigrp_update_send_GR(nbr
, EIGRP_GR_MANUAL
, vty
);
1469 static struct cmd_node eigrp_node
= {EIGRP_NODE
, "%s(config-router)# ", 1};
1471 /* Save EIGRP configuration */
1472 static int eigrp_config_write(struct vty
*vty
)
1474 struct eigrp
*eigrp
;
1478 eigrp
= eigrp_lookup();
1479 if (eigrp
!= NULL
) {
1480 /* Writes 'router eigrp' section to config */
1481 config_write_eigrp_router(vty
, eigrp
);
1483 /* Interface config print */
1484 config_write_interfaces(vty
, eigrp
);
1486 // /* static neighbor print. */
1487 // config_write_eigrp_nbr_nbma (vty, eigrp);
1489 // /* Virtual-Link print. */
1490 // config_write_virtual_link (vty, eigrp);
1492 // /* Default metric configuration. */
1493 // config_write_eigrp_default_metric (vty, eigrp);
1495 // /* Distribute-list and default-information print. */
1496 // config_write_eigrp_distribute (vty, eigrp);
1498 // /* Distance configuration. */
1499 // config_write_eigrp_distance (vty, eigrp)
1505 void eigrp_vty_show_init(void)
1507 install_element(VIEW_NODE
, &show_ip_eigrp_interfaces_cmd
);
1509 install_element(VIEW_NODE
, &show_ip_eigrp_neighbors_cmd
);
1511 install_element(VIEW_NODE
, &show_ip_eigrp_topology_cmd
);
1513 install_element(VIEW_NODE
, &show_ip_eigrp_topology_detail_cmd
);
1516 /* eigrpd's interface node. */
1517 static struct cmd_node eigrp_interface_node
= {INTERFACE_NODE
,
1518 "%s(config-if)# ", 1};
1520 void eigrp_vty_if_init(void)
1522 install_node(&eigrp_interface_node
, eigrp_write_interface
);
1525 /* Delay and bandwidth configuration commands*/
1526 install_element(INTERFACE_NODE
, &eigrp_if_delay_cmd
);
1527 install_element(INTERFACE_NODE
, &no_eigrp_if_delay_cmd
);
1528 install_element(INTERFACE_NODE
, &eigrp_if_bandwidth_cmd
);
1529 install_element(INTERFACE_NODE
, &no_eigrp_if_bandwidth_cmd
);
1531 /*Hello-interval and hold-time interval configuration commands*/
1532 install_element(INTERFACE_NODE
, &eigrp_if_ip_holdinterval_cmd
);
1533 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_holdinterval_cmd
);
1534 install_element(INTERFACE_NODE
, &eigrp_if_ip_hellointerval_cmd
);
1535 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_hellointerval_cmd
);
1537 /* "Authentication configuration commands */
1538 install_element(INTERFACE_NODE
, &eigrp_authentication_mode_cmd
);
1539 install_element(INTERFACE_NODE
, &no_eigrp_authentication_mode_cmd
);
1540 install_element(INTERFACE_NODE
, &eigrp_authentication_keychain_cmd
);
1541 install_element(INTERFACE_NODE
, &no_eigrp_authentication_keychain_cmd
);
1543 /*EIGRP Summarization commands*/
1544 install_element(INTERFACE_NODE
, &eigrp_ip_summary_address_cmd
);
1545 install_element(INTERFACE_NODE
, &no_eigrp_ip_summary_address_cmd
);
1548 static void eigrp_vty_zebra_init(void)
1550 install_element(EIGRP_NODE
, &eigrp_redistribute_source_metric_cmd
);
1551 install_element(EIGRP_NODE
, &no_eigrp_redistribute_source_metric_cmd
);
1554 /* Install EIGRP related vty commands. */
1555 void eigrp_vty_init(void)
1557 install_node(&eigrp_node
, eigrp_config_write
);
1559 install_default(EIGRP_NODE
);
1561 install_element(CONFIG_NODE
, &router_eigrp_cmd
);
1562 install_element(CONFIG_NODE
, &no_router_eigrp_cmd
);
1563 install_element(EIGRP_NODE
, &eigrp_network_cmd
);
1564 install_element(EIGRP_NODE
, &no_eigrp_network_cmd
);
1565 install_element(EIGRP_NODE
, &eigrp_variance_cmd
);
1566 install_element(EIGRP_NODE
, &no_eigrp_variance_cmd
);
1567 install_element(EIGRP_NODE
, &eigrp_router_id_cmd
);
1568 install_element(EIGRP_NODE
, &no_eigrp_router_id_cmd
);
1569 install_element(EIGRP_NODE
, &eigrp_passive_interface_cmd
);
1570 install_element(EIGRP_NODE
, &no_eigrp_passive_interface_cmd
);
1571 install_element(EIGRP_NODE
, &eigrp_timers_active_cmd
);
1572 install_element(EIGRP_NODE
, &no_eigrp_timers_active_cmd
);
1573 install_element(EIGRP_NODE
, &eigrp_metric_weights_cmd
);
1574 install_element(EIGRP_NODE
, &no_eigrp_metric_weights_cmd
);
1575 install_element(EIGRP_NODE
, &eigrp_maximum_paths_cmd
);
1576 install_element(EIGRP_NODE
, &no_eigrp_maximum_paths_cmd
);
1577 install_element(EIGRP_NODE
, &eigrp_neighbor_cmd
);
1578 install_element(EIGRP_NODE
, &no_eigrp_neighbor_cmd
);
1580 /* commands for manual hard restart */
1581 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_cmd
);
1582 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_cmd
);
1583 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_cmd
);
1584 /* commands for manual graceful restart */
1585 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_soft_cmd
);
1586 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_soft_cmd
);
1587 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_soft_cmd
);
1589 eigrp_vty_zebra_init();