1
2
3
4
5
6
7
8
9
10#ifndef _CONDITIONAL_H_
11#define _CONDITIONAL_H_
12
13#include "avtab.h"
14#include "symtab.h"
15#include "policydb.h"
16#include "../include/conditional.h"
17
18#define COND_EXPR_MAXDEPTH 10
19
20
21
22
23
24struct cond_expr {
25#define COND_BOOL 1
26#define COND_NOT 2
27#define COND_OR 3
28#define COND_AND 4
29#define COND_XOR 5
30#define COND_EQ 6
31#define COND_NEQ 7
32#define COND_LAST COND_NEQ
33 __u32 expr_type;
34 __u32 bool;
35 struct cond_expr *next;
36};
37
38
39
40
41
42
43struct cond_av_list {
44 struct avtab_node *node;
45 struct cond_av_list *next;
46};
47
48
49
50
51
52
53
54
55struct cond_node {
56 int cur_state;
57 struct cond_expr *expr;
58 struct cond_av_list *true_list;
59 struct cond_av_list *false_list;
60 struct cond_node *next;
61};
62
63int cond_policydb_init(struct policydb *p);
64void cond_policydb_destroy(struct policydb *p);
65
66int cond_init_bool_indexes(struct policydb *p);
67int cond_destroy_bool(void *key, void *datum, void *p);
68
69int cond_index_bool(void *key, void *datum, void *datap);
70
71int cond_read_bool(struct policydb *p, struct hashtab *h, void *fp);
72int cond_read_list(struct policydb *p, void *fp);
73int cond_write_bool(void *key, void *datum, void *ptr);
74int cond_write_list(struct policydb *p, struct cond_node *list, void *fp);
75
76void cond_compute_av(struct avtab *ctab, struct avtab_key *key,
77 struct av_decision *avd, struct extended_perms *xperms);
78void cond_compute_xperms(struct avtab *ctab, struct avtab_key *key,
79 struct extended_perms_decision *xpermd);
80int evaluate_cond_node(struct policydb *p, struct cond_node *node);
81
82#endif
83