16cd6a6acSopenharmony_ci#ifndef _SEPOL_PORTS_H_
26cd6a6acSopenharmony_ci#define _SEPOL_PORTS_H_
36cd6a6acSopenharmony_ci
46cd6a6acSopenharmony_ci#include <sepol/handle.h>
56cd6a6acSopenharmony_ci#include <sepol/policydb.h>
66cd6a6acSopenharmony_ci#include <sepol/port_record.h>
76cd6a6acSopenharmony_ci
86cd6a6acSopenharmony_ci#ifdef __cplusplus
96cd6a6acSopenharmony_ciextern "C" {
106cd6a6acSopenharmony_ci#endif
116cd6a6acSopenharmony_ci
126cd6a6acSopenharmony_ci/* Return the number of ports */
136cd6a6acSopenharmony_ciextern int sepol_port_count(sepol_handle_t * handle,
146cd6a6acSopenharmony_ci			    const sepol_policydb_t * p, unsigned int *response);
156cd6a6acSopenharmony_ci
166cd6a6acSopenharmony_ci/* Check if a port exists */
176cd6a6acSopenharmony_ciextern int sepol_port_exists(sepol_handle_t * handle,
186cd6a6acSopenharmony_ci			     const sepol_policydb_t * policydb,
196cd6a6acSopenharmony_ci			     const sepol_port_key_t * key, int *response);
206cd6a6acSopenharmony_ci
216cd6a6acSopenharmony_ci/* Query a port - returns the port, or NULL if not found */
226cd6a6acSopenharmony_ciextern int sepol_port_query(sepol_handle_t * handle,
236cd6a6acSopenharmony_ci			    const sepol_policydb_t * policydb,
246cd6a6acSopenharmony_ci			    const sepol_port_key_t * key,
256cd6a6acSopenharmony_ci			    sepol_port_t ** response);
266cd6a6acSopenharmony_ci
276cd6a6acSopenharmony_ci/* Modify a port, or add it, if the key is not found */
286cd6a6acSopenharmony_ciextern int sepol_port_modify(sepol_handle_t * handle,
296cd6a6acSopenharmony_ci			     sepol_policydb_t * policydb,
306cd6a6acSopenharmony_ci			     const sepol_port_key_t * key,
316cd6a6acSopenharmony_ci			     const sepol_port_t * data);
326cd6a6acSopenharmony_ci
336cd6a6acSopenharmony_ci/* Iterate the ports
346cd6a6acSopenharmony_ci * The handler may return:
356cd6a6acSopenharmony_ci * -1 to signal an error condition,
366cd6a6acSopenharmony_ci * 1 to signal successful exit
376cd6a6acSopenharmony_ci * 0 to signal continue */
386cd6a6acSopenharmony_ci
396cd6a6acSopenharmony_ciextern int sepol_port_iterate(sepol_handle_t * handle,
406cd6a6acSopenharmony_ci			      const sepol_policydb_t * policydb,
416cd6a6acSopenharmony_ci			      int (*fn) (const sepol_port_t * port,
426cd6a6acSopenharmony_ci					 void *fn_arg), void *arg);
436cd6a6acSopenharmony_ci
446cd6a6acSopenharmony_ci#ifdef __cplusplus
456cd6a6acSopenharmony_ci}
466cd6a6acSopenharmony_ci#endif
476cd6a6acSopenharmony_ci
486cd6a6acSopenharmony_ci#endif
49