]> git.proxmox.com Git - mirror_frr.git/blob - eigrpd/eigrp_cli.c
zebra: Ensure SRv6 SID length does not exceed 128
[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, const 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, const 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, const 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,
161 const struct lyd_node *dnode,
162 bool show_defaults)
163 {
164 const char *ifname = yang_dnode_get_string(dnode, NULL);
165
166 vty_out(vty, " passive-interface %s\n", ifname);
167 }
168
169 /*
170 * XPath: /frr-eigrpd:eigrpd/instance/active-time
171 */
172 DEFPY_YANG(
173 eigrp_timers_active,
174 eigrp_timers_active_cmd,
175 "timers active-time <(1-65535)$timer|disabled$disabled>",
176 "Adjust routing timers\n"
177 "Time limit for active state\n"
178 "Active state time limit in seconds\n"
179 "Disable time limit for active state\n")
180 {
181 if (disabled)
182 nb_cli_enqueue_change(vty, "./active-time", NB_OP_MODIFY, "0");
183 else
184 nb_cli_enqueue_change(vty, "./active-time",
185 NB_OP_MODIFY, timer_str);
186
187 return nb_cli_apply_changes(vty, NULL);
188 }
189
190 DEFPY_YANG(
191 no_eigrp_timers_active,
192 no_eigrp_timers_active_cmd,
193 "no timers active-time [<(1-65535)|disabled>]",
194 NO_STR
195 "Adjust routing timers\n"
196 "Time limit for active state\n"
197 "Active state time limit in seconds\n"
198 "Disable time limit for active state\n")
199 {
200 nb_cli_enqueue_change(vty, "./active-time", NB_OP_DESTROY, NULL);
201 return nb_cli_apply_changes(vty, NULL);
202 }
203
204 void eigrp_cli_show_active_time(struct vty *vty, const struct lyd_node *dnode,
205 bool show_defaults)
206 {
207 const char *timer = yang_dnode_get_string(dnode, NULL);
208
209 vty_out(vty, " timers active-time %s\n", timer);
210 }
211
212 /*
213 * XPath: /frr-eigrpd:eigrpd/instance/variance
214 */
215 DEFPY_YANG(
216 eigrp_variance,
217 eigrp_variance_cmd,
218 "variance (1-128)$variance",
219 "Control load balancing variance\n"
220 "Metric variance multiplier\n")
221 {
222 nb_cli_enqueue_change(vty, "./variance", NB_OP_MODIFY, variance_str);
223 return nb_cli_apply_changes(vty, NULL);
224 }
225
226 DEFPY_YANG(
227 no_eigrp_variance,
228 no_eigrp_variance_cmd,
229 "no variance [(1-128)]",
230 NO_STR
231 "Control load balancing variance\n"
232 "Metric variance multiplier\n")
233 {
234 nb_cli_enqueue_change(vty, "./variance", NB_OP_DESTROY, NULL);
235 return nb_cli_apply_changes(vty, NULL);
236 }
237
238 void eigrp_cli_show_variance(struct vty *vty, const struct lyd_node *dnode,
239 bool show_defaults)
240 {
241 const char *variance = yang_dnode_get_string(dnode, NULL);
242
243 vty_out(vty, " variance %s\n", variance);
244 }
245
246 /*
247 * XPath: /frr-eigrpd:eigrpd/instance/maximum-paths
248 */
249 DEFPY_YANG(
250 eigrp_maximum_paths,
251 eigrp_maximum_paths_cmd,
252 "maximum-paths (1-32)$maximum_paths",
253 "Forward packets over multiple paths\n"
254 "Number of paths\n")
255 {
256 nb_cli_enqueue_change(vty, "./maximum-paths", NB_OP_MODIFY,
257 maximum_paths_str);
258 return nb_cli_apply_changes(vty, NULL);
259 }
260
261 DEFPY_YANG(
262 no_eigrp_maximum_paths,
263 no_eigrp_maximum_paths_cmd,
264 "no maximum-paths [(1-32)]",
265 NO_STR
266 "Forward packets over multiple paths\n"
267 "Number of paths\n")
268 {
269 nb_cli_enqueue_change(vty, "./maximum-paths", NB_OP_DESTROY, NULL);
270 return nb_cli_apply_changes(vty, NULL);
271 }
272
273 void eigrp_cli_show_maximum_paths(struct vty *vty, const struct lyd_node *dnode,
274 bool show_defaults)
275 {
276 const char *maximum_paths = yang_dnode_get_string(dnode, NULL);
277
278 vty_out(vty, " maximum-paths %s\n", maximum_paths);
279 }
280
281 /*
282 * XPath: /frr-eigrpd:eigrpd/instance/metric-weights/K1
283 * XPath: /frr-eigrpd:eigrpd/instance/metric-weights/K2
284 * XPath: /frr-eigrpd:eigrpd/instance/metric-weights/K3
285 * XPath: /frr-eigrpd:eigrpd/instance/metric-weights/K4
286 * XPath: /frr-eigrpd:eigrpd/instance/metric-weights/K5
287 * XPath: /frr-eigrpd:eigrpd/instance/metric-weights/K6
288 */
289 DEFPY_YANG(
290 eigrp_metric_weights,
291 eigrp_metric_weights_cmd,
292 "metric weights (0-255)$k1 (0-255)$k2 (0-255)$k3 (0-255)$k4 (0-255)$k5 [(0-255)$k6]",
293 "Modify metrics and parameters for advertisement\n"
294 "Modify metric coefficients\n"
295 "K1\n"
296 "K2\n"
297 "K3\n"
298 "K4\n"
299 "K5\n"
300 "K6\n")
301 {
302 nb_cli_enqueue_change(vty, "./metric-weights/K1", NB_OP_MODIFY, k1_str);
303 nb_cli_enqueue_change(vty, "./metric-weights/K2", NB_OP_MODIFY, k2_str);
304 nb_cli_enqueue_change(vty, "./metric-weights/K3", NB_OP_MODIFY, k3_str);
305 nb_cli_enqueue_change(vty, "./metric-weights/K4", NB_OP_MODIFY, k4_str);
306 nb_cli_enqueue_change(vty, "./metric-weights/K5", NB_OP_MODIFY, k5_str);
307 if (k6)
308 nb_cli_enqueue_change(vty, "./metric-weights/K6",
309 NB_OP_MODIFY, k6_str);
310
311 return nb_cli_apply_changes(vty, NULL);
312 }
313
314 DEFPY_YANG(
315 no_eigrp_metric_weights,
316 no_eigrp_metric_weights_cmd,
317 "no metric weights [(0-255) (0-255) (0-255) (0-255) (0-255) (0-255)]",
318 NO_STR
319 "Modify metrics and parameters for advertisement\n"
320 "Modify metric coefficients\n"
321 "K1\n"
322 "K2\n"
323 "K3\n"
324 "K4\n"
325 "K5\n"
326 "K6\n")
327 {
328 nb_cli_enqueue_change(vty, "./metric-weights/K1", NB_OP_DESTROY, NULL);
329 nb_cli_enqueue_change(vty, "./metric-weights/K2", NB_OP_DESTROY, NULL);
330 nb_cli_enqueue_change(vty, "./metric-weights/K3", NB_OP_DESTROY, NULL);
331 nb_cli_enqueue_change(vty, "./metric-weights/K4", NB_OP_DESTROY, NULL);
332 nb_cli_enqueue_change(vty, "./metric-weights/K5", NB_OP_DESTROY, NULL);
333 nb_cli_enqueue_change(vty, "./metric-weights/K6", NB_OP_DESTROY, NULL);
334 return nb_cli_apply_changes(vty, NULL);
335 }
336
337 void eigrp_cli_show_metrics(struct vty *vty, const struct lyd_node *dnode,
338 bool show_defaults)
339 {
340 const char *k1, *k2, *k3, *k4, *k5, *k6;
341
342 k1 = yang_dnode_exists(dnode, "./K1") ?
343 yang_dnode_get_string(dnode, "./K1") : "0";
344 k2 = yang_dnode_exists(dnode, "./K2") ?
345 yang_dnode_get_string(dnode, "./K2") : "0";
346 k3 = yang_dnode_exists(dnode, "./K3") ?
347 yang_dnode_get_string(dnode, "./K3") : "0";
348 k4 = yang_dnode_exists(dnode, "./K4") ?
349 yang_dnode_get_string(dnode, "./K4") : "0";
350 k5 = yang_dnode_exists(dnode, "./K5") ?
351 yang_dnode_get_string(dnode, "./K5") : "0";
352 k6 = yang_dnode_exists(dnode, "./K6") ?
353 yang_dnode_get_string(dnode, "./K6") : "0";
354
355 vty_out(vty, " metric weights %s %s %s %s %s",
356 k1, k2, k3, k4, k5);
357 if (k6)
358 vty_out(vty, " %s", k6);
359 vty_out(vty, "\n");
360 }
361
362 /*
363 * XPath: /frr-eigrpd:eigrpd/instance/network
364 */
365 DEFPY_YANG(
366 eigrp_network,
367 eigrp_network_cmd,
368 "[no] network A.B.C.D/M$prefix",
369 NO_STR
370 "Enable routing on an IP network\n"
371 "EIGRP network prefix\n")
372 {
373 if (no)
374 nb_cli_enqueue_change(vty, "./network", NB_OP_DESTROY,
375 prefix_str);
376 else
377 nb_cli_enqueue_change(vty, "./network", NB_OP_CREATE,
378 prefix_str);
379
380 return nb_cli_apply_changes(vty, NULL);
381 }
382
383 void eigrp_cli_show_network(struct vty *vty, const struct lyd_node *dnode,
384 bool show_defaults)
385 {
386 const char *prefix = yang_dnode_get_string(dnode, NULL);
387
388 vty_out(vty, " network %s\n", prefix);
389 }
390
391 /*
392 * XPath: /frr-eigrpd:eigrpd/instance/neighbor
393 */
394 DEFPY_YANG(
395 eigrp_neighbor,
396 eigrp_neighbor_cmd,
397 "[no] neighbor A.B.C.D$addr",
398 NO_STR
399 "Specify a neighbor router\n"
400 "Neighbor address\n")
401 {
402 if (no)
403 nb_cli_enqueue_change(vty, "./neighbor", NB_OP_DESTROY,
404 addr_str);
405 else
406 nb_cli_enqueue_change(vty, "./neighbor", NB_OP_CREATE,
407 addr_str);
408
409 return nb_cli_apply_changes(vty, NULL);
410 }
411
412 void eigrp_cli_show_neighbor(struct vty *vty, const struct lyd_node *dnode,
413 bool show_defaults)
414 {
415 const char *prefix = yang_dnode_get_string(dnode, NULL);
416
417 vty_out(vty, " neighbor %s\n", prefix);
418 }
419
420 /*
421 * XPath: /frr-eigrpd:eigrpd/instance/redistribute
422 * XPath: /frr-eigrpd:eigrpd/instance/redistribute/route-map
423 * XPath: /frr-eigrpd:eigrpd/instance/redistribute/metrics/bandwidth
424 * XPath: /frr-eigrpd:eigrpd/instance/redistribute/metrics/delay
425 * XPath: /frr-eigrpd:eigrpd/instance/redistribute/metrics/reliability
426 * XPath: /frr-eigrpd:eigrpd/instance/redistribute/metrics/load
427 * XPath: /frr-eigrpd:eigrpd/instance/redistribute/metrics/mtu
428 */
429 DEFPY_YANG(
430 eigrp_redistribute_source_metric,
431 eigrp_redistribute_source_metric_cmd,
432 "[no] redistribute " FRR_REDIST_STR_EIGRPD
433 "$proto [metric (1-4294967295)$bw (0-4294967295)$delay (0-255)$rlbt (1-255)$load (1-65535)$mtu]",
434 NO_STR
435 REDIST_STR
436 FRR_REDIST_HELP_STR_EIGRPD
437 "Metric for redistributed routes\n"
438 "Bandwidth metric in Kbits per second\n"
439 "EIGRP delay metric, in 10 microsecond units\n"
440 "EIGRP reliability metric where 255 is 100% reliable2 ?\n"
441 "EIGRP Effective bandwidth metric (Loading) where 255 is 100% loaded\n"
442 "EIGRP MTU of the path\n")
443 {
444 char xpath[XPATH_MAXLEN], xpath_metric[XPATH_MAXLEN + 64];
445
446 snprintf(xpath, sizeof(xpath), "./redistribute[protocol='%s']", proto);
447
448 if (no) {
449 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
450 return nb_cli_apply_changes(vty, NULL);
451 }
452
453 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
454 if (bw == 0 || delay == 0 || rlbt == 0 || load == 0 || mtu == 0)
455 return nb_cli_apply_changes(vty, NULL);
456
457 snprintf(xpath_metric, sizeof(xpath_metric), "%s/metrics/bandwidth",
458 xpath);
459 nb_cli_enqueue_change(vty, xpath_metric, NB_OP_MODIFY, bw_str);
460 snprintf(xpath_metric, sizeof(xpath_metric), "%s/metrics/delay", xpath);
461 nb_cli_enqueue_change(vty, xpath_metric, NB_OP_MODIFY, delay_str);
462 snprintf(xpath_metric, sizeof(xpath_metric), "%s/metrics/reliability",
463 xpath);
464 nb_cli_enqueue_change(vty, xpath_metric, NB_OP_MODIFY, rlbt_str);
465 snprintf(xpath_metric, sizeof(xpath_metric), "%s/metrics/load", xpath);
466 nb_cli_enqueue_change(vty, xpath_metric, NB_OP_MODIFY, load_str);
467 snprintf(xpath_metric, sizeof(xpath_metric), "%s/metrics/mtu", xpath);
468 nb_cli_enqueue_change(vty, xpath_metric, NB_OP_MODIFY, mtu_str);
469 return nb_cli_apply_changes(vty, NULL);
470 }
471
472 void eigrp_cli_show_redistribute(struct vty *vty, const struct lyd_node *dnode,
473 bool show_defaults)
474 {
475 const char *proto = yang_dnode_get_string(dnode, "./protocol");
476 const char *bw, *delay, *load, *mtu, *rlbt;
477
478 bw = yang_dnode_exists(dnode, "./metrics/bandwidth") ?
479 yang_dnode_get_string(dnode, "./metrics/bandwidth") : NULL;
480 delay = yang_dnode_exists(dnode, "./metrics/delay") ?
481 yang_dnode_get_string(dnode, "./metrics/delay") : NULL;
482 rlbt = yang_dnode_exists(dnode, "./metrics/reliability") ?
483 yang_dnode_get_string(dnode, "./metrics/reliability") : NULL;
484 load = yang_dnode_exists(dnode, "./metrics/load") ?
485 yang_dnode_get_string(dnode, "./metrics/load") : NULL;
486 mtu = yang_dnode_exists(dnode, "./metrics/mtu") ?
487 yang_dnode_get_string(dnode, "./metrics/mtu") : NULL;
488
489 vty_out(vty, " redistribute %s", proto);
490 if (bw || rlbt || delay || load || mtu)
491 vty_out(vty, " metric %s %s %s %s %s", bw, delay, rlbt, load,
492 mtu);
493 vty_out(vty, "\n");
494 }
495
496 /*
497 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/delay
498 */
499 DEFPY_YANG(
500 eigrp_if_delay,
501 eigrp_if_delay_cmd,
502 "delay (1-16777215)$delay",
503 "Specify interface throughput delay\n"
504 "Throughput delay (tens of microseconds)\n")
505 {
506 nb_cli_enqueue_change(vty, "./frr-eigrpd:eigrp/delay",
507 NB_OP_MODIFY, delay_str);
508 return nb_cli_apply_changes(vty, NULL);
509 }
510
511 DEFPY_YANG(
512 no_eigrp_if_delay,
513 no_eigrp_if_delay_cmd,
514 "no delay [(1-16777215)]",
515 NO_STR
516 "Specify interface throughput delay\n"
517 "Throughput delay (tens of microseconds)\n")
518 {
519 nb_cli_enqueue_change(vty, "./frr-eigrpd:eigrp/delay",
520 NB_OP_DESTROY, NULL);
521 return nb_cli_apply_changes(vty, NULL);
522 }
523
524 void eigrp_cli_show_delay(struct vty *vty, const struct lyd_node *dnode,
525 bool show_defaults)
526 {
527 const char *delay = yang_dnode_get_string(dnode, NULL);
528
529 vty_out(vty, " delay %s\n", delay);
530 }
531
532 /*
533 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/bandwidth
534 */
535 DEFPY_YANG(
536 eigrp_if_bandwidth,
537 eigrp_if_bandwidth_cmd,
538 "eigrp bandwidth (1-10000000)$bw",
539 EIGRP_STR
540 "Set bandwidth informational parameter\n"
541 "Bandwidth in kilobits\n")
542 {
543 nb_cli_enqueue_change(vty, "./frr-eigrpd:eigrp/bandwidth",
544 NB_OP_MODIFY, bw_str);
545 return nb_cli_apply_changes(vty, NULL);
546 }
547
548 DEFPY_YANG(
549 no_eigrp_if_bandwidth,
550 no_eigrp_if_bandwidth_cmd,
551 "no eigrp bandwidth [(1-10000000)]",
552 NO_STR
553 EIGRP_STR
554 "Set bandwidth informational parameter\n"
555 "Bandwidth in kilobits\n")
556 {
557 nb_cli_enqueue_change(vty, "./frr-eigrpd:eigrp/bandwidth",
558 NB_OP_DESTROY, NULL);
559 return nb_cli_apply_changes(vty, NULL);
560 }
561
562 void eigrp_cli_show_bandwidth(struct vty *vty, const struct lyd_node *dnode,
563 bool show_defaults)
564 {
565 const char *bandwidth = yang_dnode_get_string(dnode, NULL);
566
567 vty_out(vty, " eigrp bandwidth %s\n", bandwidth);
568 }
569
570 /*
571 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/hello-interval
572 */
573 DEFPY_YANG(
574 eigrp_if_ip_hellointerval,
575 eigrp_if_ip_hellointerval_cmd,
576 "ip hello-interval eigrp (1-65535)$hello",
577 "Interface Internet Protocol config commands\n"
578 "Configures EIGRP hello interval\n"
579 EIGRP_STR
580 "Seconds between hello transmissions\n")
581 {
582 nb_cli_enqueue_change(vty, "./frr-eigrpd:eigrp/hello-interval",
583 NB_OP_MODIFY, hello_str);
584 return nb_cli_apply_changes(vty, NULL);
585 }
586
587 DEFPY_YANG(
588 no_eigrp_if_ip_hellointerval,
589 no_eigrp_if_ip_hellointerval_cmd,
590 "no ip hello-interval eigrp [(1-65535)]",
591 NO_STR
592 "Interface Internet Protocol config commands\n"
593 "Configures EIGRP hello interval\n"
594 EIGRP_STR
595 "Seconds between hello transmissions\n")
596 {
597 nb_cli_enqueue_change(vty, "./frr-eigrpd:eigrp/hello-interval",
598 NB_OP_DESTROY, NULL);
599 return nb_cli_apply_changes(vty, NULL);
600 }
601
602
603 void eigrp_cli_show_hello_interval(struct vty *vty,
604 const struct lyd_node *dnode,
605 bool show_defaults)
606 {
607 const char *hello = yang_dnode_get_string(dnode, NULL);
608
609 vty_out(vty, " ip hello-interval eigrp %s\n", hello);
610 }
611
612 /*
613 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/hold-time
614 */
615 DEFPY_YANG(
616 eigrp_if_ip_holdinterval,
617 eigrp_if_ip_holdinterval_cmd,
618 "ip hold-time eigrp (1-65535)$hold",
619 "Interface Internet Protocol config commands\n"
620 "Configures EIGRP IPv4 hold time\n"
621 EIGRP_STR
622 "Seconds before neighbor is considered down\n")
623 {
624 nb_cli_enqueue_change(vty, "./frr-eigrpd:eigrp/hold-time",
625 NB_OP_MODIFY, hold_str);
626 return nb_cli_apply_changes(vty, NULL);
627 }
628
629 DEFPY_YANG(
630 no_eigrp_if_ip_holdinterval,
631 no_eigrp_if_ip_holdinterval_cmd,
632 "no ip hold-time eigrp [(1-65535)]",
633 NO_STR
634 "Interface Internet Protocol config commands\n"
635 "Configures EIGRP IPv4 hold time\n"
636 EIGRP_STR
637 "Seconds before neighbor is considered down\n")
638 {
639 nb_cli_enqueue_change(vty, "./frr-eigrpd:eigrp/hold-time",
640 NB_OP_DESTROY, NULL);
641 return nb_cli_apply_changes(vty, NULL);
642 }
643
644 void eigrp_cli_show_hold_time(struct vty *vty, const struct lyd_node *dnode,
645 bool show_defaults)
646 {
647 const char *holdtime = yang_dnode_get_string(dnode, NULL);
648
649 vty_out(vty, " ip hold-time eigrp %s\n", holdtime);
650 }
651
652 /*
653 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/split-horizon
654 */
655 /* NOT implemented. */
656
657 /*
658 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/instance
659 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/instance/summarize-addresses
660 */
661 DEFPY_YANG(
662 eigrp_ip_summary_address,
663 eigrp_ip_summary_address_cmd,
664 "ip summary-address eigrp (1-65535)$as A.B.C.D/M$prefix",
665 "Interface Internet Protocol config commands\n"
666 "Perform address summarization\n"
667 EIGRP_STR
668 AS_STR
669 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
670 {
671 char xpath[XPATH_MAXLEN], xpath_auth[XPATH_MAXLEN + 64];
672
673 snprintf(xpath, sizeof(xpath), "./frr-eigrpd:eigrp/instance[asn='%s']",
674 as_str);
675 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
676
677 snprintf(xpath_auth, sizeof(xpath_auth), "%s/summarize-addresses", xpath);
678 nb_cli_enqueue_change(vty, xpath_auth, NB_OP_CREATE, prefix_str);
679
680 return nb_cli_apply_changes(vty, NULL);
681 }
682
683 DEFPY_YANG(
684 no_eigrp_ip_summary_address,
685 no_eigrp_ip_summary_address_cmd,
686 "no ip summary-address eigrp (1-65535)$as A.B.C.D/M$prefix",
687 NO_STR
688 "Interface Internet Protocol config commands\n"
689 "Perform address summarization\n"
690 EIGRP_STR
691 AS_STR
692 "Summary <network>/<length>, e.g. 192.168.0.0/16\n")
693 {
694 char xpath[XPATH_MAXLEN], xpath_auth[XPATH_MAXLEN + 64];
695
696 snprintf(xpath, sizeof(xpath), "./frr-eigrpd:eigrp/instance[asn='%s']",
697 as_str);
698 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
699
700 snprintf(xpath_auth, sizeof(xpath_auth), "%s/summarize-addresses", xpath);
701 nb_cli_enqueue_change(vty, xpath_auth, NB_OP_DESTROY, prefix_str);
702
703 return nb_cli_apply_changes(vty, NULL);
704 }
705
706 void eigrp_cli_show_summarize_address(struct vty *vty,
707 const struct lyd_node *dnode,
708 bool show_defaults)
709 {
710 const struct lyd_node *instance =
711 yang_dnode_get_parent(dnode, "instance");
712 uint16_t asn = yang_dnode_get_uint16(instance, "./asn");
713 const char *summarize_address = yang_dnode_get_string(dnode, NULL);
714
715 vty_out(vty, " ip summary-address eigrp %d %s\n", asn,
716 summarize_address);
717 }
718
719 /*
720 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/instance
721 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/instance/authentication
722 */
723 DEFPY_YANG(
724 eigrp_authentication_mode,
725 eigrp_authentication_mode_cmd,
726 "ip authentication mode eigrp (1-65535)$as <md5|hmac-sha-256>$crypt",
727 "Interface Internet Protocol config commands\n"
728 "Authentication subcommands\n"
729 "Mode\n"
730 EIGRP_STR
731 AS_STR
732 "Keyed message digest\n"
733 "HMAC SHA256 algorithm \n")
734 {
735 char xpath[XPATH_MAXLEN], xpath_auth[XPATH_MAXLEN + 64];
736
737 snprintf(xpath, sizeof(xpath), "./frr-eigrpd:eigrp/instance[asn='%s']",
738 as_str);
739 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
740
741 snprintf(xpath_auth, sizeof(xpath_auth), "%s/authentication", xpath);
742 nb_cli_enqueue_change(vty, xpath_auth, NB_OP_MODIFY, crypt);
743
744 return nb_cli_apply_changes(vty, NULL);
745 }
746
747 DEFPY_YANG(
748 no_eigrp_authentication_mode,
749 no_eigrp_authentication_mode_cmd,
750 "no ip authentication mode eigrp (1-65535)$as [<md5|hmac-sha-256>]",
751 NO_STR
752 "Interface Internet Protocol config commands\n"
753 "Authentication subcommands\n"
754 "Mode\n"
755 EIGRP_STR
756 AS_STR
757 "Keyed message digest\n"
758 "HMAC SHA256 algorithm \n")
759 {
760 char xpath[XPATH_MAXLEN], xpath_auth[XPATH_MAXLEN + 64];
761
762 snprintf(xpath, sizeof(xpath), "./frr-eigrpd:eigrp/instance[asn='%s']",
763 as_str);
764 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
765
766 snprintf(xpath_auth, sizeof(xpath_auth), "%s/authentication", xpath);
767 nb_cli_enqueue_change(vty, xpath_auth, NB_OP_MODIFY, "none");
768
769 return nb_cli_apply_changes(vty, NULL);
770 }
771
772 void eigrp_cli_show_authentication(struct vty *vty,
773 const struct lyd_node *dnode,
774 bool show_defaults)
775 {
776 const struct lyd_node *instance =
777 yang_dnode_get_parent(dnode, "instance");
778 uint16_t asn = yang_dnode_get_uint16(instance, "./asn");
779 const char *crypt = yang_dnode_get_string(dnode, NULL);
780
781 vty_out(vty, " ip authentication mode eigrp %d %s\n", asn, crypt);
782 }
783
784 /*
785 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/instance
786 * XPath: /frr-interface:lib/interface/frr-eigrpd:eigrp/instance/keychain
787 */
788 DEFPY_YANG(
789 eigrp_authentication_keychain,
790 eigrp_authentication_keychain_cmd,
791 "ip authentication key-chain eigrp (1-65535)$as WORD$name",
792 "Interface Internet Protocol config commands\n"
793 "Authentication subcommands\n"
794 "Key-chain\n"
795 EIGRP_STR
796 AS_STR
797 "Name of key-chain\n")
798 {
799 char xpath[XPATH_MAXLEN], xpath_auth[XPATH_MAXLEN + 64];
800
801 snprintf(xpath, sizeof(xpath), "./frr-eigrpd:eigrp/instance[asn='%s']",
802 as_str);
803 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
804
805 snprintf(xpath_auth, sizeof(xpath_auth), "%s/keychain", xpath);
806 nb_cli_enqueue_change(vty, xpath_auth, NB_OP_MODIFY, name);
807
808 return nb_cli_apply_changes(vty, NULL);
809 }
810
811 DEFPY_YANG(
812 no_eigrp_authentication_keychain,
813 no_eigrp_authentication_keychain_cmd,
814 "no ip authentication key-chain eigrp (1-65535)$as [WORD]",
815 NO_STR
816 "Interface Internet Protocol config commands\n"
817 "Authentication subcommands\n"
818 "Key-chain\n"
819 EIGRP_STR
820 AS_STR
821 "Name of key-chain\n")
822 {
823 char xpath[XPATH_MAXLEN], xpath_auth[XPATH_MAXLEN + 64];
824
825 snprintf(xpath, sizeof(xpath), "./frr-eigrpd:eigrp/instance[asn='%s']",
826 as_str);
827 snprintf(xpath_auth, sizeof(xpath_auth), "%s/keychain", xpath);
828 nb_cli_enqueue_change(vty, xpath_auth, NB_OP_DESTROY, NULL);
829
830 return nb_cli_apply_changes(vty, NULL);
831 }
832
833 void eigrp_cli_show_keychain(struct vty *vty, const struct lyd_node *dnode,
834 bool show_defaults)
835 {
836 const struct lyd_node *instance =
837 yang_dnode_get_parent(dnode, "instance");
838 uint16_t asn = yang_dnode_get_uint16(instance, "./asn");
839 const char *keychain = yang_dnode_get_string(dnode, NULL);
840
841 vty_out(vty, " ip authentication key-chain eigrp %d %s\n", asn,
842 keychain);
843 }
844
845
846 /*
847 * CLI installation procedures.
848 */
849 static int eigrp_config_write(struct vty *vty);
850 static struct cmd_node eigrp_node = {
851 .name = "eigrp",
852 .node = EIGRP_NODE,
853 .parent_node = CONFIG_NODE,
854 .prompt = "%s(config-router)# ",
855 .config_write = eigrp_config_write,
856 };
857
858 static int eigrp_config_write(struct vty *vty)
859 {
860 const struct lyd_node *dnode;
861 int written = 0;
862
863 dnode = yang_dnode_get(running_config->dnode, "/frr-eigrpd:eigrpd");
864 if (dnode) {
865 nb_cli_show_dnode_cmds(vty, dnode, false);
866 written = 1;
867 }
868
869 return written;
870 }
871
872 void
873 eigrp_cli_init(void)
874 {
875 install_element(CONFIG_NODE, &router_eigrp_cmd);
876 install_element(CONFIG_NODE, &no_router_eigrp_cmd);
877
878 install_node(&eigrp_node);
879 install_default(EIGRP_NODE);
880
881 install_element(EIGRP_NODE, &eigrp_router_id_cmd);
882 install_element(EIGRP_NODE, &no_eigrp_router_id_cmd);
883 install_element(EIGRP_NODE, &eigrp_passive_interface_cmd);
884 install_element(EIGRP_NODE, &eigrp_timers_active_cmd);
885 install_element(EIGRP_NODE, &no_eigrp_timers_active_cmd);
886 install_element(EIGRP_NODE, &eigrp_variance_cmd);
887 install_element(EIGRP_NODE, &no_eigrp_variance_cmd);
888 install_element(EIGRP_NODE, &eigrp_maximum_paths_cmd);
889 install_element(EIGRP_NODE, &no_eigrp_maximum_paths_cmd);
890 install_element(EIGRP_NODE, &eigrp_metric_weights_cmd);
891 install_element(EIGRP_NODE, &no_eigrp_metric_weights_cmd);
892 install_element(EIGRP_NODE, &eigrp_network_cmd);
893 install_element(EIGRP_NODE, &eigrp_neighbor_cmd);
894 install_element(EIGRP_NODE, &eigrp_redistribute_source_metric_cmd);
895
896 vrf_cmd_init(NULL);
897
898 if_cmd_init_default();
899
900 install_element(INTERFACE_NODE, &eigrp_if_delay_cmd);
901 install_element(INTERFACE_NODE, &no_eigrp_if_delay_cmd);
902 install_element(INTERFACE_NODE, &eigrp_if_bandwidth_cmd);
903 install_element(INTERFACE_NODE, &no_eigrp_if_bandwidth_cmd);
904 install_element(INTERFACE_NODE, &eigrp_if_ip_hellointerval_cmd);
905 install_element(INTERFACE_NODE, &no_eigrp_if_ip_hellointerval_cmd);
906 install_element(INTERFACE_NODE, &eigrp_if_ip_holdinterval_cmd);
907 install_element(INTERFACE_NODE, &no_eigrp_if_ip_holdinterval_cmd);
908 install_element(INTERFACE_NODE, &eigrp_ip_summary_address_cmd);
909 install_element(INTERFACE_NODE, &no_eigrp_ip_summary_address_cmd);
910 install_element(INTERFACE_NODE, &eigrp_authentication_mode_cmd);
911 install_element(INTERFACE_NODE, &no_eigrp_authentication_mode_cmd);
912 install_element(INTERFACE_NODE, &eigrp_authentication_keychain_cmd);
913 install_element(INTERFACE_NODE, &no_eigrp_authentication_keychain_cmd);
914 }