~ubuntu-branches/ubuntu/breezy/checkpolicy/breezy

« back to all changes in this revision

Viewing changes to avtab.h

  • Committer: Bazaar Package Importer
  • Author(s): Russell Coker
  • Date: 2004-05-20 04:32:00 UTC
  • Revision ID: james.westby@ubuntu.com-20040520043200-w4lzkx37dmmc3wt9
Tags: upstream-1.10
ImportĀ upstreamĀ versionĀ 1.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/* Author : Stephen Smalley, <sds@epoch.ncsc.mil> */
 
3
 
 
4
/* Updated: Frank Mayer <mayerf@tresys.com> and Karl MacMillan <kmacmillan@tresys.com>
 
5
 *
 
6
 *      Added conditional policy language extensions
 
7
 *
 
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.
 
12
 */
 
13
 
 
14
/* FLASK */
 
15
 
 
16
/*
 
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
 
21
 * tables.
 
22
 */
 
23
 
 
24
#ifndef _AVTAB_H_
 
25
#define _AVTAB_H_
 
26
 
 
27
typedef struct avtab_key {
 
28
        __u32 source_type;      /* source type */
 
29
        __u32 target_type;      /* target type */
 
30
        __u32 target_class;     /* target object class */
 
31
} avtab_key_t;
 
32
 
 
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]
 
51
} avtab_datum_t;
 
52
 
 
53
typedef struct avtab_node *avtab_ptr_t;
 
54
 
 
55
struct avtab_node {
 
56
        avtab_key_t key;
 
57
        avtab_datum_t datum;
 
58
        avtab_ptr_t next;
 
59
        void *parse_context;    /* generic context pointer used by parser;
 
60
                                 * not saved in binary policy */
 
61
};
 
62
 
 
63
typedef struct avtab {
 
64
        avtab_ptr_t *htable;
 
65
        __u32 nel;      /* number of elements */
 
66
} avtab_t;
 
67
 
 
68
int avtab_init(avtab_t *);
 
69
 
 
70
int avtab_insert(avtab_t * h, avtab_key_t * k, avtab_datum_t * d);
 
71
 
 
72
avtab_datum_t *avtab_search(avtab_t * h, avtab_key_t * k, int specified);
 
73
 
 
74
void avtab_destroy(avtab_t * h);
 
75
 
 
76
int avtab_map(avtab_t * h,
 
77
              int (*apply) (avtab_key_t * k,
 
78
                            avtab_datum_t * d,
 
79
                            void *args),
 
80
              void *args);
 
81
 
 
82
void avtab_hash_eval(avtab_t * h, char *tag);
 
83
 
 
84
int avtab_read_item(void *fp, avtab_datum_t *avdatum, avtab_key_t *avkey);
 
85
 
 
86
int avtab_read(avtab_t * a, void * fp, __u32 config);
 
87
 
 
88
avtab_ptr_t avtab_insert_nonunique(avtab_t * h, avtab_key_t * key, avtab_datum_t * datum);
 
89
 
 
90
avtab_ptr_t avtab_insert_with_parse_context(avtab_t *h, avtab_key_t *key,
 
91
                                            avtab_datum_t *datum, void *parse_context);
 
92
 
 
93
avtab_ptr_t avtab_search_node(avtab_t * h, avtab_key_t * key, int specified);
 
94
 
 
95
avtab_ptr_t avtab_search_node_next(avtab_ptr_t node, int specified);
 
96
 
 
97
#define AVTAB_HASH_BITS 15
 
98
#define AVTAB_HASH_BUCKETS (1 << AVTAB_HASH_BITS)
 
99
#define AVTAB_HASH_MASK (AVTAB_HASH_BUCKETS-1)
 
100
 
 
101
#define AVTAB_SIZE AVTAB_HASH_BUCKETS
 
102
 
 
103
#endif  /* _AVTAB_H_ */
 
104
 
 
105
/* FLASK */
 
106