]>
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")) | |
d5d737a2 | 390 | |
14b06691 IR |
391 | enum ecommunity_lb_type { |
392 | EXPLICIT_BANDWIDTH, | |
393 | CUMULATIVE_BANDWIDTH, | |
394 | COMPUTED_BANDWIDTH | |
395 | }; | |
396 | ||
718e3744 | 397 | /* Prototypes. */ |
d62a17ae | 398 | extern void route_map_init(void); |
8619629a DS |
399 | |
400 | /* | |
401 | * This should only be called on shutdown | |
402 | * Additionally this function sets the hooks to NULL | |
403 | * before any processing is done. | |
404 | */ | |
d62a17ae | 405 | extern void route_map_finish(void); |
718e3744 | 406 | |
407 | /* Add match statement to route map. */ | |
cda7187d DS |
408 | extern enum rmap_compile_rets route_map_add_match(struct route_map_index *index, |
409 | const char *match_name, | |
410 | const char *match_arg, | |
411 | route_map_event_t type); | |
718e3744 | 412 | |
413 | /* Delete specified route match rule. */ | |
cda7187d DS |
414 | extern enum rmap_compile_rets |
415 | route_map_delete_match(struct route_map_index *index, | |
909f3d56 | 416 | const char *match_name, const char *match_arg, |
417 | route_map_event_t type); | |
718e3744 | 418 | |
d62a17ae | 419 | extern const char *route_map_get_match_arg(struct route_map_index *index, |
420 | const char *match_name); | |
518f0eb1 | 421 | |
718e3744 | 422 | /* Add route-map set statement to the route map. */ |
cda7187d DS |
423 | extern enum rmap_compile_rets route_map_add_set(struct route_map_index *index, |
424 | const char *set_name, | |
425 | const char *set_arg); | |
718e3744 | 426 | |
427 | /* Delete route map set rule. */ | |
cda7187d DS |
428 | extern enum rmap_compile_rets |
429 | route_map_delete_set(struct route_map_index *index, | |
430 | const char *set_name, const char *set_arg); | |
718e3744 | 431 | |
88711d8a DL |
432 | /* struct route_map_rule_cmd is kept const in order to not have writable |
433 | * function pointers (which is a security benefit.) Hence, below struct is | |
434 | * used as proxy for hashing these for by-name lookup. | |
435 | */ | |
436 | ||
437 | PREDECL_HASH(rmap_cmd_name); | |
438 | ||
439 | struct route_map_rule_cmd_proxy { | |
440 | struct rmap_cmd_name_item itm; | |
441 | const struct route_map_rule_cmd *cmd; | |
442 | }; | |
443 | ||
444 | /* ... and just automatically create a proxy struct for each call location | |
445 | * to route_map_install_{match,set} to avoid unnecessarily added boilerplate | |
446 | * for each route-map user | |
447 | */ | |
448 | ||
449 | #define route_map_install_match(c) \ | |
450 | do { \ | |
451 | static struct route_map_rule_cmd_proxy proxy = {.cmd = c}; \ | |
452 | _route_map_install_match(&proxy); \ | |
453 | } while (0) | |
454 | ||
455 | #define route_map_install_set(c) \ | |
456 | do { \ | |
457 | static struct route_map_rule_cmd_proxy proxy = {.cmd = c}; \ | |
458 | _route_map_install_set(&proxy); \ | |
459 | } while (0) | |
460 | ||
718e3744 | 461 | /* Install rule command to the match list. */ |
88711d8a | 462 | extern void _route_map_install_match(struct route_map_rule_cmd_proxy *proxy); |
718e3744 | 463 | |
6a74c5f9 DS |
464 | /* |
465 | * Install rule command to the set list. | |
466 | * | |
467 | * When installing a particular item, Allow a difference of handling | |
468 | * of bad cli inputted(return NULL) -vs- this particular daemon cannot use | |
469 | * this form of the command(return a pointer and handle it appropriately | |
470 | * in the apply command). See 'set metric' command | |
471 | * as it is handled in ripd/ripngd and ospfd. | |
472 | */ | |
88711d8a | 473 | extern void _route_map_install_set(struct route_map_rule_cmd_proxy *proxy); |
718e3744 | 474 | |
475 | /* Lookup route map by name. */ | |
d62a17ae | 476 | extern struct route_map *route_map_lookup_by_name(const char *name); |
718e3744 | 477 | |
1de27621 DA |
478 | /* Simple helper to warn if route-map does not exist. */ |
479 | struct route_map *route_map_lookup_warn_noexist(struct vty *vty, const char *name); | |
480 | ||
718e3744 | 481 | /* Apply route map to the object. */ |
c2125847 IR |
482 | extern route_map_result_t route_map_apply_ext(struct route_map *map, |
483 | const struct prefix *prefix, | |
484 | void *match_object, | |
485 | void *set_object); | |
486 | #define route_map_apply(map, prefix, object) \ | |
487 | route_map_apply_ext(map, prefix, object, object) | |
d62a17ae | 488 | |
489 | extern void route_map_add_hook(void (*func)(const char *)); | |
490 | extern void route_map_delete_hook(void (*func)(const char *)); | |
097b5973 DS |
491 | |
492 | /* | |
493 | * This is the callback for when something has changed about a | |
494 | * route-map. The interested parties can register to receive | |
495 | * this data. | |
496 | * | |
497 | * name - Is the name of the changed route-map | |
498 | */ | |
499 | extern void route_map_event_hook(void (*func)(const char *name)); | |
7096e938 | 500 | extern int route_map_mark_updated(const char *name); |
46a69f10 | 501 | extern void route_map_walk_update_list(void (*update_fn)(char *name)); |
d62a17ae | 502 | extern void route_map_upd8_dependency(route_map_event_t type, const char *arg, |
503 | const char *rmap_name); | |
504 | extern void route_map_notify_dependencies(const char *affected_name, | |
505 | route_map_event_t event); | |
2d26f094 NT |
506 | extern void |
507 | route_map_notify_pentry_dependencies(const char *affected_name, | |
508 | struct prefix_list_entry *pentry, | |
509 | route_map_event_t event); | |
d5d737a2 | 510 | extern int generic_match_add(struct route_map_index *index, |
d62a17ae | 511 | const char *command, const char *arg, |
d5d737a2 SP |
512 | route_map_event_t type, |
513 | char *errmsg, size_t errmsg_len); | |
514 | extern int generic_match_delete(struct route_map_index *index, | |
d62a17ae | 515 | const char *command, const char *arg, |
d5d737a2 SP |
516 | route_map_event_t type, |
517 | char *errmsg, size_t errmsg_len); | |
518 | ||
519 | extern int generic_set_add(struct route_map_index *index, | |
520 | const char *command, const char *arg, | |
521 | char *errmsg, size_t errmsg_len); | |
522 | extern int generic_set_delete(struct route_map_index *index, | |
523 | const char *command, const char *arg, | |
524 | char *errmsg, size_t errmsg_len); | |
82f97584 DW |
525 | |
526 | ||
527 | /* match interface */ | |
d62a17ae | 528 | extern void route_map_match_interface_hook(int (*func)( |
d5d737a2 SP |
529 | struct route_map_index *index, const char *command, |
530 | const char *arg, route_map_event_t type, | |
531 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 532 | /* no match interface */ |
d62a17ae | 533 | extern void route_map_no_match_interface_hook(int (*func)( |
d5d737a2 SP |
534 | struct route_map_index *index, const char *command, |
535 | const char *arg, route_map_event_t type, | |
536 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 537 | /* match ip address */ |
d62a17ae | 538 | extern void route_map_match_ip_address_hook(int (*func)( |
d5d737a2 SP |
539 | struct route_map_index *index, const char *command, |
540 | const char *arg, route_map_event_t type, | |
541 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 542 | /* no match ip address */ |
d62a17ae | 543 | extern void route_map_no_match_ip_address_hook(int (*func)( |
d5d737a2 SP |
544 | struct route_map_index *index, const char *command, |
545 | const char *arg, route_map_event_t type, | |
546 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 547 | /* match ip address prefix list */ |
d62a17ae | 548 | extern void route_map_match_ip_address_prefix_list_hook(int (*func)( |
d5d737a2 SP |
549 | struct route_map_index *index, const char *command, |
550 | const char *arg, route_map_event_t type, | |
551 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 552 | /* no match ip address prefix list */ |
d62a17ae | 553 | extern void route_map_no_match_ip_address_prefix_list_hook(int (*func)( |
d5d737a2 SP |
554 | struct route_map_index *index, const char *command, |
555 | const char *arg, route_map_event_t type, | |
556 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 557 | /* match ip next hop */ |
d62a17ae | 558 | extern void route_map_match_ip_next_hop_hook(int (*func)( |
d5d737a2 SP |
559 | struct route_map_index *index, const char *command, |
560 | const char *arg, route_map_event_t type, | |
561 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 562 | /* no match ip next hop */ |
d62a17ae | 563 | extern void route_map_no_match_ip_next_hop_hook(int (*func)( |
bc63ba98 DA |
564 | struct route_map_index *index, const char *command, const char *arg, |
565 | route_map_event_t type, char *errmsg, size_t errmsg_len)); | |
566 | /* match ipv6 next hop */ | |
567 | extern void route_map_match_ipv6_next_hop_hook(int (*func)( | |
568 | struct route_map_index *index, const char *command, const char *arg, | |
569 | route_map_event_t type, char *errmsg, size_t errmsg_len)); | |
570 | /* no match ipv6 next hop */ | |
571 | extern void route_map_no_match_ipv6_next_hop_hook(int (*func)( | |
572 | struct route_map_index *index, const char *command, const char *arg, | |
573 | route_map_event_t type, char *errmsg, size_t errmsg_len)); | |
82f97584 | 574 | /* match ip next hop prefix list */ |
d62a17ae | 575 | extern void route_map_match_ip_next_hop_prefix_list_hook(int (*func)( |
d5d737a2 SP |
576 | struct route_map_index *index, const char *command, |
577 | const char *arg, route_map_event_t type, | |
578 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 579 | /* no match ip next hop prefix list */ |
d62a17ae | 580 | extern void route_map_no_match_ip_next_hop_prefix_list_hook(int (*func)( |
d5d737a2 SP |
581 | struct route_map_index *index, const char *command, |
582 | const char *arg, route_map_event_t type, | |
583 | char *errmsg, size_t errmsg_len)); | |
61ad901e DA |
584 | /* match ip next hop type */ |
585 | extern void route_map_match_ip_next_hop_type_hook(int (*func)( | |
d5d737a2 SP |
586 | struct route_map_index *index, const char *command, |
587 | const char *arg, route_map_event_t type, | |
588 | char *errmsg, size_t errmsg_len)); | |
61ad901e DA |
589 | /* no match ip next hop type */ |
590 | extern void route_map_no_match_ip_next_hop_type_hook(int (*func)( | |
d5d737a2 SP |
591 | struct route_map_index *index, const char *command, |
592 | const char *arg, route_map_event_t type, | |
593 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 594 | /* match ipv6 address */ |
d62a17ae | 595 | extern void route_map_match_ipv6_address_hook(int (*func)( |
d5d737a2 SP |
596 | struct route_map_index *index, const char *command, |
597 | const char *arg, route_map_event_t type, | |
598 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 599 | /* no match ipv6 address */ |
d62a17ae | 600 | extern void route_map_no_match_ipv6_address_hook(int (*func)( |
d5d737a2 SP |
601 | struct route_map_index *index, const char *command, |
602 | const char *arg, route_map_event_t type, | |
603 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 604 | /* match ipv6 address prefix list */ |
d62a17ae | 605 | extern void route_map_match_ipv6_address_prefix_list_hook(int (*func)( |
d5d737a2 SP |
606 | struct route_map_index *index, const char *command, |
607 | const char *arg, route_map_event_t type, | |
608 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 609 | /* no match ipv6 address prefix list */ |
d62a17ae | 610 | extern void route_map_no_match_ipv6_address_prefix_list_hook(int (*func)( |
d5d737a2 SP |
611 | struct route_map_index *index, const char *command, |
612 | const char *arg, route_map_event_t type, | |
613 | char *errmsg, size_t errmsg_len)); | |
61ad901e DA |
614 | /* match ipv6 next-hop type */ |
615 | extern void route_map_match_ipv6_next_hop_type_hook(int (*func)( | |
d5d737a2 SP |
616 | struct route_map_index *index, const char *command, |
617 | const char *arg, route_map_event_t type, | |
618 | char *errmsg, size_t errmsg_len)); | |
61ad901e DA |
619 | /* no match ipv6 next-hop type */ |
620 | extern void route_map_no_match_ipv6_next_hop_type_hook(int (*func)( | |
d5d737a2 SP |
621 | struct route_map_index *index, const char *command, |
622 | const char *arg, route_map_event_t type, | |
623 | char *errmsg, size_t errmsg_len)); | |
82f191a2 DA |
624 | /* match ipv6 next-hop prefix-list */ |
625 | extern void route_map_match_ipv6_next_hop_prefix_list_hook(int (*func)( | |
626 | struct route_map_index *index, const char *command, const char *arg, | |
627 | route_map_event_t type, char *errmsg, size_t errmsg_len)); | |
628 | /* no match ipv6 next-hop prefix-list */ | |
629 | extern void route_map_no_match_ipv6_next_hop_prefix_list_hook(int (*func)( | |
630 | struct route_map_index *index, const char *command, const char *arg, | |
631 | route_map_event_t type, char *errmsg, size_t errmsg_len)); | |
82f97584 | 632 | /* match metric */ |
d62a17ae | 633 | extern void route_map_match_metric_hook(int (*func)( |
d5d737a2 SP |
634 | struct route_map_index *index, const char *command, |
635 | const char *arg, route_map_event_t type, | |
636 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 637 | /* no match metric */ |
d62a17ae | 638 | extern void route_map_no_match_metric_hook(int (*func)( |
d5d737a2 SP |
639 | struct route_map_index *index, const char *command, |
640 | const char *arg, route_map_event_t type, | |
641 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 642 | /* match tag */ |
d62a17ae | 643 | extern void route_map_match_tag_hook(int (*func)( |
d5d737a2 SP |
644 | struct route_map_index *index, const char *command, |
645 | const char *arg, route_map_event_t type, | |
646 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 647 | /* no match tag */ |
d62a17ae | 648 | extern void route_map_no_match_tag_hook(int (*func)( |
d5d737a2 SP |
649 | struct route_map_index *index, const char *command, |
650 | const char *arg, route_map_event_t type, | |
651 | char *errmsg, size_t errmsg_len)); | |
31f937fb SM |
652 | /* set sr-te color */ |
653 | extern void route_map_set_srte_color_hook( | |
d5d737a2 SP |
654 | int (*func)(struct route_map_index *index, |
655 | const char *command, const char *arg, | |
656 | char *errmsg, size_t errmsg_len)); | |
31f937fb SM |
657 | /* no set sr-te color */ |
658 | extern void route_map_no_set_srte_color_hook( | |
d5d737a2 SP |
659 | int (*func)(struct route_map_index *index, |
660 | const char *command, const char *arg, | |
661 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 662 | /* set ip nexthop */ |
d62a17ae | 663 | extern void route_map_set_ip_nexthop_hook( |
d5d737a2 SP |
664 | int (*func)(struct route_map_index *index, |
665 | const char *command, const char *arg, | |
666 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 667 | /* no set ip nexthop */ |
d62a17ae | 668 | extern void route_map_no_set_ip_nexthop_hook( |
d5d737a2 SP |
669 | int (*func)(struct route_map_index *index, |
670 | const char *command, const char *arg, | |
671 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 672 | /* set ipv6 nexthop local */ |
d62a17ae | 673 | extern void route_map_set_ipv6_nexthop_local_hook( |
d5d737a2 SP |
674 | int (*func)(struct route_map_index *index, |
675 | const char *command, const char *arg, | |
676 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 677 | /* no set ipv6 nexthop local */ |
d62a17ae | 678 | extern void route_map_no_set_ipv6_nexthop_local_hook( |
d5d737a2 SP |
679 | int (*func)(struct route_map_index *index, |
680 | const char *command, const char *arg, | |
681 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 682 | /* set metric */ |
d5d737a2 | 683 | extern void route_map_set_metric_hook(int (*func)(struct route_map_index *index, |
d62a17ae | 684 | const char *command, |
d5d737a2 SP |
685 | const char *arg, |
686 | char *errmsg, | |
687 | size_t errmsg_len)); | |
82f97584 | 688 | /* no set metric */ |
d62a17ae | 689 | extern void route_map_no_set_metric_hook( |
d5d737a2 SP |
690 | int (*func)(struct route_map_index *index, |
691 | const char *command, const char *arg, | |
692 | char *errmsg, size_t errmsg_len)); | |
82f97584 | 693 | /* set tag */ |
d5d737a2 | 694 | extern void route_map_set_tag_hook(int (*func)(struct route_map_index *index, |
d62a17ae | 695 | const char *command, |
d5d737a2 SP |
696 | const char *arg, |
697 | char *errmsg, | |
698 | size_t errmsg_len)); | |
82f97584 | 699 | /* no set tag */ |
d5d737a2 | 700 | extern void route_map_no_set_tag_hook(int (*func)(struct route_map_index *index, |
d62a17ae | 701 | const char *command, |
d5d737a2 SP |
702 | const char *arg, |
703 | char *errmsg, | |
704 | size_t errmsg_len)); | |
e52702f2 | 705 | |
d62a17ae | 706 | extern void *route_map_rule_tag_compile(const char *arg); |
707 | extern void route_map_rule_tag_free(void *rule); | |
dc9ffce8 | 708 | |
4a2a09d0 | 709 | /* Increment the route-map used counter */ |
710 | extern void route_map_counter_increment(struct route_map *map); | |
711 | ||
712 | /* Decrement the route-map used counter */ | |
713 | extern void route_map_counter_decrement(struct route_map *map); | |
714 | ||
a7282663 RZ |
715 | /* Route map hooks data structure. */ |
716 | struct route_map_match_set_hooks { | |
717 | /* match interface */ | |
d5d737a2 | 718 | int (*match_interface)(struct route_map_index *index, |
a7282663 | 719 | const char *command, const char *arg, |
d5d737a2 SP |
720 | route_map_event_t type, |
721 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
722 | |
723 | /* no match interface */ | |
d5d737a2 | 724 | int (*no_match_interface)(struct route_map_index *index, |
a7282663 | 725 | const char *command, const char *arg, |
d5d737a2 SP |
726 | route_map_event_t type, |
727 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
728 | |
729 | /* match ip address */ | |
d5d737a2 | 730 | int (*match_ip_address)(struct route_map_index *index, |
a7282663 | 731 | const char *command, const char *arg, |
d5d737a2 SP |
732 | route_map_event_t type, |
733 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
734 | |
735 | /* no match ip address */ | |
d5d737a2 | 736 | int (*no_match_ip_address)(struct route_map_index *index, |
a7282663 | 737 | const char *command, const char *arg, |
d5d737a2 SP |
738 | route_map_event_t type, |
739 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
740 | |
741 | /* match ip address prefix list */ | |
d5d737a2 | 742 | int (*match_ip_address_prefix_list)(struct route_map_index *index, |
a7282663 RZ |
743 | const char *command, |
744 | const char *arg, | |
d5d737a2 SP |
745 | route_map_event_t type, |
746 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
747 | |
748 | /* no match ip address prefix list */ | |
d5d737a2 | 749 | int (*no_match_ip_address_prefix_list)(struct route_map_index *index, |
a7282663 RZ |
750 | const char *command, |
751 | const char *arg, | |
d5d737a2 SP |
752 | route_map_event_t type, |
753 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
754 | |
755 | /* match ip next hop */ | |
d5d737a2 | 756 | int (*match_ip_next_hop)(struct route_map_index *index, |
a7282663 | 757 | const char *command, const char *arg, |
d5d737a2 SP |
758 | route_map_event_t type, |
759 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
760 | |
761 | /* no match ip next hop */ | |
d5d737a2 | 762 | int (*no_match_ip_next_hop)(struct route_map_index *index, |
a7282663 | 763 | const char *command, const char *arg, |
d5d737a2 SP |
764 | route_map_event_t type, |
765 | char *errmsg, size_t errmsg_len); | |
a7282663 | 766 | |
bc63ba98 DA |
767 | /* match ipv6 next hop */ |
768 | int (*match_ipv6_next_hop)(struct route_map_index *index, | |
769 | const char *command, const char *arg, | |
770 | route_map_event_t type, char *errmsg, | |
771 | size_t errmsg_len); | |
772 | ||
773 | /* no match ipv6 next hop */ | |
774 | int (*no_match_ipv6_next_hop)(struct route_map_index *index, | |
775 | const char *command, const char *arg, | |
776 | route_map_event_t type, char *errmsg, | |
777 | size_t errmsg_len); | |
778 | ||
82f191a2 DA |
779 | /* match ipv6 next hop prefix-list */ |
780 | int (*match_ipv6_next_hop_prefix_list)(struct route_map_index *index, | |
781 | const char *command, | |
782 | const char *arg, | |
783 | route_map_event_t type, | |
784 | char *errmsg, size_t errmsg_len); | |
785 | ||
786 | /* no match ipv6 next-hop prefix-list */ | |
787 | int (*no_match_ipv6_next_hop_prefix_list)(struct route_map_index *index, | |
788 | const char *command, | |
789 | const char *arg, | |
790 | route_map_event_t type, | |
791 | char *errmsg, | |
792 | size_t errmsg_len); | |
793 | ||
a7282663 | 794 | /* match ip next hop prefix list */ |
d5d737a2 | 795 | int (*match_ip_next_hop_prefix_list)(struct route_map_index *index, |
a7282663 RZ |
796 | const char *command, |
797 | const char *arg, | |
d5d737a2 SP |
798 | route_map_event_t type, |
799 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
800 | |
801 | /* no match ip next hop prefix list */ | |
d5d737a2 | 802 | int (*no_match_ip_next_hop_prefix_list)(struct route_map_index *index, |
a7282663 RZ |
803 | const char *command, |
804 | const char *arg, | |
d5d737a2 SP |
805 | route_map_event_t type, |
806 | char *errmsg, | |
807 | size_t errmsg_len); | |
a7282663 RZ |
808 | |
809 | /* match ip next-hop type */ | |
d5d737a2 SP |
810 | int (*match_ip_next_hop_type)(struct route_map_index *index, |
811 | const char *command, | |
812 | const char *arg, | |
813 | route_map_event_t type, | |
814 | char *errmsg, | |
815 | size_t errmsg_len); | |
a7282663 RZ |
816 | |
817 | /* no match ip next-hop type */ | |
d5d737a2 SP |
818 | int (*no_match_ip_next_hop_type)(struct route_map_index *index, |
819 | const char *command, | |
820 | const char *arg, | |
821 | route_map_event_t type, | |
822 | char *errmsg, | |
823 | size_t errmsg_len); | |
a7282663 RZ |
824 | |
825 | /* match ipv6 address */ | |
d5d737a2 | 826 | int (*match_ipv6_address)(struct route_map_index *index, |
a7282663 | 827 | const char *command, const char *arg, |
d5d737a2 SP |
828 | route_map_event_t type, |
829 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
830 | |
831 | /* no match ipv6 address */ | |
d5d737a2 | 832 | int (*no_match_ipv6_address)(struct route_map_index *index, |
a7282663 | 833 | const char *command, const char *arg, |
d5d737a2 SP |
834 | route_map_event_t type, |
835 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
836 | |
837 | ||
838 | /* match ipv6 address prefix list */ | |
d5d737a2 | 839 | int (*match_ipv6_address_prefix_list)(struct route_map_index *index, |
a7282663 RZ |
840 | const char *command, |
841 | const char *arg, | |
d5d737a2 SP |
842 | route_map_event_t type, |
843 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
844 | |
845 | /* no match ipv6 address prefix list */ | |
d5d737a2 | 846 | int (*no_match_ipv6_address_prefix_list)(struct route_map_index *index, |
a7282663 RZ |
847 | const char *command, |
848 | const char *arg, | |
d5d737a2 SP |
849 | route_map_event_t type, |
850 | char *errmsg, | |
851 | size_t errmsg_len); | |
a7282663 RZ |
852 | |
853 | /* match ipv6 next-hop type */ | |
d5d737a2 | 854 | int (*match_ipv6_next_hop_type)(struct route_map_index *index, |
a7282663 RZ |
855 | const char *command, |
856 | const char *arg, | |
d5d737a2 SP |
857 | route_map_event_t type, |
858 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
859 | |
860 | /* no match ipv6 next-hop type */ | |
d5d737a2 | 861 | int (*no_match_ipv6_next_hop_type)(struct route_map_index *index, |
a7282663 | 862 | const char *command, const char *arg, |
d5d737a2 SP |
863 | route_map_event_t type, |
864 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
865 | |
866 | /* match metric */ | |
d5d737a2 | 867 | int (*match_metric)(struct route_map_index *index, |
a7282663 | 868 | const char *command, const char *arg, |
d5d737a2 SP |
869 | route_map_event_t type, |
870 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
871 | |
872 | /* no match metric */ | |
d5d737a2 | 873 | int (*no_match_metric)(struct route_map_index *index, |
a7282663 | 874 | const char *command, const char *arg, |
d5d737a2 SP |
875 | route_map_event_t type, |
876 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
877 | |
878 | /* match tag */ | |
d5d737a2 | 879 | int (*match_tag)(struct route_map_index *index, |
a7282663 | 880 | const char *command, const char *arg, |
d5d737a2 SP |
881 | route_map_event_t type, |
882 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
883 | |
884 | /* no match tag */ | |
d5d737a2 | 885 | int (*no_match_tag)(struct route_map_index *index, |
a7282663 | 886 | const char *command, const char *arg, |
d5d737a2 SP |
887 | route_map_event_t type, |
888 | char *errmsg, size_t errmsg_len); | |
a7282663 | 889 | |
31f937fb | 890 | /* set sr-te color */ |
d5d737a2 SP |
891 | int (*set_srte_color)(struct route_map_index *index, |
892 | const char *command, const char *arg, | |
893 | char *errmsg, size_t errmsg_len); | |
31f937fb SM |
894 | |
895 | /* no set sr-te color */ | |
d5d737a2 SP |
896 | int (*no_set_srte_color)(struct route_map_index *index, |
897 | const char *command, const char *arg, | |
898 | char *errmsg, size_t errmsg_len); | |
31f937fb | 899 | |
a7282663 | 900 | /* set ip nexthop */ |
d5d737a2 SP |
901 | int (*set_ip_nexthop)(struct route_map_index *index, |
902 | const char *command, const char *arg, | |
903 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
904 | |
905 | /* no set ip nexthop */ | |
d5d737a2 SP |
906 | int (*no_set_ip_nexthop)(struct route_map_index *index, |
907 | const char *command, const char *arg, | |
908 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
909 | |
910 | /* set ipv6 nexthop local */ | |
d5d737a2 SP |
911 | int (*set_ipv6_nexthop_local)(struct route_map_index *index, |
912 | const char *command, const char *arg, | |
913 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
914 | |
915 | /* no set ipv6 nexthop local */ | |
d5d737a2 SP |
916 | int (*no_set_ipv6_nexthop_local)(struct route_map_index *index, |
917 | const char *command, const char *arg, | |
918 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
919 | |
920 | /* set metric */ | |
d5d737a2 SP |
921 | int (*set_metric)(struct route_map_index *index, |
922 | const char *command, const char *arg, | |
923 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
924 | |
925 | /* no set metric */ | |
d5d737a2 SP |
926 | int (*no_set_metric)(struct route_map_index *index, |
927 | const char *command, const char *arg, | |
928 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
929 | |
930 | /* set tag */ | |
d5d737a2 SP |
931 | int (*set_tag)(struct route_map_index *index, |
932 | const char *command, const char *arg, | |
933 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
934 | |
935 | /* no set tag */ | |
d5d737a2 SP |
936 | int (*no_set_tag)(struct route_map_index *index, |
937 | const char *command, const char *arg, | |
938 | char *errmsg, size_t errmsg_len); | |
a7282663 RZ |
939 | }; |
940 | ||
941 | extern struct route_map_match_set_hooks rmap_match_set_hook; | |
942 | ||
943 | /* Making route map list. */ | |
944 | struct route_map_list { | |
945 | struct route_map *head; | |
946 | struct route_map *tail; | |
947 | ||
948 | void (*add_hook)(const char *); | |
949 | void (*delete_hook)(const char *); | |
950 | void (*event_hook)(const char *); | |
951 | }; | |
952 | ||
953 | extern struct route_map_list route_map_master; | |
954 | ||
955 | extern struct route_map *route_map_get(const char *name); | |
956 | extern void route_map_delete(struct route_map *map); | |
957 | extern struct route_map_index *route_map_index_get(struct route_map *map, | |
958 | enum route_map_type type, | |
959 | int pref); | |
960 | extern void route_map_index_delete(struct route_map_index *index, int notify); | |
961 | ||
686d244f | 962 | /* routemap_northbound.c */ |
d5d737a2 | 963 | typedef int (*routemap_match_hook_fun)(struct route_map_index *rmi, |
686d244f | 964 | const char *command, const char *arg, |
d5d737a2 SP |
965 | route_map_event_t event, |
966 | char *errmsg, size_t errmsg_len); | |
967 | typedef int (*routemap_set_hook_fun)(struct route_map_index *rmi, | |
968 | const char *command, const char *arg, | |
969 | char *errmsg, size_t errmsg_len); | |
686d244f RZ |
970 | struct routemap_hook_context { |
971 | struct route_map_index *rhc_rmi; | |
972 | const char *rhc_rule; | |
973 | route_map_event_t rhc_event; | |
974 | routemap_set_hook_fun rhc_shook; | |
975 | routemap_match_hook_fun rhc_mhook; | |
54a35ff4 | 976 | TAILQ_ENTRY(routemap_hook_context) rhc_entry; |
686d244f RZ |
977 | }; |
978 | ||
60ee8be1 RW |
979 | int lib_route_map_entry_match_destroy(struct nb_cb_destroy_args *args); |
980 | int lib_route_map_entry_set_destroy(struct nb_cb_destroy_args *args); | |
2b3e4807 | 981 | |
54a35ff4 RZ |
982 | struct routemap_hook_context * |
983 | routemap_hook_context_insert(struct route_map_index *rmi); | |
984 | void routemap_hook_context_free(struct routemap_hook_context *rhc); | |
985 | ||
686d244f RZ |
986 | extern const struct frr_yang_module_info frr_route_map_info; |
987 | ||
2b3e4807 | 988 | /* routemap_cli.c */ |
25605051 IR |
989 | extern int route_map_instance_cmp(const struct lyd_node *dnode1, |
990 | const struct lyd_node *dnode2); | |
991 | extern void route_map_instance_show(struct vty *vty, | |
992 | const struct lyd_node *dnode, | |
2b3e4807 RZ |
993 | bool show_defaults); |
994 | extern void route_map_instance_show_end(struct vty *vty, | |
25605051 IR |
995 | const struct lyd_node *dnode); |
996 | extern void route_map_condition_show(struct vty *vty, | |
997 | const struct lyd_node *dnode, | |
2b3e4807 | 998 | bool show_defaults); |
25605051 | 999 | extern void route_map_action_show(struct vty *vty, const struct lyd_node *dnode, |
2b3e4807 | 1000 | bool show_defaults); |
25605051 IR |
1001 | extern void route_map_exit_policy_show(struct vty *vty, |
1002 | const struct lyd_node *dnode, | |
2b3e4807 | 1003 | bool show_defaults); |
25605051 | 1004 | extern void route_map_call_show(struct vty *vty, const struct lyd_node *dnode, |
2b3e4807 RZ |
1005 | bool show_defaults); |
1006 | extern void route_map_description_show(struct vty *vty, | |
25605051 | 1007 | const struct lyd_node *dnode, |
2b3e4807 | 1008 | bool show_defaults); |
38133c4a | 1009 | extern void route_map_optimization_disabled_show(struct vty *vty, |
25605051 | 1010 | const struct lyd_node *dnode, |
38133c4a | 1011 | bool show_defaults); |
2b3e4807 RZ |
1012 | extern void route_map_cli_init(void); |
1013 | ||
5e244469 RW |
1014 | #ifdef __cplusplus |
1015 | } | |
1016 | #endif | |
1017 | ||
718e3744 | 1018 | #endif /* _ZEBRA_ROUTEMAP_H */ |