xref: /aosp_15_r20/external/selinux/libsepol/include/sepol/ibendports.h (revision 2d543d20722ada2425b5bdab9d0d1d29470e7bba)
1*2d543d20SAndroid Build Coastguard Worker #ifndef _SEPOL_IBENDPORTS_H_
2*2d543d20SAndroid Build Coastguard Worker #define _SEPOL_IBENDPORTS_H_
3*2d543d20SAndroid Build Coastguard Worker 
4*2d543d20SAndroid Build Coastguard Worker #include <sepol/handle.h>
5*2d543d20SAndroid Build Coastguard Worker #include <sepol/policydb.h>
6*2d543d20SAndroid Build Coastguard Worker #include <sepol/ibendport_record.h>
7*2d543d20SAndroid Build Coastguard Worker 
8*2d543d20SAndroid Build Coastguard Worker #ifdef __cplusplus
9*2d543d20SAndroid Build Coastguard Worker extern "C" {
10*2d543d20SAndroid Build Coastguard Worker #endif
11*2d543d20SAndroid Build Coastguard Worker 
12*2d543d20SAndroid Build Coastguard Worker /* Return the number of ibendports */
13*2d543d20SAndroid Build Coastguard Worker extern int sepol_ibendport_count(sepol_handle_t *handle,
14*2d543d20SAndroid Build Coastguard Worker 				 const sepol_policydb_t *p,
15*2d543d20SAndroid Build Coastguard Worker 				 unsigned int *response);
16*2d543d20SAndroid Build Coastguard Worker 
17*2d543d20SAndroid Build Coastguard Worker /* Check if a ibendport exists */
18*2d543d20SAndroid Build Coastguard Worker extern int sepol_ibendport_exists(sepol_handle_t *handle,
19*2d543d20SAndroid Build Coastguard Worker 				  const sepol_policydb_t *policydb,
20*2d543d20SAndroid Build Coastguard Worker 				  const sepol_ibendport_key_t *key, int *response);
21*2d543d20SAndroid Build Coastguard Worker 
22*2d543d20SAndroid Build Coastguard Worker /* Query a ibendport - returns the ibendport, or NULL if not found */
23*2d543d20SAndroid Build Coastguard Worker extern int sepol_ibendport_query(sepol_handle_t *handle,
24*2d543d20SAndroid Build Coastguard Worker 				 const sepol_policydb_t *policydb,
25*2d543d20SAndroid Build Coastguard Worker 				 const sepol_ibendport_key_t *key,
26*2d543d20SAndroid Build Coastguard Worker 				 sepol_ibendport_t **response);
27*2d543d20SAndroid Build Coastguard Worker 
28*2d543d20SAndroid Build Coastguard Worker /* Modify a ibendport, or add it, if the key is not found */
29*2d543d20SAndroid Build Coastguard Worker extern int sepol_ibendport_modify(sepol_handle_t *handle,
30*2d543d20SAndroid Build Coastguard Worker 				  sepol_policydb_t *policydb,
31*2d543d20SAndroid Build Coastguard Worker 				  const sepol_ibendport_key_t *key,
32*2d543d20SAndroid Build Coastguard Worker 				  const sepol_ibendport_t *data);
33*2d543d20SAndroid Build Coastguard Worker 
34*2d543d20SAndroid Build Coastguard Worker /* Iterate the ibendports
35*2d543d20SAndroid Build Coastguard Worker  * The handler may return:
36*2d543d20SAndroid Build Coastguard Worker  * -1 to signal an error condition,
37*2d543d20SAndroid Build Coastguard Worker  * 1 to signal successful exit
38*2d543d20SAndroid Build Coastguard Worker  * 0 to signal continue
39*2d543d20SAndroid Build Coastguard Worker  */
40*2d543d20SAndroid Build Coastguard Worker extern int sepol_ibendport_iterate(sepol_handle_t *handle,
41*2d543d20SAndroid Build Coastguard Worker 				   const sepol_policydb_t *policydb,
42*2d543d20SAndroid Build Coastguard Worker 				   int (*fn)(const sepol_ibendport_t *ibendport,
43*2d543d20SAndroid Build Coastguard Worker 					     void *fn_arg), void *arg);
44*2d543d20SAndroid Build Coastguard Worker 
45*2d543d20SAndroid Build Coastguard Worker 
46*2d543d20SAndroid Build Coastguard Worker #ifdef __cplusplus
47*2d543d20SAndroid Build Coastguard Worker }
48*2d543d20SAndroid Build Coastguard Worker #endif
49*2d543d20SAndroid Build Coastguard Worker 
50*2d543d20SAndroid Build Coastguard Worker #endif
51