2 * Filters: utility functions
4 * Copyright 1998 Pavel Machek <pavel@ucw.cz>
5 * 2017 Jan Maria Matejka <mq@ucw.cz>
7 * Can be freely distributed and used under the terms of the GNU GPL.
10 #include "nest/bird.h"
11 #include "conf/conf.h"
12 #include "filter/filter.h"
14 #define P(a,b) ((a<<8) | b)
17 f_new_inst(enum f_instruction_code fi_code
)
20 ret
= cfg_allocz(sizeof(struct f_inst
));
21 ret
->fi_code
= fi_code
;
22 ret
->lineno
= ifs
->lino
;
27 f_new_inst_da(enum f_instruction_code fi_code
, struct f_dynamic_attr da
)
29 struct f_inst
*ret
= f_new_inst(fi_code
);
31 ret
->a2
.i
= da
.ea_code
;
36 f_new_inst_sa(enum f_instruction_code fi_code
, struct f_static_attr sa
)
38 struct f_inst
*ret
= f_new_inst(fi_code
);
40 ret
->a2
.i
= sa
.sa_code
;
41 ret
->a1
.i
= sa
.readonly
;
46 * Generate set_dynamic( operation( get_dynamic(), argument ) )
49 f_generate_complex(int operation
, int operation_aux
, struct f_dynamic_attr da
, struct f_inst
*argument
)
51 struct f_inst
*set_dyn
= f_new_inst_da(FI_EA_SET
, da
),
52 *oper
= f_new_inst(operation
),
53 *get_dyn
= f_new_inst_da(FI_EA_GET
, da
);
55 oper
->aux
= operation_aux
;
57 oper
->a2
.p
= argument
;
65 f_generate_roa_check(struct symbol
*sym
, struct f_inst
*prefix
, struct f_inst
*asn
)
67 struct f_inst_roa_check
*ret
= cfg_allocz(sizeof(struct f_inst_roa_check
));
68 ret
->i
.fi_code
= FI_ROA_CHECK
;
69 ret
->i
.lineno
= ifs
->lino
;
72 /* prefix == NULL <-> asn == NULL */
74 if ((sym
->class != SYM_ROA
) || ! sym
->def
)
75 cf_error("%s is not a ROA table", sym
->name
);
82 filter_name(struct filter
*filter
)
86 else if (filter
== FILTER_REJECT
)
88 else if (!filter
->name
)