xref: /onnv-gate/usr/src/cmd/svc/startd/protocol.h (revision 12967:ab9ae749152f)
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*12967Sgavin.maltby@oracle.com  * Common Development and Distribution License (the "License").
6*12967Sgavin.maltby@oracle.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*12967Sgavin.maltby@oracle.com  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate #ifndef	_PROTOCOL_H
260Sstevel@tonic-gate #define	_PROTOCOL_H
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #include <startd.h>
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #ifdef	__cplusplus
310Sstevel@tonic-gate extern "C" {
320Sstevel@tonic-gate #endif
330Sstevel@tonic-gate 
340Sstevel@tonic-gate typedef enum {
350Sstevel@tonic-gate 	GRAPH_UPDATE_RELOAD_GRAPH,
360Sstevel@tonic-gate 	GRAPH_UPDATE_ADD_INSTANCE,
370Sstevel@tonic-gate 	GRAPH_UPDATE_STATE_CHANGE
380Sstevel@tonic-gate } graph_event_type_t;
390Sstevel@tonic-gate 
400Sstevel@tonic-gate typedef struct protocol_states {
410Sstevel@tonic-gate 	restarter_instance_state_t	ps_state;
420Sstevel@tonic-gate 	restarter_instance_state_t	ps_state_next;
430Sstevel@tonic-gate 	restarter_error_t		ps_err;
44*12967Sgavin.maltby@oracle.com 	restarter_str_t			ps_reason;
450Sstevel@tonic-gate } protocol_states_t;
460Sstevel@tonic-gate 
470Sstevel@tonic-gate 
480Sstevel@tonic-gate typedef struct graph_protocol_event {
490Sstevel@tonic-gate 	char			*gpe_inst;
500Sstevel@tonic-gate 	size_t			gpe_inst_sz;
510Sstevel@tonic-gate 	graph_event_type_t	gpe_type;
520Sstevel@tonic-gate 	protocol_states_t	*gpe_data;
530Sstevel@tonic-gate 
540Sstevel@tonic-gate 	uu_list_node_t		gpe_link;
550Sstevel@tonic-gate 	pthread_mutex_t		gpe_lock;
560Sstevel@tonic-gate } graph_protocol_event_t;
570Sstevel@tonic-gate 
580Sstevel@tonic-gate typedef struct graph_update {
590Sstevel@tonic-gate 	pthread_mutex_t			gu_lock;
600Sstevel@tonic-gate 	pthread_cond_t			gu_cv;
610Sstevel@tonic-gate 	int				gu_wakeup;
620Sstevel@tonic-gate 
630Sstevel@tonic-gate 	pthread_mutex_t			gu_freeze_lock;
640Sstevel@tonic-gate 	pthread_cond_t			gu_freeze_cv;
650Sstevel@tonic-gate 	int				gu_freeze_wakeup;
660Sstevel@tonic-gate } graph_update_t;
670Sstevel@tonic-gate 
680Sstevel@tonic-gate typedef struct restarter_protocol_event {
690Sstevel@tonic-gate 	char			*rpe_inst;
700Sstevel@tonic-gate 	restarter_event_type_t	rpe_type;
71*12967Sgavin.maltby@oracle.com 	int32_t			rpe_reason;
720Sstevel@tonic-gate 
730Sstevel@tonic-gate 	uu_list_node_t		rpe_link;
740Sstevel@tonic-gate } restarter_protocol_event_t;
750Sstevel@tonic-gate 
760Sstevel@tonic-gate typedef struct restarter_update {
770Sstevel@tonic-gate 	pthread_mutex_t			restarter_update_lock;
780Sstevel@tonic-gate 	pthread_cond_t			restarter_update_cv;
790Sstevel@tonic-gate 	int				restarter_update_wakeup;
800Sstevel@tonic-gate } restarter_update_t;
810Sstevel@tonic-gate 
820Sstevel@tonic-gate extern restarter_update_t *ru;
830Sstevel@tonic-gate extern graph_update_t *gu;
840Sstevel@tonic-gate 
850Sstevel@tonic-gate void graph_protocol_init();
860Sstevel@tonic-gate void graph_protocol_send_event(const char *, graph_event_type_t,
870Sstevel@tonic-gate     protocol_states_t *);
880Sstevel@tonic-gate graph_protocol_event_t *graph_event_dequeue();
890Sstevel@tonic-gate void graph_event_requeue(graph_protocol_event_t *);
900Sstevel@tonic-gate void graph_event_release(graph_protocol_event_t *);
910Sstevel@tonic-gate 
920Sstevel@tonic-gate void restarter_protocol_init();
930Sstevel@tonic-gate evchan_t *restarter_protocol_init_delegate(char *);
940Sstevel@tonic-gate void restarter_protocol_send_event(const char *, evchan_t *,
95*12967Sgavin.maltby@oracle.com     restarter_event_type_t, int32_t);
960Sstevel@tonic-gate restarter_protocol_event_t *restarter_event_dequeue();
970Sstevel@tonic-gate void restarter_event_requeue(restarter_protocol_event_t *);
980Sstevel@tonic-gate void restarter_event_release(restarter_protocol_event_t *);
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate #ifdef	__cplusplus
1010Sstevel@tonic-gate }
1020Sstevel@tonic-gate #endif
1030Sstevel@tonic-gate 
1040Sstevel@tonic-gate #endif	/* _PROTOCOL_H */
105