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 /* Route map rule structure for matching and setting. */
71 struct route_map_rule_cmd
73 /* Route map rule name (e.g. as-path, metric) */
76 /* Function for value set or match. */
77 route_map_result_t (*func_apply
)(void *, struct prefix
*,
78 route_map_object_t
, void *);
80 /* Compile argument and return result as void *. */
81 void *(*func_compile
)(char *);
83 /* Free allocated value by func_compile (). */
84 void (*func_free
)(void *);
87 /* Route map apply error. */
90 /* Route map rule is missing. */
91 RMAP_RULE_MISSING
= 1,
93 /* Route map rule can't compile */
97 /* Route map rule list. */
98 struct route_map_rule_list
100 struct route_map_rule
*head
;
101 struct route_map_rule
*tail
;
104 /* Route map index structure. */
105 struct route_map_index
107 struct route_map
*map
;
109 /* Preference of this route map rule. */
112 /* Route map type permit or deny. */
113 enum route_map_type type
;
115 /* Do we follow old rules, or hop forward? */
116 route_map_end_t exitpolicy
;
118 /* If we're using "GOTO", to where do we go? */
121 /* Matching rule list. */
122 struct route_map_rule_list match_list
;
123 struct route_map_rule_list set_list
;
125 /* Make linked list. */
126 struct route_map_index
*next
;
127 struct route_map_index
*prev
;
130 /* Route map list structure. */
133 /* Name of route map. */
136 /* Route map's rule. */
137 struct route_map_index
*head
;
138 struct route_map_index
*tail
;
140 /* Make linked list. */
141 struct route_map
*next
;
142 struct route_map
*prev
;
146 void route_map_init ();
147 void route_map_init_vty ();
149 /* Add match statement to route map. */
151 route_map_add_match (struct route_map_index
*index
,
155 /* Delete specified route match rule. */
157 route_map_delete_match (struct route_map_index
*index
,
161 /* Add route-map set statement to the route map. */
163 route_map_add_set (struct route_map_index
*index
,
167 /* Delete route map set rule. */
169 route_map_delete_set (struct route_map_index
*index
, char *set_name
,
172 /* Install rule command to the match list. */
174 route_map_install_match (struct route_map_rule_cmd
*cmd
);
176 /* Install rule command to the set list. */
178 route_map_install_set (struct route_map_rule_cmd
*cmd
);
180 /* Lookup route map by name. */
182 route_map_lookup_by_name (char *name
);
184 /* Apply route map to the object. */
186 route_map_apply (struct route_map
*map
, struct prefix
*,
187 route_map_object_t object_type
, void *object
);
189 void route_map_add_hook (void (*func
) (char *));
190 void route_map_delete_hook (void (*func
) (char *));
191 void route_map_event_hook (void (*func
) (route_map_event_t
, char *));
194 #endif /* _ZEBRA_ROUTEMAP_H */