Annotation of embedaddon/bird2/filter/f-inst.h, revision 1.1.1.1

1.1       misho       1: /*
                      2:  *     BIRD Internet Routing Daemon -- Filter instructions
                      3:  *
                      4:  *     (c) 1999 Pavel Machek <pavel@ucw.cz>
                      5:  *     (c) 2018--2019 Maria Matejka <mq@jmq.cz>
                      6:  *
                      7:  *     Can be freely distributed and used under the terms of the GNU GPL.
                      8:  *
                      9:  *     Filter interpreter data structures and internal API.
                     10:  *     See filter/f-inst.c for documentation.
                     11:  */
                     12: 
                     13: #ifndef _BIRD_F_INST_H_
                     14: #define _BIRD_F_INST_H_
                     15: 
                     16: #include "nest/bird.h"
                     17: #include "conf/conf.h"
                     18: #include "filter/filter.h"
                     19: #include "filter/data.h"
                     20: 
                     21: /* Flags for instructions */
                     22: enum f_instruction_flags {
                     23:   FIF_PRINTED = 1,             /* FI_PRINT_AND_DIE: message put in buffer */
                     24: } PACKED;
                     25: 
                     26: /* Include generated filter instruction declarations */
                     27: #include "filter/inst-gen.h"
                     28: 
                     29: #define f_new_inst(...) MACRO_CONCAT_AFTER(f_new_inst_, MACRO_FIRST(__VA_ARGS__))(__VA_ARGS__)
                     30: 
                     31: /* Convert the instruction back to the enum name */
                     32: const char *f_instruction_name(enum f_instruction_code fi);
                     33: 
                     34: /* Filter structures for execution */
                     35: /* Line of instructions to be unconditionally executed one after another */
                     36: struct f_line {
                     37:   uint len;                            /* Line length */
                     38:   u8 args;                             /* Function: Args required */
                     39:   u8 vars;
                     40:   struct f_line_item items[0];         /* The items themselves */
                     41: };
                     42: 
                     43: /* Convert the f_inst infix tree to the f_line structures */
                     44: struct f_line *f_linearize_concat(const struct f_inst * const inst[], uint count);
                     45: static inline struct f_line *f_linearize(const struct f_inst *root)
                     46: { return f_linearize_concat(&root, 1); }
                     47: 
                     48: void f_dump_line(const struct f_line *, uint indent);
                     49: 
                     50: struct filter *f_new_where(struct f_inst *);
                     51: static inline struct f_dynamic_attr f_new_dynamic_attr(u8 type, enum f_type f_type, uint code) /* Type as core knows it, type as filters know it, and code of dynamic attribute */
                     52: { return (struct f_dynamic_attr) { .type = type, .f_type = f_type, .ea_code = code }; }   /* f_type currently unused; will be handy for static type checking */
                     53: static inline struct f_dynamic_attr f_new_dynamic_attr_bit(u8 bit, enum f_type f_type, uint code) /* Type as core knows it, type as filters know it, and code of dynamic attribute */
                     54: { return (struct f_dynamic_attr) { .type = EAF_TYPE_BITFIELD, .bit = bit, .f_type = f_type, .ea_code = code }; }   /* f_type currently unused; will be handy for static type checking */
                     55: static inline struct f_static_attr f_new_static_attr(int f_type, int code, int readonly)
                     56: { return (struct f_static_attr) { .f_type = f_type, .sa_code = code, .readonly = readonly }; }
                     57: struct f_inst *f_generate_complex(enum f_instruction_code fi_code, struct f_dynamic_attr da, struct f_inst *argument);
                     58: struct f_inst *f_generate_roa_check(struct rtable_config *table, struct f_inst *prefix, struct f_inst *asn);
                     59: 
                     60: /* Hook for call bt_assert() function in configuration */
                     61: extern void (*bt_assert_hook)(int result, const struct f_line_item *assert);
                     62: 
                     63: /* Bird Tests */
                     64: struct f_bt_test_suite {
                     65:   node n;                      /* Node in config->tests */
                     66:   const struct f_line *fn;     /* Root of function */
                     67:   const struct f_line *cmp;    /* Compare to this function */
                     68:   const char *fn_name;         /* Name of test */
                     69:   const char *dsc;             /* Description */
                     70:   int result;                  /* Desired result */
                     71: };
                     72: 
                     73: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>