]> git.proxmox.com Git - mirror_frr.git/blob - eigrpd/eigrp_cli.c
Merge pull request #9761 from mjstapp/fix_topo_debug_cli
[mirror_frr.git] / eigrpd / eigrp_cli.c
1 /*
2 * EIGRP daemon CLI implementation.
3 *
4 * Copyright (C) 2019 Network Device Education Foundation, Inc. ("NetDEF")
5 * Rafael Zalamena
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301 USA.
21 */
22
23 #include <zebra.h>
24
25 #include "lib/command.h"
26 #include "lib/log.h"
27 #include "lib/northbound_cli.h"
28
29 #include "eigrp_structs.h"
30 #include "eigrpd.h"
31 #include "eigrp_zebra.h"
32 #include "eigrp_cli.h"
33
34 #ifndef VTYSH_EXTRACT_PL
35 #include "eigrpd/eigrp_cli_clippy.c"
36 #endif /* VTYSH_EXTRACT_PL */
37
38 /*
39 * XPath: /frr-eigrpd:eigrpd/instance
40 */
41 DEFPY_YANG_NOSH(
42 router_eigrp,
43 router_eigrp_cmd,
44 "router eigrp (1-65535)$as [vrf NAME]",
45 ROUTER_STR
46 EIGRP_STR
47 AS_STR
48 VRF_CMD_HELP_STR)
49 {
50 char xpath[XPATH_MAXLEN];
51 int rv;
52
53 snprintf(xpath, sizeof(xpath),
54 "/frr-eigrpd:eigrpd/instance[asn='%s'][vrf='%s']",
55 as_str, vrf ? vrf : VRF_DEFAULT_NAME);
56
57 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
58 rv = nb_cli_apply_changes(vty, NULL);
59 if (rv == CMD_SUCCESS)
60 VTY_PUSH_XPATH(EIGRP_NODE, xpath);
61
62 return rv;
63 }
64
65 DEFPY_YANG(
66 no_router_eigrp,
67 no_router_eigrp_cmd,
68 "no router eigrp (1-65535)$as [vrf NAME]",
69 NO_STR
70 ROUTER_STR
71 EIGRP_STR
72 AS_STR
73 VRF_CMD_HELP_STR)
74 {
75 char xpath[XPATH_MAXLEN];
76
77 snprintf(xpath, sizeof(xpath),
78 "/frr-eigrpd:eigrpd/instance[asn='%s'][vrf='%s']",
79 as_str, vrf ? vrf : VRF_DEFAULT_NAME);
80
81 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
82 return nb_cli_apply_changes_clear_pending(vty, NULL);
83 }
84
85 void eigrp_cli_show_header(struct vty *vty, struct lyd_node *dnode,
86 bool show_defaults)
87 {
88 const char *asn = yang_dnode_get_string(dnode, "./asn");
89 const char *vrf = yang_dnode_get_string(dnode, "./vrf");
90
91 vty_out(vty, "router eigrp %s", asn);
92 if (strcmp(vrf, VRF_DEFAULT_NAME))
93 vty_out(vty, " vrf %s", vrf);
94 vty_out(vty, "\n");
95 }
96
97 void eigrp_cli_show_end_header(struct vty *vty, struct lyd_node *dnode)
98 {
99 vty_out(vty, "exit\n");
100 vty_out(vty, "!\n");
101 }
102
103 /*
104 * XPath: /frr-eigrpd:eigrpd/instance/router-id
105 */
106 DEFPY_YANG(
107 eigrp_router_id,
108 eigrp_router_id_cmd,
109 "eigrp router-id A.B.C.D$addr",
110 EIGRP_STR
111 "Router ID for this EIGRP process\n"
112 "EIGRP Router-ID in IP address format\n")
113 {
114 nb_cli_enqueue_change(vty, "./router-id", NB_OP_MODIFY, addr_str);
115 return nb_cli_apply_changes(vty, NULL);
116 }
117
118 DEFPY_YANG(
119 no_eigrp_router_id,
120 no_eigrp_router_id_cmd,
121 "no eigrp router-id [A.B.C.D]",
122 NO_STR
123 EIGRP_STR
124 "Router ID for this EIGRP process\n"
125 "EIGRP Router-ID in IP address format\n")
126 {
127 nb_cli_enqueue_change(vty, "./router-id", NB_OP_DESTROY, NULL);
128 return nb_cli_apply_changes(vty, NULL);
129 }
130
131 void eigrp_cli_show_router_id(struct vty *vty, struct lyd_node *dnode,
132 bool show_defaults)
133 {
134 const char *router_id = yang_dnode_get_string(dnode, NULL);
135
136 vty_out(vty, " eigrp router-id %s\n", router_id);
137 }
138
139 /*
140 * XPath: /frr-eigrpd:eigrpd/instance/passive-interface
141 */
142 DEFPY_YANG(
143 eigrp_passive_interface,
144 eigrp_passive_interface_cmd,
145 "[no] passive-interface IFNAME",
146 NO_STR
147 "Suppress routing updates on an interface\n"
148 "Interface to suppress on\n")
149 {
150 if (no)
151 nb_cli_enqueue_change(vty, "./passive-interface",
152 NB_OP_DESTROY, ifname);
153 else
154 nb_cli_enqueue_change(vty, "./passive-interface",
155 NB_OP_CREATE, ifname);
156
157 return nb_cli_apply_changes(vty, NULL);
158 }
159
160 void eigrp_cli_show_passive_interface(struct vty *vty, struct lyd_node *dnode,
161 bool show_defaults)
162 {
163 const char *ifname = yang_dnode_get_string(dnode, NULL);
164
165 vty_out(vty, " passive-interface %s\n", ifname);
166 }
167
168 /*
169 * XPath: /frr-eigrpd:eigrpd/instance/active-time
170 */
171 DEFPY_YANG(
172 eigrp_timers_active,
173 eigrp_timers_active_cmd,
174 "timers active-time <(1-65535)$timer|disabled$disabled>",
175 "Adjust routing timers\n"
176 "Time limit for active state\n"
177 "Active state time limit in seconds\n"
178 "Disable time limit for active state\n")
179 {
180 if (disabled)
181 nb_cli_enqueue_change(vty, "./active-time", NB_OP_MODIFY, "0");
182 else
183 nb_cli_enqueue_change(vty, "./active-time",
184 NB_OP_MODIFY, timer_str);
185
186 return nb_cli_apply_changes(vty, NULL);
187 }
188
189 DEFPY_YANG(
190 no_eigrp_timers_active,
191 no_eigrp_timers_active_cmd,
192 "no timers active-time [<(1-65535)|disabled>]",
193 NO_STR
194 "Adjust routing timers\n"
195 "Time limit for active state\n"
196 "Active state time limit in seconds\n"
197 "Disable time limit for active state\n")
198 {
199 nb_cli_enqueue_change(vty, "./active-time", NB_OP_DESTROY, NULL);
200 return nb_cli_apply_changes(vty, NULL);
201 }
202
203 void eigrp_cli_show_active_time(struct vty *vty, struct lyd_node *dnode,
204 bool show_defaults)
205 {
206 const char *timer = yang_dnode_get_string(dnode, NULL);
207
208 vty_out(vty, " timers active-time %s\n", timer);
209 }
210
211 /*
212 * XPath: /frr-eigrpd:eigrpd/instance/variance
213 */
214 DEFPY_YANG(
215 eigrp_variance,
216 eigrp_variance_cmd,
217 "variance (1-128)$variance",
218 "Control load balancing variance\n"
219 "Metric variance multiplier\n")
220 {
221 nb_cli_enqueue_change(vty, "./variance", NB_OP_MODIFY, variance_str);
222 return nb_cli_apply_changes(vty, NULL);
223 }
224
225 DEFPY_YANG(
226 no_eigrp_variance,
227 no_eigrp_variance_cmd,
228 "no variance [(1-128)]",
229 NO_STR
230 "Control load balancing variance\n"
231 "Metric variance multiplier\n")
232 {
233 nb_cli_enqueue_change(vty, "./variance", NB_OP_DESTROY, NULL);
234 return nb_cli_apply_changes(vty, NULL);
235 }
236
237 void eigrp_cli_show_variance(struct vty *vty, struct lyd_node *dnode,
238 bool show_defaults)
239 {
240 const char *variance = yang_dnode_get_string(dnode, NULL);
241
242 vty_out(vty, " variance %s\n", variance);
243 }
244
245 /*
246 * XPath: /frr-eigrpd:eigrpd/instance/maximum-paths
247 */
248 DEFPY_YANG(
249 eigrp_maximum_paths,
250 eigrp_maximum_paths_cmd,
251 "maximum-paths (1-32)$maximum_paths",
252 "Forward packets over multiple paths\n"
253 "Number of paths\n")
254 {
255 nb_cli_enqueue_change(vty, "./maximum-paths", NB_OP_MODIFY,
256 maximum_paths_str);
257 return nb_cli_apply_changes(vty, NULL);
258 }
259
260 DEFPY_YANG(
261 no_eigrp_maximum_paths,
262 no_eigrp_maximum_paths_cmd,
263 "no maximum-paths [(1-32)]",
264 NO_STR
265 "Forward packets over multiple paths\n"
266 "Number of paths\n")
267 {
268 nb_cli_enqueue_change(vty, "./maximum-paths", NB_OP_DESTROY, NULL);
269 return nb_cli_apply_changes(vty, NULL);
270 }
271
272 void eigrp_cli_show_maximum_paths(struct vty *vty, struct lyd_node *dnode,
273 bool show_defaults)
274 {
275 const char *maximum_paths = yang_dnode_get_string(dnode, NULL);
276
277 vty_out(vty, " maximum-paths %s\n", maximum_paths);
278 }
279
280 /*
281 * XPath: /frr-eigrpd:eigrpd/instance/metric-weights/K1
282 * XPath: /frr-eigrpd:eigrpd/instance/metric-weights/K2
283 * XPath: /frr-eigrpd:eigrpd/instance/metric-weights/K3
284 * XPath: /frr-eigrpd:eigrpd/instance/metric-weights/K4
285 * XPath: /frr-eigrpd:eigrpd/instance/metric-weights/K5
286 * XPath: /frr-eigrpd:eigrpd/instance/metric-weights/K6
287 */
288 DEFPY_YANG(
289 eigrp_metric_weights,
290 eigrp_metric_weights_cmd,
291 "metric weights (0-255)$k1 (0-255)$k2 (0-255)$k3 (0-255)$k4 (0-255)$k5 [(0-255)$k6]",
292 "Modify metrics and parameters for advertisement\n"
293 "Modify metric coefficients\n"
294 "K1\n"
295 "K2\n"
296 "K3\n"
297 "K4\n"
298 "K5\n"
299 "K6\n")
300 {
301 nb_cli_enqueue_change(vty, "./metric-weights/K1", NB_OP_MODIFY, k1_str);
302 nb_cli_enqueue_change(vty, "./metric-weights/K2", NB_OP_MODIFY, k2_str);
303 nb_cli_enqueue_change(vty, "./metric-weights/K3", NB_OP_MODIFY, k3_str);
304 nb_cli_enqueue_change(vty, "./metric-weights/K4", NB_OP_MODIFY, k4_str);
305 nb_cli_enqueue_change(vty, "./metric-weights/K5", NB_OP_MODIFY, k5_str);
306 if (k6)
307 nb_cli_enqueue_change(vty, "./metric-weights/K6",
308 NB_OP_MODIFY, k6_str);
309
310 return nb_cli_apply_changes(vty, NULL);
311 }
312
313 DEFPY_YANG(
314 no_eigrp_metric_weights,
315 no_eigrp_metric_weights_cmd,
316 "no metric weights [(0-255) (0-255) (0-255) (0-255) (0-255) (0-255)]",
317 NO_STR
318 "Modify metrics and parameters for advertisement\n"
319 "Modify metric coefficients\n"
320 "K1\n"
321 "K2\n"
322 "K3\n"
323 "K4\n"
324 "K5\n"
325 "K6\n")
326 {
327 nb_cli_enqueue_change(vty, "./metric-weights/K1", NB_OP_DESTROY, NULL);
328 nb_cli_enqueue_change(vty, "./metric-weights/K2", NB_OP_DESTROY, NULL);
329 nb_cli_enqueue_change(vty, "./metric-weights/K3", NB_OP_DESTROY, NULL);
330 nb_cli_enqueue_change(vty, "./metric-weights/K4", NB_OP_DESTROY, NULL);
331 nb_cli_enqueue_change(vty, "./metric-weights/K5", NB_OP_DESTROY, NULL);
332 nb_cli_enqueue_change(vty, "./metric-weights/K6", NB_OP_DESTROY, NULL);
333 return nb_cli_apply_changes(vty, NULL);
334 }
335
336 void eigrp_cli_show_metrics(struct vty *vty, struct lyd_node *dnode,
337 bool show_defaults)
338 {
339 const char *k1, *k2, *k3, *k4, *k5, *k6;
340
341 k1 = yang_dnode_exists(dnode, "./K1") ?
342 yang_dnode_get_string(dnode, "./K1") : "0";
343 k2 = yang_dnode_exists(dnode, "./K2") ?
344 yang_dnode_get_string(dnode, "./K2") : "0";
345 k3 = yang_dnode_exists(dnode, "./K3") ?
346 yang_dnode_get_string(dnode, "./K3") : "0";
347 k4 = yang_dnode_exists(dnode, "./K4") ?
348 yang_dnode_get_string(dnode, "./K4") : "0";
349 k5 = yang_dnode_exists(dnode, "./K5") ?
350 yang_dnode_get_string(dnode, "./K5") : "0";
351 k6 = yang_dnode_exists(dnode, "./K6") ?
352 yang_dnode_get_string(dnode, "./K6") : "0";
353
354 vty_out(vty, " metric weights %s %s %s %s %s",
355 k1, k2, k3, k4, k5);
356 if (k6)
357 vty_out(vty, " %s", k6);
358 vty_out(vty, "\n");
359 }
360
361 /*
362 * XPath: /frr-eigrpd:eigrpd/instance/network
363 */
364 DEFPY_YANG(
365 eigrp_network,
366 eigrp_network_cmd,
367 "[no] network A.B.C.D/M$prefix",
368 NO_STR
369 "Enable routing on an IP network\n"
370 "EIGRP network prefix\n")
371 {
372 if (no)
373 nb_cli_enqueue_change(vty, "./network", NB_OP_DESTROY,
374 prefix_str);
375 else
376 nb_cli_enqueue_change(vty, "./network", NB_OP_CREATE,
377 prefix_str);
378
379 return nb_cli_apply_changes(vty, NULL);
380 }
381
382 void eigrp_cli_show_network(struct vty *vty, struct lyd_node *dnode,
383 bool show_defaults)
384 {
385 const char *prefix = yang_dnode_get_string(dnode, NULL);
386
387 vty_out(vty, " network %s\n", prefix);
388 }
389
390 /*
391 * XPath: /frr-eigrpd:eigrpd/instance/neighbor
392 */
393 DEFPY_YANG(
394 eigrp_neighbor,
395 eigrp_neighbor_cmd,
396 "[no] neighbor A.B.C.D$addr",
397 NO_STR
398 "Specify a neighbor router\n"
399 "Neighbor address\n")
400 {
401 if (no)
402 nb_cli_enqueue_change(vty, "./neighbor", NB_OP_DESTROY,
403 addr_str);
404 else
405 nb_cli_enqueue_change(vty, "./neighbor", NB_OP_CREATE,
406 addr_str);
407
408 return nb_cli_apply_changes(vty, NULL);
409 }
410
411 void eigrp_cli_show_neighbor(struct vty *vty, struct lyd_node *dnode,
412 bool show_defaults)
413 {
414 const char *prefix = yang_dnode_get_string(dnode, NULL);
415
416 vty_out(vty, " neighbor %s\n", prefix);
417 }
418
419 /*
420 * XPath: /frr-eigrpd:eigrpd/instance/redistribute
421 * XPath: /frr-eigrpd:eigrpd/instance/redistribute/route-map
422 * XPath: /frr-eigrpd:eigrpd/instance/redistribute/metrics/bandwidth
423 * XPath: /frr-eigrpd:eigrpd/instance/redistribute/metrics/delay
424 * XPath: /frr-eigrpd:eigrpd/instance/redistribute/metrics/reliability
425 * XPath: /frr-eigrpd:eigrpd/instance/redistribute/metrics/load
426 * XPath: /frr-eigrpd:eigrpd/instance/redistribute/metrics/mtu
427 */
428 DEFPY_YANG(
429 eigrp_redistribute_source_metric,
430 eigrp_redistribute_source_metric_cmd,
431 "[no] redistribute " FRR_REDIST_STR_EIGRPD
432 "$proto [metric (1-4294967295)$bw (0-4294967295)$delay (0-255)$rlbt (1-255)$load (1-65535)$mtu]",
433 NO_STR
434 REDIST_STR
435 FRR_REDIST_HELP_STR_EIGRPD
436 "Metric for redistributed routes\n"
437 "Bandwidth metric in Kbits per second\n"
438 "EIGRP delay metric, in 10 microsecond units\n"
439 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
440 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
441 "EIGRP MTU of the path\n")
442 {
443 char xpath[XPATH_MAXLEN], xpath_metric[XPATH_MAXLEN + 64];
444
445 snprintf(xpath, sizeof(xpath), "./redistribute[protocol='%s']", proto);
446
447 if (no) {
448 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
449 return nb_cli_apply_changes(vty, NULL);
450 }
451
452 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
453 if (bw == 0 || delay == 0 || rlbt == 0 || load == 0 || mtu == 0)
454 return nb_cli_apply_changes(vty, NULL);
455
456 snprintf(xpath_metric, sizeof(xpath_metric), "%s/metrics/bandwidth",
457 xpath);
458 nb_cli_enqueue_change(vty, xpath_metric, NB_OP_MODIFY, bw_str);
459 snprintf(xpath_metric, sizeof(xpath_metric), "%s/metrics/delay", xpath);
460 nb_cli_enqueue_change(vty, xpath_metric, NB_OP_MODIFY, delay_str);
461 snprintf(xpath_metric, sizeof(xpath_metric), "%s/metrics/reliability",
462 xpath);
463 nb_cli_enqueue_change(vty, xpath_metric, NB_OP_MODIFY, rlbt_str);
464 snprintf(xpath_metric, sizeof(xpath_metric), "%s/metrics/load", xpath);
465 nb_cli_enqueue_change(vty, xpath_metric, NB_OP_MODIFY, load_str);
466 snprintf(xpath_metric, sizeof(xpath_metric), "%s/metrics/mtu", xpath);
467 nb_cli_enqueue_change(vty, xpath_metric, NB_OP_MODIFY, mtu_str);
468 return nb_cli_apply_changes(vty, NULL);
469 }
470
471 void eigrp_cli_show_redistribute(struct vty *vty, struct lyd_node *dnode,
472 bool show_defaults)
473 {
474 const char *proto = yang_dnode_get_string(dnode, "./protocol");
475 const char *bw, *delay, *load, *mtu, *rlbt;
476
477 bw = yang_dnode_exists(dnode, "./metrics/bandwidth") ?
478 yang_dnode_get_string(dnode, "./metrics/bandwidth") : NULL;
479 delay = yang_dnode_exists(dnode, "./metrics/delay") ?
480 yang_dnode_get_string(dnode, "./metrics/delay") : NULL;
481 rlbt = yang_dnode_exists(dnode, "./metrics/reliability") ?
482 yang_dnode_get_string(dnode, "./metrics/reliability") : NULL;
483 load = yang_dnode_exists(dnode, "./metrics/load") ?
484 yang_dnode_get_string(dnode, "./metrics/load") : NULL;
485 mtu = yang_dnode_exists(dnode, "./metrics/mtu") ?
486 yang_dnode_get_string(dnode, "./metrics/mtu") : NULL;
487
488 vty_out(vty, " redistribute %s", proto);
489 if (bw || rlbt || delay || load || mtu)
490 vty_out(vty, " metric %s %s %s %s %s", bw, delay, rlbt, load,
491 mtu);
492 vty_out(vty, "\n");
493 }
494
495 /*
496 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/delay
497 */
498 DEFPY_YANG(
499 eigrp_if_delay,
500 eigrp_if_delay_cmd,
501 "delay (1-16777215)$delay",
502 "Specify interface throughput delay\n"
503 "Throughput delay (tens of microseconds)\n")
504 {
505 nb_cli_enqueue_change(vty, "./frr-eigrpd:eigrp/delay",
506 NB_OP_MODIFY, delay_str);
507 return nb_cli_apply_changes(vty, NULL);
508 }
509
510 DEFPY_YANG(
511 no_eigrp_if_delay,
512 no_eigrp_if_delay_cmd,
513 "no delay [(1-16777215)]",
514 NO_STR
515 "Specify interface throughput delay\n"
516 "Throughput delay (tens of microseconds)\n")
517 {
518 nb_cli_enqueue_change(vty, "./frr-eigrpd:eigrp/delay",
519 NB_OP_DESTROY, NULL);
520 return nb_cli_apply_changes(vty, NULL);
521 }
522
523 void eigrp_cli_show_delay(struct vty *vty, struct lyd_node *dnode,
524 bool show_defaults)
525 {
526 const char *delay = yang_dnode_get_string(dnode, NULL);
527
528 vty_out(vty, " delay %s\n", delay);
529 }
530
531 /*
532 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/bandwidth
533 */
534 DEFPY_YANG(
535 eigrp_if_bandwidth,
536 eigrp_if_bandwidth_cmd,
537 "eigrp bandwidth (1-10000000)$bw",
538 EIGRP_STR
539 "Set bandwidth informational parameter\n"
540 "Bandwidth in kilobits\n")
541 {
542 nb_cli_enqueue_change(vty, "./frr-eigrpd:eigrp/bandwidth",
543 NB_OP_MODIFY, bw_str);
544 return nb_cli_apply_changes(vty, NULL);
545 }
546
547 DEFPY_YANG(
548 no_eigrp_if_bandwidth,
549 no_eigrp_if_bandwidth_cmd,
550 "no eigrp bandwidth [(1-10000000)]",
551 NO_STR
552 EIGRP_STR
553 "Set bandwidth informational parameter\n"
554 "Bandwidth in kilobits\n")
555 {
556 nb_cli_enqueue_change(vty, "./frr-eigrpd:eigrp/bandwidth",
557 NB_OP_DESTROY, NULL);
558 return nb_cli_apply_changes(vty, NULL);
559 }
560
561 void eigrp_cli_show_bandwidth(struct vty *vty, struct lyd_node *dnode,
562 bool show_defaults)
563 {
564 const char *bandwidth = yang_dnode_get_string(dnode, NULL);
565
566 vty_out(vty, " eigrp bandwidth %s\n", bandwidth);
567 }
568
569 /*
570 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/hello-interval
571 */
572 DEFPY_YANG(
573 eigrp_if_ip_hellointerval,
574 eigrp_if_ip_hellointerval_cmd,
575 "ip hello-interval eigrp (1-65535)$hello",
576 "Interface Internet Protocol config commands\n"
577 "Configures EIGRP hello interval\n"
578 EIGRP_STR
579 "Seconds between hello transmissions\n")
580 {
581 nb_cli_enqueue_change(vty, "./frr-eigrpd:eigrp/hello-interval",
582 NB_OP_MODIFY, hello_str);
583 return nb_cli_apply_changes(vty, NULL);
584 }
585
586 DEFPY_YANG(
587 no_eigrp_if_ip_hellointerval,
588 no_eigrp_if_ip_hellointerval_cmd,
589 "no ip hello-interval eigrp [(1-65535)]",
590 NO_STR
591 "Interface Internet Protocol config commands\n"
592 "Configures EIGRP hello interval\n"
593 EIGRP_STR
594 "Seconds between hello transmissions\n")
595 {
596 nb_cli_enqueue_change(vty, "./frr-eigrpd:eigrp/hello-interval",
597 NB_OP_DESTROY, NULL);
598 return nb_cli_apply_changes(vty, NULL);
599 }
600
601
602 void eigrp_cli_show_hello_interval(struct vty *vty, struct lyd_node *dnode,
603 bool show_defaults)
604 {
605 const char *hello = yang_dnode_get_string(dnode, NULL);
606
607 vty_out(vty, " ip hello-interval eigrp %s\n", hello);
608 }
609
610 /*
611 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/hold-time
612 */
613 DEFPY_YANG(
614 eigrp_if_ip_holdinterval,
615 eigrp_if_ip_holdinterval_cmd,
616 "ip hold-time eigrp (1-65535)$hold",
617 "Interface Internet Protocol config commands\n"
618 "Configures EIGRP IPv4 hold time\n"
619 EIGRP_STR
620 "Seconds before neighbor is considered down\n")
621 {
622 nb_cli_enqueue_change(vty, "./frr-eigrpd:eigrp/hold-time",
623 NB_OP_MODIFY, hold_str);
624 return nb_cli_apply_changes(vty, NULL);
625 }
626
627 DEFPY_YANG(
628 no_eigrp_if_ip_holdinterval,
629 no_eigrp_if_ip_holdinterval_cmd,
630 "no ip hold-time eigrp [(1-65535)]",
631 NO_STR
632 "Interface Internet Protocol config commands\n"
633 "Configures EIGRP IPv4 hold time\n"
634 EIGRP_STR
635 "Seconds before neighbor is considered down\n")
636 {
637 nb_cli_enqueue_change(vty, "./frr-eigrpd:eigrp/hold-time",
638 NB_OP_DESTROY, NULL);
639 return nb_cli_apply_changes(vty, NULL);
640 }
641
642 void eigrp_cli_show_hold_time(struct vty *vty, struct lyd_node *dnode,
643 bool show_defaults)
644 {
645 const char *holdtime = yang_dnode_get_string(dnode, NULL);
646
647 vty_out(vty, " ip hold-time eigrp %s\n", holdtime);
648 }
649
650 /*
651 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/split-horizon
652 */
653 /* NOT implemented. */
654
655 /*
656 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/instance
657 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/instance/summarize-addresses
658 */
659 DEFPY_YANG(
660 eigrp_ip_summary_address,
661 eigrp_ip_summary_address_cmd,
662 "ip summary-address eigrp (1-65535)$as A.B.C.D/M$prefix",
663 "Interface Internet Protocol config commands\n"
664 "Perform address summarization\n"
665 EIGRP_STR
666 AS_STR
667 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
668 {
669 char xpath[XPATH_MAXLEN], xpath_auth[XPATH_MAXLEN + 64];
670
671 snprintf(xpath, sizeof(xpath), "./frr-eigrpd:eigrp/instance[asn='%s']",
672 as_str);
673 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
674
675 snprintf(xpath_auth, sizeof(xpath_auth), "%s/summarize-addresses", xpath);
676 nb_cli_enqueue_change(vty, xpath_auth, NB_OP_CREATE, prefix_str);
677
678 return nb_cli_apply_changes(vty, NULL);
679 }
680
681 DEFPY_YANG(
682 no_eigrp_ip_summary_address,
683 no_eigrp_ip_summary_address_cmd,
684 "no ip summary-address eigrp (1-65535)$as A.B.C.D/M$prefix",
685 NO_STR
686 "Interface Internet Protocol config commands\n"
687 "Perform address summarization\n"
688 EIGRP_STR
689 AS_STR
690 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
691 {
692 char xpath[XPATH_MAXLEN], xpath_auth[XPATH_MAXLEN + 64];
693
694 snprintf(xpath, sizeof(xpath), "./frr-eigrpd:eigrp/instance[asn='%s']",
695 as_str);
696 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
697
698 snprintf(xpath_auth, sizeof(xpath_auth), "%s/summarize-addresses", xpath);
699 nb_cli_enqueue_change(vty, xpath_auth, NB_OP_DESTROY, prefix_str);
700
701 return nb_cli_apply_changes(vty, NULL);
702 }
703
704 void eigrp_cli_show_summarize_address(struct vty *vty, struct lyd_node *dnode,
705 bool show_defaults)
706 {
707 const struct lyd_node *instance = yang_dnode_get_parent(dnode, "instance");
708 uint16_t asn = yang_dnode_get_uint16(instance, "./asn");
709 const char *summarize_address = yang_dnode_get_string(dnode, NULL);
710
711 vty_out(vty, " ip summary-address eigrp %d %s\n", asn,
712 summarize_address);
713 }
714
715 /*
716 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/instance
717 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/instance/authentication
718 */
719 DEFPY_YANG(
720 eigrp_authentication_mode,
721 eigrp_authentication_mode_cmd,
722 "ip authentication mode eigrp (1-65535)$as <md5|hmac-sha-256>$crypt",
723 "Interface Internet Protocol config commands\n"
724 "Authentication subcommands\n"
725 "Mode\n"
726 EIGRP_STR
727 AS_STR
728 "Keyed message digest\n"
729 "HMAC SHA256 algorithm \n")
730 {
731 char xpath[XPATH_MAXLEN], xpath_auth[XPATH_MAXLEN + 64];
732
733 snprintf(xpath, sizeof(xpath), "./frr-eigrpd:eigrp/instance[asn='%s']",
734 as_str);
735 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
736
737 snprintf(xpath_auth, sizeof(xpath_auth), "%s/authentication", xpath);
738 nb_cli_enqueue_change(vty, xpath_auth, NB_OP_MODIFY, crypt);
739
740 return nb_cli_apply_changes(vty, NULL);
741 }
742
743 DEFPY_YANG(
744 no_eigrp_authentication_mode,
745 no_eigrp_authentication_mode_cmd,
746 "no ip authentication mode eigrp (1-65535)$as [<md5|hmac-sha-256>]",
747 NO_STR
748 "Interface Internet Protocol config commands\n"
749 "Authentication subcommands\n"
750 "Mode\n"
751 EIGRP_STR
752 AS_STR
753 "Keyed message digest\n"
754 "HMAC SHA256 algorithm \n")
755 {
756 char xpath[XPATH_MAXLEN], xpath_auth[XPATH_MAXLEN + 64];
757
758 snprintf(xpath, sizeof(xpath), "./frr-eigrpd:eigrp/instance[asn='%s']",
759 as_str);
760 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
761
762 snprintf(xpath_auth, sizeof(xpath_auth), "%s/authentication", xpath);
763 nb_cli_enqueue_change(vty, xpath_auth, NB_OP_MODIFY, "none");
764
765 return nb_cli_apply_changes(vty, NULL);
766 }
767
768 void eigrp_cli_show_authentication(struct vty *vty, struct lyd_node *dnode,
769 bool show_defaults)
770 {
771 const struct lyd_node *instance = yang_dnode_get_parent(dnode, "instance");
772 uint16_t asn = yang_dnode_get_uint16(instance, "./asn");
773 const char *crypt = yang_dnode_get_string(dnode, NULL);
774
775 vty_out(vty, " ip authentication mode eigrp %d %s\n", asn, crypt);
776 }
777
778 /*
779 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/instance
780 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/instance/keychain
781 */
782 DEFPY_YANG(
783 eigrp_authentication_keychain,
784 eigrp_authentication_keychain_cmd,
785 "ip authentication key-chain eigrp (1-65535)$as WORD$name",
786 "Interface Internet Protocol config commands\n"
787 "Authentication subcommands\n"
788 "Key-chain\n"
789 EIGRP_STR
790 AS_STR
791 "Name of key-chain\n")
792 {
793 char xpath[XPATH_MAXLEN], xpath_auth[XPATH_MAXLEN + 64];
794
795 snprintf(xpath, sizeof(xpath), "./frr-eigrpd:eigrp/instance[asn='%s']",
796 as_str);
797 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
798
799 snprintf(xpath_auth, sizeof(xpath_auth), "%s/keychain", xpath);
800 nb_cli_enqueue_change(vty, xpath_auth, NB_OP_MODIFY, name);
801
802 return nb_cli_apply_changes(vty, NULL);
803 }
804
805 DEFPY_YANG(
806 no_eigrp_authentication_keychain,
807 no_eigrp_authentication_keychain_cmd,
808 "no ip authentication key-chain eigrp (1-65535)$as [WORD]",
809 NO_STR
810 "Interface Internet Protocol config commands\n"
811 "Authentication subcommands\n"
812 "Key-chain\n"
813 EIGRP_STR
814 AS_STR
815 "Name of key-chain\n")
816 {
817 char xpath[XPATH_MAXLEN], xpath_auth[XPATH_MAXLEN + 64];
818
819 snprintf(xpath, sizeof(xpath), "./frr-eigrpd:eigrp/instance[asn='%s']",
820 as_str);
821 snprintf(xpath_auth, sizeof(xpath_auth), "%s/keychain", xpath);
822 nb_cli_enqueue_change(vty, xpath_auth, NB_OP_DESTROY, NULL);
823
824 return nb_cli_apply_changes(vty, NULL);
825 }
826
827 void eigrp_cli_show_keychain(struct vty *vty, struct lyd_node *dnode,
828 bool show_defaults)
829 {
830 const struct lyd_node *instance = yang_dnode_get_parent(dnode, "instance");
831 uint16_t asn = yang_dnode_get_uint16(instance, "./asn");
832 const char *keychain = yang_dnode_get_string(dnode, NULL);
833
834 vty_out(vty, " ip authentication key-chain eigrp %d %s\n", asn,
835 keychain);
836 }
837
838
839 /*
840 * CLI installation procedures.
841 */
842 static int eigrp_config_write(struct vty *vty);
843 static struct cmd_node eigrp_node = {
844 .name = "eigrp",
845 .node = EIGRP_NODE,
846 .parent_node = CONFIG_NODE,
847 .prompt = "%s(config-router)# ",
848 .config_write = eigrp_config_write,
849 };
850
851 static int eigrp_config_write(struct vty *vty)
852 {
853 struct lyd_node *dnode;
854 int written = 0;
855
856 dnode = yang_dnode_get(running_config->dnode, "/frr-eigrpd:eigrpd");
857 if (dnode) {
858 nb_cli_show_dnode_cmds(vty, dnode, false);
859 written = 1;
860 }
861
862 return written;
863 }
864
865 static int eigrp_write_interface(struct vty *vty)
866 {
867 struct lyd_node *dnode;
868 struct interface *ifp;
869 struct vrf *vrf;
870 int written = 0;
871
872 RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) {
873 FOR_ALL_INTERFACES(vrf, ifp) {
874 dnode = yang_dnode_getf(
875 running_config->dnode,
876 "/frr-interface:lib/interface[name='%s'][vrf='%s']",
877 ifp->name, vrf->name);
878 if (dnode == NULL)
879 continue;
880
881 written = 1;
882 nb_cli_show_dnode_cmds(vty, dnode, false);
883 }
884 }
885
886 return written;
887 }
888
889 void
890 eigrp_cli_init(void)
891 {
892 install_element(CONFIG_NODE, &router_eigrp_cmd);
893 install_element(CONFIG_NODE, &no_router_eigrp_cmd);
894
895 install_node(&eigrp_node);
896 install_default(EIGRP_NODE);
897
898 install_element(EIGRP_NODE, &eigrp_router_id_cmd);
899 install_element(EIGRP_NODE, &no_eigrp_router_id_cmd);
900 install_element(EIGRP_NODE, &eigrp_passive_interface_cmd);
901 install_element(EIGRP_NODE, &eigrp_timers_active_cmd);
902 install_element(EIGRP_NODE, &no_eigrp_timers_active_cmd);
903 install_element(EIGRP_NODE, &eigrp_variance_cmd);
904 install_element(EIGRP_NODE, &no_eigrp_variance_cmd);
905 install_element(EIGRP_NODE, &eigrp_maximum_paths_cmd);
906 install_element(EIGRP_NODE, &no_eigrp_maximum_paths_cmd);
907 install_element(EIGRP_NODE, &eigrp_metric_weights_cmd);
908 install_element(EIGRP_NODE, &no_eigrp_metric_weights_cmd);
909 install_element(EIGRP_NODE, &eigrp_network_cmd);
910 install_element(EIGRP_NODE, &eigrp_neighbor_cmd);
911 install_element(EIGRP_NODE, &eigrp_redistribute_source_metric_cmd);
912
913 vrf_cmd_init(NULL);
914
915 if_cmd_init(eigrp_write_interface);
916
917 install_element(INTERFACE_NODE, &eigrp_if_delay_cmd);
918 install_element(INTERFACE_NODE, &no_eigrp_if_delay_cmd);
919 install_element(INTERFACE_NODE, &eigrp_if_bandwidth_cmd);
920 install_element(INTERFACE_NODE, &no_eigrp_if_bandwidth_cmd);
921 install_element(INTERFACE_NODE, &eigrp_if_ip_hellointerval_cmd);
922 install_element(INTERFACE_NODE, &no_eigrp_if_ip_hellointerval_cmd);
923 install_element(INTERFACE_NODE, &eigrp_if_ip_holdinterval_cmd);
924 install_element(INTERFACE_NODE, &no_eigrp_if_ip_holdinterval_cmd);
925 install_element(INTERFACE_NODE, &eigrp_ip_summary_address_cmd);
926 install_element(INTERFACE_NODE, &no_eigrp_ip_summary_address_cmd);
927 install_element(INTERFACE_NODE, &eigrp_authentication_mode_cmd);
928 install_element(INTERFACE_NODE, &no_eigrp_authentication_mode_cmd);
929 install_element(INTERFACE_NODE, &eigrp_authentication_keychain_cmd);
930 install_element(INTERFACE_NODE, &no_eigrp_authentication_keychain_cmd);
931 }