summaryrefslogtreecommitdiff
path: root/filter/f-inst.h
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2019-02-08 13:38:12 +0100
committerMaria Matejka <mq@ucw.cz>2019-02-20 22:30:54 +0100
commit4f082dfa892e95f86ca8137410992a248110b6ef (patch)
treee5dbd45a36579f82da8de060d137980f4e2a651b /filter/f-inst.h
parent0a793ebc6059f4354c62ccec62ef7c950988ca4a (diff)
Filter: merged filter instruction constructors, counting line size on instruction construct
Diffstat (limited to 'filter/f-inst.h')
-rw-r--r--filter/f-inst.h131
1 files changed, 6 insertions, 125 deletions
diff --git a/filter/f-inst.h b/filter/f-inst.h
index 63124aa1..1423e685 100644
--- a/filter/f-inst.h
+++ b/filter/f-inst.h
@@ -10,137 +10,21 @@
#ifndef _BIRD_F_INST_H_
#define _BIRD_F_INST_H_
+#include "nest/bird.h"
+#include "conf/conf.h"
#include "filter/filter.h"
-#include "filter/f-util.h"
+#include "filter/data.h"
-/* Filter l-value type */
-enum f_lval_type {
- F_LVAL_VARIABLE,
- F_LVAL_PREFERENCE,
- F_LVAL_SA,
- F_LVAL_EA,
-};
-
-/* Filter l-value */
-struct f_lval {
- enum f_lval_type type;
- union {
- const struct symbol *sym;
- struct f_dynamic_attr da;
- struct f_static_attr sa;
- };
-};
+/* Include generated filter instruction declarations */
+#include "filter/f-inst-decl.h"
-/* Filter instruction declarations */
-#define FI__LIST \
- F(FI_NOP) \
- F(FI_ADD, ARG, ARG) \
- F(FI_SUBTRACT, ARG, ARG) \
- F(FI_MULTIPLY, ARG, ARG) \
- F(FI_DIVIDE, ARG, ARG) \
- F(FI_AND, ARG, LINE) \
- F(FI_OR, ARG, LINE) \
- F(FI_PAIR_CONSTRUCT, ARG, ARG) \
- F(FI_EC_CONSTRUCT, ARG, ARG, ECS) \
- F(FI_LC_CONSTRUCT, ARG, ARG, ARG) \
- F(FI_PATHMASK_CONSTRUCT, ARG, COUNT) \
- F(FI_NEQ, ARG, ARG) \
- F(FI_EQ, ARG, ARG) \
- F(FI_LT, ARG, ARG) \
- F(FI_LTE, ARG, ARG) \
- F(FI_NOT, ARG) \
- F(FI_MATCH, ARG, ARG) \
- F(FI_NOT_MATCH, ARG, ARG) \
- F(FI_DEFINED, ARG) \
- F(FI_TYPE, ARG) \
- F(FI_IS_V4, ARG) \
- F(FI_SET, ARG, SYMBOL) \
- F(FI_CONSTANT, VALI) \
- F(FI_VARIABLE, SYMBOL) \
- F(FI_CONSTANT_INDIRECT, VALP) \
- F(FI_PRINT, ARG) \
- F(FI_CONDITION, ARG, LINE, LINE) \
- F(FI_PRINT_AND_DIE, ARG, FRET) \
- F(FI_RTA_GET, SA) \
- F(FI_RTA_SET, ARG, SA) \
- F(FI_EA_GET, EA) \
- F(FI_EA_SET, ARG, EA) \
- F(FI_EA_UNSET, EA) \
- F(FI_PREF_GET) \
- F(FI_PREF_SET, ARG) \
- F(FI_LENGTH, ARG) \
- F(FI_ROA_MAXLEN, ARG) \
- F(FI_ROA_ASN, ARG) \
- F(FI_SADR_SRC, ARG) \
- F(FI_IP, ARG) \
- F(FI_ROUTE_DISTINGUISHER, ARG) \
- F(FI_AS_PATH_FIRST, ARG) \
- F(FI_AS_PATH_LAST, ARG) \
- F(FI_AS_PATH_LAST_NAG, ARG) \
- F(FI_RETURN, ARG) \
- F(FI_CALL, SYMBOL, LINE) \
- F(FI_DROP_RESULT, ARG) \
- F(FI_SWITCH, ARG, TREE) \
- F(FI_IP_MASK, ARG, ARG) \
- F(FI_PATH_PREPEND, ARG, ARG) \
- F(FI_CLIST_ADD, ARG, ARG) \
- F(FI_CLIST_DEL, ARG, ARG) \
- F(FI_CLIST_FILTER, ARG, ARG) \
- F(FI_ROA_CHECK_IMPLICIT, RTC) \
- F(FI_ROA_CHECK_EXPLICIT, ARG, ARG, RTC) \
- F(FI_FORMAT, ARG) \
- F(FI_ASSERT, ARG, STRING)
-
-/* The enum itself */
-enum f_instruction_code {
-#define F(c, ...) c,
-FI__LIST
-#undef F
- FI__MAX,
-} PACKED;
+#define f_new_inst(...) MACRO_CONCAT_AFTER(f_new_inst_, MACRO_FIRST(__VA_ARGS__))(__VA_ARGS__)
/* Convert the instruction back to the enum name */
const char *f_instruction_name(enum f_instruction_code fi);
-struct f_inst;
-void f_inst_next(struct f_inst *first, const struct f_inst *append);
struct f_inst *f_clear_local_vars(struct f_inst *decls);
-#define FIA(x) , FIA_##x
-#define FIA_ARG const struct f_inst *
-#define FIA_LINE const struct f_inst *
-#define FIA_COUNT uint
-#define FIA_SYMBOL const struct symbol *
-#define FIA_VALI struct f_val
-#define FIA_VALP const struct f_val *
-#define FIA_FRET enum filter_return
-#define FIA_ECS enum ec_subtype
-#define FIA_SA struct f_static_attr
-#define FIA_EA struct f_dynamic_attr
-#define FIA_RTC const struct rtable_config *
-#define FIA_TREE const struct f_tree *
-#define FIA_STRING const char *
-#define F(c, ...) \
- struct f_inst *f_new_inst_##c(enum f_instruction_code MACRO_IFELSE(MACRO_ISLAST(__VA_ARGS__))()(MACRO_FOREACH(FIA, __VA_ARGS__)));
-FI__LIST
-#undef F
-#undef FIA_ARG
-#undef FIA_LINE
-#undef FIA_LINEP
-#undef FIA_COUNT
-#undef FIA_SYMBOL
-#undef FIA_VALI
-#undef FIA_VALP
-#undef FIA_FRET
-#undef FIA_ECS
-#undef FIA_SA
-#undef FIA_EA
-#undef FIA_RTC
-#undef FIA_STRING
-#undef FIA
-
-#define f_new_inst(...) MACRO_CONCAT_AFTER(f_new_inst_, MACRO_FIRST(__VA_ARGS__))(__VA_ARGS__)
-
/* Flags for instructions */
enum f_instruction_flags {
FIF_PRINTED = 1, /* FI_PRINT_AND_DIE: message put in buffer */
@@ -202,7 +86,4 @@ struct f_bt_test_suite {
const char *dsc; /* Description */
};
-/* Include the auto-generated structures */
-#include "filter/f-inst-struct.h"
-
#endif