blob: 05d96431f81984061b575fd6adbad5c5de2ced19 [file] [log] [blame]
Paul Moored15c3452006-08-03 16:48:37 -07001/*
2 * NetLabel Management Support
3 *
4 * This file defines the management functions for the NetLabel system. The
5 * NetLabel system manages static and dynamic label mappings for network
6 * protocols such as CIPSO and RIPSO.
7 *
8 * Author: Paul Moore <paul.moore@hp.com>
9 *
10 */
11
12/*
13 * (c) Copyright Hewlett-Packard Development Company, L.P., 2006
14 *
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.
19 *
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.
24 *
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
28 *
29 */
30
31#ifndef _NETLABEL_MGMT_H
32#define _NETLABEL_MGMT_H
33
34#include <net/netlabel.h>
Paul Moorec783f1c2008-01-29 08:37:52 -050035#include <asm/atomic.h>
Paul Moored15c3452006-08-03 16:48:37 -070036
37/*
Paul Moorefd385852006-09-25 15:56:37 -070038 * The following NetLabel payloads are supported by the management interface.
Paul Moored15c3452006-08-03 16:48:37 -070039 *
40 * o ADD:
41 * Sent by an application to add a domain mapping to the NetLabel system.
Paul Moored15c3452006-08-03 16:48:37 -070042 *
Paul Moorefd385852006-09-25 15:56:37 -070043 * Required attributes:
Paul Moored15c3452006-08-03 16:48:37 -070044 *
Paul Moorefd385852006-09-25 15:56:37 -070045 * NLBL_MGMT_A_DOMAIN
46 * NLBL_MGMT_A_PROTOCOL
Paul Moored15c3452006-08-03 16:48:37 -070047 *
Paul Moore63c41682008-10-10 10:16:32 -040048 * If IPv4 is specified the following attributes are required:
49 *
50 * NLBL_MGMT_A_IPV4ADDR
51 * NLBL_MGMT_A_IPV4MASK
52 *
53 * If IPv6 is specified the following attributes are required:
54 *
55 * NLBL_MGMT_A_IPV6ADDR
56 * NLBL_MGMT_A_IPV6MASK
57 *
Paul Moorefd385852006-09-25 15:56:37 -070058 * If using NETLBL_NLTYPE_CIPSOV4 the following attributes are required:
Paul Moored15c3452006-08-03 16:48:37 -070059 *
Paul Moorefd385852006-09-25 15:56:37 -070060 * NLBL_MGMT_A_CV4DOI
Paul Moored15c3452006-08-03 16:48:37 -070061 *
Paul Moorefd385852006-09-25 15:56:37 -070062 * If using NETLBL_NLTYPE_UNLABELED no other attributes are required.
Paul Moored15c3452006-08-03 16:48:37 -070063 *
64 * o REMOVE:
65 * Sent by an application to remove a domain mapping from the NetLabel
Paul Moorefd385852006-09-25 15:56:37 -070066 * system.
Paul Moored15c3452006-08-03 16:48:37 -070067 *
Paul Moorefd385852006-09-25 15:56:37 -070068 * Required attributes:
Paul Moored15c3452006-08-03 16:48:37 -070069 *
Paul Moorefd385852006-09-25 15:56:37 -070070 * NLBL_MGMT_A_DOMAIN
Paul Moored15c3452006-08-03 16:48:37 -070071 *
Paul Moorefd385852006-09-25 15:56:37 -070072 * o LISTALL:
Paul Moored15c3452006-08-03 16:48:37 -070073 * This message can be sent either from an application or by the kernel in
Paul Moorefd385852006-09-25 15:56:37 -070074 * response to an application generated LISTALL message. When sent by an
75 * application there is no payload and the NLM_F_DUMP flag should be set.
76 * The kernel should respond with a series of the following messages.
Paul Moored15c3452006-08-03 16:48:37 -070077 *
Paul Moorefd385852006-09-25 15:56:37 -070078 * Required attributes:
Paul Moored15c3452006-08-03 16:48:37 -070079 *
Paul Moorefd385852006-09-25 15:56:37 -070080 * NLBL_MGMT_A_DOMAIN
Paul Moore63c41682008-10-10 10:16:32 -040081 *
82 * If the IP address selectors are not used the following attribute is
83 * required:
84 *
Paul Moorefd385852006-09-25 15:56:37 -070085 * NLBL_MGMT_A_PROTOCOL
Paul Moored15c3452006-08-03 16:48:37 -070086 *
Paul Moore63c41682008-10-10 10:16:32 -040087 * If the IP address selectors are used then the following attritbute is
88 * required:
89 *
90 * NLBL_MGMT_A_SELECTORLIST
91 *
92 * If the mapping is using the NETLBL_NLTYPE_CIPSOV4 type then the following
93 * attributes are required:
Paul Moored15c3452006-08-03 16:48:37 -070094 *
Paul Moorefd385852006-09-25 15:56:37 -070095 * NLBL_MGMT_A_CV4DOI
Paul Moored15c3452006-08-03 16:48:37 -070096 *
Paul Moore63c41682008-10-10 10:16:32 -040097 * If the mapping is using the NETLBL_NLTYPE_UNLABELED type no other
98 * attributes are required.
Paul Moored15c3452006-08-03 16:48:37 -070099 *
100 * o ADDDEF:
101 * Sent by an application to set the default domain mapping for the NetLabel
Paul Moorefd385852006-09-25 15:56:37 -0700102 * system.
Paul Moored15c3452006-08-03 16:48:37 -0700103 *
Paul Moorefd385852006-09-25 15:56:37 -0700104 * Required attributes:
Paul Moored15c3452006-08-03 16:48:37 -0700105 *
Paul Moorefd385852006-09-25 15:56:37 -0700106 * NLBL_MGMT_A_PROTOCOL
Paul Moored15c3452006-08-03 16:48:37 -0700107 *
Paul Moorefd385852006-09-25 15:56:37 -0700108 * If using NETLBL_NLTYPE_CIPSOV4 the following attributes are required:
Paul Moored15c3452006-08-03 16:48:37 -0700109 *
Paul Moorefd385852006-09-25 15:56:37 -0700110 * NLBL_MGMT_A_CV4DOI
Paul Moored15c3452006-08-03 16:48:37 -0700111 *
Paul Moorefd385852006-09-25 15:56:37 -0700112 * If using NETLBL_NLTYPE_UNLABELED no other attributes are required.
Paul Moored15c3452006-08-03 16:48:37 -0700113 *
114 * o REMOVEDEF:
115 * Sent by an application to remove the default domain mapping from the
Paul Moorefd385852006-09-25 15:56:37 -0700116 * NetLabel system, there is no payload.
Paul Moored15c3452006-08-03 16:48:37 -0700117 *
118 * o LISTDEF:
119 * This message can be sent either from an application or by the kernel in
120 * response to an application generated LISTDEF message. When sent by an
Paul Moorefd385852006-09-25 15:56:37 -0700121 * application there is no payload. On success the kernel should send a
122 * response using the following format.
Paul Moored15c3452006-08-03 16:48:37 -0700123 *
Paul Moore63c41682008-10-10 10:16:32 -0400124 * If the IP address selectors are not used the following attribute is
125 * required:
Paul Moored15c3452006-08-03 16:48:37 -0700126 *
Paul Moorefd385852006-09-25 15:56:37 -0700127 * NLBL_MGMT_A_PROTOCOL
Paul Moored15c3452006-08-03 16:48:37 -0700128 *
Paul Moore63c41682008-10-10 10:16:32 -0400129 * If the IP address selectors are used then the following attritbute is
130 * required:
131 *
132 * NLBL_MGMT_A_SELECTORLIST
133 *
134 * If the mapping is using the NETLBL_NLTYPE_CIPSOV4 type then the following
135 * attributes are required:
Paul Moored15c3452006-08-03 16:48:37 -0700136 *
Paul Moorefd385852006-09-25 15:56:37 -0700137 * NLBL_MGMT_A_CV4DOI
Paul Moored15c3452006-08-03 16:48:37 -0700138 *
Paul Moore63c41682008-10-10 10:16:32 -0400139 * If the mapping is using the NETLBL_NLTYPE_UNLABELED type no other
140 * attributes are required.
Paul Moored15c3452006-08-03 16:48:37 -0700141 *
Paul Moorefd385852006-09-25 15:56:37 -0700142 * o PROTOCOLS:
143 * Sent by an application to request a list of configured NetLabel protocols
144 * in the kernel. When sent by an application there is no payload and the
145 * NLM_F_DUMP flag should be set. The kernel should respond with a series of
146 * the following messages.
Paul Moored15c3452006-08-03 16:48:37 -0700147 *
Paul Moorefd385852006-09-25 15:56:37 -0700148 * Required attributes:
Paul Moored15c3452006-08-03 16:48:37 -0700149 *
Paul Moorefd385852006-09-25 15:56:37 -0700150 * NLBL_MGMT_A_PROTOCOL
Paul Moored15c3452006-08-03 16:48:37 -0700151 *
152 * o VERSION:
Paul Moorefd385852006-09-25 15:56:37 -0700153 * Sent by an application to request the NetLabel version. When sent by an
154 * application there is no payload. This message type is also used by the
155 * kernel to respond to an VERSION request.
Paul Moored15c3452006-08-03 16:48:37 -0700156 *
Paul Moorefd385852006-09-25 15:56:37 -0700157 * Required attributes:
Paul Moored15c3452006-08-03 16:48:37 -0700158 *
Paul Moorefd385852006-09-25 15:56:37 -0700159 * NLBL_MGMT_A_VERSION
Paul Moored15c3452006-08-03 16:48:37 -0700160 *
161 */
162
163/* NetLabel Management commands */
164enum {
165 NLBL_MGMT_C_UNSPEC,
Paul Moored15c3452006-08-03 16:48:37 -0700166 NLBL_MGMT_C_ADD,
167 NLBL_MGMT_C_REMOVE,
Paul Moorefd385852006-09-25 15:56:37 -0700168 NLBL_MGMT_C_LISTALL,
Paul Moored15c3452006-08-03 16:48:37 -0700169 NLBL_MGMT_C_ADDDEF,
170 NLBL_MGMT_C_REMOVEDEF,
171 NLBL_MGMT_C_LISTDEF,
Paul Moorefd385852006-09-25 15:56:37 -0700172 NLBL_MGMT_C_PROTOCOLS,
Paul Moored15c3452006-08-03 16:48:37 -0700173 NLBL_MGMT_C_VERSION,
174 __NLBL_MGMT_C_MAX,
175};
176#define NLBL_MGMT_C_MAX (__NLBL_MGMT_C_MAX - 1)
177
Paul Moorefd385852006-09-25 15:56:37 -0700178/* NetLabel Management attributes */
179enum {
180 NLBL_MGMT_A_UNSPEC,
181 NLBL_MGMT_A_DOMAIN,
182 /* (NLA_NUL_STRING)
183 * the NULL terminated LSM domain string */
184 NLBL_MGMT_A_PROTOCOL,
185 /* (NLA_U32)
186 * the NetLabel protocol type (defined by NETLBL_NLTYPE_*) */
187 NLBL_MGMT_A_VERSION,
188 /* (NLA_U32)
189 * the NetLabel protocol version number (defined by
190 * NETLBL_PROTO_VERSION) */
191 NLBL_MGMT_A_CV4DOI,
192 /* (NLA_U32)
193 * the CIPSOv4 DOI value */
Paul Moore63c41682008-10-10 10:16:32 -0400194 NLBL_MGMT_A_IPV6ADDR,
195 /* (NLA_BINARY, struct in6_addr)
196 * an IPv6 address */
197 NLBL_MGMT_A_IPV6MASK,
198 /* (NLA_BINARY, struct in6_addr)
199 * an IPv6 address mask */
200 NLBL_MGMT_A_IPV4ADDR,
201 /* (NLA_BINARY, struct in_addr)
202 * an IPv4 address */
203 NLBL_MGMT_A_IPV4MASK,
204 /* (NLA_BINARY, struct in_addr)
205 * and IPv4 address mask */
206 NLBL_MGMT_A_ADDRSELECTOR,
207 /* (NLA_NESTED)
208 * an IP address selector, must contain an address, mask, and protocol
209 * attribute plus any protocol specific attributes */
210 NLBL_MGMT_A_SELECTORLIST,
211 /* (NLA_NESTED)
212 * the selector list, there must be at least one
213 * NLBL_MGMT_A_ADDRSELECTOR attribute */
Paul Moorefd385852006-09-25 15:56:37 -0700214 __NLBL_MGMT_A_MAX,
215};
216#define NLBL_MGMT_A_MAX (__NLBL_MGMT_A_MAX - 1)
217
Paul Moored15c3452006-08-03 16:48:37 -0700218/* NetLabel protocol functions */
219int netlbl_mgmt_genl_init(void);
220
Paul Moorec783f1c2008-01-29 08:37:52 -0500221/* NetLabel configured protocol reference counter */
222extern atomic_t netlabel_mgmt_protocount;
Paul Moore23bcdc12007-07-18 12:28:45 -0400223
Paul Moored15c3452006-08-03 16:48:37 -0700224#endif