diff options
Diffstat (limited to 'filter/data.h')
-rw-r--r-- | filter/data.h | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/filter/data.h b/filter/data.h index b3767f7b..21a78bf6 100644 --- a/filter/data.h +++ b/filter/data.h @@ -11,6 +11,7 @@ #define _BIRD_FILTER_DATA_H_ #include "nest/bird.h" +#include "nest/route.h" /* Type numbers must be in 0..0xff range */ #define T_MASK 0xff @@ -20,6 +21,8 @@ enum f_type { /* Nothing. Simply nothing. */ T_VOID = 0, + T_NONE = 1, /* Special hack to represent missing arguments */ + /* User visible types, which fit in int */ T_INT = 0x10, T_BOOL = 0x11, @@ -39,6 +42,7 @@ enum f_type { T_ENUM_NETTYPE = 0x36, T_ENUM_RA_PREFERENCE = 0x37, T_ENUM_AF = 0x38, + T_ENUM_MPLS_POLICY = 0x39, /* new enums go here */ T_ENUM_EMPTY = 0x3f, /* Special hack for atomic_aggr */ @@ -58,11 +62,22 @@ enum f_type { T_LCLIST = 0x29, /* Large community list */ T_RD = 0x2a, /* Route distinguisher for VPN addresses */ T_PATH_MASK_ITEM = 0x2b, /* Path mask item for path mask constructors */ + T_BYTESTRING = 0x2c, + T_ROUTE = 0x78, + T_ROUTES_BLOCK = 0x79, T_SET = 0x80, T_PREFIX_SET = 0x81, } PACKED; +struct f_method { + struct symbol *sym; + struct f_inst *(*new_inst)(struct f_inst *obj, struct f_inst *args); + const struct f_method *next; + uint arg_num; + enum f_type args_type[]; +}; + /* Filter value; size of this affects filter memory consumption */ struct f_val { enum f_type type; /* T_* */ @@ -73,11 +88,13 @@ struct f_val { ip_addr ip; const net_addr *net; const char *s; + const struct adata *bs; const struct f_tree *t; const struct f_trie *ti; const struct adata *ad; const struct f_path_mask *path_mask; struct f_path_mask_item pmi; + struct rte *rte; } val; }; @@ -87,6 +104,7 @@ struct f_dynamic_attr { u8 bit; /* For bitfield accessors */ enum f_type f_type; /* Filter type */ uint ea_code; /* EA code */ + uint flags; }; enum f_sa_code { @@ -123,6 +141,7 @@ enum f_lval_type { /* Filter l-value */ struct f_lval { enum f_lval_type type; + struct f_inst *rte; union { struct symbol *sym; struct f_dynamic_attr da; @@ -275,8 +294,8 @@ trie_match_next_longest_ip6(net_addr_ip6 *n, ip6_addr *found) #define F_CMP_ERROR 999 const char *f_type_name(enum f_type t); - enum f_type f_type_element_type(enum f_type t); +struct sym_scope *f_type_method_scope(enum f_type t); int val_same(const struct f_val *v1, const struct f_val *v2); int val_compare(const struct f_val *v1, const struct f_val *v2); @@ -306,15 +325,33 @@ const struct adata *lclist_filter(struct linpool *pool, const struct adata *list /* Special undef value for paths and clists */ + static inline int -undef_value(struct f_val v) +val_is_undefined(struct f_val v) { return ((v.type == T_PATH) || (v.type == T_CLIST) || (v.type == T_ECLIST) || (v.type == T_LCLIST)) && (v.val.ad == &null_adata); } -extern const struct f_val f_const_empty_path, f_const_empty_clist, f_const_empty_eclist, f_const_empty_lclist, f_const_empty_prefix_set; +static inline struct f_val +val_empty(enum f_type t) +{ + switch (t) + { + case T_PATH: + case T_CLIST: + case T_ECLIST: + case T_LCLIST: + return (struct f_val) { .type = t, .val.ad = &null_adata }; + + default: + return (struct f_val) { }; + } +} + + +extern const struct f_val f_const_empty_prefix_set; enum filter_return f_eval(const struct f_line *expr, struct linpool *tmp_pool, struct f_val *pres); |