blob: 8b6e1ab62b485729dca126c8ab6a82671623d1fe [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 *
Paul Moore82c21bf2011-08-01 11:10:33 +00008 * Author: Paul Moore <paul@paul-moore.com>
Paul Moored15c3452006-08-03 16:48:37 -07009 *
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
Jeff Kirsherd484ff12013-12-06 09:13:41 -080026 * along with this program; if not, see <http://www.gnu.org/licenses/>.
Paul Moored15c3452006-08-03 16:48:37 -070027 *
28 */
29
30#ifndef _NETLABEL_MGMT_H
31#define _NETLABEL_MGMT_H
32
33#include <net/netlabel.h>
Arun Sharma600634972011-07-26 16:09:06 -070034#include <linux/atomic.h>
Paul Moored15c3452006-08-03 16:48:37 -070035
36/*
Paul Moorefd385852006-09-25 15:56:37 -070037 * The following NetLabel payloads are supported by the management interface.
Paul Moored15c3452006-08-03 16:48:37 -070038 *
39 * o ADD:
40 * Sent by an application to add a domain mapping to the NetLabel system.
Paul Moored15c3452006-08-03 16:48:37 -070041 *
Paul Moorefd385852006-09-25 15:56:37 -070042 * Required attributes:
Paul Moored15c3452006-08-03 16:48:37 -070043 *
Paul Moorefd385852006-09-25 15:56:37 -070044 * NLBL_MGMT_A_DOMAIN
45 * NLBL_MGMT_A_PROTOCOL
Paul Moored15c3452006-08-03 16:48:37 -070046 *
Paul Moore63c41682008-10-10 10:16:32 -040047 * If IPv4 is specified the following attributes are required:
48 *
49 * NLBL_MGMT_A_IPV4ADDR
50 * NLBL_MGMT_A_IPV4MASK
51 *
52 * If IPv6 is specified the following attributes are required:
53 *
54 * NLBL_MGMT_A_IPV6ADDR
55 * NLBL_MGMT_A_IPV6MASK
56 *
Paul Moorefd385852006-09-25 15:56:37 -070057 * If using NETLBL_NLTYPE_CIPSOV4 the following attributes are required:
Paul Moored15c3452006-08-03 16:48:37 -070058 *
Paul Moorefd385852006-09-25 15:56:37 -070059 * NLBL_MGMT_A_CV4DOI
Paul Moored15c3452006-08-03 16:48:37 -070060 *
Paul Moorefd385852006-09-25 15:56:37 -070061 * If using NETLBL_NLTYPE_UNLABELED no other attributes are required.
Paul Moored15c3452006-08-03 16:48:37 -070062 *
63 * o REMOVE:
64 * Sent by an application to remove a domain mapping from the NetLabel
Paul Moorefd385852006-09-25 15:56:37 -070065 * system.
Paul Moored15c3452006-08-03 16:48:37 -070066 *
Paul Moorefd385852006-09-25 15:56:37 -070067 * Required attributes:
Paul Moored15c3452006-08-03 16:48:37 -070068 *
Paul Moorefd385852006-09-25 15:56:37 -070069 * NLBL_MGMT_A_DOMAIN
Paul Moored15c3452006-08-03 16:48:37 -070070 *
Paul Moorefd385852006-09-25 15:56:37 -070071 * o LISTALL:
Paul Moored15c3452006-08-03 16:48:37 -070072 * This message can be sent either from an application or by the kernel in
Paul Moorefd385852006-09-25 15:56:37 -070073 * response to an application generated LISTALL message. When sent by an
74 * application there is no payload and the NLM_F_DUMP flag should be set.
75 * The kernel should respond with a series of the following messages.
Paul Moored15c3452006-08-03 16:48:37 -070076 *
Paul Moorefd385852006-09-25 15:56:37 -070077 * Required attributes:
Paul Moored15c3452006-08-03 16:48:37 -070078 *
Paul Moorefd385852006-09-25 15:56:37 -070079 * NLBL_MGMT_A_DOMAIN
Paul Moore63c41682008-10-10 10:16:32 -040080 *
81 * If the IP address selectors are not used the following attribute is
82 * required:
83 *
Paul Moorefd385852006-09-25 15:56:37 -070084 * NLBL_MGMT_A_PROTOCOL
Paul Moored15c3452006-08-03 16:48:37 -070085 *
Paul Moore63c41682008-10-10 10:16:32 -040086 * If the IP address selectors are used then the following attritbute is
87 * required:
88 *
89 * NLBL_MGMT_A_SELECTORLIST
90 *
91 * If the mapping is using the NETLBL_NLTYPE_CIPSOV4 type then the following
92 * attributes are required:
Paul Moored15c3452006-08-03 16:48:37 -070093 *
Paul Moorefd385852006-09-25 15:56:37 -070094 * NLBL_MGMT_A_CV4DOI
Paul Moored15c3452006-08-03 16:48:37 -070095 *
Paul Moore63c41682008-10-10 10:16:32 -040096 * If the mapping is using the NETLBL_NLTYPE_UNLABELED type no other
97 * attributes are required.
Paul Moored15c3452006-08-03 16:48:37 -070098 *
99 * o ADDDEF:
100 * Sent by an application to set the default domain mapping for the NetLabel
Paul Moorefd385852006-09-25 15:56:37 -0700101 * system.
Paul Moored15c3452006-08-03 16:48:37 -0700102 *
Paul Moorefd385852006-09-25 15:56:37 -0700103 * Required attributes:
Paul Moored15c3452006-08-03 16:48:37 -0700104 *
Paul Moorefd385852006-09-25 15:56:37 -0700105 * NLBL_MGMT_A_PROTOCOL
Paul Moored15c3452006-08-03 16:48:37 -0700106 *
Paul Moorefd385852006-09-25 15:56:37 -0700107 * If using NETLBL_NLTYPE_CIPSOV4 the following attributes are required:
Paul Moored15c3452006-08-03 16:48:37 -0700108 *
Paul Moorefd385852006-09-25 15:56:37 -0700109 * NLBL_MGMT_A_CV4DOI
Paul Moored15c3452006-08-03 16:48:37 -0700110 *
Paul Moorefd385852006-09-25 15:56:37 -0700111 * If using NETLBL_NLTYPE_UNLABELED no other attributes are required.
Paul Moored15c3452006-08-03 16:48:37 -0700112 *
113 * o REMOVEDEF:
114 * Sent by an application to remove the default domain mapping from the
Paul Moorefd385852006-09-25 15:56:37 -0700115 * NetLabel system, there is no payload.
Paul Moored15c3452006-08-03 16:48:37 -0700116 *
117 * o LISTDEF:
118 * This message can be sent either from an application or by the kernel in
119 * response to an application generated LISTDEF message. When sent by an
Paul Moorefd385852006-09-25 15:56:37 -0700120 * application there is no payload. On success the kernel should send a
121 * response using the following format.
Paul Moored15c3452006-08-03 16:48:37 -0700122 *
Paul Moore63c41682008-10-10 10:16:32 -0400123 * If the IP address selectors are not used the following attribute is
124 * required:
Paul Moored15c3452006-08-03 16:48:37 -0700125 *
Paul Moorefd385852006-09-25 15:56:37 -0700126 * NLBL_MGMT_A_PROTOCOL
Paul Moored15c3452006-08-03 16:48:37 -0700127 *
Paul Moore63c41682008-10-10 10:16:32 -0400128 * If the IP address selectors are used then the following attritbute is
129 * required:
130 *
131 * NLBL_MGMT_A_SELECTORLIST
132 *
133 * If the mapping is using the NETLBL_NLTYPE_CIPSOV4 type then the following
134 * attributes are required:
Paul Moored15c3452006-08-03 16:48:37 -0700135 *
Paul Moorefd385852006-09-25 15:56:37 -0700136 * NLBL_MGMT_A_CV4DOI
Paul Moored15c3452006-08-03 16:48:37 -0700137 *
Paul Moore63c41682008-10-10 10:16:32 -0400138 * If the mapping is using the NETLBL_NLTYPE_UNLABELED type no other
139 * attributes are required.
Paul Moored15c3452006-08-03 16:48:37 -0700140 *
Paul Moorefd385852006-09-25 15:56:37 -0700141 * o PROTOCOLS:
142 * Sent by an application to request a list of configured NetLabel protocols
143 * in the kernel. When sent by an application there is no payload and the
144 * NLM_F_DUMP flag should be set. The kernel should respond with a series of
145 * the following messages.
Paul Moored15c3452006-08-03 16:48:37 -0700146 *
Paul Moorefd385852006-09-25 15:56:37 -0700147 * Required attributes:
Paul Moored15c3452006-08-03 16:48:37 -0700148 *
Paul Moorefd385852006-09-25 15:56:37 -0700149 * NLBL_MGMT_A_PROTOCOL
Paul Moored15c3452006-08-03 16:48:37 -0700150 *
151 * o VERSION:
Paul Moorefd385852006-09-25 15:56:37 -0700152 * Sent by an application to request the NetLabel version. When sent by an
153 * application there is no payload. This message type is also used by the
154 * kernel to respond to an VERSION request.
Paul Moored15c3452006-08-03 16:48:37 -0700155 *
Paul Moorefd385852006-09-25 15:56:37 -0700156 * Required attributes:
Paul Moored15c3452006-08-03 16:48:37 -0700157 *
Paul Moorefd385852006-09-25 15:56:37 -0700158 * NLBL_MGMT_A_VERSION
Paul Moored15c3452006-08-03 16:48:37 -0700159 *
160 */
161
162/* NetLabel Management commands */
163enum {
164 NLBL_MGMT_C_UNSPEC,
Paul Moored15c3452006-08-03 16:48:37 -0700165 NLBL_MGMT_C_ADD,
166 NLBL_MGMT_C_REMOVE,
Paul Moorefd385852006-09-25 15:56:37 -0700167 NLBL_MGMT_C_LISTALL,
Paul Moored15c3452006-08-03 16:48:37 -0700168 NLBL_MGMT_C_ADDDEF,
169 NLBL_MGMT_C_REMOVEDEF,
170 NLBL_MGMT_C_LISTDEF,
Paul Moorefd385852006-09-25 15:56:37 -0700171 NLBL_MGMT_C_PROTOCOLS,
Paul Moored15c3452006-08-03 16:48:37 -0700172 NLBL_MGMT_C_VERSION,
173 __NLBL_MGMT_C_MAX,
174};
Paul Moored15c3452006-08-03 16:48:37 -0700175
Paul Moorefd385852006-09-25 15:56:37 -0700176/* NetLabel Management attributes */
177enum {
178 NLBL_MGMT_A_UNSPEC,
179 NLBL_MGMT_A_DOMAIN,
180 /* (NLA_NUL_STRING)
181 * the NULL terminated LSM domain string */
182 NLBL_MGMT_A_PROTOCOL,
183 /* (NLA_U32)
184 * the NetLabel protocol type (defined by NETLBL_NLTYPE_*) */
185 NLBL_MGMT_A_VERSION,
186 /* (NLA_U32)
187 * the NetLabel protocol version number (defined by
188 * NETLBL_PROTO_VERSION) */
189 NLBL_MGMT_A_CV4DOI,
190 /* (NLA_U32)
191 * the CIPSOv4 DOI value */
Paul Moore63c41682008-10-10 10:16:32 -0400192 NLBL_MGMT_A_IPV6ADDR,
193 /* (NLA_BINARY, struct in6_addr)
194 * an IPv6 address */
195 NLBL_MGMT_A_IPV6MASK,
196 /* (NLA_BINARY, struct in6_addr)
197 * an IPv6 address mask */
198 NLBL_MGMT_A_IPV4ADDR,
199 /* (NLA_BINARY, struct in_addr)
200 * an IPv4 address */
201 NLBL_MGMT_A_IPV4MASK,
202 /* (NLA_BINARY, struct in_addr)
203 * and IPv4 address mask */
204 NLBL_MGMT_A_ADDRSELECTOR,
205 /* (NLA_NESTED)
206 * an IP address selector, must contain an address, mask, and protocol
207 * attribute plus any protocol specific attributes */
208 NLBL_MGMT_A_SELECTORLIST,
209 /* (NLA_NESTED)
210 * the selector list, there must be at least one
211 * NLBL_MGMT_A_ADDRSELECTOR attribute */
Paul Moorefd385852006-09-25 15:56:37 -0700212 __NLBL_MGMT_A_MAX,
213};
214#define NLBL_MGMT_A_MAX (__NLBL_MGMT_A_MAX - 1)
215
Paul Moored15c3452006-08-03 16:48:37 -0700216/* NetLabel protocol functions */
217int netlbl_mgmt_genl_init(void);
218
Paul Moorec783f1c2008-01-29 08:37:52 -0500219/* NetLabel configured protocol reference counter */
220extern atomic_t netlabel_mgmt_protocount;
Paul Moore23bcdc12007-07-18 12:28:45 -0400221
Paul Moored15c3452006-08-03 16:48:37 -0700222#endif