Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 1 | /* |
| 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 Moore | 82c21bf | 2011-08-01 11:10:33 +0000 | [diff] [blame] | 8 | * Author: Paul Moore <paul@paul-moore.com> |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 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 |
Jeff Kirsher | d484ff1 | 2013-12-06 09:13:41 -0800 | [diff] [blame] | 26 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 27 | * |
| 28 | */ |
| 29 | |
| 30 | #ifndef _NETLABEL_MGMT_H |
| 31 | #define _NETLABEL_MGMT_H |
| 32 | |
| 33 | #include <net/netlabel.h> |
Arun Sharma | 60063497 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 34 | #include <linux/atomic.h> |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 35 | |
| 36 | /* |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 37 | * The following NetLabel payloads are supported by the management interface. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 38 | * |
| 39 | * o ADD: |
| 40 | * Sent by an application to add a domain mapping to the NetLabel system. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 41 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 42 | * Required attributes: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 43 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 44 | * NLBL_MGMT_A_DOMAIN |
| 45 | * NLBL_MGMT_A_PROTOCOL |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 46 | * |
Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 47 | * 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 Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 57 | * If using NETLBL_NLTYPE_CIPSOV4 the following attributes are required: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 58 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 59 | * NLBL_MGMT_A_CV4DOI |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 60 | * |
Huw Davies | 8f18e67 | 2016-06-27 15:02:46 -0400 | [diff] [blame] | 61 | * If using NETLBL_NLTYPE_UNLABELED no other attributes are required, |
| 62 | * however the following attribute may optionally be sent: |
| 63 | * |
| 64 | * NLBL_MGMT_A_FAMILY |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 65 | * |
| 66 | * o REMOVE: |
| 67 | * Sent by an application to remove a domain mapping from the NetLabel |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 68 | * system. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 69 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 70 | * Required attributes: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 71 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 72 | * NLBL_MGMT_A_DOMAIN |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 73 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 74 | * o LISTALL: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 75 | * This message can be sent either from an application or by the kernel in |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 76 | * response to an application generated LISTALL message. When sent by an |
| 77 | * application there is no payload and the NLM_F_DUMP flag should be set. |
| 78 | * The kernel should respond with a series of the following messages. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 79 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 80 | * Required attributes: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 81 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 82 | * NLBL_MGMT_A_DOMAIN |
Huw Davies | 8f18e67 | 2016-06-27 15:02:46 -0400 | [diff] [blame] | 83 | * NLBL_MGMT_A_FAMILY |
Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 84 | * |
| 85 | * If the IP address selectors are not used the following attribute is |
| 86 | * required: |
| 87 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 88 | * NLBL_MGMT_A_PROTOCOL |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 89 | * |
Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 90 | * If the IP address selectors are used then the following attritbute is |
| 91 | * required: |
| 92 | * |
| 93 | * NLBL_MGMT_A_SELECTORLIST |
| 94 | * |
| 95 | * If the mapping is using the NETLBL_NLTYPE_CIPSOV4 type then the following |
| 96 | * attributes are required: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 97 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 98 | * NLBL_MGMT_A_CV4DOI |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 99 | * |
Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 100 | * If the mapping is using the NETLBL_NLTYPE_UNLABELED type no other |
| 101 | * attributes are required. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 102 | * |
| 103 | * o ADDDEF: |
| 104 | * Sent by an application to set the default domain mapping for the NetLabel |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 105 | * system. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 106 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 107 | * Required attributes: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 108 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 109 | * NLBL_MGMT_A_PROTOCOL |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 110 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 111 | * If using NETLBL_NLTYPE_CIPSOV4 the following attributes are required: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 112 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 113 | * NLBL_MGMT_A_CV4DOI |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 114 | * |
Huw Davies | 8f18e67 | 2016-06-27 15:02:46 -0400 | [diff] [blame] | 115 | * If using NETLBL_NLTYPE_UNLABELED no other attributes are required, |
| 116 | * however the following attribute may optionally be sent: |
| 117 | * |
| 118 | * NLBL_MGMT_A_FAMILY |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 119 | * |
| 120 | * o REMOVEDEF: |
| 121 | * Sent by an application to remove the default domain mapping from the |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 122 | * NetLabel system, there is no payload. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 123 | * |
| 124 | * o LISTDEF: |
| 125 | * This message can be sent either from an application or by the kernel in |
| 126 | * response to an application generated LISTDEF message. When sent by an |
Huw Davies | 8f18e67 | 2016-06-27 15:02:46 -0400 | [diff] [blame] | 127 | * application there may be an optional payload. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 128 | * |
Huw Davies | 8f18e67 | 2016-06-27 15:02:46 -0400 | [diff] [blame] | 129 | * NLBL_MGMT_A_FAMILY |
| 130 | * |
| 131 | * On success the kernel should send a response using the following format: |
| 132 | * |
| 133 | * If the IP address selectors are not used the following attributes are |
Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 134 | * required: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 135 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 136 | * NLBL_MGMT_A_PROTOCOL |
Huw Davies | 8f18e67 | 2016-06-27 15:02:46 -0400 | [diff] [blame] | 137 | * NLBL_MGMT_A_FAMILY |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 138 | * |
Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 139 | * If the IP address selectors are used then the following attritbute is |
| 140 | * required: |
| 141 | * |
| 142 | * NLBL_MGMT_A_SELECTORLIST |
| 143 | * |
| 144 | * If the mapping is using the NETLBL_NLTYPE_CIPSOV4 type then the following |
| 145 | * attributes are required: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 146 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 147 | * NLBL_MGMT_A_CV4DOI |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 148 | * |
Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 149 | * If the mapping is using the NETLBL_NLTYPE_UNLABELED type no other |
| 150 | * attributes are required. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 151 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 152 | * o PROTOCOLS: |
| 153 | * Sent by an application to request a list of configured NetLabel protocols |
| 154 | * in the kernel. When sent by an application there is no payload and the |
| 155 | * NLM_F_DUMP flag should be set. The kernel should respond with a series of |
| 156 | * the following messages. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 157 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 158 | * Required attributes: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 159 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 160 | * NLBL_MGMT_A_PROTOCOL |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 161 | * |
| 162 | * o VERSION: |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 163 | * Sent by an application to request the NetLabel version. When sent by an |
| 164 | * application there is no payload. This message type is also used by the |
| 165 | * kernel to respond to an VERSION request. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 166 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 167 | * Required attributes: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 168 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 169 | * NLBL_MGMT_A_VERSION |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 170 | * |
| 171 | */ |
| 172 | |
| 173 | /* NetLabel Management commands */ |
| 174 | enum { |
| 175 | NLBL_MGMT_C_UNSPEC, |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 176 | NLBL_MGMT_C_ADD, |
| 177 | NLBL_MGMT_C_REMOVE, |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 178 | NLBL_MGMT_C_LISTALL, |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 179 | NLBL_MGMT_C_ADDDEF, |
| 180 | NLBL_MGMT_C_REMOVEDEF, |
| 181 | NLBL_MGMT_C_LISTDEF, |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 182 | NLBL_MGMT_C_PROTOCOLS, |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 183 | NLBL_MGMT_C_VERSION, |
| 184 | __NLBL_MGMT_C_MAX, |
| 185 | }; |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 186 | |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 187 | /* NetLabel Management attributes */ |
| 188 | enum { |
| 189 | NLBL_MGMT_A_UNSPEC, |
| 190 | NLBL_MGMT_A_DOMAIN, |
| 191 | /* (NLA_NUL_STRING) |
| 192 | * the NULL terminated LSM domain string */ |
| 193 | NLBL_MGMT_A_PROTOCOL, |
| 194 | /* (NLA_U32) |
| 195 | * the NetLabel protocol type (defined by NETLBL_NLTYPE_*) */ |
| 196 | NLBL_MGMT_A_VERSION, |
| 197 | /* (NLA_U32) |
| 198 | * the NetLabel protocol version number (defined by |
| 199 | * NETLBL_PROTO_VERSION) */ |
| 200 | NLBL_MGMT_A_CV4DOI, |
| 201 | /* (NLA_U32) |
| 202 | * the CIPSOv4 DOI value */ |
Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 203 | NLBL_MGMT_A_IPV6ADDR, |
| 204 | /* (NLA_BINARY, struct in6_addr) |
| 205 | * an IPv6 address */ |
| 206 | NLBL_MGMT_A_IPV6MASK, |
| 207 | /* (NLA_BINARY, struct in6_addr) |
| 208 | * an IPv6 address mask */ |
| 209 | NLBL_MGMT_A_IPV4ADDR, |
| 210 | /* (NLA_BINARY, struct in_addr) |
| 211 | * an IPv4 address */ |
| 212 | NLBL_MGMT_A_IPV4MASK, |
| 213 | /* (NLA_BINARY, struct in_addr) |
| 214 | * and IPv4 address mask */ |
| 215 | NLBL_MGMT_A_ADDRSELECTOR, |
| 216 | /* (NLA_NESTED) |
| 217 | * an IP address selector, must contain an address, mask, and protocol |
| 218 | * attribute plus any protocol specific attributes */ |
| 219 | NLBL_MGMT_A_SELECTORLIST, |
| 220 | /* (NLA_NESTED) |
| 221 | * the selector list, there must be at least one |
| 222 | * NLBL_MGMT_A_ADDRSELECTOR attribute */ |
Huw Davies | 8f18e67 | 2016-06-27 15:02:46 -0400 | [diff] [blame] | 223 | NLBL_MGMT_A_FAMILY, |
| 224 | /* (NLA_U16) |
| 225 | * The address family */ |
Huw Davies | dc7de73 | 2016-06-27 15:02:49 -0400 | [diff] [blame] | 226 | NLBL_MGMT_A_CLPDOI, |
| 227 | /* (NLA_U32) |
| 228 | * the CALIPSO DOI value */ |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 229 | __NLBL_MGMT_A_MAX, |
| 230 | }; |
| 231 | #define NLBL_MGMT_A_MAX (__NLBL_MGMT_A_MAX - 1) |
| 232 | |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 233 | /* NetLabel protocol functions */ |
| 234 | int netlbl_mgmt_genl_init(void); |
| 235 | |
Paul Moore | c783f1c | 2008-01-29 08:37:52 -0500 | [diff] [blame] | 236 | /* NetLabel configured protocol reference counter */ |
| 237 | extern atomic_t netlabel_mgmt_protocount; |
Paul Moore | 23bcdc1 | 2007-07-18 12:28:45 -0400 | [diff] [blame] | 238 | |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 239 | #endif |