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