Filter: Merged filter line item dumpers into common generated source
This commit is contained in:
parent
b256f24145
commit
de12cd18fb
7 changed files with 123 additions and 126 deletions
|
@ -22,11 +22,10 @@ $(o)inst-gen.h: $(s)decl.m4 $(s)f-inst.c $(objdir)/.dir-stamp
|
||||||
$(o)inst-gen.c: $(s)decl.m4 $(s)f-inst.c $(objdir)/.dir-stamp
|
$(o)inst-gen.c: $(s)decl.m4 $(s)f-inst.c $(objdir)/.dir-stamp
|
||||||
$(M4) $(M4FLAGS_FILTERS) -DTARGET=C -P $^ >$@
|
$(M4) $(M4FLAGS_FILTERS) -DTARGET=C -P $^ >$@
|
||||||
|
|
||||||
$(o)f-inst-dump.c: $(s)dump.m4 $(s)f-inst.c $(objdir)/.dir-stamp
|
$(o)filter.o: $(o)f-inst-interpret.c $(o)f-inst-postfixify.c $(o)f-inst-same.c $(o)inst-gen.h
|
||||||
$(M4) $(M4FLAGS_FILTERS) -P $^ >$@
|
|
||||||
|
|
||||||
$(o)filter.o: $(o)f-inst-interpret.c $(o)f-inst-postfixify.c $(o)f-inst-same.c $(o)f-inst-dump.c $(o)inst-gen.h
|
|
||||||
|
|
||||||
tests_src := tree_test.c filter_test.c trie_test.c
|
tests_src := tree_test.c filter_test.c trie_test.c
|
||||||
tests_targets := $(tests_targets) $(tests-target-files)
|
tests_targets := $(tests_targets) $(tests-target-files)
|
||||||
tests_objs := $(tests_objs) $(src-o-files)
|
tests_objs := $(tests_objs) $(src-o-files)
|
||||||
|
|
||||||
|
$(call clean,inst-gen.h inst-gen.c)
|
||||||
|
|
125
filter/decl.m4
125
filter/decl.m4
|
@ -10,6 +10,8 @@ m4_divert(-1)m4_dnl
|
||||||
# Global Diversions:
|
# Global Diversions:
|
||||||
# 4 enum fi_code
|
# 4 enum fi_code
|
||||||
# 5 enum fi_code to string
|
# 5 enum fi_code to string
|
||||||
|
# 6 dump line item
|
||||||
|
# 7 dump line item callers
|
||||||
# 1 struct f_inst_FI_...
|
# 1 struct f_inst_FI_...
|
||||||
# 2 union in struct f_inst
|
# 2 union in struct f_inst
|
||||||
# 3 constructors
|
# 3 constructors
|
||||||
|
@ -18,8 +20,10 @@ m4_divert(-1)m4_dnl
|
||||||
# 101 content of struct f_inst_FI_...
|
# 101 content of struct f_inst_FI_...
|
||||||
# 102 constructor arguments
|
# 102 constructor arguments
|
||||||
# 103 constructor body
|
# 103 constructor body
|
||||||
|
# 104 dump line item content
|
||||||
#
|
#
|
||||||
# Put-around Diversions: 9xx
|
# Diversions for TARGET=C: 8xx
|
||||||
|
# Diversions for TARGET=H: 9xx
|
||||||
|
|
||||||
# Flush the completed instruction
|
# Flush the completed instruction
|
||||||
m4_define(FID_END, `m4_divert(-1)')
|
m4_define(FID_END, `m4_divert(-1)')
|
||||||
|
@ -32,10 +36,13 @@ m4_define(FID_UNION, `FID_ZONE(2, Union member)')
|
||||||
m4_define(FID_NEW, `FID_ZONE(3, Constructor)')
|
m4_define(FID_NEW, `FID_ZONE(3, Constructor)')
|
||||||
m4_define(FID_ENUM, `FID_ZONE(4, Code enum)')
|
m4_define(FID_ENUM, `FID_ZONE(4, Code enum)')
|
||||||
m4_define(FID_ENUM_STR, `FID_ZONE(5, Code enum to string)')
|
m4_define(FID_ENUM_STR, `FID_ZONE(5, Code enum to string)')
|
||||||
|
m4_define(FID_DUMP, `FID_ZONE(6, Dump line)')
|
||||||
|
m4_define(FID_DUMP_CALLER, `FID_ZONE(7, Dump line caller)')
|
||||||
|
|
||||||
m4_define(FID_STRUCT_IN, `m4_divert(101)')
|
m4_define(FID_STRUCT_IN, `m4_divert(101)')
|
||||||
m4_define(FID_NEW_ARGS, `m4_divert(102)')
|
m4_define(FID_NEW_ARGS, `m4_divert(102)')
|
||||||
m4_define(FID_NEW_BODY, `m4_divert(103)')
|
m4_define(FID_NEW_BODY, `m4_divert(103)')
|
||||||
|
m4_define(FID_DUMP_BODY, `m4_divert(104)m4_define(FID_DUMP_BODY_EXISTS)')
|
||||||
|
|
||||||
m4_define(FID_ALL, `m4_ifdef([[FID_CURDIV]], [[m4_divert(FID_CURDIV)m4_undefine([[FID_CURDIV]])]])')
|
m4_define(FID_ALL, `m4_ifdef([[FID_CURDIV]], [[m4_divert(FID_CURDIV)m4_undefine([[FID_CURDIV]])]])')
|
||||||
m4_define(FID_C, `m4_ifelse(TARGET, [[C]], FID_ALL, [[m4_define(FID_CURDIV, m4_divnum)m4_divert(-1)]])')
|
m4_define(FID_C, `m4_ifelse(TARGET, [[C]], FID_ALL, [[m4_define(FID_CURDIV, m4_divnum)m4_divert(-1)]])')
|
||||||
|
@ -57,7 +64,9 @@ FID_NEW
|
||||||
struct f_inst *f_new_inst_]]INST_NAME()[[(enum f_instruction_code fi_code
|
struct f_inst *f_new_inst_]]INST_NAME()[[(enum f_instruction_code fi_code
|
||||||
m4_undivert(102)
|
m4_undivert(102)
|
||||||
)
|
)
|
||||||
FID_H ; FID_C
|
FID_H
|
||||||
|
;
|
||||||
|
FID_C
|
||||||
{
|
{
|
||||||
struct f_inst *what_ = cfg_allocz(sizeof(struct f_inst));
|
struct f_inst *what_ = cfg_allocz(sizeof(struct f_inst));
|
||||||
what_->fi_code = fi_code;
|
what_->fi_code = fi_code;
|
||||||
|
@ -67,6 +76,19 @@ FID_H ; FID_C
|
||||||
m4_undivert(103)
|
m4_undivert(103)
|
||||||
return what_;
|
return what_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FID_DUMP_CALLER
|
||||||
|
case INST_NAME(): f_dump_line_item_]]INST_NAME()[[(item, indent + 1); break;
|
||||||
|
|
||||||
|
FID_DUMP
|
||||||
|
m4_ifdef([[FID_DUMP_BODY_EXISTS]],
|
||||||
|
[[static inline void f_dump_line_item_]]INST_NAME()[[(const struct f_line_item *item, const int indent)]]
|
||||||
|
,
|
||||||
|
[[static inline void f_dump_line_item_]]INST_NAME()[[(const struct f_line_item *item UNUSED, const int indent UNUSED)]])
|
||||||
|
m4_undefine([[FID_DUMP_BODY_EXISTS]])
|
||||||
|
{
|
||||||
|
m4_undivert(104)
|
||||||
|
}
|
||||||
FID_ALL
|
FID_ALL
|
||||||
FID_END
|
FID_END
|
||||||
]])')
|
]])')
|
||||||
|
@ -80,23 +102,32 @@ FID_NEW_ARGS
|
||||||
, $1 $2
|
, $1 $2
|
||||||
FID_NEW_BODY
|
FID_NEW_BODY
|
||||||
what->$2 = $2;
|
what->$2 = $2;
|
||||||
|
m4_ifelse($3,,,[[
|
||||||
|
FID_DUMP_BODY
|
||||||
|
debug("%s$3\n", INDENT, $4);
|
||||||
|
]])
|
||||||
FID_END')
|
FID_END')
|
||||||
|
|
||||||
m4_define(ARG, `FID_MEMBER(const struct f_inst *, f$1)
|
m4_define(ARG, `FID_MEMBER(const struct f_inst *, f$1,,)
|
||||||
FID_NEW_BODY
|
FID_NEW_BODY
|
||||||
for (const struct f_inst *child = f$1; child; child = child->next) what_->size += child->size;
|
for (const struct f_inst *child = f$1; child; child = child->next) what_->size += child->size;
|
||||||
FID_END')
|
FID_END')
|
||||||
m4_define(ARG_ANY, `FID_MEMBER(const struct f_inst *, f$1)
|
m4_define(ARG_ANY, `FID_MEMBER(const struct f_inst *, f$1,,)
|
||||||
FID_NEW_BODY
|
FID_NEW_BODY
|
||||||
for (const struct f_inst *child = f$1; child; child = child->next) what_->size += child->size;
|
for (const struct f_inst *child = f$1; child; child = child->next) what_->size += child->size;
|
||||||
FID_END')
|
FID_END')
|
||||||
m4_define(LINE, `FID_MEMBER(const struct f_inst *, f$1)')
|
m4_define(LINE, `FID_MEMBER(const struct f_inst *, f$1,,)
|
||||||
|
FID_DUMP_BODY
|
||||||
|
f_dump_line(item->lines[$2], indent + 1);
|
||||||
|
FID_END')
|
||||||
m4_define(LINEP, `FID_STRUCT_IN
|
m4_define(LINEP, `FID_STRUCT_IN
|
||||||
const struct f_line *fl$1;
|
const struct f_line *fl$1;
|
||||||
|
FID_DUMP_BODY
|
||||||
|
f_dump_line(item->lines[$2], indent + 1)
|
||||||
FID_END')
|
FID_END')
|
||||||
m4_define(SYMBOL, `FID_MEMBER(const struct symbol *, sym)')
|
m4_define(SYMBOL, `FID_MEMBER(const struct symbol *, sym, symbol %s, item->sym->name)')
|
||||||
m4_define(VALI, `FID_MEMBER(struct f_val, vali)')
|
m4_define(VALI, `FID_MEMBER(struct f_val, vali, value %s, val_dump(&item->val))')
|
||||||
m4_define(VALP, `FID_MEMBER(const struct f_val *, valp)')
|
m4_define(VALP, `FID_MEMBER(const struct f_val *, valp, value %s, val_dump(&item->val))')
|
||||||
m4_define(VAR, `m4_dnl
|
m4_define(VAR, `m4_dnl
|
||||||
FID_STRUCT_IN
|
FID_STRUCT_IN
|
||||||
const struct f_val *valp;
|
const struct f_val *valp;
|
||||||
|
@ -105,39 +136,33 @@ FID_NEW_ARGS
|
||||||
, const struct symbol *sym
|
, const struct symbol *sym
|
||||||
FID_NEW_BODY
|
FID_NEW_BODY
|
||||||
what->valp = (what->sym = sym)->def;
|
what->valp = (what->sym = sym)->def;
|
||||||
|
FID_DUMP_BODY
|
||||||
|
debug("%svariable %s with value %s\n", INDENT, item->sym->name, val_dump(item->vp));
|
||||||
FID_END')
|
FID_END')
|
||||||
m4_define(FRET, `FID_MEMBER(enum filter_return, fret)')
|
m4_define(FRET, `FID_MEMBER(enum filter_return, fret, %s, filter_return_str(item->fret))')
|
||||||
m4_define(ECS, `FID_MEMBER(enum ec_subtype, ecs)')
|
m4_define(ECS, `FID_MEMBER(enum ec_subtype, ecs, ec subtype %s, ec_subtype_str(item->ecs))')
|
||||||
m4_define(RTC, `FID_MEMBER(const struct rtable_config *, rtc)')
|
m4_define(RTC, `FID_MEMBER(const struct rtable_config *, rtc, route table %s, item->rtc->name)')
|
||||||
m4_define(STATIC_ATTR, `FID_MEMBER(struct f_static_attr, sa)')
|
m4_define(STATIC_ATTR, `FID_MEMBER(struct f_static_attr, sa)')
|
||||||
m4_define(DYNAMIC_ATTR, `FID_MEMBER(struct f_dynamic_attr, da)')
|
m4_define(DYNAMIC_ATTR, `FID_MEMBER(struct f_dynamic_attr, da)')
|
||||||
m4_define(COUNT, `FID_MEMBER(uint, count)')
|
m4_define(COUNT, `FID_MEMBER(uint, count, number %u, item->count)')
|
||||||
m4_define(TREE, `FID_MEMBER(const struct f_tree *, tree)')
|
m4_define(TREE, `FID_MEMBER(const struct f_tree *, tree, tree %p, item->tree)')
|
||||||
m4_define(STRING, `FID_MEMBER(const char *, s)')
|
m4_define(STRING, `FID_MEMBER(const char *, s, string \"%s\", item->s)')
|
||||||
|
|
||||||
m4_define(FID_WR_UNDIVERT_LIST,FID_WR_DPUT(900))
|
m4_define(FID_WR_PUT_LIST)
|
||||||
m4_define(FID_WR_CUR_DIRECT,900)
|
m4_define(FID_WR_DROP_LIST)
|
||||||
m4_define(FID_WR_PUT, `m4_ifelse(1, m4_eval(m4_divnum > -1), [[m4_divert(-1)
|
|
||||||
m4_define([[FID_WR_CUR_DIRECT]], m4_eval(FID_WR_CUR_DIRECT + 1))
|
|
||||||
m4_define([[FID_WR_UNDIVERT_LIST]], FID_WR_UNDIVERT_LIST[[]]/* wrput $1 */FID_WR_DPUT($1)/* wrputdir FID_WR_CUR_DIRECT */FID_WR_DPUT(FID_WR_CUR_DIRECT))
|
|
||||||
m4_divert(FID_WR_CUR_DIRECT)]], [[m4_define([[FID_WR_UNDIVERT_LIST]], FID_WR_UNDIVERT_LIST[[]]/* wrdrop $1 */FID_WR_DROP($1))]])')
|
|
||||||
|
|
||||||
|
m4_define(FID_WR_IPUT, `m4_define([[FID_WR_CUR_DIRECT]], m4_eval(FID_WR_CUR_DIRECT + 1))m4_define([[FID_WR_PUT_LIST]], FID_WR_PUT_LIST[[]]FID_WR_DPUT($1)FID_WR_DPUT(FID_WR_CUR_DIRECT))m4_divert(FID_WR_CUR_DIRECT)')
|
||||||
|
m4_define(FID_WR_IDROP, `m4_define([[FID_WR_CUR_DIRECT]], m4_eval(FID_WR_CUR_DIRECT + 1))m4_define([[FID_WR_DROP_LIST]], FID_WR_DROP_LIST[[]]FID_WR_DPUT($1)FID_WR_DPUT(FID_WR_CUR_DIRECT))m4_divert(FID_WR_CUR_DIRECT)')
|
||||||
|
|
||||||
|
m4_define(FID_WR_DIRECT, `m4_define([[FID_WR_CUR_DIRECT]],$1)m4_ifelse(TARGET,[[$2]],[[m4_define([[FID_WR_PUT]], [[FID_WR_IPUT($]][[@)]])m4_define([[FID_WR_PUT_LIST]],FID_WR_PUT_LIST[[]]FID_WR_DPUT($1))]],[[m4_define([[FID_WR_PUT]], [[FID_WR_IDROP($]][[@)]])m4_define([[FID_WR_DROP_LIST]],FID_WR_DROP_LIST[[]]FID_WR_DPUT($1))]])m4_divert($1)')
|
||||||
|
|
||||||
|
m4_dnl m4_define(FID_WR_CUR_DIRECT,m4_ifelse(TARGET,`C',800,TARGET,`H',900,m4_errprint(`Bad TARGET: 'TARGET)m4_m4exit(1)))
|
||||||
m4_changequote([[,]])
|
m4_changequote([[,]])
|
||||||
m4_divert(900)
|
FID_WR_DIRECT(800,C)
|
||||||
FID_C
|
|
||||||
#include "nest/bird.h"
|
#include "nest/bird.h"
|
||||||
#include "filter/filter.h"
|
#include "filter/filter.h"
|
||||||
#include "filter/f-inst.h"
|
#include "filter/f-inst.h"
|
||||||
|
|
||||||
FID_H
|
|
||||||
|
|
||||||
/* Filter instruction codes */
|
|
||||||
enum f_instruction_code {
|
|
||||||
FID_WR_PUT(4)
|
|
||||||
};
|
|
||||||
|
|
||||||
FID_C
|
|
||||||
|
|
||||||
/* Instruction codes to string */
|
/* Instruction codes to string */
|
||||||
static const char * const f_instruction_name_str[] = {
|
static const char * const f_instruction_name_str[] = {
|
||||||
FID_WR_PUT(5)
|
FID_WR_PUT(5)
|
||||||
|
@ -152,7 +177,39 @@ f_instruction_name(enum f_instruction_code fi)
|
||||||
bug("Got unknown instruction code: %d", fi);
|
bug("Got unknown instruction code: %d", fi);
|
||||||
}
|
}
|
||||||
|
|
||||||
FID_H
|
/* Instruction constructors */
|
||||||
|
FID_WR_PUT(3)
|
||||||
|
|
||||||
|
/* Line dumpers */
|
||||||
|
#define INDENT (((const char *) f_dump_line_indent_str) + sizeof(f_dump_line_indent_str) - (indent) - 1)
|
||||||
|
static const char f_dump_line_indent_str[] = " ";
|
||||||
|
void f_dump_line(const struct f_line *dest, int indent);
|
||||||
|
|
||||||
|
FID_WR_PUT(6)
|
||||||
|
|
||||||
|
void f_dump_line(const struct f_line *dest, int indent)
|
||||||
|
{
|
||||||
|
if (!dest) {
|
||||||
|
debug("%sNo filter line (NULL)\n", INDENT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
debug("%sFilter line %p (len=%u)\n", INDENT, dest, dest->len);
|
||||||
|
for (uint i=0; i<dest->len; i++) {
|
||||||
|
const struct f_line_item *item = &dest->items[i];
|
||||||
|
debug("%sInstruction %s at line %u\n", INDENT, f_instruction_name(item->fi_code), item->lineno);
|
||||||
|
switch (item->fi_code) {
|
||||||
|
FID_WR_PUT(7)
|
||||||
|
default: bug("Unknown instruction %x in f_dump_line", item->fi_code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
debug("%sFilter line %p dump done\n", INDENT, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
FID_WR_DIRECT(900,H)
|
||||||
|
/* Filter instruction codes */
|
||||||
|
enum f_instruction_code {
|
||||||
|
FID_WR_PUT(4)
|
||||||
|
};
|
||||||
|
|
||||||
/* Per-instruction structures */
|
/* Per-instruction structures */
|
||||||
FID_WR_PUT(1)
|
FID_WR_PUT(1)
|
||||||
|
@ -167,12 +224,12 @@ struct f_inst {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
FID_ALL
|
|
||||||
/* Instruction constructors */
|
/* Instruction constructors */
|
||||||
FID_WR_PUT(3)
|
FID_WR_PUT(3)
|
||||||
|
|
||||||
m4_divert(-1)
|
m4_divert(-1)
|
||||||
m4_changequote(`,')
|
m4_changequote(`,')
|
||||||
|
|
||||||
m4_m4wrap(`INST_FLUSH()m4_define(FID_WR_DPUT, [[m4_undivert($1)]])m4_define(FID_WR_DROP, [[m4_divert(-1)m4_undivert($1)m4_divert(0)]])m4_divert(0)FID_WR_UNDIVERT_LIST[[]]m4_divert(-1)')
|
m4_m4wrap(`INST_FLUSH()m4_define(FID_WR_DPUT, [[m4_undivert($1)]])m4_divert(0)FID_WR_PUT_LIST[[]]m4_divert(-1)FID_WR_DROP_LIST[[]]')
|
||||||
|
|
||||||
m4_changequote([[,]])
|
m4_changequote([[,]])
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
m4_divert(-1)m4_dnl
|
|
||||||
#
|
|
||||||
# BIRD -- Dumping instruction lines
|
|
||||||
#
|
|
||||||
# (c) 2018 Maria Matejka <mq@jmq.cz>
|
|
||||||
#
|
|
||||||
# Can be freely distributed and used under the terms of the GNU GPL.
|
|
||||||
#
|
|
||||||
|
|
||||||
# Common aliases
|
|
||||||
m4_define(DNL, `m4_dnl')
|
|
||||||
|
|
||||||
m4_define(INST_FLUSH, `m4_ifdef([[INST_NAME]], [[
|
|
||||||
m4_divert(1)
|
|
||||||
case INST_NAME():
|
|
||||||
m4_undivert(2)
|
|
||||||
break;
|
|
||||||
m4_divert(-1)
|
|
||||||
]])')
|
|
||||||
m4_define(INST, `INST_FLUSH()m4_define([[INST_NAME]], [[$1]])')
|
|
||||||
|
|
||||||
m4_define(LINE, `m4_divert(2)f_dump_line(item->lines[$2], indent + 1);
|
|
||||||
m4_divert(-1)')
|
|
||||||
m4_define(LINEP, `LINE($@)')
|
|
||||||
m4_define(SYMBOL, `m4_divert(2)debug("%ssymbol %s\n", INDENT, item->sym->name);
|
|
||||||
m4_divert(-1)')
|
|
||||||
m4_define(VALI, `m4_divert(2)debug("%svalue %s\n", INDENT, val_dump(&item->val));
|
|
||||||
m4_divert(-1)')
|
|
||||||
m4_define(VAR, `m4_divert(2)debug("%svar %s: value %s\n", INDENT, item->sym->name, val_dump(item->vp));
|
|
||||||
m4_divert(-1)')
|
|
||||||
m4_define(FRET, `m4_divert(2)debug("%sfilter return value %d\n", INDENT, item->fret);
|
|
||||||
m4_divert(-1)')
|
|
||||||
m4_define(ECS, `m4_divert(2)debug("%sec subtype %d\n", INDENT, item->ecs);
|
|
||||||
m4_divert(-1)')
|
|
||||||
m4_define(RTC, `m4_divert(2)debug("%sroute table %s\n", INDENT, item->rtc->name);
|
|
||||||
m4_divert(-1)')
|
|
||||||
m4_define(STATIC_ATTR, `m4_divert(2)debug("%sstatic attribute %u/%u/%u\n", INDENT, item->sa.f_type, item->sa.sa_code, item->sa.readonly);
|
|
||||||
m4_divert(-1)')
|
|
||||||
m4_define(DYNAMIC_ATTR, `m4_divert(2)debug("%sdynamic attribute %u/%u/%u/%u\n", INDENT, item->da.type, item->da.bit, item->da.f_type, item->da.ea_code);
|
|
||||||
m4_divert(-1)')
|
|
||||||
m4_define(DUMP, `m4_divert(2)$1m4_divert(-1)')
|
|
||||||
|
|
||||||
m4_m4wrap(`
|
|
||||||
INST_FLUSH()
|
|
||||||
m4_divert(0)DNL
|
|
||||||
m4_undivert(1)
|
|
||||||
|
|
||||||
default: bug( "Unknown instruction %d (%c)", item->fi_code, item->fi_code & 0xff);
|
|
||||||
')
|
|
||||||
|
|
||||||
m4_changequote([[,]])
|
|
|
@ -112,34 +112,6 @@ val_format_str(struct filter_state *fs, struct f_val *v) {
|
||||||
|
|
||||||
static struct tbf rl_runtime_err = TBF_DEFAULT_LOG_LIMITS;
|
static struct tbf rl_runtime_err = TBF_DEFAULT_LOG_LIMITS;
|
||||||
|
|
||||||
#define INDENT (((const char *) f_dump_line_indent_str) + sizeof(f_dump_line_indent_str) - (indent) - 1)
|
|
||||||
static const char f_dump_line_indent_str[] = " ";
|
|
||||||
|
|
||||||
static void f_dump_line(const struct f_line *dest, int indent);
|
|
||||||
|
|
||||||
static void
|
|
||||||
f_dump_line_item(const struct f_line_item *item, int indent)
|
|
||||||
{
|
|
||||||
debug("%sInstruction %s at line %u\n", INDENT, f_instruction_name(item->fi_code), item->lineno);
|
|
||||||
switch (item->fi_code) {
|
|
||||||
#include "filter/f-inst-dump.c"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
f_dump_line(const struct f_line *dest, int indent)
|
|
||||||
{
|
|
||||||
if (!dest) {
|
|
||||||
debug("%sNo filter line (NULL)\n", INDENT);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
debug("%sFilter line %p (len=%u)\n", INDENT, dest, dest->len);
|
|
||||||
for (uint i=0; i<dest->len; i++)
|
|
||||||
f_dump_line_item(&dest->items[i], indent+1);
|
|
||||||
debug("%sFilter line %p dump done\n", INDENT, dest);
|
|
||||||
#undef INDENT
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint
|
static uint
|
||||||
postfixify(struct f_line *dest, const struct f_inst *what_, uint pos)
|
postfixify(struct f_line *dest, const struct f_inst *what_, uint pos)
|
||||||
{
|
{
|
||||||
|
@ -166,7 +138,7 @@ f_postfixify_concat(const struct f_inst * const inst[], uint count)
|
||||||
out->len = postfixify(out, inst[i], out->len);
|
out->len = postfixify(out, inst[i], out->len);
|
||||||
|
|
||||||
#if DEBUGGING
|
#if DEBUGGING
|
||||||
f_dump_line(out, 0);
|
// f_dump_line(out, 0);
|
||||||
#endif
|
#endif
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,21 @@ enum filter_return {
|
||||||
F_QUITBIRD,
|
F_QUITBIRD,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline const char *filter_return_str(const enum filter_return fret) {
|
||||||
|
switch (fret) {
|
||||||
|
#define FRS(x) case x: return #x
|
||||||
|
FRS(F_NOP);
|
||||||
|
FRS(F_NONL);
|
||||||
|
FRS(F_RETURN);
|
||||||
|
FRS(F_ACCEPT);
|
||||||
|
FRS(F_REJECT);
|
||||||
|
FRS(F_ERROR);
|
||||||
|
FRS(F_QUITBIRD);
|
||||||
|
#undef FRS
|
||||||
|
default: bug("This shall not happen");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct f_val;
|
struct f_val;
|
||||||
|
|
||||||
/* The filter encapsulating structure to be pointed-to from outside */
|
/* The filter encapsulating structure to be pointed-to from outside */
|
||||||
|
|
|
@ -72,12 +72,9 @@ ec_format(byte *buf, u64 ec)
|
||||||
char tbuf[16], *kind;
|
char tbuf[16], *kind;
|
||||||
|
|
||||||
type = ec >> 48;
|
type = ec >> 48;
|
||||||
switch (type & 0xf0ff)
|
kind = ec_subtype_str(type & 0xf0ff);
|
||||||
{
|
|
||||||
case EC_RT: kind = "rt"; break;
|
|
||||||
case EC_RO: kind = "ro"; break;
|
|
||||||
|
|
||||||
default:
|
if (!kind) {
|
||||||
kind = tbuf;
|
kind = tbuf;
|
||||||
bsprintf(kind, "unknown 0x%x", type);
|
bsprintf(kind, "unknown 0x%x", type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,6 +125,14 @@ enum ec_subtype {
|
||||||
EC_GENERIC = 0xFFFF,
|
EC_GENERIC = 0xFFFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline const char *ec_subtype_str(const enum ec_subtype ecs) {
|
||||||
|
switch (ecs) {
|
||||||
|
case EC_RT: return "rt";
|
||||||
|
case EC_RO: return "ro";
|
||||||
|
default: return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Transitive bit (for first u32 half of EC) */
|
/* Transitive bit (for first u32 half of EC) */
|
||||||
#define EC_TBIT 0x40000000
|
#define EC_TBIT 0x40000000
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue