ospf6d: fix warnings from recent prefix bit commit
[jleu-quagga.git] / lib / routemap.h
blob1402f5c84bd2b4348efd570c3252e05686fe9071
1 /* Route map function.
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
9 * later version.
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
19 * 02111-1307, USA.
22 #ifndef _ZEBRA_ROUTEMAP_H
23 #define _ZEBRA_ROUTEMAP_H
25 /* Route map's type. */
26 enum route_map_type
28 RMAP_PERMIT,
29 RMAP_DENY,
30 RMAP_ANY
33 typedef enum
35 RMAP_MATCH,
36 RMAP_DENYMATCH,
37 RMAP_NOMATCH,
38 RMAP_ERROR,
39 RMAP_OKAY
40 } route_map_result_t;
42 typedef enum
44 RMAP_RIP,
45 RMAP_RIPNG,
46 RMAP_OSPF,
47 RMAP_OSPF6,
48 RMAP_BGP,
49 RMAP_ZEBRA
50 } route_map_object_t;
52 typedef enum
54 RMAP_EXIT,
55 RMAP_GOTO,
56 RMAP_NEXT
57 } route_map_end_t;
59 typedef enum
61 RMAP_EVENT_SET_ADDED,
62 RMAP_EVENT_SET_DELETED,
63 RMAP_EVENT_SET_REPLACED,
64 RMAP_EVENT_MATCH_ADDED,
65 RMAP_EVENT_MATCH_DELETED,
66 RMAP_EVENT_MATCH_REPLACED,
67 RMAP_EVENT_INDEX_ADDED,
68 RMAP_EVENT_INDEX_DELETED
69 } route_map_event_t;
71 /* Depth limit in RMAP recursion using RMAP_CALL. */
72 #define RMAP_RECURSION_LIMIT 10
74 /* Route map rule structure for matching and setting. */
75 struct route_map_rule_cmd
77 /* Route map rule name (e.g. as-path, metric) */
78 const char *str;
80 /* Function for value set or match. */
81 route_map_result_t (*func_apply)(void *, struct prefix *,
82 route_map_object_t, void *);
84 /* Compile argument and return result as void *. */
85 void *(*func_compile)(const char *);
87 /* Free allocated value by func_compile (). */
88 void (*func_free)(void *);
91 /* Route map apply error. */
92 enum
94 /* Route map rule is missing. */
95 RMAP_RULE_MISSING = 1,
97 /* Route map rule can't compile */
98 RMAP_COMPILE_ERROR
101 /* Route map rule list. */
102 struct route_map_rule_list
104 struct route_map_rule *head;
105 struct route_map_rule *tail;
108 /* Route map index structure. */
109 struct route_map_index
111 struct route_map *map;
112 char *description;
114 /* Preference of this route map rule. */
115 int pref;
117 /* Route map type permit or deny. */
118 enum route_map_type type;
120 /* Do we follow old rules, or hop forward? */
121 route_map_end_t exitpolicy;
123 /* If we're using "GOTO", to where do we go? */
124 int nextpref;
126 /* If we're using "CALL", to which route-map do ew go? */
127 char *nextrm;
129 /* Matching rule list. */
130 struct route_map_rule_list match_list;
131 struct route_map_rule_list set_list;
133 /* Make linked list. */
134 struct route_map_index *next;
135 struct route_map_index *prev;
138 /* Route map list structure. */
139 struct route_map
141 /* Name of route map. */
142 char *name;
144 /* Route map's rule. */
145 struct route_map_index *head;
146 struct route_map_index *tail;
148 /* Make linked list. */
149 struct route_map *next;
150 struct route_map *prev;
153 /* Prototypes. */
154 extern void route_map_init (void);
155 extern void route_map_init_vty (void);
156 extern void route_map_finish (void);
158 /* Add match statement to route map. */
159 extern int route_map_add_match (struct route_map_index *index,
160 const char *match_name,
161 const char *match_arg);
163 /* Delete specified route match rule. */
164 extern int route_map_delete_match (struct route_map_index *index,
165 const char *match_name,
166 const char *match_arg);
168 /* Add route-map set statement to the route map. */
169 extern int route_map_add_set (struct route_map_index *index,
170 const char *set_name,
171 const char *set_arg);
173 /* Delete route map set rule. */
174 extern int route_map_delete_set (struct route_map_index *index,
175 const char *set_name,
176 const char *set_arg);
178 /* Install rule command to the match list. */
179 extern void route_map_install_match (struct route_map_rule_cmd *cmd);
181 /* Install rule command to the set list. */
182 extern void route_map_install_set (struct route_map_rule_cmd *cmd);
184 /* Lookup route map by name. */
185 extern struct route_map * route_map_lookup_by_name (const char *name);
187 /* Apply route map to the object. */
188 extern route_map_result_t route_map_apply (struct route_map *map,
189 struct prefix *,
190 route_map_object_t object_type,
191 void *object);
193 extern void route_map_add_hook (void (*func) (const char *));
194 extern void route_map_delete_hook (void (*func) (const char *));
195 extern void route_map_event_hook (void (*func) (route_map_event_t, const char *));
197 #endif /* _ZEBRA_ROUTEMAP_H */