summaryrefslogtreecommitdiff
path: root/match.h
blob: c3821a753e68faa4ca9c8ae896ce642cfa21ce90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
 * struct kernel_set - Representation of in-kernel set data
 * @groups:	Number of 4-bit groups for each field (algorithm step 3.1)
 * @offset:	Offset of field within packet data, in bytes
 * @bsize:	Lookup table bucket size for field, in bytes
 * @lt:		Lookup table for field (algorithm steps 3.2 - 3.4)
 * @mt:		Mapping table for field (algorithm steps 3.5 - 3.6)
 * @map:	Result bitmap, two copies: swap indices instead of copying
 * @map_idx:	Index of current matching bitmap
 * @max_bsize:	Maximum lookup table bucket size for all fields in the set
 */
struct kernel_set {
	int groups[MAX_FIELDS];
	int offset[MAX_FIELDS];
	int bsize[MAX_FIELDS];
	uint8_t *lt[MAX_FIELDS];
	union map_bucket *mt[MAX_FIELDS];
	uint8_t *map[2];
	int map_idx;
	int max_bsize;
};

struct kernel_set *kernel_init(struct set *s, struct desc_spec **layout);
uint32_t match(struct kernel_set *ks, uint8_t *packet);