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",
113 ei
->params
.auth_keychain
);
116 if (ei
->params
.v_hello
!= EIGRP_HELLO_INTERVAL_DEFAULT
) {
117 vty_out(vty
, " ip hello-interval eigrp %d\n",
121 if (ei
->params
.v_wait
!= EIGRP_HOLD_INTERVAL_DEFAULT
) {
122 vty_out(vty
, " ip hold-time eigrp %d\n",
126 /*Separate this EIGRP interface configuration from the others*/
127 vty_endframe(vty
, "!\n");
133 static int eigrp_write_interface(struct vty
*vty
)
135 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
136 struct interface
*ifp
;
137 struct eigrp_interface
*ei
;
139 FOR_ALL_INTERFACES (vrf
, ifp
) {
144 vty_frame(vty
, "interface %s\n", ifp
->name
);
147 vty_out(vty
, " description %s\n", ifp
->desc
);
149 if (ei
->params
.bandwidth
!= EIGRP_BANDWIDTH_DEFAULT
)
150 vty_out(vty
, " bandwidth %u\n",
151 ei
->params
.bandwidth
);
152 if (ei
->params
.delay
!= EIGRP_DELAY_DEFAULT
)
153 vty_out(vty
, " delay %u\n", ei
->params
.delay
);
154 if (ei
->params
.v_hello
!= EIGRP_HELLO_INTERVAL_DEFAULT
)
155 vty_out(vty
, " ip hello-interval eigrp %u\n",
157 if (ei
->params
.v_wait
!= EIGRP_HOLD_INTERVAL_DEFAULT
)
158 vty_out(vty
, " ip hold-time eigrp %u\n",
161 vty_endframe(vty
, "!\n");
168 * Writes distribute lists to config
170 static int config_write_eigrp_distribute(struct vty
*vty
, struct eigrp
*eigrp
)
174 /* Distribute configuration. */
175 write
+= config_write_distribute(vty
);
181 * Writes 'router eigrp' section to config
183 static int config_write_eigrp_router(struct vty
*vty
, struct eigrp
*eigrp
)
187 /* `router eigrp' print. */
188 vty_out(vty
, "router eigrp %d\n", eigrp
->AS
);
192 if (!eigrp
->networks
)
195 /* Router ID print. */
196 if (eigrp
->router_id_static
!= 0) {
197 struct in_addr router_id_static
;
198 router_id_static
.s_addr
= htonl(eigrp
->router_id_static
);
199 vty_out(vty
, " eigrp router-id %s\n",
200 inet_ntoa(router_id_static
));
203 /* Network area print. */
204 config_write_network(vty
, eigrp
);
206 /* Distribute-list and default-information print. */
207 config_write_eigrp_distribute(vty
, eigrp
);
209 /*Separate EIGRP configuration from the rest of the config*/
215 DEFUN_NOSH (router_eigrp
,
217 "router eigrp (1-65535)",
218 "Enable a routing process\n"
219 "Start EIGRP configuration\n"
220 "AS Number to use\n")
222 struct eigrp
*eigrp
= eigrp_get(argv
[2]->arg
);
223 VTY_PUSH_CONTEXT(EIGRP_NODE
, eigrp
);
228 DEFUN (no_router_eigrp
,
230 "no router eigrp (1-65535)",
233 "EIGRP configuration\n"
234 "AS number to use\n")
236 vty
->node
= CONFIG_NODE
;
240 eigrp
= eigrp_lookup();
242 vty_out(vty
, " EIGRP Routing Process not enabled\n");
246 if (eigrp
->AS
!= atoi(argv
[3]->arg
)) {
247 vty_out(vty
, "%% Attempting to deconfigure non-existent AS\n");
248 return CMD_WARNING_CONFIG_FAILED
;
251 eigrp_finish_final(eigrp
);
256 DEFUN (eigrp_router_id
,
258 "eigrp router-id A.B.C.D",
259 "EIGRP specific commands\n"
260 "Router ID for this EIGRP process\n"
261 "EIGRP Router-ID in IP address format\n")
263 // struct eigrp *eigrp = vty->index;
269 DEFUN (no_eigrp_router_id
,
270 no_eigrp_router_id_cmd
,
271 "no eigrp router-id A.B.C.D",
273 "EIGRP specific commands\n"
274 "Router ID for this EIGRP process\n"
275 "EIGRP Router-ID in IP address format\n")
277 // struct eigrp *eigrp = vty->index;
283 DEFUN (eigrp_passive_interface
,
284 eigrp_passive_interface_cmd
,
285 "passive-interface IFNAME",
286 "Suppress routing updates on an interface\n"
287 "Interface to suppress on\n")
289 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
290 struct eigrp_interface
*ei
;
291 struct listnode
*node
;
292 char *ifname
= argv
[1]->arg
;
294 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
295 if (strcmp(ifname
, ei
->ifp
->name
) == 0) {
296 ei
->params
.passive_interface
= EIGRP_IF_PASSIVE
;
303 DEFUN (no_eigrp_passive_interface
,
304 no_eigrp_passive_interface_cmd
,
305 "no passive-interface IFNAME",
307 "Suppress routing updates on an interface\n"
308 "Interface to suppress on\n")
310 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
311 struct eigrp_interface
*ei
;
312 struct listnode
*node
;
313 char *ifname
= argv
[2]->arg
;
315 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
316 if (strcmp(ifname
, ei
->ifp
->name
) == 0) {
317 ei
->params
.passive_interface
= EIGRP_IF_ACTIVE
;
325 DEFUN (eigrp_timers_active
,
326 eigrp_timers_active_cmd
,
327 "timers active-time <(1-65535)|disabled>",
328 "Adjust routing timers\n"
329 "Time limit for active state\n"
330 "Active state time limit in minutes\n"
331 "Disable time limit for active state\n")
333 // struct eigrp *eigrp = vty->index;
339 DEFUN (no_eigrp_timers_active
,
340 no_eigrp_timers_active_cmd
,
341 "no timers active-time <(1-65535)|disabled>",
343 "Adjust routing timers\n"
344 "Time limit for active state\n"
345 "Active state time limit in minutes\n"
346 "Disable time limit for active state\n")
348 // struct eigrp *eigrp = vty->index;
355 DEFUN (eigrp_metric_weights
,
356 eigrp_metric_weights_cmd
,
357 "metric weights (0-255) (0-255) (0-255) (0-255) (0-255) ",
358 "Modify metrics and parameters for advertisement\n"
359 "Modify metric coefficients\n"
366 // struct eigrp *eigrp = vty->index;
372 DEFUN (no_eigrp_metric_weights
,
373 no_eigrp_metric_weights_cmd
,
374 "no metric weights <0-255> <0-255> <0-255> <0-255> <0-255>",
376 "Modify metrics and parameters for advertisement\n"
377 "Modify metric coefficients\n"
384 // struct eigrp *eigrp = vty->index;
391 DEFUN (eigrp_network
,
394 "Enable routing on an IP network\n"
395 "EIGRP network prefix\n")
397 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
401 str2prefix(argv
[1]->arg
, &p
);
403 ret
= eigrp_network_set(eigrp
, &p
);
406 vty_out(vty
, "There is already same network statement.\n");
413 DEFUN (no_eigrp_network
,
414 no_eigrp_network_cmd
,
415 "no network A.B.C.D/M",
417 "Disable routing on an IP network\n"
418 "EIGRP network prefix\n")
420 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
424 str2prefix(argv
[2]->arg
, &p
);
426 ret
= eigrp_network_unset(eigrp
, &p
);
429 vty_out(vty
, "Can't find specified network configuration.\n");
430 return CMD_WARNING_CONFIG_FAILED
;
436 DEFUN (eigrp_neighbor
,
439 "Specify a neighbor router\n"
440 "Neighbor address\n")
442 // struct eigrp *eigrp = vty->index;
447 DEFUN (no_eigrp_neighbor
,
448 no_eigrp_neighbor_cmd
,
449 "no neighbor A.B.C.D",
451 "Specify a neighbor router\n"
452 "Neighbor address\n")
454 // struct eigrp *eigrp = vty->index;
459 DEFUN (show_ip_eigrp_topology
,
460 show_ip_eigrp_topology_cmd
,
461 "show ip eigrp topology [all-links]",
464 "IP-EIGRP show commands\n"
465 "IP-EIGRP topology\n"
466 "Show all links in topology table\n")
469 struct listnode
*node
;
470 struct eigrp_prefix_entry
*tn
;
471 struct eigrp_nexthop_entry
*te
;
472 struct route_node
*rn
;
475 eigrp
= eigrp_lookup();
477 vty_out(vty
, " EIGRP Routing Process not enabled\n");
481 show_ip_eigrp_topology_header(vty
, eigrp
);
483 for (rn
= route_top(eigrp
->topology_table
); rn
; rn
= route_next(rn
)) {
489 for (ALL_LIST_ELEMENTS_RO(tn
->entries
, node
, te
)) {
492 & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG
)
493 == EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG
)
495 & EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG
)
496 == EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG
))) {
497 show_ip_eigrp_nexthop_entry(vty
, eigrp
, te
,
507 ALIAS(show_ip_eigrp_topology
, show_ip_eigrp_topology_detail_cmd
,
508 "show ip eigrp topology <A.B.C.D|A.B.C.D/M|detail|summary>",
510 "IP-EIGRP show commands\n"
511 "IP-EIGRP topology\n"
512 "Netwok to display information about\n"
513 "IP prefix <network>/<length>, e.g., 192.168.0.0/16\n"
514 "Show all links in topology table\n"
515 "Show a summary of the topology table\n")
517 DEFUN (show_ip_eigrp_interfaces
,
518 show_ip_eigrp_interfaces_cmd
,
519 "show ip eigrp interfaces [IFNAME] [detail]",
522 "IP-EIGRP show commands\n"
523 "IP-EIGRP interfaces\n"
524 "Interface name to look at\n"
525 "Detailed information\n")
527 struct eigrp_interface
*ei
;
529 struct listnode
*node
;
532 const char *ifname
= NULL
;
534 eigrp
= eigrp_lookup();
536 vty_out(vty
, "EIGRP Routing Process not enabled\n");
540 if (argv_find(argv
, argc
, "IFNAME", &idx
))
541 ifname
= argv
[idx
]->arg
;
543 if (argv_find(argv
, argc
, "detail", &idx
))
547 show_ip_eigrp_interface_header(vty
, eigrp
);
549 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
550 if (!ifname
|| strcmp(ei
->ifp
->name
, ifname
) == 0) {
551 show_ip_eigrp_interface_sub(vty
, eigrp
, ei
);
553 show_ip_eigrp_interface_detail(vty
, eigrp
, ei
);
560 DEFUN (show_ip_eigrp_neighbors
,
561 show_ip_eigrp_neighbors_cmd
,
562 "show ip eigrp neighbors [IFNAME] [detail]",
565 "IP-EIGRP show commands\n"
566 "IP-EIGRP neighbors\n"
567 "Interface to show on\n"
568 "Detailed Information\n")
571 struct eigrp_interface
*ei
;
572 struct listnode
*node
, *node2
, *nnode2
;
573 struct eigrp_neighbor
*nbr
;
576 const char *ifname
= NULL
;
578 eigrp
= eigrp_lookup();
580 vty_out(vty
, " EIGRP Routing Process not enabled\n");
584 if (argv_find(argv
, argc
, "IFNAME", &idx
))
585 ifname
= argv
[idx
]->arg
;
587 detail
= (argv_find(argv
, argc
, "detail", &idx
));
589 show_ip_eigrp_neighbor_header(vty
, eigrp
);
591 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
592 if (!ifname
|| strcmp(ei
->ifp
->name
, ifname
) == 0) {
593 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
594 if (detail
|| (nbr
->state
== EIGRP_NEIGHBOR_UP
))
595 show_ip_eigrp_neighbor_sub(vty
, nbr
,
604 DEFUN (eigrp_if_delay
,
606 "delay (1-16777215)",
607 "Specify interface throughput delay\n"
608 "Throughput delay (tens of microseconds)\n")
610 VTY_DECLVAR_CONTEXT(interface
, ifp
);
611 struct eigrp_interface
*ei
= ifp
->info
;
615 eigrp
= eigrp_lookup();
617 vty_out(vty
, " EIGRP Routing Process not enabled\n");
623 vty_out(vty
, " EIGRP not configured on this interface\n");
626 delay
= atoi(argv
[1]->arg
);
628 ei
->params
.delay
= delay
;
634 DEFUN (no_eigrp_if_delay
,
635 no_eigrp_if_delay_cmd
,
636 "no delay (1-16777215)",
638 "Specify interface throughput delay\n"
639 "Throughput delay (tens of microseconds)\n")
641 VTY_DECLVAR_CONTEXT(interface
, ifp
);
642 struct eigrp_interface
*ei
= ifp
->info
;
645 eigrp
= eigrp_lookup();
647 vty_out(vty
, " EIGRP Routing Process not enabled\n");
652 vty_out(vty
, " EIGRP not configured on this interface\n");
656 ei
->params
.delay
= EIGRP_DELAY_DEFAULT
;
662 DEFUN (eigrp_if_bandwidth
,
663 eigrp_if_bandwidth_cmd
,
664 "eigrp bandwidth (1-10000000)",
665 "EIGRP specific commands\n"
666 "Set bandwidth informational parameter\n"
667 "Bandwidth in kilobits\n")
669 VTY_DECLVAR_CONTEXT(interface
, ifp
);
670 struct eigrp_interface
*ei
= ifp
->info
;
674 eigrp
= eigrp_lookup();
676 vty_out(vty
, " EIGRP Routing Process not enabled\n");
681 vty_out(vty
, " EIGRP not configured on this interface\n");
685 bandwidth
= atoi(argv
[1]->arg
);
687 ei
->params
.bandwidth
= bandwidth
;
693 DEFUN (no_eigrp_if_bandwidth
,
694 no_eigrp_if_bandwidth_cmd
,
695 "no eigrp bandwidth [(1-10000000)]",
697 "EIGRP specific commands\n"
698 "Set bandwidth informational parameter\n"
699 "Bandwidth in kilobits\n")
701 VTY_DECLVAR_CONTEXT(interface
, ifp
);
702 struct eigrp_interface
*ei
= ifp
->info
;
705 eigrp
= eigrp_lookup();
707 vty_out(vty
, " EIGRP Routing Process not enabled\n");
712 vty_out(vty
, " EIGRP not configured on this interface\n");
716 ei
->params
.bandwidth
= EIGRP_BANDWIDTH_DEFAULT
;
722 DEFUN (eigrp_if_ip_hellointerval
,
723 eigrp_if_ip_hellointerval_cmd
,
724 "ip hello-interval eigrp (1-65535)",
725 "Interface Internet Protocol config commands\n"
726 "Configures EIGRP hello interval\n"
727 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
728 "Seconds between hello transmissions\n")
730 VTY_DECLVAR_CONTEXT(interface
, ifp
);
731 struct eigrp_interface
*ei
= ifp
->info
;
735 eigrp
= eigrp_lookup();
737 vty_out(vty
, " EIGRP Routing Process not enabled\n");
742 vty_out(vty
, " EIGRP not configured on this interface\n");
746 hello
= atoi(argv
[3]->arg
);
748 ei
->params
.v_hello
= hello
;
753 DEFUN (no_eigrp_if_ip_hellointerval
,
754 no_eigrp_if_ip_hellointerval_cmd
,
755 "no ip hello-interval eigrp [(1-65535)]",
757 "Interface Internet Protocol config commands\n"
758 "Configures EIGRP hello interval\n"
759 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
760 "Seconds between hello transmissions\n")
762 VTY_DECLVAR_CONTEXT(interface
, ifp
);
763 struct eigrp_interface
*ei
= ifp
->info
;
766 eigrp
= eigrp_lookup();
768 vty_out(vty
, " EIGRP Routing Process not enabled\n");
773 vty_out(vty
, " EIGRP not configured on this interface\n");
777 ei
->params
.v_hello
= EIGRP_HELLO_INTERVAL_DEFAULT
;
779 THREAD_TIMER_OFF(ei
->t_hello
);
780 thread_add_timer(master
, eigrp_hello_timer
, ei
, 1,
786 DEFUN (eigrp_if_ip_holdinterval
,
787 eigrp_if_ip_holdinterval_cmd
,
788 "ip hold-time eigrp (1-65535)",
789 "Interface Internet Protocol config commands\n"
790 "Configures EIGRP IPv4 hold time\n"
791 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
792 "Seconds before neighbor is considered down\n")
794 VTY_DECLVAR_CONTEXT(interface
, ifp
);
795 struct eigrp_interface
*ei
= ifp
->info
;
799 eigrp
= eigrp_lookup();
801 vty_out(vty
, " EIGRP Routing Process not enabled\n");
806 vty_out(vty
, " EIGRP not configured on this interface\n");
810 hold
= atoi(argv
[3]->arg
);
812 ei
->params
.v_wait
= hold
;
817 DEFUN (eigrp_ip_summary_address
,
818 eigrp_ip_summary_address_cmd
,
819 "ip summary-address eigrp (1-65535) A.B.C.D/M",
820 "Interface Internet Protocol config commands\n"
821 "Perform address summarization\n"
822 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
824 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
826 // VTY_DECLVAR_CONTEXT(interface, ifp);
830 eigrp
= eigrp_lookup();
832 vty_out(vty
, " EIGRP Routing Process not enabled\n");
836 // AS = atoi (argv[3]->arg);
843 DEFUN (no_eigrp_ip_summary_address
,
844 no_eigrp_ip_summary_address_cmd
,
845 "no ip summary-address eigrp (1-65535) A.B.C.D/M",
847 "Interface Internet Protocol config commands\n"
848 "Perform address summarization\n"
849 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
851 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
853 // VTY_DECLVAR_CONTEXT(interface, ifp);
857 eigrp
= eigrp_lookup();
859 vty_out(vty
, " EIGRP Routing Process not enabled\n");
863 // AS = atoi (argv[4]->arg);
870 DEFUN (no_eigrp_if_ip_holdinterval
,
871 no_eigrp_if_ip_holdinterval_cmd
,
872 "no ip hold-time eigrp",
874 "Interface Internet Protocol config commands\n"
875 "Configures EIGRP hello interval\n"
876 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
877 "Seconds before neighbor is considered down\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 DEFUN (eigrp_authentication_keychain
,
983 eigrp_authentication_keychain_cmd
,
984 "ip authentication key-chain eigrp (1-65535) WORD",
985 "Interface Internet Protocol config commands\n"
986 "Authentication subcommands\n"
988 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
989 "Autonomous system number\n"
990 "Name of key-chain\n")
992 VTY_DECLVAR_CONTEXT(interface
, ifp
);
993 struct eigrp_interface
*ei
= ifp
->info
;
995 struct keychain
*keychain
;
997 eigrp
= eigrp_lookup();
999 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1004 vty_out(vty
, " EIGRP not configured on this interface\n");
1008 keychain
= keychain_lookup(argv
[4]->arg
);
1009 if (keychain
!= NULL
) {
1010 if (ei
->params
.auth_keychain
) {
1011 free(ei
->params
.auth_keychain
);
1012 ei
->params
.auth_keychain
=
1013 strdup(keychain
->name
);
1015 ei
->params
.auth_keychain
=
1016 strdup(keychain
->name
);
1018 vty_out(vty
, "Key chain with specified name not found\n");
1023 DEFUN (no_eigrp_authentication_keychain
,
1024 no_eigrp_authentication_keychain_cmd
,
1025 "no ip authentication key-chain eigrp (1-65535) WORD",
1027 "Interface Internet Protocol config commands\n"
1028 "Authentication subcommands\n"
1030 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
1031 "Autonomous system number\n"
1032 "Name of key-chain\n")
1034 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1035 struct eigrp_interface
*ei
= ifp
->info
;
1036 struct eigrp
*eigrp
;
1038 eigrp
= eigrp_lookup();
1039 if (eigrp
== NULL
) {
1040 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1045 vty_out(vty
, " EIGRP not configured on this interface\n");
1049 if ((ei
->params
.auth_keychain
!= NULL
)
1050 && (strcmp(ei
->params
.auth_keychain
, argv
[5]->arg
) == 0)) {
1051 free(ei
->params
.auth_keychain
);
1052 ei
->params
.auth_keychain
= NULL
;
1055 "Key chain with specified name not configured on interface\n");
1060 DEFUN (eigrp_redistribute_source_metric
,
1061 eigrp_redistribute_source_metric_cmd
,
1062 "redistribute " FRR_REDIST_STR_EIGRPD
1063 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
1065 FRR_REDIST_HELP_STR_EIGRPD
1066 "Metric for redistributed routes\n"
1067 "Bandwidth metric in Kbits per second\n"
1068 "EIGRP delay metric, in 10 microsecond units\n"
1069 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1070 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1071 "EIGRP MTU of the path\n")
1073 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1074 struct eigrp_metrics metrics_from_command
= {0};
1078 /* Get distribute source. */
1079 argv_find(argv
, argc
, "redistribute", &idx
);
1080 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1082 vty_out(vty
, "%% Invalid route type\n");
1083 return CMD_WARNING_CONFIG_FAILED
;
1086 /* Get metrics values */
1088 return eigrp_redistribute_set(eigrp
, source
, metrics_from_command
);
1091 DEFUN (no_eigrp_redistribute_source_metric
,
1092 no_eigrp_redistribute_source_metric_cmd
,
1093 "no redistribute " FRR_REDIST_STR_EIGRPD
1094 " metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)",
1097 FRR_REDIST_HELP_STR_EIGRPD
1098 "Metric for redistributed routes\n"
1099 "Bandwidth metric in Kbits per second\n"
1100 "EIGRP delay metric, in 10 microsecond units\n"
1101 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1102 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1103 "EIGRP MTU of the path\n")
1105 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1109 /* Get distribute source. */
1110 argv_find(argv
, argc
, "redistribute", &idx
);
1111 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1113 vty_out(vty
, "%% Invalid route type\n");
1114 return CMD_WARNING_CONFIG_FAILED
;
1117 /* Get metrics values */
1119 return eigrp_redistribute_unset(eigrp
, source
);
1122 DEFUN (eigrp_variance
,
1125 "Control load balancing variance\n"
1126 "Metric variance multiplier\n")
1128 struct eigrp
*eigrp
;
1131 eigrp
= eigrp_lookup();
1132 if (eigrp
== NULL
) {
1133 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1136 variance
= atoi(argv
[1]->arg
);
1138 eigrp
->variance
= variance
;
1145 DEFUN (no_eigrp_variance
,
1146 no_eigrp_variance_cmd
,
1147 "no variance (1-128)",
1149 "Control load balancing variance\n"
1150 "Metric variance multiplier\n")
1152 struct eigrp
*eigrp
;
1153 eigrp
= eigrp_lookup();
1154 if (eigrp
== NULL
) {
1155 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1159 eigrp
->variance
= EIGRP_VARIANCE_DEFAULT
;
1166 DEFUN (eigrp_maximum_paths
,
1167 eigrp_maximum_paths_cmd
,
1168 "maximum-paths (1-32)",
1169 "Forward packets over multiple paths\n"
1170 "Number of paths\n")
1172 struct eigrp
*eigrp
;
1175 eigrp
= eigrp_lookup();
1176 if (eigrp
== NULL
) {
1177 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1181 max
= atoi(argv
[1]->arg
);
1183 eigrp
->max_paths
= max
;
1190 DEFUN (no_eigrp_maximum_paths
,
1191 no_eigrp_maximum_paths_cmd
,
1192 "no maximum-paths <1-32>",
1194 "Forward packets over multiple paths\n"
1195 "Number of paths\n")
1197 struct eigrp
*eigrp
;
1199 eigrp
= eigrp_lookup();
1200 if (eigrp
== NULL
) {
1201 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1205 eigrp
->max_paths
= EIGRP_MAX_PATHS_DEFAULT
;
1213 * Execute hard restart for all neighbors
1215 DEFUN (clear_ip_eigrp_neighbors
,
1216 clear_ip_eigrp_neighbors_cmd
,
1217 "clear ip eigrp neighbors",
1221 "Clear IP-EIGRP neighbors\n")
1223 struct eigrp
*eigrp
;
1224 struct eigrp_interface
*ei
;
1225 struct listnode
*node
, *node2
, *nnode2
;
1226 struct eigrp_neighbor
*nbr
;
1228 /* Check if eigrp process is enabled */
1229 eigrp
= eigrp_lookup();
1230 if (eigrp
== NULL
) {
1231 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1235 /* iterate over all eigrp interfaces */
1236 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
1237 /* send Goodbye Hello */
1238 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1240 /* iterate over all neighbors on eigrp interface */
1241 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1242 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1244 "Neighbor %s (%s) is down: manually cleared",
1245 inet_ntoa(nbr
->src
),
1246 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1248 vty_time_print(vty
, 0);
1250 "Neighbor %s (%s) is down: manually cleared\n",
1251 inet_ntoa(nbr
->src
),
1252 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1255 /* set neighbor to DOWN */
1256 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1257 /* delete neighbor */
1258 eigrp_nbr_delete(nbr
);
1267 * Execute hard restart for all neighbors on interface
1269 DEFUN (clear_ip_eigrp_neighbors_int
,
1270 clear_ip_eigrp_neighbors_int_cmd
,
1271 "clear ip eigrp neighbors IFNAME",
1275 "Clear IP-EIGRP neighbors\n"
1276 "Interface's name\n")
1278 struct eigrp
*eigrp
;
1279 struct eigrp_interface
*ei
;
1280 struct listnode
*node2
, *nnode2
;
1281 struct eigrp_neighbor
*nbr
;
1284 /* Check if eigrp process is enabled */
1285 eigrp
= eigrp_lookup();
1286 if (eigrp
== NULL
) {
1287 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1291 /* lookup interface by specified name */
1292 argv_find(argv
, argc
, "IFNAME", &idx
);
1293 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[idx
]->arg
);
1295 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[idx
]->arg
);
1299 /* send Goodbye Hello */
1300 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1302 /* iterate over all neighbors on eigrp interface */
1303 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1304 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1305 zlog_debug("Neighbor %s (%s) is down: manually cleared",
1306 inet_ntoa(nbr
->src
),
1307 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1309 vty_time_print(vty
, 0);
1311 "Neighbor %s (%s) is down: manually cleared\n",
1312 inet_ntoa(nbr
->src
),
1313 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1316 /* set neighbor to DOWN */
1317 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1318 /* delete neighbor */
1319 eigrp_nbr_delete(nbr
);
1327 * Execute hard restart for neighbor specified by IP
1329 DEFUN (clear_ip_eigrp_neighbors_IP
,
1330 clear_ip_eigrp_neighbors_IP_cmd
,
1331 "clear ip eigrp neighbors A.B.C.D",
1335 "Clear IP-EIGRP neighbors\n"
1336 "IP-EIGRP neighbor address\n")
1338 struct eigrp
*eigrp
;
1339 struct eigrp_neighbor
*nbr
;
1340 struct in_addr nbr_addr
;
1342 if (!inet_aton(argv
[4]->arg
, &nbr_addr
)) {
1343 vty_out(vty
, "Unable to parse %s",
1348 /* Check if eigrp process is enabled */
1349 eigrp
= eigrp_lookup();
1350 if (eigrp
== NULL
) {
1351 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1355 /* lookup neighbor in whole process */
1356 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1358 /* if neighbor doesn't exists, notify user and exit */
1360 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1364 /* execute hard reset on neighbor */
1365 eigrp_nbr_hard_restart(nbr
, vty
);
1371 * Execute graceful restart for all neighbors
1373 DEFUN (clear_ip_eigrp_neighbors_soft
,
1374 clear_ip_eigrp_neighbors_soft_cmd
,
1375 "clear ip eigrp neighbors soft",
1379 "Clear IP-EIGRP neighbors\n"
1380 "Resync with peers without adjacency reset\n")
1382 struct eigrp
*eigrp
;
1384 /* Check if eigrp process is enabled */
1385 eigrp
= eigrp_lookup();
1386 if (eigrp
== NULL
) {
1387 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1391 /* execute graceful restart on all neighbors */
1392 eigrp_update_send_process_GR(eigrp
, EIGRP_GR_MANUAL
, vty
);
1398 * Execute graceful restart for all neighbors on interface
1400 DEFUN (clear_ip_eigrp_neighbors_int_soft
,
1401 clear_ip_eigrp_neighbors_int_soft_cmd
,
1402 "clear ip eigrp neighbors IFNAME soft",
1406 "Clear IP-EIGRP neighbors\n"
1407 "Interface's name\n"
1408 "Resync with peer without adjacency reset\n")
1410 struct eigrp
*eigrp
;
1411 struct eigrp_interface
*ei
;
1413 /* Check if eigrp process is enabled */
1414 eigrp
= eigrp_lookup();
1415 if (eigrp
== NULL
) {
1416 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1420 /* lookup interface by specified name */
1421 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[4]->arg
);
1423 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[4]->arg
);
1427 /* execute graceful restart for all neighbors on interface */
1428 eigrp_update_send_interface_GR(ei
, EIGRP_GR_MANUAL
, vty
);
1433 * Execute graceful restart for neighbor specified by IP
1435 DEFUN (clear_ip_eigrp_neighbors_IP_soft
,
1436 clear_ip_eigrp_neighbors_IP_soft_cmd
,
1437 "clear ip eigrp neighbors A.B.C.D soft",
1441 "Clear IP-EIGRP neighbors\n"
1442 "IP-EIGRP neighbor address\n"
1443 "Resync with peer without adjacency reset\n")
1445 struct eigrp
*eigrp
;
1446 struct eigrp_neighbor
*nbr
;
1447 struct in_addr nbr_addr
;
1449 if (!inet_aton(argv
[4]->arg
, &nbr_addr
)) {
1450 vty_out(vty
, "Unable to parse: %s",
1455 /* Check if eigrp process is enabled */
1456 eigrp
= eigrp_lookup();
1457 if (eigrp
== NULL
) {
1458 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1462 /* lookup neighbor in whole process */
1463 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1465 /* if neighbor doesn't exists, notify user and exit */
1467 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1471 /* execute graceful restart on neighbor */
1472 eigrp_update_send_GR(nbr
, EIGRP_GR_MANUAL
, vty
);
1477 static struct cmd_node eigrp_node
= {EIGRP_NODE
, "%s(config-router)# ", 1};
1479 /* Save EIGRP configuration */
1480 static int eigrp_config_write(struct vty
*vty
)
1482 struct eigrp
*eigrp
;
1486 eigrp
= eigrp_lookup();
1487 if (eigrp
!= NULL
) {
1488 /* Writes 'router eigrp' section to config */
1489 config_write_eigrp_router(vty
, eigrp
);
1491 /* Interface config print */
1492 config_write_interfaces(vty
, eigrp
);
1494 // /* static neighbor print. */
1495 // config_write_eigrp_nbr_nbma (vty, eigrp);
1497 // /* Virtual-Link print. */
1498 // config_write_virtual_link (vty, eigrp);
1500 // /* Default metric configuration. */
1501 // config_write_eigrp_default_metric (vty, eigrp);
1503 // /* Distribute-list and default-information print. */
1504 // config_write_eigrp_distribute (vty, eigrp);
1506 // /* Distance configuration. */
1507 // config_write_eigrp_distance (vty, eigrp)
1513 void eigrp_vty_show_init(void)
1515 install_element(VIEW_NODE
, &show_ip_eigrp_interfaces_cmd
);
1517 install_element(VIEW_NODE
, &show_ip_eigrp_neighbors_cmd
);
1519 install_element(VIEW_NODE
, &show_ip_eigrp_topology_cmd
);
1521 install_element(VIEW_NODE
, &show_ip_eigrp_topology_detail_cmd
);
1524 /* eigrpd's interface node. */
1525 static struct cmd_node eigrp_interface_node
= {INTERFACE_NODE
,
1526 "%s(config-if)# ", 1};
1528 void eigrp_vty_if_init(void)
1530 install_node(&eigrp_interface_node
, eigrp_write_interface
);
1533 /* Delay and bandwidth configuration commands*/
1534 install_element(INTERFACE_NODE
, &eigrp_if_delay_cmd
);
1535 install_element(INTERFACE_NODE
, &no_eigrp_if_delay_cmd
);
1536 install_element(INTERFACE_NODE
, &eigrp_if_bandwidth_cmd
);
1537 install_element(INTERFACE_NODE
, &no_eigrp_if_bandwidth_cmd
);
1539 /*Hello-interval and hold-time interval configuration commands*/
1540 install_element(INTERFACE_NODE
, &eigrp_if_ip_holdinterval_cmd
);
1541 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_holdinterval_cmd
);
1542 install_element(INTERFACE_NODE
, &eigrp_if_ip_hellointerval_cmd
);
1543 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_hellointerval_cmd
);
1545 /* "Authentication configuration commands */
1546 install_element(INTERFACE_NODE
, &eigrp_authentication_mode_cmd
);
1547 install_element(INTERFACE_NODE
, &no_eigrp_authentication_mode_cmd
);
1548 install_element(INTERFACE_NODE
, &eigrp_authentication_keychain_cmd
);
1549 install_element(INTERFACE_NODE
, &no_eigrp_authentication_keychain_cmd
);
1551 /*EIGRP Summarization commands*/
1552 install_element(INTERFACE_NODE
, &eigrp_ip_summary_address_cmd
);
1553 install_element(INTERFACE_NODE
, &no_eigrp_ip_summary_address_cmd
);
1556 static void eigrp_vty_zebra_init(void)
1558 install_element(EIGRP_NODE
, &eigrp_redistribute_source_metric_cmd
);
1559 install_element(EIGRP_NODE
, &no_eigrp_redistribute_source_metric_cmd
);
1562 /* Install EIGRP related vty commands. */
1563 void eigrp_vty_init(void)
1565 install_node(&eigrp_node
, eigrp_config_write
);
1567 install_default(EIGRP_NODE
);
1569 install_element(CONFIG_NODE
, &router_eigrp_cmd
);
1570 install_element(CONFIG_NODE
, &no_router_eigrp_cmd
);
1571 install_element(EIGRP_NODE
, &eigrp_network_cmd
);
1572 install_element(EIGRP_NODE
, &no_eigrp_network_cmd
);
1573 install_element(EIGRP_NODE
, &eigrp_variance_cmd
);
1574 install_element(EIGRP_NODE
, &no_eigrp_variance_cmd
);
1575 install_element(EIGRP_NODE
, &eigrp_router_id_cmd
);
1576 install_element(EIGRP_NODE
, &no_eigrp_router_id_cmd
);
1577 install_element(EIGRP_NODE
, &eigrp_passive_interface_cmd
);
1578 install_element(EIGRP_NODE
, &no_eigrp_passive_interface_cmd
);
1579 install_element(EIGRP_NODE
, &eigrp_timers_active_cmd
);
1580 install_element(EIGRP_NODE
, &no_eigrp_timers_active_cmd
);
1581 install_element(EIGRP_NODE
, &eigrp_metric_weights_cmd
);
1582 install_element(EIGRP_NODE
, &no_eigrp_metric_weights_cmd
);
1583 install_element(EIGRP_NODE
, &eigrp_maximum_paths_cmd
);
1584 install_element(EIGRP_NODE
, &no_eigrp_maximum_paths_cmd
);
1585 install_element(EIGRP_NODE
, &eigrp_neighbor_cmd
);
1586 install_element(EIGRP_NODE
, &no_eigrp_neighbor_cmd
);
1588 /* commands for manual hard restart */
1589 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_cmd
);
1590 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_cmd
);
1591 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_cmd
);
1592 /* commands for manual graceful restart */
1593 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_soft_cmd
);
1594 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_soft_cmd
);
1595 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_soft_cmd
);
1597 eigrp_vty_zebra_init();