xref: /titanic_52/usr/src/cmd/auditd/queue.h (revision 88447a05f537aabe9a1bc3d5313f22581ec992a7)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  *
26  */
27 
28 #ifndef	_QUEUE_H
29 #define	_QUEUE_H
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #include <pthread.h>
38 #include <stddef.h>
39 
40 typedef struct aln audit_link_t;
41 struct aln {
42 	audit_link_t	*aln_next;
43 };
44 
45 /* one audit_rec_t per audit record */
46 
47 typedef struct abq audit_rec_t;
48 struct abq {
49 	audit_link_t	abq_l;
50 	int		abq_ref_count;
51 	size_t		abq_buf_len;	/* space allocated */
52 	size_t		abq_data_len;	/* space used	   */
53 	char		abq_buffer[1];	/* variable length */
54 };
55 #define	AUDIT_REC_HEADER  offsetof(audit_rec_t, abq_buffer[0])
56 
57 /* one audit_q_t entry per audit record per plugin */
58 
59 typedef struct aqq audit_q_t;		/* plugin queued data */
60 struct aqq {
61 	audit_link_t	aqq_l;
62 	audit_rec_t	*aqq_data;
63 	int		aqq_sequence;
64 };
65 
66 /* queue head */
67 
68 typedef struct auq au_queue_t;
69 
70 struct auq {
71 	void		*auq_head;
72 	void		*auq_tail;
73 	int		auq_count;
74 	pthread_mutex_t	auq_lock;
75 };
76 
77 int		audit_dequeue(au_queue_t *, void **);
78 void		audit_queue_destroy(au_queue_t *);
79 void		audit_enqueue(au_queue_t *, void *);
80 int		audit_queue_size(au_queue_t *);
81 void		audit_queue_init(au_queue_t *);
82 audit_rec_t	*audit_release(pthread_mutex_t *, audit_rec_t *);
83 void		audit_incr_ref(pthread_mutex_t *, audit_rec_t *);
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 
89 #endif	/* _QUEUE_H */
90