aboutsummaryrefslogtreecommitdiff
path: root/syscall_filter.h
blob: 4790d9fdc1ea2985bdd03fa13d6bc17236e4f3eb (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
25
26
27
28
29
30
31
32
33
34
35
36
37
/* syscall_filter.h
 * Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 *
 * Syscall filter functions.
 */

#ifndef SYSCALL_FILTER_H
#define SYSCALL_FILTER_H

#include "bpf.h"

#define NO_LOGGING  0
#define USE_LOGGING 1

struct filter_block {
	struct sock_filter *instrs;
	size_t len;

	struct filter_block *next;
	struct filter_block *last;
	size_t total_len;
};

struct bpf_labels;

struct filter_block *compile_section(int nr, const char *policy_line,
		unsigned int label_id, struct bpf_labels *labels);
int compile_filter(FILE *policy_file, struct sock_fprog *prog,
		int log_failures);

int flatten_block_list(struct filter_block *head, struct sock_filter *filter,
		size_t index, size_t cap);
void free_block_list(struct filter_block *head);

#endif /* SYSCALL_FILTER_H */