1/*
2 * Copyright (C) 2017 Mellanox Technologies Inc
3 *
4 *  This library is free software; you can redistribute it and/or
5 *  modify it under the terms of the GNU Lesser General Public
6 *  License as published by the Free Software Foundation; either
7 *  version 2.1 of the License, or (at your option) any later version.
8 *
9 *  This library is distributed in the hope that it will be useful,
10 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 *  Lesser General Public License for more details.
13 */
14
15struct semanage_ibendport;
16struct semanage_ibendport_key;
17typedef struct semanage_ibendport record_t;
18typedef struct semanage_ibendport_key record_key_t;
19#define DBASE_RECORD_DEFINED
20
21struct dbase_policydb;
22typedef struct dbase_policydb dbase_t;
23#define DBASE_DEFINED
24
25#include <sepol/ibendports.h>
26#include <semanage/handle.h>
27#include "ibendport_internal.h"
28#include "debug.h"
29#include "database_policydb.h"
30#include "semanage_store.h"
31
32/* IBENDPORT RECORD (SEPOL): POLICYDB extension : method table */
33record_policydb_table_t SEMANAGE_IBENDPORT_POLICYDB_RTABLE = {
34	.add = NULL,
35	.modify = (record_policydb_table_modify_t)sepol_ibendport_modify,
36	.set = NULL,
37	.query = (record_policydb_table_query_t)sepol_ibendport_query,
38	.count = (record_policydb_table_count_t)sepol_ibendport_count,
39	.exists = (record_policydb_table_exists_t)sepol_ibendport_exists,
40	.iterate = (record_policydb_table_iterate_t)sepol_ibendport_iterate,
41};
42
43int ibendport_policydb_dbase_init(semanage_handle_t *handle,
44				  dbase_config_t *dconfig)
45{
46	if (dbase_policydb_init(handle,
47				semanage_path(SEMANAGE_ACTIVE, SEMANAGE_STORE_KERNEL),
48				semanage_path(SEMANAGE_TMP, SEMANAGE_STORE_KERNEL),
49				&SEMANAGE_IBENDPORT_RTABLE,
50				&SEMANAGE_IBENDPORT_POLICYDB_RTABLE,
51				&dconfig->dbase) < 0)
52		return STATUS_ERR;
53
54	dconfig->dtable = &SEMANAGE_POLICYDB_DTABLE;
55
56	return STATUS_SUCCESS;
57}
58
59void ibendport_policydb_dbase_release(dbase_config_t *dconfig)
60{
61	dbase_policydb_release(dconfig->dbase);
62}
63