2 * Copyright (C) 1998 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
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
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.
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 #ifndef _ZEBRA_ROUTEMAP_H
23 #define _ZEBRA_ROUTEMAP_H
27 /* Route map's type. */
66 RMAP_EVENT_SET_DELETED,
67 RMAP_EVENT_SET_REPLACED,
68 RMAP_EVENT_MATCH_ADDED,
69 RMAP_EVENT_MATCH_DELETED,
70 RMAP_EVENT_MATCH_REPLACED,
71 RMAP_EVENT_INDEX_ADDED,
72 RMAP_EVENT_INDEX_DELETED
75 /* Depth limit in RMAP recursion using RMAP_CALL. */
76 #define RMAP_RECURSION_LIMIT 10
78 /* Route map rule structure for matching and setting. */
79 struct route_map_rule_cmd
81 /* Route map rule name (e.g. as-path, metric) */
84 /* Function for value set or match. */
85 route_map_result_t (*func_apply)(void *, struct prefix *,
86 route_map_object_t, void *);
88 /* Compile argument and return result as void *. */
89 void *(*func_compile)(const char *);
91 /* Free allocated value by func_compile (). */
92 void (*func_free)(void *);
95 /* Route map apply error. */
98 /* Route map rule is missing. */
99 RMAP_RULE_MISSING = 1,
101 /* Route map rule can't compile */
105 /* Route map rule list. */
106 struct route_map_rule_list
108 struct route_map_rule *head;
109 struct route_map_rule *tail;
112 /* Route map index structure. */
113 struct route_map_index
115 struct route_map *map;
118 /* Preference of this route map rule. */
121 /* Route map type permit or deny. */
122 enum route_map_type type;
124 /* Do we follow old rules, or hop forward? */
125 route_map_end_t exitpolicy;
127 /* If we're using "GOTO", to where do we go? */
130 /* If we're using "CALL", to which route-map do ew go? */
133 /* Matching rule list. */
134 struct route_map_rule_list match_list;
135 struct route_map_rule_list set_list;
137 /* Make linked list. */
138 struct route_map_index *next;
139 struct route_map_index *prev;
142 /* Route map list structure. */
145 /* Name of route map. */
148 /* Route map's rule. */
149 struct route_map_index *head;
150 struct route_map_index *tail;
152 /* Make linked list. */
153 struct route_map *next;
154 struct route_map *prev;
158 extern void route_map_init (void);
159 extern void route_map_init_vty (void);
160 extern void route_map_finish (void);
162 /* Add match statement to route map. */
163 extern int route_map_add_match (struct route_map_index *index,
164 const char *match_name,
165 const char *match_arg);
167 /* Delete specified route match rule. */
168 extern int route_map_delete_match (struct route_map_index *index,
169 const char *match_name,
170 const char *match_arg);
172 /* Add route-map set statement to the route map. */
173 extern int route_map_add_set (struct route_map_index *index,
174 const char *set_name,
175 const char *set_arg);
177 /* Delete route map set rule. */
178 extern int route_map_delete_set (struct route_map_index *index,
179 const char *set_name,
180 const char *set_arg);
182 /* Install rule command to the match list. */
183 extern void route_map_install_match (struct route_map_rule_cmd *cmd);
185 /* Install rule command to the set list. */
186 extern void route_map_install_set (struct route_map_rule_cmd *cmd);
188 /* Lookup route map by name. */
189 extern struct route_map * route_map_lookup_by_name (const char *name);
191 /* Apply route map to the object. */
192 extern route_map_result_t route_map_apply (struct route_map *map,
194 route_map_object_t object_type,
197 extern void route_map_add_hook (void (*func) (const char *));
198 extern void route_map_delete_hook (void (*func) (const char *));
199 extern void route_map_event_hook (void (*func) (route_map_event_t, const char *));
201 extern void *route_map_rule_tag_compile (const char *arg);
202 extern void route_map_rule_tag_free (void *rule);
204 #endif /* _ZEBRA_ROUTEMAP_H */