]> git.ipfire.org Git - thirdparty/bird.git/blob - filter/f-util.c
Added type parameter to f_new_dynamic_attr.
[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 <stdio.h>
10 #include <fcntl.h>
11 #include <unistd.h>
12 #include <sys/signal.h>
13 #include <setjmp.h>
14
15 #include "nest/bird.h"
16 #include "lib/lists.h"
17 #include "lib/resource.h"
18 #include "lib/socket.h"
19 #include "nest/route.h"
20 #include "nest/protocol.h"
21 #include "nest/iface.h"
22 #include "conf/conf.h"
23 #include "filter/filter.h"
24
25 struct f_inst *
26 f_new_inst(void)
27 {
28 struct f_inst * ret;
29 ret = cfg_alloc(sizeof(struct f_inst));
30 ret->code = ret->aux = 0;
31 ret->arg1 = ret->arg2 = ret->next = NULL;
32 return ret;
33 }
34
35 struct f_inst *
36 f_new_dynamic_attr(int type, int code)
37 {
38 struct f_inst *f = f_new_inst();
39 f->aux = type;
40 f->a2.i = code;
41 return f;
42 }
43
44 char *
45 filter_name(struct filter *filter)
46 {
47 if (!filter)
48 return "ACCEPT";
49 else if (filter == FILTER_REJECT)
50 return "REJECT";
51 else
52 return filter->name;
53 }