2
/* Author : Stephen Smalley, <sds@epoch.ncsc.mil> */
4
/* Updated: Frank Mayer <mayerf@tresys.com> and Karl MacMillan <kmacmillan@tresys.com>
6
* Added conditional policy language extensions
8
* Copyright (C) 2003 Tresys Technology, LLC
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation, version 2.
17
* An access vector table (avtab) is a hash table
18
* of access vectors and transition types indexed
19
* by a type pair and a class. An access vector
20
* table is used to represent the type enforcement
27
typedef struct avtab_key {
28
__u32 source_type; /* source type */
29
__u32 target_type; /* target type */
30
__u32 target_class; /* target object class */
33
typedef struct avtab_datum {
34
#define AVTAB_ALLOWED 1
35
#define AVTAB_AUDITALLOW 2
36
#define AVTAB_AUDITDENY 4
37
#define AVTAB_AV (AVTAB_ALLOWED | AVTAB_AUDITALLOW | AVTAB_AUDITDENY)
38
#define AVTAB_TRANSITION 16
39
#define AVTAB_MEMBER 32
40
#define AVTAB_CHANGE 64
41
#define AVTAB_TYPE (AVTAB_TRANSITION | AVTAB_MEMBER | AVTAB_CHANGE)
42
#define AVTAB_ENABLED 0x80000000 /* reserved for used in cond_avtab */
43
__u32 specified; /* what fields are specified */
44
__u32 data[3]; /* access vectors or types */
45
#define avtab_allowed(x) (x)->data[0]
46
#define avtab_auditdeny(x) (x)->data[1]
47
#define avtab_auditallow(x) (x)->data[2]
48
#define avtab_transition(x) (x)->data[0]
49
#define avtab_change(x) (x)->data[1]
50
#define avtab_member(x) (x)->data[2]
53
typedef struct avtab_node *avtab_ptr_t;
59
void *parse_context; /* generic context pointer used by parser;
60
* not saved in binary policy */
63
typedef struct avtab {
65
__u32 nel; /* number of elements */
68
int avtab_init(avtab_t *);
70
int avtab_insert(avtab_t * h, avtab_key_t * k, avtab_datum_t * d);
72
avtab_datum_t *avtab_search(avtab_t * h, avtab_key_t * k, int specified);
74
void avtab_destroy(avtab_t * h);
76
int avtab_map(avtab_t * h,
77
int (*apply) (avtab_key_t * k,
82
void avtab_hash_eval(avtab_t * h, char *tag);
84
int avtab_read_item(void *fp, avtab_datum_t *avdatum, avtab_key_t *avkey);
86
int avtab_read(avtab_t * a, void * fp, __u32 config);
88
avtab_ptr_t avtab_insert_nonunique(avtab_t * h, avtab_key_t * key, avtab_datum_t * datum);
90
avtab_ptr_t avtab_insert_with_parse_context(avtab_t *h, avtab_key_t *key,
91
avtab_datum_t *datum, void *parse_context);
93
avtab_ptr_t avtab_search_node(avtab_t * h, avtab_key_t * key, int specified);
95
avtab_ptr_t avtab_search_node_next(avtab_ptr_t node, int specified);
97
#define AVTAB_HASH_BITS 15
98
#define AVTAB_HASH_BUCKETS (1 << AVTAB_HASH_BITS)
99
#define AVTAB_HASH_MASK (AVTAB_HASH_BUCKETS-1)
101
#define AVTAB_SIZE AVTAB_HASH_BUCKETS
103
#endif /* _AVTAB_H_ */