]> git.proxmox.com Git - mirror_frr.git/blob - eigrpd/eigrp_vty.c
*: use rb-trees to store interfaces instead of sorted linked-lists
[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,
113 ei->params.auth_keychain);
114 }
115
116 if (ei->params.v_hello != EIGRP_HELLO_INTERVAL_DEFAULT) {
117 vty_out(vty, " ip hello-interval eigrp %d\n",
118 ei->params.v_hello);
119 }
120
121 if (ei->params.v_wait != EIGRP_HOLD_INTERVAL_DEFAULT) {
122 vty_out(vty, " ip hold-time eigrp %d\n",
123 ei->params.v_wait);
124 }
125
126 /*Separate this EIGRP interface configuration from the others*/
127 vty_endframe(vty, "!\n");
128 }
129
130 return 0;
131 }
132
133 static int eigrp_write_interface(struct vty *vty)
134 {
135 struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
136 struct interface *ifp;
137 struct eigrp_interface *ei;
138
139 RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
140 ei = ifp->info;
141 if (!ei)
142 continue;
143
144 vty_frame(vty, "interface %s\n", ifp->name);
145
146 if (ifp->desc)
147 vty_out(vty, " description %s\n", ifp->desc);
148
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",
156 ei->params.v_hello);
157 if (ei->params.v_wait != EIGRP_HOLD_INTERVAL_DEFAULT)
158 vty_out(vty, " ip hold-time eigrp %u\n",
159 ei->params.v_wait);
160
161 vty_endframe(vty, "!\n");
162 }
163
164 return 0;
165 }
166
167 /**
168 * Writes distribute lists to config
169 */
170 static int config_write_eigrp_distribute(struct vty *vty, struct eigrp *eigrp)
171 {
172 int write = 0;
173
174 /* Distribute configuration. */
175 write += config_write_distribute(vty);
176
177 return write;
178 }
179
180 /**
181 * Writes 'router eigrp' section to config
182 */
183 static int config_write_eigrp_router(struct vty *vty, struct eigrp *eigrp)
184 {
185 int write = 0;
186
187 /* `router eigrp' print. */
188 vty_out(vty, "router eigrp %d\n", eigrp->AS);
189
190 write++;
191
192 if (!eigrp->networks)
193 return write;
194
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));
201 }
202
203 /* Network area print. */
204 config_write_network(vty, eigrp);
205
206 /* Distribute-list and default-information print. */
207 config_write_eigrp_distribute(vty, eigrp);
208
209 /*Separate EIGRP configuration from the rest of the config*/
210 vty_out(vty, "!\n");
211
212 return write;
213 }
214
215 DEFUN_NOSH (router_eigrp,
216 router_eigrp_cmd,
217 "router eigrp (1-65535)",
218 "Enable a routing process\n"
219 "Start EIGRP configuration\n"
220 "AS Number to use\n")
221 {
222 struct eigrp *eigrp = eigrp_get(argv[2]->arg);
223 VTY_PUSH_CONTEXT(EIGRP_NODE, eigrp);
224
225 return CMD_SUCCESS;
226 }
227
228 DEFUN (no_router_eigrp,
229 no_router_eigrp_cmd,
230 "no router eigrp (1-65535)",
231 NO_STR
232 "Routing process\n"
233 "EIGRP configuration\n"
234 "AS number to use\n")
235 {
236 vty->node = CONFIG_NODE;
237
238 struct eigrp *eigrp;
239
240 eigrp = eigrp_lookup();
241 if (eigrp == NULL) {
242 vty_out(vty, " EIGRP Routing Process not enabled\n");
243 return CMD_SUCCESS;
244 }
245
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;
249 }
250
251 eigrp_finish_final(eigrp);
252
253 return CMD_SUCCESS;
254 }
255
256 DEFUN (eigrp_router_id,
257 eigrp_router_id_cmd,
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")
262 {
263 // struct eigrp *eigrp = vty->index;
264 /*TODO: */
265
266 return CMD_SUCCESS;
267 }
268
269 DEFUN (no_eigrp_router_id,
270 no_eigrp_router_id_cmd,
271 "no eigrp router-id A.B.C.D",
272 NO_STR
273 "EIGRP specific commands\n"
274 "Router ID for this EIGRP process\n"
275 "EIGRP Router-ID in IP address format\n")
276 {
277 // struct eigrp *eigrp = vty->index;
278 /*TODO: */
279
280 return CMD_SUCCESS;
281 }
282
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")
288 {
289 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
290 struct eigrp_interface *ei;
291 struct listnode *node;
292 char *ifname = argv[1]->arg;
293
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;
297 return CMD_SUCCESS;
298 }
299 }
300 return CMD_SUCCESS;
301 }
302
303 DEFUN (no_eigrp_passive_interface,
304 no_eigrp_passive_interface_cmd,
305 "no passive-interface IFNAME",
306 NO_STR
307 "Suppress routing updates on an interface\n"
308 "Interface to suppress on\n")
309 {
310 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
311 struct eigrp_interface *ei;
312 struct listnode *node;
313 char *ifname = argv[2]->arg;
314
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;
318 return CMD_SUCCESS;
319 }
320 }
321
322 return CMD_SUCCESS;
323 }
324
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")
332 {
333 // struct eigrp *eigrp = vty->index;
334 /*TODO: */
335
336 return CMD_SUCCESS;
337 }
338
339 DEFUN (no_eigrp_timers_active,
340 no_eigrp_timers_active_cmd,
341 "no timers active-time <(1-65535)|disabled>",
342 NO_STR
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")
347 {
348 // struct eigrp *eigrp = vty->index;
349 /*TODO: */
350
351 return CMD_SUCCESS;
352 }
353
354
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"
360 "K1\n"
361 "K2\n"
362 "K3\n"
363 "K4\n"
364 "K5\n")
365 {
366 // struct eigrp *eigrp = vty->index;
367 /*TODO: */
368
369 return CMD_SUCCESS;
370 }
371
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>",
375 NO_STR
376 "Modify metrics and parameters for advertisement\n"
377 "Modify metric coefficients\n"
378 "K1\n"
379 "K2\n"
380 "K3\n"
381 "K4\n"
382 "K5\n")
383 {
384 // struct eigrp *eigrp = vty->index;
385 /*TODO: */
386
387 return CMD_SUCCESS;
388 }
389
390
391 DEFUN (eigrp_network,
392 eigrp_network_cmd,
393 "network A.B.C.D/M",
394 "Enable routing on an IP network\n"
395 "EIGRP network prefix\n")
396 {
397 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
398 struct prefix p;
399 int ret;
400
401 str2prefix(argv[1]->arg, &p);
402
403 ret = eigrp_network_set(eigrp, &p);
404
405 if (ret == 0) {
406 vty_out(vty, "There is already same network statement.\n");
407 return CMD_WARNING;
408 }
409
410 return CMD_SUCCESS;
411 }
412
413 DEFUN (no_eigrp_network,
414 no_eigrp_network_cmd,
415 "no network A.B.C.D/M",
416 NO_STR
417 "Disable routing on an IP network\n"
418 "EIGRP network prefix\n")
419 {
420 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
421 struct prefix p;
422 int ret;
423
424 str2prefix(argv[2]->arg, &p);
425
426 ret = eigrp_network_unset(eigrp, &p);
427
428 if (ret == 0) {
429 vty_out(vty, "Can't find specified network configuration.\n");
430 return CMD_WARNING_CONFIG_FAILED;
431 }
432
433 return CMD_SUCCESS;
434 }
435
436 DEFUN (eigrp_neighbor,
437 eigrp_neighbor_cmd,
438 "neighbor A.B.C.D",
439 "Specify a neighbor router\n"
440 "Neighbor address\n")
441 {
442 // struct eigrp *eigrp = vty->index;
443
444 return CMD_SUCCESS;
445 }
446
447 DEFUN (no_eigrp_neighbor,
448 no_eigrp_neighbor_cmd,
449 "no neighbor A.B.C.D",
450 NO_STR
451 "Specify a neighbor router\n"
452 "Neighbor address\n")
453 {
454 // struct eigrp *eigrp = vty->index;
455
456 return CMD_SUCCESS;
457 }
458
459 DEFUN (show_ip_eigrp_topology,
460 show_ip_eigrp_topology_cmd,
461 "show ip eigrp topology [all-links]",
462 SHOW_STR
463 IP_STR
464 "IP-EIGRP show commands\n"
465 "IP-EIGRP topology\n"
466 "Show all links in topology table\n")
467 {
468 struct eigrp *eigrp;
469 struct listnode *node, *node2;
470 struct eigrp_prefix_entry *tn;
471 struct eigrp_nexthop_entry *te;
472 int first;
473
474 eigrp = eigrp_lookup();
475 if (eigrp == NULL) {
476 vty_out(vty, " EIGRP Routing Process not enabled\n");
477 return CMD_SUCCESS;
478 }
479
480 show_ip_eigrp_topology_header(vty, eigrp);
481
482 for (ALL_LIST_ELEMENTS_RO(eigrp->topology_table, node, tn)) {
483 first = 1;
484 for (ALL_LIST_ELEMENTS_RO(tn->entries, node2, te)) {
485 if (argc == 5
486 || (((te->flags
487 & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)
488 == EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)
489 || ((te->flags
490 & EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG)
491 == EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG))) {
492 show_ip_eigrp_nexthop_entry(vty, eigrp, te,
493 &first);
494 first = 0;
495 }
496 }
497 }
498
499 return CMD_SUCCESS;
500 }
501
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>",
504 SHOW_STR IP_STR
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")
511
512 DEFUN (show_ip_eigrp_interfaces,
513 show_ip_eigrp_interfaces_cmd,
514 "show ip eigrp interfaces [IFNAME] [detail]",
515 SHOW_STR
516 IP_STR
517 "IP-EIGRP show commands\n"
518 "IP-EIGRP interfaces\n"
519 "Interface name to look at\n"
520 "Detailed information\n")
521 {
522 struct eigrp_interface *ei;
523 struct eigrp *eigrp;
524 struct listnode *node;
525 int idx = 0;
526 bool detail = false;
527 const char *ifname = NULL;
528
529 eigrp = eigrp_lookup();
530 if (eigrp == NULL) {
531 vty_out(vty, "EIGRP Routing Process not enabled\n");
532 return CMD_SUCCESS;
533 }
534
535 if (argv_find(argv, argc, "IFNAME", &idx))
536 ifname = argv[idx]->arg;
537
538 if (argv_find(argv, argc, "detail", &idx))
539 detail = true;
540
541 if (!ifname)
542 show_ip_eigrp_interface_header(vty, eigrp);
543
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);
547 if (detail)
548 show_ip_eigrp_interface_detail(vty, eigrp, ei);
549 }
550 }
551
552 return CMD_SUCCESS;
553 }
554
555 DEFUN (show_ip_eigrp_neighbors,
556 show_ip_eigrp_neighbors_cmd,
557 "show ip eigrp neighbors [IFNAME] [detail]",
558 SHOW_STR
559 IP_STR
560 "IP-EIGRP show commands\n"
561 "IP-EIGRP neighbors\n"
562 "Interface to show on\n"
563 "Detailed Information\n")
564 {
565 struct eigrp *eigrp;
566 struct eigrp_interface *ei;
567 struct listnode *node, *node2, *nnode2;
568 struct eigrp_neighbor *nbr;
569 bool detail = false;
570 int idx = 0;
571 const char *ifname = NULL;
572
573 eigrp = eigrp_lookup();
574 if (eigrp == NULL) {
575 vty_out(vty, " EIGRP Routing Process not enabled\n");
576 return CMD_SUCCESS;
577 }
578
579 if (argv_find(argv, argc, "IFNAME", &idx))
580 ifname = argv[idx]->arg;
581
582 detail = (argv_find(argv, argc, "detail", &idx));
583
584 show_ip_eigrp_neighbor_header(vty, eigrp);
585
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,
591 detail);
592 }
593 }
594 }
595
596 return CMD_SUCCESS;
597 }
598
599 DEFUN (eigrp_if_delay,
600 eigrp_if_delay_cmd,
601 "delay (1-16777215)",
602 "Specify interface throughput delay\n"
603 "Throughput delay (tens of microseconds)\n")
604 {
605 VTY_DECLVAR_CONTEXT(interface, ifp);
606 struct eigrp_interface *ei = ifp->info;
607 struct eigrp *eigrp;
608 u_int32_t delay;
609
610 eigrp = eigrp_lookup();
611 if (eigrp == NULL) {
612 vty_out(vty, " EIGRP Routing Process not enabled\n");
613
614 return CMD_SUCCESS;
615 }
616
617 if (!ei) {
618 vty_out(vty, " EIGRP not configured on this interface\n");
619 return CMD_SUCCESS;
620 }
621 delay = atoi(argv[1]->arg);
622
623 ei->params.delay = delay;
624 eigrp_if_reset(ifp);
625
626 return CMD_SUCCESS;
627 }
628
629 DEFUN (no_eigrp_if_delay,
630 no_eigrp_if_delay_cmd,
631 "no delay (1-16777215)",
632 NO_STR
633 "Specify interface throughput delay\n"
634 "Throughput delay (tens of microseconds)\n")
635 {
636 VTY_DECLVAR_CONTEXT(interface, ifp);
637 struct eigrp_interface *ei = ifp->info;
638 struct eigrp *eigrp;
639
640 eigrp = eigrp_lookup();
641 if (eigrp == NULL) {
642 vty_out(vty, " EIGRP Routing Process not enabled\n");
643
644 return CMD_SUCCESS;
645 }
646 if (!ei) {
647 vty_out(vty, " EIGRP not configured on this interface\n");
648 return CMD_SUCCESS;
649 }
650
651 ei->params.delay = EIGRP_DELAY_DEFAULT;
652 eigrp_if_reset(ifp);
653
654 return CMD_SUCCESS;
655 }
656
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")
663 {
664 VTY_DECLVAR_CONTEXT(interface, ifp);
665 struct eigrp_interface *ei = ifp->info;
666 u_int32_t bandwidth;
667 struct eigrp *eigrp;
668
669 eigrp = eigrp_lookup();
670 if (eigrp == NULL) {
671 vty_out(vty, " EIGRP Routing Process not enabled\n");
672 return CMD_SUCCESS;
673 }
674
675 if (!ei) {
676 vty_out(vty, " EIGRP not configured on this interface\n");
677 return CMD_SUCCESS;
678 }
679
680 bandwidth = atoi(argv[1]->arg);
681
682 ei->params.bandwidth = bandwidth;
683 eigrp_if_reset(ifp);
684
685 return CMD_SUCCESS;
686 }
687
688 DEFUN (no_eigrp_if_bandwidth,
689 no_eigrp_if_bandwidth_cmd,
690 "no eigrp bandwidth [(1-10000000)]",
691 NO_STR
692 "EIGRP specific commands\n"
693 "Set bandwidth informational parameter\n"
694 "Bandwidth in kilobits\n")
695 {
696 VTY_DECLVAR_CONTEXT(interface, ifp);
697 struct eigrp_interface *ei = ifp->info;
698 struct eigrp *eigrp;
699
700 eigrp = eigrp_lookup();
701 if (eigrp == NULL) {
702 vty_out(vty, " EIGRP Routing Process not enabled\n");
703 return CMD_SUCCESS;
704 }
705
706 if (!ei) {
707 vty_out(vty, " EIGRP not configured on this interface\n");
708 return CMD_SUCCESS;
709 }
710
711 ei->params.bandwidth = EIGRP_BANDWIDTH_DEFAULT;
712 eigrp_if_reset(ifp);
713
714 return CMD_SUCCESS;
715 }
716
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")
724 {
725 VTY_DECLVAR_CONTEXT(interface, ifp);
726 struct eigrp_interface *ei = ifp->info;
727 u_int32_t hello;
728 struct eigrp *eigrp;
729
730 eigrp = eigrp_lookup();
731 if (eigrp == NULL) {
732 vty_out(vty, " EIGRP Routing Process not enabled\n");
733 return CMD_SUCCESS;
734 }
735
736 if (!ei) {
737 vty_out(vty, " EIGRP not configured on this interface\n");
738 return CMD_SUCCESS;
739 }
740
741 hello = atoi(argv[3]->arg);
742
743 ei->params.v_hello = hello;
744
745 return CMD_SUCCESS;
746 }
747
748 DEFUN (no_eigrp_if_ip_hellointerval,
749 no_eigrp_if_ip_hellointerval_cmd,
750 "no ip hello-interval eigrp [(1-65535)]",
751 NO_STR
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")
756 {
757 VTY_DECLVAR_CONTEXT(interface, ifp);
758 struct eigrp_interface *ei = ifp->info;
759 struct eigrp *eigrp;
760
761 eigrp = eigrp_lookup();
762 if (eigrp == NULL) {
763 vty_out(vty, " EIGRP Routing Process not enabled\n");
764 return CMD_SUCCESS;
765 }
766
767 if (!ei) {
768 vty_out(vty, " EIGRP not configured on this interface\n");
769 return CMD_SUCCESS;
770 }
771
772 ei->params.v_hello = EIGRP_HELLO_INTERVAL_DEFAULT;
773
774 THREAD_TIMER_OFF(ei->t_hello);
775 thread_add_timer(master, eigrp_hello_timer, ei, 1,
776 &ei->t_hello);
777
778 return CMD_SUCCESS;
779 }
780
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")
788 {
789 VTY_DECLVAR_CONTEXT(interface, ifp);
790 struct eigrp_interface *ei = ifp->info;
791 u_int32_t hold;
792 struct eigrp *eigrp;
793
794 eigrp = eigrp_lookup();
795 if (eigrp == NULL) {
796 vty_out(vty, " EIGRP Routing Process not enabled\n");
797 return CMD_SUCCESS;
798 }
799
800 if (!ei) {
801 vty_out(vty, " EIGRP not configured on this interface\n");
802 return CMD_SUCCESS;
803 }
804
805 hold = atoi(argv[3]->arg);
806
807 ei->params.v_wait = hold;
808
809 return CMD_SUCCESS;
810 }
811
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"
818 "AS number\n"
819 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
820 {
821 // VTY_DECLVAR_CONTEXT(interface, ifp);
822 // u_int32_t AS;
823 struct eigrp *eigrp;
824
825 eigrp = eigrp_lookup();
826 if (eigrp == NULL) {
827 vty_out(vty, " EIGRP Routing Process not enabled\n");
828 return CMD_SUCCESS;
829 }
830
831 // AS = atoi (argv[3]->arg);
832
833 /*TODO: */
834
835 return CMD_SUCCESS;
836 }
837
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",
841 NO_STR
842 "Interface Internet Protocol config commands\n"
843 "Perform address summarization\n"
844 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
845 "AS number\n"
846 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
847 {
848 // VTY_DECLVAR_CONTEXT(interface, ifp);
849 // u_int32_t AS;
850 struct eigrp *eigrp;
851
852 eigrp = eigrp_lookup();
853 if (eigrp == NULL) {
854 vty_out(vty, " EIGRP Routing Process not enabled\n");
855 return CMD_SUCCESS;
856 }
857
858 // AS = atoi (argv[4]->arg);
859
860 /*TODO: */
861
862 return CMD_SUCCESS;
863 }
864
865 DEFUN (no_eigrp_if_ip_holdinterval,
866 no_eigrp_if_ip_holdinterval_cmd,
867 "no ip hold-time eigrp",
868 "No"
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")
873 {
874 VTY_DECLVAR_CONTEXT(interface, ifp);
875 struct eigrp_interface *ei = ifp->info;
876 struct eigrp *eigrp;
877
878 eigrp = eigrp_lookup();
879 if (eigrp == NULL) {
880 vty_out(vty, " EIGRP Routing Process not enabled\n");
881 return CMD_SUCCESS;
882 }
883
884 if (!ei) {
885 vty_out(vty, " EIGRP not configured on this interface\n");
886 return CMD_SUCCESS;
887 }
888
889 ei->params.v_wait = EIGRP_HOLD_INTERVAL_DEFAULT;
890
891 return CMD_SUCCESS;
892 }
893
894 static int str2auth_type(const char *str, struct eigrp_interface *ei)
895 {
896 /* Sanity check. */
897 if (str == NULL)
898 return CMD_WARNING_CONFIG_FAILED;
899
900 if (strncmp(str, "md5", 3) == 0) {
901 ei->params.auth_type = EIGRP_AUTH_TYPE_MD5;
902 return CMD_SUCCESS;
903 } else if (strncmp(str, "hmac-sha-256", 12) == 0) {
904 ei->params.auth_type = EIGRP_AUTH_TYPE_SHA256;
905 return CMD_SUCCESS;
906 }
907
908 return CMD_WARNING_CONFIG_FAILED;
909 }
910
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"
916 "Mode\n"
917 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
918 "Autonomous system number\n"
919 "Keyed message digest\n"
920 "HMAC SHA256 algorithm \n")
921 {
922 VTY_DECLVAR_CONTEXT(interface, ifp);
923 struct eigrp_interface *ei = ifp->info;
924 struct eigrp *eigrp;
925
926 eigrp = eigrp_lookup();
927 if (eigrp == NULL) {
928 vty_out(vty, " EIGRP Routing Process not enabled\n");
929 return CMD_SUCCESS;
930 }
931
932 if (!ei) {
933 vty_out(vty, " EIGRP not configured on this interface\n");
934 return CMD_SUCCESS;
935 }
936
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;
941
942 return str2auth_type(argv[5]->arg, ei);
943 }
944
945 DEFUN (no_eigrp_authentication_mode,
946 no_eigrp_authentication_mode_cmd,
947 "no ip authentication mode eigrp (1-65535) <md5|hmac-sha-256>",
948 "Disable\n"
949 "Interface Internet Protocol config commands\n"
950 "Authentication subcommands\n"
951 "Mode\n"
952 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
953 "Autonomous system number\n"
954 "Keyed message digest\n"
955 "HMAC SHA256 algorithm \n")
956 {
957 VTY_DECLVAR_CONTEXT(interface, ifp);
958 struct eigrp_interface *ei = ifp->info;
959 struct eigrp *eigrp;
960
961 eigrp = eigrp_lookup();
962 if (eigrp == NULL) {
963 vty_out(vty, " EIGRP Routing Process not enabled\n");
964 return CMD_SUCCESS;
965 }
966
967 if (!ei) {
968 vty_out(vty, " EIGRP not configured on this interface\n");
969 return CMD_SUCCESS;
970 }
971
972 ei->params.auth_type = EIGRP_AUTH_TYPE_NONE;
973
974 return CMD_SUCCESS;
975 }
976
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"
982 "Key-chain\n"
983 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
984 "Autonomous system number\n"
985 "Name of key-chain\n")
986 {
987 VTY_DECLVAR_CONTEXT(interface, ifp);
988 struct eigrp_interface *ei = ifp->info;
989 struct eigrp *eigrp;
990 struct keychain *keychain;
991
992 eigrp = eigrp_lookup();
993 if (eigrp == NULL) {
994 vty_out(vty, "EIGRP Routing Process not enabled\n");
995 return CMD_SUCCESS;
996 }
997
998 if (!ei) {
999 vty_out(vty, " EIGRP not configured on this interface\n");
1000 return CMD_SUCCESS;
1001 }
1002
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);
1009 } else
1010 ei->params.auth_keychain =
1011 strdup(keychain->name);
1012 } else
1013 vty_out(vty, "Key chain with specified name not found\n");
1014
1015 return CMD_SUCCESS;
1016 }
1017
1018 DEFUN (no_eigrp_authentication_keychain,
1019 no_eigrp_authentication_keychain_cmd,
1020 "no ip authentication key-chain eigrp (1-65535) WORD",
1021 "Disable\n"
1022 "Interface Internet Protocol config commands\n"
1023 "Authentication subcommands\n"
1024 "Key-chain\n"
1025 "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
1026 "Autonomous system number\n"
1027 "Name of key-chain\n")
1028 {
1029 VTY_DECLVAR_CONTEXT(interface, ifp);
1030 struct eigrp_interface *ei = ifp->info;
1031 struct eigrp *eigrp;
1032
1033 eigrp = eigrp_lookup();
1034 if (eigrp == NULL) {
1035 vty_out(vty, "EIGRP Routing Process not enabled\n");
1036 return CMD_SUCCESS;
1037 }
1038
1039 if (!ei) {
1040 vty_out(vty, " EIGRP not configured on this interface\n");
1041 return CMD_SUCCESS;
1042 }
1043
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;
1048 } else
1049 vty_out(vty,
1050 "Key chain with specified name not configured on interface\n");
1051
1052 return CMD_SUCCESS;
1053 }
1054
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)]",
1059 REDIST_STR
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")
1067 {
1068 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
1069 struct eigrp_metrics metrics_from_command = {0};
1070 int source;
1071 int idx = 0;
1072
1073 /* Get distribute source. */
1074 argv_find(argv, argc, "redistribute", &idx);
1075 source = proto_redistnum(AFI_IP, argv[idx + 1]->text);
1076 if (source < 0) {
1077 vty_out(vty, "%% Invalid route type\n");
1078 return CMD_WARNING_CONFIG_FAILED;
1079 }
1080
1081 /* Get metrics values */
1082
1083 return eigrp_redistribute_set(eigrp, source, metrics_from_command);
1084 }
1085
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)",
1090 "Disable\n"
1091 REDIST_STR
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")
1099 {
1100 VTY_DECLVAR_CONTEXT(eigrp, eigrp);
1101 int source;
1102 int idx = 0;
1103
1104 /* Get distribute source. */
1105 argv_find(argv, argc, "redistribute", &idx);
1106 source = proto_redistnum(AFI_IP, argv[idx + 1]->text);
1107 if (source < 0) {
1108 vty_out(vty, "%% Invalid route type\n");
1109 return CMD_WARNING_CONFIG_FAILED;
1110 }
1111
1112 /* Get metrics values */
1113
1114 return eigrp_redistribute_unset(eigrp, source);
1115 }
1116
1117 DEFUN (eigrp_variance,
1118 eigrp_variance_cmd,
1119 "variance (1-128)",
1120 "Control load balancing variance\n"
1121 "Metric variance multiplier\n")
1122 {
1123 struct eigrp *eigrp;
1124 u_char variance;
1125
1126 eigrp = eigrp_lookup();
1127 if (eigrp == NULL) {
1128 vty_out(vty, "EIGRP Routing Process not enabled\n");
1129 return CMD_SUCCESS;
1130 }
1131 variance = atoi(argv[1]->arg);
1132
1133 eigrp->variance = variance;
1134
1135 /*TODO: */
1136
1137 return CMD_SUCCESS;
1138 }
1139
1140 DEFUN (no_eigrp_variance,
1141 no_eigrp_variance_cmd,
1142 "no variance (1-128)",
1143 "Disable\n"
1144 "Control load balancing variance\n"
1145 "Metric variance multiplier\n")
1146 {
1147 struct eigrp *eigrp;
1148 eigrp = eigrp_lookup();
1149 if (eigrp == NULL) {
1150 vty_out(vty, "EIGRP Routing Process not enabled\n");
1151 return CMD_SUCCESS;
1152 }
1153
1154 eigrp->variance = EIGRP_VARIANCE_DEFAULT;
1155
1156 /*TODO: */
1157
1158 return CMD_SUCCESS;
1159 }
1160
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")
1166 {
1167 struct eigrp *eigrp;
1168 u_char max;
1169
1170 eigrp = eigrp_lookup();
1171 if (eigrp == NULL) {
1172 vty_out(vty, "EIGRP Routing Process not enabled\n");
1173 return CMD_SUCCESS;
1174 }
1175
1176 max = atoi(argv[1]->arg);
1177
1178 eigrp->max_paths = max;
1179
1180 /*TODO: */
1181
1182 return CMD_SUCCESS;
1183 }
1184
1185 DEFUN (no_eigrp_maximum_paths,
1186 no_eigrp_maximum_paths_cmd,
1187 "no maximum-paths <1-32>",
1188 NO_STR
1189 "Forward packets over multiple paths\n"
1190 "Number of paths\n")
1191 {
1192 struct eigrp *eigrp;
1193
1194 eigrp = eigrp_lookup();
1195 if (eigrp == NULL) {
1196 vty_out(vty, "EIGRP Routing Process not enabled\n");
1197 return CMD_SUCCESS;
1198 }
1199
1200 eigrp->max_paths = EIGRP_MAX_PATHS_DEFAULT;
1201
1202 /*TODO: */
1203
1204 return CMD_SUCCESS;
1205 }
1206
1207 /*
1208 * Execute hard restart for all neighbors
1209 */
1210 DEFUN (clear_ip_eigrp_neighbors,
1211 clear_ip_eigrp_neighbors_cmd,
1212 "clear ip eigrp neighbors",
1213 CLEAR_STR
1214 IP_STR
1215 "Clear IP-EIGRP\n"
1216 "Clear IP-EIGRP neighbors\n")
1217 {
1218 struct eigrp *eigrp;
1219 struct eigrp_interface *ei;
1220 struct listnode *node, *node2, *nnode2;
1221 struct eigrp_neighbor *nbr;
1222
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");
1227 return CMD_SUCCESS;
1228 }
1229
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);
1234
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) {
1238 zlog_debug(
1239 "Neighbor %s (%s) is down: manually cleared",
1240 inet_ntoa(nbr->src),
1241 ifindex2ifname(nbr->ei->ifp->ifindex,
1242 VRF_DEFAULT));
1243 vty_time_print(vty, 0);
1244 vty_out(vty,
1245 "Neighbor %s (%s) is down: manually cleared\n",
1246 inet_ntoa(nbr->src),
1247 ifindex2ifname(nbr->ei->ifp->ifindex,
1248 VRF_DEFAULT));
1249
1250 /* set neighbor to DOWN */
1251 nbr->state = EIGRP_NEIGHBOR_DOWN;
1252 /* delete neighbor */
1253 eigrp_nbr_delete(nbr);
1254 }
1255 }
1256 }
1257
1258 return CMD_SUCCESS;
1259 }
1260
1261 /*
1262 * Execute hard restart for all neighbors on interface
1263 */
1264 DEFUN (clear_ip_eigrp_neighbors_int,
1265 clear_ip_eigrp_neighbors_int_cmd,
1266 "clear ip eigrp neighbors IFNAME",
1267 CLEAR_STR
1268 IP_STR
1269 "Clear IP-EIGRP\n"
1270 "Clear IP-EIGRP neighbors\n"
1271 "Interface's name\n")
1272 {
1273 struct eigrp *eigrp;
1274 struct eigrp_interface *ei;
1275 struct listnode *node2, *nnode2;
1276 struct eigrp_neighbor *nbr;
1277 int idx = 0;
1278
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");
1283 return CMD_SUCCESS;
1284 }
1285
1286 /* lookup interface by specified name */
1287 argv_find(argv, argc, "IFNAME", &idx);
1288 ei = eigrp_if_lookup_by_name(eigrp, argv[idx]->arg);
1289 if (ei == NULL) {
1290 vty_out(vty, " Interface (%s) doesn't exist\n", argv[idx]->arg);
1291 return CMD_WARNING;
1292 }
1293
1294 /* send Goodbye Hello */
1295 eigrp_hello_send(ei, EIGRP_HELLO_GRACEFUL_SHUTDOWN, NULL);
1296
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,
1303 VRF_DEFAULT));
1304 vty_time_print(vty, 0);
1305 vty_out(vty,
1306 "Neighbor %s (%s) is down: manually cleared\n",
1307 inet_ntoa(nbr->src),
1308 ifindex2ifname(nbr->ei->ifp->ifindex,
1309 VRF_DEFAULT));
1310
1311 /* set neighbor to DOWN */
1312 nbr->state = EIGRP_NEIGHBOR_DOWN;
1313 /* delete neighbor */
1314 eigrp_nbr_delete(nbr);
1315 }
1316 }
1317
1318 return CMD_SUCCESS;
1319 }
1320
1321 /*
1322 * Execute hard restart for neighbor specified by IP
1323 */
1324 DEFUN (clear_ip_eigrp_neighbors_IP,
1325 clear_ip_eigrp_neighbors_IP_cmd,
1326 "clear ip eigrp neighbors A.B.C.D",
1327 CLEAR_STR
1328 IP_STR
1329 "Clear IP-EIGRP\n"
1330 "Clear IP-EIGRP neighbors\n"
1331 "IP-EIGRP neighbor address\n")
1332 {
1333 struct eigrp *eigrp;
1334 struct eigrp_neighbor *nbr;
1335 struct in_addr nbr_addr;
1336
1337 if (!inet_aton(argv[4]->arg, &nbr_addr)) {
1338 vty_out(vty, "Unable to parse %s",
1339 argv[4]->arg);
1340 return CMD_WARNING;
1341 }
1342
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");
1347 return CMD_SUCCESS;
1348 }
1349
1350 /* lookup neighbor in whole process */
1351 nbr = eigrp_nbr_lookup_by_addr_process(eigrp, nbr_addr);
1352
1353 /* if neighbor doesn't exists, notify user and exit */
1354 if (nbr == NULL) {
1355 vty_out(vty, "Neighbor with entered address doesn't exists.\n");
1356 return CMD_WARNING;
1357 }
1358
1359 /* execute hard reset on neighbor */
1360 eigrp_nbr_hard_restart(nbr, vty);
1361
1362 return CMD_SUCCESS;
1363 }
1364
1365 /*
1366 * Execute graceful restart for all neighbors
1367 */
1368 DEFUN (clear_ip_eigrp_neighbors_soft,
1369 clear_ip_eigrp_neighbors_soft_cmd,
1370 "clear ip eigrp neighbors soft",
1371 CLEAR_STR
1372 IP_STR
1373 "Clear IP-EIGRP\n"
1374 "Clear IP-EIGRP neighbors\n"
1375 "Resync with peers without adjacency reset\n")
1376 {
1377 struct eigrp *eigrp;
1378
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");
1383 return CMD_SUCCESS;
1384 }
1385
1386 /* execute graceful restart on all neighbors */
1387 eigrp_update_send_process_GR(eigrp, EIGRP_GR_MANUAL, vty);
1388
1389 return CMD_SUCCESS;
1390 }
1391
1392 /*
1393 * Execute graceful restart for all neighbors on interface
1394 */
1395 DEFUN (clear_ip_eigrp_neighbors_int_soft,
1396 clear_ip_eigrp_neighbors_int_soft_cmd,
1397 "clear ip eigrp neighbors IFNAME soft",
1398 CLEAR_STR
1399 IP_STR
1400 "Clear IP-EIGRP\n"
1401 "Clear IP-EIGRP neighbors\n"
1402 "Interface's name\n"
1403 "Resync with peer without adjacency reset\n")
1404 {
1405 struct eigrp *eigrp;
1406 struct eigrp_interface *ei;
1407
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");
1412 return CMD_SUCCESS;
1413 }
1414
1415 /* lookup interface by specified name */
1416 ei = eigrp_if_lookup_by_name(eigrp, argv[4]->arg);
1417 if (ei == NULL) {
1418 vty_out(vty, " Interface (%s) doesn't exist\n", argv[4]->arg);
1419 return CMD_WARNING;
1420 }
1421
1422 /* execute graceful restart for all neighbors on interface */
1423 eigrp_update_send_interface_GR(ei, EIGRP_GR_MANUAL, vty);
1424 return CMD_SUCCESS;
1425 }
1426
1427 /*
1428 * Execute graceful restart for neighbor specified by IP
1429 */
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",
1433 CLEAR_STR
1434 IP_STR
1435 "Clear IP-EIGRP\n"
1436 "Clear IP-EIGRP neighbors\n"
1437 "IP-EIGRP neighbor address\n"
1438 "Resync with peer without adjacency reset\n")
1439 {
1440 struct eigrp *eigrp;
1441 struct eigrp_neighbor *nbr;
1442 struct in_addr nbr_addr;
1443
1444 if (!inet_aton(argv[4]->arg, &nbr_addr)) {
1445 vty_out(vty, "Unable to parse: %s",
1446 argv[4]->arg);
1447 return CMD_WARNING;
1448 }
1449
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");
1454 return CMD_SUCCESS;
1455 }
1456
1457 /* lookup neighbor in whole process */
1458 nbr = eigrp_nbr_lookup_by_addr_process(eigrp, nbr_addr);
1459
1460 /* if neighbor doesn't exists, notify user and exit */
1461 if (nbr == NULL) {
1462 vty_out(vty, "Neighbor with entered address doesn't exists.\n");
1463 return CMD_WARNING;
1464 }
1465
1466 /* execute graceful restart on neighbor */
1467 eigrp_update_send_GR(nbr, EIGRP_GR_MANUAL, vty);
1468
1469 return CMD_SUCCESS;
1470 }
1471
1472 static struct cmd_node eigrp_node = {EIGRP_NODE, "%s(config-router)# ", 1};
1473
1474 /* Save EIGRP configuration */
1475 static int eigrp_config_write(struct vty *vty)
1476 {
1477 struct eigrp *eigrp;
1478
1479 int write = 0;
1480
1481 eigrp = eigrp_lookup();
1482 if (eigrp != NULL) {
1483 /* Writes 'router eigrp' section to config */
1484 config_write_eigrp_router(vty, eigrp);
1485
1486 /* Interface config print */
1487 config_write_interfaces(vty, eigrp);
1488 //
1489 // /* static neighbor print. */
1490 // config_write_eigrp_nbr_nbma (vty, eigrp);
1491 //
1492 // /* Virtual-Link print. */
1493 // config_write_virtual_link (vty, eigrp);
1494 //
1495 // /* Default metric configuration. */
1496 // config_write_eigrp_default_metric (vty, eigrp);
1497 //
1498 // /* Distribute-list and default-information print. */
1499 // config_write_eigrp_distribute (vty, eigrp);
1500 //
1501 // /* Distance configuration. */
1502 // config_write_eigrp_distance (vty, eigrp)
1503 }
1504
1505 return write;
1506 }
1507
1508 void eigrp_vty_show_init(void)
1509 {
1510 install_element(VIEW_NODE, &show_ip_eigrp_interfaces_cmd);
1511
1512 install_element(VIEW_NODE, &show_ip_eigrp_neighbors_cmd);
1513
1514 install_element(VIEW_NODE, &show_ip_eigrp_topology_cmd);
1515
1516 install_element(VIEW_NODE, &show_ip_eigrp_topology_detail_cmd);
1517 }
1518
1519 /* eigrpd's interface node. */
1520 static struct cmd_node eigrp_interface_node = {INTERFACE_NODE,
1521 "%s(config-if)# ", 1};
1522
1523 void eigrp_vty_if_init(void)
1524 {
1525 install_node(&eigrp_interface_node, eigrp_write_interface);
1526 if_cmd_init();
1527
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);
1533
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);
1539
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);
1545
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);
1549 }
1550
1551 static void eigrp_vty_zebra_init(void)
1552 {
1553 install_element(EIGRP_NODE, &eigrp_redistribute_source_metric_cmd);
1554 install_element(EIGRP_NODE, &no_eigrp_redistribute_source_metric_cmd);
1555 }
1556
1557 /* Install EIGRP related vty commands. */
1558 void eigrp_vty_init(void)
1559 {
1560 install_node(&eigrp_node, eigrp_config_write);
1561
1562 install_default(EIGRP_NODE);
1563
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);
1582
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);
1591
1592 eigrp_vty_zebra_init();
1593 }