[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 2

srcstat_r Subroutine

Purpose

Gets short status on a subsystem.

Library

System Resource Controller Library (libsrc.a)

Syntax

#include <spc.h>

int srcstat_r(Host, SubsystemName, SubsystemPID, ReplyLength, StatusReply, Continued, SRCHandle)
char *Host, *SubsystemName;
pid_t SubsystemPID;
int *Continued;
short *ReplyLength;
struct statrep *StatusReply;
char **SRCHandle;

Description

The srcstat_r subroutine sends a short status request to the System Resource Controller (SRC) and returns status for one or more subsystems to the caller. This subroutine is threadsafe and reentrant.

Parameters

Host Specifies the foreign host on which this status action is requested. If the host is null, the status request is sent to the SRC on the local host.
SubsystemName Specifies the name of the subsystem on which to get short status. To get status of all subsystems, use the SRCALLSUBSYS constant. To get status of a group of subsystems, the SubsystemName parameter must start with the SRCGROUP constant, followed by the name of the group for which you want status appended. If you specify a null SubsystemName parameter, you must specify a SubsystemPID parameter.
SubsystemPID Specifies the PID of the subsystem on which to get status as returned by the srcstat_r subroutine. You must specify the SubsystemPID parameter if multiple instances of the subsystem are active and you request a long subsystem status or subserver status. If you specify a null SubsystemPID parameter, you must specify a SubsystemName parameter.
ReplyLength Specifies size of a srchdr structure plus the number of statcode structures times the size of one statcode structure. On return from the srcstat_r subroutine, this value is updated.
StatusReply Specifies a pointer to a statrep code structure containing a statcode array that receives the status reply for the requested subsystem. The first element of the returned statcode array contains the status title line. The statcode structure is defined in the spc.h file.
Continued Specifies whether this call to the srcstat_r subroutine is a continuation of a previous status request. If the Continued parameter is set to NEWREQUEST, a request for short subsystem status is sent to the SRC and srcstat_r waits for the first status response. During NEWREQUEST processing, the srcstat_r subroutine opens a socket, mallocs internal buffers, and saves a value in SRCHandle. In normal circumstances, the calling process should never set Continued to a value other than NEWREQUEST. When the srcstat_r subroutine returns with Continued=STATCONTINUED, call srcstat_r without changing the Continued and SRCHandle parameters to receive additional data. The last response from the SRC sets Continued to END. The caller must continue to call srcstat_r until END is received. Otherwise, the socket will not be closed and the internal buffers freed. As an alternative, call srcstat_r with Continued=STATCONTINUED to discard the remaining data, close the socket, and free the internal buffers.
SRCHandle Identifies a request and its associated responses. Set to NULL by the caller for a NEWREQUEST. The srcstat_r subroutine saves a value in SRCHandle to allow subsequent srcstat_r calls to use the same socket and internal buffers. The SRCHandle parameter should not be changed by the caller except for NEWREQUESTs.

Return Values

If the srcstat_r subroutine succeeds, it returns a value of 0. An error code is returned if the subroutine is unsuccessful.

Error Codes

The srcstat_r subroutine fails and returns the corresponding error code if one of the following error conditions is detected:

SRC_DMNA The SRC daemon is not active.
SRC_INET_AUTHORIZED_HOST The local host is not in the remote /etc/hosts.equiv file.
SRC_INET_INVALID_HOST On the remote host, the local host is not known.
SRC_INVALID_USER The user is not root or group system.
SRC_MMRY An SRC component could not allocate the memory it needs.
SRC_NOCONTINUE Continued was not set to NEWREQUEST and no continuation is currently active.
SRC_NORPLY The request timed out waiting for a response.
SRC_SOCK There is a problem with SRC socket communications.
SRC_UDP The SRC port is not defined in the /etc/services file.
SRC_UHOST The foreign host is not known.

Examples

  1. To request the status of a subsystem, enter:
    int cont=NEWREQUEST;
    struct statcode statcode[20];
    short replen=sizeof(statcode);
    char *handle;
     
    srcstat_r("MaryC","srctest",0,&replen,statcode, &cont, &handle);

    This entry requests short status of all instances of the subsystem srctest on the MaryC machine.

  2. To request the status of all subsystems, enter:
    int cont=NEWREQUEST;
    struct statcode statcode[20];
    short replen=sizeof(statcode);
    char *handle; 
     
    srcstat_r("",SRCALLSUBSYS,0,&replen,statcode, &cont, &handle);

    This entry requests short status of all subsystems on the local machine.

  3. To request the status for a group of subsystems, enter:
    int cont=NEWREQUEST;
    struct statcode statcode[20];
    short replen=sizeof(statcode);
    char subsysname[30];
    char *handle; 
    
    strcpy(subsysname,SRCGROUP);
    strcat(subsysname,"tcpip");
    srcstat_r("",subsysname,0,&replen,statcode, &cont, &handle);

    This entry requests short status of all members of the subsystem group tcpip on the local machine.

Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Files

/etc/services Defines the sockets and protocols used for Internet services.
/dev/SRC Specifies the AF_UNIX socket file.
/dev/.SRC-unix Specifies the location for temporary socket files.

Related Information

The src_err_msg_r, srcsbuf_r, srcsrqt_r, srcrrqs_r, and srcstattxt_r subroutines.

List of SRC Subroutines in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.

Programming Subsystem Communication with the SRC in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.

System Resource Controller (SRC) Overview for Programmers in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.


[ Previous | Next | Contents | Glossary | Home | Search ]