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