2 * NetLabel Domain Hash Table
4 * This file manages the domain hash table that NetLabel uses to determine
5 * which network labeling protocol to use for a given domain. The NetLabel
6 * system manages static and dynamic label mappings for network protocols such
9 * Author: Paul Moore <paul@paul-moore.com>
14 * (c) Copyright Hewlett-Packard Development Company, L.P., 2006, 2008
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
24 * the GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, see <http://www.gnu.org/licenses/>.
31 #ifndef _NETLABEL_DOMAINHASH_H
32 #define _NETLABEL_DOMAINHASH_H
34 #include <linux/types.h>
35 #include <linux/rcupdate.h>
36 #include <linux/list.h>
38 #include "netlabel_addrlist.h"
40 /* Domain hash table size */
41 /* XXX - currently this number is an uneducated guess */
42 #define NETLBL_DOMHSH_BITSIZE 7
44 /* Domain mapping definition structures */
45 struct netlbl_domaddr_map
{
46 struct list_head list4
;
47 struct list_head list6
;
49 struct netlbl_dommap_def
{
52 struct netlbl_domaddr_map
*addrsel
;
53 struct cipso_v4_doi
*cipso
;
56 #define netlbl_domhsh_addr4_entry(iter) \
57 container_of(iter, struct netlbl_domaddr4_map, list)
58 struct netlbl_domaddr4_map
{
59 struct netlbl_dommap_def def
;
61 struct netlbl_af4list list
;
63 #define netlbl_domhsh_addr6_entry(iter) \
64 container_of(iter, struct netlbl_domaddr6_map, list)
65 struct netlbl_domaddr6_map
{
66 struct netlbl_dommap_def def
;
68 struct netlbl_af6list list
;
71 struct netlbl_dom_map
{
73 struct netlbl_dommap_def def
;
76 struct list_head list
;
81 int netlbl_domhsh_init(u32 size
);
83 /* Manipulate the domain hash table */
84 int netlbl_domhsh_add(struct netlbl_dom_map
*entry
,
85 struct netlbl_audit
*audit_info
);
86 int netlbl_domhsh_add_default(struct netlbl_dom_map
*entry
,
87 struct netlbl_audit
*audit_info
);
88 int netlbl_domhsh_remove_entry(struct netlbl_dom_map
*entry
,
89 struct netlbl_audit
*audit_info
);
90 int netlbl_domhsh_remove_af4(const char *domain
,
91 const struct in_addr
*addr
,
92 const struct in_addr
*mask
,
93 struct netlbl_audit
*audit_info
);
94 int netlbl_domhsh_remove(const char *domain
, struct netlbl_audit
*audit_info
);
95 int netlbl_domhsh_remove_default(struct netlbl_audit
*audit_info
);
96 struct netlbl_dom_map
*netlbl_domhsh_getentry(const char *domain
);
97 struct netlbl_dommap_def
*netlbl_domhsh_getentry_af4(const char *domain
,
99 #if IS_ENABLED(CONFIG_IPV6)
100 struct netlbl_dommap_def
*netlbl_domhsh_getentry_af6(const char *domain
,
101 const struct in6_addr
*addr
);
104 int netlbl_domhsh_walk(u32
*skip_bkt
,
106 int (*callback
) (struct netlbl_dom_map
*entry
, void *arg
),