]>
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 | ||
165 | /* Route map index structure. */ | |
d62a17ae | 166 | struct route_map_index { |
167 | struct route_map *map; | |
168 | char *description; | |
718e3744 | 169 | |
d62a17ae | 170 | /* Preference of this route map rule. */ |
171 | int pref; | |
718e3744 | 172 | |
d62a17ae | 173 | /* Route map type permit or deny. */ |
174 | enum route_map_type type; | |
718e3744 | 175 | |
d62a17ae | 176 | /* Do we follow old rules, or hop forward? */ |
177 | route_map_end_t exitpolicy; | |
718e3744 | 178 | |
d62a17ae | 179 | /* If we're using "GOTO", to where do we go? */ |
180 | int nextpref; | |
718e3744 | 181 | |
d62a17ae | 182 | /* If we're using "CALL", to which route-map do ew go? */ |
183 | char *nextrm; | |
fee0f4c6 | 184 | |
d62a17ae | 185 | /* Matching rule list. */ |
186 | struct route_map_rule_list match_list; | |
187 | struct route_map_rule_list set_list; | |
718e3744 | 188 | |
d62a17ae | 189 | /* Make linked list. */ |
190 | struct route_map_index *next; | |
191 | struct route_map_index *prev; | |
e80e7cce | 192 | |
279b0607 DS |
193 | /* Keep track how many times we've try to apply */ |
194 | uint64_t applied; | |
1fa30509 | 195 | uint64_t applied_clear; |
279b0607 | 196 | |
d62a17ae | 197 | QOBJ_FIELDS |
718e3744 | 198 | }; |
e80e7cce | 199 | DECLARE_QOBJ_TYPE(route_map_index) |
718e3744 | 200 | |
201 | /* Route map list structure. */ | |
d62a17ae | 202 | struct route_map { |
203 | /* Name of route map. */ | |
204 | char *name; | |
718e3744 | 205 | |
d62a17ae | 206 | /* Route map's rule. */ |
207 | struct route_map_index *head; | |
208 | struct route_map_index *tail; | |
718e3744 | 209 | |
d62a17ae | 210 | /* Make linked list. */ |
211 | struct route_map *next; | |
212 | struct route_map *prev; | |
518f0eb1 | 213 | |
d62a17ae | 214 | /* Maintain update info */ |
e4694d0d DS |
215 | bool to_be_processed; /* True if modification isn't acted on yet */ |
216 | bool deleted; /* If 1, then this node will be deleted */ | |
e80e7cce | 217 | |
279b0607 DS |
218 | /* How many times have we applied this route-map */ |
219 | uint64_t applied; | |
1fa30509 | 220 | uint64_t applied_clear; |
279b0607 | 221 | |
4a2a09d0 | 222 | /* Counter to track active usage of this route-map */ |
223 | uint16_t use_count; | |
224 | ||
d62a17ae | 225 | QOBJ_FIELDS |
718e3744 | 226 | }; |
e80e7cce | 227 | DECLARE_QOBJ_TYPE(route_map) |
718e3744 | 228 | |
229 | /* Prototypes. */ | |
d62a17ae | 230 | extern void route_map_init(void); |
8619629a DS |
231 | |
232 | /* | |
233 | * This should only be called on shutdown | |
234 | * Additionally this function sets the hooks to NULL | |
235 | * before any processing is done. | |
236 | */ | |
d62a17ae | 237 | extern void route_map_finish(void); |
718e3744 | 238 | |
239 | /* Add match statement to route map. */ | |
cda7187d DS |
240 | extern enum rmap_compile_rets route_map_add_match(struct route_map_index *index, |
241 | const char *match_name, | |
242 | const char *match_arg, | |
243 | route_map_event_t type); | |
718e3744 | 244 | |
245 | /* Delete specified route match rule. */ | |
cda7187d DS |
246 | extern enum rmap_compile_rets |
247 | route_map_delete_match(struct route_map_index *index, | |
909f3d56 | 248 | const char *match_name, const char *match_arg, |
249 | route_map_event_t type); | |
718e3744 | 250 | |
d62a17ae | 251 | extern const char *route_map_get_match_arg(struct route_map_index *index, |
252 | const char *match_name); | |
518f0eb1 | 253 | |
718e3744 | 254 | /* Add route-map set statement to the route map. */ |
cda7187d DS |
255 | extern enum rmap_compile_rets route_map_add_set(struct route_map_index *index, |
256 | const char *set_name, | |
257 | const char *set_arg); | |
718e3744 | 258 | |
259 | /* Delete route map set rule. */ | |
cda7187d DS |
260 | extern enum rmap_compile_rets |
261 | route_map_delete_set(struct route_map_index *index, | |
262 | const char *set_name, const char *set_arg); | |
718e3744 | 263 | |
264 | /* Install rule command to the match list. */ | |
364deb04 | 265 | extern void route_map_install_match(const struct route_map_rule_cmd *cmd); |
718e3744 | 266 | |
6a74c5f9 DS |
267 | /* |
268 | * Install rule command to the set list. | |
269 | * | |
270 | * When installing a particular item, Allow a difference of handling | |
271 | * of bad cli inputted(return NULL) -vs- this particular daemon cannot use | |
272 | * this form of the command(return a pointer and handle it appropriately | |
273 | * in the apply command). See 'set metric' command | |
274 | * as it is handled in ripd/ripngd and ospfd. | |
275 | */ | |
364deb04 | 276 | extern void route_map_install_set(const struct route_map_rule_cmd *cmd); |
718e3744 | 277 | |
278 | /* Lookup route map by name. */ | |
d62a17ae | 279 | extern struct route_map *route_map_lookup_by_name(const char *name); |
718e3744 | 280 | |
1de27621 DA |
281 | /* Simple helper to warn if route-map does not exist. */ |
282 | struct route_map *route_map_lookup_warn_noexist(struct vty *vty, const char *name); | |
283 | ||
718e3744 | 284 | /* Apply route map to the object. */ |
d62a17ae | 285 | extern route_map_result_t route_map_apply(struct route_map *map, |
123214ef | 286 | const struct prefix *prefix, |
d62a17ae | 287 | route_map_object_t object_type, |
288 | void *object); | |
289 | ||
290 | extern void route_map_add_hook(void (*func)(const char *)); | |
291 | extern void route_map_delete_hook(void (*func)(const char *)); | |
097b5973 DS |
292 | |
293 | /* | |
294 | * This is the callback for when something has changed about a | |
295 | * route-map. The interested parties can register to receive | |
296 | * this data. | |
297 | * | |
298 | * name - Is the name of the changed route-map | |
299 | */ | |
300 | extern void route_map_event_hook(void (*func)(const char *name)); | |
7096e938 | 301 | extern int route_map_mark_updated(const char *name); |
46a69f10 | 302 | extern void route_map_walk_update_list(void (*update_fn)(char *name)); |
d62a17ae | 303 | extern void route_map_upd8_dependency(route_map_event_t type, const char *arg, |
304 | const char *rmap_name); | |
305 | extern void route_map_notify_dependencies(const char *affected_name, | |
306 | route_map_event_t event); | |
307 | ||
308 | extern int generic_match_add(struct vty *vty, struct route_map_index *index, | |
309 | const char *command, const char *arg, | |
310 | route_map_event_t type); | |
311 | ||
312 | extern int generic_match_delete(struct vty *vty, struct route_map_index *index, | |
313 | const char *command, const char *arg, | |
314 | route_map_event_t type); | |
315 | extern int generic_set_add(struct vty *vty, struct route_map_index *index, | |
316 | const char *command, const char *arg); | |
317 | extern int generic_set_delete(struct vty *vty, struct route_map_index *index, | |
318 | const char *command, const char *arg); | |
82f97584 DW |
319 | |
320 | ||
321 | /* match interface */ | |
d62a17ae | 322 | extern void route_map_match_interface_hook(int (*func)( |
323 | struct vty *vty, struct route_map_index *index, const char *command, | |
324 | const char *arg, route_map_event_t type)); | |
82f97584 | 325 | /* no match interface */ |
d62a17ae | 326 | extern void route_map_no_match_interface_hook(int (*func)( |
327 | struct vty *vty, struct route_map_index *index, const char *command, | |
328 | const char *arg, route_map_event_t type)); | |
82f97584 | 329 | /* match ip address */ |
d62a17ae | 330 | extern void route_map_match_ip_address_hook(int (*func)( |
331 | struct vty *vty, struct route_map_index *index, const char *command, | |
332 | const char *arg, route_map_event_t type)); | |
82f97584 | 333 | /* no match ip address */ |
d62a17ae | 334 | extern void route_map_no_match_ip_address_hook(int (*func)( |
335 | struct vty *vty, struct route_map_index *index, const char *command, | |
336 | const char *arg, route_map_event_t type)); | |
82f97584 | 337 | /* match ip address prefix list */ |
d62a17ae | 338 | extern void route_map_match_ip_address_prefix_list_hook(int (*func)( |
339 | struct vty *vty, struct route_map_index *index, const char *command, | |
340 | const char *arg, route_map_event_t type)); | |
82f97584 | 341 | /* no match ip address prefix list */ |
d62a17ae | 342 | extern void route_map_no_match_ip_address_prefix_list_hook(int (*func)( |
343 | struct vty *vty, struct route_map_index *index, const char *command, | |
344 | const char *arg, route_map_event_t type)); | |
82f97584 | 345 | /* match ip next hop */ |
d62a17ae | 346 | extern void route_map_match_ip_next_hop_hook(int (*func)( |
347 | struct vty *vty, struct route_map_index *index, const char *command, | |
348 | const char *arg, route_map_event_t type)); | |
82f97584 | 349 | /* no match ip next hop */ |
d62a17ae | 350 | extern void route_map_no_match_ip_next_hop_hook(int (*func)( |
351 | struct vty *vty, struct route_map_index *index, const char *command, | |
352 | const char *arg, route_map_event_t type)); | |
82f97584 | 353 | /* match ip next hop prefix list */ |
d62a17ae | 354 | extern void route_map_match_ip_next_hop_prefix_list_hook(int (*func)( |
355 | struct vty *vty, struct route_map_index *index, const char *command, | |
356 | const char *arg, route_map_event_t type)); | |
82f97584 | 357 | /* no match ip next hop prefix list */ |
d62a17ae | 358 | extern void route_map_no_match_ip_next_hop_prefix_list_hook(int (*func)( |
359 | struct vty *vty, struct route_map_index *index, const char *command, | |
360 | const char *arg, route_map_event_t type)); | |
61ad901e DA |
361 | /* match ip next hop type */ |
362 | extern void route_map_match_ip_next_hop_type_hook(int (*func)( | |
363 | struct vty *vty, struct route_map_index *index, const char *command, | |
364 | const char *arg, route_map_event_t type)); | |
365 | /* no match ip next hop type */ | |
366 | extern void route_map_no_match_ip_next_hop_type_hook(int (*func)( | |
367 | struct vty *vty, struct route_map_index *index, const char *command, | |
368 | const char *arg, route_map_event_t type)); | |
82f97584 | 369 | /* match ipv6 address */ |
d62a17ae | 370 | extern void route_map_match_ipv6_address_hook(int (*func)( |
371 | struct vty *vty, struct route_map_index *index, const char *command, | |
372 | const char *arg, route_map_event_t type)); | |
82f97584 | 373 | /* no match ipv6 address */ |
d62a17ae | 374 | extern void route_map_no_match_ipv6_address_hook(int (*func)( |
375 | struct vty *vty, struct route_map_index *index, const char *command, | |
376 | const char *arg, route_map_event_t type)); | |
82f97584 | 377 | /* match ipv6 address prefix list */ |
d62a17ae | 378 | extern void route_map_match_ipv6_address_prefix_list_hook(int (*func)( |
379 | struct vty *vty, struct route_map_index *index, const char *command, | |
380 | const char *arg, route_map_event_t type)); | |
82f97584 | 381 | /* no match ipv6 address prefix list */ |
d62a17ae | 382 | extern void route_map_no_match_ipv6_address_prefix_list_hook(int (*func)( |
383 | struct vty *vty, struct route_map_index *index, const char *command, | |
384 | const char *arg, route_map_event_t type)); | |
61ad901e DA |
385 | /* match ipv6 next-hop type */ |
386 | extern void route_map_match_ipv6_next_hop_type_hook(int (*func)( | |
387 | struct vty *vty, struct route_map_index *index, const char *command, | |
388 | const char *arg, route_map_event_t type)); | |
389 | /* no match ipv6 next-hop type */ | |
390 | extern void route_map_no_match_ipv6_next_hop_type_hook(int (*func)( | |
391 | struct vty *vty, struct route_map_index *index, const char *command, | |
392 | const char *arg, route_map_event_t type)); | |
82f97584 | 393 | /* match metric */ |
d62a17ae | 394 | extern void route_map_match_metric_hook(int (*func)( |
395 | struct vty *vty, struct route_map_index *index, const char *command, | |
396 | const char *arg, route_map_event_t type)); | |
82f97584 | 397 | /* no match metric */ |
d62a17ae | 398 | extern void route_map_no_match_metric_hook(int (*func)( |
399 | struct vty *vty, struct route_map_index *index, const char *command, | |
400 | const char *arg, route_map_event_t type)); | |
82f97584 | 401 | /* match tag */ |
d62a17ae | 402 | extern void route_map_match_tag_hook(int (*func)( |
403 | struct vty *vty, struct route_map_index *index, const char *command, | |
404 | const char *arg, route_map_event_t type)); | |
82f97584 | 405 | /* no match tag */ |
d62a17ae | 406 | extern void route_map_no_match_tag_hook(int (*func)( |
407 | struct vty *vty, struct route_map_index *index, const char *command, | |
408 | const char *arg, route_map_event_t type)); | |
82f97584 | 409 | /* set ip nexthop */ |
d62a17ae | 410 | extern void route_map_set_ip_nexthop_hook( |
411 | int (*func)(struct vty *vty, struct route_map_index *index, | |
412 | const char *command, const char *arg)); | |
82f97584 | 413 | /* no set ip nexthop */ |
d62a17ae | 414 | extern void route_map_no_set_ip_nexthop_hook( |
415 | int (*func)(struct vty *vty, struct route_map_index *index, | |
416 | const char *command, const char *arg)); | |
82f97584 | 417 | /* set ipv6 nexthop local */ |
d62a17ae | 418 | extern void route_map_set_ipv6_nexthop_local_hook( |
419 | int (*func)(struct vty *vty, struct route_map_index *index, | |
420 | const char *command, const char *arg)); | |
82f97584 | 421 | /* no set ipv6 nexthop local */ |
d62a17ae | 422 | extern void route_map_no_set_ipv6_nexthop_local_hook( |
423 | int (*func)(struct vty *vty, struct route_map_index *index, | |
424 | const char *command, const char *arg)); | |
82f97584 | 425 | /* set metric */ |
d62a17ae | 426 | extern void route_map_set_metric_hook(int (*func)(struct vty *vty, |
427 | struct route_map_index *index, | |
428 | const char *command, | |
429 | const char *arg)); | |
82f97584 | 430 | /* no set metric */ |
d62a17ae | 431 | extern void route_map_no_set_metric_hook( |
432 | int (*func)(struct vty *vty, struct route_map_index *index, | |
433 | const char *command, const char *arg)); | |
82f97584 | 434 | /* set tag */ |
d62a17ae | 435 | extern void route_map_set_tag_hook(int (*func)(struct vty *vty, |
436 | struct route_map_index *index, | |
437 | const char *command, | |
438 | const char *arg)); | |
82f97584 | 439 | /* no set tag */ |
d62a17ae | 440 | extern void route_map_no_set_tag_hook(int (*func)(struct vty *vty, |
441 | struct route_map_index *index, | |
442 | const char *command, | |
443 | const char *arg)); | |
e52702f2 | 444 | |
d62a17ae | 445 | extern void *route_map_rule_tag_compile(const char *arg); |
446 | extern void route_map_rule_tag_free(void *rule); | |
dc9ffce8 | 447 | |
4a2a09d0 | 448 | /* Increment the route-map used counter */ |
449 | extern void route_map_counter_increment(struct route_map *map); | |
450 | ||
451 | /* Decrement the route-map used counter */ | |
452 | extern void route_map_counter_decrement(struct route_map *map); | |
453 | ||
a7282663 RZ |
454 | /* Route map hooks data structure. */ |
455 | struct route_map_match_set_hooks { | |
456 | /* match interface */ | |
457 | int (*match_interface)(struct vty *vty, struct route_map_index *index, | |
458 | const char *command, const char *arg, | |
459 | route_map_event_t type); | |
460 | ||
461 | /* no match interface */ | |
462 | int (*no_match_interface)(struct vty *vty, | |
463 | struct route_map_index *index, | |
464 | const char *command, const char *arg, | |
465 | route_map_event_t type); | |
466 | ||
467 | /* match ip address */ | |
468 | int (*match_ip_address)(struct vty *vty, struct route_map_index *index, | |
469 | const char *command, const char *arg, | |
470 | route_map_event_t type); | |
471 | ||
472 | /* no match ip address */ | |
473 | int (*no_match_ip_address)(struct vty *vty, | |
474 | struct route_map_index *index, | |
475 | const char *command, const char *arg, | |
476 | route_map_event_t type); | |
477 | ||
478 | /* match ip address prefix list */ | |
479 | int (*match_ip_address_prefix_list)(struct vty *vty, | |
480 | struct route_map_index *index, | |
481 | const char *command, | |
482 | const char *arg, | |
483 | route_map_event_t type); | |
484 | ||
485 | /* no match ip address prefix list */ | |
486 | int (*no_match_ip_address_prefix_list)(struct vty *vty, | |
487 | struct route_map_index *index, | |
488 | const char *command, | |
489 | const char *arg, | |
490 | route_map_event_t type); | |
491 | ||
492 | /* match ip next hop */ | |
493 | int (*match_ip_next_hop)(struct vty *vty, struct route_map_index *index, | |
494 | const char *command, const char *arg, | |
495 | route_map_event_t type); | |
496 | ||
497 | /* no match ip next hop */ | |
498 | int (*no_match_ip_next_hop)(struct vty *vty, | |
499 | struct route_map_index *index, | |
500 | const char *command, const char *arg, | |
501 | route_map_event_t type); | |
502 | ||
503 | /* match ip next hop prefix list */ | |
504 | int (*match_ip_next_hop_prefix_list)(struct vty *vty, | |
505 | struct route_map_index *index, | |
506 | const char *command, | |
507 | const char *arg, | |
508 | route_map_event_t type); | |
509 | ||
510 | /* no match ip next hop prefix list */ | |
511 | int (*no_match_ip_next_hop_prefix_list)(struct vty *vty, | |
512 | struct route_map_index *index, | |
513 | const char *command, | |
514 | const char *arg, | |
515 | route_map_event_t type); | |
516 | ||
517 | /* match ip next-hop type */ | |
518 | int (*match_ip_next_hop_type)(struct vty *vty, | |
519 | struct route_map_index *index, | |
520 | const char *command, | |
521 | const char *arg, | |
522 | route_map_event_t type); | |
523 | ||
524 | /* no match ip next-hop type */ | |
525 | int (*no_match_ip_next_hop_type)(struct vty *vty, | |
526 | struct route_map_index *index, | |
527 | const char *command, | |
528 | const char *arg, | |
529 | route_map_event_t type); | |
530 | ||
531 | /* match ipv6 address */ | |
532 | int (*match_ipv6_address)(struct vty *vty, | |
533 | struct route_map_index *index, | |
534 | const char *command, const char *arg, | |
535 | route_map_event_t type); | |
536 | ||
537 | /* no match ipv6 address */ | |
538 | int (*no_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 | ||
544 | /* match ipv6 address prefix list */ | |
545 | int (*match_ipv6_address_prefix_list)(struct vty *vty, | |
546 | struct route_map_index *index, | |
547 | const char *command, | |
548 | const char *arg, | |
549 | route_map_event_t type); | |
550 | ||
551 | /* no match ipv6 address prefix list */ | |
552 | int (*no_match_ipv6_address_prefix_list)(struct vty *vty, | |
553 | struct route_map_index *index, | |
554 | const char *command, | |
555 | const char *arg, | |
556 | route_map_event_t type); | |
557 | ||
558 | /* match ipv6 next-hop type */ | |
559 | int (*match_ipv6_next_hop_type)(struct vty *vty, | |
560 | struct route_map_index *index, | |
561 | const char *command, | |
562 | const char *arg, | |
563 | route_map_event_t type); | |
564 | ||
565 | /* no match ipv6 next-hop type */ | |
566 | int (*no_match_ipv6_next_hop_type)(struct vty *vty, | |
567 | struct route_map_index *index, | |
568 | const char *command, const char *arg, | |
569 | route_map_event_t type); | |
570 | ||
571 | /* match metric */ | |
572 | int (*match_metric)(struct vty *vty, struct route_map_index *index, | |
573 | const char *command, const char *arg, | |
574 | route_map_event_t type); | |
575 | ||
576 | /* no match metric */ | |
577 | int (*no_match_metric)(struct vty *vty, struct route_map_index *index, | |
578 | const char *command, const char *arg, | |
579 | route_map_event_t type); | |
580 | ||
581 | /* match tag */ | |
582 | int (*match_tag)(struct vty *vty, struct route_map_index *index, | |
583 | const char *command, const char *arg, | |
584 | route_map_event_t type); | |
585 | ||
586 | /* no match tag */ | |
587 | int (*no_match_tag)(struct vty *vty, struct route_map_index *index, | |
588 | const char *command, const char *arg, | |
589 | route_map_event_t type); | |
590 | ||
591 | /* set ip nexthop */ | |
592 | int (*set_ip_nexthop)(struct vty *vty, struct route_map_index *index, | |
593 | const char *command, const char *arg); | |
594 | ||
595 | /* no set ip nexthop */ | |
596 | int (*no_set_ip_nexthop)(struct vty *vty, struct route_map_index *index, | |
597 | const char *command, const char *arg); | |
598 | ||
599 | /* set ipv6 nexthop local */ | |
600 | int (*set_ipv6_nexthop_local)(struct vty *vty, | |
601 | struct route_map_index *index, | |
602 | const char *command, const char *arg); | |
603 | ||
604 | /* no set ipv6 nexthop local */ | |
605 | int (*no_set_ipv6_nexthop_local)(struct vty *vty, | |
606 | struct route_map_index *index, | |
607 | const char *command, const char *arg); | |
608 | ||
609 | /* set metric */ | |
610 | int (*set_metric)(struct vty *vty, struct route_map_index *index, | |
611 | const char *command, const char *arg); | |
612 | ||
613 | /* no set metric */ | |
614 | int (*no_set_metric)(struct vty *vty, struct route_map_index *index, | |
615 | const char *command, const char *arg); | |
616 | ||
617 | /* set tag */ | |
618 | int (*set_tag)(struct vty *vty, struct route_map_index *index, | |
619 | const char *command, const char *arg); | |
620 | ||
621 | /* no set tag */ | |
622 | int (*no_set_tag)(struct vty *vty, struct route_map_index *index, | |
623 | const char *command, const char *arg); | |
624 | }; | |
625 | ||
626 | extern struct route_map_match_set_hooks rmap_match_set_hook; | |
627 | ||
628 | /* Making route map list. */ | |
629 | struct route_map_list { | |
630 | struct route_map *head; | |
631 | struct route_map *tail; | |
632 | ||
633 | void (*add_hook)(const char *); | |
634 | void (*delete_hook)(const char *); | |
635 | void (*event_hook)(const char *); | |
636 | }; | |
637 | ||
638 | extern struct route_map_list route_map_master; | |
639 | ||
640 | extern struct route_map *route_map_get(const char *name); | |
641 | extern void route_map_delete(struct route_map *map); | |
642 | extern struct route_map_index *route_map_index_get(struct route_map *map, | |
643 | enum route_map_type type, | |
644 | int pref); | |
645 | extern void route_map_index_delete(struct route_map_index *index, int notify); | |
646 | ||
686d244f RZ |
647 | /* routemap_northbound.c */ |
648 | typedef int (*routemap_match_hook_fun)(struct vty *vty, | |
649 | struct route_map_index *rmi, | |
650 | const char *command, const char *arg, | |
651 | route_map_event_t event); | |
652 | ||
653 | typedef int (*routemap_set_hook_fun)(struct vty *vty, | |
654 | struct route_map_index *rmi, | |
655 | const char *command, const char *arg); | |
656 | ||
657 | struct routemap_hook_context { | |
658 | struct route_map_index *rhc_rmi; | |
659 | const char *rhc_rule; | |
660 | route_map_event_t rhc_event; | |
661 | routemap_set_hook_fun rhc_shook; | |
662 | routemap_match_hook_fun rhc_mhook; | |
663 | }; | |
664 | ||
665 | int lib_route_map_entry_match_destroy(enum nb_event event, | |
666 | const struct lyd_node *dnode); | |
667 | int lib_route_map_entry_set_destroy(enum nb_event event, | |
668 | const struct lyd_node *dnode); | |
2b3e4807 | 669 | |
686d244f RZ |
670 | extern const struct frr_yang_module_info frr_route_map_info; |
671 | ||
2b3e4807 RZ |
672 | /* routemap_cli.c */ |
673 | extern void route_map_instance_show(struct vty *vty, struct lyd_node *dnode, | |
674 | bool show_defaults); | |
675 | extern void route_map_instance_show_end(struct vty *vty, | |
676 | struct lyd_node *dnode); | |
677 | extern void route_map_condition_show(struct vty *vty, struct lyd_node *dnode, | |
678 | bool show_defaults); | |
679 | extern void route_map_action_show(struct vty *vty, struct lyd_node *dnode, | |
680 | bool show_defaults); | |
681 | extern void route_map_exit_policy_show(struct vty *vty, struct lyd_node *dnode, | |
682 | bool show_defaults); | |
683 | extern void route_map_call_show(struct vty *vty, struct lyd_node *dnode, | |
684 | bool show_defaults); | |
685 | extern void route_map_description_show(struct vty *vty, | |
686 | struct lyd_node *dnode, | |
687 | bool show_defaults); | |
688 | extern void route_map_cli_init(void); | |
689 | ||
5e244469 RW |
690 | #ifdef __cplusplus |
691 | } | |
692 | #endif | |
693 | ||
718e3744 | 694 | #endif /* _ZEBRA_ROUTEMAP_H */ |