Annotation of embedaddon/quagga/lib/routemap.h, revision 1.1.1.3
1.1 misho 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:
25: /* Route map's type. */
26: enum route_map_type
27: {
28: RMAP_PERMIT,
29: RMAP_DENY,
30: RMAP_ANY
31: };
32:
33: typedef enum
34: {
35: RMAP_MATCH,
36: RMAP_DENYMATCH,
37: RMAP_NOMATCH,
38: RMAP_ERROR,
39: RMAP_OKAY
40: } route_map_result_t;
41:
42: typedef enum
43: {
44: RMAP_RIP,
45: RMAP_RIPNG,
1.1.1.2 misho 46: RMAP_BABEL,
1.1 misho 47: RMAP_OSPF,
48: RMAP_OSPF6,
49: RMAP_BGP,
1.1.1.3 ! misho 50: RMAP_ZEBRA,
! 51: RMAP_ISIS,
1.1 misho 52: } route_map_object_t;
53:
54: typedef enum
55: {
56: RMAP_EXIT,
57: RMAP_GOTO,
58: RMAP_NEXT
59: } route_map_end_t;
60:
61: typedef 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,
70: RMAP_EVENT_INDEX_DELETED
71: } route_map_event_t;
72:
73: /* Depth limit in RMAP recursion using RMAP_CALL. */
74: #define RMAP_RECURSION_LIMIT 10
75:
76: /* Route map rule structure for matching and setting. */
77: struct route_map_rule_cmd
78: {
79: /* Route map rule name (e.g. as-path, metric) */
80: const char *str;
81:
82: /* Function for value set or match. */
83: route_map_result_t (*func_apply)(void *, struct prefix *,
84: route_map_object_t, void *);
85:
86: /* Compile argument and return result as void *. */
87: void *(*func_compile)(const char *);
88:
89: /* Free allocated value by func_compile (). */
90: void (*func_free)(void *);
91: };
92:
93: /* Route map apply error. */
94: enum
95: {
96: /* Route map rule is missing. */
97: RMAP_RULE_MISSING = 1,
98:
99: /* Route map rule can't compile */
100: RMAP_COMPILE_ERROR
101: };
102:
103: /* Route map rule list. */
104: struct route_map_rule_list
105: {
106: struct route_map_rule *head;
107: struct route_map_rule *tail;
108: };
109:
110: /* Route map index structure. */
111: struct route_map_index
112: {
113: struct route_map *map;
114: char *description;
115:
116: /* Preference of this route map rule. */
117: int pref;
118:
119: /* Route map type permit or deny. */
120: enum route_map_type type;
121:
122: /* Do we follow old rules, or hop forward? */
123: route_map_end_t exitpolicy;
124:
125: /* If we're using "GOTO", to where do we go? */
126: int nextpref;
127:
128: /* If we're using "CALL", to which route-map do ew go? */
129: char *nextrm;
130:
131: /* Matching rule list. */
132: struct route_map_rule_list match_list;
133: struct route_map_rule_list set_list;
134:
135: /* Make linked list. */
136: struct route_map_index *next;
137: struct route_map_index *prev;
138: };
139:
140: /* Route map list structure. */
141: struct route_map
142: {
143: /* Name of route map. */
144: char *name;
145:
146: /* Route map's rule. */
147: struct route_map_index *head;
148: struct route_map_index *tail;
149:
150: /* Make linked list. */
151: struct route_map *next;
152: struct route_map *prev;
153: };
154:
155: /* Prototypes. */
156: extern void route_map_init (void);
157: extern void route_map_init_vty (void);
158: extern void route_map_finish (void);
159:
160: /* Add match statement to route map. */
161: extern int route_map_add_match (struct route_map_index *index,
162: const char *match_name,
163: const char *match_arg);
164:
165: /* Delete specified route match rule. */
166: extern int route_map_delete_match (struct route_map_index *index,
167: const char *match_name,
168: const char *match_arg);
169:
170: /* Add route-map set statement to the route map. */
171: extern int route_map_add_set (struct route_map_index *index,
172: const char *set_name,
173: const char *set_arg);
174:
175: /* Delete route map set rule. */
176: extern int route_map_delete_set (struct route_map_index *index,
177: const char *set_name,
178: const char *set_arg);
179:
180: /* Install rule command to the match list. */
181: extern void route_map_install_match (struct route_map_rule_cmd *cmd);
182:
183: /* Install rule command to the set list. */
184: extern void route_map_install_set (struct route_map_rule_cmd *cmd);
185:
186: /* Lookup route map by name. */
187: extern struct route_map * route_map_lookup_by_name (const char *name);
188:
189: /* Apply route map to the object. */
190: extern route_map_result_t route_map_apply (struct route_map *map,
191: struct prefix *,
192: route_map_object_t object_type,
193: void *object);
194:
195: extern void route_map_add_hook (void (*func) (const char *));
196: extern void route_map_delete_hook (void (*func) (const char *));
197: extern void route_map_event_hook (void (*func) (route_map_event_t, const char *));
198:
199: #endif /* _ZEBRA_ROUTEMAP_H */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>