]>
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 */
39 #define LEN_PLUS 0x1000000
40 #define LEN_MINUS 0x2000000
41 #define LEN_RANGE 0x4000000
42 /* If range then prefix must be in range (len >> 16 & 0xff, len >> 8 & 0xff) */
49 /* ip_addr ip; Folded into prefix */
55 struct f_path_mask
*path_mask
;
64 struct f_inst
*f_new_inst(void);
65 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 */
66 struct f_tree
*f_new_tree(void);
67 struct f_inst
*f_generate_complex(int operation
, int operation_aux
, struct f_inst
*dyn
, struct f_inst
*argument
);
69 struct f_tree
*build_tree(struct f_tree
*);
70 struct f_tree
*find_tree(struct f_tree
*t
, struct f_val val
);
71 int same_tree(struct f_tree
*t1
, struct f_tree
*t2
);
73 struct f_trie
*f_new_trie(void);
74 void trie_add_prefix(struct f_trie
*t
, struct f_prefix
*px
);
75 int trie_match_prefix(struct f_trie
*t
, struct f_prefix
*px
);
76 int trie_same(struct f_trie
*t1
, struct f_trie
*t2
);
77 int trie_print(struct f_trie
*t
, char *buf
, int blen
);
82 int f_run(struct filter
*filter
, struct rte
**rte
, struct ea_list
**tmp_attrs
, struct linpool
*tmp_pool
, int flags
);
83 int f_eval_int(struct f_inst
*expr
);
84 u32
f_eval_asn(struct f_inst
*expr
);
86 char *filter_name(struct filter
*filter
);
87 int filter_same(struct filter
*new, struct filter
*old
);
89 int i_same(struct f_inst
*f1
, struct f_inst
*f2
);
90 void f_prefix_get_bounds(struct f_prefix
*px
, int *l
, int *h
);
92 int val_compare(struct f_val v1
, struct f_val v2
);
93 void val_print(struct f_val v
);
97 #define F_ACCEPT 2 /* Need to preserve ordering: accepts < rejects! */
102 #define FILTER_ACCEPT NULL
103 #define FILTER_REJECT ((void *) 1)
105 /* Type numbers must be in 0..0xff range */
109 /* Do not use type of zero, that way we'll see errors easier. */
112 /* User visible types, which fit in int */
115 #define T_PAIR 0x12 /* Notice that pair is stored as integer: first << 16 | second */
117 /* Put enumerational types in 0x30..0x3f range */
118 #define T_ENUM_LO 0x30
119 #define T_ENUM_HI 0x3f
121 #define T_ENUM_RTS 0x30
122 #define T_ENUM_BGP_ORIGIN 0x31
123 #define T_ENUM_SCOPE 0x32
124 #define T_ENUM_RTC 0x33
125 #define T_ENUM_RTD 0x34
126 /* new enums go here */
127 #define T_ENUM_EMPTY 0x3f /* Special hack for atomic_aggr */
129 #define T_ENUM T_ENUM_LO ... T_ENUM_HI
133 #define T_PREFIX 0x21
134 #define T_STRING 0x22
135 #define T_PATH_MASK 0x23 /* mask for BGP path */
136 #define T_PATH 0x24 /* BGP path */
137 #define T_CLIST 0x25 /* Community list */
139 #define T_RETURN 0x40
141 #define T_PREFIX_SET 0x81
144 struct f_tree
*left
, *right
;
145 struct f_val from
, to
;
151 ip_addr addr
, mask
, accept
;
153 struct f_trie_node
*c
[2];
159 struct f_trie_node root
;
162 #define NEW_F_VAL struct f_val * val; val = cfg_alloc(sizeof(struct f_val));
164 #define FF_FORCE_TMPATTR 1 /* Force all attributes to be temporary */