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 {
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 struct cond_expr *next;
34};
35
36
37
38
39
40
41struct cond_av_list {
42 struct avtab_node *node;
43 struct cond_av_list *next;
44};
45
46
47
48
49
50
51
52
53struct cond_node {
54 int cur_state;
55 struct cond_expr *expr;
56 struct cond_av_list *true_list;
57 struct cond_av_list *false_list;
58 struct cond_node *next;
59};
60
61int cond_policydb_init(struct policydb *p);
62void cond_policydb_destroy(struct policydb *p);
63
64int cond_init_bool_indexes(struct policydb *p);
65int cond_destroy_bool(void *key, void *datum, void *p);
66
67int cond_index_bool(void *key, void *datum, void *datap);
68
69int cond_read_bool(struct policydb *p, struct hashtab *h, void *fp);
70int cond_read_list(struct policydb *p, void *fp);
71int cond_write_bool(void *key, void *datum, void *ptr);
72int cond_write_list(struct policydb *p, struct cond_node *list, void *fp);
73
74void cond_compute_av(struct avtab *ctab, struct avtab_key *key,
75 struct av_decision *avd, struct extended_perms *xperms);
76void cond_compute_xperms(struct avtab *ctab, struct avtab_key *key,
77 struct extended_perms_decision *xpermd);
78int evaluate_cond_node(struct policydb *p, struct cond_node *node);
79
80#endif
81