/* SPDX-License-Identifier: GPL-2.0-or-later */1/*2* NetLabel CALIPSO Support3*4* This file defines the CALIPSO functions for the NetLabel system. The5* NetLabel system manages static and dynamic label mappings for network6* protocols such as CIPSO and RIPSO.7*8* Authors: Paul Moore <[email protected]>9* Huw Davies <[email protected]>10*/1112/* (c) Copyright Hewlett-Packard Development Company, L.P., 200613* (c) Copyright Huw Davies <[email protected]>, 201514*/1516#ifndef _NETLABEL_CALIPSO17#define _NETLABEL_CALIPSO1819#include <net/netlabel.h>20#include <net/calipso.h>2122/* The following NetLabel payloads are supported by the CALIPSO subsystem.23*24* o ADD:25* Sent by an application to add a new DOI mapping table.26*27* Required attributes:28*29* NLBL_CALIPSO_A_DOI30* NLBL_CALIPSO_A_MTYPE31*32* If using CALIPSO_MAP_PASS no additional attributes are required.33*34* o REMOVE:35* Sent by an application to remove a specific DOI mapping table from the36* CALIPSO system.37*38* Required attributes:39*40* NLBL_CALIPSO_A_DOI41*42* o LIST:43* Sent by an application to list the details of a DOI definition. On44* success the kernel should send a response using the following format.45*46* Required attributes:47*48* NLBL_CALIPSO_A_DOI49*50* The valid response message format depends on the type of the DOI mapping,51* the defined formats are shown below.52*53* Required attributes:54*55* NLBL_CALIPSO_A_MTYPE56*57* If using CALIPSO_MAP_PASS no additional attributes are required.58*59* o LISTALL:60* This message is sent by an application to list the valid DOIs on the61* system. When sent by an application there is no payload and the62* NLM_F_DUMP flag should be set. The kernel should respond with a series of63* the following messages.64*65* Required attributes:66*67* NLBL_CALIPSO_A_DOI68* NLBL_CALIPSO_A_MTYPE69*70*/7172/* NetLabel CALIPSO commands */73enum {74NLBL_CALIPSO_C_UNSPEC,75NLBL_CALIPSO_C_ADD,76NLBL_CALIPSO_C_REMOVE,77NLBL_CALIPSO_C_LIST,78NLBL_CALIPSO_C_LISTALL,79__NLBL_CALIPSO_C_MAX,80};8182/* NetLabel CALIPSO attributes */83enum {84NLBL_CALIPSO_A_UNSPEC,85NLBL_CALIPSO_A_DOI,86/* (NLA_U32)87* the DOI value */88NLBL_CALIPSO_A_MTYPE,89/* (NLA_U32)90* the mapping table type (defined in the calipso.h header as91* CALIPSO_MAP_*) */92__NLBL_CALIPSO_A_MAX,93};9495#define NLBL_CALIPSO_A_MAX (__NLBL_CALIPSO_A_MAX - 1)9697/* NetLabel protocol functions */98#if IS_ENABLED(CONFIG_IPV6)99int netlbl_calipso_genl_init(void);100#else101static inline int netlbl_calipso_genl_init(void)102{103return 0;104}105#endif106107int calipso_doi_add(struct calipso_doi *doi_def,108struct netlbl_audit *audit_info);109void calipso_doi_free(struct calipso_doi *doi_def);110int calipso_doi_remove(u32 doi, struct netlbl_audit *audit_info);111struct calipso_doi *calipso_doi_getdef(u32 doi);112void calipso_doi_putdef(struct calipso_doi *doi_def);113int calipso_doi_walk(u32 *skip_cnt,114int (*callback)(struct calipso_doi *doi_def, void *arg),115void *cb_arg);116int calipso_sock_getattr(struct sock *sk, struct netlbl_lsm_secattr *secattr);117int calipso_sock_setattr(struct sock *sk,118const struct calipso_doi *doi_def,119const struct netlbl_lsm_secattr *secattr);120void calipso_sock_delattr(struct sock *sk);121int calipso_req_setattr(struct request_sock *req,122const struct calipso_doi *doi_def,123const struct netlbl_lsm_secattr *secattr);124void calipso_req_delattr(struct request_sock *req);125unsigned char *calipso_optptr(const struct sk_buff *skb);126int calipso_getattr(const unsigned char *calipso,127struct netlbl_lsm_secattr *secattr);128int calipso_skbuff_setattr(struct sk_buff *skb,129const struct calipso_doi *doi_def,130const struct netlbl_lsm_secattr *secattr);131int calipso_skbuff_delattr(struct sk_buff *skb);132void calipso_cache_invalidate(void);133int calipso_cache_add(const unsigned char *calipso_ptr,134const struct netlbl_lsm_secattr *secattr);135136#endif137138139