xref: /onnv-gate/usr/src/cmd/auditd/queue.h (revision 11704:9a0a28a63bb4)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*11704SJan.Friedel@Sun.COM  * Common Development and Distribution License (the "License").
6*11704SJan.Friedel@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*11704SJan.Friedel@Sun.COM  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  *
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef	_QUEUE_H
280Sstevel@tonic-gate #define	_QUEUE_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #ifdef __cplusplus
310Sstevel@tonic-gate extern "C" {
320Sstevel@tonic-gate #endif
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #include <pthread.h>
350Sstevel@tonic-gate #include <stddef.h>
360Sstevel@tonic-gate 
370Sstevel@tonic-gate typedef struct aln audit_link_t;
380Sstevel@tonic-gate struct aln {
390Sstevel@tonic-gate 	audit_link_t	*aln_next;
400Sstevel@tonic-gate };
410Sstevel@tonic-gate 
420Sstevel@tonic-gate /* one audit_rec_t per audit record */
430Sstevel@tonic-gate 
440Sstevel@tonic-gate typedef struct abq audit_rec_t;
450Sstevel@tonic-gate struct abq {
460Sstevel@tonic-gate 	audit_link_t	abq_l;
470Sstevel@tonic-gate 	int		abq_ref_count;
480Sstevel@tonic-gate 	size_t		abq_buf_len;	/* space allocated */
490Sstevel@tonic-gate 	size_t		abq_data_len;	/* space used	   */
500Sstevel@tonic-gate 	char		abq_buffer[1];	/* variable length */
510Sstevel@tonic-gate };
520Sstevel@tonic-gate #define	AUDIT_REC_HEADER  offsetof(audit_rec_t, abq_buffer[0])
530Sstevel@tonic-gate 
540Sstevel@tonic-gate /* one audit_q_t entry per audit record per plugin */
550Sstevel@tonic-gate 
560Sstevel@tonic-gate typedef struct aqq audit_q_t;		/* plugin queued data */
570Sstevel@tonic-gate struct aqq {
580Sstevel@tonic-gate 	audit_link_t	aqq_l;
590Sstevel@tonic-gate 	audit_rec_t	*aqq_data;
60*11704SJan.Friedel@Sun.COM 	uint64_t	aqq_sequence;
610Sstevel@tonic-gate };
620Sstevel@tonic-gate 
630Sstevel@tonic-gate /* queue head */
640Sstevel@tonic-gate 
650Sstevel@tonic-gate typedef struct auq au_queue_t;
660Sstevel@tonic-gate 
670Sstevel@tonic-gate struct auq {
680Sstevel@tonic-gate 	void		*auq_head;
690Sstevel@tonic-gate 	void		*auq_tail;
700Sstevel@tonic-gate 	int		auq_count;
710Sstevel@tonic-gate 	pthread_mutex_t	auq_lock;
720Sstevel@tonic-gate };
730Sstevel@tonic-gate 
740Sstevel@tonic-gate int		audit_dequeue(au_queue_t *, void **);
750Sstevel@tonic-gate void		audit_queue_destroy(au_queue_t *);
760Sstevel@tonic-gate void		audit_enqueue(au_queue_t *, void *);
770Sstevel@tonic-gate int		audit_queue_size(au_queue_t *);
780Sstevel@tonic-gate void		audit_queue_init(au_queue_t *);
790Sstevel@tonic-gate audit_rec_t	*audit_release(pthread_mutex_t *, audit_rec_t *);
800Sstevel@tonic-gate void		audit_incr_ref(pthread_mutex_t *, audit_rec_t *);
810Sstevel@tonic-gate 
820Sstevel@tonic-gate #ifdef __cplusplus
830Sstevel@tonic-gate }
840Sstevel@tonic-gate #endif
850Sstevel@tonic-gate 
860Sstevel@tonic-gate #endif	/* _QUEUE_H */
87