16cd6a6acSopenharmony_ci/* Author : Stephen Smalley, <sds@tycho.nsa.gov> */ 26cd6a6acSopenharmony_ci 36cd6a6acSopenharmony_ci/* FLASK */ 46cd6a6acSopenharmony_ci 56cd6a6acSopenharmony_ci/* 66cd6a6acSopenharmony_ci * A security identifier table (sidtab) is a hash table 76cd6a6acSopenharmony_ci * of security context structures indexed by SID value. 86cd6a6acSopenharmony_ci */ 96cd6a6acSopenharmony_ci 106cd6a6acSopenharmony_ci#ifndef _SEPOL_POLICYDB_SIDTAB_H_ 116cd6a6acSopenharmony_ci#define _SEPOL_POLICYDB_SIDTAB_H_ 126cd6a6acSopenharmony_ci 136cd6a6acSopenharmony_ci#include <sepol/policydb/context.h> 146cd6a6acSopenharmony_ci 156cd6a6acSopenharmony_ci#ifdef __cplusplus 166cd6a6acSopenharmony_ciextern "C" { 176cd6a6acSopenharmony_ci#endif 186cd6a6acSopenharmony_ci 196cd6a6acSopenharmony_citypedef struct sidtab_node { 206cd6a6acSopenharmony_ci sepol_security_id_t sid; /* security identifier */ 216cd6a6acSopenharmony_ci context_struct_t context; /* security context structure */ 226cd6a6acSopenharmony_ci struct sidtab_node *next; 236cd6a6acSopenharmony_ci} sidtab_node_t; 246cd6a6acSopenharmony_ci 256cd6a6acSopenharmony_citypedef struct sidtab_node *sidtab_ptr_t; 266cd6a6acSopenharmony_ci 276cd6a6acSopenharmony_ci#define SIDTAB_HASH_BITS 7 286cd6a6acSopenharmony_ci#define SIDTAB_HASH_BUCKETS (1 << SIDTAB_HASH_BITS) 296cd6a6acSopenharmony_ci#define SIDTAB_HASH_MASK (SIDTAB_HASH_BUCKETS-1) 306cd6a6acSopenharmony_ci 316cd6a6acSopenharmony_ci#define SIDTAB_SIZE SIDTAB_HASH_BUCKETS 326cd6a6acSopenharmony_ci 336cd6a6acSopenharmony_citypedef struct { 346cd6a6acSopenharmony_ci sidtab_ptr_t *htable; 356cd6a6acSopenharmony_ci unsigned int nel; /* number of elements */ 366cd6a6acSopenharmony_ci unsigned int next_sid; /* next SID to allocate */ 376cd6a6acSopenharmony_ci unsigned char shutdown; 386cd6a6acSopenharmony_ci} sidtab_t; 396cd6a6acSopenharmony_ci 406cd6a6acSopenharmony_ciextern int sepol_sidtab_init(sidtab_t * s); 416cd6a6acSopenharmony_ci 426cd6a6acSopenharmony_ciextern int sepol_sidtab_insert(sidtab_t * s, 436cd6a6acSopenharmony_ci sepol_security_id_t sid, 446cd6a6acSopenharmony_ci context_struct_t * context); 456cd6a6acSopenharmony_ci 466cd6a6acSopenharmony_ciextern context_struct_t *sepol_sidtab_search(sidtab_t * s, 476cd6a6acSopenharmony_ci sepol_security_id_t sid); 486cd6a6acSopenharmony_ci 496cd6a6acSopenharmony_ciextern int sepol_sidtab_map(sidtab_t * s, 506cd6a6acSopenharmony_ci int (*apply) (sepol_security_id_t sid, 516cd6a6acSopenharmony_ci context_struct_t * context, 526cd6a6acSopenharmony_ci void *args), void *args); 536cd6a6acSopenharmony_ci 546cd6a6acSopenharmony_ciextern void sepol_sidtab_map_remove_on_error(sidtab_t * s, 556cd6a6acSopenharmony_ci int (*apply) (sepol_security_id_t 566cd6a6acSopenharmony_ci s, 576cd6a6acSopenharmony_ci context_struct_t * 586cd6a6acSopenharmony_ci context, void *args), 596cd6a6acSopenharmony_ci void *args); 606cd6a6acSopenharmony_ci 616cd6a6acSopenharmony_ciextern int sepol_sidtab_context_to_sid(sidtab_t * s, /* IN */ 626cd6a6acSopenharmony_ci context_struct_t * context, /* IN */ 636cd6a6acSopenharmony_ci sepol_security_id_t * sid); /* OUT */ 646cd6a6acSopenharmony_ci 656cd6a6acSopenharmony_ciextern void sepol_sidtab_hash_eval(sidtab_t * h, char *tag); 666cd6a6acSopenharmony_ci 676cd6a6acSopenharmony_ciextern void sepol_sidtab_destroy(sidtab_t * s); 686cd6a6acSopenharmony_ci 696cd6a6acSopenharmony_ciextern void sepol_sidtab_set(sidtab_t * dst, sidtab_t * src); 706cd6a6acSopenharmony_ci 716cd6a6acSopenharmony_ciextern void sepol_sidtab_shutdown(sidtab_t * s); 726cd6a6acSopenharmony_ci 736cd6a6acSopenharmony_ci#ifdef __cplusplus 746cd6a6acSopenharmony_ci} 756cd6a6acSopenharmony_ci#endif 766cd6a6acSopenharmony_ci 776cd6a6acSopenharmony_ci#endif /* _SIDTAB_H_ */ 786cd6a6acSopenharmony_ci 796cd6a6acSopenharmony_ci/* FLASK */ 80