]> git.proxmox.com Git - mirror_frr.git/blob - eigrpd/eigrp_vty.c
Merge pull request #1921 from donaldsharp/pim_stuff
[mirror_frr.git] / eigrpd / eigrp_vty.c
1 /*
2 * EIGRP VTY Interface.
3 * Copyright (C) 2013-2016
4 * Authors:
5 * Donnie Savage
6 * Jan Janovic
7 * Matej Perina
8 * Peter Orsag
9 * Peter Paluch
10 * Frantisek Gazo
11 * Tomas Hvorkovy
12 * Martin Kontsek
13 * Lukas Koribsky
14 *
15 * This file is part of GNU Zebra.
16 *
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
20 * later version.
21 *
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.
26 *
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
30 */
31
32 #include <zebra.h>
33
34 #include "memory.h"
35 #include "thread.h"
36 #include "prefix.h"
37 #include "table.h"
38 #include "vty.h"
39 #include "command.h"
40 #include "plist.h"
41 #include "log.h"
42 #include "zclient.h"
43 #include "keychain.h"
44 #include "linklist.h"
45 #include "distribute.h"
46
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"
57
58 static int config_write_network(struct vty *vty, struct eigrp *eigrp)
59 {
60 struct route_node *rn;
61 int i;
62
63 /* `network area' print. */
64 for (rn = route_top(eigrp->networks); rn; rn = route_next(rn))
65 if (rn->info) {
66 /* Network print. */
67 vty_out(vty, " network %s/%d \n",
68 inet_ntoa(rn->p.u.prefix4), rn->p.prefixlen);
69 }
70
71 if (eigrp->max_paths != EIGRP_MAX_PATHS_DEFAULT)
72 vty_out(vty, " maximum-paths %d\n", eigrp->max_paths);
73
74 if (eigrp->variance != EIGRP_VARIANCE_DEFAULT)
75 vty_out(vty, " variance %d\n", eigrp->variance);
76
77 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
78 if (i != zclient->redist_default
79 && vrf_bitmap_check(zclient->redist[AFI_IP][i],
80 VRF_DEFAULT))
81 vty_out(vty, " redistribute %s\n",
82 zebra_route_string(i));
83
84 /*Separate EIGRP configuration from the rest of the config*/
85 vty_out(vty, "!\n");
86
87 return 0;
88 }
89
90 static int config_write_interfaces(struct vty *vty, struct eigrp *eigrp)
91 {
92 struct eigrp_interface *ei;
93 struct listnode *node;
94
95 for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) {
96 vty_frame(vty, "interface %s\n", ei->ifp->name);
97
98 if (ei->params.auth_type == EIGRP_AUTH_TYPE_MD5) {
99 vty_out(vty, " ip authentication mode eigrp %d md5\n",
100 eigrp->AS);
101 }
102
103 if (ei->params.auth_type == EIGRP_AUTH_TYPE_SHA256) {
104 vty_out(vty,
105 " ip authentication mode eigrp %d hmac-sha-256\n",
106 eigrp->AS);
107 }
108
109 if (ei->params.auth_keychain) {
110 vty_out(vty,
111 " ip authentication key-chain eigrp %d %s\n",
112 eigrp->AS, ei->params.auth_keychain);
113 }
114
115 if (ei->params.v_hello != EIGRP_HELLO_INTERVAL_DEFAULT) {
116 vty_out(vty, " ip hello-interval eigrp %d\n",
117 ei->params.v_hello);
118 }
119
120 if (ei->params.v_wait != EIGRP_HOLD_INTERVAL_DEFAULT) {
121 vty_out(vty, " ip hold-time eigrp %d\n",
122 ei->params.v_wait);
123 }
124
125 /*Separate this EIGRP interface configuration from the others*/
126 vty_endframe(vty, "!\n");
127 }
128
129 return 0;
130 }
131
132 static int eigrp_write_interface(struct vty *vty)
133 {
134 struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
135 struct interface *ifp;
136 struct eigrp_interface *ei;
137
138 FOR_ALL_INTERFACES (vrf, ifp) {
139 ei = ifp->info;
140 if (!ei)
141 continue;
142
143 vty_frame(vty, "interface %s\n", ifp->name);
144
145 if (ifp->desc)
146 vty_out(vty, " description %s\n", ifp->desc);
147
148 if (ei->params.bandwidth != EIGRP_BANDWIDTH_DEFAULT)
149 vty_out(vty, " bandwidth %u\n", ei->params.bandwidth);
150 if (ei->params.delay != EIGRP_DELAY_DEFAULT)
151 vty_out(vty, " delay %u\n", ei->params.delay);
152 if (ei->params.v_hello != EIGRP_HELLO_INTERVAL_DEFAULT)
153 vty_out(vty, " ip hello-interval eigrp %u\n",
154 ei->params.v_hello);
155 if (ei->params.v_wait != EIGRP_HOLD_INTERVAL_DEFAULT)
156 vty_out(vty, " ip hold-time eigrp %u\n",
157 ei->params.v_wait);
158
159 vty_endframe(vty, "!\n");
160 }
161
162 return 0;
163 }
164
165 /**
166 * Writes distribute lists to config
167 */
168 static int config_write_eigrp_distribute(struct vty *vty, struct eigrp *eigrp)
169 {
170 int write = 0;
171
172 /* Distribute configuration. */
173 write += config_write_distribute(vty);
174
175 return write;
176 }
177
178 /**
179 * Writes 'router eigrp' section to config
180 */
181 static int config_write_eigrp_router(struct vty *vty, struct eigrp *eigrp)
182 {
183 int write = 0;
184
185 /* `router eigrp' print. */
186 vty_out(vty, "router eigrp %d\n", eigrp->AS);
187
188 write++;
189
190 if (!eigrp->networks)
191 return write;
192
193 /* Router ID print. */
194 if (eigrp->router_id_static != 0) {
195 struct in_addr router_id_static;
196 router_id_static.s_addr = htonl(eigrp->router_id_static);
197 vty_out(vty, " eigrp router-id %s\n",
198 inet_ntoa(router_id_static));
199 }
200
201 /* Network area print. */
202 config_write_network(vty, eigrp);
203
204 /* Distribute-list and default-information print. */
205 config_write_eigrp_distribute(vty, eigrp);
206
207 /*Separate EIGRP configuration from the rest of the config*/
208 vty_out(vty, "!\n");
209
210 return write;
211 }
212
213 DEFUN_NOSH (router_eigrp,
214 router_eigrp_cmd,
215 "router eigrp (1-65535)",
216 "Enable a routing process\n"
217 "Start EIGRP configuration\n"
218 "AS Number to use\n")
219 {
220 struct eigrp *eigrp = eigrp_get(argv[2]->arg);
221 VTY_PUSH_CONTEXT(EIGRP_NODE, eigrp);
222
223 return CMD_SUCCESS;
224 }
225
226 DEFUN (no_router_eigrp,
227 no_router_eigrp_cmd,
228 "no router eigrp (1-65535)",
229 NO_STR
230 "Routing process\n"
231 "EIGRP configuration\n"
232 "AS number to use\n")
233 {
234 vty->node = CONFIG_NODE;
235
236 struct eigrp *eigrp;
237
238 eigrp = eigrp_lookup();
239 if (eigrp == NULL) {
240 vty_out(vty, " EIGRP Routing Process not enabled\n");
241 return CMD_SUCCESS;
242 }
243
244 if (eigrp->AS != atoi(argv[3]->arg)) {
245 vty_out(vty, "%% Attempting to deconfigure non-existent AS\n");
246 return CMD_WARNING_CONFIG_FAILED;
247 }
248
249 eigrp_finish_final(eigrp);
250
251 return CMD_SUCCESS;
252 }
253
254 DEFUN (eigrp_router_id,
255 eigrp_router_id_cmd,
256 "eigrp router-id A.B.C.D",
257 "EIGRP specific commands\n"
258 "Router ID for this EIGRP process\n"
259 "EIGRP Router-ID in IP address format\n")
260 {
261 // struct eigrp *eigrp = vty->index;
262 /*TODO: */
263
264 return CMD_SUCCESS;
265 }
266
267 DEFUN (no_eigrp_router_id,
268 no_eigrp_router_id_cmd,
269 "no eigrp router-id A.B.C.D",
270 NO_STR
271 "EIGRP specific commands\n"
272 "Router ID for this EIGRP process\n"
273 "EIGRP Router-ID in IP address format\n")
274 {
275 // struct eigrp *eigrp = vty->index;
276 /*TODO: */
277
278 return CMD_SUCCESS;
279 }
280
281 DEFUN (eigrp_passive_interface,
282 eigrp_passive_interface_cmd,
283 "passive-interface IFNAME",
284 "Suppress routing updates on an interface\n"
285 "Interface to suppress on\n")
286 {
287 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
288 struct eigrp_interface *ei;
289 struct listnode *node;
290 char *ifname = argv[1]->arg;
291
292 for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) {
293 if (strcmp(ifname, ei->ifp->name) == 0) {
294 ei->params.passive_interface = EIGRP_IF_PASSIVE;
295 return CMD_SUCCESS;
296 }
297 }
298 return CMD_SUCCESS;
299 }
300
301 DEFUN (no_eigrp_passive_interface,
302 no_eigrp_passive_interface_cmd,
303 "no passive-interface IFNAME",
304 NO_STR
305 "Suppress routing updates on an interface\n"
306 "Interface to suppress on\n")
307 {
308 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
309 struct eigrp_interface *ei;
310 struct listnode *node;
311 char *ifname = argv[2]->arg;
312
313 for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) {
314 if (strcmp(ifname, ei->ifp->name) == 0) {
315 ei->params.passive_interface = EIGRP_IF_ACTIVE;
316 return CMD_SUCCESS;
317 }
318 }
319
320 return CMD_SUCCESS;
321 }
322
323 DEFUN (eigrp_timers_active,
324 eigrp_timers_active_cmd,
325 "timers active-time <(1-65535)|disabled>",
326 "Adjust routing timers\n"
327 "Time limit for active state\n"
328 "Active state time limit in minutes\n"
329 "Disable time limit for active state\n")
330 {
331 // struct eigrp *eigrp = vty->index;
332 /*TODO: */
333
334 return CMD_SUCCESS;
335 }
336
337 DEFUN (no_eigrp_timers_active,
338 no_eigrp_timers_active_cmd,
339 "no timers active-time <(1-65535)|disabled>",
340 NO_STR
341 "Adjust routing timers\n"
342 "Time limit for active state\n"
343 "Active state time limit in minutes\n"
344 "Disable time limit for active state\n")
345 {
346 // struct eigrp *eigrp = vty->index;
347 /*TODO: */
348
349 return CMD_SUCCESS;
350 }
351
352
353 DEFUN (eigrp_metric_weights,
354 eigrp_metric_weights_cmd,
355 "metric weights (0-255) (0-255) (0-255) (0-255) (0-255) ",
356 "Modify metrics and parameters for advertisement\n"
357 "Modify metric coefficients\n"
358 "K1\n"
359 "K2\n"
360 "K3\n"
361 "K4\n"
362 "K5\n")
363 {
364 // struct eigrp *eigrp = vty->index;
365 /*TODO: */
366
367 return CMD_SUCCESS;
368 }
369
370 DEFUN (no_eigrp_metric_weights,
371 no_eigrp_metric_weights_cmd,
372 "no metric weights <0-255> <0-255> <0-255> <0-255> <0-255>",
373 NO_STR
374 "Modify metrics and parameters for advertisement\n"
375 "Modify metric coefficients\n"
376 "K1\n"
377 "K2\n"
378 "K3\n"
379 "K4\n"
380 "K5\n")
381 {
382 // struct eigrp *eigrp = vty->index;
383 /*TODO: */
384
385 return CMD_SUCCESS;
386 }
387
388
389 DEFUN (eigrp_network,
390 eigrp_network_cmd,
391 "network A.B.C.D/M",
392 "Enable routing on an IP network\n"
393 "EIGRP network prefix\n")
394 {
395 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
396 struct prefix p;
397 int ret;
398
399 (void)str2prefix(argv[1]->arg, &p);
400
401 ret = eigrp_network_set(eigrp, &p);
402
403 if (ret == 0) {
404 vty_out(vty, "There is already same network statement.\n");
405 return CMD_WARNING;
406 }
407
408 return CMD_SUCCESS;
409 }
410
411 DEFUN (no_eigrp_network,
412 no_eigrp_network_cmd,
413 "no network A.B.C.D/M",
414 NO_STR
415 "Disable routing on an IP network\n"
416 "EIGRP network prefix\n")
417 {
418 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
419 struct prefix p;
420 int ret;
421
422 (void)str2prefix(argv[2]->arg, &p);
423
424 ret = eigrp_network_unset(eigrp, &p);
425
426 if (ret == 0) {
427 vty_out(vty, "Can't find specified network configuration.\n");
428 return CMD_WARNING_CONFIG_FAILED;
429 }
430
431 return CMD_SUCCESS;
432 }
433
434 DEFUN (eigrp_neighbor,
435 eigrp_neighbor_cmd,
436 "neighbor A.B.C.D",
437 "Specify a neighbor router\n"
438 "Neighbor address\n")
439 {
440 // struct eigrp *eigrp = vty->index;
441
442 return CMD_SUCCESS;
443 }
444
445 DEFUN (no_eigrp_neighbor,
446 no_eigrp_neighbor_cmd,
447 "no neighbor A.B.C.D",
448 NO_STR
449 "Specify a neighbor router\n"
450 "Neighbor address\n")
451 {
452 // struct eigrp *eigrp = vty->index;
453
454 return CMD_SUCCESS;
455 }
456
457 DEFUN (show_ip_eigrp_topology,
458 show_ip_eigrp_topology_cmd,
459 "show ip eigrp topology [all-links]",
460 SHOW_STR
461 IP_STR
462 "IP-EIGRP show commands\n"
463 "IP-EIGRP topology\n"
464 "Show all links in topology table\n")
465 {
466 struct eigrp *eigrp;
467 struct listnode *node;
468 struct eigrp_prefix_entry *tn;
469 struct eigrp_nexthop_entry *te;
470 struct route_node *rn;
471 int first;
472
473 eigrp = eigrp_lookup();
474 if (eigrp == NULL) {
475 vty_out(vty, " EIGRP Routing Process not enabled\n");
476 return CMD_SUCCESS;
477 }
478
479 show_ip_eigrp_topology_header(vty, eigrp);
480
481 for (rn = route_top(eigrp->topology_table); rn; rn = route_next(rn)) {
482 if (!rn->info)
483 continue;
484
485 tn = rn->info;
486 first = 1;
487 for (ALL_LIST_ELEMENTS_RO(tn->entries, node, te)) {
488 if (argc == 5
489 || (((te->flags
490 & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)
491 == EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)
492 || ((te->flags
493 & EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG)
494 == EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG))) {
495 show_ip_eigrp_nexthop_entry(vty, eigrp, te,
496 &first);
497 first = 0;
498 }
499 }
500 }
501
502 return CMD_SUCCESS;
503 }
504
505 ALIAS(show_ip_eigrp_topology, show_ip_eigrp_topology_detail_cmd,
506 "show ip eigrp topology <A.B.C.D|A.B.C.D/M|detail|summary>",
507 SHOW_STR IP_STR
508 "IP-EIGRP show commands\n"
509 "IP-EIGRP topology\n"
510 "Netwok to display information about\n"
511 "IP prefix <network>/<length>, e.g., 192.168.0.0/16\n"
512 "Show all links in topology table\n"
513 "Show a summary of the topology table\n")
514
515 DEFUN (show_ip_eigrp_interfaces,
516 show_ip_eigrp_interfaces_cmd,
517 "show ip eigrp interfaces [IFNAME] [detail]",
518 SHOW_STR
519 IP_STR
520 "IP-EIGRP show commands\n"
521 "IP-EIGRP interfaces\n"
522 "Interface name to look at\n"
523 "Detailed information\n")
524 {
525 struct eigrp_interface *ei;
526 struct eigrp *eigrp;
527 struct listnode *node;
528 int idx = 0;
529 bool detail = false;
530 const char *ifname = NULL;
531
532 eigrp = eigrp_lookup();
533 if (eigrp == NULL) {
534 vty_out(vty, "EIGRP Routing Process not enabled\n");
535 return CMD_SUCCESS;
536 }
537
538 if (argv_find(argv, argc, "IFNAME", &idx))
539 ifname = argv[idx]->arg;
540
541 if (argv_find(argv, argc, "detail", &idx))
542 detail = true;
543
544 if (!ifname)
545 show_ip_eigrp_interface_header(vty, eigrp);
546
547 for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) {
548 if (!ifname || strcmp(ei->ifp->name, ifname) == 0) {
549 show_ip_eigrp_interface_sub(vty, eigrp, ei);
550 if (detail)
551 show_ip_eigrp_interface_detail(vty, eigrp, ei);
552 }
553 }
554
555 return CMD_SUCCESS;
556 }
557
558 DEFUN (show_ip_eigrp_neighbors,
559 show_ip_eigrp_neighbors_cmd,
560 "show ip eigrp neighbors [IFNAME] [detail]",
561 SHOW_STR
562 IP_STR
563 "IP-EIGRP show commands\n"
564 "IP-EIGRP neighbors\n"
565 "Interface to show on\n"
566 "Detailed Information\n")
567 {
568 struct eigrp *eigrp;
569 struct eigrp_interface *ei;
570 struct listnode *node, *node2, *nnode2;
571 struct eigrp_neighbor *nbr;
572 bool detail = false;
573 int idx = 0;
574 const char *ifname = NULL;
575
576 eigrp = eigrp_lookup();
577 if (eigrp == NULL) {
578 vty_out(vty, " EIGRP Routing Process not enabled\n");
579 return CMD_SUCCESS;
580 }
581
582 if (argv_find(argv, argc, "IFNAME", &idx))
583 ifname = argv[idx]->arg;
584
585 detail = (argv_find(argv, argc, "detail", &idx));
586
587 show_ip_eigrp_neighbor_header(vty, eigrp);
588
589 for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) {
590 if (!ifname || strcmp(ei->ifp->name, ifname) == 0) {
591 for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) {
592 if (detail || (nbr->state == EIGRP_NEIGHBOR_UP))
593 show_ip_eigrp_neighbor_sub(vty, nbr,
594 detail);
595 }
596 }
597 }
598
599 return CMD_SUCCESS;
600 }
601
602 DEFUN (eigrp_if_delay,
603 eigrp_if_delay_cmd,
604 "delay (1-16777215)",
605 "Specify interface throughput delay\n"
606 "Throughput delay (tens of microseconds)\n")
607 {
608 VTY_DECLVAR_CONTEXT(interface, ifp);
609 struct eigrp_interface *ei = ifp->info;
610 struct eigrp *eigrp;
611 uint32_t delay;
612
613 eigrp = eigrp_lookup();
614 if (eigrp == NULL) {
615 vty_out(vty, " EIGRP Routing Process not enabled\n");
616
617 return CMD_SUCCESS;
618 }
619
620 if (!ei) {
621 vty_out(vty, " EIGRP not configured on this interface\n");
622 return CMD_SUCCESS;
623 }
624 delay = atoi(argv[1]->arg);
625
626 ei->params.delay = delay;
627 eigrp_if_reset(ifp);
628
629 return CMD_SUCCESS;
630 }
631
632 DEFUN (no_eigrp_if_delay,
633 no_eigrp_if_delay_cmd,
634 "no delay (1-16777215)",
635 NO_STR
636 "Specify interface throughput delay\n"
637 "Throughput delay (tens of microseconds)\n")
638 {
639 VTY_DECLVAR_CONTEXT(interface, ifp);
640 struct eigrp_interface *ei = ifp->info;
641 struct eigrp *eigrp;
642
643 eigrp = eigrp_lookup();
644 if (eigrp == NULL) {
645 vty_out(vty, " EIGRP Routing Process not enabled\n");
646
647 return CMD_SUCCESS;
648 }
649 if (!ei) {
650 vty_out(vty, " EIGRP not configured on this interface\n");
651 return CMD_SUCCESS;
652 }
653
654 ei->params.delay = EIGRP_DELAY_DEFAULT;
655 eigrp_if_reset(ifp);
656
657 return CMD_SUCCESS;
658 }
659
660 DEFUN (eigrp_if_bandwidth,
661 eigrp_if_bandwidth_cmd,
662 "eigrp bandwidth (1-10000000)",
663 "EIGRP specific commands\n"
664 "Set bandwidth informational parameter\n"
665 "Bandwidth in kilobits\n")
666 {
667 VTY_DECLVAR_CONTEXT(interface, ifp);
668 struct eigrp_interface *ei = ifp->info;
669 uint32_t bandwidth;
670 struct eigrp *eigrp;
671
672 eigrp = eigrp_lookup();
673 if (eigrp == NULL) {
674 vty_out(vty, " EIGRP Routing Process not enabled\n");
675 return CMD_SUCCESS;
676 }
677
678 if (!ei) {
679 vty_out(vty, " EIGRP not configured on this interface\n");
680 return CMD_SUCCESS;
681 }
682
683 bandwidth = atoi(argv[1]->arg);
684
685 ei->params.bandwidth = bandwidth;
686 eigrp_if_reset(ifp);
687
688 return CMD_SUCCESS;
689 }
690
691 DEFUN (no_eigrp_if_bandwidth,
692 no_eigrp_if_bandwidth_cmd,
693 "no eigrp bandwidth [(1-10000000)]",
694 NO_STR
695 "EIGRP specific commands\n"
696 "Set bandwidth informational parameter\n"
697 "Bandwidth in kilobits\n")
698 {
699 VTY_DECLVAR_CONTEXT(interface, ifp);
700 struct eigrp_interface *ei = ifp->info;
701 struct eigrp *eigrp;
702
703 eigrp = eigrp_lookup();
704 if (eigrp == NULL) {
705 vty_out(vty, " EIGRP Routing Process not enabled\n");
706 return CMD_SUCCESS;
707 }
708
709 if (!ei) {
710 vty_out(vty, " EIGRP not configured on this interface\n");
711 return CMD_SUCCESS;
712 }
713
714 ei->params.bandwidth = EIGRP_BANDWIDTH_DEFAULT;
715 eigrp_if_reset(ifp);
716
717 return CMD_SUCCESS;
718 }
719
720 DEFUN (eigrp_if_ip_hellointerval,
721 eigrp_if_ip_hellointerval_cmd,
722 "ip hello-interval eigrp (1-65535)",
723 "Interface Internet Protocol config commands\n"
724 "Configures EIGRP hello interval\n"
725 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
726 "Seconds between hello transmissions\n")
727 {
728 VTY_DECLVAR_CONTEXT(interface, ifp);
729 struct eigrp_interface *ei = ifp->info;
730 uint32_t hello;
731 struct eigrp *eigrp;
732
733 eigrp = eigrp_lookup();
734 if (eigrp == NULL) {
735 vty_out(vty, " EIGRP Routing Process not enabled\n");
736 return CMD_SUCCESS;
737 }
738
739 if (!ei) {
740 vty_out(vty, " EIGRP not configured on this interface\n");
741 return CMD_SUCCESS;
742 }
743
744 hello = atoi(argv[3]->arg);
745
746 ei->params.v_hello = hello;
747
748 return CMD_SUCCESS;
749 }
750
751 DEFUN (no_eigrp_if_ip_hellointerval,
752 no_eigrp_if_ip_hellointerval_cmd,
753 "no ip hello-interval eigrp [(1-65535)]",
754 NO_STR
755 "Interface Internet Protocol config commands\n"
756 "Configures EIGRP hello interval\n"
757 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
758 "Seconds between hello transmissions\n")
759 {
760 VTY_DECLVAR_CONTEXT(interface, ifp);
761 struct eigrp_interface *ei = ifp->info;
762 struct eigrp *eigrp;
763
764 eigrp = eigrp_lookup();
765 if (eigrp == NULL) {
766 vty_out(vty, " EIGRP Routing Process not enabled\n");
767 return CMD_SUCCESS;
768 }
769
770 if (!ei) {
771 vty_out(vty, " EIGRP not configured on this interface\n");
772 return CMD_SUCCESS;
773 }
774
775 ei->params.v_hello = EIGRP_HELLO_INTERVAL_DEFAULT;
776
777 THREAD_TIMER_OFF(ei->t_hello);
778 thread_add_timer(master, eigrp_hello_timer, ei, 1, &ei->t_hello);
779
780 return CMD_SUCCESS;
781 }
782
783 DEFUN (eigrp_if_ip_holdinterval,
784 eigrp_if_ip_holdinterval_cmd,
785 "ip hold-time eigrp (1-65535)",
786 "Interface Internet Protocol config commands\n"
787 "Configures EIGRP IPv4 hold time\n"
788 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
789 "Seconds before neighbor is considered down\n")
790 {
791 VTY_DECLVAR_CONTEXT(interface, ifp);
792 struct eigrp_interface *ei = ifp->info;
793 uint32_t hold;
794 struct eigrp *eigrp;
795
796 eigrp = eigrp_lookup();
797 if (eigrp == NULL) {
798 vty_out(vty, " EIGRP Routing Process not enabled\n");
799 return CMD_SUCCESS;
800 }
801
802 if (!ei) {
803 vty_out(vty, " EIGRP not configured on this interface\n");
804 return CMD_SUCCESS;
805 }
806
807 hold = atoi(argv[3]->arg);
808
809 ei->params.v_wait = hold;
810
811 return CMD_SUCCESS;
812 }
813
814 DEFUN (eigrp_ip_summary_address,
815 eigrp_ip_summary_address_cmd,
816 "ip summary-address eigrp (1-65535) A.B.C.D/M",
817 "Interface Internet Protocol config commands\n"
818 "Perform address summarization\n"
819 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
820 "AS number\n"
821 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
822 {
823 // VTY_DECLVAR_CONTEXT(interface, ifp);
824 // uint32_t AS;
825 struct eigrp *eigrp;
826
827 eigrp = eigrp_lookup();
828 if (eigrp == NULL) {
829 vty_out(vty, " EIGRP Routing Process not enabled\n");
830 return CMD_SUCCESS;
831 }
832
833 // AS = atoi (argv[3]->arg);
834
835 /*TODO: */
836
837 return CMD_SUCCESS;
838 }
839
840 DEFUN (no_eigrp_ip_summary_address,
841 no_eigrp_ip_summary_address_cmd,
842 "no ip summary-address eigrp (1-65535) A.B.C.D/M",
843 NO_STR
844 "Interface Internet Protocol config commands\n"
845 "Perform address summarization\n"
846 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
847 "AS number\n"
848 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
849 {
850 // VTY_DECLVAR_CONTEXT(interface, ifp);
851 // uint32_t AS;
852 struct eigrp *eigrp;
853
854 eigrp = eigrp_lookup();
855 if (eigrp == NULL) {
856 vty_out(vty, " EIGRP Routing Process not enabled\n");
857 return CMD_SUCCESS;
858 }
859
860 // AS = atoi (argv[4]->arg);
861
862 /*TODO: */
863
864 return CMD_SUCCESS;
865 }
866
867 DEFUN (no_eigrp_if_ip_holdinterval,
868 no_eigrp_if_ip_holdinterval_cmd,
869 "no ip hold-time eigrp",
870 NO_STR
871 "Interface Internet Protocol config commands\n"
872 "Configures EIGRP hello interval\n"
873 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n")
874 {
875 VTY_DECLVAR_CONTEXT(interface, ifp);
876 struct eigrp_interface *ei = ifp->info;
877 struct eigrp *eigrp;
878
879 eigrp = eigrp_lookup();
880 if (eigrp == NULL) {
881 vty_out(vty, " EIGRP Routing Process not enabled\n");
882 return CMD_SUCCESS;
883 }
884
885 if (!ei) {
886 vty_out(vty, " EIGRP not configured on this interface\n");
887 return CMD_SUCCESS;
888 }
889
890 ei->params.v_wait = EIGRP_HOLD_INTERVAL_DEFAULT;
891
892 return CMD_SUCCESS;
893 }
894
895 static int str2auth_type(const char *str, struct eigrp_interface *ei)
896 {
897 /* Sanity check. */
898 if (str == NULL)
899 return CMD_WARNING_CONFIG_FAILED;
900
901 if (strncmp(str, "md5", 3) == 0) {
902 ei->params.auth_type = EIGRP_AUTH_TYPE_MD5;
903 return CMD_SUCCESS;
904 } else if (strncmp(str, "hmac-sha-256", 12) == 0) {
905 ei->params.auth_type = EIGRP_AUTH_TYPE_SHA256;
906 return CMD_SUCCESS;
907 }
908
909 return CMD_WARNING_CONFIG_FAILED;
910 }
911
912 DEFUN (eigrp_authentication_mode,
913 eigrp_authentication_mode_cmd,
914 "ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
915 "Interface Internet Protocol config commands\n"
916 "Authentication subcommands\n"
917 "Mode\n"
918 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
919 "Autonomous system number\n"
920 "Keyed message digest\n"
921 "HMAC SHA256 algorithm \n")
922 {
923 VTY_DECLVAR_CONTEXT(interface, ifp);
924 struct eigrp_interface *ei = ifp->info;
925 struct eigrp *eigrp;
926
927 eigrp = eigrp_lookup();
928 if (eigrp == NULL) {
929 vty_out(vty, " EIGRP Routing Process not enabled\n");
930 return CMD_SUCCESS;
931 }
932
933 if (!ei) {
934 vty_out(vty, " EIGRP not configured on this interface\n");
935 return CMD_SUCCESS;
936 }
937
938 // if(strncmp(argv[2], "md5",3))
939 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_MD5;
940 // else if(strncmp(argv[2], "hmac-sha-256",12))
941 // IF_DEF_PARAMS (ifp)->auth_type = EIGRP_AUTH_TYPE_SHA256;
942
943 return str2auth_type(argv[5]->arg, ei);
944 }
945
946 DEFUN (no_eigrp_authentication_mode,
947 no_eigrp_authentication_mode_cmd,
948 "no ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
949 "Disable\n"
950 "Interface Internet Protocol config commands\n"
951 "Authentication subcommands\n"
952 "Mode\n"
953 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
954 "Autonomous system number\n"
955 "Keyed message digest\n"
956 "HMAC SHA256 algorithm \n")
957 {
958 VTY_DECLVAR_CONTEXT(interface, ifp);
959 struct eigrp_interface *ei = ifp->info;
960 struct eigrp *eigrp;
961
962 eigrp = eigrp_lookup();
963 if (eigrp == NULL) {
964 vty_out(vty, " EIGRP Routing Process not enabled\n");
965 return CMD_SUCCESS;
966 }
967
968 if (!ei) {
969 vty_out(vty, " EIGRP not configured on this interface\n");
970 return CMD_SUCCESS;
971 }
972
973 ei->params.auth_type = EIGRP_AUTH_TYPE_NONE;
974
975 return CMD_SUCCESS;
976 }
977
978 DEFUN (eigrp_authentication_keychain,
979 eigrp_authentication_keychain_cmd,
980 "ip authentication key-chain eigrp (1-65535) WORD",
981 "Interface Internet Protocol config commands\n"
982 "Authentication subcommands\n"
983 "Key-chain\n"
984 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
985 "Autonomous system number\n"
986 "Name of key-chain\n")
987 {
988 VTY_DECLVAR_CONTEXT(interface, ifp);
989 struct eigrp_interface *ei = ifp->info;
990 struct eigrp *eigrp;
991 struct keychain *keychain;
992
993 eigrp = eigrp_lookup();
994 if (eigrp == NULL) {
995 vty_out(vty, "EIGRP Routing Process not enabled\n");
996 return CMD_SUCCESS;
997 }
998
999 if (!ei) {
1000 vty_out(vty, " EIGRP not configured on this interface\n");
1001 return CMD_SUCCESS;
1002 }
1003
1004 keychain = keychain_lookup(argv[4]->arg);
1005 if (keychain != NULL) {
1006 if (ei->params.auth_keychain) {
1007 free(ei->params.auth_keychain);
1008 ei->params.auth_keychain = strdup(keychain->name);
1009 } else
1010 ei->params.auth_keychain = strdup(keychain->name);
1011 } else
1012 vty_out(vty, "Key chain with specified name not found\n");
1013
1014 return CMD_SUCCESS;
1015 }
1016
1017 DEFUN (no_eigrp_authentication_keychain,
1018 no_eigrp_authentication_keychain_cmd,
1019 "no ip authentication key-chain eigrp (1-65535) WORD",
1020 "Disable\n"
1021 "Interface Internet Protocol config commands\n"
1022 "Authentication subcommands\n"
1023 "Key-chain\n"
1024 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
1025 "Autonomous system number\n"
1026 "Name of key-chain\n")
1027 {
1028 VTY_DECLVAR_CONTEXT(interface, ifp);
1029 struct eigrp_interface *ei = ifp->info;
1030 struct eigrp *eigrp;
1031
1032 eigrp = eigrp_lookup();
1033 if (eigrp == NULL) {
1034 vty_out(vty, "EIGRP Routing Process not enabled\n");
1035 return CMD_SUCCESS;
1036 }
1037
1038 if (!ei) {
1039 vty_out(vty, " EIGRP not configured on this interface\n");
1040 return CMD_SUCCESS;
1041 }
1042
1043 if ((ei->params.auth_keychain != NULL)
1044 && (strcmp(ei->params.auth_keychain, argv[5]->arg) == 0)) {
1045 free(ei->params.auth_keychain);
1046 ei->params.auth_keychain = NULL;
1047 } else
1048 vty_out(vty,
1049 "Key chain with specified name not configured on interface\n");
1050
1051 return CMD_SUCCESS;
1052 }
1053
1054 DEFUN (eigrp_redistribute_source_metric,
1055 eigrp_redistribute_source_metric_cmd,
1056 "redistribute " FRR_REDIST_STR_EIGRPD
1057 " [metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)]",
1058 REDIST_STR
1059 FRR_REDIST_HELP_STR_EIGRPD
1060 "Metric for redistributed routes\n"
1061 "Bandwidth metric in Kbits per second\n"
1062 "EIGRP delay metric, in 10 microsecond units\n"
1063 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1064 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1065 "EIGRP MTU of the path\n")
1066 {
1067 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
1068 struct eigrp_metrics metrics_from_command = {0};
1069 int source;
1070 int idx = 0;
1071
1072 /* Get distribute source. */
1073 argv_find(argv, argc, "redistribute", &idx);
1074 source = proto_redistnum(AFI_IP, argv[idx + 1]->text);
1075 if (source < 0) {
1076 vty_out(vty, "%% Invalid route type\n");
1077 return CMD_WARNING_CONFIG_FAILED;
1078 }
1079
1080 /* Get metrics values */
1081
1082 return eigrp_redistribute_set(eigrp, source, metrics_from_command);
1083 }
1084
1085 DEFUN (no_eigrp_redistribute_source_metric,
1086 no_eigrp_redistribute_source_metric_cmd,
1087 "no redistribute " FRR_REDIST_STR_EIGRPD
1088 " metric (1-4294967295) (0-4294967295) (0-255) (1-255) (1-65535)",
1089 "Disable\n"
1090 REDIST_STR
1091 FRR_REDIST_HELP_STR_EIGRPD
1092 "Metric for redistributed routes\n"
1093 "Bandwidth metric in Kbits per second\n"
1094 "EIGRP delay metric, in 10 microsecond units\n"
1095 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
1096 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
1097 "EIGRP MTU of the path\n")
1098 {
1099 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
1100 int source;
1101 int idx = 0;
1102
1103 /* Get distribute source. */
1104 argv_find(argv, argc, "redistribute", &idx);
1105 source = proto_redistnum(AFI_IP, argv[idx + 1]->text);
1106 if (source < 0) {
1107 vty_out(vty, "%% Invalid route type\n");
1108 return CMD_WARNING_CONFIG_FAILED;
1109 }
1110
1111 /* Get metrics values */
1112
1113 return eigrp_redistribute_unset(eigrp, source);
1114 }
1115
1116 DEFUN (eigrp_variance,
1117 eigrp_variance_cmd,
1118 "variance (1-128)",
1119 "Control load balancing variance\n"
1120 "Metric variance multiplier\n")
1121 {
1122 struct eigrp *eigrp;
1123 uint8_t variance;
1124
1125 eigrp = eigrp_lookup();
1126 if (eigrp == NULL) {
1127 vty_out(vty, "EIGRP Routing Process not enabled\n");
1128 return CMD_SUCCESS;
1129 }
1130 variance = atoi(argv[1]->arg);
1131
1132 eigrp->variance = variance;
1133
1134 /*TODO: */
1135
1136 return CMD_SUCCESS;
1137 }
1138
1139 DEFUN (no_eigrp_variance,
1140 no_eigrp_variance_cmd,
1141 "no variance (1-128)",
1142 "Disable\n"
1143 "Control load balancing variance\n"
1144 "Metric variance multiplier\n")
1145 {
1146 struct eigrp *eigrp;
1147 eigrp = eigrp_lookup();
1148 if (eigrp == NULL) {
1149 vty_out(vty, "EIGRP Routing Process not enabled\n");
1150 return CMD_SUCCESS;
1151 }
1152
1153 eigrp->variance = EIGRP_VARIANCE_DEFAULT;
1154
1155 /*TODO: */
1156
1157 return CMD_SUCCESS;
1158 }
1159
1160 DEFUN (eigrp_maximum_paths,
1161 eigrp_maximum_paths_cmd,
1162 "maximum-paths (1-32)",
1163 "Forward packets over multiple paths\n"
1164 "Number of paths\n")
1165 {
1166 struct eigrp *eigrp;
1167 uint8_t max;
1168
1169 eigrp = eigrp_lookup();
1170 if (eigrp == NULL) {
1171 vty_out(vty, "EIGRP Routing Process not enabled\n");
1172 return CMD_SUCCESS;
1173 }
1174
1175 max = atoi(argv[1]->arg);
1176
1177 eigrp->max_paths = max;
1178
1179 /*TODO: */
1180
1181 return CMD_SUCCESS;
1182 }
1183
1184 DEFUN (no_eigrp_maximum_paths,
1185 no_eigrp_maximum_paths_cmd,
1186 "no maximum-paths <1-32>",
1187 NO_STR
1188 "Forward packets over multiple paths\n"
1189 "Number of paths\n")
1190 {
1191 struct eigrp *eigrp;
1192
1193 eigrp = eigrp_lookup();
1194 if (eigrp == NULL) {
1195 vty_out(vty, "EIGRP Routing Process not enabled\n");
1196 return CMD_SUCCESS;
1197 }
1198
1199 eigrp->max_paths = EIGRP_MAX_PATHS_DEFAULT;
1200
1201 /*TODO: */
1202
1203 return CMD_SUCCESS;
1204 }
1205
1206 /*
1207 * Execute hard restart for all neighbors
1208 */
1209 DEFUN (clear_ip_eigrp_neighbors,
1210 clear_ip_eigrp_neighbors_cmd,
1211 "clear ip eigrp neighbors",
1212 CLEAR_STR
1213 IP_STR
1214 "Clear IP-EIGRP\n"
1215 "Clear IP-EIGRP neighbors\n")
1216 {
1217 struct eigrp *eigrp;
1218 struct eigrp_interface *ei;
1219 struct listnode *node, *node2, *nnode2;
1220 struct eigrp_neighbor *nbr;
1221
1222 /* Check if eigrp process is enabled */
1223 eigrp = eigrp_lookup();
1224 if (eigrp == NULL) {
1225 vty_out(vty, " EIGRP Routing Process not enabled\n");
1226 return CMD_SUCCESS;
1227 }
1228
1229 /* iterate over all eigrp interfaces */
1230 for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) {
1231 /* send Goodbye Hello */
1232 eigrp_hello_send(ei, EIGRP_HELLO_GRACEFUL_SHUTDOWN, NULL);
1233
1234 /* iterate over all neighbors on eigrp interface */
1235 for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) {
1236 if (nbr->state != EIGRP_NEIGHBOR_DOWN) {
1237 zlog_debug(
1238 "Neighbor %s (%s) is down: manually cleared",
1239 inet_ntoa(nbr->src),
1240 ifindex2ifname(nbr->ei->ifp->ifindex,
1241 VRF_DEFAULT));
1242 vty_time_print(vty, 0);
1243 vty_out(vty,
1244 "Neighbor %s (%s) is down: manually cleared\n",
1245 inet_ntoa(nbr->src),
1246 ifindex2ifname(nbr->ei->ifp->ifindex,
1247 VRF_DEFAULT));
1248
1249 /* set neighbor to DOWN */
1250 nbr->state = EIGRP_NEIGHBOR_DOWN;
1251 /* delete neighbor */
1252 eigrp_nbr_delete(nbr);
1253 }
1254 }
1255 }
1256
1257 return CMD_SUCCESS;
1258 }
1259
1260 /*
1261 * Execute hard restart for all neighbors on interface
1262 */
1263 DEFUN (clear_ip_eigrp_neighbors_int,
1264 clear_ip_eigrp_neighbors_int_cmd,
1265 "clear ip eigrp neighbors IFNAME",
1266 CLEAR_STR
1267 IP_STR
1268 "Clear IP-EIGRP\n"
1269 "Clear IP-EIGRP neighbors\n"
1270 "Interface's name\n")
1271 {
1272 struct eigrp *eigrp;
1273 struct eigrp_interface *ei;
1274 struct listnode *node2, *nnode2;
1275 struct eigrp_neighbor *nbr;
1276 int idx = 0;
1277
1278 /* Check if eigrp process is enabled */
1279 eigrp = eigrp_lookup();
1280 if (eigrp == NULL) {
1281 vty_out(vty, " EIGRP Routing Process not enabled\n");
1282 return CMD_SUCCESS;
1283 }
1284
1285 /* lookup interface by specified name */
1286 argv_find(argv, argc, "IFNAME", &idx);
1287 ei = eigrp_if_lookup_by_name(eigrp, argv[idx]->arg);
1288 if (ei == NULL) {
1289 vty_out(vty, " Interface (%s) doesn't exist\n", argv[idx]->arg);
1290 return CMD_WARNING;
1291 }
1292
1293 /* send Goodbye Hello */
1294 eigrp_hello_send(ei, EIGRP_HELLO_GRACEFUL_SHUTDOWN, NULL);
1295
1296 /* iterate over all neighbors on eigrp interface */
1297 for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) {
1298 if (nbr->state != EIGRP_NEIGHBOR_DOWN) {
1299 zlog_debug("Neighbor %s (%s) is down: manually cleared",
1300 inet_ntoa(nbr->src),
1301 ifindex2ifname(nbr->ei->ifp->ifindex,
1302 VRF_DEFAULT));
1303 vty_time_print(vty, 0);
1304 vty_out(vty,
1305 "Neighbor %s (%s) is down: manually cleared\n",
1306 inet_ntoa(nbr->src),
1307 ifindex2ifname(nbr->ei->ifp->ifindex,
1308 VRF_DEFAULT));
1309
1310 /* set neighbor to DOWN */
1311 nbr->state = EIGRP_NEIGHBOR_DOWN;
1312 /* delete neighbor */
1313 eigrp_nbr_delete(nbr);
1314 }
1315 }
1316
1317 return CMD_SUCCESS;
1318 }
1319
1320 /*
1321 * Execute hard restart for neighbor specified by IP
1322 */
1323 DEFUN (clear_ip_eigrp_neighbors_IP,
1324 clear_ip_eigrp_neighbors_IP_cmd,
1325 "clear ip eigrp neighbors A.B.C.D",
1326 CLEAR_STR
1327 IP_STR
1328 "Clear IP-EIGRP\n"
1329 "Clear IP-EIGRP neighbors\n"
1330 "IP-EIGRP neighbor address\n")
1331 {
1332 struct eigrp *eigrp;
1333 struct eigrp_neighbor *nbr;
1334 struct in_addr nbr_addr;
1335
1336 if (!inet_aton(argv[4]->arg, &nbr_addr)) {
1337 vty_out(vty, "Unable to parse %s", argv[4]->arg);
1338 return CMD_WARNING;
1339 }
1340
1341 /* Check if eigrp process is enabled */
1342 eigrp = eigrp_lookup();
1343 if (eigrp == NULL) {
1344 vty_out(vty, " EIGRP Routing Process not enabled\n");
1345 return CMD_SUCCESS;
1346 }
1347
1348 /* lookup neighbor in whole process */
1349 nbr = eigrp_nbr_lookup_by_addr_process(eigrp, nbr_addr);
1350
1351 /* if neighbor doesn't exists, notify user and exit */
1352 if (nbr == NULL) {
1353 vty_out(vty, "Neighbor with entered address doesn't exists.\n");
1354 return CMD_WARNING;
1355 }
1356
1357 /* execute hard reset on neighbor */
1358 eigrp_nbr_hard_restart(nbr, vty);
1359
1360 return CMD_SUCCESS;
1361 }
1362
1363 /*
1364 * Execute graceful restart for all neighbors
1365 */
1366 DEFUN (clear_ip_eigrp_neighbors_soft,
1367 clear_ip_eigrp_neighbors_soft_cmd,
1368 "clear ip eigrp neighbors soft",
1369 CLEAR_STR
1370 IP_STR
1371 "Clear IP-EIGRP\n"
1372 "Clear IP-EIGRP neighbors\n"
1373 "Resync with peers without adjacency reset\n")
1374 {
1375 struct eigrp *eigrp;
1376
1377 /* Check if eigrp process is enabled */
1378 eigrp = eigrp_lookup();
1379 if (eigrp == NULL) {
1380 vty_out(vty, " EIGRP Routing Process not enabled\n");
1381 return CMD_SUCCESS;
1382 }
1383
1384 /* execute graceful restart on all neighbors */
1385 eigrp_update_send_process_GR(eigrp, EIGRP_GR_MANUAL, vty);
1386
1387 return CMD_SUCCESS;
1388 }
1389
1390 /*
1391 * Execute graceful restart for all neighbors on interface
1392 */
1393 DEFUN (clear_ip_eigrp_neighbors_int_soft,
1394 clear_ip_eigrp_neighbors_int_soft_cmd,
1395 "clear ip eigrp neighbors IFNAME soft",
1396 CLEAR_STR
1397 IP_STR
1398 "Clear IP-EIGRP\n"
1399 "Clear IP-EIGRP neighbors\n"
1400 "Interface's name\n"
1401 "Resync with peer without adjacency reset\n")
1402 {
1403 struct eigrp *eigrp;
1404 struct eigrp_interface *ei;
1405
1406 /* Check if eigrp process is enabled */
1407 eigrp = eigrp_lookup();
1408 if (eigrp == NULL) {
1409 vty_out(vty, " EIGRP Routing Process not enabled\n");
1410 return CMD_SUCCESS;
1411 }
1412
1413 /* lookup interface by specified name */
1414 ei = eigrp_if_lookup_by_name(eigrp, argv[4]->arg);
1415 if (ei == NULL) {
1416 vty_out(vty, " Interface (%s) doesn't exist\n", argv[4]->arg);
1417 return CMD_WARNING;
1418 }
1419
1420 /* execute graceful restart for all neighbors on interface */
1421 eigrp_update_send_interface_GR(ei, EIGRP_GR_MANUAL, vty);
1422 return CMD_SUCCESS;
1423 }
1424
1425 /*
1426 * Execute graceful restart for neighbor specified by IP
1427 */
1428 DEFUN (clear_ip_eigrp_neighbors_IP_soft,
1429 clear_ip_eigrp_neighbors_IP_soft_cmd,
1430 "clear ip eigrp neighbors A.B.C.D soft",
1431 CLEAR_STR
1432 IP_STR
1433 "Clear IP-EIGRP\n"
1434 "Clear IP-EIGRP neighbors\n"
1435 "IP-EIGRP neighbor address\n"
1436 "Resync with peer without adjacency reset\n")
1437 {
1438 struct eigrp *eigrp;
1439 struct eigrp_neighbor *nbr;
1440 struct in_addr nbr_addr;
1441
1442 if (!inet_aton(argv[4]->arg, &nbr_addr)) {
1443 vty_out(vty, "Unable to parse: %s", argv[4]->arg);
1444 return CMD_WARNING;
1445 }
1446
1447 /* Check if eigrp process is enabled */
1448 eigrp = eigrp_lookup();
1449 if (eigrp == NULL) {
1450 vty_out(vty, " EIGRP Routing Process not enabled\n");
1451 return CMD_SUCCESS;
1452 }
1453
1454 /* lookup neighbor in whole process */
1455 nbr = eigrp_nbr_lookup_by_addr_process(eigrp, nbr_addr);
1456
1457 /* if neighbor doesn't exists, notify user and exit */
1458 if (nbr == NULL) {
1459 vty_out(vty, "Neighbor with entered address doesn't exists.\n");
1460 return CMD_WARNING;
1461 }
1462
1463 /* execute graceful restart on neighbor */
1464 eigrp_update_send_GR(nbr, EIGRP_GR_MANUAL, vty);
1465
1466 return CMD_SUCCESS;
1467 }
1468
1469 static struct cmd_node eigrp_node = {EIGRP_NODE, "%s(config-router)# ", 1};
1470
1471 /* Save EIGRP configuration */
1472 static int eigrp_config_write(struct vty *vty)
1473 {
1474 struct eigrp *eigrp;
1475
1476 int write = 0;
1477
1478 eigrp = eigrp_lookup();
1479 if (eigrp != NULL) {
1480 /* Writes 'router eigrp' section to config */
1481 config_write_eigrp_router(vty, eigrp);
1482
1483 /* Interface config print */
1484 config_write_interfaces(vty, eigrp);
1485 //
1486 // /* static neighbor print. */
1487 // config_write_eigrp_nbr_nbma (vty, eigrp);
1488 //
1489 // /* Virtual-Link print. */
1490 // config_write_virtual_link (vty, eigrp);
1491 //
1492 // /* Default metric configuration. */
1493 // config_write_eigrp_default_metric (vty, eigrp);
1494 //
1495 // /* Distribute-list and default-information print. */
1496 // config_write_eigrp_distribute (vty, eigrp);
1497 //
1498 // /* Distance configuration. */
1499 // config_write_eigrp_distance (vty, eigrp)
1500 }
1501
1502 return write;
1503 }
1504
1505 void eigrp_vty_show_init(void)
1506 {
1507 install_element(VIEW_NODE, &show_ip_eigrp_interfaces_cmd);
1508
1509 install_element(VIEW_NODE, &show_ip_eigrp_neighbors_cmd);
1510
1511 install_element(VIEW_NODE, &show_ip_eigrp_topology_cmd);
1512
1513 install_element(VIEW_NODE, &show_ip_eigrp_topology_detail_cmd);
1514 }
1515
1516 /* eigrpd's interface node. */
1517 static struct cmd_node eigrp_interface_node = {INTERFACE_NODE,
1518 "%s(config-if)# ", 1};
1519
1520 void eigrp_vty_if_init(void)
1521 {
1522 install_node(&eigrp_interface_node, eigrp_write_interface);
1523 if_cmd_init();
1524
1525 /* Delay and bandwidth configuration commands*/
1526 install_element(INTERFACE_NODE, &eigrp_if_delay_cmd);
1527 install_element(INTERFACE_NODE, &no_eigrp_if_delay_cmd);
1528 install_element(INTERFACE_NODE, &eigrp_if_bandwidth_cmd);
1529 install_element(INTERFACE_NODE, &no_eigrp_if_bandwidth_cmd);
1530
1531 /*Hello-interval and hold-time interval configuration commands*/
1532 install_element(INTERFACE_NODE, &eigrp_if_ip_holdinterval_cmd);
1533 install_element(INTERFACE_NODE, &no_eigrp_if_ip_holdinterval_cmd);
1534 install_element(INTERFACE_NODE, &eigrp_if_ip_hellointerval_cmd);
1535 install_element(INTERFACE_NODE, &no_eigrp_if_ip_hellointerval_cmd);
1536
1537 /* "Authentication configuration commands */
1538 install_element(INTERFACE_NODE, &eigrp_authentication_mode_cmd);
1539 install_element(INTERFACE_NODE, &no_eigrp_authentication_mode_cmd);
1540 install_element(INTERFACE_NODE, &eigrp_authentication_keychain_cmd);
1541 install_element(INTERFACE_NODE, &no_eigrp_authentication_keychain_cmd);
1542
1543 /*EIGRP Summarization commands*/
1544 install_element(INTERFACE_NODE, &eigrp_ip_summary_address_cmd);
1545 install_element(INTERFACE_NODE, &no_eigrp_ip_summary_address_cmd);
1546 }
1547
1548 static void eigrp_vty_zebra_init(void)
1549 {
1550 install_element(EIGRP_NODE, &eigrp_redistribute_source_metric_cmd);
1551 install_element(EIGRP_NODE, &no_eigrp_redistribute_source_metric_cmd);
1552 }
1553
1554 /* Install EIGRP related vty commands. */
1555 void eigrp_vty_init(void)
1556 {
1557 install_node(&eigrp_node, eigrp_config_write);
1558
1559 install_default(EIGRP_NODE);
1560
1561 install_element(CONFIG_NODE, &router_eigrp_cmd);
1562 install_element(CONFIG_NODE, &no_router_eigrp_cmd);
1563 install_element(EIGRP_NODE, &eigrp_network_cmd);
1564 install_element(EIGRP_NODE, &no_eigrp_network_cmd);
1565 install_element(EIGRP_NODE, &eigrp_variance_cmd);
1566 install_element(EIGRP_NODE, &no_eigrp_variance_cmd);
1567 install_element(EIGRP_NODE, &eigrp_router_id_cmd);
1568 install_element(EIGRP_NODE, &no_eigrp_router_id_cmd);
1569 install_element(EIGRP_NODE, &eigrp_passive_interface_cmd);
1570 install_element(EIGRP_NODE, &no_eigrp_passive_interface_cmd);
1571 install_element(EIGRP_NODE, &eigrp_timers_active_cmd);
1572 install_element(EIGRP_NODE, &no_eigrp_timers_active_cmd);
1573 install_element(EIGRP_NODE, &eigrp_metric_weights_cmd);
1574 install_element(EIGRP_NODE, &no_eigrp_metric_weights_cmd);
1575 install_element(EIGRP_NODE, &eigrp_maximum_paths_cmd);
1576 install_element(EIGRP_NODE, &no_eigrp_maximum_paths_cmd);
1577 install_element(EIGRP_NODE, &eigrp_neighbor_cmd);
1578 install_element(EIGRP_NODE, &no_eigrp_neighbor_cmd);
1579
1580 /* commands for manual hard restart */
1581 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_cmd);
1582 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_int_cmd);
1583 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_IP_cmd);
1584 /* commands for manual graceful restart */
1585 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_soft_cmd);
1586 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_int_soft_cmd);
1587 install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_IP_soft_cmd);
1588
1589 eigrp_vty_zebra_init();
1590 }