1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifndef _SS_AVTAB_H_
24#define _SS_AVTAB_H_
25
26struct avtab_key {
27 u16 source_type;
28 u16 target_type;
29 u16 target_class;
30#define AVTAB_ALLOWED 0x0001
31#define AVTAB_AUDITALLOW 0x0002
32#define AVTAB_AUDITDENY 0x0004
33#define AVTAB_AV (AVTAB_ALLOWED | AVTAB_AUDITALLOW | AVTAB_AUDITDENY)
34#define AVTAB_TRANSITION 0x0010
35#define AVTAB_MEMBER 0x0020
36#define AVTAB_CHANGE 0x0040
37#define AVTAB_TYPE (AVTAB_TRANSITION | AVTAB_MEMBER | AVTAB_CHANGE)
38#define AVTAB_ENABLED_OLD 0x80000000
39#define AVTAB_ENABLED 0x8000
40 u16 specified;
41};
42
43struct avtab_datum {
44 u32 data;
45};
46
47struct avtab_node {
48 struct avtab_key key;
49 struct avtab_datum datum;
50 struct avtab_node *next;
51};
52
53struct avtab {
54 struct avtab_node **htable;
55 u32 nel;
56 u32 nslot;
57 u16 mask;
58
59};
60
61int avtab_init(struct avtab *);
62int avtab_alloc(struct avtab *, u32);
63struct avtab_datum *avtab_search(struct avtab *h, struct avtab_key *k);
64void avtab_destroy(struct avtab *h);
65void avtab_hash_eval(struct avtab *h, char *tag);
66
67struct policydb;
68int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,
69 int (*insert)(struct avtab *a, struct avtab_key *k,
70 struct avtab_datum *d, void *p),
71 void *p);
72
73int avtab_read(struct avtab *a, void *fp, struct policydb *pol);
74int avtab_write_item(struct policydb *p, struct avtab_node *cur, void *fp);
75int avtab_write(struct policydb *p, struct avtab *a, void *fp);
76
77struct avtab_node *avtab_insert_nonunique(struct avtab *h, struct avtab_key *key,
78 struct avtab_datum *datum);
79
80struct avtab_node *avtab_search_node(struct avtab *h, struct avtab_key *key);
81
82struct avtab_node *avtab_search_node_next(struct avtab_node *node, int specified);
83
84void avtab_cache_init(void);
85void avtab_cache_destroy(void);
86
87#define MAX_AVTAB_HASH_BITS 11
88#define MAX_AVTAB_HASH_BUCKETS (1 << MAX_AVTAB_HASH_BITS)
89
90#endif
91
92