Merge v3.2-rc4 into usb-next
[zen-stable.git] / net / netlabel / netlabel_unlabeled.h
blob700af49022a040a2d11a23747e51e1a0b6b9eca4
1 /*
2 * NetLabel Unlabeled Support
4 * This file defines functions for dealing with unlabeled packets for the
5 * NetLabel system. The NetLabel system manages static and dynamic label
6 * mappings for network protocols such as CIPSO and RIPSO.
8 * Author: Paul Moore <paul@paul-moore.com>
13 * (c) Copyright Hewlett-Packard Development Company, L.P., 2006
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
23 * the GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #ifndef _NETLABEL_UNLABELED_H
32 #define _NETLABEL_UNLABELED_H
34 #include <net/netlabel.h>
37 * The following NetLabel payloads are supported by the Unlabeled subsystem.
39 * o STATICADD
40 * This message is sent from an application to add a new static label for
41 * incoming unlabeled connections.
43 * Required attributes:
45 * NLBL_UNLABEL_A_IFACE
46 * NLBL_UNLABEL_A_SECCTX
48 * If IPv4 is specified the following attributes are required:
50 * NLBL_UNLABEL_A_IPV4ADDR
51 * NLBL_UNLABEL_A_IPV4MASK
53 * If IPv6 is specified the following attributes are required:
55 * NLBL_UNLABEL_A_IPV6ADDR
56 * NLBL_UNLABEL_A_IPV6MASK
58 * o STATICREMOVE
59 * This message is sent from an application to remove an existing static
60 * label for incoming unlabeled connections.
62 * Required attributes:
64 * NLBL_UNLABEL_A_IFACE
66 * If IPv4 is specified the following attributes are required:
68 * NLBL_UNLABEL_A_IPV4ADDR
69 * NLBL_UNLABEL_A_IPV4MASK
71 * If IPv6 is specified the following attributes are required:
73 * NLBL_UNLABEL_A_IPV6ADDR
74 * NLBL_UNLABEL_A_IPV6MASK
76 * o STATICLIST
77 * This message can be sent either from an application or by the kernel in
78 * response to an application generated STATICLIST message. When sent by an
79 * application there is no payload and the NLM_F_DUMP flag should be set.
80 * The kernel should response with a series of the following messages.
82 * Required attributes:
84 * NLBL_UNLABEL_A_IFACE
85 * NLBL_UNLABEL_A_SECCTX
87 * If IPv4 is specified the following attributes are required:
89 * NLBL_UNLABEL_A_IPV4ADDR
90 * NLBL_UNLABEL_A_IPV4MASK
92 * If IPv6 is specified the following attributes are required:
94 * NLBL_UNLABEL_A_IPV6ADDR
95 * NLBL_UNLABEL_A_IPV6MASK
97 * o STATICADDDEF
98 * This message is sent from an application to set the default static
99 * label for incoming unlabeled connections.
101 * Required attribute:
103 * NLBL_UNLABEL_A_SECCTX
105 * If IPv4 is specified the following attributes are required:
107 * NLBL_UNLABEL_A_IPV4ADDR
108 * NLBL_UNLABEL_A_IPV4MASK
110 * If IPv6 is specified the following attributes are required:
112 * NLBL_UNLABEL_A_IPV6ADDR
113 * NLBL_UNLABEL_A_IPV6MASK
115 * o STATICREMOVEDEF
116 * This message is sent from an application to remove the existing default
117 * static label for incoming unlabeled connections.
119 * If IPv4 is specified the following attributes are required:
121 * NLBL_UNLABEL_A_IPV4ADDR
122 * NLBL_UNLABEL_A_IPV4MASK
124 * If IPv6 is specified the following attributes are required:
126 * NLBL_UNLABEL_A_IPV6ADDR
127 * NLBL_UNLABEL_A_IPV6MASK
129 * o STATICLISTDEF
130 * This message can be sent either from an application or by the kernel in
131 * response to an application generated STATICLISTDEF message. When sent by
132 * an application there is no payload and the NLM_F_DUMP flag should be set.
133 * The kernel should response with the following message.
135 * Required attribute:
137 * NLBL_UNLABEL_A_SECCTX
139 * If IPv4 is specified the following attributes are required:
141 * NLBL_UNLABEL_A_IPV4ADDR
142 * NLBL_UNLABEL_A_IPV4MASK
144 * If IPv6 is specified the following attributes are required:
146 * NLBL_UNLABEL_A_IPV6ADDR
147 * NLBL_UNLABEL_A_IPV6MASK
149 * o ACCEPT
150 * This message is sent from an application to specify if the kernel should
151 * allow unlabled packets to pass if they do not match any of the static
152 * mappings defined in the unlabeled module.
154 * Required attributes:
156 * NLBL_UNLABEL_A_ACPTFLG
158 * o LIST
159 * This message can be sent either from an application or by the kernel in
160 * response to an application generated LIST message. When sent by an
161 * application there is no payload. The kernel should respond to a LIST
162 * message with a LIST message on success.
164 * Required attributes:
166 * NLBL_UNLABEL_A_ACPTFLG
170 /* NetLabel Unlabeled commands */
171 enum {
172 NLBL_UNLABEL_C_UNSPEC,
173 NLBL_UNLABEL_C_ACCEPT,
174 NLBL_UNLABEL_C_LIST,
175 NLBL_UNLABEL_C_STATICADD,
176 NLBL_UNLABEL_C_STATICREMOVE,
177 NLBL_UNLABEL_C_STATICLIST,
178 NLBL_UNLABEL_C_STATICADDDEF,
179 NLBL_UNLABEL_C_STATICREMOVEDEF,
180 NLBL_UNLABEL_C_STATICLISTDEF,
181 __NLBL_UNLABEL_C_MAX,
184 /* NetLabel Unlabeled attributes */
185 enum {
186 NLBL_UNLABEL_A_UNSPEC,
187 NLBL_UNLABEL_A_ACPTFLG,
188 /* (NLA_U8)
189 * if true then unlabeled packets are allowed to pass, else unlabeled
190 * packets are rejected */
191 NLBL_UNLABEL_A_IPV6ADDR,
192 /* (NLA_BINARY, struct in6_addr)
193 * an IPv6 address */
194 NLBL_UNLABEL_A_IPV6MASK,
195 /* (NLA_BINARY, struct in6_addr)
196 * an IPv6 address mask */
197 NLBL_UNLABEL_A_IPV4ADDR,
198 /* (NLA_BINARY, struct in_addr)
199 * an IPv4 address */
200 NLBL_UNLABEL_A_IPV4MASK,
201 /* (NLA_BINARY, struct in_addr)
202 * and IPv4 address mask */
203 NLBL_UNLABEL_A_IFACE,
204 /* (NLA_NULL_STRING)
205 * network interface */
206 NLBL_UNLABEL_A_SECCTX,
207 /* (NLA_BINARY)
208 * a LSM specific security context */
209 __NLBL_UNLABEL_A_MAX,
211 #define NLBL_UNLABEL_A_MAX (__NLBL_UNLABEL_A_MAX - 1)
213 /* NetLabel protocol functions */
214 int netlbl_unlabel_genl_init(void);
216 /* Unlabeled connection hash table size */
217 /* XXX - currently this number is an uneducated guess */
218 #define NETLBL_UNLHSH_BITSIZE 7
220 /* General Unlabeled init function */
221 int netlbl_unlabel_init(u32 size);
223 /* Static/Fallback label management functions */
224 int netlbl_unlhsh_add(struct net *net,
225 const char *dev_name,
226 const void *addr,
227 const void *mask,
228 u32 addr_len,
229 u32 secid,
230 struct netlbl_audit *audit_info);
231 int netlbl_unlhsh_remove(struct net *net,
232 const char *dev_name,
233 const void *addr,
234 const void *mask,
235 u32 addr_len,
236 struct netlbl_audit *audit_info);
238 /* Process Unlabeled incoming network packets */
239 int netlbl_unlabel_getattr(const struct sk_buff *skb,
240 u16 family,
241 struct netlbl_lsm_secattr *secattr);
243 /* Set the default configuration to allow Unlabeled packets */
244 int netlbl_unlabel_defconf(void);
246 #endif