code:
/*
 * Copyright (c) 2010 The FreeBSD Foundation
 * All rights reserved.
 *
 * This software was developed by Rui Paulo under sponsorship from the
 * FreeBSD Foundation.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/lib/librtld_db/rtld_db.h 210678 2010-07-31 14:26:10Z rpaulo $
 */

#ifndef _RTLD_DB_H_
#define _RTLD_DB_H_

#include <sys/param.h>
#include <sys/cdefs.h>
#include <sys/types.h>

#define	RD_VERSION	1

typedef enum {
	RD_OK,
	RD_ERR,
	RD_DBERR,
	RD_NOCAPAB,
	RD_NODYNAM,
	RD_NOBASE,
	RD_NOMAPS
} rd_err_e;

typedef struct rd_agent {
	struct proc_handle *rda_php;
	uintptr_t rda_addr;		/* address of r_debug_state */
} rd_agent_t;

typedef struct rd_loadobj {
	uintptr_t	rdl_saddr;		/* start address */
	uintptr_t	rdl_eaddr;		/* end address */
	uint32_t	rdl_offset;
	uint8_t		rdl_prot;
#define RD_RDL_R	0x01
#define RD_RDL_W	0x02
#define RD_RDL_X	0x04
	enum {
		RDL_TYPE_NONE	= 0,
		RDL_TYPE_DEF,
		RDL_TYPE_VNODE,
		RDL_TYPE_SWAP,
		RDL_TYPE_DEV,
		/* XXX some types missing */
		RDL_TYPE_UNKNOWN = 255
	} rdl_type;
	unsigned char	rdl_path[PATH_MAX];
} rd_loadobj_t;

typedef enum {
	RD_NONE = 0,
	RD_PREINIT,
	RD_POSTINIT,
	RD_DLACTIVITY
} rd_event_e;

typedef enum {
	RD_NOTIFY_BPT,
	RD_NOTIFY_AUTOBPT,
	RD_NOTIFY_SYSCALL
} rd_notify_e;

typedef struct rd_notify {
	rd_notify_e type;
	union {
		uintptr_t bptaddr;
		long      syscallno;
	} u;
} rd_notify_t;

typedef enum {
	RD_NOSTATE = 0,
	RD_CONSISTENT,
	RD_ADD,
	RD_DELETE
} rd_state_e;

typedef struct rd_event_msg {
	rd_event_e type;
	union {
		rd_state_e state;
	} u;
} rd_event_msg_t;

typedef enum {
	RD_RESOLVE_NONE,
	RD_RESOLVE_STEP,
	RD_RESOLVE_TARGET,
	RD_RESOLVE_TARGET_STEP
} rd_skip_e;

typedef struct rd_plt_info {
	rd_skip_e pi_skip_method;
	long	  pi_nstep;
	uintptr_t pi_target;
	uintptr_t pi_baddr;
	unsigned int pi_flags;
} rd_plt_info_t;

#define RD_FLG_PI_PLTBOUND	0x0001

__BEGIN_DECLS

struct proc_handle;
void		rd_delete(rd_agent_t *);
const char 	*rd_errstr(rd_err_e);
rd_err_e	rd_event_addr(rd_agent_t *, rd_event_e, rd_notify_t *);
rd_err_e	rd_event_enable(rd_agent_t *, int);
rd_err_e	rd_event_getmsg(rd_agent_t *, rd_event_msg_t *);
rd_err_e	rd_init(int);
typedef int rl_iter_f(const rd_loadobj_t *, void *);
rd_err_e	rd_loadobj_iter(rd_agent_t *, rl_iter_f *, void *);
void		rd_log(const int);
rd_agent_t 	*rd_new(struct proc_handle *);
rd_err_e	rd_objpad_enable(rd_agent_t *, size_t);
struct proc;
rd_err_e	rd_plt_resolution(rd_agent_t *, uintptr_t, struct proc *,
		    uintptr_t, rd_plt_info_t *);
rd_err_e	rd_reset(rd_agent_t *);

__END_DECLS

#endif /* _RTLD_DB_H_ */


code:
/*-
 * Copyright (c) 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * This code is derived from software contributed to Berkeley by
 * Paul Borman at Krystal Technologies.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	@(#)runetype.h	8.1 (Berkeley) 6/2/93
 * $FreeBSD: release/9.0.0/include/runetype.h 203964 2010-02-16 19:39:50Z imp $
 */

#ifndef	_RUNETYPE_H_
#define	_RUNETYPE_H_

#include <sys/cdefs.h>
#include <sys/_types.h>

#define	_CACHED_RUNES	(1 <<8 )	/* Must be a power of 2 */
#define	_CRMASK		(~(_CACHED_RUNES - 1))

/*
 * The lower 8 bits of runetype[] contain the digit value of the rune.
 */
typedef struct {
	__rune_t	__min;		/* First rune of the range */
	__rune_t	__max;		/* Last rune (inclusive) of the range */
	__rune_t	__map;		/* What first maps to in maps */
	unsigned long	*__types;	/* Array of types in range */
} _RuneEntry;

typedef struct {
	int		__nranges;	/* Number of ranges stored */
	_RuneEntry	*__ranges;	/* Pointer to the ranges */
} _RuneRange;

typedef struct {
	char		__magic[8];	/* Magic saying what version we are */
	char		__encoding[32];	/* ASCII name of this encoding */

	__rune_t	(*__sgetrune)(const char *, __size_t, char const **);
	int		(*__sputrune)(__rune_t, char *, __size_t, char **);
	__rune_t	__invalid_rune;

	unsigned long	__runetype[_CACHED_RUNES];
	__rune_t	__maplower[_CACHED_RUNES];
	__rune_t	__mapupper[_CACHED_RUNES];

	/*
	 * The following are to deal with Runes larger than _CACHED_RUNES - 1.
	 * Their data is actually contiguous with this structure so as to make
	 * it easier to read/write from/to disk.
	 */
	_RuneRange	__runetype_ext;
	_RuneRange	__maplower_ext;
	_RuneRange	__mapupper_ext;

	void		*__variable;	/* Data which depends on the encoding */
	int		__variable_len;	/* how long that data is */
} _RuneLocale;

#define	_RUNE_MAGIC_1	"RuneMagi"	/* Indicates version 0 of RuneLocale */

extern _RuneLocale _DefaultRuneLocale;
extern _RuneLocale *_CurrentRuneLocale;

#endif	/* !_RUNETYPE_H_ */

repo_name: veiledmerc/mira

license: mit


code:
/*-
 * Copyright (c) 1996, 1997
 *      HD Associates, Inc.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *      This product includes software developed by HD Associates, Inc
 *      and Jukka Antero Ukkonen.
 * 4. Neither the name of the author nor the names of any co-contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL HD ASSOCIATES OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

/*-
 * Copyright (c) 2002-2008, Jeffrey Roberson <jeff@freebsd.org>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice unmodified, this list of conditions, and the following
 *    disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/sys/sched.h 216791 2010-12-29 09:26:46Z davidxu $
 */

#ifndef _SCHED_H_
#define	_SCHED_H_

#ifdef _KERNEL
/*
 * General scheduling info.
 *
 * sched_load:
 *	Total runnable non-ithread threads in the system.
 *
 * sched_runnable:
 *	Runnable threads for this processor.
 */
int	sched_load(void);
int	sched_rr_interval(void);
int	sched_runnable(void);

/*
 * Proc related scheduling hooks.
 */
void	sched_exit(struct proc *p, struct thread *childtd);
void	sched_fork(struct thread *td, struct thread *childtd);
void	sched_fork_exit(struct thread *td);
void	sched_class(struct thread *td, int class);
void	sched_nice(struct proc *p, int nice);

/*
 * Threads are switched in and out, block on resources, have temporary
 * priorities inherited from their procs, and use up cpu time.
 */
void	sched_exit_thread(struct thread *td, struct thread *child);
void	sched_fork_thread(struct thread *td, struct thread *child);
void	sched_lend_prio(struct thread *td, u_char prio);
void	sched_lend_user_prio(struct thread *td, u_char pri);
fixpt_t	sched_pctcpu(struct thread *td);
void	sched_prio(struct thread *td, u_char prio);
void	sched_sleep(struct thread *td, int prio);
void	sched_switch(struct thread *td, struct thread *newtd, int flags);
void	sched_throw(struct thread *td);
void	sched_unlend_prio(struct thread *td, u_char prio);
void	sched_user_prio(struct thread *td, u_char prio);
void	sched_userret(struct thread *td);
void	sched_wakeup(struct thread *td);
void	sched_preempt(struct thread *td);

/*
 * Threads are moved on and off of run queues
 */
void	sched_add(struct thread *td, int flags);
void	sched_clock(struct thread *td);
void	sched_rem(struct thread *td);
void	sched_tick(int cnt);
void	sched_relinquish(struct thread *td);
struct thread *sched_choose(void);
void	sched_idletd(void *);

/*
 * Binding makes cpu affinity permanent while pinning is used to temporarily
 * hold a thread on a particular CPU.
 */
void	sched_bind(struct thread *td, int cpu);
static __inline void sched_pin(void);
void	sched_unbind(struct thread *td);
static __inline void sched_unpin(void);
int	sched_is_bound(struct thread *td);
void	sched_affinity(struct thread *td);

/*
 * These procedures tell the process data structure allocation code how
 * many bytes to actually allocate.
 */
int	sched_sizeof_proc(void);
int	sched_sizeof_thread(void);

/*
 * This routine provides a consistent thread name for use with KTR graphing
 * functions.
 */
char	*sched_tdname(struct thread *td);

static __inline void
sched_pin(void)
{
	curthread->td_pinned++;
}

static __inline void
sched_unpin(void)
{
	curthread->td_pinned--;
}

/* sched_add arguments (formerly setrunqueue) */
#define	SRQ_BORING	0x0000		/* No special circumstances. */
#define	SRQ_YIELDING	0x0001		/* We are yielding (from mi_switch). */
#define	SRQ_OURSELF	0x0002		/* It is ourself (from mi_switch). */
#define	SRQ_INTR	0x0004		/* It is probably urgent. */
#define	SRQ_PREEMPTED	0x0008		/* has been preempted.. be kind */
#define	SRQ_BORROWING	0x0010		/* Priority updated due to prio_lend */

/* Scheduler stats. */
#ifdef SCHED_STATS
DPCPU_DECLARE(long, sched_switch_stats[SWT_COUNT]);

#define	SCHED_STAT_DEFINE_VAR(name, ptr, descr)				\
static void name ## _add_proc(void *dummy __unused)			\
{									\
									\
	SYSCTL_ADD_PROC(NULL,						\
	    SYSCTL_STATIC_CHILDREN(_kern_sched_stats), OID_AUTO,	\
	    #name, CTLTYPE_LONG|CTLFLAG_RD|CTLFLAG_MPSAFE,		\
	    ptr, 0, sysctl_dpcpu_long, "LU", descr);			\
}									\
SYSINIT(name, SI_SUB_RUN_SCHEDULER, SI_ORDER_MIDDLE, name ## _add_proc, NULL);

#define	SCHED_STAT_DEFINE(name, descr)					\
    DPCPU_DEFINE(unsigned long, name);					\
    SCHED_STAT_DEFINE_VAR(name, &DPCPU_NAME(name), descr)
/*
 * Sched stats are always incremented in critical sections so no atomic
 * is necesssary to increment them.
 */
#define SCHED_STAT_INC(var)     DPCPU_GET(var)++;
#else
#define	SCHED_STAT_DEFINE_VAR(name, descr, ptr)
#define	SCHED_STAT_DEFINE(name, descr)
#define SCHED_STAT_INC(var)			(void)0
#endif

/*
 * Fixup scheduler state for proc0 and thread0
 */
void schedinit(void);
#endif /* _KERNEL */

/* POSIX 1003.1b Process Scheduling */

/*
 * POSIX scheduling policies
 */
#define SCHED_FIFO      1
#define SCHED_OTHER     2
#define SCHED_RR        3

struct sched_param {
        int     sched_priority;
};

/*
 * POSIX scheduling declarations for userland.
 */
#ifndef _KERNEL
#include <sys/cdefs.h>
#include <sys/_types.h>

#ifndef _PID_T_DECLARED
typedef __pid_t         pid_t;
#define _PID_T_DECLARED
#endif

struct timespec;

__BEGIN_DECLS
int     sched_get_priority_max(int);
int     sched_get_priority_min(int);
int     sched_getparam(pid_t, struct sched_param *);
int     sched_getscheduler(pid_t);
int     sched_rr_get_interval(pid_t, struct timespec *);
int     sched_setparam(pid_t, const struct sched_param *);
int     sched_setscheduler(pid_t, int, const struct sched_param *);
int     sched_yield(void);
__END_DECLS

#endif
#endif /* !_SCHED_H_ */


code:
/*
 * sdp.h
 *
 * Copyright (c) 2001-2003 Maksim Yevmenkin <m_evmenkin@yahoo.com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $Id: sdp.h,v 1.3 2003/09/05 00:33:59 max Exp $
 * $FreeBSD: release/9.0.0/lib/libsdp/sdp.h 177364 2008-03-19 00:06:30Z emax $
 */

#ifndef _SDP_H_
#define _SDP_H_

__BEGIN_DECLS

/*
 * Data representation (page 349)
 */

/* Nil, the null type */
#define SDP_DATA_NIL					0x00

/* Unsigned integer */
#define SDP_DATA_UINT8					0x08
#define SDP_DATA_UINT16					0x09
#define SDP_DATA_UINT32					0x0A
#define SDP_DATA_UINT64					0x0B
#define SDP_DATA_UINT128				0x0C

/* Signed two's-complement integer */
#define SDP_DATA_INT8					0x10
#define SDP_DATA_INT16					0x11
#define SDP_DATA_INT32					0x12
#define SDP_DATA_INT64					0x13
#define SDP_DATA_INT128					0x14

/* UUID, a universally unique identifier */
#define SDP_DATA_UUID16					0x19
#define SDP_DATA_UUID32					0x1A
#define SDP_DATA_UUID128				0x1C

/* Text string */
#define SDP_DATA_STR8					0x25
#define SDP_DATA_STR16					0x26
#define SDP_DATA_STR32					0x27

/* Boolean */
#define SDP_DATA_BOOL					0x28

/*
 * Data element sequence.
 * A data element whose data field is a sequence of data elements
 */
#define SDP_DATA_SEQ8					0x35
#define SDP_DATA_SEQ16					0x36
#define SDP_DATA_SEQ32					0x37

/*
 * Data element alternative.
 * A data element whose data field is a sequence of data elements from
 * which one data element is to be selected.
 */
#define SDP_DATA_ALT8					0x3D
#define SDP_DATA_ALT16					0x3E
#define SDP_DATA_ALT32					0x3F

/* URL, a uniform resource locator */
#define SDP_DATA_URL8					0x45
#define SDP_DATA_URL16					0x46
#define SDP_DATA_URL32					0x47

/*
 * Protocols UUID (short) https://www.bluetooth.org/assigned-numbers/service_discovery.php
 * BASE UUID 00000000-0000-1000-8000-00805F9B34FB
 */

#define SDP_UUID_PROTOCOL_SDP				0x0001
#define SDP_UUID_PROTOCOL_UDP				0x0002
#define SDP_UUID_PROTOCOL_RFCOMM			0x0003
#define SDP_UUID_PROTOCOL_TCP				0x0004
#define SDP_UUID_PROTOCOL_TCS_BIN			0x0005
#define SDP_UUID_PROTOCOL_TCS_AT			0x0006
#define SDP_UUID_PROTOCOL_OBEX				0x0008
#define SDP_UUID_PROTOCOL_IP				0x0009
#define SDP_UUID_PROTOCOL_FTP				0x000A
#define SDP_UUID_PROTOCOL_HTTP				0x000C
#define SDP_UUID_PROTOCOL_WSP				0x000E
#define SDP_UUID_PROTOCOL_BNEP				0x000F
#define SDP_UUID_PROTOCOL_UPNP				0x0010
#define SDP_UUID_PROTOCOL_HIDP				0x0011
#define SDP_UUID_PROTOCOL_HARDCOPY_CONTROL_CHANNEL	0x0012
#define SDP_UUID_PROTOCOL_HARDCOPY_DATA_CHANNEL		0x0014
#define SDP_UUID_PROTOCOL_HARDCOPY_NOTIFICATION		0x0016
#define SDP_UUID_PROTOCOL_AVCTP				0x0017
#define SDP_UUID_PROTOCOL_AVDTP				0x0019
#define SDP_UUID_PROTOCOL_CMPT				0x001B
#define SDP_UUID_PROTOCOL_UDI_C_PLANE			0x001D
#define SDP_UUID_PROTOCOL_L2CAP				0x0100

/*
 * Service class IDs https://www.bluetooth.org/assigned-numbers/service_discovery.php
 */

#define SDP_SERVICE_CLASS_SERVICE_DISCOVERY_SERVER	0x1000
#define SDP_SERVICE_CLASS_BROWSE_GROUP_DESCRIPTOR	0x1001
#define SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP		0x1002
#define SDP_SERVICE_CLASS_SERIAL_PORT			0x1101
#define SDP_SERVICE_CLASS_LAN_ACCESS_USING_PPP		0x1102
#define SDP_SERVICE_CLASS_DIALUP_NETWORKING		0x1103
#define SDP_SERVICE_CLASS_IR_MC_SYNC			0x1104
#define SDP_SERVICE_CLASS_OBEX_OBJECT_PUSH		0x1105
#define SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER		0x1106
#define SDP_SERVICE_CLASS_IR_MC_SYNC_COMMAND		0x1107
#define SDP_SERVICE_CLASS_HEADSET			0x1108
#define SDP_SERVICE_CLASS_CORDLESS_TELEPHONY		0x1109
#define SDP_SERVICE_CLASS_AUDIO_SOURCE			0x110A
#define SDP_SERVICE_CLASS_AUDIO_SINK			0x110B
#define SDP_SERVICE_CLASS_AV_REMOTE_CONTROL_TARGET	0x110C
#define SDP_SERVICE_CLASS_ADVANCED_AUDIO_DISTRIBUTION	0x110D
#define SDP_SERVICE_CLASS_AV_REMOTE_CONTROL		0x110E
#define SDP_SERVICE_CLASS_VIDEO_CONFERENCING		0x110F
#define SDP_SERVICE_CLASS_INTERCOM			0x1110
#define SDP_SERVICE_CLASS_FAX				0x1111
#define SDP_SERVICE_CLASS_HEADSET_AUDIO_GATEWAY		0x1112
#define SDP_SERVICE_CLASS_WAP				0x1113
#define SDP_SERVICE_CLASS_WAP_CLIENT			0x1114
#define SDP_SERVICE_CLASS_PANU				0x1115
#define SDP_SERVICE_CLASS_NAP				0x1116
#define SDP_SERVICE_CLASS_GN				0x1117
#define SDP_SERVICE_CLASS_DIRECT_PRINTING		0x1118
#define SDP_SERVICE_CLASS_REFERENCE_PRINTING		0x1119
#define SDP_SERVICE_CLASS_IMAGING			0x111A
#define SDP_SERVICE_CLASS_IMAGING_RESPONDER		0x111B
#define SDP_SERVICE_CLASS_IMAGING_AUTOMATIC_ARCHIVE	0x111C
#define SDP_SERVICE_CLASS_IMAGING_REFERENCED_OBJECTS	0x111D
#define SDP_SERVICE_CLASS_HANDSFREE			0x111E
#define SDP_SERVICE_CLASS_HANDSFREE_AUDIO_GATEWAY	0x111F
#define SDP_SERVICE_CLASS_DIRECT_PRINTING_REFERENCE_OBJECTS	0x1120
#define SDP_SERVICE_CLASS_REFLECTED_UI			0x1121
#define SDP_SERVICE_CLASS_BASIC_PRINTING		0x1122
#define SDP_SERVICE_CLASS_PRINTING_STATUS		0x1123
#define SDP_SERVICE_CLASS_HUMAN_INTERFACE_DEVICE	0x1124
#define SDP_SERVICE_CLASS_HARDCOPY_CABLE_REPLACEMENT	0x1125
#define SDP_SERVICE_CLASS_HCR_PRINT			0x1126
#define SDP_SERVICE_CLASS_HCR_SCAN			0x1127
#define SDP_SERVICE_CLASS_COMMON_ISDN_ACCESS		0x1128
#define SDP_SERVICE_CLASS_VIDEO_CONFERENCING_GW		0x1129
#define SDP_SERVICE_CLASS_UDI_MT			0x112A
#define SDP_SERVICE_CLASS_UDI_TA			0x112B
#define SDP_SERVICE_CLASS_AUDIO_VIDEO			0x112C
#define SDP_SERVICE_CLASS_SIM_ACCESS			0x112D
#define SDP_SERVICE_CLASS_PHONEBOOK_ACCESS_PCE		0x112E
#define SDP_SERVICE_CLASS_PHONEBOOK_ACCESS_PSE		0x112F
#define SDP_SERVICE_CLASS_PHONEBOOK_ACCESS		0x1130
#define SDP_SERVICE_CLASS_PNP_INFORMATION		0x1200
#define SDP_SERVICE_CLASS_GENERIC_NETWORKING		0x1201
#define SDP_SERVICE_CLASS_GENERIC_FILE_TRANSFER		0x1202
#define SDP_SERVICE_CLASS_GENERIC_AUDIO			0x1203
#define SDP_SERVICE_CLASS_GENERIC_TELEPHONY		0x1204
#define SDP_SERVICE_CLASS_UPNP				0x1205
#define SDP_SERVICE_CLASS_UPNP_IP			0x1206
#define SDP_SERVICE_CLASS_ESDP_UPNP_IP_PAN		0x1300
#define SDP_SERVICE_CLASS_ESDP_UPNP_IP_LAP		0x1301
#define SDP_SERVICE_CLASS_ESDP_UPNP_L2CAP		0x1302
#define SDP_SERVICE_CLASS_VIDEO_SOURCE			0x1303
#define SDP_SERVICE_CLASS_VIDEO_SINK			0x1304
#define SDP_SERVICE_CLASS_VIDEO_DISTRIBUTION		0x1305

/*
 * Universal attribute definitions (page 366) and
 * https://www.bluetooth.org/assigned-numbers/service_discovery.php
 */

#define SDP_ATTR_RANGE(lo, hi) \
	(uint32_t)(((uint16_t)(lo) << 16) | ((uint16_t)(hi)))

#define SDP_ATTR_SERVICE_RECORD_HANDLE			0x0000
#define SDP_ATTR_SERVICE_CLASS_ID_LIST			0x0001
#define SDP_ATTR_SERVICE_RECORD_STATE			0x0002
#define SDP_ATTR_SERVICE_ID				0x0003
#define SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST		0x0004
#define SDP_ATTR_BROWSE_GROUP_LIST			0x0005
#define SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST	0x0006
#define SDP_ATTR_SERVICE_INFO_TIME_TO_LIVE		0x0007
#define SDP_ATTR_SERVICE_AVAILABILITY			0x0008
#define SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST	0x0009
#define SDP_ATTR_DOCUMENTATION_URL			0x000A
#define SDP_ATTR_CLIENT_EXECUTABLE_URL			0x000B
#define SDP_ATTR_ICON_URL				0x000C
#define SDP_ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LISTS	0x000D
#define SDP_ATTR_GROUP_ID				0x0200
#define SDP_ATTR_IP_SUBNET				0x0200
#define SDP_ATTR_VERSION_NUMBER_LIST			0x0200
#define SDP_ATTR_SERVICE_DATABASE_STATE			0x0201
#define SDP_ATTR_SERVICE_VERSION			0x0300
#define SDP_ATTR_EXTERNAL_NETWORK			0x0301
#define SDP_ATTR_NETWORK				0x0301
#define SDP_ATTR_SUPPORTED_DATA_STORES_LIST		0x0301
#define SDP_ATTR_FAX_CLASS1_SUPPORT			0x0302
#define SDP_ATTR_REMOTE_AUDIO_VOLUME_CONTROL		0x0302
#define SDP_ATTR_FAX_CLASS20_SUPPORT			0x0303
#define SDP_ATTR_SUPPORTED_FORMATS_LIST			0x0303
#define SDP_ATTR_FAX_CLASS2_SUPPORT			0x0304
#define SDP_ATTR_AUDIO_FEEDBACK_SUPPORT			0x0305
#define SDP_ATTR_NETWORK_ADDRESS			0x0306
#define SDP_ATTR_WAP_GATEWAY				0x0307
#define SDP_ATTR_HOME_PAGE_URL				0x0308
#define SDP_ATTR_WAP_STACK_TYPE				0x0309
#define SDP_ATTR_SECURITY_DESCRIPTION			0x030A
#define SDP_ATTR_NET_ACCESS_TYPE			0x030B
#define SDP_ATTR_MAX_NET_ACCESS_RATE			0x030C
#define SDP_ATTR_IPV4_SUBNET				0x030D
#define SDP_ATTR_IPV6_SUBNET				0x030E
#define SDP_ATTR_SUPPORTED_CAPABALITIES			0x0310
#define SDP_ATTR_SUPPORTED_FEATURES			0x0311
#define SDP_ATTR_SUPPORTED_FUNCTIONS			0x0312
#define SDP_ATTR_TOTAL_IMAGING_DATA_CAPACITY		0x0313
#define SDP_ATTR_SUPPORTED_REPOSITORIES			0x0314

/*
 * The offset must be added to the attribute ID base (contained in the
 * LANGUAGE_BASE_ATTRIBUTE_ID_LIST attribute) in order to compute the
 * attribute ID for these attributes.
 */

#define SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID		0x0100
#define SDP_ATTR_SERVICE_NAME_OFFSET			0x0000
#define SDP_ATTR_SERVICE_DESCRIPTION_OFFSET		0x0001
#define SDP_ATTR_PROVIDER_NAME_OFFSET			0x0002

/*
 * Protocol data unit (PDU) format (page 352)
 */

#define SDP_PDU_ERROR_RESPONSE				0x01
#define SDP_PDU_SERVICE_SEARCH_REQUEST			0x02
#define SDP_PDU_SERVICE_SEARCH_RESPONSE			0x03
#define SDP_PDU_SERVICE_ATTRIBUTE_REQUEST		0x04
#define SDP_PDU_SERVICE_ATTRIBUTE_RESPONSE		0x05
#define SDP_PDU_SERVICE_SEARCH_ATTRIBUTE_REQUEST	0x06
#define SDP_PDU_SERVICE_SEARCH_ATTRIBUTE_RESPONSE	0x07

struct sdp_pdu {
	uint8_t		pid;	/* PDU ID - SDP_PDU_xxx */
	uint16_t	tid;	/* transaction ID */
	uint16_t	len;	/* parameters length (in bytes) */
} __attribute__ ((packed));
typedef struct sdp_pdu		sdp_pdu_t;
typedef struct sdp_pdu *	sdp_pdu_p;

/*
 * Error codes for SDP_PDU_ERROR_RESPONSE
 */

#define SDP_ERROR_CODE_INVALID_SDP_VERSION		0x0001
#define SDP_ERROR_CODE_INVALID_SERVICE_RECORD_HANDLE	0x0002
#define SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX		0x0003
#define SDP_ERROR_CODE_INVALID_PDU_SIZE			0x0004
#define SDP_ERROR_CODE_INVALID_CONTINUATION_STATE	0x0005
#define SDP_ERROR_CODE_INSUFFICIENT_RESOURCES		0x0006

/*
 * SDP int128/uint128 parameter
 */

struct int128 {
	int8_t	b[16];
};
typedef struct int128	int128_t;
typedef struct int128	uint128_t;

/*
 * SDP attribute
 */

struct sdp_attr {
	uint16_t	 flags;
#define SDP_ATTR_OK		(0 << 0)
#define SDP_ATTR_INVALID	(1 << 0)
#define SDP_ATTR_TRUNCATED	(1 << 1)
	uint16_t	 attr;  /* SDP_ATTR_xxx */
	uint32_t	 vlen;	/* length of the value[] in bytes */
	uint8_t		*value;	/* base pointer */
};
typedef struct sdp_attr		sdp_attr_t;
typedef struct sdp_attr *	sdp_attr_p;

/******************************************************************************
 * User interface
 *****************************************************************************/

/* Inline versions of get/put byte/short/long. Pointer is advanced */
#define SDP_GET8(b, cp) { \
	register uint8_t *t_cp = (uint8_t *)(cp); \
	(b) = *t_cp; \
	(cp) ++; \
}

#define SDP_GET16(s, cp) { \
	register uint8_t *t_cp = (uint8_t *)(cp); \
	(s) = ((uint16_t)t_cp[0] << 8) \
	    | ((uint16_t)t_cp[1]) \
	    ; \
	(cp) += 2; \
}

#define SDP_GET32(l, cp) { \
	register uint8_t *t_cp = (uint8_t *)(cp); \
	(l) = ((uint32_t)t_cp[0] << 24) \
	    | ((uint32_t)t_cp[1] << 16) \
	    | ((uint32_t)t_cp[2] << 8) \
	    | ((uint32_t)t_cp[3]) \
	    ; \
	(cp) += 4; \
}

#define SDP_GET64(l, cp) { \
	register uint8_t *t_cp = (uint8_t *)(cp); \
	(l) = ((uint64_t)t_cp[0] << 56) \
	    | ((uint64_t)t_cp[1] << 48) \
	    | ((uint64_t)t_cp[2] << 40) \
	    | ((uint64_t)t_cp[3] << 32) \
	    | ((uint64_t)t_cp[4] << 24) \
	    | ((uint64_t)t_cp[5] << 16) \
	    | ((uint64_t)t_cp[6] << 8) \
	    | ((uint64_t)t_cp[7]) \
	    ; \
	(cp) += 8; \
}

#if BYTE_ORDER == LITTLE_ENDIAN
#define SDP_GET128(l, cp) { \
	register uint8_t *t_cp = (uint8_t *)(cp); \
	(l)->b[15] = *t_cp++; \
	(l)->b[14] = *t_cp++; \
	(l)->b[13] = *t_cp++; \
	(l)->b[12] = *t_cp++; \
	(l)->b[11] = *t_cp++; \
	(l)->b[10] = *t_cp++; \
	(l)->b[9]  = *t_cp++; \
	(l)->b[8]  = *t_cp++; \
	(l)->b[7]  = *t_cp++; \
	(l)->b[6]  = *t_cp++; \
	(l)->b[5]  = *t_cp++; \
	(l)->b[4]  = *t_cp++; \
	(l)->b[3]  = *t_cp++; \
	(l)->b[2]  = *t_cp++; \
	(l)->b[1]  = *t_cp++; \
	(l)->b[0]  = *t_cp++; \
	(cp) += 16; \
}

#define SDP_GET_UUID128(l, cp) { \
	register uint8_t *t_cp = (uint8_t *)(cp); \
	(l)->b[0]  = *t_cp++; \
	(l)->b[1]  = *t_cp++; \
	(l)->b[2]  = *t_cp++; \
	(l)->b[3]  = *t_cp++; \
	(l)->b[4]  = *t_cp++; \
	(l)->b[5]  = *t_cp++; \
	(l)->b[6]  = *t_cp++; \
	(l)->b[7]  = *t_cp++; \
	(l)->b[8]  = *t_cp++; \
	(l)->b[9]  = *t_cp++; \
	(l)->b[10] = *t_cp++; \
	(l)->b[11] = *t_cp++; \
	(l)->b[12] = *t_cp++; \
	(l)->b[13] = *t_cp++; \
	(l)->b[14] = *t_cp++; \
	(l)->b[15] = *t_cp++; \
	(cp) += 16; \
}
#elif BYTE_ORDER == BIG_ENDIAN
#define SDP_GET128(l, cp) { \
	register uint8_t *t_cp = (uint8_t *)(cp); \
	(l)->b[0]  = *t_cp++; \
	(l)->b[1]  = *t_cp++; \
	(l)->b[2]  = *t_cp++; \
	(l)->b[3]  = *t_cp++; \
	(l)->b[4]  = *t_cp++; \
	(l)->b[5]  = *t_cp++; \
	(l)->b[6]  = *t_cp++; \
	(l)->b[7]  = *t_cp++; \
	(l)->b[8]  = *t_cp++; \
	(l)->b[9]  = *t_cp++; \
	(l)->b[10] = *t_cp++; \
	(l)->b[11] = *t_cp++; \
	(l)->b[12] = *t_cp++; \
	(l)->b[13] = *t_cp++; \
	(l)->b[14] = *t_cp++; \
	(l)->b[15] = *t_cp++; \
	(cp) += 16; \
}

#define	SDP_GET_UUID128(l, cp)	SDP_GET128(l, cp)
#else
#error	"Unsupported BYTE_ORDER"
#endif /* BYTE_ORDER */

#define SDP_PUT8(b, cp) { \
	register uint8_t t_b = (uint8_t)(b); \
	register uint8_t *t_cp = (uint8_t *)(cp); \
	*t_cp = t_b; \
	(cp) ++; \
}

#define SDP_PUT16(s, cp) { \
	register uint16_t t_s = (uint16_t)(s); \
	register uint8_t *t_cp = (uint8_t *)(cp); \
	*t_cp++ = t_s >> 8; \
	*t_cp   = t_s; \
	(cp) += 2; \
}

#define SDP_PUT32(l, cp) { \
	register uint32_t t_l = (uint32_t)(l); \
	register uint8_t *t_cp = (uint8_t *)(cp); \
	*t_cp++ = t_l >> 24; \
	*t_cp++ = t_l >> 16; \
	*t_cp++ = t_l >> 8; \
	*t_cp   = t_l; \
	(cp) += 4; \
}

#define SDP_PUT64(l, cp) { \
	register uint64_t t_l = (uint64_t)(l); \
	register uint8_t *t_cp = (uint8_t *)(cp); \
	*t_cp++ = t_l >> 56; \
	*t_cp++ = t_l >> 48; \
	*t_cp++ = t_l >> 40; \
	*t_cp++ = t_l >> 32; \
	*t_cp++ = t_l >> 24; \
	*t_cp++ = t_l >> 16; \
	*t_cp++ = t_l >> 8; \
	*t_cp   = t_l; \
	(cp) += 8; \
}

#if BYTE_ORDER == LITTLE_ENDIAN
#define SDP_PUT128(l, cp) { \
	register uint8_t *t_cp = (uint8_t *)(cp); \
	*t_cp++ = (l)->b[15]; \
	*t_cp++ = (l)->b[14]; \
	*t_cp++ = (l)->b[13]; \
	*t_cp++ = (l)->b[12]; \
	*t_cp++ = (l)->b[11]; \
	*t_cp++ = (l)->b[10]; \
	*t_cp++ = (l)->b[9];  \
	*t_cp++ = (l)->b[8];  \
	*t_cp++ = (l)->b[7];  \
	*t_cp++ = (l)->b[6];  \
	*t_cp++ = (l)->b[5];  \
	*t_cp++ = (l)->b[4];  \
	*t_cp++ = (l)->b[3];  \
	*t_cp++ = (l)->b[2];  \
	*t_cp++ = (l)->b[1];  \
	*t_cp   = (l)->b[0];  \
	(cp) += 16; \
}

#define SDP_PUT_UUID128(l, cp) { \
	register uint8_t *t_cp = (uint8_t *)(cp); \
	*t_cp++ = (l)->b[0];  \
	*t_cp++ = (l)->b[1];  \
	*t_cp++ = (l)->b[2];  \
	*t_cp++ = (l)->b[3];  \
	*t_cp++ = (l)->b[4];  \
	*t_cp++ = (l)->b[5];  \
	*t_cp++ = (l)->b[6];  \
	*t_cp++ = (l)->b[7];  \
	*t_cp++ = (l)->b[8];  \
	*t_cp++ = (l)->b[9];  \
	*t_cp++ = (l)->b[10]; \
	*t_cp++ = (l)->b[11]; \
	*t_cp++ = (l)->b[12]; \
	*t_cp++ = (l)->b[13]; \
	*t_cp++ = (l)->b[14]; \
	*t_cp   = (l)->b[15]; \
	(cp) += 16; \
}
#elif BYTE_ORDER == BIG_ENDIAN
#define SDP_PUT128(l, cp) { \
	register uint8_t *t_cp = (uint8_t *)(cp); \
	*t_cp++ = (l)->b[0];  \
	*t_cp++ = (l)->b[1];  \
	*t_cp++ = (l)->b[2];  \
	*t_cp++ = (l)->b[3];  \
	*t_cp++ = (l)->b[4];  \
	*t_cp++ = (l)->b[5];  \
	*t_cp++ = (l)->b[6];  \
	*t_cp++ = (l)->b[7];  \
	*t_cp++ = (l)->b[8];  \
	*t_cp++ = (l)->b[9];  \
	*t_cp++ = (l)->b[10]; \
	*t_cp++ = (l)->b[11]; \
	*t_cp++ = (l)->b[12]; \
	*t_cp++ = (l)->b[13]; \
	*t_cp++ = (l)->b[14]; \
	*t_cp   = (l)->b[15]; \
	(cp) += 16; \
}

#define SDP_PUT_UUID128(l, cp)	SDP_PUT128(l, cp)
#else
#error	"Unsupported BYTE_ORDER"
#endif /* BYTE_ORDER */

void *             sdp_open       (bdaddr_t const *l, bdaddr_t const *r);
void *             sdp_open_local (char const *control);
int32_t            sdp_close      (void *xs);
int32_t            sdp_error      (void *xs);

int32_t            sdp_search     (void *xs,
                                   uint32_t plen, uint16_t const *pp,
                                   uint32_t alen, uint32_t const *ap,
                                   uint32_t vlen, sdp_attr_t *vp);

char const *	   sdp_attr2desc  (uint16_t attr);
char const *	   sdp_uuid2desc  (uint16_t uuid);
void               sdp_print      (uint32_t level, uint8_t const *start,
                                   uint8_t const *end);

/******************************************************************************
 * sdpd interface and Bluetooth profiles data
 *****************************************************************************/

#define SDP_LOCAL_PATH	"/var/run/sdp"
#define SDP_LOCAL_MTU	4096

/*
 * These are NOT defined in spec and only accepted on control sockets.
 * The response to these request always will be SDP_PDU_ERROR_RESPONSE.
 * The first 2 bytes (after PDU header) is an error code (in network
 * byte order). The rest of the data (pdu->len - 2) is a response data
 * and depend on the request.
 *
 * SDP_PDU_SERVICE_REGISTER_REQUEST
 * 	pdu_header_t	hdr;
 *	u_int16_t	uuid;	service class UUID (network byte order)
 *	bdaddr_t	bdaddr;	local BD_ADDR (or ANY)
 *	profile data[pdu->len - sizeof(uuid) - sizeof(bdaddr)]
 *
 * in successful reponse additional data will contain 4 bytes record handle
 *
 *
 * SDP_PDU_SERVICE_UNREGISTER_REQUEST
 *	pdu_header_t	hdr;
 *	u_int32_t	record_handle;	(network byte order)
 *
 * no additional data in response.
 *
 *
 * SDP_PDU_SERVICE_CHANGE_REQUEST
 * 	pdu_header_t	hdr;
 *	u_int32_t	record_handle;	(network byte order)
 *	profile data[pdu->len - sizeof(record_handle)]
 *
 * no additional data in response.
 */

#define SDP_PDU_SERVICE_REGISTER_REQUEST	0x81
#define SDP_PDU_SERVICE_UNREGISTER_REQUEST	0x82
#define SDP_PDU_SERVICE_CHANGE_REQUEST		0x83

struct sdp_dun_profile
{
	uint8_t	server_channel;
	uint8_t	audio_feedback_support;
	uint8_t	reserved[2];
};
typedef struct sdp_dun_profile		sdp_dun_profile_t;
typedef struct sdp_dun_profile *	sdp_dun_profile_p;

struct sdp_ftrn_profile
{
	uint8_t	server_channel;
	uint8_t	reserved[3];
};
typedef struct sdp_ftrn_profile		sdp_ftrn_profile_t;
typedef struct sdp_ftrn_profile *	sdp_ftrn_profile_p;

/* Keep this in sync with sdp_opush_profile */
struct sdp_irmc_profile
{
	uint8_t	server_channel;
	uint8_t	supported_formats_size;
	uint8_t	supported_formats[30];
};
typedef struct sdp_irmc_profile		sdp_irmc_profile_t;
typedef struct sdp_irmc_profile *	sdp_irmc_profile_p;

struct sdp_irmc_command_profile
{
	uint8_t	server_channel;
	uint8_t	reserved[3];
};
typedef struct sdp_irmc_command_profile		sdp_irmc_command_profile_t;
typedef struct sdp_irmc_command_profile *	sdp_irmc_command_profile_p;

struct sdp_lan_profile
{
	uint8_t		server_channel;
	uint8_t		load_factor;
	uint8_t		reserved;
	uint8_t		ip_subnet_radius;
	uint32_t	ip_subnet;
};
typedef struct sdp_lan_profile		sdp_lan_profile_t;
typedef struct sdp_lan_profile *	sdp_lan_profile_p;

/* Keep this in sync with sdp_irmc_profile */
struct sdp_opush_profile
{
	uint8_t	server_channel;
	uint8_t	supported_formats_size;
	uint8_t	supported_formats[30];
};
typedef struct sdp_opush_profile	sdp_opush_profile_t;
typedef struct sdp_opush_profile *	sdp_opush_profile_p;

struct sdp_sp_profile
{
	uint8_t	server_channel;
	uint8_t	reserved[3];
};
typedef struct sdp_sp_profile	sdp_sp_profile_t;
typedef struct sdp_sp_profile *	sdp_sp_profile_p;

struct sdp_nap_profile
{
	uint8_t		reserved;
	uint8_t		load_factor;
	uint16_t	psm;			/* HBO */
	uint16_t	security_description;	/* HBO */
	uint16_t	net_access_type;	/* HBO */
	uint32_t	max_net_access_rate;	/* HBO */
};
typedef struct sdp_nap_profile		sdp_nap_profile_t;
typedef struct sdp_nap_profile *	sdp_nap_profile_p;

struct sdp_gn_profile
{
	uint8_t		reserved;
	uint8_t		load_factor;
	uint16_t	psm;			/* HBO */
	uint16_t	security_description;	/* HBO */
	uint16_t	reserved2;
};
typedef struct sdp_gn_profile		sdp_gn_profile_t;
typedef struct sdp_gn_profile *		sdp_gn_profile_p;

struct sdp_panu_profile
{
	uint8_t		reserved;
	uint8_t		load_factor;
	uint16_t	psm;			/* HBO */
	uint16_t	security_description;	/* HBO */
	uint16_t	reserved2;
};
typedef struct sdp_panu_profile		sdp_panu_profile_t;
typedef struct sdp_panu_profile *	sdp_panu_profile_p;

int32_t	sdp_register_service	(void *xss, uint16_t uuid,
				 bdaddr_p const bdaddr, uint8_t const *data,
				 uint32_t datalen, uint32_t *handle);
int32_t	sdp_unregister_service	(void *xss, uint32_t handle);
int32_t	sdp_change_service	(void *xss, uint32_t handle,
				 uint8_t const *data, uint32_t datalen);

__END_DECLS

#endif /* ndef _SDP_H_ */


code:
/*-
 * Written by J.T. Conklin <jtc@netbsd.org>
 * Public domain.
 *
 *	$NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $
 * $FreeBSD: release/9.0.0/include/search.h 105250 2002-10-16 14:29:23Z robert $
 */

#ifndef _SEARCH_H_
#define _SEARCH_H_

#include <sys/cdefs.h>
#include <sys/_types.h>

#ifndef _SIZE_T_DECLARED
typedef	__size_t	size_t;
#define	_SIZE_T_DECLARED
#endif

typedef	struct entry {
	char	*key;
	void	*data;
} ENTRY;

typedef	enum {
	FIND, ENTER
} ACTION;

typedef	enum {
	preorder,
	postorder,
	endorder,
	leaf
} VISIT;

#ifdef _SEARCH_PRIVATE
typedef	struct node {
	char         *key;
	struct node  *llink, *rlink;
} node_t;

struct que_elem {
	struct que_elem *next;
	struct que_elem *prev;
};
#endif

__BEGIN_DECLS
int	 hcreate(size_t);
void	 hdestroy(void);
ENTRY	*hsearch(ENTRY, ACTION);
void	 insque(void *, void *);
void	*lfind(const void *, const void *, size_t *, size_t,
	    int (*)(const void *, const void *));
void	*lsearch(const void *, void *, size_t *, size_t,
	    int (*)(const void *, const void *));
void	 remque(void *);
void	*tdelete(const void * __restrict, void ** __restrict,
	    int (*)(const void *, const void *));
void	*tfind(const void *, void * const *,
	    int (*)(const void *, const void *));
void	*tsearch(const void *, void **, int (*)(const void *, const void *));
void	 twalk(const void *, void (*)(const void *, VISIT, int));
__END_DECLS

#endif /* !_SEARCH_H_ */


code:
/*-
 * Copyright (c) 1999-2005 Apple Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1.  Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 * 2.  Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
 *     its contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/security/audit/audit.h 224181 2011-07-18 12:58:18Z jonathan $
 */

/*
 * This header includes function prototypes and type definitions that are
 * necessary for the kernel as a whole to interact with the audit subsystem.
 */

#ifndef _SECURITY_AUDIT_KERNEL_H_
#define	_SECURITY_AUDIT_KERNEL_H_

#ifndef _KERNEL
#error "no user-serviceable parts inside"
#endif

#include <bsm/audit.h>

#include <sys/file.h>
#include <sys/sysctl.h>

/*
 * Audit subsystem condition flags.  The audit_enabled flag is set and
 * removed automatically as a result of configuring log files, and can be
 * observed but should not be directly manipulated.  The audit suspension
 * flag permits audit to be temporarily disabled without reconfiguring the
 * audit target.
 */
extern int	audit_enabled;
extern int	audit_suspended;

void	 audit_syscall_enter(unsigned short code, struct thread *td);
void	 audit_syscall_exit(int error, struct thread *td);

/*
 * The remaining kernel functions are conditionally compiled in as they are
 * wrapped by a macro, and the macro should be the only place in the source
 * tree where these functions are referenced.
 */
#ifdef AUDIT
struct ipc_perm;
struct sockaddr;
union auditon_udata;
void	 audit_arg_addr(void * addr);
void	 audit_arg_exit(int status, int retval);
void	 audit_arg_len(int len);
void	 audit_arg_atfd1(int atfd);
void	 audit_arg_atfd2(int atfd);
void	 audit_arg_fd(int fd);
void	 audit_arg_fflags(int fflags);
void	 audit_arg_gid(gid_t gid);
void	 audit_arg_uid(uid_t uid);
void	 audit_arg_egid(gid_t egid);
void	 audit_arg_euid(uid_t euid);
void	 audit_arg_rgid(gid_t rgid);
void	 audit_arg_ruid(uid_t ruid);
void	 audit_arg_sgid(gid_t sgid);
void	 audit_arg_suid(uid_t suid);
void	 audit_arg_groupset(gid_t *gidset, u_int gidset_size);
void	 audit_arg_login(char *login);
void	 audit_arg_ctlname(int *name, int namelen);
void	 audit_arg_mask(int mask);
void	 audit_arg_mode(mode_t mode);
void	 audit_arg_dev(int dev);
void	 audit_arg_value(long value);
void	 audit_arg_owner(uid_t uid, gid_t gid);
void	 audit_arg_pid(pid_t pid);
void	 audit_arg_process(struct proc *p);
void	 audit_arg_signum(u_int signum);
void	 audit_arg_socket(int sodomain, int sotype, int soprotocol);
void	 audit_arg_sockaddr(struct thread *td, struct sockaddr *sa);
void	 audit_arg_auid(uid_t auid);
void	 audit_arg_auditinfo(struct auditinfo *au_info);
void	 audit_arg_auditinfo_addr(struct auditinfo_addr *au_info);
void	 audit_arg_upath1(struct thread *td, char *upath);
void	 audit_arg_upath2(struct thread *td, char *upath);
void	 audit_arg_vnode1(struct vnode *vp);
void	 audit_arg_vnode2(struct vnode *vp);
void	 audit_arg_text(char *text);
void	 audit_arg_cmd(int cmd);
void	 audit_arg_svipc_cmd(int cmd);
void	 audit_arg_svipc_perm(struct ipc_perm *perm);
void	 audit_arg_svipc_id(int id);
void	 audit_arg_svipc_addr(void *addr);
void	 audit_arg_posix_ipc_perm(uid_t uid, gid_t gid, mode_t mode);
void	 audit_arg_auditon(union auditon_udata *udata);
void	 audit_arg_file(struct proc *p, struct file *fp);
void	 audit_arg_argv(char *argv, int argc, int length);
void	 audit_arg_envv(char *envv, int envc, int length);
void	 audit_arg_rights(cap_rights_t rights);
void	 audit_sysclose(struct thread *td, int fd);
void	 audit_cred_copy(struct ucred *src, struct ucred *dest);
void	 audit_cred_destroy(struct ucred *cred);
void	 audit_cred_init(struct ucred *cred);
void	 audit_cred_kproc0(struct ucred *cred);
void	 audit_cred_proc1(struct ucred *cred);
void	 audit_proc_coredump(struct thread *td, char *path, int errcode);
void	 audit_thread_alloc(struct thread *td);
void	 audit_thread_free(struct thread *td);

/*
 * Define macros to wrap the audit_arg_* calls by checking the global
 * audit_enabled flag before performing the actual call.
 */
#define	AUDITING_TD(td)		((td)->td_pflags & TDP_AUDITREC)

#define	AUDIT_ARG_ADDR(addr) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_addr((addr));					\
} while (0)

#define	AUDIT_ARG_ARGV(argv, argc, length) do {				\
	if (AUDITING_TD(curthread))					\
		audit_arg_argv((argv), (argc), (length));		\
} while (0)

#define	AUDIT_ARG_ATFD1(atfd) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_atfd1((atfd));				\
} while (0)

#define	AUDIT_ARG_ATFD2(atfd) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_atfd2((atfd));				\
} while (0)

#define	AUDIT_ARG_AUDITON(udata) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_auditon((udata));				\
} while (0)

#define	AUDIT_ARG_CMD(cmd) do {						\
	if (AUDITING_TD(curthread))					\
		audit_arg_cmd((cmd));					\
} while (0)

#define	AUDIT_ARG_DEV(dev) do {						\
	if (AUDITING_TD(curthread))					\
		audit_arg_dev((dev));					\
} while (0)

#define	AUDIT_ARG_EGID(egid) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_egid((egid));					\
} while (0)

#define	AUDIT_ARG_ENVV(envv, envc, length) do {				\
	if (AUDITING_TD(curthread))					\
		audit_arg_envv((envv), (envc), (length));		\
} while (0)

#define	AUDIT_ARG_EXIT(status, retval) do {				\
	if (AUDITING_TD(curthread))					\
		audit_arg_exit((status), (retval));			\
} while (0)

#define	AUDIT_ARG_EUID(euid) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_euid((euid));					\
} while (0)

#define	AUDIT_ARG_FD(fd) do {						\
	if (AUDITING_TD(curthread))					\
		audit_arg_fd((fd));					\
} while (0)

#define	AUDIT_ARG_FILE(p, fp) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_file((p), (fp));				\
} while (0)

#define	AUDIT_ARG_FFLAGS(fflags) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_fflags((fflags));				\
} while (0)

#define	AUDIT_ARG_GID(gid) do {						\
	if (AUDITING_TD(curthread))					\
		audit_arg_gid((gid));					\
} while (0)

#define	AUDIT_ARG_GROUPSET(gidset, gidset_size) do {			\
	if (AUDITING_TD(curthread))					\
		audit_arg_groupset((gidset), (gidset_size));		\
} while (0)

#define	AUDIT_ARG_MODE(mode) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_mode((mode));					\
} while (0)

#define	AUDIT_ARG_OWNER(uid, gid) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_owner((uid), (gid));				\
} while (0)

#define	AUDIT_ARG_PID(pid) do {						\
	if (AUDITING_TD(curthread))					\
		audit_arg_pid((pid));					\
} while (0)

#define	AUDIT_ARG_PROCESS(p) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_process((p));					\
} while (0)

#define	AUDIT_ARG_RGID(rgid) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_rgid((rgid));					\
} while (0)

#define	AUDIT_ARG_RIGHTS(rights) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_rights((rights));				\
} while (0)

#define	AUDIT_ARG_RUID(ruid) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_ruid((ruid));					\
} while (0)

#define	AUDIT_ARG_SIGNUM(signum) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_signum((signum));				\
} while (0)

#define	AUDIT_ARG_SGID(sgid) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_sgid((sgid));					\
} while (0)

#define	AUDIT_ARG_SOCKET(sodomain, sotype, soprotocol) do {		\
	if (AUDITING_TD(curthread))					\
		audit_arg_socket((sodomain), (sotype), (soprotocol));	\
} while (0)

#define	AUDIT_ARG_SUID(suid) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_suid((suid));					\
} while (0)

#define	AUDIT_ARG_TEXT(text) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_text((text));					\
} while (0)

#define	AUDIT_ARG_UID(uid) do {						\
	if (AUDITING_TD(curthread))					\
		audit_arg_uid((uid));					\
} while (0)

#define	AUDIT_ARG_UPATH1(td, upath) do {				\
	if (AUDITING_TD(curthread))					\
		audit_arg_upath1((td), (upath));			\
} while (0)

#define	AUDIT_ARG_UPATH2(td, upath) do {				\
	if (AUDITING_TD(curthread))					\
		audit_arg_upath2((td), (upath));			\
} while (0)

#define	AUDIT_ARG_VALUE(value) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_value((value));				\
} while (0)

#define	AUDIT_ARG_VNODE1(vp) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_vnode1((vp));					\
} while (0)

#define	AUDIT_ARG_VNODE2(vp) do {					\
	if (AUDITING_TD(curthread))					\
		audit_arg_vnode2((vp));					\
} while (0)

#define	AUDIT_SYSCALL_ENTER(code, td)	do {				\
	if (audit_enabled) {						\
		audit_syscall_enter(code, td);				\
	}								\
} while (0)

/*
 * Wrap the audit_syscall_exit() function so that it is called only when
 * we have a audit record on the thread.  Audit records can persist after
 * auditing is disabled, so we don't just check audit_enabled here.
 */
#define	AUDIT_SYSCALL_EXIT(error, td)	do {				\
	if (td->td_pflags & TDP_AUDITREC)				\
		audit_syscall_exit(error, td);				\
} while (0)

/*
 * A Macro to wrap the audit_sysclose() function.
 */
#define	AUDIT_SYSCLOSE(td, fd)	do {					\
	if (td->td_pflags & TDP_AUDITREC)				\
		audit_sysclose(td, fd);					\
} while (0)

#else /* !AUDIT */

#define	AUDIT_ARG_ADDR(addr)
#define	AUDIT_ARG_ARGV(argv, argc, length)
#define	AUDIT_ARG_ATFD1(atfd)
#define	AUDIT_ARG_ATFD2(atfd)
#define	AUDIT_ARG_AUDITON(udata)
#define	AUDIT_ARG_CMD(cmd)
#define	AUDIT_ARG_DEV(dev)
#define	AUDIT_ARG_EGID(egid)
#define	AUDIT_ARG_ENVV(envv, envc, length)
#define	AUDIT_ARG_EXIT(status, retval)
#define	AUDIT_ARG_EUID(euid)
#define	AUDIT_ARG_FD(fd)
#define	AUDIT_ARG_FILE(p, fp)
#define	AUDIT_ARG_FFLAGS(fflags)
#define	AUDIT_ARG_GID(gid)
#define	AUDIT_ARG_GROUPSET(gidset, gidset_size)
#define	AUDIT_ARG_MODE(mode)
#define	AUDIT_ARG_OWNER(uid, gid)
#define	AUDIT_ARG_PID(pid)
#define	AUDIT_ARG_PROCESS(p)
#define	AUDIT_ARG_RGID(rgid)
#define	AUDIT_ARG_RIGHTS(rights)
#define	AUDIT_ARG_RUID(ruid)
#define	AUDIT_ARG_SIGNUM(signum)
#define	AUDIT_ARG_SGID(sgid)
#define	AUDIT_ARG_SOCKET(sodomain, sotype, soprotocol)
#define	AUDIT_ARG_SUID(suid)
#define	AUDIT_ARG_TEXT(text)
#define	AUDIT_ARG_UID(uid)
#define	AUDIT_ARG_UPATH1(td, upath)
#define	AUDIT_ARG_UPATH2(td, upath)
#define	AUDIT_ARG_VALUE(value)
#define	AUDIT_ARG_VNODE1(vp)
#define	AUDIT_ARG_VNODE2(vp)

#define	AUDIT_SYSCALL_ENTER(code, td)
#define	AUDIT_SYSCALL_EXIT(error, td)

#define	AUDIT_SYSCLOSE(p, fd)

#endif /* AUDIT */

#endif /* !_SECURITY_AUDIT_KERNEL_H_ */


code:
/*-
 * Copyright (c) 2006 Robert N. M. Watson
 * All rights reserved.
 *
 * This software was developed by Robert Watson for the TrustedBSD Project.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/security/audit/audit_ioctl.h 169097 2007-04-29 16:20:32Z rwatson $
 */

#ifndef _SECURITY_AUDIT_AUDIT_IOCTL_H_
#define	_SECURITY_AUDIT_AUDIT_IOCTL_H_

#define	AUDITPIPE_IOBASE	'A'

/*
 * Data structures used for complex ioctl arguments.  Do not change existing
 * structures, add new revised ones to be used by new ioctls, and keep the
 * old structures and ioctls for backwards compatibility.
 */
struct auditpipe_ioctl_preselect {
	au_id_t		aip_auid;
	au_mask_t	aip_mask;
};

/*
 * Possible modes of operation for audit pipe preselection.
 */
#define	AUDITPIPE_PRESELECT_MODE_TRAIL	1	/* Global audit trail. */
#define	AUDITPIPE_PRESELECT_MODE_LOCAL	2	/* Local audit trail. */

/*
 * Ioctls to read and control the behavior of individual audit pipe devices.
 */
#define	AUDITPIPE_GET_QLEN		_IOR(AUDITPIPE_IOBASE, 1, u_int)
#define	AUDITPIPE_GET_QLIMIT		_IOR(AUDITPIPE_IOBASE, 2, u_int)
#define	AUDITPIPE_SET_QLIMIT		_IOW(AUDITPIPE_IOBASE, 3, u_int)
#define	AUDITPIPE_GET_QLIMIT_MIN	_IOR(AUDITPIPE_IOBASE, 4, u_int)
#define	AUDITPIPE_GET_QLIMIT_MAX	_IOR(AUDITPIPE_IOBASE, 5, u_int)
#define	AUDITPIPE_GET_PRESELECT_FLAGS	_IOR(AUDITPIPE_IOBASE, 6, au_mask_t)
#define	AUDITPIPE_SET_PRESELECT_FLAGS	_IOW(AUDITPIPE_IOBASE, 7, au_mask_t)
#define	AUDITPIPE_GET_PRESELECT_NAFLAGS	_IOR(AUDITPIPE_IOBASE, 8, au_mask_t)
#define	AUDITPIPE_SET_PRESELECT_NAFLAGS	_IOW(AUDITPIPE_IOBASE, 9, au_mask_t)
#define	AUDITPIPE_GET_PRESELECT_AUID	_IOR(AUDITPIPE_IOBASE, 10,	\
					    struct auditpipe_ioctl_preselect)
#define	AUDITPIPE_SET_PRESELECT_AUID	_IOW(AUDITPIPE_IOBASE, 11,	\
					    struct auditpipe_ioctl_preselect)
#define	AUDITPIPE_DELETE_PRESELECT_AUID	_IOW(AUDITPIPE_IOBASE, 12, au_id_t)
#define	AUDITPIPE_FLUSH_PRESELECT_AUID	_IO(AUDITPIPE_IOBASE, 13)
#define	AUDITPIPE_GET_PRESELECT_MODE	_IOR(AUDITPIPE_IOBASE, 14, int)
#define	AUDITPIPE_SET_PRESELECT_MODE	_IOW(AUDITPIPE_IOBASE, 15, int)
#define	AUDITPIPE_FLUSH			_IO(AUDITPIPE_IOBASE, 16)
#define	AUDITPIPE_GET_MAXAUDITDATA	_IOR(AUDITPIPE_IOBASE, 17, u_int)

/*
 * Ioctls to retrieve audit pipe statistics.
 */
#define	AUDITPIPE_GET_INSERTS		_IOR(AUDITPIPE_IOBASE, 100, u_int64_t)
#define	AUDITPIPE_GET_READS		_IOR(AUDITPIPE_IOBASE, 101, u_int64_t)
#define	AUDITPIPE_GET_DROPS		_IOR(AUDITPIPE_IOBASE, 102, u_int64_t)
#define	AUDITPIPE_GET_TRUNCATES		_IOR(AUDITPIPE_IOBASE, 103, u_int64_t)

#endif /* _SECURITY_AUDIT_AUDIT_IOCTL_H_ */


code:
/*-
 * Copyright (c) 1999-2009 Apple Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1.  Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 * 2.  Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
 *     its contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/security/audit/audit_private.h 224181 2011-07-18 12:58:18Z jonathan $
 */

/*
 * This include file contains function prototypes and type definitions used
 * within the audit implementation.
 */

#ifndef _SECURITY_AUDIT_PRIVATE_H_
#define	_SECURITY_AUDIT_PRIVATE_H_

#ifndef _KERNEL
#error "no user-serviceable parts inside"
#endif

#include <sys/ipc.h>
#include <sys/socket.h>
#include <sys/ucred.h>

#ifdef MALLOC_DECLARE
MALLOC_DECLARE(M_AUDITBSM);
MALLOC_DECLARE(M_AUDITDATA);
MALLOC_DECLARE(M_AUDITPATH);
MALLOC_DECLARE(M_AUDITTEXT);
MALLOC_DECLARE(M_AUDITGIDSET);
#endif

/*
 * Audit control variables that are usually set/read via system calls and
 * used to control various aspects of auditing.
 */
extern struct au_qctrl		audit_qctrl;
extern struct audit_fstat	audit_fstat;
extern struct au_mask		audit_nae_mask;
extern int			audit_panic_on_write_fail;
extern int			audit_fail_stop;
extern int			audit_argv;
extern int			audit_arge;

/*
 * Success/failure conditions for the conversion of a kernel audit record to
 * BSM format.
 */
#define	BSM_SUCCESS	0
#define	BSM_FAILURE	1
#define	BSM_NOAUDIT	2

/*
 * Defines for the kernel audit record k_ar_commit field.  Flags are set to
 * indicate what sort of record it is, and which preselection mechanism
 * selected it.
 */
#define	AR_COMMIT_KERNEL	0x00000001U
#define	AR_COMMIT_USER		0x00000010U

#define	AR_PRESELECT_TRAIL	0x00001000U
#define	AR_PRESELECT_PIPE	0x00002000U

#define	AR_PRESELECT_USER_TRAIL	0x00004000U
#define	AR_PRESELECT_USER_PIPE	0x00008000U

/*
 * Audit data is generated as a stream of struct audit_record structures,
 * linked by struct kaudit_record, and contain storage for possible audit so
 * that it will not need to be allocated during the processing of a system
 * call, both improving efficiency and avoiding sleeping at untimely moments.
 * This structure is converted to BSM format before being written to disk.
 */
struct vnode_au_info {
	mode_t	vn_mode;
	uid_t	vn_uid;
	gid_t	vn_gid;
	dev_t	vn_dev;
	long	vn_fsid;
	long	vn_fileid;
	long	vn_gen;
};

struct groupset {
	gid_t	*gidset;
	u_int	 gidset_size;
};

struct socket_au_info {
	int		so_domain;
	int		so_type;
	int		so_protocol;
	in_addr_t	so_raddr;	/* Remote address if INET socket. */
	in_addr_t	so_laddr;	/* Local address if INET socket. */
	u_short		so_rport;	/* Remote port. */
	u_short		so_lport;	/* Local port. */
};

/*
 * The following is used for A_OLDSETQCTRL and AU_OLDGETQCTRL and a 64-bit
 * userland.
 */
struct au_qctrl64 {
	u_int64_t	aq64_hiwater;
	u_int64_t	aq64_lowater;
	u_int64_t	aq64_bufsz;
	u_int64_t	aq64_delay;
	u_int64_t	aq64_minfree;
};
typedef	struct au_qctrl64	au_qctrl64_t;

union auditon_udata {
	char			*au_path;
	int			au_cond;
	int			au_flags;
	int			au_policy;
	int			au_trigger;
	int64_t			au_cond64;
	int64_t			au_policy64;
	au_evclass_map_t	au_evclass;
	au_mask_t		au_mask;
	auditinfo_t		au_auinfo;
	auditpinfo_t		au_aupinfo;
	auditpinfo_addr_t	au_aupinfo_addr;
	au_qctrl_t		au_qctrl;
	au_qctrl64_t		au_qctrl64;
	au_stat_t		au_stat;
	au_fstat_t		au_fstat;
	auditinfo_addr_t	au_kau_info;
};

struct posix_ipc_perm {
	uid_t	pipc_uid;
	gid_t	pipc_gid;
	mode_t	pipc_mode;
};

struct audit_record {
	/* Audit record header. */
	u_int32_t		ar_magic;
	int			ar_event;
	int			ar_retval; /* value returned to the process */
	int			ar_errno;  /* return status of system call */
	struct timespec		ar_starttime;
	struct timespec		ar_endtime;
	u_int64_t		ar_valid_arg;  /* Bitmask of valid arguments */

	/* Audit subject information. */
	struct xucred		ar_subj_cred;
	uid_t			ar_subj_ruid;
	gid_t			ar_subj_rgid;
	gid_t			ar_subj_egid;
	uid_t			ar_subj_auid; /* Audit user ID */
	pid_t			ar_subj_asid; /* Audit session ID */
	pid_t			ar_subj_pid;
	struct au_tid		ar_subj_term;
	struct au_tid_addr	ar_subj_term_addr;
	struct au_mask		ar_subj_amask;

	/* Operation arguments. */
	uid_t			ar_arg_euid;
	uid_t			ar_arg_ruid;
	uid_t			ar_arg_suid;
	gid_t			ar_arg_egid;
	gid_t			ar_arg_rgid;
	gid_t			ar_arg_sgid;
	pid_t			ar_arg_pid;
	pid_t			ar_arg_asid;
	struct au_tid		ar_arg_termid;
	struct au_tid_addr	ar_arg_termid_addr;
	uid_t			ar_arg_uid;
	uid_t			ar_arg_auid;
	gid_t			ar_arg_gid;
	struct groupset		ar_arg_groups;
	int			ar_arg_fd;
	int			ar_arg_atfd1;
	int			ar_arg_atfd2;
	int			ar_arg_fflags;
	mode_t			ar_arg_mode;
	int			ar_arg_dev;
	long			ar_arg_value;
	void *			ar_arg_addr;
	int			ar_arg_len;
	int			ar_arg_mask;
	u_int			ar_arg_signum;
	char			ar_arg_login[MAXLOGNAME];
	int			ar_arg_ctlname[CTL_MAXNAME];
	struct socket_au_info	ar_arg_sockinfo;
	char			*ar_arg_upath1;
	char			*ar_arg_upath2;
	char			*ar_arg_text;
	struct au_mask		ar_arg_amask;
	struct vnode_au_info	ar_arg_vnode1;
	struct vnode_au_info	ar_arg_vnode2;
	int			ar_arg_cmd;
	int			ar_arg_svipc_cmd;
	struct ipc_perm		ar_arg_svipc_perm;
	int			ar_arg_svipc_id;
	void *			ar_arg_svipc_addr;
	struct posix_ipc_perm	ar_arg_pipc_perm;
	union auditon_udata	ar_arg_auditon;
	char			*ar_arg_argv;
	int			ar_arg_argc;
	char			*ar_arg_envv;
	int			ar_arg_envc;
	int			ar_arg_exitstatus;
	int			ar_arg_exitretval;
	struct sockaddr_storage ar_arg_sockaddr;
	cap_rights_t		ar_arg_rights;
};

/*
 * Arguments in the audit record are initially not defined; flags are set to
 * indicate if they are present so they can be included in the audit log
 * stream only if defined.
 */
#define	ARG_EUID		0x0000000000000001ULL
#define	ARG_RUID		0x0000000000000002ULL
#define	ARG_SUID		0x0000000000000004ULL
#define	ARG_EGID		0x0000000000000008ULL
#define	ARG_RGID		0x0000000000000010ULL
#define	ARG_SGID		0x0000000000000020ULL
#define	ARG_PID			0x0000000000000040ULL
#define	ARG_UID			0x0000000000000080ULL
#define	ARG_AUID		0x0000000000000100ULL
#define	ARG_GID			0x0000000000000200ULL
#define	ARG_FD			0x0000000000000400ULL
#define	ARG_POSIX_IPC_PERM	0x0000000000000800ULL
#define	ARG_FFLAGS		0x0000000000001000ULL
#define	ARG_MODE		0x0000000000002000ULL
#define	ARG_DEV			0x0000000000004000ULL
#define	ARG_ADDR		0x0000000000008000ULL
#define	ARG_LEN			0x0000000000010000ULL
#define	ARG_MASK		0x0000000000020000ULL
#define	ARG_SIGNUM		0x0000000000040000ULL
#define	ARG_LOGIN		0x0000000000080000ULL
#define	ARG_SADDRINET		0x0000000000100000ULL
#define	ARG_SADDRINET6		0x0000000000200000ULL
#define	ARG_SADDRUNIX		0x0000000000400000ULL
#define	ARG_TERMID_ADDR		0x0000000000400000ULL
#define	ARG_UNUSED2		0x0000000001000000ULL
#define	ARG_UPATH1		0x0000000002000000ULL
#define	ARG_UPATH2		0x0000000004000000ULL
#define	ARG_TEXT		0x0000000008000000ULL
#define	ARG_VNODE1		0x0000000010000000ULL
#define	ARG_VNODE2		0x0000000020000000ULL
#define	ARG_SVIPC_CMD		0x0000000040000000ULL
#define	ARG_SVIPC_PERM		0x0000000080000000ULL
#define	ARG_SVIPC_ID		0x0000000100000000ULL
#define	ARG_SVIPC_ADDR		0x0000000200000000ULL
#define	ARG_GROUPSET		0x0000000400000000ULL
#define	ARG_CMD			0x0000000800000000ULL
#define	ARG_SOCKINFO		0x0000001000000000ULL
#define	ARG_ASID		0x0000002000000000ULL
#define	ARG_TERMID		0x0000004000000000ULL
#define	ARG_AUDITON		0x0000008000000000ULL
#define	ARG_VALUE		0x0000010000000000ULL
#define	ARG_AMASK		0x0000020000000000ULL
#define	ARG_CTLNAME		0x0000040000000000ULL
#define	ARG_PROCESS		0x0000080000000000ULL
#define	ARG_MACHPORT1		0x0000100000000000ULL
#define	ARG_MACHPORT2		0x0000200000000000ULL
#define	ARG_EXIT		0x0000400000000000ULL
#define	ARG_IOVECSTR		0x0000800000000000ULL
#define	ARG_ARGV		0x0001000000000000ULL
#define	ARG_ENVV		0x0002000000000000ULL
#define	ARG_ATFD1		0x0004000000000000ULL
#define	ARG_ATFD2		0x0008000000000000ULL
#define	ARG_RIGHTS		0x0010000000000000ULL
#define	ARG_NONE		0x0000000000000000ULL
#define	ARG_ALL			0xFFFFFFFFFFFFFFFFULL

#define	ARG_IS_VALID(kar, arg)	((kar)->k_ar.ar_valid_arg & (arg))
#define	ARG_SET_VALID(kar, arg) do {					\
	(kar)->k_ar.ar_valid_arg |= (arg);				\
} while (0)
#define	ARG_CLEAR_VALID(kar, arg) do {					\
	(kar)->k_ar.ar_valid_arg &= ~(arg);				\
} while (0)

/*
 * In-kernel version of audit record; the basic record plus queue meta-data.
 * This record can also have a pointer set to some opaque data that will be
 * passed through to the audit writing mechanism.
 */
struct kaudit_record {
	struct audit_record		 k_ar;
	u_int32_t			 k_ar_commit;
	void				*k_udata;	/* User data. */
	u_int				 k_ulen;	/* User data length. */
	struct uthread			*k_uthread;	/* Audited thread. */
	TAILQ_ENTRY(kaudit_record)	 k_q;
};
TAILQ_HEAD(kaudit_queue, kaudit_record);

/*
 * Functions to manage the allocation, release, and commit of kernel audit
 * records.
 */
void			 audit_abort(struct kaudit_record *ar);
void			 audit_commit(struct kaudit_record *ar, int error,
			    int retval);
struct kaudit_record	*audit_new(int event, struct thread *td);

/*
 * Functions relating to the conversion of internal kernel audit records to
 * the BSM file format.
 */
struct au_record;
int	 kaudit_to_bsm(struct kaudit_record *kar, struct au_record **pau);
int	 bsm_rec_verify(void *rec);

/*
 * Kernel versions of the libbsm audit record functions.
 */
void	 kau_free(struct au_record *rec);
void	 kau_init(void);

/*
 * Return values for pre-selection and post-selection decisions.
 */
#define	AU_PRS_SUCCESS	1
#define	AU_PRS_FAILURE	2
#define	AU_PRS_BOTH	(AU_PRS_SUCCESS|AU_PRS_FAILURE)

/*
 * Data structures relating to the kernel audit queue.  Ideally, these might
 * be abstracted so that only accessor methods are exposed.
 */
extern struct mtx		audit_mtx;
extern struct cv		audit_watermark_cv;
extern struct cv		audit_worker_cv;
extern struct kaudit_queue	audit_q;
extern int			audit_q_len;
extern int			audit_pre_q_len;
extern int			audit_in_failure;

/*
 * Flags to use on audit files when opening and closing.
 */
#define	AUDIT_OPEN_FLAGS	(FWRITE | O_APPEND)
#define	AUDIT_CLOSE_FLAGS	(FWRITE | O_APPEND)

#include <sys/fcntl.h>
#include <sys/kernel.h>
#include <sys/malloc.h>

/*
 * Some of the BSM tokenizer functions take different parameters in the
 * kernel implementations in order to save the copying of large kernel data
 * structures.  The prototypes of these functions are declared here.
 */
token_t		*kau_to_socket(struct socket_au_info *soi);

/*
 * audit_klib prototypes
 */
int		 au_preselect(au_event_t event, au_class_t class,
		    au_mask_t *mask_p, int sorf);
void		 au_evclassmap_init(void);
void		 au_evclassmap_insert(au_event_t event, au_class_t class);
au_class_t	 au_event_class(au_event_t event);
au_event_t	 audit_ctlname_to_sysctlevent(int name[], uint64_t valid_arg);
au_event_t	 audit_flags_and_error_to_openevent(int oflags, int error);
au_event_t	 audit_flags_and_error_to_openatevent(int oflags, int error);
au_event_t	 audit_msgctl_to_event(int cmd);
au_event_t	 audit_semctl_to_event(int cmr);
void		 audit_canon_path(struct thread *td, char *path, char *cpath);
au_event_t	 auditon_command_event(int cmd);

/*
 * Audit trigger events notify user space of kernel audit conditions
 * asynchronously.
 */
void		 audit_trigger_init(void);
int		 audit_send_trigger(unsigned int trigger);

/*
 * Accessor functions to manage global audit state.
 */
void	 audit_set_kinfo(struct auditinfo_addr *);
void	 audit_get_kinfo(struct auditinfo_addr *);

/*
 * General audit related functions.
 */
struct kaudit_record	*currecord(void);
void			 audit_free(struct kaudit_record *ar);
void			 audit_shutdown(void *arg, int howto);
void			 audit_rotate_vnode(struct ucred *cred,
			    struct vnode *vp);
void			 audit_worker_init(void);

/*
 * Audit pipe functions.
 */
int	 audit_pipe_preselect(au_id_t auid, au_event_t event,
	    au_class_t class, int sorf, int trail_select);
void	 audit_pipe_submit(au_id_t auid, au_event_t event, au_class_t class,
	    int sorf, int trail_select, void *record, u_int record_len);
void	 audit_pipe_submit_user(void *record, u_int record_len);

#endif /* ! _SECURITY_AUDIT_PRIVATE_H_ */


code:
/*-
 * Copyright (c) 1999-2002 Robert N. M. Watson
 * Copyright (c) 2001-2004 Networks Associates Technology, Inc.
 * All rights reserved.
 *
 * This software was developed by Robert Watson for the TrustedBSD Project.
 *
 * This software was developed for the FreeBSD Project in part by Network
 * Associates Laboratories, the Security Research Division of Network
 * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"),
 * as part of the DARPA CHATS research program.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/security/mac_biba/mac_biba.h 132232 2004-07-16 02:03:50Z rwatson $
 */
/*
 * Definitions for the TrustedBSD Biba integrity policy module.
 */
#ifndef _SYS_SECURITY_MAC_BIBA_H
#define	_SYS_SECURITY_MAC_BIBA_H

#define	MAC_BIBA_EXTATTR_NAMESPACE	EXTATTR_NAMESPACE_SYSTEM
#define	MAC_BIBA_EXTATTR_NAME		"mac_biba"

#define	MAC_BIBA_LABEL_NAME		"biba"

#define	MAC_BIBA_FLAG_EFFECTIVE	0x00000001	/* mb_effective initialized */
#define	MAC_BIBA_FLAG_RANGE	0x00000002	/* mb_range* initialized */
#define	MAC_BIBA_FLAGS_BOTH	(MAC_BIBA_FLAG_EFFECTIVE | MAC_BIBA_FLAG_RANGE)

#define	MAC_BIBA_TYPE_UNDEF	0	/* Undefined */
#define	MAC_BIBA_TYPE_GRADE	1	/* Hierarchal grade with mb_grade. */
#define	MAC_BIBA_TYPE_LOW	2	/* Dominated by any
					 * MAC_BIBA_TYPE_LABEL. */
#define	MAC_BIBA_TYPE_HIGH	3	/* Dominates any
					 * MAC_BIBA_TYPE_LABEL. */
#define	MAC_BIBA_TYPE_EQUAL	4	/* Equivilent to any
					 * MAC_BIBA_TYPE_LABEL. */

/*
 * Structures and constants associated with a Biba Integrity policy.
 * mac_biba represents a Biba label, with mb_type determining its properties,
 * and mb_grade represents the hierarchal grade if valid for the current
 * mb_type.
 */

#define	MAC_BIBA_MAX_COMPARTMENTS	256

struct mac_biba_element {
	u_short	mbe_type;
	u_short	mbe_grade;
	u_char	mbe_compartments[MAC_BIBA_MAX_COMPARTMENTS >> 3];
};

/*
 * Biba labels consist of two components: an effective label, and a label
 * range.  Depending on the context, one or both may be used; the mb_flags
 * field permits the provider to indicate what fields are intended for
 * use.
 */
struct mac_biba {
	int			mb_flags;
	struct mac_biba_element	mb_effective;
	struct mac_biba_element	mb_rangelow, mb_rangehigh;
};

/*
 * Biba compartments bit test/set macros.
 * The range is 1 to MAC_BIBA_MAX_COMPARTMENTS.
 */
#define	MAC_BIBA_BIT_TEST(b, w) \
	((w)[(((b) - 1) >> 3)] & (1 << (((b) - 1) & 7)))
#define	MAC_BIBA_BIT_SET(b, w) \
	((w)[(((b) - 1) >> 3)] |= (1 << (((b) - 1) & 7)))
#define	MAC_BIBA_BIT_SET_EMPTY(set)	biba_bit_set_empty(set)

#endif /* !_SYS_SECURITY_MAC_BIBA_H */


code:
/*-
 * Copyright (c) 1999-2002 Robert N. M. Watson
 * Copyright (c) 2001-2004 Networks Associates Technology, Inc.
 * All rights reserved.
 *
 * This software was developed by Robert Watson for the TrustedBSD Project.
 *
 * This software was developed for the FreeBSD Project in part by Network
 * Associates Laboratories, the Security Research Division of Network
 * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"),
 * as part of the DARPA CHATS research program.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/security/mac_bsdextended/mac_bsdextended.h 171253 2007-07-05 13:16:04Z rwatson $
 */

#ifndef _SYS_SECURITY_MAC_BSDEXTENDED_H
#define	_SYS_SECURITY_MAC_BSDEXTENDED_H

#define MB_VERSION 2 /* Used to check library and kernel are the same. */

/*
 * Rights that can be represented in mbr_mode.  These have the same values as
 * the V* rights in vnode.h, but in order to avoid sharing user and kernel
 * constants, we define them here.  That will also improve ABI stability if
 * the in-kernel values change.
 */
#define	MBI_EXEC	000100
#define	MBI_WRITE	000200
#define	MBI_READ	000400
#define	MBI_ADMIN	010000
#define	MBI_STAT	020000
#define	MBI_APPEND	040000
#define	MBI_ALLPERM	(MBI_EXEC | MBI_WRITE | MBI_READ | MBI_ADMIN | \
			    MBI_STAT | MBI_APPEND)

#define	MBS_UID_DEFINED	0x00000001	/* uid field should be matched */
#define	MBS_GID_DEFINED	0x00000002	/* gid field should be matched */
#define	MBS_PRISON_DEFINED 0x00000004	/* prison field should be matched */

#define MBS_ALL_FLAGS (MBS_UID_DEFINED | MBS_GID_DEFINED | MBS_PRISON_DEFINED)

struct mac_bsdextended_subject {
	int	mbs_flags;
	int	mbs_neg;
	uid_t	mbs_uid_min;
	uid_t	mbs_uid_max;
	gid_t	mbs_gid_min;
	gid_t	mbs_gid_max;
	int	mbs_prison;
};

#define	MBO_UID_DEFINED	0x00000001	/* uid field should be matched */
#define	MBO_GID_DEFINED	0x00000002	/* gid field should be matched */
#define	MBO_FSID_DEFINED 0x00000004	/* fsid field should be matched */
#define	MBO_SUID	0x00000008	/* object must be suid */
#define	MBO_SGID	0x00000010	/* object must be sgid */
#define	MBO_UID_SUBJECT	0x00000020	/* uid must match subject */
#define	MBO_GID_SUBJECT	0x00000040	/* gid must match subject */
#define	MBO_TYPE_DEFINED 0x00000080	/* object type should be matched */

#define MBO_ALL_FLAGS (MBO_UID_DEFINED | MBO_GID_DEFINED | MBO_FSID_DEFINED | \
	    MBO_SUID | MBO_SGID | MBO_UID_SUBJECT | MBO_GID_SUBJECT | \
	    MBO_TYPE_DEFINED)

#define MBO_TYPE_REG	0x00000001
#define MBO_TYPE_DIR	0x00000002
#define MBO_TYPE_BLK	0x00000004
#define MBO_TYPE_CHR	0x00000008
#define MBO_TYPE_LNK	0x00000010
#define MBO_TYPE_SOCK	0x00000020
#define MBO_TYPE_FIFO	0x00000040

#define MBO_ALL_TYPE	(MBO_TYPE_REG | MBO_TYPE_DIR | MBO_TYPE_BLK | \
	    MBO_TYPE_CHR | MBO_TYPE_LNK | MBO_TYPE_SOCK | MBO_TYPE_FIFO)

struct mac_bsdextended_object {
	int	mbo_flags;
	int	mbo_neg;
	uid_t	mbo_uid_min;
	uid_t	mbo_uid_max;
	gid_t	mbo_gid_min;
	gid_t	mbo_gid_max;
	struct fsid mbo_fsid;
	int	mbo_type;
};

struct mac_bsdextended_rule {
	struct mac_bsdextended_subject	mbr_subject;
	struct mac_bsdextended_object	mbr_object;
	mode_t				mbr_mode;	/* maximum access */
};

#endif /* _SYS_SECURITY_MAC_BSDEXTENDED_H */


code:
/*-
 * Copyright (c) 2008 Robert N. M. Watson
 * All rights reserved.
 *
 * This software was developed by Robert Watson for the TrustedBSD Project.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/security/mac_bsdextended/ugidfw_internal.h 189533 2009-03-08 12:32:06Z rwatson $
 */

#ifndef _SYS_SECURITY_MAC_BSDEXTENDED_UGIDFW_INTERNAL_H
#define	_SYS_SECURITY_MAC_BSDEXTENDED_UGIDFW_INTERNAL_H

/*
 * Central access control routines used by object-specific checks.
 */
int	ugidfw_accmode2mbi(accmode_t accmode);
int	ugidfw_check(struct ucred *cred, struct vnode *vp, struct vattr *vap,
	    int acc_mode);
int	ugidfw_check_vp(struct ucred *cred, struct vnode *vp, int acc_mode);

/*
 * System access control checks.
 */
int	ugidfw_system_check_acct(struct ucred *cred, struct vnode *vp,
	    struct label *vplabel);
int	ugidfw_system_check_auditctl(struct ucred *cred, struct vnode *vp,
	    struct label *vplabel);
int	ugidfw_system_check_swapon(struct ucred *cred, struct vnode *vp,
	    struct label *vplabel);

/*
 * Vnode access control checks.
 */
int	ugidfw_vnode_check_access(struct ucred *cred, struct vnode *vp,
	    struct label *vplabel, accmode_t accmode);
int	ugidfw_vnode_check_chdir(struct ucred *cred, struct vnode *dvp,
	    struct label *dvplabel);
int	ugidfw_vnode_check_chroot(struct ucred *cred, struct vnode *dvp,
	    struct label *dvplabel);
int	ugidfw_check_create_vnode(struct ucred *cred, struct vnode *dvp,
	    struct label *dvplabel, struct componentname *cnp,
	    struct vattr *vap);
int	ugidfw_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp,
	    struct label *vplabel, acl_type_t type);
int	ugidfw_vnode_check_deleteextattr(struct ucred *cred,
	    struct vnode *vp, struct label *vplabel, int attrnamespace,
	    const char *name);
int	ugidfw_vnode_check_exec(struct ucred *cred, struct vnode *vp,
	    struct label *vplabel, struct image_params *imgp,
	    struct label *execlabel);
int	ugidfw_vnode_check_getacl(struct ucred *cred, struct vnode *vp,
	    struct label *vplabel, acl_type_t type);
int	ugidfw_vnode_check_getextattr(struct ucred *cred, struct vnode *vp,
	    struct label *vplabel, int attrnamespace, const char *name);
int	ugidfw_vnode_check_link(struct ucred *cred, struct vnode *dvp,
	    struct label *dvplabel, struct vnode *vp, struct label *label,
	    struct componentname *cnp);
int	ugidfw_vnode_check_listextattr(struct ucred *cred, struct vnode *vp,
	    struct label *vplabel, int attrnamespace);
int	ugidfw_vnode_check_lookup(struct ucred *cred, struct vnode *dvp,
	    struct label *dvplabel, struct componentname *cnp);
int	ugidfw_vnode_check_open(struct ucred *cred, struct vnode *vp,
	    struct label *vplabel, accmode_t accmode);
int	ugidfw_vnode_check_readdir(struct ucred *cred, struct vnode *dvp,
	    struct label *dvplabel);
int	ugidfw_vnode_check_readdlink(struct ucred *cred, struct vnode *vp,
	    struct label *vplabel);
int	ugidfw_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp,
	    struct label *dvplabel, struct vnode *vp, struct label *vplabel,
	    struct componentname *cnp);
int	ugidfw_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp,
	    struct label *dvplabel, struct vnode *vp, struct label *vplabel,
	    int samedir, struct componentname *cnp);
int	ugidfw_vnode_check_revoke(struct ucred *cred, struct vnode *vp,
	    struct label *vplabel);
int	ugidfw_check_setacl_vnode(struct ucred *cred, struct vnode *vp,
	    struct label *vplabel, acl_type_t type, struct acl *acl);
int	ugidfw_vnode_check_setextattr(struct ucred *cred, struct vnode *vp,
	    struct label *vplabel, int attrnamespace, const char *name);
int	ugidfw_vnode_check_setflags(struct ucred *cred, struct vnode *vp,
	    struct label *vplabel, u_long flags);
int	ugidfw_vnode_check_setmode(struct ucred *cred, struct vnode *vp,
	    struct label *vplabel, mode_t mode);
int	ugidfw_vnode_check_setowner(struct ucred *cred, struct vnode *vp,
	    struct label *vplabel, uid_t uid, gid_t gid);
int	ugidfw_vnode_check_setutimes(struct ucred *cred, struct vnode *vp,
	    struct label *vplabel, struct timespec atime,
	    struct timespec utime);
int	ugidfw_vnode_check_stat(struct ucred *active_cred,
	    struct ucred *file_cred, struct vnode *vp, struct label *vplabel);
int	ugidfw_vnode_check_unlink(struct ucred *cred, struct vnode *dvp,
	    struct label *dvplabel, struct vnode *vp, struct label *vplabel,
	    struct componentname *cnp);

#endif /* _SYS_SECURITY_MAC_BSDEXTENDED_UGIDFW_INTERNAL_H */


code:
/*-
 * Copyright (c) 1999-2002 Robert N. M. Watson
 * Copyright (c) 2001-2002 Networks Associates Technology, Inc.
 * All rights reserved.
 *
 * This software was developed by Robert Watson for the TrustedBSD Project.
 *
 * This software was developed for the FreeBSD Project in part by NAI Labs,
 * the Security Research Division of Network Associates, Inc. under
 * DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA
 * CHATS research program.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/security/mac_lomac/mac_lomac.h 140661 2005-01-23 14:26:09Z rwatson $
 */
/*
 * Definitions for the TrustedBSD LOMAC integrity policy module.
 */
#ifndef _SYS_SECURITY_MAC_LOMAC_H
#define	_SYS_SECURITY_MAC_LOMAC_H

#define	MAC_LOMAC_EXTATTR_NAMESPACE	EXTATTR_NAMESPACE_SYSTEM
#define	MAC_LOMAC_EXTATTR_NAME		"mac_lomac"

#define	MAC_LOMAC_LABEL_NAME		"lomac"

#define	MAC_LOMAC_FLAG_SINGLE	0x00000001	/* ml_single initialized */
#define	MAC_LOMAC_FLAG_RANGE	0x00000002	/* ml_range* initialized */
#define	MAC_LOMAC_FLAG_AUX	0x00000004	/* ml_auxsingle initialized */
#define	MAC_LOMAC_FLAGS_BOTH	(MAC_LOMAC_FLAG_SINGLE | MAC_LOMAC_FLAG_RANGE)
#define	MAC_LOMAC_FLAG_UPDATE	0x00000008	/* must demote this process */

#define	MAC_LOMAC_TYPE_UNDEF	0	/* Undefined */
#define	MAC_LOMAC_TYPE_GRADE	1	/* Hierarchal grade with mb_grade. */
#define	MAC_LOMAC_TYPE_LOW	2	/* Dominated by any
					 * MAC_LOMAC_TYPE_LABEL. */
#define	MAC_LOMAC_TYPE_HIGH	3	/* Dominates any
					 * MAC_LOMAC_TYPE_LABEL. */
#define	MAC_LOMAC_TYPE_EQUAL	4	/* Equivilent to any
					 * MAC_LOMAC_TYPE_LABEL. */

/*
 * Structures and constants associated with a LOMAC Integrity policy.
 * mac_lomac represents a LOMAC label, with mb_type determining its properties,
 * and mb_grade represents the hierarchal grade if valid for the current
 * mb_type.
 */

struct mac_lomac_element {
	u_short	mle_type;
	u_short	mle_grade;
};

/*
 * LOMAC labels start with two components: a single label, and a label
 * range.  Depending on the context, one or both may be used; the ml_flags
 * field permits the provider to indicate what fields are intended for
 * use.  The auxiliary label works the same way, but is only valid on
 * filesystem objects to provide inheritance semantics on directories
 * and "non-demoting" execution on executable files.
 */
struct mac_lomac {
	int				ml_flags;
	struct mac_lomac_element	ml_single;
	struct mac_lomac_element	ml_rangelow, ml_rangehigh;
	struct mac_lomac_element	ml_auxsingle;
};

#endif /* !_SYS_SECURITY_MAC_LOMAC_H */


code:
/*-
 * Copyright (c) 1999-2002 Robert N. M. Watson
 * Copyright (c) 2001-2004 Networks Associates Technology, Inc.
 * All rights reserved.
 *
 * This software was developed by Robert Watson for the TrustedBSD Project.
 *
 * This software was developed for the FreeBSD Project in part by Network
 * Associates Laboratories, the Security Research Division of Network
 * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"),
 * as part of the DARPA CHATS research program.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/security/mac_mls/mac_mls.h 132232 2004-07-16 02:03:50Z rwatson $
 */
/*
 * Definitions for the TrustedBSD MLS confidentiality policy module.
 */
#ifndef _SYS_SECURITY_MAC_MLS_H
#define	_SYS_SECURITY_MAC_MLS_H

#define	MAC_MLS_EXTATTR_NAMESPACE	EXTATTR_NAMESPACE_SYSTEM
#define	MAC_MLS_EXTATTR_NAME		"mac_mls"

#define	MAC_MLS_LABEL_NAME		"mls"

#define	MAC_MLS_FLAG_EFFECTIVE	0x00000001	/* mm_effective initialized */
#define	MAC_MLS_FLAG_RANGE	0x00000002	/* mm_range* initialized */
#define	MAC_MLS_FLAGS_BOTH	(MAC_MLS_FLAG_EFFECTIVE | MAC_MLS_FLAG_RANGE)

#define	MAC_MLS_TYPE_UNDEF	0	/* Undefined */
#define	MAC_MLS_TYPE_LEVEL	1	/* Hierarchal level with mm_level. */
#define	MAC_MLS_TYPE_LOW	2	/* Dominated by any
					 * MAC_MLS_TYPE_LABEL. */
#define	MAC_MLS_TYPE_HIGH	3	/* Dominates any
					 * MAC_MLS_TYPE_LABEL. */
#define	MAC_MLS_TYPE_EQUAL	4	/* Equivilent to any
					 * MAC_MLS_TYPE_LABEL. */

/*
 * Structures and constants associated with a Multi-Level Security policy.
 * mac_mls represents an MLS label, with mm_type determining its properties,
 * and mm_level represents the hierarchal sensitivity level if valid for the
 * current mm_type.  If compartments are used, the same semantics apply as
 * long as the suject is in every compartment the object is in.  LOW, EQUAL
 * and HIGH cannot be in compartments.
 */

/*
 * MLS compartments bit set size (in bits).
 */
#define	MAC_MLS_MAX_COMPARTMENTS	256

struct mac_mls_element {
	u_short	mme_type;
	u_short	mme_level;
	u_char	mme_compartments[MAC_MLS_MAX_COMPARTMENTS >> 3];
};

/*
 * MLS labels consist of two components: an effective label, and a label
 * range.  Depending on the context, one or both may be used; the mb_flags
 * field permits the provider to indicate what fields are intended for
 * use.
 */
struct mac_mls {
	int			mm_flags;
	struct mac_mls_element	mm_effective;
	struct mac_mls_element	mm_rangelow, mm_rangehigh;
};

/*
 * MLS compartments bit test/set macros.
 * The range is 1 to MAC_MLS_MAX_COMPARTMENTS.
 */
#define	MAC_MLS_BIT_TEST(b, w) \
	((w)[(((b) - 1) >> 3)] & (1 << (((b) - 1) & 7)))
#define	MAC_MLS_BIT_SET(b, w) \
	((w)[(((b) - 1) >> 3)] |= (1 << (((b) - 1) & 7)))
#define	MAC_MLS_BIT_SET_EMPTY(set)	mls_bit_set_empty(set)

#endif /* !_SYS_SECURITY_MAC_MLS_H */


code:
/*-
 * Copyright (c) 1999-2002 Robert N. M. Watson
 * Copyright (c) 2001-2002 Networks Associates Technology, Inc.
 * All rights reserved.
 *
 * This software was developed by Robert Watson for the TrustedBSD Project.
 *
 * This software was developed for the FreeBSD Project in part by Network
 * Associates Laboratories, the Security Research Division of Network
 * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"),
 * as part of the DARPA CHATS research program.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/security/mac_partition/mac_partition.h 126097 2004-02-22 00:33:12Z rwatson $
 */

/*
 * Definitions for the TrustedBSD partition policy module.
 */

#ifndef _SYS_SECURITY_MAC_PARTITION_H
#define	_SYS_SECURITY_MAC_PARTITION_H

#define	MAC_PARTITION_LABEL_NAME	"partition"

#endif /* !_SYS_SECURITY_MAC_PARTITION_H */