]> git.proxmox.com Git - mirror_frr.git/blame - lib/routemap.h
Revert "lib: Fix handling of poll"
[mirror_frr.git] / lib / routemap.h
CommitLineData
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 *
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.
20 */
21
22#ifndef _ZEBRA_ROUTEMAP_H
23#define _ZEBRA_ROUTEMAP_H
24
24873f0c
DS
25#include "prefix.h"
26
718e3744 27/* Route map's type. */
28enum route_map_type
29{
30 RMAP_PERMIT,
31 RMAP_DENY,
32 RMAP_ANY
33};
34
35typedef enum
36{
37 RMAP_MATCH,
38 RMAP_DENYMATCH,
39 RMAP_NOMATCH,
40 RMAP_ERROR,
41 RMAP_OKAY
42} route_map_result_t;
43
44typedef enum
45{
46 RMAP_RIP,
47 RMAP_RIPNG,
48 RMAP_OSPF,
49 RMAP_OSPF6,
7514fb77
PJ
50 RMAP_BGP,
51 RMAP_ZEBRA
718e3744 52} route_map_object_t;
53
54typedef enum
55{
56 RMAP_EXIT,
57 RMAP_GOTO,
58 RMAP_NEXT
59} route_map_end_t;
60
61typedef enum
62{
63 RMAP_EVENT_SET_ADDED,
64 RMAP_EVENT_SET_DELETED,
65 RMAP_EVENT_SET_REPLACED,
66 RMAP_EVENT_MATCH_ADDED,
67 RMAP_EVENT_MATCH_DELETED,
68 RMAP_EVENT_MATCH_REPLACED,
69 RMAP_EVENT_INDEX_ADDED,
518f0eb1
DS
70 RMAP_EVENT_INDEX_DELETED,
71 RMAP_EVENT_CALL_ADDED, /* call to another routemap added */
72 RMAP_EVENT_CALL_DELETED,
73 RMAP_EVENT_PLIST_ADDED,
74 RMAP_EVENT_PLIST_DELETED,
75 RMAP_EVENT_CLIST_ADDED,
76 RMAP_EVENT_CLIST_DELETED,
77 RMAP_EVENT_ECLIST_ADDED,
78 RMAP_EVENT_ECLIST_DELETED,
79 RMAP_EVENT_ASLIST_ADDED,
80 RMAP_EVENT_ASLIST_DELETED,
81 RMAP_EVENT_FILTER_ADDED,
82 RMAP_EVENT_FILTER_DELETED,
718e3744 83} route_map_event_t;
84
fee0f4c6 85/* Depth limit in RMAP recursion using RMAP_CALL. */
86#define RMAP_RECURSION_LIMIT 10
87
718e3744 88/* Route map rule structure for matching and setting. */
89struct route_map_rule_cmd
90{
91 /* Route map rule name (e.g. as-path, metric) */
27a43a81 92 const char *str;
718e3744 93
94 /* Function for value set or match. */
95 route_map_result_t (*func_apply)(void *, struct prefix *,
96 route_map_object_t, void *);
97
98 /* Compile argument and return result as void *. */
c9eca01b 99 void *(*func_compile)(const char *);
718e3744 100
101 /* Free allocated value by func_compile (). */
102 void (*func_free)(void *);
103};
104
105/* Route map apply error. */
106enum
107{
108 /* Route map rule is missing. */
109 RMAP_RULE_MISSING = 1,
110
111 /* Route map rule can't compile */
112 RMAP_COMPILE_ERROR
113};
114
115/* Route map rule list. */
116struct route_map_rule_list
117{
118 struct route_map_rule *head;
119 struct route_map_rule *tail;
120};
121
122/* Route map index structure. */
123struct route_map_index
124{
125 struct route_map *map;
4a8164e5 126 char *description;
718e3744 127
128 /* Preference of this route map rule. */
129 int pref;
130
131 /* Route map type permit or deny. */
132 enum route_map_type type;
133
134 /* Do we follow old rules, or hop forward? */
135 route_map_end_t exitpolicy;
136
137 /* If we're using "GOTO", to where do we go? */
138 int nextpref;
139
fee0f4c6 140 /* If we're using "CALL", to which route-map do ew go? */
141 char *nextrm;
142
718e3744 143 /* Matching rule list. */
144 struct route_map_rule_list match_list;
145 struct route_map_rule_list set_list;
146
147 /* Make linked list. */
148 struct route_map_index *next;
149 struct route_map_index *prev;
150};
151
152/* Route map list structure. */
153struct route_map
154{
155 /* Name of route map. */
156 char *name;
157
158 /* Route map's rule. */
159 struct route_map_index *head;
160 struct route_map_index *tail;
161
162 /* Make linked list. */
163 struct route_map *next;
164 struct route_map *prev;
518f0eb1
DS
165
166 /* Maintain update info */
167 int to_be_processed; /* True if modification isn't acted on yet */
168 int deleted; /* If 1, then this node will be deleted */
718e3744 169};
170
171/* Prototypes. */
8cc4198f 172extern void route_map_init (void);
173extern void route_map_init_vty (void);
228da428 174extern void route_map_finish (void);
718e3744 175
176/* Add match statement to route map. */
8cc4198f 177extern int route_map_add_match (struct route_map_index *index,
178 const char *match_name,
179 const char *match_arg);
718e3744 180
181/* Delete specified route match rule. */
8cc4198f 182extern int route_map_delete_match (struct route_map_index *index,
183 const char *match_name,
184 const char *match_arg);
718e3744 185
518f0eb1
DS
186extern const char *route_map_get_match_arg (struct route_map_index *index,
187 const char *match_name);
188
718e3744 189/* Add route-map set statement to the route map. */
8cc4198f 190extern int route_map_add_set (struct route_map_index *index,
191 const char *set_name,
192 const char *set_arg);
718e3744 193
194/* Delete route map set rule. */
8cc4198f 195extern int route_map_delete_set (struct route_map_index *index,
196 const char *set_name,
197 const char *set_arg);
718e3744 198
199/* Install rule command to the match list. */
8cc4198f 200extern void route_map_install_match (struct route_map_rule_cmd *cmd);
718e3744 201
202/* Install rule command to the set list. */
8cc4198f 203extern void route_map_install_set (struct route_map_rule_cmd *cmd);
718e3744 204
205/* Lookup route map by name. */
8cc4198f 206extern struct route_map * route_map_lookup_by_name (const char *name);
718e3744 207
208/* Apply route map to the object. */
8cc4198f 209extern route_map_result_t route_map_apply (struct route_map *map,
210 struct prefix *,
211 route_map_object_t object_type,
212 void *object);
213
214extern void route_map_add_hook (void (*func) (const char *));
215extern void route_map_delete_hook (void (*func) (const char *));
518f0eb1
DS
216extern void route_map_event_hook (void (*func) (route_map_event_t,
217 const char *));
218extern int route_map_mark_updated (const char *name, int deleted);
219extern int route_map_clear_updated (struct route_map *rmap);
5fe9f963 220extern void route_map_walk_update_list (int (*update_fn) (char *name));
518f0eb1
DS
221extern void route_map_upd8_dependency (route_map_event_t type, const char *arg,
222 const char *rmap_name);
223extern void route_map_notify_dependencies (const char *affected_name,
224 route_map_event_t event);
718e3744 225
226#endif /* _ZEBRA_ROUTEMAP_H */