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