1cb72d382SHuw Davies /*
2cb72d382SHuw Davies  * NetLabel CALIPSO Support
3cb72d382SHuw Davies  *
4cb72d382SHuw Davies  * This file defines the CALIPSO functions for the NetLabel system.  The
5cb72d382SHuw Davies  * NetLabel system manages static and dynamic label mappings for network
6cb72d382SHuw Davies  * protocols such as CIPSO and RIPSO.
7cb72d382SHuw Davies  *
8cb72d382SHuw Davies  * Authors: Paul Moore <paul@paul-moore.com>
9cb72d382SHuw Davies  *          Huw Davies <huw@codeweavers.com>
10cb72d382SHuw Davies  *
11cb72d382SHuw Davies  */
12cb72d382SHuw Davies 
13cb72d382SHuw Davies /* (c) Copyright Hewlett-Packard Development Company, L.P., 2006
14cb72d382SHuw Davies  * (c) Copyright Huw Davies <huw@codeweavers.com>, 2015
15cb72d382SHuw Davies  *
16cb72d382SHuw Davies  * This program is free software;  you can redistribute it and/or modify
17cb72d382SHuw Davies  * it under the terms of the GNU General Public License as published by
18cb72d382SHuw Davies  * the Free Software Foundation; either version 2 of the License, or
19cb72d382SHuw Davies  * (at your option) any later version.
20cb72d382SHuw Davies  *
21cb72d382SHuw Davies  * This program is distributed in the hope that it will be useful,
22cb72d382SHuw Davies  * but WITHOUT ANY WARRANTY;  without even the implied warranty of
23cb72d382SHuw Davies  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
24cb72d382SHuw Davies  * the GNU General Public License for more details.
25cb72d382SHuw Davies  *
26cb72d382SHuw Davies  * You should have received a copy of the GNU General Public License
27cb72d382SHuw Davies  * along with this program;  if not, see <http://www.gnu.org/licenses/>.
28cb72d382SHuw Davies  *
29cb72d382SHuw Davies  */
30cb72d382SHuw Davies 
31cb72d382SHuw Davies #ifndef _NETLABEL_CALIPSO
32cb72d382SHuw Davies #define _NETLABEL_CALIPSO
33cb72d382SHuw Davies 
34cb72d382SHuw Davies #include <net/netlabel.h>
35cb72d382SHuw Davies #include <net/calipso.h>
36cb72d382SHuw Davies 
37cb72d382SHuw Davies /* The following NetLabel payloads are supported by the CALIPSO subsystem.
38cb72d382SHuw Davies  *
39cb72d382SHuw Davies  * o ADD:
40cb72d382SHuw Davies  *   Sent by an application to add a new DOI mapping table.
41cb72d382SHuw Davies  *
42cb72d382SHuw Davies  *   Required attributes:
43cb72d382SHuw Davies  *
44cb72d382SHuw Davies  *     NLBL_CALIPSO_A_DOI
45cb72d382SHuw Davies  *     NLBL_CALIPSO_A_MTYPE
46cb72d382SHuw Davies  *
47cb72d382SHuw Davies  *   If using CALIPSO_MAP_PASS no additional attributes are required.
48cb72d382SHuw Davies  *
49a5e34490SHuw Davies  * o LIST:
50a5e34490SHuw Davies  *   Sent by an application to list the details of a DOI definition.  On
51a5e34490SHuw Davies  *   success the kernel should send a response using the following format.
52a5e34490SHuw Davies  *
53a5e34490SHuw Davies  *   Required attributes:
54a5e34490SHuw Davies  *
55a5e34490SHuw Davies  *     NLBL_CALIPSO_A_DOI
56a5e34490SHuw Davies  *
57a5e34490SHuw Davies  *   The valid response message format depends on the type of the DOI mapping,
58a5e34490SHuw Davies  *   the defined formats are shown below.
59a5e34490SHuw Davies  *
60a5e34490SHuw Davies  *   Required attributes:
61a5e34490SHuw Davies  *
62a5e34490SHuw Davies  *     NLBL_CALIPSO_A_MTYPE
63a5e34490SHuw Davies  *
64a5e34490SHuw Davies  *   If using CALIPSO_MAP_PASS no additional attributes are required.
65a5e34490SHuw Davies  *
66cb72d382SHuw Davies  */
67cb72d382SHuw Davies 
68cb72d382SHuw Davies /* NetLabel CALIPSO commands */
69cb72d382SHuw Davies enum {
70cb72d382SHuw Davies 	NLBL_CALIPSO_C_UNSPEC,
71cb72d382SHuw Davies 	NLBL_CALIPSO_C_ADD,
72cb72d382SHuw Davies 	NLBL_CALIPSO_C_REMOVE,
73cb72d382SHuw Davies 	NLBL_CALIPSO_C_LIST,
74cb72d382SHuw Davies 	NLBL_CALIPSO_C_LISTALL,
75cb72d382SHuw Davies 	__NLBL_CALIPSO_C_MAX,
76cb72d382SHuw Davies };
77cb72d382SHuw Davies 
78cb72d382SHuw Davies /* NetLabel CALIPSO attributes */
79cb72d382SHuw Davies enum {
80cb72d382SHuw Davies 	NLBL_CALIPSO_A_UNSPEC,
81cb72d382SHuw Davies 	NLBL_CALIPSO_A_DOI,
82cb72d382SHuw Davies 	/* (NLA_U32)
83cb72d382SHuw Davies 	 * the DOI value */
84cb72d382SHuw Davies 	NLBL_CALIPSO_A_MTYPE,
85cb72d382SHuw Davies 	/* (NLA_U32)
86cb72d382SHuw Davies 	 * the mapping table type (defined in the calipso.h header as
87cb72d382SHuw Davies 	 * CALIPSO_MAP_*) */
88cb72d382SHuw Davies 	__NLBL_CALIPSO_A_MAX,
89cb72d382SHuw Davies };
90cb72d382SHuw Davies 
91cb72d382SHuw Davies #define NLBL_CALIPSO_A_MAX (__NLBL_CALIPSO_A_MAX - 1)
92cb72d382SHuw Davies 
93cb72d382SHuw Davies /* NetLabel protocol functions */
94cb72d382SHuw Davies #if IS_ENABLED(CONFIG_IPV6)
95cb72d382SHuw Davies int netlbl_calipso_genl_init(void);
96cb72d382SHuw Davies #else
97cb72d382SHuw Davies static inline int netlbl_calipso_genl_init(void)
98cb72d382SHuw Davies {
99cb72d382SHuw Davies 	return 0;
100cb72d382SHuw Davies }
101cb72d382SHuw Davies #endif
102cb72d382SHuw Davies 
103cb72d382SHuw Davies int calipso_doi_add(struct calipso_doi *doi_def,
104cb72d382SHuw Davies 		    struct netlbl_audit *audit_info);
105cb72d382SHuw Davies void calipso_doi_free(struct calipso_doi *doi_def);
106a5e34490SHuw Davies struct calipso_doi *calipso_doi_getdef(u32 doi);
107a5e34490SHuw Davies void calipso_doi_putdef(struct calipso_doi *doi_def);
108cb72d382SHuw Davies 
109cb72d382SHuw Davies #endif
110