]>
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 | ||
24873f0c | 24 | #include "prefix.h" |
4a1ab8e4 | 25 | #include "memory.h" |
e80e7cce | 26 | #include "qobj.h" |
0a538fc9 QY |
27 | #include "vty.h" |
28 | ||
5e244469 RW |
29 | #ifdef __cplusplus |
30 | extern "C" { | |
31 | #endif | |
32 | ||
4a1ab8e4 DL |
33 | DECLARE_MTYPE(ROUTE_MAP_NAME) |
34 | DECLARE_MTYPE(ROUTE_MAP_RULE) | |
35 | DECLARE_MTYPE(ROUTE_MAP_COMPILED) | |
24873f0c | 36 | |
718e3744 | 37 | /* Route map's type. */ |
d62a17ae | 38 | enum route_map_type { RMAP_PERMIT, RMAP_DENY, RMAP_ANY }; |
39 | ||
40 | typedef enum { | |
d62a17ae | 41 | RMAP_DENYMATCH, |
b68885f9 | 42 | RMAP_PERMITMATCH |
718e3744 | 43 | } route_map_result_t; |
44 | ||
b68885f9 LK |
45 | /* |
46 | * Route-map match or set result "Eg: match evpn vni xx" | |
47 | * route-map match cmd always returns match/nomatch/noop | |
48 | * match--> found a match | |
49 | * nomatch--> didnt find a match | |
50 | * noop--> not applicable | |
51 | * route-map set retuns okay/error | |
52 | * okay --> set was successful | |
53 | * error --> set was not successful | |
54 | */ | |
55 | enum route_map_cmd_result_t { | |
56 | /* | |
57 | * route-map match cmd results | |
58 | */ | |
59 | RMAP_MATCH, | |
60 | RMAP_NOMATCH, | |
61 | RMAP_NOOP, | |
62 | /* | |
63 | * route-map set cmd results | |
64 | */ | |
65 | RMAP_OKAY, | |
66 | RMAP_ERROR | |
67 | }; | |
68 | ||
69 | ||
d62a17ae | 70 | typedef enum { |
71 | RMAP_RIP, | |
72 | RMAP_RIPNG, | |
73 | RMAP_OSPF, | |
74 | RMAP_OSPF6, | |
75 | RMAP_BGP, | |
76 | RMAP_ZEBRA, | |
77 | RMAP_ISIS, | |
718e3744 | 78 | } route_map_object_t; |
79 | ||
d62a17ae | 80 | typedef enum { RMAP_EXIT, RMAP_GOTO, RMAP_NEXT } route_map_end_t; |
81 | ||
82 | typedef enum { | |
83 | RMAP_EVENT_SET_ADDED, | |
84 | RMAP_EVENT_SET_DELETED, | |
85 | RMAP_EVENT_SET_REPLACED, | |
86 | RMAP_EVENT_MATCH_ADDED, | |
87 | RMAP_EVENT_MATCH_DELETED, | |
88 | RMAP_EVENT_MATCH_REPLACED, | |
89 | RMAP_EVENT_INDEX_ADDED, | |
90 | RMAP_EVENT_INDEX_DELETED, | |
91 | RMAP_EVENT_CALL_ADDED, /* call to another routemap added */ | |
92 | RMAP_EVENT_CALL_DELETED, | |
93 | RMAP_EVENT_PLIST_ADDED, | |
94 | RMAP_EVENT_PLIST_DELETED, | |
95 | RMAP_EVENT_CLIST_ADDED, | |
96 | RMAP_EVENT_CLIST_DELETED, | |
97 | RMAP_EVENT_ECLIST_ADDED, | |
98 | RMAP_EVENT_ECLIST_DELETED, | |
99 | RMAP_EVENT_LLIST_ADDED, | |
100 | RMAP_EVENT_LLIST_DELETED, | |
101 | RMAP_EVENT_ASLIST_ADDED, | |
102 | RMAP_EVENT_ASLIST_DELETED, | |
103 | RMAP_EVENT_FILTER_ADDED, | |
104 | RMAP_EVENT_FILTER_DELETED, | |
718e3744 | 105 | } route_map_event_t; |
106 | ||
fee0f4c6 | 107 | /* Depth limit in RMAP recursion using RMAP_CALL. */ |
108 | #define RMAP_RECURSION_LIMIT 10 | |
109 | ||
718e3744 | 110 | /* Route map rule structure for matching and setting. */ |
d62a17ae | 111 | struct route_map_rule_cmd { |
112 | /* Route map rule name (e.g. as-path, metric) */ | |
113 | const char *str; | |
718e3744 | 114 | |
d62a17ae | 115 | /* Function for value set or match. */ |
b68885f9 LK |
116 | enum route_map_cmd_result_t (*func_apply)(void *rule, |
117 | const struct prefix *prefix, | |
118 | route_map_object_t type, | |
119 | void *object); | |
718e3744 | 120 | |
d62a17ae | 121 | /* Compile argument and return result as void *. */ |
122 | void *(*func_compile)(const char *); | |
718e3744 | 123 | |
d62a17ae | 124 | /* Free allocated value by func_compile (). */ |
125 | void (*func_free)(void *); | |
909f3d56 | 126 | |
127 | /** To get the rule key after Compilation **/ | |
128 | void *(*func_get_rmap_rule_key)(void *val); | |
718e3744 | 129 | }; |
130 | ||
131 | /* Route map apply error. */ | |
cda7187d | 132 | enum rmap_compile_rets { |
e2c8d6ce | 133 | RMAP_COMPILE_SUCCESS, |
9ca25fed | 134 | |
e2c8d6ce NT |
135 | /* Route map rule is missing. */ |
136 | RMAP_RULE_MISSING, | |
718e3744 | 137 | |
e2c8d6ce NT |
138 | /* Route map rule can't compile */ |
139 | RMAP_COMPILE_ERROR, | |
140 | ||
e2c8d6ce | 141 | }; |
718e3744 | 142 | |
a7282663 RZ |
143 | /* Route map rule. This rule has both `match' rule and `set' rule. */ |
144 | struct route_map_rule { | |
145 | /* Rule type. */ | |
146 | const struct route_map_rule_cmd *cmd; | |
147 | ||
148 | /* For pretty printing. */ | |
149 | char *rule_str; | |
150 | ||
151 | /* Pre-compiled match rule. */ | |
152 | void *value; | |
153 | ||
154 | /* Linked list. */ | |
155 | struct route_map_rule *next; | |
156 | struct route_map_rule *prev; | |
157 | }; | |
158 | ||
718e3744 | 159 | /* Route map rule list. */ |
d62a17ae | 160 | struct route_map_rule_list { |
161 | struct route_map_rule *head; | |
162 | struct route_map_rule *tail; | |
718e3744 | 163 | }; |
164 | ||
54a35ff4 RZ |
165 | /* Forward struct declaration: the complete can be found later this file. */ |
166 | struct routemap_hook_context; | |
167 | ||
718e3744 | 168 | /* Route map index structure. */ |
d62a17ae | 169 | struct route_map_index { |
170 | struct route_map *map; | |
171 | char *description; | |
718e3744 | 172 | |
d62a17ae | 173 | /* Preference of this route map rule. */ |
174 | int pref; | |
718e3744 | 175 | |
d62a17ae | 176 | /* Route map type permit or deny. */ |
177 | enum route_map_type type; | |
718e3744 | 178 | |
d62a17ae | 179 | /* Do we follow old rules, or hop forward? */ |
180 | route_map_end_t exitpolicy; | |
718e3744 | 181 | |
d62a17ae | 182 | /* If we're using "GOTO", to where do we go? */ |
183 | int nextpref; | |
718e3744 | 184 | |
d62a17ae | 185 | /* If we're using "CALL", to which route-map do ew go? */ |
186 | char *nextrm; | |
fee0f4c6 | 187 | |
d62a17ae | 188 | /* Matching rule list. */ |
189 | struct route_map_rule_list match_list; | |
190 | struct route_map_rule_list set_list; | |
718e3744 | 191 | |
d62a17ae | 192 | /* Make linked list. */ |
193 | struct route_map_index *next; | |
194 | struct route_map_index *prev; | |
e80e7cce | 195 | |
279b0607 DS |
196 | /* Keep track how many times we've try to apply */ |
197 | uint64_t applied; | |
1fa30509 | 198 | uint64_t applied_clear; |
279b0607 | 199 | |
54a35ff4 RZ |
200 | /* List of match/sets contexts. */ |
201 | TAILQ_HEAD(, routemap_hook_context) rhclist; | |
202 | ||
d62a17ae | 203 | QOBJ_FIELDS |
718e3744 | 204 | }; |
e80e7cce | 205 | DECLARE_QOBJ_TYPE(route_map_index) |
718e3744 | 206 | |
207 | /* Route map list structure. */ | |
d62a17ae | 208 | struct route_map { |
209 | /* Name of route map. */ | |
210 | char *name; | |
718e3744 | 211 | |
d62a17ae | 212 | /* Route map's rule. */ |
213 | struct route_map_index *head; | |
214 | struct route_map_index *tail; | |
718e3744 | 215 | |
d62a17ae | 216 | /* Make linked list. */ |
217 | struct route_map *next; | |
218 | struct route_map *prev; | |
518f0eb1 | 219 | |
d62a17ae | 220 | /* Maintain update info */ |
e4694d0d DS |
221 | bool to_be_processed; /* True if modification isn't acted on yet */ |
222 | bool deleted; /* If 1, then this node will be deleted */ | |
e80e7cce | 223 | |
279b0607 DS |
224 | /* How many times have we applied this route-map */ |
225 | uint64_t applied; | |
1fa30509 | 226 | uint64_t applied_clear; |
279b0607 | 227 | |
4a2a09d0 | 228 | /* Counter to track active usage of this route-map */ |
229 | uint16_t use_count; | |
230 | ||
d62a17ae | 231 | QOBJ_FIELDS |
718e3744 | 232 | }; |
e80e7cce | 233 | DECLARE_QOBJ_TYPE(route_map) |
718e3744 | 234 | |
235 | /* Prototypes. */ | |
d62a17ae | 236 | extern void route_map_init(void); |
8619629a DS |
237 | |
238 | /* | |
239 | * This should only be called on shutdown | |
240 | * Additionally this function sets the hooks to NULL | |
241 | * before any processing is done. | |
242 | */ | |
d62a17ae | 243 | extern void route_map_finish(void); |
718e3744 | 244 | |
245 | /* Add match statement to route map. */ | |
cda7187d DS |
246 | extern enum rmap_compile_rets route_map_add_match(struct route_map_index *index, |
247 | const char *match_name, | |
248 | const char *match_arg, | |
249 | route_map_event_t type); | |
718e3744 | 250 | |
251 | /* Delete specified route match rule. */ | |
cda7187d DS |
252 | extern enum rmap_compile_rets |
253 | route_map_delete_match(struct route_map_index *index, | |
909f3d56 | 254 | const char *match_name, const char *match_arg, |
255 | route_map_event_t type); | |
718e3744 | 256 | |
d62a17ae | 257 | extern const char *route_map_get_match_arg(struct route_map_index *index, |
258 | const char *match_name); | |
518f0eb1 | 259 | |
718e3744 | 260 | /* Add route-map set statement to the route map. */ |
cda7187d DS |
261 | extern enum rmap_compile_rets route_map_add_set(struct route_map_index *index, |
262 | const char *set_name, | |
263 | const char *set_arg); | |
718e3744 | 264 | |
265 | /* Delete route map set rule. */ | |
cda7187d DS |
266 | extern enum rmap_compile_rets |
267 | route_map_delete_set(struct route_map_index *index, | |
268 | const char *set_name, const char *set_arg); | |
718e3744 | 269 | |
270 | /* Install rule command to the match list. */ | |
364deb04 | 271 | extern void route_map_install_match(const struct route_map_rule_cmd *cmd); |
718e3744 | 272 | |
6a74c5f9 DS |
273 | /* |
274 | * Install rule command to the set list. | |
275 | * | |
276 | * When installing a particular item, Allow a difference of handling | |
277 | * of bad cli inputted(return NULL) -vs- this particular daemon cannot use | |
278 | * this form of the command(return a pointer and handle it appropriately | |
279 | * in the apply command). See 'set metric' command | |
280 | * as it is handled in ripd/ripngd and ospfd. | |
281 | */ | |
364deb04 | 282 | extern void route_map_install_set(const struct route_map_rule_cmd *cmd); |
718e3744 | 283 | |
284 | /* Lookup route map by name. */ | |
d62a17ae | 285 | extern struct route_map *route_map_lookup_by_name(const char *name); |
718e3744 | 286 | |
1de27621 DA |
287 | /* Simple helper to warn if route-map does not exist. */ |
288 | struct route_map *route_map_lookup_warn_noexist(struct vty *vty, const char *name); | |
289 | ||
718e3744 | 290 | /* Apply route map to the object. */ |
d62a17ae | 291 | extern route_map_result_t route_map_apply(struct route_map *map, |
123214ef | 292 | const struct prefix *prefix, |
d62a17ae | 293 | route_map_object_t object_type, |
294 | void *object); | |
295 | ||
296 | extern void route_map_add_hook(void (*func)(const char *)); | |
297 | extern void route_map_delete_hook(void (*func)(const char *)); | |
097b5973 DS |
298 | |
299 | /* | |
300 | * This is the callback for when something has changed about a | |
301 | * route-map. The interested parties can register to receive | |
302 | * this data. | |
303 | * | |
304 | * name - Is the name of the changed route-map | |
305 | */ | |
306 | extern void route_map_event_hook(void (*func)(const char *name)); | |
7096e938 | 307 | extern int route_map_mark_updated(const char *name); |
46a69f10 | 308 | extern void route_map_walk_update_list(void (*update_fn)(char *name)); |
d62a17ae | 309 | extern void route_map_upd8_dependency(route_map_event_t type, const char *arg, |
310 | const char *rmap_name); | |
311 | extern void route_map_notify_dependencies(const char *affected_name, | |
312 | route_map_event_t event); | |
313 | ||
314 | extern int generic_match_add(struct vty *vty, struct route_map_index *index, | |
315 | const char *command, const char *arg, | |
316 | route_map_event_t type); | |
317 | ||
318 | extern int generic_match_delete(struct vty *vty, struct route_map_index *index, | |
319 | const char *command, const char *arg, | |
320 | route_map_event_t type); | |
321 | extern int generic_set_add(struct vty *vty, struct route_map_index *index, | |
322 | const char *command, const char *arg); | |
323 | extern int generic_set_delete(struct vty *vty, struct route_map_index *index, | |
324 | const char *command, const char *arg); | |
82f97584 DW |
325 | |
326 | ||
327 | /* match interface */ | |
d62a17ae | 328 | extern void route_map_match_interface_hook(int (*func)( |
329 | struct vty *vty, struct route_map_index *index, const char *command, | |
330 | const char *arg, route_map_event_t type)); | |
82f97584 | 331 | /* no match interface */ |
d62a17ae | 332 | extern void route_map_no_match_interface_hook(int (*func)( |
333 | struct vty *vty, struct route_map_index *index, const char *command, | |
334 | const char *arg, route_map_event_t type)); | |
82f97584 | 335 | /* match ip address */ |
d62a17ae | 336 | extern void route_map_match_ip_address_hook(int (*func)( |
337 | struct vty *vty, struct route_map_index *index, const char *command, | |
338 | const char *arg, route_map_event_t type)); | |
82f97584 | 339 | /* no match ip address */ |
d62a17ae | 340 | extern void route_map_no_match_ip_address_hook(int (*func)( |
341 | struct vty *vty, struct route_map_index *index, const char *command, | |
342 | const char *arg, route_map_event_t type)); | |
82f97584 | 343 | /* match ip address prefix list */ |
d62a17ae | 344 | extern void route_map_match_ip_address_prefix_list_hook(int (*func)( |
345 | struct vty *vty, struct route_map_index *index, const char *command, | |
346 | const char *arg, route_map_event_t type)); | |
82f97584 | 347 | /* no match ip address prefix list */ |
d62a17ae | 348 | extern void route_map_no_match_ip_address_prefix_list_hook(int (*func)( |
349 | struct vty *vty, struct route_map_index *index, const char *command, | |
350 | const char *arg, route_map_event_t type)); | |
82f97584 | 351 | /* match ip next hop */ |
d62a17ae | 352 | extern void route_map_match_ip_next_hop_hook(int (*func)( |
353 | struct vty *vty, struct route_map_index *index, const char *command, | |
354 | const char *arg, route_map_event_t type)); | |
82f97584 | 355 | /* no match ip next hop */ |
d62a17ae | 356 | extern void route_map_no_match_ip_next_hop_hook(int (*func)( |
357 | struct vty *vty, struct route_map_index *index, const char *command, | |
358 | const char *arg, route_map_event_t type)); | |
82f97584 | 359 | /* match ip next hop prefix list */ |
d62a17ae | 360 | extern void route_map_match_ip_next_hop_prefix_list_hook(int (*func)( |
361 | struct vty *vty, struct route_map_index *index, const char *command, | |
362 | const char *arg, route_map_event_t type)); | |
82f97584 | 363 | /* no match ip next hop prefix list */ |
d62a17ae | 364 | extern void route_map_no_match_ip_next_hop_prefix_list_hook(int (*func)( |
365 | struct vty *vty, struct route_map_index *index, const char *command, | |
366 | const char *arg, route_map_event_t type)); | |
61ad901e DA |
367 | /* match ip next hop type */ |
368 | extern void route_map_match_ip_next_hop_type_hook(int (*func)( | |
369 | struct vty *vty, struct route_map_index *index, const char *command, | |
370 | const char *arg, route_map_event_t type)); | |
371 | /* no match ip next hop type */ | |
372 | extern void route_map_no_match_ip_next_hop_type_hook(int (*func)( | |
373 | struct vty *vty, struct route_map_index *index, const char *command, | |
374 | const char *arg, route_map_event_t type)); | |
82f97584 | 375 | /* match ipv6 address */ |
d62a17ae | 376 | extern void route_map_match_ipv6_address_hook(int (*func)( |
377 | struct vty *vty, struct route_map_index *index, const char *command, | |
378 | const char *arg, route_map_event_t type)); | |
82f97584 | 379 | /* no match ipv6 address */ |
d62a17ae | 380 | extern void route_map_no_match_ipv6_address_hook(int (*func)( |
381 | struct vty *vty, struct route_map_index *index, const char *command, | |
382 | const char *arg, route_map_event_t type)); | |
82f97584 | 383 | /* match ipv6 address prefix list */ |
d62a17ae | 384 | extern void route_map_match_ipv6_address_prefix_list_hook(int (*func)( |
385 | struct vty *vty, struct route_map_index *index, const char *command, | |
386 | const char *arg, route_map_event_t type)); | |
82f97584 | 387 | /* no match ipv6 address prefix list */ |
d62a17ae | 388 | extern void route_map_no_match_ipv6_address_prefix_list_hook(int (*func)( |
389 | struct vty *vty, struct route_map_index *index, const char *command, | |
390 | const char *arg, route_map_event_t type)); | |
61ad901e DA |
391 | /* match ipv6 next-hop type */ |
392 | extern void route_map_match_ipv6_next_hop_type_hook(int (*func)( | |
393 | struct vty *vty, struct route_map_index *index, const char *command, | |
394 | const char *arg, route_map_event_t type)); | |
395 | /* no match ipv6 next-hop type */ | |
396 | extern void route_map_no_match_ipv6_next_hop_type_hook(int (*func)( | |
397 | struct vty *vty, struct route_map_index *index, const char *command, | |
398 | const char *arg, route_map_event_t type)); | |
82f97584 | 399 | /* match metric */ |
d62a17ae | 400 | extern void route_map_match_metric_hook(int (*func)( |
401 | struct vty *vty, struct route_map_index *index, const char *command, | |
402 | const char *arg, route_map_event_t type)); | |
82f97584 | 403 | /* no match metric */ |
d62a17ae | 404 | extern void route_map_no_match_metric_hook(int (*func)( |
405 | struct vty *vty, struct route_map_index *index, const char *command, | |
406 | const char *arg, route_map_event_t type)); | |
82f97584 | 407 | /* match tag */ |
d62a17ae | 408 | extern void route_map_match_tag_hook(int (*func)( |
409 | struct vty *vty, struct route_map_index *index, const char *command, | |
410 | const char *arg, route_map_event_t type)); | |
82f97584 | 411 | /* no match tag */ |
d62a17ae | 412 | extern void route_map_no_match_tag_hook(int (*func)( |
413 | struct vty *vty, struct route_map_index *index, const char *command, | |
414 | const char *arg, route_map_event_t type)); | |
82f97584 | 415 | /* set ip nexthop */ |
d62a17ae | 416 | extern void route_map_set_ip_nexthop_hook( |
417 | int (*func)(struct vty *vty, struct route_map_index *index, | |
418 | const char *command, const char *arg)); | |
82f97584 | 419 | /* no set ip nexthop */ |
d62a17ae | 420 | extern void route_map_no_set_ip_nexthop_hook( |
421 | int (*func)(struct vty *vty, struct route_map_index *index, | |
422 | const char *command, const char *arg)); | |
82f97584 | 423 | /* set ipv6 nexthop local */ |
d62a17ae | 424 | extern void route_map_set_ipv6_nexthop_local_hook( |
425 | int (*func)(struct vty *vty, struct route_map_index *index, | |
426 | const char *command, const char *arg)); | |
82f97584 | 427 | /* no set ipv6 nexthop local */ |
d62a17ae | 428 | extern void route_map_no_set_ipv6_nexthop_local_hook( |
429 | int (*func)(struct vty *vty, struct route_map_index *index, | |
430 | const char *command, const char *arg)); | |
82f97584 | 431 | /* set metric */ |
d62a17ae | 432 | extern void route_map_set_metric_hook(int (*func)(struct vty *vty, |
433 | struct route_map_index *index, | |
434 | const char *command, | |
435 | const char *arg)); | |
82f97584 | 436 | /* no set metric */ |
d62a17ae | 437 | extern void route_map_no_set_metric_hook( |
438 | int (*func)(struct vty *vty, struct route_map_index *index, | |
439 | const char *command, const char *arg)); | |
82f97584 | 440 | /* set tag */ |
d62a17ae | 441 | extern void route_map_set_tag_hook(int (*func)(struct vty *vty, |
442 | struct route_map_index *index, | |
443 | const char *command, | |
444 | const char *arg)); | |
82f97584 | 445 | /* no set tag */ |
d62a17ae | 446 | extern void route_map_no_set_tag_hook(int (*func)(struct vty *vty, |
447 | struct route_map_index *index, | |
448 | const char *command, | |
449 | const char *arg)); | |
e52702f2 | 450 | |
d62a17ae | 451 | extern void *route_map_rule_tag_compile(const char *arg); |
452 | extern void route_map_rule_tag_free(void *rule); | |
dc9ffce8 | 453 | |
4a2a09d0 | 454 | /* Increment the route-map used counter */ |
455 | extern void route_map_counter_increment(struct route_map *map); | |
456 | ||
457 | /* Decrement the route-map used counter */ | |
458 | extern void route_map_counter_decrement(struct route_map *map); | |
459 | ||
a7282663 RZ |
460 | /* Route map hooks data structure. */ |
461 | struct route_map_match_set_hooks { | |
462 | /* match interface */ | |
463 | int (*match_interface)(struct vty *vty, struct route_map_index *index, | |
464 | const char *command, const char *arg, | |
465 | route_map_event_t type); | |
466 | ||
467 | /* no match interface */ | |
468 | int (*no_match_interface)(struct vty *vty, | |
469 | struct route_map_index *index, | |
470 | const char *command, const char *arg, | |
471 | route_map_event_t type); | |
472 | ||
473 | /* match ip address */ | |
474 | int (*match_ip_address)(struct vty *vty, struct route_map_index *index, | |
475 | const char *command, const char *arg, | |
476 | route_map_event_t type); | |
477 | ||
478 | /* no match ip address */ | |
479 | int (*no_match_ip_address)(struct vty *vty, | |
480 | struct route_map_index *index, | |
481 | const char *command, const char *arg, | |
482 | route_map_event_t type); | |
483 | ||
484 | /* match ip address prefix list */ | |
485 | int (*match_ip_address_prefix_list)(struct vty *vty, | |
486 | struct route_map_index *index, | |
487 | const char *command, | |
488 | const char *arg, | |
489 | route_map_event_t type); | |
490 | ||
491 | /* no match ip address prefix list */ | |
492 | int (*no_match_ip_address_prefix_list)(struct vty *vty, | |
493 | struct route_map_index *index, | |
494 | const char *command, | |
495 | const char *arg, | |
496 | route_map_event_t type); | |
497 | ||
498 | /* match ip next hop */ | |
499 | int (*match_ip_next_hop)(struct vty *vty, struct route_map_index *index, | |
500 | const char *command, const char *arg, | |
501 | route_map_event_t type); | |
502 | ||
503 | /* no match ip next hop */ | |
504 | int (*no_match_ip_next_hop)(struct vty *vty, | |
505 | struct route_map_index *index, | |
506 | const char *command, const char *arg, | |
507 | route_map_event_t type); | |
508 | ||
509 | /* match ip next hop prefix list */ | |
510 | int (*match_ip_next_hop_prefix_list)(struct vty *vty, | |
511 | struct route_map_index *index, | |
512 | const char *command, | |
513 | const char *arg, | |
514 | route_map_event_t type); | |
515 | ||
516 | /* no match ip next hop prefix list */ | |
517 | int (*no_match_ip_next_hop_prefix_list)(struct vty *vty, | |
518 | struct route_map_index *index, | |
519 | const char *command, | |
520 | const char *arg, | |
521 | route_map_event_t type); | |
522 | ||
523 | /* match ip next-hop type */ | |
524 | int (*match_ip_next_hop_type)(struct vty *vty, | |
525 | struct route_map_index *index, | |
526 | const char *command, | |
527 | const char *arg, | |
528 | route_map_event_t type); | |
529 | ||
530 | /* no match ip next-hop type */ | |
531 | int (*no_match_ip_next_hop_type)(struct vty *vty, | |
532 | struct route_map_index *index, | |
533 | const char *command, | |
534 | const char *arg, | |
535 | route_map_event_t type); | |
536 | ||
537 | /* match ipv6 address */ | |
538 | int (*match_ipv6_address)(struct vty *vty, | |
539 | struct route_map_index *index, | |
540 | const char *command, const char *arg, | |
541 | route_map_event_t type); | |
542 | ||
543 | /* no match ipv6 address */ | |
544 | int (*no_match_ipv6_address)(struct vty *vty, | |
545 | struct route_map_index *index, | |
546 | const char *command, const char *arg, | |
547 | route_map_event_t type); | |
548 | ||
549 | ||
550 | /* match ipv6 address prefix list */ | |
551 | int (*match_ipv6_address_prefix_list)(struct vty *vty, | |
552 | struct route_map_index *index, | |
553 | const char *command, | |
554 | const char *arg, | |
555 | route_map_event_t type); | |
556 | ||
557 | /* no match ipv6 address prefix list */ | |
558 | int (*no_match_ipv6_address_prefix_list)(struct vty *vty, | |
559 | struct route_map_index *index, | |
560 | const char *command, | |
561 | const char *arg, | |
562 | route_map_event_t type); | |
563 | ||
564 | /* match ipv6 next-hop type */ | |
565 | int (*match_ipv6_next_hop_type)(struct vty *vty, | |
566 | struct route_map_index *index, | |
567 | const char *command, | |
568 | const char *arg, | |
569 | route_map_event_t type); | |
570 | ||
571 | /* no match ipv6 next-hop type */ | |
572 | int (*no_match_ipv6_next_hop_type)(struct vty *vty, | |
573 | struct route_map_index *index, | |
574 | const char *command, const char *arg, | |
575 | route_map_event_t type); | |
576 | ||
577 | /* match metric */ | |
578 | int (*match_metric)(struct vty *vty, struct route_map_index *index, | |
579 | const char *command, const char *arg, | |
580 | route_map_event_t type); | |
581 | ||
582 | /* no match metric */ | |
583 | int (*no_match_metric)(struct vty *vty, struct route_map_index *index, | |
584 | const char *command, const char *arg, | |
585 | route_map_event_t type); | |
586 | ||
587 | /* match tag */ | |
588 | int (*match_tag)(struct vty *vty, struct route_map_index *index, | |
589 | const char *command, const char *arg, | |
590 | route_map_event_t type); | |
591 | ||
592 | /* no match tag */ | |
593 | int (*no_match_tag)(struct vty *vty, struct route_map_index *index, | |
594 | const char *command, const char *arg, | |
595 | route_map_event_t type); | |
596 | ||
597 | /* set ip nexthop */ | |
598 | int (*set_ip_nexthop)(struct vty *vty, struct route_map_index *index, | |
599 | const char *command, const char *arg); | |
600 | ||
601 | /* no set ip nexthop */ | |
602 | int (*no_set_ip_nexthop)(struct vty *vty, struct route_map_index *index, | |
603 | const char *command, const char *arg); | |
604 | ||
605 | /* set ipv6 nexthop local */ | |
606 | int (*set_ipv6_nexthop_local)(struct vty *vty, | |
607 | struct route_map_index *index, | |
608 | const char *command, const char *arg); | |
609 | ||
610 | /* no set ipv6 nexthop local */ | |
611 | int (*no_set_ipv6_nexthop_local)(struct vty *vty, | |
612 | struct route_map_index *index, | |
613 | const char *command, const char *arg); | |
614 | ||
615 | /* set metric */ | |
616 | int (*set_metric)(struct vty *vty, struct route_map_index *index, | |
617 | const char *command, const char *arg); | |
618 | ||
619 | /* no set metric */ | |
620 | int (*no_set_metric)(struct vty *vty, struct route_map_index *index, | |
621 | const char *command, const char *arg); | |
622 | ||
623 | /* set tag */ | |
624 | int (*set_tag)(struct vty *vty, struct route_map_index *index, | |
625 | const char *command, const char *arg); | |
626 | ||
627 | /* no set tag */ | |
628 | int (*no_set_tag)(struct vty *vty, struct route_map_index *index, | |
629 | const char *command, const char *arg); | |
630 | }; | |
631 | ||
632 | extern struct route_map_match_set_hooks rmap_match_set_hook; | |
633 | ||
634 | /* Making route map list. */ | |
635 | struct route_map_list { | |
636 | struct route_map *head; | |
637 | struct route_map *tail; | |
638 | ||
639 | void (*add_hook)(const char *); | |
640 | void (*delete_hook)(const char *); | |
641 | void (*event_hook)(const char *); | |
642 | }; | |
643 | ||
644 | extern struct route_map_list route_map_master; | |
645 | ||
646 | extern struct route_map *route_map_get(const char *name); | |
647 | extern void route_map_delete(struct route_map *map); | |
648 | extern struct route_map_index *route_map_index_get(struct route_map *map, | |
649 | enum route_map_type type, | |
650 | int pref); | |
651 | extern void route_map_index_delete(struct route_map_index *index, int notify); | |
652 | ||
686d244f RZ |
653 | /* routemap_northbound.c */ |
654 | typedef int (*routemap_match_hook_fun)(struct vty *vty, | |
655 | struct route_map_index *rmi, | |
656 | const char *command, const char *arg, | |
657 | route_map_event_t event); | |
658 | ||
659 | typedef int (*routemap_set_hook_fun)(struct vty *vty, | |
660 | struct route_map_index *rmi, | |
661 | const char *command, const char *arg); | |
662 | ||
663 | struct routemap_hook_context { | |
664 | struct route_map_index *rhc_rmi; | |
665 | const char *rhc_rule; | |
666 | route_map_event_t rhc_event; | |
667 | routemap_set_hook_fun rhc_shook; | |
668 | routemap_match_hook_fun rhc_mhook; | |
54a35ff4 | 669 | TAILQ_ENTRY(routemap_hook_context) rhc_entry; |
686d244f RZ |
670 | }; |
671 | ||
672 | int lib_route_map_entry_match_destroy(enum nb_event event, | |
673 | const struct lyd_node *dnode); | |
674 | int lib_route_map_entry_set_destroy(enum nb_event event, | |
675 | const struct lyd_node *dnode); | |
2b3e4807 | 676 | |
54a35ff4 RZ |
677 | struct routemap_hook_context * |
678 | routemap_hook_context_insert(struct route_map_index *rmi); | |
679 | void routemap_hook_context_free(struct routemap_hook_context *rhc); | |
680 | ||
686d244f RZ |
681 | extern const struct frr_yang_module_info frr_route_map_info; |
682 | ||
2b3e4807 RZ |
683 | /* routemap_cli.c */ |
684 | extern void route_map_instance_show(struct vty *vty, struct lyd_node *dnode, | |
685 | bool show_defaults); | |
686 | extern void route_map_instance_show_end(struct vty *vty, | |
687 | struct lyd_node *dnode); | |
688 | extern void route_map_condition_show(struct vty *vty, struct lyd_node *dnode, | |
689 | bool show_defaults); | |
690 | extern void route_map_action_show(struct vty *vty, struct lyd_node *dnode, | |
691 | bool show_defaults); | |
692 | extern void route_map_exit_policy_show(struct vty *vty, struct lyd_node *dnode, | |
693 | bool show_defaults); | |
694 | extern void route_map_call_show(struct vty *vty, struct lyd_node *dnode, | |
695 | bool show_defaults); | |
696 | extern void route_map_description_show(struct vty *vty, | |
697 | struct lyd_node *dnode, | |
698 | bool show_defaults); | |
699 | extern void route_map_cli_init(void); | |
700 | ||
5e244469 RW |
701 | #ifdef __cplusplus |
702 | } | |
703 | #endif | |
704 | ||
718e3744 | 705 | #endif /* _ZEBRA_ROUTEMAP_H */ |