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
25 /* Route map's type. */
61 RMAP_EVENT_SET_DELETED
,
62 RMAP_EVENT_SET_REPLACED
,
63 RMAP_EVENT_MATCH_ADDED
,
64 RMAP_EVENT_MATCH_DELETED
,
65 RMAP_EVENT_MATCH_REPLACED
,
66 RMAP_EVENT_INDEX_ADDED
,
67 RMAP_EVENT_INDEX_DELETED
70 /* Depth limit in RMAP recursion using RMAP_CALL. */
71 #define RMAP_RECURSION_LIMIT 10
73 /* Route map rule structure for matching and setting. */
74 struct route_map_rule_cmd
76 /* Route map rule name (e.g. as-path, metric) */
79 /* Function for value set or match. */
80 route_map_result_t (*func_apply
)(void *, struct prefix
*,
81 route_map_object_t
, void *);
83 /* Compile argument and return result as void *. */
84 void *(*func_compile
)(const char *);
86 /* Free allocated value by func_compile (). */
87 void (*func_free
)(void *);
90 /* Route map apply error. */
93 /* Route map rule is missing. */
94 RMAP_RULE_MISSING
= 1,
96 /* Route map rule can't compile */
100 /* Route map rule list. */
101 struct route_map_rule_list
103 struct route_map_rule
*head
;
104 struct route_map_rule
*tail
;
107 /* Route map index structure. */
108 struct route_map_index
110 struct route_map
*map
;
112 /* Preference of this route map rule. */
115 /* Route map type permit or deny. */
116 enum route_map_type type
;
118 /* Do we follow old rules, or hop forward? */
119 route_map_end_t exitpolicy
;
121 /* If we're using "GOTO", to where do we go? */
124 /* If we're using "CALL", to which route-map do ew go? */
127 /* Matching rule list. */
128 struct route_map_rule_list match_list
;
129 struct route_map_rule_list set_list
;
131 /* Make linked list. */
132 struct route_map_index
*next
;
133 struct route_map_index
*prev
;
136 /* Route map list structure. */
139 /* Name of route map. */
142 /* Route map's rule. */
143 struct route_map_index
*head
;
144 struct route_map_index
*tail
;
146 /* Make linked list. */
147 struct route_map
*next
;
148 struct route_map
*prev
;
152 void route_map_init ();
153 void route_map_init_vty ();
155 /* Add match statement to route map. */
157 route_map_add_match (struct route_map_index
*index
,
158 const char *match_name
,
159 const char *match_arg
);
161 /* Delete specified route match rule. */
163 route_map_delete_match (struct route_map_index
*index
,
164 const char *match_name
,
165 const char *match_arg
);
167 /* Add route-map set statement to the route map. */
169 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. */
175 route_map_delete_set (struct route_map_index
*index
, const char *set_name
,
176 const char *set_arg
);
178 /* Install rule command to the match list. */
180 route_map_install_match (struct route_map_rule_cmd
*cmd
);
182 /* Install rule command to the set list. */
184 route_map_install_set (struct route_map_rule_cmd
*cmd
);
186 /* Lookup route map by name. */
188 route_map_lookup_by_name (const char *name
);
190 /* Apply route map to the object. */
192 route_map_apply (struct route_map
*map
, struct prefix
*,
193 route_map_object_t object_type
, void *object
);
195 void route_map_add_hook (void (*func
) (const char *));
196 void route_map_delete_hook (void (*func
) (const char *));
197 void route_map_event_hook (void (*func
) (route_map_event_t
, const char *));
200 #endif /* _ZEBRA_ROUTEMAP_H */