00001 /** 00002 * @file 00003 * Declaration of the internal interface for 00004 * qpol_iterator, an arbitrary valued policy component 00005 * iterator used to return lists of components. 00006 * 00007 * @author Kevin Carr kcarr@tresys.com 00008 * @author Jeremy A. Mowery jmowery@tresys.com 00009 * @author Jason Tang jtang@tresys.com 00010 * 00011 * Copyright (C) 2006-2007 Tresys Technology, LLC 00012 * 00013 * This library is free software; you can redistribute it and/or 00014 * modify it under the terms of the GNU Lesser General Public 00015 * License as published by the Free Software Foundation; either 00016 * version 2.1 of the License, or (at your option) any later version. 00017 * 00018 * This library is distributed in the hope that it will be useful, 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00021 * Lesser General Public License for more details. 00022 * 00023 * You should have received a copy of the GNU Lesser General Public 00024 * License along with this library; if not, write to the Free Software 00025 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00026 */ 00027 00028 #ifndef QPOL_ITERATOR_INTERNAL_H 00029 #define QPOL_ITERATOR_INTERNAL_H 00030 00031 #ifdef __cplusplus 00032 extern "C" 00033 { 00034 #endif 00035 00036 #include <sepol/policydb/policydb.h> 00037 #include <sepol/policydb/avtab.h> 00038 #include <qpol/iterator.h> 00039 #include <qpol/policy.h> 00040 #include <stddef.h> 00041 00042 typedef struct hash_state 00043 { 00044 unsigned int bucket; 00045 hashtab_node_t *node; 00046 hashtab_t *table; 00047 } hash_state_t; 00048 00049 typedef struct ebitmap_state 00050 { 00051 ebitmap_t *bmap; 00052 size_t cur; 00053 } ebitmap_state_t; 00054 00055 typedef struct ocon_state 00056 { 00057 ocontext_t *head; 00058 ocontext_t *cur; 00059 } ocon_state_t; 00060 00061 typedef struct perm_state 00062 { 00063 uint32_t perm_set; 00064 uint32_t obj_class_val; 00065 uint8_t cur; 00066 } perm_state_t; 00067 00068 typedef struct avtab_state 00069 { 00070 uint32_t rule_type_mask; 00071 avtab_t *ucond_tab; 00072 avtab_t *cond_tab; 00073 uint32_t bucket; 00074 avtab_ptr_t node; 00075 #define QPOL_AVTAB_STATE_AV 0 00076 #define QPOL_AVTAB_STATE_COND 1 00077 unsigned which; 00078 } avtab_state_t; 00079 00080 int qpol_iterator_create(const qpol_policy_t * policy, void *state, 00081 void *(*get_cur) (const qpol_iterator_t * iter), 00082 int (*next) (qpol_iterator_t * iter), 00083 int (*end) (const qpol_iterator_t * iter), 00084 size_t(*size) (const qpol_iterator_t * iter), void (*free_fn) (void *x), qpol_iterator_t ** iter); 00085 00086 void *qpol_iterator_state(const qpol_iterator_t * iter); 00087 const policydb_t *qpol_iterator_policy(const qpol_iterator_t * iter); 00088 00089 void *hash_state_get_cur(const qpol_iterator_t * iter); 00090 void *hash_state_get_cur_key(const qpol_iterator_t * iter); 00091 void *ebitmap_state_get_cur_type(const qpol_iterator_t * iter); 00092 void *ebitmap_state_get_cur_role(const qpol_iterator_t * iter); 00093 void *ebitmap_state_get_cur_cat(const qpol_iterator_t * iter); 00094 void *ocon_state_get_cur(const qpol_iterator_t * iter); 00095 void *perm_state_get_cur(const qpol_iterator_t * iter); 00096 void *avtab_state_get_cur(const qpol_iterator_t * iter); 00097 00098 int hash_state_next(qpol_iterator_t * iter); 00099 int ebitmap_state_next(qpol_iterator_t * iter); 00100 int ocon_state_next(qpol_iterator_t * iter); 00101 int perm_state_next(qpol_iterator_t * iter); 00102 int avtab_state_next(qpol_iterator_t * iter); 00103 00104 int hash_state_end(const qpol_iterator_t * iter); 00105 int ebitmap_state_end(const qpol_iterator_t * iter); 00106 int ocon_state_end(const qpol_iterator_t * iter); 00107 int perm_state_end(const qpol_iterator_t * iter); 00108 int avtab_state_end(const qpol_iterator_t * iter); 00109 00110 size_t hash_state_size(const qpol_iterator_t * iter); 00111 size_t ebitmap_state_size(const qpol_iterator_t * iter); 00112 size_t ocon_state_size(const qpol_iterator_t * iter); 00113 size_t perm_state_size(const qpol_iterator_t * iter); 00114 size_t avtab_state_size(const qpol_iterator_t * iter); 00115 00116 void ebitmap_state_destroy(void *es); 00117 #ifdef __cplusplus 00118 } 00119 #endif 00120 00121 #endif /* QPOL_ITERATOR_INTERNAL_H */