Path: blob/master/net/netlabel/netlabel_domainhash.h
15109 views
/*1* NetLabel Domain Hash Table2*3* This file manages the domain hash table that NetLabel uses to determine4* which network labeling protocol to use for a given domain. The NetLabel5* system manages static and dynamic label mappings for network protocols such6* as CIPSO and RIPSO.7*8* Author: Paul Moore <[email protected]>9*10*/1112/*13* (c) Copyright Hewlett-Packard Development Company, L.P., 2006, 200814*15* This program is free software; you can redistribute it and/or modify16* it under the terms of the GNU General Public License as published by17* the Free Software Foundation; either version 2 of the License, or18* (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 of22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See23* the GNU General Public License for more details.24*25* You should have received a copy of the GNU General Public License26* along with this program; if not, write to the Free Software27* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA28*29*/3031#ifndef _NETLABEL_DOMAINHASH_H32#define _NETLABEL_DOMAINHASH_H3334#include <linux/types.h>35#include <linux/rcupdate.h>36#include <linux/list.h>3738#include "netlabel_addrlist.h"3940/* Domain hash table size */41/* XXX - currently this number is an uneducated guess */42#define NETLBL_DOMHSH_BITSIZE 74344/* Domain mapping definition structures */45#define netlbl_domhsh_addr4_entry(iter) \46container_of(iter, struct netlbl_domaddr4_map, list)47struct netlbl_domaddr4_map {48u32 type;49union {50struct cipso_v4_doi *cipsov4;51} type_def;5253struct netlbl_af4list list;54};55#define netlbl_domhsh_addr6_entry(iter) \56container_of(iter, struct netlbl_domaddr6_map, list)57struct netlbl_domaddr6_map {58u32 type;5960/* NOTE: no 'type_def' union needed at present since we don't currently61* support any IPv6 labeling protocols */6263struct netlbl_af6list list;64};65struct netlbl_domaddr_map {66struct list_head list4;67struct list_head list6;68};69struct netlbl_dom_map {70char *domain;71u32 type;72union {73struct cipso_v4_doi *cipsov4;74struct netlbl_domaddr_map *addrsel;75} type_def;7677u32 valid;78struct list_head list;79struct rcu_head rcu;80};8182/* init function */83int netlbl_domhsh_init(u32 size);8485/* Manipulate the domain hash table */86int netlbl_domhsh_add(struct netlbl_dom_map *entry,87struct netlbl_audit *audit_info);88int netlbl_domhsh_add_default(struct netlbl_dom_map *entry,89struct netlbl_audit *audit_info);90int netlbl_domhsh_remove_entry(struct netlbl_dom_map *entry,91struct netlbl_audit *audit_info);92int netlbl_domhsh_remove_af4(const char *domain,93const struct in_addr *addr,94const struct in_addr *mask,95struct netlbl_audit *audit_info);96int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info);97int netlbl_domhsh_remove_default(struct netlbl_audit *audit_info);98struct netlbl_dom_map *netlbl_domhsh_getentry(const char *domain);99struct netlbl_domaddr4_map *netlbl_domhsh_getentry_af4(const char *domain,100__be32 addr);101int netlbl_domhsh_walk(u32 *skip_bkt,102u32 *skip_chain,103int (*callback) (struct netlbl_dom_map *entry, void *arg),104void *cb_arg);105106#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)107struct netlbl_domaddr6_map *netlbl_domhsh_getentry_af6(const char *domain,108const struct in6_addr *addr);109#endif /* IPv6 */110111#endif112113114