]> git.proxmox.com Git - mirror_frr.git/blame - lib/routemap_cli.c
Merge pull request #13455 from sri-mohan1/srib-ldpd
[mirror_frr.git] / lib / routemap_cli.c
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
2b3e4807
RZ
2/*
3 * Route map northbound CLI implementation.
4 *
5 * Copyright (C) 2019 Network Device Education Foundation, Inc. ("NetDEF")
6 * Rafael Zalamena
2b3e4807
RZ
7 */
8
9#include <zebra.h>
10
11#include "lib/command.h"
12#include "lib/northbound_cli.h"
13#include "lib/routemap.h"
14
2b3e4807 15#include "lib/routemap_cli_clippy.c"
2b3e4807
RZ
16
17#define ROUTE_MAP_CMD_STR \
18 "Create route-map or enter route-map command mode\n" \
19 "Route map tag\n"
20#define ROUTE_MAP_OP_CMD_STR \
21 "Route map denies set operations\n" \
22 "Route map permits set operations\n"
23#define ROUTE_MAP_SEQUENCE_CMD_STR \
24 "Sequence to insert to/delete from existing route-map entry\n"
25
ca77b518 26DEFPY_YANG_NOSH(
2b3e4807 27 route_map, route_map_cmd,
8f241168 28 "route-map RMAP_NAME$name <deny|permit>$action (1-65535)$sequence",
2b3e4807
RZ
29 ROUTE_MAP_CMD_STR
30 ROUTE_MAP_OP_CMD_STR
31 ROUTE_MAP_SEQUENCE_CMD_STR)
32{
33 char xpath_action[XPATH_MAXLEN + 64];
34 char xpath_index[XPATH_MAXLEN + 32];
35 char xpath[XPATH_MAXLEN];
36 int rv;
37
38 snprintf(xpath, sizeof(xpath),
39 "/frr-route-map:lib/route-map[name='%s']", name);
40 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
41
42 snprintf(xpath_index, sizeof(xpath_index), "%s/entry[sequence='%lu']",
43 xpath, sequence);
44 nb_cli_enqueue_change(vty, xpath_index, NB_OP_CREATE, NULL);
45
46 snprintf(xpath_action, sizeof(xpath_action), "%s/action", xpath_index);
47 nb_cli_enqueue_change(vty, xpath_action, NB_OP_MODIFY, action);
48
49 rv = nb_cli_apply_changes(vty, NULL);
d5d737a2 50 if (rv == CMD_SUCCESS)
2b3e4807
RZ
51 VTY_PUSH_XPATH(RMAP_NODE, xpath_index);
52
53 return rv;
54}
55
ca77b518 56DEFPY_YANG(
2b3e4807 57 no_route_map_all, no_route_map_all_cmd,
8f241168 58 "no route-map RMAP_NAME$name",
2b3e4807
RZ
59 NO_STR
60 ROUTE_MAP_CMD_STR)
61{
62 char xpath[XPATH_MAXLEN];
63
64 snprintf(xpath, sizeof(xpath),
65 "/frr-route-map:lib/route-map[name='%s']", name);
66 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
67
68 return nb_cli_apply_changes(vty, NULL);
69}
70
ca77b518 71DEFPY_YANG(
2b3e4807 72 no_route_map, no_route_map_cmd,
8f241168 73 "no route-map RMAP_NAME$name <deny|permit>$action (1-65535)$sequence",
2b3e4807
RZ
74 NO_STR
75 ROUTE_MAP_CMD_STR
76 ROUTE_MAP_OP_CMD_STR
77 ROUTE_MAP_SEQUENCE_CMD_STR)
78{
79 char xpath[XPATH_MAXLEN];
80
81 snprintf(xpath, sizeof(xpath),
82 "/frr-route-map:lib/route-map[name='%s']/entry[sequence='%lu']",
83 name, sequence);
d5d737a2 84
2b3e4807
RZ
85 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
86
87 return nb_cli_apply_changes(vty, NULL);
88}
89
25605051
IR
90int route_map_instance_cmp(const struct lyd_node *dnode1,
91 const struct lyd_node *dnode2)
de8936be
IR
92{
93 uint16_t seq1 = yang_dnode_get_uint16(dnode1, "./sequence");
94 uint16_t seq2 = yang_dnode_get_uint16(dnode2, "./sequence");
95
96 return seq1 - seq2;
97}
98
25605051 99void route_map_instance_show(struct vty *vty, const struct lyd_node *dnode,
2b3e4807
RZ
100 bool show_defaults)
101{
102 const char *name = yang_dnode_get_string(dnode, "../name");
103 const char *action = yang_dnode_get_string(dnode, "./action");
104 const char *sequence = yang_dnode_get_string(dnode, "./sequence");
105
106 vty_out(vty, "route-map %s %s %s\n", name, action, sequence);
e324ef43 107
2b3e4807
RZ
108}
109
25605051 110void route_map_instance_show_end(struct vty *vty, const struct lyd_node *dnode)
2b3e4807 111{
07679ad9 112 vty_out(vty, "exit\n");
2b3e4807
RZ
113 vty_out(vty, "!\n");
114}
115
ca77b518 116DEFPY_YANG(
2b3e4807
RZ
117 match_interface, match_interface_cmd,
118 "match interface IFNAME",
119 MATCH_STR
120 "Match first hop interface of route\n"
121 INTERFACE_STR)
122{
d5d737a2
SP
123 const char *xpath =
124 "./match-condition[condition='frr-route-map:interface']";
2b3e4807
RZ
125 char xpath_value[XPATH_MAXLEN];
126
127 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
d5d737a2
SP
128 snprintf(xpath_value, sizeof(xpath_value),
129 "%s/rmap-match-condition/interface", xpath);
2b3e4807
RZ
130 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, ifname);
131
132 return nb_cli_apply_changes(vty, NULL);
133}
134
ca77b518 135DEFPY_YANG(
2b3e4807
RZ
136 no_match_interface, no_match_interface_cmd,
137 "no match interface [IFNAME]",
138 NO_STR
139 MATCH_STR
140 "Match first hop interface of route\n"
141 INTERFACE_STR)
142{
d5d737a2
SP
143 const char *xpath =
144 "./match-condition[condition='frr-route-map:interface']";
2b3e4807
RZ
145
146 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
147
148 return nb_cli_apply_changes(vty, NULL);
149}
150
ca77b518 151DEFPY_YANG(
2b3e4807 152 match_ip_address, match_ip_address_cmd,
c60dec36 153 "match ip address ACCESSLIST4_NAME$name",
2b3e4807
RZ
154 MATCH_STR
155 IP_STR
156 "Match address of route\n"
2b3e4807
RZ
157 "IP Access-list name\n")
158{
d5d737a2
SP
159 const char *xpath =
160 "./match-condition[condition='frr-route-map:ipv4-address-list']";
2b3e4807 161 char xpath_value[XPATH_MAXLEN + 32];
2b3e4807
RZ
162
163 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
d5d737a2
SP
164 snprintf(xpath_value, sizeof(xpath_value),
165 "%s/rmap-match-condition/list-name", xpath);
375d157f 166 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, name);
2b3e4807
RZ
167
168 return nb_cli_apply_changes(vty, NULL);
169}
170
ca77b518 171DEFPY_YANG(
2b3e4807 172 no_match_ip_address, no_match_ip_address_cmd,
c60dec36 173 "no match ip address [ACCESSLIST4_NAME]",
2b3e4807
RZ
174 NO_STR
175 MATCH_STR
176 IP_STR
177 "Match address of route\n"
2b3e4807
RZ
178 "IP Access-list name\n")
179{
d5d737a2
SP
180 const char *xpath =
181 "./match-condition[condition='frr-route-map:ipv4-address-list']";
2b3e4807
RZ
182
183 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
184
185 return nb_cli_apply_changes(vty, NULL);
186}
187
ca77b518 188DEFPY_YANG(
2b3e4807
RZ
189 match_ip_address_prefix_list,
190 match_ip_address_prefix_list_cmd,
943224a1 191 "match ip address prefix-list PREFIXLIST_NAME$name",
2b3e4807
RZ
192 MATCH_STR
193 IP_STR
194 "Match address of route\n"
195 "Match entries of prefix-lists\n"
196 "IP prefix-list name\n")
197{
d5d737a2
SP
198 const char *xpath =
199 "./match-condition[condition='frr-route-map:ipv4-prefix-list']";
2b3e4807
RZ
200 char xpath_value[XPATH_MAXLEN];
201
202 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
d5d737a2
SP
203 snprintf(xpath_value, sizeof(xpath_value),
204 "%s/rmap-match-condition/list-name", xpath);
2b3e4807
RZ
205 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, name);
206
207 return nb_cli_apply_changes(vty, NULL);
208}
209
ca77b518 210DEFPY_YANG(
2b3e4807 211 no_match_ip_address_prefix_list, no_match_ip_address_prefix_list_cmd,
943224a1 212 "no match ip address prefix-list [PREFIXLIST_NAME]",
2b3e4807
RZ
213 NO_STR
214 MATCH_STR
215 IP_STR
216 "Match address of route\n"
217 "Match entries of prefix-lists\n"
218 "IP prefix-list name\n")
219{
d5d737a2
SP
220 const char *xpath =
221 "./match-condition[condition='frr-route-map:ipv4-prefix-list']";
2b3e4807
RZ
222
223 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
224
225 return nb_cli_apply_changes(vty, NULL);
226}
227
ca77b518 228DEFPY_YANG(
2b3e4807 229 match_ip_next_hop, match_ip_next_hop_cmd,
c60dec36 230 "match ip next-hop ACCESSLIST4_NAME$name",
2b3e4807
RZ
231 MATCH_STR
232 IP_STR
233 "Match next-hop address of route\n"
2b3e4807
RZ
234 "IP Access-list name\n")
235{
d5d737a2
SP
236 const char *xpath =
237 "./match-condition[condition='frr-route-map:ipv4-next-hop-list']";
2b3e4807 238 char xpath_value[XPATH_MAXLEN + 32];
2b3e4807
RZ
239
240 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
d5d737a2
SP
241 snprintf(xpath_value, sizeof(xpath_value),
242 "%s/rmap-match-condition/list-name", xpath);
375d157f 243 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, name);
2b3e4807
RZ
244
245 return nb_cli_apply_changes(vty, NULL);
246}
247
ca77b518 248DEFPY_YANG(
2b3e4807 249 no_match_ip_next_hop, no_match_ip_next_hop_cmd,
c60dec36 250 "no match ip next-hop [ACCESSLIST4_NAME]",
2b3e4807
RZ
251 NO_STR
252 MATCH_STR
253 IP_STR
254 "Match address of route\n"
2b3e4807
RZ
255 "IP Access-list name\n")
256{
d5d737a2
SP
257 const char *xpath =
258 "./match-condition[condition='frr-route-map:ipv4-next-hop-list']";
2b3e4807
RZ
259
260 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
261
262 return nb_cli_apply_changes(vty, NULL);
263}
264
ca77b518 265DEFPY_YANG(
2b3e4807
RZ
266 match_ip_next_hop_prefix_list,
267 match_ip_next_hop_prefix_list_cmd,
943224a1 268 "match ip next-hop prefix-list PREFIXLIST_NAME$name",
2b3e4807
RZ
269 MATCH_STR
270 IP_STR
271 "Match next-hop address of route\n"
272 "Match entries of prefix-lists\n"
273 "IP prefix-list name\n")
274{
275 const char *xpath =
d5d737a2 276 "./match-condition[condition='frr-route-map:ipv4-next-hop-prefix-list']";
2b3e4807
RZ
277 char xpath_value[XPATH_MAXLEN];
278
279 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
d5d737a2
SP
280 snprintf(xpath_value, sizeof(xpath_value),
281 "%s/rmap-match-condition/list-name", xpath);
2b3e4807
RZ
282 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, name);
283
284 return nb_cli_apply_changes(vty, NULL);
285}
286
ca77b518 287DEFPY_YANG(
2b3e4807
RZ
288 no_match_ip_next_hop_prefix_list,
289 no_match_ip_next_hop_prefix_list_cmd,
943224a1 290 "no match ip next-hop prefix-list [PREFIXLIST_NAME]",
2b3e4807
RZ
291 NO_STR
292 MATCH_STR
293 IP_STR
294 "Match next-hop address of route\n"
295 "Match entries of prefix-lists\n"
296 "IP prefix-list name\n")
297{
298 const char *xpath =
d5d737a2 299 "./match-condition[condition='frr-route-map:ipv4-next-hop-prefix-list']";
2b3e4807
RZ
300
301 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
302
303 return nb_cli_apply_changes(vty, NULL);
304}
305
ca77b518 306DEFPY_YANG(
2b3e4807
RZ
307 match_ip_next_hop_type, match_ip_next_hop_type_cmd,
308 "match ip next-hop type <blackhole>$type",
309 MATCH_STR
310 IP_STR
311 "Match next-hop address of route\n"
312 "Match entries by type\n"
313 "Blackhole\n")
314{
d5d737a2
SP
315 const char *xpath =
316 "./match-condition[condition='frr-route-map:ipv4-next-hop-type']";
2b3e4807
RZ
317 char xpath_value[XPATH_MAXLEN];
318
319 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
d5d737a2
SP
320 snprintf(xpath_value, sizeof(xpath_value),
321 "%s/rmap-match-condition/ipv4-next-hop-type", xpath);
2b3e4807
RZ
322 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, type);
323
324 return nb_cli_apply_changes(vty, NULL);
325}
326
ca77b518 327DEFPY_YANG(
2b3e4807
RZ
328 no_match_ip_next_hop_type, no_match_ip_next_hop_type_cmd,
329 "no match ip next-hop type [<blackhole>]",
330 NO_STR MATCH_STR IP_STR
331 "Match next-hop address of route\n"
332 "Match entries by type\n"
333 "Blackhole\n")
334{
d5d737a2
SP
335 const char *xpath =
336 "./match-condition[condition='frr-route-map:ipv4-next-hop-type']";
2b3e4807
RZ
337
338 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
339
340 return nb_cli_apply_changes(vty, NULL);
341}
342
ca77b518 343DEFPY_YANG(
2b3e4807 344 match_ipv6_address, match_ipv6_address_cmd,
c60dec36 345 "match ipv6 address ACCESSLIST6_NAME$name",
2b3e4807
RZ
346 MATCH_STR
347 IPV6_STR
348 "Match IPv6 address of route\n"
349 "IPv6 access-list name\n")
350{
d5d737a2
SP
351 const char *xpath =
352 "./match-condition[condition='frr-route-map:ipv6-address-list']";
2b3e4807
RZ
353 char xpath_value[XPATH_MAXLEN];
354
355 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
d5d737a2
SP
356 snprintf(xpath_value, sizeof(xpath_value),
357 "%s/rmap-match-condition/list-name", xpath);
2b3e4807
RZ
358 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, name);
359
360 return nb_cli_apply_changes(vty, NULL);
361}
362
ca77b518 363DEFPY_YANG(
2b3e4807 364 no_match_ipv6_address, no_match_ipv6_address_cmd,
c60dec36 365 "no match ipv6 address [ACCESSLIST6_NAME]",
2b3e4807
RZ
366 NO_STR
367 MATCH_STR
368 IPV6_STR
369 "Match IPv6 address of route\n"
370 "IPv6 access-list name\n")
371{
d5d737a2
SP
372 const char *xpath =
373 "./match-condition[condition='frr-route-map:ipv6-address-list']";
2b3e4807
RZ
374
375 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
376
377 return nb_cli_apply_changes(vty, NULL);
378}
379
ca77b518 380DEFPY_YANG(
2b3e4807 381 match_ipv6_address_prefix_list, match_ipv6_address_prefix_list_cmd,
943224a1 382 "match ipv6 address prefix-list PREFIXLIST_NAME$name",
2b3e4807
RZ
383 MATCH_STR
384 IPV6_STR
385 "Match address of route\n"
386 "Match entries of prefix-lists\n"
387 "IP prefix-list name\n")
388{
d5d737a2
SP
389 const char *xpath =
390 "./match-condition[condition='frr-route-map:ipv6-prefix-list']";
2b3e4807
RZ
391 char xpath_value[XPATH_MAXLEN];
392
393 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
d5d737a2
SP
394 snprintf(xpath_value, sizeof(xpath_value),
395 "%s/rmap-match-condition/list-name", xpath);
2b3e4807
RZ
396 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, name);
397
398 return nb_cli_apply_changes(vty, NULL);
399}
400
ca77b518 401DEFPY_YANG(
2b3e4807
RZ
402 no_match_ipv6_address_prefix_list,
403 no_match_ipv6_address_prefix_list_cmd,
943224a1 404 "no match ipv6 address prefix-list [PREFIXLIST_NAME]",
2b3e4807
RZ
405 NO_STR
406 MATCH_STR
407 IPV6_STR
408 "Match address of route\n"
409 "Match entries of prefix-lists\n"
410 "IP prefix-list name\n")
411{
d5d737a2
SP
412 const char *xpath =
413 "./match-condition[condition='frr-route-map:ipv6-prefix-list']";
2b3e4807
RZ
414
415 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
416
417 return nb_cli_apply_changes(vty, NULL);
418}
419
ca77b518 420DEFPY_YANG(
2b3e4807
RZ
421 match_ipv6_next_hop_type, match_ipv6_next_hop_type_cmd,
422 "match ipv6 next-hop type <blackhole>$type",
423 MATCH_STR IPV6_STR
424 "Match next-hop address of route\n"
425 "Match entries by type\n"
426 "Blackhole\n")
427{
d5d737a2
SP
428 const char *xpath =
429 "./match-condition[condition='frr-route-map:ipv6-next-hop-type']";
2b3e4807
RZ
430 char xpath_value[XPATH_MAXLEN];
431
432 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
d5d737a2
SP
433 snprintf(xpath_value, sizeof(xpath_value),
434 "%s/rmap-match-condition/ipv6-next-hop-type", xpath);
2b3e4807
RZ
435 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, type);
436
437 return nb_cli_apply_changes(vty, NULL);
438}
439
ca77b518 440DEFPY_YANG(
2b3e4807
RZ
441 no_match_ipv6_next_hop_type, no_match_ipv6_next_hop_type_cmd,
442 "no match ipv6 next-hop type [<blackhole>]",
443 NO_STR MATCH_STR IPV6_STR
444 "Match address of route\n"
445 "Match entries by type\n"
446 "Blackhole\n")
447{
d5d737a2
SP
448 const char *xpath =
449 "./match-condition[condition='frr-route-map:ipv6-next-hop-type']";
2b3e4807
RZ
450
451 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
452
453 return nb_cli_apply_changes(vty, NULL);
454}
455
ca77b518 456DEFPY_YANG(
2b3e4807
RZ
457 match_metric, match_metric_cmd,
458 "match metric (0-4294967295)$metric",
459 MATCH_STR
460 "Match metric of route\n"
461 "Metric value\n")
462{
d5d737a2
SP
463 const char *xpath =
464 "./match-condition[condition='frr-route-map:match-metric']";
2b3e4807
RZ
465 char xpath_value[XPATH_MAXLEN];
466
467 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
d5d737a2
SP
468 snprintf(xpath_value, sizeof(xpath_value),
469 "%s/rmap-match-condition/metric", xpath);
2b3e4807
RZ
470 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, metric_str);
471
472 return nb_cli_apply_changes(vty, NULL);
473}
474
ca77b518 475DEFPY_YANG(
2b3e4807
RZ
476 no_match_metric, no_match_metric_cmd,
477 "no match metric [(0-4294967295)]",
478 NO_STR
479 MATCH_STR
480 "Match metric of route\n"
481 "Metric value\n")
482{
d5d737a2
SP
483 const char *xpath =
484 "./match-condition[condition='frr-route-map:match-metric']";
2b3e4807
RZ
485
486 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
487
488 return nb_cli_apply_changes(vty, NULL);
489}
490
ca77b518 491DEFPY_YANG(
2b3e4807
RZ
492 match_tag, match_tag_cmd,
493 "match tag (1-4294967295)$tag",
494 MATCH_STR
495 "Match tag of route\n"
496 "Tag value\n")
497{
d5d737a2
SP
498 const char *xpath =
499 "./match-condition[condition='frr-route-map:match-tag']";
2b3e4807
RZ
500 char xpath_value[XPATH_MAXLEN];
501
502 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
d5d737a2
SP
503 snprintf(xpath_value, sizeof(xpath_value),
504 "%s/rmap-match-condition/tag", xpath);
2b3e4807
RZ
505 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, tag_str);
506
507 return nb_cli_apply_changes(vty, NULL);
508}
509
ca77b518 510DEFPY_YANG(
2b3e4807
RZ
511 no_match_tag, no_match_tag_cmd,
512 "no match tag [(1-4294967295)]",
513 NO_STR
514 MATCH_STR
515 "Match tag of route\n"
516 "Tag value\n")
517{
d5d737a2
SP
518 const char *xpath =
519 "./match-condition[condition='frr-route-map:match-tag']";
2b3e4807
RZ
520
521 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
522
523 return nb_cli_apply_changes(vty, NULL);
524}
525
25605051 526void route_map_condition_show(struct vty *vty, const struct lyd_node *dnode,
2b3e4807
RZ
527 bool show_defaults)
528{
d5d737a2 529 const char *condition = yang_dnode_get_string(dnode, "./condition");
25605051 530 const struct lyd_node *ln;
d5d737a2 531 const char *acl;
2b3e4807 532
d5d737a2 533 if (IS_MATCH_INTERFACE(condition)) {
2b3e4807 534 vty_out(vty, " match interface %s\n",
d5d737a2
SP
535 yang_dnode_get_string(
536 dnode, "./rmap-match-condition/interface"));
fb2e99ef
IR
537 } else if (IS_MATCH_IPv4_ADDRESS_LIST(condition)) {
538 vty_out(vty, " match ip address %s\n",
539 yang_dnode_get_string(
540 dnode, "./rmap-match-condition/list-name"));
541 } else if (IS_MATCH_IPv4_NEXTHOP_LIST(condition)) {
542 vty_out(vty, " match ip next-hop %s\n",
543 yang_dnode_get_string(
544 dnode, "./rmap-match-condition/list-name"));
545 } else if (IS_MATCH_IPv6_NEXTHOP_LIST(condition)) {
546 vty_out(vty, " match ipv6 next-hop %s\n",
547 yang_dnode_get_string(
548 dnode, "./rmap-match-condition/list-name"));
d5d737a2 549 } else if (IS_MATCH_IPv4_PREFIX_LIST(condition)) {
2b3e4807 550 vty_out(vty, " match ip address prefix-list %s\n",
d5d737a2
SP
551 yang_dnode_get_string(
552 dnode, "./rmap-match-condition/list-name"));
553 } else if (IS_MATCH_IPv4_NEXTHOP_PREFIX_LIST(condition)) {
2b3e4807 554 vty_out(vty, " match ip next-hop prefix-list %s\n",
d5d737a2
SP
555 yang_dnode_get_string(
556 dnode, "./rmap-match-condition/list-name"));
82f191a2
DA
557 } else if (IS_MATCH_IPv6_NEXTHOP_PREFIX_LIST(condition)) {
558 vty_out(vty, " match ipv6 next-hop prefix-list %s\n",
559 yang_dnode_get_string(
560 dnode, "./rmap-match-condition/list-name"));
d5d737a2 561 } else if (IS_MATCH_IPv6_ADDRESS_LIST(condition)) {
2b3e4807 562 vty_out(vty, " match ipv6 address %s\n",
d5d737a2
SP
563 yang_dnode_get_string(
564 dnode, "./rmap-match-condition/list-name"));
565 } else if (IS_MATCH_IPv6_PREFIX_LIST(condition)) {
2b3e4807 566 vty_out(vty, " match ipv6 address prefix-list %s\n",
d5d737a2
SP
567 yang_dnode_get_string(
568 dnode, "./rmap-match-condition/list-name"));
569 } else if (IS_MATCH_IPv4_NEXTHOP_TYPE(condition)) {
570 vty_out(vty, " match ip next-hop type %s\n",
571 yang_dnode_get_string(
572 dnode,
573 "./rmap-match-condition/ipv4-next-hop-type"));
574 } else if (IS_MATCH_IPv6_NEXTHOP_TYPE(condition)) {
2b3e4807 575 vty_out(vty, " match ipv6 next-hop type %s\n",
d5d737a2
SP
576 yang_dnode_get_string(
577 dnode,
578 "./rmap-match-condition/ipv6-next-hop-type"));
579 } else if (IS_MATCH_METRIC(condition)) {
2b3e4807 580 vty_out(vty, " match metric %s\n",
d5d737a2
SP
581 yang_dnode_get_string(dnode,
582 "./rmap-match-condition/metric"));
583 } else if (IS_MATCH_TAG(condition)) {
2b3e4807 584 vty_out(vty, " match tag %s\n",
d5d737a2
SP
585 yang_dnode_get_string(dnode,
586 "./rmap-match-condition/tag"));
587 } else if (IS_MATCH_IPv4_PREFIX_LEN(condition)) {
f42cc965 588 vty_out(vty, " match ip address prefix-len %s\n",
d5d737a2
SP
589 yang_dnode_get_string(
590 dnode,
591 "./rmap-match-condition/frr-zebra-route-map:ipv4-prefix-length"));
592 } else if (IS_MATCH_IPv6_PREFIX_LEN(condition)) {
f42cc965 593 vty_out(vty, " match ipv6 address prefix-len %s\n",
d5d737a2
SP
594 yang_dnode_get_string(
595 dnode,
596 "./rmap-match-condition/frr-zebra-route-map:ipv6-prefix-length"));
597 } else if (IS_MATCH_IPv4_NH_PREFIX_LEN(condition)) {
f42cc965 598 vty_out(vty, " match ip next-hop prefix-len %s\n",
d5d737a2
SP
599 yang_dnode_get_string(
600 dnode,
601 "./rmap-match-condition/frr-zebra-route-map:ipv4-prefix-length"));
602 } else if (IS_MATCH_SRC_PROTO(condition)) {
f42cc965 603 vty_out(vty, " match source-protocol %s\n",
d5d737a2
SP
604 yang_dnode_get_string(
605 dnode,
606 "./rmap-match-condition/frr-zebra-route-map:source-protocol"));
607 } else if (IS_MATCH_SRC_INSTANCE(condition)) {
f42cc965 608 vty_out(vty, " match source-instance %s\n",
d5d737a2
SP
609 yang_dnode_get_string(
610 dnode,
611 "./rmap-match-condition/frr-zebra-route-map:source-instance"));
612 } else if (IS_MATCH_LOCAL_PREF(condition)) {
613 vty_out(vty, " match local-preference %s\n",
614 yang_dnode_get_string(
615 dnode,
616 "./rmap-match-condition/frr-bgp-route-map:local-preference"));
2690f18c
DA
617 } else if (IS_MATCH_ALIAS(condition)) {
618 vty_out(vty, " match alias %s\n",
619 yang_dnode_get_string(
620 dnode,
621 "./rmap-match-condition/frr-bgp-route-map:alias"));
49ecb8b8
DA
622 } else if (IS_MATCH_SCRIPT(condition)) {
623 vty_out(vty, " match script %s\n",
624 yang_dnode_get_string(
625 dnode,
626 "./rmap-match-condition/frr-bgp-route-map:script"));
d5d737a2
SP
627 } else if (IS_MATCH_ORIGIN(condition)) {
628 vty_out(vty, " match origin %s\n",
629 yang_dnode_get_string(
630 dnode,
631 "./rmap-match-condition/frr-bgp-route-map:origin"));
632 } else if (IS_MATCH_RPKI(condition)) {
633 vty_out(vty, " match rpki %s\n",
634 yang_dnode_get_string(
635 dnode,
636 "./rmap-match-condition/frr-bgp-route-map:rpki"));
324e8b1f
DA
637 } else if (IS_MATCH_RPKI_EXTCOMMUNITY(condition)) {
638 vty_out(vty, " match rpki-extcommunity %s\n",
639 yang_dnode_get_string(
640 dnode,
641 "./rmap-match-condition/frr-bgp-route-map:rpki-extcommunity"));
d5d737a2
SP
642 } else if (IS_MATCH_PROBABILITY(condition)) {
643 vty_out(vty, " match probability %s\n",
644 yang_dnode_get_string(
645 dnode,
646 "./rmap-match-condition/frr-bgp-route-map:probability"));
647 } else if (IS_MATCH_SRC_VRF(condition)) {
648 vty_out(vty, " match source-vrf %s\n",
649 yang_dnode_get_string(
650 dnode,
651 "./rmap-match-condition/frr-bgp-route-map:source-vrf"));
652 } else if (IS_MATCH_PEER(condition)) {
653 acl = NULL;
654 if ((ln = yang_dnode_get(
655 dnode,
656 "./rmap-match-condition/frr-bgp-route-map:peer-ipv4-address"))
657 != NULL)
658 acl = yang_dnode_get_string(ln, NULL);
659 else if (
660 (ln = yang_dnode_get(
661 dnode,
662 "./rmap-match-condition/frr-bgp-route-map:peer-ipv6-address"))
663 != NULL)
664 acl = yang_dnode_get_string(ln, NULL);
665 else if (
666 (ln = yang_dnode_get(
667 dnode,
668 "./rmap-match-condition/frr-bgp-route-map:peer-interface"))
669 != NULL)
670 acl = yang_dnode_get_string(ln, NULL);
671 else if (yang_dnode_get(
672 dnode,
673 "./rmap-match-condition/frr-bgp-route-map:peer-local")
674 != NULL)
675 acl = "local";
676
677 vty_out(vty, " match peer %s\n", acl);
678 } else if (IS_MATCH_AS_LIST(condition)) {
679 vty_out(vty, " match as-path %s\n",
680 yang_dnode_get_string(
681 dnode,
682 "./rmap-match-condition/frr-bgp-route-map:list-name"));
683 } else if (IS_MATCH_EVPN_ROUTE_TYPE(condition)) {
684 vty_out(vty, " match evpn route-type %s\n",
685 yang_dnode_get_string(
686 dnode,
687 "./rmap-match-condition/frr-bgp-route-map:evpn-route-type"));
688 } else if (IS_MATCH_EVPN_DEFAULT_ROUTE(condition)) {
689 vty_out(vty, " match evpn default-route\n");
690 } else if (IS_MATCH_EVPN_VNI(condition)) {
691 vty_out(vty, " match evpn vni %s\n",
692 yang_dnode_get_string(
693 dnode,
694 "./rmap-match-condition/frr-bgp-route-map:evpn-vni"));
695 } else if (IS_MATCH_EVPN_DEFAULT_ROUTE(condition)) {
696 vty_out(vty, " match evpn default-route %s\n",
697 yang_dnode_get_string(
698 dnode,
699 "./rmap-match-condition/frr-bgp-route-map:evpn-default-route"));
700 } else if (IS_MATCH_EVPN_RD(condition)) {
701 vty_out(vty, " match evpn rd %s\n",
702 yang_dnode_get_string(
703 dnode,
704 "./rmap-match-condition/frr-bgp-route-map:route-distinguisher"));
705 } else if (IS_MATCH_MAC_LIST(condition)) {
706 vty_out(vty, " match mac address %s\n",
707 yang_dnode_get_string(
708 dnode,
709 "./rmap-match-condition/frr-bgp-route-map:list-name"));
710 } else if (IS_MATCH_ROUTE_SRC(condition)) {
fb2e99ef
IR
711 vty_out(vty, " match ip route-source %s\n",
712 yang_dnode_get_string(
713 dnode,
714 "./rmap-match-condition/frr-bgp-route-map:list-name"));
d5d737a2
SP
715 } else if (IS_MATCH_ROUTE_SRC_PL(condition)) {
716 vty_out(vty, " match ip route-source prefix-list %s\n",
717 yang_dnode_get_string(
718 dnode,
719 "./rmap-match-condition/frr-bgp-route-map:list-name"));
d5d737a2 720 } else if (IS_MATCH_COMMUNITY(condition)) {
fb2e99ef
IR
721 vty_out(vty, " match community %s",
722 yang_dnode_get_string(
723 dnode,
724 "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name"));
725 if (yang_dnode_get_bool(
726 dnode,
727 "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match"))
728 vty_out(vty, " exact-match");
729 vty_out(vty, "\n");
d5d737a2 730 } else if (IS_MATCH_LCOMMUNITY(condition)) {
fb2e99ef
IR
731 vty_out(vty, " match large-community %s",
732 yang_dnode_get_string(
733 dnode,
734 "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name"));
735 if (yang_dnode_get_bool(
736 dnode,
737 "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match"))
738 vty_out(vty, " exact-match");
739 vty_out(vty, "\n");
d5d737a2 740 } else if (IS_MATCH_EXTCOMMUNITY(condition)) {
fb2e99ef
IR
741 vty_out(vty, " match extcommunity %s\n",
742 yang_dnode_get_string(
743 dnode,
744 "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name"));
d5d737a2 745 } else if (IS_MATCH_IPV4_NH(condition)) {
03030106 746 vty_out(vty, " match ip next-hop address %s\n",
d5d737a2
SP
747 yang_dnode_get_string(
748 dnode,
749 "./rmap-match-condition/frr-bgp-route-map:ipv4-address"));
750 } else if (IS_MATCH_IPV6_NH(condition)) {
03030106 751 vty_out(vty, " match ipv6 next-hop address %s\n",
d5d737a2
SP
752 yang_dnode_get_string(
753 dnode,
754 "./rmap-match-condition/frr-bgp-route-map:ipv6-address"));
2b3e4807
RZ
755 }
756}
757
ca77b518 758DEFPY_YANG(
2b3e4807
RZ
759 set_ip_nexthop, set_ip_nexthop_cmd,
760 "set ip next-hop A.B.C.D$addr",
761 SET_STR
762 IP_STR
763 "Next hop address\n"
764 "IP address of next hop\n")
765{
d5d737a2
SP
766 const char *xpath =
767 "./set-action[action='frr-route-map:ipv4-next-hop']";
2b3e4807
RZ
768 char xpath_value[XPATH_MAXLEN];
769
770 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
d5d737a2
SP
771 snprintf(xpath_value, sizeof(xpath_value),
772 "%s/rmap-set-action/ipv4-address", xpath);
2b3e4807
RZ
773 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, addr_str);
774
775 return nb_cli_apply_changes(vty, NULL);
776}
777
ca77b518 778DEFPY_YANG(
2b3e4807
RZ
779 no_set_ip_nexthop, no_set_ip_nexthop_cmd,
780 "no set ip next-hop [A.B.C.D]",
781 NO_STR
782 SET_STR
783 IP_STR
784 "Next hop address\n"
785 "IP address of next hop\n")
786{
d5d737a2
SP
787 const char *xpath =
788 "./set-action[action='frr-route-map:ipv4-next-hop']";
2b3e4807
RZ
789
790 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
791
792 return nb_cli_apply_changes(vty, NULL);
793}
794
ca77b518 795DEFPY_YANG(
2b3e4807
RZ
796 set_ipv6_nexthop_local, set_ipv6_nexthop_local_cmd,
797 "set ipv6 next-hop local X:X::X:X$addr",
798 SET_STR
799 IPV6_STR
800 "IPv6 next-hop address\n"
801 "IPv6 local address\n"
802 "IPv6 address of next hop\n")
803{
d5d737a2
SP
804 const char *xpath =
805 "./set-action[action='frr-route-map:ipv6-next-hop']";
2b3e4807
RZ
806 char xpath_value[XPATH_MAXLEN];
807
808 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
d5d737a2
SP
809 snprintf(xpath_value, sizeof(xpath_value),
810 "%s/rmap-set-action/ipv6-address", xpath);
2b3e4807
RZ
811 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, addr_str);
812
813 return nb_cli_apply_changes(vty, NULL);
814}
815
ca77b518 816DEFPY_YANG(
2b3e4807
RZ
817 no_set_ipv6_nexthop_local, no_set_ipv6_nexthop_local_cmd,
818 "no set ipv6 next-hop local [X:X::X:X]",
819 NO_STR
820 SET_STR
821 IPV6_STR
822 "IPv6 next-hop address\n"
823 "IPv6 local address\n"
824 "IPv6 address of next hop\n")
825{
d5d737a2
SP
826 const char *xpath =
827 "./set-action[action='frr-route-map:ipv6-next-hop']";
2b3e4807
RZ
828
829 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
830
831 return nb_cli_apply_changes(vty, NULL);
832}
833
ca77b518 834DEFPY_YANG(
2b3e4807 835 set_metric, set_metric_cmd,
add39cde 836 "set metric <(-4294967295-4294967295)$metric|rtt$rtt|+rtt$artt|-rtt$srtt>",
2b3e4807
RZ
837 SET_STR
838 "Metric value for destination routing protocol\n"
add39cde 839 "Metric value (use +/- for additions or subtractions)\n"
2b3e4807
RZ
840 "Assign round trip time\n"
841 "Add round trip time\n"
add39cde 842 "Subtract round trip time\n")
2b3e4807 843{
d5d737a2 844 const char *xpath = "./set-action[action='frr-route-map:set-metric']";
2b3e4807
RZ
845 char xpath_value[XPATH_MAXLEN];
846 char value[64];
847
848 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
849 if (rtt) {
850 snprintf(xpath_value, sizeof(xpath_value),
d5d737a2 851 "%s/rmap-set-action/use-round-trip-time", xpath);
2b3e4807
RZ
852 snprintf(value, sizeof(value), "true");
853 } else if (artt) {
854 snprintf(xpath_value, sizeof(xpath_value),
d5d737a2 855 "%s/rmap-set-action/add-round-trip-time", xpath);
2b3e4807
RZ
856 snprintf(value, sizeof(value), "true");
857 } else if (srtt) {
858 snprintf(xpath_value, sizeof(xpath_value),
d5d737a2 859 "%s/rmap-set-action/subtract-round-trip-time", xpath);
2b3e4807 860 snprintf(value, sizeof(value), "true");
add39cde 861 } else if (metric_str && metric_str[0] == '+') {
d5d737a2
SP
862 snprintf(xpath_value, sizeof(xpath_value),
863 "%s/rmap-set-action/add-metric", xpath);
add39cde
RW
864 snprintf(value, sizeof(value), "%s", ++metric_str);
865 } else if (metric_str && metric_str[0] == '-') {
d5d737a2
SP
866 snprintf(xpath_value, sizeof(xpath_value),
867 "%s/rmap-set-action/subtract-metric", xpath);
add39cde 868 snprintf(value, sizeof(value), "%s", ++metric_str);
2b3e4807 869 } else {
d5d737a2
SP
870 snprintf(xpath_value, sizeof(xpath_value),
871 "%s/rmap-set-action/value", xpath);
add39cde 872 snprintf(value, sizeof(value), "%s", metric_str);
2b3e4807
RZ
873 }
874 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, value);
875
876 return nb_cli_apply_changes(vty, NULL);
877}
878
ca77b518 879DEFPY_YANG(
2b3e4807 880 no_set_metric, no_set_metric_cmd,
12488d7c 881 "no set metric [OPTVAL]",
2b3e4807
RZ
882 NO_STR
883 SET_STR
884 "Metric value for destination routing protocol\n"
885 "Metric value\n")
886{
d5d737a2 887 const char *xpath = "./set-action[action='frr-route-map:set-metric']";
2b3e4807
RZ
888
889 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
890 return nb_cli_apply_changes(vty, NULL);
891}
892
055355e1
JAG
893DEFPY_YANG(set_min_metric, set_min_metric_cmd,
894 "set min-metric <(0-4294967295)$metric>",
895 SET_STR
896 "Minimum metric value for destination routing protocol\n"
897 "Minimum metric value\n")
898{
899 const char *xpath =
900 "./set-action[action='frr-route-map:set-min-metric']";
901 char xpath_value[XPATH_MAXLEN];
902 char value[64];
903
904 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
905
906 snprintf(xpath_value, sizeof(xpath_value),
907 "%s/rmap-set-action/min-metric", xpath);
908 snprintf(value, sizeof(value), "%s", metric_str);
909
910 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, value);
911
912 return nb_cli_apply_changes(vty, NULL);
913}
914
915DEFPY_YANG(no_set_min_metric, no_set_min_metric_cmd,
916 "no set min-metric [(0-4294967295)]",
917 NO_STR SET_STR
918 "Minimum metric value for destination routing protocol\n"
919 "Minumum metric value\n")
920{
921 const char *xpath =
922 "./set-action[action='frr-route-map:set-min-metric']";
923
924 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
925 return nb_cli_apply_changes(vty, NULL);
926}
927
928DEFPY_YANG(set_max_metric, set_max_metric_cmd,
929 "set max-metric <(0-4294967295)$metric>",
930 SET_STR
931 "Maximum metric value for destination routing protocol\n"
932 "Miximum metric value\n")
933{
934 const char *xpath =
935 "./set-action[action='frr-route-map:set-max-metric']";
936 char xpath_value[XPATH_MAXLEN];
937 char value[64];
938
939 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
940
941 snprintf(xpath_value, sizeof(xpath_value),
942 "%s/rmap-set-action/max-metric", xpath);
943 snprintf(value, sizeof(value), "%s", metric_str);
944
945 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, value);
946
947 return nb_cli_apply_changes(vty, NULL);
948}
949
950DEFPY_YANG(no_set_max_metric, no_set_max_metric_cmd,
951 "no set max-metric [(0-4294967295)]",
952 NO_STR SET_STR
953 "Maximum Metric value for destination routing protocol\n"
954 "Maximum metric value\n")
955{
956 const char *xpath =
957 "./set-action[action='frr-route-map:set-max-metric']";
958
959 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
960 return nb_cli_apply_changes(vty, NULL);
961}
962
ca77b518 963DEFPY_YANG(
2b3e4807
RZ
964 set_tag, set_tag_cmd,
965 "set tag (1-4294967295)$tag",
966 SET_STR
967 "Tag value for routing protocol\n"
968 "Tag value\n")
969{
d5d737a2 970 const char *xpath = "./set-action[action='frr-route-map:set-tag']";
2b3e4807
RZ
971 char xpath_value[XPATH_MAXLEN];
972
973 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
d5d737a2
SP
974 snprintf(xpath_value, sizeof(xpath_value), "%s/rmap-set-action/tag",
975 xpath);
2b3e4807
RZ
976 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, tag_str);
977
978 return nb_cli_apply_changes(vty, NULL);
979}
980
ca77b518 981DEFPY_YANG(
2b3e4807
RZ
982 no_set_tag, no_set_tag_cmd,
983 "no set tag [(1-4294967295)]",
984 NO_STR
985 SET_STR
986 "Tag value for routing protocol\n"
987 "Tag value\n")
988{
d5d737a2
SP
989 const char *xpath = "./set-action[action='frr-route-map:set-tag']";
990
991 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
992
993 return nb_cli_apply_changes(vty, NULL);
994}
995
996DEFUN_YANG (set_srte_color,
997 set_srte_color_cmd,
998 "set sr-te color (1-4294967295)",
999 SET_STR
1000 SRTE_STR
1001 SRTE_COLOR_STR
1002 "Color of the SR-TE Policies to match with\n")
1003{
1004 const char *xpath =
1005 "./set-action[action='frr-route-map:set-sr-te-color']";
1006 char xpath_value[XPATH_MAXLEN];
1007 int idx = 0;
1008
1009 char *arg = argv_find(argv, argc, "(1-4294967295)", &idx)
1010 ? argv[idx]->arg
1011 : NULL;
1012
1013 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
1014 snprintf(xpath_value, sizeof(xpath_value),
1015 "%s/rmap-set-action/policy", xpath);
1016 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, arg);
1017
1018 return nb_cli_apply_changes(vty, NULL);
1019}
1020
1021DEFUN_YANG (no_set_srte_color,
1022 no_set_srte_color_cmd,
1023 "no set sr-te color [(1-4294967295)]",
1024 NO_STR
1025 SET_STR
1026 SRTE_STR
1027 SRTE_COLOR_STR
1028 "Color of the SR-TE Policies to match with\n")
1029{
1030 const char *xpath =
1031 "./set-action[action='frr-route-map:set-sr-te-color']";
2b3e4807
RZ
1032
1033 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
1034
1035 return nb_cli_apply_changes(vty, NULL);
1036}
1037
d5d737a2 1038
25605051 1039void route_map_action_show(struct vty *vty, const struct lyd_node *dnode,
2b3e4807
RZ
1040 bool show_defaults)
1041{
d5d737a2 1042 const char *action = yang_dnode_get_string(dnode, "./action");
25605051 1043 const struct lyd_node *ln;
d5d737a2 1044 const char *acl;
2b3e4807 1045
d5d737a2 1046 if (IS_SET_IPv4_NH(action)) {
2b3e4807 1047 vty_out(vty, " set ip next-hop %s\n",
d5d737a2
SP
1048 yang_dnode_get_string(
1049 dnode, "./rmap-set-action/ipv4-address"));
1050 } else if (IS_SET_IPv6_NH(action)) {
2b3e4807 1051 vty_out(vty, " set ipv6 next-hop local %s\n",
d5d737a2
SP
1052 yang_dnode_get_string(
1053 dnode, "./rmap-set-action/ipv6-address"));
1054 } else if (IS_SET_METRIC(action)) {
1055 if (yang_dnode_get(dnode,
1056 "./rmap-set-action/use-round-trip-time")) {
2b3e4807 1057 vty_out(vty, " set metric rtt\n");
d5d737a2
SP
1058 } else if (yang_dnode_get(
1059 dnode,
1060 "./rmap-set-action/add-round-trip-time")) {
2b3e4807 1061 vty_out(vty, " set metric +rtt\n");
d5d737a2
SP
1062 } else if (
1063 yang_dnode_get(
1064 dnode,
1065 "./rmap-set-action/subtract-round-trip-time")) {
2b3e4807 1066 vty_out(vty, " set metric -rtt\n");
d5d737a2
SP
1067 } else if (yang_dnode_get(dnode,
1068 "./rmap-set-action/add-metric")) {
add39cde 1069 vty_out(vty, " set metric +%s\n",
d5d737a2
SP
1070 yang_dnode_get_string(
1071 dnode, "./rmap-set-action/add-metric"));
1072 } else if (yang_dnode_get(
1073 dnode,
1074 "./rmap-set-action/subtract-metric")) {
add39cde 1075 vty_out(vty, " set metric -%s\n",
d5d737a2
SP
1076 yang_dnode_get_string(
1077 dnode,
1078 "./rmap-set-action/subtract-metric"));
2b3e4807
RZ
1079 } else {
1080 vty_out(vty, " set metric %s\n",
d5d737a2
SP
1081 yang_dnode_get_string(
1082 dnode, "./rmap-set-action/value"));
2b3e4807 1083 }
055355e1
JAG
1084 } else if (IS_SET_MIN_METRIC(action)) {
1085 vty_out(vty, " set min-metric %s\n",
1086 yang_dnode_get_string(dnode,
1087 "./rmap-set-action/min-metric"));
1088 } else if (IS_SET_MAX_METRIC(action)) {
1089 vty_out(vty, " set max-metric %s\n",
1090 yang_dnode_get_string(dnode,
1091 "./rmap-set-action/max-metric"));
d5d737a2 1092 } else if (IS_SET_TAG(action)) {
2b3e4807 1093 vty_out(vty, " set tag %s\n",
d5d737a2
SP
1094 yang_dnode_get_string(dnode, "./rmap-set-action/tag"));
1095 } else if (IS_SET_SR_TE_COLOR(action)) {
1096 vty_out(vty, " set sr-te color %s\n",
1097 yang_dnode_get_string(dnode,
1098 "./rmap-set-action/policy"));
1099 } else if (IS_SET_SRC(action)) {
1100 if (yang_dnode_exists(
1101 dnode,
1102 "./rmap-set-action/frr-zebra-route-map:ipv4-src-address"))
f42cc965 1103 vty_out(vty, " set src %s\n",
d5d737a2
SP
1104 yang_dnode_get_string(
1105 dnode,
1106 "./rmap-set-action/frr-zebra-route-map:ipv4-src-address"));
f42cc965
RZ
1107 else
1108 vty_out(vty, " set src %s\n",
d5d737a2
SP
1109 yang_dnode_get_string(
1110 dnode,
1111 "./rmap-set-action/frr-zebra-route-map:ipv6-src-address"));
1112 } else if (IS_SET_METRIC_TYPE(action)) {
1113 vty_out(vty, " set metric-type %s\n",
1114 yang_dnode_get_string(
1115 dnode,
1116 "./rmap-set-action/frr-ospf-route-map:metric-type"));
1117 } else if (IS_SET_FORWARDING_ADDR(action)) {
1118 vty_out(vty, " set forwarding-address %s\n",
1119 yang_dnode_get_string(
1120 dnode,
1121 "./rmap-set-action/frr-ospf6-route-map:ipv6-address"));
1122 } else if (IS_SET_WEIGHT(action)) {
1123 vty_out(vty, " set weight %s\n",
1124 yang_dnode_get_string(
1125 dnode,
1126 "./rmap-set-action/frr-bgp-route-map:weight"));
1127 } else if (IS_SET_TABLE(action)) {
1128 vty_out(vty, " set table %s\n",
1129 yang_dnode_get_string(
1130 dnode,
1131 "./rmap-set-action/frr-bgp-route-map:table"));
1132 } else if (IS_SET_LOCAL_PREF(action)) {
1133 vty_out(vty, " set local-preference %s\n",
1134 yang_dnode_get_string(
1135 dnode,
1136 "./rmap-set-action/frr-bgp-route-map:local-pref"));
1137 } else if (IS_SET_LABEL_INDEX(action)) {
1138 vty_out(vty, " set label-index %s\n",
1139 yang_dnode_get_string(
1140 dnode,
1141 "./rmap-set-action/frr-bgp-route-map:label-index"));
1142 } else if (IS_SET_DISTANCE(action)) {
1143 vty_out(vty, " set distance %s\n",
1144 yang_dnode_get_string(
1145 dnode,
1146 "./rmap-set-action/frr-bgp-route-map:distance"));
1147 } else if (IS_SET_ORIGIN(action)) {
1148 vty_out(vty, " set origin %s\n",
1149 yang_dnode_get_string(
1150 dnode,
1151 "./rmap-set-action/frr-bgp-route-map:origin"));
1152 } else if (IS_SET_ATOMIC_AGGREGATE(action)) {
1153 vty_out(vty, " set atomic-aggregate\n");
97a52c82
DA
1154 } else if (IS_SET_AIGP_METRIC(action)) {
1155 vty_out(vty, " set aigp-metric %s\n",
1156 yang_dnode_get_string(
1157 dnode,
1158 "./rmap-set-action/frr-bgp-route-map:aigp-metric"));
d5d737a2
SP
1159 } else if (IS_SET_ORIGINATOR_ID(action)) {
1160 vty_out(vty, " set originator-id %s\n",
1161 yang_dnode_get_string(
1162 dnode,
1163 "./rmap-set-action/frr-bgp-route-map:originator-id"));
1164 } else if (IS_SET_COMM_LIST_DEL(action)) {
1165 acl = NULL;
1166 if ((ln = yang_dnode_get(
1167 dnode,
1168 "./rmap-set-action/frr-bgp-route-map:comm-list-name"))
1169 != NULL)
1170 acl = yang_dnode_get_string(ln, NULL);
1171
1172 assert(acl);
1173
1174 vty_out(vty, " set comm-list %s delete\n", acl);
1175 } else if (IS_SET_LCOMM_LIST_DEL(action)) {
1176 acl = NULL;
1177 if ((ln = yang_dnode_get(
1178 dnode,
1179 "./rmap-set-action/frr-bgp-route-map:comm-list-name"))
1180 != NULL)
1181 acl = yang_dnode_get_string(ln, NULL);
1182
1183 assert(acl);
1184
1185 vty_out(vty, " set large-comm-list %s delete\n", acl);
1186 } else if (IS_SET_LCOMMUNITY(action)) {
1187 if (yang_dnode_exists(
1188 dnode,
1189 "./rmap-set-action/frr-bgp-route-map:large-community-string"))
1190 vty_out(vty, " set large-community %s\n",
1191 yang_dnode_get_string(
1192 dnode,
1193 "./rmap-set-action/frr-bgp-route-map:large-community-string"));
1194 else {
1195 if (true
1196 == yang_dnode_get_bool(
1197 dnode,
1198 "./rmap-set-action/frr-bgp-route-map:large-community-none"))
1199 vty_out(vty, " set large-community none\n");
1200 }
1201 } else if (IS_SET_COMMUNITY(action)) {
1202 if (yang_dnode_exists(
1203 dnode,
1204 "./rmap-set-action/frr-bgp-route-map:community-string"))
1205 vty_out(vty, " set community %s\n",
1206 yang_dnode_get_string(
1207 dnode,
1208 "./rmap-set-action/frr-bgp-route-map:community-string"));
1209 else {
1210 if (true
1211 == yang_dnode_get_bool(
1212 dnode,
1213 "./rmap-set-action/frr-bgp-route-map:community-none"))
1214 vty_out(vty, " set community none\n");
1215 }
1216 } else if (IS_SET_EXTCOMMUNITY_RT(action)) {
1217 vty_out(vty, " set extcommunity rt %s\n",
1218 yang_dnode_get_string(
1219 dnode,
1220 "./rmap-set-action/frr-bgp-route-map:extcommunity-rt"));
c9a25614
DA
1221 } else if (IS_SET_EXTCOMMUNITY_NT(action)) {
1222 vty_out(vty, " set extcommunity nt %s\n",
1223 yang_dnode_get_string(
1224 dnode,
1225 "./rmap-set-action/frr-bgp-route-map:extcommunity-nt"));
d5d737a2
SP
1226 } else if (IS_SET_EXTCOMMUNITY_SOO(action)) {
1227 vty_out(vty, " set extcommunity soo %s\n",
1228 yang_dnode_get_string(
1229 dnode,
1230 "./rmap-set-action/frr-bgp-route-map:extcommunity-soo"));
71bdae66
DA
1231 } else if (IS_SET_EXTCOMMUNITY_LB(action)) {
1232 enum ecommunity_lb_type lb_type;
1233 char str[VTY_BUFSIZ];
1234 uint16_t bandwidth;
1235
1236 lb_type = yang_dnode_get_enum(
1237 dnode,
1238 "./rmap-set-action/frr-bgp-route-map:extcommunity-lb/lb-type");
1239 switch (lb_type) {
1240 case EXPLICIT_BANDWIDTH:
1241 bandwidth = yang_dnode_get_uint16(
1242 dnode,
1243 "./rmap-set-action/frr-bgp-route-map:extcommunity-lb/bandwidth");
1244 snprintf(str, sizeof(str), "%d", bandwidth);
1245 break;
1246 case CUMULATIVE_BANDWIDTH:
1247 snprintf(str, sizeof(str), "%s", "cumulative");
1248 break;
1249 case COMPUTED_BANDWIDTH:
1250 snprintf(str, sizeof(str), "%s", "num-multipaths");
1251 }
1252
1253 if (yang_dnode_get_bool(
1254 dnode,
1255 "./rmap-set-action/frr-bgp-route-map:extcommunity-lb/two-octet-as-specific"))
1256 strlcat(str, " non-transitive", sizeof(str));
1257
1258 vty_out(vty, " set extcommunity bandwidth %s\n", str);
bb4dcdd1
DA
1259 } else if (IS_SET_EXTCOMMUNITY_NONE(action)) {
1260 if (yang_dnode_get_bool(
1261 dnode,
1262 "./rmap-set-action/frr-bgp-route-map:extcommunity-none"))
1263 vty_out(vty, " set extcommunity none\n");
d5d737a2
SP
1264 } else if (IS_SET_AGGREGATOR(action)) {
1265 vty_out(vty, " set aggregator as %s %s\n",
1266 yang_dnode_get_string(
1267 dnode,
1268 "./rmap-set-action/frr-bgp-route-map:aggregator/aggregator-asn"),
1269 yang_dnode_get_string(
1270 dnode,
1271 "./rmap-set-action/frr-bgp-route-map:aggregator/aggregator-address"));
1272 } else if (IS_SET_AS_EXCLUDE(action)) {
1273 vty_out(vty, " set as-path exclude %s\n",
1274 yang_dnode_get_string(
1275 dnode,
1276 "./rmap-set-action/frr-bgp-route-map:exclude-as-path"));
77e3d821
DA
1277 } else if (IS_SET_AS_REPLACE(action)) {
1278 vty_out(vty, " set as-path replace %s\n",
1279 yang_dnode_get_string(
1280 dnode,
1281 "./rmap-set-action/frr-bgp-route-map:replace-as-path"));
d5d737a2
SP
1282 } else if (IS_SET_AS_PREPEND(action)) {
1283 if (yang_dnode_exists(
1284 dnode,
1285 "./rmap-set-action/frr-bgp-route-map:prepend-as-path"))
1286 vty_out(vty, " set as-path prepend %s\n",
1287 yang_dnode_get_string(
1288 dnode,
1289 "./rmap-set-action/frr-bgp-route-map:prepend-as-path"));
1290 else {
1291 vty_out(vty, " set as-path prepend last-as %u\n",
1292 yang_dnode_get_uint8(
1293 dnode,
1294 "./rmap-set-action/frr-bgp-route-map:last-as"));
1295 }
1296 } else if (IS_SET_IPV6_NH_GLOBAL(action)) {
1297 vty_out(vty, " set ipv6 next-hop global %s\n",
1298 yang_dnode_get_string(
1299 dnode,
1300 "./rmap-set-action/frr-bgp-route-map:ipv6-address"));
1301 } else if (IS_SET_IPV6_VPN_NH(action)) {
1302 vty_out(vty, " set ipv6 vpn next-hop %s\n",
1303 yang_dnode_get_string(
1304 dnode,
1305 "./rmap-set-action/frr-bgp-route-map:ipv6-address"));
1306 } else if (IS_SET_IPV6_PEER_ADDR(action)) {
1307 if (true
1308 == yang_dnode_get_bool(
1309 dnode,
1310 "./rmap-set-action/frr-bgp-route-map:preference"))
1311 vty_out(vty, " set ipv6 next-hop peer-address\n");
1312 } else if (IS_SET_IPV6_PREFER_GLOBAL(action)) {
1313 if (true
1314 == yang_dnode_get_bool(
1315 dnode,
1316 "./rmap-set-action/frr-bgp-route-map:preference"))
1317 vty_out(vty, " set ipv6 next-hop prefer-global\n");
1318 } else if (IS_SET_IPV4_VPN_NH(action)) {
1319 vty_out(vty, " set ipv4 vpn next-hop %s\n",
1320 yang_dnode_get_string(
1321 dnode,
1322 "./rmap-set-action/frr-bgp-route-map:ipv4-address"));
1323 } else if (IS_SET_BGP_IPV4_NH(action)) {
1324 vty_out(vty, " set ip next-hop %s\n",
1325 yang_dnode_get_string(
1326 dnode,
1327 "./rmap-set-action/frr-bgp-route-map:ipv4-nexthop"));
d0a4ee60
AD
1328 } else if (IS_SET_BGP_EVPN_GATEWAY_IP_IPV4(action)) {
1329 vty_out(vty, " set evpn gateway-ip ipv4 %s\n",
1330 yang_dnode_get_string(
1331 dnode,
1332 "./rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv4"));
1333 } else if (IS_SET_BGP_EVPN_GATEWAY_IP_IPV6(action)) {
1334 vty_out(vty, " set evpn gateway-ip ipv6 %s\n",
1335 yang_dnode_get_string(
1336 dnode,
1337 "./rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv6"));
1bb550b6
PG
1338 } else if (IS_SET_BGP_L3VPN_NEXTHOP_ENCAPSULATION(action)) {
1339 vty_out(vty, " set l3vpn next-hop encapsulation %s\n",
1340 yang_dnode_get_string(
1341 dnode,
1342 "./rmap-set-action/frr-bgp-route-map:l3vpn-nexthop-encapsulation"));
2b3e4807
RZ
1343 }
1344}
1345
ca77b518 1346DEFPY_YANG(
2b3e4807
RZ
1347 rmap_onmatch_next, rmap_onmatch_next_cmd,
1348 "on-match next",
1349 "Exit policy on matches\n"
1350 "Next clause\n")
1351{
1352 nb_cli_enqueue_change(vty, "./exit-policy", NB_OP_MODIFY, "next");
1353
1354 return nb_cli_apply_changes(vty, NULL);
1355}
1356
ca77b518 1357DEFPY_YANG(
2b3e4807
RZ
1358 no_rmap_onmatch_next,
1359 no_rmap_onmatch_next_cmd,
1360 "no on-match next",
1361 NO_STR
1362 "Exit policy on matches\n"
1363 "Next clause\n")
1364{
1365 nb_cli_enqueue_change(vty, "./exit-policy", NB_OP_DESTROY, NULL);
1366
1367 return nb_cli_apply_changes(vty, NULL);
1368}
1369
ca77b518 1370DEFPY_YANG(
2b3e4807
RZ
1371 rmap_onmatch_goto, rmap_onmatch_goto_cmd,
1372 "on-match goto (1-65535)$rm_num",
1373 "Exit policy on matches\n"
1374 "Goto Clause number\n"
1375 "Number\n")
1376{
1377 nb_cli_enqueue_change(vty, "./exit-policy", NB_OP_MODIFY, "goto");
1378 nb_cli_enqueue_change(vty, "./goto-value", NB_OP_MODIFY, rm_num_str);
1379
1380 return nb_cli_apply_changes(vty, NULL);
1381}
1382
ca77b518 1383DEFPY_YANG(
2b3e4807
RZ
1384 no_rmap_onmatch_goto, no_rmap_onmatch_goto_cmd,
1385 "no on-match goto",
1386 NO_STR
1387 "Exit policy on matches\n"
1388 "Goto Clause number\n")
1389{
1390 nb_cli_enqueue_change(vty, "./exit-policy", NB_OP_DESTROY, NULL);
1391
1392 return nb_cli_apply_changes(vty, NULL);
1393}
1394
1395/* Cisco/GNU Zebra compatibility aliases */
ca77b518 1396ALIAS_YANG(
2b3e4807
RZ
1397 rmap_onmatch_goto, rmap_continue_cmd,
1398 "continue (1-65535)$rm_num",
1399 "Continue on a different entry within the route-map\n"
1400 "Route-map entry sequence number\n")
1401
ca77b518 1402ALIAS_YANG(
2b3e4807
RZ
1403 no_rmap_onmatch_goto, no_rmap_continue_cmd,
1404 "no continue [(1-65535)]",
1405 NO_STR
1406 "Continue on a different entry within the route-map\n"
1407 "Route-map entry sequence number\n")
1408
25605051 1409void route_map_exit_policy_show(struct vty *vty, const struct lyd_node *dnode,
2b3e4807
RZ
1410 bool show_defaults)
1411{
1412 int exit_policy = yang_dnode_get_enum(dnode, NULL);
1413
1414 switch (exit_policy) {
1415 case 0: /* permit-or-deny */
1416 /* NOTHING: default option. */
1417 break;
1418 case 1: /* next */
1419 vty_out(vty, " on-match next\n");
1420 break;
1421 case 2: /* goto */
1422 vty_out(vty, " on-match goto %s\n",
1423 yang_dnode_get_string(dnode, "../goto-value"));
1424 break;
1425 }
1426}
1427
ca77b518 1428DEFPY_YANG(
2b3e4807
RZ
1429 rmap_call, rmap_call_cmd,
1430 "call WORD$name",
1431 "Jump to another Route-Map after match+set\n"
1432 "Target route-map name\n")
1433{
1434 nb_cli_enqueue_change(vty, "./call", NB_OP_MODIFY, name);
1435
1436 return nb_cli_apply_changes(vty, NULL);
1437}
1438
ca77b518 1439DEFPY_YANG(
2b3e4807 1440 no_rmap_call, no_rmap_call_cmd,
680b9b62 1441 "no call [NAME]",
2b3e4807 1442 NO_STR
20684537
RZ
1443 "Jump to another Route-Map after match+set\n"
1444 "Target route-map name\n")
2b3e4807
RZ
1445{
1446 nb_cli_enqueue_change(vty, "./call", NB_OP_DESTROY, NULL);
1447
1448 return nb_cli_apply_changes(vty, NULL);
1449}
1450
25605051 1451void route_map_call_show(struct vty *vty, const struct lyd_node *dnode,
2b3e4807
RZ
1452 bool show_defaults)
1453{
1454 vty_out(vty, " call %s\n", yang_dnode_get_string(dnode, NULL));
1455}
1456
ca77b518 1457DEFPY_YANG(
2b3e4807
RZ
1458 rmap_description, rmap_description_cmd,
1459 "description LINE...",
1460 "Route-map comment\n"
1461 "Comment describing this route-map rule\n")
1462{
1463 char *desc;
1464 int rv;
1465
1466 desc = argv_concat(argv, argc, 1);
1467 nb_cli_enqueue_change(vty, "./description", NB_OP_MODIFY, desc);
1468 rv = nb_cli_apply_changes(vty, NULL);
1469 XFREE(MTYPE_TMP, desc);
1470
1471 return rv;
1472}
1473
ca77b518 1474DEFUN_YANG (no_rmap_description,
2b3e4807
RZ
1475 no_rmap_description_cmd,
1476 "no description",
1477 NO_STR
1478 "Route-map comment\n")
1479{
1480 nb_cli_enqueue_change(vty, "./description", NB_OP_DESTROY, NULL);
1481
1482 return nb_cli_apply_changes(vty, NULL);
1483}
1484
25605051 1485void route_map_description_show(struct vty *vty, const struct lyd_node *dnode,
2b3e4807
RZ
1486 bool show_defaults)
1487{
1488 vty_out(vty, " description %s\n", yang_dnode_get_string(dnode, NULL));
1489}
1490
38133c4a
IR
1491DEFPY_YANG(
1492 route_map_optimization, route_map_optimization_cmd,
8f241168 1493 "[no] route-map RMAP_NAME$name optimization",
38133c4a
IR
1494 NO_STR
1495 ROUTE_MAP_CMD_STR
1496 "Configure route-map optimization\n")
1497{
1498 char xpath[XPATH_MAXLEN];
1499
1500 snprintf(xpath, sizeof(xpath),
1501 "/frr-route-map:lib/route-map[name='%s']", name);
1502 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
1503
1504 snprintf(
1505 xpath, sizeof(xpath),
1506 "/frr-route-map:lib/route-map[name='%s']/optimization-disabled",
1507 name);
1508 nb_cli_enqueue_change(vty, xpath, NB_OP_MODIFY, no ? "true" : "false");
1509
1510 return nb_cli_apply_changes(vty, NULL);
1511}
1512
1513void route_map_optimization_disabled_show(struct vty *vty,
25605051 1514 const struct lyd_node *dnode,
38133c4a
IR
1515 bool show_defaults)
1516{
1517 const char *name = yang_dnode_get_string(dnode, "../name");
1518 const bool disabled = yang_dnode_get_bool(dnode, NULL);
1519
1520 vty_out(vty, "%sroute-map %s optimization\n", disabled ? "no " : "",
1521 name);
1522}
1523
2b3e4807
RZ
1524static int route_map_config_write(struct vty *vty)
1525{
25605051 1526 const struct lyd_node *dnode;
2b3e4807
RZ
1527 int written = 0;
1528
1529 dnode = yang_dnode_get(running_config->dnode,
1530 "/frr-route-map:lib");
1531 if (dnode) {
1532 nb_cli_show_dnode_cmds(vty, dnode, false);
1533 written = 1;
1534 }
1535
1536 return written;
1537}
1538
1539/* Route map node structure. */
612c2c15 1540static int route_map_config_write(struct vty *vty);
62b346ee 1541static struct cmd_node rmap_node = {
f4b8291f 1542 .name = "routemap",
62b346ee 1543 .node = RMAP_NODE,
24389580 1544 .parent_node = CONFIG_NODE,
62b346ee 1545 .prompt = "%s(config-route-map)# ",
612c2c15 1546 .config_write = route_map_config_write,
62b346ee 1547};
2b3e4807
RZ
1548
1549static void rmap_autocomplete(vector comps, struct cmd_token *token)
1550{
1551 struct route_map *map;
1552
1553 for (map = route_map_master.head; map; map = map->next)
1554 vector_set(comps, XSTRDUP(MTYPE_COMPLETION, map->name));
1555}
1556
1557static const struct cmd_variable_handler rmap_var_handlers[] = {
1558 {.varname = "route_map", .completions = rmap_autocomplete},
1559 {.tokenname = "ROUTEMAP_NAME", .completions = rmap_autocomplete},
1560 {.tokenname = "RMAP_NAME", .completions = rmap_autocomplete},
1561 {.completions = NULL}
1562};
1563
1564void route_map_cli_init(void)
1565{
1566 /* Auto complete handler. */
1567 cmd_variable_handler_register(rmap_var_handlers);
1568
1569 /* CLI commands. */
612c2c15 1570 install_node(&rmap_node);
2b3e4807
RZ
1571 install_default(RMAP_NODE);
1572 install_element(CONFIG_NODE, &route_map_cmd);
1573 install_element(CONFIG_NODE, &no_route_map_cmd);
1574 install_element(CONFIG_NODE, &no_route_map_all_cmd);
38133c4a 1575 install_element(CONFIG_NODE, &route_map_optimization_cmd);
2b3e4807
RZ
1576
1577 /* Install the on-match stuff */
2b3e4807
RZ
1578 install_element(RMAP_NODE, &rmap_onmatch_next_cmd);
1579 install_element(RMAP_NODE, &no_rmap_onmatch_next_cmd);
1580 install_element(RMAP_NODE, &rmap_onmatch_goto_cmd);
1581 install_element(RMAP_NODE, &no_rmap_onmatch_goto_cmd);
1582 install_element(RMAP_NODE, &rmap_continue_cmd);
1583 install_element(RMAP_NODE, &no_rmap_continue_cmd);
1584
1585 /* Install the call stuff. */
1586 install_element(RMAP_NODE, &rmap_call_cmd);
1587 install_element(RMAP_NODE, &no_rmap_call_cmd);
1588
1589 /* Install description commands. */
1590 install_element(RMAP_NODE, &rmap_description_cmd);
1591 install_element(RMAP_NODE, &no_rmap_description_cmd);
1592
1593 /* Install 'match' commands. */
1594 install_element(RMAP_NODE, &match_interface_cmd);
1595 install_element(RMAP_NODE, &no_match_interface_cmd);
1596
1597 install_element(RMAP_NODE, &match_ip_address_cmd);
1598 install_element(RMAP_NODE, &no_match_ip_address_cmd);
1599
1600 install_element(RMAP_NODE, &match_ip_address_prefix_list_cmd);
1601 install_element(RMAP_NODE, &no_match_ip_address_prefix_list_cmd);
1602
1603 install_element(RMAP_NODE, &match_ip_next_hop_cmd);
1604 install_element(RMAP_NODE, &no_match_ip_next_hop_cmd);
1605
1606 install_element(RMAP_NODE, &match_ip_next_hop_prefix_list_cmd);
1607 install_element(RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd);
1608
1609 install_element(RMAP_NODE, &match_ip_next_hop_type_cmd);
1610 install_element(RMAP_NODE, &no_match_ip_next_hop_type_cmd);
1611
1612 install_element(RMAP_NODE, &match_ipv6_address_cmd);
1613 install_element(RMAP_NODE, &no_match_ipv6_address_cmd);
1614
1615 install_element(RMAP_NODE, &match_ipv6_address_prefix_list_cmd);
1616 install_element(RMAP_NODE, &no_match_ipv6_address_prefix_list_cmd);
1617
1618 install_element(RMAP_NODE, &match_ipv6_next_hop_type_cmd);
1619 install_element(RMAP_NODE, &no_match_ipv6_next_hop_type_cmd);
1620
1621 install_element(RMAP_NODE, &match_metric_cmd);
1622 install_element(RMAP_NODE, &no_match_metric_cmd);
1623
1624 install_element(RMAP_NODE, &match_tag_cmd);
1625 install_element(RMAP_NODE, &no_match_tag_cmd);
1626
1627 /* Install 'set' commands. */
1628 install_element(RMAP_NODE, &set_ip_nexthop_cmd);
1629 install_element(RMAP_NODE, &no_set_ip_nexthop_cmd);
1630
1631 install_element(RMAP_NODE, &set_ipv6_nexthop_local_cmd);
1632 install_element(RMAP_NODE, &no_set_ipv6_nexthop_local_cmd);
1633
1634 install_element(RMAP_NODE, &set_metric_cmd);
1635 install_element(RMAP_NODE, &no_set_metric_cmd);
1636
055355e1
JAG
1637 install_element(RMAP_NODE, &set_min_metric_cmd);
1638 install_element(RMAP_NODE, &no_set_min_metric_cmd);
1639
1640 install_element(RMAP_NODE, &set_max_metric_cmd);
1641 install_element(RMAP_NODE, &no_set_max_metric_cmd);
1642
2b3e4807
RZ
1643 install_element(RMAP_NODE, &set_tag_cmd);
1644 install_element(RMAP_NODE, &no_set_tag_cmd);
d5d737a2
SP
1645
1646 install_element(RMAP_NODE, &set_srte_color_cmd);
1647 install_element(RMAP_NODE, &no_set_srte_color_cmd);
2b3e4807 1648}