]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* Route map function. |
2 | * Copyright (C) 1998 Kunihiro Ishiguro | |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
896014f4 DL |
16 | * You should have received a copy of the GNU General Public License along |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
718e3744 | 19 | */ |
20 | ||
21 | #ifndef _ZEBRA_ROUTEMAP_H | |
22 | #define _ZEBRA_ROUTEMAP_H | |
23 | ||
88711d8a | 24 | #include "typesafe.h" |
24873f0c | 25 | #include "prefix.h" |
4a1ab8e4 | 26 | #include "memory.h" |
e80e7cce | 27 | #include "qobj.h" |
0a538fc9 | 28 | #include "vty.h" |
49a08bb0 NT |
29 | #include "lib/plist.h" |
30 | #include "lib/plist_int.h" | |
0a538fc9 | 31 | |
5e244469 RW |
32 | #ifdef __cplusplus |
33 | extern "C" { | |
34 | #endif | |
35 | ||
bf8d3d6a DL |
36 | DECLARE_MTYPE(ROUTE_MAP_NAME); |
37 | DECLARE_MTYPE(ROUTE_MAP_RULE); | |
38 | DECLARE_MTYPE(ROUTE_MAP_COMPILED); | |
24873f0c | 39 | |
1c950f37 DS |
40 | #define DEBUG_ROUTEMAP 0x01 |
41 | #define DEBUG_ROUTEMAP_DETAIL 0x02 | |
42 | extern uint32_t rmap_debug; | |
43 | ||
718e3744 | 44 | /* Route map's type. */ |
d62a17ae | 45 | enum route_map_type { RMAP_PERMIT, RMAP_DENY, RMAP_ANY }; |
46 | ||
47 | typedef enum { | |
d62a17ae | 48 | RMAP_DENYMATCH, |
b68885f9 | 49 | RMAP_PERMITMATCH |
718e3744 | 50 | } route_map_result_t; |
51 | ||
b68885f9 LK |
52 | /* |
53 | * Route-map match or set result "Eg: match evpn vni xx" | |
54 | * route-map match cmd always returns match/nomatch/noop | |
55 | * match--> found a match | |
56 | * nomatch--> didnt find a match | |
57 | * noop--> not applicable | |
58 | * route-map set retuns okay/error | |
59 | * okay --> set was successful | |
60 | * error --> set was not successful | |
61 | */ | |
62 | enum route_map_cmd_result_t { | |
63 | /* | |
64 | * route-map match cmd results | |
65 | */ | |
66 | RMAP_MATCH, | |
67 | RMAP_NOMATCH, | |
68 | RMAP_NOOP, | |
69 | /* | |
70 | * route-map set cmd results | |
71 | */ | |
72 | RMAP_OKAY, | |
73 | RMAP_ERROR | |
74 | }; | |
75 | ||
d62a17ae | 76 | typedef enum { RMAP_EXIT, RMAP_GOTO, RMAP_NEXT } route_map_end_t; |
77 | ||
78 | typedef enum { | |
79 | RMAP_EVENT_SET_ADDED, | |
80 | RMAP_EVENT_SET_DELETED, | |
81 | RMAP_EVENT_SET_REPLACED, | |
82 | RMAP_EVENT_MATCH_ADDED, | |
83 | RMAP_EVENT_MATCH_DELETED, | |
84 | RMAP_EVENT_MATCH_REPLACED, | |
85 | RMAP_EVENT_INDEX_ADDED, | |
86 | RMAP_EVENT_INDEX_DELETED, | |
87 | RMAP_EVENT_CALL_ADDED, /* call to another routemap added */ | |
88 | RMAP_EVENT_CALL_DELETED, | |
89 | RMAP_EVENT_PLIST_ADDED, | |
90 | RMAP_EVENT_PLIST_DELETED, | |
91 | RMAP_EVENT_CLIST_ADDED, | |
92 | RMAP_EVENT_CLIST_DELETED, | |
93 | RMAP_EVENT_ECLIST_ADDED, | |
94 | RMAP_EVENT_ECLIST_DELETED, | |
95 | RMAP_EVENT_LLIST_ADDED, | |
96 | RMAP_EVENT_LLIST_DELETED, | |
97 | RMAP_EVENT_ASLIST_ADDED, | |
98 | RMAP_EVENT_ASLIST_DELETED, | |
99 | RMAP_EVENT_FILTER_ADDED, | |
100 | RMAP_EVENT_FILTER_DELETED, | |
718e3744 | 101 | } route_map_event_t; |
102 | ||
fee0f4c6 | 103 | /* Depth limit in RMAP recursion using RMAP_CALL. */ |
104 | #define RMAP_RECURSION_LIMIT 10 | |
105 | ||
718e3744 | 106 | /* Route map rule structure for matching and setting. */ |
d62a17ae | 107 | struct route_map_rule_cmd { |
108 | /* Route map rule name (e.g. as-path, metric) */ | |
109 | const char *str; | |
718e3744 | 110 | |
d62a17ae | 111 | /* Function for value set or match. */ |
b68885f9 LK |
112 | enum route_map_cmd_result_t (*func_apply)(void *rule, |
113 | const struct prefix *prefix, | |
b68885f9 | 114 | void *object); |
718e3744 | 115 | |
d62a17ae | 116 | /* Compile argument and return result as void *. */ |
117 | void *(*func_compile)(const char *); | |
718e3744 | 118 | |
d62a17ae | 119 | /* Free allocated value by func_compile (). */ |
120 | void (*func_free)(void *); | |
909f3d56 | 121 | |
122 | /** To get the rule key after Compilation **/ | |
123 | void *(*func_get_rmap_rule_key)(void *val); | |
718e3744 | 124 | }; |
125 | ||
126 | /* Route map apply error. */ | |
cda7187d | 127 | enum rmap_compile_rets { |
e2c8d6ce | 128 | RMAP_COMPILE_SUCCESS, |
9ca25fed | 129 | |
e2c8d6ce NT |
130 | /* Route map rule is missing. */ |
131 | RMAP_RULE_MISSING, | |
718e3744 | 132 | |
e2c8d6ce NT |
133 | /* Route map rule can't compile */ |
134 | RMAP_COMPILE_ERROR, | |
135 | ||
e2c8d6ce | 136 | }; |
718e3744 | 137 | |
a7282663 RZ |
138 | /* Route map rule. This rule has both `match' rule and `set' rule. */ |
139 | struct route_map_rule { | |
140 | /* Rule type. */ | |
141 | const struct route_map_rule_cmd *cmd; | |
142 | ||
143 | /* For pretty printing. */ | |
144 | char *rule_str; | |
145 | ||
146 | /* Pre-compiled match rule. */ | |
147 | void *value; | |
148 | ||
149 | /* Linked list. */ | |
150 | struct route_map_rule *next; | |
151 | struct route_map_rule *prev; | |
152 | }; | |
153 | ||
718e3744 | 154 | /* Route map rule list. */ |
d62a17ae | 155 | struct route_map_rule_list { |
156 | struct route_map_rule *head; | |
157 | struct route_map_rule *tail; | |
718e3744 | 158 | }; |
159 | ||
54a35ff4 RZ |
160 | /* Forward struct declaration: the complete can be found later this file. */ |
161 | struct routemap_hook_context; | |
162 | ||
718e3744 | 163 | /* Route map index structure. */ |
d62a17ae | 164 | struct route_map_index { |
165 | struct route_map *map; | |
166 | char *description; | |
718e3744 | 167 | |
d62a17ae | 168 | /* Preference of this route map rule. */ |
169 | int pref; | |
718e3744 | 170 | |
d62a17ae | 171 | /* Route map type permit or deny. */ |
172 | enum route_map_type type; | |
718e3744 | 173 | |
d62a17ae | 174 | /* Do we follow old rules, or hop forward? */ |
175 | route_map_end_t exitpolicy; | |
718e3744 | 176 | |
d62a17ae | 177 | /* If we're using "GOTO", to where do we go? */ |
178 | int nextpref; | |
718e3744 | 179 | |
d62a17ae | 180 | /* If we're using "CALL", to which route-map do ew go? */ |
181 | char *nextrm; | |
fee0f4c6 | 182 | |
d62a17ae | 183 | /* Matching rule list. */ |
184 | struct route_map_rule_list match_list; | |
185 | struct route_map_rule_list set_list; | |
718e3744 | 186 | |
d62a17ae | 187 | /* Make linked list. */ |
188 | struct route_map_index *next; | |
189 | struct route_map_index *prev; | |
e80e7cce | 190 | |
279b0607 DS |
191 | /* Keep track how many times we've try to apply */ |
192 | uint64_t applied; | |
1fa30509 | 193 | uint64_t applied_clear; |
279b0607 | 194 | |
54a35ff4 RZ |
195 | /* List of match/sets contexts. */ |
196 | TAILQ_HEAD(, routemap_hook_context) rhclist; | |
197 | ||
96244aca | 198 | QOBJ_FIELDS; |
718e3744 | 199 | }; |
96244aca | 200 | DECLARE_QOBJ_TYPE(route_map_index); |
718e3744 | 201 | |
f71ed6df YR |
202 | /* route map maximum length. Not strictly the maximum xpath length but cannot be |
203 | * greater | |
204 | */ | |
205 | #define RMAP_NAME_MAXLEN XPATH_MAXLEN | |
206 | ||
718e3744 | 207 | /* Route map list structure. */ |
d62a17ae | 208 | struct route_map { |
209 | /* Name of route map. */ | |
210 | char *name; | |
718e3744 | 211 | |
d62a17ae | 212 | /* Route map's rule. */ |
213 | struct route_map_index *head; | |
214 | struct route_map_index *tail; | |
718e3744 | 215 | |
d62a17ae | 216 | /* Make linked list. */ |
217 | struct route_map *next; | |
218 | struct route_map *prev; | |
518f0eb1 | 219 | |
d62a17ae | 220 | /* Maintain update info */ |
e4694d0d DS |
221 | bool to_be_processed; /* True if modification isn't acted on yet */ |
222 | bool deleted; /* If 1, then this node will be deleted */ | |
49a08bb0 | 223 | bool optimization_disabled; |
e80e7cce | 224 | |
279b0607 DS |
225 | /* How many times have we applied this route-map */ |
226 | uint64_t applied; | |
1fa30509 | 227 | uint64_t applied_clear; |
279b0607 | 228 | |
4a2a09d0 | 229 | /* Counter to track active usage of this route-map */ |
230 | uint16_t use_count; | |
231 | ||
49a08bb0 NT |
232 | /* Tables to maintain IPv4 and IPv6 prefixes from |
233 | * the prefix-list match clause. | |
234 | */ | |
235 | struct route_table *ipv4_prefix_table; | |
236 | struct route_table *ipv6_prefix_table; | |
237 | ||
96244aca | 238 | QOBJ_FIELDS; |
718e3744 | 239 | }; |
96244aca | 240 | DECLARE_QOBJ_TYPE(route_map); |
718e3744 | 241 | |
d5d737a2 SP |
242 | /* Route-map match conditions */ |
243 | #define IS_MATCH_INTERFACE(C) \ | |
244 | (strmatch(C, "frr-route-map:interface")) | |
245 | #define IS_MATCH_IPv4_ADDRESS_LIST(C) \ | |
246 | (strmatch(C, "frr-route-map:ipv4-address-list")) | |
247 | #define IS_MATCH_IPv6_ADDRESS_LIST(C) \ | |
248 | (strmatch(C, "frr-route-map:ipv6-address-list")) | |
249 | #define IS_MATCH_IPv4_NEXTHOP_LIST(C) \ | |
250 | (strmatch(C, "frr-route-map:ipv4-next-hop-list")) | |
bc63ba98 DA |
251 | #define IS_MATCH_IPv6_NEXTHOP_LIST(C) \ |
252 | (strmatch(C, "frr-route-map:ipv6-next-hop-list")) | |
d5d737a2 SP |
253 | #define IS_MATCH_IPv4_PREFIX_LIST(C) \ |
254 | (strmatch(C, "frr-route-map:ipv4-prefix-list")) | |
255 | #define IS_MATCH_IPv6_PREFIX_LIST(C) \ | |
256 | (strmatch(C, "frr-route-map:ipv6-prefix-list")) | |
257 | #define IS_MATCH_IPv4_NEXTHOP_PREFIX_LIST(C) \ | |
258 | (strmatch(C, "frr-route-map:ipv4-next-hop-prefix-list")) | |
82f191a2 DA |
259 | #define IS_MATCH_IPv6_NEXTHOP_PREFIX_LIST(C) \ |
260 | (strmatch(C, "frr-route-map:ipv6-next-hop-prefix-list")) | |
d5d737a2 SP |
261 | #define IS_MATCH_IPv4_NEXTHOP_TYPE(C) \ |
262 | (strmatch(C, "frr-route-map:ipv4-next-hop-type")) | |
263 | #define IS_MATCH_IPv6_NEXTHOP_TYPE(C) \ | |
264 | (strmatch(C, "frr-route-map:ipv6-next-hop-type")) | |
265 | #define IS_MATCH_METRIC(C) \ | |
266 | (strmatch(C, "frr-route-map:match-metric")) | |
267 | #define IS_MATCH_TAG(C) (strmatch(C, "frr-route-map:match-tag")) | |
268 | /* Zebra route-map match conditions */ | |
269 | #define IS_MATCH_IPv4_PREFIX_LEN(C) \ | |
270 | (strmatch(C, "frr-zebra-route-map:ipv4-prefix-length")) | |
271 | #define IS_MATCH_IPv6_PREFIX_LEN(C) \ | |
272 | (strmatch(C, "frr-zebra-route-map:ipv6-prefix-length")) | |
273 | #define IS_MATCH_IPv4_NH_PREFIX_LEN(C) \ | |
274 | (strmatch(C, "frr-zebra-route-map:ipv4-next-hop-prefix-length")) | |
275 | #define IS_MATCH_SRC_PROTO(C) \ | |
276 | (strmatch(C, "frr-zebra-route-map:source-protocol")) | |
277 | #define IS_MATCH_SRC_INSTANCE(C) \ | |
278 | (strmatch(C, "frr-zebra-route-map:source-instance")) | |
279 | /* BGP route-map match conditions */ | |
280 | #define IS_MATCH_LOCAL_PREF(C) \ | |
281 | (strmatch(C, "frr-bgp-route-map:match-local-preference")) | |
2690f18c | 282 | #define IS_MATCH_ALIAS(C) (strmatch(C, "frr-bgp-route-map:match-alias")) |
49ecb8b8 | 283 | #define IS_MATCH_SCRIPT(C) (strmatch(C, "frr-bgp-route-map:match-script")) |
d5d737a2 SP |
284 | #define IS_MATCH_ORIGIN(C) \ |
285 | (strmatch(C, "frr-bgp-route-map:match-origin")) | |
286 | #define IS_MATCH_RPKI(C) (strmatch(C, "frr-bgp-route-map:rpki")) | |
324e8b1f DA |
287 | #define IS_MATCH_RPKI_EXTCOMMUNITY(C) \ |
288 | (strmatch(C, "frr-bgp-route-map:rpki-extcommunity")) | |
d5d737a2 SP |
289 | #define IS_MATCH_PROBABILITY(C) \ |
290 | (strmatch(C, "frr-bgp-route-map:probability")) | |
291 | #define IS_MATCH_SRC_VRF(C) \ | |
292 | (strmatch(C, "frr-bgp-route-map:source-vrf")) | |
293 | #define IS_MATCH_PEER(C) (strmatch(C, "frr-bgp-route-map:peer")) | |
294 | #define IS_MATCH_AS_LIST(C) \ | |
295 | (strmatch(C, "frr-bgp-route-map:as-path-list")) | |
296 | #define IS_MATCH_MAC_LIST(C) \ | |
297 | (strmatch(C, "frr-bgp-route-map:mac-address-list")) | |
298 | #define IS_MATCH_EVPN_ROUTE_TYPE(C) \ | |
299 | (strmatch(C, "frr-bgp-route-map:evpn-route-type")) | |
300 | #define IS_MATCH_EVPN_DEFAULT_ROUTE(C) \ | |
301 | (strmatch(C, "frr-bgp-route-map:evpn-default-route")) | |
302 | #define IS_MATCH_EVPN_VNI(C) \ | |
303 | (strmatch(C, "frr-bgp-route-map:evpn-vni")) | |
304 | #define IS_MATCH_EVPN_DEFAULT_ROUTE(C) \ | |
305 | (strmatch(C, "frr-bgp-route-map:evpn-default-route")) | |
306 | #define IS_MATCH_EVPN_RD(C) \ | |
307 | (strmatch(C, "frr-bgp-route-map:evpn-rd")) | |
308 | #define IS_MATCH_ROUTE_SRC(C) \ | |
309 | (strmatch(C, "frr-bgp-route-map:ip-route-source")) | |
310 | #define IS_MATCH_ROUTE_SRC_PL(C) \ | |
311 | (strmatch(C, "frr-bgp-route-map:ip-route-source-prefix-list")) | |
312 | #define IS_MATCH_COMMUNITY(C) \ | |
313 | (strmatch(C, "frr-bgp-route-map:match-community")) | |
314 | #define IS_MATCH_LCOMMUNITY(C) \ | |
315 | (strmatch(C, "frr-bgp-route-map:match-large-community")) | |
316 | #define IS_MATCH_EXTCOMMUNITY(C) \ | |
317 | (strmatch(C, "frr-bgp-route-map:match-extcommunity")) | |
318 | #define IS_MATCH_IPV4_NH(C) \ | |
319 | (strmatch(C, "frr-bgp-route-map:ipv4-nexthop")) | |
320 | #define IS_MATCH_IPV6_NH(C) \ | |
321 | (strmatch(C, "frr-bgp-route-map:ipv6-nexthop")) | |
322 | ||
323 | /* Route-map set actions */ | |
324 | #define IS_SET_IPv4_NH(A) \ | |
325 | (strmatch(A, "frr-route-map:ipv4-next-hop")) | |
326 | #define IS_SET_IPv6_NH(A) \ | |
327 | (strmatch(A, "frr-route-map:ipv6-next-hop")) | |
328 | #define IS_SET_METRIC(A) \ | |
329 | (strmatch(A, "frr-route-map:set-metric")) | |
330 | #define IS_SET_TAG(A) (strmatch(A, "frr-route-map:set-tag")) | |
331 | #define IS_SET_SR_TE_COLOR(A) \ | |
332 | (strmatch(A, "frr-route-map:set-sr-te-color")) | |
333 | /* Zebra route-map set actions */ | |
334 | #define IS_SET_SRC(A) \ | |
335 | (strmatch(A, "frr-zebra-route-map:src-address")) | |
336 | /* OSPF route-map set actions */ | |
337 | #define IS_SET_METRIC_TYPE(A) \ | |
338 | (strmatch(A, "frr-ospf-route-map:metric-type")) | |
339 | #define IS_SET_FORWARDING_ADDR(A) \ | |
340 | (strmatch(A, "frr-ospf6-route-map:forwarding-address")) | |
341 | /* BGP route-map_set actions */ | |
342 | #define IS_SET_WEIGHT(A) \ | |
343 | (strmatch(A, "frr-bgp-route-map:weight")) | |
344 | #define IS_SET_TABLE(A) (strmatch(A, "frr-bgp-route-map:table")) | |
345 | #define IS_SET_LOCAL_PREF(A) \ | |
346 | (strmatch(A, "frr-bgp-route-map:set-local-preference")) | |
347 | #define IS_SET_LABEL_INDEX(A) \ | |
348 | (strmatch(A, "frr-bgp-route-map:label-index")) | |
349 | #define IS_SET_DISTANCE(A) \ | |
350 | (strmatch(A, "frr-bgp-route-map:distance")) | |
351 | #define IS_SET_ORIGIN(A) \ | |
352 | (strmatch(A, "frr-bgp-route-map:set-origin")) | |
353 | #define IS_SET_ATOMIC_AGGREGATE(A) \ | |
354 | (strmatch(A, "frr-bgp-route-map:atomic-aggregate")) | |
97a52c82 | 355 | #define IS_SET_AIGP_METRIC(A) (strmatch(A, "frr-bgp-route-map:aigp-metric")) |
d5d737a2 SP |
356 | #define IS_SET_ORIGINATOR_ID(A) \ |
357 | (strmatch(A, "frr-bgp-route-map:originator-id")) | |
358 | #define IS_SET_COMM_LIST_DEL(A) \ | |
359 | (strmatch(A, "frr-bgp-route-map:comm-list-delete")) | |
360 | #define IS_SET_LCOMM_LIST_DEL(A) \ | |
361 | (strmatch(A, "frr-bgp-route-map:large-comm-list-delete")) | |
362 | #define IS_SET_LCOMMUNITY(A) \ | |
363 | (strmatch(A, "frr-bgp-route-map:set-large-community")) | |
364 | #define IS_SET_COMMUNITY(A) \ | |
365 | (strmatch(A, "frr-bgp-route-map:set-community")) | |
bb4dcdd1 DA |
366 | #define IS_SET_EXTCOMMUNITY_NONE(A) \ |
367 | (strmatch(A, "frr-bgp-route-map:set-extcommunity-none")) | |
d5d737a2 SP |
368 | #define IS_SET_EXTCOMMUNITY_RT(A) \ |
369 | (strmatch(A, "frr-bgp-route-map:set-extcommunity-rt")) | |
370 | #define IS_SET_EXTCOMMUNITY_SOO(A) \ | |
371 | (strmatch(A, "frr-bgp-route-map:set-extcommunity-soo")) | |
71bdae66 DA |
372 | #define IS_SET_EXTCOMMUNITY_LB(A) \ |
373 | (strmatch(A, "frr-bgp-route-map:set-extcommunity-lb")) | |
d5d737a2 SP |
374 | #define IS_SET_AGGREGATOR(A) \ |
375 | (strmatch(A, "frr-bgp-route-map:aggregator")) | |
376 | #define IS_SET_AS_PREPEND(A) \ | |
377 | (strmatch(A, "frr-bgp-route-map:as-path-prepend")) | |
378 | #define IS_SET_AS_EXCLUDE(A) \ | |
379 | (strmatch(A, "frr-bgp-route-map:as-path-exclude")) | |
77e3d821 | 380 | #define IS_SET_AS_REPLACE(A) (strmatch(A, "frr-bgp-route-map:as-path-replace")) |
d5d737a2 SP |
381 | #define IS_SET_IPV6_NH_GLOBAL(A) \ |
382 | (strmatch(A, "frr-bgp-route-map:ipv6-nexthop-global")) | |
383 | #define IS_SET_IPV6_VPN_NH(A) \ | |
384 | (strmatch(A, "frr-bgp-route-map:ipv6-vpn-address")) | |
385 | #define IS_SET_IPV6_PEER_ADDR(A) \ | |
386 | (strmatch(A, "frr-bgp-route-map:ipv6-peer-address")) | |
387 | #define IS_SET_IPV6_PREFER_GLOBAL(A) \ | |
388 | (strmatch(A, "frr-bgp-route-map:ipv6-prefer-global")) | |
389 | #define IS_SET_IPV4_VPN_NH(A) \ | |
390 | (strmatch(A, "frr-bgp-route-map:ipv4-vpn-address")) | |
391 | #define IS_SET_BGP_IPV4_NH(A) \ | |
392 | (strmatch(A, "frr-bgp-route-map:set-ipv4-nexthop")) | |
d0a4ee60 AD |
393 | #define IS_SET_BGP_EVPN_GATEWAY_IP_IPV4(A) \ |
394 | (strmatch(A, "frr-bgp-route-map:set-evpn-gateway-ip-ipv4")) | |
395 | #define IS_SET_BGP_EVPN_GATEWAY_IP_IPV6(A) \ | |
396 | (strmatch(A, "frr-bgp-route-map:set-evpn-gateway-ip-ipv6")) | |
1bb550b6 PG |
397 | #define IS_SET_BGP_L3VPN_NEXTHOP_ENCAPSULATION(A) \ |
398 | (strmatch(A, "frr-bgp-route-map:set-l3vpn-nexthop-encapsulation")) | |
d5d737a2 | 399 | |
14b06691 IR |
400 | enum ecommunity_lb_type { |
401 | EXPLICIT_BANDWIDTH, | |
402 | CUMULATIVE_BANDWIDTH, | |
403 | COMPUTED_BANDWIDTH | |
404 | }; | |
405 | ||
718e3744 | 406 | /* Prototypes. */ |
d62a17ae | 407 | extern void route_map_init(void); |
8619629a DS |
408 | |
409 | /* | |
410 | * This should only be called on shutdown | |
411 | * Additionally this function sets the hooks to NULL | |
412 | * before any processing is done. | |
413 | */ | |
d62a17ae | 414 | extern void route_map_finish(void); |
718e3744 | 415 | |
416 | /* Add match statement to route map. */ | |
cda7187d DS |
417 | extern enum rmap_compile_rets route_map_add_match(struct route_map_index *index, |
418 | const char *match_name, | |
419 | const char *match_arg, | |
420 | route_map_event_t type); | |
718e3744 | 421 | |
422 | /* Delete specified route match rule. */ | |
cda7187d DS |
423 | extern enum rmap_compile_rets |
424 | route_map_delete_match(struct route_map_index *index, | |
909f3d56 | 425 | const char *match_name, const char *match_arg, |
426 | route_map_event_t type); | |
718e3744 | 427 | |
d62a17ae | 428 | extern const char *route_map_get_match_arg(struct route_map_index *index, |
429 | const char *match_name); | |
518f0eb1 | 430 | |
718e3744 | 431 | /* Add route-map set statement to the route map. */ |
cda7187d DS |
432 | extern enum rmap_compile_rets route_map_add_set(struct route_map_index *index, |
433 | const char *set_name, | |
434 | const char *set_arg); | |
718e3744 | 435 | |
436 | /* Delete route map set rule. */ | |
cda7187d DS |
437 | extern enum rmap_compile_rets |
438 | route_map_delete_set(struct route_map_index *index, | |
439 | const char *set_name, const char *set_arg); | |
718e3744 | 440 | |
88711d8a DL |
441 | /* struct route_map_rule_cmd is kept const in order to not have writable |
442 | * function pointers (which is a security benefit.) Hence, below struct is | |
443 | * used as proxy for hashing these for by-name lookup. | |
444 | */ | |
445 | ||
446 | PREDECL_HASH(rmap_cmd_name); | |
447 | ||
448 | struct route_map_rule_cmd_proxy { | |
449 | struct rmap_cmd_name_item itm; | |
450 | const struct route_map_rule_cmd *cmd; | |
451 | }; | |
452 | ||
453 | /* ... and just automatically create a proxy struct for each call location | |
454 | * to route_map_install_{match,set} to avoid unnecessarily added boilerplate | |
455 | * for each route-map user | |
456 | */ | |
457 | ||
458 | #define route_map_install_match(c) \ | |
459 | do { \ | |
460 | static struct route_map_rule_cmd_proxy proxy = {.cmd = c}; \ | |
461 | _route_map_install_match(&proxy); \ | |
462 | } while (0) | |
463 | ||
464 | #define route_map_install_set(c) \ | |
465 | do { \ | |
466 | static struct route_map_rule_cmd_proxy proxy = {.cmd = c}; \ | |
467 | _route_map_install_set(&proxy); \ | |
468 | } while (0) | |
469 | ||
718e3744 | 470 | /* Install rule command to the match list. */ |
88711d8a | 471 | extern void _route_map_install_match(struct route_map_rule_cmd_proxy *proxy); |
718e3744 | 472 | |
6a74c5f9 DS |
473 | /* |
474 | * Install rule command to the set list. | |
475 | * | |
476 | * When installing a particular item, Allow a difference of handling | |
477 | * of bad cli inputted(return NULL) -vs- this particular daemon cannot use | |
478 | * this form of the command(return a pointer and handle it appropriately | |
479 | * in the apply command). See 'set metric' command | |
480 | * as it is handled in ripd/ripngd and ospfd. | |
481 | */ | |
88711d8a | 482 | extern void _route_map_install_set(struct route_map_rule_cmd_proxy *proxy); |
718e3744 | 483 | |
484 | /* Lookup route map by name. */ | |
d62a17ae | 485 | extern struct route_map *route_map_lookup_by_name(const char *name); |
718e3744 | 486 | |
1de27621 DA |
487 | /* Simple helper to warn if route-map does not exist. */ |
488 | struct route_map *route_map_lookup_warn_noexist(struct vty *vty, const char *name); | |
489 | ||
718e3744 | 490 | /* Apply route map to the object. */ |
c2125847 IR |
491 | extern route_map_result_t route_map_apply_ext(struct route_map *map, |
492 | const struct prefix *prefix, | |
493 | void *match_object, | |
a633fb57 | 494 | void *set_object, int *pref); |
c2125847 | 495 | #define route_map_apply(map, prefix, object) \ |
a633fb57 | 496 | route_map_apply_ext(map, prefix, object, object, NULL) |
d62a17ae | 497 | |
498 | extern void route_map_add_hook(void (*func)(const char *)); | |
499 | extern void route_map_delete_hook(void (*func)(const char *)); | |
097b5973 DS |
500 | |
501 | /* | |
502 | * This is the callback for when something has changed about a | |
503 | * route-map. The interested parties can register to receive | |
504 | * this data. | |
505 | * | |
506 | * name - Is the name of the changed route-map | |
507 | */ | |
508 | extern void route_map_event_hook(void (*func)(const char *name)); | |
7096e938 | 509 | extern int route_map_mark_updated(const char *name); |
46a69f10 | 510 | extern void route_map_walk_update_list(void (*update_fn)(char *name)); |
d62a17ae | 511 | extern void route_map_upd8_dependency(route_map_event_t type, const char *arg, |
512 | const char *rmap_name); | |
513 | extern void route_map_notify_dependencies(const char *affected_name, | |
514 | route_map_event_t event); | |
2d26f094 NT |
515 | extern void |
516 | route_map_notify_pentry_dependencies(const char *affected_name, | |
517 | struct prefix_list_entry *pentry, | |
518 | route_map_event_t event); | |
d5d737a2 | 519 | extern int generic_match_add(struct route_map_index *index, |
d62a17ae | 520 | const char *command, const char *arg, |
d5d737a2 SP |
521 | route_map_event_t type, |
522 | char *errmsg, size_t errmsg_len); | |
523 | extern int generic_match_delete(struct route_map_index *index, | |
d62a17ae | 524 | const char *command, const char *arg, |
d5d737a2 SP |
525 | route_map_event_t type, |
526 | char *errmsg, size_t errmsg_len); | |
527 | ||
528 | extern int generic_set_add(struct route_map_index *index, | |
529 | const char *command, const char *arg, | |
530 | char *errmsg, size_t errmsg_len); | |
531 | extern int generic_set_delete(struct route_map_index *index, | |
532 | const char *command, const char *arg, | |
533 | char *errmsg, size_t errmsg_len); | |
82f97584 DW |
534 | |
535 | ||
536 | /* match interface */ | |
d62a17ae | 537 | extern void route_map_match_interface_hook(int (*func)( |
d5d737a2 SP |
538 | struct route_map_index *index, const char *command, |
539 | const char *arg, route_map_event_t type, | |
540 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 541 | /* no match interface */ |
d62a17ae | 542 | extern void route_map_no_match_interface_hook(int (*func)( |
d5d737a2 SP |
543 | struct route_map_index *index, const char *command, |
544 | const char *arg, route_map_event_t type, | |
545 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 546 | /* match ip address */ |
d62a17ae | 547 | extern void route_map_match_ip_address_hook(int (*func)( |
d5d737a2 SP |
548 | struct route_map_index *index, const char *command, |
549 | const char *arg, route_map_event_t type, | |
550 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 551 | /* no match ip address */ |
d62a17ae | 552 | extern void route_map_no_match_ip_address_hook(int (*func)( |
d5d737a2 SP |
553 | struct route_map_index *index, const char *command, |
554 | const char *arg, route_map_event_t type, | |
555 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 556 | /* match ip address prefix list */ |
d62a17ae | 557 | extern void route_map_match_ip_address_prefix_list_hook(int (*func)( |
d5d737a2 SP |
558 | struct route_map_index *index, const char *command, |
559 | const char *arg, route_map_event_t type, | |
560 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 561 | /* no match ip address prefix list */ |
d62a17ae | 562 | extern void route_map_no_match_ip_address_prefix_list_hook(int (*func)( |
d5d737a2 SP |
563 | struct route_map_index *index, const char *command, |
564 | const char *arg, route_map_event_t type, | |
565 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 566 | /* match ip next hop */ |
d62a17ae | 567 | extern void route_map_match_ip_next_hop_hook(int (*func)( |
d5d737a2 SP |
568 | struct route_map_index *index, const char *command, |
569 | const char *arg, route_map_event_t type, | |
570 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 571 | /* no match ip next hop */ |
d62a17ae | 572 | extern void route_map_no_match_ip_next_hop_hook(int (*func)( |
bc63ba98 DA |
573 | struct route_map_index *index, const char *command, const char *arg, |
574 | route_map_event_t type, char *errmsg, size_t errmsg_len)); | |
575 | /* match ipv6 next hop */ | |
576 | extern void route_map_match_ipv6_next_hop_hook(int (*func)( | |
577 | struct route_map_index *index, const char *command, const char *arg, | |
578 | route_map_event_t type, char *errmsg, size_t errmsg_len)); | |
579 | /* no match ipv6 next hop */ | |
580 | extern void route_map_no_match_ipv6_next_hop_hook(int (*func)( | |
581 | struct route_map_index *index, const char *command, const char *arg, | |
582 | route_map_event_t type, char *errmsg, size_t errmsg_len)); | |
82f97584 | 583 | /* match ip next hop prefix list */ |
d62a17ae | 584 | extern void route_map_match_ip_next_hop_prefix_list_hook(int (*func)( |
d5d737a2 SP |
585 | struct route_map_index *index, const char *command, |
586 | const char *arg, route_map_event_t type, | |
587 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 588 | /* no match ip next hop prefix list */ |
d62a17ae | 589 | extern void route_map_no_match_ip_next_hop_prefix_list_hook(int (*func)( |
d5d737a2 SP |
590 | struct route_map_index *index, const char *command, |
591 | const char *arg, route_map_event_t type, | |
592 | char *errmsg, size_t errmsg_len)); | |
61ad901e DA |
593 | /* match ip next hop type */ |
594 | extern void route_map_match_ip_next_hop_type_hook(int (*func)( | |
d5d737a2 SP |
595 | struct route_map_index *index, const char *command, |
596 | const char *arg, route_map_event_t type, | |
597 | char *errmsg, size_t errmsg_len)); | |
61ad901e DA |
598 | /* no match ip next hop type */ |
599 | extern void route_map_no_match_ip_next_hop_type_hook(int (*func)( | |
d5d737a2 SP |
600 | struct route_map_index *index, const char *command, |
601 | const char *arg, route_map_event_t type, | |
602 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 603 | /* match ipv6 address */ |
d62a17ae | 604 | extern void route_map_match_ipv6_address_hook(int (*func)( |
d5d737a2 SP |
605 | struct route_map_index *index, const char *command, |
606 | const char *arg, route_map_event_t type, | |
607 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 608 | /* no match ipv6 address */ |
d62a17ae | 609 | extern void route_map_no_match_ipv6_address_hook(int (*func)( |
d5d737a2 SP |
610 | struct route_map_index *index, const char *command, |
611 | const char *arg, route_map_event_t type, | |
612 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 613 | /* match ipv6 address prefix list */ |
d62a17ae | 614 | extern void route_map_match_ipv6_address_prefix_list_hook(int (*func)( |
d5d737a2 SP |
615 | struct route_map_index *index, const char *command, |
616 | const char *arg, route_map_event_t type, | |
617 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 618 | /* no match ipv6 address prefix list */ |
d62a17ae | 619 | extern void route_map_no_match_ipv6_address_prefix_list_hook(int (*func)( |
d5d737a2 SP |
620 | struct route_map_index *index, const char *command, |
621 | const char *arg, route_map_event_t type, | |
622 | char *errmsg, size_t errmsg_len)); | |
61ad901e DA |
623 | /* match ipv6 next-hop type */ |
624 | extern void route_map_match_ipv6_next_hop_type_hook(int (*func)( | |
d5d737a2 SP |
625 | struct route_map_index *index, const char *command, |
626 | const char *arg, route_map_event_t type, | |
627 | char *errmsg, size_t errmsg_len)); | |
61ad901e DA |
628 | /* no match ipv6 next-hop type */ |
629 | extern void route_map_no_match_ipv6_next_hop_type_hook(int (*func)( | |
d5d737a2 SP |
630 | struct route_map_index *index, const char *command, |
631 | const char *arg, route_map_event_t type, | |
632 | char *errmsg, size_t errmsg_len)); | |
82f191a2 DA |
633 | /* match ipv6 next-hop prefix-list */ |
634 | extern void route_map_match_ipv6_next_hop_prefix_list_hook(int (*func)( | |
635 | struct route_map_index *index, const char *command, const char *arg, | |
636 | route_map_event_t type, char *errmsg, size_t errmsg_len)); | |
637 | /* no match ipv6 next-hop prefix-list */ | |
638 | extern void route_map_no_match_ipv6_next_hop_prefix_list_hook(int (*func)( | |
639 | struct route_map_index *index, const char *command, const char *arg, | |
640 | route_map_event_t type, char *errmsg, size_t errmsg_len)); | |
82f97584 | 641 | /* match metric */ |
d62a17ae | 642 | extern void route_map_match_metric_hook(int (*func)( |
d5d737a2 SP |
643 | struct route_map_index *index, const char *command, |
644 | const char *arg, route_map_event_t type, | |
645 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 646 | /* no match metric */ |
d62a17ae | 647 | extern void route_map_no_match_metric_hook(int (*func)( |
d5d737a2 SP |
648 | struct route_map_index *index, const char *command, |
649 | const char *arg, route_map_event_t type, | |
650 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 651 | /* match tag */ |
d62a17ae | 652 | extern void route_map_match_tag_hook(int (*func)( |
d5d737a2 SP |
653 | struct route_map_index *index, const char *command, |
654 | const char *arg, route_map_event_t type, | |
655 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 656 | /* no match tag */ |
d62a17ae | 657 | extern void route_map_no_match_tag_hook(int (*func)( |
d5d737a2 SP |
658 | struct route_map_index *index, const char *command, |
659 | const char *arg, route_map_event_t type, | |
660 | char *errmsg, size_t errmsg_len)); | |
31f937fb SM |
661 | /* set sr-te color */ |
662 | extern void route_map_set_srte_color_hook( | |
d5d737a2 SP |
663 | int (*func)(struct route_map_index *index, |
664 | const char *command, const char *arg, | |
665 | char *errmsg, size_t errmsg_len)); | |
31f937fb SM |
666 | /* no set sr-te color */ |
667 | extern void route_map_no_set_srte_color_hook( | |
d5d737a2 SP |
668 | int (*func)(struct route_map_index *index, |
669 | const char *command, const char *arg, | |
670 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 671 | /* set ip nexthop */ |
d62a17ae | 672 | extern void route_map_set_ip_nexthop_hook( |
d5d737a2 SP |
673 | int (*func)(struct route_map_index *index, |
674 | const char *command, const char *arg, | |
675 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 676 | /* no set ip nexthop */ |
d62a17ae | 677 | extern void route_map_no_set_ip_nexthop_hook( |
d5d737a2 SP |
678 | int (*func)(struct route_map_index *index, |
679 | const char *command, const char *arg, | |
680 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 681 | /* set ipv6 nexthop local */ |
d62a17ae | 682 | extern void route_map_set_ipv6_nexthop_local_hook( |
d5d737a2 SP |
683 | int (*func)(struct route_map_index *index, |
684 | const char *command, const char *arg, | |
685 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 686 | /* no set ipv6 nexthop local */ |
d62a17ae | 687 | extern void route_map_no_set_ipv6_nexthop_local_hook( |
d5d737a2 SP |
688 | int (*func)(struct route_map_index *index, |
689 | const char *command, const char *arg, | |
690 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 691 | /* set metric */ |
d5d737a2 | 692 | extern void route_map_set_metric_hook(int (*func)(struct route_map_index *index, |
d62a17ae | 693 | const char *command, |
d5d737a2 SP |
694 | const char *arg, |
695 | char *errmsg, | |
696 | size_t errmsg_len)); | |
82f97584 | 697 | /* no set metric */ |
d62a17ae | 698 | extern void route_map_no_set_metric_hook( |
d5d737a2 SP |
699 | int (*func)(struct route_map_index *index, |
700 | const char *command, const char *arg, | |
701 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 702 | /* set tag */ |
d5d737a2 | 703 | extern void route_map_set_tag_hook(int (*func)(struct route_map_index *index, |
d62a17ae | 704 | const char *command, |
d5d737a2 SP |
705 | const char *arg, |
706 | char *errmsg, | |
707 | size_t errmsg_len)); | |
82f97584 | 708 | /* no set tag */ |
d5d737a2 | 709 | extern void route_map_no_set_tag_hook(int (*func)(struct route_map_index *index, |
d62a17ae | 710 | const char *command, |
d5d737a2 SP |
711 | const char *arg, |
712 | char *errmsg, | |
713 | size_t errmsg_len)); | |
e52702f2 | 714 | |
d62a17ae | 715 | extern void *route_map_rule_tag_compile(const char *arg); |
716 | extern void route_map_rule_tag_free(void *rule); | |
dc9ffce8 | 717 | |
4a2a09d0 | 718 | /* Increment the route-map used counter */ |
719 | extern void route_map_counter_increment(struct route_map *map); | |
720 | ||
721 | /* Decrement the route-map used counter */ | |
722 | extern void route_map_counter_decrement(struct route_map *map); | |
723 | ||
a7282663 RZ |
724 | /* Route map hooks data structure. */ |
725 | struct route_map_match_set_hooks { | |
726 | /* match interface */ | |
d5d737a2 | 727 | int (*match_interface)(struct route_map_index *index, |
a7282663 | 728 | const char *command, const char *arg, |
d5d737a2 SP |
729 | route_map_event_t type, |
730 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
731 | |
732 | /* no match interface */ | |
d5d737a2 | 733 | int (*no_match_interface)(struct route_map_index *index, |
a7282663 | 734 | const char *command, const char *arg, |
d5d737a2 SP |
735 | route_map_event_t type, |
736 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
737 | |
738 | /* match ip address */ | |
d5d737a2 | 739 | int (*match_ip_address)(struct route_map_index *index, |
a7282663 | 740 | const char *command, const char *arg, |
d5d737a2 SP |
741 | route_map_event_t type, |
742 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
743 | |
744 | /* no match ip address */ | |
d5d737a2 | 745 | int (*no_match_ip_address)(struct route_map_index *index, |
a7282663 | 746 | const char *command, const char *arg, |
d5d737a2 SP |
747 | route_map_event_t type, |
748 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
749 | |
750 | /* match ip address prefix list */ | |
d5d737a2 | 751 | int (*match_ip_address_prefix_list)(struct route_map_index *index, |
a7282663 RZ |
752 | const char *command, |
753 | const char *arg, | |
d5d737a2 SP |
754 | route_map_event_t type, |
755 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
756 | |
757 | /* no match ip address prefix list */ | |
d5d737a2 | 758 | int (*no_match_ip_address_prefix_list)(struct route_map_index *index, |
a7282663 RZ |
759 | const char *command, |
760 | const char *arg, | |
d5d737a2 SP |
761 | route_map_event_t type, |
762 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
763 | |
764 | /* match ip next hop */ | |
d5d737a2 | 765 | int (*match_ip_next_hop)(struct route_map_index *index, |
a7282663 | 766 | const char *command, const char *arg, |
d5d737a2 SP |
767 | route_map_event_t type, |
768 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
769 | |
770 | /* no match ip next hop */ | |
d5d737a2 | 771 | int (*no_match_ip_next_hop)(struct route_map_index *index, |
a7282663 | 772 | const char *command, const char *arg, |
d5d737a2 SP |
773 | route_map_event_t type, |
774 | char *errmsg, size_t errmsg_len); | |
a7282663 | 775 | |
bc63ba98 DA |
776 | /* match ipv6 next hop */ |
777 | int (*match_ipv6_next_hop)(struct route_map_index *index, | |
778 | const char *command, const char *arg, | |
779 | route_map_event_t type, char *errmsg, | |
780 | size_t errmsg_len); | |
781 | ||
782 | /* no match ipv6 next hop */ | |
783 | int (*no_match_ipv6_next_hop)(struct route_map_index *index, | |
784 | const char *command, const char *arg, | |
785 | route_map_event_t type, char *errmsg, | |
786 | size_t errmsg_len); | |
787 | ||
82f191a2 DA |
788 | /* match ipv6 next hop prefix-list */ |
789 | int (*match_ipv6_next_hop_prefix_list)(struct route_map_index *index, | |
790 | const char *command, | |
791 | const char *arg, | |
792 | route_map_event_t type, | |
793 | char *errmsg, size_t errmsg_len); | |
794 | ||
795 | /* no match ipv6 next-hop prefix-list */ | |
796 | int (*no_match_ipv6_next_hop_prefix_list)(struct route_map_index *index, | |
797 | const char *command, | |
798 | const char *arg, | |
799 | route_map_event_t type, | |
800 | char *errmsg, | |
801 | size_t errmsg_len); | |
802 | ||
a7282663 | 803 | /* match ip next hop prefix list */ |
d5d737a2 | 804 | int (*match_ip_next_hop_prefix_list)(struct route_map_index *index, |
a7282663 RZ |
805 | const char *command, |
806 | const char *arg, | |
d5d737a2 SP |
807 | route_map_event_t type, |
808 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
809 | |
810 | /* no match ip next hop prefix list */ | |
d5d737a2 | 811 | int (*no_match_ip_next_hop_prefix_list)(struct route_map_index *index, |
a7282663 RZ |
812 | const char *command, |
813 | const char *arg, | |
d5d737a2 SP |
814 | route_map_event_t type, |
815 | char *errmsg, | |
816 | size_t errmsg_len); | |
a7282663 RZ |
817 | |
818 | /* match ip next-hop type */ | |
d5d737a2 SP |
819 | int (*match_ip_next_hop_type)(struct route_map_index *index, |
820 | const char *command, | |
821 | const char *arg, | |
822 | route_map_event_t type, | |
823 | char *errmsg, | |
824 | size_t errmsg_len); | |
a7282663 RZ |
825 | |
826 | /* no match ip next-hop type */ | |
d5d737a2 SP |
827 | int (*no_match_ip_next_hop_type)(struct route_map_index *index, |
828 | const char *command, | |
829 | const char *arg, | |
830 | route_map_event_t type, | |
831 | char *errmsg, | |
832 | size_t errmsg_len); | |
a7282663 RZ |
833 | |
834 | /* match ipv6 address */ | |
d5d737a2 | 835 | int (*match_ipv6_address)(struct route_map_index *index, |
a7282663 | 836 | const char *command, const char *arg, |
d5d737a2 SP |
837 | route_map_event_t type, |
838 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
839 | |
840 | /* no match ipv6 address */ | |
d5d737a2 | 841 | int (*no_match_ipv6_address)(struct route_map_index *index, |
a7282663 | 842 | const char *command, const char *arg, |
d5d737a2 SP |
843 | route_map_event_t type, |
844 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
845 | |
846 | ||
847 | /* match ipv6 address prefix list */ | |
d5d737a2 | 848 | int (*match_ipv6_address_prefix_list)(struct route_map_index *index, |
a7282663 RZ |
849 | const char *command, |
850 | const char *arg, | |
d5d737a2 SP |
851 | route_map_event_t type, |
852 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
853 | |
854 | /* no match ipv6 address prefix list */ | |
d5d737a2 | 855 | int (*no_match_ipv6_address_prefix_list)(struct route_map_index *index, |
a7282663 RZ |
856 | const char *command, |
857 | const char *arg, | |
d5d737a2 SP |
858 | route_map_event_t type, |
859 | char *errmsg, | |
860 | size_t errmsg_len); | |
a7282663 RZ |
861 | |
862 | /* match ipv6 next-hop type */ | |
d5d737a2 | 863 | int (*match_ipv6_next_hop_type)(struct route_map_index *index, |
a7282663 RZ |
864 | const char *command, |
865 | const char *arg, | |
d5d737a2 SP |
866 | route_map_event_t type, |
867 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
868 | |
869 | /* no match ipv6 next-hop type */ | |
d5d737a2 | 870 | int (*no_match_ipv6_next_hop_type)(struct route_map_index *index, |
a7282663 | 871 | const char *command, const char *arg, |
d5d737a2 SP |
872 | route_map_event_t type, |
873 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
874 | |
875 | /* match metric */ | |
d5d737a2 | 876 | int (*match_metric)(struct route_map_index *index, |
a7282663 | 877 | const char *command, const char *arg, |
d5d737a2 SP |
878 | route_map_event_t type, |
879 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
880 | |
881 | /* no match metric */ | |
d5d737a2 | 882 | int (*no_match_metric)(struct route_map_index *index, |
a7282663 | 883 | const char *command, const char *arg, |
d5d737a2 SP |
884 | route_map_event_t type, |
885 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
886 | |
887 | /* match tag */ | |
d5d737a2 | 888 | int (*match_tag)(struct route_map_index *index, |
a7282663 | 889 | const char *command, const char *arg, |
d5d737a2 SP |
890 | route_map_event_t type, |
891 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
892 | |
893 | /* no match tag */ | |
d5d737a2 | 894 | int (*no_match_tag)(struct route_map_index *index, |
a7282663 | 895 | const char *command, const char *arg, |
d5d737a2 SP |
896 | route_map_event_t type, |
897 | char *errmsg, size_t errmsg_len); | |
a7282663 | 898 | |
31f937fb | 899 | /* set sr-te color */ |
d5d737a2 SP |
900 | int (*set_srte_color)(struct route_map_index *index, |
901 | const char *command, const char *arg, | |
902 | char *errmsg, size_t errmsg_len); | |
31f937fb SM |
903 | |
904 | /* no set sr-te color */ | |
d5d737a2 SP |
905 | int (*no_set_srte_color)(struct route_map_index *index, |
906 | const char *command, const char *arg, | |
907 | char *errmsg, size_t errmsg_len); | |
31f937fb | 908 | |
a7282663 | 909 | /* set ip nexthop */ |
d5d737a2 SP |
910 | int (*set_ip_nexthop)(struct route_map_index *index, |
911 | const char *command, const char *arg, | |
912 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
913 | |
914 | /* no set ip nexthop */ | |
d5d737a2 SP |
915 | int (*no_set_ip_nexthop)(struct route_map_index *index, |
916 | const char *command, const char *arg, | |
917 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
918 | |
919 | /* set ipv6 nexthop local */ | |
d5d737a2 SP |
920 | int (*set_ipv6_nexthop_local)(struct route_map_index *index, |
921 | const char *command, const char *arg, | |
922 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
923 | |
924 | /* no set ipv6 nexthop local */ | |
d5d737a2 SP |
925 | int (*no_set_ipv6_nexthop_local)(struct route_map_index *index, |
926 | const char *command, const char *arg, | |
927 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
928 | |
929 | /* set metric */ | |
d5d737a2 SP |
930 | int (*set_metric)(struct route_map_index *index, |
931 | const char *command, const char *arg, | |
932 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
933 | |
934 | /* no set metric */ | |
d5d737a2 SP |
935 | int (*no_set_metric)(struct route_map_index *index, |
936 | const char *command, const char *arg, | |
937 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
938 | |
939 | /* set tag */ | |
d5d737a2 SP |
940 | int (*set_tag)(struct route_map_index *index, |
941 | const char *command, const char *arg, | |
942 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
943 | |
944 | /* no set tag */ | |
d5d737a2 SP |
945 | int (*no_set_tag)(struct route_map_index *index, |
946 | const char *command, const char *arg, | |
947 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
948 | }; |
949 | ||
950 | extern struct route_map_match_set_hooks rmap_match_set_hook; | |
951 | ||
952 | /* Making route map list. */ | |
953 | struct route_map_list { | |
954 | struct route_map *head; | |
955 | struct route_map *tail; | |
956 | ||
957 | void (*add_hook)(const char *); | |
958 | void (*delete_hook)(const char *); | |
959 | void (*event_hook)(const char *); | |
960 | }; | |
961 | ||
962 | extern struct route_map_list route_map_master; | |
963 | ||
964 | extern struct route_map *route_map_get(const char *name); | |
965 | extern void route_map_delete(struct route_map *map); | |
966 | extern struct route_map_index *route_map_index_get(struct route_map *map, | |
967 | enum route_map_type type, | |
968 | int pref); | |
969 | extern void route_map_index_delete(struct route_map_index *index, int notify); | |
970 | ||
686d244f | 971 | /* routemap_northbound.c */ |
d5d737a2 | 972 | typedef int (*routemap_match_hook_fun)(struct route_map_index *rmi, |
686d244f | 973 | const char *command, const char *arg, |
d5d737a2 SP |
974 | route_map_event_t event, |
975 | char *errmsg, size_t errmsg_len); | |
976 | typedef int (*routemap_set_hook_fun)(struct route_map_index *rmi, | |
977 | const char *command, const char *arg, | |
978 | char *errmsg, size_t errmsg_len); | |
686d244f RZ |
979 | struct routemap_hook_context { |
980 | struct route_map_index *rhc_rmi; | |
981 | const char *rhc_rule; | |
982 | route_map_event_t rhc_event; | |
983 | routemap_set_hook_fun rhc_shook; | |
984 | routemap_match_hook_fun rhc_mhook; | |
54a35ff4 | 985 | TAILQ_ENTRY(routemap_hook_context) rhc_entry; |
686d244f RZ |
986 | }; |
987 | ||
60ee8be1 RW |
988 | int lib_route_map_entry_match_destroy(struct nb_cb_destroy_args *args); |
989 | int lib_route_map_entry_set_destroy(struct nb_cb_destroy_args *args); | |
2b3e4807 | 990 | |
54a35ff4 RZ |
991 | struct routemap_hook_context * |
992 | routemap_hook_context_insert(struct route_map_index *rmi); | |
993 | void routemap_hook_context_free(struct routemap_hook_context *rhc); | |
994 | ||
686d244f RZ |
995 | extern const struct frr_yang_module_info frr_route_map_info; |
996 | ||
2b3e4807 | 997 | /* routemap_cli.c */ |
25605051 IR |
998 | extern int route_map_instance_cmp(const struct lyd_node *dnode1, |
999 | const struct lyd_node *dnode2); | |
1000 | extern void route_map_instance_show(struct vty *vty, | |
1001 | const struct lyd_node *dnode, | |
2b3e4807 RZ |
1002 | bool show_defaults); |
1003 | extern void route_map_instance_show_end(struct vty *vty, | |
25605051 IR |
1004 | const struct lyd_node *dnode); |
1005 | extern void route_map_condition_show(struct vty *vty, | |
1006 | const struct lyd_node *dnode, | |
2b3e4807 | 1007 | bool show_defaults); |
25605051 | 1008 | extern void route_map_action_show(struct vty *vty, const struct lyd_node *dnode, |
2b3e4807 | 1009 | bool show_defaults); |
25605051 IR |
1010 | extern void route_map_exit_policy_show(struct vty *vty, |
1011 | const struct lyd_node *dnode, | |
2b3e4807 | 1012 | bool show_defaults); |
25605051 | 1013 | extern void route_map_call_show(struct vty *vty, const struct lyd_node *dnode, |
2b3e4807 RZ |
1014 | bool show_defaults); |
1015 | extern void route_map_description_show(struct vty *vty, | |
25605051 | 1016 | const struct lyd_node *dnode, |
2b3e4807 | 1017 | bool show_defaults); |
38133c4a | 1018 | extern void route_map_optimization_disabled_show(struct vty *vty, |
25605051 | 1019 | const struct lyd_node *dnode, |
38133c4a | 1020 | bool show_defaults); |
2b3e4807 RZ |
1021 | extern void route_map_cli_init(void); |
1022 | ||
cf00164b DS |
1023 | extern void route_map_show_debug(struct vty *vty); |
1024 | ||
5e244469 RW |
1025 | #ifdef __cplusplus |
1026 | } | |
1027 | #endif | |
1028 | ||
718e3744 | 1029 | #endif /* _ZEBRA_ROUTEMAP_H */ |