xref: /titanic_44/usr/src/head/sac.h (revision ba3594ba9b5dd4c846c472a8d657edcb7c8109ac)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*ba3594baSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24*ba3594baSGarrett D'Amore  *
257c478bd9Sstevel@tonic-gate  * Copyright (c) 1997-1998 by Sun Microsystems, Inc.
267c478bd9Sstevel@tonic-gate  * All rights reserved.
277c478bd9Sstevel@tonic-gate  */
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
307c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifndef _SAC_H
347c478bd9Sstevel@tonic-gate #define	_SAC_H
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #include <sys/types.h>
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
397c478bd9Sstevel@tonic-gate extern "C" {
407c478bd9Sstevel@tonic-gate #endif
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #define	IDLEN		4	/* length in bytes of a utmp id */
437c478bd9Sstevel@tonic-gate #define	SC_WILDC	0xff	/* wild character for utmp ids */
447c478bd9Sstevel@tonic-gate #define	PMTAGSIZE	14	/* maximum length in bytes for */
457c478bd9Sstevel@tonic-gate 				/* a port monitor tag */
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate /*
487c478bd9Sstevel@tonic-gate  * values for rflag in doconfig()
497c478bd9Sstevel@tonic-gate  */
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate #define	NOASSIGN	0x1	/* don't allow assign operations */
527c478bd9Sstevel@tonic-gate #define	NORUN		0x2	/* don't allow run or runwait operations */
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate /*
567c478bd9Sstevel@tonic-gate  * message to SAC (header only).  This header is forever fixed.  The
577c478bd9Sstevel@tonic-gate  * size field (pm_size) defines the size of the data portion of the
587c478bd9Sstevel@tonic-gate  * message, which follows the header.  The form of this optional
597c478bd9Sstevel@tonic-gate  * data portion is defined strictly by the message type (pm_type).
607c478bd9Sstevel@tonic-gate  */
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate struct	pmmsg {
637c478bd9Sstevel@tonic-gate 	char	pm_type;		/* type of message */
647c478bd9Sstevel@tonic-gate 	uchar_t	pm_state;		/* current state of port monitor */
657c478bd9Sstevel@tonic-gate 	char	pm_maxclass;		/* max message class this PM */
667c478bd9Sstevel@tonic-gate 					/* understands */
677c478bd9Sstevel@tonic-gate 	char	pm_tag[PMTAGSIZE + 1];	/* port monitor's tag */
687c478bd9Sstevel@tonic-gate 	int	pm_size;		/* size of optional data portion */
697c478bd9Sstevel@tonic-gate };
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate /*
747c478bd9Sstevel@tonic-gate  * pm_type values
757c478bd9Sstevel@tonic-gate  */
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate #define	PM_STATUS	1		/* status response */
787c478bd9Sstevel@tonic-gate #define	PM_UNKNOWN	2		/* an unknown message was received */
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate /*
817c478bd9Sstevel@tonic-gate  * pm_state values
827c478bd9Sstevel@tonic-gate  */
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate /*
857c478bd9Sstevel@tonic-gate  * Class 1 responses
867c478bd9Sstevel@tonic-gate  */
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate #define	PM_STARTING	1		/* port monitor in starting state */
897c478bd9Sstevel@tonic-gate #define	PM_ENABLED	2		/* port monitor in enabled state */
907c478bd9Sstevel@tonic-gate #define	PM_DISABLED	3		/* port monitor in disabled state */
917c478bd9Sstevel@tonic-gate #define	PM_STOPPING	4		/* port monitor in stopping state */
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate /*
947c478bd9Sstevel@tonic-gate  * message to port monitor
957c478bd9Sstevel@tonic-gate  */
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate struct	sacmsg {
987c478bd9Sstevel@tonic-gate 	int	sc_size;		/* size of optional data portion */
997c478bd9Sstevel@tonic-gate 	char	sc_type;		/* type of message */
1007c478bd9Sstevel@tonic-gate };
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate /*
1057c478bd9Sstevel@tonic-gate  * sc_type values
1067c478bd9Sstevel@tonic-gate  * These represent commands that the SAC sends to a port monitor.  These
1077c478bd9Sstevel@tonic-gate  * commands are divided into "classes" for extensibility.  Each subsequent
1087c478bd9Sstevel@tonic-gate  * "class" is a superset of the previous "classes" plus the new commands
1097c478bd9Sstevel@tonic-gate  * defined within that "class".  The header for all commands is identical;
1107c478bd9Sstevel@tonic-gate  * however, a command may be defined such that an optional data portion may
1117c478bd9Sstevel@tonic-gate  * be sent in addition to the header.  The format of this optional data piece
1127c478bd9Sstevel@tonic-gate  * is self-defining based on the command.  Important note:  the first message
1137c478bd9Sstevel@tonic-gate  * sent by the SAC will always be a class 1 message.  The port monitor
1147c478bd9Sstevel@tonic-gate  * response will indicate the maximum class that it is able to understand.
1157c478bd9Sstevel@tonic-gate  * Another note is that port monitors should only respond to a message with
1167c478bd9Sstevel@tonic-gate  * an equivalent class response (i.e. a class 1 command causes a class 1
1177c478bd9Sstevel@tonic-gate  * response).
1187c478bd9Sstevel@tonic-gate  */
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate /*
1217c478bd9Sstevel@tonic-gate  * Class 1 commands (currently, there are only class 1 commands)
1227c478bd9Sstevel@tonic-gate  */
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate #define	SC_STATUS	1		/* status request */
1257c478bd9Sstevel@tonic-gate #define	SC_ENABLE	2		/* enable request */
1267c478bd9Sstevel@tonic-gate #define	SC_DISABLE	3		/* disable request */
1277c478bd9Sstevel@tonic-gate #define	SC_READDB	4		/* read pmtab request */
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate /*
1307c478bd9Sstevel@tonic-gate  * `errno' values for Saferrno, note that Saferrno is used by
1317c478bd9Sstevel@tonic-gate  * both pmadm and sacadm and these values are shared between
1327c478bd9Sstevel@tonic-gate  * them
1337c478bd9Sstevel@tonic-gate  */
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate #define	E_BADARGS	1	/* bad args or ill-formed command line */
1367c478bd9Sstevel@tonic-gate #define	E_NOPRIV	2	/* user not privileged for operation */
1377c478bd9Sstevel@tonic-gate #define	E_SAFERR	3	/* generic SAF error */
1387c478bd9Sstevel@tonic-gate #define	E_SYSERR	4	/* system error */
1397c478bd9Sstevel@tonic-gate #define	E_NOEXIST	5	/* invalid specification */
1407c478bd9Sstevel@tonic-gate #define	E_DUP		6	/* entry already exists */
1417c478bd9Sstevel@tonic-gate #define	E_PMRUN	7	/* port monitor is running */
1427c478bd9Sstevel@tonic-gate #define	E_PMNOTRUN	8	/* port monitor is not running */
1437c478bd9Sstevel@tonic-gate #define	E_RECOVER	9	/* in recovery */
1447c478bd9Sstevel@tonic-gate #define	E_SACNOTRUN	10	/* sac daemon is not running */
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate extern int	doconfig(int, char *, long);
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1497c478bd9Sstevel@tonic-gate }
1507c478bd9Sstevel@tonic-gate #endif
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate #endif	/* _SAC_H */
153