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();
241 vty_out(vty
, " EIGRP Routing Process not enabled\n");
245 if (eigrp
->AS
!= atoi(argv
[3]->arg
)) {
246 vty_out(vty
, "%% Attempting to deconfigure non-existent AS\n");
247 return CMD_WARNING_CONFIG_FAILED
;
250 eigrp_finish_final(eigrp
);
255 DEFUN (eigrp_router_id
,
257 "eigrp router-id A.B.C.D",
258 "EIGRP specific commands\n"
259 "Router ID for this EIGRP process\n"
260 "EIGRP Router-ID in IP address format\n")
262 // struct eigrp *eigrp = vty->index;
268 DEFUN (no_eigrp_router_id
,
269 no_eigrp_router_id_cmd
,
270 "no eigrp router-id A.B.C.D",
272 "EIGRP specific commands\n"
273 "Router ID for this EIGRP process\n"
274 "EIGRP Router-ID in IP address format\n")
276 // struct eigrp *eigrp = vty->index;
282 DEFUN (eigrp_passive_interface
,
283 eigrp_passive_interface_cmd
,
284 "passive-interface IFNAME",
285 "Suppress routing updates on an interface\n"
286 "Interface to suppress on\n")
288 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
289 struct eigrp_interface
*ei
;
290 struct listnode
*node
;
291 char *ifname
= argv
[1]->arg
;
293 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
294 if (strcmp(ifname
, ei
->ifp
->name
) == 0)
295 SET_IF_PARAM(IF_DEF_PARAMS(ei
->ifp
), passive_interface
);
300 DEFUN (no_eigrp_passive_interface
,
301 no_eigrp_passive_interface_cmd
,
302 "no passive-interface IFNAME",
304 "Suppress routing updates on an interface\n"
305 "Interface to suppress on\n")
307 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
308 struct eigrp_interface
*ei
;
309 struct listnode
*node
;
310 char *ifname
= argv
[2]->arg
;
312 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
313 if (strcmp(ifname
, ei
->ifp
->name
) == 0)
314 UNSET_IF_PARAM(IF_DEF_PARAMS(ei
->ifp
),
321 DEFUN (eigrp_timers_active
,
322 eigrp_timers_active_cmd
,
323 "timers active-time <(1-65535)|disabled>",
324 "Adjust routing timers\n"
325 "Time limit for active state\n"
326 "Active state time limit in minutes\n"
327 "Disable time limit for active state\n")
329 // struct eigrp *eigrp = vty->index;
335 DEFUN (no_eigrp_timers_active
,
336 no_eigrp_timers_active_cmd
,
337 "no timers active-time <(1-65535)|disabled>",
339 "Adjust routing timers\n"
340 "Time limit for active state\n"
341 "Active state time limit in minutes\n"
342 "Disable time limit for active state\n")
344 // struct eigrp *eigrp = vty->index;
351 DEFUN (eigrp_metric_weights
,
352 eigrp_metric_weights_cmd
,
353 "metric weights (0-255) (0-255) (0-255) (0-255) (0-255) ",
354 "Modify metrics and parameters for advertisement\n"
355 "Modify metric coefficients\n"
362 // struct eigrp *eigrp = vty->index;
368 DEFUN (no_eigrp_metric_weights
,
369 no_eigrp_metric_weights_cmd
,
370 "no metric weights <0-255> <0-255> <0-255> <0-255> <0-255>",
372 "Modify metrics and parameters for advertisement\n"
373 "Modify metric coefficients\n"
380 // struct eigrp *eigrp = vty->index;
387 DEFUN (eigrp_network
,
390 "Enable routing on an IP network\n"
391 "EIGRP network prefix\n")
393 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
397 str2prefix(argv
[1]->arg
, &p
);
399 ret
= eigrp_network_set(eigrp
, &p
);
402 vty_out(vty
, "There is already same network statement.\n");
409 DEFUN (no_eigrp_network
,
410 no_eigrp_network_cmd
,
411 "no network A.B.C.D/M",
413 "Disable routing on an IP network\n"
414 "EIGRP network prefix\n")
416 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
420 str2prefix(argv
[2]->arg
, &p
);
422 ret
= eigrp_network_unset(eigrp
, &p
);
425 vty_out(vty
, "Can't find specified network configuration.\n");
426 return CMD_WARNING_CONFIG_FAILED
;
432 DEFUN (eigrp_neighbor
,
435 "Specify a neighbor router\n"
436 "Neighbor address\n")
438 // struct eigrp *eigrp = vty->index;
443 DEFUN (no_eigrp_neighbor
,
444 no_eigrp_neighbor_cmd
,
445 "no neighbor A.B.C.D",
447 "Specify a neighbor router\n"
448 "Neighbor address\n")
450 // struct eigrp *eigrp = vty->index;
455 DEFUN (show_ip_eigrp_topology
,
456 show_ip_eigrp_topology_cmd
,
457 "show ip eigrp topology [all-links]",
460 "IP-EIGRP show commands\n"
461 "IP-EIGRP topology\n"
462 "Show all links in topology table\n")
465 struct listnode
*node
, *node2
;
466 struct eigrp_prefix_entry
*tn
;
467 struct eigrp_neighbor_entry
*te
;
470 eigrp
= eigrp_lookup();
472 vty_out(vty
, " EIGRP Routing Process not enabled\n");
476 show_ip_eigrp_topology_header(vty
, eigrp
);
478 for (ALL_LIST_ELEMENTS_RO(eigrp
->topology_table
, node
, tn
)) {
480 for (ALL_LIST_ELEMENTS_RO(tn
->entries
, node2
, te
)) {
483 & EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG
)
484 == EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG
)
486 & EIGRP_NEIGHBOR_ENTRY_FSUCCESSOR_FLAG
)
487 == EIGRP_NEIGHBOR_ENTRY_FSUCCESSOR_FLAG
))) {
488 show_ip_eigrp_neighbor_entry(vty
, eigrp
, te
,
498 ALIAS(show_ip_eigrp_topology
, show_ip_eigrp_topology_detail_cmd
,
499 "show ip eigrp topology <A.B.C.D|A.B.C.D/M|detail|summary>",
501 "IP-EIGRP show commands\n"
502 "IP-EIGRP topology\n"
503 "Netwok to display information about\n"
504 "IP prefix <network>/<length>, e.g., 192.168.0.0/16\n"
505 "Show all links in topology table\n"
506 "Show a summary of the topology table\n")
508 DEFUN (show_ip_eigrp_interfaces
,
509 show_ip_eigrp_interfaces_cmd
,
510 "show ip eigrp interfaces [IFNAME] [detail]",
513 "IP-EIGRP show commands\n"
514 "IP-EIGRP interfaces\n"
515 "Interface name to look at\n"
516 "Detailed information\n")
518 struct eigrp_interface
*ei
;
520 struct listnode
*node
;
523 const char *ifname
= NULL
;
525 eigrp
= eigrp_lookup();
527 vty_out(vty
, "EIGRP Routing Process not enabled\n");
531 if (argv_find(argv
, argc
, "IFNAME", &idx
))
532 ifname
= argv
[idx
]->arg
;
534 if (argv_find(argv
, argc
, "detail", &idx
))
538 show_ip_eigrp_interface_header(vty
, eigrp
);
540 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
541 if (!ifname
|| strcmp(ei
->ifp
->name
, ifname
) == 0) {
542 show_ip_eigrp_interface_sub(vty
, eigrp
, ei
);
544 show_ip_eigrp_interface_detail(vty
, eigrp
, ei
);
551 DEFUN (show_ip_eigrp_neighbors
,
552 show_ip_eigrp_neighbors_cmd
,
553 "show ip eigrp neighbors [IFNAME] [detail]",
556 "IP-EIGRP show commands\n"
557 "IP-EIGRP neighbors\n"
558 "Interface to show on\n"
559 "Detailed Information\n")
562 struct eigrp_interface
*ei
;
563 struct listnode
*node
, *node2
, *nnode2
;
564 struct eigrp_neighbor
*nbr
;
567 const char *ifname
= NULL
;
569 eigrp
= eigrp_lookup();
571 vty_out(vty
, " EIGRP Routing Process not enabled\n");
575 if (argv_find(argv
, argc
, "IFNAME", &idx
))
576 ifname
= argv
[idx
]->arg
;
578 detail
= (argv_find(argv
, argc
, "detail", &idx
));
580 show_ip_eigrp_neighbor_header(vty
, eigrp
);
582 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
583 if (!ifname
|| strcmp(ei
->ifp
->name
, ifname
) == 0) {
584 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
585 if (detail
|| (nbr
->state
== EIGRP_NEIGHBOR_UP
))
586 show_ip_eigrp_neighbor_sub(vty
, nbr
,
595 DEFUN (eigrp_if_delay
,
597 "delay (1-16777215)",
598 "Specify interface throughput delay\n"
599 "Throughput delay (tens of microseconds)\n")
601 VTY_DECLVAR_CONTEXT(interface
, ifp
);
605 eigrp
= eigrp_lookup();
607 vty_out(vty
, " EIGRP Routing Process not enabled\n");
612 delay
= atoi(argv
[1]->arg
);
614 IF_DEF_PARAMS(ifp
)->delay
= delay
;
620 DEFUN (no_eigrp_if_delay
,
621 no_eigrp_if_delay_cmd
,
622 "no delay (1-16777215)",
624 "Specify interface throughput delay\n"
625 "Throughput delay (tens of microseconds)\n")
627 VTY_DECLVAR_CONTEXT(interface
, ifp
);
630 eigrp
= eigrp_lookup();
632 vty_out(vty
, " EIGRP Routing Process not enabled\n");
637 IF_DEF_PARAMS(ifp
)->delay
= EIGRP_DELAY_DEFAULT
;
643 DEFUN (eigrp_if_bandwidth
,
644 eigrp_if_bandwidth_cmd
,
645 "eigrp bandwidth (1-10000000)",
646 "EIGRP specific commands\n"
647 "Set bandwidth informational parameter\n"
648 "Bandwidth in kilobits\n")
650 VTY_DECLVAR_CONTEXT(interface
, ifp
);
654 eigrp
= eigrp_lookup();
656 vty_out(vty
, " EIGRP Routing Process not enabled\n");
660 bandwidth
= atoi(argv
[1]->arg
);
662 IF_DEF_PARAMS(ifp
)->bandwidth
= bandwidth
;
668 DEFUN (no_eigrp_if_bandwidth
,
669 no_eigrp_if_bandwidth_cmd
,
670 "no eigrp bandwidth [(1-10000000)]",
672 "EIGRP specific commands\n"
673 "Set bandwidth informational parameter\n"
674 "Bandwidth in kilobits\n")
676 VTY_DECLVAR_CONTEXT(interface
, ifp
);
679 eigrp
= eigrp_lookup();
681 vty_out(vty
, " EIGRP Routing Process not enabled\n");
685 IF_DEF_PARAMS(ifp
)->bandwidth
= EIGRP_BANDWIDTH_DEFAULT
;
691 DEFUN (eigrp_if_ip_hellointerval
,
692 eigrp_if_ip_hellointerval_cmd
,
693 "ip hello-interval eigrp (1-65535)",
694 "Interface Internet Protocol config commands\n"
695 "Configures EIGRP hello interval\n"
696 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
697 "Seconds between hello transmissions\n")
699 VTY_DECLVAR_CONTEXT(interface
, ifp
);
703 eigrp
= eigrp_lookup();
705 vty_out(vty
, " EIGRP Routing Process not enabled\n");
709 hello
= atoi(argv
[3]->arg
);
711 IF_DEF_PARAMS(ifp
)->v_hello
= hello
;
716 DEFUN (no_eigrp_if_ip_hellointerval
,
717 no_eigrp_if_ip_hellointerval_cmd
,
718 "no ip hello-interval eigrp [(1-65535)]",
720 "Interface Internet Protocol config commands\n"
721 "Configures EIGRP hello interval\n"
722 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
723 "Seconds between hello transmissions\n")
725 VTY_DECLVAR_CONTEXT(interface
, ifp
);
727 struct eigrp_interface
*ei
;
728 struct listnode
*node
, *nnode
;
730 eigrp
= eigrp_lookup();
732 vty_out(vty
, " EIGRP Routing Process not enabled\n");
736 IF_DEF_PARAMS(ifp
)->v_hello
= EIGRP_HELLO_INTERVAL_DEFAULT
;
738 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
, ei
)) {
739 if (ei
->ifp
== ifp
) {
740 THREAD_TIMER_OFF(ei
->t_hello
);
741 thread_add_timer(master
, eigrp_hello_timer
, ei
, 1,
750 DEFUN (eigrp_if_ip_holdinterval
,
751 eigrp_if_ip_holdinterval_cmd
,
752 "ip hold-time eigrp (1-65535)",
753 "Interface Internet Protocol config commands\n"
754 "Configures EIGRP IPv4 hold time\n"
755 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
756 "Seconds before neighbor is considered down\n")
758 VTY_DECLVAR_CONTEXT(interface
, ifp
);
762 eigrp
= eigrp_lookup();
764 vty_out(vty
, " EIGRP Routing Process not enabled\n");
768 hold
= atoi(argv
[3]->arg
);
770 IF_DEF_PARAMS(ifp
)->v_wait
= hold
;
775 DEFUN (eigrp_ip_summary_address
,
776 eigrp_ip_summary_address_cmd
,
777 "ip summary-address eigrp (1-65535) A.B.C.D/M",
778 "Interface Internet Protocol config commands\n"
779 "Perform address summarization\n"
780 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
782 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
784 // VTY_DECLVAR_CONTEXT(interface, ifp);
788 eigrp
= eigrp_lookup();
790 vty_out(vty
, " EIGRP Routing Process not enabled\n");
794 // AS = atoi (argv[3]->arg);
801 DEFUN (no_eigrp_ip_summary_address
,
802 no_eigrp_ip_summary_address_cmd
,
803 "no ip summary-address eigrp (1-65535) A.B.C.D/M",
805 "Interface Internet Protocol config commands\n"
806 "Perform address summarization\n"
807 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
809 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
811 // VTY_DECLVAR_CONTEXT(interface, ifp);
815 eigrp
= eigrp_lookup();
817 vty_out(vty
, " EIGRP Routing Process not enabled\n");
821 // AS = atoi (argv[4]->arg);
828 DEFUN (no_eigrp_if_ip_holdinterval
,
829 no_eigrp_if_ip_holdinterval_cmd
,
830 "no ip hold-time eigrp",
832 "Interface Internet Protocol config commands\n"
833 "Configures EIGRP hello interval\n"
834 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
835 "Seconds before neighbor is considered down\n")
837 VTY_DECLVAR_CONTEXT(interface
, ifp
);
840 eigrp
= eigrp_lookup();
842 vty_out(vty
, " EIGRP Routing Process not enabled\n");
846 IF_DEF_PARAMS(ifp
)->v_wait
= EIGRP_HOLD_INTERVAL_DEFAULT
;
851 static int str2auth_type(const char *str
, struct interface
*ifp
)
855 return CMD_WARNING_CONFIG_FAILED
;
857 if (strncmp(str
, "md5", 3) == 0) {
858 IF_DEF_PARAMS(ifp
)->auth_type
= EIGRP_AUTH_TYPE_MD5
;
860 } else if (strncmp(str
, "hmac-sha-256", 12) == 0) {
861 IF_DEF_PARAMS(ifp
)->auth_type
= EIGRP_AUTH_TYPE_SHA256
;
865 return CMD_WARNING_CONFIG_FAILED
;
868 DEFUN (eigrp_authentication_mode
,
869 eigrp_authentication_mode_cmd
,
870 "ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
871 "Interface Internet Protocol config commands\n"
872 "Authentication subcommands\n"
874 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
875 "Autonomous system number\n"
876 "Keyed message digest\n"
877 "HMAC SHA256 algorithm \n")
879 VTY_DECLVAR_CONTEXT(interface
, ifp
);
882 eigrp
= eigrp_lookup();
884 vty_out(vty
, " EIGRP Routing Process not enabled\n");
888 // if(strncmp(argv[2], "md5",3))
889 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_MD5;
890 // else if(strncmp(argv[2], "hmac-sha-256",12))
891 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_SHA256;
893 return str2auth_type(argv
[5]->arg
, ifp
);
896 DEFUN (no_eigrp_authentication_mode
,
897 no_eigrp_authentication_mode_cmd
,
898 "no ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
900 "Interface Internet Protocol config commands\n"
901 "Authentication subcommands\n"
903 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
904 "Autonomous system number\n"
905 "Keyed message digest\n"
906 "HMAC SHA256 algorithm \n")
908 VTY_DECLVAR_CONTEXT(interface
, ifp
);
911 eigrp
= eigrp_lookup();
913 vty_out(vty
, " EIGRP Routing Process not enabled\n");
917 IF_DEF_PARAMS(ifp
)->auth_type
= EIGRP_AUTH_TYPE_NONE
;
922 DEFUN (eigrp_authentication_keychain
,
923 eigrp_authentication_keychain_cmd
,
924 "ip authentication key-chain eigrp (1-65535) WORD",
925 "Interface Internet Protocol config commands\n"
926 "Authentication subcommands\n"
928 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
929 "Autonomous system number\n"
930 "Name of key-chain\n")
932 VTY_DECLVAR_CONTEXT(interface
, ifp
);
934 struct keychain
*keychain
;
936 eigrp
= eigrp_lookup();
938 vty_out(vty
, "EIGRP Routing Process not enabled\n");
942 keychain
= keychain_lookup(argv
[4]->arg
);
943 if (keychain
!= NULL
) {
944 if (IF_DEF_PARAMS(ifp
)->auth_keychain
) {
945 free(IF_DEF_PARAMS(ifp
)->auth_keychain
);
946 IF_DEF_PARAMS(ifp
)->auth_keychain
=
947 strdup(keychain
->name
);
949 IF_DEF_PARAMS(ifp
)->auth_keychain
=
950 strdup(keychain
->name
);
952 vty_out(vty
, "Key chain with specified name not found\n");
957 DEFUN (no_eigrp_authentication_keychain
,
958 no_eigrp_authentication_keychain_cmd
,
959 "no ip authentication key-chain eigrp (1-65535) WORD",
961 "Interface Internet Protocol config commands\n"
962 "Authentication subcommands\n"
964 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
965 "Autonomous system number\n"
966 "Name of key-chain\n")
968 VTY_DECLVAR_CONTEXT(interface
, ifp
);
971 eigrp
= eigrp_lookup();
973 vty_out(vty
, "EIGRP Routing Process not enabled\n");
977 if ((IF_DEF_PARAMS(ifp
)->auth_keychain
!= NULL
)
978 && (strcmp(IF_DEF_PARAMS(ifp
)->auth_keychain
, argv
[5]->arg
) == 0)) {
979 free(IF_DEF_PARAMS(ifp
)->auth_keychain
);
980 IF_DEF_PARAMS(ifp
)->auth_keychain
= NULL
;
983 "Key chain with specified name not configured on interface\n");
988 DEFUN (eigrp_redistribute_source_metric
,
989 eigrp_redistribute_source_metric_cmd
,
990 "redistribute " FRR_REDIST_STR_EIGRPD
991 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
993 FRR_REDIST_HELP_STR_EIGRPD
994 "Metric for redistributed routes\n"
995 "Bandwidth metric in Kbits per second\n"
996 "EIGRP delay metric, in 10 microsecond units\n"
997 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
998 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
999 "EIGRP MTU of the path\n")
1001 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1002 struct eigrp_metrics metrics_from_command
= {0};
1006 /* Get distribute source. */
1007 argv_find(argv
, argc
, "redistribute", &idx
);
1008 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1010 vty_out(vty
, "%% Invalid route type\n");
1011 return CMD_WARNING_CONFIG_FAILED
;
1014 /* Get metrics values */
1016 return eigrp_redistribute_set(eigrp
, source
, metrics_from_command
);
1019 DEFUN (no_eigrp_redistribute_source_metric
,
1020 no_eigrp_redistribute_source_metric_cmd
,
1021 "no redistribute " FRR_REDIST_STR_EIGRPD
1022 " metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)",
1025 FRR_REDIST_HELP_STR_EIGRPD
1026 "Metric for redistributed routes\n"
1027 "Bandwidth metric in Kbits per second\n"
1028 "EIGRP delay metric, in 10 microsecond units\n"
1029 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1030 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1031 "EIGRP MTU of the path\n")
1033 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1037 /* Get distribute source. */
1038 argv_find(argv
, argc
, "redistribute", &idx
);
1039 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1041 vty_out(vty
, "%% Invalid route type\n");
1042 return CMD_WARNING_CONFIG_FAILED
;
1045 /* Get metrics values */
1047 return eigrp_redistribute_unset(eigrp
, source
);
1050 DEFUN (eigrp_variance
,
1053 "Control load balancing variance\n"
1054 "Metric variance multiplier\n")
1056 struct eigrp
*eigrp
;
1059 eigrp
= eigrp_lookup();
1060 if (eigrp
== NULL
) {
1061 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1064 variance
= atoi(argv
[1]->arg
);
1066 eigrp
->variance
= variance
;
1073 DEFUN (no_eigrp_variance
,
1074 no_eigrp_variance_cmd
,
1075 "no variance (1-128)",
1077 "Control load balancing variance\n"
1078 "Metric variance multiplier\n")
1080 struct eigrp
*eigrp
;
1081 eigrp
= eigrp_lookup();
1082 if (eigrp
== NULL
) {
1083 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1087 eigrp
->variance
= EIGRP_VARIANCE_DEFAULT
;
1094 DEFUN (eigrp_maximum_paths
,
1095 eigrp_maximum_paths_cmd
,
1096 "maximum-paths (1-32)",
1097 "Forward packets over multiple paths\n"
1098 "Number of paths\n")
1100 struct eigrp
*eigrp
;
1103 eigrp
= eigrp_lookup();
1104 if (eigrp
== NULL
) {
1105 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1109 max
= atoi(argv
[1]->arg
);
1111 eigrp
->max_paths
= max
;
1118 DEFUN (no_eigrp_maximum_paths
,
1119 no_eigrp_maximum_paths_cmd
,
1120 "no maximum-paths <1-32>",
1122 "Forward packets over multiple paths\n"
1123 "Number of paths\n")
1125 struct eigrp
*eigrp
;
1127 eigrp
= eigrp_lookup();
1128 if (eigrp
== NULL
) {
1129 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1133 eigrp
->max_paths
= EIGRP_MAX_PATHS_DEFAULT
;
1141 * Execute hard restart for all neighbors
1143 DEFUN (clear_ip_eigrp_neighbors
,
1144 clear_ip_eigrp_neighbors_cmd
,
1145 "clear ip eigrp neighbors",
1149 "Clear IP-EIGRP neighbors\n")
1151 struct eigrp
*eigrp
;
1152 struct eigrp_interface
*ei
;
1153 struct listnode
*node
, *node2
, *nnode2
;
1154 struct eigrp_neighbor
*nbr
;
1156 /* Check if eigrp process is enabled */
1157 eigrp
= eigrp_lookup();
1158 if (eigrp
== NULL
) {
1159 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1163 /* iterate over all eigrp interfaces */
1164 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
1165 /* send Goodbye Hello */
1166 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1168 /* iterate over all neighbors on eigrp interface */
1169 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1170 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1172 "Neighbor %s (%s) is down: manually cleared",
1173 inet_ntoa(nbr
->src
),
1174 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1176 vty_time_print(vty
, 0);
1178 "Neighbor %s (%s) is down: manually cleared\n",
1179 inet_ntoa(nbr
->src
),
1180 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1183 /* set neighbor to DOWN */
1184 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1185 /* delete neighbor */
1186 eigrp_nbr_delete(nbr
);
1195 * Execute hard restart for all neighbors on interface
1197 DEFUN (clear_ip_eigrp_neighbors_int
,
1198 clear_ip_eigrp_neighbors_int_cmd
,
1199 "clear ip eigrp neighbors IFNAME",
1203 "Clear IP-EIGRP neighbors\n"
1204 "Interface's name\n")
1206 struct eigrp
*eigrp
;
1207 struct eigrp_interface
*ei
;
1208 struct listnode
*node2
, *nnode2
;
1209 struct eigrp_neighbor
*nbr
;
1212 /* Check if eigrp process is enabled */
1213 eigrp
= eigrp_lookup();
1214 if (eigrp
== NULL
) {
1215 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1219 /* lookup interface by specified name */
1220 argv_find(argv
, argc
, "IFNAME", &idx
);
1221 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[idx
]->arg
);
1223 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[idx
]->arg
);
1227 /* send Goodbye Hello */
1228 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1230 /* iterate over all neighbors on eigrp interface */
1231 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1232 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1233 zlog_debug("Neighbor %s (%s) is down: manually cleared",
1234 inet_ntoa(nbr
->src
),
1235 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1237 vty_time_print(vty
, 0);
1239 "Neighbor %s (%s) is down: manually cleared\n",
1240 inet_ntoa(nbr
->src
),
1241 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1244 /* set neighbor to DOWN */
1245 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1246 /* delete neighbor */
1247 eigrp_nbr_delete(nbr
);
1255 * Execute hard restart for neighbor specified by IP
1257 DEFUN (clear_ip_eigrp_neighbors_IP
,
1258 clear_ip_eigrp_neighbors_IP_cmd
,
1259 "clear ip eigrp neighbors A.B.C.D",
1263 "Clear IP-EIGRP neighbors\n"
1264 "IP-EIGRP neighbor address\n")
1266 struct eigrp
*eigrp
;
1267 struct eigrp_neighbor
*nbr
;
1268 struct in_addr nbr_addr
;
1270 inet_aton(argv
[4]->arg
, &nbr_addr
);
1272 /* Check if eigrp process is enabled */
1273 eigrp
= eigrp_lookup();
1274 if (eigrp
== NULL
) {
1275 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1279 /* lookup neighbor in whole process */
1280 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1282 /* if neighbor doesn't exists, notify user and exit */
1284 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1288 /* execute hard reset on neighbor */
1289 eigrp_nbr_hard_restart(nbr
, vty
);
1295 * Execute graceful restart for all neighbors
1297 DEFUN (clear_ip_eigrp_neighbors_soft
,
1298 clear_ip_eigrp_neighbors_soft_cmd
,
1299 "clear ip eigrp neighbors soft",
1303 "Clear IP-EIGRP neighbors\n"
1304 "Resync with peers without adjacency reset\n")
1306 struct eigrp
*eigrp
;
1308 /* Check if eigrp process is enabled */
1309 eigrp
= eigrp_lookup();
1310 if (eigrp
== NULL
) {
1311 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1315 /* execute graceful restart on all neighbors */
1316 eigrp_update_send_process_GR(eigrp
, EIGRP_GR_MANUAL
, vty
);
1322 * Execute graceful restart for all neighbors on interface
1324 DEFUN (clear_ip_eigrp_neighbors_int_soft
,
1325 clear_ip_eigrp_neighbors_int_soft_cmd
,
1326 "clear ip eigrp neighbors IFNAME soft",
1330 "Clear IP-EIGRP neighbors\n"
1331 "Interface's name\n"
1332 "Resync with peer without adjacency reset\n")
1334 struct eigrp
*eigrp
;
1335 struct eigrp_interface
*ei
;
1337 /* Check if eigrp process is enabled */
1338 eigrp
= eigrp_lookup();
1339 if (eigrp
== NULL
) {
1340 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1344 /* lookup interface by specified name */
1345 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[4]->arg
);
1347 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[4]->arg
);
1351 /* execute graceful restart for all neighbors on interface */
1352 eigrp_update_send_interface_GR(ei
, EIGRP_GR_MANUAL
, vty
);
1357 * Execute graceful restart for neighbor specified by IP
1359 DEFUN (clear_ip_eigrp_neighbors_IP_soft
,
1360 clear_ip_eigrp_neighbors_IP_soft_cmd
,
1361 "clear ip eigrp neighbors A.B.C.D soft",
1365 "Clear IP-EIGRP neighbors\n"
1366 "IP-EIGRP neighbor address\n"
1367 "Resync with peer without adjacency reset\n")
1369 struct eigrp
*eigrp
;
1370 struct eigrp_neighbor
*nbr
;
1371 struct in_addr nbr_addr
;
1373 inet_aton(argv
[4]->arg
, &nbr_addr
);
1375 /* Check if eigrp process is enabled */
1376 eigrp
= eigrp_lookup();
1377 if (eigrp
== NULL
) {
1378 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1382 /* lookup neighbor in whole process */
1383 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1385 /* if neighbor doesn't exists, notify user and exit */
1387 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1391 /* execute graceful restart on neighbor */
1392 eigrp_update_send_GR(nbr
, EIGRP_GR_MANUAL
, vty
);
1397 static struct cmd_node eigrp_node
= {EIGRP_NODE
, "%s(config-router)# ", 1};
1399 /* Save EIGRP configuration */
1400 static int eigrp_config_write(struct vty
*vty
)
1402 struct eigrp
*eigrp
;
1406 eigrp
= eigrp_lookup();
1407 if (eigrp
!= NULL
) {
1408 /* Writes 'router eigrp' section to config */
1409 config_write_eigrp_router(vty
, eigrp
);
1411 /* Interface config print */
1412 config_write_interfaces(vty
, eigrp
);
1414 // /* static neighbor print. */
1415 // config_write_eigrp_nbr_nbma (vty, eigrp);
1417 // /* Virtual-Link print. */
1418 // config_write_virtual_link (vty, eigrp);
1420 // /* Default metric configuration. */
1421 // config_write_eigrp_default_metric (vty, eigrp);
1423 // /* Distribute-list and default-information print. */
1424 // config_write_eigrp_distribute (vty, eigrp);
1426 // /* Distance configuration. */
1427 // config_write_eigrp_distance (vty, eigrp)
1433 void eigrp_vty_show_init(void)
1435 install_element(VIEW_NODE
, &show_ip_eigrp_interfaces_cmd
);
1437 install_element(VIEW_NODE
, &show_ip_eigrp_neighbors_cmd
);
1439 install_element(VIEW_NODE
, &show_ip_eigrp_topology_cmd
);
1441 install_element(VIEW_NODE
, &show_ip_eigrp_topology_detail_cmd
);
1444 /* eigrpd's interface node. */
1445 static struct cmd_node eigrp_interface_node
= {INTERFACE_NODE
,
1446 "%s(config-if)# ", 1};
1448 void eigrp_vty_if_init(void)
1450 install_node(&eigrp_interface_node
, eigrp_write_interface
);
1453 /* Delay and bandwidth configuration commands*/
1454 install_element(INTERFACE_NODE
, &eigrp_if_delay_cmd
);
1455 install_element(INTERFACE_NODE
, &no_eigrp_if_delay_cmd
);
1456 install_element(INTERFACE_NODE
, &eigrp_if_bandwidth_cmd
);
1457 install_element(INTERFACE_NODE
, &no_eigrp_if_bandwidth_cmd
);
1459 /*Hello-interval and hold-time interval configuration commands*/
1460 install_element(INTERFACE_NODE
, &eigrp_if_ip_holdinterval_cmd
);
1461 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_holdinterval_cmd
);
1462 install_element(INTERFACE_NODE
, &eigrp_if_ip_hellointerval_cmd
);
1463 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_hellointerval_cmd
);
1465 /* "Authentication configuration commands */
1466 install_element(INTERFACE_NODE
, &eigrp_authentication_mode_cmd
);
1467 install_element(INTERFACE_NODE
, &no_eigrp_authentication_mode_cmd
);
1468 install_element(INTERFACE_NODE
, &eigrp_authentication_keychain_cmd
);
1469 install_element(INTERFACE_NODE
, &no_eigrp_authentication_keychain_cmd
);
1471 /*EIGRP Summarization commands*/
1472 install_element(INTERFACE_NODE
, &eigrp_ip_summary_address_cmd
);
1473 install_element(INTERFACE_NODE
, &no_eigrp_ip_summary_address_cmd
);
1476 static void eigrp_vty_zebra_init(void)
1478 install_element(EIGRP_NODE
, &eigrp_redistribute_source_metric_cmd
);
1479 install_element(EIGRP_NODE
, &no_eigrp_redistribute_source_metric_cmd
);
1482 /* Install EIGRP related vty commands. */
1483 void eigrp_vty_init(void)
1485 install_node(&eigrp_node
, eigrp_config_write
);
1487 install_default(EIGRP_NODE
);
1489 install_element(CONFIG_NODE
, &router_eigrp_cmd
);
1490 install_element(CONFIG_NODE
, &no_router_eigrp_cmd
);
1491 install_element(EIGRP_NODE
, &eigrp_network_cmd
);
1492 install_element(EIGRP_NODE
, &no_eigrp_network_cmd
);
1493 install_element(EIGRP_NODE
, &eigrp_variance_cmd
);
1494 install_element(EIGRP_NODE
, &no_eigrp_variance_cmd
);
1495 install_element(EIGRP_NODE
, &eigrp_router_id_cmd
);
1496 install_element(EIGRP_NODE
, &no_eigrp_router_id_cmd
);
1497 install_element(EIGRP_NODE
, &eigrp_passive_interface_cmd
);
1498 install_element(EIGRP_NODE
, &no_eigrp_passive_interface_cmd
);
1499 install_element(EIGRP_NODE
, &eigrp_timers_active_cmd
);
1500 install_element(EIGRP_NODE
, &no_eigrp_timers_active_cmd
);
1501 install_element(EIGRP_NODE
, &eigrp_metric_weights_cmd
);
1502 install_element(EIGRP_NODE
, &no_eigrp_metric_weights_cmd
);
1503 install_element(EIGRP_NODE
, &eigrp_maximum_paths_cmd
);
1504 install_element(EIGRP_NODE
, &no_eigrp_maximum_paths_cmd
);
1505 install_element(EIGRP_NODE
, &eigrp_neighbor_cmd
);
1506 install_element(EIGRP_NODE
, &no_eigrp_neighbor_cmd
);
1508 /* commands for manual hard restart */
1509 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_cmd
);
1510 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_cmd
);
1511 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_cmd
);
1512 /* commands for manual graceful restart */
1513 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_soft_cmd
);
1514 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_soft_cmd
);
1515 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_soft_cmd
);
1517 eigrp_vty_zebra_init();