Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
F.  Writing a Port Monitor With the Service Access Facility (SAF) Sample Port Monitor Code   Previous   Contents   Next 
   
 

The following code example shows the sac.h header file.


Example F-2 sac.h Header File

/* length in bytes of a utmpx id */
# define IDLEN 4
/* wild character for utmpx ids */
# define SC_WILDC 0xff
/* max len in bytes for port monitor tag */
# define PMTAGSIZE 14
/*
 * values for rflag in doconfig()
 */
/* don't allow assign operations */
# define NOASSIGN 0x1
/* don't allow run or runwait operations */
# define NORUN 0x2
/*
 * message to SAC (header only). This header is forever fixed. The
 * size field (pm_size) defines the size of the data portion of
the
 * message, which follows the header. The form of this optional
data
 * portion is defined strictly by the message type (pm_type).
 */
struct pmmsg {
	char pm_type;               /* type of message */
	unchar pm_state;            /* current state of pm */
	char pm_maxclass;           /* max message class this port
monitor
					                understands */
	char pm_tag[PMTAGSIZE + 1]; /* pm's tag */
	int pm_size;                /* size of opt data portion */
};
/*
 * pm_type values
 */
# define PM_STATUS 1 /* status response */
# define PM_UNKNOWN 2 /* unknown message was received */
/*
 * pm_state values
 */
/*
 * Class 1 responses
 */
# define PM_STARTING 1   /* monitor in starting state */
# define PM_ENABLED 2    /* monitor in enabled state */
# define PM_DISABLED 3   /* monitor in disabled state */
# define PM_STOPPING 4   /* monitor in stopping state */
/*
 * message to port monitor
 */
struct sacmsg {
	int sc_size;         /* size of optional data portion */
	char sc_type;        /* type of message */
};
/*
 * sc_type values
 * These represent commands that the SAC sends to a port monitor.
 * These commands are divided into "classes" for extensibility.
Each
 * subsequent "class" is a superset of the previous "classes" plus
 * the new commands defined within that "class". The header for
all
 * commands is identical; however, a command may be defined such
that
 * an optional data portion may be sent in addition to the header.
 * The format of this optional data piece is self-defining based
on
 * the command. Important note:the first message sent by the SAC
is 
 * always be a class 1 message. The port monitor response
indicates
 * the maximum class that it is able to understand. Another note
is
 * that port monitors should only respond to a message with an
 * equivalent class response (i.e. a class 1 command causes a
class 1
 * response).
 */
/*
 * Class 1 commands (currently, there are only class 1 commands)
 */
# define SC_STATUS 1    /* status request *
# define SC_ENABLE 2    /* enable request */
# define SC_DISABLE 3   /* disable request */
# define SC_READDB 4    /* read pmtab request */
/*
 * `errno' values for Saferrno, note that Saferrno is used by both
 * pmadm and sacadm and these values are shared between them
 */
# define E_BADARGS 1   /* bad args/ill-formed cmd line */
# define E_NOPRIV 2    /* user not priv for operation */
# define E_SAFERR 3    /* generic SAF error */
# define E_SYSERR 4    /* system error */
# define E_NOEXIST 5   /* invalid specification */
# define E_DUP 6       /* entry already exists */
# define E_PMRUN 7     /* port monitor is running */
# define E_PMNOTRUN 8  /* port monitor is not running */
# define E_RECOVER 9   /* in recovery */

Logic Diagram and Directory Structure

Figure F-1 is a logical diagram of the SAF. It illustrates how a single service access controller can spawn a number of port monitors on a per-system basis. This technique means that several monitors can run concurrently, providing for the simultaneous operation of several different protocols.

Figure F-1 SAF Logical Framework

The following figure shows is the corresponding directory structure diagram. Following the diagram is a description of the files and directories.

Figure F-2 SAF Directory Structure

The scripts and files in the SAF directory structure are:

  • /etc/saf/_sysconfig The per-system configuration script.

  • /etc/saf/_sactab The SAC's administrative file. Contains information about the port monitors for which the SAC is responsible.

  • /etc/saf/pmtag The home directory for port monitor pmtag.

  • /etc/saf/pmtag/_config The per-port monitor configuration script for port monitor pmtag.

  • /etc/saf/pmtag/_pmtab Port monitor pmtag's administrative file. Contains information about the services for which pmtag is responsible.

  • /etc/saf/pmtag/svctag The file in which the per-service configuration script for service svctag, available through port monitor pmtag, is placed.

  • /etc/saf/pmtag/_pid The file in which a port monitor writes its process ID in the current directory and places an advisory lock on the file.

  • /etc/saf/pmtag/_pmpipe The file in which the port monitor receives messages from the SAC and ../_sacpipe and sends return messages to the SAC.

  • /var/saf/_log The SAC's log file.

  • /var/saf/pmtag The directory for files created by port monitor pmtag, for example its log file.

 
 
 
  Previous   Contents   Next