/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* bos72Q src/bos/kernel/net/net_secattr.h 1.4.1.1                        */
/*                                                                        */
/* Licensed Materials - Property of IBM                                   */
/*                                                                        */
/* Restricted Materials of IBM                                            */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2006,2019              */
/* All Rights Reserved                                                    */
/*                                                                        */
/* US Government Users Restricted Rights - Use, duplication or            */
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.      */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
/* @(#)95  1.4.1.1  src/bos/kernel/net/net_secattr.h, sysnet, bos72Q, q2019_13A4 2/6/19 00:43:49 */
/*
 * COMPONENT_NAME: SYSNET
 */

/** Copyright (c) 2000-2005 by Innovative Security Systems, Inc. **/

#ifndef _NET_SECATTR_H
#define _NET_SECATTR_H

#include <sys/mac.h>

#ifdef __cplusplus
extern "C" {
#endif

/* The sl_eq routine is defined only for 64-bit kernels. To avoid compilation
   problems with 32-bit kernel extensions this macro will be a dummy one
   for 32-bit drivers. MLS is only enabled on 64-bit kernels anyways.
*/

/* Returns 1 if both pointers are NULL or if the SL on both are the same */
#ifdef __64BIT_KERNEL
#define NCRED_EQUAL(ncreda, ncredb)	\
	((!ncreda && !ncredb) ||        \
	 (ncreda && ncredb && sl_eq(&ncreda->labels.sl, &ncredb->labels.sl)))
#else
#define NCRED_EQUAL(ncreda, ncredb) 1
#endif

/*
 * Structure: net_secattr
 *
 * Purpose:
 *	This structure is attached to network messages (mbuf chains) to specify
 *	the MLS security information associated with the message.
 */
struct net_secattr
{
	sec_labels_t labels;
	int refcount;
	/* paf to use on transmission when this cred is part of ICMP error. */
	int use_error_paf;
};


/*
 * Function Prototypes
 */
extern struct net_secattr * ncred_malloc (void);
extern int ncred_free (struct net_secattr * ncredp);

#define ncred_ref(ncred)	(fetch_and_add(&ncred->refcount,1))

/*
 * Default label attached to non-MLS protocol messages.
 */
extern struct net_secattr *net_default_label;

#ifdef __cplusplus
}
#endif

#endif /* _NET_SECATTR_H */
