diff options
author | Jan Maria Matejka <mq@ucw.cz> | 2018-05-02 12:34:35 +0200 |
---|---|---|
committer | Jan Maria Matejka <mq@ucw.cz> | 2018-05-29 12:35:06 +0200 |
commit | c3becfe1934da2dc2c0881a71eac8a26f810791f (patch) | |
tree | afb194f5921a6bd629a32931d10d502d1d56471a | |
parent | 0ec6b5ecd37529d57079e13748c4ecbd336332c1 (diff) |
Filter: macro for recursive interpretation of instructions
-rw-r--r-- | filter/filter.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/filter/filter.c b/filter/filter.c index 2b22bfa3..66a9e05e 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -590,16 +590,18 @@ static struct tbf rl_runtime_err = TBF_DEFAULT_LOG_LIMITS; return res; \ } while(0) -#define ARG_ANY(n) \ - v##n = interpret(what->a##n.p); \ - if (v##n.type & T_RETURN) \ - return v##n; +#define ARG_ANY(n) INTERPRET(v##n, what->a##n.p) #define ARG(n,t) ARG_ANY(n) \ if (v##n.type != t) \ runtime("Argument %d of instruction %s must be of type %02x, got %02x", \ n, f_instruction_name(what->fi_code), t, v##n.type); +#define INTERPRET(val, what_) \ + val = interpret(what_); \ + if (val.type & T_RETURN) \ + return val; + #define ACCESS_RTE \ do { if (!f_rte) runtime("No route to access"); } while (0) @@ -747,7 +749,8 @@ interpret(struct f_inst *what) while (tt) { *vv = lp_alloc(f_pool, sizeof(struct f_path_mask)); if (tt->kind == PM_ASN_EXPR) { - struct f_val res = interpret((struct f_inst *) tt->val); + struct f_val res; + INTERPRET(res, (struct f_inst *) tt->val); (*vv)->kind = PM_ASN; if (res.type != T_INT) { runtime( "Error resolving path mask template: value not an integer" ); @@ -1312,9 +1315,7 @@ interpret(struct f_inst *what) } /* It is actually possible to have t->data NULL */ - res = interpret(t->data); - if (res.type & T_RETURN) - return res; + INTERPRET(res, t->data); } break; case FI_IP_MASK: /* IP.MASK(val) */ |