Revision 5e173e9f filter/filter.h

View differences:

filter/filter.h
39 39
};
40 40

  
41 41
struct f_prefix {
42
  ip_addr ip;
43
  int len;
44
#define LEN_MASK 0xff
45
#define LEN_PLUS  0x1000000
46
#define LEN_MINUS 0x2000000
47
#define LEN_RANGE 0x4000000
48
  /* If range then prefix must be in range (len >> 16 & 0xff, len >> 8 & 0xff) */
42
  net_addr_union net;
43
  u8 lo, hi;
49 44
};
50 45

  
51 46
struct f_val {
......
53 48
  union {
54 49
    uint i;
55 50
    u64 ec;
56
    /*    ip_addr ip; Folded into prefix */	
57
    struct f_prefix px;
51
    ip_addr ip;
52
    const net_addr *net;
58 53
    char *s;
59 54
    struct f_tree *t;
60 55
    struct f_trie *ti;
......
81 76
void tree_format(struct f_tree *t, buffer *buf);
82 77

  
83 78
struct f_trie *f_new_trie(linpool *lp, uint node_size);
84
void *trie_add_prefix(struct f_trie *t, ip_addr px, int plen, int l, int h);
85
int trie_match_prefix(struct f_trie *t, ip_addr px, int plen);
79
void *trie_add_prefix(struct f_trie *t, net_addr *n, uint l, uint h);
80
int trie_match_net(struct f_trie *t, const net_addr *n);
86 81
int trie_same(struct f_trie *t1, struct f_trie *t2);
87 82
void trie_format(struct f_trie *t, buffer *buf);
88 83

  
89
void fprefix_get_bounds(struct f_prefix *px, int *l, int *h);
90

  
91
static inline void
92
trie_add_fprefix(struct f_trie *t, struct f_prefix *px)
93
{
94
  int l, h;
95
  fprefix_get_bounds(px, &l, &h);
96
  trie_add_prefix(t, px->ip, px->len & LEN_MASK, l, h);
97
}
98

  
99
static inline int
100
trie_match_fprefix(struct f_trie *t, struct f_prefix *px)
101
{
102
  return trie_match_prefix(t, px->ip, px->len & LEN_MASK);
103
}
104

  
105

  
106 84
struct ea_list;
107 85
struct rte;
108 86

  
......
163 141

  
164 142
/* Bigger ones */
165 143
#define T_IP 0x20
166
#define T_PREFIX 0x21
144
#define T_NET 0x21
167 145
#define T_STRING 0x22
168 146
#define T_PATH_MASK 0x23	/* mask for BGP path */
169 147
#define T_PATH 0x24		/* BGP path */
......
176 154
#define T_PREFIX_SET 0x81
177 155

  
178 156

  
179
#define SA_FROM		 1    
180
#define SA_GW		 2      
181
#define SA_NET		 3     
182
#define SA_PROTO	 4   
183
#define SA_SOURCE	 5  
184
#define SA_SCOPE	 6   
157
#define SA_FROM		 1
158
#define SA_GW		 2
159
#define SA_NET		 3
160
#define SA_PROTO	 4
161
#define SA_SOURCE	 5
162
#define SA_SCOPE	 6
185 163
#define SA_CAST    	 7
186 164
#define SA_DEST    	 8
187 165
#define SA_IFNAME  	 9

Also available in: Unified diff