]> git.ipfire.org Git - thirdparty/bird.git/blob - filter/f-util.c
82dc1c3dfa150408314a3f57e5969fb4c1f4d6b1
[thirdparty/bird.git] / filter / f-util.c
1 /*
2 * Filters: utility functions
3 *
4 * Copyright 1998 Pavel Machek <pavel@ucw.cz>
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
9 #include "nest/bird.h"
10 #include "conf/conf.h"
11 #include "filter/filter.h"
12
13 struct f_inst *
14 f_new_inst(void)
15 {
16 struct f_inst * ret;
17 ret = cfg_alloc(sizeof(struct f_inst));
18 ret->code = ret->aux = 0;
19 ret->arg1 = ret->arg2 = ret->next = NULL;
20 return ret;
21 }
22
23 struct f_inst *
24 f_new_dynamic_attr(int type, int code)
25 {
26 struct f_inst *f = f_new_inst();
27 f->aux = type;
28 f->a2.i = code;
29 return f;
30 }
31
32 char *
33 filter_name(struct filter *filter)
34 {
35 if (!filter)
36 return "ACCEPT";
37 else if (filter == FILTER_REJECT)
38 return "REJECT";
39 else
40 return filter->name;
41 }