filter.h 1.4 KB
Newer Older
1
/*
Martin Mareš's avatar
Martin Mareš committed
2
 *	BIRD Internet Routing Daemon -- Filters
3
 *
Martin Mareš's avatar
Martin Mareš committed
4
 *	(c) 1999 Pavel Machek <pavel@ucw.cz>
5 6 7 8 9 10 11 12
 *
 *	Can be freely distributed and used under the terms of the GNU GPL.
 */

#ifndef _BIRD_FILT_H_
#define _BIRD_FILT_H_

#include "lib/resource.h"
13
#include "lib/ip.h"
14

15 16
struct f_inst {		/* Instruction */
  struct f_inst *next;	/* Structure is 16 bytes, anyway */
17 18 19 20
  int code;
  void *arg1, *arg2;
};

21 22 23 24 25
struct prefix {
  ip_addr ip;
  int len;
};

26 27 28 29
struct f_val {
  int type;
  union {
    int i;
30 31
    struct prefix *px;
    char *s;
32 33 34
  } val;
};

Martin Mareš's avatar
Martin Mareš committed
35 36 37 38 39
struct filter {
  char *name;
  struct f_inst *root;
};

40
void filters_postconfig(void);
41
struct f_inst *f_new_inst(void);
42

43 44
int f_run(struct filter *filter, struct rte **rte, struct ea_list **tmp_attrs, struct linpool *tmp_pool);
char *filter_name(struct filter *filter);
Martin Mareš's avatar
Martin Mareš committed
45

46 47

#define F_NOP 0
48 49 50
#define F_ACCEPT 1	/* Need to preserve ordering: accepts < rejects! */
#define F_MODIFY 2	/* FIXME: Introduce modification flags instead? */
#define F_REJECT 3
51 52
#define F_ERROR 4
#define F_QUITBIRD 5
53

54 55 56
#define FILTER_ACCEPT NULL
#define FILTER_REJECT ((void *) 1)

57 58 59 60
/* Type numbers must be in 0..0xff range */
#define T_MASK 0xff

/* Internal types */
61
#define T_VOID 0
62
#define T_RETURN 1
63 64 65 66 67 68 69 70 71 72 73 74 75

/* User visible types, which fit in int */
#define T_INT 0x10
#define T_BOOL 0x11
#define T_PAIR 0x12
#define T_ENUM 0x13

/* Bigger ones */
#define T_IP 0x20
#define T_PREFIX 0x21
#define T_STRING 0x22

#define T_SET 0x80
76

77
#endif