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 RB_FOREACH (ifp
, if_name_head
, &vrf
->ifaces_by_name
) {
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
, *node2
;
470 struct eigrp_prefix_entry
*tn
;
471 struct eigrp_nexthop_entry
*te
;
474 eigrp
= eigrp_lookup();
476 vty_out(vty
, " EIGRP Routing Process not enabled\n");
480 show_ip_eigrp_topology_header(vty
, eigrp
);
482 for (ALL_LIST_ELEMENTS_RO(eigrp
->topology_table
, node
, tn
)) {
484 for (ALL_LIST_ELEMENTS_RO(tn
->entries
, node2
, te
)) {
487 & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG
)
488 == EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG
)
490 & EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG
)
491 == EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG
))) {
492 show_ip_eigrp_nexthop_entry(vty
, eigrp
, te
,
502 ALIAS(show_ip_eigrp_topology
, show_ip_eigrp_topology_detail_cmd
,
503 "show ip eigrp topology <A.B.C.D|A.B.C.D/M|detail|summary>",
505 "IP-EIGRP show commands\n"
506 "IP-EIGRP topology\n"
507 "Netwok to display information about\n"
508 "IP prefix <network>/<length>, e.g., 192.168.0.0/16\n"
509 "Show all links in topology table\n"
510 "Show a summary of the topology table\n")
512 DEFUN (show_ip_eigrp_interfaces
,
513 show_ip_eigrp_interfaces_cmd
,
514 "show ip eigrp interfaces [IFNAME] [detail]",
517 "IP-EIGRP show commands\n"
518 "IP-EIGRP interfaces\n"
519 "Interface name to look at\n"
520 "Detailed information\n")
522 struct eigrp_interface
*ei
;
524 struct listnode
*node
;
527 const char *ifname
= NULL
;
529 eigrp
= eigrp_lookup();
531 vty_out(vty
, "EIGRP Routing Process not enabled\n");
535 if (argv_find(argv
, argc
, "IFNAME", &idx
))
536 ifname
= argv
[idx
]->arg
;
538 if (argv_find(argv
, argc
, "detail", &idx
))
542 show_ip_eigrp_interface_header(vty
, eigrp
);
544 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
545 if (!ifname
|| strcmp(ei
->ifp
->name
, ifname
) == 0) {
546 show_ip_eigrp_interface_sub(vty
, eigrp
, ei
);
548 show_ip_eigrp_interface_detail(vty
, eigrp
, ei
);
555 DEFUN (show_ip_eigrp_neighbors
,
556 show_ip_eigrp_neighbors_cmd
,
557 "show ip eigrp neighbors [IFNAME] [detail]",
560 "IP-EIGRP show commands\n"
561 "IP-EIGRP neighbors\n"
562 "Interface to show on\n"
563 "Detailed Information\n")
566 struct eigrp_interface
*ei
;
567 struct listnode
*node
, *node2
, *nnode2
;
568 struct eigrp_neighbor
*nbr
;
571 const char *ifname
= NULL
;
573 eigrp
= eigrp_lookup();
575 vty_out(vty
, " EIGRP Routing Process not enabled\n");
579 if (argv_find(argv
, argc
, "IFNAME", &idx
))
580 ifname
= argv
[idx
]->arg
;
582 detail
= (argv_find(argv
, argc
, "detail", &idx
));
584 show_ip_eigrp_neighbor_header(vty
, eigrp
);
586 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
587 if (!ifname
|| strcmp(ei
->ifp
->name
, ifname
) == 0) {
588 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
589 if (detail
|| (nbr
->state
== EIGRP_NEIGHBOR_UP
))
590 show_ip_eigrp_neighbor_sub(vty
, nbr
,
599 DEFUN (eigrp_if_delay
,
601 "delay (1-16777215)",
602 "Specify interface throughput delay\n"
603 "Throughput delay (tens of microseconds)\n")
605 VTY_DECLVAR_CONTEXT(interface
, ifp
);
606 struct eigrp_interface
*ei
= ifp
->info
;
610 eigrp
= eigrp_lookup();
612 vty_out(vty
, " EIGRP Routing Process not enabled\n");
618 vty_out(vty
, " EIGRP not configured on this interface\n");
621 delay
= atoi(argv
[1]->arg
);
623 ei
->params
.delay
= delay
;
629 DEFUN (no_eigrp_if_delay
,
630 no_eigrp_if_delay_cmd
,
631 "no delay (1-16777215)",
633 "Specify interface throughput delay\n"
634 "Throughput delay (tens of microseconds)\n")
636 VTY_DECLVAR_CONTEXT(interface
, ifp
);
637 struct eigrp_interface
*ei
= ifp
->info
;
640 eigrp
= eigrp_lookup();
642 vty_out(vty
, " EIGRP Routing Process not enabled\n");
647 vty_out(vty
, " EIGRP not configured on this interface\n");
651 ei
->params
.delay
= EIGRP_DELAY_DEFAULT
;
657 DEFUN (eigrp_if_bandwidth
,
658 eigrp_if_bandwidth_cmd
,
659 "eigrp bandwidth (1-10000000)",
660 "EIGRP specific commands\n"
661 "Set bandwidth informational parameter\n"
662 "Bandwidth in kilobits\n")
664 VTY_DECLVAR_CONTEXT(interface
, ifp
);
665 struct eigrp_interface
*ei
= ifp
->info
;
669 eigrp
= eigrp_lookup();
671 vty_out(vty
, " EIGRP Routing Process not enabled\n");
676 vty_out(vty
, " EIGRP not configured on this interface\n");
680 bandwidth
= atoi(argv
[1]->arg
);
682 ei
->params
.bandwidth
= bandwidth
;
688 DEFUN (no_eigrp_if_bandwidth
,
689 no_eigrp_if_bandwidth_cmd
,
690 "no eigrp bandwidth [(1-10000000)]",
692 "EIGRP specific commands\n"
693 "Set bandwidth informational parameter\n"
694 "Bandwidth in kilobits\n")
696 VTY_DECLVAR_CONTEXT(interface
, ifp
);
697 struct eigrp_interface
*ei
= ifp
->info
;
700 eigrp
= eigrp_lookup();
702 vty_out(vty
, " EIGRP Routing Process not enabled\n");
707 vty_out(vty
, " EIGRP not configured on this interface\n");
711 ei
->params
.bandwidth
= EIGRP_BANDWIDTH_DEFAULT
;
717 DEFUN (eigrp_if_ip_hellointerval
,
718 eigrp_if_ip_hellointerval_cmd
,
719 "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
);
726 struct eigrp_interface
*ei
= ifp
->info
;
730 eigrp
= eigrp_lookup();
732 vty_out(vty
, " EIGRP Routing Process not enabled\n");
737 vty_out(vty
, " EIGRP not configured on this interface\n");
741 hello
= atoi(argv
[3]->arg
);
743 ei
->params
.v_hello
= hello
;
748 DEFUN (no_eigrp_if_ip_hellointerval
,
749 no_eigrp_if_ip_hellointerval_cmd
,
750 "no ip hello-interval eigrp [(1-65535)]",
752 "Interface Internet Protocol config commands\n"
753 "Configures EIGRP hello interval\n"
754 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
755 "Seconds between hello transmissions\n")
757 VTY_DECLVAR_CONTEXT(interface
, ifp
);
758 struct eigrp_interface
*ei
= ifp
->info
;
761 eigrp
= eigrp_lookup();
763 vty_out(vty
, " EIGRP Routing Process not enabled\n");
768 vty_out(vty
, " EIGRP not configured on this interface\n");
772 ei
->params
.v_hello
= EIGRP_HELLO_INTERVAL_DEFAULT
;
774 THREAD_TIMER_OFF(ei
->t_hello
);
775 thread_add_timer(master
, eigrp_hello_timer
, ei
, 1,
781 DEFUN (eigrp_if_ip_holdinterval
,
782 eigrp_if_ip_holdinterval_cmd
,
783 "ip hold-time eigrp (1-65535)",
784 "Interface Internet Protocol config commands\n"
785 "Configures EIGRP IPv4 hold time\n"
786 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
787 "Seconds before neighbor is considered down\n")
789 VTY_DECLVAR_CONTEXT(interface
, ifp
);
790 struct eigrp_interface
*ei
= ifp
->info
;
794 eigrp
= eigrp_lookup();
796 vty_out(vty
, " EIGRP Routing Process not enabled\n");
801 vty_out(vty
, " EIGRP not configured on this interface\n");
805 hold
= atoi(argv
[3]->arg
);
807 ei
->params
.v_wait
= hold
;
812 DEFUN (eigrp_ip_summary_address
,
813 eigrp_ip_summary_address_cmd
,
814 "ip summary-address eigrp (1-65535) A.B.C.D/M",
815 "Interface Internet Protocol config commands\n"
816 "Perform address summarization\n"
817 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
819 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
821 // VTY_DECLVAR_CONTEXT(interface, ifp);
825 eigrp
= eigrp_lookup();
827 vty_out(vty
, " EIGRP Routing Process not enabled\n");
831 // AS = atoi (argv[3]->arg);
838 DEFUN (no_eigrp_ip_summary_address
,
839 no_eigrp_ip_summary_address_cmd
,
840 "no ip summary-address eigrp (1-65535) A.B.C.D/M",
842 "Interface Internet Protocol config commands\n"
843 "Perform address summarization\n"
844 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
846 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
848 // VTY_DECLVAR_CONTEXT(interface, ifp);
852 eigrp
= eigrp_lookup();
854 vty_out(vty
, " EIGRP Routing Process not enabled\n");
858 // AS = atoi (argv[4]->arg);
865 DEFUN (no_eigrp_if_ip_holdinterval
,
866 no_eigrp_if_ip_holdinterval_cmd
,
867 "no ip hold-time eigrp",
869 "Interface Internet Protocol config commands\n"
870 "Configures EIGRP hello interval\n"
871 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
872 "Seconds before neighbor is considered down\n")
874 VTY_DECLVAR_CONTEXT(interface
, ifp
);
875 struct eigrp_interface
*ei
= ifp
->info
;
878 eigrp
= eigrp_lookup();
880 vty_out(vty
, " EIGRP Routing Process not enabled\n");
885 vty_out(vty
, " EIGRP not configured on this interface\n");
889 ei
->params
.v_wait
= EIGRP_HOLD_INTERVAL_DEFAULT
;
894 static int str2auth_type(const char *str
, struct eigrp_interface
*ei
)
898 return CMD_WARNING_CONFIG_FAILED
;
900 if (strncmp(str
, "md5", 3) == 0) {
901 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_MD5
;
903 } else if (strncmp(str
, "hmac-sha-256", 12) == 0) {
904 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_SHA256
;
908 return CMD_WARNING_CONFIG_FAILED
;
911 DEFUN (eigrp_authentication_mode
,
912 eigrp_authentication_mode_cmd
,
913 "ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
914 "Interface Internet Protocol config commands\n"
915 "Authentication subcommands\n"
917 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
918 "Autonomous system number\n"
919 "Keyed message digest\n"
920 "HMAC SHA256 algorithm \n")
922 VTY_DECLVAR_CONTEXT(interface
, ifp
);
923 struct eigrp_interface
*ei
= ifp
->info
;
926 eigrp
= eigrp_lookup();
928 vty_out(vty
, " EIGRP Routing Process not enabled\n");
933 vty_out(vty
, " EIGRP not configured on this interface\n");
937 // if(strncmp(argv[2], "md5",3))
938 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_MD5;
939 // else if(strncmp(argv[2], "hmac-sha-256",12))
940 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_SHA256;
942 return str2auth_type(argv
[5]->arg
, ei
);
945 DEFUN (no_eigrp_authentication_mode
,
946 no_eigrp_authentication_mode_cmd
,
947 "no ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
949 "Interface Internet Protocol config commands\n"
950 "Authentication subcommands\n"
952 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
953 "Autonomous system number\n"
954 "Keyed message digest\n"
955 "HMAC SHA256 algorithm \n")
957 VTY_DECLVAR_CONTEXT(interface
, ifp
);
958 struct eigrp_interface
*ei
= ifp
->info
;
961 eigrp
= eigrp_lookup();
963 vty_out(vty
, " EIGRP Routing Process not enabled\n");
968 vty_out(vty
, " EIGRP not configured on this interface\n");
972 ei
->params
.auth_type
= EIGRP_AUTH_TYPE_NONE
;
977 DEFUN (eigrp_authentication_keychain
,
978 eigrp_authentication_keychain_cmd
,
979 "ip authentication key-chain eigrp (1-65535) WORD",
980 "Interface Internet Protocol config commands\n"
981 "Authentication subcommands\n"
983 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
984 "Autonomous system number\n"
985 "Name of key-chain\n")
987 VTY_DECLVAR_CONTEXT(interface
, ifp
);
988 struct eigrp_interface
*ei
= ifp
->info
;
990 struct keychain
*keychain
;
992 eigrp
= eigrp_lookup();
994 vty_out(vty
, "EIGRP Routing Process not enabled\n");
999 vty_out(vty
, " EIGRP not configured on this interface\n");
1003 keychain
= keychain_lookup(argv
[4]->arg
);
1004 if (keychain
!= NULL
) {
1005 if (ei
->params
.auth_keychain
) {
1006 free(ei
->params
.auth_keychain
);
1007 ei
->params
.auth_keychain
=
1008 strdup(keychain
->name
);
1010 ei
->params
.auth_keychain
=
1011 strdup(keychain
->name
);
1013 vty_out(vty
, "Key chain with specified name not found\n");
1018 DEFUN (no_eigrp_authentication_keychain
,
1019 no_eigrp_authentication_keychain_cmd
,
1020 "no ip authentication key-chain eigrp (1-65535) WORD",
1022 "Interface Internet Protocol config commands\n"
1023 "Authentication subcommands\n"
1025 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
1026 "Autonomous system number\n"
1027 "Name of key-chain\n")
1029 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1030 struct eigrp_interface
*ei
= ifp
->info
;
1031 struct eigrp
*eigrp
;
1033 eigrp
= eigrp_lookup();
1034 if (eigrp
== NULL
) {
1035 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1040 vty_out(vty
, " EIGRP not configured on this interface\n");
1044 if ((ei
->params
.auth_keychain
!= NULL
)
1045 && (strcmp(ei
->params
.auth_keychain
, argv
[5]->arg
) == 0)) {
1046 free(ei
->params
.auth_keychain
);
1047 ei
->params
.auth_keychain
= NULL
;
1050 "Key chain with specified name not configured on interface\n");
1055 DEFUN (eigrp_redistribute_source_metric
,
1056 eigrp_redistribute_source_metric_cmd
,
1057 "redistribute " FRR_REDIST_STR_EIGRPD
1058 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
1060 FRR_REDIST_HELP_STR_EIGRPD
1061 "Metric for redistributed routes\n"
1062 "Bandwidth metric in Kbits per second\n"
1063 "EIGRP delay metric, in 10 microsecond units\n"
1064 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1065 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1066 "EIGRP MTU of the path\n")
1068 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1069 struct eigrp_metrics metrics_from_command
= {0};
1073 /* Get distribute source. */
1074 argv_find(argv
, argc
, "redistribute", &idx
);
1075 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1077 vty_out(vty
, "%% Invalid route type\n");
1078 return CMD_WARNING_CONFIG_FAILED
;
1081 /* Get metrics values */
1083 return eigrp_redistribute_set(eigrp
, source
, metrics_from_command
);
1086 DEFUN (no_eigrp_redistribute_source_metric
,
1087 no_eigrp_redistribute_source_metric_cmd
,
1088 "no redistribute " FRR_REDIST_STR_EIGRPD
1089 " metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)",
1092 FRR_REDIST_HELP_STR_EIGRPD
1093 "Metric for redistributed routes\n"
1094 "Bandwidth metric in Kbits per second\n"
1095 "EIGRP delay metric, in 10 microsecond units\n"
1096 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1097 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1098 "EIGRP MTU of the path\n")
1100 VTY_DECLVAR_CONTEXT(eigrp
, eigrp
);
1104 /* Get distribute source. */
1105 argv_find(argv
, argc
, "redistribute", &idx
);
1106 source
= proto_redistnum(AFI_IP
, argv
[idx
+ 1]->text
);
1108 vty_out(vty
, "%% Invalid route type\n");
1109 return CMD_WARNING_CONFIG_FAILED
;
1112 /* Get metrics values */
1114 return eigrp_redistribute_unset(eigrp
, source
);
1117 DEFUN (eigrp_variance
,
1120 "Control load balancing variance\n"
1121 "Metric variance multiplier\n")
1123 struct eigrp
*eigrp
;
1126 eigrp
= eigrp_lookup();
1127 if (eigrp
== NULL
) {
1128 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1131 variance
= atoi(argv
[1]->arg
);
1133 eigrp
->variance
= variance
;
1140 DEFUN (no_eigrp_variance
,
1141 no_eigrp_variance_cmd
,
1142 "no variance (1-128)",
1144 "Control load balancing variance\n"
1145 "Metric variance multiplier\n")
1147 struct eigrp
*eigrp
;
1148 eigrp
= eigrp_lookup();
1149 if (eigrp
== NULL
) {
1150 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1154 eigrp
->variance
= EIGRP_VARIANCE_DEFAULT
;
1161 DEFUN (eigrp_maximum_paths
,
1162 eigrp_maximum_paths_cmd
,
1163 "maximum-paths (1-32)",
1164 "Forward packets over multiple paths\n"
1165 "Number of paths\n")
1167 struct eigrp
*eigrp
;
1170 eigrp
= eigrp_lookup();
1171 if (eigrp
== NULL
) {
1172 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1176 max
= atoi(argv
[1]->arg
);
1178 eigrp
->max_paths
= max
;
1185 DEFUN (no_eigrp_maximum_paths
,
1186 no_eigrp_maximum_paths_cmd
,
1187 "no maximum-paths <1-32>",
1189 "Forward packets over multiple paths\n"
1190 "Number of paths\n")
1192 struct eigrp
*eigrp
;
1194 eigrp
= eigrp_lookup();
1195 if (eigrp
== NULL
) {
1196 vty_out(vty
, "EIGRP Routing Process not enabled\n");
1200 eigrp
->max_paths
= EIGRP_MAX_PATHS_DEFAULT
;
1208 * Execute hard restart for all neighbors
1210 DEFUN (clear_ip_eigrp_neighbors
,
1211 clear_ip_eigrp_neighbors_cmd
,
1212 "clear ip eigrp neighbors",
1216 "Clear IP-EIGRP neighbors\n")
1218 struct eigrp
*eigrp
;
1219 struct eigrp_interface
*ei
;
1220 struct listnode
*node
, *node2
, *nnode2
;
1221 struct eigrp_neighbor
*nbr
;
1223 /* Check if eigrp process is enabled */
1224 eigrp
= eigrp_lookup();
1225 if (eigrp
== NULL
) {
1226 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1230 /* iterate over all eigrp interfaces */
1231 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
1232 /* send Goodbye Hello */
1233 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1235 /* iterate over all neighbors on eigrp interface */
1236 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1237 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1239 "Neighbor %s (%s) is down: manually cleared",
1240 inet_ntoa(nbr
->src
),
1241 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1243 vty_time_print(vty
, 0);
1245 "Neighbor %s (%s) is down: manually cleared\n",
1246 inet_ntoa(nbr
->src
),
1247 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1250 /* set neighbor to DOWN */
1251 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1252 /* delete neighbor */
1253 eigrp_nbr_delete(nbr
);
1262 * Execute hard restart for all neighbors on interface
1264 DEFUN (clear_ip_eigrp_neighbors_int
,
1265 clear_ip_eigrp_neighbors_int_cmd
,
1266 "clear ip eigrp neighbors IFNAME",
1270 "Clear IP-EIGRP neighbors\n"
1271 "Interface's name\n")
1273 struct eigrp
*eigrp
;
1274 struct eigrp_interface
*ei
;
1275 struct listnode
*node2
, *nnode2
;
1276 struct eigrp_neighbor
*nbr
;
1279 /* Check if eigrp process is enabled */
1280 eigrp
= eigrp_lookup();
1281 if (eigrp
== NULL
) {
1282 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1286 /* lookup interface by specified name */
1287 argv_find(argv
, argc
, "IFNAME", &idx
);
1288 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[idx
]->arg
);
1290 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[idx
]->arg
);
1294 /* send Goodbye Hello */
1295 eigrp_hello_send(ei
, EIGRP_HELLO_GRACEFUL_SHUTDOWN
, NULL
);
1297 /* iterate over all neighbors on eigrp interface */
1298 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
1299 if (nbr
->state
!= EIGRP_NEIGHBOR_DOWN
) {
1300 zlog_debug("Neighbor %s (%s) is down: manually cleared",
1301 inet_ntoa(nbr
->src
),
1302 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1304 vty_time_print(vty
, 0);
1306 "Neighbor %s (%s) is down: manually cleared\n",
1307 inet_ntoa(nbr
->src
),
1308 ifindex2ifname(nbr
->ei
->ifp
->ifindex
,
1311 /* set neighbor to DOWN */
1312 nbr
->state
= EIGRP_NEIGHBOR_DOWN
;
1313 /* delete neighbor */
1314 eigrp_nbr_delete(nbr
);
1322 * Execute hard restart for neighbor specified by IP
1324 DEFUN (clear_ip_eigrp_neighbors_IP
,
1325 clear_ip_eigrp_neighbors_IP_cmd
,
1326 "clear ip eigrp neighbors A.B.C.D",
1330 "Clear IP-EIGRP neighbors\n"
1331 "IP-EIGRP neighbor address\n")
1333 struct eigrp
*eigrp
;
1334 struct eigrp_neighbor
*nbr
;
1335 struct in_addr nbr_addr
;
1337 if (!inet_aton(argv
[4]->arg
, &nbr_addr
)) {
1338 vty_out(vty
, "Unable to parse %s",
1343 /* Check if eigrp process is enabled */
1344 eigrp
= eigrp_lookup();
1345 if (eigrp
== NULL
) {
1346 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1350 /* lookup neighbor in whole process */
1351 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1353 /* if neighbor doesn't exists, notify user and exit */
1355 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1359 /* execute hard reset on neighbor */
1360 eigrp_nbr_hard_restart(nbr
, vty
);
1366 * Execute graceful restart for all neighbors
1368 DEFUN (clear_ip_eigrp_neighbors_soft
,
1369 clear_ip_eigrp_neighbors_soft_cmd
,
1370 "clear ip eigrp neighbors soft",
1374 "Clear IP-EIGRP neighbors\n"
1375 "Resync with peers without adjacency reset\n")
1377 struct eigrp
*eigrp
;
1379 /* Check if eigrp process is enabled */
1380 eigrp
= eigrp_lookup();
1381 if (eigrp
== NULL
) {
1382 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1386 /* execute graceful restart on all neighbors */
1387 eigrp_update_send_process_GR(eigrp
, EIGRP_GR_MANUAL
, vty
);
1393 * Execute graceful restart for all neighbors on interface
1395 DEFUN (clear_ip_eigrp_neighbors_int_soft
,
1396 clear_ip_eigrp_neighbors_int_soft_cmd
,
1397 "clear ip eigrp neighbors IFNAME soft",
1401 "Clear IP-EIGRP neighbors\n"
1402 "Interface's name\n"
1403 "Resync with peer without adjacency reset\n")
1405 struct eigrp
*eigrp
;
1406 struct eigrp_interface
*ei
;
1408 /* Check if eigrp process is enabled */
1409 eigrp
= eigrp_lookup();
1410 if (eigrp
== NULL
) {
1411 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1415 /* lookup interface by specified name */
1416 ei
= eigrp_if_lookup_by_name(eigrp
, argv
[4]->arg
);
1418 vty_out(vty
, " Interface (%s) doesn't exist\n", argv
[4]->arg
);
1422 /* execute graceful restart for all neighbors on interface */
1423 eigrp_update_send_interface_GR(ei
, EIGRP_GR_MANUAL
, vty
);
1428 * Execute graceful restart for neighbor specified by IP
1430 DEFUN (clear_ip_eigrp_neighbors_IP_soft
,
1431 clear_ip_eigrp_neighbors_IP_soft_cmd
,
1432 "clear ip eigrp neighbors A.B.C.D soft",
1436 "Clear IP-EIGRP neighbors\n"
1437 "IP-EIGRP neighbor address\n"
1438 "Resync with peer without adjacency reset\n")
1440 struct eigrp
*eigrp
;
1441 struct eigrp_neighbor
*nbr
;
1442 struct in_addr nbr_addr
;
1444 if (!inet_aton(argv
[4]->arg
, &nbr_addr
)) {
1445 vty_out(vty
, "Unable to parse: %s",
1450 /* Check if eigrp process is enabled */
1451 eigrp
= eigrp_lookup();
1452 if (eigrp
== NULL
) {
1453 vty_out(vty
, " EIGRP Routing Process not enabled\n");
1457 /* lookup neighbor in whole process */
1458 nbr
= eigrp_nbr_lookup_by_addr_process(eigrp
, nbr_addr
);
1460 /* if neighbor doesn't exists, notify user and exit */
1462 vty_out(vty
, "Neighbor with entered address doesn't exists.\n");
1466 /* execute graceful restart on neighbor */
1467 eigrp_update_send_GR(nbr
, EIGRP_GR_MANUAL
, vty
);
1472 static struct cmd_node eigrp_node
= {EIGRP_NODE
, "%s(config-router)# ", 1};
1474 /* Save EIGRP configuration */
1475 static int eigrp_config_write(struct vty
*vty
)
1477 struct eigrp
*eigrp
;
1481 eigrp
= eigrp_lookup();
1482 if (eigrp
!= NULL
) {
1483 /* Writes 'router eigrp' section to config */
1484 config_write_eigrp_router(vty
, eigrp
);
1486 /* Interface config print */
1487 config_write_interfaces(vty
, eigrp
);
1489 // /* static neighbor print. */
1490 // config_write_eigrp_nbr_nbma (vty, eigrp);
1492 // /* Virtual-Link print. */
1493 // config_write_virtual_link (vty, eigrp);
1495 // /* Default metric configuration. */
1496 // config_write_eigrp_default_metric (vty, eigrp);
1498 // /* Distribute-list and default-information print. */
1499 // config_write_eigrp_distribute (vty, eigrp);
1501 // /* Distance configuration. */
1502 // config_write_eigrp_distance (vty, eigrp)
1508 void eigrp_vty_show_init(void)
1510 install_element(VIEW_NODE
, &show_ip_eigrp_interfaces_cmd
);
1512 install_element(VIEW_NODE
, &show_ip_eigrp_neighbors_cmd
);
1514 install_element(VIEW_NODE
, &show_ip_eigrp_topology_cmd
);
1516 install_element(VIEW_NODE
, &show_ip_eigrp_topology_detail_cmd
);
1519 /* eigrpd's interface node. */
1520 static struct cmd_node eigrp_interface_node
= {INTERFACE_NODE
,
1521 "%s(config-if)# ", 1};
1523 void eigrp_vty_if_init(void)
1525 install_node(&eigrp_interface_node
, eigrp_write_interface
);
1528 /* Delay and bandwidth configuration commands*/
1529 install_element(INTERFACE_NODE
, &eigrp_if_delay_cmd
);
1530 install_element(INTERFACE_NODE
, &no_eigrp_if_delay_cmd
);
1531 install_element(INTERFACE_NODE
, &eigrp_if_bandwidth_cmd
);
1532 install_element(INTERFACE_NODE
, &no_eigrp_if_bandwidth_cmd
);
1534 /*Hello-interval and hold-time interval configuration commands*/
1535 install_element(INTERFACE_NODE
, &eigrp_if_ip_holdinterval_cmd
);
1536 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_holdinterval_cmd
);
1537 install_element(INTERFACE_NODE
, &eigrp_if_ip_hellointerval_cmd
);
1538 install_element(INTERFACE_NODE
, &no_eigrp_if_ip_hellointerval_cmd
);
1540 /* "Authentication configuration commands */
1541 install_element(INTERFACE_NODE
, &eigrp_authentication_mode_cmd
);
1542 install_element(INTERFACE_NODE
, &no_eigrp_authentication_mode_cmd
);
1543 install_element(INTERFACE_NODE
, &eigrp_authentication_keychain_cmd
);
1544 install_element(INTERFACE_NODE
, &no_eigrp_authentication_keychain_cmd
);
1546 /*EIGRP Summarization commands*/
1547 install_element(INTERFACE_NODE
, &eigrp_ip_summary_address_cmd
);
1548 install_element(INTERFACE_NODE
, &no_eigrp_ip_summary_address_cmd
);
1551 static void eigrp_vty_zebra_init(void)
1553 install_element(EIGRP_NODE
, &eigrp_redistribute_source_metric_cmd
);
1554 install_element(EIGRP_NODE
, &no_eigrp_redistribute_source_metric_cmd
);
1557 /* Install EIGRP related vty commands. */
1558 void eigrp_vty_init(void)
1560 install_node(&eigrp_node
, eigrp_config_write
);
1562 install_default(EIGRP_NODE
);
1564 install_element(CONFIG_NODE
, &router_eigrp_cmd
);
1565 install_element(CONFIG_NODE
, &no_router_eigrp_cmd
);
1566 install_element(EIGRP_NODE
, &eigrp_network_cmd
);
1567 install_element(EIGRP_NODE
, &no_eigrp_network_cmd
);
1568 install_element(EIGRP_NODE
, &eigrp_variance_cmd
);
1569 install_element(EIGRP_NODE
, &no_eigrp_variance_cmd
);
1570 install_element(EIGRP_NODE
, &eigrp_router_id_cmd
);
1571 install_element(EIGRP_NODE
, &no_eigrp_router_id_cmd
);
1572 install_element(EIGRP_NODE
, &eigrp_passive_interface_cmd
);
1573 install_element(EIGRP_NODE
, &no_eigrp_passive_interface_cmd
);
1574 install_element(EIGRP_NODE
, &eigrp_timers_active_cmd
);
1575 install_element(EIGRP_NODE
, &no_eigrp_timers_active_cmd
);
1576 install_element(EIGRP_NODE
, &eigrp_metric_weights_cmd
);
1577 install_element(EIGRP_NODE
, &no_eigrp_metric_weights_cmd
);
1578 install_element(EIGRP_NODE
, &eigrp_maximum_paths_cmd
);
1579 install_element(EIGRP_NODE
, &no_eigrp_maximum_paths_cmd
);
1580 install_element(EIGRP_NODE
, &eigrp_neighbor_cmd
);
1581 install_element(EIGRP_NODE
, &no_eigrp_neighbor_cmd
);
1583 /* commands for manual hard restart */
1584 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_cmd
);
1585 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_cmd
);
1586 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_cmd
);
1587 /* commands for manual graceful restart */
1588 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_soft_cmd
);
1589 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_int_soft_cmd
);
1590 install_element(ENABLE_NODE
, &clear_ip_eigrp_neighbors_IP_soft_cmd
);
1592 eigrp_vty_zebra_init();