File: iterator_internal.h

package info (click to toggle)
setools 3.3.7-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 9,840 kB
  • sloc: ansic: 82,247; tcl: 13,145; cpp: 4,885; makefile: 1,603; yacc: 779; lex: 296; python: 57; sh: 50
file content (123 lines) | stat: -rw-r--r-- 3,953 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
 * @file
 * Declaration of the internal interface for 
 * qpol_iterator, an arbitrary valued policy component
 * iterator used to return lists of components.
 *
 * @author Kevin Carr kcarr@tresys.com
 * @author Jeremy A. Mowery jmowery@tresys.com
 * @author Jason Tang jtang@tresys.com
 *
 * Copyright (C) 2006-2007 Tresys Technology, LLC
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef QPOL_ITERATOR_INTERNAL_H
#define QPOL_ITERATOR_INTERNAL_H

#ifdef	__cplusplus
extern "C"
{
#endif

#include <sepol/policydb/policydb.h>
#include <sepol/policydb/avtab.h>
#include <qpol/iterator.h>
#include <qpol/policy.h>
#include <stddef.h>

	typedef struct hash_state
	{
		unsigned int bucket;
		hashtab_node_t *node;
		hashtab_t *table;
	} hash_state_t;

	typedef struct ebitmap_state
	{
		ebitmap_t *bmap;
		size_t cur;
	} ebitmap_state_t;

	typedef struct ocon_state
	{
		ocontext_t *head;
		ocontext_t *cur;
	} ocon_state_t;

	typedef struct perm_state
	{
		uint32_t perm_set;
		uint32_t obj_class_val;
		uint8_t cur;
	} perm_state_t;

	typedef struct avtab_state
	{
		uint32_t rule_type_mask;
		avtab_t *ucond_tab;
		avtab_t *cond_tab;
		uint32_t bucket;
		avtab_ptr_t node;
#define QPOL_AVTAB_STATE_AV   0
#define QPOL_AVTAB_STATE_COND 1
		unsigned which;
	} avtab_state_t;

	int qpol_iterator_create(const qpol_policy_t * policy, void *state,
				 void *(*get_cur) (const qpol_iterator_t * iter),
				 int (*next) (qpol_iterator_t * iter),
				 int (*end) (const qpol_iterator_t * iter),
				 size_t(*size) (const qpol_iterator_t * iter), void (*free_fn) (void *x), qpol_iterator_t ** iter);

	void *qpol_iterator_state(const qpol_iterator_t * iter);
	const policydb_t *qpol_iterator_policy(const qpol_iterator_t * iter);

	void *hash_state_get_cur(const qpol_iterator_t * iter);
	void *hash_state_get_cur_key(const qpol_iterator_t * iter);
	void *ebitmap_state_get_cur_type(const qpol_iterator_t * iter);
	void *ebitmap_state_get_cur_role(const qpol_iterator_t * iter);
	void *ebitmap_state_get_cur_cat(const qpol_iterator_t * iter);
	void *ebitmap_state_get_cur_permissive(const qpol_iterator_t * iter);
	void *ebitmap_state_get_cur_polcap(const qpol_iterator_t * iter);
	void *ocon_state_get_cur(const qpol_iterator_t * iter);
	void *perm_state_get_cur(const qpol_iterator_t * iter);
	void *avtab_state_get_cur(const qpol_iterator_t * iter);

	int hash_state_next(qpol_iterator_t * iter);
	int ebitmap_state_next(qpol_iterator_t * iter);
	int ocon_state_next(qpol_iterator_t * iter);
	int perm_state_next(qpol_iterator_t * iter);
	int avtab_state_next(qpol_iterator_t * iter);

	int hash_state_end(const qpol_iterator_t * iter);
	int ebitmap_state_end(const qpol_iterator_t * iter);
	int ocon_state_end(const qpol_iterator_t * iter);
	int perm_state_end(const qpol_iterator_t * iter);
	int avtab_state_end(const qpol_iterator_t * iter);

	size_t hash_state_size(const qpol_iterator_t * iter);
	size_t ebitmap_state_size(const qpol_iterator_t * iter);
	size_t ocon_state_size(const qpol_iterator_t * iter);
	size_t perm_state_size(const qpol_iterator_t * iter);
	size_t avtab_state_size(const qpol_iterator_t * iter);

	void ebitmap_state_destroy(void *es);
#ifdef	__cplusplus
}
#endif

#endif				       /* QPOL_ITERATOR_INTERNAL_H */