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#ifndef _NETLABEL_DOMAINHASH_H
32#define _NETLABEL_DOMAINHASH_H
33
34#include <linux/types.h>
35#include <linux/rcupdate.h>
36#include <linux/list.h>
37
38#include "netlabel_addrlist.h"
39
40
41
42#define NETLBL_DOMHSH_BITSIZE 7
43
44
45struct netlbl_domaddr_map {
46 struct list_head list4;
47 struct list_head list6;
48};
49struct netlbl_dommap_def {
50 u32 type;
51 union {
52 struct netlbl_domaddr_map *addrsel;
53 struct cipso_v4_doi *cipso;
54 struct calipso_doi *calipso;
55 };
56};
57#define netlbl_domhsh_addr4_entry(iter) \
58 container_of(iter, struct netlbl_domaddr4_map, list)
59struct netlbl_domaddr4_map {
60 struct netlbl_dommap_def def;
61
62 struct netlbl_af4list list;
63};
64#define netlbl_domhsh_addr6_entry(iter) \
65 container_of(iter, struct netlbl_domaddr6_map, list)
66struct netlbl_domaddr6_map {
67 struct netlbl_dommap_def def;
68
69 struct netlbl_af6list list;
70};
71
72struct netlbl_dom_map {
73 char *domain;
74 u16 family;
75 struct netlbl_dommap_def def;
76
77 u32 valid;
78 struct list_head list;
79 struct rcu_head rcu;
80};
81
82
83int netlbl_domhsh_init(u32 size);
84
85
86int netlbl_domhsh_add(struct netlbl_dom_map *entry,
87 struct netlbl_audit *audit_info);
88int netlbl_domhsh_add_default(struct netlbl_dom_map *entry,
89 struct netlbl_audit *audit_info);
90int netlbl_domhsh_remove_entry(struct netlbl_dom_map *entry,
91 struct netlbl_audit *audit_info);
92int netlbl_domhsh_remove_af4(const char *domain,
93 const struct in_addr *addr,
94 const struct in_addr *mask,
95 struct netlbl_audit *audit_info);
96int netlbl_domhsh_remove_af6(const char *domain,
97 const struct in6_addr *addr,
98 const struct in6_addr *mask,
99 struct netlbl_audit *audit_info);
100int netlbl_domhsh_remove(const char *domain, u16 family,
101 struct netlbl_audit *audit_info);
102int netlbl_domhsh_remove_default(u16 family, struct netlbl_audit *audit_info);
103struct netlbl_dom_map *netlbl_domhsh_getentry(const char *domain, u16 family);
104struct netlbl_dommap_def *netlbl_domhsh_getentry_af4(const char *domain,
105 __be32 addr);
106#if IS_ENABLED(CONFIG_IPV6)
107struct netlbl_dommap_def *netlbl_domhsh_getentry_af6(const char *domain,
108 const struct in6_addr *addr);
109int netlbl_domhsh_remove_af6(const char *domain,
110 const struct in6_addr *addr,
111 const struct in6_addr *mask,
112 struct netlbl_audit *audit_info);
113#endif
114
115int netlbl_domhsh_walk(u32 *skip_bkt,
116 u32 *skip_chain,
117 int (*callback) (struct netlbl_dom_map *entry, void *arg),
118 void *cb_arg);
119
120#endif
121