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