1 2 /* Author : Stephen Smalley, <sds@epoch.ncsc.mil> */ 3 4 /* FLASK */ 5 6 /* 7 * A security identifier table (sidtab) is a hash table 8 * of security context structures indexed by SID value. 9 */ 10 11 #ifndef _SEPOL_POLICYDB_SIDTAB_H_ 12 #define _SEPOL_POLICYDB_SIDTAB_H_ 13 14 #include <sepol/policydb/context.h> 15 16 typedef struct sidtab_node { 17 sepol_security_id_t sid; /* security identifier */ 18 context_struct_t context; /* security context structure */ 19 struct sidtab_node *next; 20 } sidtab_node_t; 21 22 typedef struct sidtab_node *sidtab_ptr_t; 23 24 #define SIDTAB_HASH_BITS 7 25 #define SIDTAB_HASH_BUCKETS (1 << SIDTAB_HASH_BITS) 26 #define SIDTAB_HASH_MASK (SIDTAB_HASH_BUCKETS-1) 27 28 #define SIDTAB_SIZE SIDTAB_HASH_BUCKETS 29 30 typedef struct { 31 sidtab_ptr_t *htable; 32 unsigned int nel; /* number of elements */ 33 unsigned int next_sid; /* next SID to allocate */ 34 unsigned char shutdown; 35 } sidtab_t; 36 37 extern int sepol_sidtab_init(sidtab_t * s); 38 39 extern int sepol_sidtab_insert(sidtab_t * s, 40 sepol_security_id_t sid, 41 context_struct_t * context); 42 43 extern context_struct_t *sepol_sidtab_search(sidtab_t * s, 44 sepol_security_id_t sid); 45 46 extern int sepol_sidtab_map(sidtab_t * s, 47 int (*apply) (sepol_security_id_t sid, 48 context_struct_t * context, 49 void *args), void *args); 50 51 extern void sepol_sidtab_map_remove_on_error(sidtab_t * s, 52 int (*apply) (sepol_security_id_t 53 s, 54 context_struct_t * 55 context, void *args), 56 void *args); 57 58 extern int sepol_sidtab_context_to_sid(sidtab_t * s, /* IN */ 59 context_struct_t * context, /* IN */ 60 sepol_security_id_t * sid); /* OUT */ 61 62 extern void sepol_sidtab_hash_eval(sidtab_t * h, char *tag); 63 64 extern void sepol_sidtab_destroy(sidtab_t * s); 65 66 extern void sepol_sidtab_set(sidtab_t * dst, sidtab_t * src); 67 68 extern void sepol_sidtab_shutdown(sidtab_t * s); 69 70 #endif /* _SIDTAB_H_ */ 71 72 /* FLASK */ 73