]>
git.ipfire.org Git - thirdparty/bird.git/blob - filter/filter.h
2 * BIRD Internet Routing Daemon -- Filters
4 * (c) 1999 Pavel Machek <pavel@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL.
12 #include "lib/resource.h"
14 #include "nest/route.h"
15 #include "nest/attrs.h"
17 struct f_inst
{ /* Instruction */
18 struct f_inst
*next
; /* Structure is 16 bytes, anyway */
35 /* Not enough fields in f_inst for three args used by roa_check() */
36 struct f_inst_roa_check
{
38 struct roa_table_config
*rtc
;
57 struct f_path_mask
*path_mask
;
66 struct f_inst
*f_new_inst(void);
67 struct f_inst
*f_new_dynamic_attr(int type
, int f_type
, int code
); /* Type as core knows it, type as filters know it, and code of dynamic attribute */
68 struct f_tree
*f_new_tree(void);
69 struct f_inst
*f_generate_complex(int operation
, int operation_aux
, struct f_inst
*dyn
, struct f_inst
*argument
);
70 struct f_inst
*f_generate_roa_check(struct symbol
*sym
, struct f_inst
*prefix
, struct f_inst
*asn
);
73 struct f_tree
*build_tree(struct f_tree
*);
74 struct f_tree
*find_tree(struct f_tree
*t
, struct f_val val
);
75 int same_tree(struct f_tree
*t1
, struct f_tree
*t2
);
76 void tree_format(struct f_tree
*t
, buffer
*buf
);
78 struct f_trie
*f_new_trie(linpool
*lp
, uint node_size
);
79 void *trie_add_prefix(struct f_trie
*t
, net_addr
*n
, uint l
, uint h
);
80 int trie_match_net(struct f_trie
*t
, const net_addr
*n
);
81 int trie_same(struct f_trie
*t1
, struct f_trie
*t2
);
82 void trie_format(struct f_trie
*t
, buffer
*buf
);
87 int f_run(struct filter
*filter
, struct rte
**rte
, struct ea_list
**tmp_attrs
, struct linpool
*tmp_pool
, int flags
);
88 struct f_val
f_eval_rte(struct f_inst
*expr
, struct rte
**rte
, struct linpool
*tmp_pool
);
89 struct f_val
f_eval(struct f_inst
*expr
, struct linpool
*tmp_pool
);
90 uint
f_eval_int(struct f_inst
*expr
);
91 u32
f_eval_asn(struct f_inst
*expr
);
93 char *filter_name(struct filter
*filter
);
94 int filter_same(struct filter
*new, struct filter
*old
);
96 int i_same(struct f_inst
*f1
, struct f_inst
*f2
);
98 int val_compare(struct f_val v1
, struct f_val v2
);
99 int val_same(struct f_val v1
, struct f_val v2
);
101 void val_format(struct f_val v
, buffer
*buf
);
106 #define F_ACCEPT 2 /* Need to preserve ordering: accepts < rejects! */
111 #define FILTER_ACCEPT NULL
112 #define FILTER_REJECT ((void *) 1)
114 /* Type numbers must be in 0..0xff range */
118 /* Do not use type of zero, that way we'll see errors easier. */
121 /* User visible types, which fit in int */
124 #define T_PAIR 0x12 /* Notice that pair is stored as integer: first << 16 | second */
127 /* Put enumerational types in 0x30..0x3f range */
128 #define T_ENUM_LO 0x30
129 #define T_ENUM_HI 0x3f
131 #define T_ENUM_RTS 0x30
132 #define T_ENUM_BGP_ORIGIN 0x31
133 #define T_ENUM_SCOPE 0x32
134 #define T_ENUM_RTC 0x33
135 #define T_ENUM_RTD 0x34
136 #define T_ENUM_ROA 0x35
137 /* new enums go here */
138 #define T_ENUM_EMPTY 0x3f /* Special hack for atomic_aggr */
140 #define T_ENUM T_ENUM_LO ... T_ENUM_HI
145 #define T_STRING 0x22
146 #define T_PATH_MASK 0x23 /* mask for BGP path */
147 #define T_PATH 0x24 /* BGP path */
148 #define T_CLIST 0x25 /* Community list */
149 #define T_ECLIST 0x26 /* Extended community list */
150 #define T_EC 0x27 /* Extended community value, u64 */
152 #define T_RETURN 0x40
154 #define T_PREFIX_SET 0x81
166 #define SA_IFINDEX 10
170 struct f_tree
*left
, *right
;
171 struct f_val from
, to
;
177 ip_addr addr
, mask
, accept
;
179 struct f_trie_node
*c
[2];
187 struct f_trie_node root
[0]; /* Root trie node follows */
190 #define NEW_F_VAL struct f_val * val; val = cfg_alloc(sizeof(struct f_val));
192 #define FF_FORCE_TMPATTR 1 /* Force all attributes to be temporary */