xref: /illumos-gate/usr/src/cmd/isns/isnsd/isns_msgq.h (revision 5422785d352a2bb398daceab3d1898a8aa64d006)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _ISNS_MSGQ_H
28 #define	_ISNS_MSGQ_H
29 
30 #include <pthread.h>
31 #include <synch.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #define	TEST_CLI_STOPPED	(0x0001)
38 #define	DD_SERVICE_STOPPED	(0x0002)
39 #define	SCN_STOPPED		(0x0004)
40 #define	ESI_STOPPED		(0x0008)
41 
42 typedef enum msg_id {
43 	DATA_ADD = 1,
44 	DATA_UPDATE,
45 	DATA_DELETE,
46 	DATA_DELETE_ASSOC,
47 	DATA_COMMIT,
48 	DATA_RETREAT,
49 	REG_EXP,
50 	DEAD_PORTAL,
51 	SYS_QUIT_OK,
52 	SCN_ADD = 100,
53 	SCN_REMOVE,
54 	SCN_REMOVE_P,
55 	SCN_SET,
56 	SCN_TRIGGER,
57 	SCN_IGNORE,
58 	SCN_STOP,
59 	SERVER_EXIT,
60 	CONFIG_RELOAD
61 } msg_id_t;
62 
63 typedef struct msg_text {
64 	struct msg_text	*prev;
65 	struct msg_text	*next;
66 	msg_id_t	 id;
67 	void		*data;
68 } msg_text_t;
69 
70 typedef struct msg_queue {
71 	msg_text_t	*q_head;
72 	msg_text_t	*q_tail;
73 	pthread_mutex_t	 q_mutex;
74 	sema_t		 q_sema;
75 } msg_queue_t;
76 
77 /* function prototypes */
78 msg_queue_t *queue_calloc();
79 int queue_msg_set(msg_queue_t *, msg_id_t, void *);
80 msg_text_t *queue_msg_get(msg_queue_t *);
81 void queue_msg_free(msg_text_t *);
82 
83 #ifdef __cplusplus
84 }
85 #endif
86 
87 #endif /* _ISNS_MSGQ_H */
88