summaryrefslogtreecommitdiffstats
path: root/src/db/sysdb_ipnetworks.h
blob: e2f9527567efd1852f0f190e7eb5ff3d63ebaa12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
    SSSD

    Authors:
        Samuel Cabrero <scabrero@suse.com>

    Copyright (C) 2020 SUSE LINUX GmbH, Nuernberg, Germany.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef SYSDB_IP_NETWORKS_H_
#define SYSDB_IP_NETWORKS_H_

#include "db/sysdb.h"

#define SYSDB_IP_NETWORK_CLASS          "network"
#define SYSDB_IP_NETWORK_CONTAINER      "cn=networks"

#define SYSDB_IP_NETWORK_CLASS_FILTER   "objectclass="SYSDB_IP_NETWORK_CLASS
#define SYSDB_IP_NETWORK_ATTR_NUMBER    "ipNetworkNumber"

#define SYSDB_TMPL_IP_NETWORK_BASE      SYSDB_IP_NETWORK_CONTAINER",cn=%s,"SYSDB_BASE
#define SYSDB_TMPL_IP_NETWORK           SYSDB_NAME"=%s,"SYSDB_TMPL_IP_NETWORK_BASE

#define SYSDB_IP_NETWORK_BYNAME_SUBFILTER \
    "(|("SYSDB_NAME"=%s)("SYSDB_NAME_ALIAS"=%s))"
#define SYSDB_IP_NETWORK_BYADDR_SUBFILTER \
    "("SYSDB_IP_NETWORK_ATTR_NUMBER"=%s)"

errno_t sysdb_getipnetworkbyname(TALLOC_CTX *mem_ctx,
                                 struct sss_domain_info *domain,
                                 const char *name,
                                 struct ldb_result **_res);

errno_t sysdb_getipnetworkbyaddr(TALLOC_CTX *mem_ctx,
                                 struct sss_domain_info *domain,
				 const char *address,
                                 struct ldb_result **_res);

errno_t
sysdb_store_ipnetwork(struct sss_domain_info *domain,
                      const char *primary_name,
                      const char **aliases,
                      const char *address,
                      struct sysdb_attrs *extra_attrs,
                      char **remove_attrs,
                      uint64_t cache_timeout,
                      time_t now);

struct ldb_dn *sysdb_ipnetwork_dn(TALLOC_CTX *mem_ctx,
                                  struct sss_domain_info *domain,
                                  const char *name);

errno_t sysdb_ipnetwork_add(TALLOC_CTX *mem_ctx,
                            struct sss_domain_info *domain,
                            const char *primary_name,
                            const char **aliases,
			    const char *address,
                            struct ldb_dn **dn);

errno_t sysdb_ipnetwork_delete(struct sss_domain_info *domain,
                               const char *name,
			       const char *address);

errno_t sysdb_search_ipnetworks(TALLOC_CTX *mem_ctx,
                                struct sss_domain_info *domain,
                                const char *sub_filter,
                                const char **attrs,
                                size_t *msgs_count,
                                struct ldb_message ***msgs);

errno_t sysdb_enumnetent(TALLOC_CTX *mem_ctx,
                         struct sss_domain_info *domain,
                         struct ldb_result **_res);

#endif /* SYSDB_IP_NETWORKS_H_ */