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 * 66e1ce69dfSHuw Davies * o LISTALL: 67e1ce69dfSHuw Davies * This message is sent by an application to list the valid DOIs on the 68e1ce69dfSHuw Davies * system. When sent by an application there is no payload and the 69e1ce69dfSHuw Davies * NLM_F_DUMP flag should be set. The kernel should respond with a series of 70e1ce69dfSHuw Davies * the following messages. 71e1ce69dfSHuw Davies * 72e1ce69dfSHuw Davies * Required attributes: 73e1ce69dfSHuw Davies * 74e1ce69dfSHuw Davies * NLBL_CALIPSO_A_DOI 75e1ce69dfSHuw Davies * NLBL_CALIPSO_A_MTYPE 76e1ce69dfSHuw Davies * 77cb72d382SHuw Davies */ 78cb72d382SHuw Davies 79cb72d382SHuw Davies /* NetLabel CALIPSO commands */ 80cb72d382SHuw Davies enum { 81cb72d382SHuw Davies NLBL_CALIPSO_C_UNSPEC, 82cb72d382SHuw Davies NLBL_CALIPSO_C_ADD, 83cb72d382SHuw Davies NLBL_CALIPSO_C_REMOVE, 84cb72d382SHuw Davies NLBL_CALIPSO_C_LIST, 85cb72d382SHuw Davies NLBL_CALIPSO_C_LISTALL, 86cb72d382SHuw Davies __NLBL_CALIPSO_C_MAX, 87cb72d382SHuw Davies }; 88cb72d382SHuw Davies 89cb72d382SHuw Davies /* NetLabel CALIPSO attributes */ 90cb72d382SHuw Davies enum { 91cb72d382SHuw Davies NLBL_CALIPSO_A_UNSPEC, 92cb72d382SHuw Davies NLBL_CALIPSO_A_DOI, 93cb72d382SHuw Davies /* (NLA_U32) 94cb72d382SHuw Davies * the DOI value */ 95cb72d382SHuw Davies NLBL_CALIPSO_A_MTYPE, 96cb72d382SHuw Davies /* (NLA_U32) 97cb72d382SHuw Davies * the mapping table type (defined in the calipso.h header as 98cb72d382SHuw Davies * CALIPSO_MAP_*) */ 99cb72d382SHuw Davies __NLBL_CALIPSO_A_MAX, 100cb72d382SHuw Davies }; 101cb72d382SHuw Davies 102cb72d382SHuw Davies #define NLBL_CALIPSO_A_MAX (__NLBL_CALIPSO_A_MAX - 1) 103cb72d382SHuw Davies 104cb72d382SHuw Davies /* NetLabel protocol functions */ 105cb72d382SHuw Davies #if IS_ENABLED(CONFIG_IPV6) 106cb72d382SHuw Davies int netlbl_calipso_genl_init(void); 107cb72d382SHuw Davies #else 108cb72d382SHuw Davies static inline int netlbl_calipso_genl_init(void) 109cb72d382SHuw Davies { 110cb72d382SHuw Davies return 0; 111cb72d382SHuw Davies } 112cb72d382SHuw Davies #endif 113cb72d382SHuw Davies 114cb72d382SHuw Davies int calipso_doi_add(struct calipso_doi *doi_def, 115cb72d382SHuw Davies struct netlbl_audit *audit_info); 116cb72d382SHuw Davies void calipso_doi_free(struct calipso_doi *doi_def); 117a5e34490SHuw Davies struct calipso_doi *calipso_doi_getdef(u32 doi); 118a5e34490SHuw Davies void calipso_doi_putdef(struct calipso_doi *doi_def); 119e1ce69dfSHuw Davies int calipso_doi_walk(u32 *skip_cnt, 120e1ce69dfSHuw Davies int (*callback)(struct calipso_doi *doi_def, void *arg), 121e1ce69dfSHuw Davies void *cb_arg); 122cb72d382SHuw Davies 123cb72d382SHuw Davies #endif 124