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