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